ReceiptController.php 529 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class ReceiptController extends DooController {
  6. public $staff;
  7. public $verifyId;
  8. public $executeId;
  9. // public static $NEW2 = 0;
  10. public $AGENCY = "日常相关费用";
  11. public $TRAVEL = "差旅相关费用";
  12. public $TRAIN = "培训班费用";
  13. public $OTHER = "其他";
  14. public $INTTRAIN='内部培训费用';
  15. private $MYREVEIPTCACHEPATH = "protected/cache/myReceipt/";
  16. private $PERSONALCOLLECTCACHEPATH = "protected/cache/personalCollect/";
  17. private $CATEGORYCOLLECTPATH = "protected/cache/categoryCollect/";
  18. private $STAFFCOLLECTPATH = "protected/cache/staffCollect/";
  19. private function showCache($path) {
  20. if (file_exists ( $path )) {
  21. echo "<!DOCTYPE html>";
  22. include $path;
  23. die ();
  24. }
  25. }
  26. private function cacheFile($path) {
  27. $content = ob_get_contents ();
  28. $fp = fopen ( $path, "w" );
  29. fwrite ( $fp, $content );
  30. fclose ( $fp );
  31. }
  32. private function collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {
  33. $collectHtml = "";
  34. $sumPrice = 0.00;
  35. for($i = 1; $i <= 12; $i ++) {
  36. $falg = true;
  37. foreach ( $receiptCollectList as $key => $value ) {
  38. if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {
  39. $sumPrice += $value ['price'];
  40. if ($classType == "b") {
  41. $collectHtml .= '<td class="colGreen taR">¥' . $value ['price'] . '</td>';
  42. $falg = false;
  43. break;
  44. } else {
  45. $collectHtml .= '<td class="taR">¥' . $value ['price'] . '</td>';
  46. $falg = false;
  47. break;
  48. }
  49. }
  50. }
  51. if ($falg)
  52. $collectHtml .= '<td class="taR">-</td>';
  53. }
  54. $collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';
  55. return $collectHtml;
  56. }
  57. public function beforeRun($resource, $action) {
  58. Doo::loadClass ( 'XDeode' );
  59. $XDeode = new XDeode ( 5 );
  60. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  61. // 单独判断公司汇总的访问权限
  62. if ($action == 'companyCategoryCollect') {
  63. Doo::loadModel ( "receiptAuthorityManage" );
  64. $invoiceCompanyManage = new receiptAuthorityManage ();
  65. $icm = $invoiceCompanyManage->getInvoiceCMByStaff ( $sid );
  66. if (empty ( $icm ))
  67. die ( 'illegal request' );
  68. }
  69. Doo::loadModel ( 'staff' );
  70. $staff = new staff ();
  71. $detail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  72. $accessModular = 'RECEIPTS';
  73. if (empty ( $detail ['cldAccessArray'] ))
  74. die ( 'illegal request' );
  75. else {
  76. if (in_array ( $accessModular, $detail ['cldAccessArray'] )) {
  77. if (Doo::acl ()->isAllowed ( $accessModular, $resource, $action )) {
  78. $flag = true;
  79. } else {
  80. $flag = false;
  81. }
  82. } else {
  83. die ( 'illegal request' );
  84. }
  85. }
  86. if (! $flag)
  87. die ( 'illegal request' );
  88. }
  89. function __construct() {
  90. if (isset ( $_COOKIE ["staff"] )) {
  91. if (! empty ( $_COOKIE ["staff"] )) {
  92. Doo::loadModel ( 'staff' );
  93. Doo::loadModel ( 'verify' );
  94. $verify = new verify ();
  95. $staff = new staff ();
  96. Doo::loadModel ( "execute" );
  97. $execute = new execute ();
  98. $verifyList = $verify->find ( array (
  99. 'select' => 'staff',
  100. 'asArray' => true
  101. ) );
  102. $list = array ();
  103. // 判断角色的审批权限
  104. foreach ( $verifyList as $key => $value ) {
  105. $ver = json_decode ( $value ['staff'] );
  106. foreach ( $ver as $k => $v ) {
  107. if ($v [1] == 'ROLE') {
  108. $roleList = json_decode ( $v [3] );
  109. foreach ( $roleList as $t => $g ) {
  110. $gList = explode ( "_", $g );
  111. array_push ( $list, $gList [0] );
  112. // print_r($list);
  113. }
  114. } else
  115. array_push ( $list, $v [0] );
  116. }
  117. }
  118. // 判断执行人的审批权限
  119. $executeList = $execute->find ( array (
  120. 'where'=>'mold !="日常收支"',
  121. 'select' => 'staff',
  122. 'asArray' => true
  123. ) );
  124. $list2 = array ();
  125. foreach ( $executeList as $key => $value ) {
  126. $ver = json_decode ( $value ['staff'] );
  127. foreach ( $ver as $k => $v ) {
  128. array_push ( $list2, $v [0] );
  129. }
  130. }
  131. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  132. $eidList = array_filter ( explode ( ",", $eidList ) );
  133. $this->executeId = array_merge ( $list2, $eidList );
  134. $this->verifyId = $list;
  135. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  136. // 检测用户信息完成
  137. $this->data ['isStaffCompleteMsg'] = false;
  138. $detail = $staff->checkStaffInfoIsComplete ( $_COOKIE ["staff"] );
  139. if (! empty ( $detail ))
  140. $this->data ['isStaffCompleteMsg'] = true;
  141. return "/";
  142. }
  143. }
  144. Doo::loadCore ( 'uri/DooUriRouter' );
  145. $router = new DooUriRouter ();
  146. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  147. if ($routeRs ['1'] != "login") {
  148. header ( 'Content-Type:text/html;charset=utf-8' );
  149. @header ( "Location: /login" );
  150. }
  151. }
  152. function saeaBorad() {
  153. Doo::loadModel ( 'receipt' );
  154. $receipt = new receipt ();
  155. Doo::loadModel ( 'verify' );
  156. $verify = new verify ();
  157. Doo::loadModel ( 'L_category' );
  158. $lCategory = new L_category ();
  159. Doo::loadModel ( "role" );
  160. $role = new role ();
  161. Doo::loadModel ( "receiptLog" );
  162. $receiptLog = new receiptLog ();
  163. Doo::loadClass ( 'XDeode' );
  164. $XDeode = new XDeode ( 7 );
  165. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  166. $receiptDetail = $receipt->find ( array (
  167. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  168. 'desc' => 'rid',
  169. 'asArray' => true
  170. ) );
  171. foreach ( $receiptDetail as $key => $value ) {
  172. $receiptDetail [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  173. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  174. $veList = $verify->getOne ( array (
  175. 'where' => 'vid=' . $value ['verify'],
  176. 'asArray' => true
  177. ) );
  178. $v = json_decode ( $veList ['staff'] );
  179. array_push ( $v [0], $veList ['description'] );
  180. foreach ( $v as $n => $m ) {
  181. if ($m ['1'] == 'ROLE') {
  182. $roleInfo = $role->getOne ( array (
  183. 'where' => 'rid=' . $m [0],
  184. 'asArray' => true
  185. ) );
  186. $v [$n] [1] = $roleInfo ['name'];
  187. }
  188. }
  189. $receiptDetail [$key] ['staff'] = $v;
  190. $category = $lCategory->getOne ( array (
  191. 'where' => 'cid=' . $value ['cid'],
  192. 'asArray' => true
  193. ) );
  194. $receiptDetail [$key] ['category'] = $category ['title'];
  195. }
  196. // print_r($receiptLogList);
  197. Doo::loadModel ( 'RAssist' );
  198. $RAssist = new RAssist ();
  199. $receiptExtendList=$RAssist->getRAssistBySid($this->staff[0]['sid']);
  200. $data ['receiptExtendList'] = $receiptExtendList;
  201. $data ['receiptLogList'] = $receiptLogList;
  202. $data ['receiptDetail'] = $receiptDetail;
  203. $data ['memu'] = "receipt";
  204. $data ['staff'] = $this->staff;
  205. $data ['receiptMemu'] = 'saeaBorad';
  206. $data ['verifyId'] = $this->verifyId;
  207. $data ['executeId'] = $this->executeId;
  208. $this->render ( "/admin/saeaBorad", $data );
  209. }
  210. function remitAdd() {
  211. Doo::loadModel ( 'accountItem' );
  212. Doo::loadModel ( 'verify' );
  213. Doo::loadModel ( 'receipt' );
  214. Doo::loadModel ( 'L_category' );
  215. $lCategory = new L_category ();
  216. $receipt = new receipt ();
  217. $verify = new verify ();
  218. $accountItem = new accountItem ();
  219. Doo::loadModel ( "role" );
  220. $role = new role ();
  221. $acItem = $accountItem->find ( array (
  222. 'asArray' => true
  223. ) );
  224. $veList = $verify->getVerifyBySubordinate('REMIT');
  225. $data ['category'] = $lCategory->find ( array (
  226. 'asArray' => true
  227. ) );
  228. $data ['veList'] = $veList;
  229. $data ['acItem'] = $acItem;
  230. $data ['memu'] = "receipt";
  231. $data ['staff'] = $this->staff;
  232. $data ['receiptMemu'] = 'saeaBorad';
  233. $data ['verifyId'] = $this->verifyId;
  234. $data ['executeId'] = $this->executeId;
  235. $this->render ( "/admin/remitAdd", $data );
  236. }
  237. function remitAddDo() {
  238. $agency = $this->get_args ( 'agency' );
  239. $travel = $this->get_args ( 'travel' );
  240. $train = $this->get_args ( 'train' );
  241. $other = $this->get_args ( 'other' );
  242. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  243. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  244. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  245. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  246. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  247. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  248. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  249. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  250. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  251. // print_r($agency);die;
  252. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  253. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  254. header ( 'Content-Type:text/html;charset=utf-8' );
  255. die ( '请填写联行号' );
  256. }
  257. Doo::loadModel ( 'receipt' );
  258. Doo::loadModel ( 'receiptDetail' );
  259. Doo::loadModel ( 'accountItem' );
  260. $accountItem = new accountItem ();
  261. $receipt = new receipt ();
  262. Doo::loadModel ( 'enclosur' );
  263. Doo::loadModel ( 'execute' );
  264. $execute = new execute ();
  265. $executeDetail = $execute->getOne ( array (
  266. 'where' => 'mold="对公汇款执行人"',
  267. 'asArray' => true
  268. ) );
  269. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  270. $aItem = $accountItem->find ( array (
  271. 'where' => 'name like "办公费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保"',
  272. 'asArray' => true
  273. ) );
  274. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  275. $ag = $tr = $ta = $ot = 0;
  276. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  277. foreach ( $aItem as $key => $value ) {
  278. if ($value ['category'] == $this->AGENCY) {
  279. if (isset ( $agency [$ag] )) {
  280. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  281. array_push ( $accountJson [$this->AGENCY], array (
  282. 'aid' => $value ['aid'],
  283. 'name' => $value ['name'],
  284. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  285. ) );
  286. $sum += $agency [$ag];
  287. $agencySum += $agency [$ag];
  288. }
  289. }
  290. $ag ++;
  291. }
  292. }
  293. $accountJson ['cSum'] = array (
  294. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  295. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  296. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  297. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  298. );
  299. // 报销单
  300. $receipt->accountItem = json_encode ( $accountJson );
  301. $receipt->staff = $this->staff [0] ['sid'];
  302. $receipt->sum = number_format ( $sum, 2, '.', '' );
  303. $receipt->date = date ( "Y-m-d" );
  304. $receipt->cid = $cid;
  305. $receipt->status = 5;
  306. $receipt->Rtype = 2;
  307. // 修改审批流程加入角色
  308. $receipt->verify = $verify;
  309. $receipt->executeCopy = $executeDetail ['staff'];
  310. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  311. $order = array (
  312. "\r\n",
  313. "\n",
  314. "\r"
  315. );
  316. $replace = '<br/>';
  317. $explanation = str_replace ( $order, $replace, $explanation );
  318. $receipt->explanation = $explanation;
  319. $receipt->remittanceName = $remittanceName;
  320. $receipt->bankName = $bankName;
  321. $receipt->bankNumber = $bankNumber;
  322. $receipt->remittanceBankType = $remittanceBankType;
  323. if ($remittanceBankType == 1)
  324. $receipt->coupletNumber = $coupletNumber;
  325. $rid = $receipt->insert ();
  326. // 附件
  327. if (! empty ( $enclosurName )) {
  328. $enclosurArray = explode ( '-', $enclosurName );
  329. foreach ( $enclosurArray as $value ) {
  330. $enclosur = new enclosur ();
  331. $enclosur->name = $value;
  332. $enclosur->rid = $rid;
  333. $enclosur->insert ();
  334. }
  335. // print_r($enclosurArray);die;
  336. }
  337. // 报销详情
  338. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  339. $receiptDetail = new receiptDetail ();
  340. $receiptDetail->staff = $this->staff [0] ['sid'];
  341. $receiptDetail->item = $value ['name'];
  342. $receiptDetail->itemCategory = $this->AGENCY;
  343. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  344. $receiptDetail->date = date ( "Y-m-d" );
  345. $receiptDetail->cid = $cid;
  346. $receiptDetail->rid = $rid;
  347. $receiptDetail->status = 4;
  348. $receiptDetail->insert ();
  349. }
  350. return "/saeaBorad";
  351. } else
  352. die ( 'illegal request' );
  353. }
  354. function remitEdit() {
  355. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  356. Doo::loadClass ( 'XDeode' );
  357. $XDeode = new XDeode ( 7 );
  358. $rid = $XDeode->decode ( $ridKey );
  359. if (! is_numeric ( $rid ))
  360. die ( 'illegal request' );
  361. Doo::loadModel ( 'accountItem' );
  362. Doo::loadModel ( 'verify' );
  363. Doo::loadModel ( 'receipt' );
  364. $receipt = new receipt ();
  365. $verify = new verify ();
  366. $accountItem = new accountItem ();
  367. Doo::loadModel ( 'L_category' );
  368. $lCategory = new L_category ();
  369. Doo::loadModel ( "role" );
  370. $role = new role ();
  371. Doo::loadModel ( 'enclosur' );
  372. $enclosur = new enclosur ();
  373. $receiptDetail = $receipt->getOne ( array (
  374. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  375. 'asArray' => true
  376. ) );
  377. if (empty ( $receiptDetail ))
  378. return "/saeaCreate";
  379. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  380. $acItem = $accountItem->find ( array (
  381. 'asArray' => true
  382. ) );
  383. $veList = $verify->getVerifyBySubordinate('REMIT');
  384. // 配置编辑信息
  385. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  386. foreach ( $acItem as $key => $value ) {
  387. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  388. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  389. $acItem [$key] ['price'] = $v ['price'];
  390. }
  391. }
  392. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  393. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  394. $acItem [$key] ['price'] = $v ['price'];
  395. }
  396. }
  397. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  398. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  399. $acItem [$key] ['price'] = $v ['price'];
  400. }
  401. }
  402. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  403. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  404. $acItem [$key] ['price'] = $v ['price'];
  405. }
  406. }
  407. }
  408. $data ['category'] = $lCategory->find ( array (
  409. 'asArray' => true
  410. ) );
  411. $data ['enclosurList'] = $enclosurList;
  412. $data ['cSum'] = $accountItemList ['cSum'];
  413. $data ['sum'] = $receiptDetail ['sum'];
  414. $data ['receiptDetail'] = $receiptDetail;
  415. $data ['veList'] = $veList;
  416. $data ['acItem'] = $acItem;
  417. $data ['memu'] = "receipt";
  418. $data ['staff'] = $this->staff;
  419. $data ['receiptMemu'] = 'saeaBorad';
  420. $data ['verify'] = $receiptDetail ['verify'];
  421. $data ['verifyId'] = $this->verifyId;
  422. $data ['executeId'] = $this->executeId;
  423. $data ['rid'] = $rid;
  424. $data ['ridKey'] = $ridKey;
  425. $this->render ( "/admin/remitEdit", $data );
  426. }
  427. function remitEdiDo() {
  428. $agency = $this->get_args ( 'agency' );
  429. $travel = $this->get_args ( 'travel' );
  430. $train = $this->get_args ( 'train' );
  431. $other = $this->get_args ( 'other' );
  432. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  433. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  434. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  435. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  436. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  437. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  438. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  439. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  440. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  441. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  442. Doo::loadClass ( 'XDeode' );
  443. $XDeode = new XDeode ( 7 );
  444. $rid = $XDeode->decode ( $ridKey );
  445. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  446. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  447. header ( 'Content-Type:text/html;charset=utf-8' );
  448. die ( '请填写联行号' );
  449. }
  450. Doo::loadModel ( 'receipt' );
  451. Doo::loadModel ( 'receiptDetail' );
  452. Doo::loadModel ( 'accountItem' );
  453. $accountItem = new accountItem ();
  454. $receipt = new receipt ();
  455. Doo::loadModel ( 'enclosur' );
  456. $enclosur = new enclosur ();
  457. Doo::loadModel ( 'execute' );
  458. $execute = new execute ();
  459. $executeDetail = $execute->getOne ( array (
  460. 'where' => 'mold="对公汇款执行人"',
  461. 'asArray' => true
  462. ) );
  463. $receiptDetail = $receipt->getOne ( array (
  464. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  465. 'asArray' => true
  466. ) );
  467. if (empty ( $receiptDetail ))
  468. return "/saeaBorad";
  469. $aItem = $accountItem->find ( array (
  470. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  471. 'asArray' => true
  472. ) );
  473. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  474. $ag = $tr = $ta = $ot = 0;
  475. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  476. foreach ( $aItem as $key => $value ) {
  477. if ($value ['category'] == $this->AGENCY) {
  478. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  479. array_push ( $accountJson [$this->AGENCY], array (
  480. 'aid' => $value ['aid'],
  481. 'name' => $value ['name'],
  482. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  483. ) );
  484. $sum += $agency [$ag];
  485. $agencySum += $agency [$ag];
  486. }
  487. $ag ++;
  488. }
  489. }
  490. $accountJson ['cSum'] = array (
  491. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  492. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  493. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  494. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  495. );
  496. // 报销单
  497. $rid = $receipt->rid = $receiptDetail ['rid'];
  498. $receipt->accountItem = json_encode ( $accountJson );
  499. $receipt->staff = $this->staff [0] ['sid'];
  500. $receipt->sum = number_format ( $sum, 2, '.', '' );
  501. $receipt->date = date ( "Y-m-d" );
  502. $receipt->cid = $cid;
  503. if ($receiptDetail ['Rtype'] == 1)
  504. $receipt->status = 7;
  505. else
  506. $receipt->status = 5;
  507. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  508. $receipt->verify = $verify;
  509. $receipt->executeCopy = $executeDetail ['staff'];
  510. $order = array (
  511. "\r\n",
  512. "\n",
  513. "\r"
  514. );
  515. $replace = '<br/>';
  516. $explanation = str_replace ( $order, $replace, $explanation );
  517. $receipt->explanation = $explanation;
  518. $receipt->remittanceName = $remittanceName;
  519. $receipt->bankName = $bankName;
  520. $receipt->bankNumber = $bankNumber;
  521. $receipt->remittanceBankType = $remittanceBankType;
  522. if ($remittanceBankType == 1)
  523. $receipt->coupletNumber = $coupletNumber;
  524. $receipt->update ();
  525. $receiptDetail = new receiptDetail ();
  526. $receiptDetail->delete ( array (
  527. 'where' => 'rid=' . $rid
  528. ) );
  529. // 报销详情
  530. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  531. $receiptDetail = new receiptDetail ();
  532. $receiptDetail->staff = $this->staff [0] ['sid'];
  533. $receiptDetail->item = $value ['name'];
  534. $receiptDetail->itemCategory = $this->AGENCY;
  535. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  536. $receiptDetail->date = date ( "Y-m-d" );
  537. $receiptDetail->cid = $cid;
  538. $receiptDetail->rid = $rid;
  539. $receiptDetail->status = 4;
  540. $receiptDetail->insert ();
  541. }
  542. // 附件
  543. if (! empty ( $enclosurName )) {
  544. $enclosurArray = explode ( '-', $enclosurName );
  545. foreach ( $enclosurArray as $value ) {
  546. $enclosur = new enclosur ();
  547. $enclosur->name = $value;
  548. $enclosur->rid = $rid;
  549. $enclosur->insert ();
  550. }
  551. }
  552. }
  553. return "/saeaBorad";
  554. }
  555. function remitApproval() {
  556. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  557. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  558. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  559. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  560. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  561. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  562. if (empty ( $status ))
  563. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  564. $vidList = array ();
  565. $button = 0;
  566. Doo::loadModel ( 'verify' );
  567. Doo::loadModel ( 'receipt' );
  568. Doo::loadModel ( 'staff' );
  569. $staff = new staff ();
  570. $receipt = new receipt ();
  571. $verify = new verify ();
  572. Doo::loadModel ( 'L_category' );
  573. $Lcategory = new L_category ();
  574. Doo::loadModel ( 'enclosur' );
  575. $enclosur = new enclosur ();
  576. // user verify ID
  577. $verifyDetail = $verify->find ( array (
  578. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  579. 'asArray' => true
  580. ) );
  581. foreach ( $verifyDetail as $key => $value ) {
  582. array_push ( $vidList, $value ['vid'] );
  583. }
  584. $vid = implode ( ",", $vidList );
  585. if (empty ( $verifyDetail ))
  586. $vid = 0;
  587. $categoryList = $Lcategory->find ( array (
  588. 'asArray' => true
  589. ) );
  590. $staffList = $staff->find ( array (
  591. 'where' => 'cid=' . $cid,
  592. 'asArray' => true
  593. ) );
  594. $ap = "";
  595. if ($status == 4) {
  596. $ap = 4;
  597. $status = 2;
  598. }
  599. // get Receipt By verifyID status 2
  600. $receiptList = $receipt->find ( array (
  601. 'where' => 'rid =' . $rid . ' and status=2',
  602. 'desc' => 'rid',
  603. 'asArray' => true
  604. ) );
  605. if (empty ( $receiptList )) {
  606. die ( 'illegal request' );
  607. }
  608. $Locate = 0;
  609. $roleId = 0;
  610. if ($ap == 4)
  611. $status = 4;
  612. foreach ( $receiptList as $key => $value ) {
  613. $receiptList [$key] ['Locate'] = $Locate;
  614. $Locate ++;
  615. $receiptList [$key] ['reviseDetail'] = array ();
  616. if (! empty ( $value ['reviseDetail'] ))
  617. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  618. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  619. $categoryDetil = $Lcategory->getOne ( array (
  620. 'where' => 'cid=' . $value ['cid'],
  621. 'asArray' => true
  622. ) );
  623. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  624. // 检测编辑状态
  625. $verifyList = $verify->getOne ( array (
  626. 'where' => 'vid=' . $value ['verify'],
  627. 'asArray' => true
  628. ) );
  629. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  630. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  631. Doo::loadModel ( 'role' );
  632. $role = new role ();
  633. // print_r($verifyList);
  634. $flag = true;
  635. $roleKey = 0;
  636. $endStaffArray = array ();
  637. $roleArrayCopy = array ();
  638. foreach ( $verifyList as $k => $v ) {
  639. // init verifyStaff
  640. if ($v [1] == 'ROLE') {
  641. if (! empty ( $verifyStaff )) {
  642. $endStaffArray = end ( $verifyStaff );
  643. if ($v [0] == $endStaffArray ['nextStaff']) {
  644. $roleId = $v [0];
  645. }
  646. }
  647. $roleVerify = json_decode ( $v [3], true );
  648. $roleKey = $k;
  649. $roleArray = array ();
  650. $rolename = $role->getOne ( array (
  651. 'where' => 'rid=' . $v [0],
  652. 'asArray' => true
  653. ) );
  654. foreach ( $roleVerify as $o => $p ) {
  655. $staffID = explode ( '_', $p );
  656. $staffInfo = $staff->getOne ( array (
  657. 'where' => 'sid=' . $staffID [0],
  658. 'asArray' => true
  659. ) );
  660. // print_r($staffID);
  661. $exp = array (
  662. 0 => $staffInfo ['sid'],
  663. 1 => $staffID [1],
  664. 2 => $staffInfo ['avatar'],
  665. 'date' => '',
  666. 'date' => '',
  667. 'opinion' => '',
  668. 'status' => '',
  669. 'rolename' => $rolename ['name']
  670. );
  671. array_push ( $roleArray, $exp );
  672. }
  673. $roleArrayCopy [$v [0]] = $roleArray;
  674. // $verifyList[$k]['roleArray']=$roleArray;
  675. }
  676. // print_r($roleArray);
  677. $verifyList [$k] ['date'] = "";
  678. $verifyList [$k] ['opinion'] = "";
  679. $verifyList [$k] ['status'] = "";
  680. if (empty ( $verifyStaff )) {
  681. $verifyList [$k] ['date'] = "";
  682. $verifyList [$k] ['opinion'] = "";
  683. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  684. $verifyList [$k] ['status'] = 4;
  685. $button = 4;
  686. $flag = false;
  687. }
  688. } else {
  689. foreach ( $verifyStaff as $m => $u ) {
  690. if ($v [0] == $m) {
  691. $verifyList [$k] ['date'] = $u ['date'];
  692. $verifyList [$k] ['opinion'] = $u ['opinion'];
  693. $verifyList [$k] ['status'] = $u ['status'];
  694. $flag = false;
  695. break;
  696. }
  697. }
  698. $endStaffArray = end ( $verifyStaff );
  699. if (isset ( $endStaffArray ['ROLE'] )) {
  700. } else {
  701. $endKey = key ( $verifyStaff );
  702. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  703. $button = 4;
  704. $verifyList [$k] ['status'] = 4;
  705. }
  706. }
  707. }
  708. }
  709. $rolename ['name'] = '';
  710. if (! empty ( $roleId )) {
  711. Doo::loadModel ( 'role' );
  712. $role = new role ();
  713. $rolename = $role->getOne ( array (
  714. 'where' => 'rid=' . $roleId,
  715. 'asArray' => true
  716. ) );
  717. }
  718. if (! empty ( $verifyStaff ))
  719. $endStaffArray = end ( $verifyStaff );
  720. $KOP = false;
  721. foreach ( $roleArrayCopy as $P => $A ) {
  722. foreach ( $A as $MKI => $AVL ) {
  723. if (! empty ( $verifyStaff )) {
  724. // &&$rolename['rid']==$endStaffArray['nextStaff']
  725. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  726. $button = 4;
  727. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  728. }
  729. foreach ( $verifyStaff as $m => $u ) {
  730. $AVLFK = $AVL [0] . '_R';
  731. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  732. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  733. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  734. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  735. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  736. break;
  737. }
  738. }
  739. } else {
  740. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  741. $button = 4;
  742. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  743. }
  744. }
  745. // $roleArray[$MKI]['rolename']=$rolename['name'];
  746. $KOP = true;
  747. }
  748. }
  749. foreach ( $roleArrayCopy as $k => $v ) {
  750. foreach ( $verifyList as $m => $n ) {
  751. if ($n [0] == $k) {
  752. array_splice ( $verifyList, $m, 1, $v );
  753. }
  754. }
  755. }
  756. $receiptList [$key] ['verifyList'] = $verifyList;
  757. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  758. 'where' => 'sid=' . $value ['staff'],
  759. 'asArray' => true
  760. ) );
  761. $receiptList [$key] ['button'] = $button;
  762. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  763. }
  764. $mothHtml = "";
  765. for($i = 1; $i <= 12; $i ++) {
  766. if ($month == $i)
  767. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  768. else
  769. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  770. }
  771. // 获取审批日志
  772. Doo::loadModel ( 'receiptLog' );
  773. $receiptLog = new receiptLog ();
  774. $rlList = array ();
  775. $rlInfo = $receiptLog->getOne ( array (
  776. 'where' => 'rid=' . $rid . ' and status=4',
  777. 'asArray' => true
  778. ) );
  779. $tijdate = $receiptLog->getOne ( array (
  780. 'where' => 'rid=' . $rid . ' and status=2',
  781. 'asc' => 'rlid',
  782. 'asArray' => true
  783. ) );
  784. if (! empty ( $rlInfo )) {
  785. $rlList = $receiptLog->find ( array (
  786. 'where' => 'rid=' . $rid,
  787. 'asc' => 'rlid',
  788. 'asArray' => true
  789. ) );
  790. }
  791. $receiptList [0] ['rlList'] = $rlList;
  792. $enclosurList = $enclosur->find ( array (
  793. 'where' => 'rid=' . $rid,
  794. 'asArray' => true
  795. ) );
  796. $enclosurHtml = '';
  797. foreach ( $enclosurList as $value ) {
  798. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  799. }
  800. // print_r($receiptList);
  801. $data ['enclosurHtml'] = $enclosurHtml;
  802. $data ['rolename'] = $rolename ['name'];
  803. $data ['datetij'] = $tijdate ['date'];
  804. $data ['mothHtml'] = $mothHtml;
  805. $data ['rid'] = $rid;
  806. $data ['receiptList'] = $receiptList;
  807. $data ['receiptApprovalCount'] = count ( $receiptList );
  808. $data ['status'] = $status;
  809. $data ['year'] = $year;
  810. $data ['categoryList'] = $categoryList;
  811. $data ['staffList'] = $staffList;
  812. $data ['cid'] = $cid;
  813. $data ['sid'] = $sid;
  814. $data ['ap'] = $ap;
  815. $data ['memu'] = "receipt";
  816. $data ['staff'] = $this->staff;
  817. $data ['receiptMemu'] = 'approvalExpenses';
  818. $data ['verifyId'] = $this->verifyId;
  819. $data ['executeId'] = $this->executeId;
  820. $this->render ( "/admin/remitApproval", $data );
  821. }
  822. function saeaLoanAdd() {
  823. Doo::loadModel ( 'verify' );
  824. $verify = new verify ();
  825. Doo::loadModel ( "role" );
  826. $role = new role ();
  827. Doo::loadModel ( 'L_category' );
  828. $lCategory = new L_category ();
  829. $veList = $verify->getVerifyBySubordinate('LOAN');
  830. $data ['category'] = $lCategory->find ( array (
  831. 'asArray' => true
  832. ) );
  833. $data ['veList'] = $veList;
  834. $data ['memu'] = "receipt";
  835. $data ['staff'] = $this->staff;
  836. $data ['receiptMemu'] = 'saeaBorad';
  837. $data ['verifyId'] = $this->verifyId;
  838. $data ['executeId'] = $this->executeId;
  839. $this->render ( "/admin/saeaLoanAdd", $data );
  840. }
  841. function saeaLoanAddDo() {
  842. $agency = $this->get_args ( 'agency' );
  843. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  844. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  845. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  846. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  847. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  848. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  849. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  850. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  851. // die;
  852. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  853. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  854. header ( 'Content-Type:text/html;charset=utf-8' );
  855. die ( '请填写联行号' );
  856. }
  857. Doo::loadModel ( 'receipt' );
  858. Doo::loadModel ( 'receiptDetail' );
  859. Doo::loadModel ( 'accountItem' );
  860. $accountItem = new accountItem ();
  861. $receipt = new receipt ();
  862. Doo::loadModel ( 'loanReceipt' );
  863. $loanReceipt = new loanReceipt ();
  864. Doo::loadModel ( 'execute' );
  865. $execute = new execute ();
  866. Doo::loadModel ( 'enclosur' );
  867. $executeDetail = $execute->getOne ( array (
  868. 'where' => 'mold="借款执行人"',
  869. 'asArray' => true
  870. ) );
  871. $aItem = $accountItem->find ( array (
  872. 'asArray' => true
  873. ) );
  874. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  875. $ag = $tr = $ta = $ot = 0;
  876. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  877. array_push ( $accountJson ['借款费用'], array (
  878. 'aid' => 0,
  879. 'name' => '申请金额',
  880. 'price' => number_format ( $agency, 2, '.', '' )
  881. ) );
  882. $sum += $agency;
  883. $agencySum += $agency;
  884. $accountJson ['cSum'] = array (
  885. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  886. 'agencySum' => number_format ( 0, 2, '.', '' ),
  887. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  888. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  889. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  890. );
  891. // 借款数据备份
  892. $loanReceipt->loanItem = json_encode ( $accountJson );
  893. $loanReceipt->staff = $this->staff [0] ['sid'];
  894. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  895. $loanReceipt->date = date ( "Y-m-d" );
  896. $loanReceipt->cid = $cid;
  897. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  898. $loanReceipt->status = 5;
  899. $loanReceipt->Rtype = 1;
  900. $loanReceipt->verify = $verify;
  901. $receipt->receiptOrder = $receipt->receiptOrder;
  902. // 添加HTML换行符
  903. // var_dump($explanation);
  904. $order = array (
  905. "\r\n",
  906. "\n",
  907. "\r"
  908. );
  909. $replace = '<br/>';
  910. $explanation = str_replace ( $order, $replace, $explanation );
  911. // $explanation=str_replace('\r',"<br/>",$explanation);
  912. // $explanation=str_replace('\r\n',"<br/>",$explanation);
  913. $loanReceipt->explanation = $explanation;
  914. $loanRid = $loanReceipt->insert ();
  915. // 报销单
  916. $receipt->loanItem = json_encode ( $accountJson );
  917. $receipt->staff = $this->staff [0] ['sid'];
  918. $receipt->sum = number_format ( $sum, 2, '.', '' );
  919. $receipt->date = date ( "Y-m-d" );
  920. $receipt->cid = $cid;
  921. // 特殊状态
  922. $receipt->status = 5;
  923. $receipt->Rtype = 1;
  924. $receipt->loanRid = $loanRid;
  925. // 修改审批流程加入角色
  926. $receipt->verify = $verify;
  927. $receipt->executeCopy = $executeDetail ['staff'];
  928. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  929. $receipt->explanation = $explanation;
  930. $receipt->remittanceName = $remittanceName;
  931. $receipt->bankName = $bankName;
  932. $receipt->bankNumber = $bankNumber;
  933. $receipt->remittanceBankType = $remittanceBankType;
  934. if ($remittanceBankType == 1)
  935. $receipt->coupletNumber = $coupletNumber;
  936. $rid = $receipt->insert ();
  937. return "/saeaBorad";
  938. } else
  939. die ( 'illegal request' );
  940. }
  941. function saeaLoanEdi() {
  942. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  943. Doo::loadClass ( 'XDeode' );
  944. $XDeode = new XDeode ( 7 );
  945. $rid = $XDeode->decode ( $ridKey );
  946. if (! is_numeric ( $rid ))
  947. die ( 'illegal request' );
  948. Doo::loadModel ( 'verify' );
  949. $verify = new verify ();
  950. Doo::loadModel ( "role" );
  951. $role = new role ();
  952. Doo::loadModel ( 'L_category' );
  953. $lCategory = new L_category ();
  954. Doo::loadModel ( 'receipt' );
  955. $receipt = new receipt ();
  956. $receiptInfo = $receipt->getOne ( array (
  957. 'where' => 'rid=' . $rid,
  958. 'asArray' => true
  959. ) );
  960. $veList = $verify->find ( array (
  961. 'where'=>'subordinate like "%LOAN%"',
  962. 'asArray' => true
  963. ) );
  964. foreach ( $veList as $key => $value ) {
  965. $v = json_decode ( $value ['staff'] );
  966. $list = array ();
  967. foreach ( $v as $n => $m ) {
  968. if ($m ['1'] == 'ROLE') {
  969. $roleInfo = $role->getOne ( array (
  970. 'where' => 'rid=' . $m [0],
  971. 'asArray' => true
  972. ) );
  973. $v [$n] [1] = $roleInfo ['name'];
  974. array_push ( $list, $roleInfo ['name'] );
  975. } else {
  976. array_push ( $list, $v [$n] [1] );
  977. }
  978. }
  979. $veList [$key] ['staff'] = implode ( '>', $list );
  980. }
  981. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  982. // print_r($receiptInfo);
  983. $data ['receiptInfo'] = $receiptInfo;
  984. $data ['category'] = $lCategory->find ( array (
  985. 'asArray' => true
  986. ) );
  987. $data ['veList'] = $veList;
  988. $data ['ridKey'] = $ridKey;
  989. $data ['memu'] = "receipt";
  990. $data ['staff'] = $this->staff;
  991. $data ['receiptMemu'] = 'saeaBorad';
  992. $data ['verifyId'] = $this->verifyId;
  993. $data ['executeId'] = $this->executeId;
  994. $this->render ( "/admin/saeaLoanEdi", $data );
  995. }
  996. function saeaLoanEdiDo() {
  997. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  998. $agency = $this->get_args ( 'agency' );
  999. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1000. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1001. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1002. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1003. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1004. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1005. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1006. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1007. // die;
  1008. Doo::loadClass ( 'XDeode' );
  1009. $XDeode = new XDeode ( 7 );
  1010. $rid = $XDeode->decode ( $ridKey );
  1011. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1012. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1013. header ( 'Content-Type:text/html;charset=utf-8' );
  1014. die ( '请填写联行号' );
  1015. }
  1016. Doo::loadModel ( 'receipt' );
  1017. Doo::loadModel ( 'receiptDetail' );
  1018. Doo::loadModel ( 'accountItem' );
  1019. $accountItem = new accountItem ();
  1020. $receipt = new receipt ();
  1021. Doo::loadModel ( 'loanReceipt' );
  1022. $loanReceipt = new loanReceipt ();
  1023. Doo::loadModel ( 'enclosur' );
  1024. Doo::loadModel ( 'execute' );
  1025. $execute = new execute ();
  1026. $executeDetail = $execute->getOne ( array (
  1027. 'where' => 'mold="借款执行人"',
  1028. 'asArray' => true
  1029. ) );
  1030. $receiptDetail = $receipt->getOne ( array (
  1031. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  1032. 'asArray' => true
  1033. ) );
  1034. if (empty ( $receiptDetail ))
  1035. die ( '参数错误' );
  1036. $aItem = $accountItem->find ( array (
  1037. 'asArray' => true
  1038. ) );
  1039. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1040. $ag = $tr = $ta = $ot = 0;
  1041. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1042. array_push ( $accountJson ['借款费用'], array (
  1043. 'aid' => 0,
  1044. 'name' => '申请金额',
  1045. 'price' => number_format ( $agency, 2, '.', '' )
  1046. ) );
  1047. $sum += $agency;
  1048. $agencySum += $agency;
  1049. $accountJson ['cSum'] = array (
  1050. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1051. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1052. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1053. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1054. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1055. );
  1056. // 报销单
  1057. $receipt->loanItem = json_encode ( $accountJson );
  1058. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1059. $receipt->cid = $cid;
  1060. // 特殊状态
  1061. // 修改审批流程加入角色
  1062. if ($receiptDetail ['status'] != 4)
  1063. $receipt->verify = $verify;
  1064. $order = array (
  1065. "\r\n",
  1066. "\n",
  1067. "\r"
  1068. );
  1069. $replace = '<br/>';
  1070. $explanation = str_replace ( $order, $replace, $explanation );
  1071. $receipt->explanation = $explanation;
  1072. $receipt->remittanceName = $remittanceName;
  1073. $receipt->bankName = $bankName;
  1074. $receipt->bankNumber = $bankNumber;
  1075. $receipt->remittanceBankType = $remittanceBankType;
  1076. if ($remittanceBankType == 1)
  1077. $receipt->coupletNumber = $coupletNumber;
  1078. $receipt->update ( array (
  1079. 'where' => 'rid=' . $rid
  1080. ) );
  1081. // 借款数据更新
  1082. $loanReceipt->loanItem = json_encode ( $accountJson );
  1083. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1084. $loanReceipt->cid = $cid;
  1085. if ($receiptDetail ['status'] != 4)
  1086. $loanReceipt->verify = $verify;
  1087. $loanReceipt->explanation = $explanation;
  1088. $receipt->executeCopy = $executeDetail ['staff'];
  1089. $loanReceipt->update ( array (
  1090. 'where' => 'rid=' . $receiptDetail ['loanRid']
  1091. ) );
  1092. }
  1093. return "/saeaBorad";
  1094. }
  1095. function saeaLoanReceiptAdd() {
  1096. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1097. Doo::loadModel ( 'receipt' );
  1098. $receipt = new receipt ();
  1099. Doo::loadModel ( 'loanReceipt' );
  1100. $loanReceipt = new loanReceipt ();
  1101. Doo::loadModel ( 'L_category' );
  1102. $Lcategory = new L_category ();
  1103. Doo::loadModel ( 'verify' );
  1104. Doo::loadModel ( 'statistics' );
  1105. $statistics = new statistics ();
  1106. $verify = new verify ();
  1107. Doo::loadModel ( 'staff' );
  1108. $staff = new staff ();
  1109. $receiptDetail = $receipt->getOne ( array (
  1110. 'where' => 'rid=' . $rid,
  1111. 'desc' => 'rid',
  1112. 'asArray' => true
  1113. ) );
  1114. $receiptList = $loanReceipt->find ( array (
  1115. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1116. 'desc' => 'rid',
  1117. 'asArray' => true
  1118. ) );
  1119. $Locate = 0;
  1120. $roleId = 0;
  1121. $button = 0;
  1122. foreach ( $receiptList as $key => $value ) {
  1123. $receiptList [$key] ['Locate'] = $Locate;
  1124. $Locate ++;
  1125. $receiptList [$key] ['reviseDetail'] = array ();
  1126. if (! empty ( $value ['reviseDetail'] ))
  1127. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1128. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1129. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1130. $categoryDetil = $Lcategory->getOne ( array (
  1131. 'where' => 'cid=' . $value ['cid'],
  1132. 'asArray' => true
  1133. ) );
  1134. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1135. // 检测编辑状态
  1136. $verifyList = $verify->getOne ( array (
  1137. 'where' => 'vid=' . $value ['verify'],
  1138. 'asArray' => true
  1139. ) );
  1140. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1141. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1142. Doo::loadModel ( 'role' );
  1143. $role = new role ();
  1144. $flag = true;
  1145. $roleKey = 0;
  1146. $endStaffArray = array ();
  1147. $roleArrayCopy = array ();
  1148. foreach ( $verifyList as $k => $v ) {
  1149. // init verifyStaff
  1150. if ($v [1] == 'ROLE') {
  1151. if (! empty ( $verifyStaff )) {
  1152. $endStaffArray = end ( $verifyStaff );
  1153. // if ($v[0]==$endStaffArray['nextStaff']){
  1154. // $roleId=$v[0];
  1155. // }
  1156. }
  1157. $roleVerify = json_decode ( $v [3], true );
  1158. $roleKey = $k;
  1159. $roleArray = array ();
  1160. $rolename = $role->getOne ( array (
  1161. 'where' => 'rid=' . $v [0],
  1162. 'asArray' => true
  1163. ) );
  1164. foreach ( $roleVerify as $o => $p ) {
  1165. $staffID = explode ( '_', $p );
  1166. $staffInfo = $staff->getOne ( array (
  1167. 'where' => 'sid=' . $staffID [0],
  1168. 'asArray' => true
  1169. ) );
  1170. // print_r($staffID);
  1171. $exp = array (
  1172. 0 => $staffInfo ['sid'],
  1173. 1 => $staffID [1],
  1174. 2 => $staffInfo ['avatar'],
  1175. 'date' => '',
  1176. 'date' => '',
  1177. 'opinion' => '',
  1178. 'status' => '',
  1179. 'rolename' => $rolename ['name']
  1180. );
  1181. array_push ( $roleArray, $exp );
  1182. }
  1183. $roleArrayCopy [$v [0]] = $roleArray;
  1184. // $verifyList[$k]['roleArray']=$roleArray;
  1185. }
  1186. $verifyList [$k] ['date'] = "";
  1187. $verifyList [$k] ['opinion'] = "";
  1188. $verifyList [$k] ['status'] = "";
  1189. if (empty ( $verifyStaff )) {
  1190. $verifyList [$k] ['date'] = "";
  1191. $verifyList [$k] ['opinion'] = "";
  1192. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1193. $verifyList [$k] ['status'] = 4;
  1194. $flag = false;
  1195. }
  1196. } else {
  1197. foreach ( $verifyStaff as $m => $u ) {
  1198. if ($v [0] == $m) {
  1199. $verifyList [$k] ['date'] = $u ['date'];
  1200. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1201. $verifyList [$k] ['status'] = $u ['status'];
  1202. $flag = false;
  1203. break;
  1204. }
  1205. }
  1206. $endStaffArray = end ( $verifyStaff );
  1207. if (isset ( $endStaffArray ['ROLE'] )) {
  1208. } else {
  1209. // $endKey=key($verifyStaff);
  1210. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1211. // $button=4;
  1212. // $verifyList[$k]['status']=4;
  1213. // }
  1214. }
  1215. }
  1216. }
  1217. $rolename ['name'] = '';
  1218. if (! empty ( $roleId )) {
  1219. Doo::loadModel ( 'role' );
  1220. $role = new role ();
  1221. $rolename = $role->getOne ( array (
  1222. 'where' => 'rid=' . $roleId,
  1223. 'asArray' => true
  1224. ) );
  1225. }
  1226. if (! empty ( $verifyStaff ))
  1227. $endStaffArray = end ( $verifyStaff );
  1228. $KOP = false;
  1229. foreach ( $roleArrayCopy as $P => $A ) {
  1230. foreach ( $A as $MKI => $AVL ) {
  1231. if (! empty ( $verifyStaff )) {
  1232. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1233. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1234. $button = 4;
  1235. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1236. }
  1237. foreach ( $verifyStaff as $m => $u ) {
  1238. $AVLFK = $AVL [0] . '_R';
  1239. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1240. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1241. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1242. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1243. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1244. break;
  1245. }
  1246. }
  1247. } else {
  1248. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1249. $button = 4;
  1250. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1251. }
  1252. }
  1253. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1254. $KOP = true;
  1255. }
  1256. }
  1257. foreach ( $roleArrayCopy as $k => $v ) {
  1258. foreach ( $verifyList as $m => $n ) {
  1259. if ($n [0] == $k) {
  1260. array_splice ( $verifyList, $m, 1, $v );
  1261. }
  1262. }
  1263. }
  1264. $receiptList [$key] ['verifyList'] = $verifyList;
  1265. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1266. 'where' => 'sid=' . $value ['staff'],
  1267. 'asArray' => true
  1268. ) );
  1269. $receiptList [$key] ['button'] = $button;
  1270. //
  1271. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1272. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1273. }
  1274. $data ['receiptList'] = $receiptList;
  1275. $data ['receiptDetail'] = $receiptDetail;
  1276. Doo::loadModel ( 'L_category' );
  1277. $lCategory = new L_category ();
  1278. Doo::loadModel ( 'accountItem' );
  1279. $accountItem = new accountItem ();
  1280. $acItem = $accountItem->find ( array (
  1281. 'asArray' => true
  1282. ) );
  1283. $veList = $verify->getVerifyBySubordinate('RECEIPT','LOAN');
  1284. $data ['rid'] = $rid;
  1285. $data ['category'] = $lCategory->find ( array (
  1286. 'asArray' => true
  1287. ) );
  1288. $data ['veList'] = $veList;
  1289. $data ['acItem'] = $acItem;
  1290. $data ['memu'] = "receipt";
  1291. $data ['staff'] = $this->staff;
  1292. $data ['receiptMemu'] = 'saeaBorad';
  1293. $data ['verifyId'] = $this->verifyId;
  1294. $data ['executeId'] = $this->executeId;
  1295. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1296. }
  1297. function saeaLoanReceiptAddDo() {
  1298. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1299. $agency = $this->get_args ( 'agency' );
  1300. $travel = $this->get_args ( 'travel' );
  1301. $train = $this->get_args ( 'train' );
  1302. $other = $this->get_args ( 'other' );
  1303. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1304. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1305. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1306. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1307. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1308. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1309. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1310. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1311. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1312. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1313. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1314. header ( 'Content-Type:text/html;charset=utf-8' );
  1315. die ( '请填写联行号' );
  1316. }
  1317. Doo::loadModel ( 'receipt' );
  1318. Doo::loadModel ( 'receiptDetail' );
  1319. Doo::loadModel ( 'accountItem' );
  1320. $accountItem = new accountItem ();
  1321. $receipt = new receipt ();
  1322. Doo::loadModel ( 'enclosur' );
  1323. Doo::loadModel ( 'execute' );
  1324. $execute = new execute ();
  1325. $executeDetail = $execute->getOne ( array (
  1326. 'where' => 'mold="借款费用执行人"',
  1327. 'asArray' => true
  1328. ) );
  1329. $receiptDet = $receipt->getOne ( array (
  1330. 'where' => 'rid=' . $rid,
  1331. 'asArray' => true
  1332. ) );
  1333. // if(!empty($receiptDetail))
  1334. // return "/referReceipt/".$receiptDetail['rid'];
  1335. $aItem = $accountItem->find ( array (
  1336. 'asArray' => true
  1337. ) );
  1338. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1339. $ag = $tr = $ta = $ot = 0;
  1340. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1341. foreach ( $aItem as $key => $value ) {
  1342. if ($value ['category'] == $this->AGENCY) {
  1343. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1344. array_push ( $accountJson [$this->AGENCY], array (
  1345. 'aid' => $value ['aid'],
  1346. 'name' => $value ['name'],
  1347. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1348. ) );
  1349. $sum += $agency [$ag];
  1350. $agencySum += $agency [$ag];
  1351. }
  1352. $ag ++;
  1353. }
  1354. if ($value ['category'] == $this->TRAVEL) {
  1355. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1356. array_push ( $accountJson [$this->TRAVEL], array (
  1357. 'aid' => $value ['aid'],
  1358. 'name' => $value ['name'],
  1359. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1360. ) );
  1361. $sum += $travel [$tr];
  1362. $travelSum += $travel [$tr];
  1363. }
  1364. $tr ++;
  1365. }
  1366. if ($value ['category'] == $this->TRAIN) {
  1367. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1368. array_push ( $accountJson [$this->TRAIN], array (
  1369. 'aid' => $value ['aid'],
  1370. 'name' => $value ['name'],
  1371. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1372. ) );
  1373. $sum += $train [$ta];
  1374. $trainSum += $train [$ta];
  1375. }
  1376. $ta ++;
  1377. }
  1378. if ($value ['category'] == $this->OTHER) {
  1379. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1380. array_push ( $accountJson [$this->OTHER], array (
  1381. 'aid' => $value ['aid'],
  1382. 'name' => $value ['name'],
  1383. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1384. ) );
  1385. $sum += $other [$ot];
  1386. $otherSum += $other [$ot];
  1387. }
  1388. $ot ++;
  1389. }
  1390. }
  1391. $accountJson ['cSum'] = array (
  1392. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1393. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1394. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1395. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1396. );
  1397. // 报销单
  1398. $receipt->accountItem = json_encode ( $accountJson );
  1399. $receipt->staff = $this->staff [0] ['sid'];
  1400. $receipt->loanSum = $receiptDet ['sum'];
  1401. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1402. $receipt->date = date ( "Y-m-d" );
  1403. $receipt->pastDate = '';
  1404. $receipt->cid = $cid;
  1405. $receipt->status = 7;
  1406. // 修改审批流程加入角色
  1407. $receipt->verify = $verify;
  1408. $receipt->verifyStaff = '';
  1409. $receipt->executeStaff = '';
  1410. $receipt->executeCopy = $executeDetail ['staff'];
  1411. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1412. $receipt->explanation = $explanation;
  1413. $receipt->remittanceName = $remittanceName;
  1414. $receipt->bankName = $bankName;
  1415. $receipt->bankNumber = $bankNumber;
  1416. $receipt->remittanceBankType = $remittanceBankType;
  1417. if ($remittanceBankType == 1)
  1418. $receipt->coupletNumber = $coupletNumber;
  1419. $receipt->update ( array (
  1420. 'where' => 'rid=' . $rid
  1421. ) );
  1422. // 附件
  1423. if (! empty ( $enclosurName )) {
  1424. $enclosurArray = explode ( '-', $enclosurName );
  1425. foreach ( $enclosurArray as $value ) {
  1426. $enclosur = new enclosur ();
  1427. $enclosur->name = $value;
  1428. $enclosur->rid = $rid;
  1429. $enclosur->insert ();
  1430. }
  1431. // print_r($enclosurArray);die;
  1432. }
  1433. // 报销详情
  1434. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1435. $receiptDetail = new receiptDetail ();
  1436. $receiptDetail->staff = $this->staff [0] ['sid'];
  1437. $receiptDetail->item = $value ['name'];
  1438. $receiptDetail->itemCategory = $this->AGENCY;
  1439. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1440. $receiptDetail->date = date ( "Y-m-d" );
  1441. $receiptDetail->cid = $cid;
  1442. $receiptDetail->rid = $rid;
  1443. $receiptDetail->status = 4;
  1444. $receiptDetail->insert ();
  1445. }
  1446. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1447. $receiptDetail = new receiptDetail ();
  1448. $receiptDetail->staff = $this->staff [0] ['sid'];
  1449. $receiptDetail->item = $value ['name'];
  1450. $receiptDetail->itemCategory = $this->TRAVEL;
  1451. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1452. $receiptDetail->date = date ( "Y-m-d" );
  1453. $receiptDetail->cid = $cid;
  1454. $receiptDetail->rid = $rid;
  1455. $receiptDetail->status = 4;
  1456. $receiptDetail->insert ();
  1457. }
  1458. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1459. $receiptDetail = new receiptDetail ();
  1460. $receiptDetail->staff = $this->staff [0] ['sid'];
  1461. $receiptDetail->item = $value ['name'];
  1462. $receiptDetail->itemCategory = $this->TRAIN;
  1463. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1464. $receiptDetail->date = date ( "Y-m-d" );
  1465. $receiptDetail->cid = $cid;
  1466. $receiptDetail->rid = $rid;
  1467. $receiptDetail->status = 4;
  1468. $receiptDetail->insert ();
  1469. }
  1470. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1471. $receiptDetail = new receiptDetail ();
  1472. $receiptDetail->staff = $this->staff [0] ['sid'];
  1473. $receiptDetail->item = $value ['name'];
  1474. $receiptDetail->itemCategory = $this->OTHER;
  1475. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1476. $receiptDetail->date = date ( "Y-m-d" );
  1477. $receiptDetail->cid = $cid;
  1478. $receiptDetail->rid = $rid;
  1479. $receiptDetail->status = 4;
  1480. $receiptDetail->insert ();
  1481. }
  1482. return "/saeaBorad";
  1483. }
  1484. return "/saeaLoanReceiptAdd/" . $rid;
  1485. }
  1486. function saeaLoanReceiptEdi() {
  1487. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1488. Doo::loadClass ( 'XDeode' );
  1489. $XDeode = new XDeode ( 7 );
  1490. $rid = $XDeode->decode ( $ridKey );
  1491. if (! is_numeric ( $rid ))
  1492. die ( 'illegal request' );
  1493. Doo::loadModel ( 'accountItem' );
  1494. Doo::loadModel ( 'verify' );
  1495. Doo::loadModel ( 'receipt' );
  1496. $receipt = new receipt ();
  1497. $verify = new verify ();
  1498. $accountItem = new accountItem ();
  1499. Doo::loadModel ( 'L_category' );
  1500. $Lcategory = new L_category ();
  1501. Doo::loadModel ( "role" );
  1502. $role = new role ();
  1503. Doo::loadModel ( 'loanReceipt' );
  1504. $loanReceipt = new loanReceipt ();
  1505. Doo::loadModel ( 'staff' );
  1506. $staff = new staff ();
  1507. $receiptDetail = $receipt->getOne ( array (
  1508. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1509. 'asArray' => true
  1510. ) );
  1511. if (empty ( $receiptDetail ))
  1512. return "/saeaBorad";
  1513. $receiptList = $loanReceipt->find ( array (
  1514. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1515. 'desc' => 'rid',
  1516. 'asArray' => true
  1517. ) );
  1518. $Locate = 0;
  1519. $roleId = 0;
  1520. $button = 0;
  1521. foreach ( $receiptList as $key => $value ) {
  1522. $receiptList [$key] ['Locate'] = $Locate;
  1523. $Locate ++;
  1524. $receiptList [$key] ['reviseDetail'] = array ();
  1525. if (! empty ( $value ['reviseDetail'] ))
  1526. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1527. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1528. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1529. $categoryDetil = $Lcategory->getOne ( array (
  1530. 'where' => 'cid=' . $value ['cid'],
  1531. 'asArray' => true
  1532. ) );
  1533. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1534. // 检测编辑状态
  1535. $verifyList = $verify->getOne ( array (
  1536. 'where' => 'vid=' . $value ['verify'],
  1537. 'asArray' => true
  1538. ) );
  1539. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1540. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1541. Doo::loadModel ( 'role' );
  1542. $role = new role ();
  1543. $flag = true;
  1544. $roleKey = 0;
  1545. $endStaffArray = array ();
  1546. $roleArrayCopy = array ();
  1547. foreach ( $verifyList as $k => $v ) {
  1548. // init verifyStaff
  1549. if ($v [1] == 'ROLE') {
  1550. if (! empty ( $verifyStaff )) {
  1551. $endStaffArray = end ( $verifyStaff );
  1552. // if ($v[0]==$endStaffArray['nextStaff']){
  1553. // $roleId=$v[0];
  1554. // }
  1555. }
  1556. $roleVerify = json_decode ( $v [3], true );
  1557. $roleKey = $k;
  1558. $roleArray = array ();
  1559. $rolename = $role->getOne ( array (
  1560. 'where' => 'rid=' . $v [0],
  1561. 'asArray' => true
  1562. ) );
  1563. foreach ( $roleVerify as $o => $p ) {
  1564. $staffID = explode ( '_', $p );
  1565. $staffInfo = $staff->getOne ( array (
  1566. 'where' => 'sid=' . $staffID [0],
  1567. 'asArray' => true
  1568. ) );
  1569. // print_r($staffID);
  1570. $exp = array (
  1571. 0 => $staffInfo ['sid'],
  1572. 1 => $staffID [1],
  1573. 2 => $staffInfo ['avatar'],
  1574. 'date' => '',
  1575. 'date' => '',
  1576. 'opinion' => '',
  1577. 'status' => '',
  1578. 'rolename' => $rolename ['name']
  1579. );
  1580. array_push ( $roleArray, $exp );
  1581. }
  1582. $roleArrayCopy [$v [0]] = $roleArray;
  1583. // $verifyList[$k]['roleArray']=$roleArray;
  1584. }
  1585. $verifyList [$k] ['date'] = "";
  1586. $verifyList [$k] ['opinion'] = "";
  1587. $verifyList [$k] ['status'] = "";
  1588. if (empty ( $verifyStaff )) {
  1589. $verifyList [$k] ['date'] = "";
  1590. $verifyList [$k] ['opinion'] = "";
  1591. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1592. $verifyList [$k] ['status'] = 4;
  1593. $flag = false;
  1594. }
  1595. } else {
  1596. foreach ( $verifyStaff as $m => $u ) {
  1597. if ($v [0] == $m) {
  1598. $verifyList [$k] ['date'] = $u ['date'];
  1599. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1600. $verifyList [$k] ['status'] = $u ['status'];
  1601. $flag = false;
  1602. break;
  1603. }
  1604. }
  1605. $endStaffArray = end ( $verifyStaff );
  1606. if (isset ( $endStaffArray ['ROLE'] )) {
  1607. } else {
  1608. // $endKey=key($verifyStaff);
  1609. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1610. // $button=4;
  1611. // $verifyList[$k]['status']=4;
  1612. // }
  1613. }
  1614. }
  1615. }
  1616. $rolename ['name'] = '';
  1617. if (! empty ( $roleId )) {
  1618. Doo::loadModel ( 'role' );
  1619. $role = new role ();
  1620. $rolename = $role->getOne ( array (
  1621. 'where' => 'rid=' . $roleId,
  1622. 'asArray' => true
  1623. ) );
  1624. }
  1625. if (! empty ( $verifyStaff ))
  1626. $endStaffArray = end ( $verifyStaff );
  1627. $KOP = false;
  1628. foreach ( $roleArrayCopy as $P => $A ) {
  1629. foreach ( $A as $MKI => $AVL ) {
  1630. if (! empty ( $verifyStaff )) {
  1631. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1632. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1633. $button = 4;
  1634. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1635. }
  1636. foreach ( $verifyStaff as $m => $u ) {
  1637. $AVLFK = $AVL [0] . '_R';
  1638. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1639. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1640. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1641. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1642. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1643. break;
  1644. }
  1645. }
  1646. } else {
  1647. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1648. $button = 4;
  1649. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1650. }
  1651. }
  1652. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1653. $KOP = true;
  1654. }
  1655. }
  1656. foreach ( $roleArrayCopy as $k => $v ) {
  1657. foreach ( $verifyList as $m => $n ) {
  1658. if ($n [0] == $k) {
  1659. array_splice ( $verifyList, $m, 1, $v );
  1660. }
  1661. }
  1662. }
  1663. $receiptList [$key] ['verifyList'] = $verifyList;
  1664. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1665. 'where' => 'sid=' . $value ['staff'],
  1666. 'asArray' => true
  1667. ) );
  1668. $receiptList [$key] ['button'] = $button;
  1669. //
  1670. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1671. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1672. }
  1673. $data ['receiptList'] = $receiptList;
  1674. $acItem = $accountItem->find ( array (
  1675. 'asArray' => true
  1676. ) );
  1677. $veList = $verify->find ( array (
  1678. 'asArray' => true
  1679. ) );
  1680. foreach ( $veList as $key => $value ) {
  1681. $v = json_decode ( $value ['staff'] );
  1682. $list = array ();
  1683. foreach ( $v as $n => $m ) {
  1684. if ($m ['1'] == 'ROLE') {
  1685. $roleInfo = $role->getOne ( array (
  1686. 'where' => 'rid=' . $m [0],
  1687. 'asArray' => true
  1688. ) );
  1689. $v [$n] [1] = $roleInfo ['name'];
  1690. array_push ( $list, $roleInfo ['name'] );
  1691. } else {
  1692. array_push ( $list, $v [$n] [1] );
  1693. }
  1694. }
  1695. $veList [$key] ['staff'] = implode ( '>', $list );
  1696. }
  1697. // 配置编辑信息
  1698. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1699. foreach ( $acItem as $key => $value ) {
  1700. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1701. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1702. $acItem [$key] ['price'] = $v ['price'];
  1703. }
  1704. }
  1705. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1706. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1707. $acItem [$key] ['price'] = $v ['price'];
  1708. }
  1709. }
  1710. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1711. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1712. $acItem [$key] ['price'] = $v ['price'];
  1713. }
  1714. }
  1715. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1716. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1717. $acItem [$key] ['price'] = $v ['price'];
  1718. }
  1719. }
  1720. }
  1721. $data ['category'] = $Lcategory->find ( array (
  1722. 'asArray' => true
  1723. ) );
  1724. $data ['ridKey'] = $ridKey;
  1725. $data ['cSum'] = $accountItemList ['cSum'];
  1726. $data ['sum'] = $receiptDetail ['sum'];
  1727. $data ['receiptDetail'] = $receiptDetail;
  1728. $data ['veList'] = $veList;
  1729. $data ['acItem'] = $acItem;
  1730. $data ['memu'] = "receipt";
  1731. $data ['staff'] = $this->staff;
  1732. $data ['receiptMemu'] = 'saeaBorad';
  1733. $data ['verify'] = $receiptDetail ['verify'];
  1734. $data ['verifyId'] = $this->verifyId;
  1735. $data ['executeId'] = $this->executeId;
  1736. $data ['rid'] = $rid;
  1737. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1738. }
  1739. /**
  1740. * 培训班结算
  1741. */
  1742. function receiptTrainAdd() {
  1743. Doo::loadModel ( 'accountItem' );
  1744. $accountItem = new accountItem ();
  1745. $acItem = $accountItem->find ( array (
  1746. 'asArray' => true
  1747. ) );
  1748. // 审批组
  1749. Doo::loadModel ( 'verify' );
  1750. $verify = new verify ();
  1751. $veList = $verify->getVerifyBySubordinate('TRAIN');
  1752. // 办事处
  1753. Doo::loadModel ( 'L_category' );
  1754. $lCategory = new L_category ();
  1755. $data ['category'] = $lCategory->getCategory ();
  1756. $data ['veList'] = $veList;
  1757. $data ['memu'] = "receipt";
  1758. $data ['staff'] = $this->staff;
  1759. $data ['acItem'] = $acItem;
  1760. $data ['receiptMemu'] = 'saeaBorad';
  1761. $data ['verifyId'] = $this->verifyId;
  1762. $data ['executeId'] = $this->executeId;
  1763. $this->render ( "/receipt/receiptTrainAdd", $data );
  1764. }
  1765. /**
  1766. * 添加培训班结算
  1767. */
  1768. function receiptTrainAddDo() {//include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  1769. // 培训班信息
  1770. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  1771. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  1772. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  1773. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  1774. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  1775. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  1776. // 发票信息
  1777. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1778. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  1779. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1780. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1781. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1782. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1783. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1784. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $participants ) && ! empty ( $trainAddress )) {
  1785. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1786. header ( 'Content-Type:text/html;charset=utf-8' );
  1787. die ( '请填写联行号' );
  1788. }
  1789. Doo::loadModel ( 'execute' );
  1790. $execute = new execute ();
  1791. $executeDetail = $execute->getOne ( array (
  1792. 'where' => 'mold="培训班结算"',
  1793. 'asArray' => true
  1794. ) );
  1795. if (empty ( $executeDetail )) {
  1796. header ( 'Content-Type:text/html;charset=utf-8' );
  1797. die ( '未设置执行人' );
  1798. }
  1799. Doo::loadClass ( 'XDeode' );
  1800. $XDeode = new XDeode ( 5 );
  1801. $cid = $XDeode->decode ( $cid );
  1802. Doo::loadModel ( 'receipt' );
  1803. $receipt = new receipt ();
  1804. Doo::loadModel ( 'receiptTraining' );
  1805. $receiptTraining = new receiptTraining ();
  1806. // 创建费用培训班
  1807. $item = array (
  1808. 'cid' => $this->staff [0] ['cid'],
  1809. 'categoryName' => $this->staff [0] ['category'],
  1810. 'trainName' => $trainName,
  1811. 'trainStartDate' => $trainStartDate,
  1812. 'trainEndDate' => $trainEndDate,
  1813. 'participants' => $participants,
  1814. 'trainAddress' => $trainAddress,
  1815. 'trainRemarks' => $trainRemarks,
  1816. 'creator' => $this->staff [0] ['sid'],
  1817. 'creatorDate' => date ( "Y-m-d H:i:s" )
  1818. );
  1819. $irid = $receiptTraining->addReceiptTraining ( $item );
  1820. // 报销单
  1821. $receipt->status = 5;
  1822. $receipt->trainId = $irid;
  1823. $receipt->Rtype = 3;
  1824. $receipt->staff = $this->staff [0] ['sid'];
  1825. $receipt->cid = $cid;
  1826. $receipt->verify = $verify;
  1827. $receipt->date = date ( "Y-m-d" );
  1828. $receipt->executeCopy = $executeDetail ['staff'];
  1829. $receipt->receiptOrder = "#P" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1830. $receipt->remittanceName = $remittanceName;
  1831. $receipt->bankName = $bankName;
  1832. $receipt->bankNumber = $bankNumber;
  1833. $receipt->remittanceBankType = $remittanceBankType;
  1834. if ($remittanceBankType == 1)
  1835. $receipt->coupletNumber = $coupletNumber;
  1836. $rid = $receipt->insert ();
  1837. $XDeode = new XDeode ( 7 );
  1838. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html";
  1839. } else
  1840. die ( 'illegal request' );
  1841. }
  1842. /**
  1843. * 培训班编辑
  1844. */
  1845. function receiptTrainEdi() {
  1846. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  1847. $trainEdiType = $this->get_args ( 'trainEdiType' ) ? $this->get_args ( 'trainEdiType' ) : "INFO";
  1848. Doo::loadClass ( 'XDeode' );
  1849. $XDeode = new XDeode ( 7 );
  1850. $rid = $XDeode->decode ( $ridKey );
  1851. if (! is_numeric ( $rid ))
  1852. die ( 'illegal request' );
  1853. Doo::loadModel ( 'receipt' );
  1854. $receipt = new receipt ();
  1855. Doo::loadModel ( 'receiptTraining' );
  1856. $receiptTraining = new receiptTraining ();
  1857. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  1858. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)){
  1859. die ('illegal request--status');
  1860. }
  1861. //如有已入账已收款的发票,自动取消办事处已收款
  1862. // Doo::loadModel ( 'RIExtend' );
  1863. // $RIExtend = new RIExtend ();
  1864. // $RIExtendList=$RIExtend->getRIExtendByRid($rid);
  1865. // if (!empty($RIExtendList)){
  1866. // foreach ($RIExtendList as $key=>$value){
  1867. // $RIExtend = new RIExtend ();
  1868. // $RIExtend->delete(array (
  1869. // 'where' => 'iid=' . $value['iid'],
  1870. // 'limit' => 1
  1871. // ));
  1872. // }
  1873. // }
  1874. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  1875. // 汇总表合计
  1876. // 收入合计--加入开票合计
  1877. Doo::loadModel ( 'invoiceTraining' );
  1878. $invoiceTraining = new invoiceTraining ();
  1879. $invoiceTrainingDetail = array (
  1880. 'invoiceArriveAmount' => 0,
  1881. 'RIAmount' => 0,
  1882. 'invoiceTotalAmount' => 0,
  1883. 'invoiceCompanyAmount'=>0
  1884. );
  1885. if ($receiptDetail ['invoiceTrainId'] != 0) {
  1886. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  1887. }
  1888. // print_r($invoiceTrainingDetail);
  1889. $invoiceArriveAmount = $RIAmount = 0;
  1890. if (! empty ( $invoiceTrainingDetail )) {
  1891. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  1892. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  1893. }
  1894. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  1895. //print_r($invoiceTrainingDetail);
  1896. // 支出项目
  1897. Doo::loadModel ( 'accountItem' );
  1898. $accountItem = new accountItem ();
  1899. // 项目金额合计
  1900. Doo::loadModel ( 'RItem' );
  1901. $RItem = new RItem ();
  1902. // 讲师获得
  1903. Doo::loadModel ( 'RILecturer' );
  1904. $RILecturer = new RILecturer ();
  1905. $RItemList = $RItem->getRItemByRid ( $rid );
  1906. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  1907. // 支出项金额详情
  1908. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  1909. // print_r($aiData);
  1910. // 利润
  1911. $profit=$invoiceArriveAmount - $aiData ['total'];
  1912. $companyProfit=$profit * 0.6;
  1913. $categoryProfit=$profit * 0.4;
  1914. $data ['profit'] = sprintf("%.2f",$profit);
  1915. $data ['companyProfit'] = sprintf("%.2f",$companyProfit);
  1916. $data ['categoryProfit'] = sprintf("%.2f",$categoryProfit);
  1917. //发票利润
  1918. $data ['invoiceProfit'] = $invoiceTrainingDetail ['invoiceTotalAmount'] - $aiData ['total'];
  1919. //发票公司利润
  1920. $invoiceCompanyProfit=$data ['invoiceProfit'] * 0.6;
  1921. $data ['invoiceCompanyProfit'] = sprintf("%.2f",$invoiceCompanyProfit);
  1922. //办事处利润
  1923. $invoiceCategoryProfit=$data ['invoiceProfit'] * 0.4;
  1924. $data ['invoiceCategoryProfit'] = sprintf("%.2f",$invoiceCategoryProfit);
  1925. // print_r($aiData['dataList']);
  1926. $categoryActualExpenditure= $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  1927. $data ['categoryActualExpenditure'] = sprintf("%.2f",$categoryActualExpenditure);
  1928. // 备用金
  1929. $sum = 0;
  1930. $data ['receiptLoanDetail'] = array (
  1931. 'sum' => '0.00'
  1932. );
  1933. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  1934. $data ['receiptLoanDetail'] = $receipt->getReceiptByRid ( $receiptDetail ['trainLoanRid'] );
  1935. $sum = $data ['receiptLoanDetail'] ['sum'];
  1936. }
  1937. $payment=$sum + $RIAmount - $categoryActualExpenditure;
  1938. $data ['payment'] = sprintf("%.2f",$payment);
  1939. $data ['total'] = sprintf("%.2f",$aiData ['total']);
  1940. $data ['aiCount'] = count ( $aiData ['dataList'] ) + 5;
  1941. $data ['aiList'] = $aiData ['dataList'];
  1942. // 占比计算
  1943. if ($invoiceArriveAmount != 0) {
  1944. $data ['totalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceArriveAmount* 100) ;
  1945. $data ['profitProportion'] = sprintf("%.2f",$profit / $invoiceArriveAmount*100) ; //number_format ( $profit / $invoiceArriveAmount, 2, '.', '' ) * 100;
  1946. $data ['sumProportion'] = sprintf("%.2f",$sum / $invoiceArriveAmount*100) ; //number_format ( $sum / $invoiceArriveAmount, 2, '.', '' ) * 100;
  1947. $data ['invoiceTotalAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceArriveAmount*100) ;
  1948. $data ['RIAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceArriveAmount*100) ;
  1949. $data ['companyProfitProportion'] = sprintf("%.2f",$companyProfit / $invoiceArriveAmount*100) ;
  1950. $data ['categoryProportion'] = sprintf("%.2f",$categoryProfit / $invoiceArriveAmount*100) ;
  1951. $data ['categoryActualExpenditureProportion'] = sprintf("%.2f",$categoryActualExpenditure / $invoiceArriveAmount*100) ;
  1952. $data ['paymentProportion'] = sprintf("%.2f",$payment / $invoiceArriveAmount*100) ;
  1953. } else {
  1954. $data ['totalProportion'] = $data ['profitProportion'] = $data ['sumProportion'] = $data ['invoiceTotalAmountProportion'] = $data ['RIAmountProportion'] = $data ['companyProfitProportion'] = $data ['categoryActualExpenditureProportion'] = $data ['paymentProportion'] = $data ['categoryProportion'] = 0;
  1955. }
  1956. //发票金额占比计算
  1957. if ($invoiceTrainingDetail ['invoiceTotalAmount'] != 0) {
  1958. //支出
  1959. $data ['invoicetotalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  1960. //利润
  1961. $data ['invoiceprofitProportion'] = sprintf("%.2f",$data ['invoiceProfit'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  1962. //公司利润
  1963. $data ['invoicecompanyProfitProportion'] = sprintf("%.2f", $invoiceCompanyProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  1964. //办事处利润
  1965. $data ['invoicecategoryProportion'] = sprintf("%.2f", $invoiceCategoryProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  1966. //公司收款
  1967. $data ['invoiceTotalAmountProportionB'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  1968. //备用金
  1969. $data ['invoicesumProportion'] = sprintf("%.2f", $sum / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  1970. //办事处收款
  1971. $data ['invoiceRIAmountProportion'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  1972. //办事处实际支出
  1973. $data ['ICAEP'] = sprintf("%.2f", $categoryActualExpenditure / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  1974. //付总部款
  1975. $data ['invoicepaymentProportion'] = sprintf("%.2f", $payment / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  1976. }else{
  1977. $data ['invoiceprofitProportion'] =$data ['invoiceRIAmountProportion'] =$data ['invoicetotalProportion'] =$data ['invoiceTotalAmountProportionB'] =$data ['invoicesumProportion'] =$data ['ICAEP'] =$data ['invoicepaymentProportion'] =$data ['invoicecompanyProfitProportion'] =$data ['invoicecategoryProportion'] =0;
  1978. }
  1979. //讲师人数
  1980. Doo::loadModel ( 'RILecturer' );
  1981. $RILecturer = new RILecturer ();
  1982. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  1983. $data['lectureCount']=count($RILecturerList);
  1984. // 审批组
  1985. Doo::loadModel ( 'verify' );
  1986. $verify = new verify ();
  1987. $veList = $verify->getVerifyBySubordinate('TRAIN');
  1988. // 办事处
  1989. Doo::loadModel ( 'L_category' );
  1990. $lCategory = new L_category ();
  1991. $data ['category'] = $lCategory->getCategory ();
  1992. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  1993. $data ['receiptDetail'] = $receiptDetail;
  1994. $data ['veList'] = $veList;
  1995. $data ['trainEdiType'] = $trainEdiType;
  1996. $data ['ridKey'] = $ridKey;
  1997. $data ['memu'] = "receipt";
  1998. $data ['staff'] = $this->staff;
  1999. $data ['receiptMemu'] = 'saeaBorad';
  2000. $data ['verifyId'] = $this->verifyId;
  2001. $data ['executeId'] = $this->executeId;
  2002. $this->render ( "/receipt/receiptTrainEdi", $data );
  2003. }
  2004. /**
  2005. * 培训班借款编辑
  2006. */
  2007. function receiptTrainLoanEdi() {
  2008. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2009. Doo::loadClass ( 'XDeode' );
  2010. $XDeode = new XDeode ( 7 );
  2011. $rid = $XDeode->decode ( $ridKey );
  2012. if (! is_numeric ( $rid ))
  2013. die ( 'illegal request' );
  2014. Doo::loadModel ( 'receipt' );
  2015. $receipt = new receipt ();
  2016. Doo::loadModel ( 'receiptTraining' );
  2017. $receiptTraining = new receiptTraining ();
  2018. Doo::loadModel ( 'verify' );
  2019. $verify = new verify ();
  2020. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2021. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  2022. die ();
  2023. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2024. // 借款详情HTML
  2025. // 获得借款信息
  2026. $receiptLoanHtml = '';
  2027. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  2028. $receiptLoanDetail = $receipt->getReceiptByRid ( $receiptDetail ['trainLoanRid'] );
  2029. // 获得某费用单审批信息
  2030. $verifylist = $verify->getVerifyByRid ( $receiptDetail ['trainLoanRid'] );
  2031. Doo::loadClass ( 'receipt.func' );
  2032. $extendHtml = '<p><a class="button" href="javascript:if(window.confirm(\'确认移除?\'))window.location=\'/receiptTrainLoanRemoveDo/' . $receiptDetail ['ridKey'] . '/' . $receiptDetail ['trainLoanRidKey'] . '.html\'" data-toggle="modal">移除借款</a></p>';
  2033. $receiptLoanHtml = _getReceiptLoanHtml ( $receiptLoanDetail, $verifylist, $extendHtml );
  2034. }
  2035. $data ['receiptLoanHtml'] = $receiptLoanHtml;
  2036. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2037. $data ['receiptDetail'] = $receiptDetail;
  2038. $data ['trainEdiType'] = "LOAN";
  2039. $data ['ridKey'] = $ridKey;
  2040. $data ['memu'] = "receipt";
  2041. $data ['staff'] = $this->staff;
  2042. $data ['receiptMemu'] = 'saeaBorad';
  2043. $data ['verifyId'] = $this->verifyId;
  2044. $data ['executeId'] = $this->executeId;
  2045. $this->render ( "/receipt/receiptTrainLoanEdi", $data );
  2046. }
  2047. /**
  2048. * 更新培训班结算基本信息
  2049. */
  2050. function receiptTrainInfoEdiDo() {
  2051. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  2052. $rtid = $this->get_args ( 'rtid' ) ? $this->get_args ( 'rtid' ) : "";
  2053. // 培训班信息
  2054. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  2055. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  2056. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  2057. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  2058. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  2059. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  2060. // 发票信息
  2061. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2062. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2063. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2064. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2065. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2066. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2067. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2068. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $participants ) && ! empty ( $trainAddress )) {
  2069. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2070. header ( 'Content-Type:text/html;charset=utf-8' );
  2071. die ( '请填写联行号' );
  2072. }
  2073. Doo::loadClass ( 'XDeode' );
  2074. $XDeode = new XDeode ( 5 );
  2075. $cid = $XDeode->decode ( $cid );
  2076. $rtid = $XDeode->decode ( $rtid );
  2077. $rid = $XDeode->decode ( $rid );
  2078. if (! is_numeric ( $rtid ) || ! is_numeric ( $rid )) {
  2079. die ( 'illegal request-IdError' );
  2080. }
  2081. Doo::loadModel ( 'receipt' );
  2082. $receipt = new receipt ();
  2083. Doo::loadModel ( 'receiptTraining' );
  2084. $receiptTraining = new receiptTraining ();
  2085. // 更新费用培训班
  2086. $item = array (
  2087. 'rtid' => $rtid,
  2088. 'trainName' => $trainName,
  2089. 'trainStartDate' => $trainStartDate,
  2090. 'trainEndDate' => $trainEndDate,
  2091. 'participants' => $participants,
  2092. 'trainAddress' => $trainAddress,
  2093. 'trainRemarks' => $trainRemarks
  2094. );
  2095. $irid = $receiptTraining->setReceiptTrainByCondition ( $item );
  2096. // 报销单
  2097. $receipt->rid = $rid;
  2098. $receipt->cid = $cid;
  2099. $receipt->verify = $verify;
  2100. $receipt->remittanceName = $remittanceName;
  2101. $receipt->bankName = $bankName;
  2102. $receipt->bankNumber = $bankNumber;
  2103. $receipt->remittanceBankType = $remittanceBankType;
  2104. if ($remittanceBankType == 1)
  2105. $receipt->coupletNumber = $coupletNumber;
  2106. $receipt->update ();
  2107. $XDeode = new XDeode ( 7 );
  2108. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html?trainEdiType=INFO";
  2109. } else
  2110. die ( 'illegal request' );
  2111. }
  2112. /**
  2113. * 编辑培训班结算---更新借款
  2114. */
  2115. function receiptTrainLoanEdiDo() {
  2116. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2117. $ridLoanKey = $this->get_args ( 'ridLoanKey' ) ? $this->get_args ( 'ridLoanKey' ) : "";
  2118. if (! empty ( $ridKey ) && ! empty ( $ridLoanKey )) {
  2119. Doo::loadModel ( 'receipt' );
  2120. $receipt = new receipt ();
  2121. Doo::loadClass ( 'XDeode' );
  2122. $XDeode = new XDeode ( 5 );
  2123. $rid = $XDeode->decode ( $ridKey );
  2124. $ridLoan = $XDeode->decode ( $ridLoanKey );
  2125. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  2126. die ( 'illegal request-ridError' );
  2127. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2128. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  2129. // 不合法的数据if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  2130. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2131. die ( 'illegal request-receiptError' );
  2132. }
  2133. if ($receiptLoanDetail ['status'] != 8 || $receiptLoanDetail ['Rtype'] != 1) {
  2134. die ( 'illegal request-receipLoantError' );
  2135. }
  2136. // 培训班结算挂钩借款
  2137. $receipt = new receipt ();
  2138. $item = array (
  2139. 'rid' => $rid,
  2140. 'trainLoanRid' => $ridLoan
  2141. );
  2142. $receipt->setReceiptByCondition ( $item );
  2143. // 更新借款状态变成已挂钩
  2144. $receipt = new receipt ();
  2145. $item = array (
  2146. 'rid' => $ridLoan,
  2147. 'status' => 10,
  2148. 'statusTrain' => 1
  2149. );
  2150. $receipt->setReceiptByCondition ( $item );
  2151. $XDeode = new XDeode ( 7 );
  2152. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  2153. } else
  2154. die ( 'illegal request' );
  2155. }
  2156. /**
  2157. * 编辑培训班结算--移除借款
  2158. */
  2159. function receiptTrainLoanRemoveDo() {
  2160. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : 0;
  2161. $ridLoanKey = isset ( $this->params ['ridLoanKey'] ) ? $this->params ['ridLoanKey'] : 0;
  2162. if (! empty ( $ridKey ) || ! empty ( $ridLoanKey )) {
  2163. Doo::loadModel ( 'receipt' );
  2164. $receipt = new receipt ();
  2165. Doo::loadClass ( 'XDeode' );
  2166. $XDeode = new XDeode ( 5 );
  2167. $rid = $XDeode->decode ( $ridKey );
  2168. $ridLoan = $XDeode->decode ( $ridLoanKey );
  2169. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  2170. die ( 'illegal request-ridError' );
  2171. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2172. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  2173. // 不合法的数据 !($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)
  2174. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2175. die ( 'illegal request-receiptError' );
  2176. }
  2177. if ($receiptLoanDetail ['status'] != 10 || $receiptLoanDetail ['Rtype'] != 1) {
  2178. die ( 'illegal request-receipLoantError' );
  2179. }
  2180. // 培训班结算挂钩借款
  2181. $receipt = new receipt ();
  2182. $item = array (
  2183. 'rid' => $rid,
  2184. 'trainLoanRid' => 0
  2185. );
  2186. $receipt->setReceiptByCondition ( $item );
  2187. // 更新借款状态变成已挂钩
  2188. $receipt = new receipt ();
  2189. $item = array (
  2190. 'rid' => $ridLoan,
  2191. 'status' => 8,
  2192. 'statusTrain' => 0
  2193. );
  2194. $receipt->setReceiptByCondition ( $item );
  2195. $XDeode = new XDeode ( 7 );
  2196. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  2197. } else
  2198. die ( 'illegal request' );
  2199. }
  2200. /**
  2201. * 编辑培训班结算 ---开票
  2202. */
  2203. function receiptTrainInvoiceEdi() {
  2204. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2205. Doo::loadClass ( 'XDeode' );
  2206. $XDeode = new XDeode ( 7 );
  2207. $rid = $XDeode->decode ( $ridKey );
  2208. if (! is_numeric ( $rid ))
  2209. die ( 'illegal request' );
  2210. Doo::loadModel ( 'receipt' );
  2211. $receipt = new receipt ();
  2212. Doo::loadModel ( 'receiptTraining' );
  2213. $receiptTraining = new receiptTraining ();
  2214. Doo::loadModel ( 'invoice' );
  2215. $invoice = new invoice ();
  2216. Doo::loadModel ( 'invoiceTraining' );
  2217. $invoiceTraining = new invoiceTraining ();
  2218. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2219. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  2220. die ();
  2221. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2222. $invoiceList = $invoiceTrainingDetail = array ();
  2223. if ($receiptDetail ['invoiceTrainId'] != 0) {
  2224. $invoiceList = $invoice->getInvoicePrintedByItid ( $receiptDetail ['invoiceTrainId'] );
  2225. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  2226. }
  2227. //print_r($invoiceList);
  2228. $data ['invoiceList'] = $invoiceList;
  2229. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  2230. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2231. $data ['receiptDetail'] = $receiptDetail;
  2232. $data ['trainEdiType'] = "INVOICE";
  2233. $data ['ridKey'] = $ridKey;
  2234. $data ['memu'] = "receipt";
  2235. $data ['staff'] = $this->staff;
  2236. $data ['receiptMemu'] = 'saeaBorad';
  2237. $data ['verifyId'] = $this->verifyId;
  2238. $data ['executeId'] = $this->executeId;
  2239. $this->render ( "/receipt/receiptTrainInvoiceEdi", $data );
  2240. }
  2241. /**
  2242. * 编辑培训班结算---更新开票
  2243. */
  2244. function receiptTrainInvoiceEdiDo() {
  2245. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2246. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : "";
  2247. if (! empty ( $ridKey ) && ! empty ( $itidKey )) {
  2248. Doo::loadModel ( 'receipt' );
  2249. $receipt = new receipt ();
  2250. Doo::loadModel ( 'invoiceTraining' );
  2251. $invoiceTraining = new invoiceTraining ();
  2252. Doo::loadClass ( 'XDeode' );
  2253. $XDeode = new XDeode ( 5 );
  2254. $rid = $XDeode->decode ( $ridKey );
  2255. $itid = $XDeode->decode ( $itidKey );
  2256. if (! is_numeric ( $rid ) || ! is_numeric ( $itid ))
  2257. die ( 'illegal request-idError' );
  2258. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2259. $invoiceTrainDetail = $invoiceTraining->getInvoiceTrainingByItid ( $itid );
  2260. // 不合法的数据
  2261. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2262. die ( 'illegal request-receiptError' );
  2263. }
  2264. if (empty ( $invoiceTrainDetail ) || $invoiceTrainDetail ['bindReceipt'] == 1) {
  2265. die ( 'illegal request-receipLoantError' );
  2266. }
  2267. // 培训班结算挂钩借款
  2268. $receipt = new receipt ();
  2269. $item = array (
  2270. 'rid' => $rid,
  2271. 'invoiceTrainId' => $itid
  2272. );
  2273. $receipt->setReceiptByCondition ( $item );
  2274. $invoiceTraining = new invoiceTraining ();
  2275. $item = array (
  2276. 'bindReceipt' => 1,
  2277. 'itid' => $itid
  2278. );
  2279. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  2280. $XDeode = new XDeode ( 7 );
  2281. return "/receiptTrainInvoiceEdi/" . $XDeode->encode ( $rid ) . ".html";
  2282. } else
  2283. die ( 'illegal request' );
  2284. }
  2285. /**
  2286. * 更新培训班结算 收款和取消收款
  2287. */
  2288. function receiptTrainReceivables() {
  2289. $doType = isset ( $this->params ['doType'] ) ? $this->params ['doType'] : '';
  2290. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2291. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  2292. Doo::loadClass ( 'XDeode' );
  2293. $XDeode = new XDeode ( 5 );
  2294. $rid = $XDeode->decode ( $ridKey );
  2295. $iid = $XDeode->decode ( $iidKey );
  2296. if (! is_numeric ( $rid ) || ! is_numeric ( $iid ))
  2297. die ( 'illegal request-iid' );
  2298. Doo::loadModel ( 'RIExtend' );
  2299. $RIExtend = new RIExtend ();
  2300. if ($doType == 'CONFIRM') {
  2301. $RIExtend->rid = $rid;
  2302. $RIExtend->iid = $iid;
  2303. $RIExtend->RIstatus = 1;
  2304. $RIExtend->insert ();
  2305. echo json_encode ( array (
  2306. 'status' => 1,
  2307. ) );
  2308. die ( );
  2309. } elseif ($doType == 'CANCEL') {
  2310. $RIExtend->delete ( array (
  2311. 'where' => 'rid=' . $rid . ' and iid=' . $iid,
  2312. 'limit' => 1
  2313. ) );
  2314. echo json_encode ( array (
  2315. 'status' => 1,
  2316. ) );
  2317. die ( );
  2318. } else {
  2319. echo json_encode ( array (
  2320. 'status' => 2,
  2321. ) );
  2322. die ( );
  2323. }
  2324. }
  2325. /**
  2326. * 移除挂钩的培训班发票
  2327. */
  2328. function receiptTrainReceivablesDelDo() {
  2329. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  2330. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : ""; // 发票培训班
  2331. Doo::loadModel ( 'receipt' );
  2332. $receipt = new receipt ();
  2333. Doo::loadModel ( 'RIExtend' );
  2334. $RIExtend = new RIExtend ();
  2335. Doo::loadClass ( 'XDeode' );
  2336. $XDeode = new XDeode ( 5 );
  2337. $rid = $XDeode->decode ( $ridKey );
  2338. $itid = $XDeode->decode ( $itidKey );
  2339. if (is_numeric ( $rid ) && is_numeric ( $itid )) {
  2340. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2341. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  2342. die ( 'illegal request-status' );
  2343. }
  2344. $receipt = new receipt ();
  2345. $receipt->rid = $rid;
  2346. $receipt->invoiceTrainId = 0;
  2347. $receipt->update ();
  2348. Doo::loadModel ( 'invoiceTraining' );
  2349. $invoiceTraining = new invoiceTraining ();
  2350. $item = array (
  2351. 'bindReceipt' => 0,
  2352. 'itid' => $itid
  2353. );
  2354. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  2355. $RIExtend->delete ( array (
  2356. 'where' => 'rid=' . $rid
  2357. ) );
  2358. $XDeode = new XDeode ( 7 );
  2359. return '/receiptTrainInvoiceEdi/' . $XDeode->encode ( $rid ) . '.html';
  2360. } else
  2361. die ( 'illegal request-iid' );
  2362. }
  2363. /**
  2364. * 编辑培训班结算
  2365. */
  2366. function receiptTrainItemEdi() {
  2367. //include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  2368. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2369. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : '';
  2370. Doo::loadClass ( 'XDeode' );
  2371. $XDeode = new XDeode ( 7 );
  2372. $rid = $XDeode->decode ( $ridKey );
  2373. if (! is_numeric ( $rid ))
  2374. die ( 'illegal request' );
  2375. Doo::loadModel ( 'receipt' );
  2376. $receipt = new receipt ();
  2377. Doo::loadModel ( 'receiptTraining' );
  2378. $receiptTraining = new receiptTraining ();
  2379. Doo::loadModel ( 'RItem' );
  2380. $RItem = new RItem ();
  2381. Doo::loadModel ( 'accountItem' );
  2382. $accountItem = new accountItem ();
  2383. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2384. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  2385. die ();
  2386. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2387. $RItemList = $RItem->getRItemByRid ( $rid,$name );
  2388. $aiList = $accountItem->getAccountBookByCategory ( '培训班费用' );//print_r($aiList);
  2389. // foreach ($aiList as $key=>$value){//不需要添加税款,在添加收入时自动添加
  2390. // if($value['name']=='税款'){
  2391. // unset($aiList[$key]);break;
  2392. // }
  2393. // }
  2394. //print_r($RItemList);
  2395. $data ['name'] = $name;
  2396. $data ['RItemList'] = $RItemList;
  2397. $data ['aiList'] = $aiList;
  2398. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2399. $data ['receiptDetail'] = $receiptDetail;
  2400. $data ['trainEdiType'] = "ITEM";
  2401. $data ['ridKey'] = $ridKey;
  2402. $data ['memu'] = "receipt";
  2403. $data ['staff'] = $this->staff;
  2404. $data ['receiptMemu'] = 'saeaBorad';
  2405. $data ['verifyId'] = $this->verifyId;
  2406. $data ['executeId'] = $this->executeId;
  2407. $this->render ( "/receipt/receiptTrainItemEdi", $data );
  2408. }
  2409. /**
  2410. * 添加支出项 需要修改 费用金额合计
  2411. */
  2412. function receiptTrainItemAddDo() {
  2413. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2414. // 支出项信息
  2415. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  2416. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : 0;
  2417. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  2418. $inputer = $this->get_args ( 'inputer' ) ? $this->get_args ( 'inputer' ) : "";
  2419. $describe = $this->get_args ( 'describe' ) ? $this->get_args ( 'describe' ) : "";
  2420. $payType = isset ( $this->params ['payType'] ) ? $this->params ['payType'] : '';
  2421. if (! empty ( $ridKey ) && ! empty ( $item ) && is_numeric( $price ) && ! empty ( $date ) && ! empty ( $inputer )) {
  2422. Doo::loadClass ( 'XDeode' );
  2423. $XDeode = new XDeode ( 5 );
  2424. Doo::loadModel ( 'RItem' );
  2425. $RItem = new RItem ();
  2426. $rid = $XDeode->decode ( $ridKey );
  2427. if (! is_numeric ( $rid )){
  2428. die ( 'illegal request' );
  2429. }
  2430. Doo::loadModel ( 'receiptDetail' );
  2431. $receiptDetail = new receiptDetail ();
  2432. Doo::loadModel ( 'receipt' );
  2433. $receipt = new receipt ();
  2434. $order = array (
  2435. "\r\n",
  2436. "\n",
  2437. "\r"
  2438. );
  2439. $replace = '<br/>';
  2440. $describe = str_replace ( $order, $replace, $describe );
  2441. $itemData = array (
  2442. 'rid' => $rid,
  2443. 'item' => $item,
  2444. 'price' => $price,
  2445. 'date' => $date,
  2446. 'inputer' => $inputer,
  2447. 'describe' => $describe,
  2448. 'creater' => $this->staff['0']['username'],
  2449. 'createrId' => $this->staff['0']['sid'],
  2450. 'creatDate' => date ( "Y-m-d H:i:s" )
  2451. );
  2452. if($payType=='company'){
  2453. $itemData += array (
  2454. 'payType' => 1
  2455. );
  2456. }
  2457. $RItem->addRItem($itemData, $receipt, $receiptDetail, $rid, $item, $price, $payType);
  2458. $XDeode = new XDeode ( 7 );
  2459. if($payType=='company'){
  2460. return '/receiptTrainItem/approval/' . $XDeode->encode ( $rid ) . '.html';
  2461. }else{
  2462. return '/receiptTrainItemEdi/' . $XDeode->encode ( $rid ) . '.html';
  2463. }
  2464. } else
  2465. die ( 'illegal request-dataError' );
  2466. }
  2467. /**
  2468. * 培训班结算-讲师
  2469. */
  2470. function receiptTrainLecturerEdi() {
  2471. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2472. Doo::loadClass ( 'XDeode' );
  2473. $XDeode = new XDeode ( 7 );
  2474. $rid = $XDeode->decode ( $ridKey );
  2475. if (! is_numeric ( $rid ))
  2476. die ( 'illegal request' );
  2477. Doo::loadModel ( 'receipt' );
  2478. $receipt = new receipt ();
  2479. Doo::loadModel ( 'receiptTraining' );
  2480. $receiptTraining = new receiptTraining ();
  2481. Doo::loadModel ( 'RILecturer' );
  2482. $RILecturer = new RILecturer ();
  2483. Doo::loadModel ( 'lecturer' );
  2484. $lecturer = new lecturer ();
  2485. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2486. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  2487. die ();
  2488. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2489. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2490. $lecturerList = $lecturer->getLecturerAll ();
  2491. $INSIDEhtml = $OUTSIDEhtml = '';
  2492. foreach ( $lecturerList as $key => $value ) {
  2493. if ($value ['ltype'] == 'INSIDE') {
  2494. $INSIDEhtml .= '<option value="' . $value ['category'] . '-' . $value ['staff'] . '">' . $value ['category'] . '-' . $value ['staff'] . '</option>';
  2495. } elseif ($value ['ltype'] == 'OUTSIDE') {
  2496. $OUTSIDEhtml .= '<option value="' . $value ['staff'] . '">' . $value ['staff'] . '</option>';
  2497. }
  2498. }
  2499. $data ['INSIDEhtml'] = $INSIDEhtml;
  2500. $data ['OUTSIDEhtml'] = $OUTSIDEhtml;
  2501. // print_r($RItemList);
  2502. $data ['RILecturerList'] = $RILecturerList;
  2503. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2504. $data ['receiptDetail'] = $receiptDetail;
  2505. $data ['trainEdiType'] = "LECTURER";
  2506. $data ['ridKey'] = $ridKey;
  2507. $data ['memu'] = "receipt";
  2508. $data ['staff'] = $this->staff;
  2509. $data ['receiptMemu'] = 'saeaBorad';
  2510. $data ['verifyId'] = $this->verifyId;
  2511. $data ['executeId'] = $this->executeId;
  2512. $this->render ( "/receipt/receiptTrainLecturerEdi", $data );
  2513. }
  2514. /**
  2515. * 添加讲师
  2516. */
  2517. function receiptTrainLecturerAddDo() {
  2518. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2519. // 支出项信息
  2520. $ltype = $this->get_args ( 'ltype' ) ? $this->get_args ( 'ltype' ) : "";
  2521. $lecturerName = $this->get_args ( 'lecturerName' ) ? $this->get_args ( 'lecturerName' ) : "";
  2522. $schoolDay = $this->get_args ( 'schoolDay' ) ? $this->get_args ( 'schoolDay' ) : "";
  2523. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  2524. $taxation = $this->get_args ( 'taxation' ) ? $this->get_args ( 'taxation' ) : "";
  2525. if (! empty ( $ridKey ) && ! empty ( $ltype ) && ! empty ( $lecturerName ) && ! empty ( $schoolDay ) && ! empty ( $price )) {
  2526. Doo::loadClass ( 'XDeode' );
  2527. $XDeode = new XDeode ( 5 );
  2528. Doo::loadModel ( 'RILecturer' );
  2529. $RILecturer = new RILecturer ();
  2530. $rid = $XDeode->decode ( $ridKey );
  2531. if (! is_numeric ( $rid ))
  2532. die ( 'illegal request' );
  2533. if ($ltype == 'OUTSIDE' && empty ( $taxation ))
  2534. die ( 'illegal request-taxationError' );
  2535. $RILecturer->rid = $rid;
  2536. $RILecturer->ltype = $ltype;
  2537. if ($ltype == 'OUTSIDE') {
  2538. if ($taxation == 'TAXATION') {
  2539. $RILecturer->taxation = 1;
  2540. } elseif ($taxation == 'NOTAXATION') {
  2541. $RILecturer->taxation = 0;
  2542. }
  2543. }
  2544. $RILecturer->lecturerName = $lecturerName;
  2545. $RILecturer->schoolDay = $schoolDay;
  2546. $RILecturer->price = $price;
  2547. $RILecturer->insert ();
  2548. // 添加公司汇总
  2549. // 报销详情
  2550. Doo::loadModel ( 'receiptDetail' );
  2551. $receiptDetail = new receiptDetail ();
  2552. Doo::loadModel ( 'receipt' );
  2553. $receipt = new receipt ();
  2554. // 金额总计
  2555. $price = $price * $schoolDay;
  2556. $rInfo = $receipt->getReceiptByRid ( $rid );
  2557. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  2558. if (empty ( $rdInfo )) {
  2559. $receiptDetail = new receiptDetail ();
  2560. $receiptDetail->staff = $rInfo ['staff'];
  2561. $receiptDetail->item = '讲课费';
  2562. $receiptDetail->itemCategory = '培训班费用';
  2563. $receiptDetail->price = number_format ( $price, 2, '.', '' );
  2564. $receiptDetail->date = date ( "Y-m-d" );
  2565. $receiptDetail->cid = $rInfo ['cid'];
  2566. $receiptDetail->rid = $rid;
  2567. $receiptDetail->status = 4;
  2568. $receiptDetail->insert ();
  2569. } else {
  2570. $receiptDetail = new receiptDetail ();
  2571. $rdInfo ['price'] += $price;
  2572. $receiptDetail->price = $rdInfo ['price'];
  2573. $receiptDetail->update ( array (
  2574. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  2575. ) );
  2576. }
  2577. $receipt = new receipt ();
  2578. $receipt->sum=$rInfo['sum']+$price;
  2579. $receipt->update ( array (
  2580. 'where' => 'rid=' . $rid
  2581. ) );
  2582. $XDeode = new XDeode ( 7 );
  2583. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  2584. } else
  2585. die ( 'illegal request' );
  2586. }
  2587. /**
  2588. * 移除讲师
  2589. */
  2590. function receiptTrainLecturerDelDo() {
  2591. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  2592. $rlidKey = $this->get_args ( 'rlidKey' ) ? $this->get_args ( 'rlidKey' ) : ""; // 发票培训班
  2593. Doo::loadModel ( 'receipt' );
  2594. $receipt = new receipt ();
  2595. Doo::loadModel ( 'RILecturer' );
  2596. $RILecturer = new RILecturer ();
  2597. Doo::loadClass ( 'XDeode' );
  2598. $XDeode = new XDeode ( 5 );
  2599. $rid = $XDeode->decode ( $ridKey );
  2600. $rlid = $XDeode->decode ( $rlidKey );
  2601. if (is_numeric ( $rid ) && is_numeric ( $rlid )) {
  2602. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2603. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  2604. die ( 'illegal request-status' );
  2605. }
  2606. $detail=$RILecturer->getRILecturerByRlid($rlid);
  2607. if (empty($detail)){
  2608. die ( 'illegal request-data' );
  2609. }
  2610. $RILecturer->delete ( array (
  2611. 'where' => 'rid=' . $rid . ' and rlid=' . $rlid
  2612. ) );
  2613. //更新费用合计金额
  2614. $rInfo = $receipt->getReceiptByRid ( $rid );
  2615. $receipt = new receipt ();
  2616. $receipt->sum= $receiptDetail['sum']-$detail['price'];
  2617. $receipt->update ( array (
  2618. 'where' => 'rid=' . $rid
  2619. ) );
  2620. Doo::loadModel ( 'receiptDetail' );
  2621. $receiptDetail = new receiptDetail ();
  2622. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  2623. $receiptDetail = new receiptDetail ();
  2624. $rdInfo ['price'] -= number_format ( $detail['price'], 2, '.', '' );
  2625. $receiptDetail->price = $rdInfo ['price'];
  2626. $receiptDetail->update ( array (
  2627. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  2628. ) );
  2629. $XDeode = new XDeode ( 7 );
  2630. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  2631. } else
  2632. die ( 'illegal request-iid' );
  2633. }
  2634. /**
  2635. * 培训班提交审批
  2636. */
  2637. function receiptTrainDo() {
  2638. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2639. Doo::loadClass ( 'XDeode' );
  2640. $XDeode = new XDeode ( 7 );
  2641. $rid = $XDeode->decode ( $ridKey );
  2642. Doo::loadModel ( 'receipt' );
  2643. $receipt = new receipt ();
  2644. Doo::loadModel ( 'receiptDetail' );
  2645. $receiptDetail = new receiptDetail ();
  2646. Doo::loadModel ( 'statistics' );
  2647. $statistics = new statistics ();
  2648. Doo::loadModel ( "verify" );
  2649. $verify = new verify ();
  2650. // 审批状态的判定
  2651. $receiptDetailList = $receipt->getOne ( array (
  2652. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  2653. 'asArray' => true
  2654. ) );
  2655. if (empty ( $receiptDetailList ))
  2656. return "/saeaBorad";
  2657. $verifyDetail = $verify->getOne ( array (
  2658. 'where' => ' vid =' . $receiptDetailList ['verify'],
  2659. 'asArray' => true
  2660. ) );
  2661. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  2662. if (empty ( $receiptDetailList ['nowStaff'] )) {
  2663. $nowStaff = "";
  2664. $nowStaffList = array ();
  2665. if ($verifyDetail [0] [1] == 'ROLE') {
  2666. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  2667. foreach ( $vStaffString as $key => $value ) {
  2668. $staffK = explode ( "_", $value );
  2669. array_push ( $nowStaffList, $staffK [0] );
  2670. }
  2671. $nowStaff = implode ( ',', $nowStaffList );
  2672. } else {
  2673. $nowStaff = $verifyDetail [0] [0];
  2674. }
  2675. $receipt->nowStaff = $nowStaff;
  2676. }
  2677. // echo $nowStaff;
  2678. // print_r($verifyDetail);die;
  2679. $receipt->rid = $receiptDetailList ['rid'];
  2680. $receipt->date = date ( "Y-m-d" );
  2681. $receipt->status = 2;
  2682. $receipt->update ();
  2683. $receiptDetail->status = 2;
  2684. $receiptDetail->update ( array (
  2685. 'where' => 'rid=' . $receiptDetailList ['rid']
  2686. ) );
  2687. Doo::loadModel ( "receiptLog" );
  2688. $receiptLog = new receiptLog ();
  2689. Doo::loadModel ( "verify" );
  2690. $verify = new verify ();
  2691. $vr = $verify->getOne ( array (
  2692. 'where' => 'vid=' . $receiptDetailList ['verify'],
  2693. 'asArray' => true
  2694. ) );
  2695. $jd = json_decode ( $vr ['staff'] );
  2696. $roleId = 0;
  2697. foreach ( $jd as $key => $value ) {
  2698. if ($value [1] == 'ROLE') {
  2699. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  2700. if ($pos !== false) {
  2701. $roleId = $value [0];
  2702. }
  2703. }
  2704. }
  2705. // 审批日志
  2706. // echo $roleId;die;
  2707. if (! empty ( $roleId )) {
  2708. Doo::loadModel ( "role" );
  2709. $role = new role ();
  2710. $roleInfo = $role->getOne ( array (
  2711. 'where' => 'rid=' . $roleId,
  2712. 'asArray' => true
  2713. ) );
  2714. // $receiptLog->rolename = $roleInfo ['name'];
  2715. }
  2716. $receiptLog->username = $this->staff [0] ['username'];
  2717. $receiptLog->uid = $this->staff [0] ['sid'];
  2718. $receiptLog->date = date ( "Y-m-d" );
  2719. $receiptLog->opinion = '提交审批';
  2720. $receiptLog->img = $this->staff [0] ['avatar'];
  2721. $receiptLog->status = 2;
  2722. $receiptLog->rid = $rid;
  2723. $receiptLog->insert ();
  2724. // 写入列表项
  2725. Doo::loadModel ( 'accountItem' );
  2726. $accountItem = new accountItem ();
  2727. $aItem = $accountItem->getAccountBookByCategory ( '培训班费用' );
  2728. // 项目金额合计
  2729. Doo::loadModel ( 'RItem' );
  2730. $RItem = new RItem ();
  2731. // 讲师获得
  2732. Doo::loadModel ( 'RILecturer' );
  2733. $RILecturer = new RILecturer ();
  2734. $RItemList = $RItem->getRItemByRid ( $rid );
  2735. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2736. // 支出项金额详情
  2737. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, 0 );
  2738. // print_r($aItem);
  2739. // print_r($aiData);
  2740. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  2741. $ag = $tr = $ta = $ot = 0;
  2742. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  2743. foreach ( $aItem as $key => $value ) {
  2744. if ($value ['category'] == $this->TRAIN) {
  2745. foreach ( $aiData ['dataList'] as $k => $v ) {
  2746. if ($value ['name'] == $v ['name']) {
  2747. array_push ( $accountJson [$this->TRAIN], array (
  2748. 'aid' => $value ['aid'],
  2749. 'name' => $value ['name'],
  2750. 'price' => number_format ( $v ['price'], 2, '.', '' )
  2751. ) );
  2752. $sum += $v ['price'];
  2753. $trainSum += $v ['price'];
  2754. unset ( $aiData ['dataList'] [$k] );
  2755. break;
  2756. }
  2757. }
  2758. }
  2759. }
  2760. $accountJson ['cSum'] = array (
  2761. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  2762. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  2763. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  2764. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  2765. );
  2766. // 报销单
  2767. $receipt = new receipt ();
  2768. $receipt->accountItem = json_encode ( $accountJson );
  2769. $receipt->sum = number_format ( $sum, 2, '.', '' );
  2770. $receipt->update ( array (
  2771. 'where' => 'rid=' . $rid
  2772. ) );
  2773. // print_r($accountJson);
  2774. // statistics item 统计写入
  2775. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  2776. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  2777. $accountItem = $accountJson;
  2778. $stat = $statistics->getOne ( array (
  2779. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  2780. 'asArray' => true
  2781. ) );
  2782. if (empty ( $stat )) {
  2783. $statistics->date = date ( "Y-m-d" );
  2784. $statistics->cid = $this->staff [0] ['cid'];
  2785. $statistics->staff = $this->staff [0] ['sid'];
  2786. $statistics->agPrice = 0;
  2787. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  2788. $statistics->insert ();
  2789. } else {
  2790. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  2791. $statistics->update ( array (
  2792. 'where' => 'sid=' . $stat ['sid']
  2793. ) );
  2794. }
  2795. return "/saeaBorad";
  2796. }
  2797. function confirmation() {
  2798. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2799. Doo::loadModel ( 'receipt' );
  2800. Doo::loadModel ( 'receiptDetail' );
  2801. $receipt = new receipt ();
  2802. $receiptDetail = new receiptDetail ();
  2803. Doo::loadModel ( 'statistics' );
  2804. Doo::loadModel ( 'itemStatistics' );
  2805. $statistics = new statistics ();
  2806. $itemStatistics = new itemStatistics ();
  2807. Doo::loadModel ( "verify" );
  2808. $verify = new verify ();
  2809. $receiptDetailList = $receipt->getOne ( array (
  2810. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  2811. 'asArray' => true
  2812. ) );
  2813. if (empty ( $receiptDetailList ))
  2814. return "/saeaBorad";
  2815. $verifyDetail = $verify->getOne ( array (
  2816. 'where' => ' vid =' . $receiptDetailList ['verify'],
  2817. 'asArray' => true
  2818. ) );
  2819. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  2820. if (empty ( $receiptDetailList ['nowStaff'] )) {
  2821. $nowStaff = "";
  2822. $nowStaffList = array ();
  2823. if ($verifyDetail [0] [1] == 'ROLE') {
  2824. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  2825. foreach ( $vStaffString as $key => $value ) {
  2826. $staffK = explode ( "_", $value );
  2827. array_push ( $nowStaffList, $staffK [0] );
  2828. }
  2829. $nowStaff = implode ( ',', $nowStaffList );
  2830. } else {
  2831. $nowStaff = $verifyDetail [0] [0];
  2832. }
  2833. $receipt->nowStaff = $nowStaff;
  2834. }
  2835. // echo $nowStaff;
  2836. // print_r($verifyDetail);die;
  2837. $receipt->rid = $receiptDetailList ['rid'];
  2838. $receipt->status = 2;
  2839. $receipt->update ();
  2840. // 操作日志
  2841. Doo::loadModel ( "receiptLog" );
  2842. $receiptLog = new receiptLog ();
  2843. $verify = new verify ();
  2844. $receiptInfo = $receipt->getOne ( array (
  2845. 'where' => 'rid=' . $rid,
  2846. 'asArray' => true
  2847. ) );
  2848. $vr = $verify->getOne ( array (
  2849. 'where' => 'vid=' . $receiptInfo ['verify'],
  2850. 'asArray' => true
  2851. ) );
  2852. $jd = json_decode ( $vr ['staff'] );
  2853. $roleId = 0;
  2854. foreach ( $jd as $key => $value ) {
  2855. if ($value [1] == 'ROLE') {
  2856. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  2857. if ($pos !== false) {
  2858. $roleId = $value [0];
  2859. }
  2860. }
  2861. }
  2862. // 审批日志
  2863. // echo $roleId;die;
  2864. if (! empty ( $roleId )) {
  2865. Doo::loadModel ( "role" );
  2866. $role = new role ();
  2867. $roleInfo = $role->getOne ( array (
  2868. 'where' => 'rid=' . $roleId,
  2869. 'asArray' => true
  2870. ) );
  2871. // $receiptLog->rolename = $roleInfo ['name'];
  2872. }
  2873. $receiptLog->username = $this->staff [0] ['username'];
  2874. $receiptLog->uid = $this->staff [0] ['sid'];
  2875. $receiptLog->date = date ( "Y-m-d" );
  2876. $receiptLog->opinion = '提交审批';
  2877. $receiptLog->img = $this->staff [0] ['avatar'];
  2878. $receiptLog->status = 2;
  2879. $receiptLog->rid = $rid;
  2880. $receiptLog->insert ();
  2881. return "/expenses";
  2882. }
  2883. function expenses() {
  2884. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  2885. if (empty ( $item ))
  2886. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  2887. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  2888. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  2889. Doo::loadClass ( 'XDeode' );
  2890. $XDeode = new XDeode ( 7 );
  2891. Doo::loadModel ( 'receipt' );
  2892. $receipt = new receipt ();
  2893. Doo::loadModel ( 'L_category' );
  2894. $Lcategory = new L_category ();
  2895. Doo::loadModel ( 'verify' );
  2896. Doo::loadModel ( 'statistics' );
  2897. $statistics = new statistics ();
  2898. $verify = new verify ();
  2899. Doo::loadModel ( 'staff' );
  2900. $staff = new staff ();
  2901. $condition = "";
  2902. if ($item == "expenses")
  2903. $condition = " and Rtype=1 ";
  2904. elseif ($item == "receipts")
  2905. $condition = " and Rtype=0 ";
  2906. elseif ($item == "remits")
  2907. $condition = " and Rtype=2 ";
  2908. elseif ($item == "train")
  2909. $condition = " and Rtype=3 ";
  2910. $dateCondition = " and Year(date) =" . $year;
  2911. if (! empty ( $moth )) {
  2912. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  2913. $stList = $statistics->getOne ( array (
  2914. 'select' => 'rePrice ,agPrice',
  2915. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  2916. 'asArray' => true
  2917. ) );
  2918. } else
  2919. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  2920. if (empty ( $stList ))
  2921. $stList = array (
  2922. 'rePrice' => 0,
  2923. 'agPrice' => 0
  2924. );
  2925. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  2926. if (! isset ( $noPassSum ['sum'] ))
  2927. $noPassSum ['sum'] = 0;
  2928. $data ['stList'] = array (
  2929. 'rePrice' => $stList ['rePrice'],
  2930. 'agPrice' => $stList ['agPrice'],
  2931. 'skPrice' => ($noPassSum ['sum'])
  2932. );
  2933. $receiptList = $receipt->find ( array (
  2934. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  2935. 'desc' => 'rid',
  2936. 'asArray' => true
  2937. ) );
  2938. $Locate = 0;
  2939. $roleId = 0;
  2940. $button = 0;
  2941. foreach ( $receiptList as $key => $value ) {
  2942. $receiptList [$key] ['Locate'] = $Locate;
  2943. $Locate ++;
  2944. $receiptList [$key] ['reviseDetail'] = array ();
  2945. if (! empty ( $value ['reviseDetail'] ))
  2946. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2947. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2948. $categoryDetil = $Lcategory->getOne ( array (
  2949. 'where' => 'cid=' . $value ['cid'],
  2950. 'asArray' => true
  2951. ) );
  2952. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2953. // 检测编辑状态
  2954. $verifyList = $verify->getOne ( array (
  2955. 'where' => 'vid=' . $value ['verify'],
  2956. 'asArray' => true
  2957. ) );
  2958. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2959. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2960. Doo::loadModel ( 'role' );
  2961. $role = new role ();
  2962. $flag = true;
  2963. $roleKey = 0;
  2964. $endStaffArray = array ();
  2965. $roleArrayCopy = array ();
  2966. foreach ( $verifyList as $k => $v ) {
  2967. // init verifyStaff
  2968. if ($v [1] == 'ROLE') {
  2969. if (! empty ( $verifyStaff )) {
  2970. $endStaffArray = end ( $verifyStaff );
  2971. // if ($v[0]==$endStaffArray['nextStaff']){
  2972. // $roleId=$v[0];
  2973. // }
  2974. }
  2975. $roleVerify = json_decode ( $v [3], true );
  2976. $roleKey = $k;
  2977. $roleArray = array ();
  2978. $rolename = $role->getOne ( array (
  2979. 'where' => 'rid=' . $v [0],
  2980. 'asArray' => true
  2981. ) );
  2982. foreach ( $roleVerify as $o => $p ) {
  2983. $staffID = explode ( '_', $p );
  2984. $staffInfo = $staff->getOne ( array (
  2985. 'where' => 'sid=' . $staffID [0],
  2986. 'asArray' => true
  2987. ) );
  2988. // print_r($staffID);
  2989. $exp = array (
  2990. 0 => $staffInfo ['sid'],
  2991. 1 => $staffID [1],
  2992. 2 => $staffInfo ['avatar'],
  2993. 'date' => '',
  2994. 'date' => '',
  2995. 'opinion' => '',
  2996. 'status' => '',
  2997. 'rolename' => $rolename ['name']
  2998. );
  2999. array_push ( $roleArray, $exp );
  3000. }
  3001. $roleArrayCopy [$v [0]] = $roleArray;
  3002. // $verifyList[$k]['roleArray']=$roleArray;
  3003. }
  3004. $verifyList [$k] ['date'] = "";
  3005. $verifyList [$k] ['opinion'] = "";
  3006. $verifyList [$k] ['status'] = "";
  3007. if (empty ( $verifyStaff )) {
  3008. $verifyList [$k] ['date'] = "";
  3009. $verifyList [$k] ['opinion'] = "";
  3010. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3011. $verifyList [$k] ['status'] = 4;
  3012. $flag = false;
  3013. }
  3014. } else {
  3015. foreach ( $verifyStaff as $m => $u ) {
  3016. if ($v [0] == $m) {
  3017. $verifyList [$k] ['date'] = $u ['date'];
  3018. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3019. $verifyList [$k] ['status'] = $u ['status'];
  3020. $flag = false;
  3021. break;
  3022. }
  3023. }
  3024. $endStaffArray = end ( $verifyStaff );
  3025. if (isset ( $endStaffArray ['ROLE'] )) {
  3026. } else {
  3027. // $endKey=key($verifyStaff);
  3028. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3029. // $button=4;
  3030. // $verifyList[$k]['status']=4;
  3031. // }
  3032. }
  3033. }
  3034. }
  3035. $rolename ['name'] = '';
  3036. if (! empty ( $roleId )) {
  3037. Doo::loadModel ( 'role' );
  3038. $role = new role ();
  3039. $rolename = $role->getOne ( array (
  3040. 'where' => 'rid=' . $roleId,
  3041. 'asArray' => true
  3042. ) );
  3043. }
  3044. if (! empty ( $verifyStaff ))
  3045. $endStaffArray = end ( $verifyStaff );
  3046. $KOP = false;
  3047. foreach ( $roleArrayCopy as $P => $A ) {
  3048. foreach ( $A as $MKI => $AVL ) {
  3049. if (! empty ( $verifyStaff )) {
  3050. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3051. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3052. $button = 4;
  3053. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3054. }
  3055. foreach ( $verifyStaff as $m => $u ) {
  3056. $AVLFK = $AVL [0] . '_R';
  3057. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3058. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3059. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3060. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3061. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3062. break;
  3063. }
  3064. }
  3065. } else {
  3066. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3067. $button = 4;
  3068. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3069. }
  3070. }
  3071. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3072. $KOP = true;
  3073. }
  3074. }
  3075. foreach ( $roleArrayCopy as $k => $v ) {
  3076. foreach ( $verifyList as $m => $n ) {
  3077. if ($n [0] == $k) {
  3078. array_splice ( $verifyList, $m, 1, $v );
  3079. }
  3080. }
  3081. }
  3082. $receiptList [$key] ['verifyList'] = $verifyList;
  3083. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3084. 'where' => 'sid=' . $value ['staff'],
  3085. 'asArray' => true
  3086. ) );
  3087. $receiptList [$key] ['button'] = $button;
  3088. $receiptList [$key] ['ridKey'] =$XDeode->encode( $value ['rid'] );
  3089. }
  3090. // print_r($receiptList);die;
  3091. $mothHtml = "";
  3092. for($i = 1; $i <= 12; $i ++) {
  3093. if ($moth == $i)
  3094. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3095. else
  3096. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3097. }
  3098. $dateHtml = "";
  3099. $now = date ( "Y" );
  3100. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  3101. if ($YEARD <= $now) {
  3102. $dateHtml .= '<option ';
  3103. if ($year == $YEARD) {
  3104. $dateHtml .= 'selected ';
  3105. }
  3106. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  3107. }
  3108. }
  3109. $data ['dateHtml'] = $dateHtml;
  3110. $data ['mothHtml'] = $mothHtml;
  3111. $data ['receiptList'] = $receiptList;
  3112. $data ['memu'] = "receipt";
  3113. $data ['staff'] = $this->staff;
  3114. $data ['receiptMemu'] = 'expenses';
  3115. $data ['verifyId'] = $this->verifyId;
  3116. $data ['executeId'] = $this->executeId;
  3117. $data ['item'] = $item;
  3118. $data ['year'] = $year;
  3119. $this->render ( "/admin/expenses", $data );
  3120. }
  3121. function expensesCollect() {
  3122. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3123. Doo::loadModel ( 'receipt' );
  3124. $receipt = new receipt ();
  3125. Doo::loadModel ( 'L_category' );
  3126. $Lcategory = new L_category ();
  3127. Doo::loadModel ( 'verify' );
  3128. Doo::loadModel ( 'statistics' );
  3129. $statistics = new statistics ();
  3130. $verify = new verify ();
  3131. Doo::loadModel ( 'staff' );
  3132. $staff = new staff ();
  3133. Doo::loadModel ( 'loanReceipt' );
  3134. $loanReceipt = new loanReceipt ();
  3135. $receiptList = $receipt->find ( array (//去掉
  3136. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  3137. 'desc' => 'rid',
  3138. 'asArray' => true
  3139. ) );
  3140. $loanList = $loanReceipt->find ( array (
  3141. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3142. 'desc' => 'rid',
  3143. 'asArray' => true
  3144. ) );
  3145. /*
  3146. * $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;
  3147. */
  3148. $data ['explanation'] = '';
  3149. if (! empty ( $loanList ))
  3150. $data ['explanation'] = $loanList [0] ['explanation'];
  3151. $Locate = 0;
  3152. $roleId = 0;
  3153. $button = 0;
  3154. foreach ( $receiptList as $key => $value ) {
  3155. $receiptList [$key] ['Locate'] = $Locate;
  3156. $Locate ++;
  3157. $receiptList [$key] ['reviseDetail'] = array ();
  3158. if (! empty ( $value ['reviseDetail'] ))
  3159. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3160. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3161. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3162. $categoryDetil = $Lcategory->getOne ( array (
  3163. 'where' => 'cid=' . $value ['cid'],
  3164. 'asArray' => true
  3165. ) );
  3166. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3167. // 检测编辑状态
  3168. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  3169. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  3170. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  3171. else
  3172. $verifyList ['staff'] = $value ['verifyBreakup'];
  3173. } else
  3174. $verifyList = $verify->getOne ( array (
  3175. 'where' => 'vid=' . $value ['verify'],
  3176. 'asArray' => true
  3177. ) );
  3178. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3179. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3180. Doo::loadModel ( 'role' );
  3181. $role = new role ();
  3182. $flag = true;
  3183. $roleKey = 0;
  3184. $endStaffArray = array ();
  3185. $roleArrayCopy = array ();
  3186. foreach ( $verifyList as $k => $v ) {
  3187. // init verifyStaff
  3188. if ($v [1] == 'ROLE') {
  3189. if (! empty ( $verifyStaff )) {
  3190. $endStaffArray = end ( $verifyStaff );
  3191. // if ($v[0]==$endStaffArray['nextStaff']){
  3192. // $roleId=$v[0];
  3193. // }
  3194. }
  3195. $roleVerify = json_decode ( $v [3], true );
  3196. $roleKey = $k;
  3197. $roleArray = array ();
  3198. $rolename = $role->getOne ( array (
  3199. 'where' => 'rid=' . $v [0],
  3200. 'asArray' => true
  3201. ) );
  3202. foreach ( $roleVerify as $o => $p ) {
  3203. $staffID = explode ( '_', $p );
  3204. $staffInfo = $staff->getOne ( array (
  3205. 'where' => 'sid=' . $staffID [0],
  3206. 'asArray' => true
  3207. ) );
  3208. // print_r($staffID);
  3209. $exp = array (
  3210. 0 => $staffInfo ['sid'],
  3211. 1 => $staffID [1],
  3212. 2 => $staffInfo ['avatar'],
  3213. 'date' => '',
  3214. 'date' => '',
  3215. 'opinion' => '',
  3216. 'status' => '',
  3217. 'rolename' => $rolename ['name']
  3218. );
  3219. array_push ( $roleArray, $exp );
  3220. }
  3221. $roleArrayCopy [$v [0]] = $roleArray;
  3222. // $verifyList[$k]['roleArray']=$roleArray;
  3223. }
  3224. $verifyList [$k] ['date'] = "";
  3225. $verifyList [$k] ['opinion'] = "";
  3226. $verifyList [$k] ['status'] = "";
  3227. if (empty ( $verifyStaff )) {
  3228. $verifyList [$k] ['date'] = "";
  3229. $verifyList [$k] ['opinion'] = "";
  3230. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3231. $verifyList [$k] ['status'] = 4;
  3232. $flag = false;
  3233. }
  3234. } else {
  3235. foreach ( $verifyStaff as $m => $u ) {
  3236. if ($v [0] == $m) {
  3237. $verifyList [$k] ['date'] = $u ['date'];
  3238. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3239. $verifyList [$k] ['status'] = $u ['status'];
  3240. $flag = false;
  3241. break;
  3242. }
  3243. }
  3244. $endStaffArray = end ( $verifyStaff );
  3245. if (isset ( $endStaffArray ['ROLE'] )) {
  3246. } else {
  3247. // $endKey=key($verifyStaff);
  3248. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3249. // $button=4;
  3250. // $verifyList[$k]['status']=4;
  3251. // }
  3252. }
  3253. }
  3254. }
  3255. $rolename ['name'] = '';
  3256. if (! empty ( $roleId )) {
  3257. Doo::loadModel ( 'role' );
  3258. $role = new role ();
  3259. $rolename = $role->getOne ( array (
  3260. 'where' => 'rid=' . $roleId,
  3261. 'asArray' => true
  3262. ) );
  3263. }
  3264. if (! empty ( $verifyStaff ))
  3265. $endStaffArray = end ( $verifyStaff );
  3266. $KOP = false;
  3267. foreach ( $roleArrayCopy as $P => $A ) {
  3268. foreach ( $A as $MKI => $AVL ) {
  3269. if (! empty ( $verifyStaff )) {
  3270. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3271. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3272. $button = 4;
  3273. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3274. }
  3275. foreach ( $verifyStaff as $m => $u ) {
  3276. $AVLFK = $AVL [0] . '_R';
  3277. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3278. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3279. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3280. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3281. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3282. break;
  3283. }
  3284. }
  3285. } else {
  3286. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3287. $button = 4;
  3288. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3289. }
  3290. }
  3291. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3292. $KOP = true;
  3293. }
  3294. }
  3295. foreach ( $roleArrayCopy as $k => $v ) {
  3296. foreach ( $verifyList as $m => $n ) {
  3297. if ($n [0] == $k) {
  3298. array_splice ( $verifyList, $m, 1, $v );
  3299. }
  3300. }
  3301. }
  3302. // 费用执行人相关数据
  3303. $executeCopy = json_decode ( $value ['executeCopy'], true );
  3304. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3305. foreach ( $executeCopy as $k => $v ) {
  3306. $executeCopy [$k] ['date'] = '';
  3307. $executeCopy [$k] ['opinion'] = '';
  3308. $executeCopy [$k] ['status'] = '';
  3309. if (! empty ( $executeStaff ))
  3310. foreach ( $executeStaff as $m => $u ) {
  3311. if ($v [0] == $m) {
  3312. $executeCopy [$k] ['date'] = $u ['date'];
  3313. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  3314. $executeCopy [$k] ['status'] = $u ['status'];
  3315. break;
  3316. }
  3317. }
  3318. }
  3319. $receiptList [$key] ['executeCopy'] = $executeCopy;
  3320. $receiptList [$key] ['verifyList'] = $verifyList;
  3321. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3322. 'where' => 'sid=' . $value ['staff'],
  3323. 'asArray' => true
  3324. ) );
  3325. $receiptList [$key] ['button'] = $button;
  3326. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3327. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3328. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  3329. $receiptList [$key] ['relust'] = $relust;
  3330. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  3331. }
  3332. Doo::loadModel ( 'enclosur' );
  3333. $enclosur = new enclosur ();
  3334. $enclosurList = $enclosur->find ( array (
  3335. 'where' => 'rid=' . $rid,
  3336. 'asArray' => true
  3337. ) );
  3338. $enclosurHtml = '';
  3339. foreach ( $enclosurList as $value ) {
  3340. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3341. }
  3342. $data ['enclosurHtml'] = $enclosurHtml;
  3343. // print_r($receiptList);
  3344. $data ['receiptList'] = $receiptList;
  3345. $data ['memu'] = "receipt";
  3346. $data ['staff'] = $this->staff;
  3347. $data ['receiptMemu'] = 'expenses';
  3348. $data ['verifyId'] = $this->verifyId;
  3349. $data ['executeId'] = $this->executeId;
  3350. $this->render ( "/admin/expensesCollect", $data );
  3351. }
  3352. function approvalExpenses() {
  3353. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  3354. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3355. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3356. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3357. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3358. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  3359. // echo $rdate;
  3360. if (empty ( $status ))
  3361. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3362. $page_size = 8;
  3363. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  3364. $vidList = array ();
  3365. $button = 0;
  3366. Doo::loadModel ( 'verify' );
  3367. $verify = new verify ();
  3368. Doo::loadModel ( 'receipt' );
  3369. $receipt = new receipt ();
  3370. Doo::loadModel ( 'staff' );
  3371. $staff = new staff ();
  3372. Doo::loadModel ( 'L_category' );
  3373. $Lcategory = new L_category ();
  3374. // user verify ID
  3375. $verifyDetail = $verify->find ( array (
  3376. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  3377. 'asArray' => true
  3378. ) );
  3379. foreach ( $verifyDetail as $key => $value ) {
  3380. array_push ( $vidList, $value ['vid'] );
  3381. }
  3382. $vid = implode ( ",", $vidList );
  3383. if (empty ( $verifyDetail ))
  3384. $vid = 0;
  3385. // if ($status==0)
  3386. // $dateCondition="";
  3387. // else
  3388. $dateCondition = " ";
  3389. // if (! empty ( $month ))
  3390. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  3391. if ($status == 'done' || $status == 'termination') {
  3392. if (! empty ( $year )) {
  3393. $dateCondition = " and Year(pastDate) =" . $year;
  3394. if (! empty ( $month ))
  3395. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  3396. }
  3397. } elseif ($status == 'finish') {
  3398. if (! empty ( $year )) {
  3399. $dateCondition = " and Year(pastDate) =" . $year;
  3400. if (! empty ( $month ))
  3401. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  3402. }
  3403. }
  3404. // date ( 'Y-m' )
  3405. // if (! empty ( $rdate ) && $status == 'done')
  3406. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  3407. // elseif (! empty ( $rdate ))
  3408. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  3409. $categoryList = $Lcategory->find ( array (
  3410. 'asArray' => true
  3411. ) );
  3412. $staffList = $staff->find ( array (
  3413. 'where' => 'cid=' . $cid,
  3414. 'asArray' => true
  3415. ) );
  3416. $cateCondition = "";
  3417. $staffCondition = "";
  3418. $approvalCondition = "";
  3419. if (! empty ( $cid )) {
  3420. $cateCondition = ' and cid=' . $cid;
  3421. }
  3422. if (! empty ( $sid )) {
  3423. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  3424. $cateCondition = "";
  3425. }
  3426. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  3427. if ($status == 'pendApproval') {
  3428. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  3429. }
  3430. if ($status == 'ongoing') {
  3431. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  3432. }
  3433. if ($status == 'done') {
  3434. $approvalCondition = ' and (status=8 or status=9 ) ';
  3435. }
  3436. if ($status == 'termination') {
  3437. $approvalCondition = " and status=3";
  3438. }
  3439. if ($status == 'finish') {
  3440. $approvalCondition = " and (status=1 or status=8 or status=9)";
  3441. }
  3442. $pageinfo ['page'] = array (
  3443. 'previous' => ''
  3444. );
  3445. if(!empty($receiptOrder)){
  3446. $pageinfo = $this->get_page ( "CLD_receipt", ' and receiptOrder like "%' . $receiptOrder . '%"', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  3447. $receiptList = $receipt->find ( array ( // $dateCondition
  3448. 'where' => 'receiptOrder like "%' . $receiptOrder . '%"',
  3449. 'desc' => 'rid',
  3450. 'asArray' => true
  3451. ) );
  3452. }else{
  3453. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  3454. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  3455. $receiptList = $receipt->find ( array ( // $dateCondition.
  3456. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  3457. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  3458. 'desc' => 'rid',
  3459. 'asArray' => true
  3460. ) );
  3461. } else {
  3462. $receiptList = $receipt->find ( array ( // $dateCondition
  3463. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  3464. 'desc' => 'rid',
  3465. 'asArray' => true
  3466. ) );
  3467. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  3468. }
  3469. }
  3470. $rLRes = $receipt->find ( array (
  3471. '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 . ')',
  3472. 'desc' => 'rid',
  3473. 'asArray' => true
  3474. ) );
  3475. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  3476. // print_r($receiptList);
  3477. Doo::loadClass ( 'XDeode' );
  3478. $XDeode = new XDeode ( 7 );
  3479. $Locate = 0;
  3480. $reportList = $reportCateList = array ();
  3481. foreach ( $receiptList as $key => $value ) {
  3482. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  3483. $receiptList [$key] ['Locate'] = $Locate;
  3484. $Locate ++;
  3485. $receiptList [$key] ['reviseDetail'] = array ();
  3486. if (! empty ( $value ['reviseDetail'] ))
  3487. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3488. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3489. $categoryDetil = $Lcategory->getOne ( array (
  3490. 'where' => 'cid=' . $value ['cid'],
  3491. 'asArray' => true
  3492. ) );
  3493. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3494. $verifyList = $verify->getOne ( array (
  3495. 'where' => 'vid=' . $value ['verify'],
  3496. 'asArray' => true
  3497. ) );
  3498. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3499. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3500. foreach ( $verifyList as $k => $v ) {
  3501. // init verifyStaff
  3502. $verifyList [$k] ['date'] = "";
  3503. $verifyList [$k] ['opinion'] = "";
  3504. $verifyList [$k] ['status'] = "";
  3505. if (empty ( $verifyStaff )) {
  3506. $verifyList [$k] ['date'] = "";
  3507. $verifyList [$k] ['opinion'] = "";
  3508. if ($v [0] == $this->staff [0] ['sid']) {
  3509. $verifyList [$k] ['status'] = 4;
  3510. $button = 4;
  3511. }
  3512. } else {
  3513. $flag = true;
  3514. foreach ( $verifyStaff as $m => $u ) {
  3515. if ($v [0] == $m) {
  3516. $verifyList [$k] ['date'] = $u ['date'];
  3517. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3518. $verifyList [$k] ['status'] = $u ['status'];
  3519. $flag = false;
  3520. break;
  3521. }
  3522. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  3523. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  3524. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  3525. }
  3526. if ($flag) { // 检测可编辑
  3527. if ($v [0] == $this->staff [0] ['sid']) {
  3528. $verifyList [$k] ['status'] = 4;
  3529. $button = 4;
  3530. }
  3531. }
  3532. }
  3533. }
  3534. $receiptList [$key] ['verifyList'] = $verifyList;
  3535. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3536. 'where' => 'sid=' . $value ['staff'],
  3537. 'asArray' => true
  3538. ) );
  3539. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  3540. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  3541. $receiptList [$key] ['button'] = $button;
  3542. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  3543. }
  3544. $reportList = array_unique ( $reportList );
  3545. $reportHtml = '';
  3546. foreach ( $reportList as $key => $value ) {
  3547. $v = explode ( "-", $value );
  3548. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  3549. }
  3550. // print_r($reportList)
  3551. $data ['reportHtml'] = $reportHtml;
  3552. $reportCateList = array_unique ( $reportCateList );
  3553. $reportCateHtml = '';
  3554. foreach ( $reportCateList as $key => $value ) {
  3555. $v = explode ( "-", $value );
  3556. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  3557. }
  3558. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  3559. $data ['reportCateHtml'] = $reportCateHtml;
  3560. // print_r($receiptList);die;
  3561. // $data['verifyDetail']=$verifyDetail;
  3562. $mothHtml = "";
  3563. for($i = 1; $i <= 12; $i ++) {
  3564. if ($month == $i)
  3565. $mothHtml .= '<option selected value="0' . $i . '">' . $i . '月</option>';
  3566. else
  3567. $mothHtml .= '<option value="0' . $i . '">' . $i . '月</option>';
  3568. }
  3569. $data ['mothHtml'] = $mothHtml;
  3570. $dateHtml = "";
  3571. $now = date ( "Y" );
  3572. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  3573. if ($YEARD <= $now) {
  3574. $dateHtml .= '<option ';
  3575. if ($year == $YEARD) {
  3576. $dateHtml .= 'selected ';
  3577. }
  3578. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  3579. }
  3580. }
  3581. $data ['dateHtml'] = $dateHtml;
  3582. $data ['page'] = $pageinfo;
  3583. $data ['receiptList'] = $receiptList;
  3584. $data ['receiptApprovalCount'] = count ( $rLRes );
  3585. $data ['status'] = $status;
  3586. $data ['year'] = $year;
  3587. $data ['month'] = $month;
  3588. $data ['categoryList'] = $categoryList;
  3589. $data ['staffList'] = $staffList;
  3590. $data ['cid'] = $cid;
  3591. $data ['sid'] = $sid;
  3592. // print_r($receiptList);
  3593. $data['receiptOrder']=$receiptOrder;
  3594. $data ['memu'] = "receipt";
  3595. $data ['staff'] = $this->staff;
  3596. $data ['receiptMemu'] = 'approvalExpenses';
  3597. $data ['verifyId'] = $this->verifyId;
  3598. $data ['executeId'] = $this->executeId;
  3599. $this->render ( "/admin/approvalExpenses", $data );
  3600. }
  3601. function expensesDoc() {
  3602. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3603. Doo::loadClass ( 'XDeode' );
  3604. $XDeode = new XDeode ( 5 );
  3605. if (! empty ( $rid ) && ! is_numeric ( $rid ))
  3606. $rid = $XDeode->decode ( $rid );
  3607. if (! is_numeric ( $rid ))
  3608. die ( 'illegal request' );
  3609. Doo::loadModel ( 'receipt' );
  3610. $receipt = new receipt ();
  3611. Doo::loadModel ( 'L_category' );
  3612. $Lcategory = new L_category ();
  3613. Doo::loadModel ( 'verify' );
  3614. Doo::loadModel ( 'statistics' );
  3615. $statistics = new statistics ();
  3616. $verify = new verify ();
  3617. Doo::loadModel ( 'staff' );
  3618. $staff = new staff ();
  3619. Doo::loadModel ( 'loanReceipt' );
  3620. $loanReceipt = new loanReceipt ();
  3621. $receiptList = $receipt->find ( array (
  3622. 'where' => ' rid=' . $rid,
  3623. 'desc' => 'rid',
  3624. 'asArray' => true
  3625. ) );
  3626. $loanList = array ();
  3627. if (! empty ( $receiptList ))
  3628. $loanList = $loanReceipt->find ( array (
  3629. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3630. 'desc' => 'rid',
  3631. 'asArray' => true
  3632. ) );
  3633. $Locate = 0;
  3634. $roleId = 0;
  3635. $button = 0;
  3636. foreach ( $loanList as $key => $value ) {
  3637. $loanList [$key] ['Locate'] = $Locate;
  3638. $Locate ++;
  3639. $loanList [$key] ['reviseDetail'] = array ();
  3640. if (! empty ( $value ['reviseDetail'] ))
  3641. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3642. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3643. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3644. $categoryDetil = $Lcategory->getOne ( array (
  3645. 'where' => 'cid=' . $value ['cid'],
  3646. 'asArray' => true
  3647. ) );
  3648. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3649. // 检测编辑状态
  3650. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  3651. $verifyList ['staff'] = $value ['verifyBreakup'];
  3652. else
  3653. $verifyList = $verify->getOne ( array (
  3654. 'where' => 'vid=' . $value ['verify'],
  3655. 'asArray' => true
  3656. ) );
  3657. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3658. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3659. Doo::loadModel ( 'role' );
  3660. $role = new role ();
  3661. $flag = true;
  3662. $roleKey = 0;
  3663. $endStaffArray = array ();
  3664. $roleArrayCopy = array ();
  3665. foreach ( $verifyList as $k => $v ) {
  3666. // init verifyStaff
  3667. if ($v [1] == 'ROLE') {
  3668. if (! empty ( $verifyStaff )) {
  3669. $endStaffArray = end ( $verifyStaff );
  3670. // if ($v[0]==$endStaffArray['nextStaff']){
  3671. // $roleId=$v[0];
  3672. // }
  3673. }
  3674. $roleVerify = json_decode ( $v [3], true );
  3675. $roleKey = $k;
  3676. $roleArray = array ();
  3677. $rolename = $role->getOne ( array (
  3678. 'where' => 'rid=' . $v [0],
  3679. 'asArray' => true
  3680. ) );
  3681. foreach ( $roleVerify as $o => $p ) {
  3682. $staffID = explode ( '_', $p );
  3683. $staffInfo = $staff->getOne ( array (
  3684. 'where' => 'sid=' . $staffID [0],
  3685. 'asArray' => true
  3686. ) );
  3687. // print_r($staffID);
  3688. $exp = array (
  3689. 0 => $staffInfo ['sid'],
  3690. 1 => $staffID [1],
  3691. 2 => $staffInfo ['avatar'],
  3692. 'date' => '',
  3693. 'date' => '',
  3694. 'opinion' => '',
  3695. 'status' => '',
  3696. 'rolename' => $rolename ['name']
  3697. );
  3698. array_push ( $roleArray, $exp );
  3699. }
  3700. $roleArrayCopy [$v [0]] = $roleArray;
  3701. // $verifyList[$k]['roleArray']=$roleArray;
  3702. }
  3703. $verifyList [$k] ['date'] = "";
  3704. $verifyList [$k] ['opinion'] = "";
  3705. $verifyList [$k] ['status'] = "";
  3706. if (empty ( $verifyStaff )) {
  3707. $verifyList [$k] ['date'] = "";
  3708. $verifyList [$k] ['opinion'] = "";
  3709. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3710. $verifyList [$k] ['status'] = 4;
  3711. $flag = false;
  3712. }
  3713. } else {
  3714. foreach ( $verifyStaff as $m => $u ) {
  3715. if ($v [0] == $m) {
  3716. $verifyList [$k] ['date'] = $u ['date'];
  3717. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3718. $verifyList [$k] ['status'] = $u ['status'];
  3719. $flag = false;
  3720. break;
  3721. }
  3722. }
  3723. $endStaffArray = end ( $verifyStaff );
  3724. if (isset ( $endStaffArray ['ROLE'] )) {
  3725. } else {
  3726. // $endKey=key($verifyStaff);
  3727. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3728. // $button=4;
  3729. // $verifyList[$k]['status']=4;
  3730. // }
  3731. }
  3732. }
  3733. }
  3734. $rolename ['name'] = '';
  3735. if (! empty ( $roleId )) {
  3736. Doo::loadModel ( 'role' );
  3737. $role = new role ();
  3738. $rolename = $role->getOne ( array (
  3739. 'where' => 'rid=' . $roleId,
  3740. 'asArray' => true
  3741. ) );
  3742. }
  3743. if (! empty ( $verifyStaff ))
  3744. $endStaffArray = end ( $verifyStaff );
  3745. $KOP = false;
  3746. foreach ( $roleArrayCopy as $P => $A ) {
  3747. foreach ( $A as $MKI => $AVL ) {
  3748. if (! empty ( $verifyStaff )) {
  3749. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3750. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3751. $button = 4;
  3752. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3753. }
  3754. foreach ( $verifyStaff as $m => $u ) {
  3755. $AVLFK = $AVL [0] . '_R';
  3756. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3757. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3758. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3759. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3760. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3761. break;
  3762. }
  3763. }
  3764. } else {
  3765. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3766. $button = 4;
  3767. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3768. }
  3769. }
  3770. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3771. $KOP = true;
  3772. }
  3773. }
  3774. foreach ( $roleArrayCopy as $k => $v ) {
  3775. foreach ( $verifyList as $m => $n ) {
  3776. if ($n [0] == $k) {
  3777. array_splice ( $verifyList, $m, 1, $v );
  3778. }
  3779. }
  3780. }
  3781. $loanList [$key] ['verifyList'] = $verifyList;
  3782. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3783. 'where' => 'sid=' . $value ['staff'],
  3784. 'asArray' => true
  3785. ) );
  3786. $loanList [$key] ['button'] = $button;
  3787. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  3788. }
  3789. $data ['loanList'] = $loanList;
  3790. // print_r($loanList);
  3791. $Locate = 0;
  3792. $roleId = 0;
  3793. $button = 0;
  3794. foreach ( $receiptList as $key => $value ) {
  3795. $receiptList [$key] ['Locate'] = $Locate;
  3796. $Locate ++;
  3797. $receiptList [$key] ['reviseDetail'] = array ();
  3798. if (! empty ( $value ['reviseDetail'] ))
  3799. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3800. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3801. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3802. $categoryDetil = $Lcategory->getOne ( array (
  3803. 'where' => 'cid=' . $value ['cid'],
  3804. 'asArray' => true
  3805. ) );
  3806. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3807. // 检测编辑状态
  3808. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3809. $verifyList ['staff'] = $value ['verifyBreakup'];
  3810. } else
  3811. $verifyList = $verify->getOne ( array (
  3812. 'where' => 'vid=' . $value ['verify'],
  3813. 'asArray' => true
  3814. ) );
  3815. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3816. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3817. Doo::loadModel ( 'role' );
  3818. $role = new role ();
  3819. if ($verifyList == NULL)
  3820. $verifyList = array ();
  3821. $flag = true;
  3822. $roleKey = 0;
  3823. $endStaffArray = array ();
  3824. $roleArrayCopy = array ();
  3825. foreach ( $verifyList as $k => $v ) {
  3826. // init verifyStaff
  3827. if ($v [1] == 'ROLE') {
  3828. if (! empty ( $verifyStaff )) {
  3829. $endStaffArray = end ( $verifyStaff );
  3830. // if ($v[0]==$endStaffArray['nextStaff']){
  3831. // $roleId=$v[0];
  3832. // }
  3833. }
  3834. $roleVerify = json_decode ( $v [3], true );
  3835. $roleKey = $k;
  3836. $roleArray = array ();
  3837. $rolename = $role->getOne ( array (
  3838. 'where' => 'rid=' . $v [0],
  3839. 'asArray' => true
  3840. ) );
  3841. foreach ( $roleVerify as $o => $p ) {
  3842. $staffID = explode ( '_', $p );
  3843. $staffInfo = $staff->getOne ( array (
  3844. 'where' => 'sid=' . $staffID [0],
  3845. 'asArray' => true
  3846. ) );
  3847. // print_r($staffID);
  3848. $exp = array (
  3849. 0 => $staffInfo ['sid'],
  3850. 1 => $staffID [1],
  3851. 2 => $staffInfo ['avatar'],
  3852. 'date' => '',
  3853. 'date' => '',
  3854. 'opinion' => '',
  3855. 'status' => '',
  3856. 'rolename' => $rolename ['name']
  3857. );
  3858. array_push ( $roleArray, $exp );
  3859. }
  3860. $roleArrayCopy [$v [0]] = $roleArray;
  3861. // $verifyList[$k]['roleArray']=$roleArray;
  3862. }
  3863. $verifyList [$k] ['date'] = "";
  3864. $verifyList [$k] ['opinion'] = "";
  3865. $verifyList [$k] ['status'] = "";
  3866. if (empty ( $verifyStaff )) {
  3867. $verifyList [$k] ['date'] = "";
  3868. $verifyList [$k] ['opinion'] = "";
  3869. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3870. $verifyList [$k] ['status'] = 4;
  3871. $flag = false;
  3872. }
  3873. } else {
  3874. foreach ( $verifyStaff as $m => $u ) {
  3875. if ($v [0] == $m) {
  3876. $verifyList [$k] ['date'] = $u ['date'];
  3877. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3878. $verifyList [$k] ['status'] = $u ['status'];
  3879. $flag = false;
  3880. break;
  3881. }
  3882. }
  3883. $endStaffArray = end ( $verifyStaff );
  3884. if (isset ( $endStaffArray ['ROLE'] )) {
  3885. } else {
  3886. // $endKey=key($verifyStaff);
  3887. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3888. // $button=4;
  3889. // $verifyList[$k]['status']=4;
  3890. // }
  3891. }
  3892. }
  3893. }
  3894. $FC = @$rolename ['name'];
  3895. $rolename ['name'] = '';
  3896. if (! empty ( $roleId )) {
  3897. Doo::loadModel ( 'role' );
  3898. $role = new role ();
  3899. $rolename = $role->getOne ( array (
  3900. 'where' => 'rid=' . $roleId,
  3901. 'asArray' => true
  3902. ) );
  3903. }
  3904. if (! empty ( $verifyStaff ))
  3905. $endStaffArray = end ( $verifyStaff );
  3906. $KOP = false;
  3907. foreach ( $roleArrayCopy as $P => $A ) {
  3908. foreach ( $A as $MKI => $AVL ) {
  3909. if (! empty ( $verifyStaff )) {
  3910. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3911. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3912. $button = 4;
  3913. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3914. }
  3915. foreach ( $verifyStaff as $m => $u ) {
  3916. $AVLFK = $AVL [0] . '_R';
  3917. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3918. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3919. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3920. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3921. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3922. break;
  3923. }
  3924. }
  3925. } else {
  3926. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3927. $button = 4;
  3928. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3929. }
  3930. }
  3931. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3932. $KOP = true;
  3933. }
  3934. }
  3935. foreach ( $roleArrayCopy as $k => $v ) {
  3936. foreach ( $verifyList as $m => $n ) {
  3937. if ($n [0] == $k) {
  3938. array_splice ( $verifyList, $m, 1, $v );
  3939. }
  3940. }
  3941. }
  3942. // 费用执行人相关数据
  3943. $executeCopy = json_decode ( $value ['executeCopy'], true );
  3944. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3945. foreach ( $executeCopy as $k => $v ) {
  3946. $executeCopy [$k] ['date'] = '';
  3947. $executeCopy [$k] ['opinion'] = '';
  3948. $executeCopy [$k] ['status'] = '';
  3949. if (! empty ( $executeStaff ))
  3950. foreach ( $executeStaff as $m => $u ) {
  3951. if ($v [0] == $m) {
  3952. $executeCopy [$k] ['date'] = $u ['date'];
  3953. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  3954. $executeCopy [$k] ['status'] = $u ['status'];
  3955. break;
  3956. }
  3957. }
  3958. }
  3959. $receiptList [$key] ['executeCopy'] = $executeCopy;
  3960. // print_r($verifyList);
  3961. $receiptList [$key] ['verifyList'] = $verifyList;
  3962. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3963. 'where' => 'sid=' . $value ['staff'],
  3964. 'asArray' => true
  3965. ) );
  3966. $receiptList [$key] ['button'] = $button;
  3967. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3968. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3969. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  3970. $receiptList [$key] ['relust'] = $relust;
  3971. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  3972. }
  3973. // print_r($receiptList);
  3974. // 获取审批日志
  3975. Doo::loadModel ( 'receiptLog' );
  3976. $receiptLog = new receiptLog ();
  3977. $rlList = array ();
  3978. $rlInfo = $receiptLog->getOne ( array (
  3979. 'where' => 'rid=' . $rid . ' and status=4',
  3980. 'asArray' => true
  3981. ) );
  3982. $tijdate = $receiptLog->getOne ( array (
  3983. 'where' => 'rid=' . $rid . ' and status=2',
  3984. 'asc' => 'rlid',
  3985. 'asArray' => true
  3986. ) );
  3987. if (! empty ( $rlInfo )) {
  3988. $rlList = $receiptLog->find ( array (
  3989. 'where' => 'rid=' . $rid,
  3990. 'asc' => 'rlid',
  3991. 'asArray' => true
  3992. ) );
  3993. }
  3994. $RN = @json_decode ( $rolename ['staff'] );
  3995. //
  3996. foreach ( $rlList as $key => $value ) {
  3997. $rlList [$key] ['rolename'] = '';
  3998. foreach ( $RN as $k => $v ) {
  3999. $id = explode ( "_", $v );
  4000. if ($id [0] == $value ['uid']) {
  4001. $rlList [$key] ['rolename'] = $FC;
  4002. break;
  4003. }
  4004. }
  4005. }
  4006. Doo::loadModel ( 'enclosur' );
  4007. $enclosur = new enclosur ();
  4008. $enclosurList = $enclosur->find ( array (
  4009. 'where' => 'rid=' . $rid,
  4010. 'asArray' => true
  4011. ) );
  4012. $enclosurHtml = '';
  4013. foreach ( $enclosurList as $value ) {
  4014. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4015. }
  4016. $data ['enclosurHtml'] = $enclosurHtml;
  4017. $receiptList [0] ['rlList'] = $rlList;
  4018. $data ['receiptList'] = $receiptList;
  4019. // print_r($receiptList);
  4020. $data ['memu'] = "receipt";
  4021. $data ['staff'] = $this->staff;
  4022. $data ['receiptMemu'] = 'approvalExpenses';
  4023. $data ['verifyId'] = $this->verifyId;
  4024. $data ['executeId'] = $this->executeId;
  4025. $this->render ( "/admin/expensesDoc", $data );
  4026. }
  4027. function expensesEdi() {
  4028. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4029. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  4030. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4031. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4032. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4033. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4034. if (empty ( $status ))
  4035. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  4036. $vidList = array ();
  4037. $button = 0;
  4038. Doo::loadModel ( 'verify' );
  4039. Doo::loadModel ( 'receipt' );
  4040. Doo::loadModel ( 'staff' );
  4041. $staff = new staff ();
  4042. $receipt = new receipt ();
  4043. $verify = new verify ();
  4044. Doo::loadModel ( 'L_category' );
  4045. $Lcategory = new L_category ();
  4046. Doo::loadModel ( 'enclosur' );
  4047. $enclosur = new enclosur ();
  4048. // user verify ID
  4049. $verifyDetail = $verify->find ( array (
  4050. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  4051. 'asArray' => true
  4052. ) );
  4053. foreach ( $verifyDetail as $key => $value ) {
  4054. array_push ( $vidList, $value ['vid'] );
  4055. }
  4056. $vid = implode ( ",", $vidList );
  4057. if (empty ( $verifyDetail ))
  4058. $vid = 0;
  4059. $categoryList = $Lcategory->find ( array (
  4060. 'asArray' => true
  4061. ) );
  4062. $staffList = $staff->find ( array (
  4063. 'where' => 'cid=' . $cid,
  4064. 'asArray' => true
  4065. ) );
  4066. $ap = "";
  4067. if ($status == 4) {
  4068. $ap = 4;
  4069. $status = 2;
  4070. }
  4071. // get Receipt By verifyID status 2
  4072. $receiptList = $receipt->find ( array (
  4073. 'where' => 'rid =' . $rid . ' and status=2',
  4074. 'desc' => 'rid',
  4075. 'asArray' => true
  4076. ) );
  4077. if (empty ( $receiptList )) {
  4078. die ( 'illegal request' );
  4079. }
  4080. $Locate = 0;
  4081. $roleId = 0;
  4082. if ($ap == 4)
  4083. $status = 4;
  4084. foreach ( $receiptList as $key => $value ) {
  4085. $receiptList [$key] ['Locate'] = $Locate;
  4086. $Locate ++;
  4087. $receiptList [$key] ['reviseDetail'] = array ();
  4088. if (! empty ( $value ['reviseDetail'] ))
  4089. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4090. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4091. $categoryDetil = $Lcategory->getOne ( array (
  4092. 'where' => 'cid=' . $value ['cid'],
  4093. 'asArray' => true
  4094. ) );
  4095. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4096. // 检测编辑状态
  4097. $verifyList = $verify->getOne ( array (
  4098. 'where' => 'vid=' . $value ['verify'],
  4099. 'asArray' => true
  4100. ) );
  4101. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4102. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4103. Doo::loadModel ( 'role' );
  4104. $role = new role ();
  4105. // print_r($verifyList);
  4106. $flag = true;
  4107. $roleKey = 0;
  4108. $endStaffArray = array ();
  4109. $roleArrayCopy = array ();
  4110. foreach ( $verifyList as $k => $v ) {
  4111. // init verifyStaff
  4112. if ($v [1] == 'ROLE') {
  4113. if (! empty ( $verifyStaff )) {
  4114. $endStaffArray = end ( $verifyStaff );
  4115. if ($v [0] == $endStaffArray ['nextStaff']) {
  4116. $roleId = $v [0];
  4117. }
  4118. }
  4119. $roleVerify = json_decode ( $v [3], true );
  4120. $roleKey = $k;
  4121. $roleArray = array ();
  4122. $rolename = $role->getOne ( array (
  4123. 'where' => 'rid=' . $v [0],
  4124. 'asArray' => true
  4125. ) );
  4126. foreach ( $roleVerify as $o => $p ) {
  4127. $staffID = explode ( '_', $p );
  4128. $staffInfo = $staff->getOne ( array (
  4129. 'where' => 'sid=' . $staffID [0],
  4130. 'asArray' => true
  4131. ) );
  4132. // print_r($staffID);
  4133. $exp = array (
  4134. 0 => $staffInfo ['sid'],
  4135. 1 => $staffID [1],
  4136. 2 => $staffInfo ['avatar'],
  4137. 'date' => '',
  4138. 'date' => '',
  4139. 'opinion' => '',
  4140. 'status' => '',
  4141. 'rolename' => $rolename ['name']
  4142. );
  4143. array_push ( $roleArray, $exp );
  4144. }
  4145. $roleArrayCopy [$v [0]] = $roleArray;
  4146. // $verifyList[$k]['roleArray']=$roleArray;
  4147. }
  4148. // print_r($roleArray);
  4149. $verifyList [$k] ['date'] = "";
  4150. $verifyList [$k] ['opinion'] = "";
  4151. $verifyList [$k] ['status'] = "";
  4152. if (empty ( $verifyStaff )) {
  4153. $verifyList [$k] ['date'] = "";
  4154. $verifyList [$k] ['opinion'] = "";
  4155. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4156. $verifyList [$k] ['status'] = 4;
  4157. $button = 4;
  4158. $flag = false;
  4159. }
  4160. } else {
  4161. foreach ( $verifyStaff as $m => $u ) {
  4162. if ($v [0] == $m) {
  4163. $verifyList [$k] ['date'] = $u ['date'];
  4164. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4165. $verifyList [$k] ['status'] = $u ['status'];
  4166. $flag = false;
  4167. break;
  4168. }
  4169. }
  4170. $endStaffArray = end ( $verifyStaff );
  4171. if (isset ( $endStaffArray ['ROLE'] )) {
  4172. } else {
  4173. $endKey = key ( $verifyStaff );
  4174. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4175. $button = 4;
  4176. $verifyList [$k] ['status'] = 4;
  4177. }
  4178. }
  4179. }
  4180. }
  4181. $rolename ['name'] = '';
  4182. if (! empty ( $roleId )) {
  4183. Doo::loadModel ( 'role' );
  4184. $role = new role ();
  4185. $rolename = $role->getOne ( array (
  4186. 'where' => 'rid=' . $roleId,
  4187. 'asArray' => true
  4188. ) );
  4189. }
  4190. if (! empty ( $verifyStaff ))
  4191. $endStaffArray = end ( $verifyStaff );
  4192. $KOP = false;
  4193. foreach ( $roleArrayCopy as $P => $A ) {
  4194. foreach ( $A as $MKI => $AVL ) {
  4195. if (! empty ( $verifyStaff )) {
  4196. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4197. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4198. $button = 4;
  4199. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4200. }
  4201. foreach ( $verifyStaff as $m => $u ) {
  4202. $AVLFK = $AVL [0] . '_R';
  4203. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4204. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4205. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4206. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4207. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4208. break;
  4209. }
  4210. }
  4211. } else {
  4212. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4213. $button = 4;
  4214. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4215. }
  4216. }
  4217. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4218. $KOP = true;
  4219. }
  4220. }
  4221. // print_r($roleArrayCopy);
  4222. // echo $roleKey;
  4223. foreach ( $roleArrayCopy as $k => $v ) {
  4224. foreach ( $verifyList as $m => $n ) {
  4225. if ($n [0] == $k) {
  4226. array_splice ( $verifyList, $m, 1, $v );
  4227. }
  4228. }
  4229. }
  4230. $receiptList [$key] ['verifyList'] = $verifyList;
  4231. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4232. 'where' => 'sid=' . $value ['staff'],
  4233. 'asArray' => true
  4234. ) );
  4235. $receiptList [$key] ['button'] = $button;
  4236. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  4237. }
  4238. // $data['verifyDetail']=$verifyDetail;
  4239. $mothHtml = "";
  4240. for($i = 1; $i <= 12; $i ++) {
  4241. if ($month == $i)
  4242. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4243. else
  4244. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4245. }
  4246. // 获取审批日志
  4247. Doo::loadModel ( 'receiptLog' );
  4248. $receiptLog = new receiptLog ();
  4249. $rlList = array ();
  4250. $rlInfo = $receiptLog->getOne ( array (
  4251. 'where' => 'rid=' . $rid . ' and status=4',
  4252. 'asArray' => true
  4253. ) );
  4254. $tijdate = $receiptLog->getOne ( array (
  4255. 'where' => 'rid=' . $rid . ' and status=2',
  4256. 'asc' => 'rlid',
  4257. 'asArray' => true
  4258. ) );
  4259. if (! empty ( $rlInfo )) {
  4260. $rlList = $receiptLog->find ( array (
  4261. 'where' => 'rid=' . $rid,
  4262. 'asc' => 'rlid',
  4263. 'asArray' => true
  4264. ) );
  4265. }
  4266. $receiptList [0] ['rlList'] = $rlList;
  4267. $enclosurList = $enclosur->find ( array (
  4268. 'where' => 'rid=' . $rid,
  4269. 'asArray' => true
  4270. ) );
  4271. $enclosurHtml = '';
  4272. foreach ( $enclosurList as $value ) {
  4273. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4274. }
  4275. // print_r($receiptList);
  4276. $data ['rid'] = $rid;
  4277. $data ['enclosurHtml'] = $enclosurHtml;
  4278. $data ['rolename'] = $rolename ['name'];
  4279. $data ['datetij'] = $tijdate ['date'];
  4280. $data ['mothHtml'] = $mothHtml;
  4281. $data ['receiptList'] = $receiptList;
  4282. $data ['receiptApprovalCount'] = count ( $receiptList );
  4283. $data ['status'] = $status;
  4284. $data ['year'] = $year;
  4285. $data ['categoryList'] = $categoryList;
  4286. $data ['staffList'] = $staffList;
  4287. $data ['cid'] = $cid;
  4288. $data ['sid'] = $sid;
  4289. $data ['ap'] = $ap;
  4290. $data ['memu'] = "receipt";
  4291. $data ['staff'] = $this->staff;
  4292. $data ['receiptMemu'] = 'approvalExpenses';
  4293. $data ['verifyId'] = $this->verifyId;
  4294. $data ['executeId'] = $this->executeId;
  4295. $this->render ( "/admin/expensesEdi", $data );
  4296. }
  4297. function expensesDefray() {
  4298. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  4299. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  4300. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4301. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  4302. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  4303. if (! empty ( $rid )) {
  4304. Doo::loadModel ( "verify" );
  4305. $verify = new verify ();
  4306. Doo::loadModel ( "receiptDetail" );
  4307. $receiptDetailObj = new receiptDetail ();
  4308. Doo::loadModel ( "itemStatistics" );
  4309. Doo::loadModel ( "statistics" );
  4310. $statistics = new statistics ();
  4311. $itemStatistics = new itemStatistics ();
  4312. Doo::loadModel ( "receipt" );
  4313. $receipt = new receipt ();
  4314. Doo::loadModel ( "loanReceipt" );
  4315. $loanReceipt = new loanReceipt ();
  4316. $receiptDetail = $receipt->getOne ( array (
  4317. 'where' => 'rid=' . $rid . ' and status=2 ',
  4318. 'asArray' => true
  4319. ) );
  4320. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  4321. $nsflag = true;
  4322. foreach ( $nslist as $value ) {
  4323. if ($value == $this->staff ['0'] ['sid']) {
  4324. $nsflag = false;
  4325. break;
  4326. }
  4327. }
  4328. // print_r($nslist);die;
  4329. if (empty ( $receiptDetail ) || $nsflag)
  4330. return "/approvalExpenses/pendApproval";
  4331. $verifyDetail = $verify->getOne ( array (
  4332. 'where' => ' vid =' . $receiptDetail ['verify'],
  4333. 'asArray' => true
  4334. ) );
  4335. $verifyString = $verifyDetail ['staff'];
  4336. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  4337. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  4338. if (empty ( $opinion )) {
  4339. if ($status == 3)
  4340. $opinion = "终止";
  4341. else
  4342. $opinion = "同意支付";
  4343. }
  4344. $nowStaff = 0;
  4345. $nowStaffList = array ();
  4346. if (empty ( $verifyStaff )) {
  4347. // 还需加入是否已经进入角色审批
  4348. if ($verifyDetail [0] [1] == 'ROLE') {
  4349. // print_r($verifyDetail);echo "ddd";
  4350. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  4351. foreach ( $vStaffString as $key => $value ) {
  4352. $staffK = explode ( "_", $value );
  4353. if ($staffK [0] != $this->staff [0] ['sid'])
  4354. array_push ( $nowStaffList, $staffK [0] );
  4355. }
  4356. // print_r($verifyDetail);
  4357. // die;
  4358. if (! empty ( $nowStaffList )) {
  4359. $nowStaff = implode ( ',', $nowStaffList );
  4360. $verifyStaff = array (
  4361. $this->staff [0] ['sid'] . "_R" => array (
  4362. 'date' => date ( 'Y-m-d' ),
  4363. 'opinion' => $opinion,
  4364. 'status' => $status,
  4365. 'nextStaff' => $verifyDetail [0] [0],
  4366. 'ROLE' => 1
  4367. )
  4368. );
  4369. } else {
  4370. $nowStaff = $verifyDetail [1] [0];
  4371. $verifyStaff = array (
  4372. $this->staff [0] ['sid'] . "_R" => array (
  4373. 'date' => date ( 'Y-m-d' ),
  4374. 'opinion' => $opinion,
  4375. 'status' => $status,
  4376. 'nextStaff' => $verifyDetail [1] [0]
  4377. )
  4378. );
  4379. }
  4380. } else {
  4381. if ($verifyDetail [1] [1] == 'ROLE') {
  4382. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  4383. // echo "dd";
  4384. foreach ( $vStaffString as $key => $value ) {
  4385. $staffK = explode ( "_", $value );
  4386. array_push ( $nowStaffList, $staffK [0] );
  4387. }
  4388. $nowStaff = implode ( ',', $nowStaffList );
  4389. $verifyStaff = array (
  4390. $this->staff [0] ['sid'] => array (
  4391. 'date' => date ( 'Y-m-d' ),
  4392. 'opinion' => $opinion,
  4393. 'status' => $status,
  4394. 'nextStaff' => $verifyDetail [1] [0],
  4395. 'ROLE' => 1
  4396. )
  4397. );
  4398. } else {
  4399. $nowStaff = $verifyDetail [1] [0];
  4400. $verifyStaff = array (
  4401. $this->staff [0] ['sid'] => array (
  4402. 'date' => date ( 'Y-m-d' ),
  4403. 'opinion' => $opinion,
  4404. 'status' => $status,
  4405. 'nextStaff' => $verifyDetail [1] [0]
  4406. )
  4407. );
  4408. }
  4409. }
  4410. if ($status == 3)
  4411. $verifyStaff = array (
  4412. 'final' => $status,
  4413. $this->staff [0] ['sid'] => array (
  4414. 'date' => date ( 'Y-m-d' ),
  4415. 'opinion' => $opinion,
  4416. 'status' => $status
  4417. )
  4418. );
  4419. $vStaffString = json_encode ( $verifyStaff );
  4420. $receipt->nowStaff = $nowStaff;
  4421. $receipt->verifyStaff = $vStaffString;
  4422. $loanReceipt->nowStaff = $nowStaff;
  4423. $loanReceipt->verifyStaff = $vStaffString;
  4424. } else {
  4425. $VS = end ( $verifyStaff );
  4426. // 非角色审批
  4427. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  4428. $nextStaff = 0;
  4429. $roleSTF = false;
  4430. foreach ( $verifyDetail as $key => $value ) {
  4431. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  4432. if (isset ( $verifyDetail [$key + 1] )) {
  4433. $nextStaff = $verifyDetail [$key + 1] [0];
  4434. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  4435. $roleSTF = true;
  4436. }
  4437. break;
  4438. }
  4439. }
  4440. if (! $roleSTF) {
  4441. $nowStaff = $nextStaff;
  4442. $verifyStaff [$this->staff [0] ['sid']] = array (
  4443. 'date' => date ( 'Y-m-d' ),
  4444. 'opinion' => $opinion,
  4445. 'status' => $status,
  4446. 'nextStaff' => $nextStaff
  4447. );
  4448. } else {
  4449. // 获取角色下的所有用户ID
  4450. $nowStaffList = array ();
  4451. foreach ( $verifyDetail as $vfk ) {
  4452. if ($vfk [1] == 'ROLE') {
  4453. $vStaffString = json_decode ( $vfk [3] );
  4454. foreach ( $vStaffString as $key => $value ) {
  4455. $staffK = explode ( "_", $value );
  4456. array_push ( $nowStaffList, $staffK [0] );
  4457. }
  4458. }
  4459. }
  4460. $nowStaff = implode ( ',', $nowStaffList );
  4461. $verifyStaff [$this->staff [0] ['sid']] = array (
  4462. 'date' => date ( 'Y-m-d' ),
  4463. 'opinion' => $opinion,
  4464. 'status' => $status,
  4465. 'nextStaff' => $nextStaff,
  4466. 'ROLE' => 0
  4467. );
  4468. }
  4469. if ($status == 3) {
  4470. $verifyStaff ['final'] = $status;
  4471. $verifyStaff [$this->staff [0] ['sid']] = array (
  4472. 'date' => date ( 'Y-m-d' ),
  4473. 'opinion' => $opinion,
  4474. 'status' => $status
  4475. );
  4476. }
  4477. $vStaffString = json_encode ( $verifyStaff );
  4478. $receipt->nowStaff = $nowStaff;
  4479. $receipt->verifyStaff = $vStaffString;
  4480. $loanReceipt->nowStaff = $nowStaff;
  4481. $loanReceipt->verifyStaff = $vStaffString;
  4482. }
  4483. // 角色审批
  4484. if (isset ( $VS ['ROLE'] )) {
  4485. // 找出角色人 当前审批角色组
  4486. $verifyJSStaff = array ();
  4487. $nowStaffList2 = array ();
  4488. foreach ( $verifyDetail as $key => $value ) {
  4489. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  4490. $verifyJSStaff = json_decode ( $value [3] );
  4491. foreach ( $verifyJSStaff as $m ) {
  4492. $staffK = explode ( "_", $m );
  4493. array_push ( $nowStaffList2, $staffK [0] );
  4494. }
  4495. // print_r($nowStaffList2);
  4496. }
  4497. }
  4498. $RoleVerifyStaff = array ();
  4499. foreach ( $verifyStaff as $key => $value ) {
  4500. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  4501. foreach ( $nowStaffList2 as $m ) {
  4502. if ($key == $m . "_R")
  4503. $RoleVerifyStaff [$key] = $value;
  4504. }
  4505. }
  4506. }
  4507. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  4508. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  4509. // 下一个审批人ID
  4510. $nextStaff = 0;
  4511. $falg = false;
  4512. foreach ( $verifyDetail as $key => $value ) {
  4513. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  4514. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  4515. $falg = true;
  4516. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  4517. $nowStaffList = array ();
  4518. foreach ( $vStaffString as $v ) {
  4519. $staffK = explode ( "_", $v );
  4520. array_push ( $nowStaffList, $staffK [0] );
  4521. }
  4522. $nowStaff = implode ( ',', $nowStaffList );
  4523. $nextStaff = $verifyDetail [$key + 1] [0];
  4524. } elseif (isset ( $verifyDetail [$key + 1] )) {
  4525. $nextStaff = $verifyDetail [$key + 1] [0];
  4526. $nowStaff = $nextStaff;
  4527. } else
  4528. $nowStaff = '';
  4529. break;
  4530. }
  4531. }
  4532. if ($falg)
  4533. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  4534. 'date' => date ( 'Y-m-d' ),
  4535. 'opinion' => $opinion,
  4536. 'status' => $status,
  4537. 'nextStaff' => $nextStaff,
  4538. 'ROLE' => 1
  4539. );
  4540. else
  4541. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  4542. 'date' => date ( 'Y-m-d' ),
  4543. 'opinion' => $opinion,
  4544. 'status' => $status,
  4545. 'nextStaff' => $nextStaff
  4546. );
  4547. // print_r($verifyStaff);
  4548. // echo $nowStaff;die;
  4549. } else { // 进入下一个角色或者审批人
  4550. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  4551. //
  4552. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  4553. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  4554. 'date' => date ( 'Y-m-d' ),
  4555. 'opinion' => $opinion,
  4556. 'status' => $status,
  4557. 'nextStaff' => $VS ['nextStaff'],
  4558. 'ROLE' => 1
  4559. );
  4560. // print_r($verifyStaff);
  4561. // die;
  4562. }
  4563. if ($status == 3) {
  4564. $verifyStaff ['final'] = $status;
  4565. $verifyStaff [$this->staff [0] ['sid']] = array (
  4566. 'date' => date ( 'Y-m-d' ),
  4567. 'opinion' => $opinion,
  4568. 'status' => $status
  4569. );
  4570. }
  4571. $vStaffString = json_encode ( $verifyStaff );
  4572. $receipt->verifyStaff = $vStaffString;
  4573. $receipt->nowStaff = $nowStaff;
  4574. $loanReceipt->nowStaff = $nowStaff;
  4575. $loanReceipt->verifyStaff = $vStaffString;
  4576. // die;
  4577. // }
  4578. // print_r($verifyStaff);
  4579. // die;
  4580. }
  4581. // print_r($verifyStaff);die;
  4582. }
  4583. // print_r($verifyDetail);
  4584. $roleKey = 0;
  4585. $roleId = 0;
  4586. $verifyDetailCopy = array ();
  4587. foreach ( $verifyDetail as $k => $v ) {
  4588. if ($v [1] == 'ROLE') {
  4589. $roleId = $v [0];
  4590. $roleVerify = json_decode ( $v [3], true );
  4591. $roleKey = $k;
  4592. $roleArray = array ();
  4593. foreach ( $roleVerify as $o => $p ) {
  4594. $staffID = explode ( '_', $p );
  4595. $exp = array (
  4596. 0 => $staffID [0],
  4597. 1 => $staffID [1]
  4598. );
  4599. array_push ( $roleArray, $exp );
  4600. }
  4601. $verifyDetailCopy [$v [0]] = $roleArray;
  4602. }
  4603. }
  4604. // print_r($verifyDetail);
  4605. foreach ( $verifyDetailCopy as $k => $v ) {
  4606. foreach ( $verifyDetail as $m => $n ) {
  4607. if ($n [0] == $k) {
  4608. array_splice ( $verifyDetail, $m, 1, $v );
  4609. }
  4610. }
  4611. }
  4612. // 审批日志
  4613. if (! isset ( $verifyStaff ['final'] )) {
  4614. Doo::loadModel ( "receiptLog" );
  4615. $receiptLog = new receiptLog ();
  4616. if (! empty ( $roleId )) {
  4617. Doo::loadModel ( "role" );
  4618. $role = new role ();
  4619. $roleInfo = $role->getOne ( array (
  4620. 'where' => 'rid=' . $roleId,
  4621. 'asArray' => true
  4622. ) );
  4623. $receiptLog->rolename = $roleInfo ['name'];
  4624. }
  4625. $receiptLog->username = $this->staff [0] ['username'];
  4626. $receiptLog->uid = $this->staff [0] ['sid'];
  4627. $receiptLog->date = date ( "Y-m-d" );
  4628. $receiptLog->opinion = $opinion;
  4629. $receiptLog->img = $this->staff [0] ['avatar'];
  4630. $receiptLog->status = 1;
  4631. $receiptLog->rid = $rid;
  4632. $receiptLog->insert ();
  4633. }
  4634. if (isset ( $verifyStaff ['final'] )) { // rDetail
  4635. $receipt->status = 3;
  4636. $receipt->verifyBreakup = $verifyString;
  4637. $receiptDetailObj->status = 3;
  4638. $receiptDetailObj->update ( array (
  4639. 'where' => 'rid=' . $rid
  4640. ) );
  4641. // 微信企业号通知
  4642. $this->setWXMsg ( $rid, 3 );
  4643. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  4644. $receipt->status = 6;
  4645. $receipt->pastDate = date ( "Y-m-d" );
  4646. $receipt->isBK = 1;
  4647. $loanReceipt->verifyBreakup = $verifyString;
  4648. $loanReceipt->status = 1;
  4649. $loanReceipt->pastDate = date ( "Y-m-d" );
  4650. //生成流水后 不更新汇款金额
  4651. Doo::loadModel ( 'wasteBook' );
  4652. $wasteBook = new wasteBook ();
  4653. $wbDetail = $wasteBook->getWateBookByAD ( 1, $rid );
  4654. if (empty($wbDetail)){
  4655. $loanReceipt->amount = $receiptDetail ['amount'];
  4656. }
  4657. $loanReceipt->update ( array (
  4658. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  4659. ) );
  4660. // 微信企业号通知
  4661. $this->setWXMsg ( $rid, 1 );
  4662. }
  4663. $receipt->amount = $amount;
  4664. $receipt->update ( array (
  4665. 'where' => ' rid = ' . $rid
  4666. ) );
  4667. // 进入下一条审批费用新加需求
  4668. $vidList = array ();
  4669. $verifyDetail = $verify->find ( array (
  4670. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  4671. 'asArray' => true
  4672. ) );
  4673. foreach ( $verifyDetail as $key => $value ) {
  4674. array_push ( $vidList, $value ['vid'] );
  4675. }
  4676. $vid = implode ( ",", $vidList );
  4677. if (empty ( $verifyDetail ))
  4678. $vid = 0;
  4679. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  4680. $receipt = new receipt ();
  4681. $rd = $receipt->getOne ( array (
  4682. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  4683. 'asc' => 'rid',
  4684. 'asArray' => true
  4685. ) );
  4686. if (empty ( $rd )) {
  4687. return '/approvalExpenses/pendApproval';
  4688. }
  4689. if ($rd ['Rtype'] == 1) {
  4690. if ($rd ['isBK'] == 1) {
  4691. return '/receiptburEdi/' . $rd ['rid'];
  4692. } else {
  4693. return '/expensesEdi/' . $rd ['rid'];
  4694. }
  4695. } elseif ($rd ['Rtype'] == 2) {
  4696. return '/remitApproval/' . $rd ['rid'];
  4697. } else {
  4698. return '/receiptburEdi/' . $rd ['rid'];
  4699. }
  4700. // return "/approvalExpenses/pendApproval";
  4701. }
  4702. }
  4703. function ajaxExamineExe() {
  4704. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4705. Doo::loadModel ( 'receipt' );
  4706. $receipt = new receipt ();
  4707. Doo::loadClass ( 'XDeode' );
  4708. $XDeode = new XDeode ( 5 );
  4709. if (! empty ( $rid )) {
  4710. $rLRes = $receipt->find ( array (
  4711. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  4712. 'asArray' => true
  4713. ) );
  4714. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  4715. echo json_encode ( array (
  4716. 'status' => 1,
  4717. 'receipt' => $rLRes [0]
  4718. ) );
  4719. die ();
  4720. }
  4721. echo json_encode ( array (
  4722. 'status' => 0,
  4723. 'receipt' => array ()
  4724. ) );
  4725. die ();
  4726. }
  4727. function implement() {
  4728. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4729. Doo::loadClass ( 'XDeode' );
  4730. $XDeode = new XDeode ( 5 );
  4731. Doo::loadModel ( 'receipt' );
  4732. $receipt = new receipt ();
  4733. Doo::loadModel ( 'L_category' );
  4734. $Lcategory = new L_category ();
  4735. Doo::loadModel ( 'verify' );
  4736. $verify = new verify ();
  4737. Doo::loadModel ( 'staff' );
  4738. $staff = new staff ();
  4739. Doo::loadModel ( "execute" );
  4740. $execute = new execute ();
  4741. $rid = $XDeode->decode ( $rid );
  4742. $receiptList = $receipt->find ( array (
  4743. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  4744. 'desc' => 'rid',
  4745. 'asArray' => true
  4746. ) );
  4747. Doo::loadModel ( 'loanReceipt' );
  4748. $loanReceipt = new loanReceipt ();
  4749. // print_r($receiptList);
  4750. $loanList = array ();
  4751. if (! isset ( $receiptList ))
  4752. $loanList = $loanReceipt->find ( array (
  4753. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4754. 'desc' => 'rid',
  4755. 'asArray' => true
  4756. ) );
  4757. $Locate = 0;
  4758. $roleId = 0;
  4759. $button = 0;
  4760. foreach ( $loanList as $key => $value ) {
  4761. $loanList [$key] ['Locate'] = $Locate;
  4762. $Locate ++;
  4763. $loanList [$key] ['reviseDetail'] = array ();
  4764. if (! empty ( $value ['reviseDetail'] ))
  4765. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4766. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4767. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4768. $categoryDetil = $Lcategory->getOne ( array (
  4769. 'where' => 'cid=' . $value ['cid'],
  4770. 'asArray' => true
  4771. ) );
  4772. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4773. // 检测编辑状态
  4774. $verifyList = $verify->getOne ( array (
  4775. 'where' => 'vid=' . $value ['verify'],
  4776. 'asArray' => true
  4777. ) );
  4778. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4779. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4780. Doo::loadModel ( 'role' );
  4781. $role = new role ();
  4782. $flag = true;
  4783. $roleKey = 0;
  4784. $endStaffArray = array ();
  4785. $roleArrayCopy = array ();
  4786. foreach ( $verifyList as $k => $v ) {
  4787. // init verifyStaff
  4788. if ($v [1] == 'ROLE') {
  4789. if (! empty ( $verifyStaff )) {
  4790. $endStaffArray = end ( $verifyStaff );
  4791. // if ($v[0]==$endStaffArray['nextStaff']){
  4792. // $roleId=$v[0];
  4793. // }
  4794. }
  4795. $roleVerify = json_decode ( $v [3], true );
  4796. $roleKey = $k;
  4797. $roleArray = array ();
  4798. $rolename = $role->getOne ( array (
  4799. 'where' => 'rid=' . $v [0],
  4800. 'asArray' => true
  4801. ) );
  4802. foreach ( $roleVerify as $o => $p ) {
  4803. $staffID = explode ( '_', $p );
  4804. $staffInfo = $staff->getOne ( array (
  4805. 'where' => 'sid=' . $staffID [0],
  4806. 'asArray' => true
  4807. ) );
  4808. // print_r($staffID);
  4809. $exp = array (
  4810. 0 => $staffInfo ['sid'],
  4811. 1 => $staffID [1],
  4812. 2 => $staffInfo ['avatar'],
  4813. 'date' => '',
  4814. 'date' => '',
  4815. 'opinion' => '',
  4816. 'status' => '',
  4817. 'rolename' => $rolename ['name']
  4818. );
  4819. array_push ( $roleArray, $exp );
  4820. }
  4821. $roleArrayCopy [$v [0]] = $roleArray;
  4822. // $verifyList[$k]['roleArray']=$roleArray;
  4823. }
  4824. $verifyList [$k] ['date'] = "";
  4825. $verifyList [$k] ['opinion'] = "";
  4826. $verifyList [$k] ['status'] = "";
  4827. if (empty ( $verifyStaff )) {
  4828. $verifyList [$k] ['date'] = "";
  4829. $verifyList [$k] ['opinion'] = "";
  4830. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4831. $verifyList [$k] ['status'] = 4;
  4832. $flag = false;
  4833. }
  4834. } else {
  4835. foreach ( $verifyStaff as $m => $u ) {
  4836. if ($v [0] == $m) {
  4837. $verifyList [$k] ['date'] = $u ['date'];
  4838. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4839. $verifyList [$k] ['status'] = $u ['status'];
  4840. $flag = false;
  4841. break;
  4842. }
  4843. }
  4844. $endStaffArray = end ( $verifyStaff );
  4845. if (isset ( $endStaffArray ['ROLE'] )) {
  4846. } else {
  4847. // $endKey=key($verifyStaff);
  4848. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4849. // $button=4;
  4850. // $verifyList[$k]['status']=4;
  4851. // }
  4852. }
  4853. }
  4854. }
  4855. $rolename ['name'] = '';
  4856. if (! empty ( $roleId )) {
  4857. Doo::loadModel ( 'role' );
  4858. $role = new role ();
  4859. $rolename = $role->getOne ( array (
  4860. 'where' => 'rid=' . $roleId,
  4861. 'asArray' => true
  4862. ) );
  4863. }
  4864. if (! empty ( $verifyStaff ))
  4865. $endStaffArray = end ( $verifyStaff );
  4866. $KOP = false;
  4867. foreach ( $roleArrayCopy as $P => $A ) {
  4868. foreach ( $A as $MKI => $AVL ) {
  4869. if (! empty ( $verifyStaff )) {
  4870. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4871. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4872. $button = 4;
  4873. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4874. }
  4875. foreach ( $verifyStaff as $m => $u ) {
  4876. $AVLFK = $AVL [0] . '_R';
  4877. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4878. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4879. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4880. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4881. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4882. break;
  4883. }
  4884. }
  4885. } else {
  4886. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4887. $button = 4;
  4888. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4889. }
  4890. }
  4891. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4892. $KOP = true;
  4893. }
  4894. }
  4895. foreach ( $roleArrayCopy as $k => $v ) {
  4896. foreach ( $verifyList as $m => $n ) {
  4897. if ($n [0] == $k) {
  4898. array_splice ( $verifyList, $m, 1, $v );
  4899. }
  4900. }
  4901. }
  4902. $loanList [$key] ['verifyList'] = $verifyList;
  4903. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  4904. 'where' => 'sid=' . $value ['staff'],
  4905. 'asArray' => true
  4906. ) );
  4907. }
  4908. $data ['loanList'] = $loanList;
  4909. $Locate = 0;
  4910. $roleId = 0;
  4911. $button = 0;
  4912. Doo::loadClass ( 'XDeode' );
  4913. $XDeode = new XDeode ( 5 );
  4914. foreach ( $receiptList as $key => $value ) {
  4915. $receiptList[$key]['ridKey']=$XDeode->encode ( $value['rid'] );
  4916. $button2 = 0;
  4917. $receiptList [$key] ['Locate'] = $Locate;
  4918. $Locate ++;
  4919. $receiptList [$key] ['reviseDetail'] = array ();
  4920. if (! empty ( $value ['reviseDetail'] ))
  4921. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4922. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4923. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4924. $categoryDetil = $Lcategory->getOne ( array (
  4925. 'where' => 'cid=' . $value ['cid'],
  4926. 'asArray' => true
  4927. ) );
  4928. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4929. $executeList = json_decode ( $value ['executeCopy'], true );
  4930. $executeStaff = array ();
  4931. if (! empty ( $value ['executeStaff'] ))
  4932. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4933. if (isset ( $executeList )) {
  4934. foreach ( $executeList as $op => $lo ) {
  4935. $executeList [$op] ['date'] = "";
  4936. $executeList [$op] ['opinion'] = "";
  4937. $executeList [$op] ['status'] = "";
  4938. foreach ( $executeStaff as $m => $u ) {
  4939. if ($lo [0] == $m) {
  4940. $executeList [$op] ['date'] = $u ['date'];
  4941. $executeList [$op] ['opinion'] = $u ['opinion'];
  4942. $executeList [$op] ['status'] = $u ['status'];
  4943. break;
  4944. }
  4945. }
  4946. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  4947. $button2 = 1;
  4948. $executeList [$op] ['status'] = 4;
  4949. }
  4950. }
  4951. }
  4952. // 检测编辑状态
  4953. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  4954. $verifyList ['staff'] = $value ['verifyBreakup'];
  4955. } else
  4956. $verifyList = $verify->getOne ( array (
  4957. 'where' => 'vid=' . $value ['verify'],
  4958. 'asArray' => true
  4959. ) );
  4960. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4961. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4962. Doo::loadModel ( 'role' );
  4963. $role = new role ();
  4964. if ($verifyList == NULL)
  4965. $verifyList = array ();
  4966. $flag = true;
  4967. $roleKey = 0;
  4968. $endStaffArray = array ();
  4969. $roleArrayCopy = array ();
  4970. foreach ( $verifyList as $k => $v ) {
  4971. // init verifyStaff
  4972. if ($v [1] == 'ROLE') {
  4973. if (! empty ( $verifyStaff )) {
  4974. $endStaffArray = end ( $verifyStaff );
  4975. // if ($v[0]==$endStaffArray['nextStaff']){
  4976. // $roleId=$v[0];
  4977. // }
  4978. }
  4979. $roleVerify = json_decode ( $v [3], true );
  4980. $roleKey = $k;
  4981. $roleArray = array ();
  4982. $rolename = $role->getOne ( array (
  4983. 'where' => 'rid=' . $v [0],
  4984. 'asArray' => true
  4985. ) );
  4986. foreach ( $roleVerify as $o => $p ) {
  4987. $staffID = explode ( '_', $p );
  4988. $staffInfo = $staff->getOne ( array (
  4989. 'where' => 'sid=' . $staffID [0],
  4990. 'asArray' => true
  4991. ) );
  4992. // print_r($staffID);
  4993. $exp = array (
  4994. 0 => $staffInfo ['sid'],
  4995. 1 => $staffID [1],
  4996. 2 => $staffInfo ['avatar'],
  4997. 'date' => '',
  4998. 'date' => '',
  4999. 'opinion' => '',
  5000. 'status' => '',
  5001. 'rolename' => $rolename ['name']
  5002. );
  5003. array_push ( $roleArray, $exp );
  5004. }
  5005. $roleArrayCopy [$v [0]] = $roleArray;
  5006. // $verifyList[$k]['roleArray']=$roleArray;
  5007. }
  5008. $verifyList [$k] ['date'] = "";
  5009. $verifyList [$k] ['opinion'] = "";
  5010. $verifyList [$k] ['status'] = "";
  5011. if (empty ( $verifyStaff )) {
  5012. $verifyList [$k] ['date'] = "";
  5013. $verifyList [$k] ['opinion'] = "";
  5014. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5015. $verifyList [$k] ['status'] = 4;
  5016. $flag = false;
  5017. }
  5018. } else {
  5019. foreach ( $verifyStaff as $m => $u ) {
  5020. if ($v [0] == $m) {
  5021. $verifyList [$k] ['date'] = $u ['date'];
  5022. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5023. $verifyList [$k] ['status'] = $u ['status'];
  5024. $flag = false;
  5025. break;
  5026. }
  5027. }
  5028. $endStaffArray = end ( $verifyStaff );
  5029. if (isset ( $endStaffArray ['ROLE'] )) {
  5030. } else {
  5031. // $endKey=key($verifyStaff);
  5032. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5033. // $button=4;
  5034. // $verifyList[$k]['status']=4;
  5035. // }
  5036. }
  5037. }
  5038. }
  5039. $rolename ['name'] = '';
  5040. if (! empty ( $roleId )) {
  5041. Doo::loadModel ( 'role' );
  5042. $role = new role ();
  5043. $rolename = $role->getOne ( array (
  5044. 'where' => 'rid=' . $roleId,
  5045. 'asArray' => true
  5046. ) );
  5047. }
  5048. if (! empty ( $verifyStaff ))
  5049. $endStaffArray = end ( $verifyStaff );
  5050. $KOP = false;
  5051. foreach ( $roleArrayCopy as $P => $A ) {
  5052. foreach ( $A as $MKI => $AVL ) {
  5053. if (! empty ( $verifyStaff )) {
  5054. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5055. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5056. $button = 4;
  5057. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5058. }
  5059. foreach ( $verifyStaff as $m => $u ) {
  5060. $AVLFK = $AVL [0] . '_R';
  5061. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5062. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5063. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5064. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5065. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5066. break;
  5067. }
  5068. }
  5069. } else {
  5070. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5071. $button = 4;
  5072. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5073. }
  5074. }
  5075. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5076. $KOP = true;
  5077. }
  5078. }
  5079. foreach ( $roleArrayCopy as $k => $v ) {
  5080. foreach ( $verifyList as $m => $n ) {
  5081. if ($n [0] == $k) {
  5082. array_splice ( $verifyList, $m, 1, $v );
  5083. }
  5084. }
  5085. }
  5086. $receiptList [$key] ['verifyList'] = $verifyList;
  5087. $receiptList [$key] ['executeList'] = $executeList;
  5088. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5089. 'where' => 'sid=' . $value ['staff'],
  5090. 'asArray' => true
  5091. ) );
  5092. $receiptList [$key] ['button2'] = $button2;
  5093. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5094. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5095. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5096. $receiptList [$key] ['relust'] = $relust;
  5097. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  5098. }
  5099. // 是否写入过流水
  5100. $accountType = 0;
  5101. if ($receiptList [0] ['Rtype'] == 0) {
  5102. $accountType = 3;
  5103. } elseif ($receiptList [0] ['Rtype'] == 1) {
  5104. if (!empty($receiptList [0]['accountItem']) )
  5105. $accountType = 2;
  5106. else
  5107. $accountType = 1;
  5108. } elseif ($receiptList [0] ['Rtype'] == 2) {
  5109. $accountType = 4;
  5110. } elseif ($receiptList [0] ['Rtype'] == 3) {
  5111. $accountType = 12;
  5112. }
  5113. Doo::loadModel ( 'wasteBook' );
  5114. $wasteBook = new wasteBook ();
  5115. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $receiptList [0] ['rid'] );
  5116. $data ['wbDetail'] = $wbDetail;
  5117. $wbDetailLoan=array();
  5118. if ($accountType==2){
  5119. $wbDetailLoan = $wasteBook->getWateBookByAD ( 1, $receiptList [0] ['rid'] );
  5120. }
  5121. $data ['wbDetailLoan'] = $wbDetailLoan;
  5122. //print_r($receiptList);
  5123. $data ['receiptList'] = $receiptList;
  5124. $data ['memu'] = "receipt";
  5125. $data ['staff'] = $this->staff;
  5126. $data ['receiptMemu'] = 'implement';
  5127. $data ['verifyId'] = $this->verifyId;
  5128. $data ['executeId'] = $this->executeId;
  5129. $this->render ( "/admin/implement", $data );
  5130. }
  5131. function implementDo() {
  5132. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5133. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  5134. // $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  5135. // $accountBank = $this->get_args ( 'accountBank' ) ? $this->get_args ( 'accountBank' ) : "";
  5136. // $ab = '';
  5137. // if ($accountBank == 'CGBDeposit')
  5138. // $ab = '纵横广发';
  5139. // elseif ($accountBank == 'ICBCDeposit')
  5140. // $ab = '纵横工行';
  5141. // elseif ($accountBank == 'HUADeposit')
  5142. // $ab = '华润银行';
  5143. // elseif ($accountBank == 'PersonalDeposit')
  5144. // $ab = '个人广发';
  5145. // if (empty ( $ab ))
  5146. // die ( 'illegal request--22' );
  5147. if (! empty ( $rid )) {
  5148. Doo::loadModel ( 'receipt' );
  5149. $receipt = new receipt ();
  5150. // Doo::loadClass ( 'XDeode' );
  5151. // $XDeode = new XDeode ( 5 );
  5152. // $rinfo = $receipt->getOne ( array (
  5153. // 'where' => 'rid=' . $rid,
  5154. // 'asArray' => true
  5155. // ) );
  5156. $rinfo = $receipt->getReceiptByRid ( $rid );
  5157. // $accountType = '';
  5158. // if ($rinfo ['Rtype'] == 1) {
  5159. // if ($rinfo ['loanRid'] != 0)//判断有问题
  5160. // $accountType = 2;
  5161. // else
  5162. // $accountType = 1;
  5163. // } elseif ($rinfo ['Rtype'] == 2) {
  5164. // $accountType = 4;
  5165. // } elseif ($rinfo ['Rtype'] == 0)
  5166. // $accountType = 3;
  5167. // if (empty ( $accountType ))
  5168. // die ( 'illegal request' );
  5169. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  5170. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  5171. if (empty ( $executeStaff )) {
  5172. $executeStaff = array (
  5173. $this->staff [0] ['sid'] => array (
  5174. 'date' => date ( 'Y-m-d' ),
  5175. 'opinion' => $implementOpinions,
  5176. 'status' => 1
  5177. )
  5178. );
  5179. } else {
  5180. $executeStaff [$this->staff [0] ['sid']] = array (
  5181. 'date' => date ( 'Y-m-d' ),
  5182. 'opinion' => $implementOpinions,
  5183. 'status' => 1
  5184. );
  5185. }
  5186. if (count ( $executeStaff ) == count ( $executeCopy )) {
  5187. $receipt->executeStaff = json_encode ( $executeStaff );
  5188. $receipt->status = 8;
  5189. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  5190. $receipt->status = 9;
  5191. if ($rinfo ['status'] == 6) {
  5192. $receipt->loanDate = date ( "Y-m-d" );
  5193. }
  5194. $receipt->executeDate = date ( "Y-m-d" );
  5195. } else {
  5196. $receipt->executeStaff = json_encode ( $executeStaff );
  5197. }
  5198. //$receipt->amount = $amount;
  5199. $receipt->update ( array (
  5200. 'where' => 'rid=' . $rid
  5201. ) );
  5202. // 公司流水记录
  5203. // Doo::loadModel ( 'wasteBook' );
  5204. // $wasteBook = new wasteBook ();
  5205. // $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountType, $rid );
  5206. // // 银行
  5207. // if (empty ( $abDetail ) && ! empty ( $amount )) {
  5208. // $item = array (
  5209. // 'dataID' => $rid,
  5210. // 'expensesType' => 2,
  5211. // 'accountType' => $accountType,
  5212. // 'accountPriceShow' => $amount,
  5213. // 'accountPrice' => - $amount,
  5214. // 'accountBank' => $accountBank,
  5215. // 'category' => $rinfo ['category'] [0] ['title'],
  5216. // 'cid' => $rinfo ['category'] [0] ['cid'],
  5217. // 'name' => $rinfo ['staffDetail'] ['username'],
  5218. // 'sid' => $rinfo ['staffDetail'] ['sid'],
  5219. // 'inputDate' => date ( "Y-m-d H:i:s" )
  5220. // );
  5221. // $wasteBook->setAccountBookStatistics ( $item );
  5222. // }
  5223. }
  5224. //$ridKey = $XDeode->encode ( $rid );
  5225. return "/hisImplement";
  5226. // return "/implement/" . $ridKey . ".html";
  5227. }
  5228. function receiptburEdi() {
  5229. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5230. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5231. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5232. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5233. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5234. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5235. if (empty ( $status ))
  5236. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5237. $vidList = array ();
  5238. $button = 0;
  5239. Doo::loadModel ( 'verify' );
  5240. Doo::loadModel ( 'receipt' );
  5241. Doo::loadModel ( 'staff' );
  5242. $staff = new staff ();
  5243. $receipt = new receipt ();
  5244. $verify = new verify ();
  5245. Doo::loadModel ( 'L_category' );
  5246. $Lcategory = new L_category ();
  5247. Doo::loadModel ( 'enclosur' );
  5248. $enclosur = new enclosur ();
  5249. Doo::loadModel ( 'loanReceipt' );
  5250. $loanReceipt = new loanReceipt ();
  5251. // user verify ID
  5252. $verifyDetail = $verify->find ( array (
  5253. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5254. 'asArray' => true
  5255. ) );
  5256. foreach ( $verifyDetail as $key => $value ) {
  5257. array_push ( $vidList, $value ['vid'] );
  5258. }
  5259. $vid = implode ( ",", $vidList );
  5260. if (empty ( $verifyDetail ))
  5261. $vid = 0;
  5262. $categoryList = $Lcategory->find ( array (
  5263. 'asArray' => true
  5264. ) );
  5265. $staffList = $staff->find ( array (
  5266. 'where' => 'cid=' . $cid,
  5267. 'asArray' => true
  5268. ) );
  5269. $ap = "";
  5270. if ($status == 4) {
  5271. $ap = 4;
  5272. $status = 2;
  5273. }
  5274. // get Receipt By verifyID status 2
  5275. $receiptList = $receipt->find ( array (
  5276. 'where' => 'rid =' . $rid . ' and status=2',
  5277. 'desc' => 'rid',
  5278. 'asArray' => true
  5279. ) );
  5280. if (empty ( $receiptList )) {
  5281. die ( 'illegal request' );
  5282. }
  5283. $loanList = $loanReceipt->find ( array (
  5284. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  5285. 'desc' => 'rid',
  5286. 'asArray' => true
  5287. ) );
  5288. $data ['explanation'] = '';
  5289. if (! empty ( $loanList ))
  5290. $data ['explanation'] = $loanList [0] ['explanation'];
  5291. $Locate = 0;
  5292. $roleId = 0;
  5293. $button = 0;
  5294. foreach ( $loanList as $key => $value ) {
  5295. $loanList [$key] ['Locate'] = $Locate;
  5296. $Locate ++;
  5297. $loanList [$key] ['reviseDetail'] = array ();
  5298. if (! empty ( $value ['reviseDetail'] ))
  5299. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5300. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5301. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5302. $categoryDetil = $Lcategory->getOne ( array (
  5303. 'where' => 'cid=' . $value ['cid'],
  5304. 'asArray' => true
  5305. ) );
  5306. $loanList [$key] ['category'] = $categoryDetil ['title'];
  5307. // 检测编辑状态
  5308. $verifyList = $verify->getOne ( array (
  5309. 'where' => 'vid=' . $value ['verify'],
  5310. 'asArray' => true
  5311. ) );
  5312. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5313. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5314. Doo::loadModel ( 'role' );
  5315. $role = new role ();
  5316. $flag = true;
  5317. $roleKey = 0;
  5318. $endStaffArray = array ();
  5319. $roleArrayCopy = array ();
  5320. foreach ( $verifyList as $k => $v ) {
  5321. // init verifyStaff
  5322. if ($v [1] == 'ROLE') {
  5323. if (! empty ( $verifyStaff )) {
  5324. $endStaffArray = end ( $verifyStaff );
  5325. }
  5326. $roleVerify = json_decode ( $v [3], true );
  5327. $roleKey = $k;
  5328. $roleArray = array ();
  5329. $rolename = $role->getOne ( array (
  5330. 'where' => 'rid=' . $v [0],
  5331. 'asArray' => true
  5332. ) );
  5333. foreach ( $roleVerify as $o => $p ) {
  5334. $staffID = explode ( '_', $p );
  5335. $staffInfo = $staff->getOne ( array (
  5336. 'where' => 'sid=' . $staffID [0],
  5337. 'asArray' => true
  5338. ) );
  5339. // print_r($staffID);
  5340. $exp = array (
  5341. 0 => $staffInfo ['sid'],
  5342. 1 => $staffID [1],
  5343. 2 => $staffInfo ['avatar'],
  5344. 'date' => '',
  5345. 'date' => '',
  5346. 'opinion' => '',
  5347. 'status' => '',
  5348. 'rolename' => $rolename ['name']
  5349. );
  5350. array_push ( $roleArray, $exp );
  5351. }
  5352. $roleArrayCopy [$v [0]] = $roleArray;
  5353. // $verifyList[$k]['roleArray']=$roleArray;
  5354. }
  5355. $verifyList [$k] ['date'] = "";
  5356. $verifyList [$k] ['opinion'] = "";
  5357. $verifyList [$k] ['status'] = "";
  5358. if (empty ( $verifyStaff )) {
  5359. $verifyList [$k] ['date'] = "";
  5360. $verifyList [$k] ['opinion'] = "";
  5361. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5362. $verifyList [$k] ['status'] = 4;
  5363. $flag = false;
  5364. }
  5365. } else {
  5366. foreach ( $verifyStaff as $m => $u ) {
  5367. if ($v [0] == $m) {
  5368. $verifyList [$k] ['date'] = $u ['date'];
  5369. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5370. $verifyList [$k] ['status'] = $u ['status'];
  5371. $flag = false;
  5372. break;
  5373. }
  5374. }
  5375. $endStaffArray = end ( $verifyStaff );
  5376. if (isset ( $endStaffArray ['ROLE'] )) {
  5377. } else {
  5378. }
  5379. }
  5380. }
  5381. $rolename ['name'] = '';
  5382. if (! empty ( $roleId )) {
  5383. Doo::loadModel ( 'role' );
  5384. $role = new role ();
  5385. $rolename = $role->getOne ( array (
  5386. 'where' => 'rid=' . $roleId,
  5387. 'asArray' => true
  5388. ) );
  5389. }
  5390. if (! empty ( $verifyStaff ))
  5391. $endStaffArray = end ( $verifyStaff );
  5392. $KOP = false;
  5393. foreach ( $roleArrayCopy as $P => $A ) {
  5394. foreach ( $A as $MKI => $AVL ) {
  5395. if (! empty ( $verifyStaff )) {
  5396. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5397. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5398. $button = 4;
  5399. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5400. }
  5401. foreach ( $verifyStaff as $m => $u ) {
  5402. $AVLFK = $AVL [0] . '_R';
  5403. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5404. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5405. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5406. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5407. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5408. break;
  5409. }
  5410. }
  5411. } else {
  5412. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5413. $button = 4;
  5414. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5415. }
  5416. }
  5417. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5418. $KOP = true;
  5419. }
  5420. }
  5421. foreach ( $roleArrayCopy as $k => $v ) {
  5422. foreach ( $verifyList as $m => $n ) {
  5423. if ($n [0] == $k) {
  5424. array_splice ( $verifyList, $m, 1, $v );
  5425. }
  5426. }
  5427. }
  5428. $loanList [$key] ['verifyList'] = $verifyList;
  5429. }
  5430. $htmlLoan = '';
  5431. $data ['loanReceiptDate'] = '';
  5432. if (isset ( $loanList [0] )) {
  5433. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  5434. if ($value ['status'] == 1)
  5435. $htmlLoan .= '<li class="done" >';
  5436. elseif ($value ['status'] == 3)
  5437. $htmlLoan .= '<li class="undone" >';
  5438. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  5439. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  5440. if (isset ( $value ['rolename'] ))
  5441. $htmlLoan .= $value ['rolename'];
  5442. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  5443. }
  5444. $data ['loanDate'] = $loanList [0] ['date'];
  5445. } else {
  5446. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  5447. }
  5448. $data ['htmlLoan'] = $htmlLoan;
  5449. // $data ['LoanReceipt']=$loanList[0];
  5450. // print_r($loanList);
  5451. $Locate = 0;
  5452. $roleId = 0;
  5453. $button = 0;
  5454. if ($ap == 4)
  5455. $status = 4;
  5456. Doo::loadClass ( 'XDeode' );
  5457. $XDeode = new XDeode ( 5 );
  5458. foreach ( $receiptList as $key => $value ) {
  5459. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  5460. $receiptList [$key] ['Locate'] = $Locate;
  5461. $Locate ++;
  5462. $receiptList [$key] ['reviseDetail'] = array ();
  5463. // 调整金额 代码调整
  5464. if (! empty ( $value ['reviseDetail'] )) {
  5465. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  5466. foreach ( $reviseDetail as $ry => $re ) {
  5467. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  5468. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  5469. }
  5470. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  5471. // print_r($reviseDetail);
  5472. }
  5473. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5474. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5475. $categoryDetil = $Lcategory->getOne ( array (
  5476. 'where' => 'cid=' . $value ['cid'],
  5477. 'asArray' => true
  5478. ) );
  5479. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5480. // 检测编辑状态
  5481. $verifyList = $verify->getOne ( array (
  5482. 'where' => 'vid=' . $value ['verify'],
  5483. 'asArray' => true
  5484. ) );
  5485. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5486. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5487. Doo::loadModel ( 'role' );
  5488. $role = new role ();
  5489. // print_r($verifyList);
  5490. $flag = true;
  5491. $roleKey = 0;
  5492. $endStaffArray = array ();
  5493. $roleArrayCopy = array ();
  5494. foreach ( $verifyList as $k => $v ) {
  5495. // init verifyStaff
  5496. if ($v [1] == 'ROLE') {
  5497. if (! empty ( $verifyStaff )) {
  5498. $endStaffArray = end ( $verifyStaff );
  5499. if ($v [0] == $endStaffArray ['nextStaff']) {
  5500. $roleId = $v [0];
  5501. }
  5502. }
  5503. $roleVerify = json_decode ( $v [3], true );
  5504. $roleKey = $k;
  5505. $roleArray = array ();
  5506. $rolename = $role->getOne ( array (
  5507. 'where' => 'rid=' . $v [0],
  5508. 'asArray' => true
  5509. ) );
  5510. foreach ( $roleVerify as $o => $p ) {
  5511. $staffID = explode ( '_', $p );
  5512. $staffInfo = $staff->getOne ( array (
  5513. 'where' => 'sid=' . $staffID [0],
  5514. 'asArray' => true
  5515. ) );
  5516. // print_r($staffID);
  5517. $exp = array (
  5518. 0 => $staffInfo ['sid'],
  5519. 1 => $staffID [1],
  5520. 2 => $staffInfo ['avatar'],
  5521. 'date' => '',
  5522. 'date' => '',
  5523. 'opinion' => '',
  5524. 'status' => '',
  5525. 'rolename' => $rolename ['name']
  5526. );
  5527. array_push ( $roleArray, $exp );
  5528. }
  5529. $roleArrayCopy [$v [0]] = $roleArray;
  5530. // $verifyList[$k]['roleArray']=$roleArray;
  5531. }
  5532. // print_r($roleArray);
  5533. $verifyList [$k] ['date'] = "";
  5534. $verifyList [$k] ['opinion'] = "";
  5535. $verifyList [$k] ['status'] = "";
  5536. if (empty ( $verifyStaff )) {
  5537. $verifyList [$k] ['date'] = "";
  5538. $verifyList [$k] ['opinion'] = "";
  5539. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5540. $verifyList [$k] ['status'] = 4;
  5541. $button = 4;
  5542. $flag = false;
  5543. }
  5544. } else {
  5545. foreach ( $verifyStaff as $m => $u ) {
  5546. if ($v [0] == $m) {
  5547. $verifyList [$k] ['date'] = $u ['date'];
  5548. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5549. $verifyList [$k] ['status'] = $u ['status'];
  5550. $flag = false;
  5551. break;
  5552. }
  5553. }
  5554. $endStaffArray = end ( $verifyStaff );
  5555. if (isset ( $endStaffArray ['ROLE'] )) {
  5556. } else {
  5557. $endKey = key ( $verifyStaff );
  5558. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5559. $button = 4;
  5560. $verifyList [$k] ['status'] = 4;
  5561. }
  5562. }
  5563. }
  5564. }
  5565. $rolename ['name'] = '';
  5566. if (! empty ( $roleId )) {
  5567. Doo::loadModel ( 'role' );
  5568. $role = new role ();
  5569. $rolename = $role->getOne ( array (
  5570. 'where' => 'rid=' . $roleId,
  5571. 'asArray' => true
  5572. ) );
  5573. }
  5574. if (! empty ( $verifyStaff ))
  5575. $endStaffArray = end ( $verifyStaff );
  5576. $KOP = false;
  5577. foreach ( $roleArrayCopy as $P => $A ) {
  5578. foreach ( $A as $MKI => $AVL ) {
  5579. if (! empty ( $verifyStaff )) {
  5580. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5581. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5582. $button = 4;
  5583. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5584. }
  5585. foreach ( $verifyStaff as $m => $u ) {
  5586. $AVLFK = $AVL [0] . '_R';
  5587. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5588. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5589. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5590. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5591. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5592. break;
  5593. }
  5594. }
  5595. } else {
  5596. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5597. $button = 4;
  5598. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5599. }
  5600. }
  5601. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5602. $KOP = true;
  5603. }
  5604. }
  5605. foreach ( $roleArrayCopy as $k => $v ) {
  5606. foreach ( $verifyList as $m => $n ) {
  5607. if ($n [0] == $k) {
  5608. array_splice ( $verifyList, $m, 1, $v );
  5609. }
  5610. }
  5611. }
  5612. // print_r($verifyList);
  5613. $receiptList [$key] ['verifyList'] = $verifyList;
  5614. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5615. 'where' => 'sid=' . $value ['staff'],
  5616. 'asArray' => true
  5617. ) );
  5618. $receiptList [$key] ['button'] = $button;
  5619. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5620. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5621. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5622. $receiptList [$key] ['relust'] = $relust;
  5623. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  5624. }
  5625. // print_r($receiptList);die;
  5626. // $data['verifyDetail']=$verifyDetail;
  5627. $mothHtml = "";
  5628. for($i = 1; $i <= 12; $i ++) {
  5629. if ($month == $i)
  5630. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5631. else
  5632. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5633. }
  5634. // 获取审批日志
  5635. Doo::loadModel ( 'receiptLog' );
  5636. $receiptLog = new receiptLog ();
  5637. $rlList = array ();
  5638. $rlInfo = $receiptLog->getOne ( array (
  5639. 'where' => 'rid=' . $rid . ' and status=4',
  5640. 'asArray' => true
  5641. ) );
  5642. $tijdate = $receiptLog->getOne ( array (
  5643. 'where' => 'rid=' . $rid . ' and status=2',
  5644. 'asc' => 'rlid',
  5645. 'asArray' => true
  5646. ) );
  5647. if (! empty ( $rlInfo )) {
  5648. $rlList = $receiptLog->find ( array (
  5649. 'where' => 'rid=' . $rid,
  5650. 'asc' => 'rlid',
  5651. 'asArray' => true
  5652. ) );
  5653. }
  5654. // echo $rid;
  5655. // print_r($receiptList);
  5656. $receiptList [0] ['rlList'] = $rlList;
  5657. // print_r($receiptList);
  5658. $enclosurList = $enclosur->find ( array (
  5659. 'where' => 'rid=' . $rid,
  5660. 'asArray' => true
  5661. ) );
  5662. $enclosurHtml = '';
  5663. foreach ( $enclosurList as $value ) {
  5664. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5665. }
  5666. $data ['enclosurHtml'] = $enclosurHtml;
  5667. $data ['rolename'] = $rolename ['name'];
  5668. $data ['mothHtml'] = $mothHtml;
  5669. // print_r($receiptList);
  5670. $data ['rid'] = $rid;
  5671. $data ['tijdate'] = $tijdate ['date'];
  5672. $data ['receiptList'] = $receiptList;
  5673. $data ['receiptApprovalCount'] = count ( $receiptList );
  5674. $data ['status'] = $status;
  5675. $data ['year'] = $year;
  5676. $data ['categoryList'] = $categoryList;
  5677. $data ['staffList'] = $staffList;
  5678. $data ['cid'] = $cid;
  5679. $data ['sid'] = $sid;
  5680. $data ['ap'] = $ap;
  5681. $data ['memu'] = "receipt";
  5682. $data ['staff'] = $this->staff;
  5683. $data ['receiptMemu'] = 'approvalExpenses';
  5684. $data ['verifyId'] = $this->verifyId;
  5685. $data ['executeId'] = $this->executeId;
  5686. $this->render ( "/admin/receiptburEdi", $data );
  5687. }
  5688. function hisImplement() {
  5689. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  5690. if (empty ( $item ))
  5691. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  5692. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  5693. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  5694. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  5695. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  5696. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  5697. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  5698. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  5699. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  5700. Doo::loadClass ( 'XDeode' );
  5701. $XDeode = new XDeode ( 5 );
  5702. Doo::loadModel ( 'receipt' );
  5703. $receipt = new receipt ();
  5704. Doo::loadModel ( 'L_category' );
  5705. $Lcategory = new L_category ();
  5706. Doo::loadModel ( 'verify' );
  5707. Doo::loadModel ( 'statistics' );
  5708. $statistics = new statistics ();
  5709. $verify = new verify ();
  5710. Doo::loadModel ( 'staff' );
  5711. $staff = new staff ();
  5712. Doo::loadClass ( 'XDeode' );
  5713. $XDeode = new XDeode ( 5 );
  5714. $XDeode7 = new XDeode ( 7 );
  5715. $cid = $XDeode->decode ( $cidKey );
  5716. $condition = "";
  5717. if ($item == "expenses")
  5718. $condition = " and Rtype=1 ";
  5719. elseif ($item == "receipts")
  5720. $condition = " and Rtype=0 ";
  5721. elseif ($item == "remits")
  5722. $condition = " and Rtype=2 ";
  5723. elseif($item == "train")
  5724. $condition = " and Rtype=3 ";
  5725. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  5726. $sopString = $cidString = "";
  5727. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  5728. if (empty ( $rdate ))
  5729. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  5730. else
  5731. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  5732. if ($status == 'pendImplement') {
  5733. $condition .= ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  5734. } elseif ($status == 'alerpts') {
  5735. $statusCon = '(status=8 or status=9 )';
  5736. if (empty ( $rdate ))
  5737. $dateCondition .= " and Year(date) =" . $year;
  5738. else
  5739. $dateCondition .= " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  5740. }
  5741. if ($sop != 'SOP')
  5742. $sopString = " and staff=" . $sop;
  5743. if ($cidKey != 'ALL')
  5744. $cidString = " and cid=" . $cid;
  5745. if(!empty($receiptOrder)){
  5746. $receiptList = $receipt->find ( array (
  5747. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  5748. 'desc' => 'rid',
  5749. 'asArray' => true
  5750. ) );
  5751. // 员工筛选
  5752. $receiptList2 = $receipt->find ( array (
  5753. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  5754. 'desc' => 'rid',
  5755. 'asArray' => true
  5756. ) );
  5757. }else{
  5758. $receiptList = $receipt->find ( array (
  5759. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  5760. 'desc' => 'rid',
  5761. 'asArray' => true
  5762. ) );
  5763. // 员工筛选
  5764. $receiptList2 = $receipt->find ( array (
  5765. 'where' => $statusCon . $condition . $dateCondition,
  5766. 'desc' => 'rid',
  5767. 'asArray' => true
  5768. ) );
  5769. }
  5770. $sopStaff = array ();
  5771. foreach ( $receiptList2 as $key => $value ) {
  5772. $staffDetail = $staff->getOne ( array (
  5773. 'select' => 'username',
  5774. 'where' => 'sid=' . $value ['staff'],
  5775. 'asArray' => true
  5776. ) );
  5777. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  5778. }
  5779. // 办事处筛选
  5780. $categoryScreen = array ();
  5781. $categorList = $Lcategory->getCategory ();
  5782. foreach ( $receiptList2 as $key => $value ) {
  5783. foreach ( $categorList as $k => $v ) {
  5784. if ($value ['cid'] == $v ['cid']) {
  5785. $categoryScreen [$v ['cidKey']] = $v ['title'];
  5786. break;
  5787. }
  5788. }
  5789. }
  5790. $categoryScreenHtml = "";
  5791. foreach ( $categoryScreen as $key => $value ) {
  5792. if ($cidKey == $key)
  5793. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  5794. else
  5795. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  5796. }
  5797. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  5798. $data ['cidKey'] = $cidKey;
  5799. $Locate = 0;
  5800. $roleId = 0;
  5801. $button = 0;
  5802. $staffBatchNumber = 100001;
  5803. $remittanceList = array ();
  5804. foreach ( $receiptList as $key => $value ) {
  5805. $receiptList [$key] ['ridKey7'] = $XDeode7->encode ( $value ['rid'] );
  5806. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  5807. $receiptList [$key] ['Texe'] = 'false';
  5808. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  5809. $receiptList [$key] ['Texe'] = 'true';
  5810. }
  5811. $receiptList [$key] ['TRexe'] = 'true';
  5812. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  5813. $receiptList [$key] ['TRexe'] = 'false';
  5814. }
  5815. $receiptList [$key] ['Locate'] = $Locate;
  5816. $Locate ++;
  5817. $receiptList [$key] ['reviseDetail'] = array ();
  5818. if (! empty ( $value ['reviseDetail'] ))
  5819. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5820. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5821. $categoryDetil = $Lcategory->getOne ( array (
  5822. 'where' => 'cid=' . $value ['cid'],
  5823. 'asArray' => true
  5824. ) );
  5825. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5826. // 检测编辑状态
  5827. $verifyList = $verify->getOne ( array (
  5828. 'where' => 'vid=' . $value ['verify'],
  5829. 'asArray' => true
  5830. ) );
  5831. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5832. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5833. Doo::loadModel ( 'role' );
  5834. $role = new role ();
  5835. $flag = true;
  5836. $roleKey = 0;
  5837. $endStaffArray = array ();
  5838. $roleArrayCopy = array ();
  5839. foreach ( $verifyList as $k => $v ) {
  5840. // init verifyStaff
  5841. if ($v [1] == 'ROLE') {
  5842. if (! empty ( $verifyStaff )) {
  5843. $endStaffArray = end ( $verifyStaff );
  5844. }
  5845. $roleVerify = json_decode ( $v [3], true );
  5846. $roleKey = $k;
  5847. $roleArray = array ();
  5848. $rolename = $role->getOne ( array (
  5849. 'where' => 'rid=' . $v [0],
  5850. 'asArray' => true
  5851. ) );
  5852. foreach ( $roleVerify as $o => $p ) {
  5853. $staffID = explode ( '_', $p );
  5854. $staffInfo = $staff->getOne ( array (
  5855. 'where' => 'sid=' . $staffID [0],
  5856. 'asArray' => true
  5857. ) );
  5858. $exp = array (
  5859. 0 => $staffInfo ['sid'],
  5860. 1 => $staffID [1],
  5861. 2 => $staffInfo ['avatar'],
  5862. 'date' => '',
  5863. 'date' => '',
  5864. 'opinion' => '',
  5865. 'status' => '',
  5866. 'rolename' => $rolename ['name']
  5867. );
  5868. array_push ( $roleArray, $exp );
  5869. }
  5870. $roleArrayCopy [$v [0]] = $roleArray;
  5871. }
  5872. $verifyList [$k] ['date'] = "";
  5873. $verifyList [$k] ['opinion'] = "";
  5874. $verifyList [$k] ['status'] = "";
  5875. if (empty ( $verifyStaff )) {
  5876. $verifyList [$k] ['date'] = "";
  5877. $verifyList [$k] ['opinion'] = "";
  5878. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5879. $verifyList [$k] ['status'] = 4;
  5880. $flag = false;
  5881. }
  5882. } else {
  5883. foreach ( $verifyStaff as $m => $u ) {
  5884. if ($v [0] == $m) {
  5885. $verifyList [$k] ['date'] = $u ['date'];
  5886. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5887. $verifyList [$k] ['status'] = $u ['status'];
  5888. $flag = false;
  5889. break;
  5890. }
  5891. }
  5892. $endStaffArray = end ( $verifyStaff );
  5893. }
  5894. }
  5895. $rolename ['name'] = '';
  5896. if (! empty ( $roleId )) {
  5897. Doo::loadModel ( 'role' );
  5898. $role = new role ();
  5899. $rolename = $role->getOne ( array (
  5900. 'where' => 'rid=' . $roleId,
  5901. 'asArray' => true
  5902. ) );
  5903. }
  5904. if (! empty ( $verifyStaff ))
  5905. $endStaffArray = end ( $verifyStaff );
  5906. $KOP = false;
  5907. foreach ( $roleArrayCopy as $P => $A ) {
  5908. foreach ( $A as $MKI => $AVL ) {
  5909. if (! empty ( $verifyStaff )) {
  5910. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5911. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5912. $button = 4;
  5913. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5914. }
  5915. foreach ( $verifyStaff as $m => $u ) {
  5916. $AVLFK = $AVL [0] . '_R';
  5917. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5918. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5919. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5920. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5921. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5922. break;
  5923. }
  5924. }
  5925. } else {
  5926. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5927. $button = 4;
  5928. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5929. }
  5930. }
  5931. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5932. $KOP = true;
  5933. }
  5934. }
  5935. foreach ( $roleArrayCopy as $k => $v ) {
  5936. foreach ( $verifyList as $m => $n ) {
  5937. if ($n [0] == $k) {
  5938. array_splice ( $verifyList, $m, 1, $v );
  5939. }
  5940. }
  5941. }
  5942. $receiptList [$key] ['verifyList'] = $verifyList;
  5943. $staffDetail = $staff->getOne ( array (
  5944. 'where' => 'sid=' . $value ['staff'],
  5945. 'asArray' => true
  5946. ) );
  5947. $receiptList [$key] ['staffDetail'] = $staffDetail;
  5948. $receiptList [$key] ['button'] = $button;
  5949. // 设置导出汇款execl
  5950. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  5951. $remittanceDetail = array (
  5952. $staffBatchNumber,
  5953. $value ['remittanceName'],
  5954. $value ['bankNumber'],
  5955. $value ['bankName'],
  5956. $value ['remittanceBankType'],
  5957. $value ['coupletNumber'],
  5958. $value ['sum']
  5959. );
  5960. array_push ( $remittanceList, $remittanceDetail );
  5961. $staffBatchNumber ++;
  5962. }
  5963. }
  5964. $data ['remittanceList'] = json_encode ( $remittanceList );
  5965. // print_r($receiptList);
  5966. $mothHtml = "";
  5967. for($i = 1; $i <= 12; $i ++) {
  5968. if ($moth == $i)
  5969. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5970. else
  5971. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5972. }
  5973. $dayHtml = "";
  5974. if ($day != "DAY" || $moth != "MONTH") {
  5975. for($i = 1; $i <= 31; $i ++) {
  5976. if ($day == $i)
  5977. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  5978. else
  5979. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  5980. }
  5981. }
  5982. $sopHtml = "";
  5983. foreach ( $sopStaff as $key => $value ) {
  5984. if ($sop == $key)
  5985. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  5986. else
  5987. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  5988. }
  5989. $data ['status'] = $status;
  5990. $data ['rdate'] = $rdate;
  5991. $data ['sopHtml'] = $sopHtml;
  5992. $data ['dayHtml'] = $dayHtml;
  5993. $data ['mothHtml'] = $mothHtml;
  5994. $data ['receiptList'] = $receiptList;
  5995. $data ['memu'] = "receipt";
  5996. $data ['staff'] = $this->staff;
  5997. $data ['receiptMemu'] = 'implement';
  5998. $data ['verifyId'] = $this->verifyId;
  5999. $data ['executeId'] = $this->executeId;
  6000. $data ['item'] = $item;
  6001. $data ['year'] = $year;
  6002. $data ['moth'] = $moth;
  6003. $data['receiptOrder']=$receiptOrder;
  6004. $data ['day'] = $day;
  6005. $data ['sop'] = $sop;
  6006. $this->render ( "/admin/hisImplement", $data );
  6007. }
  6008. /**
  6009. * 导出汇款信息的exelc
  6010. */
  6011. function exportRemittance() {
  6012. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  6013. if (empty ( $remittanceInfo ))
  6014. die ( 'illegal request' );
  6015. $title = array (
  6016. '员工编号',
  6017. '姓名',
  6018. '员工账号',
  6019. '员工账户开户行',
  6020. '转账类型',
  6021. '联行号',
  6022. '金额'
  6023. );
  6024. $data = json_decode ( $remittanceInfo, true );
  6025. if (empty ( $data ))
  6026. die ( 'illegal request' );
  6027. Doo::loadClass ( 'receipt.func' );
  6028. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  6029. header ( 'Content-Type:text/html;charset=utf-8' );
  6030. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  6031. }
  6032. function ajaxExamine() {
  6033. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6034. Doo::loadModel ( 'receipt' );
  6035. $receipt = new receipt ();
  6036. if (! empty ( $rid )) {
  6037. $rLRes = $receipt->find ( array (
  6038. '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,
  6039. 'asArray' => true
  6040. ) );
  6041. echo json_encode ( array (
  6042. 'status' => 1,
  6043. 'receipt' => $rLRes [0]
  6044. ) );
  6045. die ();
  6046. }
  6047. echo json_encode ( array (
  6048. 'status' => 0,
  6049. 'receipt' => array ()
  6050. ) );
  6051. die ();
  6052. }
  6053. /*
  6054. * 废弃
  6055. */
  6056. function myReceipt() {
  6057. // all approval past withdraw
  6058. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  6059. if (empty ( $item ))
  6060. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  6061. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6062. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  6063. Doo::loadModel ( 'receipt' );
  6064. $receipt = new receipt ();
  6065. // pre-loaded
  6066. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  6067. // have cache
  6068. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  6069. if (! empty ( $moth )) // yearPage
  6070. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  6071. $this->showCache ( $path );
  6072. }
  6073. Doo::loadModel ( 'L_category' );
  6074. $Lcategory = new L_category ();
  6075. Doo::loadModel ( 'verify' );
  6076. Doo::loadModel ( 'statistics' );
  6077. $statistics = new statistics ();
  6078. $verify = new verify ();
  6079. Doo::loadModel ( 'staff' );
  6080. $staff = new staff ();
  6081. $condition = " and status!=0 ";
  6082. if ($item == "approval")
  6083. $condition = " and status=2 ";
  6084. elseif ($item == "withdraw")
  6085. $condition = " and status=3 ";
  6086. elseif ($item == "past")
  6087. $condition = " and status=1 ";
  6088. elseif ($item == "whdw")
  6089. $condition = " and status=4 ";
  6090. $dateCondition = " and Year(date) =" . $year;
  6091. if (! empty ( $moth )) {
  6092. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  6093. $stList = $statistics->getOne ( array (
  6094. 'select' => 'rePrice ,agPrice',
  6095. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  6096. 'asArray' => true
  6097. ) );
  6098. } else
  6099. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  6100. if (empty ( $stList ))
  6101. $stList = array (
  6102. 'rePrice' => 0,
  6103. 'agPrice' => 0
  6104. );
  6105. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  6106. $data ['stList'] = array (
  6107. 'rePrice' => $stList ['rePrice'],
  6108. 'agPrice' => $stList ['agPrice'],
  6109. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  6110. );
  6111. $receiptList = $receipt->find ( array (
  6112. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  6113. 'desc' => 'rid',
  6114. 'asArray' => true
  6115. ) );
  6116. $Locate = 0;
  6117. $roleId = 0;
  6118. $button = 0;
  6119. foreach ( $receiptList as $key => $value ) {
  6120. $receiptList [$key] ['Locate'] = $Locate;
  6121. $Locate ++;
  6122. $receiptList [$key] ['reviseDetail'] = array ();
  6123. if (! empty ( $value ['reviseDetail'] ))
  6124. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6125. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6126. $categoryDetil = $Lcategory->getOne ( array (
  6127. 'where' => 'cid=' . $value ['cid'],
  6128. 'asArray' => true
  6129. ) );
  6130. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6131. // 检测编辑状态
  6132. $verifyList = $verify->getOne ( array (
  6133. 'where' => 'vid=' . $value ['verify'],
  6134. 'asArray' => true
  6135. ) );
  6136. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6137. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6138. Doo::loadModel ( 'role' );
  6139. $role = new role ();
  6140. $flag = true;
  6141. $roleKey = 0;
  6142. $endStaffArray = array ();
  6143. $roleArrayCopy = array ();
  6144. foreach ( $verifyList as $k => $v ) {
  6145. // init verifyStaff
  6146. if ($v [1] == 'ROLE') {
  6147. if (! empty ( $verifyStaff )) {
  6148. $endStaffArray = end ( $verifyStaff );
  6149. // if ($v[0]==$endStaffArray['nextStaff']){
  6150. // $roleId=$v[0];
  6151. // }
  6152. }
  6153. $roleVerify = json_decode ( $v [3], true );
  6154. $roleKey = $k;
  6155. $roleArray = array ();
  6156. $rolename = $role->getOne ( array (
  6157. 'where' => 'rid=' . $v [0],
  6158. 'asArray' => true
  6159. ) );
  6160. foreach ( $roleVerify as $o => $p ) {
  6161. $staffID = explode ( '_', $p );
  6162. $staffInfo = $staff->getOne ( array (
  6163. 'where' => 'sid=' . $staffID [0],
  6164. 'asArray' => true
  6165. ) );
  6166. // print_r($staffID);
  6167. $exp = array (
  6168. 0 => $staffInfo ['sid'],
  6169. 1 => $staffID [1],
  6170. 2 => $staffInfo ['avatar'],
  6171. 'date' => '',
  6172. 'date' => '',
  6173. 'opinion' => '',
  6174. 'status' => '',
  6175. 'rolename' => $rolename ['name']
  6176. );
  6177. array_push ( $roleArray, $exp );
  6178. }
  6179. $roleArrayCopy [$v [0]] = $roleArray;
  6180. // $verifyList[$k]['roleArray']=$roleArray;
  6181. }
  6182. $verifyList [$k] ['date'] = "";
  6183. $verifyList [$k] ['opinion'] = "";
  6184. $verifyList [$k] ['status'] = "";
  6185. if (empty ( $verifyStaff )) {
  6186. $verifyList [$k] ['date'] = "";
  6187. $verifyList [$k] ['opinion'] = "";
  6188. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6189. $verifyList [$k] ['status'] = 4;
  6190. $flag = false;
  6191. }
  6192. } else {
  6193. foreach ( $verifyStaff as $m => $u ) {
  6194. if ($v [0] == $m) {
  6195. $verifyList [$k] ['date'] = $u ['date'];
  6196. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6197. $verifyList [$k] ['status'] = $u ['status'];
  6198. $flag = false;
  6199. break;
  6200. }
  6201. }
  6202. $endStaffArray = end ( $verifyStaff );
  6203. if (isset ( $endStaffArray ['ROLE'] )) {
  6204. } else {
  6205. // $endKey=key($verifyStaff);
  6206. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  6207. // $button=4;
  6208. // $verifyList[$k]['status']=4;
  6209. // }
  6210. }
  6211. }
  6212. }
  6213. $rolename ['name'] = '';
  6214. if (! empty ( $roleId )) {
  6215. Doo::loadModel ( 'role' );
  6216. $role = new role ();
  6217. $rolename = $role->getOne ( array (
  6218. 'where' => 'rid=' . $roleId,
  6219. 'asArray' => true
  6220. ) );
  6221. }
  6222. if (! empty ( $verifyStaff ))
  6223. $endStaffArray = end ( $verifyStaff );
  6224. $KOP = false;
  6225. foreach ( $roleArrayCopy as $P => $A ) {
  6226. foreach ( $A as $MKI => $AVL ) {
  6227. if (! empty ( $verifyStaff )) {
  6228. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6229. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6230. $button = 4;
  6231. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6232. }
  6233. foreach ( $verifyStaff as $m => $u ) {
  6234. $AVLFK = $AVL [0] . '_R';
  6235. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6236. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6237. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6238. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6239. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6240. break;
  6241. }
  6242. }
  6243. } else {
  6244. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6245. $button = 4;
  6246. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6247. }
  6248. }
  6249. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6250. $KOP = true;
  6251. }
  6252. }
  6253. foreach ( $roleArrayCopy as $k => $v ) {
  6254. foreach ( $verifyList as $m => $n ) {
  6255. if ($n [0] == $k) {
  6256. array_splice ( $verifyList, $m, 1, $v );
  6257. }
  6258. }
  6259. }
  6260. $receiptList [$key] ['verifyList'] = $verifyList;
  6261. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6262. 'where' => 'sid=' . $value ['staff'],
  6263. 'asArray' => true
  6264. ) );
  6265. $receiptList [$key] ['button'] = $button;
  6266. }
  6267. // print_r($receiptList);die;
  6268. $mothHtml = "";
  6269. for($i = 1; $i <= 12; $i ++) {
  6270. if ($moth == $i)
  6271. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6272. else
  6273. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6274. }
  6275. $data ['mothHtml'] = $mothHtml;
  6276. $data ['receiptList'] = $receiptList;
  6277. $data ['memu'] = "receipt";
  6278. $data ['staff'] = $this->staff;
  6279. $data ['receiptMemu'] = 'receipt';
  6280. $data ['verifyId'] = $this->verifyId;
  6281. $data ['executeId'] = $this->executeId;
  6282. $data ['item'] = $item;
  6283. $data ['year'] = $year;
  6284. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  6285. // sufficient condition to generate cache
  6286. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  6287. $receiptList = $receipt->find ( array (
  6288. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  6289. 'asArray' => true
  6290. ) );
  6291. if (empty ( $receiptList )) { // generated files
  6292. ob_start ();
  6293. $this->render ( "/admin/saea_myList", $data );
  6294. $this->cacheFile ( $path );
  6295. die ();
  6296. // $content = ob_get_contents();
  6297. // $fp = fopen($path, "w");
  6298. // fwrite($fp, $content);
  6299. // fclose($fp);
  6300. }
  6301. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  6302. $receiptList = $receipt->find ( array (
  6303. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  6304. 'asArray' => true
  6305. ) );
  6306. if (empty ( $receiptList )) { // generated files
  6307. ob_start ();
  6308. $this->render ( "/admin/saea_myList", $data );
  6309. $this->cacheFile ( $path );
  6310. die ();
  6311. }
  6312. }
  6313. }
  6314. $this->render ( "/admin/saea_myList", $data );
  6315. }
  6316. function saeaCreate() {
  6317. Doo::loadModel ( 'accountItem' );
  6318. Doo::loadModel ( 'verify' );
  6319. Doo::loadModel ( 'receipt' );
  6320. Doo::loadModel ( 'L_category' );
  6321. $lCategory = new L_category ();
  6322. $receipt = new receipt ();
  6323. $verify = new verify ();
  6324. $accountItem = new accountItem ();
  6325. Doo::loadModel ( "role" );
  6326. $role = new role ();
  6327. $acItem = $accountItem->find ( array (
  6328. 'asArray' => true
  6329. ) );
  6330. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  6331. $data ['category'] = $lCategory->find ( array (
  6332. 'asArray' => true
  6333. ) );
  6334. $data ['veList'] = $veList;
  6335. $data ['acItem'] = $acItem;
  6336. $data ['memu'] = "receipt";
  6337. $data ['staff'] = $this->staff;
  6338. $data ['receiptMemu'] = 'saeaBorad';
  6339. $data ['verifyId'] = $this->verifyId;
  6340. $data ['executeId'] = $this->executeId;
  6341. $this->render ( "/admin/saea_create", $data );
  6342. }
  6343. function addReceipt() {
  6344. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  6345. $agency = $this->get_args ( 'agency' );
  6346. $travel = $this->get_args ( 'travel' );
  6347. $train = $this->get_args ( 'train' );
  6348. $other = $this->get_args ( 'other' );
  6349. $inttrain = $this->get_args ( 'inttrain' );
  6350. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  6351. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  6352. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  6353. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  6354. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  6355. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  6356. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  6357. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  6358. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  6359. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  6360. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  6361. header ( 'Content-Type:text/html;charset=utf-8' );
  6362. die ( '请填写联行号' );
  6363. }
  6364. Doo::loadModel ( 'receipt' );
  6365. Doo::loadModel ( 'receiptDetail' );
  6366. Doo::loadModel ( 'accountItem' );
  6367. $accountItem = new accountItem ();
  6368. $receipt = new receipt ();
  6369. Doo::loadModel ( 'enclosur' );
  6370. Doo::loadModel ( 'execute' );
  6371. $execute = new execute ();
  6372. $executeDetail = $execute->getOne ( array (
  6373. 'where' => 'mold="报销单执行人"',
  6374. 'asArray' => true
  6375. ) );
  6376. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  6377. // if(!empty($receiptDetail))
  6378. // return "/referReceipt/".$receiptDetail['rid'];
  6379. $aItem = $accountItem->find ( array (
  6380. 'asArray' => true
  6381. ) );
  6382. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  6383. $ag = $tr = $ta = $ot= $it = 0;
  6384. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  6385. foreach ( $aItem as $key => $value ) {
  6386. if ($value ['category'] == $this->AGENCY) {
  6387. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  6388. array_push ( $accountJson [$this->AGENCY], array (
  6389. 'aid' => $value ['aid'],
  6390. 'name' => $value ['name'],
  6391. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  6392. ) );
  6393. $sum += $agency [$ag];
  6394. $agencySum += $agency [$ag];
  6395. }
  6396. $ag ++;
  6397. }
  6398. if ($value ['category'] == $this->TRAVEL) {
  6399. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  6400. array_push ( $accountJson [$this->TRAVEL], array (
  6401. 'aid' => $value ['aid'],
  6402. 'name' => $value ['name'],
  6403. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  6404. ) );
  6405. $sum += $travel [$tr];
  6406. $travelSum += $travel [$tr];
  6407. }
  6408. $tr ++;
  6409. }
  6410. if ($value ['category'] == $this->TRAIN) {
  6411. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  6412. array_push ( $accountJson [$this->TRAIN], array (
  6413. 'aid' => $value ['aid'],
  6414. 'name' => $value ['name'],
  6415. 'price' => number_format ( $train [$ta], 2, '.', '' )
  6416. ) );
  6417. $sum += $train [$ta];
  6418. $trainSum += $train [$ta];
  6419. }
  6420. $ta ++;
  6421. }
  6422. if ($value ['category'] == $this->INTTRAIN) {
  6423. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  6424. array_push ( $accountJson [$this->INTTRAIN], array (
  6425. 'aid' => $value ['aid'],
  6426. 'name' => $value ['name'],
  6427. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  6428. ) );
  6429. $sum += $inttrain [$it];
  6430. $inttrainSum += $inttrain [$it];
  6431. }
  6432. $it ++;
  6433. }
  6434. if ($value ['category'] == $this->OTHER) {
  6435. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  6436. array_push ( $accountJson [$this->OTHER], array (
  6437. 'aid' => $value ['aid'],
  6438. 'name' => $value ['name'],
  6439. 'price' => number_format ( $other [$ot], 2, '.', '' )
  6440. ) );
  6441. $sum += $other [$ot];
  6442. $otherSum += $other [$ot];
  6443. }
  6444. $ot ++;
  6445. }
  6446. }
  6447. $accountJson ['cSum'] = array (
  6448. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  6449. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  6450. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  6451. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  6452. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  6453. );
  6454. // 报销单
  6455. $receipt->accountItem = json_encode ( $accountJson );
  6456. $receipt->staff = $this->staff [0] ['sid'];
  6457. $receipt->sum = number_format ( $sum, 2, '.', '' );
  6458. $receipt->date = date ( "Y-m-d" );
  6459. $receipt->cid = $cid;
  6460. $receipt->status = 5;
  6461. // 修改审批流程加入角色
  6462. $receipt->verify = $verify;
  6463. $receipt->executeCopy = $executeDetail ['staff'];
  6464. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  6465. $order = array (
  6466. "\r\n",
  6467. "\n",
  6468. "\r"
  6469. );
  6470. $replace = '<br/>';
  6471. $explanation = str_replace ( $order, $replace, $explanation );
  6472. $receipt->explanation = $explanation;
  6473. $receipt->remittanceName = $remittanceName;
  6474. $receipt->bankName = $bankName;
  6475. $receipt->bankNumber = $bankNumber;
  6476. $receipt->remittanceBankType = $remittanceBankType;
  6477. if ($remittanceBankType == 1)
  6478. $receipt->coupletNumber = $coupletNumber;
  6479. $rid = $receipt->insert ();
  6480. // 附件
  6481. if (! empty ( $enclosurName )) {
  6482. $enclosurArray = explode ( '-', $enclosurName );
  6483. foreach ( $enclosurArray as $value ) {
  6484. $enclosur = new enclosur ();
  6485. $enclosur->name = $value;
  6486. $enclosur->rid = $rid;
  6487. $enclosur->insert ();
  6488. }
  6489. // print_r($enclosurArray);die;
  6490. }
  6491. // 报销详情
  6492. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  6493. $receiptDetail = new receiptDetail ();
  6494. $receiptDetail->staff = $this->staff [0] ['sid'];
  6495. $receiptDetail->item = $value ['name'];
  6496. $receiptDetail->itemCategory = $this->AGENCY;
  6497. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6498. $receiptDetail->date = date ( "Y-m-d" );
  6499. $receiptDetail->cid = $cid;
  6500. $receiptDetail->rid = $rid;
  6501. $receiptDetail->status = 4;
  6502. $receiptDetail->insert ();
  6503. }
  6504. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  6505. $receiptDetail = new receiptDetail ();
  6506. $receiptDetail->staff = $this->staff [0] ['sid'];
  6507. $receiptDetail->item = $value ['name'];
  6508. $receiptDetail->itemCategory = $this->TRAVEL;
  6509. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6510. $receiptDetail->date = date ( "Y-m-d" );
  6511. $receiptDetail->cid = $cid;
  6512. $receiptDetail->rid = $rid;
  6513. $receiptDetail->status = 4;
  6514. $receiptDetail->insert ();
  6515. }
  6516. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  6517. $receiptDetail = new receiptDetail ();
  6518. $receiptDetail->staff = $this->staff [0] ['sid'];
  6519. $receiptDetail->item = $value ['name'];
  6520. $receiptDetail->itemCategory = $this->TRAIN;
  6521. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6522. $receiptDetail->date = date ( "Y-m-d" );
  6523. $receiptDetail->cid = $cid;
  6524. $receiptDetail->rid = $rid;
  6525. $receiptDetail->status = 4;
  6526. $receiptDetail->insert ();
  6527. }
  6528. //内训
  6529. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  6530. $receiptDetail = new receiptDetail ();
  6531. $receiptDetail->staff = $this->staff [0] ['sid'];
  6532. $receiptDetail->item = $value ['name'];
  6533. $receiptDetail->itemCategory = $this->INTTRAIN;
  6534. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6535. $receiptDetail->date = date ( "Y-m-d" );
  6536. $receiptDetail->cid = $cid;
  6537. $receiptDetail->rid = $rid;
  6538. $receiptDetail->status = 4;
  6539. $receiptDetail->insert ();
  6540. }
  6541. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  6542. $receiptDetail = new receiptDetail ();
  6543. $receiptDetail->staff = $this->staff [0] ['sid'];
  6544. $receiptDetail->item = $value ['name'];
  6545. $receiptDetail->itemCategory = $this->OTHER;
  6546. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6547. $receiptDetail->date = date ( "Y-m-d" );
  6548. $receiptDetail->cid = $cid;
  6549. $receiptDetail->rid = $rid;
  6550. $receiptDetail->status = 4;
  6551. $receiptDetail->insert ();
  6552. }
  6553. return "/saeaBorad";
  6554. } else
  6555. die ( 'illegal request' );
  6556. }
  6557. function referReceipt() {
  6558. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  6559. Doo::loadModel ( 'receipt' );
  6560. Doo::loadModel ( 'verify' );
  6561. $verify = new verify ();
  6562. $receipt = new receipt ();
  6563. Doo::loadModel ( 'L_category' );
  6564. $lCategory = new L_category ();
  6565. Doo::loadModel ( "role" );
  6566. $role = new role ();
  6567. $receiptDetail = $receipt->find ( array (
  6568. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  6569. 'asArray' => true
  6570. ) );
  6571. if (empty ( $receiptDetail ))
  6572. return "/addReceipt";
  6573. foreach ( $receiptDetail as $key => $value ) {
  6574. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6575. $veList = $verify->getOne ( array (
  6576. 'where' => 'vid=' . $value ['verify'],
  6577. 'asArray' => true
  6578. ) );
  6579. $v = json_decode ( $veList ['staff'] );
  6580. array_push ( $v [0], $veList ['description'] );
  6581. foreach ( $v as $n => $m ) {
  6582. if ($m ['1'] == 'ROLE') {
  6583. $roleInfo = $role->getOne ( array (
  6584. 'where' => 'rid=' . $m [0],
  6585. 'asArray' => true
  6586. ) );
  6587. $v [$n] [1] = $roleInfo ['name'];
  6588. }
  6589. }
  6590. $receiptDetail [$key] ['staff'] = $v;
  6591. $category = $lCategory->getOne ( array (
  6592. 'where' => 'cid=' . $value ['cid'],
  6593. 'asArray' => true
  6594. ) );
  6595. $receiptDetail [$key] ['category'] = $category ['title'];
  6596. }
  6597. // print_r($receiptDetail);
  6598. $data ['receiptDetail'] = $receiptDetail;
  6599. $data ['memu'] = "receipt";
  6600. $data ['staff'] = $this->staff;
  6601. $data ['receiptMemu'] = 'saeaCreate';
  6602. $data ['verifyId'] = $this->verifyId;
  6603. $data ['executeId'] = $this->executeId;
  6604. $this->render ( "/admin/saea_confirm", $data );
  6605. }
  6606. function editReceipt() {
  6607. // edit status 4
  6608. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  6609. Doo::loadClass ( 'XDeode' );
  6610. $XDeode = new XDeode ( 7 );
  6611. $rid = $XDeode->decode ( $ridKey );
  6612. if (empty ( $rid ))
  6613. die ( 'illegal request' );
  6614. // echo $rid.'sd';
  6615. Doo::loadModel ( 'accountItem' );
  6616. Doo::loadModel ( 'verify' );
  6617. Doo::loadModel ( 'receipt' );
  6618. $receipt = new receipt ();
  6619. $verify = new verify ();
  6620. $accountItem = new accountItem ();
  6621. Doo::loadModel ( 'L_category' );
  6622. $lCategory = new L_category ();
  6623. Doo::loadModel ( "role" );
  6624. $role = new role ();
  6625. Doo::loadModel ( 'enclosur' );
  6626. $enclosur = new enclosur ();
  6627. $receiptDetail = $receipt->getOne ( array (
  6628. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  6629. 'asArray' => true
  6630. ) );
  6631. if (empty ( $receiptDetail ))
  6632. die ( 'illegal request' );
  6633. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  6634. $acItem = $accountItem->find ( array (
  6635. 'asArray' => true
  6636. ) );
  6637. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  6638. // 配置编辑信息
  6639. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  6640. foreach ( $acItem as $key => $value ) {
  6641. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  6642. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  6643. $acItem [$key] ['price'] = $v ['price'];
  6644. }
  6645. }
  6646. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  6647. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  6648. $acItem [$key] ['price'] = $v ['price'];
  6649. }
  6650. }
  6651. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  6652. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  6653. $acItem [$key] ['price'] = $v ['price'];
  6654. }
  6655. }
  6656. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  6657. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  6658. $acItem [$key] ['price'] = $v ['price'];
  6659. }
  6660. }
  6661. }
  6662. $data ['category'] = $lCategory->find ( array (
  6663. 'asArray' => true
  6664. ) );
  6665. $data ['cSum'] = $accountItemList ['cSum'];
  6666. $data ['sum'] = $receiptDetail ['sum'];
  6667. $data ['enclosurList'] = $enclosurList;
  6668. $data ['receiptDetail'] = $receiptDetail;
  6669. $data ['veList'] = $veList;
  6670. $data ['acItem'] = $acItem;
  6671. $data ['memu'] = "receipt";
  6672. $data ['staff'] = $this->staff;
  6673. $data ['receiptMemu'] = 'saeaBorad';
  6674. $data ['verify'] = $receiptDetail ['verify'];
  6675. $data ['verifyId'] = $this->verifyId;
  6676. $data ['executeId'] = $this->executeId;
  6677. $data ['rid'] = $ridKey;
  6678. $this->render ( "/admin/saea_edit", $data );
  6679. }
  6680. function updateReceipt() {
  6681. $agency = $this->get_args ( 'agency' );
  6682. $travel = $this->get_args ( 'travel' );
  6683. $train = $this->get_args ( 'train' );
  6684. $other = $this->get_args ( 'other' );
  6685. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  6686. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  6687. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  6688. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  6689. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  6690. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  6691. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  6692. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  6693. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  6694. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  6695. Doo::loadClass ( 'XDeode' );
  6696. $XDeode = new XDeode ( 7 );
  6697. $rid = $XDeode->decode ( $ridKey );
  6698. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  6699. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  6700. header ( 'Content-Type:text/html;charset=utf-8' );
  6701. die ( '请填写联行号' );
  6702. }
  6703. Doo::loadModel ( 'receipt' );
  6704. Doo::loadModel ( 'receiptDetail' );
  6705. Doo::loadModel ( 'accountItem' );
  6706. $accountItem = new accountItem ();
  6707. $receipt = new receipt ();
  6708. Doo::loadModel ( 'enclosur' );
  6709. Doo::loadModel ( 'execute' );
  6710. $execute = new execute ();
  6711. $receiptDetail = $receipt->getOne ( array (
  6712. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  6713. 'asArray' => true
  6714. ) );
  6715. if (empty ( $receiptDetail ))
  6716. return "/saeaBorad";
  6717. if ($receiptDetail ['Rtype'] == 1)
  6718. $executeDetail = $execute->getOne ( array (
  6719. 'where' => 'mold="借款费用执行人"',
  6720. 'asArray' => true
  6721. ) );
  6722. else
  6723. $executeDetail = $execute->getOne ( array (
  6724. 'where' => 'mold="报销单执行人"',
  6725. 'asArray' => true
  6726. ) );
  6727. $aItem = $accountItem->find ( array (
  6728. 'asArray' => true
  6729. ) );
  6730. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  6731. $ag = $tr = $ta = $ot = 0;
  6732. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  6733. foreach ( $aItem as $key => $value ) {
  6734. if ($value ['category'] == $this->AGENCY) {
  6735. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  6736. array_push ( $accountJson [$this->AGENCY], array (
  6737. 'aid' => $value ['aid'],
  6738. 'name' => $value ['name'],
  6739. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  6740. ) );
  6741. $sum += $agency [$ag];
  6742. $agencySum += $agency [$ag];
  6743. }
  6744. $ag ++;
  6745. }
  6746. if ($value ['category'] == $this->TRAVEL) {
  6747. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  6748. array_push ( $accountJson [$this->TRAVEL], array (
  6749. 'aid' => $value ['aid'],
  6750. 'name' => $value ['name'],
  6751. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  6752. ) );
  6753. $sum += $travel [$tr];
  6754. $travelSum += $travel [$tr];
  6755. }
  6756. $tr ++;
  6757. }
  6758. if ($value ['category'] == $this->TRAIN) {
  6759. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  6760. array_push ( $accountJson [$this->TRAIN], array (
  6761. 'aid' => $value ['aid'],
  6762. 'name' => $value ['name'],
  6763. 'price' => number_format ( $train [$ta], 2, '.', '' )
  6764. ) );
  6765. $sum += $train [$ta];
  6766. $trainSum += $train [$ta];
  6767. }
  6768. $ta ++;
  6769. }
  6770. if ($value ['category'] == $this->OTHER) {
  6771. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  6772. array_push ( $accountJson [$this->OTHER], array (
  6773. 'aid' => $value ['aid'],
  6774. 'name' => $value ['name'],
  6775. 'price' => number_format ( $other [$ot], 2, '.', '' )
  6776. ) );
  6777. $sum += $other [$ot];
  6778. $otherSum += $other [$ot];
  6779. }
  6780. $ot ++;
  6781. }
  6782. }
  6783. $accountJson ['cSum'] = array (
  6784. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  6785. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  6786. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  6787. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  6788. );
  6789. // 报销单
  6790. $rid = $receipt->rid = $receiptDetail ['rid'];
  6791. $receipt->accountItem = json_encode ( $accountJson );
  6792. $receipt->staff = $this->staff [0] ['sid'];
  6793. $receipt->sum = number_format ( $sum, 2, '.', '' );
  6794. $receipt->date = date ( "Y-m-d" );
  6795. $receipt->cid = $cid;
  6796. if (($receiptDetail ['status'] != 4)) {
  6797. if ($receiptDetail ['Rtype'] == 1)
  6798. $receipt->status = 7;
  6799. else
  6800. $receipt->status = 5;
  6801. }
  6802. if ($receiptDetail != 4 && ! empty ( $verify ))
  6803. $receipt->verify = $verify;
  6804. $receipt->executeCopy = $executeDetail ['staff'];
  6805. $order = array (
  6806. "\r\n",
  6807. "\n",
  6808. "\r"
  6809. );
  6810. $replace = '<br/>';
  6811. $explanation = str_replace ( $order, $replace, $explanation );
  6812. $receipt->explanation = $explanation;
  6813. $receipt->remittanceName = $remittanceName;
  6814. $receipt->bankName = $bankName;
  6815. $receipt->bankNumber = $bankNumber;
  6816. $receipt->remittanceBankType = $remittanceBankType;
  6817. if ($remittanceBankType == 1)
  6818. $receipt->coupletNumber = $coupletNumber;
  6819. $receipt->update ();
  6820. $receiptDetail = new receiptDetail ();
  6821. $receiptDetail->delete ( array (
  6822. 'where' => 'rid=' . $rid
  6823. ) );
  6824. // 报销详情
  6825. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  6826. $receiptDetail = new receiptDetail ();
  6827. $receiptDetail->staff = $this->staff [0] ['sid'];
  6828. $receiptDetail->item = $value ['name'];
  6829. $receiptDetail->itemCategory = $this->AGENCY;
  6830. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6831. $receiptDetail->date = date ( "Y-m-d" );
  6832. $receiptDetail->cid = $cid;
  6833. $receiptDetail->rid = $rid;
  6834. $receiptDetail->status = 4;
  6835. $receiptDetail->insert ();
  6836. }
  6837. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  6838. $receiptDetail = new receiptDetail ();
  6839. $receiptDetail->staff = $this->staff [0] ['sid'];
  6840. $receiptDetail->item = $value ['name'];
  6841. $receiptDetail->itemCategory = $this->TRAVEL;
  6842. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6843. $receiptDetail->date = date ( "Y-m-d" );
  6844. $receiptDetail->cid = $cid;
  6845. $receiptDetail->rid = $rid;
  6846. $receiptDetail->status = 4;
  6847. $receiptDetail->insert ();
  6848. }
  6849. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  6850. $receiptDetail = new receiptDetail ();
  6851. $receiptDetail->staff = $this->staff [0] ['sid'];
  6852. $receiptDetail->item = $value ['name'];
  6853. $receiptDetail->itemCategory = $this->TRAIN;
  6854. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6855. $receiptDetail->date = date ( "Y-m-d" );
  6856. $receiptDetail->cid = $cid;
  6857. $receiptDetail->rid = $rid;
  6858. $receiptDetail->status = 4;
  6859. $receiptDetail->insert ();
  6860. }
  6861. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  6862. $receiptDetail = new receiptDetail ();
  6863. $receiptDetail->staff = $this->staff [0] ['sid'];
  6864. $receiptDetail->item = $value ['name'];
  6865. $receiptDetail->itemCategory = $this->OTHER;
  6866. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6867. $receiptDetail->date = date ( "Y-m-d" );
  6868. $receiptDetail->cid = $cid;
  6869. $receiptDetail->rid = $rid;
  6870. $receiptDetail->status = 4;
  6871. $receiptDetail->insert ();
  6872. }
  6873. // 附件
  6874. if (! empty ( $enclosurName )) {
  6875. $enclosurArray = explode ( '-', $enclosurName );
  6876. foreach ( $enclosurArray as $value ) {
  6877. $enclosur = new enclosur ();
  6878. $enclosur->name = $value;
  6879. $enclosur->rid = $rid;
  6880. $enclosur->insert ();
  6881. }
  6882. }
  6883. // return "/referReceipt/".$rid;
  6884. }
  6885. return "/saeaBorad";
  6886. }
  6887. function approvedReceipt() {
  6888. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6889. Doo::loadModel ( 'receipt' );
  6890. Doo::loadModel ( 'receiptDetail' );
  6891. $receipt = new receipt ();
  6892. $receiptDetail = new receiptDetail ();
  6893. Doo::loadModel ( 'statistics' );
  6894. Doo::loadModel ( 'itemStatistics' );
  6895. $statistics = new statistics ();
  6896. $itemStatistics = new itemStatistics ();
  6897. Doo::loadModel ( "verify" );
  6898. $verify = new verify ();
  6899. // 审批状态的判定
  6900. $receiptDetailList = $receipt->getOne ( array (
  6901. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  6902. 'asArray' => true
  6903. ) );
  6904. if (empty ( $receiptDetailList ))
  6905. return "/saeaBorad";
  6906. $verifyDetail = $verify->getOne ( array (
  6907. 'where' => ' vid =' . $receiptDetailList ['verify'],
  6908. 'asArray' => true
  6909. ) );
  6910. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  6911. if (empty ( $receiptDetailList ['nowStaff'] )) {
  6912. $nowStaff = "";
  6913. $nowStaffList = array ();
  6914. if ($verifyDetail [0] [1] == 'ROLE') {
  6915. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  6916. foreach ( $vStaffString as $key => $value ) {
  6917. $staffK = explode ( "_", $value );
  6918. array_push ( $nowStaffList, $staffK [0] );
  6919. }
  6920. $nowStaff = implode ( ',', $nowStaffList );
  6921. } else {
  6922. $nowStaff = $verifyDetail [0] [0];
  6923. }
  6924. $receipt->nowStaff = $nowStaff;
  6925. }
  6926. // echo $nowStaff;
  6927. // print_r($verifyDetail);die;
  6928. $receipt->rid = $receiptDetailList ['rid'];
  6929. $receipt->date = date ( "Y-m-d" );
  6930. $receipt->status = 2;
  6931. $receipt->update ();
  6932. $receiptDetail->status = 2;
  6933. $receiptDetail->update ( array (
  6934. 'where' => 'rid=' . $receiptDetailList ['rid']
  6935. ) );
  6936. Doo::loadModel ( "receiptLog" );
  6937. $receiptLog = new receiptLog ();
  6938. Doo::loadModel ( "verify" );
  6939. $verify = new verify ();
  6940. $receiptInfo = $receipt->getOne ( array (
  6941. 'where' => 'rid=' . $rid,
  6942. 'asArray' => true
  6943. ) );
  6944. $vr = $verify->getOne ( array (
  6945. 'where' => 'vid=' . $receiptInfo ['verify'],
  6946. 'asArray' => true
  6947. ) );
  6948. $jd = json_decode ( $vr ['staff'] );
  6949. $roleId = 0;
  6950. foreach ( $jd as $key => $value ) {
  6951. if ($value [1] == 'ROLE') {
  6952. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  6953. if ($pos !== false) {
  6954. $roleId = $value [0];
  6955. }
  6956. }
  6957. }
  6958. // 审批日志
  6959. // echo $roleId;die;
  6960. if (! empty ( $roleId )) {
  6961. Doo::loadModel ( "role" );
  6962. $role = new role ();
  6963. $roleInfo = $role->getOne ( array (
  6964. 'where' => 'rid=' . $roleId,
  6965. 'asArray' => true
  6966. ) );
  6967. // $receiptLog->rolename = $roleInfo ['name'];
  6968. }
  6969. $receiptLog->username = $this->staff [0] ['username'];
  6970. $receiptLog->uid = $this->staff [0] ['sid'];
  6971. $receiptLog->date = date ( "Y-m-d" );
  6972. $receiptLog->opinion = '提交审批';
  6973. $receiptLog->img = $this->staff [0] ['avatar'];
  6974. $receiptLog->status = 2;
  6975. $receiptLog->rid = $rid;
  6976. $receiptLog->insert ();
  6977. // statistics item
  6978. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  6979. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  6980. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  6981. $stat = $statistics->getOne ( array (
  6982. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  6983. 'asArray' => true
  6984. ) );
  6985. if (empty ( $stat )) {
  6986. $statistics->date = date ( "Y-m-d" );
  6987. $statistics->cid = $this->staff [0] ['cid'];
  6988. $statistics->staff = $this->staff [0] ['sid'];
  6989. $statistics->agPrice = 0;
  6990. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  6991. $statistics->insert ();
  6992. } else {
  6993. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  6994. $statistics->update ( array (
  6995. 'where' => 'sid=' . $stat ['sid']
  6996. ) );
  6997. }
  6998. return "/expenses";
  6999. }
  7000. function approval() {
  7001. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7002. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7003. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7004. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7005. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7006. if (empty ( $status ))
  7007. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7008. $vidList = array ();
  7009. $button = 0;
  7010. Doo::loadModel ( 'verify' );
  7011. $verify = new verify ();
  7012. Doo::loadModel ( 'receipt' );
  7013. $receipt = new receipt ();
  7014. Doo::loadModel ( 'staff' );
  7015. $staff = new staff ();
  7016. Doo::loadModel ( 'L_category' );
  7017. $Lcategory = new L_category ();
  7018. // user verify ID
  7019. $verifyDetail = $verify->find ( array (
  7020. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7021. 'asArray' => true
  7022. ) );
  7023. foreach ( $verifyDetail as $key => $value ) {
  7024. array_push ( $vidList, $value ['vid'] );
  7025. }
  7026. $vid = implode ( ",", $vidList );
  7027. if (empty ( $verifyDetail ))
  7028. $vid = 0;
  7029. /*
  7030. */
  7031. $dateCondition = " and Year(date) =" . $year;
  7032. if (! empty ( $month ))
  7033. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  7034. $categoryList = $Lcategory->find ( array (
  7035. 'asArray' => true
  7036. ) );
  7037. $staffList = $staff->find ( array (
  7038. 'where' => 'cid=' . $cid,
  7039. 'asArray' => true
  7040. ) );
  7041. $cateCondition = "";
  7042. $staffCondition = "";
  7043. $approvalCondition = "";
  7044. if (! empty ( $cid ))
  7045. $cateCondition = ' and cid=' . $cid;
  7046. if (! empty ( $sid )) {
  7047. $staffCondition = ' and staff=' . $sid;
  7048. $cateCondition = "";
  7049. }
  7050. // elseif($status==1){
  7051. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  7052. // }
  7053. if ($status == 2) {
  7054. // 查找角色审批人
  7055. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  7056. }
  7057. $ap = "";
  7058. if ($status == 4) {
  7059. $ap = 4;
  7060. $status = 2;
  7061. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  7062. }
  7063. if ($status == 5) {
  7064. $status = 4;
  7065. $ap = 5;
  7066. }
  7067. // echo $vid;
  7068. // get Receipt By verifyID status 2 .$approvalCondition
  7069. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  7070. $receiptList = $receipt->find ( array (
  7071. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  7072. 'desc' => 'rid',
  7073. 'asArray' => true
  7074. ) );
  7075. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  7076. $Locate = 0;
  7077. if ($ap == 4)
  7078. $status = 4;
  7079. elseif ($ap == 5)
  7080. $status = 5;
  7081. foreach ( $receiptList as $key => $value ) {
  7082. $receiptList [$key] ['Locate'] = $Locate;
  7083. $Locate ++;
  7084. $receiptList [$key] ['reviseDetail'] = array ();
  7085. if (! empty ( $value ['reviseDetail'] ))
  7086. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7087. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7088. $categoryDetil = $Lcategory->getOne ( array (
  7089. 'where' => 'cid=' . $value ['cid'],
  7090. 'asArray' => true
  7091. ) );
  7092. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7093. $verifyList = $verify->getOne ( array (
  7094. 'where' => 'vid=' . $value ['verify'],
  7095. 'asArray' => true
  7096. ) );
  7097. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7098. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7099. foreach ( $verifyList as $k => $v ) {
  7100. // init verifyStaff
  7101. $verifyList [$k] ['date'] = "";
  7102. $verifyList [$k] ['opinion'] = "";
  7103. $verifyList [$k] ['status'] = "";
  7104. if (empty ( $verifyStaff )) {
  7105. $verifyList [$k] ['date'] = "";
  7106. $verifyList [$k] ['opinion'] = "";
  7107. if ($v [0] == $this->staff [0] ['sid']) {
  7108. $verifyList [$k] ['status'] = 4;
  7109. $button = 4;
  7110. }
  7111. } else {
  7112. $flag = true;
  7113. foreach ( $verifyStaff as $m => $u ) {
  7114. if ($v [0] == $m) {
  7115. $verifyList [$k] ['date'] = $u ['date'];
  7116. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7117. $verifyList [$k] ['status'] = $u ['status'];
  7118. $flag = false;
  7119. break;
  7120. }
  7121. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  7122. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  7123. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  7124. }
  7125. if ($flag) { // 检测可编辑
  7126. if ($v [0] == $this->staff [0] ['sid']) {
  7127. $verifyList [$k] ['status'] = 4;
  7128. $button = 4;
  7129. }
  7130. }
  7131. }
  7132. }
  7133. $receiptList [$key] ['verifyList'] = $verifyList;
  7134. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7135. 'where' => 'sid=' . $value ['staff'],
  7136. 'asArray' => true
  7137. ) );
  7138. $receiptList [$key] ['button'] = $button;
  7139. }
  7140. // print_r($receiptList);die;
  7141. // $data['verifyDetail']=$verifyDetail;
  7142. $mothHtml = "";
  7143. for($i = 1; $i <= 12; $i ++) {
  7144. if ($month == $i)
  7145. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7146. else
  7147. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7148. }
  7149. $data ['mothHtml'] = $mothHtml;
  7150. $data ['receiptList'] = $receiptList;
  7151. $data ['receiptApprovalCount'] = count ( $receiptList );
  7152. $data ['status'] = $status;
  7153. $data ['year'] = $year;
  7154. $data ['categoryList'] = $categoryList;
  7155. $data ['staffList'] = $staffList;
  7156. $data ['cid'] = $cid;
  7157. $data ['sid'] = $sid;
  7158. $data ['ap'] = $ap;
  7159. $data ['memu'] = "receipt";
  7160. $data ['staff'] = $this->staff;
  7161. $data ['receiptMemu'] = 'approval';
  7162. $data ['verifyId'] = $this->verifyId;
  7163. $data ['executeId'] = $this->executeId;
  7164. $this->render ( "/admin/saea_reportList", $data );
  7165. }
  7166. function approvalDetails() {
  7167. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7168. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7169. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7170. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7171. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7172. Doo::loadModel ( 'verify' );
  7173. $verify = new verify ();
  7174. Doo::loadModel ( 'receipt' );
  7175. $receipt = new receipt ();
  7176. Doo::loadModel ( 'staff' );
  7177. $staff = new staff ();
  7178. Doo::loadModel ( 'L_category' );
  7179. $Lcategory = new L_category ();
  7180. Doo::loadModel ( 'enclosur' );
  7181. $enclosur = new enclosur ();
  7182. $vidList = array ();
  7183. $verifyDetail = $verify->find ( array (
  7184. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7185. 'asArray' => true
  7186. ) );
  7187. foreach ( $verifyDetail as $key => $value ) {
  7188. array_push ( $vidList, $value ['vid'] );
  7189. }
  7190. $vid = implode ( ",", $vidList );
  7191. if (empty ( $verifyDetail ))
  7192. $vid = 0;
  7193. $categoryList = $Lcategory->find ( array (
  7194. 'asArray' => true
  7195. ) );
  7196. $staffList = $staff->find ( array (
  7197. 'where' => 'cid=' . $cid,
  7198. 'asArray' => true
  7199. ) );
  7200. $ap = 0;
  7201. $receiptList = $receipt->find ( array (
  7202. 'where' => 'rid =' . $rid,
  7203. 'desc' => 'rid',
  7204. 'asArray' => true
  7205. ) );
  7206. $Locate = 0;
  7207. $roleId = 0;
  7208. $button = 0;
  7209. foreach ( $receiptList as $key => $value ) {
  7210. $receiptList [$key] ['Locate'] = $Locate;
  7211. $Locate ++;
  7212. $receiptList [$key] ['reviseDetail'] = array ();
  7213. if (! empty ( $value ['reviseDetail'] ))
  7214. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7215. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7216. $categoryDetil = $Lcategory->getOne ( array (
  7217. 'where' => 'cid=' . $value ['cid'],
  7218. 'asArray' => true
  7219. ) );
  7220. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7221. // 检测编辑状态
  7222. $verifyList = $verify->getOne ( array (
  7223. 'where' => 'vid=' . $value ['verify'],
  7224. 'asArray' => true
  7225. ) );
  7226. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7227. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7228. Doo::loadModel ( 'role' );
  7229. $role = new role ();
  7230. // print_r($verifyList);
  7231. $flag = true;
  7232. $roleKey = 0;
  7233. $endStaffArray = array ();
  7234. $roleArrayCopy = array ();
  7235. foreach ( $verifyList as $k => $v ) {
  7236. // init verifyStaff
  7237. if ($v [1] == 'ROLE') {
  7238. if (! empty ( $verifyStaff )) {
  7239. $endStaffArray = end ( $verifyStaff );
  7240. if ($v [0] == $endStaffArray ['nextStaff']) {
  7241. $roleId = $v [0];
  7242. }
  7243. }
  7244. $roleVerify = json_decode ( $v [3], true );
  7245. $roleKey = $k;
  7246. $roleArray = array ();
  7247. $rolename = $role->getOne ( array (
  7248. 'where' => 'rid=' . $v [0],
  7249. 'asArray' => true
  7250. ) );
  7251. foreach ( $roleVerify as $o => $p ) {
  7252. $staffID = explode ( '_', $p );
  7253. $staffInfo = $staff->getOne ( array (
  7254. 'where' => 'sid=' . $staffID [0],
  7255. 'asArray' => true
  7256. ) );
  7257. // print_r($staffID);
  7258. $exp = array (
  7259. 0 => $staffInfo ['sid'],
  7260. 1 => $staffID [1],
  7261. 2 => $staffInfo ['avatar'],
  7262. 'date' => '',
  7263. 'date' => '',
  7264. 'opinion' => '',
  7265. 'status' => '',
  7266. 'rolename' => $rolename ['name']
  7267. );
  7268. array_push ( $roleArray, $exp );
  7269. }
  7270. $roleArrayCopy [$v [0]] = $roleArray;
  7271. // $verifyList[$k]['roleArray']=$roleArray;
  7272. }
  7273. // print_r($roleArray);
  7274. $verifyList [$k] ['date'] = "";
  7275. $verifyList [$k] ['opinion'] = "";
  7276. $verifyList [$k] ['status'] = "";
  7277. if (empty ( $verifyStaff )) {
  7278. $verifyList [$k] ['date'] = "";
  7279. $verifyList [$k] ['opinion'] = "";
  7280. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7281. $verifyList [$k] ['status'] = 4;
  7282. $button = 4;
  7283. $flag = false;
  7284. }
  7285. } else {
  7286. foreach ( $verifyStaff as $m => $u ) {
  7287. if ($v [0] == $m) {
  7288. $verifyList [$k] ['date'] = $u ['date'];
  7289. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7290. $verifyList [$k] ['status'] = $u ['status'];
  7291. $flag = false;
  7292. break;
  7293. }
  7294. }
  7295. $endStaffArray = end ( $verifyStaff );
  7296. if (isset ( $endStaffArray ['ROLE'] )) {
  7297. } else {
  7298. $endKey = key ( $verifyStaff );
  7299. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7300. $button = 4;
  7301. $verifyList [$k] ['status'] = 4;
  7302. }
  7303. }
  7304. }
  7305. }
  7306. $rolename ['name'] = '';
  7307. if (! empty ( $roleId )) {
  7308. Doo::loadModel ( 'role' );
  7309. $role = new role ();
  7310. $rolename = $role->getOne ( array (
  7311. 'where' => 'rid=' . $roleId,
  7312. 'asArray' => true
  7313. ) );
  7314. }
  7315. if (! empty ( $verifyStaff ))
  7316. $endStaffArray = end ( $verifyStaff );
  7317. $KOP = false;
  7318. foreach ( $roleArrayCopy as $P => $A ) {
  7319. foreach ( $A as $MKI => $AVL ) {
  7320. if (! empty ( $verifyStaff )) {
  7321. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7322. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7323. $button = 4;
  7324. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7325. }
  7326. foreach ( $verifyStaff as $m => $u ) {
  7327. $AVLFK = $AVL [0] . '_R';
  7328. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7329. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7330. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7331. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7332. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7333. break;
  7334. }
  7335. }
  7336. } else {
  7337. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7338. $button = 4;
  7339. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7340. }
  7341. }
  7342. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7343. $KOP = true;
  7344. }
  7345. }
  7346. foreach ( $roleArrayCopy as $k => $v ) {
  7347. foreach ( $verifyList as $m => $n ) {
  7348. if ($n [0] == $k) {
  7349. array_splice ( $verifyList, $m, 1, $v );
  7350. }
  7351. }
  7352. }
  7353. $receiptList [$key] ['verifyList'] = $verifyList;
  7354. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7355. 'where' => 'sid=' . $value ['staff'],
  7356. 'asArray' => true
  7357. ) );
  7358. $receiptList [$key] ['button'] = $button;
  7359. }
  7360. $mothHtml = "";
  7361. for($i = 1; $i <= 12; $i ++) {
  7362. if ($month == $i)
  7363. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7364. else
  7365. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7366. }
  7367. // 获取审批日志
  7368. Doo::loadModel ( 'receiptLog' );
  7369. $receiptLog = new receiptLog ();
  7370. $rlList = array ();
  7371. $rlInfo = $receiptLog->getOne ( array (
  7372. 'where' => 'rid=' . $rid . ' and status=4',
  7373. 'asArray' => true
  7374. ) );
  7375. $tijdate = $receiptLog->getOne ( array (
  7376. 'where' => 'rid=' . $rid . ' and status=2',
  7377. 'asc' => 'rlid',
  7378. 'asArray' => true
  7379. ) );
  7380. if (! empty ( $rlInfo )) {
  7381. $rlList = $receiptLog->find ( array (
  7382. 'where' => 'rid=' . $rid,
  7383. 'asc' => 'rlid',
  7384. 'asArray' => true
  7385. ) );
  7386. }
  7387. $receiptList [0] ['rlList'] = $rlList;
  7388. $enclosurList = $enclosur->find ( array (
  7389. 'where' => 'rid=' . $rid,
  7390. 'asArray' => true
  7391. ) );
  7392. $enclosurHtml = '';
  7393. foreach ( $enclosurList as $value ) {
  7394. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  7395. }
  7396. $data ['enclosurHtml'] = $enclosurHtml;
  7397. $data ['rolename'] = $rolename ['name'];
  7398. $data ['datetij'] = $tijdate ['date'];
  7399. $data ['mothHtml'] = $mothHtml;
  7400. $data ['receiptList'] = $receiptList;
  7401. $data ['receiptApprovalCount'] = count ( $receiptList );
  7402. $data ['year'] = $year;
  7403. $data ['categoryList'] = $categoryList;
  7404. $data ['staffList'] = $staffList;
  7405. $data ['cid'] = $cid;
  7406. $data ['sid'] = $sid;
  7407. $data ['status'] = 0;
  7408. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  7409. $ap = 4;
  7410. } else
  7411. $data ['status'] = $receiptList [0] ['status'];
  7412. if ($receiptList [0] ['status'] == 4) {
  7413. $data ['status'] = 5;
  7414. $ap = 0;
  7415. }
  7416. $data ['ap'] = $ap;
  7417. $data ['memu'] = "receipt";
  7418. $data ['staff'] = $this->staff;
  7419. $data ['receiptMemu'] = 'approval';
  7420. $data ['verifyId'] = $this->verifyId;
  7421. $data ['executeId'] = $this->executeId;
  7422. $this->render ( "/admin/saeaReportListReport", $data );
  7423. }
  7424. function approvalEdi() {
  7425. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7426. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7427. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7428. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7429. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7430. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7431. if (empty ( $status ))
  7432. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7433. $vidList = array ();
  7434. $button = 0;
  7435. Doo::loadModel ( 'verify' );
  7436. Doo::loadModel ( 'receipt' );
  7437. Doo::loadModel ( 'staff' );
  7438. $staff = new staff ();
  7439. $receipt = new receipt ();
  7440. $verify = new verify ();
  7441. Doo::loadModel ( 'L_category' );
  7442. $Lcategory = new L_category ();
  7443. Doo::loadModel ( 'enclosur' );
  7444. $enclosur = new enclosur ();
  7445. // user verify ID
  7446. $verifyDetail = $verify->find ( array (
  7447. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7448. 'asArray' => true
  7449. ) );
  7450. foreach ( $verifyDetail as $key => $value ) {
  7451. array_push ( $vidList, $value ['vid'] );
  7452. }
  7453. $vid = implode ( ",", $vidList );
  7454. if (empty ( $verifyDetail ))
  7455. $vid = 0;
  7456. $categoryList = $Lcategory->find ( array (
  7457. 'asArray' => true
  7458. ) );
  7459. $staffList = $staff->find ( array (
  7460. 'where' => 'cid=' . $cid,
  7461. 'asArray' => true
  7462. ) );
  7463. $ap = "";
  7464. if ($status == 4) {
  7465. $ap = 4;
  7466. $status = 2;
  7467. }
  7468. // get Receipt By verifyID status 2
  7469. $receiptList = $receipt->find ( array (
  7470. 'where' => 'rid =' . $rid,
  7471. 'desc' => 'rid',
  7472. 'asArray' => true
  7473. ) );
  7474. $Locate = 0;
  7475. $roleId = 0;
  7476. if ($ap == 4)
  7477. $status = 4;
  7478. foreach ( $receiptList as $key => $value ) {
  7479. $receiptList [$key] ['Locate'] = $Locate;
  7480. $Locate ++;
  7481. $receiptList [$key] ['reviseDetail'] = array ();
  7482. if (! empty ( $value ['reviseDetail'] ))
  7483. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7484. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7485. $categoryDetil = $Lcategory->getOne ( array (
  7486. 'where' => 'cid=' . $value ['cid'],
  7487. 'asArray' => true
  7488. ) );
  7489. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7490. // 检测编辑状态
  7491. $verifyList = $verify->getOne ( array (
  7492. 'where' => 'vid=' . $value ['verify'],
  7493. 'asArray' => true
  7494. ) );
  7495. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7496. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7497. // print_r($verifyList);
  7498. //
  7499. // if (empty($verifyStaff)){
  7500. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  7501. // $verifyList[0]['status']=4;$button=4;
  7502. // }
  7503. //
  7504. // }else{
  7505. //
  7506. // }
  7507. // die;
  7508. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  7509. // echo array_search("green",$a);
  7510. //
  7511. Doo::loadModel ( 'role' );
  7512. $role = new role ();
  7513. // print_r($verifyList);
  7514. $flag = true;
  7515. $roleKey = 0;
  7516. $endStaffArray = array ();
  7517. $roleArrayCopy = array ();
  7518. foreach ( $verifyList as $k => $v ) {
  7519. // init verifyStaff
  7520. if ($v [1] == 'ROLE') {
  7521. if (! empty ( $verifyStaff )) {
  7522. $endStaffArray = end ( $verifyStaff );
  7523. if ($v [0] == $endStaffArray ['nextStaff']) {
  7524. $roleId = $v [0];
  7525. }
  7526. }
  7527. $roleVerify = json_decode ( $v [3], true );
  7528. $roleKey = $k;
  7529. $roleArray = array ();
  7530. $rolename = $role->getOne ( array (
  7531. 'where' => 'rid=' . $v [0],
  7532. 'asArray' => true
  7533. ) );
  7534. foreach ( $roleVerify as $o => $p ) {
  7535. $staffID = explode ( '_', $p );
  7536. $staffInfo = $staff->getOne ( array (
  7537. 'where' => 'sid=' . $staffID [0],
  7538. 'asArray' => true
  7539. ) );
  7540. // print_r($staffID);
  7541. $exp = array (
  7542. 0 => $staffInfo ['sid'],
  7543. 1 => $staffID [1],
  7544. 2 => $staffInfo ['avatar'],
  7545. 'date' => '',
  7546. 'date' => '',
  7547. 'opinion' => '',
  7548. 'status' => '',
  7549. 'rolename' => $rolename ['name']
  7550. );
  7551. array_push ( $roleArray, $exp );
  7552. }
  7553. $roleArrayCopy [$v [0]] = $roleArray;
  7554. // $verifyList[$k]['roleArray']=$roleArray;
  7555. }
  7556. // print_r($roleArray);
  7557. $verifyList [$k] ['date'] = "";
  7558. $verifyList [$k] ['opinion'] = "";
  7559. $verifyList [$k] ['status'] = "";
  7560. if (empty ( $verifyStaff )) {
  7561. $verifyList [$k] ['date'] = "";
  7562. $verifyList [$k] ['opinion'] = "";
  7563. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7564. $verifyList [$k] ['status'] = 4;
  7565. $button = 4;
  7566. $flag = false;
  7567. }
  7568. } else {
  7569. foreach ( $verifyStaff as $m => $u ) {
  7570. if ($v [0] == $m) {
  7571. $verifyList [$k] ['date'] = $u ['date'];
  7572. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7573. $verifyList [$k] ['status'] = $u ['status'];
  7574. $flag = false;
  7575. break;
  7576. }
  7577. }
  7578. $endStaffArray = end ( $verifyStaff );
  7579. if (isset ( $endStaffArray ['ROLE'] )) {
  7580. } else {
  7581. $endKey = key ( $verifyStaff );
  7582. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7583. $button = 4;
  7584. $verifyList [$k] ['status'] = 4;
  7585. }
  7586. }
  7587. // print_r($endStaffArray);die;
  7588. // if (empty($verifyStaff)){
  7589. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  7590. // $verifyList[$k]['status']=4;$button=4;
  7591. // }
  7592. //
  7593. // }else{
  7594. //
  7595. // }
  7596. // if($flag){//检测可编辑
  7597. // if($v[0]==$this->staff[0]['sid']){
  7598. // $verifyList[$k]['status']=4;$button=4;
  7599. // }
  7600. // }
  7601. }
  7602. }
  7603. $rolename ['name'] = '';
  7604. if (! empty ( $roleId )) {
  7605. Doo::loadModel ( 'role' );
  7606. $role = new role ();
  7607. $rolename = $role->getOne ( array (
  7608. 'where' => 'rid=' . $roleId,
  7609. 'asArray' => true
  7610. ) );
  7611. }
  7612. if (! empty ( $verifyStaff ))
  7613. $endStaffArray = end ( $verifyStaff );
  7614. $KOP = false;
  7615. foreach ( $roleArrayCopy as $P => $A ) {
  7616. foreach ( $A as $MKI => $AVL ) {
  7617. if (! empty ( $verifyStaff )) {
  7618. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7619. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7620. $button = 4;
  7621. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7622. }
  7623. foreach ( $verifyStaff as $m => $u ) {
  7624. $AVLFK = $AVL [0] . '_R';
  7625. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7626. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7627. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7628. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7629. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7630. break;
  7631. }
  7632. }
  7633. } else {
  7634. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7635. $button = 4;
  7636. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7637. }
  7638. }
  7639. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7640. $KOP = true;
  7641. }
  7642. }
  7643. // print_r($roleArrayCopy);
  7644. // echo $roleKey;
  7645. foreach ( $roleArrayCopy as $k => $v ) {
  7646. foreach ( $verifyList as $m => $n ) {
  7647. if ($n [0] == $k) {
  7648. array_splice ( $verifyList, $m, 1, $v );
  7649. }
  7650. }
  7651. }
  7652. // if ($KOP)
  7653. // array_splice($verifyList,$roleKey,1,$roleArray);
  7654. // print_r($verifyList);
  7655. $receiptList [$key] ['verifyList'] = $verifyList;
  7656. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7657. 'where' => 'sid=' . $value ['staff'],
  7658. 'asArray' => true
  7659. ) );
  7660. $receiptList [$key] ['button'] = $button;
  7661. }
  7662. // $data['verifyDetail']=$verifyDetail;
  7663. $mothHtml = "";
  7664. for($i = 1; $i <= 12; $i ++) {
  7665. if ($month == $i)
  7666. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7667. else
  7668. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7669. }
  7670. // 获取审批日志
  7671. Doo::loadModel ( 'receiptLog' );
  7672. $receiptLog = new receiptLog ();
  7673. $rlList = array ();
  7674. $rlInfo = $receiptLog->getOne ( array (
  7675. 'where' => 'rid=' . $rid . ' and status=4',
  7676. 'asArray' => true
  7677. ) );
  7678. $tijdate = $receiptLog->getOne ( array (
  7679. 'where' => 'rid=' . $rid . ' and status=2',
  7680. 'asc' => 'rlid',
  7681. 'asArray' => true
  7682. ) );
  7683. if (! empty ( $rlInfo )) {
  7684. $rlList = $receiptLog->find ( array (
  7685. 'where' => 'rid=' . $rid,
  7686. 'asc' => 'rlid',
  7687. 'asArray' => true
  7688. ) );
  7689. }
  7690. $receiptList [0] ['rlList'] = $rlList;
  7691. $enclosurList = $enclosur->find ( array (
  7692. 'where' => 'rid=' . $rid,
  7693. 'asArray' => true
  7694. ) );
  7695. $enclosurHtml = '';
  7696. foreach ( $enclosurList as $value ) {
  7697. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  7698. }
  7699. $data ['enclosurHtml'] = $enclosurHtml;
  7700. $data ['rolename'] = $rolename ['name'];
  7701. $data ['datetij'] = $tijdate ['date'];
  7702. $data ['mothHtml'] = $mothHtml;
  7703. $data ['receiptList'] = $receiptList;
  7704. $data ['receiptApprovalCount'] = count ( $receiptList );
  7705. $data ['status'] = $status;
  7706. $data ['year'] = $year;
  7707. $data ['categoryList'] = $categoryList;
  7708. $data ['staffList'] = $staffList;
  7709. $data ['cid'] = $cid;
  7710. $data ['sid'] = $sid;
  7711. $data ['ap'] = $ap;
  7712. $data ['memu'] = "receipt";
  7713. $data ['staff'] = $this->staff;
  7714. $data ['receiptMemu'] = 'approval';
  7715. $data ['verifyId'] = $this->verifyId;
  7716. $data ['executeId'] = $this->executeId;
  7717. $this->render ( "/admin/saeaReportListReport", $data );
  7718. }
  7719. function remittanceHky() {
  7720. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7721. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  7722. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  7723. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  7724. $page_size = 15;
  7725. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  7726. Doo::loadModel ( 'receipt' );
  7727. $receipt = new receipt ();
  7728. Doo::loadModel ( 'staff' );
  7729. $staff = new staff ();
  7730. $dateCondition = " and Year(executeDate) =" . $year;
  7731. if ($moth != 'MONTH')
  7732. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  7733. if ($day != 'DAY' && $moth != 'MONTH')
  7734. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  7735. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  7736. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  7737. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  7738. $limit = $pageinfo ['lower'] . ',' . $page_size;
  7739. $dayList = $receipt->find ( array (
  7740. 'select' => 'executeDate,sum(amount) as amount',
  7741. 'where' => $sql,
  7742. 'desc' => 'executeDate',
  7743. 'groupby' => 'executeDate',
  7744. 'limit' => $limit,
  7745. 'asArray' => true
  7746. ) );
  7747. // print_r($dayList);
  7748. foreach ( $dayList as $key => $value ) {
  7749. $remitString = "";
  7750. $receiptList = $receipt->find ( array (
  7751. 'select' => 'rid,executeDate,amount,staff,cid',
  7752. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  7753. 'desc' => 'executeDate',
  7754. 'asArray' => true
  7755. ) );
  7756. foreach ( $receiptList as $k => $v ) {
  7757. $sinfo = $staff->getOne ( array (
  7758. 'select' => 'username,category',
  7759. 'where' => ' sid=' . $v ['staff'],
  7760. 'asArray' => true
  7761. ) );
  7762. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  7763. }
  7764. $dayList [$key] ['staff'] = $remitString;
  7765. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  7766. }
  7767. // print_r($dayList);
  7768. $mothHtml = "";
  7769. for($i = 1; $i <= 12; $i ++) {
  7770. if ($moth == $i)
  7771. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7772. else
  7773. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7774. }
  7775. $dayHtml = "";
  7776. if ($day != "DAY" || $moth != "MONTH") {
  7777. for($i = 1; $i <= 31; $i ++) {
  7778. if ($day == $i)
  7779. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  7780. else
  7781. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  7782. }
  7783. }
  7784. $dateHtml = "";
  7785. $now = date ( "Y" );
  7786. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  7787. if ($YEARD <= $now) {
  7788. $dateHtml .= '<option ';
  7789. if ($year == $YEARD) {
  7790. $dateHtml .= 'selected ';
  7791. }
  7792. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  7793. }
  7794. }
  7795. $data ['dateHtml'] = $dateHtml;
  7796. $data ['page'] = $pageinfo;
  7797. $data ['year'] = $year;
  7798. $data ['moth'] = $moth;
  7799. $data ['day'] = $day;
  7800. $data ['get'] = $get;
  7801. $data ['dayHtml'] = $dayHtml;
  7802. $data ['mothHtml'] = $mothHtml;
  7803. $data ['receiptList'] = $dayList;
  7804. $data ['memu'] = "receipt";
  7805. $data ['staff'] = $this->staff;
  7806. $data ['receiptMemu'] = 'remittanceHky';
  7807. $data ['verifyId'] = $this->verifyId;
  7808. $data ['executeId'] = $this->executeId;
  7809. $this->render ( "/admin/remittanceHky", $data );
  7810. }
  7811. function remittancep() {
  7812. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  7813. Doo::loadModel ( 'receipt' );
  7814. $receipt = new receipt ();
  7815. Doo::loadModel ( 'staff' );
  7816. $staff = new staff ();
  7817. Doo::loadClass ( 'XDeode' );
  7818. $XDeode = new XDeode ( 5 );
  7819. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  7820. $rplist = $receipt->find ( array (
  7821. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  7822. 'asArray' => true
  7823. ) );
  7824. $dayList = $receipt->find ( array (
  7825. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  7826. 'desc' => 'executeDate',
  7827. 'groupby' => 'staff',
  7828. 'asArray' => true
  7829. ) );
  7830. $html = '';
  7831. foreach ( $dayList as $key => $value ) {
  7832. $sinfo = $staff->getOne ( array (
  7833. 'select' => 'username,category',
  7834. 'where' => ' sid=' . $value ['staff'],
  7835. 'asArray' => true
  7836. ) );
  7837. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  7838. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  7839. $au = 0;
  7840. foreach ( $rplist as $k => $v ) {
  7841. if ($value ['staff'] == $v ['staff']) {
  7842. $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>';
  7843. $au += $v ['amount'];
  7844. }
  7845. }
  7846. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  7847. }
  7848. $data ['html'] = $html;
  7849. $data ['memu'] = "receipt";
  7850. $data ['staff'] = $this->staff;
  7851. $data ['receiptMemu'] = 'remittanceHky';
  7852. $data ['verifyId'] = $this->verifyId;
  7853. $data ['executeId'] = $this->executeId;
  7854. $this->render ( "/admin/remittancep", $data );
  7855. }
  7856. function ajaxGetReceiptDetails() {
  7857. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  7858. Doo::loadClass ( 'XDeode' );
  7859. $XDeode = new XDeode ( 5 );
  7860. $rid = $XDeode->decode ( $rid );
  7861. if (empty ( $rid )) {
  7862. echo json_encode ( array (
  7863. 'status' => 2,
  7864. 'msg' => 'illegal request'
  7865. ) );
  7866. die ();
  7867. }
  7868. Doo::loadModel ( 'receipt' );
  7869. $receipt = new receipt ();
  7870. Doo::loadModel ( 'staff' );
  7871. $staff = new staff ();
  7872. $rinfo = $receipt->getOne ( array (
  7873. 'where' => 'rid= ' . $rid,
  7874. 'asArray' => true
  7875. ) );
  7876. $sinfo = $staff->getOne ( array (
  7877. 'select' => 'username,category',
  7878. 'where' => ' sid=' . $rinfo ['staff'],
  7879. 'asArray' => true
  7880. ) );
  7881. $rinfo ['reviseDetail'] = array ();
  7882. if (! empty ( $rinfo ['reviseDetail'] ))
  7883. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  7884. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  7885. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  7886. $rinfo ['category'] = $sinfo ['category'];
  7887. $verifyStaff = array ();
  7888. if (! empty ( $rinfo ['verifyStaff'] ))
  7889. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  7890. $relust = bcsub ( $rinfo ['sum'], $rinfo ['loanSum'], 2 );
  7891. $rinfo ['relust'] = $relust;
  7892. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  7893. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  7894. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  7895. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  7896. // 费用执行人相关数据
  7897. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  7898. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  7899. foreach ( $executeCopy as $k => $v ) {
  7900. $executeCopy [$k] ['date'] = '';
  7901. $executeCopy [$k] ['opinion'] = '';
  7902. $executeCopy [$k] ['status'] = '';
  7903. if (! empty ( $executeStaff ))
  7904. foreach ( $executeStaff as $m => $u ) {
  7905. if ($v [0] == $m) {
  7906. $executeCopy [$k] ['date'] = $u ['date'];
  7907. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  7908. $executeCopy [$k] ['status'] = $u ['status'];
  7909. break;
  7910. }
  7911. }
  7912. }
  7913. $rinfo ['executeCopy'] = $executeCopy;
  7914. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  7915. if ($rinfo ['Rtype'] == 1) { // 借款费用
  7916. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  7917. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  7918. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  7919. $html .= '<tr><th>' . $value ['name'] . '</th>
  7920. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7921. }
  7922. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  7923. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  7924. <tr><th class="taC" colspan="2">费用说明</th>
  7925. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  7926. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  7927. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  7928. </tbody></table>';
  7929. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  7930. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  7931. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  7932. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  7933. $html .= '<tr><th>' . $value ['name'] . '</th>
  7934. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7935. }
  7936. $html .= '<tr><th class="taR">合计</th>
  7937. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  7938. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  7939. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  7940. $html .= '<tr><th>' . $value ['name'] . '</th>
  7941. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7942. }
  7943. $html .= '<tr><th class="taR">合计</th>
  7944. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  7945. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  7946. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  7947. $html .= '<tr><th>' . $value ['name'] . '</th>
  7948. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7949. }
  7950. $html .= '<tr><th class="taR">合计</th>
  7951. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  7952. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  7953. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  7954. $html .= '<tr><th>' . $value ['name'] . '</th>
  7955. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7956. }
  7957. $html .= '<tr><th class="taR">合计</th>
  7958. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  7959. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  7960. foreach ( $rinfo ['reviseDetail'] as $value ) {
  7961. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  7962. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  7963. }
  7964. $html .= '<tr><th class="taR">合计</th>
  7965. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  7966. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  7967. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  7968. <tr><th class="taC" colspan="2">报销说明</th></tr>
  7969. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  7970. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  7971. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  7972. <tr';
  7973. if ($rinfo ['relust'] >= 0) {
  7974. $html .= 'class="success"';
  7975. } else {
  7976. $html .= 'class="error"';
  7977. }
  7978. $html .= '><td class="taR"><b>借款结余</b></td>
  7979. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  7980. </tbody></table>
  7981. ';
  7982. }
  7983. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  7984. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  7985. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  7986. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  7987. $html .= '<tr><th>' . $value ['name'] . '</th>
  7988. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7989. }
  7990. $html .= '<tr><th class="taR">合计</th>
  7991. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  7992. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  7993. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  7994. <tr><th class="taC" colspan="2">费用说明</th>
  7995. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  7996. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  7997. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  7998. </tbody></table>';
  7999. } else {
  8000. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8001. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8002. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8003. $html .= '<tr><th>' . $value ['name'] . '</th>
  8004. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8005. }
  8006. $html .= '<tr><th class="taR">合计</th>
  8007. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8008. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8009. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8010. $html .= '<tr><th>' . $value ['name'] . '</th>
  8011. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8012. }
  8013. $html .= '<tr><th class="taR">合计</th>
  8014. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8015. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8016. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8017. $html .= '<tr><th>' . $value ['name'] . '</th>
  8018. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8019. }
  8020. $html .= '<tr><th class="taR">合计</th>
  8021. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8022. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8023. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8024. $html .= '<tr><th>' . $value ['name'] . '</th>
  8025. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8026. }
  8027. $html .= '<tr><th class="taR">合计</th>
  8028. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8029. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8030. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8031. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8032. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8033. }
  8034. $html .= '<tr><th class="taR">合计</th>
  8035. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8036. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8037. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8038. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8039. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8040. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8041. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  8042. $html .= '</tbody></table>';
  8043. /*
  8044. * <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>
  8045. */
  8046. }
  8047. // print_r($verifyStaff);die;
  8048. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  8049. foreach ( $verifyStaff as $key => $value ) {
  8050. $key = trim ( strtr ( $key, '_R', ' ' ) );
  8051. $sinfo = $staff->getOne ( array (
  8052. 'select' => 'username',
  8053. 'where' => ' sid=' . $key,
  8054. 'asArray' => true
  8055. ) );
  8056. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8057. }
  8058. $html .= '</tbody></table>';
  8059. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  8060. foreach ( $rinfo ['executeCopy'] as $value ) {
  8061. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8062. }
  8063. $html .= '</tbody></table>';
  8064. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  8065. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  8066. </tr></table>';
  8067. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  8068. echo json_encode ( array (
  8069. 'status' => 1,
  8070. 'html' => $html
  8071. ) );
  8072. die ();
  8073. }
  8074. /**
  8075. * 删除附件
  8076. */
  8077. function ajaxRemEnclousur() {
  8078. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  8079. if (empty ( $key ))
  8080. echo json_encode ( array (
  8081. 'status' => 2
  8082. ) );
  8083. Doo::loadModel ( 'enclosur' );
  8084. $enclosur = new enclosur ();
  8085. $enclosur->delEnclosurByEid ( $key );
  8086. echo json_encode ( array (
  8087. 'status' => 1
  8088. ) );
  8089. }
  8090. function remittance() {
  8091. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8092. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8093. Doo::loadModel ( 'receipt' );
  8094. $receipt = new receipt ();
  8095. Doo::loadModel ( 'staff' );
  8096. $staff = new staff ();
  8097. $dateCondition = " and Year(pastDate) =" . $year;
  8098. if (! empty ( $month ))
  8099. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  8100. // get Receipt By verifyID status 1
  8101. $receiptList = $receipt->find ( array (
  8102. 'select' => 'sum(sum) as sum,staff,pastDate',
  8103. 'where' => ' status=1' . $dateCondition,
  8104. 'desc' => 'pastDate',
  8105. 'groupby' => 'staff,pastDate',
  8106. 'asArray' => true
  8107. ) );
  8108. $dateList = $receipt->find ( array (
  8109. 'select' => 'pastDate,verifyStaff',
  8110. 'where' => ' status=1' . $dateCondition,
  8111. 'desc' => 'pastDate',
  8112. 'groupby' => 'pastDate',
  8113. 'asArray' => true
  8114. ) );
  8115. $dataList = array ();
  8116. foreach ( $dateList as $d => $a ) {
  8117. $dataList [$a ['pastDate']] = array ();
  8118. $daySum = 0;
  8119. foreach ( $receiptList as $key => $value ) {
  8120. if ($a ['pastDate'] == $value ['pastDate']) {
  8121. $oderList = $receipt->find ( array (
  8122. 'select' => 'receiptOrder',
  8123. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  8124. 'asArray' => true
  8125. ) );
  8126. $list = array ();
  8127. $html = "";
  8128. foreach ( $oderList as $v ) {
  8129. array_push ( $list, $v ['receiptOrder'] );
  8130. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  8131. }
  8132. $receiptList [$key] ['receiptOrder'] = $html;
  8133. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  8134. $sinfo = $staff->getOne ( array (
  8135. 'select' => 'username ',
  8136. 'where' => ' sid=' . $value ['staff'],
  8137. 'asArray' => true
  8138. ) );
  8139. $receiptList [$key] ['username'] = $sinfo ['username'];
  8140. $daySum += $value ['sum'];
  8141. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  8142. }
  8143. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  8144. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  8145. }
  8146. }
  8147. // print_r($dataList);
  8148. $data ['dataList'] = $dataList;
  8149. $mothHtml = "";
  8150. for($i = 1; $i <= 12; $i ++) {
  8151. if ($month == $i)
  8152. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8153. else
  8154. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8155. }
  8156. $data ['year'] = $year;
  8157. $data ['mothHtml'] = $mothHtml;
  8158. $data ['memu'] = "receipt";
  8159. $data ['staff'] = $this->staff;
  8160. $data ['receiptMemu'] = 'approval';
  8161. $data ['verifyId'] = $this->verifyId;
  8162. $data ['executeId'] = $this->executeId;
  8163. $this->render ( "/admin/saeaReportListPay", $data );
  8164. }
  8165. /**
  8166. * 金额调整,提高稳定性
  8167. * @return string
  8168. */
  8169. function revocationAdjustment() {
  8170. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  8171. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  8172. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  8173. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  8174. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  8175. Doo::loadClass ( 'XDeode' );
  8176. $XDeode = new XDeode ( 5 );
  8177. Doo::loadModel ( 'receipt' );
  8178. $receipt = new receipt ();
  8179. $sid = $XDeode->decode ( $sidKey );
  8180. $rid = $XDeode->decode ( $ridKey );
  8181. $reviseKey = $XDeode->decode ( $reviseKey );
  8182. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  8183. die ( 'illegal request' );
  8184. $receiptDetail = $receipt->getOne ( array (
  8185. 'where' => 'rid=' . $rid,
  8186. 'asArray' => true
  8187. ) );
  8188. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  8189. die ( 'illegal request' );
  8190. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8191. if (! isset ( $reviseDetail [$reviseKey] ))
  8192. die ( 'illegal request' );
  8193. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  8194. unset ( $reviseDetail [$reviseKey] );
  8195. $revisePrice = 0;
  8196. foreach ( $reviseDetail as $key => $value ) {
  8197. $revisePrice += $value ['price'];
  8198. }
  8199. $reviseDetailString = json_encode ( $reviseDetail );
  8200. $receipt->reviseDetail = $reviseDetailString;
  8201. $receipt->sum = $receiptDetail ['sum'] - $price;
  8202. $receipt->revisePrice = $revisePrice;
  8203. $receipt->update ( array (
  8204. 'where' => 'rid=' . $rid
  8205. ) );
  8206. return '/receiptburEdi/' . $rid;
  8207. } else
  8208. die ( 'illegal request2' );
  8209. }
  8210. function updateApprovalReceipt() {
  8211. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  8212. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  8213. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8214. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  8215. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  8216. if (! empty ( $rid )) {
  8217. Doo::loadModel ( "verify" );
  8218. $verify = new verify ();
  8219. Doo::loadModel ( "receiptDetail" );
  8220. $receiptDetailObj = new receiptDetail ();
  8221. Doo::loadModel ( "itemStatistics" );
  8222. Doo::loadModel ( "statistics" );
  8223. $statistics = new statistics ();
  8224. $itemStatistics = new itemStatistics ();
  8225. Doo::loadModel ( "receipt" );
  8226. $receipt = new receipt ();
  8227. $receiptDetail = $receipt->getOne ( array (
  8228. 'where' => 'rid=' . $rid . ' and status=2 ',
  8229. 'asArray' => true
  8230. ) );
  8231. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  8232. $nsflag = true;
  8233. foreach ( $nslist as $value ) {
  8234. if ($value == $this->staff ['0'] ['sid']) {
  8235. $nsflag = false;
  8236. break;
  8237. }
  8238. }
  8239. if (empty ( $receiptDetail ) || $nsflag)
  8240. return "/approvalExpenses/pendApproval";
  8241. $verifyDetail = $verify->getOne ( array (
  8242. 'where' => ' vid =' . $receiptDetail ['verify'],
  8243. 'asArray' => true
  8244. ) );
  8245. $verifyString = $verifyDetail ['staff'];
  8246. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  8247. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  8248. if (empty ( $opinion )) {
  8249. if ($status == 3)
  8250. $opinion = "终止";
  8251. else
  8252. $opinion = "同意支付";
  8253. }
  8254. $nowStaff = 0;
  8255. $nowStaffList = array ();
  8256. if (empty ( $verifyStaff )) {
  8257. // 还需加入是否已经进入角色审批
  8258. if ($verifyDetail [0] [1] == 'ROLE') {
  8259. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  8260. foreach ( $vStaffString as $key => $value ) {
  8261. $staffK = explode ( "_", $value );
  8262. if ($staffK [0] != $this->staff [0] ['sid'])
  8263. array_push ( $nowStaffList, $staffK [0] );
  8264. }
  8265. // print_r($verifyDetail);
  8266. // die;
  8267. if (! empty ( $nowStaffList )) {
  8268. $nowStaff = implode ( ',', $nowStaffList );
  8269. $verifyStaff = array (
  8270. $this->staff [0] ['sid'] . "_R" => array (
  8271. 'date' => date ( 'Y-m-d' ),
  8272. 'opinion' => $opinion,
  8273. 'status' => $status,
  8274. 'nextStaff' => $verifyDetail [0] [0],
  8275. 'ROLE' => 1
  8276. )
  8277. );
  8278. } else {
  8279. $nowStaff = $verifyDetail [1] [0];
  8280. $verifyStaff = array (
  8281. $this->staff [0] ['sid'] . "_R" => array (
  8282. 'date' => date ( 'Y-m-d' ),
  8283. 'opinion' => $opinion,
  8284. 'status' => $status,
  8285. 'nextStaff' => $verifyDetail [1] [0]
  8286. )
  8287. );
  8288. }
  8289. } else {
  8290. if ($verifyDetail [1] [1] == 'ROLE') {
  8291. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  8292. // echo "dd";
  8293. foreach ( $vStaffString as $key => $value ) {
  8294. $staffK = explode ( "_", $value );
  8295. array_push ( $nowStaffList, $staffK [0] );
  8296. }
  8297. $nowStaff = implode ( ',', $nowStaffList );
  8298. $verifyStaff = array (
  8299. $this->staff [0] ['sid'] => array (
  8300. 'date' => date ( 'Y-m-d' ),
  8301. 'opinion' => $opinion,
  8302. 'status' => $status,
  8303. 'nextStaff' => $verifyDetail [1] [0],
  8304. 'ROLE' => 1
  8305. )
  8306. );
  8307. } else {
  8308. $nowStaff = $verifyDetail [1] [0];
  8309. $verifyStaff = array (
  8310. $this->staff [0] ['sid'] => array (
  8311. 'date' => date ( 'Y-m-d' ),
  8312. 'opinion' => $opinion,
  8313. 'status' => $status,
  8314. 'nextStaff' => $verifyDetail [1] [0]
  8315. )
  8316. );
  8317. }
  8318. }
  8319. if ($status == 3)
  8320. $verifyStaff = array (
  8321. 'final' => $status,
  8322. $this->staff [0] ['sid'] => array (
  8323. 'date' => date ( 'Y-m-d' ),
  8324. 'opinion' => $opinion,
  8325. 'status' => $status
  8326. )
  8327. );
  8328. $vStaffString = json_encode ( $verifyStaff );
  8329. $receipt->nowStaff = $nowStaff;
  8330. $receipt->verifyStaff = $vStaffString;
  8331. } else {
  8332. $VS = end ( $verifyStaff );
  8333. // 非角色审批
  8334. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  8335. $nextStaff = 0;
  8336. $roleSTF = false;
  8337. foreach ( $verifyDetail as $key => $value ) {
  8338. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  8339. if (isset ( $verifyDetail [$key + 1] )) {
  8340. $nextStaff = $verifyDetail [$key + 1] [0];
  8341. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  8342. $roleSTF = true;
  8343. }
  8344. break;
  8345. }
  8346. }
  8347. if (! $roleSTF) {
  8348. $nowStaff = $nextStaff;
  8349. $verifyStaff [$this->staff [0] ['sid']] = array (
  8350. 'date' => date ( 'Y-m-d' ),
  8351. 'opinion' => $opinion,
  8352. 'status' => $status,
  8353. 'nextStaff' => $nextStaff
  8354. );
  8355. } else {
  8356. // 获取角色下的所有用户ID
  8357. $nowStaffList = array ();
  8358. foreach ( $verifyDetail as $vfk ) {
  8359. if ($vfk [1] == 'ROLE') {
  8360. $vStaffString = json_decode ( $vfk [3] );
  8361. foreach ( $vStaffString as $key => $value ) {
  8362. $staffK = explode ( "_", $value );
  8363. array_push ( $nowStaffList, $staffK [0] );
  8364. }
  8365. }
  8366. }
  8367. $nowStaff = implode ( ',', $nowStaffList );
  8368. $verifyStaff [$this->staff [0] ['sid']] = array (
  8369. 'date' => date ( 'Y-m-d' ),
  8370. 'opinion' => $opinion,
  8371. 'status' => $status,
  8372. 'nextStaff' => $nextStaff,
  8373. 'ROLE' => 0
  8374. );
  8375. }
  8376. if ($status == 3) {
  8377. $verifyStaff ['final'] = $status;
  8378. $verifyStaff [$this->staff [0] ['sid']] = array (
  8379. 'date' => date ( 'Y-m-d' ),
  8380. 'opinion' => $opinion,
  8381. 'status' => $status
  8382. );
  8383. }
  8384. $vStaffString = json_encode ( $verifyStaff );
  8385. $receipt->nowStaff = $nowStaff;
  8386. $receipt->verifyStaff = $vStaffString;
  8387. }
  8388. // 角色审批
  8389. if (isset ( $VS ['ROLE'] )) {
  8390. // 找出角色人 当前审批角色组
  8391. $verifyJSStaff = array ();
  8392. $nowStaffList2 = array ();
  8393. foreach ( $verifyDetail as $key => $value ) {
  8394. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  8395. $verifyJSStaff = json_decode ( $value [3] );
  8396. foreach ( $verifyJSStaff as $m ) {
  8397. $staffK = explode ( "_", $m );
  8398. array_push ( $nowStaffList2, $staffK [0] );
  8399. }
  8400. // print_r($nowStaffList2);
  8401. }
  8402. }
  8403. $RoleVerifyStaff = array ();
  8404. foreach ( $verifyStaff as $key => $value ) {
  8405. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  8406. foreach ( $nowStaffList2 as $m ) {
  8407. if ($key == $m . "_R")
  8408. $RoleVerifyStaff [$key] = $value;
  8409. }
  8410. }
  8411. }
  8412. // print_r($verifyStaff);
  8413. // print_r($nowStaffList2);
  8414. // print_r($RoleVerifyStaff);
  8415. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  8416. // print_r($verifyJSStaff);
  8417. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  8418. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  8419. // 下一个审批人ID
  8420. $nextStaff = 0;
  8421. $falg = false;
  8422. foreach ( $verifyDetail as $key => $value ) {
  8423. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  8424. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  8425. $falg = true;
  8426. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  8427. $nowStaffList = array ();
  8428. foreach ( $vStaffString as $v ) {
  8429. $staffK = explode ( "_", $v );
  8430. array_push ( $nowStaffList, $staffK [0] );
  8431. }
  8432. $nowStaff = implode ( ',', $nowStaffList );
  8433. $nextStaff = $verifyDetail [$key + 1] [0];
  8434. } elseif (isset ( $verifyDetail [$key + 1] )) {
  8435. $nextStaff = $verifyDetail [$key + 1] [0];
  8436. $nowStaff = $nextStaff;
  8437. } else
  8438. $nowStaff = '';
  8439. break;
  8440. }
  8441. }
  8442. if ($falg)
  8443. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8444. 'date' => date ( 'Y-m-d' ),
  8445. 'opinion' => $opinion,
  8446. 'status' => $status,
  8447. 'nextStaff' => $nextStaff,
  8448. 'ROLE' => 1
  8449. );
  8450. else
  8451. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8452. 'date' => date ( 'Y-m-d' ),
  8453. 'opinion' => $opinion,
  8454. 'status' => $status,
  8455. 'nextStaff' => $nextStaff
  8456. );
  8457. // print_r($verifyStaff);
  8458. // echo $nowStaff;die;
  8459. } else { // 进入下一个角色或者审批人
  8460. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  8461. //
  8462. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  8463. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8464. 'date' => date ( 'Y-m-d' ),
  8465. 'opinion' => $opinion,
  8466. 'status' => $status,
  8467. 'nextStaff' => $VS ['nextStaff'],
  8468. 'ROLE' => 1
  8469. );
  8470. // print_r($verifyStaff);
  8471. // die;
  8472. }
  8473. if ($status == 3) {
  8474. $verifyStaff ['final'] = $status;
  8475. $verifyStaff [$this->staff [0] ['sid']] = array (
  8476. 'date' => date ( 'Y-m-d' ),
  8477. 'opinion' => $opinion,
  8478. 'status' => $status
  8479. );
  8480. }
  8481. $vStaffString = json_encode ( $verifyStaff );
  8482. $receipt->verifyStaff = $vStaffString;
  8483. $receipt->nowStaff = $nowStaff;
  8484. // die;
  8485. // }
  8486. // print_r($verifyStaff);
  8487. // die;
  8488. }
  8489. // print_r($verifyStaff);die;
  8490. }
  8491. // print_r($verifyDetail);
  8492. $roleKey = 0;
  8493. $roleId = 0;
  8494. $verifyDetailCopy = array ();
  8495. foreach ( $verifyDetail as $k => $v ) {
  8496. if ($v [1] == 'ROLE') {
  8497. $roleId = $v [0];
  8498. $roleVerify = json_decode ( $v [3], true );
  8499. $roleKey = $k;
  8500. $roleArray = array ();
  8501. foreach ( $roleVerify as $o => $p ) {
  8502. $staffID = explode ( '_', $p );
  8503. $exp = array (
  8504. 0 => $staffID [0],
  8505. 1 => $staffID [1]
  8506. );
  8507. array_push ( $roleArray, $exp );
  8508. }
  8509. $verifyDetailCopy [$v [0]] = $roleArray;
  8510. }
  8511. }
  8512. // print_r($verifyDetail);
  8513. foreach ( $verifyDetailCopy as $k => $v ) {
  8514. foreach ( $verifyDetail as $m => $n ) {
  8515. if ($n [0] == $k) {
  8516. array_splice ( $verifyDetail, $m, 1, $v );
  8517. }
  8518. }
  8519. }
  8520. // die;
  8521. // if (!empty($roleArray))
  8522. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  8523. // echo $roleId;
  8524. // print_r($verifyStaff);
  8525. // print_r($verifyDetail);
  8526. // die;
  8527. Doo::loadModel ( "receiptLog" );
  8528. $receiptLog = new receiptLog ();
  8529. // 审批日志
  8530. if (! isset ( $verifyStaff ['final'] )) {
  8531. if (! empty ( $roleId )) {
  8532. Doo::loadModel ( "role" );
  8533. $role = new role ();
  8534. $roleInfo = $role->getOne ( array (
  8535. 'where' => 'rid=' . $roleId,
  8536. 'asArray' => true
  8537. ) );
  8538. $receiptLog->rolename = $roleInfo ['name'];
  8539. }
  8540. $receiptLog->username = $this->staff [0] ['username'];
  8541. $receiptLog->uid = $this->staff [0] ['sid'];
  8542. $receiptLog->date = date ( "Y-m-d" );
  8543. $receiptLog->opinion = $opinion;
  8544. $receiptLog->img = $this->staff [0] ['avatar'];
  8545. $receiptLog->status = 1;
  8546. $receiptLog->rid = $rid;
  8547. $receiptLog->insert ();
  8548. }
  8549. if (isset ( $verifyStaff ['final'] )) { // rDetail
  8550. $receipt->verifyBreakup = $verifyString;
  8551. $receipt->status = 3;
  8552. $receiptDetailObj->status = 3;
  8553. $receiptDetailObj->update ( array (
  8554. 'where' => 'rid=' . $rid
  8555. ) );
  8556. if (! empty ( $roleId )) {
  8557. Doo::loadModel ( "role" );
  8558. $role = new role ();
  8559. $roleInfo = $role->getOne ( array (
  8560. 'where' => 'rid=' . $roleId,
  8561. 'asArray' => true
  8562. ) );
  8563. $receiptLog->rolename = $roleInfo ['name'];
  8564. }
  8565. $receiptLog->username = $this->staff [0] ['username'];
  8566. $receiptLog->uid = $this->staff [0] ['sid'];
  8567. $receiptLog->date = date ( "Y-m-d" );
  8568. $receiptLog->opinion = $opinion;
  8569. $receiptLog->img = $this->staff [0] ['avatar'];
  8570. $receiptLog->status = 3;
  8571. $receiptLog->rid = $rid;
  8572. $receiptLog->insert ();
  8573. // 微信企业号通知
  8574. $this->setWXMsg ( $rid, 3 );
  8575. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  8576. $receipt->status = 1;
  8577. $reviseSum = 0;
  8578. $receipt->verifyBreakup = $verifyString;
  8579. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  8580. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8581. foreach ( $reviseDetail as $key => $value ) {
  8582. $receiptDetailObj = new receiptDetail ();
  8583. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8584. $receiptDetailObj->item = $value ['description'];
  8585. $receiptDetailObj->itemCategory = "报销金额调整";
  8586. $receiptDetailObj->price = $value ['price'];
  8587. $receiptDetailObj->date = $receiptDetail ['date'];
  8588. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  8589. $receiptDetailObj->rid = $rid;
  8590. $receiptDetailObj->status = 1;
  8591. $receiptDetailObj->insert ();
  8592. $reviseSum += $value ['price'];
  8593. }
  8594. $itemStatistics = new itemStatistics ();
  8595. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  8596. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8597. $itemStatistics->price = $reviseSum;
  8598. $itemStatistics->itemCategory = "报销金额调整";
  8599. $itemStatistics->date = $receiptDetail ['date'];
  8600. $itemStatistics->insert ();
  8601. }
  8602. $receiptDetailObj = new receiptDetail ();
  8603. $receiptDetailObj->status = 1;
  8604. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  8605. $receiptDetailObj->update ( array (
  8606. 'where' => 'rid=' . $rid
  8607. ) );
  8608. $dateArray = explode ( "-", $receiptDetail ['date'] );
  8609. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  8610. $stat = $statistics->getOne ( array (
  8611. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  8612. 'asArray' => true
  8613. ) );
  8614. if (empty ( $stat )) {
  8615. $statistics->date = $receiptDetail ['date'];
  8616. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  8617. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8618. $statistics->agPrice = $receiptDetail ['sum'];
  8619. $statistics->rePrice = $reviseSum;
  8620. $statistics->insert ();
  8621. } else {
  8622. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  8623. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  8624. $statistics->update ( array (
  8625. 'where' => 'sid=' . $stat ['sid']
  8626. ) );
  8627. }
  8628. $dateArray = explode ( "-", $receiptDetail ['date'] );
  8629. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  8630. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  8631. foreach ( $accountItem ['cSum'] as $key => $value ) {
  8632. if ($key == "agencySum") {
  8633. $iStatistics = $itemStatistics->getOne ( array (
  8634. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  8635. 'asArray' => true
  8636. ) );
  8637. if (empty ( $iStatistics )) {
  8638. $itemStatistics->cid = $receiptDetail ['cid'];
  8639. ;
  8640. $itemStatistics->staff = $receiptDetail ['staff'];
  8641. $itemStatistics->price = $value;
  8642. $itemStatistics->itemCategory = $this->AGENCY;
  8643. $itemStatistics->date = $receiptDetail ['date'];
  8644. $itemStatistics->insert ();
  8645. } else {
  8646. if (! empty ( $value )) {
  8647. $itemStatistics->price = $value + $iStatistics ['price'];
  8648. $itemStatistics->update ( array (
  8649. 'where' => 'sid=' . $iStatistics ['sid']
  8650. ) );
  8651. }
  8652. }
  8653. } elseif ($key == "travelSum") {
  8654. $iStatistics = $itemStatistics->getOne ( array (
  8655. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  8656. 'asArray' => true
  8657. ) );
  8658. if (empty ( $iStatistics )) {
  8659. $itemStatistics->cid = $receiptDetail ['cid'];
  8660. $itemStatistics->staff = $receiptDetail ['staff'];
  8661. $itemStatistics->price = $value;
  8662. $itemStatistics->itemCategory = $this->TRAVEL;
  8663. $itemStatistics->date = $receiptDetail ['date'];
  8664. $itemStatistics->insert ();
  8665. } else {
  8666. if (! empty ( $value )) {
  8667. $itemStatistics->price = $value + $iStatistics ['price'];
  8668. $itemStatistics->update ( array (
  8669. 'where' => 'sid=' . $iStatistics ['sid']
  8670. ) );
  8671. }
  8672. }
  8673. } elseif ($key == "trainSum") {
  8674. $iStatistics = $itemStatistics->getOne ( array (
  8675. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  8676. 'asArray' => true
  8677. ) );
  8678. if (empty ( $iStatistics )) {
  8679. $itemStatistics->cid = $receiptDetail ['cid'];
  8680. $itemStatistics->staff = $receiptDetail ['staff'];
  8681. $itemStatistics->price = $value;
  8682. $itemStatistics->itemCategory = $this->TRAIN;
  8683. $itemStatistics->date = $receiptDetail ['date'];
  8684. $itemStatistics->insert ();
  8685. } else {
  8686. if (! empty ( $value )) {
  8687. $itemStatistics->price = $value + $iStatistics ['price'];
  8688. $itemStatistics->update ( array (
  8689. 'where' => 'sid=' . $iStatistics ['sid']
  8690. ) );
  8691. }
  8692. }
  8693. } elseif ($key == "otherSum") {
  8694. $iStatistics = $itemStatistics->getOne ( array (
  8695. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  8696. 'asArray' => true
  8697. ) );
  8698. if (empty ( $iStatistics )) {
  8699. $itemStatistics->cid = $receiptDetail ['cid'];
  8700. $itemStatistics->staff = $receiptDetail ['staff'];
  8701. $itemStatistics->price = $value;
  8702. $itemStatistics->itemCategory = $this->OTHER;
  8703. $itemStatistics->date = $receiptDetail ['date'];
  8704. $itemStatistics->insert ();
  8705. } else {
  8706. if (! empty ( $value )) {
  8707. $itemStatistics->price = $value + $iStatistics ['price'];
  8708. $itemStatistics->update ( array (
  8709. 'where' => 'sid=' . $iStatistics ['sid']
  8710. ) );
  8711. }
  8712. }
  8713. }
  8714. }
  8715. $receipt->pastDate = date ( "Y-m-d" );
  8716. // 微信企业号通知
  8717. $this->setWXMsg ( $rid, 1 );
  8718. }
  8719. //是否有流水
  8720. Doo::loadModel ( 'wasteBook' );
  8721. $wasteBook = new wasteBook ();
  8722. $accountType=3;
  8723. if ($receiptDetail['Rtype']==1){
  8724. $accountType=2;
  8725. }elseif($receiptDetail['Rtype']==2){
  8726. $accountType=4;
  8727. }
  8728. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $rid );
  8729. if (empty($wbDetail)){
  8730. $receipt->amount = $amount;
  8731. }
  8732. $receipt->update ( array (
  8733. 'where' => ' rid = ' . $rid
  8734. ) );
  8735. // 进入下一条审批费用新加需求
  8736. $vidList = array ();
  8737. $verifyDetail = $verify->find ( array (
  8738. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  8739. 'asArray' => true
  8740. ) );
  8741. foreach ( $verifyDetail as $key => $value ) {
  8742. array_push ( $vidList, $value ['vid'] );
  8743. }
  8744. $vid = implode ( ",", $vidList );
  8745. if (empty ( $verifyDetail ))
  8746. $vid = 0;
  8747. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  8748. $receipt = new receipt ();
  8749. $rd = $receipt->getOne ( array (
  8750. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ') and Rtype!=3',
  8751. 'asc' => 'rid',
  8752. 'asArray' => true
  8753. ) );
  8754. if (empty ( $rd )) {
  8755. return '/approvalExpenses/pendApproval';
  8756. }
  8757. if ($rd ['Rtype'] == 1) {
  8758. if ($rd ['isBK'] == 1) {
  8759. return '/receiptburEdi/' . $rd ['rid'];
  8760. } else {
  8761. return '/expensesEdi/' . $rd ['rid'];
  8762. }
  8763. } elseif ($rd ['Rtype'] == 2) {
  8764. return '/remitApproval/' . $rd ['rid'];
  8765. } else {
  8766. return '/receiptburEdi/' . $rd ['rid'];
  8767. }
  8768. // return "/approvalExpenses/pendApproval";
  8769. }
  8770. }
  8771. function expensesRetreats() {
  8772. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  8773. if (! empty ( $rid )) {
  8774. // 操作记录
  8775. Doo::loadModel ( "receipt" );
  8776. $receipt = new receipt ();
  8777. Doo::loadModel ( "receiptLog" );
  8778. $receiptLog = new receiptLog ();
  8779. Doo::loadModel ( "verify" );
  8780. $verify = new verify ();
  8781. $receiptInfo = $receipt->getOne ( array (
  8782. 'where' => 'rid=' . $rid,
  8783. 'asArray' => true
  8784. ) );
  8785. $vr = $verify->getOne ( array (
  8786. 'where' => 'vid=' . $receiptInfo ['verify'],
  8787. 'asArray' => true
  8788. ) );
  8789. $jd = json_decode ( $vr ['staff'] );
  8790. $roleId = 0;
  8791. foreach ( $jd as $key => $value ) {
  8792. if ($value [1] == 'ROLE') {
  8793. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  8794. if ($pos !== false) {
  8795. $roleId = $value [0];
  8796. }
  8797. }
  8798. }
  8799. // 审批日志
  8800. // echo $roleId;die;
  8801. if (! empty ( $roleId )) {
  8802. Doo::loadModel ( "role" );
  8803. $role = new role ();
  8804. $roleInfo = $role->getOne ( array (
  8805. 'where' => 'rid=' . $roleId,
  8806. 'asArray' => true
  8807. ) );
  8808. $receiptLog->rolename = $roleInfo ['name'];
  8809. }
  8810. $receiptLog->username = $this->staff [0] ['username'];
  8811. $receiptLog->uid = $this->staff [0] ['sid'];
  8812. $receiptLog->date = date ( "Y-m-d" );
  8813. $receiptLog->opinion = '撤回';
  8814. $receiptLog->img = $this->staff [0] ['avatar'];
  8815. $receiptLog->status = 4;
  8816. $receiptLog->rid = $rid;
  8817. $receiptLog->insert ();
  8818. $receipt->status = 4;
  8819. $receipt->update ( array (
  8820. 'where' => 'rid=' . $rid
  8821. ) );
  8822. // 微信企业号通知
  8823. $this->setWXMsg ( $rid, 2 );
  8824. }
  8825. // echo "ddd";
  8826. return '/approvalExpenses/pendApproval';
  8827. }
  8828. function updateCheReceipt() {
  8829. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8830. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  8831. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  8832. if (! empty ( $rid )) {
  8833. // 操作记录
  8834. Doo::loadModel ( "receipt" );
  8835. $receipt = new receipt ();
  8836. Doo::loadModel ( "receiptLog" );
  8837. $receiptLog = new receiptLog ();
  8838. Doo::loadModel ( "verify" );
  8839. $verify = new verify ();
  8840. $receiptInfo = $receipt->getOne ( array (
  8841. 'where' => 'rid=' . $rid . ' and status=2',
  8842. 'asArray' => true
  8843. ) );
  8844. if (empty ( $receiptInfo )) {
  8845. echo json_encode ( array (
  8846. 'status' => 2
  8847. ) );
  8848. die ();
  8849. }
  8850. $vr = $verify->getOne ( array (
  8851. 'where' => 'vid=' . $receiptInfo ['verify'],
  8852. 'asArray' => true
  8853. ) );
  8854. $jd = json_decode ( $vr ['staff'] );
  8855. $roleId = 0;
  8856. foreach ( $jd as $key => $value ) {
  8857. if ($value [1] == 'ROLE') {
  8858. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  8859. if ($pos !== false) {
  8860. $roleId = $value [0];
  8861. }
  8862. }
  8863. }
  8864. // 审批日志
  8865. // echo $roleId;die;
  8866. if (! empty ( $roleId )) {
  8867. Doo::loadModel ( "role" );
  8868. $role = new role ();
  8869. $roleInfo = $role->getOne ( array (
  8870. 'where' => 'rid=' . $roleId,
  8871. 'asArray' => true
  8872. ) );
  8873. $receiptLog->rolename = $roleInfo ['name'];
  8874. }
  8875. $receiptLog->username = $this->staff [0] ['username'];
  8876. $receiptLog->uid = $this->staff [0] ['sid'];
  8877. $receiptLog->date = date ( "Y-m-d" );
  8878. $receiptLog->opinion = $opinion;
  8879. $receiptLog->img = $this->staff [0] ['avatar'];
  8880. $receiptLog->status = 4;
  8881. $receiptLog->rid = $rid;
  8882. $receiptLog->insert ();
  8883. $receipt->status = 4;
  8884. $receipt->update ( array (
  8885. 'where' => 'rid=' . $rid
  8886. ) );
  8887. // 微信企业号通知
  8888. $this->setWXMsg ( $rid, 2 );
  8889. echo json_encode ( array (
  8890. 'status' => 1
  8891. ) );
  8892. // Header("HTTP/1.1 303 See Other");
  8893. // Header("Location: /approvalExpenses/pendApproval");
  8894. die ();
  8895. }
  8896. echo json_encode ( array (
  8897. 'status' => 2
  8898. ) );
  8899. die ();
  8900. // echo "ddd";
  8901. // return '/saeaBorad';
  8902. }
  8903. function revisePrice() {
  8904. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  8905. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  8906. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8907. // echo $price;die;
  8908. if (! empty ( $rid )) {
  8909. Doo::loadModel ( "receipt" );
  8910. $receipt = new receipt ();
  8911. $receiptDetail = $receipt->getOne ( array (
  8912. 'where' => 'rid=' . $rid . ' and status=2 ',
  8913. 'asArray' => true
  8914. ) );
  8915. if (empty ( $receiptDetail ))
  8916. die ( 'illegal request' );
  8917. $reviseDetail = array ();
  8918. if (empty ( $receiptDetail ['reviseDetail'] )) {
  8919. array_push ( $reviseDetail, array (
  8920. 'sid' => $this->staff [0] ['sid'],
  8921. 'name' => $this->staff [0] ['username'],
  8922. 'description' => $description,
  8923. 'price' => $price
  8924. ) );
  8925. $reviseDetailString = json_encode ( $reviseDetail );
  8926. $receipt->reviseDetail = $reviseDetailString;
  8927. $receipt->revisePrice = $price;
  8928. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  8929. } else {
  8930. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8931. array_push ( $reviseDetail, array (
  8932. 'sid' => $this->staff [0] ['sid'],
  8933. 'name' => $this->staff [0] ['username'],
  8934. 'description' => $description,
  8935. 'price' => $price
  8936. ) );
  8937. $reviseDetailString = json_encode ( $reviseDetail );
  8938. $receipt->reviseDetail = $reviseDetailString;
  8939. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  8940. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  8941. }
  8942. $receipt->update ( array (
  8943. 'where' => 'rid=' . $rid
  8944. ) );
  8945. if ($receiptDetail ['Rtype'] == 1) {
  8946. if ($receiptDetail ['isBK'] == 1) {
  8947. return '/receiptburEdi/' . $receiptDetail ['rid'];
  8948. }
  8949. } elseif ($receiptDetail ['Rtype'] == 2) {
  8950. } else {
  8951. return '/receiptburEdi/' . $receiptDetail ['rid'];
  8952. }
  8953. }
  8954. die ( 'illegal request' );
  8955. }
  8956. function personalCollect() {
  8957. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8958. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  8959. $this->showCache ( $path );
  8960. Doo::loadModel ( "receiptDetail" );
  8961. Doo::loadModel ( "itemStatistics" );
  8962. Doo::loadModel ( 'statistics' );
  8963. $statistics = new statistics ();
  8964. $itemStatistics = new itemStatistics ();
  8965. $receiptDetail = new receiptDetail ();
  8966. $receiptCollectList = $receiptDetail->find ( array (
  8967. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  8968. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  8969. 'groupby' => 'itemCategory,Month(date)',
  8970. 'asArray' => true
  8971. ) );
  8972. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  8973. 'where' => 'staff=' . $this->staff [0] ['sid'],
  8974. 'asArray' => true
  8975. ) );
  8976. // create collect html
  8977. $collectArray = array (
  8978. '日常相关费用' => array (),
  8979. '差旅相关费用' => array (),
  8980. '培训班费用' => array (),
  8981. '其他' => array ()
  8982. );
  8983. $adjustment = array ();
  8984. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  8985. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  8986. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  8987. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  8988. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  8989. array_push ( $collectArray ['培训班费用'], $collectHtml );
  8990. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  8991. array_push ( $collectArray ['其他'], $collectHtml );
  8992. $data ['collectArray'] = $collectArray;
  8993. // statistics html
  8994. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  8995. if (empty ( $stList ))
  8996. $stList = array (
  8997. 'rePrice' => 0,
  8998. 'agPrice' => 0
  8999. );
  9000. $data ['stList'] = array (
  9001. 'rePrice' => $stList ['rePrice'],
  9002. 'agPrice' => $stList ['agPrice'],
  9003. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9004. );
  9005. // Adjustment price html
  9006. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9007. array_push ( $adjustment, $collectHtml );
  9008. $data ['adjustment'] = $adjustment;
  9009. // total price html
  9010. $collectHtml = "";
  9011. $total = 0;
  9012. for($i = 1; $i <= 12; $i ++) {
  9013. $sumPrice = 0;
  9014. foreach ( $receiptCollectList as $key => $value ) {
  9015. if ($value ['month'] == $i) {
  9016. $sumPrice += $value ['price'];
  9017. }
  9018. }
  9019. if ($sumPrice == 0)
  9020. $collectHtml .= '<td class="taR">-</td>';
  9021. else
  9022. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9023. $total += $sumPrice;
  9024. }
  9025. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9026. $data ['totalPrice'] = $collectHtml;
  9027. $dateHtml = "";
  9028. $now = date ( "Y" );
  9029. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9030. if ($YEARD <= $now) {
  9031. $dateHtml .= '<option ';
  9032. if ($year == $YEARD) {
  9033. $dateHtml .= 'selected ';
  9034. }
  9035. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9036. }
  9037. }
  9038. $data ['dateHtml'] = $dateHtml;
  9039. $data ['year'] = $year;
  9040. $data ['totalYear'] = $total;
  9041. $data ['memu'] = "receipt";
  9042. $data ['staff'] = $this->staff;
  9043. $data ['receiptMemu'] = 'personalCollect';
  9044. $data ['verifyId'] = $this->verifyId;
  9045. $data ['executeId'] = $this->executeId;
  9046. // year staff status 2,4
  9047. if ($year < date ( "Y" )) {
  9048. Doo::loadModel ( 'receipt' );
  9049. $receipt = new receipt ();
  9050. $receiptList = $receipt->find ( array (
  9051. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9052. 'asArray' => true
  9053. ) );
  9054. if (empty ( $receiptList )) {
  9055. ob_start ();
  9056. $this->render ( "/admin/saea_slist_collect", $data );
  9057. $this->cacheFile ( $path );
  9058. die ();
  9059. }
  9060. }
  9061. $this->render ( "/admin/saea_slist_collect", $data );
  9062. }
  9063. function personalCollectDetail() {
  9064. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9065. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  9066. $this->showCache ( $path );
  9067. Doo::loadModel ( "receiptDetail" );
  9068. Doo::loadModel ( "itemStatistics" );
  9069. Doo::loadModel ( 'statistics' );
  9070. Doo::loadModel ( 'accountItem' );
  9071. $accountItem = new accountItem ();
  9072. $statistics = new statistics ();
  9073. $itemStatistics = new itemStatistics ();
  9074. $receiptDetail = new receiptDetail ();
  9075. $receiptCollectList = $receiptDetail->find ( array (
  9076. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9077. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9078. 'groupby' => 'item,Month(date)',
  9079. 'asArray' => true
  9080. ) );
  9081. $accountList = $accountItem->find ( array (
  9082. 'asArray' => true
  9083. ) );
  9084. // create CollectDetail HTML
  9085. $collectHtml = array ();
  9086. foreach ( $accountList as $key => $value ) {
  9087. $html = "";
  9088. $asum = 0;
  9089. for($i = 1; $i <= 12; $i ++) {
  9090. $falg = true;
  9091. foreach ( $receiptCollectList as $v ) {
  9092. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9093. $asum += $v ['price'];
  9094. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9095. $falg = false;
  9096. break;
  9097. }
  9098. }
  9099. if ($falg)
  9100. $html .= '<td class="taR">-</td>';
  9101. }
  9102. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9103. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9104. }
  9105. $data ['collectHtml'] = $collectHtml;
  9106. // create Adjustment price html
  9107. $receiptCollectList = $receiptDetail->find ( array (
  9108. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9109. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9110. 'groupby' => 'itemCategory,Month(date)',
  9111. 'asArray' => true
  9112. ) );
  9113. $adjustment = array ();
  9114. $collectArray = array (
  9115. '日常相关费用' => array (),
  9116. '差旅相关费用' => array (),
  9117. '培训班费用' => array (),
  9118. '其他' => array ()
  9119. );
  9120. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9121. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9122. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9123. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9124. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9125. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9126. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9127. array_push ( $collectArray ['其他'], $collectHtml );
  9128. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9129. array_push ( $adjustment, $collectHtml );
  9130. // total price html
  9131. $collectHtml = "";
  9132. $total = 0;
  9133. for($i = 1; $i <= 12; $i ++) {
  9134. $sumPrice = 0;
  9135. foreach ( $receiptCollectList as $key => $value ) {
  9136. if ($value ['month'] == $i) {
  9137. $sumPrice += $value ['price'];
  9138. }
  9139. }
  9140. if ($sumPrice == 0)
  9141. $collectHtml .= '<td class="taR">-</td>';
  9142. else
  9143. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9144. $total += $sumPrice;
  9145. }
  9146. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9147. // statistics html
  9148. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9149. if (empty ( $stList ))
  9150. $stList = array (
  9151. 'rePrice' => 0,
  9152. 'agPrice' => 0
  9153. );
  9154. $data ['stList'] = array (
  9155. 'rePrice' => $stList ['rePrice'],
  9156. 'agPrice' => $stList ['agPrice'],
  9157. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9158. );
  9159. $data ['collectArray'] = $collectArray;
  9160. $data ['adjustment'] = $adjustment;
  9161. $data ['totalPrice'] = $collectHtml;
  9162. $data ['totalYear'] = $total;
  9163. $data ['year'] = $year;
  9164. $dateHtml = "";
  9165. $now = date ( "Y" );
  9166. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9167. if ($YEARD <= $now) {
  9168. $dateHtml .= '<option ';
  9169. if ($year == $YEARD) {
  9170. $dateHtml .= 'selected ';
  9171. }
  9172. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9173. }
  9174. }
  9175. $data ['dateHtml'] = $dateHtml;
  9176. $data ['memu'] = "receipt";
  9177. $data ['staff'] = $this->staff;
  9178. $data ['receiptMemu'] = 'personalCollect';
  9179. $data ['verifyId'] = $this->verifyId;
  9180. $data ['executeId'] = $this->executeId;
  9181. // year staff status 2,4
  9182. if ($year < date ( "Y" )) {
  9183. Doo::loadModel ( 'receipt' );
  9184. $receipt = new receipt ();
  9185. $receiptList = $receipt->find ( array (
  9186. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9187. 'asArray' => true
  9188. ) );
  9189. if (empty ( $receiptList )) {
  9190. ob_start ();
  9191. $this->render ( "/admin/saeaCollectArticles", $data );
  9192. $this->cacheFile ( $path );
  9193. die ();
  9194. }
  9195. }
  9196. $this->render ( "/admin/saeaCollectArticles", $data );
  9197. }
  9198. function companyCategoryCollect() {
  9199. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9200. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  9201. $this->showCache ( $path );
  9202. Doo::loadModel ( 'L_category' );
  9203. Doo::loadModel ( 'itemStatistics' );
  9204. Doo::loadModel ( 'statistics' );
  9205. $statistics = new statistics ();
  9206. $Lcategory = new L_category ();
  9207. $itemStatistics = new itemStatistics ();
  9208. Doo::loadModel ( "receiptAuthorityManage" );
  9209. $receiptAuthorityManage = new receiptAuthorityManage ();
  9210. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9211. $cidList = array ();
  9212. foreach ( $imcStaff as $key => $value ) {
  9213. array_push ( $cidList, $value ['cid'] );
  9214. }
  9215. $cidString = implode ( ',', $cidList );
  9216. $LcategoryList = $Lcategory->find ( array (
  9217. 'where' => ' cid in (' . $cidString . ')',
  9218. 'asArray' => true
  9219. ) ); // 'staff='.$this->staff[0]['sid']." and
  9220. $itemStatisticsList = $itemStatistics->find ( array (
  9221. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9222. 'where' => " Year(date)=" . $year,
  9223. 'groupby' => 'cid,Month(date)',
  9224. 'asArray' => true
  9225. ) );
  9226. // ceatre companyCollectHtml
  9227. foreach ( $LcategoryList as $value ) {
  9228. $html = "";
  9229. $asum = 0;
  9230. for($i = 1; $i <= 12; $i ++) {
  9231. $falg = true;
  9232. foreach ( $itemStatisticsList as $v ) {
  9233. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  9234. $asum += $v ['price'];
  9235. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9236. $falg = false;
  9237. break;
  9238. }
  9239. }
  9240. if ($falg)
  9241. $html .= '<td class="taR">-</td>';
  9242. }
  9243. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9244. $collectHtml [$value ['title']] = array (
  9245. 'html' => $html,
  9246. 'cid' => $value ['cid']
  9247. );
  9248. }
  9249. $data ['companyHtml'] = $collectHtml;
  9250. // total price html
  9251. $collectHtml = "";
  9252. $total = 0;
  9253. for($i = 1; $i <= 12; $i ++) {
  9254. $sumPrice = 0;
  9255. foreach ( $itemStatisticsList as $key => $value ) {
  9256. if ($value ['month'] == $i) {
  9257. $sumPrice += $value ['price'];
  9258. }
  9259. }
  9260. if ($sumPrice == 0)
  9261. $collectHtml .= '<td class="taR">-</td>';
  9262. else
  9263. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9264. $total += $sumPrice;
  9265. }
  9266. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9267. $data ['companyTotalHtml'] = $collectHtml;
  9268. $data ['total'] = $total;
  9269. // statistics html
  9270. // echo $cidString;
  9271. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9272. if (empty ( $stList ))
  9273. $stList = array (
  9274. 'rePrice' => 0,
  9275. 'agPrice' => 0
  9276. );
  9277. $data ['stList'] = array (
  9278. 'rePrice' => $stList ['rePrice'],
  9279. 'agPrice' => $stList ['agPrice'],
  9280. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9281. );
  9282. $data ['year'] = $year;
  9283. $data ['memu'] = "receipt";
  9284. $data ['staff'] = $this->staff;
  9285. $data ['receiptMemu'] = 'companyCategoryCollect';
  9286. $data ['verifyId'] = $this->verifyId;
  9287. $data ['executeId'] = $this->executeId;
  9288. $dateHtml = "";
  9289. $now = date ( "Y" );
  9290. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9291. if ($YEARD <= $now) {
  9292. $dateHtml .= '<option ';
  9293. if ($year == $YEARD) {
  9294. $dateHtml .= 'selected ';
  9295. }
  9296. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9297. }
  9298. }
  9299. $data ['dateHtml'] = $dateHtml;
  9300. // year staff status 2,4
  9301. if ($year < date ( "Y" )) {
  9302. Doo::loadModel ( 'receipt' );
  9303. $receipt = new receipt ();
  9304. $receiptList = $receipt->find ( array (
  9305. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  9306. 'asArray' => true
  9307. ) );
  9308. if (empty ( $receiptList )) {
  9309. ob_start ();
  9310. $this->render ( "/admin/saeaCompanyCollect", $data );
  9311. $this->cacheFile ( $path );
  9312. die ();
  9313. }
  9314. }
  9315. $this->render ( "/admin/saeaCompanyCollect", $data );
  9316. }
  9317. function categoryCollectDetail() {
  9318. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9319. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  9320. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  9321. $this->showCache ( $path );
  9322. Doo::loadModel ( 'statistics' );
  9323. $statistics = new statistics ();
  9324. Doo::loadModel ( "receiptDetail" );
  9325. $receiptDetail = new receiptDetail ();
  9326. Doo::loadModel ( 'L_category' );
  9327. $Lcategory = new L_category ();
  9328. Doo::loadModel ( 'accountItem' );
  9329. $accountItem = new accountItem ();
  9330. Doo::loadModel ( "receiptAuthorityManage" );
  9331. $receiptAuthorityManage = new receiptAuthorityManage ();
  9332. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9333. $cidList = array ();
  9334. foreach ( $imcStaff as $key => $value ) {
  9335. array_push ( $cidList, $value ['cid'] );
  9336. }
  9337. $cidString = implode ( ',', $cidList );
  9338. $LcategoryList = $Lcategory->find ( array (
  9339. 'where' => 'cid in (' . $cidString . ')',
  9340. 'asArray' => true
  9341. ) );
  9342. if ($cid == 0) {
  9343. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9344. if ($cid == 0)
  9345. $cid = $LcategoryList [0] ['cid'];
  9346. }
  9347. $data ['LcategoryList'] = $LcategoryList;
  9348. $receiptCollectList = $receiptDetail->find ( array (
  9349. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9350. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9351. 'groupby' => 'item,Month(pastDate)',
  9352. 'asArray' => true
  9353. ) );
  9354. $accountList = $accountItem->find ( array (
  9355. 'asArray' => true
  9356. ) );
  9357. // create CollectDetail HTML
  9358. $collectHtml = array ();
  9359. foreach ( $accountList as $key => $value ) {
  9360. $html = "";
  9361. $asum = 0;
  9362. for($i = 1; $i <= 12; $i ++) {
  9363. $falg = true;
  9364. foreach ( $receiptCollectList as $v ) {
  9365. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9366. $asum += $v ['price'];
  9367. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9368. $falg = false;
  9369. break;
  9370. }
  9371. }
  9372. if ($falg)
  9373. $html .= '<td class="taR">-</td>';
  9374. }
  9375. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9376. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9377. }
  9378. $data ['collectHtml'] = $collectHtml;
  9379. // create Adjustment price html
  9380. $receiptCollectList = $receiptDetail->find ( array (
  9381. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9382. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9383. 'groupby' => 'itemCategory,Month(pastDate)',
  9384. 'asArray' => true
  9385. ) );
  9386. $adjustment = array ();
  9387. $collectArray = array (
  9388. '日常相关费用' => array (),
  9389. '差旅相关费用' => array (),
  9390. '培训班费用' => array (),
  9391. '其他' => array ()
  9392. );
  9393. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9394. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9395. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9396. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9397. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9398. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9399. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9400. array_push ( $collectArray ['其他'], $collectHtml );
  9401. $data ['collectArray'] = $collectArray;
  9402. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9403. array_push ( $adjustment, $collectHtml );
  9404. $data ['adjustment'] = $adjustment;
  9405. // total price html
  9406. $collectHtml = "";
  9407. $total = 0;
  9408. for($i = 1; $i <= 12; $i ++) {
  9409. $sumPrice = 0;
  9410. foreach ( $receiptCollectList as $key => $value ) {
  9411. if ($value ['month'] == $i) {
  9412. $sumPrice += $value ['price'];
  9413. }
  9414. }
  9415. if ($sumPrice == 0)
  9416. $collectHtml .= '<td class="taR">-</td>';
  9417. else
  9418. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9419. $total += $sumPrice;
  9420. }
  9421. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9422. // statistics html
  9423. $stList = $statistics->statisticsByCid ( $year, $cid );
  9424. if (empty ( $stList ))
  9425. $stList = array (
  9426. 'rePrice' => 0,
  9427. 'agPrice' => 0
  9428. );
  9429. $data ['stList'] = array (
  9430. 'rePrice' => $stList ['rePrice'],
  9431. 'agPrice' => $stList ['agPrice'],
  9432. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9433. );
  9434. $data ['totalYear'] = $total;
  9435. $data ['year'] = $year;
  9436. $data ['cid'] = $cid;
  9437. $data ['memu'] = "receipt";
  9438. $data ['staff'] = $this->staff;
  9439. $data ['receiptMemu'] = 'companyCategoryCollect';
  9440. $data ['verifyId'] = $this->verifyId;
  9441. $data ['executeId'] = $this->executeId;
  9442. // year staff status 2,4
  9443. if ($year < date ( "Y" )) {
  9444. Doo::loadModel ( 'receipt' );
  9445. $receipt = new receipt ();
  9446. $receiptList = $receipt->find ( array (
  9447. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  9448. 'asArray' => true
  9449. ) );
  9450. if (empty ( $receiptList )) {
  9451. ob_start ();
  9452. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  9453. $this->cacheFile ( $path );
  9454. die ();
  9455. }
  9456. }
  9457. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  9458. }
  9459. function staffCollect() {
  9460. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9461. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ONJOB';//
  9462. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  9463. // $this->showCache($path);
  9464. Doo::loadModel ( 'statistics' );
  9465. $statistics = new statistics ();
  9466. Doo::loadModel ( "receiptDetail" );
  9467. $receiptDetail = new receiptDetail ();
  9468. Doo::loadModel ( 'L_category' );
  9469. $Lcategory = new L_category ();
  9470. Doo::loadModel ( 'accountItem' );
  9471. $accountItem = new accountItem ();
  9472. Doo::loadModel ( 'staff' );
  9473. $staff = new staff ();
  9474. Doo::loadModel ( 'itemStatistics' );
  9475. $itemStatistics = new itemStatistics ();
  9476. Doo::loadModel ( "receiptAuthorityManage" );
  9477. $receiptAuthorityManage = new receiptAuthorityManage ();
  9478. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9479. $cidList = array ();
  9480. foreach ( $imcStaff as $key => $value ) {
  9481. array_push ( $cidList, $value ['cid'] );
  9482. }
  9483. $cidString = implode ( ',', $cidList );
  9484. $naturecon='';
  9485. if ($nature=='ONJOB'){
  9486. $naturecon=' and (nature!=4 )';
  9487. }elseif($nature=='LEAVEJOB'){
  9488. $naturecon=' and (nature=4 )';
  9489. }else{
  9490. die ( 'illegal request--nature' );
  9491. }
  9492. // statistics html
  9493. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9494. if (empty ( $stList ))
  9495. $stList = array (
  9496. 'rePrice' => 0,
  9497. 'agPrice' => 0
  9498. );
  9499. $data ['stList'] = array (
  9500. 'rePrice' => $stList ['rePrice'],
  9501. 'agPrice' => $stList ['agPrice'],
  9502. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9503. );
  9504. // ---
  9505. $staffList = $staff->find ( array (
  9506. 'where' => 'username !="admin" '.$naturecon,
  9507. 'asArray' => true
  9508. ) );
  9509. $LcategoryList = $Lcategory->find ( array (
  9510. 'asArray' => true
  9511. ) ); // 'staff='.$this->staff[0]['sid']." and
  9512. $itemStatisticsList = $itemStatistics->find ( array (
  9513. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9514. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  9515. 'groupby' => 'staff,Month(date)',
  9516. 'asArray' => true
  9517. ) );
  9518. $categoryList = $staff->find ( array (
  9519. 'select' => 'COUNT(*) as count,cid,category',
  9520. 'where' => 'username !="admin" and cid in (' . $cidString . ') '.$naturecon,
  9521. 'groupby' => 'cid',
  9522. 'asArray' => true
  9523. ) );
  9524. // print_r($itemStatisticsList);die;
  9525. // ceatre companyCollectHtml
  9526. foreach ( $categoryList as $vlu ) {
  9527. $count = $vlu ['count'] + 1;
  9528. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  9529. $m1 = 0;
  9530. $m2 = 0;
  9531. $m3 = 0;
  9532. $m4 = 0;
  9533. $m5 = 0;
  9534. $m6 = 0;
  9535. $m7 = 0;
  9536. $m8 = 0;
  9537. $m9 = 0;
  9538. $m10 = 0;
  9539. $m11 = 0;
  9540. $m12 = 0;
  9541. $m13 = 0;
  9542. foreach ( $staffList as $value ) {
  9543. if ($vlu ['cid'] == $value ['cid']) {
  9544. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  9545. $asum = 0;
  9546. for($i = 1; $i <= 12; $i ++) {
  9547. $falg = true;
  9548. foreach ( $itemStatisticsList as $v ) {
  9549. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  9550. if ($v ['month'] == 1)
  9551. $m1 += $v ['price'];
  9552. if ($v ['month'] == 2)
  9553. $m2 += $v ['price'];
  9554. if ($v ['month'] == 3)
  9555. $m3 += $v ['price'];
  9556. if ($v ['month'] == 4)
  9557. $m4 += $v ['price'];
  9558. if ($v ['month'] == 5)
  9559. $m5 += $v ['price'];
  9560. if ($v ['month'] == 6)
  9561. $m6 += $v ['price'];
  9562. if ($v ['month'] == 7)
  9563. $m7 += $v ['price'];
  9564. if ($v ['month'] == 8)
  9565. $m8 += $v ['price'];
  9566. if ($v ['month'] == 9)
  9567. $m9 += $v ['price'];
  9568. if ($v ['month'] == 10)
  9569. $m10 += $v ['price'];
  9570. if ($v ['month'] == 11)
  9571. $m11 += $v ['price'];
  9572. if ($v ['month'] == 12)
  9573. $m12 += $v ['price'];
  9574. $asum += $v ['price'];
  9575. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9576. $falg = false;
  9577. break;
  9578. }
  9579. }
  9580. if ($falg)
  9581. $html .= '<td class="taR">-</td>';
  9582. }
  9583. $m13 += $asum;
  9584. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9585. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  9586. 'html' => $html,
  9587. 'sid' => $value ['sid']
  9588. );
  9589. $html = "";
  9590. }
  9591. }
  9592. $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>
  9593. <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>
  9594. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  9595. $collectHtml [$vlu ['cid']] = array (
  9596. 'html' => $hl,
  9597. 'sid' => ''
  9598. );
  9599. }
  9600. $data ['companyHtml'] = $collectHtml;
  9601. // total price html
  9602. $collectHtml = "";
  9603. $total = 0;
  9604. for($i = 1; $i <= 12; $i ++) {
  9605. $sumPrice = 0;
  9606. foreach ( $itemStatisticsList as $key => $value ) {
  9607. if ($value ['month'] == $i) {
  9608. $sumPrice += $value ['price'];
  9609. }
  9610. }
  9611. if ($sumPrice == 0)
  9612. $collectHtml .= '<td class="taR">-</td>';
  9613. else
  9614. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9615. $total += $sumPrice;
  9616. }
  9617. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9618. $data ['companyTotalHtml'] = $collectHtml;
  9619. $data ['total'] = $total;
  9620. $data ['nature'] =$nature;
  9621. $data ['year'] = $year;
  9622. $data ['memu'] = "receipt";
  9623. $data ['staff'] = $this->staff;
  9624. $data ['receiptMemu'] = 'companyCategoryCollect';
  9625. $data ['verifyId'] = $this->verifyId;
  9626. $data ['executeId'] = $this->executeId;
  9627. if ($year <= date ( "Y" )) {
  9628. Doo::loadModel ( 'receipt' );
  9629. $receipt = new receipt ();
  9630. $receiptList = $receipt->find ( array (
  9631. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  9632. 'asArray' => true
  9633. ) );
  9634. if (empty ( $receiptList )) { // generated files
  9635. ob_start ();
  9636. $this->render ( "/admin/saeaStaffCollectB", $data );
  9637. $this->cacheFile ( $path );
  9638. die ();
  9639. }
  9640. }
  9641. $this->render ( "/admin/saeaStaffCollectB", $data );
  9642. }
  9643. function staffCollectBak() {
  9644. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9645. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  9646. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  9647. $this->showCache ( $path );
  9648. Doo::loadModel ( 'statistics' );
  9649. $statistics = new statistics ();
  9650. Doo::loadModel ( "receiptDetail" );
  9651. $receiptDetail = new receiptDetail ();
  9652. Doo::loadModel ( 'L_category' );
  9653. $Lcategory = new L_category ();
  9654. Doo::loadModel ( 'accountItem' );
  9655. $accountItem = new accountItem ();
  9656. Doo::loadModel ( 'staff' );
  9657. $staff = new staff ();
  9658. Doo::loadModel ( 'itemStatistics' );
  9659. $itemStatistics = new itemStatistics ();
  9660. $itemStatisticsList = $itemStatistics->find ( array (
  9661. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9662. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9663. 'groupby' => 'staff,itemCategory,Month(date)',
  9664. 'asArray' => true
  9665. ) );
  9666. $itemCategoryList = $itemStatistics->find ( array (
  9667. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9668. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9669. 'groupby' => 'cid,itemCategory,Month(date)',
  9670. 'asArray' => true
  9671. ) );
  9672. $LcategoryList = $Lcategory->find ( array (
  9673. 'asArray' => true
  9674. ) );
  9675. $staffList = $staff->find ( array (
  9676. 'asArray' => true
  9677. ) );
  9678. $htmlArray = array ();
  9679. foreach ( $LcategoryList as $value ) {
  9680. $htmlArray [$value ['title']] = array ();
  9681. foreach ( $staffList as $v ) {
  9682. if ($value ['cid'] == $v ['cid']) {
  9683. $html = "";
  9684. $falg = true;
  9685. $staffSumPrice = 0;
  9686. foreach ( $itemStatisticsList as $a ) {
  9687. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  9688. if (empty ( $a ['price'] )) {
  9689. $html .= '<td class="taR">-</td>';
  9690. $falg = false;
  9691. break;
  9692. } else {
  9693. $staffSumPrice += $a ['price'];
  9694. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9695. $falg = false;
  9696. break;
  9697. }
  9698. }
  9699. }
  9700. if ($falg) {
  9701. $html .= '<td class="taR">-</td>';
  9702. $falg = true;
  9703. }
  9704. $falg = true;
  9705. foreach ( $itemStatisticsList as $a ) {
  9706. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  9707. if (empty ( $a ['price'] )) {
  9708. $html .= '<td class="taR">-</td>';
  9709. $falg = false;
  9710. break;
  9711. } else {
  9712. $staffSumPrice += $a ['price'];
  9713. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9714. $falg = false;
  9715. break;
  9716. }
  9717. }
  9718. }
  9719. if ($falg) {
  9720. $html .= '<td class="taR">-</td>';
  9721. $falg = true;
  9722. }
  9723. $falg = true;
  9724. foreach ( $itemStatisticsList as $a ) {
  9725. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  9726. if (empty ( $a ['price'] )) {
  9727. $html .= '<td class="taR">-</td>';
  9728. $falg = false;
  9729. break;
  9730. } else {
  9731. $staffSumPrice += $a ['price'];
  9732. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9733. $falg = false;
  9734. break;
  9735. }
  9736. }
  9737. }
  9738. if ($falg) {
  9739. $html .= '<td class="taR">-</td>';
  9740. $falg = true;
  9741. }
  9742. $falg = true;
  9743. foreach ( $itemStatisticsList as $a ) {
  9744. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  9745. if (! empty ( $a ['price'] )) {
  9746. $staffSumPrice += $a ['price'];
  9747. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9748. $falg = false;
  9749. break;
  9750. } else {
  9751. $html .= '<td class="taR">-</td>';
  9752. $falg = false;
  9753. break;
  9754. }
  9755. }
  9756. }
  9757. if ($falg) {
  9758. $html .= '<td class="taR">-</td>';
  9759. $falg = true;
  9760. }
  9761. $falg = true;
  9762. foreach ( $itemStatisticsList as $a ) {
  9763. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  9764. if (! empty ( $a ['price'] )) {
  9765. $staffSumPrice += $a ['price'];
  9766. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9767. $falg = false;
  9768. break;
  9769. } else {
  9770. $html .= '<td class="taR">-</td>';
  9771. $falg = false;
  9772. break;
  9773. }
  9774. }
  9775. }
  9776. if ($falg) {
  9777. $html .= '<td class="taR">-</td>';
  9778. $falg = true;
  9779. }
  9780. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  9781. $htmlArray [$value ['title']] [$v ['username']] = $html;
  9782. }
  9783. }
  9784. /* -- --- */
  9785. // 合计费用
  9786. $cateHtml = "";
  9787. $catePrice = 0;
  9788. $cateFalg = true;
  9789. foreach ( $itemCategoryList as $l ) {
  9790. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  9791. if (empty ( $l ['price'] )) {
  9792. $cateHtml .= '<td class="colGreen taR">-</td>';
  9793. $cateFalg = false;
  9794. break;
  9795. } else {
  9796. $catePrice += $l ['price'];
  9797. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9798. $cateFalg = false;
  9799. break;
  9800. }
  9801. }
  9802. }
  9803. if ($cateFalg) {
  9804. $cateHtml .= '<td class="colGreen taR">-</td>';
  9805. $cateFalg = true;
  9806. }
  9807. $cateFalg = true;
  9808. foreach ( $itemCategoryList as $l ) {
  9809. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  9810. if (empty ( $l ['price'] )) {
  9811. $cateHtml .= '<td class="colGreen taR">-</td>';
  9812. $cateFalg = false;
  9813. break;
  9814. } else {
  9815. $catePrice += $l ['price'];
  9816. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9817. $cateFalg = false;
  9818. break;
  9819. }
  9820. }
  9821. }
  9822. if ($cateFalg) {
  9823. $cateHtml .= '<td class="colGreen taR">-</td>';
  9824. $cateFalg = true;
  9825. }
  9826. $cateFalg = true;
  9827. foreach ( $itemCategoryList as $l ) {
  9828. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  9829. if (empty ( $l ['price'] )) {
  9830. $cateHtml .= '<td class="colGreen taR">-</td>';
  9831. $cateFalg = false;
  9832. break;
  9833. } else {
  9834. $catePrice += $l ['price'];
  9835. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9836. $cateFalg = false;
  9837. break;
  9838. }
  9839. }
  9840. }
  9841. if ($cateFalg) {
  9842. $cateHtml .= '<td class="colGreen taR">-</td>';
  9843. $cateFalg = true;
  9844. }
  9845. $cateFalg = true;
  9846. foreach ( $itemCategoryList as $l ) {
  9847. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  9848. if (empty ( $l ['price'] )) {
  9849. $cateHtml .= '<td class="colGreen taR">-</td>';
  9850. $cateFalg = false;
  9851. break;
  9852. } else {
  9853. $catePrice += $l ['price'];
  9854. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9855. $cateFalg = false;
  9856. break;
  9857. }
  9858. }
  9859. }
  9860. if ($cateFalg) {
  9861. $cateHtml .= '<td class="colGreen taR">-</td>';
  9862. $cateFalg = true;
  9863. }
  9864. $cateFalg = true;
  9865. foreach ( $itemCategoryList as $l ) {
  9866. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  9867. if (empty ( $l ['price'] )) {
  9868. $cateHtml .= '<td class="colGreen taR">-</td>';
  9869. $cateFalg = false;
  9870. break;
  9871. } else {
  9872. $catePrice += $l ['price'];
  9873. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9874. $cateFalg = false;
  9875. break;
  9876. }
  9877. }
  9878. }
  9879. if ($cateFalg) {
  9880. $cateHtml .= '<td class="colGreen taR">-</td>';
  9881. $cateFalg = true;
  9882. }
  9883. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  9884. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  9885. /* -- --- */
  9886. }
  9887. // print_r($htmlArray);die;
  9888. $data ['htmlArray'] = $htmlArray;
  9889. // statistics html
  9890. $stList = $statistics->getOne ( array (
  9891. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9892. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9893. 'groupby' => 'Month(date)',
  9894. 'asArray' => true
  9895. ) );
  9896. if (empty ( $stList ))
  9897. $stList = array (
  9898. 'rePrice' => 0,
  9899. 'agPrice' => 0
  9900. );
  9901. $data ['stList'] = array (
  9902. 'rePrice' => $stList ['rePrice'],
  9903. 'agPrice' => $stList ['agPrice'],
  9904. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9905. );
  9906. $monthHtml = "";
  9907. for($i = 1; $i <= 12; $i ++) {
  9908. if ($i == $month)
  9909. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9910. else
  9911. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9912. }
  9913. $data ['monthHtml'] = $monthHtml;
  9914. $data ['year'] = $year;
  9915. $data ['month'] = $month;
  9916. $data ['memu'] = "receipt";
  9917. $data ['staff'] = $this->staff;
  9918. $data ['receiptMemu'] = 'companyCategoryCollect';
  9919. $data ['verifyId'] = $this->verifyId;
  9920. $data ['executeId'] = $this->executeId;
  9921. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  9922. Doo::loadModel ( 'receipt' );
  9923. $receipt = new receipt ();
  9924. $receiptList = $receipt->find ( array (
  9925. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  9926. 'asArray' => true
  9927. ) );
  9928. if (empty ( $receiptList )) { // generated files
  9929. ob_start ();
  9930. $this->render ( "/admin/saeaStaffCollect", $data );
  9931. $this->cacheFile ( $path );
  9932. die ();
  9933. }
  9934. }
  9935. $this->render ( "/admin/saeaStaffCollect", $data );
  9936. }
  9937. /**
  9938. * 日常收支
  9939. */
  9940. function payments() {
  9941. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  9942. Doo::loadModel ( "execute" );
  9943. $execute = new execute ();
  9944. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  9945. die ( 'illegal request' );
  9946. }
  9947. Doo::loadModel ( "accountBook" );
  9948. $accountBook = new accountBook ();
  9949. Doo::loadModel ( "accountBookStatistics" );
  9950. $accountBookStatistics = new accountBookStatistics ();
  9951. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  9952. $list = $accountBook->getAccountBookByLimit ( 10 );
  9953. $data ['date'] = date ( "Y-m-d" );
  9954. $data ['statisticsList'] = $statisticsList;
  9955. $data ['list'] = $list;
  9956. $data ['memu'] = "receipt";
  9957. $data ['staff'] = $this->staff;
  9958. $data ['receiptMemu'] = 'payments';
  9959. $data ['verifyId'] = $this->verifyId;
  9960. $data ['executeId'] = $this->executeId;
  9961. $this->render ( "/expenses/payments", $data );
  9962. }
  9963. function paymentsIncomeDo() {
  9964. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  9965. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  9966. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  9967. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  9968. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  9969. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  9970. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  9971. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  9972. Doo::loadClass ( 'XDeode' );
  9973. $XDeode = new XDeode ( 5 );
  9974. Doo::loadModel ( "accountBook" );
  9975. Doo::loadModel ( "accountBookStatistics" );
  9976. Doo::loadModel ( 'wasteBook' );
  9977. // 记录流水时银行的转换
  9978. $accountBank = '';
  9979. if ($receivedBank == '纵横广发') {
  9980. $accountBank = 'CGBDeposit';
  9981. } elseif ($receivedBank == '纵横工行') {
  9982. $accountBank = 'ICBCDeposit';
  9983. } elseif ($receivedBank == '华润银行') {
  9984. $accountBank = 'HUADeposit';
  9985. } elseif ($receivedBank == '个人广发') {
  9986. $accountBank = 'PersonalDeposit';
  9987. }
  9988. if (empty ( $accountBank ))
  9989. die ( 'illegal request' );
  9990. // 收入为理财时特殊处理
  9991. if ($accountType == 7 || $accountType == 9) {
  9992. if ($receivedBank == '个人广发') {
  9993. die ( '个人广发 illegal request' );
  9994. }
  9995. // 添加一条收入
  9996. $accountBook = new accountBook ();
  9997. $accountBook->accountType = 10;
  9998. $accountBook->accountMsg = $accountMsg;
  9999. $accountBook->receivedPrice = $receivedPrice;
  10000. $accountBook->receivedMsg = $receivedMsg;
  10001. $accountBook->receivedBank = $receivedBank;
  10002. $accountBook->receivedDate = $receivedDate;
  10003. $accountBook->remarks = $remarks;
  10004. $accountBook->expensesType = 1;
  10005. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10006. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10007. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10008. $inComeId = $accountBook->insert ();
  10009. // 收支汇总-添加一条收入日常汇总
  10010. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10011. $accountBookStatistics = new accountBookStatistics ();
  10012. $item = array (
  10013. 'date' => date ( "Y-m-d" ),
  10014. 'accountType' => $abDetail ['accountType'],
  10015. 'accountMsg' => $abDetail ['accountMsg'],
  10016. 'aid' => $abDetail ['aid'],
  10017. 'inComePrice' => $abDetail ['receivedPrice'],
  10018. 'expensesType' => $abDetail ['expensesType']
  10019. );
  10020. $accountBookStatistics->setAccountBookStatistics ( $item );
  10021. // 添加收入流水
  10022. $wasteBook = new wasteBook ();
  10023. $itemWaste = array (
  10024. 'accountPriceShow' => $receivedPrice,
  10025. 'accountPrice' => $receivedPrice,
  10026. 'expensesType' => 1,
  10027. 'accountType' => 6, // 流水类型
  10028. 'dataID' => $inComeId,
  10029. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10030. 'accountBank' => $accountBank,
  10031. 'category' => $this->staff [0] ['category'],
  10032. 'cid' => $this->staff [0] ['cid'],
  10033. 'name' => $this->staff [0] ['username'],
  10034. 'sid' => $this->staff [0] ['sid'],
  10035. 'inputDate' => date ( "Y-m-d H:i:s" )
  10036. );
  10037. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10038. // 添加一条理财支出
  10039. $accountBank = 'CGBDeposit';
  10040. $expenditureBank = '纵横广发';
  10041. $dailyExpenditureType = 4;
  10042. if ($accountType == 9) {
  10043. $accountBank = 'ICBCDeposit';
  10044. $expenditureBank = '纵横工行';
  10045. $dailyExpenditureType = 6;
  10046. }
  10047. $accountBook = new accountBook ();
  10048. $accountBook->expensesType = 2;
  10049. $accountBook->expenditureType = $dailyExpenditureType;
  10050. $accountBook->expenditureMsg = $accountMsg;
  10051. $accountBook->expenditurePrice = $receivedPrice;
  10052. $accountBook->expenditureBank = $expenditureBank;
  10053. $accountBook->expenditureDate = $receivedDate;
  10054. $accountBook->remarks = $remarks;
  10055. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10056. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10057. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10058. $id = $accountBook->insert ();
  10059. // 收支汇总-添加一条理财支出汇总
  10060. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10061. $accountBookStatistics = new accountBookStatistics ();
  10062. $item = array (
  10063. 'date' => date ( "Y-m-d" ),
  10064. 'accountType' => $abDetail ['accountType'],
  10065. 'accountMsg' => $abDetail ['accountMsg'],
  10066. 'aid' => $abDetail ['aid'],
  10067. 'financingPrice' => - $receivedPrice,
  10068. 'expensesType' => 3
  10069. );
  10070. $accountBookStatistics->setAccountBookStatistics ( $item );
  10071. // 添加一条支出理财流水
  10072. $accountTypeWaste = 5;
  10073. if ($accountMsg == '公司固定') {
  10074. $accountTypeWaste = 9;
  10075. } elseif ($accountMsg == '公司活期') {
  10076. $accountTypeWaste = 10;
  10077. } elseif ($accountMsg == '个人(GR)') {
  10078. $accountBank = 'PersonalDeposit';
  10079. }
  10080. $itemWaste = array (
  10081. 'expensesType' => 2,
  10082. 'accountType' => $accountTypeWaste,
  10083. 'accountPriceShow' => $receivedPrice,
  10084. 'accountPrice' => - $receivedPrice,
  10085. 'dataID' => $id,
  10086. 'dailyExpenditureType' => $dailyExpenditureType,
  10087. 'accountBank' => $accountBank,
  10088. 'category' => $this->staff [0] ['category'],
  10089. 'cid' => $this->staff [0] ['cid'],
  10090. 'name' => $this->staff [0] ['username'],
  10091. 'sid' => $this->staff [0] ['sid'],
  10092. 'inputDate' => date ( "Y-m-d H:i:s" )
  10093. );
  10094. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10095. } elseif ($accountType == 1) {
  10096. if ($receivedBank == '个人广发')
  10097. die ( 'illegal request' );
  10098. // 添加一条收入
  10099. $accountBook = new accountBook ();
  10100. $accountBook->accountType = $accountType;
  10101. $accountBook->accountMsg = $accountMsg;
  10102. $accountBook->receivedPrice = $receivedPrice;
  10103. $accountBook->receivedMsg = $receivedMsg;
  10104. $accountBook->receivedBank = $receivedBank;
  10105. $accountBook->receivedDate = $receivedDate;
  10106. $accountBook->remarks = $remarks;
  10107. $accountBook->expensesType = 1;
  10108. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10109. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10110. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10111. $id = $accountBook->insert ();
  10112. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10113. // 收支汇总-添加一条收入日常汇总
  10114. $accountBookStatistics = new accountBookStatistics ();
  10115. $item = array (
  10116. 'date' => date ( "Y-m-d" ),
  10117. 'accountType' => $abDetail ['accountType'],
  10118. 'accountMsg' => $abDetail ['accountMsg'],
  10119. 'aid' => $abDetail ['aid'],
  10120. 'expensesType' => $abDetail ['expensesType']
  10121. );
  10122. if ($abDetail ['accountType'] == 8) {
  10123. $item += array (
  10124. 'inComePrice' => $abDetail ['receivedPrice']
  10125. );
  10126. } else {
  10127. $item += array (
  10128. 'inComePrice' => $abDetail ['receivedPrice']
  10129. );
  10130. }
  10131. $accountBookStatistics->setAccountBookStatistics ( $item );
  10132. // 流水存储方向
  10133. $itemWaste = array (
  10134. 'accountType' => 6
  10135. ); // 流水类型
  10136. // if($accountMsg=='银行存款'||$accountMsg=='固定理财收益'){
  10137. // }else
  10138. if ($accountMsg == '活期理财收益') {
  10139. $itemWaste = array (
  10140. 'accountType' => 10
  10141. ); // 流水类型
  10142. }
  10143. // 添加收入流水
  10144. $wasteBook = new wasteBook ();
  10145. $itemWaste += array (
  10146. 'accountPrice' => $receivedPrice,
  10147. 'accountPriceShow' => $receivedPrice,
  10148. 'expensesType' => 1,
  10149. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10150. 'dataID' => $id,
  10151. 'accountBank' => $accountBank,
  10152. 'category' => $this->staff [0] ['category'],
  10153. 'cid' => $this->staff [0] ['cid'],
  10154. 'name' => $this->staff [0] ['username'],
  10155. 'sid' => $this->staff [0] ['sid'],
  10156. 'inputDate' => date ( "Y-m-d H:i:s" )
  10157. );
  10158. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10159. } else { // 普通日常收入处理
  10160. // 添加一条收入
  10161. $accountBook = new accountBook ();
  10162. $accountBook->accountType = $accountType;
  10163. $accountBook->accountMsg = $accountMsg;
  10164. $accountBook->receivedPrice = $receivedPrice;
  10165. $accountBook->receivedMsg = $receivedMsg;
  10166. $accountBook->receivedBank = $receivedBank;
  10167. $accountBook->receivedDate = $receivedDate;
  10168. $accountBook->remarks = $remarks;
  10169. $accountBook->expensesType = 1;
  10170. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10171. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10172. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10173. $id = $accountBook->insert ();
  10174. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10175. // 收支汇总-添加一条收入日常汇总
  10176. $accountBookStatistics = new accountBookStatistics ();
  10177. $item = array (
  10178. 'date' => date ( "Y-m-d" ),
  10179. 'accountType' => $abDetail ['accountType'],
  10180. 'accountMsg' => $abDetail ['accountMsg'],
  10181. 'aid' => $abDetail ['aid'],
  10182. 'expensesType' => $abDetail ['expensesType']
  10183. );
  10184. if ($abDetail ['accountType'] == 8) {
  10185. $item += array (
  10186. 'inComePrice' => $abDetail ['receivedPrice']
  10187. );
  10188. } else {
  10189. $item += array (
  10190. 'inComePrice' => $abDetail ['receivedPrice']
  10191. );
  10192. }
  10193. $accountBookStatistics->setAccountBookStatistics ( $item );
  10194. // 添加收入流水
  10195. $itemWaste = array (
  10196. 'accountPrice' => $receivedPrice
  10197. );
  10198. if ($receivedBank == '个人广发') {
  10199. $itemWaste = array (
  10200. 'accountPrice' => - $receivedPrice
  10201. );
  10202. }
  10203. $wasteBook = new wasteBook ();
  10204. $itemWaste += array (
  10205. 'accountPriceShow' => $receivedPrice,
  10206. 'expensesType' => 1,
  10207. 'accountType' => 6, // 流水类型
  10208. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10209. 'dataID' => $id,
  10210. 'accountBank' => $accountBank,
  10211. 'category' => $this->staff [0] ['category'],
  10212. 'cid' => $this->staff [0] ['cid'],
  10213. 'name' => $this->staff [0] ['username'],
  10214. 'sid' => $this->staff [0] ['sid'],
  10215. 'inputDate' => date ( "Y-m-d H:i:s" )
  10216. );
  10217. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10218. }
  10219. }
  10220. return '/payments';
  10221. }
  10222. /**
  10223. * 添加收入
  10224. * @return string
  10225. */
  10226. function paymentsIncomeDo_() {
  10227. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10228. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10229. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10230. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10231. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10232. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10233. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10234. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10235. Doo::loadClass ( 'XDeode' );
  10236. $XDeode = new XDeode ( 5 );
  10237. Doo::loadModel ( "accountBook" );
  10238. $accountBook = new accountBook ();
  10239. $accountBank = '';
  10240. $accountTypeWaste = 6;
  10241. if ($receivedBank == '纵横广发') {
  10242. $accountBank = 'CGBDeposit';
  10243. } elseif ($receivedBank == '纵横工行') {
  10244. $accountBank = 'ICBCDeposit';
  10245. } elseif ($receivedBank == '华润银行') {
  10246. $accountBank = 'HUADeposit';
  10247. } elseif ($receivedBank == '个人广发') {
  10248. $accountBank = 'PersonalDeposit';
  10249. }
  10250. if (empty ( $accountBank ))
  10251. die ( 'illegal request' );
  10252. $dailyIncomeType = '';
  10253. $itemWaste = array (
  10254. 'accountPrice' => $receivedPrice,
  10255. 'expensesType' => 1
  10256. );
  10257. if ($receivedBank == '个人广发') {
  10258. $itemWaste = array (
  10259. 'accountPrice' => - $receivedPrice,
  10260. 'expensesType' => 1
  10261. );
  10262. }
  10263. if ($accountType == 4) {
  10264. $dailyIncomeType = 4;
  10265. } elseif ($accountType == 1) {
  10266. $dailyIncomeType = 1;
  10267. } elseif ($accountType == 2) {
  10268. $dailyIncomeType = 2;
  10269. } elseif ($accountType == 3) {
  10270. $dailyIncomeType = 3;
  10271. } elseif ($accountType == 5) {
  10272. $dailyIncomeType = 5;
  10273. } elseif ($accountType == 6) {
  10274. $dailyIncomeType = 6;
  10275. } elseif ($accountType == 7 || $accountType == 9) {
  10276. $dailyIncomeType = 7;
  10277. if ($accountMsg == '公司固定') {
  10278. $accountTypeWaste = 9;
  10279. } elseif ($accountMsg == '公司活期') {
  10280. $accountTypeWaste = 10;
  10281. } elseif ($accountMsg == '个人(GR)') {
  10282. $accountBank = 'PersonalDeposit';
  10283. }
  10284. $itemWaste = array (
  10285. 'accountPrice' => - $receivedPrice,
  10286. 'expensesType' => 2
  10287. );
  10288. } elseif ($accountType == 8) {
  10289. $dailyIncomeType = 8;
  10290. }
  10291. if (empty ( $dailyIncomeType ))
  10292. die ( 'illegal request' );
  10293. $accountBook->accountType = $accountType;
  10294. $accountBook->accountMsg = $accountMsg;
  10295. $accountBook->receivedPrice = $receivedPrice;
  10296. $accountBook->receivedMsg = $receivedMsg;
  10297. $accountBook->receivedBank = $receivedBank;
  10298. $accountBook->receivedDate = $receivedDate;
  10299. $accountBook->remarks = $remarks;
  10300. $accountBook->expensesType = 1;
  10301. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10302. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10303. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10304. $id = $accountBook->insert ();
  10305. //
  10306. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10307. // 收支汇总
  10308. Doo::loadModel ( "accountBookStatistics" );
  10309. $accountBookStatistics = new accountBookStatistics ();
  10310. $item = array (
  10311. 'date' => date ( "Y-m-d" ),
  10312. 'accountType' => $abDetail ['accountType'],
  10313. 'accountMsg' => $abDetail ['accountMsg'],
  10314. 'aid' => $abDetail ['aid']
  10315. );
  10316. if ($abDetail ['expensesType'] == 1) {
  10317. if ($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) {
  10318. $item += array (
  10319. 'financingPrice' => - $receivedPrice,
  10320. 'expensesType' => 3
  10321. );
  10322. } else if ($abDetail ['accountType'] == 8) {
  10323. $item += array (
  10324. 'inComePrice' => - $abDetail ['receivedPrice'],
  10325. 'expensesType' => $abDetail ['expensesType']
  10326. );
  10327. } else {
  10328. $item += array (
  10329. 'inComePrice' => $abDetail ['receivedPrice'],
  10330. 'expensesType' => $abDetail ['expensesType']
  10331. );
  10332. }
  10333. }
  10334. $accountBookStatistics->setAccountBookStatistics ( $item );
  10335. // 为理财时需添加一条日常支出
  10336. if ($accountType == 7 || $accountType == 9) {
  10337. }
  10338. // 公司流水记录
  10339. Doo::loadModel ( 'wasteBook' );
  10340. $wasteBook = new wasteBook ();
  10341. // 银行
  10342. // if (empty($abDetail)){
  10343. $itemWaste += array (
  10344. 'accountPriceShow' => $receivedPrice,
  10345. 'dataID' => $id,
  10346. 'accountType' => $accountTypeWaste,
  10347. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10348. 'accountBank' => $accountBank,
  10349. 'category' => $this->staff [0] ['category'],
  10350. 'cid' => $this->staff [0] ['cid'],
  10351. 'name' => $this->staff [0] ['username'],
  10352. 'sid' => $this->staff [0] ['sid'],
  10353. 'inputDate' => date ( "Y-m-d H:i:s" )
  10354. );
  10355. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10356. // }
  10357. // 类型为理财7或者9 要添加一笔理财支出
  10358. if ($accountType == 7 || $accountType == 9) {
  10359. $accountBank = 'CGBDeposit';
  10360. $expenditureBank = '纵横广发';
  10361. $dailyExpenditureType = 4;
  10362. if ($accountType == 9) {
  10363. $accountBank = 'ICBCDeposit';
  10364. $expenditureBank = '纵横工行';
  10365. $dailyExpenditureType = 6;
  10366. }
  10367. // 添加一条支出
  10368. $accountBook = new accountBook ();
  10369. $accountBook->expenditureType = $dailyExpenditureType;
  10370. $accountBook->expenditureMsg = $accountMsg;
  10371. $accountBook->expenditurePrice = $receivedPrice;
  10372. $accountBook->expenditureBank = $expenditureBank;
  10373. $accountBook->expenditureDate = $receivedDate;
  10374. $accountBook->remarks = $remarks;
  10375. $accountBook->expensesType = 2;
  10376. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10377. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10378. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10379. $id = $accountBook->insert ();
  10380. // 添加一条收入流水
  10381. $itemWaste = array (
  10382. 'accountPriceShow' => $receivedPrice,
  10383. 'accountPrice' => $receivedPrice,
  10384. 'dataID' => $id,
  10385. 'expensesType' => 2,
  10386. 'accountType' => $accountTypeWaste,
  10387. 'dailyExpenditureType' => $dailyExpenditureType,
  10388. 'accountBank' => $accountBank,
  10389. 'category' => $this->staff [0] ['category'],
  10390. 'cid' => $this->staff [0] ['cid'],
  10391. 'name' => $this->staff [0] ['username'],
  10392. 'sid' => $this->staff [0] ['sid'],
  10393. 'inputDate' => date ( "Y-m-d H:i:s" )
  10394. );
  10395. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10396. }
  10397. }
  10398. return '/payments';
  10399. }
  10400. function paymentsExpenditureDo() {
  10401. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10402. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10403. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10404. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10405. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10406. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10407. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10408. // 理财支出特殊处理
  10409. Doo::loadModel ( "accountBook" );
  10410. Doo::loadModel ( "accountBookStatistics" );
  10411. Doo::loadModel ( 'wasteBook' );
  10412. $accountBank = '';
  10413. if ($expenditureBank == '纵横广发') {
  10414. $accountBank = 'CGBDeposit';
  10415. } elseif ($expenditureBank == '纵横工行') {
  10416. $accountBank = 'ICBCDeposit';
  10417. } elseif ($expenditureBank == '华润银行') {
  10418. $accountBank = 'HUADeposit';
  10419. } elseif ($expenditureBank == '个人广发') {
  10420. $accountBank = 'PersonalDeposit';
  10421. }
  10422. if (empty ( $accountBank ))
  10423. die ( 'illegal request' );
  10424. if ($expenditureType == 4 || $expenditureType == 6) {
  10425. if ($expenditureBank == '个人广发') {
  10426. die ( '个人广发 illegal request' );
  10427. }
  10428. // 添加一笔日常支出
  10429. $accountBook = new accountBook ();
  10430. $accountBook->expensesType = 2;
  10431. $accountBook->expenditureType = 7;
  10432. $accountBook->expenditureMsg = $expenditureMsg;
  10433. $accountBook->expenditurePrice = $expenditurePrice;
  10434. $accountBook->expenditureBank = $expenditureBank;
  10435. $accountBook->expenditureDate = $expenditureDate;
  10436. $accountBook->remarks = $remarks;
  10437. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10438. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10439. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10440. $expenditureId = $accountBook->insert ();
  10441. // 添加日常支出汇总
  10442. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  10443. $accountBookStatistics = new accountBookStatistics ();
  10444. $item = array (
  10445. 'date' => date ( "Y-m-d" ),
  10446. 'expenditureType' => $abDetail ['expenditureType'],
  10447. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10448. 'aid' => $abDetail ['aid'],
  10449. 'payPrice' => $abDetail ['expenditurePrice'],
  10450. 'expensesType' => $abDetail ['expensesType']
  10451. );
  10452. $accountBookStatistics->setAccountBookStatistics ( $item );
  10453. // 公司日常支出流水
  10454. $wasteBook = new wasteBook ();
  10455. $itemWaste = array (
  10456. 'accountPrice' => - $expenditurePrice
  10457. );
  10458. if ($expenditureBank == '个人广发') {
  10459. $itemWaste = array (
  10460. 'accountPrice' => $expenditurePrice
  10461. );
  10462. }
  10463. $itemWaste += array (
  10464. 'expensesType' => 2,
  10465. 'accountType' => 5,
  10466. 'dailyExpenditureType' => $expenditureType,
  10467. 'accountPriceShow' => $expenditurePrice,
  10468. 'accountPrice' => - $expenditurePrice,
  10469. 'dataID' => $expenditureId,
  10470. 'accountBank' => $accountBank,
  10471. 'category' => $this->staff [0] ['category'],
  10472. 'cid' => $this->staff [0] ['cid'],
  10473. 'name' => $this->staff [0] ['username'],
  10474. 'sid' => $this->staff [0] ['sid'],
  10475. 'inputDate' => date ( "Y-m-d H:i:s" )
  10476. );
  10477. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10478. // 添加一笔理财收入
  10479. $accountBank = 'CGBDeposit';
  10480. $dailyIncomeType = 7;
  10481. $receivedBank = '纵横广发';
  10482. if ($expenditureType == 6) {
  10483. $accountBank = 'ICBCDeposit';
  10484. $receivedBank = '纵横工行';
  10485. $dailyIncomeType = 9;
  10486. }
  10487. $accountBook = new accountBook ();
  10488. $accountBook->expensesType = 1;
  10489. $accountBook->accountType = $dailyIncomeType;
  10490. $accountBook->accountMsg = $expenditureMsg;
  10491. $accountBook->receivedPrice = $expenditurePrice;
  10492. $accountBook->receivedBank = $receivedBank;
  10493. $accountBook->receivedDate = $expenditureDate;
  10494. $accountBook->remarks = $remarks;
  10495. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10496. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10497. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10498. $id = $accountBook->insert ();
  10499. // 添加日常理财收入汇总
  10500. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  10501. $accountBookStatistics = new accountBookStatistics ();
  10502. $item = array (
  10503. 'date' => date ( "Y-m-d" ),
  10504. 'expenditureType' => $abDetail ['expenditureType'],
  10505. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10506. 'aid' => $abDetail ['aid'],
  10507. 'financingPrice' => $expenditurePrice,
  10508. 'expensesType' => 3
  10509. );
  10510. $accountBookStatistics->setAccountBookStatistics ( $item );
  10511. // 添加一笔收入流水
  10512. if ($expenditureMsg == '公司固定') {
  10513. $accountTypeWaste = 9;
  10514. } elseif ($expenditureMsg == '公司活期') {
  10515. $accountTypeWaste = 10;
  10516. } elseif ($expenditureMsg == '个人(GR)') {
  10517. $accountBank = 'PersonalDeposit';
  10518. }
  10519. $itemWaste = array (
  10520. 'expensesType' => 1,
  10521. 'accountType' => $accountTypeWaste,
  10522. 'accountPriceShow' => $expenditurePrice,
  10523. 'accountPrice' => $expenditurePrice,
  10524. 'dataID' => $id,
  10525. 'dailyIncomeType' => $dailyIncomeType,
  10526. 'accountBank' => $accountBank,
  10527. 'category' => $this->staff [0] ['category'],
  10528. 'cid' => $this->staff [0] ['cid'],
  10529. 'name' => $this->staff [0] ['username'],
  10530. 'sid' => $this->staff [0] ['sid'],
  10531. 'inputDate' => date ( "Y-m-d H:i:s" )
  10532. );
  10533. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10534. } else {
  10535. // 添加一笔日常支出
  10536. $accountBook = new accountBook ();
  10537. $accountBook->expensesType = 2;
  10538. $accountBook->expenditureType = $expenditureType;
  10539. $accountBook->expenditureMsg = $expenditureMsg;
  10540. $accountBook->expenditurePrice = $expenditurePrice;
  10541. $accountBook->expenditureBank = $expenditureBank;
  10542. $accountBook->expenditureDate = $expenditureDate;
  10543. $accountBook->remarks = $remarks;
  10544. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10545. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10546. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10547. $id = $accountBook->insert ();
  10548. // 添加日常支出汇总
  10549. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10550. $accountBookStatistics = new accountBookStatistics ();
  10551. $item = array (
  10552. 'date' => date ( "Y-m-d" ),
  10553. 'expenditureType' => $abDetail ['expenditureType'],
  10554. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10555. 'aid' => $abDetail ['aid'],
  10556. 'expensesType' => $abDetail ['expensesType']
  10557. );
  10558. if ($expenditureType == 5) {
  10559. $item += array (
  10560. 'payPrice' => - $abDetail ['expenditurePrice']
  10561. );
  10562. } else {
  10563. $item += array (
  10564. 'payPrice' => $abDetail ['expenditurePrice']
  10565. );
  10566. }
  10567. $accountBookStatistics->setAccountBookStatistics ( $item );
  10568. // 公司日常支出流水
  10569. $wasteBook = new wasteBook ();
  10570. $itemWaste = array (
  10571. 'accountPrice' => - $expenditurePrice
  10572. );
  10573. if ($expenditureBank == '个人广发') {
  10574. $itemWaste = array (
  10575. 'accountPrice' => $expenditurePrice
  10576. );
  10577. }
  10578. $itemWaste += array (
  10579. 'expensesType' => 2,
  10580. 'accountType' => 5,
  10581. 'accountPriceShow' => $expenditurePrice,
  10582. 'dataID' => $id,
  10583. 'dailyExpenditureType' => $expenditureType,
  10584. 'accountBank' => $accountBank,
  10585. 'category' => $this->staff [0] ['category'],
  10586. 'cid' => $this->staff [0] ['cid'],
  10587. 'name' => $this->staff [0] ['username'],
  10588. 'sid' => $this->staff [0] ['sid'],
  10589. 'inputDate' => date ( "Y-m-d H:i:s" )
  10590. );
  10591. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10592. }
  10593. }
  10594. return '/payments';
  10595. }
  10596. /**
  10597. * 添加支出
  10598. */
  10599. function paymentsExpenditureDo_() {
  10600. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10601. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10602. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10603. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10604. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10605. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10606. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10607. $dailyExpenditureType = '';
  10608. $accountTypeWaste = 5;
  10609. $accountBank = '';
  10610. if ($expenditureBank == '纵横广发') {
  10611. $accountBank = 'CGBDeposit';
  10612. } elseif ($expenditureBank == '纵横工行') {
  10613. $accountBank = 'ICBCDeposit';
  10614. } elseif ($expenditureBank == '华润银行') {
  10615. $accountBank = 'HUADeposit';
  10616. } elseif ($expenditureBank == '个人广发') {
  10617. $accountBank = 'PersonalDeposit';
  10618. }
  10619. if (empty ( $accountBank ))
  10620. die ( 'illegal request' );
  10621. $itemWaste = array (
  10622. 'accountPrice' => - $expenditurePrice
  10623. );
  10624. if ($expenditureBank == '个人广发') {
  10625. $itemWaste = array (
  10626. 'accountPrice' => $expenditurePrice
  10627. );
  10628. }
  10629. if ($expenditureType == 4 || $expenditureType == 6) {
  10630. $dailyExpenditureType = 4;
  10631. if ($expenditureMsg == '公司固定') {
  10632. $accountTypeWaste = 9;
  10633. } elseif ($expenditureMsg == '公司活期') {
  10634. $accountTypeWaste = 10;
  10635. } elseif ($expenditureMsg == '个人(GR)') {
  10636. $accountBank = 'PersonalDeposit';
  10637. }
  10638. $itemWaste = array (
  10639. 'accountPrice' => $expenditurePrice
  10640. );
  10641. } elseif ($expenditureType == 1) {
  10642. $dailyExpenditureType = 1;
  10643. } elseif ($expenditureType == 2) {
  10644. $dailyExpenditureType = 2;
  10645. } elseif ($expenditureType == 3) {
  10646. $dailyExpenditureType = 3;
  10647. } elseif ($expenditureType == 5) {
  10648. $dailyExpenditureType = 5;
  10649. }
  10650. if (empty ( $dailyExpenditureType ))
  10651. die ( 'illegal request' );
  10652. Doo::loadModel ( "accountBook" );
  10653. $accountBook = new accountBook ();
  10654. $accountBook->expenditureType = $expenditureType;
  10655. $accountBook->expenditureMsg = $expenditureMsg;
  10656. $accountBook->expenditurePrice = $expenditurePrice;
  10657. $accountBook->expenditureBank = $expenditureBank;
  10658. $accountBook->expenditureDate = $expenditureDate;
  10659. $accountBook->remarks = $remarks;
  10660. $accountBook->expensesType = 2;
  10661. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10662. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10663. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10664. $id = $accountBook->insert ();
  10665. //
  10666. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10667. Doo::loadModel ( "accountBookStatistics" );
  10668. $accountBookStatistics = new accountBookStatistics ();
  10669. $item = array (
  10670. 'date' => date ( "Y-m-d" ),
  10671. 'expenditureType' => $abDetail ['expenditureType'],
  10672. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10673. 'aid' => $abDetail ['aid']
  10674. );
  10675. if ($abDetail ['expensesType'] == 2) {
  10676. if ($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) {
  10677. $item += array (
  10678. 'financingPrice' => $expenditurePrice,
  10679. 'expensesType' => 3
  10680. );
  10681. } elseif ($abDetail ['expenditureType'] == 5) {
  10682. $item += array (
  10683. 'payPrice' => $abDetail ['expenditurePrice'],
  10684. 'expensesType' => $abDetail ['expensesType']
  10685. );
  10686. } else {
  10687. $item += array (
  10688. 'payPrice' => $abDetail ['expenditurePrice'],
  10689. 'expensesType' => $abDetail ['expensesType']
  10690. );
  10691. }
  10692. }
  10693. $accountBookStatistics->setAccountBookStatistics ( $item );
  10694. // 公司流水记录
  10695. Doo::loadModel ( 'wasteBook' );
  10696. $wasteBook = new wasteBook ();
  10697. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountTypeWaste, $id );
  10698. // 银行
  10699. if (empty ( $abDetail )) {
  10700. $itemWaste += array (
  10701. 'accountPriceShow' => $expenditurePrice,
  10702. 'dataID' => $id,
  10703. 'expensesType' => 2,
  10704. 'accountType' => $accountTypeWaste,
  10705. 'dailyExpenditureType' => $expenditureType,
  10706. 'accountBank' => $accountBank,
  10707. 'category' => $this->staff [0] ['category'],
  10708. 'cid' => $this->staff [0] ['cid'],
  10709. 'name' => $this->staff [0] ['username'],
  10710. 'sid' => $this->staff [0] ['sid'],
  10711. 'inputDate' => date ( "Y-m-d H:i:s" )
  10712. );
  10713. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10714. }
  10715. // 支出类型为4或者6 需要添加一笔收入和收入流水
  10716. if ($expenditureType == 4 || $expenditureType == 6) {
  10717. $accountBank = 'CGBDeposit';
  10718. $dailyIncomeType = 7;
  10719. $receivedBank = '纵横广发';
  10720. if ($expenditureType == 6) {
  10721. $accountBank = 'ICBCDeposit';
  10722. $receivedBank = '纵横工行';
  10723. $dailyIncomeType = 9;
  10724. }
  10725. // 添加一笔收入
  10726. $accountBook = new accountBook ();
  10727. $accountBook->accountType = $dailyIncomeType;
  10728. $accountBook->accountMsg = $expenditureMsg;
  10729. $accountBook->receivedPrice = $expenditurePrice;
  10730. $accountBook->receivedBank = $receivedBank;
  10731. $accountBook->receivedDate = $expenditureDate;
  10732. $accountBook->remarks = $remarks;
  10733. $accountBook->expensesType = 1;
  10734. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10735. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10736. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10737. $id = $accountBook->insert ();
  10738. // 添加一笔收入流水
  10739. $itemWaste = array (
  10740. 'accountPriceShow' => $expenditurePrice,
  10741. 'accountPrice' => - $expenditurePrice,
  10742. 'dataID' => $id,
  10743. 'expensesType' => 1,
  10744. 'accountType' => $accountTypeWaste,
  10745. 'dailyIncomeType' => $dailyIncomeType,
  10746. 'accountBank' => $accountBank,
  10747. 'category' => $this->staff [0] ['category'],
  10748. 'cid' => $this->staff [0] ['cid'],
  10749. 'name' => $this->staff [0] ['username'],
  10750. 'sid' => $this->staff [0] ['sid'],
  10751. 'inputDate' => date ( "Y-m-d H:i:s" )
  10752. );
  10753. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10754. }
  10755. }
  10756. return '/payments';
  10757. }
  10758. /**
  10759. * 所有收支
  10760. */
  10761. function paymentsAchieve() {
  10762. $page_size = 12;
  10763. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  10764. $expensesType = isset ( $this->params ['expensesType'] ) ? $this->params ['expensesType'] : 'ALL';
  10765. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  10766. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  10767. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10768. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10769. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10770. $submitType = $this->get_args ( 'submitType' ) ? $this->get_args ( 'submitType' ) : "";
  10771. Doo::loadModel ( "accountBookStatistics" );
  10772. $accountBookStatistics = new accountBookStatistics ();
  10773. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  10774. $data ['statisticsList'] = $statisticsList;
  10775. Doo::loadModel ( "accountBook" );
  10776. $accountBook = new accountBook ();
  10777. $con = '';
  10778. if ($expensesType == 'INCOME')
  10779. $con = ' and expensesType=1 ';
  10780. elseif ($expensesType == 'PAY')
  10781. $con = ' and expensesType=2 ';
  10782. $dateArr = explode ( ':', $date );
  10783. $D1 = $dateString = '';
  10784. $D2 = '';
  10785. if (! empty ( $date )) {
  10786. $D1 = $dateArr [0];
  10787. if (isset ( $dateArr [1] ))
  10788. $D2 = $dateArr [1];
  10789. else
  10790. $D2 = '';
  10791. $dateString = $D1 . " : " . $D2;
  10792. }
  10793. if (! empty ( $D1 ) && ! empty ( $D2 ))
  10794. $con .= ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  10795. elseif (! empty ( $D1 ) && empty ( $D2 ))
  10796. $con .= ' and inputDate like "%' . $D1 . '%" ';
  10797. if (! empty ( $price ))
  10798. $con .= ' and (receivedPrice=' . $price . ' or expenditurePrice=' . $price . ')';
  10799. if ($submitType == 1) {
  10800. if ($accountType != '') {
  10801. $expenditureType = '';
  10802. $con .= ' and accountType=' . $accountType;
  10803. if (! empty ( $accountMsg ))
  10804. $con .= ' and (accountType=' . $accountType . ' and accountMsg like "%' . $accountMsg . '%")';
  10805. }
  10806. } elseif ($submitType == 2) {
  10807. if ($expenditureType != '') {
  10808. $accountType = $accountMsg = '';
  10809. $con .= ' and expenditureType=' . $expenditureType;
  10810. }
  10811. } else {
  10812. $accountType = $accountMsg = $expenditureType = '';
  10813. }
  10814. $sql = "" . $con;
  10815. $action = "paymentsAchieve";
  10816. $get = '/' . $expensesType; // "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  10817. $pageinfo = $this->get_page ( "CLD_accountBook", $sql, $page, $page_size, $action, $get, "" );
  10818. $limit = $pageinfo ['lower'] . ',' . $page_size;
  10819. $list = $accountBook->getAccountBookBySql ( $limit, $sql, 'desc' );
  10820. $data ['expenditureType'] = $expenditureType;
  10821. $data ['accountMsg'] = $accountMsg;
  10822. $data ['accountType'] = $accountType;
  10823. $data ['inputDate'] = $date;
  10824. $data ['price'] = $price;
  10825. $data ['expensesType'] = $expensesType;
  10826. $data ['page'] = $pageinfo;
  10827. $data ['list'] = $list;
  10828. $data ['memu'] = "receipt";
  10829. $data ['staff'] = $this->staff;
  10830. $data ['receiptMemu'] = 'payments';
  10831. $data ['verifyId'] = $this->verifyId;
  10832. $data ['executeId'] = $this->executeId;
  10833. $this->render ( "/expenses/paymentsAchieve", $data );
  10834. }
  10835. function paymentsIncomeUpdateDo() {
  10836. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  10837. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10838. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10839. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10840. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10841. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10842. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10843. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10844. if (! empty ( $aidKey ) && ! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10845. Doo::loadClass ( 'XDeode' );
  10846. $XDeode = new XDeode ( 5 );
  10847. $aid = $XDeode->decode ( $aidKey );
  10848. Doo::loadModel ( "accountBook" );
  10849. $accountBook = new accountBook ();
  10850. //
  10851. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  10852. $price = $receivedPrice - $abDetail [inComePrice];
  10853. Doo::loadModel ( "accountBookStatistics" );
  10854. $accountBookStatistics = new accountBookStatistics ();
  10855. if ($abDetail ['accountType'] == 7) {
  10856. $item += array (
  10857. 'date' => date ( "Y-m-d" ),
  10858. 'financingPrice' => - $price,
  10859. 'expensesType' => 3,
  10860. 'aid' => $abDetail ['aid']
  10861. );
  10862. } elseif ($abDetail ['accountType'] == 8) {
  10863. $item += array (
  10864. 'date' => date ( "Y-m-d" ),
  10865. 'expensesType' => $abDetail ['expensesType'],
  10866. 'inComePrice' => - $price,
  10867. 'aid' => $abDetail ['aid']
  10868. );
  10869. } else {
  10870. $item = array (
  10871. 'date' => date ( "Y-m-d" ),
  10872. 'expensesType' => $abDetail ['expensesType'],
  10873. 'inComePrice' => $price,
  10874. 'aid' => $abDetail ['aid']
  10875. );
  10876. }
  10877. $accountBookStatistics->setAccountBookStatistics ( $item );
  10878. $accountBook->accountType = $accountType;
  10879. $accountBook->accountMsg = $accountMsg;
  10880. $accountBook->receivedPrice = $receivedPrice;
  10881. $accountBook->receivedMsg = $receivedMsg;
  10882. $accountBook->receivedBank = $receivedBank;
  10883. $accountBook->receivedDate = $receivedDate;
  10884. $accountBook->remarks = $remarks;
  10885. $accountBook->aid = $aid;
  10886. $accountBook->update ();
  10887. }
  10888. return '/paymentsAchieve';
  10889. }
  10890. function paymentsExpenditureEdiDo() {
  10891. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  10892. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10893. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10894. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10895. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10896. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10897. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10898. if (! empty ( $aidKey ) && ! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10899. Doo::loadClass ( 'XDeode' );
  10900. $XDeode = new XDeode ( 5 );
  10901. $aid = $XDeode->decode ( $aidKey );
  10902. Doo::loadModel ( "accountBook" );
  10903. $accountBook = new accountBook ();
  10904. // 汇总信息
  10905. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  10906. $price = $expenditurePrice - $abDetail [expenditurePrice];
  10907. Doo::loadModel ( "accountBookStatistics" );
  10908. $accountBookStatistics = new accountBookStatistics ();
  10909. if ($abDetail ['expenditureType'] == 4) {
  10910. $item += array (
  10911. 'date' => date ( "Y-m-d" ),
  10912. 'financingPrice' => $price,
  10913. 'expensesType' => 3,
  10914. 'aid' => $abDetail ['aid']
  10915. );
  10916. } elseif ($abDetail ['expenditureType'] == 5) {
  10917. $item += array (
  10918. 'date' => date ( "Y-m-d" ),
  10919. 'expensesType' => $abDetail ['expensesType'],
  10920. 'payPrice' => $price,
  10921. 'aid' => $abDetail ['aid']
  10922. );
  10923. } else {
  10924. $item = array (
  10925. 'date' => date ( "Y-m-d" ),
  10926. 'expensesType' => $abDetail ['expensesType'],
  10927. 'payPrice' => $price,
  10928. 'aid' => $abDetail ['aid']
  10929. );
  10930. }
  10931. $accountBookStatistics->setAccountBookStatistics ( $item );
  10932. //
  10933. $accountBook->expenditureType = $expenditureType;
  10934. $accountBook->expenditureMsg = $expenditureMsg;
  10935. $accountBook->expenditurePrice = $expenditurePrice;
  10936. $accountBook->expenditureBank = $expenditureBank;
  10937. $accountBook->remarks = $remarks;
  10938. $accountBook->expenditureDate = $expenditureDate;
  10939. $accountBook->aid = $aid;
  10940. $id = $accountBook->update ();
  10941. }
  10942. return '/paymentsAchieve';
  10943. }
  10944. function paymentsDelDo() {
  10945. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  10946. if (! empty ( $aidKey )) {
  10947. Doo::loadClass ( 'XDeode' );
  10948. $XDeode = new XDeode ( 5 );
  10949. $aid = $XDeode->decode ( $aidKey );
  10950. Doo::loadModel ( "accountBook" );
  10951. $accountBook = new accountBook ();
  10952. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  10953. if (empty ( $abDetail ))
  10954. die ( 'illegal request' );
  10955. // 删除收支
  10956. Doo::loadModel ( "accountBookStatistics" );
  10957. $accountBookStatistics = new accountBookStatistics ();
  10958. $item = array (
  10959. 'date' => date ( "Y-m-d" ),
  10960. 'aid' => $abDetail ['aid']
  10961. );
  10962. $accountType = '';
  10963. if ($abDetail ['expensesType'] == 1) {
  10964. $accountType = 6;
  10965. if ($abDetail ['accountType'] != 7) {
  10966. $item += array (
  10967. 'expensesType' => $abDetail ['expensesType'],
  10968. 'inComePrice' => - $abDetail ['receivedPrice']
  10969. );
  10970. } else {
  10971. $item += array (
  10972. 'financingPrice' => $abDetail ['receivedPrice'],
  10973. 'expensesType' => 3
  10974. );
  10975. }
  10976. } elseif ($abDetail ['expensesType'] == 2) {
  10977. $accountType = 5;
  10978. if ($abDetail ['accountType'] != 7) {
  10979. $item += array (
  10980. 'expensesType' => $abDetail ['expensesType'],
  10981. 'payPrice' => - $abDetail ['expenditurePrice']
  10982. );
  10983. } else {
  10984. $item += array (
  10985. 'financingPrice' => - $abDetail ['expenditurePrice'],
  10986. 'expensesType' => 3
  10987. );
  10988. }
  10989. }
  10990. if (($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) && $abDetail ['expensesType'] == 2) {
  10991. if ($abDetail ['expenditureMsg'] == '公司固定')
  10992. $accountType = 9;
  10993. elseif ($abDetail ['expenditureMsg'] == '公司活期')
  10994. $accountType = 10;
  10995. }
  10996. if (($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) && $abDetail ['expensesType'] == 1) {
  10997. if ($abDetail ['accountMsg'] == '公司固定')
  10998. $accountType = 9;
  10999. elseif ($abDetail ['accountMsg'] == '公司活期')
  11000. $accountType = 10;
  11001. }
  11002. if ($abDetail ['accountMsg'] == '活期理财收益') {
  11003. $accountType = 10;
  11004. }
  11005. $accountBookStatistics->setAccountBookStatistics ( $item );
  11006. $accountBook->delete ( array (
  11007. 'where' => 'aid=' . $aid,
  11008. 'limit' => 1
  11009. ) );
  11010. // 删除收入流水
  11011. if (! empty ( $accountType )) {
  11012. Doo::loadModel ( 'wasteBook' );
  11013. $wasteBook = new wasteBook ();
  11014. $wasteBook->delete ( array (
  11015. 'where' => 'dataID=' . $aid . ' and accountType=' . $accountType,
  11016. 'limit' => 1
  11017. ) );
  11018. }
  11019. }
  11020. return '/paymentsAchieve';
  11021. }
  11022. function paymentsCollect() {
  11023. Doo::loadModel ( "execute" );
  11024. $execute = new execute ();
  11025. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11026. die ( 'illegal request' );
  11027. }
  11028. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11029. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  11030. Doo::loadModel ( "accountBookStatistics" );
  11031. $accountBookStatistics = new accountBookStatistics ();
  11032. Doo::loadClass ( 'receipt.func' );
  11033. $statisticsIncome = $accountBookStatistics->getStatisticsByCollect ( $year );
  11034. $html = _getPaymentsCollectByYearHtml ( $statisticsIncome );
  11035. $data ['html'] = $html ['html'];
  11036. $data ['inSum'] = $html ['sum'];
  11037. $statisticsPay = $accountBookStatistics->getStatisticsByCollect ( $year, 2 );
  11038. $html = _getPaymentsCollectPayByYearHtml ( $statisticsPay );
  11039. $data ['payHtml'] = $html ['html'];
  11040. $data ['paySum'] = $html ['sum'];
  11041. // 余额统计
  11042. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1 );
  11043. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2 );
  11044. include './protected/config/wasteBook.conf.php';
  11045. Doo::loadModel ( 'wasteBook' );
  11046. $wasteBook = new wasteBook ();
  11047. $inComePay = $wasteBook->getWasteBookByStatistics ( 1, $year );
  11048. $pay = $wasteBook->getWasteBookByStatistics ( 2, $year );
  11049. // 获得年份之前所有金额
  11050. $detail = $wasteBook->getWasteBookByStatisticsYear ( $year );
  11051. // print_r($detail);
  11052. // $waste['total'];
  11053. $lastBalanceHtml = '<tr><th colspan="2">截至上月余额</th>';
  11054. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11055. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11056. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11057. $inSum = $paySum = $showInSum = $showPaySum = $balanceSum = 0;
  11058. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11059. $limitMonth = date ( 'm' ); // 限制显示月份参数
  11060. if (date ( 'Y' ) > $year) {
  11061. $limitMonth = 12;
  11062. }
  11063. for($i = 1; $i <= 12; $i ++) {
  11064. $inComeA = $payB = 0;
  11065. $falg = true;
  11066. foreach ( $inComePay as $key => $value ) {
  11067. if ($value ['month'] == $i) {
  11068. $falg = false;
  11069. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11070. $inSum += $value ['accountPrice'];
  11071. $showInSum += $value ['accountPriceShow'];
  11072. $inComeA = $value ['accountPrice'];
  11073. break;
  11074. }
  11075. }
  11076. if ($falg)
  11077. $inComeHtml .= '<td class="taR">-</td>';
  11078. $payFalg = true;
  11079. foreach ( $pay as $key => $value ) {
  11080. if ($value ['month'] == $i) {
  11081. $payFalg = false;
  11082. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11083. $paySum += $value ['accountPrice'];
  11084. $showPaySum += $value ['accountPriceShow'];
  11085. $payB = $value ['accountPrice'];
  11086. break;
  11087. }
  11088. }
  11089. if ($payFalg)
  11090. $payHtml .= '<td class="taR">-</td>';
  11091. if (empty ( $balanceC ) || $limitMonth < $i)
  11092. $lastBalanceHtml .= '<td class="taR">-</td>';
  11093. else
  11094. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11095. $balanceC = $balanceC + $inComeA + $payB;
  11096. $balanceSum += $balanceC;
  11097. if (empty ( $balanceC ) || $limitMonth < $i)
  11098. $BalanceHtml .= '<td class="taR">-</td>';
  11099. else
  11100. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11101. // 余额统计
  11102. }
  11103. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11104. $data ['inComeHtml'] = $inComeHtml;
  11105. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11106. $data ['payBalanceHtml'] = $payHtml;
  11107. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11108. $data ['BalanceHtml'] = $BalanceHtml;
  11109. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11110. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11111. $mothHtml = "";
  11112. for($i = 1; $i <= 12; $i ++) {
  11113. if ($moth == $i)
  11114. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11115. else
  11116. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11117. }
  11118. $data ['mothHtml'] = $mothHtml;
  11119. $dateHtml = "";
  11120. $now = date ( "Y" );
  11121. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11122. if ($YEARD <= $now) {
  11123. $dateHtml .= '<option ';
  11124. if ($year == $YEARD) {
  11125. $dateHtml .= 'selected ';
  11126. }
  11127. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11128. }
  11129. }
  11130. $data ['dateHtml'] = $dateHtml;
  11131. $data ['year'] = $year;
  11132. $data ['memu'] = "receipt";
  11133. $data ['staff'] = $this->staff;
  11134. $data ['receiptMemu'] = 'paymentsCollect';
  11135. $data ['verifyId'] = $this->verifyId;
  11136. $data ['executeId'] = $this->executeId;
  11137. $this->render ( "/expenses/paymentsCollect", $data );
  11138. }
  11139. function paymentsCollectDay() {
  11140. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11141. $moth = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : '';
  11142. if (empty ( $moth ))
  11143. return 'paymentsCollect';
  11144. Doo::loadModel ( "accountBookStatistics" );
  11145. $accountBookStatistics = new accountBookStatistics ();
  11146. $i = 2;
  11147. $y = 2013;
  11148. $day = date ( "t", strtotime ( "$year-$moth" ) );
  11149. Doo::loadClass ( 'receipt.func' );
  11150. $statisticsIncome = $accountBookStatistics->getStatisticsByCollectDay ( $year, 1, $moth );
  11151. $html = _getPaymentsCollectByDayHtml ( $statisticsIncome, $day );
  11152. $data ['html'] = $html ['html'];
  11153. $data ['inSum'] = $html ['sum'];
  11154. $statisticsPay = $accountBookStatistics->getStatisticsByCollectDay ( $year, 2, $moth );
  11155. $html = _getPaymentsCollectPayByDayHtml ( $statisticsPay, $day );
  11156. $data ['payHtml'] = $html ['html'];
  11157. $data ['paySum'] = $html ['sum'];
  11158. $mothHtml = "";
  11159. for($i = 1; $i <= 12; $i ++) {
  11160. if ($moth == $i)
  11161. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11162. else
  11163. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11164. }
  11165. $data ['mothHtml'] = $mothHtml;
  11166. $data ['year'] = $year;
  11167. // 余额
  11168. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1, $moth );
  11169. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2, $moth );
  11170. include './protected/config/wasteBook.conf.php';
  11171. Doo::loadModel ( 'wasteBook' );
  11172. $wasteBook = new wasteBook ();
  11173. $inComePay = $wasteBook->getStatisticsByDay ( 1, $year, $moth );
  11174. $pay = $wasteBook->getStatisticsByDay ( 2, $year, $moth );
  11175. // 获得年份之前所有金额
  11176. $detail = $wasteBook->getWasteBookByStatisticsDay ( $year, $moth );
  11177. $lastBalanceHtml = '<tr><th colspan="2">截至上日余额</th>';
  11178. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11179. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11180. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11181. $dayHtml = '<tr><th class="taC" colspan="2">余额</th>';
  11182. $inSum = $paySum = $showPaySum = $showInSum = $balanceSum = 0;
  11183. // $balanceC = 0;
  11184. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11185. $limitDay = date ( 'd' );
  11186. $monthLK = ( int ) date ( 'm' );
  11187. if (date ( 'Y' ) > $year) {
  11188. $limitDay = cal_days_in_month ( CAL_GREGORIAN, date ( 'm' ), date ( 'Y' ) );
  11189. } elseif (date ( 'Y' ) <= $year && $monthLK < $moth) {
  11190. $limitDay = 0;
  11191. }
  11192. for($i = 1; $i <= $day; $i ++) {
  11193. $dayHtml .= '<td class="taC">' . $i . '日</td>';
  11194. $inComeA = $payB = 0;
  11195. $falg = true;
  11196. foreach ( $inComePay as $key => $value ) {
  11197. if ($value ['day'] == $i) {
  11198. $falg = false;
  11199. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11200. $inSum += $value ['accountPrice'];
  11201. $showInSum += $value ['accountPriceShow'];
  11202. $inComeA = $value ['accountPrice'];
  11203. break;
  11204. }
  11205. }
  11206. if ($falg)
  11207. $inComeHtml .= '<td class="taR">-</td>';
  11208. $payFalg = true;
  11209. foreach ( $pay as $key => $value ) {
  11210. if ($value ['day'] == $i) {
  11211. $payFalg = false;
  11212. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11213. $paySum += $value ['accountPrice'];
  11214. $showPaySum += $value ['accountPriceShow'];
  11215. $payB = $value ['accountPrice'];
  11216. break;
  11217. }
  11218. }
  11219. if ($payFalg)
  11220. $payHtml .= '<td class="taR">-</td>';
  11221. if (empty ( $balanceC ) || $limitDay < $i)
  11222. $lastBalanceHtml .= '<td class="taR">-</td>';
  11223. else
  11224. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11225. $balanceC = $balanceC + $inComeA + $payB;
  11226. $balanceSum += $balanceC;
  11227. if (empty ( $balanceC ) || $limitDay < $i)
  11228. $BalanceHtml .= '<td class="taR">-</td>';
  11229. else
  11230. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11231. }
  11232. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11233. $data ['inComeHtml'] = $inComeHtml;
  11234. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11235. $data ['payBalanceHtml'] = $payHtml;
  11236. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11237. $data ['BalanceHtml'] = $BalanceHtml;
  11238. $dayHtml .= '<td class="taR ">总计</td></tr>';
  11239. $data ['dayHtml'] = $dayHtml;
  11240. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11241. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11242. $dateHtml = "";
  11243. $now = date ( "Y" );
  11244. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11245. if ($YEARD <= $now) {
  11246. $dateHtml .= '<option ';
  11247. if ($year == $YEARD) {
  11248. $dateHtml .= 'selected ';
  11249. }
  11250. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11251. }
  11252. }
  11253. $data ['dateHtml'] = $dateHtml;
  11254. $data ['memu'] = "receipt";
  11255. $data ['staff'] = $this->staff;
  11256. $data ['receiptMemu'] = 'paymentsCollect';
  11257. $data ['verifyId'] = $this->verifyId;
  11258. $data ['executeId'] = $this->executeId;
  11259. $this->render ( "/expenses/paymentsCollectDay", $data );
  11260. }
  11261. // 公司流水
  11262. function wasteBook() {
  11263. Doo::loadModel ( "execute" );
  11264. $execute = new execute ();
  11265. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11266. die ( 'illegal request' );
  11267. }
  11268. include './protected/config/wasteBook.conf.php';
  11269. Doo::loadModel ( 'wasteBook' );
  11270. $wasteBook = new wasteBook ();
  11271. $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  11272. $waste = $this->getWasteBookStatistics ( $waste, $inComeStatistics );
  11273. $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'];
  11274. // print_r($waste);
  11275. $data ['waste'] = $waste;
  11276. $data ['total'] = $total;
  11277. // 月流水数据结构
  11278. $monthStatistics = array ();
  11279. $incomeMothStatistics = array ();
  11280. $expenditureMothStatistics = array ();
  11281. for($i = 1; $i <= 12; $i ++) {
  11282. $month = date ( 'Y' ) . '-' . $i;
  11283. if ($i < 10)
  11284. $month = date ( 'Y' ) . '-0' . $i;
  11285. array_push ( $monthStatistics, $month );
  11286. }
  11287. foreach ( $monthStatistics as $value ) {
  11288. $falg = true;
  11289. foreach ( $inComeStatistics ['incomeReport'] as $k => $v ) {
  11290. if ($value == $v ['inputDate']) {
  11291. array_push ( $incomeMothStatistics, $v ['accountPrice'] );
  11292. $falg = false;
  11293. }
  11294. }
  11295. if ($falg) {
  11296. array_push ( $incomeMothStatistics, '' );
  11297. }
  11298. $falgEx = true;
  11299. foreach ( $inComeStatistics ['expenditureReport'] as $k => $v ) {
  11300. if ($value == $v ['inputDate']) {
  11301. array_push ( $expenditureMothStatistics, $v ['accountPrice'] );
  11302. $falg = false;
  11303. }
  11304. }
  11305. if ($falgEx) {
  11306. array_push ( $expenditureMothStatistics, '' );
  11307. }
  11308. }
  11309. $data ['monthStatistics'] = json_encode ( $monthStatistics );
  11310. $data ['incomeMothStatistics'] = json_encode ( $incomeMothStatistics );
  11311. $data ['expenditureMothStatistics'] = json_encode ( $expenditureMothStatistics );
  11312. $expenditureList = $wasteBook->getAccountBookByExpensesType ( 4, 2 );
  11313. $incomeList = $wasteBook->getAccountBookByExpensesType ( 4, 1 );
  11314. // print_r($incomeList);
  11315. $data ['expenditureList'] = $expenditureList;
  11316. $data ['incomeList'] = $incomeList;
  11317. $data ['memu'] = "receipt";
  11318. $data ['staff'] = $this->staff;
  11319. $data ['receiptMemu'] = 'wasteBook';
  11320. $data ['verifyId'] = $this->verifyId;
  11321. $data ['executeId'] = $this->executeId;
  11322. $this->render ( "/expenses/wasteBook", $data );
  11323. }
  11324. function wasteBookIncome() {
  11325. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11326. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11327. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  11328. $dailyIncomeType = $this->get_args ( 'dailyIncomeType' ) ? $this->get_args ( 'dailyIncomeType' ) : "ALL";
  11329. $data ['dailyIncomeType'] = $dailyIncomeType;
  11330. Doo::loadModel ( 'wasteBook' );
  11331. $wasteBook = new wasteBook ();
  11332. Doo::loadModel ( 'L_category' );
  11333. $L_category = new L_category ();
  11334. Doo::loadClass ( 'XDeode' );
  11335. $XDeode = new XDeode ( 5 );
  11336. // echo $XDeode->encode(1).'<br>';
  11337. // echo $XDeode->encode(2).'<br>';
  11338. // echo $XDeode->encode(3).'<br>';
  11339. // echo $XDeode->encode(4).'<br>';
  11340. // echo $XDeode->encode(5).'<br>';
  11341. // echo $XDeode->encode(6).'<br>';
  11342. // echo $XDeode->encode(7).'<br>';
  11343. // echo $XDeode->encode(8).'<br>';
  11344. // echo $XDeode->encode(9).'<br>';
  11345. // echo $XDeode->encode(10).'<br>';
  11346. $dateArr = explode ( ':', $date );
  11347. $D1 = '';
  11348. $D2 = '';
  11349. $con = '';
  11350. if (! empty ( $date )) {
  11351. $D1 = $dateArr [0];
  11352. $D2 = $dateArr [1];
  11353. }
  11354. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11355. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11356. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11357. $con = ' and inputDate = "' . $D1 . '"';
  11358. if ($cid != 'ALL') {
  11359. $cid = $XDeode->decode ( $cid );
  11360. $con .= ' and cid = "' . $cid . '"';
  11361. }
  11362. if ($accountType != 'ALL') {
  11363. if ($accountType == 'INVOICE') {
  11364. $con .= ' and (accountType = 7 or accountType = 8)';
  11365. } elseif ($accountType == 'PAYMENTS') {
  11366. $con .= ' and (accountType = 6 or accountType = 9 or accountType = 10)';
  11367. if ($dailyIncomeType != 'ALL') {
  11368. $dailyIncomeType = $XDeode->decode ( $dailyIncomeType );
  11369. $con .= ' and dailyIncomeType = ' . $dailyIncomeType;
  11370. }
  11371. }
  11372. }
  11373. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 1, $con );
  11374. $sum = 0;
  11375. foreach ( $incomeList as $key => $value ) {
  11376. $sum += $value ['accountPrice'];
  11377. }
  11378. // print_r($incomeList);
  11379. // 获得办事和部门
  11380. $categoryList = $L_category->getCategory ();
  11381. $data ['accountType'] = $accountType;
  11382. $data ['cid'] = $cid;
  11383. $data ['categoryList'] = $categoryList;
  11384. $data ['sum'] = $sum;
  11385. $data ['incomeList'] = $incomeList;
  11386. $data ['inputDate'] = $date;
  11387. $data ['memu'] = "receipt";
  11388. $data ['staff'] = $this->staff;
  11389. $data ['receiptMemu'] = 'wasteBook';
  11390. $data ['verifyId'] = $this->verifyId;
  11391. $data ['executeId'] = $this->executeId;
  11392. $this->render ( "/expenses/wasteBookIncome", $data );
  11393. }
  11394. /**
  11395. * 所有支出
  11396. */
  11397. function wasteBookExpenditure() {
  11398. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11399. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11400. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  11401. $dailyExpenditureType = $this->get_args ( 'dailyExpenditureType' ) ? $this->get_args ( 'dailyExpenditureType' ) : "ALL";
  11402. $data ['dailyExpenditureType'] = $dailyExpenditureType;
  11403. $receiptType = $this->get_args ( 'receiptType' ) ? $this->get_args ( 'receiptType' ) : "ALL";
  11404. $data ['receiptType'] = $receiptType;
  11405. Doo::loadModel ( 'wasteBook' );
  11406. $wasteBook = new wasteBook ();
  11407. Doo::loadModel ( 'L_category' );
  11408. $L_category = new L_category ();
  11409. Doo::loadClass ( 'XDeode' );
  11410. $XDeode = new XDeode ( 5 );
  11411. $dateArr = explode ( ':', $date );
  11412. $D1 = '';
  11413. $D2 = '';
  11414. $con = '';
  11415. if (! empty ( $date )) {
  11416. $D1 = $dateArr [0];
  11417. $D2 = $dateArr [1];
  11418. }
  11419. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11420. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11421. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11422. $con = ' and inputDate = "' . $D1 . '"';
  11423. if ($cid != 'ALL') {
  11424. $cid = $XDeode->decode ( $cid );
  11425. $con .= ' and cid = "' . $cid . '"';
  11426. }
  11427. if ($accountType != 'ALL') {
  11428. if ($accountType == 'INVOICE') {
  11429. $con .= ' and accountType = 11';
  11430. } elseif ($accountType == 'PAYMENTS') {
  11431. $con .= ' and (accountType = 5 or accountType = 9 or accountType = 10)';
  11432. if ($dailyExpenditureType != 'ALL') {
  11433. $dailyExpenditureType = $XDeode->decode ( $dailyExpenditureType );
  11434. $con .= ' and dailyExpenditureType = ' . $dailyExpenditureType;
  11435. }
  11436. } elseif ($accountType == 'RECEIPT') {
  11437. if ($receiptType == 'ALL') {
  11438. $con .= ' and (accountType = 1 or accountType = 2 or accountType = 3 or accountType = 4)';
  11439. } else {
  11440. $receiptType = $XDeode->decode ( $receiptType );
  11441. echo $receiptType;
  11442. if ($receiptType == 1) {
  11443. $con .= ' and (accountType = 1 or accountType=2)';
  11444. } else {
  11445. $con .= ' and accountType = ' . $receiptType;
  11446. }
  11447. }
  11448. }
  11449. }
  11450. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 2, $con );
  11451. $sum = 0;
  11452. foreach ( $incomeList as $key => $value ) {
  11453. $sum += $value ['accountPriceShow'];
  11454. }
  11455. // print_r($incomeList);
  11456. // 获得办事和部门
  11457. $categoryList = $L_category->getCategory ();
  11458. $data ['accountType'] = $accountType;
  11459. $data ['cid'] = $cid;
  11460. $data ['categoryList'] = $categoryList;
  11461. $data ['sum'] = $sum;
  11462. $data ['incomeList'] = $incomeList;
  11463. $data ['inputDate'] = $date;
  11464. $data ['memu'] = "receipt";
  11465. $data ['staff'] = $this->staff;
  11466. $data ['receiptMemu'] = 'wasteBook';
  11467. $data ['verifyId'] = $this->verifyId;
  11468. $data ['executeId'] = $this->executeId;
  11469. $this->render ( "/expenses/wasteBookExpenditure", $data );
  11470. }
  11471. function ajaxGetWasteinvoiceReceivables() {
  11472. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11473. Doo::loadClass ( 'XDeode' );
  11474. $XDeode = new XDeode ( 5 );
  11475. $irid = $XDeode->decode ( $serial );
  11476. Doo::loadModel ( 'invoiceReceivables' );
  11477. $invoiceReceivables = new invoiceReceivables ();
  11478. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  11479. echo json_encode ( array (
  11480. 'status' => 1,
  11481. 'detail' => $detail
  11482. ) );
  11483. }
  11484. function ajaxGetPaymentsByAid() {
  11485. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11486. Doo::loadModel ( "accountBook" );
  11487. $accountBook = new accountBook ();
  11488. $detail = $accountBook->getAccountBookByAid ( $serial );
  11489. echo json_encode ( array (
  11490. 'status' => 1,
  11491. 'detail' => $detail
  11492. ) );
  11493. }
  11494. function ajaxGetWasteInvoice() {
  11495. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11496. Doo::loadModel ( 'invoice' );
  11497. $invoice = new invoice ();
  11498. Doo::loadModel ( 'invoiceReceivables' );
  11499. $invoiceReceivables = new invoiceReceivables ();
  11500. $detail = $invoice->getInvoiceByIid ( $serial );
  11501. $detailReceivables = $invoiceReceivables->getInvoiceReceivablesByIrid ( $detail ['irid'] );
  11502. $detail ['receivablesBank'] = $detailReceivables ['receivablesBank'];
  11503. echo json_encode ( array (
  11504. 'status' => 1,
  11505. 'detail' => $detail
  11506. ) );
  11507. }
  11508. /**
  11509. */
  11510. function ajaxGetWasteReceipt() {
  11511. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11512. $accountTypeKey = $this->get_args ( 'accountTypeKey' ) ? $this->get_args ( 'accountTypeKey' ) : "";
  11513. Doo::loadModel ( 'receipt' );
  11514. $receipt = new receipt ();
  11515. Doo::loadClass ( 'XDeode' );
  11516. $XDeode = new XDeode ( 5 );
  11517. $rid = $XDeode->decode ( $serial );
  11518. $accountType= $XDeode->decode ( $accountTypeKey );
  11519. // 获得个数据
  11520. $detail = $receipt->getReceiptByRid ( $rid );
  11521. // 初始化
  11522. $detail ['reviseDetail'] = array ();
  11523. if (! empty ( $value ['reviseDetail'] ))
  11524. $detail ['reviseDetail'] = json_decode ( $detail ['reviseDetail'], true );
  11525. $detail ['accountItem'] = json_decode ( $detail ['accountItem'], true );
  11526. $detail ['loanItem'] = json_decode ( $detail ['loanItem'], true );
  11527. $detail ['loanSumCN'] = $this->num_to_rmb ( $detail ['loanSum'] );
  11528. $detail ['sumCN'] = $this->num_to_rmb ( $detail ['sum'] );
  11529. // 获得费用html
  11530. $html = $this->getWasteReceiptHtml ( $detail ,$accountType);
  11531. // 获得费用审批人数据
  11532. $detail = $this->getReceiptApproverHtml ( $detail );
  11533. // 审批执行
  11534. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  11535. <th class="taC" width="90">审批人</th>
  11536. <th class="taC">审批意见</th></tr>';
  11537. foreach ( $detail ['verifyList'] as $key => $value ) {
  11538. $html .= '<tr>
  11539. <td>' . $value [1] . '</td>
  11540. <td>' . $value ['opinion'] . '</td>
  11541. </tr>
  11542. ';
  11543. }
  11544. $html .= ' </tbody></table>';
  11545. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  11546. <th class="taC" width="90">执行人</th>
  11547. <th class="taC">执行意见</th></tr>';
  11548. foreach ( $detail ['executeCopy'] as $key => $value ) {
  11549. $html .= '<tr>
  11550. <td>' . $value [1] . '</td>
  11551. <td>' . $value ['opinion'] . '</td>
  11552. </tr>
  11553. ';
  11554. }
  11555. $html .= ' </tbody></table>';
  11556. if($accountType==1){
  11557. Doo::loadModel ( 'loanReceipt' );
  11558. $loanReceipt = new loanReceipt ();
  11559. $loanList = $loanReceipt->getOne ( array (
  11560. 'where' => 'rid=' . $detail ['loanRid'],
  11561. 'desc' => 'rid',
  11562. 'asArray' => true
  11563. ) );
  11564. $html .= '<table class="table table-bordered table-condensed">
  11565. <tr class="warning">
  11566. <td class="taR"><b>汇款金额</b></td>
  11567. <td width="140" class="taR"><b style="font-size: 24px">¥'.$loanList['amount'].'</b></td>
  11568. </tr>
  11569. </table>';
  11570. }else{
  11571. $html .= '<table class="table table-bordered table-condensed">
  11572. <tr class="warning">
  11573. <td class="taR"><b>汇款金额</b></td>
  11574. <td width="140" class="taR"><b style="font-size: 24px">¥' . $detail ['amount'] . '</b></td>
  11575. </tr>
  11576. </table>';
  11577. }
  11578. // print_r($detail['verifyList']);
  11579. // header ( 'Content-Type:text/html;charset=utf-8' );
  11580. // echo $html;
  11581. echo json_encode ( array (
  11582. 'status' => 1,
  11583. 'html' => $html,
  11584. 'detail' => $detail
  11585. ) );
  11586. }
  11587. function getReceiptApproverHtml($detail = array()) {
  11588. Doo::loadModel ( 'loanReceipt' );
  11589. $loanReceipt = new loanReceipt ();
  11590. Doo::loadModel ( 'verify' );
  11591. $verify = new verify ();
  11592. Doo::loadModel ( 'staff' );
  11593. $staff = new staff ();
  11594. if (empty ( $detail ))
  11595. return array ();
  11596. $loanList = $loanReceipt->getOne ( array (
  11597. 'where' => 'rid=' . $detail ['loanRid'],
  11598. 'desc' => 'rid',
  11599. 'asArray' => true
  11600. ) );
  11601. if ($detail ['status'] == 3 || $detail ['status'] == 1 || $detail ['status'] == 8 || $detail ['status'] == 9) {
  11602. if ($detail ['status'] == 8 && $detail ['Rtype'] == 1)
  11603. $verifyList ['staff'] = $loanList ['verifyBreakup'];
  11604. else
  11605. $verifyList ['staff'] = $detail ['verifyBreakup'];
  11606. } else
  11607. $verifyList = $verify->getOne ( array (
  11608. 'where' => 'vid=' . $detail ['verify'],
  11609. 'asArray' => true
  11610. ) );
  11611. $verifyList = json_decode ( $verifyList ['staff'], true );
  11612. Doo::loadModel ( 'role' );
  11613. $role = new role ();
  11614. $roleId = 0;
  11615. $flag = true;
  11616. $roleKey = 0;
  11617. $endStaffArray = array ();
  11618. $roleArrayCopy = array ();
  11619. foreach ( $verifyList as $k => $v ) {
  11620. // init verifyStaff
  11621. if ($v [1] == 'ROLE') {
  11622. if (! empty ( $verifyStaff )) {
  11623. $endStaffArray = end ( $verifyStaff );
  11624. }
  11625. $roleVerify = json_decode ( $v [3], true );
  11626. $roleKey = $k;
  11627. $roleArray = array ();
  11628. $rolename = $role->getOne ( array (
  11629. 'where' => 'rid=' . $v [0],
  11630. 'asArray' => true
  11631. ) );
  11632. foreach ( $roleVerify as $o => $p ) {
  11633. $staffID = explode ( '_', $p );
  11634. $staffInfo = $staff->getOne ( array (
  11635. 'where' => 'sid=' . $staffID [0],
  11636. 'asArray' => true
  11637. ) );
  11638. // print_r($staffID);
  11639. $exp = array (
  11640. 0 => $staffInfo ['sid'],
  11641. 1 => $staffID [1],
  11642. 2 => $staffInfo ['avatar'],
  11643. 'date' => '',
  11644. 'date' => '',
  11645. 'opinion' => '',
  11646. 'status' => '',
  11647. 'rolename' => $rolename ['name']
  11648. );
  11649. array_push ( $roleArray, $exp );
  11650. }
  11651. $roleArrayCopy [$v [0]] = $roleArray;
  11652. // $verifyList[$k]['roleArray']=$roleArray;
  11653. }
  11654. $verifyList [$k] ['date'] = "";
  11655. $verifyList [$k] ['opinion'] = "";
  11656. $verifyList [$k] ['status'] = "";
  11657. if (empty ( $verifyStaff )) {
  11658. $verifyList [$k] ['date'] = "";
  11659. $verifyList [$k] ['opinion'] = "";
  11660. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  11661. $verifyList [$k] ['status'] = 4;
  11662. $flag = false;
  11663. }
  11664. } else {
  11665. foreach ( $verifyStaff as $m => $u ) {
  11666. if ($v [0] == $m) {
  11667. $verifyList [$k] ['date'] = $u ['date'];
  11668. $verifyList [$k] ['opinion'] = $u ['opinion'];
  11669. $verifyList [$k] ['status'] = $u ['status'];
  11670. $flag = false;
  11671. break;
  11672. }
  11673. }
  11674. $endStaffArray = end ( $verifyStaff );
  11675. }
  11676. }
  11677. $rolename ['name'] = '';
  11678. if (! empty ( $roleId )) {
  11679. Doo::loadModel ( 'role' );
  11680. $role = new role ();
  11681. $rolename = $role->getOne ( array (
  11682. 'where' => 'rid=' . $roleId,
  11683. 'asArray' => true
  11684. ) );
  11685. }
  11686. if (! empty ( $verifyStaff ))
  11687. $endStaffArray = end ( $verifyStaff );
  11688. $KOP = false;
  11689. foreach ( $roleArrayCopy as $P => $A ) {
  11690. foreach ( $A as $MKI => $AVL ) {
  11691. if (! empty ( $verifyStaff )) {
  11692. // &&$rolename['rid']==$endStaffArray['nextStaff']
  11693. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  11694. $button = 4;
  11695. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  11696. }
  11697. foreach ( $verifyStaff as $m => $u ) {
  11698. $AVLFK = $AVL [0] . '_R';
  11699. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  11700. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  11701. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  11702. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  11703. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  11704. break;
  11705. }
  11706. }
  11707. } else {
  11708. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  11709. $button = 4;
  11710. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  11711. }
  11712. }
  11713. // $roleArray[$MKI]['rolename']=$rolename['name'];
  11714. $KOP = true;
  11715. }
  11716. }
  11717. foreach ( $roleArrayCopy as $k => $v ) {
  11718. foreach ( $verifyList as $m => $n ) {
  11719. if ($n [0] == $k) {
  11720. array_splice ( $verifyList, $m, 1, $v );
  11721. }
  11722. }
  11723. }
  11724. // 费用执行人相关数据
  11725. $executeCopy = json_decode ( $detail ['executeCopy'], true );
  11726. $executeStaff = json_decode ( $detail ['executeStaff'], true );
  11727. foreach ( $executeCopy as $k => $v ) {
  11728. $executeCopy [$k] ['date'] = '';
  11729. $executeCopy [$k] ['opinion'] = '';
  11730. $executeCopy [$k] ['status'] = '';
  11731. if (! empty ( $executeStaff ))
  11732. foreach ( $executeStaff as $m => $u ) {
  11733. if ($v [0] == $m) {
  11734. $executeCopy [$k] ['date'] = $u ['date'];
  11735. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  11736. $executeCopy [$k] ['status'] = $u ['status'];
  11737. break;
  11738. }
  11739. }
  11740. }
  11741. $detail ['executeCopy'] = $executeCopy;
  11742. $detail ['verifyList'] = $verifyList;
  11743. return $detail;
  11744. }
  11745. function getWasteReceiptHtml($detail = array(),$accountType=1) {
  11746. if (empty ( $detail ))
  11747. return '';
  11748. $html = '';
  11749. if ($detail ['Rtype'] == 0) { // 报销单
  11750. $html .= '
  11751. <table class="table table-bordered table-condensed">
  11752. <tbody>
  11753. <tr>
  11754. <th colspan="2" class="taC">日常相关费用</th>
  11755. </tr>';
  11756. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  11757. $html .= '
  11758. <tr>
  11759. <th>' . $value ['name'] . '</th>
  11760. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11761. </tr>';
  11762. }
  11763. $html .= '
  11764. <tr>
  11765. <th class="taR">合计</th>
  11766. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  11767. </tr>';
  11768. $html .= '<tr>
  11769. <th colspan="2" class="taC">差旅相关费用</th>
  11770. </tr>';
  11771. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  11772. $html .= '
  11773. <tr>
  11774. <th>' . $value ['name'] . '</th>
  11775. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11776. </tr>';
  11777. }
  11778. $html .= '
  11779. <tr>
  11780. <th class="taR">合计</th>
  11781. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  11782. </tr>';
  11783. $html .= '<tr>
  11784. <th colspan="2" class="taC">培训班费用</th>
  11785. </tr>';
  11786. foreach ( $detail ['accountItem'] ['培训班费用'] as $key => $value ) {
  11787. $html .= '
  11788. <tr>
  11789. <th>' . $value ['name'] . '</th>
  11790. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11791. </tr>';
  11792. }
  11793. $html .= '
  11794. <tr>
  11795. <th class="taR">合计</th>
  11796. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['trainSum'] . '</td>
  11797. </tr>';
  11798. $html .= '<tr>
  11799. <th colspan="2" class="taC">其他</th>
  11800. </tr>';
  11801. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  11802. $html .= '
  11803. <tr>
  11804. <th>' . $value ['name'] . '</th>
  11805. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11806. </tr>';
  11807. }
  11808. $html .= '
  11809. <tr>
  11810. <th class="taR">合计</th>
  11811. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  11812. </tr>';
  11813. $html .= '<tr>
  11814. <th colspan="2" class="taC">报销金额调整</th>
  11815. </tr>';
  11816. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  11817. $html .= '
  11818. <tr>
  11819. <th>' . $value ['name'] . '</th>
  11820. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11821. </tr>';
  11822. }
  11823. $html .= '
  11824. <tr>
  11825. <th class="taR">合计</th>
  11826. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  11827. </tr>';
  11828. $html .= '
  11829. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  11830. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  11831. <tr><th class="taC" colspan="2">报销说明</th></tr>
  11832. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  11833. <tr class="warning">
  11834. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  11835. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  11836. </tr>
  11837. </tbody>
  11838. </table>';
  11839. } elseif ($detail ['Rtype'] == 2) {//对公汇款
  11840. $html .= '
  11841. <table class="table table-bordered table-condensed">
  11842. <tbody>
  11843. <tr>
  11844. <th colspan="2" class="taC">办事处相关费用</th>
  11845. </tr>';
  11846. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  11847. $html .= '
  11848. <tr>
  11849. <th>' . $value ['name'] . '</th>
  11850. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11851. </tr>';
  11852. }
  11853. $html .= '
  11854. <tr>
  11855. <th class="taR">合计</th>
  11856. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  11857. </tr>';
  11858. $html .= '
  11859. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  11860. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  11861. <tr><th class="taC" colspan="2">报销说明</th></tr>
  11862. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  11863. <tr class="warning">
  11864. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  11865. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  11866. </tr>
  11867. </tbody>
  11868. </table>';
  11869. } elseif ($detail ['Rtype'] == 1) {//借款 或者借款报销
  11870. Doo::loadModel ( 'loanReceipt' );
  11871. $loanReceipt = new loanReceipt ();
  11872. $loanList = $loanReceipt->getOne ( array (
  11873. 'where' => 'rid=' . $detail ['loanRid'],
  11874. 'desc' => 'rid',
  11875. 'asArray' => true
  11876. ) );
  11877. // print_r($loanList);
  11878. $loanList ['sumCN']=$this->num_to_rmb($loanList ['sum']);
  11879. $html .= '<table class="table table-bordered table-condensed">
  11880. <tbody>
  11881. <tr>
  11882. <th colspan="2" class="taC">借款费用</th>
  11883. </tr>';
  11884. foreach ( $detail ['loanItem'] ['借款费用'] as $key => $value ) {
  11885. $html .= '<tr>
  11886. <th>' . $value ['name'] . '</th>
  11887. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11888. </tr>';
  11889. }
  11890. $html .= '<tr>
  11891. <th class="taC" colspan="2">产生费用所在办事处</th>
  11892. </tr>
  11893. <tr>
  11894. <th style="text-align: center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th>
  11895. </tr>
  11896. <tr>
  11897. <th class="taC" colspan="2">费用说明</th>
  11898. </tr>
  11899. <tr>
  11900. <td colspan="2">' . $loanList ['explanation'] . '</td>
  11901. </tr>
  11902. <tr class="warning">
  11903. <td class="taR"><b>(' . $loanList ['receiptOrder'] . ')本次费用合计</b></td>
  11904. <td class="taR"><b style="font-size: 24px">¥' . $loanList ['sum'] . '</b><br>' . $loanList ['sumCN'] . '</td>
  11905. </tr>
  11906. </tbody>
  11907. </table>
  11908. ';
  11909. if ( $accountType==2) {
  11910. $balance=$detail ['sum']-$loanList ['sum'];
  11911. $balanceCN=$this->num_to_rmb($balance);
  11912. $html .= '<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 .= '<tr>
  11930. <th colspan="2" class="taC">差旅相关费用</th>
  11931. </tr>';
  11932. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  11933. $html .= '
  11934. <tr>
  11935. <th>' . $value ['name'] . '</th>
  11936. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11937. </tr>';
  11938. }
  11939. $html .= '
  11940. <tr>
  11941. <th class="taR">合计</th>
  11942. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  11943. </tr>';
  11944. $html .= '<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'] ['trainSum'] . '</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'] ['otherSum'] . '</td>
  11973. </tr>';
  11974. $html .= '<tr>
  11975. <th colspan="2" class="taC">报销金额调整</th>
  11976. </tr>';
  11977. foreach ( $detail ['reviseDetail'] 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 ['revisePrice'] . '</td>
  11988. </tr>';
  11989. $html .= '
  11990. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  11991. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  11992. <tr><th class="taC" colspan="2">报销说明</th></tr>
  11993. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  11994. <tr class="warning">
  11995. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  11996. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  11997. </tr>
  11998. <tr class="success">
  11999. <td class="taR"><b>借款结余</b></td>
  12000. <td class="taR"><b style="font-size:24px">¥'.$balance.'</b><br>'.$balanceCN.'</td>
  12001. </tr>
  12002. </tbody>
  12003. </table>';
  12004. }
  12005. }
  12006. return $html;
  12007. }
  12008. /**
  12009. * 计算流水
  12010. */
  12011. function getWasteBookStatistics($waste = array(), $inComeStatistics) {
  12012. $bakWaste ['bank'] = array (
  12013. 'CGBDeposit' => 0,
  12014. 'ICBCDeposit' => 0,
  12015. 'HUADeposit' => 0,
  12016. 'PersonalDeposit' => 0
  12017. );
  12018. $bakWaste ['financial'] = array (
  12019. 'current' => array (
  12020. 'CGBDeposit' => 0,
  12021. 'ICBCDeposit' => 0
  12022. ),
  12023. 'fixed' => array (
  12024. 'CGBDeposit' => 0,
  12025. 'ICBCDeposit' => 0
  12026. )
  12027. );
  12028. // 存款
  12029. foreach ( $waste ['bank'] as $key => $value ) {
  12030. // 收入
  12031. foreach ( $inComeStatistics ['incomeStatistics'] as $k => $v ) {
  12032. // 广发
  12033. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12034. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12035. }
  12036. // 工商
  12037. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12038. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12039. }
  12040. // 华润
  12041. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12042. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12043. }
  12044. // 个人
  12045. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12046. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12047. }
  12048. }
  12049. }
  12050. foreach ( $waste ['bank'] as $key => $value ) {
  12051. // 支出
  12052. foreach ( $inComeStatistics ['expenditureStatistics'] as $k => $v ) {
  12053. // 广发
  12054. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12055. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12056. }
  12057. // 工商
  12058. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12059. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12060. }
  12061. // 华润
  12062. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12063. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12064. }
  12065. // 个人
  12066. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12067. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12068. }
  12069. }
  12070. }
  12071. // 活期
  12072. foreach ( $waste ['financial'] ['current'] as $key => $value ) {
  12073. foreach ( $inComeStatistics ['currentStatistics'] as $k => $v ) {
  12074. // 广发
  12075. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12076. $waste ['financial'] ['current'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  12077. }
  12078. // 工商
  12079. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12080. $waste ['financial'] ['current'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  12081. }
  12082. // 个人
  12083. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12084. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  12085. }
  12086. }
  12087. }
  12088. // print_r($inComeStatistics ['fixedStatistics']);
  12089. // 固期
  12090. foreach ( $waste ['financial'] ['fixed'] as $key => $value ) {
  12091. foreach ( $inComeStatistics ['fixedStatistics'] as $k => $v ) {
  12092. // 广发
  12093. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12094. $waste ['financial'] ['fixed'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  12095. }
  12096. // 工商
  12097. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12098. $waste ['financial'] ['fixed'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  12099. }
  12100. // 个人
  12101. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12102. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  12103. }
  12104. }
  12105. }
  12106. return $waste;
  12107. }
  12108. function lyt() {
  12109. Doo::loadModel ( "receiptDetail" );
  12110. $receiptDetail = new receiptDetail ();
  12111. $receiptCollectList = $receiptDetail->find ( array (
  12112. 'where' => 'status=1 ',
  12113. 'asArray' => true
  12114. ) );
  12115. foreach ( $receiptCollectList as $key => $value ) {
  12116. $receiptDetail = new receiptDetail ();
  12117. $receiptDetail->pastDate = $value ['date'];
  12118. $receiptDetail->update ( array (
  12119. 'where' => "rdid= '" . $value ['rdid'] . "'"
  12120. ) );
  12121. }
  12122. }
  12123. function staffCollectMonthDetail() {
  12124. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12125. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12126. if (! $year)
  12127. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12128. if (! $month)
  12129. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12130. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  12131. if (! $nature){
  12132. $nature = isset ( $this->params ['nature'] ) ? $this->params ['nature'] : 'ONJOB';
  12133. }
  12134. Doo::loadModel ( 'staff' );
  12135. $staff = new staff ();
  12136. Doo::loadModel ( "receiptDetail" );
  12137. $receiptDetail = new receiptDetail ();
  12138. Doo::loadModel ( 'accountItem' );
  12139. $accountItem = new accountItem ();
  12140. Doo::loadModel ( 'statistics' );
  12141. $statistics = new statistics ();
  12142. Doo::loadModel ( 'L_category' );
  12143. $lCategory = new L_category ();
  12144. Doo::loadModel ( "receiptAuthorityManage" );
  12145. $receiptAuthorityManage = new receiptAuthorityManage ();
  12146. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  12147. $cidList = array ();
  12148. foreach ( $imcStaff as $key => $value ) {
  12149. array_push ( $cidList, $value ['cid'] );
  12150. }
  12151. $cidString = implode ( ',', $cidList );
  12152. $naturecon='';
  12153. if ($nature=='ONJOB'){
  12154. $naturecon=' and (nature!=4 )';
  12155. }elseif($nature=='LEAVEJOB'){
  12156. $naturecon=' and (nature=4 )';
  12157. }else{
  12158. die ( 'illegal request--nature' );
  12159. }
  12160. $staffList = $staff->find ( array (
  12161. 'where' => 'username!="admin" and cid in (' . $cidString . ')'.$naturecon,
  12162. 'asArray' => true
  12163. ) );
  12164. $categoryList = $staff->find ( array (
  12165. 'select' => 'COUNT(*) as count,cid,category',
  12166. 'where' => 'username !="admin" and cid in (' . $cidString . ')'.$naturecon,
  12167. 'groupby' => 'cid',
  12168. 'asArray' => true
  12169. ) );
  12170. $list = array ();
  12171. foreach ( $categoryList as $vlu ) {
  12172. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  12173. $r1 = 0;
  12174. $r2 = 0;
  12175. $r3 = 0;
  12176. $r4 = 0;
  12177. $r5 = 0;
  12178. $r6 = 0;
  12179. $r7 = 0;
  12180. $r8 = 0;
  12181. $r9 = 0;
  12182. $r10 = 0;
  12183. $r11 = 0;
  12184. $r12 = 0;
  12185. $r13 = 0;
  12186. $r14 = 0;
  12187. $r15 = 0;
  12188. $r16 = 0;
  12189. $r17 = 0;
  12190. $r18 = 0;
  12191. $c1 = 0;
  12192. $c2 = 0;
  12193. $c3 = 0;
  12194. $c4 = 0;
  12195. $c5 = 0;
  12196. $c6 = 0;
  12197. $p1 = 0;
  12198. $p2 = 0;
  12199. $p3 = 0;
  12200. $p4 = 0;
  12201. $p5 = 0;
  12202. $p6 = 0;
  12203. $p7 = 0;
  12204. $p8 = 0;
  12205. $p9 = 0;
  12206. $p10 = 0;
  12207. $p11 = 0;
  12208. $t1 = 0;
  12209. $t2 = 0;
  12210. $t3 = 0;
  12211. $t4 = 0;
  12212. $t5 = 0;
  12213. $s1 = 0;
  12214. $m1 = 0;
  12215. foreach ( $staffList as $value ) {
  12216. if ($vlu ['cid'] == $value ['cid']) {
  12217. // pastDate
  12218. $receiptCollectList = $receiptDetail->find ( array (
  12219. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12220. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12221. 'groupby' => 'item,Month(pastDate),itemCategory',
  12222. 'asArray' => true
  12223. ) );
  12224. // if ($value['sid']==42){
  12225. // print_r($receiptCollectList);die;
  12226. // }
  12227. if (! empty ( $receiptCollectList )) {
  12228. $receiptL = array (
  12229. '日常相关费用' => array (),
  12230. '差旅相关费用' => array (),
  12231. '培训班费用' => array (),
  12232. '其他' => array ()
  12233. );
  12234. $html = "";
  12235. $psum = 0;
  12236. $item = array (
  12237. '市内交通费',
  12238. '市内出租费',
  12239. '办事处房租',
  12240. '电话费',
  12241. '水费',
  12242. '电费',
  12243. '办公费用',
  12244. '邮寄费',
  12245. '其他费用',
  12246. '车辆费用',
  12247. '广告费',
  12248. '团队建设费',
  12249. '物业管理费',
  12250. '宽带费',
  12251. '人员薪酬',
  12252. '公积金',
  12253. '社保'
  12254. );
  12255. foreach ( $item as $va ) {
  12256. $falg = true;
  12257. foreach ( $receiptCollectList as $v ) {
  12258. if ($v ['itemCategory'] == '日常相关费用') {
  12259. if ($v ['item'] == $va) {
  12260. if ($va == '市内交通费')
  12261. $r1 += $v ['price'];
  12262. if ($va == '市内出租费')
  12263. $r2 += $v ['price'];
  12264. if ($va == '办事处房租')
  12265. $r3 += $v ['price'];
  12266. if ($va == '电话费')
  12267. $r4 += $v ['price'];
  12268. if ($va == '水费')
  12269. $r5 += $v ['price'];
  12270. if ($va == '电费')
  12271. $r6 += $v ['price'];
  12272. if ($va == '办公费用')
  12273. $r7 += $v ['price'];
  12274. if ($va == '邮寄费')
  12275. $r8 += $v ['price'];
  12276. if ($va == '其他费用')
  12277. $r9 += $v ['price'];
  12278. if ($va == '车辆费用')
  12279. $r10 += $v ['price'];
  12280. if ($va == '广告费')
  12281. $r11 += $v ['price'];
  12282. if ($va == '团队建设费')
  12283. $r13 += $v ['price'];
  12284. if ($va == '物业管理费')
  12285. $r14 += $v ['price'];
  12286. if ($va == '宽带费')
  12287. $r15 += $v ['price'];
  12288. if ($va == '公积金')
  12289. $r16 += $v ['price'];
  12290. if ($va == '社保')
  12291. $r17 += $v ['price'];
  12292. if ($va == '人员薪酬')
  12293. $r18 += $v ['price'];
  12294. $psum += $v ['price'];
  12295. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12296. $falg = false;
  12297. break;
  12298. }
  12299. }
  12300. }
  12301. if ($falg)
  12302. $html .= '<td class="taR">-</td>';
  12303. }
  12304. $r12 += $psum;
  12305. if (! empty ( $psum ))
  12306. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12307. else
  12308. $psum = '<td class="colGreen taR">-</td>';
  12309. $receiptL ['日常相关费用'] = $psum . $html;
  12310. /* ----------------------------------- */
  12311. $html = "";
  12312. $psum = 0;
  12313. $item = array (
  12314. '往来交通费',
  12315. '市内交通费',
  12316. '出差住宿费',
  12317. '出差补助',
  12318. '其他费用'
  12319. );
  12320. foreach ( $item as $va ) {
  12321. $falg = true;
  12322. foreach ( $receiptCollectList as $v ) {
  12323. if ($v ['itemCategory'] == '差旅相关费用') {
  12324. if ($v ['item'] == $va) {
  12325. if ($va == '往来交通费')
  12326. $c1 += $v ['price'];
  12327. if ($va == '市内交通费')
  12328. $c2 += $v ['price'];
  12329. if ($va == '出差住宿费')
  12330. $c3 += $v ['price'];
  12331. if ($va == '出差补助')
  12332. $c4 += $v ['price'];
  12333. if ($va == '其他费用')
  12334. $c5 += $v ['price'];
  12335. $psum += $v ['price'];
  12336. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12337. $falg = false;
  12338. break;
  12339. }
  12340. }
  12341. }
  12342. if ($falg)
  12343. $html .= '<td class="taR">-</td>';
  12344. }
  12345. $c6 += $psum;
  12346. if (! empty ( $psum ))
  12347. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12348. else
  12349. $psum = '<td class="colGreen taR">-</td>';
  12350. $receiptL ['差旅相关费用'] = $psum . $html;
  12351. /* ------------------------------------- */
  12352. $html = "";
  12353. $psum = 0;
  12354. $item = array (
  12355. '场租费',
  12356. '薪酬',
  12357. '住宿费',
  12358. '交通费',
  12359. '餐饮费',
  12360. '办公费',
  12361. '公关费',
  12362. '其他',
  12363. '电话费',
  12364. '邮寄费'
  12365. );
  12366. foreach ( $item as $va ) {
  12367. $falg = true;
  12368. foreach ( $receiptCollectList as $v ) {
  12369. if ($v ['itemCategory'] == '培训班费用') {
  12370. if ($v ['item'] == $va) {
  12371. if ($va == '场租费')
  12372. $p1 += $v ['price'];
  12373. if ($va == '薪酬')
  12374. $p2 += $v ['price'];
  12375. if ($va == '住宿费')
  12376. $p3 += $v ['price'];
  12377. if ($va == '交通费')
  12378. $p4 += $v ['price'];
  12379. if ($va == '餐饮费')
  12380. $p5 += $v ['price'];
  12381. if ($va == '办公费')
  12382. $p6 += $v ['price'];
  12383. if ($va == '公关费')
  12384. $p7 += $v ['price'];
  12385. if ($va == '其他')
  12386. $p8 += $v ['price'];
  12387. if ($va == '电话费')
  12388. $p9 += $v ['price'];
  12389. if ($va == '邮寄费')
  12390. $p10 += $v ['price'];
  12391. $psum += $v ['price'];
  12392. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12393. $falg = false;
  12394. break;
  12395. }
  12396. }
  12397. }
  12398. if ($falg)
  12399. $html .= '<td class="taR">-</td>';
  12400. }
  12401. $p11 += $psum;
  12402. if (! empty ( $psum ))
  12403. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12404. else
  12405. $psum = '<td class="colGreen taR">-</td>';
  12406. $receiptL ['培训班费用'] = $psum . $html;
  12407. /* ------------------------------------- */
  12408. $html = "";
  12409. $psum = 0;
  12410. $item = array (
  12411. '公关费',
  12412. '广告费',
  12413. '借款',
  12414. '可自加费用'
  12415. );
  12416. foreach ( $item as $va ) {
  12417. $falg = true;
  12418. foreach ( $receiptCollectList as $v ) {
  12419. if ($v ['itemCategory'] == '其他') {
  12420. // if ($value['sid']==42){
  12421. //
  12422. // echo var_dump($v['item']);
  12423. // echo var_dump($va);
  12424. // echo var_dump($v['item']==" ".$va);
  12425. // echo $v['item']."==".$va."/<br/>";
  12426. // //print_r( $receiptCollectList);//echo $va;
  12427. // }
  12428. if (trim ( $v ['item'] ) == $va) {
  12429. if ($va == '公关费')
  12430. $t1 += $v ['price'];
  12431. if ($va == '广告费') {
  12432. $t2 += $v ['price'];
  12433. }
  12434. if ($va == '借款')
  12435. $t3 += $v ['price'];
  12436. if ($va == '可自加费用')
  12437. $t4 += $v ['price'];
  12438. $psum += $v ['price'];
  12439. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12440. $falg = false;
  12441. break;
  12442. }
  12443. }
  12444. }
  12445. if ($falg)
  12446. $html .= '<td class="taR">-</td>';
  12447. }
  12448. $t5 += $psum;
  12449. if (! empty ( $psum ))
  12450. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12451. else
  12452. $psum = '<td class="colGreen taR">-</td>';
  12453. $receiptL ['其他'] = $psum . $html;
  12454. /* ------------------------------------- */
  12455. $html = "";
  12456. $psum = 0;
  12457. foreach ( $receiptCollectList as $v ) {
  12458. if ($v ['itemCategory'] == '报销金额调整') {
  12459. if (! empty ( $v ['price'] )) {
  12460. $psum += $v ['price'];
  12461. }
  12462. }
  12463. }
  12464. $s1 += $psum;
  12465. if (! empty ( $psum ))
  12466. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  12467. else
  12468. $psum = '<td class="taR colOrange">-</td>';
  12469. $receiptL ['报销金额调整'] = $psum . $html;
  12470. } else {
  12471. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  12472. <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>
  12473. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12474. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  12475. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12476. $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>
  12477. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12478. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12479. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  12480. }
  12481. $monthStaffPrice = $receiptDetail->find ( array (
  12482. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12483. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12484. 'groupby' => 'Month(pastDate)',
  12485. 'asArray' => true
  12486. ) );
  12487. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  12488. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  12489. $m1 += $monthStaffPrice [0] ['price'];
  12490. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  12491. } else
  12492. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  12493. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  12494. $list [$value ['username']] = $receiptL;
  12495. }
  12496. }
  12497. $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>
  12498. <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>
  12499. <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>';
  12500. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  12501. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  12502. $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>
  12503. <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>';
  12504. $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>';
  12505. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  12506. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  12507. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  12508. }
  12509. $data ['list'] = $list;
  12510. // print_r($list);
  12511. $receiptCollectList = $receiptDetail->find ( array (
  12512. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12513. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12514. 'groupby' => 'item,Month(pastDate),itemCategory',
  12515. 'asArray' => true
  12516. ) );
  12517. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  12518. // statistics html
  12519. $stList = $statistics->getOne ( array (
  12520. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  12521. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  12522. 'groupby' => 'Month(date)',
  12523. 'asArray' => true
  12524. ) );
  12525. if (empty ( $stList ))
  12526. $stList = array (
  12527. 'rePrice' => 0,
  12528. 'agPrice' => 0
  12529. );
  12530. $data ['stList'] = array (
  12531. 'rePrice' => $stList ['rePrice'],
  12532. 'agPrice' => $stList ['agPrice'],
  12533. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12534. );
  12535. $monthHtml = "";
  12536. for($i = 1; $i <= 12; $i ++) {
  12537. if ($i == $month)
  12538. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  12539. else
  12540. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  12541. }
  12542. $data ['monthHtml'] = $monthHtml;
  12543. $data ['year'] = $year;
  12544. $data ['month'] = $month;
  12545. $data ['nature'] = $nature;
  12546. $data ['memu'] = "receipt";
  12547. $data ['staff'] = $this->staff;
  12548. $data ['receiptMemu'] = 'companyCategoryCollect';
  12549. $data ['verifyId'] = $this->verifyId;
  12550. $data ['executeId'] = $this->executeId;
  12551. $this->render ( "/admin/staffCollectMonthDetail", $data );
  12552. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  12553. }
  12554. function staffCollectMonthDetail2() {
  12555. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12556. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12557. if (! $year)
  12558. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12559. if (! $month)
  12560. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12561. Doo::loadModel ( 'staff' );
  12562. $staff = new staff ();
  12563. Doo::loadModel ( "receiptDetail" );
  12564. $receiptDetail = new receiptDetail ();
  12565. Doo::loadModel ( 'accountItem' );
  12566. $accountItem = new accountItem ();
  12567. Doo::loadModel ( 'statistics' );
  12568. $statistics = new statistics ();
  12569. Doo::loadModel ( 'L_category' );
  12570. $lCategory = new L_category ();
  12571. $staffList = $staff->find ( array (
  12572. 'where' => 'username!="admin"',
  12573. 'asArray' => true
  12574. ) );
  12575. $categoryList = $staff->find ( array (
  12576. 'select' => 'COUNT(*) as count,cid,category',
  12577. 'where' => 'username !="admin"',
  12578. 'groupby' => 'cid',
  12579. 'asArray' => true
  12580. ) );
  12581. $list = array ();
  12582. foreach ( $categoryList as $vlu ) {
  12583. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  12584. $r1 = 0;
  12585. $r2 = 0;
  12586. $r3 = 0;
  12587. $r4 = 0;
  12588. $r5 = 0;
  12589. $r6 = 0;
  12590. $r7 = 0;
  12591. $r8 = 0;
  12592. $r9 = 0;
  12593. $r10 = 0;
  12594. $r11 = 0;
  12595. $r12 = 0;
  12596. $r13 = 0;
  12597. $r14 = 0;
  12598. $r15 = 0;
  12599. $c1 = 0;
  12600. $c2 = 0;
  12601. $c3 = 0;
  12602. $c4 = 0;
  12603. $c5 = 0;
  12604. $c6 = 0;
  12605. $p1 = 0;
  12606. $p2 = 0;
  12607. $p3 = 0;
  12608. $p4 = 0;
  12609. $p5 = 0;
  12610. $p6 = 0;
  12611. $p7 = 0;
  12612. $p8 = 0;
  12613. $p9 = 0;
  12614. $t1 = 0;
  12615. $t2 = 0;
  12616. $t3 = 0;
  12617. $t4 = 0;
  12618. $t5 = 0;
  12619. $s1 = 0;
  12620. $m1 = 0;
  12621. foreach ( $staffList as $value ) {
  12622. if ($vlu ['cid'] == $value ['cid']) {
  12623. $receiptCollectList = $receiptDetail->find ( array (
  12624. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  12625. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  12626. 'groupby' => 'item,Month(date),itemCategory',
  12627. 'asArray' => true
  12628. ) );
  12629. if (! empty ( $receiptCollectList )) {
  12630. $receiptL = array (
  12631. '日常相关费用' => array (),
  12632. '差旅相关费用' => array (),
  12633. '培训班费用' => array (),
  12634. '其他' => array ()
  12635. );
  12636. $html = "";
  12637. $psum = 0;
  12638. $item = array (
  12639. '市内交通费',
  12640. '市内出租费',
  12641. '办事处房租',
  12642. '电话费',
  12643. '水费',
  12644. '电费',
  12645. '办公费用',
  12646. '邮寄费',
  12647. '其他费用',
  12648. '车辆费用',
  12649. '广告费',
  12650. '团队建设费',
  12651. '物业管理费',
  12652. '宽带费'
  12653. );
  12654. foreach ( $item as $va ) {
  12655. $falg = true;
  12656. foreach ( $receiptCollectList as $v ) {
  12657. if ($v ['itemCategory'] == '日常相关费用') {
  12658. if ($v ['item'] == $va) {
  12659. if ($va == '市内交通费')
  12660. $r1 += $v ['price'];
  12661. if ($va == '市内出租费')
  12662. $r2 += $v ['price'];
  12663. if ($va == '办事处房租')
  12664. $r3 += $v ['price'];
  12665. if ($va == '电话费')
  12666. $r4 += $v ['price'];
  12667. if ($va == '水费')
  12668. $r5 += $v ['price'];
  12669. if ($va == '电费')
  12670. $r6 += $v ['price'];
  12671. if ($va == '办公费用')
  12672. $r7 += $v ['price'];
  12673. if ($va == '邮寄费')
  12674. $r8 += $v ['price'];
  12675. if ($va == '其他费用')
  12676. $r9 += $v ['price'];
  12677. if ($va == '车辆费用')
  12678. $r10 += $v ['price'];
  12679. if ($va == '广告费')
  12680. $r11 += $v ['price'];
  12681. if ($va == '团队建设费')
  12682. $r13 += $v ['price'];
  12683. if ($va == '物业管理费')
  12684. $r14 += $v ['price'];
  12685. if ($va == '宽带费')
  12686. $r15 += $v ['price'];
  12687. $psum += $v ['price'];
  12688. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12689. $falg = false;
  12690. break;
  12691. }
  12692. }
  12693. }
  12694. if ($falg)
  12695. $html .= '<td class="taR">-</td>';
  12696. }
  12697. $r12 += $psum;
  12698. if (! empty ( $psum ))
  12699. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12700. else
  12701. $psum = '<td class="colGreen taR">-</td>';
  12702. $receiptL ['日常相关费用'] = $psum . $html;
  12703. /* ----------------------------------- */
  12704. $html = "";
  12705. $psum = 0;
  12706. $item = array (
  12707. '往来交通费',
  12708. '市内交通费',
  12709. '出差住宿费',
  12710. '出差补助',
  12711. '其他费用'
  12712. );
  12713. foreach ( $item as $va ) {
  12714. $falg = true;
  12715. foreach ( $receiptCollectList as $v ) {
  12716. if ($v ['itemCategory'] == '差旅相关费用') {
  12717. if ($v ['item'] == $va) {
  12718. if ($va == '往来交通费')
  12719. $c1 += $v ['price'];
  12720. if ($va == '市内交通费')
  12721. $c2 += $v ['price'];
  12722. if ($va == '出差住宿费')
  12723. $c3 += $v ['price'];
  12724. if ($va == '出差补助')
  12725. $c4 += $v ['price'];
  12726. if ($va == '其他费用')
  12727. $c5 += $v ['price'];
  12728. $psum += $v ['price'];
  12729. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12730. $falg = false;
  12731. break;
  12732. }
  12733. }
  12734. }
  12735. if ($falg)
  12736. $html .= '<td class="taR">-</td>';
  12737. }
  12738. $c6 += $psum;
  12739. if (! empty ( $psum ))
  12740. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12741. else
  12742. $psum = '<td class="colGreen taR">-</td>';
  12743. $receiptL ['差旅相关费用'] = $psum . $html;
  12744. /* ------------------------------------- */
  12745. $html = "";
  12746. $psum = 0;
  12747. $item = array (
  12748. '场租费',
  12749. '薪酬',
  12750. '住宿费',
  12751. '交通费',
  12752. '餐饮费',
  12753. '办公费',
  12754. '公关费',
  12755. '其他'
  12756. );
  12757. foreach ( $item as $va ) {
  12758. $falg = true;
  12759. foreach ( $receiptCollectList as $v ) {
  12760. if ($v ['itemCategory'] == '培训班费用') {
  12761. if ($v ['item'] == $va) {
  12762. if ($va == '场租费')
  12763. $p1 += $v ['price'];
  12764. if ($va == '薪酬')
  12765. $p2 += $v ['price'];
  12766. if ($va == '住宿费')
  12767. $p3 += $v ['price'];
  12768. if ($va == '交通费')
  12769. $p4 += $v ['price'];
  12770. if ($va == '餐饮费')
  12771. $p5 += $v ['price'];
  12772. if ($va == '办公费')
  12773. $p6 += $v ['price'];
  12774. if ($va == '公关费')
  12775. $p7 += $v ['price'];
  12776. if ($va == '其他')
  12777. $p8 += $v ['price'];
  12778. $psum += $v ['price'];
  12779. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12780. $falg = false;
  12781. break;
  12782. }
  12783. }
  12784. }
  12785. if ($falg)
  12786. $html .= '<td class="taR">-</td>';
  12787. }
  12788. $p9 += $psum;
  12789. if (! empty ( $psum ))
  12790. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12791. else
  12792. $psum = '<td class="colGreen taR">-</td>';
  12793. $receiptL ['培训班费用'] = $psum . $html;
  12794. /* ------------------------------------- */
  12795. $html = "";
  12796. $psum = 0;
  12797. $item = array (
  12798. '公关费',
  12799. '广告费',
  12800. '借款',
  12801. '可自加费用'
  12802. );
  12803. foreach ( $item as $va ) {
  12804. $falg = true;
  12805. foreach ( $receiptCollectList as $v ) {
  12806. if ($v ['itemCategory'] == '其他') {
  12807. if ($v ['item'] == $va) {
  12808. if ($va == '公关费')
  12809. $t1 += $v ['price'];
  12810. if ($va == '广告费')
  12811. $t2 += $v ['price'];
  12812. if ($va == '借款')
  12813. $t3 += $v ['price'];
  12814. if ($va == '可自加费用')
  12815. $t4 += $v ['price'];
  12816. $psum += $v ['price'];
  12817. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12818. $falg = false;
  12819. break;
  12820. }
  12821. }
  12822. }
  12823. if ($falg)
  12824. $html .= '<td class="taR">-</td>';
  12825. }
  12826. $t5 += $psum;
  12827. if (! empty ( $psum ))
  12828. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12829. else
  12830. $psum = '<td class="colGreen taR">-</td>';
  12831. $receiptL ['其他'] = $psum . $html;
  12832. /* ------------------------------------- */
  12833. $html = "";
  12834. $psum = 0;
  12835. foreach ( $receiptCollectList as $v ) {
  12836. if ($v ['itemCategory'] == '报销金额调整') {
  12837. if (! empty ( $v ['price'] )) {
  12838. $psum += $v ['price'];
  12839. }
  12840. }
  12841. }
  12842. $s1 += $psum;
  12843. if (! empty ( $psum ))
  12844. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  12845. else
  12846. $psum = '<td class="taR colOrange">-</td>';
  12847. $receiptL ['报销金额调整'] = $psum . $html;
  12848. } else {
  12849. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  12850. <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>';
  12851. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  12852. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12853. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  12854. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12855. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12856. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  12857. }
  12858. $monthStaffPrice = $receiptDetail->find ( array (
  12859. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  12860. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  12861. 'asArray' => true
  12862. ) );
  12863. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  12864. $m1 += $monthStaffPrice [0] ['price'];
  12865. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  12866. } else
  12867. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  12868. $list [$value ['username']] = $receiptL;
  12869. }
  12870. }
  12871. $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>
  12872. <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>
  12873. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  12874. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  12875. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  12876. $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>
  12877. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  12878. $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>';
  12879. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  12880. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  12881. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  12882. }
  12883. $data ['list'] = $list;
  12884. $receiptCollectList = $receiptDetail->find ( array (
  12885. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  12886. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  12887. 'groupby' => 'item,Month(date),itemCategory',
  12888. 'asArray' => true
  12889. ) );
  12890. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  12891. // statistics html
  12892. $stList = $statistics->getOne ( array (
  12893. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  12894. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  12895. 'groupby' => 'Month(date)',
  12896. 'asArray' => true
  12897. ) );
  12898. if (empty ( $stList ))
  12899. $stList = array (
  12900. 'rePrice' => 0,
  12901. 'agPrice' => 0
  12902. );
  12903. $data ['stList'] = array (
  12904. 'rePrice' => $stList ['rePrice'],
  12905. 'agPrice' => $stList ['agPrice'],
  12906. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12907. );
  12908. $monthHtml = "";
  12909. for($i = 1; $i <= 12; $i ++) {
  12910. if ($i == $month)
  12911. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  12912. else
  12913. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  12914. }
  12915. $data ['monthHtml'] = $monthHtml;
  12916. $data ['year'] = $year;
  12917. $data ['month'] = $month;
  12918. $data ['memu'] = "receipt";
  12919. $data ['staff'] = $this->staff;
  12920. $data ['receiptMemu'] = 'companyCategoryCollect';
  12921. $data ['verifyId'] = $this->verifyId;
  12922. $data ['executeId'] = $this->executeId;
  12923. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  12924. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  12925. }
  12926. /**
  12927. * 用户报销单列表
  12928. */
  12929. function receiptStatisticsStaffDetail() {
  12930. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12931. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12932. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  12933. Doo::loadModel ( "receipt" );
  12934. $receipt = new receipt ();
  12935. Doo::loadModel ( "receiptDetail" );
  12936. $receiptDetail = new receiptDetail ();
  12937. Doo::loadModel ( 'staff' );
  12938. $staff = new staff ();
  12939. Doo::loadModel ( 'accountItem' );
  12940. $accountItem = new accountItem ();
  12941. Doo::loadModel ( 'statistics' );
  12942. $statistics = new statistics ();
  12943. if (! empty ( $username )) {
  12944. $username = addslashes ( urldecode ( $username ) );
  12945. $staffDetail = $staff->getStaffByName ( $username );
  12946. if (empty ( $staffDetail ))
  12947. die ( 'illegal request' );
  12948. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  12949. $itemList = $accountItem->getAccountItem ();
  12950. $itemHtml = '';
  12951. $categoryHtml = '';
  12952. $itemKeyList = array_keys ( $itemList );
  12953. $revisePrice = 0;
  12954. // 报销单内容详情
  12955. foreach ( $list as $key => $value ) {
  12956. $accountItemList = json_decode ( $value ['accountItem'], true );
  12957. $list [$key] ['accountItemList'] = $accountItemList;
  12958. $receiptItemHtml = '';
  12959. foreach ( $itemKeyList as $v ) {
  12960. if ($v == '日常相关费用')
  12961. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  12962. elseif ($v == '差旅相关费用')
  12963. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  12964. elseif ($v == '培训班费用')
  12965. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  12966. elseif ($v == '其他')
  12967. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  12968. foreach ( $itemList [$v] as $ke => $va ) {
  12969. $falg = true;
  12970. if (! empty ( $accountItemList [$v] )) {
  12971. foreach ( $accountItemList [$v] as $ve ) {
  12972. if ($va ['name'] == $ve ['name']) {
  12973. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  12974. $falg = false;
  12975. break;
  12976. }
  12977. }
  12978. }
  12979. if ($falg)
  12980. $receiptItemHtml .= '<td class="taR"></td>';
  12981. }
  12982. }
  12983. // 金额调整和费用查看
  12984. $revisePrice += $value ['revisePrice'];
  12985. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  12986. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" id="sen'.$key.'" data="' . htmlspecialchars($value ['explanation']) . '" onclick=showExplanation() >查看</a></td>';
  12987. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  12988. }
  12989. // 报销单合计
  12990. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  12991. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  12992. $receiptTotalHtml = '';
  12993. // 报销单项目抬头
  12994. foreach ( $itemKeyList as $value ) {
  12995. $count = count ( $itemList [$value] ) + 1;
  12996. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  12997. $categoryHtml .= '<th class="taC">合计</th>';
  12998. $sumfalg=true;
  12999. foreach ( $rtl as $rtlValue ) {
  13000. if ($rtlValue ['itemCategory'] == $value) {
  13001. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  13002. $sumfalg=false;
  13003. break;
  13004. }
  13005. }
  13006. if ($sumfalg)
  13007. $receiptTotalHtml .= '<th></th>';
  13008. foreach ( $itemList [$value] as $k => $v ) {
  13009. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  13010. // 合计
  13011. $falg = true;
  13012. foreach ( $receiptTotalList as $ve ) {
  13013. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  13014. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  13015. $falg = false;
  13016. break;
  13017. }
  13018. }
  13019. if ($falg)
  13020. $receiptTotalHtml .= '<th></th>';
  13021. }
  13022. }
  13023. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  13024. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  13025. if (empty ( $stList ))
  13026. $stList = array (
  13027. 'rePrice' => 0,
  13028. 'agPrice' => 0
  13029. );
  13030. $data ['stList'] = array (
  13031. 'rePrice' => $stList ['rePrice'],
  13032. 'agPrice' => $stList ['agPrice'],
  13033. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13034. );
  13035. $monthHtml = "";
  13036. for($i = 1; $i <= 12; $i ++) {
  13037. if ($i == $month)
  13038. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13039. else
  13040. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13041. }
  13042. $data ['username'] = urlencode ( $username );
  13043. $data ['usernameEN'] = $username;
  13044. $data ['monthHtml'] = $monthHtml;
  13045. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  13046. $data ['list'] = $list;
  13047. $data ['categoryHtml'] = $categoryHtml;
  13048. $data ['itemHtml'] = $itemHtml;
  13049. $data ['itemList'] = $itemList;
  13050. $data ['year'] = $year;
  13051. $data ['month'] = $month;
  13052. $data ['memu'] = "receipt";
  13053. $data ['staff'] = $this->staff;
  13054. $data ['receiptMemu'] = 'companyCategoryCollect';
  13055. $data ['verifyId'] = $this->verifyId;
  13056. $data ['executeId'] = $this->executeId;
  13057. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  13058. }
  13059. die ( 'illegal request' );
  13060. }
  13061. function companyMonthCollectDetail() {
  13062. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13063. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13064. if (! $year)
  13065. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13066. if (! $month)
  13067. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13068. Doo::loadModel ( 'staff' );
  13069. $staff = new staff ();
  13070. Doo::loadModel ( "receiptDetail" );
  13071. $receiptDetail = new receiptDetail ();
  13072. Doo::loadModel ( 'accountItem' );
  13073. $accountItem = new accountItem ();
  13074. Doo::loadModel ( 'statistics' );
  13075. $statistics = new statistics ();
  13076. Doo::loadModel ( 'L_category' );
  13077. $lCategory = new L_category ();
  13078. $staffList = $staff->find ( array (
  13079. 'where' => 'username!="admin"',
  13080. 'asArray' => true
  13081. ) );
  13082. $categoryList = $lCategory->find ( array (
  13083. 'asArray' => true
  13084. ) );
  13085. $list = array ();
  13086. foreach ( $categoryList as $value ) {
  13087. $receiptCollectList = $receiptDetail->find ( array (
  13088. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13089. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13090. 'groupby' => 'item,Month(pastDate),itemCategory',
  13091. 'asArray' => true
  13092. ) );
  13093. if (! empty ( $receiptCollectList )) {
  13094. $receiptL = array (
  13095. '日常相关费用' => array (),
  13096. '差旅相关费用' => array (),
  13097. '培训班费用' => array (),
  13098. '其他' => array ()
  13099. );
  13100. $html = "";
  13101. $psum = 0;
  13102. $item = array (
  13103. '市内交通费',
  13104. '市内出租费',
  13105. '办事处房租',
  13106. '电话费',
  13107. '水费',
  13108. '电费',
  13109. '办公费用',
  13110. '邮寄费',
  13111. '其他费用',
  13112. '车辆费用',
  13113. '广告费',
  13114. '团队建设费'
  13115. );
  13116. foreach ( $item as $va ) {
  13117. $falg = true;
  13118. foreach ( $receiptCollectList as $v ) {
  13119. if ($v ['itemCategory'] == '日常相关费用') {
  13120. if ($v ['item'] == $va) {
  13121. $psum += $v ['price'];
  13122. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13123. $falg = false;
  13124. break;
  13125. }
  13126. }
  13127. }
  13128. if ($falg)
  13129. $html .= '<td class="taR">-</td>';
  13130. }
  13131. if (! empty ( $psum ))
  13132. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13133. else
  13134. $psum = '<td class="colGreen taR">-</td>';
  13135. $receiptL ['日常相关费用'] = $psum . $html;
  13136. /* ----------------------------------- */
  13137. $html = "";
  13138. $psum = 0;
  13139. $item = array (
  13140. '往来交通费',
  13141. '市内交通费',
  13142. '出差住宿费',
  13143. '出差补助',
  13144. '其他费用'
  13145. );
  13146. foreach ( $item as $va ) {
  13147. $falg = true;
  13148. foreach ( $receiptCollectList as $v ) {
  13149. if ($v ['itemCategory'] == '差旅相关费用') {
  13150. if ($v ['item'] == $va) {
  13151. $psum += $v ['price'];
  13152. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13153. $falg = false;
  13154. break;
  13155. }
  13156. }
  13157. }
  13158. if ($falg)
  13159. $html .= '<td class="taR">-</td>';
  13160. }
  13161. if (! empty ( $psum ))
  13162. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13163. else
  13164. $psum = '<td class="colGreen taR">-</td>';
  13165. $receiptL ['差旅相关费用'] = $psum . $html;
  13166. /* ------------------------------------- */
  13167. $html = "";
  13168. $psum = 0;
  13169. $item = array (
  13170. '场租费',
  13171. '薪酬',
  13172. '住宿费',
  13173. '交通费',
  13174. '餐饮费',
  13175. '办公费',
  13176. '公关费',
  13177. '其他'
  13178. );
  13179. foreach ( $item as $va ) {
  13180. $falg = true;
  13181. foreach ( $receiptCollectList as $v ) {
  13182. if ($v ['itemCategory'] == '培训班费用') {
  13183. if ($v ['item'] == $va) {
  13184. $psum += $v ['price'];
  13185. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13186. $falg = false;
  13187. break;
  13188. }
  13189. }
  13190. }
  13191. if ($falg)
  13192. $html .= '<td class="taR">-</td>';
  13193. }
  13194. if (! empty ( $psum ))
  13195. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13196. else
  13197. $psum = '<td class="colGreen taR">-</td>';
  13198. $receiptL ['培训班费用'] = $psum . $html;
  13199. /* ------------------------------------- */
  13200. $html = "";
  13201. $psum = 0;
  13202. $item = array (
  13203. '公关费',
  13204. '广告费',
  13205. '借款',
  13206. '可自加费用'
  13207. );
  13208. foreach ( $item as $va ) {
  13209. $falg = true;
  13210. foreach ( $receiptCollectList as $v ) {
  13211. if ($v ['itemCategory'] == '其他') {
  13212. if ($v ['item'] == $va) {
  13213. $psum += $v ['price'];
  13214. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13215. $falg = false;
  13216. break;
  13217. }
  13218. }
  13219. }
  13220. if ($falg)
  13221. $html .= '<td class="taR">-</td>';
  13222. }
  13223. if (! empty ( $psum ))
  13224. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13225. else
  13226. $psum = '<td class="colGreen taR">-</td>';
  13227. $receiptL ['其他'] = $psum . $html;
  13228. /* ------------------------------------- */
  13229. $html = "";
  13230. $psum = 0;
  13231. foreach ( $receiptCollectList as $v ) {
  13232. if ($v ['itemCategory'] == '报销金额调整') {
  13233. if (! empty ( $v ['price'] ))
  13234. $psum += $v ['price'];
  13235. }
  13236. }
  13237. if (! empty ( $psum ))
  13238. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  13239. else
  13240. $psum = '<td class="taR colOrange">-</td>';
  13241. $receiptL ['报销金额调整'] = $psum . $html;
  13242. } else {
  13243. $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>
  13244. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13245. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  13246. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13247. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13248. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13249. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13250. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13251. }
  13252. $monthStaffPrice = $receiptDetail->find ( array (
  13253. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13254. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13255. 'asArray' => true
  13256. ) );
  13257. if (! empty ( $monthStaffPrice [0] ['price'] ))
  13258. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13259. else
  13260. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13261. $list [$value ['title']] = $receiptL;
  13262. }
  13263. $data ['list'] = $list;
  13264. $receiptCollectList = $receiptDetail->find ( array (
  13265. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13266. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13267. 'groupby' => 'item,Month(pastDate),itemCategory',
  13268. 'asArray' => true
  13269. ) );
  13270. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  13271. // print_r($data['monthPriceHtml']);
  13272. // foreach ($data['monthPriceHtml'] as $value){
  13273. // echo $value;
  13274. // }
  13275. // die;
  13276. // statistics html
  13277. $stList = $statistics->getOne ( array (
  13278. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13279. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13280. 'groupby' => 'Month(date)',
  13281. 'asArray' => true
  13282. ) );
  13283. if (empty ( $stList ))
  13284. $stList = array (
  13285. 'rePrice' => 0,
  13286. 'agPrice' => 0
  13287. );
  13288. $data ['stList'] = array (
  13289. 'rePrice' => $stList ['rePrice'],
  13290. 'agPrice' => $stList ['agPrice'],
  13291. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13292. );
  13293. $monthHtml = "";
  13294. for($i = 1; $i <= 12; $i ++) {
  13295. if ($i == $month)
  13296. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13297. else
  13298. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13299. }
  13300. $data ['monthHtml'] = $monthHtml;
  13301. $data ['year'] = $year;
  13302. $data ['month'] = $month;
  13303. $data ['memu'] = "receipt";
  13304. $data ['staff'] = $this->staff;
  13305. $data ['receiptMemu'] = 'companyCategoryCollect';
  13306. $data ['verifyId'] = $this->verifyId;
  13307. $data ['executeId'] = $this->executeId;
  13308. $this->render ( "/admin/companyMonthCollectDetail", $data );
  13309. }
  13310. function staffCollectDetail() {
  13311. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  13312. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13313. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  13314. if (! $staffname) {
  13315. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  13316. $staffname = urldecode ( $staffname );
  13317. }
  13318. Doo::loadModel ( 'staff' );
  13319. $staff = new staff ();
  13320. Doo::loadModel ( "receiptDetail" );
  13321. $receiptDetail = new receiptDetail ();
  13322. Doo::loadModel ( 'accountItem' );
  13323. $accountItem = new accountItem ();
  13324. Doo::loadModel ( 'statistics' );
  13325. $statistics = new statistics ();
  13326. Doo::loadModel ( 'L_category' );
  13327. $lCategory = new L_category ();
  13328. Doo::loadModel ( "receiptAuthorityManage" );
  13329. $receiptAuthorityManage = new receiptAuthorityManage ();
  13330. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  13331. $cidList = array ();
  13332. foreach ( $imcStaff as $key => $value ) {
  13333. array_push ( $cidList, $value ['cid'] );
  13334. }
  13335. $cidString = implode ( ',', $cidList );
  13336. $staffList = $staff->find ( array (
  13337. 'where' => ' cid in (' . $cidString . ')',
  13338. 'asArray' => true
  13339. ) );
  13340. $stHtml = '';
  13341. $stTitle = "";
  13342. $staffId = 0;
  13343. $cid = 0;
  13344. $ocid = 0;
  13345. foreach ( $staffList as $value ) {
  13346. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  13347. $stTitle = $value ['category'] . '-' . $value ['username'];
  13348. $staffId = $value ['sid'];
  13349. $cid = $value ['cid'];
  13350. $ocid = $value ['cid'];
  13351. if (! empty ( $value ['othercid'] ))
  13352. $cid = $value ['cid'] . ',' . $value ['othercid'];
  13353. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13354. } elseif ($value ['username'] != 'admin')
  13355. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13356. }
  13357. $data ['lCategoryHtml'] = $lCategory->find ( array (
  13358. 'where' => 'cid in(' . $cid . ')',
  13359. 'asArray' => true
  13360. ) );
  13361. if (empty ( $pcid ))
  13362. $pcid = $ocid;
  13363. $data ['ocid'] = $pcid;
  13364. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  13365. $this->showCache ( $path );
  13366. //
  13367. $receiptCollectList = $receiptDetail->find ( array (
  13368. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13369. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  13370. 'groupby' => 'item,Month(pastDate),itemCategory',
  13371. 'asArray' => true
  13372. ) );
  13373. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  13374. // print_r($receiptCollectList);
  13375. $accountList = $accountItem->find ( array (
  13376. 'asArray' => true
  13377. ) );
  13378. // create CollectDetail HTML
  13379. $collectHtml = array ();
  13380. foreach ( $accountList as $key => $value ) {
  13381. $html = "";
  13382. $asum = 0;
  13383. for($i = 1; $i <= 12; $i ++) {
  13384. $falg = true;
  13385. foreach ( $receiptCollectList as $v ) {
  13386. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  13387. if ($v ['item'] == '可自加费用') {
  13388. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  13389. }
  13390. $asum += $v ['price'];
  13391. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13392. $falg = false;
  13393. break;
  13394. }
  13395. }
  13396. if ($falg)
  13397. $html .= '<td class="taR">-</td>';
  13398. }
  13399. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  13400. $collectHtml [$value ['category']] [$value ['name']] = $html;
  13401. }
  13402. $data ['collectHtml'] = $collectHtml;
  13403. // print_r($collectHtml);
  13404. // create Adjustment price html
  13405. $receiptCollectList = $receiptDetail->find ( array (
  13406. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  13407. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  13408. 'groupby' => 'itemCategory,Month(pastDate)',
  13409. 'asArray' => true
  13410. ) );
  13411. $adjustment = array ();
  13412. $collectArray = array (
  13413. '日常相关费用' => array (),
  13414. '差旅相关费用' => array (),
  13415. '培训班费用' => array (),
  13416. '其他' => array ()
  13417. );
  13418. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  13419. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  13420. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  13421. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  13422. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  13423. array_push ( $collectArray ['培训班费用'], $collectHtml );
  13424. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  13425. array_push ( $collectArray ['其他'], $collectHtml );
  13426. $data ['collectArray'] = $collectArray;
  13427. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  13428. array_push ( $adjustment, $collectHtml );
  13429. $data ['adjustment'] = $adjustment;
  13430. // total price html
  13431. $collectHtml = "";
  13432. $total = 0;
  13433. for($i = 1; $i <= 12; $i ++) {
  13434. $sumPrice = 0;
  13435. foreach ( $receiptCollectList as $key => $value ) {
  13436. if ($value ['month'] == $i) {
  13437. $sumPrice += $value ['price'];
  13438. }
  13439. }
  13440. if ($sumPrice == 0)
  13441. $collectHtml .= '<td class="taR">-</td>';
  13442. else
  13443. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  13444. $total += $sumPrice;
  13445. }
  13446. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  13447. // statistics html
  13448. $stList = $statistics->statisticsByYear ( $year, $staffId );
  13449. if (empty ( $stList ))
  13450. $stList = array (
  13451. 'rePrice' => 0,
  13452. 'agPrice' => 0
  13453. );
  13454. $data ['stList'] = array (
  13455. 'rePrice' => $stList ['rePrice'],
  13456. 'agPrice' => $stList ['agPrice'],
  13457. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13458. );
  13459. $data ['totalPrice'] = $collectHtml;
  13460. $data ['totalYear'] = $total;
  13461. $data ['stHtml'] = $stHtml;
  13462. $data ['year'] = $year;
  13463. $data ['stTitle'] = $stTitle;
  13464. $data ['staffname'] = urlencode ( $staffname );
  13465. $data ['memu'] = "receipt";
  13466. $data ['staff'] = $this->staff;
  13467. $data ['receiptMemu'] = 'companyCategoryCollect';
  13468. $data ['verifyId'] = $this->verifyId;
  13469. $data ['executeId'] = $this->executeId;
  13470. if ($year < date ( "Y" )) {
  13471. Doo::loadModel ( 'receipt' );
  13472. $receipt = new receipt ();
  13473. $receiptList = $receipt->find ( array (
  13474. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  13475. 'asArray' => true
  13476. ) );
  13477. if (empty ( $receiptList )) { // generated files
  13478. ob_start ();
  13479. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13480. $this->cacheFile ( $path );
  13481. die ();
  13482. }
  13483. }
  13484. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13485. }
  13486. function BUGFLAG() {
  13487. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  13488. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  13489. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13490. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  13491. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  13492. if (empty ( $status ))
  13493. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  13494. $page_size = 12;
  13495. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  13496. $vidList = array ();
  13497. $button = 0;
  13498. Doo::loadModel ( 'verify' );
  13499. $verify = new verify ();
  13500. Doo::loadModel ( 'receipt' );
  13501. $receipt = new receipt ();
  13502. Doo::loadModel ( 'staff' );
  13503. $staff = new staff ();
  13504. Doo::loadModel ( 'L_category' );
  13505. $Lcategory = new L_category ();
  13506. $dateCondition = " and Year(date) =" . $year;
  13507. if (! empty ( $month ))
  13508. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  13509. $categoryList = $Lcategory->find ( array (
  13510. 'asArray' => true
  13511. ) );
  13512. $staffList = $staff->find ( array (
  13513. 'where' => 'cid=' . $cid,
  13514. 'asArray' => true
  13515. ) );
  13516. $cateCondition = "";
  13517. $staffCondition = "";
  13518. $approvalCondition = "";
  13519. if (! empty ( $cid ))
  13520. $cateCondition = ' and cid=' . $cid;
  13521. if (! empty ( $sid )) {
  13522. $staffCondition = ' and staff=' . $sid;
  13523. $cateCondition = "";
  13524. }
  13525. $approvalCondition = " and status=" . $status;
  13526. if ($status == 2) {
  13527. // 查找角色审批人
  13528. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  13529. }
  13530. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  13531. $approvalCondition = ' and status=2 ';
  13532. }
  13533. if ($status == 1) {
  13534. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  13535. }
  13536. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  13537. $pageinfo ['page'] = array (
  13538. 'previous' => ''
  13539. );
  13540. if ($status == 0) {
  13541. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  13542. $receiptList = $receipt->find ( array (
  13543. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  13544. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  13545. 'desc' => 'rid',
  13546. 'asArray' => true
  13547. ) );
  13548. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  13549. } else
  13550. $receiptList = $receipt->find ( array (
  13551. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  13552. 'desc' => 'rid',
  13553. 'asArray' => true
  13554. ) );
  13555. $rLRes = $receipt->find ( array (
  13556. '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,
  13557. 'desc' => 'rid',
  13558. 'asArray' => true
  13559. ) );
  13560. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  13561. // print_r($pageinfo);
  13562. $Locate = 0;
  13563. foreach ( $receiptList as $key => $value ) {
  13564. $receiptList [$key] ['Locate'] = $Locate;
  13565. $Locate ++;
  13566. $receiptList [$key] ['reviseDetail'] = array ();
  13567. if (! empty ( $value ['reviseDetail'] ))
  13568. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  13569. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  13570. $categoryDetil = $Lcategory->getOne ( array (
  13571. 'where' => 'cid=' . $value ['cid'],
  13572. 'asArray' => true
  13573. ) );
  13574. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  13575. $verifyList = $verify->getOne ( array (
  13576. 'where' => 'vid=' . $value ['verify'],
  13577. 'asArray' => true
  13578. ) );
  13579. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  13580. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  13581. foreach ( $verifyList as $k => $v ) {
  13582. // init verifyStaff
  13583. $verifyList [$k] ['date'] = "";
  13584. $verifyList [$k] ['opinion'] = "";
  13585. $verifyList [$k] ['status'] = "";
  13586. if (empty ( $verifyStaff )) {
  13587. $verifyList [$k] ['date'] = "";
  13588. $verifyList [$k] ['opinion'] = "";
  13589. if ($v [0] == $this->staff [0] ['sid']) {
  13590. $verifyList [$k] ['status'] = 4;
  13591. $button = 4;
  13592. }
  13593. } else {
  13594. $flag = true;
  13595. foreach ( $verifyStaff as $m => $u ) {
  13596. if ($v [0] == $m) {
  13597. $verifyList [$k] ['date'] = $u ['date'];
  13598. $verifyList [$k] ['opinion'] = $u ['opinion'];
  13599. $verifyList [$k] ['status'] = $u ['status'];
  13600. $flag = false;
  13601. break;
  13602. }
  13603. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  13604. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  13605. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  13606. }
  13607. if ($flag) { // 检测可编辑
  13608. if ($v [0] == $this->staff [0] ['sid']) {
  13609. $verifyList [$k] ['status'] = 4;
  13610. $button = 4;
  13611. }
  13612. }
  13613. }
  13614. }
  13615. $receiptList [$key] ['verifyList'] = $verifyList;
  13616. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  13617. 'where' => 'sid=' . $value ['staff'],
  13618. 'asArray' => true
  13619. ) );
  13620. $receiptList [$key] ['button'] = $button;
  13621. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  13622. }
  13623. // print_r($receiptList);die;
  13624. // $data['verifyDetail']=$verifyDetail;
  13625. $mothHtml = "";
  13626. for($i = 1; $i <= 12; $i ++) {
  13627. if ($month == $i)
  13628. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  13629. else
  13630. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  13631. }
  13632. $data ['mothHtml'] = $mothHtml;
  13633. $data ['page'] = $pageinfo;
  13634. $data ['receiptList'] = $receiptList;
  13635. $data ['receiptApprovalCount'] = count ( $rLRes );
  13636. $data ['status'] = $status;
  13637. $data ['year'] = $year;
  13638. $data ['categoryList'] = $categoryList;
  13639. $data ['staffList'] = $staffList;
  13640. $data ['cid'] = $cid;
  13641. $data ['sid'] = $sid;
  13642. // print_r($receiptList);
  13643. $data ['memu'] = "receipt";
  13644. $data ['staff'] = $this->staff;
  13645. $data ['receiptMemu'] = 'approvalExpenses';
  13646. $data ['verifyId'] = $this->verifyId;
  13647. $data ['executeId'] = $this->executeId;
  13648. $this->render ( "/admin/FALG", $data );
  13649. }
  13650. function ajaxGetReceiptOrder() {
  13651. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  13652. if (! empty ( $receiptOrder )) {
  13653. Doo::loadModel ( 'receipt' );
  13654. $receipt = new receipt ();
  13655. Doo::loadModel ( 'staff' );
  13656. $staff = new staff ();
  13657. $receiptInfo = $receipt->getOne ( array (
  13658. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  13659. 'asArray' => true
  13660. ) );
  13661. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  13662. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  13663. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  13664. </tbody></table><table class="table table table-bordered"><tbody>';
  13665. foreach ( $verifyStaff as $key => $value ) {
  13666. $staffInfo = $staff->getOne ( array (
  13667. 'select' => 'username',
  13668. 'where' => ' sid="' . $key . '"',
  13669. 'asArray' => true
  13670. ) );
  13671. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  13672. }
  13673. $html .= '</tbody></table></div></div>';
  13674. echo json_encode ( array (
  13675. 'status' => 1,
  13676. 'receiptHtml' => $html
  13677. ) );
  13678. die ();
  13679. }
  13680. echo json_encode ( array (
  13681. 'status' => 2,
  13682. 'receiptHtml' => ''
  13683. ) );
  13684. die ();
  13685. }
  13686. function _getMonthCollectDetail($receiptCollectList) {
  13687. if (! empty ( $receiptCollectList )) {
  13688. $receiptL = array (
  13689. '日常相关费用' => array (),
  13690. '差旅相关费用' => array (),
  13691. '培训班费用' => array (),
  13692. '其他' => array ()
  13693. );
  13694. $html = "";
  13695. $psum = 0;
  13696. $item = array (
  13697. '市内交通费',
  13698. '市内出租费',
  13699. '办事处房租',
  13700. '电话费',
  13701. '水费',
  13702. '电费',
  13703. '办公费用',
  13704. '邮寄费',
  13705. '其他费用',
  13706. '车辆费用',
  13707. '广告费',
  13708. '团队建设费',
  13709. '物业管理费',
  13710. '宽带费',
  13711. '人员薪酬',
  13712. '公积金',
  13713. '社保'
  13714. );
  13715. foreach ( $item as $value ) {
  13716. $falg = true;
  13717. foreach ( $receiptCollectList as $v ) {
  13718. if ($v ['itemCategory'] == '日常相关费用') {
  13719. if ($v ['item'] == $value) {
  13720. $psum += $v ['price'];
  13721. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13722. $falg = false;
  13723. break;
  13724. }
  13725. }
  13726. }
  13727. if ($falg)
  13728. $html .= '<td class="taR">-</td>';
  13729. }
  13730. if (! empty ( $psum ))
  13731. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13732. else
  13733. $psum = '<td class="colGreen taR">-</td>';
  13734. $receiptL ['日常相关费用'] = $psum . $html;
  13735. /* ----------------------------------- */
  13736. $html = "";
  13737. $psum = 0;
  13738. $item = array (
  13739. '往来交通费',
  13740. '市内交通费',
  13741. '出差住宿费',
  13742. '出差补助',
  13743. '其他费用'
  13744. );
  13745. foreach ( $item as $value ) {
  13746. $falg = true;
  13747. foreach ( $receiptCollectList as $v ) {
  13748. if ($v ['itemCategory'] == '差旅相关费用') {
  13749. if ($v ['item'] == $value) {
  13750. $psum += $v ['price'];
  13751. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13752. $falg = false;
  13753. break;
  13754. }
  13755. }
  13756. }
  13757. if ($falg)
  13758. $html .= '<td class="taR">-</td>';
  13759. }
  13760. if (! empty ( $psum ))
  13761. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13762. else
  13763. $psum = '<td class="colGreen taR">-</td>';
  13764. $receiptL ['差旅相关费用'] = $psum . $html;
  13765. /* ------------------------------------- */
  13766. $html = "";
  13767. $psum = 0;
  13768. $item = array (
  13769. '场租费',
  13770. '薪酬',
  13771. '住宿费',
  13772. '交通费',
  13773. '餐饮费',
  13774. '办公费',
  13775. '公关费',
  13776. '其他',
  13777. '电话费',
  13778. '邮寄费'
  13779. );
  13780. foreach ( $item as $value ) {
  13781. $falg = true;
  13782. foreach ( $receiptCollectList as $v ) {
  13783. if ($v ['itemCategory'] == '培训班费用') {
  13784. if ($v ['item'] == $value) {
  13785. $psum += $v ['price'];
  13786. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13787. $falg = false;
  13788. break;
  13789. }
  13790. }
  13791. }
  13792. if ($falg)
  13793. $html .= '<td class="taR">-</td>';
  13794. }
  13795. if (! empty ( $psum ))
  13796. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13797. else
  13798. $psum = '<td class="colGreen taR">-</td>';
  13799. $receiptL ['培训班费用'] = $psum . $html;
  13800. /* ------------------------------------- */
  13801. $html = "";
  13802. $psum = 0;
  13803. $item = array (
  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. foreach ( $receiptCollectList as $v ) {
  13833. if ($v ['itemCategory'] == '报销金额调整') {
  13834. if (! empty ( $v ['price'] ))
  13835. $psum += $v ['price'];
  13836. }
  13837. }
  13838. if (! empty ( $psum ))
  13839. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  13840. else
  13841. $psum = '<td class="taR colOrange">-</td>';
  13842. $receiptL ['报销金额调整'] = $psum . $html;
  13843. } else {
  13844. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td>
  13845. <td class="taR">-</td>
  13846. <td class="taR">-</td>
  13847. <td class="taR">-</td>
  13848. <td class="taR">-</td>
  13849. <td class="taR">-</td>
  13850. <td class="taR">-</td>
  13851. <td class="taR">-</td>
  13852. <td class="taR">-</td>
  13853. <td class="taR">-</td>
  13854. <td class="taR">-</td>
  13855. <td class="taR">-</td>
  13856. <td class="taR">-</td>';
  13857. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  13858. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13859. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td>
  13860. <td class="taR">-</td>
  13861. <td class="taR">-</td>
  13862. <td class="taR">-</td>
  13863. <td class="taR">-</td>
  13864. <td class="taR">-</td>
  13865. <td class="taR">-</td>
  13866. <td class="taR">-</td>
  13867. <td class="taR">-</td>';
  13868. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13869. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13870. }
  13871. return $receiptL;
  13872. }
  13873. function eMail() {
  13874. Doo::loadModel ( 'staff' );
  13875. $staff = new staff ();
  13876. Doo::loadModel ( 'receipt' );
  13877. $receipt = new receipt ();
  13878. Doo::loadModel ( 'L_category' );
  13879. $Lcategory = new L_category ();
  13880. Doo::loadModel ( "verify" );
  13881. $verify = new verify ();
  13882. $staffList = $staff->find ( array (
  13883. 'asArray' => true
  13884. ) );
  13885. foreach ( $staffList as $key => $value ) {
  13886. if ($value ['username'] != 'admin') {
  13887. // 提交人
  13888. $receiptList = $receipt->find ( array (
  13889. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  13890. 'asArray' => true
  13891. ) );
  13892. if (! empty ( $receiptList )) {
  13893. $html = '<br><div><style></style>
  13894. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  13895. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  13896. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  13897. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  13898. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  13899. <tbody><tr>
  13900. <td style="padding: 0 40px;" align="left">
  13901. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  13902. </td></tr><tr>
  13903. <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>
  13904. </tr>
  13905. </tbody> </table></td> </tr> <tr><td>
  13906. <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">
  13907. <tbody> <tr><td>
  13908. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  13909. 以下报销单完成了审批,等着收款吧:</p>
  13910. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  13911. foreach ( $receiptList as $k => $v ) {
  13912. $category = $Lcategory->getOne ( array (
  13913. 'where' => 'cid=' . $v ['cid'],
  13914. 'asArray' => true
  13915. ) );
  13916. $html .= '
  13917. <tr>
  13918. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  13919. <td align="left">
  13920. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  13921. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  13922. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  13923. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  13924. </tr>';
  13925. }
  13926. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  13927. <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>
  13928. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  13929. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  13930. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  13931. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  13932. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  13933. $receipt = new receipt ();
  13934. $receipt->notice = 1;
  13935. $receipt->update ( array (
  13936. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  13937. ) );
  13938. }
  13939. }
  13940. // 审批人
  13941. $verifyList = $verify->find ( array (
  13942. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  13943. 'asArray' => true
  13944. ) );
  13945. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  13946. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  13947. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  13948. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  13949. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  13950. <tbody><tr><td style="padding: 0 40px;" align="left">
  13951. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  13952. </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>
  13953. </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">
  13954. <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>
  13955. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  13956. foreach ( $verifyList as $k => $v ) {
  13957. $receiptList = $receipt->find ( array (
  13958. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  13959. 'asArray' => true
  13960. ) );
  13961. foreach ( $receiptList as $r => $l ) {
  13962. $category = $Lcategory->getOne ( array (
  13963. 'where' => 'cid=' . $l ['cid'],
  13964. 'asArray' => true
  13965. ) );
  13966. $staffDetile = $staff->getOne ( array (
  13967. 'where' => 'sid=' . $l ['staff'],
  13968. 'asArray' => true
  13969. ) );
  13970. $html .= '
  13971. <tr>
  13972. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  13973. <td align="left">
  13974. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  13975. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  13976. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  13977. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  13978. </tr>';
  13979. }
  13980. }
  13981. $html .= '
  13982. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  13983. <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>
  13984. </tr></tbody></table></td></tr></tbody></table></div><br>';
  13985. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  13986. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  13987. // $receipt=new receipt();
  13988. // $receipt->notice=1;
  13989. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  13990. }
  13991. }
  13992. }
  13993. }
  13994. function setWXMsg($rid, $type) {
  13995. Doo::loadModel ( "receipt" );
  13996. $receipt = new receipt ();
  13997. $receiptDetail = $receipt->getOne ( array (
  13998. 'where' => 'rid=' . $rid,
  13999. 'asArray' => true
  14000. ) );
  14001. if (! empty ( $receiptDetail )) {
  14002. Doo::loadModel ( 'staff' );
  14003. $staff = new staff ();
  14004. $staffmsg = $staff->getOne ( array (
  14005. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  14006. 'asArray' => TRUE
  14007. ) );
  14008. if (! empty ( $staffmsg ['wxid'] )) {
  14009. require_once (SITE_PATH . '/protected/class/client.php');
  14010. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  14011. $user = $staffmsg ['wxid'];
  14012. $receiptName = '';
  14013. $msg = '';
  14014. switch ($receiptDetail ['Rtype']) {
  14015. case 0 :
  14016. $receiptName = '报销';
  14017. break;
  14018. case 1 :
  14019. $receiptName = '借款';
  14020. break;
  14021. case 2 :
  14022. $receiptName = '对公汇款';
  14023. break;
  14024. }
  14025. switch ($type) {
  14026. case 1 :
  14027. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  14028. break;
  14029. case 2 :
  14030. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  14031. break;
  14032. case 3 :
  14033. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  14034. break;
  14035. }
  14036. // $result = $client->SendMsg ( $user, $msg, 'text' );
  14037. }
  14038. }
  14039. }
  14040. // Email发送函数
  14041. function SMail($toemail, $subject, $contents) {
  14042. Doo::loadClass ( 'class.phpmailer' );
  14043. $mail = new PHPMailer ();
  14044. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  14045. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  14046. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  14047. $mail->Password = "cDO1GjtY1seH"; // 密码
  14048. $mail->CharSet = "UTF8";
  14049. $mail->SMTPAuth = true;
  14050. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  14051. $mail->Mailer = "smtp";
  14052. $mail->Port = 25;
  14053. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  14054. $mail->MsgHTML ( $contents );
  14055. $mail->AddAddress ( $toemail );
  14056. $mail->CharSet = "UTF-8";
  14057. return $mail->Send ();
  14058. }
  14059. function h5Upload() {
  14060. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14061. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14062. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14063. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14064. header ( "HTTP/1.1 500 Internal Server Error" );
  14065. echo "POST exceeded maximum allowed size.";
  14066. exit ( 0 );
  14067. }
  14068. // Settings
  14069. $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)
  14070. $upload_name = "Filedata";
  14071. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14072. $extension_whitelist = array (
  14073. "doc",
  14074. "txt",
  14075. "jpg",
  14076. "gif",
  14077. "png"
  14078. ); // Allowed file extensions
  14079. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14080. // Other variables
  14081. $MAX_FILENAME_LENGTH = 260;
  14082. $file_name = "";
  14083. $file_extension = "";
  14084. $uploadErrors = array (
  14085. 0 => "文件上传成功",
  14086. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14087. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14088. 3 => "上传的文件仅为部分文件",
  14089. 4 => "没有文件上传",
  14090. 6 => "缺少临时文件夹"
  14091. );
  14092. $nk = time ();
  14093. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14094. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14095. echo "文件无法保存.";
  14096. exit ( 0 );
  14097. }
  14098. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14099. echo json_encode ( array (
  14100. 'filename' => $file_name,
  14101. 'id' => $nk
  14102. ) );
  14103. exit ( 0 );
  14104. }
  14105. function swfupload() {
  14106. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14107. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14108. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14109. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14110. header ( "HTTP/1.1 500 Internal Server Error" );
  14111. echo "POST exceeded maximum allowed size.";
  14112. exit ( 0 );
  14113. }
  14114. // Settings
  14115. $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)
  14116. $upload_name = "Filedata";
  14117. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14118. $extension_whitelist = array (
  14119. "doc",
  14120. "txt",
  14121. "jpg",
  14122. "gif",
  14123. "png"
  14124. ); // Allowed file extensions
  14125. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14126. // Other variables
  14127. $MAX_FILENAME_LENGTH = 260;
  14128. $file_name = "";
  14129. $file_extension = "";
  14130. $uploadErrors = array (
  14131. 0 => "文件上传成功",
  14132. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14133. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14134. 3 => "上传的文件仅为部分文件",
  14135. 4 => "没有文件上传",
  14136. 6 => "缺少临时文件夹"
  14137. );
  14138. $nk = time ();
  14139. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14140. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14141. echo "文件无法保存.";
  14142. exit ( 0 );
  14143. }
  14144. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14145. echo json_encode ( array (
  14146. 'filename' => $file_name,
  14147. 'id' => $nk
  14148. ) );
  14149. exit ( 0 );
  14150. }
  14151. function _GetFileEXT($filename) {
  14152. $pics = explode ( '.', $filename );
  14153. $num = count ( $pics );
  14154. return $pics [$num - 1];
  14155. }
  14156. /**
  14157. * 获取get或者POST值
  14158. * @param string $name 属性名称
  14159. * @return fixed 值
  14160. */
  14161. function get_args($name) {
  14162. if (isset ( $_GET [$name] )) {
  14163. if (is_array ( $_GET [$name] ))
  14164. return $_GET [$name];
  14165. else
  14166. return addslashes ( $_GET [$name] );
  14167. } elseif (isset ( $_POST [$name] )) {
  14168. if (is_array ( $_POST [$name] ))
  14169. return $_POST [$name];
  14170. else
  14171. return addslashes ( $_POST [$name] );
  14172. } else
  14173. return false;
  14174. }
  14175. function num_to_rmb($num) {
  14176. $c1 = "零壹贰叁肆伍陆柒捌玖";
  14177. $c2 = "分角元拾佰仟万拾佰仟亿";
  14178. // 精确到分后面就不要了,所以只留两个小数位
  14179. $num = round ( $num, 2 );
  14180. // 将数字转化为整数
  14181. $num = $num * 100;
  14182. if (strlen ( $num ) > 10) {
  14183. return "金额太大,请检查";
  14184. }
  14185. $i = 0;
  14186. $c = "";
  14187. while ( 1 ) {
  14188. if ($i == 0) {
  14189. // 获取最后一位数字
  14190. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  14191. } else {
  14192. $n = $num % 10;
  14193. }
  14194. // 每次将最后一位数字转化为中文
  14195. $p1 = substr ( $c1, 3 * $n, 3 );
  14196. $p2 = substr ( $c2, 3 * $i, 3 );
  14197. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  14198. $c = $p1 . $p2 . $c;
  14199. } else {
  14200. $c = $p1 . $c;
  14201. }
  14202. $i = $i + 1;
  14203. // 去掉数字最后一位了
  14204. $num = $num / 10;
  14205. // echo $num.'</br>';
  14206. $num = ( int ) $num;
  14207. // $num =floor($num);
  14208. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  14209. // echo $num.'</br>';
  14210. // 结束循环
  14211. if ($num == 0) {
  14212. break;
  14213. }
  14214. }
  14215. // echo $c.'</br>';
  14216. $j = 0;
  14217. $slen = strlen ( $c );
  14218. while ( $j < $slen ) {
  14219. // utf8一个汉字相当3个字符
  14220. $m = substr ( $c, $j, 6 );
  14221. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  14222. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  14223. $left = substr ( $c, 0, $j );
  14224. $right = substr ( $c, $j + 3 );
  14225. $c = $left . $right;
  14226. $j = $j - 3;
  14227. $slen = $slen - 3;
  14228. }
  14229. $j = $j + 3;
  14230. }
  14231. // 这个是为了去掉类似23.0中最后一个“零”字
  14232. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  14233. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  14234. }
  14235. // 将处理的汉字加上“整”
  14236. if (empty ( $c )) {
  14237. return "零元整";
  14238. } else {
  14239. return $c . "整";
  14240. }
  14241. }
  14242. /**
  14243. * 获得分页数据
  14244. * @param unknown_type $table
  14245. * @param unknown_type $condition
  14246. * @param unknown_type $on_page
  14247. * @param unknown_type $page_size
  14248. */
  14249. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  14250. $page_c = "";
  14251. $page ['previous'] = $this->get_previous ( $on_page );
  14252. $page ['on_page'] = $on_page;
  14253. $total_count = $this->get_table_count ( $table, $condition );
  14254. $total = intval ( $total_count / $page_size );
  14255. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  14256. $page ['total_data'] = $total_count;
  14257. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  14258. $i = 1;
  14259. $page_max = 1;
  14260. $page_width = 3;
  14261. if ($on_page >= $page_width) {
  14262. $page_max = intval ( $on_page / $page_width ) + 1;
  14263. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  14264. }
  14265. for(; $i <= $page ['total_page']; $i ++) {
  14266. if ($i == $on_page)
  14267. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  14268. else
  14269. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  14270. if ($i == ($page_width * $page_max))
  14271. break;
  14272. }
  14273. $page ['page'] = $page_c;
  14274. $page ['lower'] = (-- $on_page) * $page_size;
  14275. return $page;
  14276. }
  14277. /**
  14278. * 获取总页数
  14279. * @param unknown_type $table
  14280. * @param unknown_type $condition
  14281. */
  14282. public function get_table_count($table = "", $condition = "") {
  14283. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14284. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14285. // echo $sql;die;
  14286. $query = Doo::db ()->query ( $sql );
  14287. $result = $query->fetch ();
  14288. return $result ['count'];
  14289. }
  14290. /**
  14291. * 获取上一页
  14292. * @param unknown_type $on_page
  14293. */
  14294. function get_previous($on_page = 1) {
  14295. return $on_page != 0 ? $on_page - 1 : $on_page;
  14296. }
  14297. }
  14298. ?>