ReceiptController.php 526 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class ReceiptController extends DooController {
  6. public $staff;
  7. public $verifyId;
  8. public $executeId;
  9. // public static $NEW2 = 0;
  10. public $AGENCY = "日常相关费用";
  11. public $TRAVEL = "差旅相关费用";
  12. public $TRAIN = "培训班费用";
  13. public $OTHER = "其他";
  14. private $MYREVEIPTCACHEPATH = "protected/cache/myReceipt/";
  15. private $PERSONALCOLLECTCACHEPATH = "protected/cache/personalCollect/";
  16. private $CATEGORYCOLLECTPATH = "protected/cache/categoryCollect/";
  17. private $STAFFCOLLECTPATH = "protected/cache/staffCollect/";
  18. private function showCache($path) {
  19. if (file_exists ( $path )) {
  20. echo "<!DOCTYPE html>";
  21. include $path;
  22. die ();
  23. }
  24. }
  25. private function cacheFile($path) {
  26. $content = ob_get_contents ();
  27. $fp = fopen ( $path, "w" );
  28. fwrite ( $fp, $content );
  29. fclose ( $fp );
  30. }
  31. private function collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {
  32. $collectHtml = "";
  33. $sumPrice = 0.00;
  34. for($i = 1; $i <= 12; $i ++) {
  35. $falg = true;
  36. foreach ( $receiptCollectList as $key => $value ) {
  37. if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {
  38. $sumPrice += $value ['price'];
  39. if ($classType == "b") {
  40. $collectHtml .= '<td class="colGreen taR">¥' . $value ['price'] . '</td>';
  41. $falg = false;
  42. break;
  43. } else {
  44. $collectHtml .= '<td class="taR">¥' . $value ['price'] . '</td>';
  45. $falg = false;
  46. break;
  47. }
  48. }
  49. }
  50. if ($falg)
  51. $collectHtml .= '<td class="taR">-</td>';
  52. }
  53. $collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';
  54. return $collectHtml;
  55. }
  56. public function beforeRun($resource, $action) {
  57. Doo::loadClass ( 'XDeode' );
  58. $XDeode = new XDeode ( 5 );
  59. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  60. // 单独判断公司汇总的访问权限
  61. if ($action == 'companyCategoryCollect') {
  62. Doo::loadModel ( "receiptAuthorityManage" );
  63. $invoiceCompanyManage = new receiptAuthorityManage ();
  64. $icm = $invoiceCompanyManage->getInvoiceCMByStaff ( $sid );
  65. if (empty ( $icm ))
  66. die ( 'illegal request' );
  67. }
  68. Doo::loadModel ( 'staff' );
  69. $staff = new staff ();
  70. $detail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  71. $accessModular = 'RECEIPTS';
  72. if (empty ( $detail ['cldAccessArray'] ))
  73. die ( 'illegal request' );
  74. else {
  75. if (in_array ( $accessModular, $detail ['cldAccessArray'] )) {
  76. if (Doo::acl ()->isAllowed ( $accessModular, $resource, $action )) {
  77. $flag = true;
  78. } else {
  79. $flag = false;
  80. }
  81. } else {
  82. die ( 'illegal request' );
  83. }
  84. }
  85. if (! $flag)
  86. die ( 'illegal request' );
  87. }
  88. function __construct() {
  89. if (isset ( $_COOKIE ["staff"] )) {
  90. if (! empty ( $_COOKIE ["staff"] )) {
  91. Doo::loadModel ( 'staff' );
  92. Doo::loadModel ( 'verify' );
  93. $verify = new verify ();
  94. $staff = new staff ();
  95. Doo::loadModel ( "execute" );
  96. $execute = new execute ();
  97. $verifyList = $verify->find ( array (
  98. 'select' => 'staff',
  99. 'asArray' => true
  100. ) );
  101. $list = array ();
  102. // 判断角色的审批权限
  103. foreach ( $verifyList as $key => $value ) {
  104. $ver = json_decode ( $value ['staff'] );
  105. foreach ( $ver as $k => $v ) {
  106. if ($v [1] == 'ROLE') {
  107. $roleList = json_decode ( $v [3] );
  108. foreach ( $roleList as $t => $g ) {
  109. $gList = explode ( "_", $g );
  110. array_push ( $list, $gList [0] );
  111. // print_r($list);
  112. }
  113. } else
  114. array_push ( $list, $v [0] );
  115. }
  116. }
  117. // 判断执行人的审批权限
  118. $executeList = $execute->find ( array (
  119. 'select' => 'staff',
  120. 'asArray' => true
  121. ) );
  122. $list2 = array ();
  123. foreach ( $executeList as $key => $value ) {
  124. $ver = json_decode ( $value ['staff'] );
  125. foreach ( $ver as $k => $v ) {
  126. array_push ( $list2, $v [0] );
  127. }
  128. }
  129. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  130. $eidList = array_filter ( explode ( ",", $eidList ) );
  131. $this->executeId = array_merge ( $list2, $eidList );
  132. $this->verifyId = $list;
  133. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  134. // 检测用户信息完成
  135. $this->data ['isStaffCompleteMsg'] = false;
  136. $detail = $staff->checkStaffInfoIsComplete ( $_COOKIE ["staff"] );
  137. if (! empty ( $detail ))
  138. $this->data ['isStaffCompleteMsg'] = true;
  139. return "/";
  140. }
  141. }
  142. Doo::loadCore ( 'uri/DooUriRouter' );
  143. $router = new DooUriRouter ();
  144. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  145. if ($routeRs ['1'] != "login") {
  146. header ( 'Content-Type:text/html;charset=utf-8' );
  147. @header ( "Location: /login" );
  148. }
  149. }
  150. function saeaBorad() {
  151. Doo::loadModel ( 'receipt' );
  152. Doo::loadModel ( 'verify' );
  153. $verify = new verify ();
  154. $receipt = new receipt ();
  155. Doo::loadModel ( 'L_category' );
  156. $lCategory = new L_category ();
  157. Doo::loadModel ( "role" );
  158. $role = new role ();
  159. Doo::loadModel ( "receiptLog" );
  160. $receiptLog = new receiptLog ();
  161. Doo::loadClass ( 'XDeode' );
  162. $XDeode = new XDeode ( 7 );
  163. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  164. $receiptDetail = $receipt->find ( array (
  165. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  166. 'desc' => 'rid',
  167. 'asArray' => true
  168. ) );
  169. foreach ( $receiptDetail as $key => $value ) {
  170. $receiptDetail [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  171. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  172. $veList = $verify->getOne ( array (
  173. 'where' => 'vid=' . $value ['verify'],
  174. 'asArray' => true
  175. ) );
  176. $v = json_decode ( $veList ['staff'] );
  177. array_push ( $v [0], $veList ['description'] );
  178. foreach ( $v as $n => $m ) {
  179. if ($m ['1'] == 'ROLE') {
  180. $roleInfo = $role->getOne ( array (
  181. 'where' => 'rid=' . $m [0],
  182. 'asArray' => true
  183. ) );
  184. $v [$n] [1] = $roleInfo ['name'];
  185. }
  186. }
  187. $receiptDetail [$key] ['staff'] = $v;
  188. $category = $lCategory->getOne ( array (
  189. 'where' => 'cid=' . $value ['cid'],
  190. 'asArray' => true
  191. ) );
  192. $receiptDetail [$key] ['category'] = $category ['title'];
  193. }
  194. // print_r($receiptLogList);
  195. $data ['receiptLogList'] = $receiptLogList;
  196. $data ['receiptDetail'] = $receiptDetail;
  197. $data ['memu'] = "receipt";
  198. $data ['staff'] = $this->staff;
  199. $data ['receiptMemu'] = 'saeaBorad';
  200. $data ['verifyId'] = $this->verifyId;
  201. $data ['executeId'] = $this->executeId;
  202. $this->render ( "/admin/saeaBorad", $data );
  203. }
  204. function remitAdd() {
  205. Doo::loadModel ( 'accountItem' );
  206. Doo::loadModel ( 'verify' );
  207. Doo::loadModel ( 'receipt' );
  208. Doo::loadModel ( 'L_category' );
  209. $lCategory = new L_category ();
  210. $receipt = new receipt ();
  211. $verify = new verify ();
  212. $accountItem = new accountItem ();
  213. Doo::loadModel ( "role" );
  214. $role = new role ();
  215. $acItem = $accountItem->find ( array (
  216. 'asArray' => true
  217. ) );
  218. $veList = $verify->find ( array (
  219. 'asArray' => true
  220. ) );
  221. foreach ( $veList as $key => $value ) {
  222. $v = json_decode ( $value ['staff'] );
  223. $list = array ();
  224. foreach ( $v as $n => $m ) {
  225. if ($m ['1'] == 'ROLE') {
  226. $roleInfo = $role->getOne ( array (
  227. 'where' => 'rid=' . $m [0],
  228. 'asArray' => true
  229. ) );
  230. $v [$n] [1] = $roleInfo ['name'];
  231. array_push ( $list, $roleInfo ['name'] );
  232. } else {
  233. array_push ( $list, $v [$n] [1] );
  234. }
  235. }
  236. $veList [$key] ['staff'] = implode ( '>', $list );
  237. }
  238. $data ['category'] = $lCategory->find ( array (
  239. 'asArray' => true
  240. ) );
  241. $data ['veList'] = $veList;
  242. $data ['acItem'] = $acItem;
  243. $data ['memu'] = "receipt";
  244. $data ['staff'] = $this->staff;
  245. $data ['receiptMemu'] = 'saeaBorad';
  246. $data ['verifyId'] = $this->verifyId;
  247. $data ['executeId'] = $this->executeId;
  248. $this->render ( "/admin/remitAdd", $data );
  249. }
  250. function remitAddDo() {
  251. $agency = $this->get_args ( 'agency' );
  252. $travel = $this->get_args ( 'travel' );
  253. $train = $this->get_args ( 'train' );
  254. $other = $this->get_args ( 'other' );
  255. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  256. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  257. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  258. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  259. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  260. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  261. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  262. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  263. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  264. // print_r($agency);die;
  265. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  266. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  267. header ( 'Content-Type:text/html;charset=utf-8' );
  268. die ( '请填写联行号' );
  269. }
  270. Doo::loadModel ( 'receipt' );
  271. Doo::loadModel ( 'receiptDetail' );
  272. Doo::loadModel ( 'accountItem' );
  273. $accountItem = new accountItem ();
  274. $receipt = new receipt ();
  275. Doo::loadModel ( 'enclosur' );
  276. Doo::loadModel ( 'execute' );
  277. $execute = new execute ();
  278. $executeDetail = $execute->getOne ( array (
  279. 'where' => 'mold="对公汇款执行人"',
  280. 'asArray' => true
  281. ) );
  282. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  283. $aItem = $accountItem->find ( array (
  284. 'where' => 'name like "办公费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保"',
  285. 'asArray' => true
  286. ) );
  287. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  288. $ag = $tr = $ta = $ot = 0;
  289. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  290. foreach ( $aItem as $key => $value ) {
  291. if ($value ['category'] == $this->AGENCY) {
  292. if (isset ( $agency [$ag] )) {
  293. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  294. array_push ( $accountJson [$this->AGENCY], array (
  295. 'aid' => $value ['aid'],
  296. 'name' => $value ['name'],
  297. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  298. ) );
  299. $sum += $agency [$ag];
  300. $agencySum += $agency [$ag];
  301. }
  302. }
  303. $ag ++;
  304. }
  305. }
  306. $accountJson ['cSum'] = array (
  307. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  308. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  309. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  310. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  311. );
  312. // 报销单
  313. $receipt->accountItem = json_encode ( $accountJson );
  314. $receipt->staff = $this->staff [0] ['sid'];
  315. $receipt->sum = number_format ( $sum, 2, '.', '' );
  316. $receipt->date = date ( "Y-m-d" );
  317. $receipt->cid = $cid;
  318. $receipt->status = 5;
  319. $receipt->Rtype = 2;
  320. // 修改审批流程加入角色
  321. $receipt->verify = $verify;
  322. $receipt->executeCopy = $executeDetail ['staff'];
  323. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  324. $order = array (
  325. "\r\n",
  326. "\n",
  327. "\r"
  328. );
  329. $replace = '<br/>';
  330. $explanation = str_replace ( $order, $replace, $explanation );
  331. $receipt->explanation = $explanation;
  332. $receipt->remittanceName = $remittanceName;
  333. $receipt->bankName = $bankName;
  334. $receipt->bankNumber = $bankNumber;
  335. $receipt->remittanceBankType = $remittanceBankType;
  336. if ($remittanceBankType == 1)
  337. $receipt->coupletNumber = $coupletNumber;
  338. $rid = $receipt->insert ();
  339. // 附件
  340. if (! empty ( $enclosurName )) {
  341. $enclosurArray = explode ( '-', $enclosurName );
  342. foreach ( $enclosurArray as $value ) {
  343. $enclosur = new enclosur ();
  344. $enclosur->name = $value;
  345. $enclosur->rid = $rid;
  346. $enclosur->insert ();
  347. }
  348. // print_r($enclosurArray);die;
  349. }
  350. // 报销详情
  351. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  352. $receiptDetail = new receiptDetail ();
  353. $receiptDetail->staff = $this->staff [0] ['sid'];
  354. $receiptDetail->item = $value ['name'];
  355. $receiptDetail->itemCategory = $this->AGENCY;
  356. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  357. $receiptDetail->date = date ( "Y-m-d" );
  358. $receiptDetail->cid = $cid;
  359. $receiptDetail->rid = $rid;
  360. $receiptDetail->status = 4;
  361. $receiptDetail->insert ();
  362. }
  363. return "/saeaBorad";
  364. } else
  365. die ( 'illegal request' );
  366. }
  367. function remitEdit() {
  368. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  369. Doo::loadClass ( 'XDeode' );
  370. $XDeode = new XDeode ( 7 );
  371. $rid = $XDeode->decode ( $ridKey );
  372. if (! is_numeric ( $rid ))
  373. die ( 'illegal request' );
  374. Doo::loadModel ( 'accountItem' );
  375. Doo::loadModel ( 'verify' );
  376. Doo::loadModel ( 'receipt' );
  377. $receipt = new receipt ();
  378. $verify = new verify ();
  379. $accountItem = new accountItem ();
  380. Doo::loadModel ( 'L_category' );
  381. $lCategory = new L_category ();
  382. Doo::loadModel ( "role" );
  383. $role = new role ();
  384. Doo::loadModel ( 'enclosur' );
  385. $enclosur = new enclosur ();
  386. $receiptDetail = $receipt->getOne ( array (
  387. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  388. 'asArray' => true
  389. ) );
  390. if (empty ( $receiptDetail ))
  391. return "/saeaCreate";
  392. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  393. $acItem = $accountItem->find ( array (
  394. 'asArray' => true
  395. ) );
  396. $veList = $verify->find ( array (
  397. 'asArray' => true
  398. ) );
  399. foreach ( $veList as $key => $value ) {
  400. $v = json_decode ( $value ['staff'] );
  401. $list = array ();
  402. foreach ( $v as $n => $m ) {
  403. if ($m ['1'] == 'ROLE') {
  404. $roleInfo = $role->getOne ( array (
  405. 'where' => 'rid=' . $m [0],
  406. 'asArray' => true
  407. ) );
  408. $v [$n] [1] = $roleInfo ['name'];
  409. array_push ( $list, $roleInfo ['name'] );
  410. } else {
  411. array_push ( $list, $v [$n] [1] );
  412. }
  413. }
  414. $veList [$key] ['staff'] = implode ( '>', $list );
  415. }
  416. // 配置编辑信息
  417. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  418. foreach ( $acItem as $key => $value ) {
  419. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  420. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  421. $acItem [$key] ['price'] = $v ['price'];
  422. }
  423. }
  424. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  425. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  426. $acItem [$key] ['price'] = $v ['price'];
  427. }
  428. }
  429. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  430. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  431. $acItem [$key] ['price'] = $v ['price'];
  432. }
  433. }
  434. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  435. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  436. $acItem [$key] ['price'] = $v ['price'];
  437. }
  438. }
  439. }
  440. $data ['category'] = $lCategory->find ( array (
  441. 'asArray' => true
  442. ) );
  443. $data ['enclosurList'] = $enclosurList;
  444. $data ['cSum'] = $accountItemList ['cSum'];
  445. $data ['sum'] = $receiptDetail ['sum'];
  446. $data ['receiptDetail'] = $receiptDetail;
  447. $data ['veList'] = $veList;
  448. $data ['acItem'] = $acItem;
  449. $data ['memu'] = "receipt";
  450. $data ['staff'] = $this->staff;
  451. $data ['receiptMemu'] = 'saeaBorad';
  452. $data ['verify'] = $receiptDetail ['verify'];
  453. $data ['verifyId'] = $this->verifyId;
  454. $data ['executeId'] = $this->executeId;
  455. $data ['rid'] = $rid;
  456. $data ['ridKey'] = $ridKey;
  457. $this->render ( "/admin/remitEdit", $data );
  458. }
  459. function remitEdiDo() {
  460. $agency = $this->get_args ( 'agency' );
  461. $travel = $this->get_args ( 'travel' );
  462. $train = $this->get_args ( 'train' );
  463. $other = $this->get_args ( 'other' );
  464. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  465. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  466. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  467. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  468. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  469. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  470. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  471. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  472. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  473. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  474. Doo::loadClass ( 'XDeode' );
  475. $XDeode = new XDeode ( 7 );
  476. $rid = $XDeode->decode ( $ridKey );
  477. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  478. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  479. header ( 'Content-Type:text/html;charset=utf-8' );
  480. die ( '请填写联行号' );
  481. }
  482. Doo::loadModel ( 'receipt' );
  483. Doo::loadModel ( 'receiptDetail' );
  484. Doo::loadModel ( 'accountItem' );
  485. $accountItem = new accountItem ();
  486. $receipt = new receipt ();
  487. Doo::loadModel ( 'enclosur' );
  488. $enclosur = new enclosur ();
  489. Doo::loadModel ( 'execute' );
  490. $execute = new execute ();
  491. $executeDetail = $execute->getOne ( array (
  492. 'where' => 'mold="对公汇款执行人"',
  493. 'asArray' => true
  494. ) );
  495. $receiptDetail = $receipt->getOne ( array (
  496. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  497. 'asArray' => true
  498. ) );
  499. if (empty ( $receiptDetail ))
  500. return "/saeaBorad";
  501. $aItem = $accountItem->find ( array (
  502. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  503. 'asArray' => true
  504. ) );
  505. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  506. $ag = $tr = $ta = $ot = 0;
  507. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  508. foreach ( $aItem as $key => $value ) {
  509. if ($value ['category'] == $this->AGENCY) {
  510. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  511. array_push ( $accountJson [$this->AGENCY], array (
  512. 'aid' => $value ['aid'],
  513. 'name' => $value ['name'],
  514. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  515. ) );
  516. $sum += $agency [$ag];
  517. $agencySum += $agency [$ag];
  518. }
  519. $ag ++;
  520. }
  521. }
  522. $accountJson ['cSum'] = array (
  523. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  524. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  525. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  526. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  527. );
  528. // 报销单
  529. $rid = $receipt->rid = $receiptDetail ['rid'];
  530. $receipt->accountItem = json_encode ( $accountJson );
  531. $receipt->staff = $this->staff [0] ['sid'];
  532. $receipt->sum = number_format ( $sum, 2, '.', '' );
  533. $receipt->date = date ( "Y-m-d" );
  534. $receipt->cid = $cid;
  535. if ($receiptDetail ['Rtype'] == 1)
  536. $receipt->status = 7;
  537. else
  538. $receipt->status = 5;
  539. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  540. $receipt->verify = $verify;
  541. $receipt->executeCopy = $executeDetail ['staff'];
  542. $order = array (
  543. "\r\n",
  544. "\n",
  545. "\r"
  546. );
  547. $replace = '<br/>';
  548. $explanation = str_replace ( $order, $replace, $explanation );
  549. $receipt->explanation = $explanation;
  550. $receipt->remittanceName = $remittanceName;
  551. $receipt->bankName = $bankName;
  552. $receipt->bankNumber = $bankNumber;
  553. $receipt->remittanceBankType = $remittanceBankType;
  554. if ($remittanceBankType == 1)
  555. $receipt->coupletNumber = $coupletNumber;
  556. $receipt->update ();
  557. $receiptDetail = new receiptDetail ();
  558. $receiptDetail->delete ( array (
  559. 'where' => 'rid=' . $rid
  560. ) );
  561. // 报销详情
  562. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  563. $receiptDetail = new receiptDetail ();
  564. $receiptDetail->staff = $this->staff [0] ['sid'];
  565. $receiptDetail->item = $value ['name'];
  566. $receiptDetail->itemCategory = $this->AGENCY;
  567. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  568. $receiptDetail->date = date ( "Y-m-d" );
  569. $receiptDetail->cid = $cid;
  570. $receiptDetail->rid = $rid;
  571. $receiptDetail->status = 4;
  572. $receiptDetail->insert ();
  573. }
  574. // 附件
  575. if (! empty ( $enclosurName )) {
  576. $enclosurArray = explode ( '-', $enclosurName );
  577. foreach ( $enclosurArray as $value ) {
  578. $enclosur = new enclosur ();
  579. $enclosur->name = $value;
  580. $enclosur->rid = $rid;
  581. $enclosur->insert ();
  582. }
  583. }
  584. }
  585. return "/saeaBorad";
  586. }
  587. function remitApproval() {
  588. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  589. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  590. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  591. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  592. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  593. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  594. if (empty ( $status ))
  595. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  596. $vidList = array ();
  597. $button = 0;
  598. Doo::loadModel ( 'verify' );
  599. Doo::loadModel ( 'receipt' );
  600. Doo::loadModel ( 'staff' );
  601. $staff = new staff ();
  602. $receipt = new receipt ();
  603. $verify = new verify ();
  604. Doo::loadModel ( 'L_category' );
  605. $Lcategory = new L_category ();
  606. Doo::loadModel ( 'enclosur' );
  607. $enclosur = new enclosur ();
  608. // user verify ID
  609. $verifyDetail = $verify->find ( array (
  610. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  611. 'asArray' => true
  612. ) );
  613. foreach ( $verifyDetail as $key => $value ) {
  614. array_push ( $vidList, $value ['vid'] );
  615. }
  616. $vid = implode ( ",", $vidList );
  617. if (empty ( $verifyDetail ))
  618. $vid = 0;
  619. $categoryList = $Lcategory->find ( array (
  620. 'asArray' => true
  621. ) );
  622. $staffList = $staff->find ( array (
  623. 'where' => 'cid=' . $cid,
  624. 'asArray' => true
  625. ) );
  626. $ap = "";
  627. if ($status == 4) {
  628. $ap = 4;
  629. $status = 2;
  630. }
  631. // get Receipt By verifyID status 2
  632. $receiptList = $receipt->find ( array (
  633. 'where' => 'rid =' . $rid . ' and status=2',
  634. 'desc' => 'rid',
  635. 'asArray' => true
  636. ) );
  637. if (empty ( $receiptList )) {
  638. die ( 'illegal request' );
  639. }
  640. $Locate = 0;
  641. $roleId = 0;
  642. if ($ap == 4)
  643. $status = 4;
  644. foreach ( $receiptList as $key => $value ) {
  645. $receiptList [$key] ['Locate'] = $Locate;
  646. $Locate ++;
  647. $receiptList [$key] ['reviseDetail'] = array ();
  648. if (! empty ( $value ['reviseDetail'] ))
  649. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  650. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  651. $categoryDetil = $Lcategory->getOne ( array (
  652. 'where' => 'cid=' . $value ['cid'],
  653. 'asArray' => true
  654. ) );
  655. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  656. // 检测编辑状态
  657. $verifyList = $verify->getOne ( array (
  658. 'where' => 'vid=' . $value ['verify'],
  659. 'asArray' => true
  660. ) );
  661. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  662. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  663. Doo::loadModel ( 'role' );
  664. $role = new role ();
  665. // print_r($verifyList);
  666. $flag = true;
  667. $roleKey = 0;
  668. $endStaffArray = array ();
  669. $roleArrayCopy = array ();
  670. foreach ( $verifyList as $k => $v ) {
  671. // init verifyStaff
  672. if ($v [1] == 'ROLE') {
  673. if (! empty ( $verifyStaff )) {
  674. $endStaffArray = end ( $verifyStaff );
  675. if ($v [0] == $endStaffArray ['nextStaff']) {
  676. $roleId = $v [0];
  677. }
  678. }
  679. $roleVerify = json_decode ( $v [3], true );
  680. $roleKey = $k;
  681. $roleArray = array ();
  682. $rolename = $role->getOne ( array (
  683. 'where' => 'rid=' . $v [0],
  684. 'asArray' => true
  685. ) );
  686. foreach ( $roleVerify as $o => $p ) {
  687. $staffID = explode ( '_', $p );
  688. $staffInfo = $staff->getOne ( array (
  689. 'where' => 'sid=' . $staffID [0],
  690. 'asArray' => true
  691. ) );
  692. // print_r($staffID);
  693. $exp = array (
  694. 0 => $staffInfo ['sid'],
  695. 1 => $staffID [1],
  696. 2 => $staffInfo ['avatar'],
  697. 'date' => '',
  698. 'date' => '',
  699. 'opinion' => '',
  700. 'status' => '',
  701. 'rolename' => $rolename ['name']
  702. );
  703. array_push ( $roleArray, $exp );
  704. }
  705. $roleArrayCopy [$v [0]] = $roleArray;
  706. // $verifyList[$k]['roleArray']=$roleArray;
  707. }
  708. // print_r($roleArray);
  709. $verifyList [$k] ['date'] = "";
  710. $verifyList [$k] ['opinion'] = "";
  711. $verifyList [$k] ['status'] = "";
  712. if (empty ( $verifyStaff )) {
  713. $verifyList [$k] ['date'] = "";
  714. $verifyList [$k] ['opinion'] = "";
  715. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  716. $verifyList [$k] ['status'] = 4;
  717. $button = 4;
  718. $flag = false;
  719. }
  720. } else {
  721. foreach ( $verifyStaff as $m => $u ) {
  722. if ($v [0] == $m) {
  723. $verifyList [$k] ['date'] = $u ['date'];
  724. $verifyList [$k] ['opinion'] = $u ['opinion'];
  725. $verifyList [$k] ['status'] = $u ['status'];
  726. $flag = false;
  727. break;
  728. }
  729. }
  730. $endStaffArray = end ( $verifyStaff );
  731. if (isset ( $endStaffArray ['ROLE'] )) {
  732. } else {
  733. $endKey = key ( $verifyStaff );
  734. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  735. $button = 4;
  736. $verifyList [$k] ['status'] = 4;
  737. }
  738. }
  739. }
  740. }
  741. $rolename ['name'] = '';
  742. if (! empty ( $roleId )) {
  743. Doo::loadModel ( 'role' );
  744. $role = new role ();
  745. $rolename = $role->getOne ( array (
  746. 'where' => 'rid=' . $roleId,
  747. 'asArray' => true
  748. ) );
  749. }
  750. if (! empty ( $verifyStaff ))
  751. $endStaffArray = end ( $verifyStaff );
  752. $KOP = false;
  753. foreach ( $roleArrayCopy as $P => $A ) {
  754. foreach ( $A as $MKI => $AVL ) {
  755. if (! empty ( $verifyStaff )) {
  756. // &&$rolename['rid']==$endStaffArray['nextStaff']
  757. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  758. $button = 4;
  759. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  760. }
  761. foreach ( $verifyStaff as $m => $u ) {
  762. $AVLFK = $AVL [0] . '_R';
  763. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  764. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  765. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  766. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  767. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  768. break;
  769. }
  770. }
  771. } else {
  772. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  773. $button = 4;
  774. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  775. }
  776. }
  777. // $roleArray[$MKI]['rolename']=$rolename['name'];
  778. $KOP = true;
  779. }
  780. }
  781. foreach ( $roleArrayCopy as $k => $v ) {
  782. foreach ( $verifyList as $m => $n ) {
  783. if ($n [0] == $k) {
  784. array_splice ( $verifyList, $m, 1, $v );
  785. }
  786. }
  787. }
  788. $receiptList [$key] ['verifyList'] = $verifyList;
  789. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  790. 'where' => 'sid=' . $value ['staff'],
  791. 'asArray' => true
  792. ) );
  793. $receiptList [$key] ['button'] = $button;
  794. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  795. }
  796. $mothHtml = "";
  797. for($i = 1; $i <= 12; $i ++) {
  798. if ($month == $i)
  799. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  800. else
  801. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  802. }
  803. // 获取审批日志
  804. Doo::loadModel ( 'receiptLog' );
  805. $receiptLog = new receiptLog ();
  806. $rlList = array ();
  807. $rlInfo = $receiptLog->getOne ( array (
  808. 'where' => 'rid=' . $rid . ' and status=4',
  809. 'asArray' => true
  810. ) );
  811. $tijdate = $receiptLog->getOne ( array (
  812. 'where' => 'rid=' . $rid . ' and status=2',
  813. 'asc' => 'rlid',
  814. 'asArray' => true
  815. ) );
  816. if (! empty ( $rlInfo )) {
  817. $rlList = $receiptLog->find ( array (
  818. 'where' => 'rid=' . $rid,
  819. 'asc' => 'rlid',
  820. 'asArray' => true
  821. ) );
  822. }
  823. $receiptList [0] ['rlList'] = $rlList;
  824. $enclosurList = $enclosur->find ( array (
  825. 'where' => 'rid=' . $rid,
  826. 'asArray' => true
  827. ) );
  828. $enclosurHtml = '';
  829. foreach ( $enclosurList as $value ) {
  830. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  831. }
  832. // print_r($receiptList);
  833. $data ['enclosurHtml'] = $enclosurHtml;
  834. $data ['rolename'] = $rolename ['name'];
  835. $data ['datetij'] = $tijdate ['date'];
  836. $data ['mothHtml'] = $mothHtml;
  837. $data ['rid'] = $rid;
  838. $data ['receiptList'] = $receiptList;
  839. $data ['receiptApprovalCount'] = count ( $receiptList );
  840. $data ['status'] = $status;
  841. $data ['year'] = $year;
  842. $data ['categoryList'] = $categoryList;
  843. $data ['staffList'] = $staffList;
  844. $data ['cid'] = $cid;
  845. $data ['sid'] = $sid;
  846. $data ['ap'] = $ap;
  847. $data ['memu'] = "receipt";
  848. $data ['staff'] = $this->staff;
  849. $data ['receiptMemu'] = 'approvalExpenses';
  850. $data ['verifyId'] = $this->verifyId;
  851. $data ['executeId'] = $this->executeId;
  852. $this->render ( "/admin/remitApproval", $data );
  853. }
  854. function saeaLoanAdd() {
  855. Doo::loadModel ( 'verify' );
  856. $verify = new verify ();
  857. Doo::loadModel ( "role" );
  858. $role = new role ();
  859. Doo::loadModel ( 'L_category' );
  860. $lCategory = new L_category ();
  861. $veList = $verify->find ( array (
  862. 'asArray' => true
  863. ) );
  864. foreach ( $veList as $key => $value ) {
  865. $v = json_decode ( $value ['staff'] );
  866. $list = array ();
  867. foreach ( $v as $n => $m ) {
  868. if ($m ['1'] == 'ROLE') {
  869. $roleInfo = $role->getOne ( array (
  870. 'where' => 'rid=' . $m [0],
  871. 'asArray' => true
  872. ) );
  873. $v [$n] [1] = $roleInfo ['name'];
  874. array_push ( $list, $roleInfo ['name'] );
  875. } else {
  876. array_push ( $list, $v [$n] [1] );
  877. }
  878. }
  879. $veList [$key] ['staff'] = implode ( '>', $list );
  880. }
  881. $data ['category'] = $lCategory->find ( array (
  882. 'asArray' => true
  883. ) );
  884. $data ['veList'] = $veList;
  885. $data ['memu'] = "receipt";
  886. $data ['staff'] = $this->staff;
  887. $data ['receiptMemu'] = 'saeaBorad';
  888. $data ['verifyId'] = $this->verifyId;
  889. $data ['executeId'] = $this->executeId;
  890. $this->render ( "/admin/saeaLoanAdd", $data );
  891. }
  892. function saeaLoanAddDo() {
  893. $agency = $this->get_args ( 'agency' );
  894. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  895. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  896. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  897. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  898. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  899. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  900. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  901. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  902. // die;
  903. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  904. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  905. header ( 'Content-Type:text/html;charset=utf-8' );
  906. die ( '请填写联行号' );
  907. }
  908. Doo::loadModel ( 'receipt' );
  909. Doo::loadModel ( 'receiptDetail' );
  910. Doo::loadModel ( 'accountItem' );
  911. $accountItem = new accountItem ();
  912. $receipt = new receipt ();
  913. Doo::loadModel ( 'loanReceipt' );
  914. $loanReceipt = new loanReceipt ();
  915. Doo::loadModel ( 'execute' );
  916. $execute = new execute ();
  917. Doo::loadModel ( 'enclosur' );
  918. $executeDetail = $execute->getOne ( array (
  919. 'where' => 'mold="借款执行人"',
  920. 'asArray' => true
  921. ) );
  922. $aItem = $accountItem->find ( array (
  923. 'asArray' => true
  924. ) );
  925. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  926. $ag = $tr = $ta = $ot = 0;
  927. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  928. array_push ( $accountJson ['借款费用'], array (
  929. 'aid' => 0,
  930. 'name' => '申请金额',
  931. 'price' => number_format ( $agency, 2, '.', '' )
  932. ) );
  933. $sum += $agency;
  934. $agencySum += $agency;
  935. $accountJson ['cSum'] = array (
  936. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  937. 'agencySum' => number_format ( 0, 2, '.', '' ),
  938. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  939. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  940. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  941. );
  942. // 借款数据备份
  943. $loanReceipt->loanItem = json_encode ( $accountJson );
  944. $loanReceipt->staff = $this->staff [0] ['sid'];
  945. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  946. $loanReceipt->date = date ( "Y-m-d" );
  947. $loanReceipt->cid = $cid;
  948. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  949. $loanReceipt->status = 5;
  950. $loanReceipt->Rtype = 1;
  951. $loanReceipt->verify = $verify;
  952. $receipt->receiptOrder = $receipt->receiptOrder;
  953. // 添加HTML换行符
  954. // var_dump($explanation);
  955. $order = array (
  956. "\r\n",
  957. "\n",
  958. "\r"
  959. );
  960. $replace = '<br/>';
  961. $explanation = str_replace ( $order, $replace, $explanation );
  962. // $explanation=str_replace('\r',"<br/>",$explanation);
  963. // $explanation=str_replace('\r\n',"<br/>",$explanation);
  964. $loanReceipt->explanation = $explanation;
  965. $loanRid = $loanReceipt->insert ();
  966. // 报销单
  967. $receipt->loanItem = json_encode ( $accountJson );
  968. $receipt->staff = $this->staff [0] ['sid'];
  969. $receipt->sum = number_format ( $sum, 2, '.', '' );
  970. $receipt->date = date ( "Y-m-d" );
  971. $receipt->cid = $cid;
  972. // 特殊状态
  973. $receipt->status = 5;
  974. $receipt->Rtype = 1;
  975. $receipt->loanRid = $loanRid;
  976. // 修改审批流程加入角色
  977. $receipt->verify = $verify;
  978. $receipt->executeCopy = $executeDetail ['staff'];
  979. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  980. $receipt->explanation = $explanation;
  981. $receipt->remittanceName = $remittanceName;
  982. $receipt->bankName = $bankName;
  983. $receipt->bankNumber = $bankNumber;
  984. $receipt->remittanceBankType = $remittanceBankType;
  985. if ($remittanceBankType == 1)
  986. $receipt->coupletNumber = $coupletNumber;
  987. $rid = $receipt->insert ();
  988. return "/saeaBorad";
  989. } else
  990. die ( 'illegal request' );
  991. }
  992. function saeaLoanEdi() {
  993. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  994. Doo::loadClass ( 'XDeode' );
  995. $XDeode = new XDeode ( 7 );
  996. $rid = $XDeode->decode ( $ridKey );
  997. if (! is_numeric ( $rid ))
  998. die ( 'illegal request' );
  999. Doo::loadModel ( 'verify' );
  1000. $verify = new verify ();
  1001. Doo::loadModel ( "role" );
  1002. $role = new role ();
  1003. Doo::loadModel ( 'L_category' );
  1004. $lCategory = new L_category ();
  1005. Doo::loadModel ( 'receipt' );
  1006. $receipt = new receipt ();
  1007. $receiptInfo = $receipt->getOne ( array (
  1008. 'where' => 'rid=' . $rid,
  1009. 'asArray' => true
  1010. ) );
  1011. $veList = $verify->find ( array (
  1012. 'asArray' => true
  1013. ) );
  1014. foreach ( $veList as $key => $value ) {
  1015. $v = json_decode ( $value ['staff'] );
  1016. $list = array ();
  1017. foreach ( $v as $n => $m ) {
  1018. if ($m ['1'] == 'ROLE') {
  1019. $roleInfo = $role->getOne ( array (
  1020. 'where' => 'rid=' . $m [0],
  1021. 'asArray' => true
  1022. ) );
  1023. $v [$n] [1] = $roleInfo ['name'];
  1024. array_push ( $list, $roleInfo ['name'] );
  1025. } else {
  1026. array_push ( $list, $v [$n] [1] );
  1027. }
  1028. }
  1029. $veList [$key] ['staff'] = implode ( '>', $list );
  1030. }
  1031. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  1032. // print_r($receiptInfo);
  1033. $data ['receiptInfo'] = $receiptInfo;
  1034. $data ['category'] = $lCategory->find ( array (
  1035. 'asArray' => true
  1036. ) );
  1037. $data ['veList'] = $veList;
  1038. $data ['ridKey'] = $ridKey;
  1039. $data ['memu'] = "receipt";
  1040. $data ['staff'] = $this->staff;
  1041. $data ['receiptMemu'] = 'saeaBorad';
  1042. $data ['verifyId'] = $this->verifyId;
  1043. $data ['executeId'] = $this->executeId;
  1044. $this->render ( "/admin/saeaLoanEdi", $data );
  1045. }
  1046. function saeaLoanEdiDo() {
  1047. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1048. $agency = $this->get_args ( 'agency' );
  1049. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1050. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1051. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1052. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1053. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1054. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1055. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1056. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1057. // die;
  1058. Doo::loadClass ( 'XDeode' );
  1059. $XDeode = new XDeode ( 7 );
  1060. $rid = $XDeode->decode ( $ridKey );
  1061. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1062. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1063. header ( 'Content-Type:text/html;charset=utf-8' );
  1064. die ( '请填写联行号' );
  1065. }
  1066. Doo::loadModel ( 'receipt' );
  1067. Doo::loadModel ( 'receiptDetail' );
  1068. Doo::loadModel ( 'accountItem' );
  1069. $accountItem = new accountItem ();
  1070. $receipt = new receipt ();
  1071. Doo::loadModel ( 'loanReceipt' );
  1072. $loanReceipt = new loanReceipt ();
  1073. Doo::loadModel ( 'enclosur' );
  1074. Doo::loadModel ( 'execute' );
  1075. $execute = new execute ();
  1076. $executeDetail = $execute->getOne ( array (
  1077. 'where' => 'mold="借款执行人"',
  1078. 'asArray' => true
  1079. ) );
  1080. $receiptDetail = $receipt->getOne ( array (
  1081. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  1082. 'asArray' => true
  1083. ) );
  1084. if (empty ( $receiptDetail ))
  1085. die ( '参数错误' );
  1086. $aItem = $accountItem->find ( array (
  1087. 'asArray' => true
  1088. ) );
  1089. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1090. $ag = $tr = $ta = $ot = 0;
  1091. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1092. array_push ( $accountJson ['借款费用'], array (
  1093. 'aid' => 0,
  1094. 'name' => '申请金额',
  1095. 'price' => number_format ( $agency, 2, '.', '' )
  1096. ) );
  1097. $sum += $agency;
  1098. $agencySum += $agency;
  1099. $accountJson ['cSum'] = array (
  1100. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1101. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1102. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1103. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1104. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1105. );
  1106. // 报销单
  1107. $receipt->loanItem = json_encode ( $accountJson );
  1108. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1109. $receipt->cid = $cid;
  1110. // 特殊状态
  1111. // 修改审批流程加入角色
  1112. if ($receiptDetail ['status'] != 4)
  1113. $receipt->verify = $verify;
  1114. $order = array (
  1115. "\r\n",
  1116. "\n",
  1117. "\r"
  1118. );
  1119. $replace = '<br/>';
  1120. $explanation = str_replace ( $order, $replace, $explanation );
  1121. $receipt->explanation = $explanation;
  1122. $receipt->remittanceName = $remittanceName;
  1123. $receipt->bankName = $bankName;
  1124. $receipt->bankNumber = $bankNumber;
  1125. $receipt->remittanceBankType = $remittanceBankType;
  1126. if ($remittanceBankType == 1)
  1127. $receipt->coupletNumber = $coupletNumber;
  1128. $receipt->update ( array (
  1129. 'where' => 'rid=' . $rid
  1130. ) );
  1131. // 借款数据更新
  1132. $loanReceipt->loanItem = json_encode ( $accountJson );
  1133. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1134. $loanReceipt->cid = $cid;
  1135. if ($receiptDetail ['status'] != 4)
  1136. $loanReceipt->verify = $verify;
  1137. $loanReceipt->explanation = $explanation;
  1138. $receipt->executeCopy = $executeDetail ['staff'];
  1139. $loanReceipt->update ( array (
  1140. 'where' => 'rid=' . $receiptDetail ['loanRid']
  1141. ) );
  1142. }
  1143. return "/saeaBorad";
  1144. }
  1145. function saeaLoanReceiptAdd() {
  1146. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1147. Doo::loadModel ( 'receipt' );
  1148. $receipt = new receipt ();
  1149. Doo::loadModel ( 'loanReceipt' );
  1150. $loanReceipt = new loanReceipt ();
  1151. Doo::loadModel ( 'L_category' );
  1152. $Lcategory = new L_category ();
  1153. Doo::loadModel ( 'verify' );
  1154. Doo::loadModel ( 'statistics' );
  1155. $statistics = new statistics ();
  1156. $verify = new verify ();
  1157. Doo::loadModel ( 'staff' );
  1158. $staff = new staff ();
  1159. $receiptDetail = $receipt->getOne ( array (
  1160. 'where' => 'rid=' . $rid,
  1161. 'desc' => 'rid',
  1162. 'asArray' => true
  1163. ) );
  1164. $receiptList = $loanReceipt->find ( array (
  1165. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1166. 'desc' => 'rid',
  1167. 'asArray' => true
  1168. ) );
  1169. $Locate = 0;
  1170. $roleId = 0;
  1171. $button = 0;
  1172. foreach ( $receiptList as $key => $value ) {
  1173. $receiptList [$key] ['Locate'] = $Locate;
  1174. $Locate ++;
  1175. $receiptList [$key] ['reviseDetail'] = array ();
  1176. if (! empty ( $value ['reviseDetail'] ))
  1177. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1178. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1179. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1180. $categoryDetil = $Lcategory->getOne ( array (
  1181. 'where' => 'cid=' . $value ['cid'],
  1182. 'asArray' => true
  1183. ) );
  1184. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1185. // 检测编辑状态
  1186. $verifyList = $verify->getOne ( array (
  1187. 'where' => 'vid=' . $value ['verify'],
  1188. 'asArray' => true
  1189. ) );
  1190. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1191. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1192. Doo::loadModel ( 'role' );
  1193. $role = new role ();
  1194. $flag = true;
  1195. $roleKey = 0;
  1196. $endStaffArray = array ();
  1197. $roleArrayCopy = array ();
  1198. foreach ( $verifyList as $k => $v ) {
  1199. // init verifyStaff
  1200. if ($v [1] == 'ROLE') {
  1201. if (! empty ( $verifyStaff )) {
  1202. $endStaffArray = end ( $verifyStaff );
  1203. // if ($v[0]==$endStaffArray['nextStaff']){
  1204. // $roleId=$v[0];
  1205. // }
  1206. }
  1207. $roleVerify = json_decode ( $v [3], true );
  1208. $roleKey = $k;
  1209. $roleArray = array ();
  1210. $rolename = $role->getOne ( array (
  1211. 'where' => 'rid=' . $v [0],
  1212. 'asArray' => true
  1213. ) );
  1214. foreach ( $roleVerify as $o => $p ) {
  1215. $staffID = explode ( '_', $p );
  1216. $staffInfo = $staff->getOne ( array (
  1217. 'where' => 'sid=' . $staffID [0],
  1218. 'asArray' => true
  1219. ) );
  1220. // print_r($staffID);
  1221. $exp = array (
  1222. 0 => $staffInfo ['sid'],
  1223. 1 => $staffID [1],
  1224. 2 => $staffInfo ['avatar'],
  1225. 'date' => '',
  1226. 'date' => '',
  1227. 'opinion' => '',
  1228. 'status' => '',
  1229. 'rolename' => $rolename ['name']
  1230. );
  1231. array_push ( $roleArray, $exp );
  1232. }
  1233. $roleArrayCopy [$v [0]] = $roleArray;
  1234. // $verifyList[$k]['roleArray']=$roleArray;
  1235. }
  1236. $verifyList [$k] ['date'] = "";
  1237. $verifyList [$k] ['opinion'] = "";
  1238. $verifyList [$k] ['status'] = "";
  1239. if (empty ( $verifyStaff )) {
  1240. $verifyList [$k] ['date'] = "";
  1241. $verifyList [$k] ['opinion'] = "";
  1242. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1243. $verifyList [$k] ['status'] = 4;
  1244. $flag = false;
  1245. }
  1246. } else {
  1247. foreach ( $verifyStaff as $m => $u ) {
  1248. if ($v [0] == $m) {
  1249. $verifyList [$k] ['date'] = $u ['date'];
  1250. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1251. $verifyList [$k] ['status'] = $u ['status'];
  1252. $flag = false;
  1253. break;
  1254. }
  1255. }
  1256. $endStaffArray = end ( $verifyStaff );
  1257. if (isset ( $endStaffArray ['ROLE'] )) {
  1258. } else {
  1259. // $endKey=key($verifyStaff);
  1260. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1261. // $button=4;
  1262. // $verifyList[$k]['status']=4;
  1263. // }
  1264. }
  1265. }
  1266. }
  1267. $rolename ['name'] = '';
  1268. if (! empty ( $roleId )) {
  1269. Doo::loadModel ( 'role' );
  1270. $role = new role ();
  1271. $rolename = $role->getOne ( array (
  1272. 'where' => 'rid=' . $roleId,
  1273. 'asArray' => true
  1274. ) );
  1275. }
  1276. if (! empty ( $verifyStaff ))
  1277. $endStaffArray = end ( $verifyStaff );
  1278. $KOP = false;
  1279. foreach ( $roleArrayCopy as $P => $A ) {
  1280. foreach ( $A as $MKI => $AVL ) {
  1281. if (! empty ( $verifyStaff )) {
  1282. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1283. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1284. $button = 4;
  1285. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1286. }
  1287. foreach ( $verifyStaff as $m => $u ) {
  1288. $AVLFK = $AVL [0] . '_R';
  1289. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1290. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1291. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1292. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1293. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1294. break;
  1295. }
  1296. }
  1297. } else {
  1298. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1299. $button = 4;
  1300. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1301. }
  1302. }
  1303. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1304. $KOP = true;
  1305. }
  1306. }
  1307. foreach ( $roleArrayCopy as $k => $v ) {
  1308. foreach ( $verifyList as $m => $n ) {
  1309. if ($n [0] == $k) {
  1310. array_splice ( $verifyList, $m, 1, $v );
  1311. }
  1312. }
  1313. }
  1314. $receiptList [$key] ['verifyList'] = $verifyList;
  1315. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1316. 'where' => 'sid=' . $value ['staff'],
  1317. 'asArray' => true
  1318. ) );
  1319. $receiptList [$key] ['button'] = $button;
  1320. //
  1321. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1322. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1323. }
  1324. $data ['receiptList'] = $receiptList;
  1325. $data ['receiptDetail'] = $receiptDetail;
  1326. Doo::loadModel ( 'L_category' );
  1327. $lCategory = new L_category ();
  1328. Doo::loadModel ( 'accountItem' );
  1329. $accountItem = new accountItem ();
  1330. $acItem = $accountItem->find ( array (
  1331. 'asArray' => true
  1332. ) );
  1333. $veList = $verify->find ( array (
  1334. 'asArray' => true
  1335. ) );
  1336. foreach ( $veList as $key => $value ) {
  1337. $v = json_decode ( $value ['staff'] );
  1338. $list = array ();
  1339. foreach ( $v as $n => $m ) {
  1340. if ($m ['1'] == 'ROLE') {
  1341. $roleInfo = $role->getOne ( array (
  1342. 'where' => 'rid=' . $m [0],
  1343. 'asArray' => true
  1344. ) );
  1345. $v [$n] [1] = $roleInfo ['name'];
  1346. array_push ( $list, $roleInfo ['name'] );
  1347. } else {
  1348. array_push ( $list, $v [$n] [1] );
  1349. }
  1350. }
  1351. $veList [$key] ['staff'] = implode ( '>', $list );
  1352. }
  1353. $data ['rid'] = $rid;
  1354. $data ['category'] = $lCategory->find ( array (
  1355. 'asArray' => true
  1356. ) );
  1357. $data ['veList'] = $veList;
  1358. $data ['acItem'] = $acItem;
  1359. $data ['memu'] = "receipt";
  1360. $data ['staff'] = $this->staff;
  1361. $data ['receiptMemu'] = 'saeaBorad';
  1362. $data ['verifyId'] = $this->verifyId;
  1363. $data ['executeId'] = $this->executeId;
  1364. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1365. }
  1366. function saeaLoanReceiptAddDo() {
  1367. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1368. $agency = $this->get_args ( 'agency' );
  1369. $travel = $this->get_args ( 'travel' );
  1370. $train = $this->get_args ( 'train' );
  1371. $other = $this->get_args ( 'other' );
  1372. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1373. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1374. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1375. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1376. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1377. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1378. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1379. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1380. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1381. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1382. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1383. header ( 'Content-Type:text/html;charset=utf-8' );
  1384. die ( '请填写联行号' );
  1385. }
  1386. Doo::loadModel ( 'receipt' );
  1387. Doo::loadModel ( 'receiptDetail' );
  1388. Doo::loadModel ( 'accountItem' );
  1389. $accountItem = new accountItem ();
  1390. $receipt = new receipt ();
  1391. Doo::loadModel ( 'enclosur' );
  1392. Doo::loadModel ( 'execute' );
  1393. $execute = new execute ();
  1394. $executeDetail = $execute->getOne ( array (
  1395. 'where' => 'mold="借款费用执行人"',
  1396. 'asArray' => true
  1397. ) );
  1398. $receiptDet = $receipt->getOne ( array (
  1399. 'where' => 'rid=' . $rid,
  1400. 'asArray' => true
  1401. ) );
  1402. // if(!empty($receiptDetail))
  1403. // return "/referReceipt/".$receiptDetail['rid'];
  1404. $aItem = $accountItem->find ( array (
  1405. 'asArray' => true
  1406. ) );
  1407. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1408. $ag = $tr = $ta = $ot = 0;
  1409. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1410. foreach ( $aItem as $key => $value ) {
  1411. if ($value ['category'] == $this->AGENCY) {
  1412. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1413. array_push ( $accountJson [$this->AGENCY], array (
  1414. 'aid' => $value ['aid'],
  1415. 'name' => $value ['name'],
  1416. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1417. ) );
  1418. $sum += $agency [$ag];
  1419. $agencySum += $agency [$ag];
  1420. }
  1421. $ag ++;
  1422. }
  1423. if ($value ['category'] == $this->TRAVEL) {
  1424. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1425. array_push ( $accountJson [$this->TRAVEL], array (
  1426. 'aid' => $value ['aid'],
  1427. 'name' => $value ['name'],
  1428. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1429. ) );
  1430. $sum += $travel [$tr];
  1431. $travelSum += $travel [$tr];
  1432. }
  1433. $tr ++;
  1434. }
  1435. if ($value ['category'] == $this->TRAIN) {
  1436. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1437. array_push ( $accountJson [$this->TRAIN], array (
  1438. 'aid' => $value ['aid'],
  1439. 'name' => $value ['name'],
  1440. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1441. ) );
  1442. $sum += $train [$ta];
  1443. $trainSum += $train [$ta];
  1444. }
  1445. $ta ++;
  1446. }
  1447. if ($value ['category'] == $this->OTHER) {
  1448. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1449. array_push ( $accountJson [$this->OTHER], array (
  1450. 'aid' => $value ['aid'],
  1451. 'name' => $value ['name'],
  1452. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1453. ) );
  1454. $sum += $other [$ot];
  1455. $otherSum += $other [$ot];
  1456. }
  1457. $ot ++;
  1458. }
  1459. }
  1460. $accountJson ['cSum'] = array (
  1461. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1462. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1463. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1464. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1465. );
  1466. // 报销单
  1467. $receipt->accountItem = json_encode ( $accountJson );
  1468. $receipt->staff = $this->staff [0] ['sid'];
  1469. $receipt->loanSum = $receiptDet ['sum'];
  1470. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1471. $receipt->date = date ( "Y-m-d" );
  1472. $receipt->pastDate = '';
  1473. $receipt->cid = $cid;
  1474. $receipt->status = 7;
  1475. // 修改审批流程加入角色
  1476. $receipt->verify = $verify;
  1477. $receipt->verifyStaff = '';
  1478. $receipt->executeStaff = '';
  1479. $receipt->executeCopy = $executeDetail ['staff'];
  1480. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1481. $receipt->explanation = $explanation;
  1482. $receipt->remittanceName = $remittanceName;
  1483. $receipt->bankName = $bankName;
  1484. $receipt->bankNumber = $bankNumber;
  1485. $receipt->remittanceBankType = $remittanceBankType;
  1486. if ($remittanceBankType == 1)
  1487. $receipt->coupletNumber = $coupletNumber;
  1488. $receipt->update ( array (
  1489. 'where' => 'rid=' . $rid
  1490. ) );
  1491. // 附件
  1492. if (! empty ( $enclosurName )) {
  1493. $enclosurArray = explode ( '-', $enclosurName );
  1494. foreach ( $enclosurArray as $value ) {
  1495. $enclosur = new enclosur ();
  1496. $enclosur->name = $value;
  1497. $enclosur->rid = $rid;
  1498. $enclosur->insert ();
  1499. }
  1500. // print_r($enclosurArray);die;
  1501. }
  1502. // 报销详情
  1503. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1504. $receiptDetail = new receiptDetail ();
  1505. $receiptDetail->staff = $this->staff [0] ['sid'];
  1506. $receiptDetail->item = $value ['name'];
  1507. $receiptDetail->itemCategory = $this->AGENCY;
  1508. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1509. $receiptDetail->date = date ( "Y-m-d" );
  1510. $receiptDetail->cid = $cid;
  1511. $receiptDetail->rid = $rid;
  1512. $receiptDetail->status = 4;
  1513. $receiptDetail->insert ();
  1514. }
  1515. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1516. $receiptDetail = new receiptDetail ();
  1517. $receiptDetail->staff = $this->staff [0] ['sid'];
  1518. $receiptDetail->item = $value ['name'];
  1519. $receiptDetail->itemCategory = $this->TRAVEL;
  1520. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1521. $receiptDetail->date = date ( "Y-m-d" );
  1522. $receiptDetail->cid = $cid;
  1523. $receiptDetail->rid = $rid;
  1524. $receiptDetail->status = 4;
  1525. $receiptDetail->insert ();
  1526. }
  1527. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1528. $receiptDetail = new receiptDetail ();
  1529. $receiptDetail->staff = $this->staff [0] ['sid'];
  1530. $receiptDetail->item = $value ['name'];
  1531. $receiptDetail->itemCategory = $this->TRAIN;
  1532. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1533. $receiptDetail->date = date ( "Y-m-d" );
  1534. $receiptDetail->cid = $cid;
  1535. $receiptDetail->rid = $rid;
  1536. $receiptDetail->status = 4;
  1537. $receiptDetail->insert ();
  1538. }
  1539. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1540. $receiptDetail = new receiptDetail ();
  1541. $receiptDetail->staff = $this->staff [0] ['sid'];
  1542. $receiptDetail->item = $value ['name'];
  1543. $receiptDetail->itemCategory = $this->OTHER;
  1544. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1545. $receiptDetail->date = date ( "Y-m-d" );
  1546. $receiptDetail->cid = $cid;
  1547. $receiptDetail->rid = $rid;
  1548. $receiptDetail->status = 4;
  1549. $receiptDetail->insert ();
  1550. }
  1551. return "/saeaBorad";
  1552. }
  1553. return "/saeaLoanReceiptAdd/" . $rid;
  1554. }
  1555. function saeaLoanReceiptEdi() {
  1556. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1557. Doo::loadClass ( 'XDeode' );
  1558. $XDeode = new XDeode ( 7 );
  1559. $rid = $XDeode->decode ( $ridKey );
  1560. if (! is_numeric ( $rid ))
  1561. die ( 'illegal request' );
  1562. Doo::loadModel ( 'accountItem' );
  1563. Doo::loadModel ( 'verify' );
  1564. Doo::loadModel ( 'receipt' );
  1565. $receipt = new receipt ();
  1566. $verify = new verify ();
  1567. $accountItem = new accountItem ();
  1568. Doo::loadModel ( 'L_category' );
  1569. $Lcategory = new L_category ();
  1570. Doo::loadModel ( "role" );
  1571. $role = new role ();
  1572. Doo::loadModel ( 'loanReceipt' );
  1573. $loanReceipt = new loanReceipt ();
  1574. Doo::loadModel ( 'staff' );
  1575. $staff = new staff ();
  1576. $receiptDetail = $receipt->getOne ( array (
  1577. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1578. 'asArray' => true
  1579. ) );
  1580. if (empty ( $receiptDetail ))
  1581. return "/saeaBorad";
  1582. $receiptList = $loanReceipt->find ( array (
  1583. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1584. 'desc' => 'rid',
  1585. 'asArray' => true
  1586. ) );
  1587. $Locate = 0;
  1588. $roleId = 0;
  1589. $button = 0;
  1590. foreach ( $receiptList as $key => $value ) {
  1591. $receiptList [$key] ['Locate'] = $Locate;
  1592. $Locate ++;
  1593. $receiptList [$key] ['reviseDetail'] = array ();
  1594. if (! empty ( $value ['reviseDetail'] ))
  1595. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1596. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1597. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1598. $categoryDetil = $Lcategory->getOne ( array (
  1599. 'where' => 'cid=' . $value ['cid'],
  1600. 'asArray' => true
  1601. ) );
  1602. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1603. // 检测编辑状态
  1604. $verifyList = $verify->getOne ( array (
  1605. 'where' => 'vid=' . $value ['verify'],
  1606. 'asArray' => true
  1607. ) );
  1608. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1609. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1610. Doo::loadModel ( 'role' );
  1611. $role = new role ();
  1612. $flag = true;
  1613. $roleKey = 0;
  1614. $endStaffArray = array ();
  1615. $roleArrayCopy = array ();
  1616. foreach ( $verifyList as $k => $v ) {
  1617. // init verifyStaff
  1618. if ($v [1] == 'ROLE') {
  1619. if (! empty ( $verifyStaff )) {
  1620. $endStaffArray = end ( $verifyStaff );
  1621. // if ($v[0]==$endStaffArray['nextStaff']){
  1622. // $roleId=$v[0];
  1623. // }
  1624. }
  1625. $roleVerify = json_decode ( $v [3], true );
  1626. $roleKey = $k;
  1627. $roleArray = array ();
  1628. $rolename = $role->getOne ( array (
  1629. 'where' => 'rid=' . $v [0],
  1630. 'asArray' => true
  1631. ) );
  1632. foreach ( $roleVerify as $o => $p ) {
  1633. $staffID = explode ( '_', $p );
  1634. $staffInfo = $staff->getOne ( array (
  1635. 'where' => 'sid=' . $staffID [0],
  1636. 'asArray' => true
  1637. ) );
  1638. // print_r($staffID);
  1639. $exp = array (
  1640. 0 => $staffInfo ['sid'],
  1641. 1 => $staffID [1],
  1642. 2 => $staffInfo ['avatar'],
  1643. 'date' => '',
  1644. 'date' => '',
  1645. 'opinion' => '',
  1646. 'status' => '',
  1647. 'rolename' => $rolename ['name']
  1648. );
  1649. array_push ( $roleArray, $exp );
  1650. }
  1651. $roleArrayCopy [$v [0]] = $roleArray;
  1652. // $verifyList[$k]['roleArray']=$roleArray;
  1653. }
  1654. $verifyList [$k] ['date'] = "";
  1655. $verifyList [$k] ['opinion'] = "";
  1656. $verifyList [$k] ['status'] = "";
  1657. if (empty ( $verifyStaff )) {
  1658. $verifyList [$k] ['date'] = "";
  1659. $verifyList [$k] ['opinion'] = "";
  1660. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1661. $verifyList [$k] ['status'] = 4;
  1662. $flag = false;
  1663. }
  1664. } else {
  1665. foreach ( $verifyStaff as $m => $u ) {
  1666. if ($v [0] == $m) {
  1667. $verifyList [$k] ['date'] = $u ['date'];
  1668. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1669. $verifyList [$k] ['status'] = $u ['status'];
  1670. $flag = false;
  1671. break;
  1672. }
  1673. }
  1674. $endStaffArray = end ( $verifyStaff );
  1675. if (isset ( $endStaffArray ['ROLE'] )) {
  1676. } else {
  1677. // $endKey=key($verifyStaff);
  1678. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1679. // $button=4;
  1680. // $verifyList[$k]['status']=4;
  1681. // }
  1682. }
  1683. }
  1684. }
  1685. $rolename ['name'] = '';
  1686. if (! empty ( $roleId )) {
  1687. Doo::loadModel ( 'role' );
  1688. $role = new role ();
  1689. $rolename = $role->getOne ( array (
  1690. 'where' => 'rid=' . $roleId,
  1691. 'asArray' => true
  1692. ) );
  1693. }
  1694. if (! empty ( $verifyStaff ))
  1695. $endStaffArray = end ( $verifyStaff );
  1696. $KOP = false;
  1697. foreach ( $roleArrayCopy as $P => $A ) {
  1698. foreach ( $A as $MKI => $AVL ) {
  1699. if (! empty ( $verifyStaff )) {
  1700. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1701. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1702. $button = 4;
  1703. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1704. }
  1705. foreach ( $verifyStaff as $m => $u ) {
  1706. $AVLFK = $AVL [0] . '_R';
  1707. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1708. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1709. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1710. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1711. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1712. break;
  1713. }
  1714. }
  1715. } else {
  1716. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1717. $button = 4;
  1718. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1719. }
  1720. }
  1721. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1722. $KOP = true;
  1723. }
  1724. }
  1725. foreach ( $roleArrayCopy as $k => $v ) {
  1726. foreach ( $verifyList as $m => $n ) {
  1727. if ($n [0] == $k) {
  1728. array_splice ( $verifyList, $m, 1, $v );
  1729. }
  1730. }
  1731. }
  1732. $receiptList [$key] ['verifyList'] = $verifyList;
  1733. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1734. 'where' => 'sid=' . $value ['staff'],
  1735. 'asArray' => true
  1736. ) );
  1737. $receiptList [$key] ['button'] = $button;
  1738. //
  1739. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1740. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1741. }
  1742. $data ['receiptList'] = $receiptList;
  1743. $acItem = $accountItem->find ( array (
  1744. 'asArray' => true
  1745. ) );
  1746. $veList = $verify->find ( array (
  1747. 'asArray' => true
  1748. ) );
  1749. foreach ( $veList as $key => $value ) {
  1750. $v = json_decode ( $value ['staff'] );
  1751. $list = array ();
  1752. foreach ( $v as $n => $m ) {
  1753. if ($m ['1'] == 'ROLE') {
  1754. $roleInfo = $role->getOne ( array (
  1755. 'where' => 'rid=' . $m [0],
  1756. 'asArray' => true
  1757. ) );
  1758. $v [$n] [1] = $roleInfo ['name'];
  1759. array_push ( $list, $roleInfo ['name'] );
  1760. } else {
  1761. array_push ( $list, $v [$n] [1] );
  1762. }
  1763. }
  1764. $veList [$key] ['staff'] = implode ( '>', $list );
  1765. }
  1766. // 配置编辑信息
  1767. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1768. foreach ( $acItem as $key => $value ) {
  1769. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1770. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1771. $acItem [$key] ['price'] = $v ['price'];
  1772. }
  1773. }
  1774. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1775. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1776. $acItem [$key] ['price'] = $v ['price'];
  1777. }
  1778. }
  1779. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1780. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1781. $acItem [$key] ['price'] = $v ['price'];
  1782. }
  1783. }
  1784. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1785. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1786. $acItem [$key] ['price'] = $v ['price'];
  1787. }
  1788. }
  1789. }
  1790. $data ['category'] = $Lcategory->find ( array (
  1791. 'asArray' => true
  1792. ) );
  1793. $data ['ridKey'] = $ridKey;
  1794. $data ['cSum'] = $accountItemList ['cSum'];
  1795. $data ['sum'] = $receiptDetail ['sum'];
  1796. $data ['receiptDetail'] = $receiptDetail;
  1797. $data ['veList'] = $veList;
  1798. $data ['acItem'] = $acItem;
  1799. $data ['memu'] = "receipt";
  1800. $data ['staff'] = $this->staff;
  1801. $data ['receiptMemu'] = 'saeaBorad';
  1802. $data ['verify'] = $receiptDetail ['verify'];
  1803. $data ['verifyId'] = $this->verifyId;
  1804. $data ['executeId'] = $this->executeId;
  1805. $data ['rid'] = $rid;
  1806. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1807. }
  1808. /**
  1809. * 培训班结算
  1810. */
  1811. function receiptTrainAdd() {
  1812. Doo::loadModel ( 'accountItem' );
  1813. $accountItem = new accountItem ();
  1814. $acItem = $accountItem->find ( array (
  1815. 'asArray' => true
  1816. ) );
  1817. // 审批组
  1818. Doo::loadModel ( 'verify' );
  1819. $verify = new verify ();
  1820. $veList = $verify->getVerifyByAll ();
  1821. // 办事处
  1822. Doo::loadModel ( 'L_category' );
  1823. $lCategory = new L_category ();
  1824. $data ['category'] = $lCategory->getCategory ();
  1825. $data ['veList'] = $veList;
  1826. $data ['memu'] = "receipt";
  1827. $data ['staff'] = $this->staff;
  1828. $data ['acItem'] = $acItem;
  1829. $data ['receiptMemu'] = 'saeaBorad';
  1830. $data ['verifyId'] = $this->verifyId;
  1831. $data ['executeId'] = $this->executeId;
  1832. $this->render ( "/receipt/receiptTrainAdd", $data );
  1833. }
  1834. /**
  1835. * 添加培训班结算
  1836. */
  1837. function receiptTrainAddDo() {
  1838. // 培训班信息
  1839. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  1840. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  1841. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  1842. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  1843. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  1844. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  1845. // 发票信息
  1846. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1847. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  1848. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1849. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1850. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1851. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1852. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1853. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $participants ) && ! empty ( $trainAddress )) {
  1854. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1855. header ( 'Content-Type:text/html;charset=utf-8' );
  1856. die ( '请填写联行号' );
  1857. }
  1858. Doo::loadModel ( 'execute' );
  1859. $execute = new execute ();
  1860. $executeDetail = $execute->getOne ( array (
  1861. 'where' => 'mold="培训班结算"',
  1862. 'asArray' => true
  1863. ) );
  1864. if (empty ( $executeDetail )) {
  1865. header ( 'Content-Type:text/html;charset=utf-8' );
  1866. die ( '未设置执行人' );
  1867. }
  1868. Doo::loadClass ( 'XDeode' );
  1869. $XDeode = new XDeode ( 5 );
  1870. $cid = $XDeode->decode ( $cid );
  1871. Doo::loadModel ( 'receipt' );
  1872. $receipt = new receipt ();
  1873. Doo::loadModel ( 'receiptTraining' );
  1874. $receiptTraining = new receiptTraining ();
  1875. // 创建费用培训班
  1876. $item = array (
  1877. 'cid' => $this->staff [0] ['cid'],
  1878. 'categoryName' => $this->staff [0] ['category'],
  1879. 'trainName' => $trainName,
  1880. 'trainStartDate' => $trainStartDate,
  1881. 'trainEndDate' => $trainEndDate,
  1882. 'participants' => $participants,
  1883. 'trainAddress' => $trainAddress,
  1884. 'trainRemarks' => $trainRemarks,
  1885. 'creator' => $this->staff [0] ['sid'],
  1886. 'creatorDate' => date ( "Y-m-d H:i:s" )
  1887. );
  1888. $irid = $receiptTraining->addReceiptTraining ( $item );
  1889. // 报销单
  1890. $receipt->status = 5;
  1891. $receipt->trainId = $irid;
  1892. $receipt->Rtype = 3;
  1893. $receipt->staff = $this->staff [0] ['sid'];
  1894. $receipt->cid = $cid;
  1895. $receipt->verify = $verify;
  1896. $receipt->date = date ( "Y-m-d" );
  1897. $receipt->executeCopy = $executeDetail ['staff'];
  1898. $receipt->receiptOrder = "#P" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1899. $receipt->remittanceName = $remittanceName;
  1900. $receipt->bankName = $bankName;
  1901. $receipt->bankNumber = $bankNumber;
  1902. $receipt->remittanceBankType = $remittanceBankType;
  1903. if ($remittanceBankType == 1)
  1904. $receipt->coupletNumber = $coupletNumber;
  1905. $rid = $receipt->insert ();
  1906. $XDeode = new XDeode ( 7 );
  1907. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html";
  1908. } else
  1909. die ( 'illegal request' );
  1910. }
  1911. /**
  1912. * 培训班编辑
  1913. */
  1914. function receiptTrainEdi() {
  1915. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  1916. $trainEdiType = $this->get_args ( 'trainEdiType' ) ? $this->get_args ( 'trainEdiType' ) : "INFO";
  1917. Doo::loadClass ( 'XDeode' );
  1918. $XDeode = new XDeode ( 7 );
  1919. $rid = $XDeode->decode ( $ridKey );
  1920. if (! is_numeric ( $rid ))
  1921. die ( 'illegal request' );
  1922. Doo::loadModel ( 'receipt' );
  1923. $receipt = new receipt ();
  1924. Doo::loadModel ( 'receiptTraining' );
  1925. $receiptTraining = new receiptTraining ();
  1926. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  1927. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  1928. die ();
  1929. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  1930. // 汇总表合计
  1931. // 收入合计
  1932. Doo::loadModel ( 'invoiceTraining' );
  1933. $invoiceTraining = new invoiceTraining ();
  1934. $invoiceTrainingDetail = array (
  1935. 'invoiceArriveAmount' => 0,
  1936. 'RIAmount' => 0,
  1937. 'invoiceTotalAmount' => 0 ,
  1938. 'invoiceCompanyAmount'=>0
  1939. );
  1940. if ($receiptDetail ['invoiceTrainId'] != 0) {
  1941. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  1942. }
  1943. // print_r($invoiceTrainingDetail);
  1944. $invoiceArriveAmount = $RIAmount = 0;
  1945. if (! empty ( $invoiceTrainingDetail )) {
  1946. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  1947. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  1948. }
  1949. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  1950. //print_r($invoiceTrainingDetail);
  1951. // 支出项目
  1952. Doo::loadModel ( 'accountItem' );
  1953. $accountItem = new accountItem ();
  1954. // 项目金额合计
  1955. Doo::loadModel ( 'RItem' );
  1956. $RItem = new RItem ();
  1957. // 讲师获得
  1958. Doo::loadModel ( 'RILecturer' );
  1959. $RILecturer = new RILecturer ();
  1960. $RItemList = $RItem->getRItemByRid ( $rid );
  1961. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  1962. // 支出项金额详情
  1963. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  1964. // print_r($aiData);
  1965. // 利润
  1966. $data ['profit'] = $invoiceArriveAmount - $aiData ['total'];
  1967. $data ['companyProfit'] = $data ['profit'] * 0.6;
  1968. $data ['categoryProfit'] = $data ['profit'] * 0.4;
  1969. // print_r($aiData['dataList']);
  1970. $data ['categoryActualExpenditure'] = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  1971. // 备用金
  1972. $sum = 0;
  1973. $data ['receiptLoanDetail'] = array (
  1974. 'sum' => 0
  1975. );
  1976. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  1977. $data ['receiptLoanDetail'] = $receipt->getReceiptByRid ( $receiptDetail ['trainLoanRid'] );
  1978. $sum = $data ['receiptLoanDetail'] ['sum'];
  1979. }
  1980. $data ['payment'] = $sum + $RIAmount - $data ['categoryActualExpenditure'];
  1981. $data ['total'] = $aiData ['total'];
  1982. $data ['aiCount'] = count ( $aiData ['dataList'] ) + 5;
  1983. $data ['aiList'] = $aiData ['dataList'];
  1984. // 占比计算
  1985. if ($invoiceArriveAmount != 0) {
  1986. $data ['totalProportion'] = number_format ( $aiData ['total'] / $invoiceArriveAmount, 4, '.', '' ) * 100;
  1987. $data ['profitProportion'] = number_format ( $data ['profit'] / $invoiceArriveAmount, 4, '.', '' ) * 100;
  1988. $data ['sumProportion'] = number_format ( $sum / $invoiceArriveAmount, 4, '.', '' ) * 100;
  1989. $data ['invoiceTotalAmountProportion'] = number_format ( $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceArriveAmount, 4, '.', '' ) * 100;
  1990. $data ['RIAmountProportion'] = number_format ( $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceArriveAmount, 4, '.', '' ) * 100;
  1991. $data ['companyProfitProportion'] = number_format ( $data ['companyProfit'] / $invoiceArriveAmount, 4, '.', '' ) * 100;
  1992. $data ['categoryProportion'] = number_format ( $data ['categoryProfit'] / $invoiceArriveAmount, 4, '.', '' ) * 100;
  1993. $data ['categoryActualExpenditureProportion'] = number_format ( $data ['categoryActualExpenditure'] / $invoiceArriveAmount, 4, '.', '' ) * 100;
  1994. $data ['paymentProportion'] = number_format ( $data ['payment'] / $invoiceArriveAmount, 4, '.', '' ) * 100;
  1995. } else {
  1996. $data ['totalProportion'] = $data ['profitProportion'] = $data ['sumProportion'] = $data ['invoiceTotalAmountProportion'] = $data ['RIAmountProportion'] = $data ['companyProfitProportion'] = $data ['categoryActualExpenditureProportion'] = $data ['paymentProportion'] = $data ['categoryProportion'] = 0;
  1997. }
  1998. // 审批组
  1999. Doo::loadModel ( 'verify' );
  2000. $verify = new verify ();
  2001. $veList = $verify->getVerifyByAll ();
  2002. // 办事处
  2003. Doo::loadModel ( 'L_category' );
  2004. $lCategory = new L_category ();
  2005. $data ['category'] = $lCategory->getCategory ();
  2006. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2007. $data ['receiptDetail'] = $receiptDetail;
  2008. $data ['veList'] = $veList;
  2009. $data ['trainEdiType'] = $trainEdiType;
  2010. $data ['ridKey'] = $ridKey;
  2011. $data ['memu'] = "receipt";
  2012. $data ['staff'] = $this->staff;
  2013. $data ['receiptMemu'] = 'saeaBorad';
  2014. $data ['verifyId'] = $this->verifyId;
  2015. $data ['executeId'] = $this->executeId;
  2016. $this->render ( "/receipt/receiptTrainEdi", $data );
  2017. }
  2018. /**
  2019. * 培训班借款编辑
  2020. */
  2021. function receiptTrainLoanEdi() {
  2022. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2023. Doo::loadClass ( 'XDeode' );
  2024. $XDeode = new XDeode ( 7 );
  2025. $rid = $XDeode->decode ( $ridKey );
  2026. if (! is_numeric ( $rid ))
  2027. die ( 'illegal request' );
  2028. Doo::loadModel ( 'receipt' );
  2029. $receipt = new receipt ();
  2030. Doo::loadModel ( 'receiptTraining' );
  2031. $receiptTraining = new receiptTraining ();
  2032. Doo::loadModel ( 'verify' );
  2033. $verify = new verify ();
  2034. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2035. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  2036. die ();
  2037. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2038. // 借款详情HTML
  2039. // 获得借款信息
  2040. $receiptLoanHtml = '';
  2041. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  2042. $receiptLoanDetail = $receipt->getReceiptByRid ( $receiptDetail ['trainLoanRid'] );
  2043. // 获得某费用单审批信息
  2044. $verifylist = $verify->getVerifyByRid ( $receiptDetail ['trainLoanRid'] );
  2045. Doo::loadClass ( 'receipt.func' );
  2046. $extendHtml = '<p><a class="button" href="javascript:if(window.confirm(\'确认移除?\'))window.location=\'/receiptTrainLoanRemoveDo/' . $receiptDetail ['ridKey'] . '/' . $receiptDetail ['trainLoanRidKey'] . '.html\'" data-toggle="modal">移除借款</a></p>';
  2047. $receiptLoanHtml = _getReceiptLoanHtml ( $receiptLoanDetail, $verifylist, $extendHtml );
  2048. }
  2049. $data ['receiptLoanHtml'] = $receiptLoanHtml;
  2050. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2051. $data ['receiptDetail'] = $receiptDetail;
  2052. $data ['trainEdiType'] = "LOAN";
  2053. $data ['ridKey'] = $ridKey;
  2054. $data ['memu'] = "receipt";
  2055. $data ['staff'] = $this->staff;
  2056. $data ['receiptMemu'] = 'saeaBorad';
  2057. $data ['verifyId'] = $this->verifyId;
  2058. $data ['executeId'] = $this->executeId;
  2059. $this->render ( "/receipt/receiptTrainLoanEdi", $data );
  2060. }
  2061. /**
  2062. * 更新培训班结算基本信息
  2063. */
  2064. function receiptTrainInfoEdiDo() {
  2065. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  2066. $rtid = $this->get_args ( 'rtid' ) ? $this->get_args ( 'rtid' ) : "";
  2067. // 培训班信息
  2068. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  2069. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  2070. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  2071. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  2072. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  2073. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  2074. // 发票信息
  2075. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2076. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2077. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2078. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2079. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2080. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2081. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2082. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $participants ) && ! empty ( $trainAddress )) {
  2083. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2084. header ( 'Content-Type:text/html;charset=utf-8' );
  2085. die ( '请填写联行号' );
  2086. }
  2087. Doo::loadClass ( 'XDeode' );
  2088. $XDeode = new XDeode ( 5 );
  2089. $cid = $XDeode->decode ( $cid );
  2090. $rtid = $XDeode->decode ( $rtid );
  2091. $rid = $XDeode->decode ( $rid );
  2092. if (! is_numeric ( $rtid ) || ! is_numeric ( $rid )) {
  2093. die ( 'illegal request-IdError' );
  2094. }
  2095. Doo::loadModel ( 'receipt' );
  2096. $receipt = new receipt ();
  2097. Doo::loadModel ( 'receiptTraining' );
  2098. $receiptTraining = new receiptTraining ();
  2099. // 更新费用培训班
  2100. $item = array (
  2101. 'rtid' => $rtid,
  2102. 'trainName' => $trainName,
  2103. 'trainStartDate' => $trainStartDate,
  2104. 'trainEndDate' => $trainEndDate,
  2105. 'participants' => $participants,
  2106. 'trainAddress' => $trainAddress,
  2107. 'trainRemarks' => $trainRemarks
  2108. );
  2109. $irid = $receiptTraining->setReceiptTrainByCondition ( $item );
  2110. // 报销单
  2111. $receipt->rid = $rid;
  2112. $receipt->cid = $cid;
  2113. $receipt->verify = $verify;
  2114. $receipt->remittanceName = $remittanceName;
  2115. $receipt->bankName = $bankName;
  2116. $receipt->bankNumber = $bankNumber;
  2117. $receipt->remittanceBankType = $remittanceBankType;
  2118. if ($remittanceBankType == 1)
  2119. $receipt->coupletNumber = $coupletNumber;
  2120. $receipt->update ();
  2121. $XDeode = new XDeode ( 7 );
  2122. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html?trainEdiType=INFO";
  2123. } else
  2124. die ( 'illegal request' );
  2125. }
  2126. /**
  2127. * 编辑培训班结算---更新借款
  2128. */
  2129. function receiptTrainLoanEdiDo() {
  2130. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2131. $ridLoanKey = $this->get_args ( 'ridLoanKey' ) ? $this->get_args ( 'ridLoanKey' ) : "";
  2132. if (! empty ( $ridKey ) && ! empty ( $ridLoanKey )) {
  2133. Doo::loadModel ( 'receipt' );
  2134. $receipt = new receipt ();
  2135. Doo::loadClass ( 'XDeode' );
  2136. $XDeode = new XDeode ( 5 );
  2137. $rid = $XDeode->decode ( $ridKey );
  2138. $ridLoan = $XDeode->decode ( $ridLoanKey );
  2139. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  2140. die ( 'illegal request-ridError' );
  2141. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2142. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  2143. // 不合法的数据if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  2144. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2145. die ( 'illegal request-receiptError' );
  2146. }
  2147. if ($receiptLoanDetail ['status'] != 8 || $receiptLoanDetail ['Rtype'] != 1) {
  2148. die ( 'illegal request-receipLoantError' );
  2149. }
  2150. // 培训班结算挂钩借款
  2151. $receipt = new receipt ();
  2152. $item = array (
  2153. 'rid' => $rid,
  2154. 'trainLoanRid' => $ridLoan
  2155. );
  2156. $receipt->setReceiptByCondition ( $item );
  2157. // 更新借款状态变成已挂钩
  2158. $receipt = new receipt ();
  2159. $item = array (
  2160. 'rid' => $ridLoan,
  2161. 'status' => 10,
  2162. 'statusTrain' => 1
  2163. );
  2164. $receipt->setReceiptByCondition ( $item );
  2165. $XDeode = new XDeode ( 7 );
  2166. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  2167. } else
  2168. die ( 'illegal request' );
  2169. }
  2170. /**
  2171. * 编辑培训班结算--移除借款
  2172. */
  2173. function receiptTrainLoanRemoveDo() {
  2174. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : 0;
  2175. $ridLoanKey = isset ( $this->params ['ridLoanKey'] ) ? $this->params ['ridLoanKey'] : 0;
  2176. if (! empty ( $ridKey ) || ! empty ( $ridLoanKey )) {
  2177. Doo::loadModel ( 'receipt' );
  2178. $receipt = new receipt ();
  2179. Doo::loadClass ( 'XDeode' );
  2180. $XDeode = new XDeode ( 5 );
  2181. $rid = $XDeode->decode ( $ridKey );
  2182. $ridLoan = $XDeode->decode ( $ridLoanKey );
  2183. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  2184. die ( 'illegal request-ridError' );
  2185. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2186. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  2187. // 不合法的数据 !($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)
  2188. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2189. die ( 'illegal request-receiptError' );
  2190. }
  2191. if ($receiptLoanDetail ['status'] != 10 || $receiptLoanDetail ['Rtype'] != 1) {
  2192. die ( 'illegal request-receipLoantError' );
  2193. }
  2194. // 培训班结算挂钩借款
  2195. $receipt = new receipt ();
  2196. $item = array (
  2197. 'rid' => $rid,
  2198. 'trainLoanRid' => 0
  2199. );
  2200. $receipt->setReceiptByCondition ( $item );
  2201. // 更新借款状态变成已挂钩
  2202. $receipt = new receipt ();
  2203. $item = array (
  2204. 'rid' => $ridLoan,
  2205. 'status' => 8,
  2206. 'statusTrain' => 0
  2207. );
  2208. $receipt->setReceiptByCondition ( $item );
  2209. $XDeode = new XDeode ( 7 );
  2210. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  2211. } else
  2212. die ( 'illegal request' );
  2213. }
  2214. /**
  2215. * 编辑培训班结算 ---开票
  2216. */
  2217. function receiptTrainInvoiceEdi() {
  2218. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2219. Doo::loadClass ( 'XDeode' );
  2220. $XDeode = new XDeode ( 7 );
  2221. $rid = $XDeode->decode ( $ridKey );
  2222. if (! is_numeric ( $rid ))
  2223. die ( 'illegal request' );
  2224. Doo::loadModel ( 'receipt' );
  2225. $receipt = new receipt ();
  2226. Doo::loadModel ( 'receiptTraining' );
  2227. $receiptTraining = new receiptTraining ();
  2228. Doo::loadModel ( 'invoice' );
  2229. $invoice = new invoice ();
  2230. Doo::loadModel ( 'invoiceTraining' );
  2231. $invoiceTraining = new invoiceTraining ();
  2232. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2233. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  2234. die ();
  2235. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2236. $invoiceList = $invoiceTrainingDetail = array ();
  2237. if ($receiptDetail ['invoiceTrainId'] != 0) {
  2238. $invoiceList = $invoice->getInvoicePrintedByItid ( $receiptDetail ['invoiceTrainId'] );
  2239. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  2240. }
  2241. // print_r($invoiceList);
  2242. $data ['invoiceList'] = $invoiceList;
  2243. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  2244. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2245. $data ['receiptDetail'] = $receiptDetail;
  2246. $data ['trainEdiType'] = "INVOICE";
  2247. $data ['ridKey'] = $ridKey;
  2248. $data ['memu'] = "receipt";
  2249. $data ['staff'] = $this->staff;
  2250. $data ['receiptMemu'] = 'saeaBorad';
  2251. $data ['verifyId'] = $this->verifyId;
  2252. $data ['executeId'] = $this->executeId;
  2253. $this->render ( "/receipt/receiptTrainInvoiceEdi", $data );
  2254. }
  2255. /**
  2256. * 编辑培训班结算---更新开票
  2257. */
  2258. function receiptTrainInvoiceEdiDo() {
  2259. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2260. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : "";
  2261. if (! empty ( $ridKey ) && ! empty ( $itidKey )) {
  2262. Doo::loadModel ( 'receipt' );
  2263. $receipt = new receipt ();
  2264. Doo::loadModel ( 'invoiceTraining' );
  2265. $invoiceTraining = new invoiceTraining ();
  2266. Doo::loadClass ( 'XDeode' );
  2267. $XDeode = new XDeode ( 5 );
  2268. $rid = $XDeode->decode ( $ridKey );
  2269. $itid = $XDeode->decode ( $itidKey );
  2270. if (! is_numeric ( $rid ) || ! is_numeric ( $itid ))
  2271. die ( 'illegal request-idError' );
  2272. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2273. $invoiceTrainDetail = $invoiceTraining->getInvoiceTrainingByItid ( $itid );
  2274. // 不合法的数据
  2275. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2276. die ( 'illegal request-receiptError' );
  2277. }
  2278. if (empty ( $invoiceTrainDetail ) || $invoiceTrainDetail ['bindReceipt'] == 1) {
  2279. die ( 'illegal request-receipLoantError' );
  2280. }
  2281. // 培训班结算挂钩借款
  2282. $receipt = new receipt ();
  2283. $item = array (
  2284. 'rid' => $rid,
  2285. 'invoiceTrainId' => $itid
  2286. );
  2287. $receipt->setReceiptByCondition ( $item );
  2288. $invoiceTraining = new invoiceTraining ();
  2289. $item = array (
  2290. 'bindReceipt' => 1,
  2291. 'itid' => $itid
  2292. );
  2293. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  2294. $XDeode = new XDeode ( 7 );
  2295. return "/receiptTrainInvoiceEdi/" . $XDeode->encode ( $rid ) . ".html";
  2296. } else
  2297. die ( 'illegal request' );
  2298. }
  2299. /**
  2300. * 更新培训班结算 收款和取消收款
  2301. */
  2302. function receiptTrainReceivables() {
  2303. $doType = isset ( $this->params ['doType'] ) ? $this->params ['doType'] : '';
  2304. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2305. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  2306. Doo::loadClass ( 'XDeode' );
  2307. $XDeode = new XDeode ( 5 );
  2308. $rid = $XDeode->decode ( $ridKey );
  2309. $iid = $XDeode->decode ( $iidKey );
  2310. if (! is_numeric ( $rid ) || ! is_numeric ( $iid ))
  2311. die ( 'illegal request-iid' );
  2312. Doo::loadModel ( 'RIExtend' );
  2313. $RIExtend = new RIExtend ();
  2314. if ($doType == 'CONFIRM') {
  2315. $RIExtend->rid = $rid;
  2316. $RIExtend->iid = $iid;
  2317. $RIExtend->RIstatus = 1;
  2318. $RIExtend->insert ();
  2319. $XDeode = new XDeode ( 7 );
  2320. return '/receiptTrainInvoiceEdi/' . $XDeode->encode ( $rid ) . '.html';
  2321. } elseif ($doType == 'CANCEL') {
  2322. $RIExtend->delete ( array (
  2323. 'where' => 'rid=' . $rid . ' and iid=' . $iid,
  2324. 'limit' => 1
  2325. ) );
  2326. $XDeode = new XDeode ( 7 );
  2327. return '/receiptTrainInvoiceEdi/' . $XDeode->encode ( $rid ) . '.html';
  2328. } else {
  2329. die ( 'illegal request' );
  2330. }
  2331. }
  2332. /**
  2333. * 移除挂钩的培训班发票
  2334. */
  2335. function receiptTrainReceivablesDelDo() {
  2336. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  2337. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : ""; // 发票培训班
  2338. Doo::loadModel ( 'receipt' );
  2339. $receipt = new receipt ();
  2340. Doo::loadModel ( 'RIExtend' );
  2341. $RIExtend = new RIExtend ();
  2342. Doo::loadClass ( 'XDeode' );
  2343. $XDeode = new XDeode ( 5 );
  2344. $rid = $XDeode->decode ( $ridKey );
  2345. $itid = $XDeode->decode ( $itidKey );
  2346. if (is_numeric ( $rid ) && is_numeric ( $itid )) {
  2347. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2348. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  2349. die ( 'illegal request-status' );
  2350. }
  2351. $receipt = new receipt ();
  2352. $receipt->rid = $rid;
  2353. $receipt->invoiceTrainId = 0;
  2354. $receipt->update ();
  2355. Doo::loadModel ( 'invoiceTraining' );
  2356. $invoiceTraining = new invoiceTraining ();
  2357. $item = array (
  2358. 'bindReceipt' => 0,
  2359. 'itid' => $itid
  2360. );
  2361. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  2362. $RIExtend->delete ( array (
  2363. 'where' => 'rid=' . $rid
  2364. ) );
  2365. $XDeode = new XDeode ( 7 );
  2366. return '/receiptTrainInvoiceEdi/' . $XDeode->encode ( $rid ) . '.html';
  2367. } else
  2368. die ( 'illegal request-iid' );
  2369. }
  2370. /**
  2371. * 编辑培训班结算
  2372. */
  2373. function receiptTrainItemEdi() {
  2374. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2375. Doo::loadClass ( 'XDeode' );
  2376. $XDeode = new XDeode ( 7 );
  2377. $rid = $XDeode->decode ( $ridKey );
  2378. if (! is_numeric ( $rid ))
  2379. die ( 'illegal request' );
  2380. Doo::loadModel ( 'receipt' );
  2381. $receipt = new receipt ();
  2382. Doo::loadModel ( 'receiptTraining' );
  2383. $receiptTraining = new receiptTraining ();
  2384. Doo::loadModel ( 'RItem' );
  2385. $RItem = new RItem ();
  2386. Doo::loadModel ( 'accountItem' );
  2387. $accountItem = new accountItem ();
  2388. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2389. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  2390. die ();
  2391. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2392. $RItemList = $RItem->getRItemByRid ( $rid );
  2393. $aiList = $accountItem->getAccountBookByCategory ( '培训班费用' );
  2394. // foreach ($aiList as $key=>$value){//不需要添加税款,在添加收入时自动添加
  2395. // if($value['name']=='税款'){
  2396. // unset($aiList[$key]);break;
  2397. // }
  2398. // }
  2399. //print_r($aiList);
  2400. $data ['RItemList'] = $RItemList;
  2401. $data ['aiList'] = $aiList;
  2402. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2403. $data ['receiptDetail'] = $receiptDetail;
  2404. $data ['trainEdiType'] = "ITEM";
  2405. $data ['ridKey'] = $ridKey;
  2406. $data ['memu'] = "receipt";
  2407. $data ['staff'] = $this->staff;
  2408. $data ['receiptMemu'] = 'saeaBorad';
  2409. $data ['verifyId'] = $this->verifyId;
  2410. $data ['executeId'] = $this->executeId;
  2411. $this->render ( "/receipt/receiptTrainItemEdi", $data );
  2412. }
  2413. /**
  2414. * 添加支出项 需要修改 费用金额合计
  2415. */
  2416. function receiptTrainItemAddDo() {
  2417. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2418. // 支出项信息
  2419. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  2420. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  2421. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  2422. $inputer = $this->get_args ( 'inputer' ) ? $this->get_args ( 'inputer' ) : "";
  2423. $describe = $this->get_args ( 'describe' ) ? $this->get_args ( 'describe' ) : "";
  2424. $payType = isset ( $this->params ['payType'] ) ? $this->params ['payType'] : '';
  2425. if (! empty ( $ridKey ) && ! empty ( $item ) && ! empty ( $price ) && ! empty ( $date ) && ! empty ( $inputer )) {
  2426. Doo::loadClass ( 'XDeode' );
  2427. $XDeode = new XDeode ( 5 );
  2428. Doo::loadModel ( 'RItem' );
  2429. $RItem = new RItem ();
  2430. $rid = $XDeode->decode ( $ridKey );
  2431. if (! is_numeric ( $rid ))
  2432. die ( 'illegal request' );
  2433. if($payType=='company'){
  2434. $RItem->payType = 1;
  2435. }
  2436. $RItem->rid = $rid;
  2437. $RItem->item = $item;
  2438. $RItem->price = $price;
  2439. $RItem->date = $date;
  2440. $RItem->inputer = $inputer;
  2441. $RItem->describe = $describe;
  2442. $RItem->insert ();
  2443. // 添加公司汇总
  2444. // 报销详情
  2445. Doo::loadModel ( 'receiptDetail' );
  2446. $receiptDetail = new receiptDetail ();
  2447. Doo::loadModel ( 'receipt' );
  2448. $receipt = new receipt ();
  2449. $rInfo = $receipt->getReceiptByRid ( $rid );
  2450. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, $item, '培训班费用' );
  2451. if (empty ( $rdInfo )) {
  2452. $receiptDetail = new receiptDetail ();
  2453. $receiptDetail->staff = $this->staff [0] ['sid'];
  2454. $receiptDetail->item = $item;
  2455. $receiptDetail->itemCategory = '培训班费用';
  2456. $receiptDetail->price = number_format ( $price, 2, '.', '' );
  2457. $receiptDetail->date = date ( "Y-m-d" );
  2458. $receiptDetail->cid = $rInfo ['cid'];
  2459. $receiptDetail->rid = $rid;
  2460. $receiptDetail->status = 4;
  2461. $receiptDetail->insert ();
  2462. } else {
  2463. $receiptDetail = new receiptDetail ();
  2464. $rdInfo ['price'] += number_format ( $price, 2, '.', '' );
  2465. $receiptDetail->price = $rdInfo ['price'];
  2466. $receiptDetail->update ( array (
  2467. 'where' => 'rid=' . $rid . ' and item like "' . $item . '" and itemCategory like "培训班费用"'
  2468. ) );
  2469. }
  2470. //更新费用合计金额
  2471. $receipt = new receipt ();
  2472. $receipt->sum=$rInfo['sum']+number_format ( $price, 2, '.', '' );
  2473. $receipt->update ( array (
  2474. 'where' => 'rid=' . $rid
  2475. ) );
  2476. $XDeode = new XDeode ( 7 );
  2477. if($payType=='company'){
  2478. return '/receiptTrainItem/approval/' . $XDeode->encode ( $rid ) . '.html';
  2479. }else{
  2480. return '/receiptTrainItemEdi/' . $XDeode->encode ( $rid ) . '.html';
  2481. }
  2482. } else
  2483. die ( 'illegal request' );
  2484. }
  2485. /**
  2486. * 培训班结算-讲师
  2487. */
  2488. function receiptTrainLecturerEdi() {
  2489. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2490. Doo::loadClass ( 'XDeode' );
  2491. $XDeode = new XDeode ( 7 );
  2492. $rid = $XDeode->decode ( $ridKey );
  2493. if (! is_numeric ( $rid ))
  2494. die ( 'illegal request' );
  2495. Doo::loadModel ( 'receipt' );
  2496. $receipt = new receipt ();
  2497. Doo::loadModel ( 'receiptTraining' );
  2498. $receiptTraining = new receiptTraining ();
  2499. Doo::loadModel ( 'RILecturer' );
  2500. $RILecturer = new RILecturer ();
  2501. Doo::loadModel ( 'lecturer' );
  2502. $lecturer = new lecturer ();
  2503. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2504. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  2505. die ();
  2506. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2507. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2508. $lecturerList = $lecturer->getLecturerAll ();
  2509. $INSIDEhtml = $OUTSIDEhtml = '';
  2510. foreach ( $lecturerList as $key => $value ) {
  2511. if ($value ['ltype'] == 'INSIDE') {
  2512. $INSIDEhtml .= '<option value="' . $value ['category'] . '-' . $value ['staff'] . '">' . $value ['category'] . '-' . $value ['staff'] . '</option>';
  2513. } elseif ($value ['ltype'] == 'OUTSIDE') {
  2514. $OUTSIDEhtml .= '<option value="' . $value ['staff'] . '">' . $value ['staff'] . '</option>';
  2515. }
  2516. }
  2517. $data ['INSIDEhtml'] = $INSIDEhtml;
  2518. $data ['OUTSIDEhtml'] = $OUTSIDEhtml;
  2519. // print_r($RItemList);
  2520. $data ['RILecturerList'] = $RILecturerList;
  2521. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2522. $data ['receiptDetail'] = $receiptDetail;
  2523. $data ['trainEdiType'] = "LECTURER";
  2524. $data ['ridKey'] = $ridKey;
  2525. $data ['memu'] = "receipt";
  2526. $data ['staff'] = $this->staff;
  2527. $data ['receiptMemu'] = 'saeaBorad';
  2528. $data ['verifyId'] = $this->verifyId;
  2529. $data ['executeId'] = $this->executeId;
  2530. $this->render ( "/receipt/receiptTrainLecturerEdi", $data );
  2531. }
  2532. /**
  2533. * 添加讲师
  2534. */
  2535. function receiptTrainLecturerAddDo() {
  2536. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2537. // 支出项信息
  2538. $ltype = $this->get_args ( 'ltype' ) ? $this->get_args ( 'ltype' ) : "";
  2539. $lecturerName = $this->get_args ( 'lecturerName' ) ? $this->get_args ( 'lecturerName' ) : "";
  2540. $schoolDay = $this->get_args ( 'schoolDay' ) ? $this->get_args ( 'schoolDay' ) : "";
  2541. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  2542. $taxation = $this->get_args ( 'taxation' ) ? $this->get_args ( 'taxation' ) : "";
  2543. if (! empty ( $ridKey ) && ! empty ( $ltype ) && ! empty ( $lecturerName ) && ! empty ( $schoolDay ) && ! empty ( $price )) {
  2544. Doo::loadClass ( 'XDeode' );
  2545. $XDeode = new XDeode ( 5 );
  2546. Doo::loadModel ( 'RILecturer' );
  2547. $RILecturer = new RILecturer ();
  2548. $rid = $XDeode->decode ( $ridKey );
  2549. if (! is_numeric ( $rid ))
  2550. die ( 'illegal request' );
  2551. if ($ltype == 'OUTSIDE' && empty ( $taxation ))
  2552. die ( 'illegal request-taxationError' );
  2553. $RILecturer->rid = $rid;
  2554. $RILecturer->ltype = $ltype;
  2555. if ($ltype == 'OUTSIDE') {
  2556. if ($taxation == 'TAXATION') {
  2557. $RILecturer->taxation = 1;
  2558. } elseif ($taxation == 'NOTAXATION') {
  2559. $RILecturer->taxation = 0;
  2560. }
  2561. }
  2562. $RILecturer->lecturerName = $lecturerName;
  2563. $RILecturer->schoolDay = $schoolDay;
  2564. $RILecturer->price = $price;
  2565. $RILecturer->insert ();
  2566. // 添加公司汇总
  2567. // 报销详情
  2568. Doo::loadModel ( 'receiptDetail' );
  2569. $receiptDetail = new receiptDetail ();
  2570. Doo::loadModel ( 'receipt' );
  2571. $receipt = new receipt ();
  2572. // 金额总计
  2573. $price = $price * $schoolDay;
  2574. $rInfo = $receipt->getReceiptByRid ( $rid );
  2575. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  2576. if (empty ( $rdInfo )) {
  2577. $receiptDetail = new receiptDetail ();
  2578. $receiptDetail->staff = $this->staff [0] ['sid'];
  2579. $receiptDetail->item = '讲课费';
  2580. $receiptDetail->itemCategory = '培训班费用';
  2581. $receiptDetail->price = number_format ( $price, 2, '.', '' );
  2582. $receiptDetail->date = date ( "Y-m-d" );
  2583. $receiptDetail->cid = $rInfo ['cid'];
  2584. $receiptDetail->rid = $rid;
  2585. $receiptDetail->status = 4;
  2586. $receiptDetail->insert ();
  2587. } else {
  2588. $receiptDetail = new receiptDetail ();
  2589. $rdInfo ['price'] += number_format ( $price, 2, '.', '' );
  2590. $receiptDetail->price = $rdInfo ['price'];
  2591. $receiptDetail->update ( array (
  2592. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  2593. ) );
  2594. }
  2595. $XDeode = new XDeode ( 7 );
  2596. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  2597. } else
  2598. die ( 'illegal request' );
  2599. }
  2600. /**
  2601. * 移除讲师
  2602. */
  2603. function receiptTrainLecturerDelDo() {
  2604. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  2605. $rlidKey = $this->get_args ( 'rlidKey' ) ? $this->get_args ( 'rlidKey' ) : ""; // 发票培训班
  2606. Doo::loadModel ( 'receipt' );
  2607. $receipt = new receipt ();
  2608. Doo::loadModel ( 'RILecturer' );
  2609. $RILecturer = new RILecturer ();
  2610. Doo::loadClass ( 'XDeode' );
  2611. $XDeode = new XDeode ( 5 );
  2612. $rid = $XDeode->decode ( $ridKey );
  2613. $rlid = $XDeode->decode ( $rlidKey );
  2614. if (is_numeric ( $rid ) && is_numeric ( $rlid )) {
  2615. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2616. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  2617. die ( 'illegal request-status' );
  2618. $RILecturer->delete ( array (
  2619. 'where' => 'rid=' . $rid . ' and rlid=' . $rlid
  2620. ) );
  2621. $XDeode = new XDeode ( 7 );
  2622. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  2623. } else
  2624. die ( 'illegal request-iid' );
  2625. }
  2626. /**
  2627. * 培训班提交审批
  2628. */
  2629. function receiptTrainDo() {
  2630. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2631. Doo::loadClass ( 'XDeode' );
  2632. $XDeode = new XDeode ( 7 );
  2633. $rid = $XDeode->decode ( $ridKey );
  2634. Doo::loadModel ( 'receipt' );
  2635. $receipt = new receipt ();
  2636. Doo::loadModel ( 'receiptDetail' );
  2637. $receiptDetail = new receiptDetail ();
  2638. Doo::loadModel ( 'statistics' );
  2639. $statistics = new statistics ();
  2640. Doo::loadModel ( "verify" );
  2641. $verify = new verify ();
  2642. // 审批状态的判定
  2643. $receiptDetailList = $receipt->getOne ( array (
  2644. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  2645. 'asArray' => true
  2646. ) );
  2647. if (empty ( $receiptDetailList ))
  2648. return "/saeaBorad";
  2649. $verifyDetail = $verify->getOne ( array (
  2650. 'where' => ' vid =' . $receiptDetailList ['verify'],
  2651. 'asArray' => true
  2652. ) );
  2653. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  2654. if (empty ( $receiptDetailList ['nowStaff'] )) {
  2655. $nowStaff = "";
  2656. $nowStaffList = array ();
  2657. if ($verifyDetail [0] [1] == 'ROLE') {
  2658. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  2659. foreach ( $vStaffString as $key => $value ) {
  2660. $staffK = explode ( "_", $value );
  2661. array_push ( $nowStaffList, $staffK [0] );
  2662. }
  2663. $nowStaff = implode ( ',', $nowStaffList );
  2664. } else {
  2665. $nowStaff = $verifyDetail [0] [0];
  2666. }
  2667. $receipt->nowStaff = $nowStaff;
  2668. }
  2669. // echo $nowStaff;
  2670. // print_r($verifyDetail);die;
  2671. $receipt->rid = $receiptDetailList ['rid'];
  2672. $receipt->date = date ( "Y-m-d" );
  2673. $receipt->status = 2;
  2674. $receipt->update ();
  2675. $receiptDetail->status = 2;
  2676. $receiptDetail->update ( array (
  2677. 'where' => 'rid=' . $receiptDetailList ['rid']
  2678. ) );
  2679. Doo::loadModel ( "receiptLog" );
  2680. $receiptLog = new receiptLog ();
  2681. Doo::loadModel ( "verify" );
  2682. $verify = new verify ();
  2683. $vr = $verify->getOne ( array (
  2684. 'where' => 'vid=' . $receiptDetailList ['verify'],
  2685. 'asArray' => true
  2686. ) );
  2687. $jd = json_decode ( $vr ['staff'] );
  2688. $roleId = 0;
  2689. foreach ( $jd as $key => $value ) {
  2690. if ($value [1] == 'ROLE') {
  2691. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  2692. if ($pos !== false) {
  2693. $roleId = $value [0];
  2694. }
  2695. }
  2696. }
  2697. // 审批日志
  2698. // echo $roleId;die;
  2699. if (! empty ( $roleId )) {
  2700. Doo::loadModel ( "role" );
  2701. $role = new role ();
  2702. $roleInfo = $role->getOne ( array (
  2703. 'where' => 'rid=' . $roleId,
  2704. 'asArray' => true
  2705. ) );
  2706. // $receiptLog->rolename = $roleInfo ['name'];
  2707. }
  2708. $receiptLog->username = $this->staff [0] ['username'];
  2709. $receiptLog->uid = $this->staff [0] ['sid'];
  2710. $receiptLog->date = date ( "Y-m-d" );
  2711. $receiptLog->opinion = '提交审批';
  2712. $receiptLog->img = $this->staff [0] ['avatar'];
  2713. $receiptLog->status = 2;
  2714. $receiptLog->rid = $rid;
  2715. $receiptLog->insert ();
  2716. // 写入列表项
  2717. Doo::loadModel ( 'accountItem' );
  2718. $accountItem = new accountItem ();
  2719. $aItem = $accountItem->getAccountBookByCategory ( '培训班费用' );
  2720. // 项目金额合计
  2721. Doo::loadModel ( 'RItem' );
  2722. $RItem = new RItem ();
  2723. // 讲师获得
  2724. Doo::loadModel ( 'RILecturer' );
  2725. $RILecturer = new RILecturer ();
  2726. $RItemList = $RItem->getRItemByRid ( $rid );
  2727. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2728. // 支出项金额详情
  2729. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, 0 );
  2730. // print_r($aItem);
  2731. // print_r($aiData);
  2732. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  2733. $ag = $tr = $ta = $ot = 0;
  2734. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  2735. foreach ( $aItem as $key => $value ) {
  2736. if ($value ['category'] == $this->TRAIN) {
  2737. foreach ( $aiData ['dataList'] as $k => $v ) {
  2738. if ($value ['name'] == $v ['name']) {
  2739. array_push ( $accountJson [$this->TRAIN], array (
  2740. 'aid' => $value ['aid'],
  2741. 'name' => $value ['name'],
  2742. 'price' => number_format ( $v ['price'], 2, '.', '' )
  2743. ) );
  2744. $sum += $v ['price'];
  2745. $trainSum += $v ['price'];
  2746. unset ( $aiData ['dataList'] [$k] );
  2747. break;
  2748. }
  2749. }
  2750. }
  2751. }
  2752. $accountJson ['cSum'] = array (
  2753. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  2754. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  2755. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  2756. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  2757. );
  2758. // 报销单
  2759. $receipt = new receipt ();
  2760. $receipt->accountItem = json_encode ( $accountJson );
  2761. $receipt->sum = number_format ( $sum, 2, '.', '' );
  2762. $receipt->update ( array (
  2763. 'where' => 'rid=' . $rid
  2764. ) );
  2765. // print_r($accountJson);
  2766. // statistics item 统计写入
  2767. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  2768. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  2769. $accountItem = $accountJson;
  2770. $stat = $statistics->getOne ( array (
  2771. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  2772. 'asArray' => true
  2773. ) );
  2774. if (empty ( $stat )) {
  2775. $statistics->date = date ( "Y-m-d" );
  2776. $statistics->cid = $this->staff [0] ['cid'];
  2777. $statistics->staff = $this->staff [0] ['sid'];
  2778. $statistics->agPrice = 0;
  2779. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  2780. $statistics->insert ();
  2781. } else {
  2782. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  2783. $statistics->update ( array (
  2784. 'where' => 'sid=' . $stat ['sid']
  2785. ) );
  2786. }
  2787. return "/saeaBorad";
  2788. }
  2789. function confirmation() {
  2790. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2791. Doo::loadModel ( 'receipt' );
  2792. Doo::loadModel ( 'receiptDetail' );
  2793. $receipt = new receipt ();
  2794. $receiptDetail = new receiptDetail ();
  2795. Doo::loadModel ( 'statistics' );
  2796. Doo::loadModel ( 'itemStatistics' );
  2797. $statistics = new statistics ();
  2798. $itemStatistics = new itemStatistics ();
  2799. Doo::loadModel ( "verify" );
  2800. $verify = new verify ();
  2801. $receiptDetailList = $receipt->getOne ( array (
  2802. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  2803. 'asArray' => true
  2804. ) );
  2805. if (empty ( $receiptDetailList ))
  2806. return "/saeaBorad";
  2807. $verifyDetail = $verify->getOne ( array (
  2808. 'where' => ' vid =' . $receiptDetailList ['verify'],
  2809. 'asArray' => true
  2810. ) );
  2811. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  2812. if (empty ( $receiptDetailList ['nowStaff'] )) {
  2813. $nowStaff = "";
  2814. $nowStaffList = array ();
  2815. if ($verifyDetail [0] [1] == 'ROLE') {
  2816. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  2817. foreach ( $vStaffString as $key => $value ) {
  2818. $staffK = explode ( "_", $value );
  2819. array_push ( $nowStaffList, $staffK [0] );
  2820. }
  2821. $nowStaff = implode ( ',', $nowStaffList );
  2822. } else {
  2823. $nowStaff = $verifyDetail [0] [0];
  2824. }
  2825. $receipt->nowStaff = $nowStaff;
  2826. }
  2827. // echo $nowStaff;
  2828. // print_r($verifyDetail);die;
  2829. $receipt->rid = $receiptDetailList ['rid'];
  2830. $receipt->status = 2;
  2831. $receipt->update ();
  2832. // 操作日志
  2833. Doo::loadModel ( "receiptLog" );
  2834. $receiptLog = new receiptLog ();
  2835. $verify = new verify ();
  2836. $receiptInfo = $receipt->getOne ( array (
  2837. 'where' => 'rid=' . $rid,
  2838. 'asArray' => true
  2839. ) );
  2840. $vr = $verify->getOne ( array (
  2841. 'where' => 'vid=' . $receiptInfo ['verify'],
  2842. 'asArray' => true
  2843. ) );
  2844. $jd = json_decode ( $vr ['staff'] );
  2845. $roleId = 0;
  2846. foreach ( $jd as $key => $value ) {
  2847. if ($value [1] == 'ROLE') {
  2848. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  2849. if ($pos !== false) {
  2850. $roleId = $value [0];
  2851. }
  2852. }
  2853. }
  2854. // 审批日志
  2855. // echo $roleId;die;
  2856. if (! empty ( $roleId )) {
  2857. Doo::loadModel ( "role" );
  2858. $role = new role ();
  2859. $roleInfo = $role->getOne ( array (
  2860. 'where' => 'rid=' . $roleId,
  2861. 'asArray' => true
  2862. ) );
  2863. // $receiptLog->rolename = $roleInfo ['name'];
  2864. }
  2865. $receiptLog->username = $this->staff [0] ['username'];
  2866. $receiptLog->uid = $this->staff [0] ['sid'];
  2867. $receiptLog->date = date ( "Y-m-d" );
  2868. $receiptLog->opinion = '提交审批';
  2869. $receiptLog->img = $this->staff [0] ['avatar'];
  2870. $receiptLog->status = 2;
  2871. $receiptLog->rid = $rid;
  2872. $receiptLog->insert ();
  2873. return "/expenses";
  2874. }
  2875. function expenses() {
  2876. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  2877. if (empty ( $item ))
  2878. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  2879. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  2880. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  2881. Doo::loadClass ( 'XDeode' );
  2882. $XDeode = new XDeode ( 7 );
  2883. Doo::loadModel ( 'receipt' );
  2884. $receipt = new receipt ();
  2885. Doo::loadModel ( 'L_category' );
  2886. $Lcategory = new L_category ();
  2887. Doo::loadModel ( 'verify' );
  2888. Doo::loadModel ( 'statistics' );
  2889. $statistics = new statistics ();
  2890. $verify = new verify ();
  2891. Doo::loadModel ( 'staff' );
  2892. $staff = new staff ();
  2893. $condition = "";
  2894. if ($item == "expenses")
  2895. $condition = " and Rtype=1 ";
  2896. elseif ($item == "receipts")
  2897. $condition = " and Rtype=0 ";
  2898. elseif ($item == "remits")
  2899. $condition = " and Rtype=2 ";
  2900. elseif ($item == "train")
  2901. $condition = " and Rtype=3 ";
  2902. $dateCondition = " and Year(date) =" . $year;
  2903. if (! empty ( $moth )) {
  2904. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  2905. $stList = $statistics->getOne ( array (
  2906. 'select' => 'rePrice ,agPrice',
  2907. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  2908. 'asArray' => true
  2909. ) );
  2910. } else
  2911. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  2912. if (empty ( $stList ))
  2913. $stList = array (
  2914. 'rePrice' => 0,
  2915. 'agPrice' => 0
  2916. );
  2917. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  2918. if (! isset ( $noPassSum ['sum'] ))
  2919. $noPassSum ['sum'] = 0;
  2920. $data ['stList'] = array (
  2921. 'rePrice' => $stList ['rePrice'],
  2922. 'agPrice' => $stList ['agPrice'],
  2923. 'skPrice' => ($noPassSum ['sum'])
  2924. );
  2925. $receiptList = $receipt->find ( array (
  2926. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  2927. 'desc' => 'rid',
  2928. 'asArray' => true
  2929. ) );
  2930. $Locate = 0;
  2931. $roleId = 0;
  2932. $button = 0;
  2933. foreach ( $receiptList as $key => $value ) {
  2934. $receiptList [$key] ['Locate'] = $Locate;
  2935. $Locate ++;
  2936. $receiptList [$key] ['reviseDetail'] = array ();
  2937. if (! empty ( $value ['reviseDetail'] ))
  2938. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2939. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2940. $categoryDetil = $Lcategory->getOne ( array (
  2941. 'where' => 'cid=' . $value ['cid'],
  2942. 'asArray' => true
  2943. ) );
  2944. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2945. // 检测编辑状态
  2946. $verifyList = $verify->getOne ( array (
  2947. 'where' => 'vid=' . $value ['verify'],
  2948. 'asArray' => true
  2949. ) );
  2950. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2951. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2952. Doo::loadModel ( 'role' );
  2953. $role = new role ();
  2954. $flag = true;
  2955. $roleKey = 0;
  2956. $endStaffArray = array ();
  2957. $roleArrayCopy = array ();
  2958. foreach ( $verifyList as $k => $v ) {
  2959. // init verifyStaff
  2960. if ($v [1] == 'ROLE') {
  2961. if (! empty ( $verifyStaff )) {
  2962. $endStaffArray = end ( $verifyStaff );
  2963. // if ($v[0]==$endStaffArray['nextStaff']){
  2964. // $roleId=$v[0];
  2965. // }
  2966. }
  2967. $roleVerify = json_decode ( $v [3], true );
  2968. $roleKey = $k;
  2969. $roleArray = array ();
  2970. $rolename = $role->getOne ( array (
  2971. 'where' => 'rid=' . $v [0],
  2972. 'asArray' => true
  2973. ) );
  2974. foreach ( $roleVerify as $o => $p ) {
  2975. $staffID = explode ( '_', $p );
  2976. $staffInfo = $staff->getOne ( array (
  2977. 'where' => 'sid=' . $staffID [0],
  2978. 'asArray' => true
  2979. ) );
  2980. // print_r($staffID);
  2981. $exp = array (
  2982. 0 => $staffInfo ['sid'],
  2983. 1 => $staffID [1],
  2984. 2 => $staffInfo ['avatar'],
  2985. 'date' => '',
  2986. 'date' => '',
  2987. 'opinion' => '',
  2988. 'status' => '',
  2989. 'rolename' => $rolename ['name']
  2990. );
  2991. array_push ( $roleArray, $exp );
  2992. }
  2993. $roleArrayCopy [$v [0]] = $roleArray;
  2994. // $verifyList[$k]['roleArray']=$roleArray;
  2995. }
  2996. $verifyList [$k] ['date'] = "";
  2997. $verifyList [$k] ['opinion'] = "";
  2998. $verifyList [$k] ['status'] = "";
  2999. if (empty ( $verifyStaff )) {
  3000. $verifyList [$k] ['date'] = "";
  3001. $verifyList [$k] ['opinion'] = "";
  3002. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3003. $verifyList [$k] ['status'] = 4;
  3004. $flag = false;
  3005. }
  3006. } else {
  3007. foreach ( $verifyStaff as $m => $u ) {
  3008. if ($v [0] == $m) {
  3009. $verifyList [$k] ['date'] = $u ['date'];
  3010. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3011. $verifyList [$k] ['status'] = $u ['status'];
  3012. $flag = false;
  3013. break;
  3014. }
  3015. }
  3016. $endStaffArray = end ( $verifyStaff );
  3017. if (isset ( $endStaffArray ['ROLE'] )) {
  3018. } else {
  3019. // $endKey=key($verifyStaff);
  3020. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3021. // $button=4;
  3022. // $verifyList[$k]['status']=4;
  3023. // }
  3024. }
  3025. }
  3026. }
  3027. $rolename ['name'] = '';
  3028. if (! empty ( $roleId )) {
  3029. Doo::loadModel ( 'role' );
  3030. $role = new role ();
  3031. $rolename = $role->getOne ( array (
  3032. 'where' => 'rid=' . $roleId,
  3033. 'asArray' => true
  3034. ) );
  3035. }
  3036. if (! empty ( $verifyStaff ))
  3037. $endStaffArray = end ( $verifyStaff );
  3038. $KOP = false;
  3039. foreach ( $roleArrayCopy as $P => $A ) {
  3040. foreach ( $A as $MKI => $AVL ) {
  3041. if (! empty ( $verifyStaff )) {
  3042. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3043. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3044. $button = 4;
  3045. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3046. }
  3047. foreach ( $verifyStaff as $m => $u ) {
  3048. $AVLFK = $AVL [0] . '_R';
  3049. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3050. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3051. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3052. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3053. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3054. break;
  3055. }
  3056. }
  3057. } else {
  3058. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3059. $button = 4;
  3060. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3061. }
  3062. }
  3063. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3064. $KOP = true;
  3065. }
  3066. }
  3067. foreach ( $roleArrayCopy as $k => $v ) {
  3068. foreach ( $verifyList as $m => $n ) {
  3069. if ($n [0] == $k) {
  3070. array_splice ( $verifyList, $m, 1, $v );
  3071. }
  3072. }
  3073. }
  3074. $receiptList [$key] ['verifyList'] = $verifyList;
  3075. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3076. 'where' => 'sid=' . $value ['staff'],
  3077. 'asArray' => true
  3078. ) );
  3079. $receiptList [$key] ['button'] = $button;
  3080. $receiptList [$key] ['ridKey'] =$XDeode->encode( $value ['rid'] );
  3081. }
  3082. // print_r($receiptList);die;
  3083. $mothHtml = "";
  3084. for($i = 1; $i <= 12; $i ++) {
  3085. if ($moth == $i)
  3086. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3087. else
  3088. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3089. }
  3090. $dateHtml = "";
  3091. $now = date ( "Y" );
  3092. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  3093. if ($YEARD <= $now) {
  3094. $dateHtml .= '<option ';
  3095. if ($year == $YEARD) {
  3096. $dateHtml .= 'selected ';
  3097. }
  3098. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  3099. }
  3100. }
  3101. $data ['dateHtml'] = $dateHtml;
  3102. $data ['mothHtml'] = $mothHtml;
  3103. $data ['receiptList'] = $receiptList;
  3104. $data ['memu'] = "receipt";
  3105. $data ['staff'] = $this->staff;
  3106. $data ['receiptMemu'] = 'expenses';
  3107. $data ['verifyId'] = $this->verifyId;
  3108. $data ['executeId'] = $this->executeId;
  3109. $data ['item'] = $item;
  3110. $data ['year'] = $year;
  3111. $this->render ( "/admin/expenses", $data );
  3112. }
  3113. function expensesCollect() {
  3114. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3115. Doo::loadModel ( 'receipt' );
  3116. $receipt = new receipt ();
  3117. Doo::loadModel ( 'L_category' );
  3118. $Lcategory = new L_category ();
  3119. Doo::loadModel ( 'verify' );
  3120. Doo::loadModel ( 'statistics' );
  3121. $statistics = new statistics ();
  3122. $verify = new verify ();
  3123. Doo::loadModel ( 'staff' );
  3124. $staff = new staff ();
  3125. Doo::loadModel ( 'loanReceipt' );
  3126. $loanReceipt = new loanReceipt ();
  3127. $receiptList = $receipt->find ( array (//去掉
  3128. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  3129. 'desc' => 'rid',
  3130. 'asArray' => true
  3131. ) );
  3132. $loanList = $loanReceipt->find ( array (
  3133. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3134. 'desc' => 'rid',
  3135. 'asArray' => true
  3136. ) );
  3137. /*
  3138. * $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;
  3139. */
  3140. $data ['explanation'] = '';
  3141. if (! empty ( $loanList ))
  3142. $data ['explanation'] = $loanList [0] ['explanation'];
  3143. $Locate = 0;
  3144. $roleId = 0;
  3145. $button = 0;
  3146. foreach ( $receiptList as $key => $value ) {
  3147. $receiptList [$key] ['Locate'] = $Locate;
  3148. $Locate ++;
  3149. $receiptList [$key] ['reviseDetail'] = array ();
  3150. if (! empty ( $value ['reviseDetail'] ))
  3151. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3152. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3153. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3154. $categoryDetil = $Lcategory->getOne ( array (
  3155. 'where' => 'cid=' . $value ['cid'],
  3156. 'asArray' => true
  3157. ) );
  3158. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3159. // 检测编辑状态
  3160. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  3161. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  3162. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  3163. else
  3164. $verifyList ['staff'] = $value ['verifyBreakup'];
  3165. } else
  3166. $verifyList = $verify->getOne ( array (
  3167. 'where' => 'vid=' . $value ['verify'],
  3168. 'asArray' => true
  3169. ) );
  3170. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3171. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3172. Doo::loadModel ( 'role' );
  3173. $role = new role ();
  3174. $flag = true;
  3175. $roleKey = 0;
  3176. $endStaffArray = array ();
  3177. $roleArrayCopy = array ();
  3178. foreach ( $verifyList as $k => $v ) {
  3179. // init verifyStaff
  3180. if ($v [1] == 'ROLE') {
  3181. if (! empty ( $verifyStaff )) {
  3182. $endStaffArray = end ( $verifyStaff );
  3183. // if ($v[0]==$endStaffArray['nextStaff']){
  3184. // $roleId=$v[0];
  3185. // }
  3186. }
  3187. $roleVerify = json_decode ( $v [3], true );
  3188. $roleKey = $k;
  3189. $roleArray = array ();
  3190. $rolename = $role->getOne ( array (
  3191. 'where' => 'rid=' . $v [0],
  3192. 'asArray' => true
  3193. ) );
  3194. foreach ( $roleVerify as $o => $p ) {
  3195. $staffID = explode ( '_', $p );
  3196. $staffInfo = $staff->getOne ( array (
  3197. 'where' => 'sid=' . $staffID [0],
  3198. 'asArray' => true
  3199. ) );
  3200. // print_r($staffID);
  3201. $exp = array (
  3202. 0 => $staffInfo ['sid'],
  3203. 1 => $staffID [1],
  3204. 2 => $staffInfo ['avatar'],
  3205. 'date' => '',
  3206. 'date' => '',
  3207. 'opinion' => '',
  3208. 'status' => '',
  3209. 'rolename' => $rolename ['name']
  3210. );
  3211. array_push ( $roleArray, $exp );
  3212. }
  3213. $roleArrayCopy [$v [0]] = $roleArray;
  3214. // $verifyList[$k]['roleArray']=$roleArray;
  3215. }
  3216. $verifyList [$k] ['date'] = "";
  3217. $verifyList [$k] ['opinion'] = "";
  3218. $verifyList [$k] ['status'] = "";
  3219. if (empty ( $verifyStaff )) {
  3220. $verifyList [$k] ['date'] = "";
  3221. $verifyList [$k] ['opinion'] = "";
  3222. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3223. $verifyList [$k] ['status'] = 4;
  3224. $flag = false;
  3225. }
  3226. } else {
  3227. foreach ( $verifyStaff as $m => $u ) {
  3228. if ($v [0] == $m) {
  3229. $verifyList [$k] ['date'] = $u ['date'];
  3230. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3231. $verifyList [$k] ['status'] = $u ['status'];
  3232. $flag = false;
  3233. break;
  3234. }
  3235. }
  3236. $endStaffArray = end ( $verifyStaff );
  3237. if (isset ( $endStaffArray ['ROLE'] )) {
  3238. } else {
  3239. // $endKey=key($verifyStaff);
  3240. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3241. // $button=4;
  3242. // $verifyList[$k]['status']=4;
  3243. // }
  3244. }
  3245. }
  3246. }
  3247. $rolename ['name'] = '';
  3248. if (! empty ( $roleId )) {
  3249. Doo::loadModel ( 'role' );
  3250. $role = new role ();
  3251. $rolename = $role->getOne ( array (
  3252. 'where' => 'rid=' . $roleId,
  3253. 'asArray' => true
  3254. ) );
  3255. }
  3256. if (! empty ( $verifyStaff ))
  3257. $endStaffArray = end ( $verifyStaff );
  3258. $KOP = false;
  3259. foreach ( $roleArrayCopy as $P => $A ) {
  3260. foreach ( $A as $MKI => $AVL ) {
  3261. if (! empty ( $verifyStaff )) {
  3262. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3263. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3264. $button = 4;
  3265. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3266. }
  3267. foreach ( $verifyStaff as $m => $u ) {
  3268. $AVLFK = $AVL [0] . '_R';
  3269. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3270. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3271. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3272. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3273. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3274. break;
  3275. }
  3276. }
  3277. } else {
  3278. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3279. $button = 4;
  3280. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3281. }
  3282. }
  3283. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3284. $KOP = true;
  3285. }
  3286. }
  3287. foreach ( $roleArrayCopy as $k => $v ) {
  3288. foreach ( $verifyList as $m => $n ) {
  3289. if ($n [0] == $k) {
  3290. array_splice ( $verifyList, $m, 1, $v );
  3291. }
  3292. }
  3293. }
  3294. // 费用执行人相关数据
  3295. $executeCopy = json_decode ( $value ['executeCopy'], true );
  3296. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3297. foreach ( $executeCopy as $k => $v ) {
  3298. $executeCopy [$k] ['date'] = '';
  3299. $executeCopy [$k] ['opinion'] = '';
  3300. $executeCopy [$k] ['status'] = '';
  3301. if (! empty ( $executeStaff ))
  3302. foreach ( $executeStaff as $m => $u ) {
  3303. if ($v [0] == $m) {
  3304. $executeCopy [$k] ['date'] = $u ['date'];
  3305. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  3306. $executeCopy [$k] ['status'] = $u ['status'];
  3307. break;
  3308. }
  3309. }
  3310. }
  3311. $receiptList [$key] ['executeCopy'] = $executeCopy;
  3312. $receiptList [$key] ['verifyList'] = $verifyList;
  3313. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3314. 'where' => 'sid=' . $value ['staff'],
  3315. 'asArray' => true
  3316. ) );
  3317. $receiptList [$key] ['button'] = $button;
  3318. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3319. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3320. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  3321. $receiptList [$key] ['relust'] = $relust;
  3322. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  3323. }
  3324. Doo::loadModel ( 'enclosur' );
  3325. $enclosur = new enclosur ();
  3326. $enclosurList = $enclosur->find ( array (
  3327. 'where' => 'rid=' . $rid,
  3328. 'asArray' => true
  3329. ) );
  3330. $enclosurHtml = '';
  3331. foreach ( $enclosurList as $value ) {
  3332. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3333. }
  3334. $data ['enclosurHtml'] = $enclosurHtml;
  3335. // print_r($receiptList);
  3336. $data ['receiptList'] = $receiptList;
  3337. $data ['memu'] = "receipt";
  3338. $data ['staff'] = $this->staff;
  3339. $data ['receiptMemu'] = 'expenses';
  3340. $data ['verifyId'] = $this->verifyId;
  3341. $data ['executeId'] = $this->executeId;
  3342. $this->render ( "/admin/expensesCollect", $data );
  3343. }
  3344. function approvalExpenses() {
  3345. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  3346. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3347. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3348. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3349. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3350. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  3351. // echo $rdate;
  3352. if (empty ( $status ))
  3353. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3354. $page_size = 2;
  3355. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  3356. $vidList = array ();
  3357. $button = 0;
  3358. Doo::loadModel ( 'verify' );
  3359. $verify = new verify ();
  3360. Doo::loadModel ( 'receipt' );
  3361. $receipt = new receipt ();
  3362. Doo::loadModel ( 'staff' );
  3363. $staff = new staff ();
  3364. Doo::loadModel ( 'L_category' );
  3365. $Lcategory = new L_category ();
  3366. // user verify ID
  3367. $verifyDetail = $verify->find ( array (
  3368. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  3369. 'asArray' => true
  3370. ) );
  3371. foreach ( $verifyDetail as $key => $value ) {
  3372. array_push ( $vidList, $value ['vid'] );
  3373. }
  3374. $vid = implode ( ",", $vidList );
  3375. if (empty ( $verifyDetail ))
  3376. $vid = 0;
  3377. // if ($status==0)
  3378. // $dateCondition="";
  3379. // else
  3380. $dateCondition = " ";
  3381. // if (! empty ( $month ))
  3382. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  3383. if ($status == 'done' || $status == 'termination') {
  3384. if (! empty ( $year )) {
  3385. $dateCondition = " and Year(pastDate) =" . $year;
  3386. if (! empty ( $month ))
  3387. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  3388. }
  3389. } elseif ($status == 'finish') {
  3390. if (! empty ( $year )) {
  3391. $dateCondition = " and Year(pastDate) =" . $year;
  3392. if (! empty ( $month ))
  3393. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  3394. }
  3395. }
  3396. // date ( 'Y-m' )
  3397. // if (! empty ( $rdate ) && $status == 'done')
  3398. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  3399. // elseif (! empty ( $rdate ))
  3400. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  3401. $categoryList = $Lcategory->find ( array (
  3402. 'asArray' => true
  3403. ) );
  3404. $staffList = $staff->find ( array (
  3405. 'where' => 'cid=' . $cid,
  3406. 'asArray' => true
  3407. ) );
  3408. $cateCondition = "";
  3409. $staffCondition = "";
  3410. $approvalCondition = "";
  3411. if (! empty ( $cid )) {
  3412. $cateCondition = ' and cid=' . $cid;
  3413. }
  3414. if (! empty ( $sid )) {
  3415. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  3416. $cateCondition = "";
  3417. }
  3418. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  3419. if ($status == 'pendApproval') {
  3420. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  3421. }
  3422. if ($status == 'ongoing') {
  3423. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  3424. }
  3425. if ($status == 'done') {
  3426. $approvalCondition = ' and (status=8 or status=9 ) ';
  3427. }
  3428. if ($status == 'termination') {
  3429. $approvalCondition = " and status=3";
  3430. }
  3431. if ($status == 'finish') {
  3432. $approvalCondition = " and (status=1 or status=8 or status=9)";
  3433. }
  3434. $pageinfo ['page'] = array (
  3435. 'previous' => ''
  3436. );
  3437. if(!empty($receiptOrder)){
  3438. $pageinfo = $this->get_page ( "CLD_receipt", ' and receiptOrder like "%' . $receiptOrder . '%"', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  3439. $receiptList = $receipt->find ( array ( // $dateCondition
  3440. 'where' => 'receiptOrder like "%' . $receiptOrder . '%"',
  3441. 'desc' => 'rid',
  3442. 'asArray' => true
  3443. ) );
  3444. }else{
  3445. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  3446. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  3447. $receiptList = $receipt->find ( array ( // $dateCondition.
  3448. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  3449. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  3450. 'desc' => 'rid',
  3451. 'asArray' => true
  3452. ) );
  3453. } else {
  3454. $receiptList = $receipt->find ( array ( // $dateCondition
  3455. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  3456. 'desc' => 'rid',
  3457. 'asArray' => true
  3458. ) );
  3459. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  3460. }
  3461. }
  3462. $rLRes = $receipt->find ( array (
  3463. '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 . ')',
  3464. 'desc' => 'rid',
  3465. 'asArray' => true
  3466. ) );
  3467. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  3468. // print_r($receiptList);
  3469. Doo::loadClass ( 'XDeode' );
  3470. $XDeode = new XDeode ( 7 );
  3471. $Locate = 0;
  3472. $reportList = $reportCateList = array ();
  3473. foreach ( $receiptList as $key => $value ) {
  3474. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  3475. $receiptList [$key] ['Locate'] = $Locate;
  3476. $Locate ++;
  3477. $receiptList [$key] ['reviseDetail'] = array ();
  3478. if (! empty ( $value ['reviseDetail'] ))
  3479. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3480. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3481. $categoryDetil = $Lcategory->getOne ( array (
  3482. 'where' => 'cid=' . $value ['cid'],
  3483. 'asArray' => true
  3484. ) );
  3485. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3486. $verifyList = $verify->getOne ( array (
  3487. 'where' => 'vid=' . $value ['verify'],
  3488. 'asArray' => true
  3489. ) );
  3490. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3491. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3492. foreach ( $verifyList as $k => $v ) {
  3493. // init verifyStaff
  3494. $verifyList [$k] ['date'] = "";
  3495. $verifyList [$k] ['opinion'] = "";
  3496. $verifyList [$k] ['status'] = "";
  3497. if (empty ( $verifyStaff )) {
  3498. $verifyList [$k] ['date'] = "";
  3499. $verifyList [$k] ['opinion'] = "";
  3500. if ($v [0] == $this->staff [0] ['sid']) {
  3501. $verifyList [$k] ['status'] = 4;
  3502. $button = 4;
  3503. }
  3504. } else {
  3505. $flag = true;
  3506. foreach ( $verifyStaff as $m => $u ) {
  3507. if ($v [0] == $m) {
  3508. $verifyList [$k] ['date'] = $u ['date'];
  3509. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3510. $verifyList [$k] ['status'] = $u ['status'];
  3511. $flag = false;
  3512. break;
  3513. }
  3514. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  3515. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  3516. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  3517. }
  3518. if ($flag) { // 检测可编辑
  3519. if ($v [0] == $this->staff [0] ['sid']) {
  3520. $verifyList [$k] ['status'] = 4;
  3521. $button = 4;
  3522. }
  3523. }
  3524. }
  3525. }
  3526. $receiptList [$key] ['verifyList'] = $verifyList;
  3527. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3528. 'where' => 'sid=' . $value ['staff'],
  3529. 'asArray' => true
  3530. ) );
  3531. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  3532. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  3533. $receiptList [$key] ['button'] = $button;
  3534. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  3535. }
  3536. $reportList = array_unique ( $reportList );
  3537. $reportHtml = '';
  3538. foreach ( $reportList as $key => $value ) {
  3539. $v = explode ( "-", $value );
  3540. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  3541. }
  3542. // print_r($reportList)
  3543. $data ['reportHtml'] = $reportHtml;
  3544. $reportCateList = array_unique ( $reportCateList );
  3545. $reportCateHtml = '';
  3546. foreach ( $reportCateList as $key => $value ) {
  3547. $v = explode ( "-", $value );
  3548. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  3549. }
  3550. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  3551. $data ['reportCateHtml'] = $reportCateHtml;
  3552. // print_r($receiptList);die;
  3553. // $data['verifyDetail']=$verifyDetail;
  3554. $mothHtml = "";
  3555. for($i = 1; $i <= 12; $i ++) {
  3556. if ($month == $i)
  3557. $mothHtml .= '<option selected value="0' . $i . '">' . $i . '月</option>';
  3558. else
  3559. $mothHtml .= '<option value="0' . $i . '">' . $i . '月</option>';
  3560. }
  3561. $data ['mothHtml'] = $mothHtml;
  3562. $dateHtml = "";
  3563. $now = date ( "Y" );
  3564. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  3565. if ($YEARD <= $now) {
  3566. $dateHtml .= '<option ';
  3567. if ($year == $YEARD) {
  3568. $dateHtml .= 'selected ';
  3569. }
  3570. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  3571. }
  3572. }
  3573. $data ['dateHtml'] = $dateHtml;
  3574. $data ['page'] = $pageinfo;
  3575. $data ['receiptList'] = $receiptList;
  3576. $data ['receiptApprovalCount'] = count ( $rLRes );
  3577. $data ['status'] = $status;
  3578. $data ['year'] = $year;
  3579. $data ['month'] = $month;
  3580. $data ['categoryList'] = $categoryList;
  3581. $data ['staffList'] = $staffList;
  3582. $data ['cid'] = $cid;
  3583. $data ['sid'] = $sid;
  3584. // print_r($receiptList);
  3585. $data['receiptOrder']=$receiptOrder;
  3586. $data ['memu'] = "receipt";
  3587. $data ['staff'] = $this->staff;
  3588. $data ['receiptMemu'] = 'approvalExpenses';
  3589. $data ['verifyId'] = $this->verifyId;
  3590. $data ['executeId'] = $this->executeId;
  3591. $this->render ( "/admin/approvalExpenses", $data );
  3592. }
  3593. function expensesDoc() {
  3594. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3595. Doo::loadClass ( 'XDeode' );
  3596. $XDeode = new XDeode ( 5 );
  3597. if (! empty ( $rid ) && ! is_numeric ( $rid ))
  3598. $rid = $XDeode->decode ( $rid );
  3599. if (! is_numeric ( $rid ))
  3600. die ( 'illegal request' );
  3601. Doo::loadModel ( 'receipt' );
  3602. $receipt = new receipt ();
  3603. Doo::loadModel ( 'L_category' );
  3604. $Lcategory = new L_category ();
  3605. Doo::loadModel ( 'verify' );
  3606. Doo::loadModel ( 'statistics' );
  3607. $statistics = new statistics ();
  3608. $verify = new verify ();
  3609. Doo::loadModel ( 'staff' );
  3610. $staff = new staff ();
  3611. Doo::loadModel ( 'loanReceipt' );
  3612. $loanReceipt = new loanReceipt ();
  3613. $receiptList = $receipt->find ( array (
  3614. 'where' => ' rid=' . $rid,
  3615. 'desc' => 'rid',
  3616. 'asArray' => true
  3617. ) );
  3618. $loanList = array ();
  3619. if (! empty ( $receiptList ))
  3620. $loanList = $loanReceipt->find ( array (
  3621. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3622. 'desc' => 'rid',
  3623. 'asArray' => true
  3624. ) );
  3625. $Locate = 0;
  3626. $roleId = 0;
  3627. $button = 0;
  3628. foreach ( $loanList as $key => $value ) {
  3629. $loanList [$key] ['Locate'] = $Locate;
  3630. $Locate ++;
  3631. $loanList [$key] ['reviseDetail'] = array ();
  3632. if (! empty ( $value ['reviseDetail'] ))
  3633. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3634. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3635. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3636. $categoryDetil = $Lcategory->getOne ( array (
  3637. 'where' => 'cid=' . $value ['cid'],
  3638. 'asArray' => true
  3639. ) );
  3640. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3641. // 检测编辑状态
  3642. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  3643. $verifyList ['staff'] = $value ['verifyBreakup'];
  3644. else
  3645. $verifyList = $verify->getOne ( array (
  3646. 'where' => 'vid=' . $value ['verify'],
  3647. 'asArray' => true
  3648. ) );
  3649. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3650. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3651. Doo::loadModel ( 'role' );
  3652. $role = new role ();
  3653. $flag = true;
  3654. $roleKey = 0;
  3655. $endStaffArray = array ();
  3656. $roleArrayCopy = array ();
  3657. foreach ( $verifyList as $k => $v ) {
  3658. // init verifyStaff
  3659. if ($v [1] == 'ROLE') {
  3660. if (! empty ( $verifyStaff )) {
  3661. $endStaffArray = end ( $verifyStaff );
  3662. // if ($v[0]==$endStaffArray['nextStaff']){
  3663. // $roleId=$v[0];
  3664. // }
  3665. }
  3666. $roleVerify = json_decode ( $v [3], true );
  3667. $roleKey = $k;
  3668. $roleArray = array ();
  3669. $rolename = $role->getOne ( array (
  3670. 'where' => 'rid=' . $v [0],
  3671. 'asArray' => true
  3672. ) );
  3673. foreach ( $roleVerify as $o => $p ) {
  3674. $staffID = explode ( '_', $p );
  3675. $staffInfo = $staff->getOne ( array (
  3676. 'where' => 'sid=' . $staffID [0],
  3677. 'asArray' => true
  3678. ) );
  3679. // print_r($staffID);
  3680. $exp = array (
  3681. 0 => $staffInfo ['sid'],
  3682. 1 => $staffID [1],
  3683. 2 => $staffInfo ['avatar'],
  3684. 'date' => '',
  3685. 'date' => '',
  3686. 'opinion' => '',
  3687. 'status' => '',
  3688. 'rolename' => $rolename ['name']
  3689. );
  3690. array_push ( $roleArray, $exp );
  3691. }
  3692. $roleArrayCopy [$v [0]] = $roleArray;
  3693. // $verifyList[$k]['roleArray']=$roleArray;
  3694. }
  3695. $verifyList [$k] ['date'] = "";
  3696. $verifyList [$k] ['opinion'] = "";
  3697. $verifyList [$k] ['status'] = "";
  3698. if (empty ( $verifyStaff )) {
  3699. $verifyList [$k] ['date'] = "";
  3700. $verifyList [$k] ['opinion'] = "";
  3701. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3702. $verifyList [$k] ['status'] = 4;
  3703. $flag = false;
  3704. }
  3705. } else {
  3706. foreach ( $verifyStaff as $m => $u ) {
  3707. if ($v [0] == $m) {
  3708. $verifyList [$k] ['date'] = $u ['date'];
  3709. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3710. $verifyList [$k] ['status'] = $u ['status'];
  3711. $flag = false;
  3712. break;
  3713. }
  3714. }
  3715. $endStaffArray = end ( $verifyStaff );
  3716. if (isset ( $endStaffArray ['ROLE'] )) {
  3717. } else {
  3718. // $endKey=key($verifyStaff);
  3719. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3720. // $button=4;
  3721. // $verifyList[$k]['status']=4;
  3722. // }
  3723. }
  3724. }
  3725. }
  3726. $rolename ['name'] = '';
  3727. if (! empty ( $roleId )) {
  3728. Doo::loadModel ( 'role' );
  3729. $role = new role ();
  3730. $rolename = $role->getOne ( array (
  3731. 'where' => 'rid=' . $roleId,
  3732. 'asArray' => true
  3733. ) );
  3734. }
  3735. if (! empty ( $verifyStaff ))
  3736. $endStaffArray = end ( $verifyStaff );
  3737. $KOP = false;
  3738. foreach ( $roleArrayCopy as $P => $A ) {
  3739. foreach ( $A as $MKI => $AVL ) {
  3740. if (! empty ( $verifyStaff )) {
  3741. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3742. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3743. $button = 4;
  3744. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3745. }
  3746. foreach ( $verifyStaff as $m => $u ) {
  3747. $AVLFK = $AVL [0] . '_R';
  3748. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3749. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3750. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3751. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3752. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3753. break;
  3754. }
  3755. }
  3756. } else {
  3757. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3758. $button = 4;
  3759. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3760. }
  3761. }
  3762. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3763. $KOP = true;
  3764. }
  3765. }
  3766. foreach ( $roleArrayCopy as $k => $v ) {
  3767. foreach ( $verifyList as $m => $n ) {
  3768. if ($n [0] == $k) {
  3769. array_splice ( $verifyList, $m, 1, $v );
  3770. }
  3771. }
  3772. }
  3773. $loanList [$key] ['verifyList'] = $verifyList;
  3774. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3775. 'where' => 'sid=' . $value ['staff'],
  3776. 'asArray' => true
  3777. ) );
  3778. $loanList [$key] ['button'] = $button;
  3779. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  3780. }
  3781. $data ['loanList'] = $loanList;
  3782. // print_r($loanList);
  3783. $Locate = 0;
  3784. $roleId = 0;
  3785. $button = 0;
  3786. foreach ( $receiptList as $key => $value ) {
  3787. $receiptList [$key] ['Locate'] = $Locate;
  3788. $Locate ++;
  3789. $receiptList [$key] ['reviseDetail'] = array ();
  3790. if (! empty ( $value ['reviseDetail'] ))
  3791. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3792. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3793. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3794. $categoryDetil = $Lcategory->getOne ( array (
  3795. 'where' => 'cid=' . $value ['cid'],
  3796. 'asArray' => true
  3797. ) );
  3798. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3799. // 检测编辑状态
  3800. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3801. $verifyList ['staff'] = $value ['verifyBreakup'];
  3802. } else
  3803. $verifyList = $verify->getOne ( array (
  3804. 'where' => 'vid=' . $value ['verify'],
  3805. 'asArray' => true
  3806. ) );
  3807. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3808. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3809. Doo::loadModel ( 'role' );
  3810. $role = new role ();
  3811. if ($verifyList == NULL)
  3812. $verifyList = array ();
  3813. $flag = true;
  3814. $roleKey = 0;
  3815. $endStaffArray = array ();
  3816. $roleArrayCopy = array ();
  3817. foreach ( $verifyList as $k => $v ) {
  3818. // init verifyStaff
  3819. if ($v [1] == 'ROLE') {
  3820. if (! empty ( $verifyStaff )) {
  3821. $endStaffArray = end ( $verifyStaff );
  3822. // if ($v[0]==$endStaffArray['nextStaff']){
  3823. // $roleId=$v[0];
  3824. // }
  3825. }
  3826. $roleVerify = json_decode ( $v [3], true );
  3827. $roleKey = $k;
  3828. $roleArray = array ();
  3829. $rolename = $role->getOne ( array (
  3830. 'where' => 'rid=' . $v [0],
  3831. 'asArray' => true
  3832. ) );
  3833. foreach ( $roleVerify as $o => $p ) {
  3834. $staffID = explode ( '_', $p );
  3835. $staffInfo = $staff->getOne ( array (
  3836. 'where' => 'sid=' . $staffID [0],
  3837. 'asArray' => true
  3838. ) );
  3839. // print_r($staffID);
  3840. $exp = array (
  3841. 0 => $staffInfo ['sid'],
  3842. 1 => $staffID [1],
  3843. 2 => $staffInfo ['avatar'],
  3844. 'date' => '',
  3845. 'date' => '',
  3846. 'opinion' => '',
  3847. 'status' => '',
  3848. 'rolename' => $rolename ['name']
  3849. );
  3850. array_push ( $roleArray, $exp );
  3851. }
  3852. $roleArrayCopy [$v [0]] = $roleArray;
  3853. // $verifyList[$k]['roleArray']=$roleArray;
  3854. }
  3855. $verifyList [$k] ['date'] = "";
  3856. $verifyList [$k] ['opinion'] = "";
  3857. $verifyList [$k] ['status'] = "";
  3858. if (empty ( $verifyStaff )) {
  3859. $verifyList [$k] ['date'] = "";
  3860. $verifyList [$k] ['opinion'] = "";
  3861. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3862. $verifyList [$k] ['status'] = 4;
  3863. $flag = false;
  3864. }
  3865. } else {
  3866. foreach ( $verifyStaff as $m => $u ) {
  3867. if ($v [0] == $m) {
  3868. $verifyList [$k] ['date'] = $u ['date'];
  3869. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3870. $verifyList [$k] ['status'] = $u ['status'];
  3871. $flag = false;
  3872. break;
  3873. }
  3874. }
  3875. $endStaffArray = end ( $verifyStaff );
  3876. if (isset ( $endStaffArray ['ROLE'] )) {
  3877. } else {
  3878. // $endKey=key($verifyStaff);
  3879. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3880. // $button=4;
  3881. // $verifyList[$k]['status']=4;
  3882. // }
  3883. }
  3884. }
  3885. }
  3886. $FC = @$rolename ['name'];
  3887. $rolename ['name'] = '';
  3888. if (! empty ( $roleId )) {
  3889. Doo::loadModel ( 'role' );
  3890. $role = new role ();
  3891. $rolename = $role->getOne ( array (
  3892. 'where' => 'rid=' . $roleId,
  3893. 'asArray' => true
  3894. ) );
  3895. }
  3896. if (! empty ( $verifyStaff ))
  3897. $endStaffArray = end ( $verifyStaff );
  3898. $KOP = false;
  3899. foreach ( $roleArrayCopy as $P => $A ) {
  3900. foreach ( $A as $MKI => $AVL ) {
  3901. if (! empty ( $verifyStaff )) {
  3902. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3903. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3904. $button = 4;
  3905. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3906. }
  3907. foreach ( $verifyStaff as $m => $u ) {
  3908. $AVLFK = $AVL [0] . '_R';
  3909. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3910. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3911. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3912. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3913. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3914. break;
  3915. }
  3916. }
  3917. } else {
  3918. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3919. $button = 4;
  3920. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3921. }
  3922. }
  3923. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3924. $KOP = true;
  3925. }
  3926. }
  3927. foreach ( $roleArrayCopy as $k => $v ) {
  3928. foreach ( $verifyList as $m => $n ) {
  3929. if ($n [0] == $k) {
  3930. array_splice ( $verifyList, $m, 1, $v );
  3931. }
  3932. }
  3933. }
  3934. // 费用执行人相关数据
  3935. $executeCopy = json_decode ( $value ['executeCopy'], true );
  3936. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3937. foreach ( $executeCopy as $k => $v ) {
  3938. $executeCopy [$k] ['date'] = '';
  3939. $executeCopy [$k] ['opinion'] = '';
  3940. $executeCopy [$k] ['status'] = '';
  3941. if (! empty ( $executeStaff ))
  3942. foreach ( $executeStaff as $m => $u ) {
  3943. if ($v [0] == $m) {
  3944. $executeCopy [$k] ['date'] = $u ['date'];
  3945. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  3946. $executeCopy [$k] ['status'] = $u ['status'];
  3947. break;
  3948. }
  3949. }
  3950. }
  3951. $receiptList [$key] ['executeCopy'] = $executeCopy;
  3952. // print_r($verifyList);
  3953. $receiptList [$key] ['verifyList'] = $verifyList;
  3954. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3955. 'where' => 'sid=' . $value ['staff'],
  3956. 'asArray' => true
  3957. ) );
  3958. $receiptList [$key] ['button'] = $button;
  3959. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3960. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3961. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  3962. $receiptList [$key] ['relust'] = $relust;
  3963. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  3964. }
  3965. // print_r($receiptList);
  3966. // 获取审批日志
  3967. Doo::loadModel ( 'receiptLog' );
  3968. $receiptLog = new receiptLog ();
  3969. $rlList = array ();
  3970. $rlInfo = $receiptLog->getOne ( array (
  3971. 'where' => 'rid=' . $rid . ' and status=4',
  3972. 'asArray' => true
  3973. ) );
  3974. $tijdate = $receiptLog->getOne ( array (
  3975. 'where' => 'rid=' . $rid . ' and status=2',
  3976. 'asc' => 'rlid',
  3977. 'asArray' => true
  3978. ) );
  3979. if (! empty ( $rlInfo )) {
  3980. $rlList = $receiptLog->find ( array (
  3981. 'where' => 'rid=' . $rid,
  3982. 'asc' => 'rlid',
  3983. 'asArray' => true
  3984. ) );
  3985. }
  3986. $RN = @json_decode ( $rolename ['staff'] );
  3987. //
  3988. foreach ( $rlList as $key => $value ) {
  3989. $rlList [$key] ['rolename'] = '';
  3990. foreach ( $RN as $k => $v ) {
  3991. $id = explode ( "_", $v );
  3992. if ($id [0] == $value ['uid']) {
  3993. $rlList [$key] ['rolename'] = $FC;
  3994. break;
  3995. }
  3996. }
  3997. }
  3998. Doo::loadModel ( 'enclosur' );
  3999. $enclosur = new enclosur ();
  4000. $enclosurList = $enclosur->find ( array (
  4001. 'where' => 'rid=' . $rid,
  4002. 'asArray' => true
  4003. ) );
  4004. $enclosurHtml = '';
  4005. foreach ( $enclosurList as $value ) {
  4006. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4007. }
  4008. $data ['enclosurHtml'] = $enclosurHtml;
  4009. $receiptList [0] ['rlList'] = $rlList;
  4010. $data ['receiptList'] = $receiptList;
  4011. // print_r($receiptList);
  4012. $data ['memu'] = "receipt";
  4013. $data ['staff'] = $this->staff;
  4014. $data ['receiptMemu'] = 'approvalExpenses';
  4015. $data ['verifyId'] = $this->verifyId;
  4016. $data ['executeId'] = $this->executeId;
  4017. $this->render ( "/admin/expensesDoc", $data );
  4018. }
  4019. function expensesEdi() {
  4020. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4021. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  4022. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4023. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4024. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4025. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4026. if (empty ( $status ))
  4027. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  4028. $vidList = array ();
  4029. $button = 0;
  4030. Doo::loadModel ( 'verify' );
  4031. Doo::loadModel ( 'receipt' );
  4032. Doo::loadModel ( 'staff' );
  4033. $staff = new staff ();
  4034. $receipt = new receipt ();
  4035. $verify = new verify ();
  4036. Doo::loadModel ( 'L_category' );
  4037. $Lcategory = new L_category ();
  4038. Doo::loadModel ( 'enclosur' );
  4039. $enclosur = new enclosur ();
  4040. // user verify ID
  4041. $verifyDetail = $verify->find ( array (
  4042. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  4043. 'asArray' => true
  4044. ) );
  4045. foreach ( $verifyDetail as $key => $value ) {
  4046. array_push ( $vidList, $value ['vid'] );
  4047. }
  4048. $vid = implode ( ",", $vidList );
  4049. if (empty ( $verifyDetail ))
  4050. $vid = 0;
  4051. $categoryList = $Lcategory->find ( array (
  4052. 'asArray' => true
  4053. ) );
  4054. $staffList = $staff->find ( array (
  4055. 'where' => 'cid=' . $cid,
  4056. 'asArray' => true
  4057. ) );
  4058. $ap = "";
  4059. if ($status == 4) {
  4060. $ap = 4;
  4061. $status = 2;
  4062. }
  4063. // get Receipt By verifyID status 2
  4064. $receiptList = $receipt->find ( array (
  4065. 'where' => 'rid =' . $rid . ' and status=2',
  4066. 'desc' => 'rid',
  4067. 'asArray' => true
  4068. ) );
  4069. if (empty ( $receiptList )) {
  4070. die ( 'illegal request' );
  4071. }
  4072. $Locate = 0;
  4073. $roleId = 0;
  4074. if ($ap == 4)
  4075. $status = 4;
  4076. foreach ( $receiptList as $key => $value ) {
  4077. $receiptList [$key] ['Locate'] = $Locate;
  4078. $Locate ++;
  4079. $receiptList [$key] ['reviseDetail'] = array ();
  4080. if (! empty ( $value ['reviseDetail'] ))
  4081. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4082. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4083. $categoryDetil = $Lcategory->getOne ( array (
  4084. 'where' => 'cid=' . $value ['cid'],
  4085. 'asArray' => true
  4086. ) );
  4087. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4088. // 检测编辑状态
  4089. $verifyList = $verify->getOne ( array (
  4090. 'where' => 'vid=' . $value ['verify'],
  4091. 'asArray' => true
  4092. ) );
  4093. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4094. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4095. Doo::loadModel ( 'role' );
  4096. $role = new role ();
  4097. // print_r($verifyList);
  4098. $flag = true;
  4099. $roleKey = 0;
  4100. $endStaffArray = array ();
  4101. $roleArrayCopy = array ();
  4102. foreach ( $verifyList as $k => $v ) {
  4103. // init verifyStaff
  4104. if ($v [1] == 'ROLE') {
  4105. if (! empty ( $verifyStaff )) {
  4106. $endStaffArray = end ( $verifyStaff );
  4107. if ($v [0] == $endStaffArray ['nextStaff']) {
  4108. $roleId = $v [0];
  4109. }
  4110. }
  4111. $roleVerify = json_decode ( $v [3], true );
  4112. $roleKey = $k;
  4113. $roleArray = array ();
  4114. $rolename = $role->getOne ( array (
  4115. 'where' => 'rid=' . $v [0],
  4116. 'asArray' => true
  4117. ) );
  4118. foreach ( $roleVerify as $o => $p ) {
  4119. $staffID = explode ( '_', $p );
  4120. $staffInfo = $staff->getOne ( array (
  4121. 'where' => 'sid=' . $staffID [0],
  4122. 'asArray' => true
  4123. ) );
  4124. // print_r($staffID);
  4125. $exp = array (
  4126. 0 => $staffInfo ['sid'],
  4127. 1 => $staffID [1],
  4128. 2 => $staffInfo ['avatar'],
  4129. 'date' => '',
  4130. 'date' => '',
  4131. 'opinion' => '',
  4132. 'status' => '',
  4133. 'rolename' => $rolename ['name']
  4134. );
  4135. array_push ( $roleArray, $exp );
  4136. }
  4137. $roleArrayCopy [$v [0]] = $roleArray;
  4138. // $verifyList[$k]['roleArray']=$roleArray;
  4139. }
  4140. // print_r($roleArray);
  4141. $verifyList [$k] ['date'] = "";
  4142. $verifyList [$k] ['opinion'] = "";
  4143. $verifyList [$k] ['status'] = "";
  4144. if (empty ( $verifyStaff )) {
  4145. $verifyList [$k] ['date'] = "";
  4146. $verifyList [$k] ['opinion'] = "";
  4147. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4148. $verifyList [$k] ['status'] = 4;
  4149. $button = 4;
  4150. $flag = false;
  4151. }
  4152. } else {
  4153. foreach ( $verifyStaff as $m => $u ) {
  4154. if ($v [0] == $m) {
  4155. $verifyList [$k] ['date'] = $u ['date'];
  4156. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4157. $verifyList [$k] ['status'] = $u ['status'];
  4158. $flag = false;
  4159. break;
  4160. }
  4161. }
  4162. $endStaffArray = end ( $verifyStaff );
  4163. if (isset ( $endStaffArray ['ROLE'] )) {
  4164. } else {
  4165. $endKey = key ( $verifyStaff );
  4166. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4167. $button = 4;
  4168. $verifyList [$k] ['status'] = 4;
  4169. }
  4170. }
  4171. }
  4172. }
  4173. $rolename ['name'] = '';
  4174. if (! empty ( $roleId )) {
  4175. Doo::loadModel ( 'role' );
  4176. $role = new role ();
  4177. $rolename = $role->getOne ( array (
  4178. 'where' => 'rid=' . $roleId,
  4179. 'asArray' => true
  4180. ) );
  4181. }
  4182. if (! empty ( $verifyStaff ))
  4183. $endStaffArray = end ( $verifyStaff );
  4184. $KOP = false;
  4185. foreach ( $roleArrayCopy as $P => $A ) {
  4186. foreach ( $A as $MKI => $AVL ) {
  4187. if (! empty ( $verifyStaff )) {
  4188. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4189. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4190. $button = 4;
  4191. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4192. }
  4193. foreach ( $verifyStaff as $m => $u ) {
  4194. $AVLFK = $AVL [0] . '_R';
  4195. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4196. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4197. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4198. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4199. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4200. break;
  4201. }
  4202. }
  4203. } else {
  4204. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4205. $button = 4;
  4206. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4207. }
  4208. }
  4209. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4210. $KOP = true;
  4211. }
  4212. }
  4213. // print_r($roleArrayCopy);
  4214. // echo $roleKey;
  4215. foreach ( $roleArrayCopy as $k => $v ) {
  4216. foreach ( $verifyList as $m => $n ) {
  4217. if ($n [0] == $k) {
  4218. array_splice ( $verifyList, $m, 1, $v );
  4219. }
  4220. }
  4221. }
  4222. $receiptList [$key] ['verifyList'] = $verifyList;
  4223. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4224. 'where' => 'sid=' . $value ['staff'],
  4225. 'asArray' => true
  4226. ) );
  4227. $receiptList [$key] ['button'] = $button;
  4228. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  4229. }
  4230. // $data['verifyDetail']=$verifyDetail;
  4231. $mothHtml = "";
  4232. for($i = 1; $i <= 12; $i ++) {
  4233. if ($month == $i)
  4234. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4235. else
  4236. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4237. }
  4238. // 获取审批日志
  4239. Doo::loadModel ( 'receiptLog' );
  4240. $receiptLog = new receiptLog ();
  4241. $rlList = array ();
  4242. $rlInfo = $receiptLog->getOne ( array (
  4243. 'where' => 'rid=' . $rid . ' and status=4',
  4244. 'asArray' => true
  4245. ) );
  4246. $tijdate = $receiptLog->getOne ( array (
  4247. 'where' => 'rid=' . $rid . ' and status=2',
  4248. 'asc' => 'rlid',
  4249. 'asArray' => true
  4250. ) );
  4251. if (! empty ( $rlInfo )) {
  4252. $rlList = $receiptLog->find ( array (
  4253. 'where' => 'rid=' . $rid,
  4254. 'asc' => 'rlid',
  4255. 'asArray' => true
  4256. ) );
  4257. }
  4258. $receiptList [0] ['rlList'] = $rlList;
  4259. $enclosurList = $enclosur->find ( array (
  4260. 'where' => 'rid=' . $rid,
  4261. 'asArray' => true
  4262. ) );
  4263. $enclosurHtml = '';
  4264. foreach ( $enclosurList as $value ) {
  4265. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4266. }
  4267. // print_r($receiptList);
  4268. $data ['rid'] = $rid;
  4269. $data ['enclosurHtml'] = $enclosurHtml;
  4270. $data ['rolename'] = $rolename ['name'];
  4271. $data ['datetij'] = $tijdate ['date'];
  4272. $data ['mothHtml'] = $mothHtml;
  4273. $data ['receiptList'] = $receiptList;
  4274. $data ['receiptApprovalCount'] = count ( $receiptList );
  4275. $data ['status'] = $status;
  4276. $data ['year'] = $year;
  4277. $data ['categoryList'] = $categoryList;
  4278. $data ['staffList'] = $staffList;
  4279. $data ['cid'] = $cid;
  4280. $data ['sid'] = $sid;
  4281. $data ['ap'] = $ap;
  4282. $data ['memu'] = "receipt";
  4283. $data ['staff'] = $this->staff;
  4284. $data ['receiptMemu'] = 'approvalExpenses';
  4285. $data ['verifyId'] = $this->verifyId;
  4286. $data ['executeId'] = $this->executeId;
  4287. $this->render ( "/admin/expensesEdi", $data );
  4288. }
  4289. function expensesDefray() {
  4290. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  4291. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  4292. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4293. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  4294. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  4295. if (! empty ( $rid )) {
  4296. Doo::loadModel ( "verify" );
  4297. $verify = new verify ();
  4298. Doo::loadModel ( "receiptDetail" );
  4299. $receiptDetailObj = new receiptDetail ();
  4300. Doo::loadModel ( "itemStatistics" );
  4301. Doo::loadModel ( "statistics" );
  4302. $statistics = new statistics ();
  4303. $itemStatistics = new itemStatistics ();
  4304. Doo::loadModel ( "receipt" );
  4305. $receipt = new receipt ();
  4306. Doo::loadModel ( "loanReceipt" );
  4307. $loanReceipt = new loanReceipt ();
  4308. $receiptDetail = $receipt->getOne ( array (
  4309. 'where' => 'rid=' . $rid . ' and status=2 ',
  4310. 'asArray' => true
  4311. ) );
  4312. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  4313. $nsflag = true;
  4314. foreach ( $nslist as $value ) {
  4315. if ($value == $this->staff ['0'] ['sid']) {
  4316. $nsflag = false;
  4317. break;
  4318. }
  4319. }
  4320. // print_r($nslist);die;
  4321. if (empty ( $receiptDetail ) || $nsflag)
  4322. return "/approvalExpenses/pendApproval";
  4323. $verifyDetail = $verify->getOne ( array (
  4324. 'where' => ' vid =' . $receiptDetail ['verify'],
  4325. 'asArray' => true
  4326. ) );
  4327. $verifyString = $verifyDetail ['staff'];
  4328. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  4329. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  4330. if (empty ( $opinion )) {
  4331. if ($status == 3)
  4332. $opinion = "终止";
  4333. else
  4334. $opinion = "同意支付";
  4335. }
  4336. $nowStaff = 0;
  4337. $nowStaffList = array ();
  4338. if (empty ( $verifyStaff )) {
  4339. // 还需加入是否已经进入角色审批
  4340. if ($verifyDetail [0] [1] == 'ROLE') {
  4341. // print_r($verifyDetail);echo "ddd";
  4342. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  4343. foreach ( $vStaffString as $key => $value ) {
  4344. $staffK = explode ( "_", $value );
  4345. if ($staffK [0] != $this->staff [0] ['sid'])
  4346. array_push ( $nowStaffList, $staffK [0] );
  4347. }
  4348. // print_r($verifyDetail);
  4349. // die;
  4350. if (! empty ( $nowStaffList )) {
  4351. $nowStaff = implode ( ',', $nowStaffList );
  4352. $verifyStaff = array (
  4353. $this->staff [0] ['sid'] . "_R" => array (
  4354. 'date' => date ( 'Y-m-d' ),
  4355. 'opinion' => $opinion,
  4356. 'status' => $status,
  4357. 'nextStaff' => $verifyDetail [0] [0],
  4358. 'ROLE' => 1
  4359. )
  4360. );
  4361. } else {
  4362. $nowStaff = $verifyDetail [1] [0];
  4363. $verifyStaff = array (
  4364. $this->staff [0] ['sid'] . "_R" => array (
  4365. 'date' => date ( 'Y-m-d' ),
  4366. 'opinion' => $opinion,
  4367. 'status' => $status,
  4368. 'nextStaff' => $verifyDetail [1] [0]
  4369. )
  4370. );
  4371. }
  4372. } else {
  4373. if ($verifyDetail [1] [1] == 'ROLE') {
  4374. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  4375. // echo "dd";
  4376. foreach ( $vStaffString as $key => $value ) {
  4377. $staffK = explode ( "_", $value );
  4378. array_push ( $nowStaffList, $staffK [0] );
  4379. }
  4380. $nowStaff = implode ( ',', $nowStaffList );
  4381. $verifyStaff = array (
  4382. $this->staff [0] ['sid'] => array (
  4383. 'date' => date ( 'Y-m-d' ),
  4384. 'opinion' => $opinion,
  4385. 'status' => $status,
  4386. 'nextStaff' => $verifyDetail [1] [0],
  4387. 'ROLE' => 1
  4388. )
  4389. );
  4390. } else {
  4391. $nowStaff = $verifyDetail [1] [0];
  4392. $verifyStaff = array (
  4393. $this->staff [0] ['sid'] => array (
  4394. 'date' => date ( 'Y-m-d' ),
  4395. 'opinion' => $opinion,
  4396. 'status' => $status,
  4397. 'nextStaff' => $verifyDetail [1] [0]
  4398. )
  4399. );
  4400. }
  4401. }
  4402. if ($status == 3)
  4403. $verifyStaff = array (
  4404. 'final' => $status,
  4405. $this->staff [0] ['sid'] => array (
  4406. 'date' => date ( 'Y-m-d' ),
  4407. 'opinion' => $opinion,
  4408. 'status' => $status
  4409. )
  4410. );
  4411. $vStaffString = json_encode ( $verifyStaff );
  4412. $receipt->nowStaff = $nowStaff;
  4413. $receipt->verifyStaff = $vStaffString;
  4414. $loanReceipt->nowStaff = $nowStaff;
  4415. $loanReceipt->verifyStaff = $vStaffString;
  4416. } else {
  4417. $VS = end ( $verifyStaff );
  4418. // 非角色审批
  4419. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  4420. $nextStaff = 0;
  4421. $roleSTF = false;
  4422. foreach ( $verifyDetail as $key => $value ) {
  4423. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  4424. if (isset ( $verifyDetail [$key + 1] )) {
  4425. $nextStaff = $verifyDetail [$key + 1] [0];
  4426. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  4427. $roleSTF = true;
  4428. }
  4429. break;
  4430. }
  4431. }
  4432. if (! $roleSTF) {
  4433. $nowStaff = $nextStaff;
  4434. $verifyStaff [$this->staff [0] ['sid']] = array (
  4435. 'date' => date ( 'Y-m-d' ),
  4436. 'opinion' => $opinion,
  4437. 'status' => $status,
  4438. 'nextStaff' => $nextStaff
  4439. );
  4440. } else {
  4441. // 获取角色下的所有用户ID
  4442. $nowStaffList = array ();
  4443. foreach ( $verifyDetail as $vfk ) {
  4444. if ($vfk [1] == 'ROLE') {
  4445. $vStaffString = json_decode ( $vfk [3] );
  4446. foreach ( $vStaffString as $key => $value ) {
  4447. $staffK = explode ( "_", $value );
  4448. array_push ( $nowStaffList, $staffK [0] );
  4449. }
  4450. }
  4451. }
  4452. $nowStaff = implode ( ',', $nowStaffList );
  4453. $verifyStaff [$this->staff [0] ['sid']] = array (
  4454. 'date' => date ( 'Y-m-d' ),
  4455. 'opinion' => $opinion,
  4456. 'status' => $status,
  4457. 'nextStaff' => $nextStaff,
  4458. 'ROLE' => 0
  4459. );
  4460. }
  4461. if ($status == 3) {
  4462. $verifyStaff ['final'] = $status;
  4463. $verifyStaff [$this->staff [0] ['sid']] = array (
  4464. 'date' => date ( 'Y-m-d' ),
  4465. 'opinion' => $opinion,
  4466. 'status' => $status
  4467. );
  4468. }
  4469. $vStaffString = json_encode ( $verifyStaff );
  4470. $receipt->nowStaff = $nowStaff;
  4471. $receipt->verifyStaff = $vStaffString;
  4472. $loanReceipt->nowStaff = $nowStaff;
  4473. $loanReceipt->verifyStaff = $vStaffString;
  4474. }
  4475. // 角色审批
  4476. if (isset ( $VS ['ROLE'] )) {
  4477. // 找出角色人 当前审批角色组
  4478. $verifyJSStaff = array ();
  4479. $nowStaffList2 = array ();
  4480. foreach ( $verifyDetail as $key => $value ) {
  4481. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  4482. $verifyJSStaff = json_decode ( $value [3] );
  4483. foreach ( $verifyJSStaff as $m ) {
  4484. $staffK = explode ( "_", $m );
  4485. array_push ( $nowStaffList2, $staffK [0] );
  4486. }
  4487. // print_r($nowStaffList2);
  4488. }
  4489. }
  4490. $RoleVerifyStaff = array ();
  4491. foreach ( $verifyStaff as $key => $value ) {
  4492. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  4493. foreach ( $nowStaffList2 as $m ) {
  4494. if ($key == $m . "_R")
  4495. $RoleVerifyStaff [$key] = $value;
  4496. }
  4497. }
  4498. }
  4499. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  4500. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  4501. // 下一个审批人ID
  4502. $nextStaff = 0;
  4503. $falg = false;
  4504. foreach ( $verifyDetail as $key => $value ) {
  4505. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  4506. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  4507. $falg = true;
  4508. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  4509. $nowStaffList = array ();
  4510. foreach ( $vStaffString as $v ) {
  4511. $staffK = explode ( "_", $v );
  4512. array_push ( $nowStaffList, $staffK [0] );
  4513. }
  4514. $nowStaff = implode ( ',', $nowStaffList );
  4515. $nextStaff = $verifyDetail [$key + 1] [0];
  4516. } elseif (isset ( $verifyDetail [$key + 1] )) {
  4517. $nextStaff = $verifyDetail [$key + 1] [0];
  4518. $nowStaff = $nextStaff;
  4519. } else
  4520. $nowStaff = '';
  4521. break;
  4522. }
  4523. }
  4524. if ($falg)
  4525. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  4526. 'date' => date ( 'Y-m-d' ),
  4527. 'opinion' => $opinion,
  4528. 'status' => $status,
  4529. 'nextStaff' => $nextStaff,
  4530. 'ROLE' => 1
  4531. );
  4532. else
  4533. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  4534. 'date' => date ( 'Y-m-d' ),
  4535. 'opinion' => $opinion,
  4536. 'status' => $status,
  4537. 'nextStaff' => $nextStaff
  4538. );
  4539. // print_r($verifyStaff);
  4540. // echo $nowStaff;die;
  4541. } else { // 进入下一个角色或者审批人
  4542. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  4543. //
  4544. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  4545. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  4546. 'date' => date ( 'Y-m-d' ),
  4547. 'opinion' => $opinion,
  4548. 'status' => $status,
  4549. 'nextStaff' => $VS ['nextStaff'],
  4550. 'ROLE' => 1
  4551. );
  4552. // print_r($verifyStaff);
  4553. // die;
  4554. }
  4555. if ($status == 3) {
  4556. $verifyStaff ['final'] = $status;
  4557. $verifyStaff [$this->staff [0] ['sid']] = array (
  4558. 'date' => date ( 'Y-m-d' ),
  4559. 'opinion' => $opinion,
  4560. 'status' => $status
  4561. );
  4562. }
  4563. $vStaffString = json_encode ( $verifyStaff );
  4564. $receipt->verifyStaff = $vStaffString;
  4565. $receipt->nowStaff = $nowStaff;
  4566. $loanReceipt->nowStaff = $nowStaff;
  4567. $loanReceipt->verifyStaff = $vStaffString;
  4568. // die;
  4569. // }
  4570. // print_r($verifyStaff);
  4571. // die;
  4572. }
  4573. // print_r($verifyStaff);die;
  4574. }
  4575. // print_r($verifyDetail);
  4576. $roleKey = 0;
  4577. $roleId = 0;
  4578. $verifyDetailCopy = array ();
  4579. foreach ( $verifyDetail as $k => $v ) {
  4580. if ($v [1] == 'ROLE') {
  4581. $roleId = $v [0];
  4582. $roleVerify = json_decode ( $v [3], true );
  4583. $roleKey = $k;
  4584. $roleArray = array ();
  4585. foreach ( $roleVerify as $o => $p ) {
  4586. $staffID = explode ( '_', $p );
  4587. $exp = array (
  4588. 0 => $staffID [0],
  4589. 1 => $staffID [1]
  4590. );
  4591. array_push ( $roleArray, $exp );
  4592. }
  4593. $verifyDetailCopy [$v [0]] = $roleArray;
  4594. }
  4595. }
  4596. // print_r($verifyDetail);
  4597. foreach ( $verifyDetailCopy as $k => $v ) {
  4598. foreach ( $verifyDetail as $m => $n ) {
  4599. if ($n [0] == $k) {
  4600. array_splice ( $verifyDetail, $m, 1, $v );
  4601. }
  4602. }
  4603. }
  4604. // 审批日志
  4605. if (! isset ( $verifyStaff ['final'] )) {
  4606. Doo::loadModel ( "receiptLog" );
  4607. $receiptLog = new receiptLog ();
  4608. if (! empty ( $roleId )) {
  4609. Doo::loadModel ( "role" );
  4610. $role = new role ();
  4611. $roleInfo = $role->getOne ( array (
  4612. 'where' => 'rid=' . $roleId,
  4613. 'asArray' => true
  4614. ) );
  4615. $receiptLog->rolename = $roleInfo ['name'];
  4616. }
  4617. $receiptLog->username = $this->staff [0] ['username'];
  4618. $receiptLog->uid = $this->staff [0] ['sid'];
  4619. $receiptLog->date = date ( "Y-m-d" );
  4620. $receiptLog->opinion = $opinion;
  4621. $receiptLog->img = $this->staff [0] ['avatar'];
  4622. $receiptLog->status = 1;
  4623. $receiptLog->rid = $rid;
  4624. $receiptLog->insert ();
  4625. }
  4626. if (isset ( $verifyStaff ['final'] )) { // rDetail
  4627. $receipt->status = 3;
  4628. $receipt->verifyBreakup = $verifyString;
  4629. $receiptDetailObj->status = 3;
  4630. $receiptDetailObj->update ( array (
  4631. 'where' => 'rid=' . $rid
  4632. ) );
  4633. // 微信企业号通知
  4634. $this->setWXMsg ( $rid, 3 );
  4635. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  4636. $receipt->status = 6;
  4637. $receipt->pastDate = date ( "Y-m-d" );
  4638. $receipt->isBK = 1;
  4639. $loanReceipt->verifyBreakup = $verifyString;
  4640. $loanReceipt->status = 1;
  4641. $loanReceipt->pastDate = date ( "Y-m-d" );
  4642. $loanReceipt->amount = $receiptDetail ['amount'];
  4643. $loanReceipt->update ( array (
  4644. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  4645. ) );
  4646. // 微信企业号通知
  4647. $this->setWXMsg ( $rid, 1 );
  4648. }
  4649. $receipt->amount = $amount;
  4650. $receipt->update ( array (
  4651. 'where' => ' rid = ' . $rid
  4652. ) );
  4653. // 进入下一条审批费用新加需求
  4654. $vidList = array ();
  4655. $verifyDetail = $verify->find ( array (
  4656. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  4657. 'asArray' => true
  4658. ) );
  4659. foreach ( $verifyDetail as $key => $value ) {
  4660. array_push ( $vidList, $value ['vid'] );
  4661. }
  4662. $vid = implode ( ",", $vidList );
  4663. if (empty ( $verifyDetail ))
  4664. $vid = 0;
  4665. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  4666. $receipt = new receipt ();
  4667. $rd = $receipt->getOne ( array (
  4668. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  4669. 'asc' => 'rid',
  4670. 'asArray' => true
  4671. ) );
  4672. if (empty ( $rd )) {
  4673. return '/approvalExpenses/pendApproval';
  4674. }
  4675. if ($rd ['Rtype'] == 1) {
  4676. if ($rd ['isBK'] == 1) {
  4677. return '/receiptburEdi/' . $rd ['rid'];
  4678. } else {
  4679. return '/expensesEdi/' . $rd ['rid'];
  4680. }
  4681. } elseif ($rd ['Rtype'] == 2) {
  4682. return '/remitApproval/' . $rd ['rid'];
  4683. } else {
  4684. return '/receiptburEdi/' . $rd ['rid'];
  4685. }
  4686. // return "/approvalExpenses/pendApproval";
  4687. }
  4688. }
  4689. function ajaxExamineExe() {
  4690. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4691. Doo::loadModel ( 'receipt' );
  4692. $receipt = new receipt ();
  4693. Doo::loadClass ( 'XDeode' );
  4694. $XDeode = new XDeode ( 5 );
  4695. if (! empty ( $rid )) {
  4696. $rLRes = $receipt->find ( array (
  4697. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  4698. 'asArray' => true
  4699. ) );
  4700. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  4701. echo json_encode ( array (
  4702. 'status' => 1,
  4703. 'receipt' => $rLRes [0]
  4704. ) );
  4705. die ();
  4706. }
  4707. echo json_encode ( array (
  4708. 'status' => 0,
  4709. 'receipt' => array ()
  4710. ) );
  4711. die ();
  4712. }
  4713. function implement() {
  4714. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4715. Doo::loadClass ( 'XDeode' );
  4716. $XDeode = new XDeode ( 5 );
  4717. Doo::loadModel ( 'receipt' );
  4718. $receipt = new receipt ();
  4719. Doo::loadModel ( 'L_category' );
  4720. $Lcategory = new L_category ();
  4721. Doo::loadModel ( 'verify' );
  4722. $verify = new verify ();
  4723. Doo::loadModel ( 'staff' );
  4724. $staff = new staff ();
  4725. Doo::loadModel ( "execute" );
  4726. $execute = new execute ();
  4727. $rid = $XDeode->decode ( $rid );
  4728. $receiptList = $receipt->find ( array (
  4729. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  4730. 'desc' => 'rid',
  4731. 'asArray' => true
  4732. ) );
  4733. Doo::loadModel ( 'loanReceipt' );
  4734. $loanReceipt = new loanReceipt ();
  4735. // print_r($receiptList);
  4736. $loanList = array ();
  4737. if (! isset ( $receiptList ))
  4738. $loanList = $loanReceipt->find ( array (
  4739. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4740. 'desc' => 'rid',
  4741. 'asArray' => true
  4742. ) );
  4743. $Locate = 0;
  4744. $roleId = 0;
  4745. $button = 0;
  4746. foreach ( $loanList as $key => $value ) {
  4747. $loanList [$key] ['Locate'] = $Locate;
  4748. $Locate ++;
  4749. $loanList [$key] ['reviseDetail'] = array ();
  4750. if (! empty ( $value ['reviseDetail'] ))
  4751. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4752. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4753. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4754. $categoryDetil = $Lcategory->getOne ( array (
  4755. 'where' => 'cid=' . $value ['cid'],
  4756. 'asArray' => true
  4757. ) );
  4758. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4759. // 检测编辑状态
  4760. $verifyList = $verify->getOne ( array (
  4761. 'where' => 'vid=' . $value ['verify'],
  4762. 'asArray' => true
  4763. ) );
  4764. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4765. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4766. Doo::loadModel ( 'role' );
  4767. $role = new role ();
  4768. $flag = true;
  4769. $roleKey = 0;
  4770. $endStaffArray = array ();
  4771. $roleArrayCopy = array ();
  4772. foreach ( $verifyList as $k => $v ) {
  4773. // init verifyStaff
  4774. if ($v [1] == 'ROLE') {
  4775. if (! empty ( $verifyStaff )) {
  4776. $endStaffArray = end ( $verifyStaff );
  4777. // if ($v[0]==$endStaffArray['nextStaff']){
  4778. // $roleId=$v[0];
  4779. // }
  4780. }
  4781. $roleVerify = json_decode ( $v [3], true );
  4782. $roleKey = $k;
  4783. $roleArray = array ();
  4784. $rolename = $role->getOne ( array (
  4785. 'where' => 'rid=' . $v [0],
  4786. 'asArray' => true
  4787. ) );
  4788. foreach ( $roleVerify as $o => $p ) {
  4789. $staffID = explode ( '_', $p );
  4790. $staffInfo = $staff->getOne ( array (
  4791. 'where' => 'sid=' . $staffID [0],
  4792. 'asArray' => true
  4793. ) );
  4794. // print_r($staffID);
  4795. $exp = array (
  4796. 0 => $staffInfo ['sid'],
  4797. 1 => $staffID [1],
  4798. 2 => $staffInfo ['avatar'],
  4799. 'date' => '',
  4800. 'date' => '',
  4801. 'opinion' => '',
  4802. 'status' => '',
  4803. 'rolename' => $rolename ['name']
  4804. );
  4805. array_push ( $roleArray, $exp );
  4806. }
  4807. $roleArrayCopy [$v [0]] = $roleArray;
  4808. // $verifyList[$k]['roleArray']=$roleArray;
  4809. }
  4810. $verifyList [$k] ['date'] = "";
  4811. $verifyList [$k] ['opinion'] = "";
  4812. $verifyList [$k] ['status'] = "";
  4813. if (empty ( $verifyStaff )) {
  4814. $verifyList [$k] ['date'] = "";
  4815. $verifyList [$k] ['opinion'] = "";
  4816. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4817. $verifyList [$k] ['status'] = 4;
  4818. $flag = false;
  4819. }
  4820. } else {
  4821. foreach ( $verifyStaff as $m => $u ) {
  4822. if ($v [0] == $m) {
  4823. $verifyList [$k] ['date'] = $u ['date'];
  4824. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4825. $verifyList [$k] ['status'] = $u ['status'];
  4826. $flag = false;
  4827. break;
  4828. }
  4829. }
  4830. $endStaffArray = end ( $verifyStaff );
  4831. if (isset ( $endStaffArray ['ROLE'] )) {
  4832. } else {
  4833. // $endKey=key($verifyStaff);
  4834. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4835. // $button=4;
  4836. // $verifyList[$k]['status']=4;
  4837. // }
  4838. }
  4839. }
  4840. }
  4841. $rolename ['name'] = '';
  4842. if (! empty ( $roleId )) {
  4843. Doo::loadModel ( 'role' );
  4844. $role = new role ();
  4845. $rolename = $role->getOne ( array (
  4846. 'where' => 'rid=' . $roleId,
  4847. 'asArray' => true
  4848. ) );
  4849. }
  4850. if (! empty ( $verifyStaff ))
  4851. $endStaffArray = end ( $verifyStaff );
  4852. $KOP = false;
  4853. foreach ( $roleArrayCopy as $P => $A ) {
  4854. foreach ( $A as $MKI => $AVL ) {
  4855. if (! empty ( $verifyStaff )) {
  4856. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4857. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4858. $button = 4;
  4859. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4860. }
  4861. foreach ( $verifyStaff as $m => $u ) {
  4862. $AVLFK = $AVL [0] . '_R';
  4863. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4864. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4865. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4866. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4867. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4868. break;
  4869. }
  4870. }
  4871. } else {
  4872. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4873. $button = 4;
  4874. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4875. }
  4876. }
  4877. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4878. $KOP = true;
  4879. }
  4880. }
  4881. foreach ( $roleArrayCopy as $k => $v ) {
  4882. foreach ( $verifyList as $m => $n ) {
  4883. if ($n [0] == $k) {
  4884. array_splice ( $verifyList, $m, 1, $v );
  4885. }
  4886. }
  4887. }
  4888. $loanList [$key] ['verifyList'] = $verifyList;
  4889. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  4890. 'where' => 'sid=' . $value ['staff'],
  4891. 'asArray' => true
  4892. ) );
  4893. }
  4894. $data ['loanList'] = $loanList;
  4895. $Locate = 0;
  4896. $roleId = 0;
  4897. $button = 0;
  4898. Doo::loadClass ( 'XDeode' );
  4899. $XDeode = new XDeode ( 5 );
  4900. foreach ( $receiptList as $key => $value ) {
  4901. $receiptList[$key]['ridKey']=$XDeode->encode ( $value['rid'] );
  4902. $button2 = 0;
  4903. $receiptList [$key] ['Locate'] = $Locate;
  4904. $Locate ++;
  4905. $receiptList [$key] ['reviseDetail'] = array ();
  4906. if (! empty ( $value ['reviseDetail'] ))
  4907. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4908. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4909. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4910. $categoryDetil = $Lcategory->getOne ( array (
  4911. 'where' => 'cid=' . $value ['cid'],
  4912. 'asArray' => true
  4913. ) );
  4914. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4915. $executeList = json_decode ( $value ['executeCopy'], true );
  4916. $executeStaff = array ();
  4917. if (! empty ( $value ['executeStaff'] ))
  4918. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4919. if (isset ( $executeList )) {
  4920. foreach ( $executeList as $op => $lo ) {
  4921. $executeList [$op] ['date'] = "";
  4922. $executeList [$op] ['opinion'] = "";
  4923. $executeList [$op] ['status'] = "";
  4924. foreach ( $executeStaff as $m => $u ) {
  4925. if ($lo [0] == $m) {
  4926. $executeList [$op] ['date'] = $u ['date'];
  4927. $executeList [$op] ['opinion'] = $u ['opinion'];
  4928. $executeList [$op] ['status'] = $u ['status'];
  4929. break;
  4930. }
  4931. }
  4932. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  4933. $button2 = 1;
  4934. $executeList [$op] ['status'] = 4;
  4935. }
  4936. }
  4937. }
  4938. // 检测编辑状态
  4939. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  4940. $verifyList ['staff'] = $value ['verifyBreakup'];
  4941. } else
  4942. $verifyList = $verify->getOne ( array (
  4943. 'where' => 'vid=' . $value ['verify'],
  4944. 'asArray' => true
  4945. ) );
  4946. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4947. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4948. Doo::loadModel ( 'role' );
  4949. $role = new role ();
  4950. if ($verifyList == NULL)
  4951. $verifyList = array ();
  4952. $flag = true;
  4953. $roleKey = 0;
  4954. $endStaffArray = array ();
  4955. $roleArrayCopy = array ();
  4956. foreach ( $verifyList as $k => $v ) {
  4957. // init verifyStaff
  4958. if ($v [1] == 'ROLE') {
  4959. if (! empty ( $verifyStaff )) {
  4960. $endStaffArray = end ( $verifyStaff );
  4961. // if ($v[0]==$endStaffArray['nextStaff']){
  4962. // $roleId=$v[0];
  4963. // }
  4964. }
  4965. $roleVerify = json_decode ( $v [3], true );
  4966. $roleKey = $k;
  4967. $roleArray = array ();
  4968. $rolename = $role->getOne ( array (
  4969. 'where' => 'rid=' . $v [0],
  4970. 'asArray' => true
  4971. ) );
  4972. foreach ( $roleVerify as $o => $p ) {
  4973. $staffID = explode ( '_', $p );
  4974. $staffInfo = $staff->getOne ( array (
  4975. 'where' => 'sid=' . $staffID [0],
  4976. 'asArray' => true
  4977. ) );
  4978. // print_r($staffID);
  4979. $exp = array (
  4980. 0 => $staffInfo ['sid'],
  4981. 1 => $staffID [1],
  4982. 2 => $staffInfo ['avatar'],
  4983. 'date' => '',
  4984. 'date' => '',
  4985. 'opinion' => '',
  4986. 'status' => '',
  4987. 'rolename' => $rolename ['name']
  4988. );
  4989. array_push ( $roleArray, $exp );
  4990. }
  4991. $roleArrayCopy [$v [0]] = $roleArray;
  4992. // $verifyList[$k]['roleArray']=$roleArray;
  4993. }
  4994. $verifyList [$k] ['date'] = "";
  4995. $verifyList [$k] ['opinion'] = "";
  4996. $verifyList [$k] ['status'] = "";
  4997. if (empty ( $verifyStaff )) {
  4998. $verifyList [$k] ['date'] = "";
  4999. $verifyList [$k] ['opinion'] = "";
  5000. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5001. $verifyList [$k] ['status'] = 4;
  5002. $flag = false;
  5003. }
  5004. } else {
  5005. foreach ( $verifyStaff as $m => $u ) {
  5006. if ($v [0] == $m) {
  5007. $verifyList [$k] ['date'] = $u ['date'];
  5008. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5009. $verifyList [$k] ['status'] = $u ['status'];
  5010. $flag = false;
  5011. break;
  5012. }
  5013. }
  5014. $endStaffArray = end ( $verifyStaff );
  5015. if (isset ( $endStaffArray ['ROLE'] )) {
  5016. } else {
  5017. // $endKey=key($verifyStaff);
  5018. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5019. // $button=4;
  5020. // $verifyList[$k]['status']=4;
  5021. // }
  5022. }
  5023. }
  5024. }
  5025. $rolename ['name'] = '';
  5026. if (! empty ( $roleId )) {
  5027. Doo::loadModel ( 'role' );
  5028. $role = new role ();
  5029. $rolename = $role->getOne ( array (
  5030. 'where' => 'rid=' . $roleId,
  5031. 'asArray' => true
  5032. ) );
  5033. }
  5034. if (! empty ( $verifyStaff ))
  5035. $endStaffArray = end ( $verifyStaff );
  5036. $KOP = false;
  5037. foreach ( $roleArrayCopy as $P => $A ) {
  5038. foreach ( $A as $MKI => $AVL ) {
  5039. if (! empty ( $verifyStaff )) {
  5040. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5041. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5042. $button = 4;
  5043. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5044. }
  5045. foreach ( $verifyStaff as $m => $u ) {
  5046. $AVLFK = $AVL [0] . '_R';
  5047. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5048. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5049. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5050. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5051. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5052. break;
  5053. }
  5054. }
  5055. } else {
  5056. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5057. $button = 4;
  5058. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5059. }
  5060. }
  5061. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5062. $KOP = true;
  5063. }
  5064. }
  5065. foreach ( $roleArrayCopy as $k => $v ) {
  5066. foreach ( $verifyList as $m => $n ) {
  5067. if ($n [0] == $k) {
  5068. array_splice ( $verifyList, $m, 1, $v );
  5069. }
  5070. }
  5071. }
  5072. $receiptList [$key] ['verifyList'] = $verifyList;
  5073. $receiptList [$key] ['executeList'] = $executeList;
  5074. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5075. 'where' => 'sid=' . $value ['staff'],
  5076. 'asArray' => true
  5077. ) );
  5078. $receiptList [$key] ['button2'] = $button2;
  5079. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5080. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5081. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5082. $receiptList [$key] ['relust'] = $relust;
  5083. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  5084. }
  5085. // 是否写入过流水
  5086. $accountType = 0;
  5087. if ($receiptList [0] ['Rtype'] == 0) {
  5088. $accountType = 3;
  5089. } elseif ($receiptList [0] ['Rtype'] == 1) {
  5090. if ($receiptList [0] ['Rtype'] == 0) {
  5091. $accountType = 1;
  5092. } elseif ($receiptList [0] ['Rtype'] == 1) {
  5093. $accountType = 2;
  5094. }
  5095. } elseif ($receiptList [0] ['Rtype'] == 2) {
  5096. $accountType = 4;
  5097. } elseif ($receiptList [0] ['Rtype'] == 3) {
  5098. $accountType = 12;
  5099. }
  5100. Doo::loadModel ( 'wasteBook' );
  5101. $wasteBook = new wasteBook ();
  5102. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $receiptList [0] ['rid'] );
  5103. $data ['wbDetail'] = $wbDetail;
  5104. //print_r($receiptList);
  5105. $data ['receiptList'] = $receiptList;
  5106. $data ['memu'] = "receipt";
  5107. $data ['staff'] = $this->staff;
  5108. $data ['receiptMemu'] = 'implement';
  5109. $data ['verifyId'] = $this->verifyId;
  5110. $data ['executeId'] = $this->executeId;
  5111. $this->render ( "/admin/implement", $data );
  5112. }
  5113. function implementDo() {
  5114. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5115. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  5116. // $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  5117. // $accountBank = $this->get_args ( 'accountBank' ) ? $this->get_args ( 'accountBank' ) : "";
  5118. // $ab = '';
  5119. // if ($accountBank == 'CGBDeposit')
  5120. // $ab = '纵横广发';
  5121. // elseif ($accountBank == 'ICBCDeposit')
  5122. // $ab = '纵横工行';
  5123. // elseif ($accountBank == 'HUADeposit')
  5124. // $ab = '华润银行';
  5125. // elseif ($accountBank == 'PersonalDeposit')
  5126. // $ab = '个人广发';
  5127. // if (empty ( $ab ))
  5128. // die ( 'illegal request--22' );
  5129. if (! empty ( $rid )) {
  5130. Doo::loadModel ( 'receipt' );
  5131. $receipt = new receipt ();
  5132. // Doo::loadClass ( 'XDeode' );
  5133. // $XDeode = new XDeode ( 5 );
  5134. // $rinfo = $receipt->getOne ( array (
  5135. // 'where' => 'rid=' . $rid,
  5136. // 'asArray' => true
  5137. // ) );
  5138. $rinfo = $receipt->getReceiptByRid ( $rid );
  5139. $accountType = '';
  5140. if ($rinfo ['Rtype'] == 1) {
  5141. if ($rinfo ['loanRid'] != 0)
  5142. $accountType = 2;
  5143. else
  5144. $accountType = 1;
  5145. } elseif ($rinfo ['Rtype'] == 2) {
  5146. $accountType = 4;
  5147. } elseif ($rinfo ['Rtype'] == 0)
  5148. $accountType = 3;
  5149. if (empty ( $accountType ))
  5150. die ( 'illegal request' );
  5151. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  5152. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  5153. if (empty ( $executeStaff )) {
  5154. $executeStaff = array (
  5155. $this->staff [0] ['sid'] => array (
  5156. 'date' => date ( 'Y-m-d' ),
  5157. 'opinion' => $implementOpinions,
  5158. 'status' => 1
  5159. )
  5160. );
  5161. } else {
  5162. $executeStaff [$this->staff [0] ['sid']] = array (
  5163. 'date' => date ( 'Y-m-d' ),
  5164. 'opinion' => $implementOpinions,
  5165. 'status' => 1
  5166. );
  5167. }
  5168. if (count ( $executeStaff ) == count ( $executeCopy )) {
  5169. $receipt->executeStaff = json_encode ( $executeStaff );
  5170. $receipt->status = 8;
  5171. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  5172. $receipt->status = 9;
  5173. if ($rinfo ['status'] == 6) {
  5174. $receipt->loanDate = date ( "Y-m-d" );
  5175. }
  5176. $receipt->executeDate = date ( "Y-m-d" );
  5177. } else {
  5178. $receipt->executeStaff = json_encode ( $executeStaff );
  5179. }
  5180. $receipt->amount = $amount;
  5181. $receipt->update ( array (
  5182. 'where' => 'rid=' . $rid
  5183. ) );
  5184. // 公司流水记录
  5185. // Doo::loadModel ( 'wasteBook' );
  5186. // $wasteBook = new wasteBook ();
  5187. // $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountType, $rid );
  5188. // // 银行
  5189. // if (empty ( $abDetail ) && ! empty ( $amount )) {
  5190. // $item = array (
  5191. // 'dataID' => $rid,
  5192. // 'expensesType' => 2,
  5193. // 'accountType' => $accountType,
  5194. // 'accountPriceShow' => $amount,
  5195. // 'accountPrice' => - $amount,
  5196. // 'accountBank' => $accountBank,
  5197. // 'category' => $rinfo ['category'] [0] ['title'],
  5198. // 'cid' => $rinfo ['category'] [0] ['cid'],
  5199. // 'name' => $rinfo ['staffDetail'] ['username'],
  5200. // 'sid' => $rinfo ['staffDetail'] ['sid'],
  5201. // 'inputDate' => date ( "Y-m-d H:i:s" )
  5202. // );
  5203. // $wasteBook->setAccountBookStatistics ( $item );
  5204. // }
  5205. }
  5206. //$ridKey = $XDeode->encode ( $rid );
  5207. return "/hisImplement";
  5208. // return "/implement/" . $ridKey . ".html";
  5209. }
  5210. function receiptburEdi() {
  5211. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5212. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5213. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5214. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5215. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5216. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5217. if (empty ( $status ))
  5218. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5219. $vidList = array ();
  5220. $button = 0;
  5221. Doo::loadModel ( 'verify' );
  5222. Doo::loadModel ( 'receipt' );
  5223. Doo::loadModel ( 'staff' );
  5224. $staff = new staff ();
  5225. $receipt = new receipt ();
  5226. $verify = new verify ();
  5227. Doo::loadModel ( 'L_category' );
  5228. $Lcategory = new L_category ();
  5229. Doo::loadModel ( 'enclosur' );
  5230. $enclosur = new enclosur ();
  5231. Doo::loadModel ( 'loanReceipt' );
  5232. $loanReceipt = new loanReceipt ();
  5233. // user verify ID
  5234. $verifyDetail = $verify->find ( array (
  5235. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5236. 'asArray' => true
  5237. ) );
  5238. foreach ( $verifyDetail as $key => $value ) {
  5239. array_push ( $vidList, $value ['vid'] );
  5240. }
  5241. $vid = implode ( ",", $vidList );
  5242. if (empty ( $verifyDetail ))
  5243. $vid = 0;
  5244. $categoryList = $Lcategory->find ( array (
  5245. 'asArray' => true
  5246. ) );
  5247. $staffList = $staff->find ( array (
  5248. 'where' => 'cid=' . $cid,
  5249. 'asArray' => true
  5250. ) );
  5251. $ap = "";
  5252. if ($status == 4) {
  5253. $ap = 4;
  5254. $status = 2;
  5255. }
  5256. // get Receipt By verifyID status 2
  5257. $receiptList = $receipt->find ( array (
  5258. 'where' => 'rid =' . $rid . ' and status=2',
  5259. 'desc' => 'rid',
  5260. 'asArray' => true
  5261. ) );
  5262. if (empty ( $receiptList )) {
  5263. die ( 'illegal request' );
  5264. }
  5265. $loanList = $loanReceipt->find ( array (
  5266. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  5267. 'desc' => 'rid',
  5268. 'asArray' => true
  5269. ) );
  5270. $data ['explanation'] = '';
  5271. if (! empty ( $loanList ))
  5272. $data ['explanation'] = $loanList [0] ['explanation'];
  5273. $Locate = 0;
  5274. $roleId = 0;
  5275. $button = 0;
  5276. foreach ( $loanList as $key => $value ) {
  5277. $loanList [$key] ['Locate'] = $Locate;
  5278. $Locate ++;
  5279. $loanList [$key] ['reviseDetail'] = array ();
  5280. if (! empty ( $value ['reviseDetail'] ))
  5281. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5282. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5283. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5284. $categoryDetil = $Lcategory->getOne ( array (
  5285. 'where' => 'cid=' . $value ['cid'],
  5286. 'asArray' => true
  5287. ) );
  5288. $loanList [$key] ['category'] = $categoryDetil ['title'];
  5289. // 检测编辑状态
  5290. $verifyList = $verify->getOne ( array (
  5291. 'where' => 'vid=' . $value ['verify'],
  5292. 'asArray' => true
  5293. ) );
  5294. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5295. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5296. Doo::loadModel ( 'role' );
  5297. $role = new role ();
  5298. $flag = true;
  5299. $roleKey = 0;
  5300. $endStaffArray = array ();
  5301. $roleArrayCopy = array ();
  5302. foreach ( $verifyList as $k => $v ) {
  5303. // init verifyStaff
  5304. if ($v [1] == 'ROLE') {
  5305. if (! empty ( $verifyStaff )) {
  5306. $endStaffArray = end ( $verifyStaff );
  5307. }
  5308. $roleVerify = json_decode ( $v [3], true );
  5309. $roleKey = $k;
  5310. $roleArray = array ();
  5311. $rolename = $role->getOne ( array (
  5312. 'where' => 'rid=' . $v [0],
  5313. 'asArray' => true
  5314. ) );
  5315. foreach ( $roleVerify as $o => $p ) {
  5316. $staffID = explode ( '_', $p );
  5317. $staffInfo = $staff->getOne ( array (
  5318. 'where' => 'sid=' . $staffID [0],
  5319. 'asArray' => true
  5320. ) );
  5321. // print_r($staffID);
  5322. $exp = array (
  5323. 0 => $staffInfo ['sid'],
  5324. 1 => $staffID [1],
  5325. 2 => $staffInfo ['avatar'],
  5326. 'date' => '',
  5327. 'date' => '',
  5328. 'opinion' => '',
  5329. 'status' => '',
  5330. 'rolename' => $rolename ['name']
  5331. );
  5332. array_push ( $roleArray, $exp );
  5333. }
  5334. $roleArrayCopy [$v [0]] = $roleArray;
  5335. // $verifyList[$k]['roleArray']=$roleArray;
  5336. }
  5337. $verifyList [$k] ['date'] = "";
  5338. $verifyList [$k] ['opinion'] = "";
  5339. $verifyList [$k] ['status'] = "";
  5340. if (empty ( $verifyStaff )) {
  5341. $verifyList [$k] ['date'] = "";
  5342. $verifyList [$k] ['opinion'] = "";
  5343. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5344. $verifyList [$k] ['status'] = 4;
  5345. $flag = false;
  5346. }
  5347. } else {
  5348. foreach ( $verifyStaff as $m => $u ) {
  5349. if ($v [0] == $m) {
  5350. $verifyList [$k] ['date'] = $u ['date'];
  5351. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5352. $verifyList [$k] ['status'] = $u ['status'];
  5353. $flag = false;
  5354. break;
  5355. }
  5356. }
  5357. $endStaffArray = end ( $verifyStaff );
  5358. if (isset ( $endStaffArray ['ROLE'] )) {
  5359. } else {
  5360. }
  5361. }
  5362. }
  5363. $rolename ['name'] = '';
  5364. if (! empty ( $roleId )) {
  5365. Doo::loadModel ( 'role' );
  5366. $role = new role ();
  5367. $rolename = $role->getOne ( array (
  5368. 'where' => 'rid=' . $roleId,
  5369. 'asArray' => true
  5370. ) );
  5371. }
  5372. if (! empty ( $verifyStaff ))
  5373. $endStaffArray = end ( $verifyStaff );
  5374. $KOP = false;
  5375. foreach ( $roleArrayCopy as $P => $A ) {
  5376. foreach ( $A as $MKI => $AVL ) {
  5377. if (! empty ( $verifyStaff )) {
  5378. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5379. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5380. $button = 4;
  5381. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5382. }
  5383. foreach ( $verifyStaff as $m => $u ) {
  5384. $AVLFK = $AVL [0] . '_R';
  5385. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5386. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5387. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5388. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5389. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5390. break;
  5391. }
  5392. }
  5393. } else {
  5394. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5395. $button = 4;
  5396. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5397. }
  5398. }
  5399. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5400. $KOP = true;
  5401. }
  5402. }
  5403. foreach ( $roleArrayCopy as $k => $v ) {
  5404. foreach ( $verifyList as $m => $n ) {
  5405. if ($n [0] == $k) {
  5406. array_splice ( $verifyList, $m, 1, $v );
  5407. }
  5408. }
  5409. }
  5410. $loanList [$key] ['verifyList'] = $verifyList;
  5411. }
  5412. $htmlLoan = '';
  5413. $data ['loanReceiptDate'] = '';
  5414. if (isset ( $loanList [0] )) {
  5415. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  5416. if ($value ['status'] == 1)
  5417. $htmlLoan .= '<li class="done" >';
  5418. elseif ($value ['status'] == 3)
  5419. $htmlLoan .= '<li class="undone" >';
  5420. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  5421. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  5422. if (isset ( $value ['rolename'] ))
  5423. $htmlLoan .= $value ['rolename'];
  5424. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  5425. }
  5426. $data ['loanDate'] = $loanList [0] ['date'];
  5427. } else {
  5428. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  5429. }
  5430. $data ['htmlLoan'] = $htmlLoan;
  5431. // $data ['LoanReceipt']=$loanList[0];
  5432. // print_r($loanList);
  5433. $Locate = 0;
  5434. $roleId = 0;
  5435. $button = 0;
  5436. if ($ap == 4)
  5437. $status = 4;
  5438. Doo::loadClass ( 'XDeode' );
  5439. $XDeode = new XDeode ( 5 );
  5440. foreach ( $receiptList as $key => $value ) {
  5441. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  5442. $receiptList [$key] ['Locate'] = $Locate;
  5443. $Locate ++;
  5444. $receiptList [$key] ['reviseDetail'] = array ();
  5445. // 调整金额 代码调整
  5446. if (! empty ( $value ['reviseDetail'] )) {
  5447. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  5448. foreach ( $reviseDetail as $ry => $re ) {
  5449. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  5450. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  5451. }
  5452. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  5453. // print_r($reviseDetail);
  5454. }
  5455. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5456. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5457. $categoryDetil = $Lcategory->getOne ( array (
  5458. 'where' => 'cid=' . $value ['cid'],
  5459. 'asArray' => true
  5460. ) );
  5461. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5462. // 检测编辑状态
  5463. $verifyList = $verify->getOne ( array (
  5464. 'where' => 'vid=' . $value ['verify'],
  5465. 'asArray' => true
  5466. ) );
  5467. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5468. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5469. Doo::loadModel ( 'role' );
  5470. $role = new role ();
  5471. // print_r($verifyList);
  5472. $flag = true;
  5473. $roleKey = 0;
  5474. $endStaffArray = array ();
  5475. $roleArrayCopy = array ();
  5476. foreach ( $verifyList as $k => $v ) {
  5477. // init verifyStaff
  5478. if ($v [1] == 'ROLE') {
  5479. if (! empty ( $verifyStaff )) {
  5480. $endStaffArray = end ( $verifyStaff );
  5481. if ($v [0] == $endStaffArray ['nextStaff']) {
  5482. $roleId = $v [0];
  5483. }
  5484. }
  5485. $roleVerify = json_decode ( $v [3], true );
  5486. $roleKey = $k;
  5487. $roleArray = array ();
  5488. $rolename = $role->getOne ( array (
  5489. 'where' => 'rid=' . $v [0],
  5490. 'asArray' => true
  5491. ) );
  5492. foreach ( $roleVerify as $o => $p ) {
  5493. $staffID = explode ( '_', $p );
  5494. $staffInfo = $staff->getOne ( array (
  5495. 'where' => 'sid=' . $staffID [0],
  5496. 'asArray' => true
  5497. ) );
  5498. // print_r($staffID);
  5499. $exp = array (
  5500. 0 => $staffInfo ['sid'],
  5501. 1 => $staffID [1],
  5502. 2 => $staffInfo ['avatar'],
  5503. 'date' => '',
  5504. 'date' => '',
  5505. 'opinion' => '',
  5506. 'status' => '',
  5507. 'rolename' => $rolename ['name']
  5508. );
  5509. array_push ( $roleArray, $exp );
  5510. }
  5511. $roleArrayCopy [$v [0]] = $roleArray;
  5512. // $verifyList[$k]['roleArray']=$roleArray;
  5513. }
  5514. // print_r($roleArray);
  5515. $verifyList [$k] ['date'] = "";
  5516. $verifyList [$k] ['opinion'] = "";
  5517. $verifyList [$k] ['status'] = "";
  5518. if (empty ( $verifyStaff )) {
  5519. $verifyList [$k] ['date'] = "";
  5520. $verifyList [$k] ['opinion'] = "";
  5521. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5522. $verifyList [$k] ['status'] = 4;
  5523. $button = 4;
  5524. $flag = false;
  5525. }
  5526. } else {
  5527. foreach ( $verifyStaff as $m => $u ) {
  5528. if ($v [0] == $m) {
  5529. $verifyList [$k] ['date'] = $u ['date'];
  5530. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5531. $verifyList [$k] ['status'] = $u ['status'];
  5532. $flag = false;
  5533. break;
  5534. }
  5535. }
  5536. $endStaffArray = end ( $verifyStaff );
  5537. if (isset ( $endStaffArray ['ROLE'] )) {
  5538. } else {
  5539. $endKey = key ( $verifyStaff );
  5540. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5541. $button = 4;
  5542. $verifyList [$k] ['status'] = 4;
  5543. }
  5544. }
  5545. }
  5546. }
  5547. $rolename ['name'] = '';
  5548. if (! empty ( $roleId )) {
  5549. Doo::loadModel ( 'role' );
  5550. $role = new role ();
  5551. $rolename = $role->getOne ( array (
  5552. 'where' => 'rid=' . $roleId,
  5553. 'asArray' => true
  5554. ) );
  5555. }
  5556. if (! empty ( $verifyStaff ))
  5557. $endStaffArray = end ( $verifyStaff );
  5558. $KOP = false;
  5559. foreach ( $roleArrayCopy as $P => $A ) {
  5560. foreach ( $A as $MKI => $AVL ) {
  5561. if (! empty ( $verifyStaff )) {
  5562. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5563. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5564. $button = 4;
  5565. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5566. }
  5567. foreach ( $verifyStaff as $m => $u ) {
  5568. $AVLFK = $AVL [0] . '_R';
  5569. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5570. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5571. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5572. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5573. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5574. break;
  5575. }
  5576. }
  5577. } else {
  5578. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5579. $button = 4;
  5580. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5581. }
  5582. }
  5583. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5584. $KOP = true;
  5585. }
  5586. }
  5587. foreach ( $roleArrayCopy as $k => $v ) {
  5588. foreach ( $verifyList as $m => $n ) {
  5589. if ($n [0] == $k) {
  5590. array_splice ( $verifyList, $m, 1, $v );
  5591. }
  5592. }
  5593. }
  5594. // print_r($verifyList);
  5595. $receiptList [$key] ['verifyList'] = $verifyList;
  5596. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5597. 'where' => 'sid=' . $value ['staff'],
  5598. 'asArray' => true
  5599. ) );
  5600. $receiptList [$key] ['button'] = $button;
  5601. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5602. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5603. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5604. $receiptList [$key] ['relust'] = $relust;
  5605. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  5606. }
  5607. // print_r($receiptList);die;
  5608. // $data['verifyDetail']=$verifyDetail;
  5609. $mothHtml = "";
  5610. for($i = 1; $i <= 12; $i ++) {
  5611. if ($month == $i)
  5612. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5613. else
  5614. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5615. }
  5616. // 获取审批日志
  5617. Doo::loadModel ( 'receiptLog' );
  5618. $receiptLog = new receiptLog ();
  5619. $rlList = array ();
  5620. $rlInfo = $receiptLog->getOne ( array (
  5621. 'where' => 'rid=' . $rid . ' and status=4',
  5622. 'asArray' => true
  5623. ) );
  5624. $tijdate = $receiptLog->getOne ( array (
  5625. 'where' => 'rid=' . $rid . ' and status=2',
  5626. 'asc' => 'rlid',
  5627. 'asArray' => true
  5628. ) );
  5629. if (! empty ( $rlInfo )) {
  5630. $rlList = $receiptLog->find ( array (
  5631. 'where' => 'rid=' . $rid,
  5632. 'asc' => 'rlid',
  5633. 'asArray' => true
  5634. ) );
  5635. }
  5636. // echo $rid;
  5637. // print_r($receiptList);
  5638. $receiptList [0] ['rlList'] = $rlList;
  5639. // print_r($receiptList);
  5640. $enclosurList = $enclosur->find ( array (
  5641. 'where' => 'rid=' . $rid,
  5642. 'asArray' => true
  5643. ) );
  5644. $enclosurHtml = '';
  5645. foreach ( $enclosurList as $value ) {
  5646. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5647. }
  5648. $data ['enclosurHtml'] = $enclosurHtml;
  5649. $data ['rolename'] = $rolename ['name'];
  5650. $data ['mothHtml'] = $mothHtml;
  5651. // print_r($receiptList);
  5652. $data ['rid'] = $rid;
  5653. $data ['tijdate'] = $tijdate ['date'];
  5654. $data ['receiptList'] = $receiptList;
  5655. $data ['receiptApprovalCount'] = count ( $receiptList );
  5656. $data ['status'] = $status;
  5657. $data ['year'] = $year;
  5658. $data ['categoryList'] = $categoryList;
  5659. $data ['staffList'] = $staffList;
  5660. $data ['cid'] = $cid;
  5661. $data ['sid'] = $sid;
  5662. $data ['ap'] = $ap;
  5663. $data ['memu'] = "receipt";
  5664. $data ['staff'] = $this->staff;
  5665. $data ['receiptMemu'] = 'approvalExpenses';
  5666. $data ['verifyId'] = $this->verifyId;
  5667. $data ['executeId'] = $this->executeId;
  5668. $this->render ( "/admin/receiptburEdi", $data );
  5669. }
  5670. function hisImplement() {
  5671. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  5672. if (empty ( $item ))
  5673. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  5674. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  5675. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  5676. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  5677. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  5678. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  5679. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  5680. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  5681. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  5682. Doo::loadClass ( 'XDeode' );
  5683. $XDeode = new XDeode ( 5 );
  5684. Doo::loadModel ( 'receipt' );
  5685. $receipt = new receipt ();
  5686. Doo::loadModel ( 'L_category' );
  5687. $Lcategory = new L_category ();
  5688. Doo::loadModel ( 'verify' );
  5689. Doo::loadModel ( 'statistics' );
  5690. $statistics = new statistics ();
  5691. $verify = new verify ();
  5692. Doo::loadModel ( 'staff' );
  5693. $staff = new staff ();
  5694. Doo::loadClass ( 'XDeode' );
  5695. $XDeode = new XDeode ( 5 );
  5696. $XDeode7 = new XDeode ( 7 );
  5697. $cid = $XDeode->decode ( $cidKey );
  5698. $condition = "";
  5699. if ($item == "expenses")
  5700. $condition = " and Rtype=1 ";
  5701. elseif ($item == "receipts")
  5702. $condition = " and Rtype=0 ";
  5703. elseif ($item == "remits")
  5704. $condition = " and Rtype=2 ";
  5705. elseif($item == "train")
  5706. $condition = " and Rtype=3 ";
  5707. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  5708. $sopString = $cidString = "";
  5709. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  5710. if (empty ( $rdate ))
  5711. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  5712. else
  5713. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  5714. if ($status == 'pendImplement') {
  5715. $condition .= ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  5716. } elseif ($status == 'alerpts') {
  5717. $statusCon = '(status=8 or status=9 )';
  5718. if (empty ( $rdate ))
  5719. $dateCondition .= " and Year(date) =" . $year;
  5720. else
  5721. $dateCondition .= " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  5722. }
  5723. if ($sop != 'SOP')
  5724. $sopString = " and staff=" . $sop;
  5725. if ($cidKey != 'ALL')
  5726. $cidString = " and cid=" . $cid;
  5727. if(!empty($receiptOrder)){
  5728. $receiptList = $receipt->find ( array (
  5729. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  5730. 'desc' => 'rid',
  5731. 'asArray' => true
  5732. ) );
  5733. // 员工筛选
  5734. $receiptList2 = $receipt->find ( array (
  5735. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  5736. 'desc' => 'rid',
  5737. 'asArray' => true
  5738. ) );
  5739. }else{
  5740. $receiptList = $receipt->find ( array (
  5741. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  5742. 'desc' => 'rid',
  5743. 'asArray' => true
  5744. ) );
  5745. // 员工筛选
  5746. $receiptList2 = $receipt->find ( array (
  5747. 'where' => $statusCon . $condition . $dateCondition,
  5748. 'desc' => 'rid',
  5749. 'asArray' => true
  5750. ) );
  5751. }
  5752. $sopStaff = array ();
  5753. foreach ( $receiptList2 as $key => $value ) {
  5754. $staffDetail = $staff->getOne ( array (
  5755. 'select' => 'username',
  5756. 'where' => 'sid=' . $value ['staff'],
  5757. 'asArray' => true
  5758. ) );
  5759. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  5760. }
  5761. // 办事处筛选
  5762. $categoryScreen = array ();
  5763. $categorList = $Lcategory->getCategory ();
  5764. foreach ( $receiptList2 as $key => $value ) {
  5765. foreach ( $categorList as $k => $v ) {
  5766. if ($value ['cid'] == $v ['cid']) {
  5767. $categoryScreen [$v ['cidKey']] = $v ['title'];
  5768. break;
  5769. }
  5770. }
  5771. }
  5772. $categoryScreenHtml = "";
  5773. foreach ( $categoryScreen as $key => $value ) {
  5774. if ($cidKey == $key)
  5775. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  5776. else
  5777. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  5778. }
  5779. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  5780. $data ['cidKey'] = $cidKey;
  5781. $Locate = 0;
  5782. $roleId = 0;
  5783. $button = 0;
  5784. $staffBatchNumber = 100001;
  5785. $remittanceList = array ();
  5786. foreach ( $receiptList as $key => $value ) {
  5787. $receiptList [$key] ['ridKey7'] = $XDeode7->encode ( $value ['rid'] );
  5788. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  5789. $receiptList [$key] ['Texe'] = 'false';
  5790. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  5791. $receiptList [$key] ['Texe'] = 'true';
  5792. }
  5793. $receiptList [$key] ['TRexe'] = 'true';
  5794. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  5795. $receiptList [$key] ['TRexe'] = 'false';
  5796. }
  5797. $receiptList [$key] ['Locate'] = $Locate;
  5798. $Locate ++;
  5799. $receiptList [$key] ['reviseDetail'] = array ();
  5800. if (! empty ( $value ['reviseDetail'] ))
  5801. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5802. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5803. $categoryDetil = $Lcategory->getOne ( array (
  5804. 'where' => 'cid=' . $value ['cid'],
  5805. 'asArray' => true
  5806. ) );
  5807. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5808. // 检测编辑状态
  5809. $verifyList = $verify->getOne ( array (
  5810. 'where' => 'vid=' . $value ['verify'],
  5811. 'asArray' => true
  5812. ) );
  5813. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5814. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5815. Doo::loadModel ( 'role' );
  5816. $role = new role ();
  5817. $flag = true;
  5818. $roleKey = 0;
  5819. $endStaffArray = array ();
  5820. $roleArrayCopy = array ();
  5821. foreach ( $verifyList as $k => $v ) {
  5822. // init verifyStaff
  5823. if ($v [1] == 'ROLE') {
  5824. if (! empty ( $verifyStaff )) {
  5825. $endStaffArray = end ( $verifyStaff );
  5826. }
  5827. $roleVerify = json_decode ( $v [3], true );
  5828. $roleKey = $k;
  5829. $roleArray = array ();
  5830. $rolename = $role->getOne ( array (
  5831. 'where' => 'rid=' . $v [0],
  5832. 'asArray' => true
  5833. ) );
  5834. foreach ( $roleVerify as $o => $p ) {
  5835. $staffID = explode ( '_', $p );
  5836. $staffInfo = $staff->getOne ( array (
  5837. 'where' => 'sid=' . $staffID [0],
  5838. 'asArray' => true
  5839. ) );
  5840. $exp = array (
  5841. 0 => $staffInfo ['sid'],
  5842. 1 => $staffID [1],
  5843. 2 => $staffInfo ['avatar'],
  5844. 'date' => '',
  5845. 'date' => '',
  5846. 'opinion' => '',
  5847. 'status' => '',
  5848. 'rolename' => $rolename ['name']
  5849. );
  5850. array_push ( $roleArray, $exp );
  5851. }
  5852. $roleArrayCopy [$v [0]] = $roleArray;
  5853. }
  5854. $verifyList [$k] ['date'] = "";
  5855. $verifyList [$k] ['opinion'] = "";
  5856. $verifyList [$k] ['status'] = "";
  5857. if (empty ( $verifyStaff )) {
  5858. $verifyList [$k] ['date'] = "";
  5859. $verifyList [$k] ['opinion'] = "";
  5860. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5861. $verifyList [$k] ['status'] = 4;
  5862. $flag = false;
  5863. }
  5864. } else {
  5865. foreach ( $verifyStaff as $m => $u ) {
  5866. if ($v [0] == $m) {
  5867. $verifyList [$k] ['date'] = $u ['date'];
  5868. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5869. $verifyList [$k] ['status'] = $u ['status'];
  5870. $flag = false;
  5871. break;
  5872. }
  5873. }
  5874. $endStaffArray = end ( $verifyStaff );
  5875. }
  5876. }
  5877. $rolename ['name'] = '';
  5878. if (! empty ( $roleId )) {
  5879. Doo::loadModel ( 'role' );
  5880. $role = new role ();
  5881. $rolename = $role->getOne ( array (
  5882. 'where' => 'rid=' . $roleId,
  5883. 'asArray' => true
  5884. ) );
  5885. }
  5886. if (! empty ( $verifyStaff ))
  5887. $endStaffArray = end ( $verifyStaff );
  5888. $KOP = false;
  5889. foreach ( $roleArrayCopy as $P => $A ) {
  5890. foreach ( $A as $MKI => $AVL ) {
  5891. if (! empty ( $verifyStaff )) {
  5892. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5893. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5894. $button = 4;
  5895. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5896. }
  5897. foreach ( $verifyStaff as $m => $u ) {
  5898. $AVLFK = $AVL [0] . '_R';
  5899. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5900. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5901. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5902. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5903. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5904. break;
  5905. }
  5906. }
  5907. } else {
  5908. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5909. $button = 4;
  5910. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5911. }
  5912. }
  5913. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5914. $KOP = true;
  5915. }
  5916. }
  5917. foreach ( $roleArrayCopy as $k => $v ) {
  5918. foreach ( $verifyList as $m => $n ) {
  5919. if ($n [0] == $k) {
  5920. array_splice ( $verifyList, $m, 1, $v );
  5921. }
  5922. }
  5923. }
  5924. $receiptList [$key] ['verifyList'] = $verifyList;
  5925. $staffDetail = $staff->getOne ( array (
  5926. 'where' => 'sid=' . $value ['staff'],
  5927. 'asArray' => true
  5928. ) );
  5929. $receiptList [$key] ['staffDetail'] = $staffDetail;
  5930. $receiptList [$key] ['button'] = $button;
  5931. // 设置导出汇款execl
  5932. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  5933. $remittanceDetail = array (
  5934. $staffBatchNumber,
  5935. $value ['remittanceName'],
  5936. $value ['bankNumber'],
  5937. $value ['bankName'],
  5938. $value ['remittanceBankType'],
  5939. $value ['coupletNumber'],
  5940. $value ['sum']
  5941. );
  5942. array_push ( $remittanceList, $remittanceDetail );
  5943. $staffBatchNumber ++;
  5944. }
  5945. }
  5946. $data ['remittanceList'] = json_encode ( $remittanceList );
  5947. // print_r($receiptList);
  5948. $mothHtml = "";
  5949. for($i = 1; $i <= 12; $i ++) {
  5950. if ($moth == $i)
  5951. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5952. else
  5953. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5954. }
  5955. $dayHtml = "";
  5956. if ($day != "DAY" || $moth != "MONTH") {
  5957. for($i = 1; $i <= 31; $i ++) {
  5958. if ($day == $i)
  5959. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  5960. else
  5961. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  5962. }
  5963. }
  5964. $sopHtml = "";
  5965. foreach ( $sopStaff as $key => $value ) {
  5966. if ($sop == $key)
  5967. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  5968. else
  5969. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  5970. }
  5971. $data ['status'] = $status;
  5972. $data ['rdate'] = $rdate;
  5973. $data ['sopHtml'] = $sopHtml;
  5974. $data ['dayHtml'] = $dayHtml;
  5975. $data ['mothHtml'] = $mothHtml;
  5976. $data ['receiptList'] = $receiptList;
  5977. $data ['memu'] = "receipt";
  5978. $data ['staff'] = $this->staff;
  5979. $data ['receiptMemu'] = 'implement';
  5980. $data ['verifyId'] = $this->verifyId;
  5981. $data ['executeId'] = $this->executeId;
  5982. $data ['item'] = $item;
  5983. $data ['year'] = $year;
  5984. $data ['moth'] = $moth;
  5985. $data['receiptOrder']=$receiptOrder;
  5986. $data ['day'] = $day;
  5987. $data ['sop'] = $sop;
  5988. $this->render ( "/admin/hisImplement", $data );
  5989. }
  5990. /**
  5991. * 导出汇款信息的exelc
  5992. */
  5993. function exportRemittance() {
  5994. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  5995. if (empty ( $remittanceInfo ))
  5996. die ( 'illegal request' );
  5997. $title = array (
  5998. '员工编号',
  5999. '姓名',
  6000. '员工账号',
  6001. '员工账户开户行',
  6002. '转账类型',
  6003. '联行号',
  6004. '金额'
  6005. );
  6006. $data = json_decode ( $remittanceInfo, true );
  6007. if (empty ( $data ))
  6008. die ( 'illegal request' );
  6009. Doo::loadClass ( 'receipt.func' );
  6010. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  6011. header ( 'Content-Type:text/html;charset=utf-8' );
  6012. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  6013. }
  6014. function ajaxExamine() {
  6015. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6016. Doo::loadModel ( 'receipt' );
  6017. $receipt = new receipt ();
  6018. if (! empty ( $rid )) {
  6019. $rLRes = $receipt->find ( array (
  6020. '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,
  6021. 'asArray' => true
  6022. ) );
  6023. echo json_encode ( array (
  6024. 'status' => 1,
  6025. 'receipt' => $rLRes [0]
  6026. ) );
  6027. die ();
  6028. }
  6029. echo json_encode ( array (
  6030. 'status' => 0,
  6031. 'receipt' => array ()
  6032. ) );
  6033. die ();
  6034. }
  6035. /*
  6036. * 废弃
  6037. */
  6038. function myReceipt() {
  6039. // all approval past withdraw
  6040. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  6041. if (empty ( $item ))
  6042. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  6043. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6044. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  6045. Doo::loadModel ( 'receipt' );
  6046. $receipt = new receipt ();
  6047. // pre-loaded
  6048. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  6049. // have cache
  6050. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  6051. if (! empty ( $moth )) // yearPage
  6052. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  6053. $this->showCache ( $path );
  6054. }
  6055. Doo::loadModel ( 'L_category' );
  6056. $Lcategory = new L_category ();
  6057. Doo::loadModel ( 'verify' );
  6058. Doo::loadModel ( 'statistics' );
  6059. $statistics = new statistics ();
  6060. $verify = new verify ();
  6061. Doo::loadModel ( 'staff' );
  6062. $staff = new staff ();
  6063. $condition = " and status!=0 ";
  6064. if ($item == "approval")
  6065. $condition = " and status=2 ";
  6066. elseif ($item == "withdraw")
  6067. $condition = " and status=3 ";
  6068. elseif ($item == "past")
  6069. $condition = " and status=1 ";
  6070. elseif ($item == "whdw")
  6071. $condition = " and status=4 ";
  6072. $dateCondition = " and Year(date) =" . $year;
  6073. if (! empty ( $moth )) {
  6074. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  6075. $stList = $statistics->getOne ( array (
  6076. 'select' => 'rePrice ,agPrice',
  6077. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  6078. 'asArray' => true
  6079. ) );
  6080. } else
  6081. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  6082. if (empty ( $stList ))
  6083. $stList = array (
  6084. 'rePrice' => 0,
  6085. 'agPrice' => 0
  6086. );
  6087. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  6088. $data ['stList'] = array (
  6089. 'rePrice' => $stList ['rePrice'],
  6090. 'agPrice' => $stList ['agPrice'],
  6091. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  6092. );
  6093. $receiptList = $receipt->find ( array (
  6094. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  6095. 'desc' => 'rid',
  6096. 'asArray' => true
  6097. ) );
  6098. $Locate = 0;
  6099. $roleId = 0;
  6100. $button = 0;
  6101. foreach ( $receiptList as $key => $value ) {
  6102. $receiptList [$key] ['Locate'] = $Locate;
  6103. $Locate ++;
  6104. $receiptList [$key] ['reviseDetail'] = array ();
  6105. if (! empty ( $value ['reviseDetail'] ))
  6106. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6107. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6108. $categoryDetil = $Lcategory->getOne ( array (
  6109. 'where' => 'cid=' . $value ['cid'],
  6110. 'asArray' => true
  6111. ) );
  6112. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6113. // 检测编辑状态
  6114. $verifyList = $verify->getOne ( array (
  6115. 'where' => 'vid=' . $value ['verify'],
  6116. 'asArray' => true
  6117. ) );
  6118. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6119. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6120. Doo::loadModel ( 'role' );
  6121. $role = new role ();
  6122. $flag = true;
  6123. $roleKey = 0;
  6124. $endStaffArray = array ();
  6125. $roleArrayCopy = array ();
  6126. foreach ( $verifyList as $k => $v ) {
  6127. // init verifyStaff
  6128. if ($v [1] == 'ROLE') {
  6129. if (! empty ( $verifyStaff )) {
  6130. $endStaffArray = end ( $verifyStaff );
  6131. // if ($v[0]==$endStaffArray['nextStaff']){
  6132. // $roleId=$v[0];
  6133. // }
  6134. }
  6135. $roleVerify = json_decode ( $v [3], true );
  6136. $roleKey = $k;
  6137. $roleArray = array ();
  6138. $rolename = $role->getOne ( array (
  6139. 'where' => 'rid=' . $v [0],
  6140. 'asArray' => true
  6141. ) );
  6142. foreach ( $roleVerify as $o => $p ) {
  6143. $staffID = explode ( '_', $p );
  6144. $staffInfo = $staff->getOne ( array (
  6145. 'where' => 'sid=' . $staffID [0],
  6146. 'asArray' => true
  6147. ) );
  6148. // print_r($staffID);
  6149. $exp = array (
  6150. 0 => $staffInfo ['sid'],
  6151. 1 => $staffID [1],
  6152. 2 => $staffInfo ['avatar'],
  6153. 'date' => '',
  6154. 'date' => '',
  6155. 'opinion' => '',
  6156. 'status' => '',
  6157. 'rolename' => $rolename ['name']
  6158. );
  6159. array_push ( $roleArray, $exp );
  6160. }
  6161. $roleArrayCopy [$v [0]] = $roleArray;
  6162. // $verifyList[$k]['roleArray']=$roleArray;
  6163. }
  6164. $verifyList [$k] ['date'] = "";
  6165. $verifyList [$k] ['opinion'] = "";
  6166. $verifyList [$k] ['status'] = "";
  6167. if (empty ( $verifyStaff )) {
  6168. $verifyList [$k] ['date'] = "";
  6169. $verifyList [$k] ['opinion'] = "";
  6170. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6171. $verifyList [$k] ['status'] = 4;
  6172. $flag = false;
  6173. }
  6174. } else {
  6175. foreach ( $verifyStaff as $m => $u ) {
  6176. if ($v [0] == $m) {
  6177. $verifyList [$k] ['date'] = $u ['date'];
  6178. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6179. $verifyList [$k] ['status'] = $u ['status'];
  6180. $flag = false;
  6181. break;
  6182. }
  6183. }
  6184. $endStaffArray = end ( $verifyStaff );
  6185. if (isset ( $endStaffArray ['ROLE'] )) {
  6186. } else {
  6187. // $endKey=key($verifyStaff);
  6188. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  6189. // $button=4;
  6190. // $verifyList[$k]['status']=4;
  6191. // }
  6192. }
  6193. }
  6194. }
  6195. $rolename ['name'] = '';
  6196. if (! empty ( $roleId )) {
  6197. Doo::loadModel ( 'role' );
  6198. $role = new role ();
  6199. $rolename = $role->getOne ( array (
  6200. 'where' => 'rid=' . $roleId,
  6201. 'asArray' => true
  6202. ) );
  6203. }
  6204. if (! empty ( $verifyStaff ))
  6205. $endStaffArray = end ( $verifyStaff );
  6206. $KOP = false;
  6207. foreach ( $roleArrayCopy as $P => $A ) {
  6208. foreach ( $A as $MKI => $AVL ) {
  6209. if (! empty ( $verifyStaff )) {
  6210. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6211. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6212. $button = 4;
  6213. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6214. }
  6215. foreach ( $verifyStaff as $m => $u ) {
  6216. $AVLFK = $AVL [0] . '_R';
  6217. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6218. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6219. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6220. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6221. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6222. break;
  6223. }
  6224. }
  6225. } else {
  6226. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6227. $button = 4;
  6228. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6229. }
  6230. }
  6231. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6232. $KOP = true;
  6233. }
  6234. }
  6235. foreach ( $roleArrayCopy as $k => $v ) {
  6236. foreach ( $verifyList as $m => $n ) {
  6237. if ($n [0] == $k) {
  6238. array_splice ( $verifyList, $m, 1, $v );
  6239. }
  6240. }
  6241. }
  6242. $receiptList [$key] ['verifyList'] = $verifyList;
  6243. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6244. 'where' => 'sid=' . $value ['staff'],
  6245. 'asArray' => true
  6246. ) );
  6247. $receiptList [$key] ['button'] = $button;
  6248. }
  6249. // print_r($receiptList);die;
  6250. $mothHtml = "";
  6251. for($i = 1; $i <= 12; $i ++) {
  6252. if ($moth == $i)
  6253. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6254. else
  6255. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6256. }
  6257. $data ['mothHtml'] = $mothHtml;
  6258. $data ['receiptList'] = $receiptList;
  6259. $data ['memu'] = "receipt";
  6260. $data ['staff'] = $this->staff;
  6261. $data ['receiptMemu'] = 'receipt';
  6262. $data ['verifyId'] = $this->verifyId;
  6263. $data ['executeId'] = $this->executeId;
  6264. $data ['item'] = $item;
  6265. $data ['year'] = $year;
  6266. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  6267. // sufficient condition to generate cache
  6268. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  6269. $receiptList = $receipt->find ( array (
  6270. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  6271. 'asArray' => true
  6272. ) );
  6273. if (empty ( $receiptList )) { // generated files
  6274. ob_start ();
  6275. $this->render ( "/admin/saea_myList", $data );
  6276. $this->cacheFile ( $path );
  6277. die ();
  6278. // $content = ob_get_contents();
  6279. // $fp = fopen($path, "w");
  6280. // fwrite($fp, $content);
  6281. // fclose($fp);
  6282. }
  6283. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  6284. $receiptList = $receipt->find ( array (
  6285. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  6286. 'asArray' => true
  6287. ) );
  6288. if (empty ( $receiptList )) { // generated files
  6289. ob_start ();
  6290. $this->render ( "/admin/saea_myList", $data );
  6291. $this->cacheFile ( $path );
  6292. die ();
  6293. }
  6294. }
  6295. }
  6296. $this->render ( "/admin/saea_myList", $data );
  6297. }
  6298. function saeaCreate() {
  6299. Doo::loadModel ( 'accountItem' );
  6300. Doo::loadModel ( 'verify' );
  6301. Doo::loadModel ( 'receipt' );
  6302. Doo::loadModel ( 'L_category' );
  6303. $lCategory = new L_category ();
  6304. $receipt = new receipt ();
  6305. $verify = new verify ();
  6306. $accountItem = new accountItem ();
  6307. Doo::loadModel ( "role" );
  6308. $role = new role ();
  6309. $acItem = $accountItem->find ( array (
  6310. 'asArray' => true
  6311. ) );
  6312. $veList = $verify->find ( array (
  6313. 'asArray' => true
  6314. ) );
  6315. foreach ( $veList as $key => $value ) {
  6316. $v = json_decode ( $value ['staff'] );
  6317. $list = array ();
  6318. foreach ( $v as $n => $m ) {
  6319. if ($m ['1'] == 'ROLE') {
  6320. $roleInfo = $role->getOne ( array (
  6321. 'where' => 'rid=' . $m [0],
  6322. 'asArray' => true
  6323. ) );
  6324. $v [$n] [1] = $roleInfo ['name'];
  6325. array_push ( $list, $roleInfo ['name'] );
  6326. } else {
  6327. array_push ( $list, $v [$n] [1] );
  6328. }
  6329. }
  6330. $veList [$key] ['staff'] = implode ( '>', $list );
  6331. }
  6332. $data ['category'] = $lCategory->find ( array (
  6333. 'asArray' => true
  6334. ) );
  6335. $data ['veList'] = $veList;
  6336. $data ['acItem'] = $acItem;
  6337. $data ['memu'] = "receipt";
  6338. $data ['staff'] = $this->staff;
  6339. $data ['receiptMemu'] = 'saeaBorad';
  6340. $data ['verifyId'] = $this->verifyId;
  6341. $data ['executeId'] = $this->executeId;
  6342. $this->render ( "/admin/saea_create", $data );
  6343. }
  6344. function addReceipt() {
  6345. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  6346. $agency = $this->get_args ( 'agency' );
  6347. $travel = $this->get_args ( 'travel' );
  6348. $train = $this->get_args ( 'train' );
  6349. $other = $this->get_args ( 'other' );
  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 = 0;
  6384. $sum = $agencySum = $travelSum = $trainSum = $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->OTHER) {
  6423. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  6424. array_push ( $accountJson [$this->OTHER], array (
  6425. 'aid' => $value ['aid'],
  6426. 'name' => $value ['name'],
  6427. 'price' => number_format ( $other [$ot], 2, '.', '' )
  6428. ) );
  6429. $sum += $other [$ot];
  6430. $otherSum += $other [$ot];
  6431. }
  6432. $ot ++;
  6433. }
  6434. }
  6435. $accountJson ['cSum'] = array (
  6436. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  6437. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  6438. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  6439. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  6440. );
  6441. // 报销单
  6442. $receipt->accountItem = json_encode ( $accountJson );
  6443. $receipt->staff = $this->staff [0] ['sid'];
  6444. $receipt->sum = number_format ( $sum, 2, '.', '' );
  6445. $receipt->date = date ( "Y-m-d" );
  6446. $receipt->cid = $cid;
  6447. $receipt->status = 5;
  6448. // 修改审批流程加入角色
  6449. $receipt->verify = $verify;
  6450. $receipt->executeCopy = $executeDetail ['staff'];
  6451. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  6452. $order = array (
  6453. "\r\n",
  6454. "\n",
  6455. "\r"
  6456. );
  6457. $replace = '<br/>';
  6458. $explanation = str_replace ( $order, $replace, $explanation );
  6459. $receipt->explanation = $explanation;
  6460. $receipt->remittanceName = $remittanceName;
  6461. $receipt->bankName = $bankName;
  6462. $receipt->bankNumber = $bankNumber;
  6463. $receipt->remittanceBankType = $remittanceBankType;
  6464. if ($remittanceBankType == 1)
  6465. $receipt->coupletNumber = $coupletNumber;
  6466. $rid = $receipt->insert ();
  6467. // 附件
  6468. if (! empty ( $enclosurName )) {
  6469. $enclosurArray = explode ( '-', $enclosurName );
  6470. foreach ( $enclosurArray as $value ) {
  6471. $enclosur = new enclosur ();
  6472. $enclosur->name = $value;
  6473. $enclosur->rid = $rid;
  6474. $enclosur->insert ();
  6475. }
  6476. // print_r($enclosurArray);die;
  6477. }
  6478. // 报销详情
  6479. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  6480. $receiptDetail = new receiptDetail ();
  6481. $receiptDetail->staff = $this->staff [0] ['sid'];
  6482. $receiptDetail->item = $value ['name'];
  6483. $receiptDetail->itemCategory = $this->AGENCY;
  6484. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6485. $receiptDetail->date = date ( "Y-m-d" );
  6486. $receiptDetail->cid = $cid;
  6487. $receiptDetail->rid = $rid;
  6488. $receiptDetail->status = 4;
  6489. $receiptDetail->insert ();
  6490. }
  6491. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  6492. $receiptDetail = new receiptDetail ();
  6493. $receiptDetail->staff = $this->staff [0] ['sid'];
  6494. $receiptDetail->item = $value ['name'];
  6495. $receiptDetail->itemCategory = $this->TRAVEL;
  6496. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6497. $receiptDetail->date = date ( "Y-m-d" );
  6498. $receiptDetail->cid = $cid;
  6499. $receiptDetail->rid = $rid;
  6500. $receiptDetail->status = 4;
  6501. $receiptDetail->insert ();
  6502. }
  6503. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  6504. $receiptDetail = new receiptDetail ();
  6505. $receiptDetail->staff = $this->staff [0] ['sid'];
  6506. $receiptDetail->item = $value ['name'];
  6507. $receiptDetail->itemCategory = $this->TRAIN;
  6508. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6509. $receiptDetail->date = date ( "Y-m-d" );
  6510. $receiptDetail->cid = $cid;
  6511. $receiptDetail->rid = $rid;
  6512. $receiptDetail->status = 4;
  6513. $receiptDetail->insert ();
  6514. }
  6515. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  6516. $receiptDetail = new receiptDetail ();
  6517. $receiptDetail->staff = $this->staff [0] ['sid'];
  6518. $receiptDetail->item = $value ['name'];
  6519. $receiptDetail->itemCategory = $this->OTHER;
  6520. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6521. $receiptDetail->date = date ( "Y-m-d" );
  6522. $receiptDetail->cid = $cid;
  6523. $receiptDetail->rid = $rid;
  6524. $receiptDetail->status = 4;
  6525. $receiptDetail->insert ();
  6526. }
  6527. return "/saeaBorad";
  6528. } else
  6529. die ( 'illegal request' );
  6530. }
  6531. function referReceipt() {
  6532. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  6533. Doo::loadModel ( 'receipt' );
  6534. Doo::loadModel ( 'verify' );
  6535. $verify = new verify ();
  6536. $receipt = new receipt ();
  6537. Doo::loadModel ( 'L_category' );
  6538. $lCategory = new L_category ();
  6539. Doo::loadModel ( "role" );
  6540. $role = new role ();
  6541. $receiptDetail = $receipt->find ( array (
  6542. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  6543. 'asArray' => true
  6544. ) );
  6545. if (empty ( $receiptDetail ))
  6546. return "/addReceipt";
  6547. foreach ( $receiptDetail as $key => $value ) {
  6548. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6549. $veList = $verify->getOne ( array (
  6550. 'where' => 'vid=' . $value ['verify'],
  6551. 'asArray' => true
  6552. ) );
  6553. $v = json_decode ( $veList ['staff'] );
  6554. array_push ( $v [0], $veList ['description'] );
  6555. foreach ( $v as $n => $m ) {
  6556. if ($m ['1'] == 'ROLE') {
  6557. $roleInfo = $role->getOne ( array (
  6558. 'where' => 'rid=' . $m [0],
  6559. 'asArray' => true
  6560. ) );
  6561. $v [$n] [1] = $roleInfo ['name'];
  6562. }
  6563. }
  6564. $receiptDetail [$key] ['staff'] = $v;
  6565. $category = $lCategory->getOne ( array (
  6566. 'where' => 'cid=' . $value ['cid'],
  6567. 'asArray' => true
  6568. ) );
  6569. $receiptDetail [$key] ['category'] = $category ['title'];
  6570. }
  6571. // print_r($receiptDetail);
  6572. $data ['receiptDetail'] = $receiptDetail;
  6573. $data ['memu'] = "receipt";
  6574. $data ['staff'] = $this->staff;
  6575. $data ['receiptMemu'] = 'saeaCreate';
  6576. $data ['verifyId'] = $this->verifyId;
  6577. $data ['executeId'] = $this->executeId;
  6578. $this->render ( "/admin/saea_confirm", $data );
  6579. }
  6580. function editReceipt() {
  6581. // edit status 4
  6582. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  6583. Doo::loadClass ( 'XDeode' );
  6584. $XDeode = new XDeode ( 7 );
  6585. $rid = $XDeode->decode ( $ridKey );
  6586. if (empty ( $rid ))
  6587. die ( 'illegal request' );
  6588. // echo $rid.'sd';
  6589. Doo::loadModel ( 'accountItem' );
  6590. Doo::loadModel ( 'verify' );
  6591. Doo::loadModel ( 'receipt' );
  6592. $receipt = new receipt ();
  6593. $verify = new verify ();
  6594. $accountItem = new accountItem ();
  6595. Doo::loadModel ( 'L_category' );
  6596. $lCategory = new L_category ();
  6597. Doo::loadModel ( "role" );
  6598. $role = new role ();
  6599. Doo::loadModel ( 'enclosur' );
  6600. $enclosur = new enclosur ();
  6601. $receiptDetail = $receipt->getOne ( array (
  6602. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  6603. 'asArray' => true
  6604. ) );
  6605. if (empty ( $receiptDetail ))
  6606. die ( 'illegal request' );
  6607. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  6608. $acItem = $accountItem->find ( array (
  6609. 'asArray' => true
  6610. ) );
  6611. $veList = $verify->find ( array (
  6612. 'asArray' => true
  6613. ) );
  6614. foreach ( $veList as $key => $value ) {
  6615. $v = json_decode ( $value ['staff'] );
  6616. $list = array ();
  6617. foreach ( $v as $n => $m ) {
  6618. if ($m ['1'] == 'ROLE') {
  6619. $roleInfo = $role->getOne ( array (
  6620. 'where' => 'rid=' . $m [0],
  6621. 'asArray' => true
  6622. ) );
  6623. $v [$n] [1] = $roleInfo ['name'];
  6624. array_push ( $list, $roleInfo ['name'] );
  6625. } else {
  6626. array_push ( $list, $v [$n] [1] );
  6627. }
  6628. }
  6629. $veList [$key] ['staff'] = implode ( '>', $list );
  6630. }
  6631. // 配置编辑信息
  6632. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  6633. foreach ( $acItem as $key => $value ) {
  6634. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  6635. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  6636. $acItem [$key] ['price'] = $v ['price'];
  6637. }
  6638. }
  6639. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  6640. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  6641. $acItem [$key] ['price'] = $v ['price'];
  6642. }
  6643. }
  6644. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  6645. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  6646. $acItem [$key] ['price'] = $v ['price'];
  6647. }
  6648. }
  6649. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  6650. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  6651. $acItem [$key] ['price'] = $v ['price'];
  6652. }
  6653. }
  6654. }
  6655. $data ['category'] = $lCategory->find ( array (
  6656. 'asArray' => true
  6657. ) );
  6658. $data ['cSum'] = $accountItemList ['cSum'];
  6659. $data ['sum'] = $receiptDetail ['sum'];
  6660. $data ['enclosurList'] = $enclosurList;
  6661. $data ['receiptDetail'] = $receiptDetail;
  6662. $data ['veList'] = $veList;
  6663. $data ['acItem'] = $acItem;
  6664. $data ['memu'] = "receipt";
  6665. $data ['staff'] = $this->staff;
  6666. $data ['receiptMemu'] = 'saeaBorad';
  6667. $data ['verify'] = $receiptDetail ['verify'];
  6668. $data ['verifyId'] = $this->verifyId;
  6669. $data ['executeId'] = $this->executeId;
  6670. $data ['rid'] = $ridKey;
  6671. $this->render ( "/admin/saea_edit", $data );
  6672. }
  6673. function updateReceipt() {
  6674. $agency = $this->get_args ( 'agency' );
  6675. $travel = $this->get_args ( 'travel' );
  6676. $train = $this->get_args ( 'train' );
  6677. $other = $this->get_args ( 'other' );
  6678. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  6679. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  6680. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  6681. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  6682. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  6683. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  6684. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  6685. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  6686. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  6687. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  6688. Doo::loadClass ( 'XDeode' );
  6689. $XDeode = new XDeode ( 7 );
  6690. $rid = $XDeode->decode ( $ridKey );
  6691. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  6692. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  6693. header ( 'Content-Type:text/html;charset=utf-8' );
  6694. die ( '请填写联行号' );
  6695. }
  6696. Doo::loadModel ( 'receipt' );
  6697. Doo::loadModel ( 'receiptDetail' );
  6698. Doo::loadModel ( 'accountItem' );
  6699. $accountItem = new accountItem ();
  6700. $receipt = new receipt ();
  6701. Doo::loadModel ( 'enclosur' );
  6702. Doo::loadModel ( 'execute' );
  6703. $execute = new execute ();
  6704. $receiptDetail = $receipt->getOne ( array (
  6705. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  6706. 'asArray' => true
  6707. ) );
  6708. if (empty ( $receiptDetail ))
  6709. return "/saeaBorad";
  6710. if ($receiptDetail ['Rtype'] == 1)
  6711. $executeDetail = $execute->getOne ( array (
  6712. 'where' => 'mold="借款费用执行人"',
  6713. 'asArray' => true
  6714. ) );
  6715. else
  6716. $executeDetail = $execute->getOne ( array (
  6717. 'where' => 'mold="报销单执行人"',
  6718. 'asArray' => true
  6719. ) );
  6720. $aItem = $accountItem->find ( array (
  6721. 'asArray' => true
  6722. ) );
  6723. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  6724. $ag = $tr = $ta = $ot = 0;
  6725. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  6726. foreach ( $aItem as $key => $value ) {
  6727. if ($value ['category'] == $this->AGENCY) {
  6728. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  6729. array_push ( $accountJson [$this->AGENCY], array (
  6730. 'aid' => $value ['aid'],
  6731. 'name' => $value ['name'],
  6732. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  6733. ) );
  6734. $sum += $agency [$ag];
  6735. $agencySum += $agency [$ag];
  6736. }
  6737. $ag ++;
  6738. }
  6739. if ($value ['category'] == $this->TRAVEL) {
  6740. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  6741. array_push ( $accountJson [$this->TRAVEL], array (
  6742. 'aid' => $value ['aid'],
  6743. 'name' => $value ['name'],
  6744. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  6745. ) );
  6746. $sum += $travel [$tr];
  6747. $travelSum += $travel [$tr];
  6748. }
  6749. $tr ++;
  6750. }
  6751. if ($value ['category'] == $this->TRAIN) {
  6752. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  6753. array_push ( $accountJson [$this->TRAIN], array (
  6754. 'aid' => $value ['aid'],
  6755. 'name' => $value ['name'],
  6756. 'price' => number_format ( $train [$ta], 2, '.', '' )
  6757. ) );
  6758. $sum += $train [$ta];
  6759. $trainSum += $train [$ta];
  6760. }
  6761. $ta ++;
  6762. }
  6763. if ($value ['category'] == $this->OTHER) {
  6764. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  6765. array_push ( $accountJson [$this->OTHER], array (
  6766. 'aid' => $value ['aid'],
  6767. 'name' => $value ['name'],
  6768. 'price' => number_format ( $other [$ot], 2, '.', '' )
  6769. ) );
  6770. $sum += $other [$ot];
  6771. $otherSum += $other [$ot];
  6772. }
  6773. $ot ++;
  6774. }
  6775. }
  6776. $accountJson ['cSum'] = array (
  6777. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  6778. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  6779. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  6780. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  6781. );
  6782. // 报销单
  6783. $rid = $receipt->rid = $receiptDetail ['rid'];
  6784. $receipt->accountItem = json_encode ( $accountJson );
  6785. $receipt->staff = $this->staff [0] ['sid'];
  6786. $receipt->sum = number_format ( $sum, 2, '.', '' );
  6787. $receipt->date = date ( "Y-m-d" );
  6788. $receipt->cid = $cid;
  6789. if (($receiptDetail ['status'] != 4)) {
  6790. if ($receiptDetail ['Rtype'] == 1)
  6791. $receipt->status = 7;
  6792. else
  6793. $receipt->status = 5;
  6794. }
  6795. if ($receiptDetail != 4 && ! empty ( $verify ))
  6796. $receipt->verify = $verify;
  6797. $receipt->executeCopy = $executeDetail ['staff'];
  6798. $order = array (
  6799. "\r\n",
  6800. "\n",
  6801. "\r"
  6802. );
  6803. $replace = '<br/>';
  6804. $explanation = str_replace ( $order, $replace, $explanation );
  6805. $receipt->explanation = $explanation;
  6806. $receipt->remittanceName = $remittanceName;
  6807. $receipt->bankName = $bankName;
  6808. $receipt->bankNumber = $bankNumber;
  6809. $receipt->remittanceBankType = $remittanceBankType;
  6810. if ($remittanceBankType == 1)
  6811. $receipt->coupletNumber = $coupletNumber;
  6812. $receipt->update ();
  6813. $receiptDetail = new receiptDetail ();
  6814. $receiptDetail->delete ( array (
  6815. 'where' => 'rid=' . $rid
  6816. ) );
  6817. // 报销详情
  6818. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  6819. $receiptDetail = new receiptDetail ();
  6820. $receiptDetail->staff = $this->staff [0] ['sid'];
  6821. $receiptDetail->item = $value ['name'];
  6822. $receiptDetail->itemCategory = $this->AGENCY;
  6823. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6824. $receiptDetail->date = date ( "Y-m-d" );
  6825. $receiptDetail->cid = $cid;
  6826. $receiptDetail->rid = $rid;
  6827. $receiptDetail->status = 4;
  6828. $receiptDetail->insert ();
  6829. }
  6830. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  6831. $receiptDetail = new receiptDetail ();
  6832. $receiptDetail->staff = $this->staff [0] ['sid'];
  6833. $receiptDetail->item = $value ['name'];
  6834. $receiptDetail->itemCategory = $this->TRAVEL;
  6835. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6836. $receiptDetail->date = date ( "Y-m-d" );
  6837. $receiptDetail->cid = $cid;
  6838. $receiptDetail->rid = $rid;
  6839. $receiptDetail->status = 4;
  6840. $receiptDetail->insert ();
  6841. }
  6842. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  6843. $receiptDetail = new receiptDetail ();
  6844. $receiptDetail->staff = $this->staff [0] ['sid'];
  6845. $receiptDetail->item = $value ['name'];
  6846. $receiptDetail->itemCategory = $this->TRAIN;
  6847. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6848. $receiptDetail->date = date ( "Y-m-d" );
  6849. $receiptDetail->cid = $cid;
  6850. $receiptDetail->rid = $rid;
  6851. $receiptDetail->status = 4;
  6852. $receiptDetail->insert ();
  6853. }
  6854. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  6855. $receiptDetail = new receiptDetail ();
  6856. $receiptDetail->staff = $this->staff [0] ['sid'];
  6857. $receiptDetail->item = $value ['name'];
  6858. $receiptDetail->itemCategory = $this->OTHER;
  6859. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6860. $receiptDetail->date = date ( "Y-m-d" );
  6861. $receiptDetail->cid = $cid;
  6862. $receiptDetail->rid = $rid;
  6863. $receiptDetail->status = 4;
  6864. $receiptDetail->insert ();
  6865. }
  6866. // 附件
  6867. if (! empty ( $enclosurName )) {
  6868. $enclosurArray = explode ( '-', $enclosurName );
  6869. foreach ( $enclosurArray as $value ) {
  6870. $enclosur = new enclosur ();
  6871. $enclosur->name = $value;
  6872. $enclosur->rid = $rid;
  6873. $enclosur->insert ();
  6874. }
  6875. }
  6876. // return "/referReceipt/".$rid;
  6877. }
  6878. return "/saeaBorad";
  6879. }
  6880. function approvedReceipt() {
  6881. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6882. Doo::loadModel ( 'receipt' );
  6883. Doo::loadModel ( 'receiptDetail' );
  6884. $receipt = new receipt ();
  6885. $receiptDetail = new receiptDetail ();
  6886. Doo::loadModel ( 'statistics' );
  6887. Doo::loadModel ( 'itemStatistics' );
  6888. $statistics = new statistics ();
  6889. $itemStatistics = new itemStatistics ();
  6890. Doo::loadModel ( "verify" );
  6891. $verify = new verify ();
  6892. // 审批状态的判定
  6893. $receiptDetailList = $receipt->getOne ( array (
  6894. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  6895. 'asArray' => true
  6896. ) );
  6897. if (empty ( $receiptDetailList ))
  6898. return "/saeaBorad";
  6899. $verifyDetail = $verify->getOne ( array (
  6900. 'where' => ' vid =' . $receiptDetailList ['verify'],
  6901. 'asArray' => true
  6902. ) );
  6903. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  6904. if (empty ( $receiptDetailList ['nowStaff'] )) {
  6905. $nowStaff = "";
  6906. $nowStaffList = array ();
  6907. if ($verifyDetail [0] [1] == 'ROLE') {
  6908. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  6909. foreach ( $vStaffString as $key => $value ) {
  6910. $staffK = explode ( "_", $value );
  6911. array_push ( $nowStaffList, $staffK [0] );
  6912. }
  6913. $nowStaff = implode ( ',', $nowStaffList );
  6914. } else {
  6915. $nowStaff = $verifyDetail [0] [0];
  6916. }
  6917. $receipt->nowStaff = $nowStaff;
  6918. }
  6919. // echo $nowStaff;
  6920. // print_r($verifyDetail);die;
  6921. $receipt->rid = $receiptDetailList ['rid'];
  6922. $receipt->date = date ( "Y-m-d" );
  6923. $receipt->status = 2;
  6924. $receipt->update ();
  6925. $receiptDetail->status = 2;
  6926. $receiptDetail->update ( array (
  6927. 'where' => 'rid=' . $receiptDetailList ['rid']
  6928. ) );
  6929. Doo::loadModel ( "receiptLog" );
  6930. $receiptLog = new receiptLog ();
  6931. Doo::loadModel ( "verify" );
  6932. $verify = new verify ();
  6933. $receiptInfo = $receipt->getOne ( array (
  6934. 'where' => 'rid=' . $rid,
  6935. 'asArray' => true
  6936. ) );
  6937. $vr = $verify->getOne ( array (
  6938. 'where' => 'vid=' . $receiptInfo ['verify'],
  6939. 'asArray' => true
  6940. ) );
  6941. $jd = json_decode ( $vr ['staff'] );
  6942. $roleId = 0;
  6943. foreach ( $jd as $key => $value ) {
  6944. if ($value [1] == 'ROLE') {
  6945. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  6946. if ($pos !== false) {
  6947. $roleId = $value [0];
  6948. }
  6949. }
  6950. }
  6951. // 审批日志
  6952. // echo $roleId;die;
  6953. if (! empty ( $roleId )) {
  6954. Doo::loadModel ( "role" );
  6955. $role = new role ();
  6956. $roleInfo = $role->getOne ( array (
  6957. 'where' => 'rid=' . $roleId,
  6958. 'asArray' => true
  6959. ) );
  6960. // $receiptLog->rolename = $roleInfo ['name'];
  6961. }
  6962. $receiptLog->username = $this->staff [0] ['username'];
  6963. $receiptLog->uid = $this->staff [0] ['sid'];
  6964. $receiptLog->date = date ( "Y-m-d" );
  6965. $receiptLog->opinion = '提交审批';
  6966. $receiptLog->img = $this->staff [0] ['avatar'];
  6967. $receiptLog->status = 2;
  6968. $receiptLog->rid = $rid;
  6969. $receiptLog->insert ();
  6970. // statistics item
  6971. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  6972. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  6973. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  6974. $stat = $statistics->getOne ( array (
  6975. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  6976. 'asArray' => true
  6977. ) );
  6978. if (empty ( $stat )) {
  6979. $statistics->date = date ( "Y-m-d" );
  6980. $statistics->cid = $this->staff [0] ['cid'];
  6981. $statistics->staff = $this->staff [0] ['sid'];
  6982. $statistics->agPrice = 0;
  6983. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  6984. $statistics->insert ();
  6985. } else {
  6986. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  6987. $statistics->update ( array (
  6988. 'where' => 'sid=' . $stat ['sid']
  6989. ) );
  6990. }
  6991. return "/expenses";
  6992. }
  6993. function approval() {
  6994. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  6995. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6996. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6997. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6998. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6999. if (empty ( $status ))
  7000. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7001. $vidList = array ();
  7002. $button = 0;
  7003. Doo::loadModel ( 'verify' );
  7004. $verify = new verify ();
  7005. Doo::loadModel ( 'receipt' );
  7006. $receipt = new receipt ();
  7007. Doo::loadModel ( 'staff' );
  7008. $staff = new staff ();
  7009. Doo::loadModel ( 'L_category' );
  7010. $Lcategory = new L_category ();
  7011. // user verify ID
  7012. $verifyDetail = $verify->find ( array (
  7013. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7014. 'asArray' => true
  7015. ) );
  7016. foreach ( $verifyDetail as $key => $value ) {
  7017. array_push ( $vidList, $value ['vid'] );
  7018. }
  7019. $vid = implode ( ",", $vidList );
  7020. if (empty ( $verifyDetail ))
  7021. $vid = 0;
  7022. /*
  7023. */
  7024. $dateCondition = " and Year(date) =" . $year;
  7025. if (! empty ( $month ))
  7026. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  7027. $categoryList = $Lcategory->find ( array (
  7028. 'asArray' => true
  7029. ) );
  7030. $staffList = $staff->find ( array (
  7031. 'where' => 'cid=' . $cid,
  7032. 'asArray' => true
  7033. ) );
  7034. $cateCondition = "";
  7035. $staffCondition = "";
  7036. $approvalCondition = "";
  7037. if (! empty ( $cid ))
  7038. $cateCondition = ' and cid=' . $cid;
  7039. if (! empty ( $sid )) {
  7040. $staffCondition = ' and staff=' . $sid;
  7041. $cateCondition = "";
  7042. }
  7043. // elseif($status==1){
  7044. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  7045. // }
  7046. if ($status == 2) {
  7047. // 查找角色审批人
  7048. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  7049. }
  7050. $ap = "";
  7051. if ($status == 4) {
  7052. $ap = 4;
  7053. $status = 2;
  7054. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  7055. }
  7056. if ($status == 5) {
  7057. $status = 4;
  7058. $ap = 5;
  7059. }
  7060. // echo $vid;
  7061. // get Receipt By verifyID status 2 .$approvalCondition
  7062. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  7063. $receiptList = $receipt->find ( array (
  7064. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  7065. 'desc' => 'rid',
  7066. 'asArray' => true
  7067. ) );
  7068. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  7069. $Locate = 0;
  7070. if ($ap == 4)
  7071. $status = 4;
  7072. elseif ($ap == 5)
  7073. $status = 5;
  7074. foreach ( $receiptList as $key => $value ) {
  7075. $receiptList [$key] ['Locate'] = $Locate;
  7076. $Locate ++;
  7077. $receiptList [$key] ['reviseDetail'] = array ();
  7078. if (! empty ( $value ['reviseDetail'] ))
  7079. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7080. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7081. $categoryDetil = $Lcategory->getOne ( array (
  7082. 'where' => 'cid=' . $value ['cid'],
  7083. 'asArray' => true
  7084. ) );
  7085. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7086. $verifyList = $verify->getOne ( array (
  7087. 'where' => 'vid=' . $value ['verify'],
  7088. 'asArray' => true
  7089. ) );
  7090. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7091. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7092. foreach ( $verifyList as $k => $v ) {
  7093. // init verifyStaff
  7094. $verifyList [$k] ['date'] = "";
  7095. $verifyList [$k] ['opinion'] = "";
  7096. $verifyList [$k] ['status'] = "";
  7097. if (empty ( $verifyStaff )) {
  7098. $verifyList [$k] ['date'] = "";
  7099. $verifyList [$k] ['opinion'] = "";
  7100. if ($v [0] == $this->staff [0] ['sid']) {
  7101. $verifyList [$k] ['status'] = 4;
  7102. $button = 4;
  7103. }
  7104. } else {
  7105. $flag = true;
  7106. foreach ( $verifyStaff as $m => $u ) {
  7107. if ($v [0] == $m) {
  7108. $verifyList [$k] ['date'] = $u ['date'];
  7109. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7110. $verifyList [$k] ['status'] = $u ['status'];
  7111. $flag = false;
  7112. break;
  7113. }
  7114. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  7115. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  7116. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  7117. }
  7118. if ($flag) { // 检测可编辑
  7119. if ($v [0] == $this->staff [0] ['sid']) {
  7120. $verifyList [$k] ['status'] = 4;
  7121. $button = 4;
  7122. }
  7123. }
  7124. }
  7125. }
  7126. $receiptList [$key] ['verifyList'] = $verifyList;
  7127. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7128. 'where' => 'sid=' . $value ['staff'],
  7129. 'asArray' => true
  7130. ) );
  7131. $receiptList [$key] ['button'] = $button;
  7132. }
  7133. // print_r($receiptList);die;
  7134. // $data['verifyDetail']=$verifyDetail;
  7135. $mothHtml = "";
  7136. for($i = 1; $i <= 12; $i ++) {
  7137. if ($month == $i)
  7138. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7139. else
  7140. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7141. }
  7142. $data ['mothHtml'] = $mothHtml;
  7143. $data ['receiptList'] = $receiptList;
  7144. $data ['receiptApprovalCount'] = count ( $receiptList );
  7145. $data ['status'] = $status;
  7146. $data ['year'] = $year;
  7147. $data ['categoryList'] = $categoryList;
  7148. $data ['staffList'] = $staffList;
  7149. $data ['cid'] = $cid;
  7150. $data ['sid'] = $sid;
  7151. $data ['ap'] = $ap;
  7152. $data ['memu'] = "receipt";
  7153. $data ['staff'] = $this->staff;
  7154. $data ['receiptMemu'] = 'approval';
  7155. $data ['verifyId'] = $this->verifyId;
  7156. $data ['executeId'] = $this->executeId;
  7157. $this->render ( "/admin/saea_reportList", $data );
  7158. }
  7159. function approvalDetails() {
  7160. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7161. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7162. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7163. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7164. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7165. Doo::loadModel ( 'verify' );
  7166. $verify = new verify ();
  7167. Doo::loadModel ( 'receipt' );
  7168. $receipt = new receipt ();
  7169. Doo::loadModel ( 'staff' );
  7170. $staff = new staff ();
  7171. Doo::loadModel ( 'L_category' );
  7172. $Lcategory = new L_category ();
  7173. Doo::loadModel ( 'enclosur' );
  7174. $enclosur = new enclosur ();
  7175. $vidList = array ();
  7176. $verifyDetail = $verify->find ( array (
  7177. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7178. 'asArray' => true
  7179. ) );
  7180. foreach ( $verifyDetail as $key => $value ) {
  7181. array_push ( $vidList, $value ['vid'] );
  7182. }
  7183. $vid = implode ( ",", $vidList );
  7184. if (empty ( $verifyDetail ))
  7185. $vid = 0;
  7186. $categoryList = $Lcategory->find ( array (
  7187. 'asArray' => true
  7188. ) );
  7189. $staffList = $staff->find ( array (
  7190. 'where' => 'cid=' . $cid,
  7191. 'asArray' => true
  7192. ) );
  7193. $ap = 0;
  7194. $receiptList = $receipt->find ( array (
  7195. 'where' => 'rid =' . $rid,
  7196. 'desc' => 'rid',
  7197. 'asArray' => true
  7198. ) );
  7199. $Locate = 0;
  7200. $roleId = 0;
  7201. $button = 0;
  7202. foreach ( $receiptList as $key => $value ) {
  7203. $receiptList [$key] ['Locate'] = $Locate;
  7204. $Locate ++;
  7205. $receiptList [$key] ['reviseDetail'] = array ();
  7206. if (! empty ( $value ['reviseDetail'] ))
  7207. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7208. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7209. $categoryDetil = $Lcategory->getOne ( array (
  7210. 'where' => 'cid=' . $value ['cid'],
  7211. 'asArray' => true
  7212. ) );
  7213. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7214. // 检测编辑状态
  7215. $verifyList = $verify->getOne ( array (
  7216. 'where' => 'vid=' . $value ['verify'],
  7217. 'asArray' => true
  7218. ) );
  7219. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7220. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7221. Doo::loadModel ( 'role' );
  7222. $role = new role ();
  7223. // print_r($verifyList);
  7224. $flag = true;
  7225. $roleKey = 0;
  7226. $endStaffArray = array ();
  7227. $roleArrayCopy = array ();
  7228. foreach ( $verifyList as $k => $v ) {
  7229. // init verifyStaff
  7230. if ($v [1] == 'ROLE') {
  7231. if (! empty ( $verifyStaff )) {
  7232. $endStaffArray = end ( $verifyStaff );
  7233. if ($v [0] == $endStaffArray ['nextStaff']) {
  7234. $roleId = $v [0];
  7235. }
  7236. }
  7237. $roleVerify = json_decode ( $v [3], true );
  7238. $roleKey = $k;
  7239. $roleArray = array ();
  7240. $rolename = $role->getOne ( array (
  7241. 'where' => 'rid=' . $v [0],
  7242. 'asArray' => true
  7243. ) );
  7244. foreach ( $roleVerify as $o => $p ) {
  7245. $staffID = explode ( '_', $p );
  7246. $staffInfo = $staff->getOne ( array (
  7247. 'where' => 'sid=' . $staffID [0],
  7248. 'asArray' => true
  7249. ) );
  7250. // print_r($staffID);
  7251. $exp = array (
  7252. 0 => $staffInfo ['sid'],
  7253. 1 => $staffID [1],
  7254. 2 => $staffInfo ['avatar'],
  7255. 'date' => '',
  7256. 'date' => '',
  7257. 'opinion' => '',
  7258. 'status' => '',
  7259. 'rolename' => $rolename ['name']
  7260. );
  7261. array_push ( $roleArray, $exp );
  7262. }
  7263. $roleArrayCopy [$v [0]] = $roleArray;
  7264. // $verifyList[$k]['roleArray']=$roleArray;
  7265. }
  7266. // print_r($roleArray);
  7267. $verifyList [$k] ['date'] = "";
  7268. $verifyList [$k] ['opinion'] = "";
  7269. $verifyList [$k] ['status'] = "";
  7270. if (empty ( $verifyStaff )) {
  7271. $verifyList [$k] ['date'] = "";
  7272. $verifyList [$k] ['opinion'] = "";
  7273. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7274. $verifyList [$k] ['status'] = 4;
  7275. $button = 4;
  7276. $flag = false;
  7277. }
  7278. } else {
  7279. foreach ( $verifyStaff as $m => $u ) {
  7280. if ($v [0] == $m) {
  7281. $verifyList [$k] ['date'] = $u ['date'];
  7282. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7283. $verifyList [$k] ['status'] = $u ['status'];
  7284. $flag = false;
  7285. break;
  7286. }
  7287. }
  7288. $endStaffArray = end ( $verifyStaff );
  7289. if (isset ( $endStaffArray ['ROLE'] )) {
  7290. } else {
  7291. $endKey = key ( $verifyStaff );
  7292. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7293. $button = 4;
  7294. $verifyList [$k] ['status'] = 4;
  7295. }
  7296. }
  7297. }
  7298. }
  7299. $rolename ['name'] = '';
  7300. if (! empty ( $roleId )) {
  7301. Doo::loadModel ( 'role' );
  7302. $role = new role ();
  7303. $rolename = $role->getOne ( array (
  7304. 'where' => 'rid=' . $roleId,
  7305. 'asArray' => true
  7306. ) );
  7307. }
  7308. if (! empty ( $verifyStaff ))
  7309. $endStaffArray = end ( $verifyStaff );
  7310. $KOP = false;
  7311. foreach ( $roleArrayCopy as $P => $A ) {
  7312. foreach ( $A as $MKI => $AVL ) {
  7313. if (! empty ( $verifyStaff )) {
  7314. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7315. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7316. $button = 4;
  7317. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7318. }
  7319. foreach ( $verifyStaff as $m => $u ) {
  7320. $AVLFK = $AVL [0] . '_R';
  7321. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7322. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7323. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7324. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7325. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7326. break;
  7327. }
  7328. }
  7329. } else {
  7330. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7331. $button = 4;
  7332. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7333. }
  7334. }
  7335. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7336. $KOP = true;
  7337. }
  7338. }
  7339. foreach ( $roleArrayCopy as $k => $v ) {
  7340. foreach ( $verifyList as $m => $n ) {
  7341. if ($n [0] == $k) {
  7342. array_splice ( $verifyList, $m, 1, $v );
  7343. }
  7344. }
  7345. }
  7346. $receiptList [$key] ['verifyList'] = $verifyList;
  7347. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7348. 'where' => 'sid=' . $value ['staff'],
  7349. 'asArray' => true
  7350. ) );
  7351. $receiptList [$key] ['button'] = $button;
  7352. }
  7353. $mothHtml = "";
  7354. for($i = 1; $i <= 12; $i ++) {
  7355. if ($month == $i)
  7356. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7357. else
  7358. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7359. }
  7360. // 获取审批日志
  7361. Doo::loadModel ( 'receiptLog' );
  7362. $receiptLog = new receiptLog ();
  7363. $rlList = array ();
  7364. $rlInfo = $receiptLog->getOne ( array (
  7365. 'where' => 'rid=' . $rid . ' and status=4',
  7366. 'asArray' => true
  7367. ) );
  7368. $tijdate = $receiptLog->getOne ( array (
  7369. 'where' => 'rid=' . $rid . ' and status=2',
  7370. 'asc' => 'rlid',
  7371. 'asArray' => true
  7372. ) );
  7373. if (! empty ( $rlInfo )) {
  7374. $rlList = $receiptLog->find ( array (
  7375. 'where' => 'rid=' . $rid,
  7376. 'asc' => 'rlid',
  7377. 'asArray' => true
  7378. ) );
  7379. }
  7380. $receiptList [0] ['rlList'] = $rlList;
  7381. $enclosurList = $enclosur->find ( array (
  7382. 'where' => 'rid=' . $rid,
  7383. 'asArray' => true
  7384. ) );
  7385. $enclosurHtml = '';
  7386. foreach ( $enclosurList as $value ) {
  7387. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  7388. }
  7389. $data ['enclosurHtml'] = $enclosurHtml;
  7390. $data ['rolename'] = $rolename ['name'];
  7391. $data ['datetij'] = $tijdate ['date'];
  7392. $data ['mothHtml'] = $mothHtml;
  7393. $data ['receiptList'] = $receiptList;
  7394. $data ['receiptApprovalCount'] = count ( $receiptList );
  7395. $data ['year'] = $year;
  7396. $data ['categoryList'] = $categoryList;
  7397. $data ['staffList'] = $staffList;
  7398. $data ['cid'] = $cid;
  7399. $data ['sid'] = $sid;
  7400. $data ['status'] = 0;
  7401. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  7402. $ap = 4;
  7403. } else
  7404. $data ['status'] = $receiptList [0] ['status'];
  7405. if ($receiptList [0] ['status'] == 4) {
  7406. $data ['status'] = 5;
  7407. $ap = 0;
  7408. }
  7409. $data ['ap'] = $ap;
  7410. $data ['memu'] = "receipt";
  7411. $data ['staff'] = $this->staff;
  7412. $data ['receiptMemu'] = 'approval';
  7413. $data ['verifyId'] = $this->verifyId;
  7414. $data ['executeId'] = $this->executeId;
  7415. $this->render ( "/admin/saeaReportListReport", $data );
  7416. }
  7417. function approvalEdi() {
  7418. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7419. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7420. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7421. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7422. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7423. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7424. if (empty ( $status ))
  7425. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7426. $vidList = array ();
  7427. $button = 0;
  7428. Doo::loadModel ( 'verify' );
  7429. Doo::loadModel ( 'receipt' );
  7430. Doo::loadModel ( 'staff' );
  7431. $staff = new staff ();
  7432. $receipt = new receipt ();
  7433. $verify = new verify ();
  7434. Doo::loadModel ( 'L_category' );
  7435. $Lcategory = new L_category ();
  7436. Doo::loadModel ( 'enclosur' );
  7437. $enclosur = new enclosur ();
  7438. // user verify ID
  7439. $verifyDetail = $verify->find ( array (
  7440. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7441. 'asArray' => true
  7442. ) );
  7443. foreach ( $verifyDetail as $key => $value ) {
  7444. array_push ( $vidList, $value ['vid'] );
  7445. }
  7446. $vid = implode ( ",", $vidList );
  7447. if (empty ( $verifyDetail ))
  7448. $vid = 0;
  7449. $categoryList = $Lcategory->find ( array (
  7450. 'asArray' => true
  7451. ) );
  7452. $staffList = $staff->find ( array (
  7453. 'where' => 'cid=' . $cid,
  7454. 'asArray' => true
  7455. ) );
  7456. $ap = "";
  7457. if ($status == 4) {
  7458. $ap = 4;
  7459. $status = 2;
  7460. }
  7461. // get Receipt By verifyID status 2
  7462. $receiptList = $receipt->find ( array (
  7463. 'where' => 'rid =' . $rid,
  7464. 'desc' => 'rid',
  7465. 'asArray' => true
  7466. ) );
  7467. $Locate = 0;
  7468. $roleId = 0;
  7469. if ($ap == 4)
  7470. $status = 4;
  7471. foreach ( $receiptList as $key => $value ) {
  7472. $receiptList [$key] ['Locate'] = $Locate;
  7473. $Locate ++;
  7474. $receiptList [$key] ['reviseDetail'] = array ();
  7475. if (! empty ( $value ['reviseDetail'] ))
  7476. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7477. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7478. $categoryDetil = $Lcategory->getOne ( array (
  7479. 'where' => 'cid=' . $value ['cid'],
  7480. 'asArray' => true
  7481. ) );
  7482. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7483. // 检测编辑状态
  7484. $verifyList = $verify->getOne ( array (
  7485. 'where' => 'vid=' . $value ['verify'],
  7486. 'asArray' => true
  7487. ) );
  7488. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7489. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7490. // print_r($verifyList);
  7491. //
  7492. // if (empty($verifyStaff)){
  7493. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  7494. // $verifyList[0]['status']=4;$button=4;
  7495. // }
  7496. //
  7497. // }else{
  7498. //
  7499. // }
  7500. // die;
  7501. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  7502. // echo array_search("green",$a);
  7503. //
  7504. Doo::loadModel ( 'role' );
  7505. $role = new role ();
  7506. // print_r($verifyList);
  7507. $flag = true;
  7508. $roleKey = 0;
  7509. $endStaffArray = array ();
  7510. $roleArrayCopy = array ();
  7511. foreach ( $verifyList as $k => $v ) {
  7512. // init verifyStaff
  7513. if ($v [1] == 'ROLE') {
  7514. if (! empty ( $verifyStaff )) {
  7515. $endStaffArray = end ( $verifyStaff );
  7516. if ($v [0] == $endStaffArray ['nextStaff']) {
  7517. $roleId = $v [0];
  7518. }
  7519. }
  7520. $roleVerify = json_decode ( $v [3], true );
  7521. $roleKey = $k;
  7522. $roleArray = array ();
  7523. $rolename = $role->getOne ( array (
  7524. 'where' => 'rid=' . $v [0],
  7525. 'asArray' => true
  7526. ) );
  7527. foreach ( $roleVerify as $o => $p ) {
  7528. $staffID = explode ( '_', $p );
  7529. $staffInfo = $staff->getOne ( array (
  7530. 'where' => 'sid=' . $staffID [0],
  7531. 'asArray' => true
  7532. ) );
  7533. // print_r($staffID);
  7534. $exp = array (
  7535. 0 => $staffInfo ['sid'],
  7536. 1 => $staffID [1],
  7537. 2 => $staffInfo ['avatar'],
  7538. 'date' => '',
  7539. 'date' => '',
  7540. 'opinion' => '',
  7541. 'status' => '',
  7542. 'rolename' => $rolename ['name']
  7543. );
  7544. array_push ( $roleArray, $exp );
  7545. }
  7546. $roleArrayCopy [$v [0]] = $roleArray;
  7547. // $verifyList[$k]['roleArray']=$roleArray;
  7548. }
  7549. // print_r($roleArray);
  7550. $verifyList [$k] ['date'] = "";
  7551. $verifyList [$k] ['opinion'] = "";
  7552. $verifyList [$k] ['status'] = "";
  7553. if (empty ( $verifyStaff )) {
  7554. $verifyList [$k] ['date'] = "";
  7555. $verifyList [$k] ['opinion'] = "";
  7556. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7557. $verifyList [$k] ['status'] = 4;
  7558. $button = 4;
  7559. $flag = false;
  7560. }
  7561. } else {
  7562. foreach ( $verifyStaff as $m => $u ) {
  7563. if ($v [0] == $m) {
  7564. $verifyList [$k] ['date'] = $u ['date'];
  7565. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7566. $verifyList [$k] ['status'] = $u ['status'];
  7567. $flag = false;
  7568. break;
  7569. }
  7570. }
  7571. $endStaffArray = end ( $verifyStaff );
  7572. if (isset ( $endStaffArray ['ROLE'] )) {
  7573. } else {
  7574. $endKey = key ( $verifyStaff );
  7575. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7576. $button = 4;
  7577. $verifyList [$k] ['status'] = 4;
  7578. }
  7579. }
  7580. // print_r($endStaffArray);die;
  7581. // if (empty($verifyStaff)){
  7582. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  7583. // $verifyList[$k]['status']=4;$button=4;
  7584. // }
  7585. //
  7586. // }else{
  7587. //
  7588. // }
  7589. // if($flag){//检测可编辑
  7590. // if($v[0]==$this->staff[0]['sid']){
  7591. // $verifyList[$k]['status']=4;$button=4;
  7592. // }
  7593. // }
  7594. }
  7595. }
  7596. $rolename ['name'] = '';
  7597. if (! empty ( $roleId )) {
  7598. Doo::loadModel ( 'role' );
  7599. $role = new role ();
  7600. $rolename = $role->getOne ( array (
  7601. 'where' => 'rid=' . $roleId,
  7602. 'asArray' => true
  7603. ) );
  7604. }
  7605. if (! empty ( $verifyStaff ))
  7606. $endStaffArray = end ( $verifyStaff );
  7607. $KOP = false;
  7608. foreach ( $roleArrayCopy as $P => $A ) {
  7609. foreach ( $A as $MKI => $AVL ) {
  7610. if (! empty ( $verifyStaff )) {
  7611. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7612. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7613. $button = 4;
  7614. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7615. }
  7616. foreach ( $verifyStaff as $m => $u ) {
  7617. $AVLFK = $AVL [0] . '_R';
  7618. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7619. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7620. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7621. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7622. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7623. break;
  7624. }
  7625. }
  7626. } else {
  7627. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7628. $button = 4;
  7629. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7630. }
  7631. }
  7632. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7633. $KOP = true;
  7634. }
  7635. }
  7636. // print_r($roleArrayCopy);
  7637. // echo $roleKey;
  7638. foreach ( $roleArrayCopy as $k => $v ) {
  7639. foreach ( $verifyList as $m => $n ) {
  7640. if ($n [0] == $k) {
  7641. array_splice ( $verifyList, $m, 1, $v );
  7642. }
  7643. }
  7644. }
  7645. // if ($KOP)
  7646. // array_splice($verifyList,$roleKey,1,$roleArray);
  7647. // print_r($verifyList);
  7648. $receiptList [$key] ['verifyList'] = $verifyList;
  7649. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7650. 'where' => 'sid=' . $value ['staff'],
  7651. 'asArray' => true
  7652. ) );
  7653. $receiptList [$key] ['button'] = $button;
  7654. }
  7655. // $data['verifyDetail']=$verifyDetail;
  7656. $mothHtml = "";
  7657. for($i = 1; $i <= 12; $i ++) {
  7658. if ($month == $i)
  7659. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7660. else
  7661. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7662. }
  7663. // 获取审批日志
  7664. Doo::loadModel ( 'receiptLog' );
  7665. $receiptLog = new receiptLog ();
  7666. $rlList = array ();
  7667. $rlInfo = $receiptLog->getOne ( array (
  7668. 'where' => 'rid=' . $rid . ' and status=4',
  7669. 'asArray' => true
  7670. ) );
  7671. $tijdate = $receiptLog->getOne ( array (
  7672. 'where' => 'rid=' . $rid . ' and status=2',
  7673. 'asc' => 'rlid',
  7674. 'asArray' => true
  7675. ) );
  7676. if (! empty ( $rlInfo )) {
  7677. $rlList = $receiptLog->find ( array (
  7678. 'where' => 'rid=' . $rid,
  7679. 'asc' => 'rlid',
  7680. 'asArray' => true
  7681. ) );
  7682. }
  7683. $receiptList [0] ['rlList'] = $rlList;
  7684. $enclosurList = $enclosur->find ( array (
  7685. 'where' => 'rid=' . $rid,
  7686. 'asArray' => true
  7687. ) );
  7688. $enclosurHtml = '';
  7689. foreach ( $enclosurList as $value ) {
  7690. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  7691. }
  7692. $data ['enclosurHtml'] = $enclosurHtml;
  7693. $data ['rolename'] = $rolename ['name'];
  7694. $data ['datetij'] = $tijdate ['date'];
  7695. $data ['mothHtml'] = $mothHtml;
  7696. $data ['receiptList'] = $receiptList;
  7697. $data ['receiptApprovalCount'] = count ( $receiptList );
  7698. $data ['status'] = $status;
  7699. $data ['year'] = $year;
  7700. $data ['categoryList'] = $categoryList;
  7701. $data ['staffList'] = $staffList;
  7702. $data ['cid'] = $cid;
  7703. $data ['sid'] = $sid;
  7704. $data ['ap'] = $ap;
  7705. $data ['memu'] = "receipt";
  7706. $data ['staff'] = $this->staff;
  7707. $data ['receiptMemu'] = 'approval';
  7708. $data ['verifyId'] = $this->verifyId;
  7709. $data ['executeId'] = $this->executeId;
  7710. $this->render ( "/admin/saeaReportListReport", $data );
  7711. }
  7712. function remittanceHky() {
  7713. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7714. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  7715. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  7716. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  7717. $page_size = 15;
  7718. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  7719. Doo::loadModel ( 'receipt' );
  7720. $receipt = new receipt ();
  7721. Doo::loadModel ( 'staff' );
  7722. $staff = new staff ();
  7723. $dateCondition = " and Year(executeDate) =" . $year;
  7724. if ($moth != 'MONTH')
  7725. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  7726. if ($day != 'DAY' && $moth != 'MONTH')
  7727. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  7728. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  7729. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  7730. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  7731. $limit = $pageinfo ['lower'] . ',' . $page_size;
  7732. $dayList = $receipt->find ( array (
  7733. 'select' => 'executeDate,sum(amount) as amount',
  7734. 'where' => $sql,
  7735. 'desc' => 'executeDate',
  7736. 'groupby' => 'executeDate',
  7737. 'limit' => $limit,
  7738. 'asArray' => true
  7739. ) );
  7740. // print_r($dayList);
  7741. foreach ( $dayList as $key => $value ) {
  7742. $remitString = "";
  7743. $receiptList = $receipt->find ( array (
  7744. 'select' => 'rid,executeDate,amount,staff,cid',
  7745. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  7746. 'desc' => 'executeDate',
  7747. 'asArray' => true
  7748. ) );
  7749. foreach ( $receiptList as $k => $v ) {
  7750. $sinfo = $staff->getOne ( array (
  7751. 'select' => 'username,category',
  7752. 'where' => ' sid=' . $v ['staff'],
  7753. 'asArray' => true
  7754. ) );
  7755. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  7756. }
  7757. $dayList [$key] ['staff'] = $remitString;
  7758. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  7759. }
  7760. // print_r($dayList);
  7761. $mothHtml = "";
  7762. for($i = 1; $i <= 12; $i ++) {
  7763. if ($moth == $i)
  7764. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7765. else
  7766. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7767. }
  7768. $dayHtml = "";
  7769. if ($day != "DAY" || $moth != "MONTH") {
  7770. for($i = 1; $i <= 31; $i ++) {
  7771. if ($day == $i)
  7772. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  7773. else
  7774. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  7775. }
  7776. }
  7777. $dateHtml = "";
  7778. $now = date ( "Y" );
  7779. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  7780. if ($YEARD <= $now) {
  7781. $dateHtml .= '<option ';
  7782. if ($year == $YEARD) {
  7783. $dateHtml .= 'selected ';
  7784. }
  7785. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  7786. }
  7787. }
  7788. $data ['dateHtml'] = $dateHtml;
  7789. $data ['page'] = $pageinfo;
  7790. $data ['year'] = $year;
  7791. $data ['moth'] = $moth;
  7792. $data ['day'] = $day;
  7793. $data ['get'] = $get;
  7794. $data ['dayHtml'] = $dayHtml;
  7795. $data ['mothHtml'] = $mothHtml;
  7796. $data ['receiptList'] = $dayList;
  7797. $data ['memu'] = "receipt";
  7798. $data ['staff'] = $this->staff;
  7799. $data ['receiptMemu'] = 'remittanceHky';
  7800. $data ['verifyId'] = $this->verifyId;
  7801. $data ['executeId'] = $this->executeId;
  7802. $this->render ( "/admin/remittanceHky", $data );
  7803. }
  7804. function remittancep() {
  7805. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  7806. Doo::loadModel ( 'receipt' );
  7807. $receipt = new receipt ();
  7808. Doo::loadModel ( 'staff' );
  7809. $staff = new staff ();
  7810. Doo::loadClass ( 'XDeode' );
  7811. $XDeode = new XDeode ( 5 );
  7812. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  7813. $rplist = $receipt->find ( array (
  7814. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  7815. 'asArray' => true
  7816. ) );
  7817. $dayList = $receipt->find ( array (
  7818. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  7819. 'desc' => 'executeDate',
  7820. 'groupby' => 'staff',
  7821. 'asArray' => true
  7822. ) );
  7823. $html = '';
  7824. foreach ( $dayList as $key => $value ) {
  7825. $sinfo = $staff->getOne ( array (
  7826. 'select' => 'username,category',
  7827. 'where' => ' sid=' . $value ['staff'],
  7828. 'asArray' => true
  7829. ) );
  7830. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  7831. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  7832. $au = 0;
  7833. foreach ( $rplist as $k => $v ) {
  7834. if ($value ['staff'] == $v ['staff']) {
  7835. $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>';
  7836. $au += $v ['amount'];
  7837. }
  7838. }
  7839. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  7840. }
  7841. $data ['html'] = $html;
  7842. $data ['memu'] = "receipt";
  7843. $data ['staff'] = $this->staff;
  7844. $data ['receiptMemu'] = 'remittanceHky';
  7845. $data ['verifyId'] = $this->verifyId;
  7846. $data ['executeId'] = $this->executeId;
  7847. $this->render ( "/admin/remittancep", $data );
  7848. }
  7849. function ajaxGetReceiptDetails() {
  7850. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  7851. Doo::loadClass ( 'XDeode' );
  7852. $XDeode = new XDeode ( 5 );
  7853. $rid = $XDeode->decode ( $rid );
  7854. if (empty ( $rid )) {
  7855. echo json_encode ( array (
  7856. 'status' => 2,
  7857. 'msg' => 'illegal request'
  7858. ) );
  7859. die ();
  7860. }
  7861. Doo::loadModel ( 'receipt' );
  7862. $receipt = new receipt ();
  7863. Doo::loadModel ( 'staff' );
  7864. $staff = new staff ();
  7865. $rinfo = $receipt->getOne ( array (
  7866. 'where' => 'rid= ' . $rid,
  7867. 'asArray' => true
  7868. ) );
  7869. $sinfo = $staff->getOne ( array (
  7870. 'select' => 'username,category',
  7871. 'where' => ' sid=' . $rinfo ['staff'],
  7872. 'asArray' => true
  7873. ) );
  7874. $rinfo ['reviseDetail'] = array ();
  7875. if (! empty ( $rinfo ['reviseDetail'] ))
  7876. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  7877. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  7878. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  7879. $rinfo ['category'] = $sinfo ['category'];
  7880. $verifyStaff = array ();
  7881. if (! empty ( $rinfo ['verifyStaff'] ))
  7882. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  7883. $relust = bcsub ( $rinfo ['sum'], $rinfo ['loanSum'], 2 );
  7884. $rinfo ['relust'] = $relust;
  7885. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  7886. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  7887. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  7888. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  7889. // 费用执行人相关数据
  7890. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  7891. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  7892. foreach ( $executeCopy as $k => $v ) {
  7893. $executeCopy [$k] ['date'] = '';
  7894. $executeCopy [$k] ['opinion'] = '';
  7895. $executeCopy [$k] ['status'] = '';
  7896. if (! empty ( $executeStaff ))
  7897. foreach ( $executeStaff as $m => $u ) {
  7898. if ($v [0] == $m) {
  7899. $executeCopy [$k] ['date'] = $u ['date'];
  7900. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  7901. $executeCopy [$k] ['status'] = $u ['status'];
  7902. break;
  7903. }
  7904. }
  7905. }
  7906. $rinfo ['executeCopy'] = $executeCopy;
  7907. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  7908. if ($rinfo ['Rtype'] == 1) { // 借款费用
  7909. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  7910. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  7911. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  7912. $html .= '<tr><th>' . $value ['name'] . '</th>
  7913. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7914. }
  7915. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  7916. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  7917. <tr><th class="taC" colspan="2">费用说明</th>
  7918. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  7919. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  7920. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  7921. </tbody></table>';
  7922. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  7923. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  7924. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  7925. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  7926. $html .= '<tr><th>' . $value ['name'] . '</th>
  7927. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7928. }
  7929. $html .= '<tr><th class="taR">合计</th>
  7930. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  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'] ['travelSum'] . '</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'] ['trainSum'] . '</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'] ['otherSum'] . '</td></tr>';
  7952. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  7953. foreach ( $rinfo ['reviseDetail'] as $value ) {
  7954. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  7955. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  7956. }
  7957. $html .= '<tr><th class="taR">合计</th>
  7958. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  7959. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  7960. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  7961. <tr><th class="taC" colspan="2">报销说明</th></tr>
  7962. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  7963. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  7964. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  7965. <tr';
  7966. if ($rinfo ['relust'] >= 0) {
  7967. $html .= 'class="success"';
  7968. } else {
  7969. $html .= 'class="error"';
  7970. }
  7971. $html .= '><td class="taR"><b>借款结余</b></td>
  7972. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  7973. </tbody></table>
  7974. ';
  7975. }
  7976. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  7977. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  7978. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  7979. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  7980. $html .= '<tr><th>' . $value ['name'] . '</th>
  7981. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7982. }
  7983. $html .= '<tr><th class="taR">合计</th>
  7984. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  7985. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  7986. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  7987. <tr><th class="taC" colspan="2">费用说明</th>
  7988. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  7989. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  7990. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  7991. </tbody></table>';
  7992. } else {
  7993. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  7994. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  7995. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  7996. $html .= '<tr><th>' . $value ['name'] . '</th>
  7997. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7998. }
  7999. $html .= '<tr><th class="taR">合计</th>
  8000. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  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'] ['travelSum'] . '</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'] ['trainSum'] . '</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'] ['otherSum'] . '</td></tr>';
  8022. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8023. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8024. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8025. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8026. }
  8027. $html .= '<tr><th class="taR">合计</th>
  8028. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8029. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8030. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8031. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8032. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8033. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8034. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  8035. $html .= '</tbody></table>';
  8036. /*
  8037. * <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>
  8038. */
  8039. }
  8040. // print_r($verifyStaff);die;
  8041. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  8042. foreach ( $verifyStaff as $key => $value ) {
  8043. $key = trim ( strtr ( $key, '_R', ' ' ) );
  8044. $sinfo = $staff->getOne ( array (
  8045. 'select' => 'username',
  8046. 'where' => ' sid=' . $key,
  8047. 'asArray' => true
  8048. ) );
  8049. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8050. }
  8051. $html .= '</tbody></table>';
  8052. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  8053. foreach ( $rinfo ['executeCopy'] as $value ) {
  8054. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8055. }
  8056. $html .= '</tbody></table>';
  8057. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  8058. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  8059. </tr></table>';
  8060. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  8061. echo json_encode ( array (
  8062. 'status' => 1,
  8063. 'html' => $html
  8064. ) );
  8065. die ();
  8066. }
  8067. /**
  8068. * 删除附件
  8069. */
  8070. function ajaxRemEnclousur() {
  8071. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  8072. if (empty ( $key ))
  8073. echo json_encode ( array (
  8074. 'status' => 2
  8075. ) );
  8076. Doo::loadModel ( 'enclosur' );
  8077. $enclosur = new enclosur ();
  8078. $enclosur->delEnclosurByEid ( $key );
  8079. echo json_encode ( array (
  8080. 'status' => 1
  8081. ) );
  8082. }
  8083. function remittance() {
  8084. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8085. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8086. Doo::loadModel ( 'receipt' );
  8087. $receipt = new receipt ();
  8088. Doo::loadModel ( 'staff' );
  8089. $staff = new staff ();
  8090. $dateCondition = " and Year(pastDate) =" . $year;
  8091. if (! empty ( $month ))
  8092. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  8093. // get Receipt By verifyID status 1
  8094. $receiptList = $receipt->find ( array (
  8095. 'select' => 'sum(sum) as sum,staff,pastDate',
  8096. 'where' => ' status=1' . $dateCondition,
  8097. 'desc' => 'pastDate',
  8098. 'groupby' => 'staff,pastDate',
  8099. 'asArray' => true
  8100. ) );
  8101. $dateList = $receipt->find ( array (
  8102. 'select' => 'pastDate,verifyStaff',
  8103. 'where' => ' status=1' . $dateCondition,
  8104. 'desc' => 'pastDate',
  8105. 'groupby' => 'pastDate',
  8106. 'asArray' => true
  8107. ) );
  8108. $dataList = array ();
  8109. foreach ( $dateList as $d => $a ) {
  8110. $dataList [$a ['pastDate']] = array ();
  8111. $daySum = 0;
  8112. foreach ( $receiptList as $key => $value ) {
  8113. if ($a ['pastDate'] == $value ['pastDate']) {
  8114. $oderList = $receipt->find ( array (
  8115. 'select' => 'receiptOrder',
  8116. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  8117. 'asArray' => true
  8118. ) );
  8119. $list = array ();
  8120. $html = "";
  8121. foreach ( $oderList as $v ) {
  8122. array_push ( $list, $v ['receiptOrder'] );
  8123. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  8124. }
  8125. $receiptList [$key] ['receiptOrder'] = $html;
  8126. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  8127. $sinfo = $staff->getOne ( array (
  8128. 'select' => 'username ',
  8129. 'where' => ' sid=' . $value ['staff'],
  8130. 'asArray' => true
  8131. ) );
  8132. $receiptList [$key] ['username'] = $sinfo ['username'];
  8133. $daySum += $value ['sum'];
  8134. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  8135. }
  8136. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  8137. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  8138. }
  8139. }
  8140. // print_r($dataList);
  8141. $data ['dataList'] = $dataList;
  8142. $mothHtml = "";
  8143. for($i = 1; $i <= 12; $i ++) {
  8144. if ($month == $i)
  8145. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8146. else
  8147. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8148. }
  8149. $data ['year'] = $year;
  8150. $data ['mothHtml'] = $mothHtml;
  8151. $data ['memu'] = "receipt";
  8152. $data ['staff'] = $this->staff;
  8153. $data ['receiptMemu'] = 'approval';
  8154. $data ['verifyId'] = $this->verifyId;
  8155. $data ['executeId'] = $this->executeId;
  8156. $this->render ( "/admin/saeaReportListPay", $data );
  8157. }
  8158. /**
  8159. * 金额调整,提高稳定性
  8160. * @return string
  8161. */
  8162. function revocationAdjustment() {
  8163. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  8164. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  8165. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  8166. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  8167. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  8168. Doo::loadClass ( 'XDeode' );
  8169. $XDeode = new XDeode ( 5 );
  8170. Doo::loadModel ( 'receipt' );
  8171. $receipt = new receipt ();
  8172. $sid = $XDeode->decode ( $sidKey );
  8173. $rid = $XDeode->decode ( $ridKey );
  8174. $reviseKey = $XDeode->decode ( $reviseKey );
  8175. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  8176. die ( 'illegal request' );
  8177. $receiptDetail = $receipt->getOne ( array (
  8178. 'where' => 'rid=' . $rid,
  8179. 'asArray' => true
  8180. ) );
  8181. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  8182. die ( 'illegal request' );
  8183. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8184. if (! isset ( $reviseDetail [$reviseKey] ))
  8185. die ( 'illegal request' );
  8186. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  8187. unset ( $reviseDetail [$reviseKey] );
  8188. $revisePrice = 0;
  8189. foreach ( $reviseDetail as $key => $value ) {
  8190. $revisePrice += $value ['price'];
  8191. }
  8192. $reviseDetailString = json_encode ( $reviseDetail );
  8193. $receipt->reviseDetail = $reviseDetailString;
  8194. $receipt->sum = $receiptDetail ['sum'] - $price;
  8195. $receipt->revisePrice = $revisePrice;
  8196. $receipt->update ( array (
  8197. 'where' => 'rid=' . $rid
  8198. ) );
  8199. return '/receiptburEdi/' . $rid;
  8200. } else
  8201. die ( 'illegal request2' );
  8202. }
  8203. function updateApprovalReceipt() {
  8204. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  8205. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  8206. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8207. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  8208. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  8209. if (! empty ( $rid )) {
  8210. Doo::loadModel ( "verify" );
  8211. $verify = new verify ();
  8212. Doo::loadModel ( "receiptDetail" );
  8213. $receiptDetailObj = new receiptDetail ();
  8214. Doo::loadModel ( "itemStatistics" );
  8215. Doo::loadModel ( "statistics" );
  8216. $statistics = new statistics ();
  8217. $itemStatistics = new itemStatistics ();
  8218. Doo::loadModel ( "receipt" );
  8219. $receipt = new receipt ();
  8220. $receiptDetail = $receipt->getOne ( array (
  8221. 'where' => 'rid=' . $rid . ' and status=2 ',
  8222. 'asArray' => true
  8223. ) );
  8224. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  8225. $nsflag = true;
  8226. foreach ( $nslist as $value ) {
  8227. if ($value == $this->staff ['0'] ['sid']) {
  8228. $nsflag = false;
  8229. break;
  8230. }
  8231. }
  8232. if (empty ( $receiptDetail ) || $nsflag)
  8233. return "/approvalExpenses/pendApproval";
  8234. $verifyDetail = $verify->getOne ( array (
  8235. 'where' => ' vid =' . $receiptDetail ['verify'],
  8236. 'asArray' => true
  8237. ) );
  8238. $verifyString = $verifyDetail ['staff'];
  8239. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  8240. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  8241. if (empty ( $opinion )) {
  8242. if ($status == 3)
  8243. $opinion = "终止";
  8244. else
  8245. $opinion = "同意支付";
  8246. }
  8247. $nowStaff = 0;
  8248. $nowStaffList = array ();
  8249. if (empty ( $verifyStaff )) {
  8250. // 还需加入是否已经进入角色审批
  8251. if ($verifyDetail [0] [1] == 'ROLE') {
  8252. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  8253. foreach ( $vStaffString as $key => $value ) {
  8254. $staffK = explode ( "_", $value );
  8255. if ($staffK [0] != $this->staff [0] ['sid'])
  8256. array_push ( $nowStaffList, $staffK [0] );
  8257. }
  8258. // print_r($verifyDetail);
  8259. // die;
  8260. if (! empty ( $nowStaffList )) {
  8261. $nowStaff = implode ( ',', $nowStaffList );
  8262. $verifyStaff = array (
  8263. $this->staff [0] ['sid'] . "_R" => array (
  8264. 'date' => date ( 'Y-m-d' ),
  8265. 'opinion' => $opinion,
  8266. 'status' => $status,
  8267. 'nextStaff' => $verifyDetail [0] [0],
  8268. 'ROLE' => 1
  8269. )
  8270. );
  8271. } else {
  8272. $nowStaff = $verifyDetail [1] [0];
  8273. $verifyStaff = array (
  8274. $this->staff [0] ['sid'] . "_R" => array (
  8275. 'date' => date ( 'Y-m-d' ),
  8276. 'opinion' => $opinion,
  8277. 'status' => $status,
  8278. 'nextStaff' => $verifyDetail [1] [0]
  8279. )
  8280. );
  8281. }
  8282. } else {
  8283. if ($verifyDetail [1] [1] == 'ROLE') {
  8284. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  8285. // echo "dd";
  8286. foreach ( $vStaffString as $key => $value ) {
  8287. $staffK = explode ( "_", $value );
  8288. array_push ( $nowStaffList, $staffK [0] );
  8289. }
  8290. $nowStaff = implode ( ',', $nowStaffList );
  8291. $verifyStaff = array (
  8292. $this->staff [0] ['sid'] => array (
  8293. 'date' => date ( 'Y-m-d' ),
  8294. 'opinion' => $opinion,
  8295. 'status' => $status,
  8296. 'nextStaff' => $verifyDetail [1] [0],
  8297. 'ROLE' => 1
  8298. )
  8299. );
  8300. } else {
  8301. $nowStaff = $verifyDetail [1] [0];
  8302. $verifyStaff = array (
  8303. $this->staff [0] ['sid'] => array (
  8304. 'date' => date ( 'Y-m-d' ),
  8305. 'opinion' => $opinion,
  8306. 'status' => $status,
  8307. 'nextStaff' => $verifyDetail [1] [0]
  8308. )
  8309. );
  8310. }
  8311. }
  8312. if ($status == 3)
  8313. $verifyStaff = array (
  8314. 'final' => $status,
  8315. $this->staff [0] ['sid'] => array (
  8316. 'date' => date ( 'Y-m-d' ),
  8317. 'opinion' => $opinion,
  8318. 'status' => $status
  8319. )
  8320. );
  8321. $vStaffString = json_encode ( $verifyStaff );
  8322. $receipt->nowStaff = $nowStaff;
  8323. $receipt->verifyStaff = $vStaffString;
  8324. } else {
  8325. $VS = end ( $verifyStaff );
  8326. // 非角色审批
  8327. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  8328. $nextStaff = 0;
  8329. $roleSTF = false;
  8330. foreach ( $verifyDetail as $key => $value ) {
  8331. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  8332. if (isset ( $verifyDetail [$key + 1] )) {
  8333. $nextStaff = $verifyDetail [$key + 1] [0];
  8334. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  8335. $roleSTF = true;
  8336. }
  8337. break;
  8338. }
  8339. }
  8340. if (! $roleSTF) {
  8341. $nowStaff = $nextStaff;
  8342. $verifyStaff [$this->staff [0] ['sid']] = array (
  8343. 'date' => date ( 'Y-m-d' ),
  8344. 'opinion' => $opinion,
  8345. 'status' => $status,
  8346. 'nextStaff' => $nextStaff
  8347. );
  8348. } else {
  8349. // 获取角色下的所有用户ID
  8350. $nowStaffList = array ();
  8351. foreach ( $verifyDetail as $vfk ) {
  8352. if ($vfk [1] == 'ROLE') {
  8353. $vStaffString = json_decode ( $vfk [3] );
  8354. foreach ( $vStaffString as $key => $value ) {
  8355. $staffK = explode ( "_", $value );
  8356. array_push ( $nowStaffList, $staffK [0] );
  8357. }
  8358. }
  8359. }
  8360. $nowStaff = implode ( ',', $nowStaffList );
  8361. $verifyStaff [$this->staff [0] ['sid']] = array (
  8362. 'date' => date ( 'Y-m-d' ),
  8363. 'opinion' => $opinion,
  8364. 'status' => $status,
  8365. 'nextStaff' => $nextStaff,
  8366. 'ROLE' => 0
  8367. );
  8368. }
  8369. if ($status == 3) {
  8370. $verifyStaff ['final'] = $status;
  8371. $verifyStaff [$this->staff [0] ['sid']] = array (
  8372. 'date' => date ( 'Y-m-d' ),
  8373. 'opinion' => $opinion,
  8374. 'status' => $status
  8375. );
  8376. }
  8377. $vStaffString = json_encode ( $verifyStaff );
  8378. $receipt->nowStaff = $nowStaff;
  8379. $receipt->verifyStaff = $vStaffString;
  8380. }
  8381. // 角色审批
  8382. if (isset ( $VS ['ROLE'] )) {
  8383. // 找出角色人 当前审批角色组
  8384. $verifyJSStaff = array ();
  8385. $nowStaffList2 = array ();
  8386. foreach ( $verifyDetail as $key => $value ) {
  8387. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  8388. $verifyJSStaff = json_decode ( $value [3] );
  8389. foreach ( $verifyJSStaff as $m ) {
  8390. $staffK = explode ( "_", $m );
  8391. array_push ( $nowStaffList2, $staffK [0] );
  8392. }
  8393. // print_r($nowStaffList2);
  8394. }
  8395. }
  8396. $RoleVerifyStaff = array ();
  8397. foreach ( $verifyStaff as $key => $value ) {
  8398. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  8399. foreach ( $nowStaffList2 as $m ) {
  8400. if ($key == $m . "_R")
  8401. $RoleVerifyStaff [$key] = $value;
  8402. }
  8403. }
  8404. }
  8405. // print_r($verifyStaff);
  8406. // print_r($nowStaffList2);
  8407. // print_r($RoleVerifyStaff);
  8408. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  8409. // print_r($verifyJSStaff);
  8410. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  8411. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  8412. // 下一个审批人ID
  8413. $nextStaff = 0;
  8414. $falg = false;
  8415. foreach ( $verifyDetail as $key => $value ) {
  8416. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  8417. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  8418. $falg = true;
  8419. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  8420. $nowStaffList = array ();
  8421. foreach ( $vStaffString as $v ) {
  8422. $staffK = explode ( "_", $v );
  8423. array_push ( $nowStaffList, $staffK [0] );
  8424. }
  8425. $nowStaff = implode ( ',', $nowStaffList );
  8426. $nextStaff = $verifyDetail [$key + 1] [0];
  8427. } elseif (isset ( $verifyDetail [$key + 1] )) {
  8428. $nextStaff = $verifyDetail [$key + 1] [0];
  8429. $nowStaff = $nextStaff;
  8430. } else
  8431. $nowStaff = '';
  8432. break;
  8433. }
  8434. }
  8435. if ($falg)
  8436. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8437. 'date' => date ( 'Y-m-d' ),
  8438. 'opinion' => $opinion,
  8439. 'status' => $status,
  8440. 'nextStaff' => $nextStaff,
  8441. 'ROLE' => 1
  8442. );
  8443. else
  8444. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8445. 'date' => date ( 'Y-m-d' ),
  8446. 'opinion' => $opinion,
  8447. 'status' => $status,
  8448. 'nextStaff' => $nextStaff
  8449. );
  8450. // print_r($verifyStaff);
  8451. // echo $nowStaff;die;
  8452. } else { // 进入下一个角色或者审批人
  8453. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  8454. //
  8455. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  8456. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8457. 'date' => date ( 'Y-m-d' ),
  8458. 'opinion' => $opinion,
  8459. 'status' => $status,
  8460. 'nextStaff' => $VS ['nextStaff'],
  8461. 'ROLE' => 1
  8462. );
  8463. // print_r($verifyStaff);
  8464. // die;
  8465. }
  8466. if ($status == 3) {
  8467. $verifyStaff ['final'] = $status;
  8468. $verifyStaff [$this->staff [0] ['sid']] = array (
  8469. 'date' => date ( 'Y-m-d' ),
  8470. 'opinion' => $opinion,
  8471. 'status' => $status
  8472. );
  8473. }
  8474. $vStaffString = json_encode ( $verifyStaff );
  8475. $receipt->verifyStaff = $vStaffString;
  8476. $receipt->nowStaff = $nowStaff;
  8477. // die;
  8478. // }
  8479. // print_r($verifyStaff);
  8480. // die;
  8481. }
  8482. // print_r($verifyStaff);die;
  8483. }
  8484. // print_r($verifyDetail);
  8485. $roleKey = 0;
  8486. $roleId = 0;
  8487. $verifyDetailCopy = array ();
  8488. foreach ( $verifyDetail as $k => $v ) {
  8489. if ($v [1] == 'ROLE') {
  8490. $roleId = $v [0];
  8491. $roleVerify = json_decode ( $v [3], true );
  8492. $roleKey = $k;
  8493. $roleArray = array ();
  8494. foreach ( $roleVerify as $o => $p ) {
  8495. $staffID = explode ( '_', $p );
  8496. $exp = array (
  8497. 0 => $staffID [0],
  8498. 1 => $staffID [1]
  8499. );
  8500. array_push ( $roleArray, $exp );
  8501. }
  8502. $verifyDetailCopy [$v [0]] = $roleArray;
  8503. }
  8504. }
  8505. // print_r($verifyDetail);
  8506. foreach ( $verifyDetailCopy as $k => $v ) {
  8507. foreach ( $verifyDetail as $m => $n ) {
  8508. if ($n [0] == $k) {
  8509. array_splice ( $verifyDetail, $m, 1, $v );
  8510. }
  8511. }
  8512. }
  8513. // die;
  8514. // if (!empty($roleArray))
  8515. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  8516. // echo $roleId;
  8517. // print_r($verifyStaff);
  8518. // print_r($verifyDetail);
  8519. // die;
  8520. Doo::loadModel ( "receiptLog" );
  8521. $receiptLog = new receiptLog ();
  8522. // 审批日志
  8523. if (! isset ( $verifyStaff ['final'] )) {
  8524. if (! empty ( $roleId )) {
  8525. Doo::loadModel ( "role" );
  8526. $role = new role ();
  8527. $roleInfo = $role->getOne ( array (
  8528. 'where' => 'rid=' . $roleId,
  8529. 'asArray' => true
  8530. ) );
  8531. $receiptLog->rolename = $roleInfo ['name'];
  8532. }
  8533. $receiptLog->username = $this->staff [0] ['username'];
  8534. $receiptLog->uid = $this->staff [0] ['sid'];
  8535. $receiptLog->date = date ( "Y-m-d" );
  8536. $receiptLog->opinion = $opinion;
  8537. $receiptLog->img = $this->staff [0] ['avatar'];
  8538. $receiptLog->status = 1;
  8539. $receiptLog->rid = $rid;
  8540. $receiptLog->insert ();
  8541. }
  8542. if (isset ( $verifyStaff ['final'] )) { // rDetail
  8543. $receipt->verifyBreakup = $verifyString;
  8544. $receipt->status = 3;
  8545. $receiptDetailObj->status = 3;
  8546. $receiptDetailObj->update ( array (
  8547. 'where' => 'rid=' . $rid
  8548. ) );
  8549. if (! empty ( $roleId )) {
  8550. Doo::loadModel ( "role" );
  8551. $role = new role ();
  8552. $roleInfo = $role->getOne ( array (
  8553. 'where' => 'rid=' . $roleId,
  8554. 'asArray' => true
  8555. ) );
  8556. $receiptLog->rolename = $roleInfo ['name'];
  8557. }
  8558. $receiptLog->username = $this->staff [0] ['username'];
  8559. $receiptLog->uid = $this->staff [0] ['sid'];
  8560. $receiptLog->date = date ( "Y-m-d" );
  8561. $receiptLog->opinion = $opinion;
  8562. $receiptLog->img = $this->staff [0] ['avatar'];
  8563. $receiptLog->status = 3;
  8564. $receiptLog->rid = $rid;
  8565. $receiptLog->insert ();
  8566. // 微信企业号通知
  8567. $this->setWXMsg ( $rid, 3 );
  8568. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  8569. $receipt->status = 1;
  8570. $reviseSum = 0;
  8571. $receipt->verifyBreakup = $verifyString;
  8572. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  8573. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8574. foreach ( $reviseDetail as $key => $value ) {
  8575. $receiptDetailObj = new receiptDetail ();
  8576. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8577. $receiptDetailObj->item = $value ['description'];
  8578. $receiptDetailObj->itemCategory = "报销金额调整";
  8579. $receiptDetailObj->price = $value ['price'];
  8580. $receiptDetailObj->date = $receiptDetail ['date'];
  8581. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  8582. $receiptDetailObj->rid = $rid;
  8583. $receiptDetailObj->status = 1;
  8584. $receiptDetailObj->insert ();
  8585. $reviseSum += $value ['price'];
  8586. }
  8587. $itemStatistics = new itemStatistics ();
  8588. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  8589. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8590. $itemStatistics->price = $reviseSum;
  8591. $itemStatistics->itemCategory = "报销金额调整";
  8592. $itemStatistics->date = $receiptDetail ['date'];
  8593. $itemStatistics->insert ();
  8594. }
  8595. $receiptDetailObj = new receiptDetail ();
  8596. $receiptDetailObj->status = 1;
  8597. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  8598. $receiptDetailObj->update ( array (
  8599. 'where' => 'rid=' . $rid
  8600. ) );
  8601. $dateArray = explode ( "-", $receiptDetail ['date'] );
  8602. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  8603. $stat = $statistics->getOne ( array (
  8604. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  8605. 'asArray' => true
  8606. ) );
  8607. if (empty ( $stat )) {
  8608. $statistics->date = $receiptDetail ['date'];
  8609. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  8610. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8611. $statistics->agPrice = $receiptDetail ['sum'];
  8612. $statistics->rePrice = $reviseSum;
  8613. $statistics->insert ();
  8614. } else {
  8615. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  8616. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  8617. $statistics->update ( array (
  8618. 'where' => 'sid=' . $stat ['sid']
  8619. ) );
  8620. }
  8621. $dateArray = explode ( "-", $receiptDetail ['date'] );
  8622. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  8623. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  8624. foreach ( $accountItem ['cSum'] as $key => $value ) {
  8625. if ($key == "agencySum") {
  8626. $iStatistics = $itemStatistics->getOne ( array (
  8627. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  8628. 'asArray' => true
  8629. ) );
  8630. if (empty ( $iStatistics )) {
  8631. $itemStatistics->cid = $receiptDetail ['cid'];
  8632. ;
  8633. $itemStatistics->staff = $receiptDetail ['staff'];
  8634. $itemStatistics->price = $value;
  8635. $itemStatistics->itemCategory = $this->AGENCY;
  8636. $itemStatistics->date = $receiptDetail ['date'];
  8637. $itemStatistics->insert ();
  8638. } else {
  8639. if (! empty ( $value )) {
  8640. $itemStatistics->price = $value + $iStatistics ['price'];
  8641. $itemStatistics->update ( array (
  8642. 'where' => 'sid=' . $iStatistics ['sid']
  8643. ) );
  8644. }
  8645. }
  8646. } elseif ($key == "travelSum") {
  8647. $iStatistics = $itemStatistics->getOne ( array (
  8648. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  8649. 'asArray' => true
  8650. ) );
  8651. if (empty ( $iStatistics )) {
  8652. $itemStatistics->cid = $receiptDetail ['cid'];
  8653. $itemStatistics->staff = $receiptDetail ['staff'];
  8654. $itemStatistics->price = $value;
  8655. $itemStatistics->itemCategory = $this->TRAVEL;
  8656. $itemStatistics->date = $receiptDetail ['date'];
  8657. $itemStatistics->insert ();
  8658. } else {
  8659. if (! empty ( $value )) {
  8660. $itemStatistics->price = $value + $iStatistics ['price'];
  8661. $itemStatistics->update ( array (
  8662. 'where' => 'sid=' . $iStatistics ['sid']
  8663. ) );
  8664. }
  8665. }
  8666. } elseif ($key == "trainSum") {
  8667. $iStatistics = $itemStatistics->getOne ( array (
  8668. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  8669. 'asArray' => true
  8670. ) );
  8671. if (empty ( $iStatistics )) {
  8672. $itemStatistics->cid = $receiptDetail ['cid'];
  8673. $itemStatistics->staff = $receiptDetail ['staff'];
  8674. $itemStatistics->price = $value;
  8675. $itemStatistics->itemCategory = $this->TRAIN;
  8676. $itemStatistics->date = $receiptDetail ['date'];
  8677. $itemStatistics->insert ();
  8678. } else {
  8679. if (! empty ( $value )) {
  8680. $itemStatistics->price = $value + $iStatistics ['price'];
  8681. $itemStatistics->update ( array (
  8682. 'where' => 'sid=' . $iStatistics ['sid']
  8683. ) );
  8684. }
  8685. }
  8686. } elseif ($key == "otherSum") {
  8687. $iStatistics = $itemStatistics->getOne ( array (
  8688. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  8689. 'asArray' => true
  8690. ) );
  8691. if (empty ( $iStatistics )) {
  8692. $itemStatistics->cid = $receiptDetail ['cid'];
  8693. $itemStatistics->staff = $receiptDetail ['staff'];
  8694. $itemStatistics->price = $value;
  8695. $itemStatistics->itemCategory = $this->OTHER;
  8696. $itemStatistics->date = $receiptDetail ['date'];
  8697. $itemStatistics->insert ();
  8698. } else {
  8699. if (! empty ( $value )) {
  8700. $itemStatistics->price = $value + $iStatistics ['price'];
  8701. $itemStatistics->update ( array (
  8702. 'where' => 'sid=' . $iStatistics ['sid']
  8703. ) );
  8704. }
  8705. }
  8706. }
  8707. }
  8708. $receipt->pastDate = date ( "Y-m-d" );
  8709. // 微信企业号通知
  8710. $this->setWXMsg ( $rid, 1 );
  8711. }
  8712. $receipt->amount = $amount;
  8713. $receipt->update ( array (
  8714. 'where' => ' rid = ' . $rid
  8715. ) );
  8716. // 进入下一条审批费用新加需求
  8717. $vidList = array ();
  8718. $verifyDetail = $verify->find ( array (
  8719. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  8720. 'asArray' => true
  8721. ) );
  8722. foreach ( $verifyDetail as $key => $value ) {
  8723. array_push ( $vidList, $value ['vid'] );
  8724. }
  8725. $vid = implode ( ",", $vidList );
  8726. if (empty ( $verifyDetail ))
  8727. $vid = 0;
  8728. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  8729. $receipt = new receipt ();
  8730. $rd = $receipt->getOne ( array (
  8731. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  8732. 'asc' => 'rid',
  8733. 'asArray' => true
  8734. ) );
  8735. if (empty ( $rd )) {
  8736. return '/approvalExpenses/pendApproval';
  8737. }
  8738. if ($rd ['Rtype'] == 1) {
  8739. if ($rd ['isBK'] == 1) {
  8740. return '/receiptburEdi/' . $rd ['rid'];
  8741. } else {
  8742. return '/expensesEdi/' . $rd ['rid'];
  8743. }
  8744. } elseif ($rd ['Rtype'] == 2) {
  8745. return '/remitApproval/' . $rd ['rid'];
  8746. } else {
  8747. return '/receiptburEdi/' . $rd ['rid'];
  8748. }
  8749. // return "/approvalExpenses/pendApproval";
  8750. }
  8751. }
  8752. function expensesRetreats() {
  8753. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  8754. if (! empty ( $rid )) {
  8755. // 操作记录
  8756. Doo::loadModel ( "receipt" );
  8757. $receipt = new receipt ();
  8758. Doo::loadModel ( "receiptLog" );
  8759. $receiptLog = new receiptLog ();
  8760. Doo::loadModel ( "verify" );
  8761. $verify = new verify ();
  8762. $receiptInfo = $receipt->getOne ( array (
  8763. 'where' => 'rid=' . $rid,
  8764. 'asArray' => true
  8765. ) );
  8766. $vr = $verify->getOne ( array (
  8767. 'where' => 'vid=' . $receiptInfo ['verify'],
  8768. 'asArray' => true
  8769. ) );
  8770. $jd = json_decode ( $vr ['staff'] );
  8771. $roleId = 0;
  8772. foreach ( $jd as $key => $value ) {
  8773. if ($value [1] == 'ROLE') {
  8774. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  8775. if ($pos !== false) {
  8776. $roleId = $value [0];
  8777. }
  8778. }
  8779. }
  8780. // 审批日志
  8781. // echo $roleId;die;
  8782. if (! empty ( $roleId )) {
  8783. Doo::loadModel ( "role" );
  8784. $role = new role ();
  8785. $roleInfo = $role->getOne ( array (
  8786. 'where' => 'rid=' . $roleId,
  8787. 'asArray' => true
  8788. ) );
  8789. $receiptLog->rolename = $roleInfo ['name'];
  8790. }
  8791. $receiptLog->username = $this->staff [0] ['username'];
  8792. $receiptLog->uid = $this->staff [0] ['sid'];
  8793. $receiptLog->date = date ( "Y-m-d" );
  8794. $receiptLog->opinion = '撤回';
  8795. $receiptLog->img = $this->staff [0] ['avatar'];
  8796. $receiptLog->status = 4;
  8797. $receiptLog->rid = $rid;
  8798. $receiptLog->insert ();
  8799. $receipt->status = 4;
  8800. $receipt->update ( array (
  8801. 'where' => 'rid=' . $rid
  8802. ) );
  8803. // 微信企业号通知
  8804. $this->setWXMsg ( $rid, 2 );
  8805. }
  8806. // echo "ddd";
  8807. return '/approvalExpenses/pendApproval';
  8808. }
  8809. function updateCheReceipt() {
  8810. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8811. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  8812. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  8813. if (! empty ( $rid )) {
  8814. // 操作记录
  8815. Doo::loadModel ( "receipt" );
  8816. $receipt = new receipt ();
  8817. Doo::loadModel ( "receiptLog" );
  8818. $receiptLog = new receiptLog ();
  8819. Doo::loadModel ( "verify" );
  8820. $verify = new verify ();
  8821. $receiptInfo = $receipt->getOne ( array (
  8822. 'where' => 'rid=' . $rid . ' and status=2',
  8823. 'asArray' => true
  8824. ) );
  8825. if (empty ( $receiptInfo )) {
  8826. echo json_encode ( array (
  8827. 'status' => 2
  8828. ) );
  8829. die ();
  8830. }
  8831. $vr = $verify->getOne ( array (
  8832. 'where' => 'vid=' . $receiptInfo ['verify'],
  8833. 'asArray' => true
  8834. ) );
  8835. $jd = json_decode ( $vr ['staff'] );
  8836. $roleId = 0;
  8837. foreach ( $jd as $key => $value ) {
  8838. if ($value [1] == 'ROLE') {
  8839. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  8840. if ($pos !== false) {
  8841. $roleId = $value [0];
  8842. }
  8843. }
  8844. }
  8845. // 审批日志
  8846. // echo $roleId;die;
  8847. if (! empty ( $roleId )) {
  8848. Doo::loadModel ( "role" );
  8849. $role = new role ();
  8850. $roleInfo = $role->getOne ( array (
  8851. 'where' => 'rid=' . $roleId,
  8852. 'asArray' => true
  8853. ) );
  8854. $receiptLog->rolename = $roleInfo ['name'];
  8855. }
  8856. $receiptLog->username = $this->staff [0] ['username'];
  8857. $receiptLog->uid = $this->staff [0] ['sid'];
  8858. $receiptLog->date = date ( "Y-m-d" );
  8859. $receiptLog->opinion = $opinion;
  8860. $receiptLog->img = $this->staff [0] ['avatar'];
  8861. $receiptLog->status = 4;
  8862. $receiptLog->rid = $rid;
  8863. $receiptLog->insert ();
  8864. $receipt->status = 4;
  8865. $receipt->update ( array (
  8866. 'where' => 'rid=' . $rid
  8867. ) );
  8868. // 微信企业号通知
  8869. $this->setWXMsg ( $rid, 2 );
  8870. echo json_encode ( array (
  8871. 'status' => 1
  8872. ) );
  8873. // Header("HTTP/1.1 303 See Other");
  8874. // Header("Location: /approvalExpenses/pendApproval");
  8875. die ();
  8876. }
  8877. echo json_encode ( array (
  8878. 'status' => 2
  8879. ) );
  8880. die ();
  8881. // echo "ddd";
  8882. // return '/saeaBorad';
  8883. }
  8884. function revisePrice() {
  8885. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  8886. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  8887. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8888. // echo $price;die;
  8889. if (! empty ( $rid )) {
  8890. Doo::loadModel ( "receipt" );
  8891. $receipt = new receipt ();
  8892. $receiptDetail = $receipt->getOne ( array (
  8893. 'where' => 'rid=' . $rid . ' and status=2 ',
  8894. 'asArray' => true
  8895. ) );
  8896. if (empty ( $receiptDetail ))
  8897. die ( 'illegal request' );
  8898. $reviseDetail = array ();
  8899. if (empty ( $receiptDetail ['reviseDetail'] )) {
  8900. array_push ( $reviseDetail, array (
  8901. 'sid' => $this->staff [0] ['sid'],
  8902. 'name' => $this->staff [0] ['username'],
  8903. 'description' => $description,
  8904. 'price' => $price
  8905. ) );
  8906. $reviseDetailString = json_encode ( $reviseDetail );
  8907. $receipt->reviseDetail = $reviseDetailString;
  8908. $receipt->revisePrice = $price;
  8909. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  8910. } else {
  8911. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8912. array_push ( $reviseDetail, array (
  8913. 'sid' => $this->staff [0] ['sid'],
  8914. 'name' => $this->staff [0] ['username'],
  8915. 'description' => $description,
  8916. 'price' => $price
  8917. ) );
  8918. $reviseDetailString = json_encode ( $reviseDetail );
  8919. $receipt->reviseDetail = $reviseDetailString;
  8920. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  8921. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  8922. }
  8923. $receipt->update ( array (
  8924. 'where' => 'rid=' . $rid
  8925. ) );
  8926. if ($receiptDetail ['Rtype'] == 1) {
  8927. if ($receiptDetail ['isBK'] == 1) {
  8928. return '/receiptburEdi/' . $receiptDetail ['rid'];
  8929. }
  8930. } elseif ($receiptDetail ['Rtype'] == 2) {
  8931. } else {
  8932. return '/receiptburEdi/' . $receiptDetail ['rid'];
  8933. }
  8934. }
  8935. die ( 'illegal request' );
  8936. }
  8937. function personalCollect() {
  8938. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8939. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  8940. $this->showCache ( $path );
  8941. Doo::loadModel ( "receiptDetail" );
  8942. Doo::loadModel ( "itemStatistics" );
  8943. Doo::loadModel ( 'statistics' );
  8944. $statistics = new statistics ();
  8945. $itemStatistics = new itemStatistics ();
  8946. $receiptDetail = new receiptDetail ();
  8947. $receiptCollectList = $receiptDetail->find ( array (
  8948. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  8949. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  8950. 'groupby' => 'itemCategory,Month(date)',
  8951. 'asArray' => true
  8952. ) );
  8953. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  8954. 'where' => 'staff=' . $this->staff [0] ['sid'],
  8955. 'asArray' => true
  8956. ) );
  8957. // create collect html
  8958. $collectArray = array (
  8959. '日常相关费用' => array (),
  8960. '差旅相关费用' => array (),
  8961. '培训班费用' => array (),
  8962. '其他' => array ()
  8963. );
  8964. $adjustment = array ();
  8965. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  8966. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  8967. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  8968. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  8969. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  8970. array_push ( $collectArray ['培训班费用'], $collectHtml );
  8971. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  8972. array_push ( $collectArray ['其他'], $collectHtml );
  8973. $data ['collectArray'] = $collectArray;
  8974. // statistics html
  8975. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  8976. if (empty ( $stList ))
  8977. $stList = array (
  8978. 'rePrice' => 0,
  8979. 'agPrice' => 0
  8980. );
  8981. $data ['stList'] = array (
  8982. 'rePrice' => $stList ['rePrice'],
  8983. 'agPrice' => $stList ['agPrice'],
  8984. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8985. );
  8986. // Adjustment price html
  8987. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  8988. array_push ( $adjustment, $collectHtml );
  8989. $data ['adjustment'] = $adjustment;
  8990. // total price html
  8991. $collectHtml = "";
  8992. $total = 0;
  8993. for($i = 1; $i <= 12; $i ++) {
  8994. $sumPrice = 0;
  8995. foreach ( $receiptCollectList as $key => $value ) {
  8996. if ($value ['month'] == $i) {
  8997. $sumPrice += $value ['price'];
  8998. }
  8999. }
  9000. if ($sumPrice == 0)
  9001. $collectHtml .= '<td class="taR">-</td>';
  9002. else
  9003. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9004. $total += $sumPrice;
  9005. }
  9006. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9007. $data ['totalPrice'] = $collectHtml;
  9008. $dateHtml = "";
  9009. $now = date ( "Y" );
  9010. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9011. if ($YEARD <= $now) {
  9012. $dateHtml .= '<option ';
  9013. if ($year == $YEARD) {
  9014. $dateHtml .= 'selected ';
  9015. }
  9016. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9017. }
  9018. }
  9019. $data ['dateHtml'] = $dateHtml;
  9020. $data ['year'] = $year;
  9021. $data ['totalYear'] = $total;
  9022. $data ['memu'] = "receipt";
  9023. $data ['staff'] = $this->staff;
  9024. $data ['receiptMemu'] = 'personalCollect';
  9025. $data ['verifyId'] = $this->verifyId;
  9026. $data ['executeId'] = $this->executeId;
  9027. // year staff status 2,4
  9028. if ($year < date ( "Y" )) {
  9029. Doo::loadModel ( 'receipt' );
  9030. $receipt = new receipt ();
  9031. $receiptList = $receipt->find ( array (
  9032. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9033. 'asArray' => true
  9034. ) );
  9035. if (empty ( $receiptList )) {
  9036. ob_start ();
  9037. $this->render ( "/admin/saea_slist_collect", $data );
  9038. $this->cacheFile ( $path );
  9039. die ();
  9040. }
  9041. }
  9042. $this->render ( "/admin/saea_slist_collect", $data );
  9043. }
  9044. function personalCollectDetail() {
  9045. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9046. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  9047. $this->showCache ( $path );
  9048. Doo::loadModel ( "receiptDetail" );
  9049. Doo::loadModel ( "itemStatistics" );
  9050. Doo::loadModel ( 'statistics' );
  9051. Doo::loadModel ( 'accountItem' );
  9052. $accountItem = new accountItem ();
  9053. $statistics = new statistics ();
  9054. $itemStatistics = new itemStatistics ();
  9055. $receiptDetail = new receiptDetail ();
  9056. $receiptCollectList = $receiptDetail->find ( array (
  9057. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9058. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9059. 'groupby' => 'item,Month(date)',
  9060. 'asArray' => true
  9061. ) );
  9062. $accountList = $accountItem->find ( array (
  9063. 'asArray' => true
  9064. ) );
  9065. // create CollectDetail HTML
  9066. $collectHtml = array ();
  9067. foreach ( $accountList as $key => $value ) {
  9068. $html = "";
  9069. $asum = 0;
  9070. for($i = 1; $i <= 12; $i ++) {
  9071. $falg = true;
  9072. foreach ( $receiptCollectList as $v ) {
  9073. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9074. $asum += $v ['price'];
  9075. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9076. $falg = false;
  9077. break;
  9078. }
  9079. }
  9080. if ($falg)
  9081. $html .= '<td class="taR">-</td>';
  9082. }
  9083. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9084. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9085. }
  9086. $data ['collectHtml'] = $collectHtml;
  9087. // create Adjustment price html
  9088. $receiptCollectList = $receiptDetail->find ( array (
  9089. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9090. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9091. 'groupby' => 'itemCategory,Month(date)',
  9092. 'asArray' => true
  9093. ) );
  9094. $adjustment = array ();
  9095. $collectArray = array (
  9096. '日常相关费用' => array (),
  9097. '差旅相关费用' => array (),
  9098. '培训班费用' => array (),
  9099. '其他' => array ()
  9100. );
  9101. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9102. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9103. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9104. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9105. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9106. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9107. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9108. array_push ( $collectArray ['其他'], $collectHtml );
  9109. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9110. array_push ( $adjustment, $collectHtml );
  9111. // total price html
  9112. $collectHtml = "";
  9113. $total = 0;
  9114. for($i = 1; $i <= 12; $i ++) {
  9115. $sumPrice = 0;
  9116. foreach ( $receiptCollectList as $key => $value ) {
  9117. if ($value ['month'] == $i) {
  9118. $sumPrice += $value ['price'];
  9119. }
  9120. }
  9121. if ($sumPrice == 0)
  9122. $collectHtml .= '<td class="taR">-</td>';
  9123. else
  9124. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9125. $total += $sumPrice;
  9126. }
  9127. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9128. // statistics html
  9129. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9130. if (empty ( $stList ))
  9131. $stList = array (
  9132. 'rePrice' => 0,
  9133. 'agPrice' => 0
  9134. );
  9135. $data ['stList'] = array (
  9136. 'rePrice' => $stList ['rePrice'],
  9137. 'agPrice' => $stList ['agPrice'],
  9138. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9139. );
  9140. $data ['collectArray'] = $collectArray;
  9141. $data ['adjustment'] = $adjustment;
  9142. $data ['totalPrice'] = $collectHtml;
  9143. $data ['totalYear'] = $total;
  9144. $data ['year'] = $year;
  9145. $dateHtml = "";
  9146. $now = date ( "Y" );
  9147. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9148. if ($YEARD <= $now) {
  9149. $dateHtml .= '<option ';
  9150. if ($year == $YEARD) {
  9151. $dateHtml .= 'selected ';
  9152. }
  9153. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9154. }
  9155. }
  9156. $data ['dateHtml'] = $dateHtml;
  9157. $data ['memu'] = "receipt";
  9158. $data ['staff'] = $this->staff;
  9159. $data ['receiptMemu'] = 'personalCollect';
  9160. $data ['verifyId'] = $this->verifyId;
  9161. $data ['executeId'] = $this->executeId;
  9162. // year staff status 2,4
  9163. if ($year < date ( "Y" )) {
  9164. Doo::loadModel ( 'receipt' );
  9165. $receipt = new receipt ();
  9166. $receiptList = $receipt->find ( array (
  9167. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9168. 'asArray' => true
  9169. ) );
  9170. if (empty ( $receiptList )) {
  9171. ob_start ();
  9172. $this->render ( "/admin/saeaCollectArticles", $data );
  9173. $this->cacheFile ( $path );
  9174. die ();
  9175. }
  9176. }
  9177. $this->render ( "/admin/saeaCollectArticles", $data );
  9178. }
  9179. function companyCategoryCollect() {
  9180. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9181. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  9182. $this->showCache ( $path );
  9183. Doo::loadModel ( 'L_category' );
  9184. Doo::loadModel ( 'itemStatistics' );
  9185. Doo::loadModel ( 'statistics' );
  9186. $statistics = new statistics ();
  9187. $Lcategory = new L_category ();
  9188. $itemStatistics = new itemStatistics ();
  9189. Doo::loadModel ( "receiptAuthorityManage" );
  9190. $receiptAuthorityManage = new receiptAuthorityManage ();
  9191. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9192. $cidList = array ();
  9193. foreach ( $imcStaff as $key => $value ) {
  9194. array_push ( $cidList, $value ['cid'] );
  9195. }
  9196. $cidString = implode ( ',', $cidList );
  9197. $LcategoryList = $Lcategory->find ( array (
  9198. 'where' => ' cid in (' . $cidString . ')',
  9199. 'asArray' => true
  9200. ) ); // 'staff='.$this->staff[0]['sid']." and
  9201. $itemStatisticsList = $itemStatistics->find ( array (
  9202. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9203. 'where' => " Year(date)=" . $year,
  9204. 'groupby' => 'cid,Month(date)',
  9205. 'asArray' => true
  9206. ) );
  9207. // ceatre companyCollectHtml
  9208. foreach ( $LcategoryList as $value ) {
  9209. $html = "";
  9210. $asum = 0;
  9211. for($i = 1; $i <= 12; $i ++) {
  9212. $falg = true;
  9213. foreach ( $itemStatisticsList as $v ) {
  9214. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  9215. $asum += $v ['price'];
  9216. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9217. $falg = false;
  9218. break;
  9219. }
  9220. }
  9221. if ($falg)
  9222. $html .= '<td class="taR">-</td>';
  9223. }
  9224. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9225. $collectHtml [$value ['title']] = array (
  9226. 'html' => $html,
  9227. 'cid' => $value ['cid']
  9228. );
  9229. }
  9230. $data ['companyHtml'] = $collectHtml;
  9231. // total price html
  9232. $collectHtml = "";
  9233. $total = 0;
  9234. for($i = 1; $i <= 12; $i ++) {
  9235. $sumPrice = 0;
  9236. foreach ( $itemStatisticsList as $key => $value ) {
  9237. if ($value ['month'] == $i) {
  9238. $sumPrice += $value ['price'];
  9239. }
  9240. }
  9241. if ($sumPrice == 0)
  9242. $collectHtml .= '<td class="taR">-</td>';
  9243. else
  9244. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9245. $total += $sumPrice;
  9246. }
  9247. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9248. $data ['companyTotalHtml'] = $collectHtml;
  9249. $data ['total'] = $total;
  9250. // statistics html
  9251. // echo $cidString;
  9252. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9253. if (empty ( $stList ))
  9254. $stList = array (
  9255. 'rePrice' => 0,
  9256. 'agPrice' => 0
  9257. );
  9258. $data ['stList'] = array (
  9259. 'rePrice' => $stList ['rePrice'],
  9260. 'agPrice' => $stList ['agPrice'],
  9261. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9262. );
  9263. $data ['year'] = $year;
  9264. $data ['memu'] = "receipt";
  9265. $data ['staff'] = $this->staff;
  9266. $data ['receiptMemu'] = 'companyCategoryCollect';
  9267. $data ['verifyId'] = $this->verifyId;
  9268. $data ['executeId'] = $this->executeId;
  9269. $dateHtml = "";
  9270. $now = date ( "Y" );
  9271. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9272. if ($YEARD <= $now) {
  9273. $dateHtml .= '<option ';
  9274. if ($year == $YEARD) {
  9275. $dateHtml .= 'selected ';
  9276. }
  9277. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9278. }
  9279. }
  9280. $data ['dateHtml'] = $dateHtml;
  9281. // year staff status 2,4
  9282. if ($year < date ( "Y" )) {
  9283. Doo::loadModel ( 'receipt' );
  9284. $receipt = new receipt ();
  9285. $receiptList = $receipt->find ( array (
  9286. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  9287. 'asArray' => true
  9288. ) );
  9289. if (empty ( $receiptList )) {
  9290. ob_start ();
  9291. $this->render ( "/admin/saeaCompanyCollect", $data );
  9292. $this->cacheFile ( $path );
  9293. die ();
  9294. }
  9295. }
  9296. $this->render ( "/admin/saeaCompanyCollect", $data );
  9297. }
  9298. function categoryCollectDetail() {
  9299. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9300. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  9301. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  9302. $this->showCache ( $path );
  9303. Doo::loadModel ( 'statistics' );
  9304. $statistics = new statistics ();
  9305. Doo::loadModel ( "receiptDetail" );
  9306. $receiptDetail = new receiptDetail ();
  9307. Doo::loadModel ( 'L_category' );
  9308. $Lcategory = new L_category ();
  9309. Doo::loadModel ( 'accountItem' );
  9310. $accountItem = new accountItem ();
  9311. Doo::loadModel ( "receiptAuthorityManage" );
  9312. $receiptAuthorityManage = new receiptAuthorityManage ();
  9313. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9314. $cidList = array ();
  9315. foreach ( $imcStaff as $key => $value ) {
  9316. array_push ( $cidList, $value ['cid'] );
  9317. }
  9318. $cidString = implode ( ',', $cidList );
  9319. $LcategoryList = $Lcategory->find ( array (
  9320. 'where' => 'cid in (' . $cidString . ')',
  9321. 'asArray' => true
  9322. ) );
  9323. if ($cid == 0) {
  9324. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9325. if ($cid == 0)
  9326. $cid = $LcategoryList [0] ['cid'];
  9327. }
  9328. $data ['LcategoryList'] = $LcategoryList;
  9329. $receiptCollectList = $receiptDetail->find ( array (
  9330. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9331. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9332. 'groupby' => 'item,Month(pastDate)',
  9333. 'asArray' => true
  9334. ) );
  9335. $accountList = $accountItem->find ( array (
  9336. 'asArray' => true
  9337. ) );
  9338. // create CollectDetail HTML
  9339. $collectHtml = array ();
  9340. foreach ( $accountList as $key => $value ) {
  9341. $html = "";
  9342. $asum = 0;
  9343. for($i = 1; $i <= 12; $i ++) {
  9344. $falg = true;
  9345. foreach ( $receiptCollectList as $v ) {
  9346. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9347. $asum += $v ['price'];
  9348. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9349. $falg = false;
  9350. break;
  9351. }
  9352. }
  9353. if ($falg)
  9354. $html .= '<td class="taR">-</td>';
  9355. }
  9356. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9357. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9358. }
  9359. $data ['collectHtml'] = $collectHtml;
  9360. // create Adjustment price html
  9361. $receiptCollectList = $receiptDetail->find ( array (
  9362. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9363. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9364. 'groupby' => 'itemCategory,Month(pastDate)',
  9365. 'asArray' => true
  9366. ) );
  9367. $adjustment = array ();
  9368. $collectArray = array (
  9369. '日常相关费用' => array (),
  9370. '差旅相关费用' => array (),
  9371. '培训班费用' => array (),
  9372. '其他' => array ()
  9373. );
  9374. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9375. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9376. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9377. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9378. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9379. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9380. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9381. array_push ( $collectArray ['其他'], $collectHtml );
  9382. $data ['collectArray'] = $collectArray;
  9383. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9384. array_push ( $adjustment, $collectHtml );
  9385. $data ['adjustment'] = $adjustment;
  9386. // total price html
  9387. $collectHtml = "";
  9388. $total = 0;
  9389. for($i = 1; $i <= 12; $i ++) {
  9390. $sumPrice = 0;
  9391. foreach ( $receiptCollectList as $key => $value ) {
  9392. if ($value ['month'] == $i) {
  9393. $sumPrice += $value ['price'];
  9394. }
  9395. }
  9396. if ($sumPrice == 0)
  9397. $collectHtml .= '<td class="taR">-</td>';
  9398. else
  9399. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9400. $total += $sumPrice;
  9401. }
  9402. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9403. // statistics html
  9404. $stList = $statistics->statisticsByCid ( $year, $cid );
  9405. if (empty ( $stList ))
  9406. $stList = array (
  9407. 'rePrice' => 0,
  9408. 'agPrice' => 0
  9409. );
  9410. $data ['stList'] = array (
  9411. 'rePrice' => $stList ['rePrice'],
  9412. 'agPrice' => $stList ['agPrice'],
  9413. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9414. );
  9415. $data ['totalYear'] = $total;
  9416. $data ['year'] = $year;
  9417. $data ['cid'] = $cid;
  9418. $data ['memu'] = "receipt";
  9419. $data ['staff'] = $this->staff;
  9420. $data ['receiptMemu'] = 'companyCategoryCollect';
  9421. $data ['verifyId'] = $this->verifyId;
  9422. $data ['executeId'] = $this->executeId;
  9423. // year staff status 2,4
  9424. if ($year < date ( "Y" )) {
  9425. Doo::loadModel ( 'receipt' );
  9426. $receipt = new receipt ();
  9427. $receiptList = $receipt->find ( array (
  9428. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  9429. 'asArray' => true
  9430. ) );
  9431. if (empty ( $receiptList )) {
  9432. ob_start ();
  9433. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  9434. $this->cacheFile ( $path );
  9435. die ();
  9436. }
  9437. }
  9438. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  9439. }
  9440. function staffCollect() {
  9441. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9442. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ONJOB';//
  9443. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  9444. // $this->showCache($path);
  9445. Doo::loadModel ( 'statistics' );
  9446. $statistics = new statistics ();
  9447. Doo::loadModel ( "receiptDetail" );
  9448. $receiptDetail = new receiptDetail ();
  9449. Doo::loadModel ( 'L_category' );
  9450. $Lcategory = new L_category ();
  9451. Doo::loadModel ( 'accountItem' );
  9452. $accountItem = new accountItem ();
  9453. Doo::loadModel ( 'staff' );
  9454. $staff = new staff ();
  9455. Doo::loadModel ( 'itemStatistics' );
  9456. $itemStatistics = new itemStatistics ();
  9457. Doo::loadModel ( "receiptAuthorityManage" );
  9458. $receiptAuthorityManage = new receiptAuthorityManage ();
  9459. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9460. $cidList = array ();
  9461. foreach ( $imcStaff as $key => $value ) {
  9462. array_push ( $cidList, $value ['cid'] );
  9463. }
  9464. $cidString = implode ( ',', $cidList );
  9465. $naturecon='';
  9466. if ($nature=='ONJOB'){
  9467. $naturecon=' and (nature!=4 )';
  9468. }elseif($nature=='LEAVEJOB'){
  9469. $naturecon=' and (nature=4 )';
  9470. }else{
  9471. die ( 'illegal request--nature' );
  9472. }
  9473. // statistics html
  9474. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9475. if (empty ( $stList ))
  9476. $stList = array (
  9477. 'rePrice' => 0,
  9478. 'agPrice' => 0
  9479. );
  9480. $data ['stList'] = array (
  9481. 'rePrice' => $stList ['rePrice'],
  9482. 'agPrice' => $stList ['agPrice'],
  9483. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9484. );
  9485. // ---
  9486. $staffList = $staff->find ( array (
  9487. 'where' => 'username !="admin" '.$naturecon,
  9488. 'asArray' => true
  9489. ) );
  9490. $LcategoryList = $Lcategory->find ( array (
  9491. 'asArray' => true
  9492. ) ); // 'staff='.$this->staff[0]['sid']." and
  9493. $itemStatisticsList = $itemStatistics->find ( array (
  9494. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9495. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  9496. 'groupby' => 'staff,Month(date)',
  9497. 'asArray' => true
  9498. ) );
  9499. $categoryList = $staff->find ( array (
  9500. 'select' => 'COUNT(*) as count,cid,category',
  9501. 'where' => 'username !="admin" and cid in (' . $cidString . ') '.$naturecon,
  9502. 'groupby' => 'cid',
  9503. 'asArray' => true
  9504. ) );
  9505. // print_r($itemStatisticsList);die;
  9506. // ceatre companyCollectHtml
  9507. foreach ( $categoryList as $vlu ) {
  9508. $count = $vlu ['count'] + 1;
  9509. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  9510. $m1 = 0;
  9511. $m2 = 0;
  9512. $m3 = 0;
  9513. $m4 = 0;
  9514. $m5 = 0;
  9515. $m6 = 0;
  9516. $m7 = 0;
  9517. $m8 = 0;
  9518. $m9 = 0;
  9519. $m10 = 0;
  9520. $m11 = 0;
  9521. $m12 = 0;
  9522. $m13 = 0;
  9523. foreach ( $staffList as $value ) {
  9524. if ($vlu ['cid'] == $value ['cid']) {
  9525. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  9526. $asum = 0;
  9527. for($i = 1; $i <= 12; $i ++) {
  9528. $falg = true;
  9529. foreach ( $itemStatisticsList as $v ) {
  9530. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  9531. if ($v ['month'] == 1)
  9532. $m1 += $v ['price'];
  9533. if ($v ['month'] == 2)
  9534. $m2 += $v ['price'];
  9535. if ($v ['month'] == 3)
  9536. $m3 += $v ['price'];
  9537. if ($v ['month'] == 4)
  9538. $m4 += $v ['price'];
  9539. if ($v ['month'] == 5)
  9540. $m5 += $v ['price'];
  9541. if ($v ['month'] == 6)
  9542. $m6 += $v ['price'];
  9543. if ($v ['month'] == 7)
  9544. $m7 += $v ['price'];
  9545. if ($v ['month'] == 8)
  9546. $m8 += $v ['price'];
  9547. if ($v ['month'] == 9)
  9548. $m9 += $v ['price'];
  9549. if ($v ['month'] == 10)
  9550. $m10 += $v ['price'];
  9551. if ($v ['month'] == 11)
  9552. $m11 += $v ['price'];
  9553. if ($v ['month'] == 12)
  9554. $m12 += $v ['price'];
  9555. $asum += $v ['price'];
  9556. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9557. $falg = false;
  9558. break;
  9559. }
  9560. }
  9561. if ($falg)
  9562. $html .= '<td class="taR">-</td>';
  9563. }
  9564. $m13 += $asum;
  9565. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9566. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  9567. 'html' => $html,
  9568. 'sid' => $value ['sid']
  9569. );
  9570. $html = "";
  9571. }
  9572. }
  9573. $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>
  9574. <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>
  9575. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  9576. $collectHtml [$vlu ['cid']] = array (
  9577. 'html' => $hl,
  9578. 'sid' => ''
  9579. );
  9580. }
  9581. $data ['companyHtml'] = $collectHtml;
  9582. // total price html
  9583. $collectHtml = "";
  9584. $total = 0;
  9585. for($i = 1; $i <= 12; $i ++) {
  9586. $sumPrice = 0;
  9587. foreach ( $itemStatisticsList as $key => $value ) {
  9588. if ($value ['month'] == $i) {
  9589. $sumPrice += $value ['price'];
  9590. }
  9591. }
  9592. if ($sumPrice == 0)
  9593. $collectHtml .= '<td class="taR">-</td>';
  9594. else
  9595. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9596. $total += $sumPrice;
  9597. }
  9598. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9599. $data ['companyTotalHtml'] = $collectHtml;
  9600. $data ['total'] = $total;
  9601. $data ['nature'] =$nature;
  9602. $data ['year'] = $year;
  9603. $data ['memu'] = "receipt";
  9604. $data ['staff'] = $this->staff;
  9605. $data ['receiptMemu'] = 'companyCategoryCollect';
  9606. $data ['verifyId'] = $this->verifyId;
  9607. $data ['executeId'] = $this->executeId;
  9608. if ($year <= date ( "Y" )) {
  9609. Doo::loadModel ( 'receipt' );
  9610. $receipt = new receipt ();
  9611. $receiptList = $receipt->find ( array (
  9612. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  9613. 'asArray' => true
  9614. ) );
  9615. if (empty ( $receiptList )) { // generated files
  9616. ob_start ();
  9617. $this->render ( "/admin/saeaStaffCollectB", $data );
  9618. $this->cacheFile ( $path );
  9619. die ();
  9620. }
  9621. }
  9622. $this->render ( "/admin/saeaStaffCollectB", $data );
  9623. }
  9624. function staffCollectBak() {
  9625. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9626. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  9627. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  9628. $this->showCache ( $path );
  9629. Doo::loadModel ( 'statistics' );
  9630. $statistics = new statistics ();
  9631. Doo::loadModel ( "receiptDetail" );
  9632. $receiptDetail = new receiptDetail ();
  9633. Doo::loadModel ( 'L_category' );
  9634. $Lcategory = new L_category ();
  9635. Doo::loadModel ( 'accountItem' );
  9636. $accountItem = new accountItem ();
  9637. Doo::loadModel ( 'staff' );
  9638. $staff = new staff ();
  9639. Doo::loadModel ( 'itemStatistics' );
  9640. $itemStatistics = new itemStatistics ();
  9641. $itemStatisticsList = $itemStatistics->find ( array (
  9642. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9643. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9644. 'groupby' => 'staff,itemCategory,Month(date)',
  9645. 'asArray' => true
  9646. ) );
  9647. $itemCategoryList = $itemStatistics->find ( array (
  9648. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9649. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9650. 'groupby' => 'cid,itemCategory,Month(date)',
  9651. 'asArray' => true
  9652. ) );
  9653. $LcategoryList = $Lcategory->find ( array (
  9654. 'asArray' => true
  9655. ) );
  9656. $staffList = $staff->find ( array (
  9657. 'asArray' => true
  9658. ) );
  9659. $htmlArray = array ();
  9660. foreach ( $LcategoryList as $value ) {
  9661. $htmlArray [$value ['title']] = array ();
  9662. foreach ( $staffList as $v ) {
  9663. if ($value ['cid'] == $v ['cid']) {
  9664. $html = "";
  9665. $falg = true;
  9666. $staffSumPrice = 0;
  9667. foreach ( $itemStatisticsList as $a ) {
  9668. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  9669. if (empty ( $a ['price'] )) {
  9670. $html .= '<td class="taR">-</td>';
  9671. $falg = false;
  9672. break;
  9673. } else {
  9674. $staffSumPrice += $a ['price'];
  9675. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9676. $falg = false;
  9677. break;
  9678. }
  9679. }
  9680. }
  9681. if ($falg) {
  9682. $html .= '<td class="taR">-</td>';
  9683. $falg = true;
  9684. }
  9685. $falg = true;
  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. $staffSumPrice += $a ['price'];
  9728. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9729. $falg = false;
  9730. break;
  9731. } else {
  9732. $html .= '<td class="taR">-</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. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  9762. $htmlArray [$value ['title']] [$v ['username']] = $html;
  9763. }
  9764. }
  9765. /* -- --- */
  9766. // 合计费用
  9767. $cateHtml = "";
  9768. $catePrice = 0;
  9769. $cateFalg = true;
  9770. foreach ( $itemCategoryList as $l ) {
  9771. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  9772. if (empty ( $l ['price'] )) {
  9773. $cateHtml .= '<td class="colGreen taR">-</td>';
  9774. $cateFalg = false;
  9775. break;
  9776. } else {
  9777. $catePrice += $l ['price'];
  9778. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9779. $cateFalg = false;
  9780. break;
  9781. }
  9782. }
  9783. }
  9784. if ($cateFalg) {
  9785. $cateHtml .= '<td class="colGreen taR">-</td>';
  9786. $cateFalg = true;
  9787. }
  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. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  9865. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  9866. /* -- --- */
  9867. }
  9868. // print_r($htmlArray);die;
  9869. $data ['htmlArray'] = $htmlArray;
  9870. // statistics html
  9871. $stList = $statistics->getOne ( array (
  9872. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9873. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9874. 'groupby' => 'Month(date)',
  9875. 'asArray' => true
  9876. ) );
  9877. if (empty ( $stList ))
  9878. $stList = array (
  9879. 'rePrice' => 0,
  9880. 'agPrice' => 0
  9881. );
  9882. $data ['stList'] = array (
  9883. 'rePrice' => $stList ['rePrice'],
  9884. 'agPrice' => $stList ['agPrice'],
  9885. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9886. );
  9887. $monthHtml = "";
  9888. for($i = 1; $i <= 12; $i ++) {
  9889. if ($i == $month)
  9890. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9891. else
  9892. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9893. }
  9894. $data ['monthHtml'] = $monthHtml;
  9895. $data ['year'] = $year;
  9896. $data ['month'] = $month;
  9897. $data ['memu'] = "receipt";
  9898. $data ['staff'] = $this->staff;
  9899. $data ['receiptMemu'] = 'companyCategoryCollect';
  9900. $data ['verifyId'] = $this->verifyId;
  9901. $data ['executeId'] = $this->executeId;
  9902. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  9903. Doo::loadModel ( 'receipt' );
  9904. $receipt = new receipt ();
  9905. $receiptList = $receipt->find ( array (
  9906. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  9907. 'asArray' => true
  9908. ) );
  9909. if (empty ( $receiptList )) { // generated files
  9910. ob_start ();
  9911. $this->render ( "/admin/saeaStaffCollect", $data );
  9912. $this->cacheFile ( $path );
  9913. die ();
  9914. }
  9915. }
  9916. $this->render ( "/admin/saeaStaffCollect", $data );
  9917. }
  9918. /**
  9919. * 日常收支
  9920. */
  9921. function payments() {
  9922. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  9923. Doo::loadModel ( "execute" );
  9924. $execute = new execute ();
  9925. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  9926. die ( 'illegal request' );
  9927. }
  9928. Doo::loadModel ( "accountBook" );
  9929. $accountBook = new accountBook ();
  9930. Doo::loadModel ( "accountBookStatistics" );
  9931. $accountBookStatistics = new accountBookStatistics ();
  9932. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  9933. $list = $accountBook->getAccountBookByLimit ( 10 );
  9934. $data ['date'] = date ( "Y-m-d" );
  9935. $data ['statisticsList'] = $statisticsList;
  9936. $data ['list'] = $list;
  9937. $data ['memu'] = "receipt";
  9938. $data ['staff'] = $this->staff;
  9939. $data ['receiptMemu'] = 'payments';
  9940. $data ['verifyId'] = $this->verifyId;
  9941. $data ['executeId'] = $this->executeId;
  9942. $this->render ( "/expenses/payments", $data );
  9943. }
  9944. function paymentsIncomeDo() {
  9945. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  9946. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  9947. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  9948. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  9949. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  9950. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  9951. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  9952. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  9953. Doo::loadClass ( 'XDeode' );
  9954. $XDeode = new XDeode ( 5 );
  9955. Doo::loadModel ( "accountBook" );
  9956. Doo::loadModel ( "accountBookStatistics" );
  9957. Doo::loadModel ( 'wasteBook' );
  9958. // 记录流水时银行的转换
  9959. $accountBank = '';
  9960. if ($receivedBank == '纵横广发') {
  9961. $accountBank = 'CGBDeposit';
  9962. } elseif ($receivedBank == '纵横工行') {
  9963. $accountBank = 'ICBCDeposit';
  9964. } elseif ($receivedBank == '华润银行') {
  9965. $accountBank = 'HUADeposit';
  9966. } elseif ($receivedBank == '个人广发') {
  9967. $accountBank = 'PersonalDeposit';
  9968. }
  9969. if (empty ( $accountBank ))
  9970. die ( 'illegal request' );
  9971. // 收入为理财时特殊处理
  9972. if ($accountType == 7 || $accountType == 9) {
  9973. if ($receivedBank == '个人广发') {
  9974. die ( '个人广发 illegal request' );
  9975. }
  9976. // 添加一条收入
  9977. $accountBook = new accountBook ();
  9978. $accountBook->accountType = 10;
  9979. $accountBook->accountMsg = $accountMsg;
  9980. $accountBook->receivedPrice = $receivedPrice;
  9981. $accountBook->receivedMsg = $receivedMsg;
  9982. $accountBook->receivedBank = $receivedBank;
  9983. $accountBook->receivedDate = $receivedDate;
  9984. $accountBook->remarks = $remarks;
  9985. $accountBook->expensesType = 1;
  9986. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9987. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9988. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9989. $inComeId = $accountBook->insert ();
  9990. // 收支汇总-添加一条收入日常汇总
  9991. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  9992. $accountBookStatistics = new accountBookStatistics ();
  9993. $item = array (
  9994. 'date' => date ( "Y-m-d" ),
  9995. 'accountType' => $abDetail ['accountType'],
  9996. 'accountMsg' => $abDetail ['accountMsg'],
  9997. 'aid' => $abDetail ['aid'],
  9998. 'inComePrice' => $abDetail ['receivedPrice'],
  9999. 'expensesType' => $abDetail ['expensesType']
  10000. );
  10001. $accountBookStatistics->setAccountBookStatistics ( $item );
  10002. // 添加收入流水
  10003. $wasteBook = new wasteBook ();
  10004. $itemWaste = array (
  10005. 'accountPriceShow' => $receivedPrice,
  10006. 'accountPrice' => $receivedPrice,
  10007. 'expensesType' => 1,
  10008. 'accountType' => 6, // 流水类型
  10009. 'dataID' => $inComeId,
  10010. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10011. 'accountBank' => $accountBank,
  10012. 'category' => $this->staff [0] ['category'],
  10013. 'cid' => $this->staff [0] ['cid'],
  10014. 'name' => $this->staff [0] ['username'],
  10015. 'sid' => $this->staff [0] ['sid'],
  10016. 'inputDate' => date ( "Y-m-d H:i:s" )
  10017. );
  10018. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10019. // 添加一条理财支出
  10020. $accountBank = 'CGBDeposit';
  10021. $expenditureBank = '纵横广发';
  10022. $dailyExpenditureType = 4;
  10023. if ($accountType == 9) {
  10024. $accountBank = 'ICBCDeposit';
  10025. $expenditureBank = '纵横工行';
  10026. $dailyExpenditureType = 6;
  10027. }
  10028. $accountBook = new accountBook ();
  10029. $accountBook->expensesType = 2;
  10030. $accountBook->expenditureType = $dailyExpenditureType;
  10031. $accountBook->expenditureMsg = $accountMsg;
  10032. $accountBook->expenditurePrice = $receivedPrice;
  10033. $accountBook->expenditureBank = $expenditureBank;
  10034. $accountBook->expenditureDate = $receivedDate;
  10035. $accountBook->remarks = $remarks;
  10036. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10037. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10038. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10039. $id = $accountBook->insert ();
  10040. // 收支汇总-添加一条理财支出汇总
  10041. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10042. $accountBookStatistics = new accountBookStatistics ();
  10043. $item = array (
  10044. 'date' => date ( "Y-m-d" ),
  10045. 'accountType' => $abDetail ['accountType'],
  10046. 'accountMsg' => $abDetail ['accountMsg'],
  10047. 'aid' => $abDetail ['aid'],
  10048. 'financingPrice' => - $receivedPrice,
  10049. 'expensesType' => 3
  10050. );
  10051. $accountBookStatistics->setAccountBookStatistics ( $item );
  10052. // 添加一条支出理财流水
  10053. $accountTypeWaste = 5;
  10054. if ($accountMsg == '公司固定') {
  10055. $accountTypeWaste = 9;
  10056. } elseif ($accountMsg == '公司活期') {
  10057. $accountTypeWaste = 10;
  10058. } elseif ($accountMsg == '个人(GR)') {
  10059. $accountBank = 'PersonalDeposit';
  10060. }
  10061. $itemWaste = array (
  10062. 'expensesType' => 2,
  10063. 'accountType' => $accountTypeWaste,
  10064. 'accountPriceShow' => $receivedPrice,
  10065. 'accountPrice' => - $receivedPrice,
  10066. 'dataID' => $id,
  10067. 'dailyExpenditureType' => $dailyExpenditureType,
  10068. 'accountBank' => $accountBank,
  10069. 'category' => $this->staff [0] ['category'],
  10070. 'cid' => $this->staff [0] ['cid'],
  10071. 'name' => $this->staff [0] ['username'],
  10072. 'sid' => $this->staff [0] ['sid'],
  10073. 'inputDate' => date ( "Y-m-d H:i:s" )
  10074. );
  10075. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10076. } elseif ($accountType == 1) {
  10077. if ($receivedBank == '个人广发')
  10078. die ( 'illegal request' );
  10079. // 添加一条收入
  10080. $accountBook = new accountBook ();
  10081. $accountBook->accountType = $accountType;
  10082. $accountBook->accountMsg = $accountMsg;
  10083. $accountBook->receivedPrice = $receivedPrice;
  10084. $accountBook->receivedMsg = $receivedMsg;
  10085. $accountBook->receivedBank = $receivedBank;
  10086. $accountBook->receivedDate = $receivedDate;
  10087. $accountBook->remarks = $remarks;
  10088. $accountBook->expensesType = 1;
  10089. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10090. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10091. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10092. $id = $accountBook->insert ();
  10093. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10094. // 收支汇总-添加一条收入日常汇总
  10095. $accountBookStatistics = new accountBookStatistics ();
  10096. $item = array (
  10097. 'date' => date ( "Y-m-d" ),
  10098. 'accountType' => $abDetail ['accountType'],
  10099. 'accountMsg' => $abDetail ['accountMsg'],
  10100. 'aid' => $abDetail ['aid'],
  10101. 'expensesType' => $abDetail ['expensesType']
  10102. );
  10103. if ($abDetail ['accountType'] == 8) {
  10104. $item += array (
  10105. 'inComePrice' => $abDetail ['receivedPrice']
  10106. );
  10107. } else {
  10108. $item += array (
  10109. 'inComePrice' => $abDetail ['receivedPrice']
  10110. );
  10111. }
  10112. $accountBookStatistics->setAccountBookStatistics ( $item );
  10113. // 流水存储方向
  10114. $itemWaste = array (
  10115. 'accountType' => 6
  10116. ); // 流水类型
  10117. // if($accountMsg=='银行存款'||$accountMsg=='固定理财收益'){
  10118. // }else
  10119. if ($accountMsg == '活期理财收益') {
  10120. $itemWaste = array (
  10121. 'accountType' => 10
  10122. ); // 流水类型
  10123. }
  10124. // 添加收入流水
  10125. $wasteBook = new wasteBook ();
  10126. $itemWaste += array (
  10127. 'accountPrice' => $receivedPrice,
  10128. 'accountPriceShow' => $receivedPrice,
  10129. 'expensesType' => 1,
  10130. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10131. 'dataID' => $id,
  10132. 'accountBank' => $accountBank,
  10133. 'category' => $this->staff [0] ['category'],
  10134. 'cid' => $this->staff [0] ['cid'],
  10135. 'name' => $this->staff [0] ['username'],
  10136. 'sid' => $this->staff [0] ['sid'],
  10137. 'inputDate' => date ( "Y-m-d H:i:s" )
  10138. );
  10139. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10140. } else { // 普通日常收入处理
  10141. // 添加一条收入
  10142. $accountBook = new accountBook ();
  10143. $accountBook->accountType = $accountType;
  10144. $accountBook->accountMsg = $accountMsg;
  10145. $accountBook->receivedPrice = $receivedPrice;
  10146. $accountBook->receivedMsg = $receivedMsg;
  10147. $accountBook->receivedBank = $receivedBank;
  10148. $accountBook->receivedDate = $receivedDate;
  10149. $accountBook->remarks = $remarks;
  10150. $accountBook->expensesType = 1;
  10151. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10152. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10153. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10154. $id = $accountBook->insert ();
  10155. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10156. // 收支汇总-添加一条收入日常汇总
  10157. $accountBookStatistics = new accountBookStatistics ();
  10158. $item = array (
  10159. 'date' => date ( "Y-m-d" ),
  10160. 'accountType' => $abDetail ['accountType'],
  10161. 'accountMsg' => $abDetail ['accountMsg'],
  10162. 'aid' => $abDetail ['aid'],
  10163. 'expensesType' => $abDetail ['expensesType']
  10164. );
  10165. if ($abDetail ['accountType'] == 8) {
  10166. $item += array (
  10167. 'inComePrice' => $abDetail ['receivedPrice']
  10168. );
  10169. } else {
  10170. $item += array (
  10171. 'inComePrice' => $abDetail ['receivedPrice']
  10172. );
  10173. }
  10174. $accountBookStatistics->setAccountBookStatistics ( $item );
  10175. // 添加收入流水
  10176. $itemWaste = array (
  10177. 'accountPrice' => $receivedPrice
  10178. );
  10179. if ($receivedBank == '个人广发') {
  10180. $itemWaste = array (
  10181. 'accountPrice' => - $receivedPrice
  10182. );
  10183. }
  10184. $wasteBook = new wasteBook ();
  10185. $itemWaste += array (
  10186. 'accountPriceShow' => $receivedPrice,
  10187. 'expensesType' => 1,
  10188. 'accountType' => 6, // 流水类型
  10189. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10190. 'dataID' => $id,
  10191. 'accountBank' => $accountBank,
  10192. 'category' => $this->staff [0] ['category'],
  10193. 'cid' => $this->staff [0] ['cid'],
  10194. 'name' => $this->staff [0] ['username'],
  10195. 'sid' => $this->staff [0] ['sid'],
  10196. 'inputDate' => date ( "Y-m-d H:i:s" )
  10197. );
  10198. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10199. }
  10200. }
  10201. return '/payments';
  10202. }
  10203. /**
  10204. * 添加收入
  10205. * @return string
  10206. */
  10207. function paymentsIncomeDo_() {
  10208. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10209. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10210. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10211. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10212. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10213. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10214. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10215. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10216. Doo::loadClass ( 'XDeode' );
  10217. $XDeode = new XDeode ( 5 );
  10218. Doo::loadModel ( "accountBook" );
  10219. $accountBook = new accountBook ();
  10220. $accountBank = '';
  10221. $accountTypeWaste = 6;
  10222. if ($receivedBank == '纵横广发') {
  10223. $accountBank = 'CGBDeposit';
  10224. } elseif ($receivedBank == '纵横工行') {
  10225. $accountBank = 'ICBCDeposit';
  10226. } elseif ($receivedBank == '华润银行') {
  10227. $accountBank = 'HUADeposit';
  10228. } elseif ($receivedBank == '个人广发') {
  10229. $accountBank = 'PersonalDeposit';
  10230. }
  10231. if (empty ( $accountBank ))
  10232. die ( 'illegal request' );
  10233. $dailyIncomeType = '';
  10234. $itemWaste = array (
  10235. 'accountPrice' => $receivedPrice,
  10236. 'expensesType' => 1
  10237. );
  10238. if ($receivedBank == '个人广发') {
  10239. $itemWaste = array (
  10240. 'accountPrice' => - $receivedPrice,
  10241. 'expensesType' => 1
  10242. );
  10243. }
  10244. if ($accountType == 4) {
  10245. $dailyIncomeType = 4;
  10246. } elseif ($accountType == 1) {
  10247. $dailyIncomeType = 1;
  10248. } elseif ($accountType == 2) {
  10249. $dailyIncomeType = 2;
  10250. } elseif ($accountType == 3) {
  10251. $dailyIncomeType = 3;
  10252. } elseif ($accountType == 5) {
  10253. $dailyIncomeType = 5;
  10254. } elseif ($accountType == 6) {
  10255. $dailyIncomeType = 6;
  10256. } elseif ($accountType == 7 || $accountType == 9) {
  10257. $dailyIncomeType = 7;
  10258. if ($accountMsg == '公司固定') {
  10259. $accountTypeWaste = 9;
  10260. } elseif ($accountMsg == '公司活期') {
  10261. $accountTypeWaste = 10;
  10262. } elseif ($accountMsg == '个人(GR)') {
  10263. $accountBank = 'PersonalDeposit';
  10264. }
  10265. $itemWaste = array (
  10266. 'accountPrice' => - $receivedPrice,
  10267. 'expensesType' => 2
  10268. );
  10269. } elseif ($accountType == 8) {
  10270. $dailyIncomeType = 8;
  10271. }
  10272. if (empty ( $dailyIncomeType ))
  10273. die ( 'illegal request' );
  10274. $accountBook->accountType = $accountType;
  10275. $accountBook->accountMsg = $accountMsg;
  10276. $accountBook->receivedPrice = $receivedPrice;
  10277. $accountBook->receivedMsg = $receivedMsg;
  10278. $accountBook->receivedBank = $receivedBank;
  10279. $accountBook->receivedDate = $receivedDate;
  10280. $accountBook->remarks = $remarks;
  10281. $accountBook->expensesType = 1;
  10282. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10283. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10284. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10285. $id = $accountBook->insert ();
  10286. //
  10287. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10288. // 收支汇总
  10289. Doo::loadModel ( "accountBookStatistics" );
  10290. $accountBookStatistics = new accountBookStatistics ();
  10291. $item = array (
  10292. 'date' => date ( "Y-m-d" ),
  10293. 'accountType' => $abDetail ['accountType'],
  10294. 'accountMsg' => $abDetail ['accountMsg'],
  10295. 'aid' => $abDetail ['aid']
  10296. );
  10297. if ($abDetail ['expensesType'] == 1) {
  10298. if ($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) {
  10299. $item += array (
  10300. 'financingPrice' => - $receivedPrice,
  10301. 'expensesType' => 3
  10302. );
  10303. } else if ($abDetail ['accountType'] == 8) {
  10304. $item += array (
  10305. 'inComePrice' => - $abDetail ['receivedPrice'],
  10306. 'expensesType' => $abDetail ['expensesType']
  10307. );
  10308. } else {
  10309. $item += array (
  10310. 'inComePrice' => $abDetail ['receivedPrice'],
  10311. 'expensesType' => $abDetail ['expensesType']
  10312. );
  10313. }
  10314. }
  10315. $accountBookStatistics->setAccountBookStatistics ( $item );
  10316. // 为理财时需添加一条日常支出
  10317. if ($accountType == 7 || $accountType == 9) {
  10318. }
  10319. // 公司流水记录
  10320. Doo::loadModel ( 'wasteBook' );
  10321. $wasteBook = new wasteBook ();
  10322. // 银行
  10323. // if (empty($abDetail)){
  10324. $itemWaste += array (
  10325. 'accountPriceShow' => $receivedPrice,
  10326. 'dataID' => $id,
  10327. 'accountType' => $accountTypeWaste,
  10328. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10329. 'accountBank' => $accountBank,
  10330. 'category' => $this->staff [0] ['category'],
  10331. 'cid' => $this->staff [0] ['cid'],
  10332. 'name' => $this->staff [0] ['username'],
  10333. 'sid' => $this->staff [0] ['sid'],
  10334. 'inputDate' => date ( "Y-m-d H:i:s" )
  10335. );
  10336. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10337. // }
  10338. // 类型为理财7或者9 要添加一笔理财支出
  10339. if ($accountType == 7 || $accountType == 9) {
  10340. $accountBank = 'CGBDeposit';
  10341. $expenditureBank = '纵横广发';
  10342. $dailyExpenditureType = 4;
  10343. if ($accountType == 9) {
  10344. $accountBank = 'ICBCDeposit';
  10345. $expenditureBank = '纵横工行';
  10346. $dailyExpenditureType = 6;
  10347. }
  10348. // 添加一条支出
  10349. $accountBook = new accountBook ();
  10350. $accountBook->expenditureType = $dailyExpenditureType;
  10351. $accountBook->expenditureMsg = $accountMsg;
  10352. $accountBook->expenditurePrice = $receivedPrice;
  10353. $accountBook->expenditureBank = $expenditureBank;
  10354. $accountBook->expenditureDate = $receivedDate;
  10355. $accountBook->remarks = $remarks;
  10356. $accountBook->expensesType = 2;
  10357. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10358. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10359. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10360. $id = $accountBook->insert ();
  10361. // 添加一条收入流水
  10362. $itemWaste = array (
  10363. 'accountPriceShow' => $receivedPrice,
  10364. 'accountPrice' => $receivedPrice,
  10365. 'dataID' => $id,
  10366. 'expensesType' => 2,
  10367. 'accountType' => $accountTypeWaste,
  10368. 'dailyExpenditureType' => $dailyExpenditureType,
  10369. 'accountBank' => $accountBank,
  10370. 'category' => $this->staff [0] ['category'],
  10371. 'cid' => $this->staff [0] ['cid'],
  10372. 'name' => $this->staff [0] ['username'],
  10373. 'sid' => $this->staff [0] ['sid'],
  10374. 'inputDate' => date ( "Y-m-d H:i:s" )
  10375. );
  10376. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10377. }
  10378. }
  10379. return '/payments';
  10380. }
  10381. function paymentsExpenditureDo() {
  10382. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10383. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10384. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10385. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10386. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10387. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10388. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10389. // 理财支出特殊处理
  10390. Doo::loadModel ( "accountBook" );
  10391. Doo::loadModel ( "accountBookStatistics" );
  10392. Doo::loadModel ( 'wasteBook' );
  10393. $accountBank = '';
  10394. if ($expenditureBank == '纵横广发') {
  10395. $accountBank = 'CGBDeposit';
  10396. } elseif ($expenditureBank == '纵横工行') {
  10397. $accountBank = 'ICBCDeposit';
  10398. } elseif ($expenditureBank == '华润银行') {
  10399. $accountBank = 'HUADeposit';
  10400. } elseif ($expenditureBank == '个人广发') {
  10401. $accountBank = 'PersonalDeposit';
  10402. }
  10403. if (empty ( $accountBank ))
  10404. die ( 'illegal request' );
  10405. if ($expenditureType == 4 || $expenditureType == 6) {
  10406. if ($expenditureBank == '个人广发') {
  10407. die ( '个人广发 illegal request' );
  10408. }
  10409. // 添加一笔日常支出
  10410. $accountBook = new accountBook ();
  10411. $accountBook->expensesType = 2;
  10412. $accountBook->expenditureType = 7;
  10413. $accountBook->expenditureMsg = $expenditureMsg;
  10414. $accountBook->expenditurePrice = $expenditurePrice;
  10415. $accountBook->expenditureBank = $expenditureBank;
  10416. $accountBook->expenditureDate = $expenditureDate;
  10417. $accountBook->remarks = $remarks;
  10418. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10419. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10420. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10421. $expenditureId = $accountBook->insert ();
  10422. // 添加日常支出汇总
  10423. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  10424. $accountBookStatistics = new accountBookStatistics ();
  10425. $item = array (
  10426. 'date' => date ( "Y-m-d" ),
  10427. 'expenditureType' => $abDetail ['expenditureType'],
  10428. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10429. 'aid' => $abDetail ['aid'],
  10430. 'payPrice' => $abDetail ['expenditurePrice'],
  10431. 'expensesType' => $abDetail ['expensesType']
  10432. );
  10433. $accountBookStatistics->setAccountBookStatistics ( $item );
  10434. // 公司日常支出流水
  10435. $wasteBook = new wasteBook ();
  10436. $itemWaste = array (
  10437. 'accountPrice' => - $expenditurePrice
  10438. );
  10439. if ($expenditureBank == '个人广发') {
  10440. $itemWaste = array (
  10441. 'accountPrice' => $expenditurePrice
  10442. );
  10443. }
  10444. $itemWaste += array (
  10445. 'expensesType' => 2,
  10446. 'accountType' => 5,
  10447. 'dailyExpenditureType' => $expenditureType,
  10448. 'accountPriceShow' => $expenditurePrice,
  10449. 'accountPrice' => - $expenditurePrice,
  10450. 'dataID' => $expenditureId,
  10451. 'accountBank' => $accountBank,
  10452. 'category' => $this->staff [0] ['category'],
  10453. 'cid' => $this->staff [0] ['cid'],
  10454. 'name' => $this->staff [0] ['username'],
  10455. 'sid' => $this->staff [0] ['sid'],
  10456. 'inputDate' => date ( "Y-m-d H:i:s" )
  10457. );
  10458. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10459. // 添加一笔理财收入
  10460. $accountBank = 'CGBDeposit';
  10461. $dailyIncomeType = 7;
  10462. $receivedBank = '纵横广发';
  10463. if ($expenditureType == 6) {
  10464. $accountBank = 'ICBCDeposit';
  10465. $receivedBank = '纵横工行';
  10466. $dailyIncomeType = 9;
  10467. }
  10468. $accountBook = new accountBook ();
  10469. $accountBook->expensesType = 1;
  10470. $accountBook->accountType = $dailyIncomeType;
  10471. $accountBook->accountMsg = $expenditureMsg;
  10472. $accountBook->receivedPrice = $expenditurePrice;
  10473. $accountBook->receivedBank = $receivedBank;
  10474. $accountBook->receivedDate = $expenditureDate;
  10475. $accountBook->remarks = $remarks;
  10476. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10477. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10478. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10479. $id = $accountBook->insert ();
  10480. // 添加日常理财收入汇总
  10481. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  10482. $accountBookStatistics = new accountBookStatistics ();
  10483. $item = array (
  10484. 'date' => date ( "Y-m-d" ),
  10485. 'expenditureType' => $abDetail ['expenditureType'],
  10486. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10487. 'aid' => $abDetail ['aid'],
  10488. 'financingPrice' => $expenditurePrice,
  10489. 'expensesType' => 3
  10490. );
  10491. $accountBookStatistics->setAccountBookStatistics ( $item );
  10492. // 添加一笔收入流水
  10493. if ($expenditureMsg == '公司固定') {
  10494. $accountTypeWaste = 9;
  10495. } elseif ($expenditureMsg == '公司活期') {
  10496. $accountTypeWaste = 10;
  10497. } elseif ($expenditureMsg == '个人(GR)') {
  10498. $accountBank = 'PersonalDeposit';
  10499. }
  10500. $itemWaste = array (
  10501. 'expensesType' => 1,
  10502. 'accountType' => $accountTypeWaste,
  10503. 'accountPriceShow' => $expenditurePrice,
  10504. 'accountPrice' => $expenditurePrice,
  10505. 'dataID' => $id,
  10506. 'dailyIncomeType' => $dailyIncomeType,
  10507. 'accountBank' => $accountBank,
  10508. 'category' => $this->staff [0] ['category'],
  10509. 'cid' => $this->staff [0] ['cid'],
  10510. 'name' => $this->staff [0] ['username'],
  10511. 'sid' => $this->staff [0] ['sid'],
  10512. 'inputDate' => date ( "Y-m-d H:i:s" )
  10513. );
  10514. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10515. } else {
  10516. // 添加一笔日常支出
  10517. $accountBook = new accountBook ();
  10518. $accountBook->expensesType = 2;
  10519. $accountBook->expenditureType = $expenditureType;
  10520. $accountBook->expenditureMsg = $expenditureMsg;
  10521. $accountBook->expenditurePrice = $expenditurePrice;
  10522. $accountBook->expenditureBank = $expenditureBank;
  10523. $accountBook->expenditureDate = $expenditureDate;
  10524. $accountBook->remarks = $remarks;
  10525. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10526. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10527. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10528. $id = $accountBook->insert ();
  10529. // 添加日常支出汇总
  10530. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10531. $accountBookStatistics = new accountBookStatistics ();
  10532. $item = array (
  10533. 'date' => date ( "Y-m-d" ),
  10534. 'expenditureType' => $abDetail ['expenditureType'],
  10535. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10536. 'aid' => $abDetail ['aid'],
  10537. 'expensesType' => $abDetail ['expensesType']
  10538. );
  10539. if ($expenditureType == 5) {
  10540. $item += array (
  10541. 'payPrice' => - $abDetail ['expenditurePrice']
  10542. );
  10543. } else {
  10544. $item += array (
  10545. 'payPrice' => $abDetail ['expenditurePrice']
  10546. );
  10547. }
  10548. $accountBookStatistics->setAccountBookStatistics ( $item );
  10549. // 公司日常支出流水
  10550. $wasteBook = new wasteBook ();
  10551. $itemWaste = array (
  10552. 'accountPrice' => - $expenditurePrice
  10553. );
  10554. if ($expenditureBank == '个人广发') {
  10555. $itemWaste = array (
  10556. 'accountPrice' => $expenditurePrice
  10557. );
  10558. }
  10559. $itemWaste += array (
  10560. 'expensesType' => 2,
  10561. 'accountType' => 5,
  10562. 'accountPriceShow' => $expenditurePrice,
  10563. 'dataID' => $id,
  10564. 'dailyExpenditureType' => $expenditureType,
  10565. 'accountBank' => $accountBank,
  10566. 'category' => $this->staff [0] ['category'],
  10567. 'cid' => $this->staff [0] ['cid'],
  10568. 'name' => $this->staff [0] ['username'],
  10569. 'sid' => $this->staff [0] ['sid'],
  10570. 'inputDate' => date ( "Y-m-d H:i:s" )
  10571. );
  10572. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10573. }
  10574. }
  10575. return '/payments';
  10576. }
  10577. /**
  10578. * 添加支出
  10579. */
  10580. function paymentsExpenditureDo_() {
  10581. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10582. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10583. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10584. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10585. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10586. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10587. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10588. $dailyExpenditureType = '';
  10589. $accountTypeWaste = 5;
  10590. $accountBank = '';
  10591. if ($expenditureBank == '纵横广发') {
  10592. $accountBank = 'CGBDeposit';
  10593. } elseif ($expenditureBank == '纵横工行') {
  10594. $accountBank = 'ICBCDeposit';
  10595. } elseif ($expenditureBank == '华润银行') {
  10596. $accountBank = 'HUADeposit';
  10597. } elseif ($expenditureBank == '个人广发') {
  10598. $accountBank = 'PersonalDeposit';
  10599. }
  10600. if (empty ( $accountBank ))
  10601. die ( 'illegal request' );
  10602. $itemWaste = array (
  10603. 'accountPrice' => - $expenditurePrice
  10604. );
  10605. if ($expenditureBank == '个人广发') {
  10606. $itemWaste = array (
  10607. 'accountPrice' => $expenditurePrice
  10608. );
  10609. }
  10610. if ($expenditureType == 4 || $expenditureType == 6) {
  10611. $dailyExpenditureType = 4;
  10612. if ($expenditureMsg == '公司固定') {
  10613. $accountTypeWaste = 9;
  10614. } elseif ($expenditureMsg == '公司活期') {
  10615. $accountTypeWaste = 10;
  10616. } elseif ($expenditureMsg == '个人(GR)') {
  10617. $accountBank = 'PersonalDeposit';
  10618. }
  10619. $itemWaste = array (
  10620. 'accountPrice' => $expenditurePrice
  10621. );
  10622. } elseif ($expenditureType == 1) {
  10623. $dailyExpenditureType = 1;
  10624. } elseif ($expenditureType == 2) {
  10625. $dailyExpenditureType = 2;
  10626. } elseif ($expenditureType == 3) {
  10627. $dailyExpenditureType = 3;
  10628. } elseif ($expenditureType == 5) {
  10629. $dailyExpenditureType = 5;
  10630. }
  10631. if (empty ( $dailyExpenditureType ))
  10632. die ( 'illegal request' );
  10633. Doo::loadModel ( "accountBook" );
  10634. $accountBook = new accountBook ();
  10635. $accountBook->expenditureType = $expenditureType;
  10636. $accountBook->expenditureMsg = $expenditureMsg;
  10637. $accountBook->expenditurePrice = $expenditurePrice;
  10638. $accountBook->expenditureBank = $expenditureBank;
  10639. $accountBook->expenditureDate = $expenditureDate;
  10640. $accountBook->remarks = $remarks;
  10641. $accountBook->expensesType = 2;
  10642. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10643. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10644. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10645. $id = $accountBook->insert ();
  10646. //
  10647. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10648. Doo::loadModel ( "accountBookStatistics" );
  10649. $accountBookStatistics = new accountBookStatistics ();
  10650. $item = array (
  10651. 'date' => date ( "Y-m-d" ),
  10652. 'expenditureType' => $abDetail ['expenditureType'],
  10653. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10654. 'aid' => $abDetail ['aid']
  10655. );
  10656. if ($abDetail ['expensesType'] == 2) {
  10657. if ($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) {
  10658. $item += array (
  10659. 'financingPrice' => $expenditurePrice,
  10660. 'expensesType' => 3
  10661. );
  10662. } elseif ($abDetail ['expenditureType'] == 5) {
  10663. $item += array (
  10664. 'payPrice' => $abDetail ['expenditurePrice'],
  10665. 'expensesType' => $abDetail ['expensesType']
  10666. );
  10667. } else {
  10668. $item += array (
  10669. 'payPrice' => $abDetail ['expenditurePrice'],
  10670. 'expensesType' => $abDetail ['expensesType']
  10671. );
  10672. }
  10673. }
  10674. $accountBookStatistics->setAccountBookStatistics ( $item );
  10675. // 公司流水记录
  10676. Doo::loadModel ( 'wasteBook' );
  10677. $wasteBook = new wasteBook ();
  10678. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountTypeWaste, $id );
  10679. // 银行
  10680. if (empty ( $abDetail )) {
  10681. $itemWaste += array (
  10682. 'accountPriceShow' => $expenditurePrice,
  10683. 'dataID' => $id,
  10684. 'expensesType' => 2,
  10685. 'accountType' => $accountTypeWaste,
  10686. 'dailyExpenditureType' => $expenditureType,
  10687. 'accountBank' => $accountBank,
  10688. 'category' => $this->staff [0] ['category'],
  10689. 'cid' => $this->staff [0] ['cid'],
  10690. 'name' => $this->staff [0] ['username'],
  10691. 'sid' => $this->staff [0] ['sid'],
  10692. 'inputDate' => date ( "Y-m-d H:i:s" )
  10693. );
  10694. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10695. }
  10696. // 支出类型为4或者6 需要添加一笔收入和收入流水
  10697. if ($expenditureType == 4 || $expenditureType == 6) {
  10698. $accountBank = 'CGBDeposit';
  10699. $dailyIncomeType = 7;
  10700. $receivedBank = '纵横广发';
  10701. if ($expenditureType == 6) {
  10702. $accountBank = 'ICBCDeposit';
  10703. $receivedBank = '纵横工行';
  10704. $dailyIncomeType = 9;
  10705. }
  10706. // 添加一笔收入
  10707. $accountBook = new accountBook ();
  10708. $accountBook->accountType = $dailyIncomeType;
  10709. $accountBook->accountMsg = $expenditureMsg;
  10710. $accountBook->receivedPrice = $expenditurePrice;
  10711. $accountBook->receivedBank = $receivedBank;
  10712. $accountBook->receivedDate = $expenditureDate;
  10713. $accountBook->remarks = $remarks;
  10714. $accountBook->expensesType = 1;
  10715. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10716. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10717. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10718. $id = $accountBook->insert ();
  10719. // 添加一笔收入流水
  10720. $itemWaste = array (
  10721. 'accountPriceShow' => $expenditurePrice,
  10722. 'accountPrice' => - $expenditurePrice,
  10723. 'dataID' => $id,
  10724. 'expensesType' => 1,
  10725. 'accountType' => $accountTypeWaste,
  10726. 'dailyIncomeType' => $dailyIncomeType,
  10727. 'accountBank' => $accountBank,
  10728. 'category' => $this->staff [0] ['category'],
  10729. 'cid' => $this->staff [0] ['cid'],
  10730. 'name' => $this->staff [0] ['username'],
  10731. 'sid' => $this->staff [0] ['sid'],
  10732. 'inputDate' => date ( "Y-m-d H:i:s" )
  10733. );
  10734. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10735. }
  10736. }
  10737. return '/payments';
  10738. }
  10739. /**
  10740. * 所有收支
  10741. */
  10742. function paymentsAchieve() {
  10743. $page_size = 12;
  10744. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  10745. $expensesType = isset ( $this->params ['expensesType'] ) ? $this->params ['expensesType'] : 'ALL';
  10746. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  10747. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  10748. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10749. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10750. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10751. $submitType = $this->get_args ( 'submitType' ) ? $this->get_args ( 'submitType' ) : "";
  10752. Doo::loadModel ( "accountBookStatistics" );
  10753. $accountBookStatistics = new accountBookStatistics ();
  10754. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  10755. $data ['statisticsList'] = $statisticsList;
  10756. Doo::loadModel ( "accountBook" );
  10757. $accountBook = new accountBook ();
  10758. $con = '';
  10759. if ($expensesType == 'INCOME')
  10760. $con = ' and expensesType=1 ';
  10761. elseif ($expensesType == 'PAY')
  10762. $con = ' and expensesType=2 ';
  10763. $dateArr = explode ( ':', $date );
  10764. $D1 = $dateString = '';
  10765. $D2 = '';
  10766. if (! empty ( $date )) {
  10767. $D1 = $dateArr [0];
  10768. if (isset ( $dateArr [1] ))
  10769. $D2 = $dateArr [1];
  10770. else
  10771. $D2 = '';
  10772. $dateString = $D1 . " : " . $D2;
  10773. }
  10774. if (! empty ( $D1 ) && ! empty ( $D2 ))
  10775. $con .= ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  10776. elseif (! empty ( $D1 ) && empty ( $D2 ))
  10777. $con .= ' and inputDate like "%' . $D1 . '%" ';
  10778. if (! empty ( $price ))
  10779. $con .= ' and (receivedPrice=' . $price . ' or expenditurePrice=' . $price . ')';
  10780. if ($submitType == 1) {
  10781. if ($accountType != '') {
  10782. $expenditureType = '';
  10783. $con .= ' and accountType=' . $accountType;
  10784. if (! empty ( $accountMsg ))
  10785. $con .= ' and (accountType=' . $accountType . ' and accountMsg like "%' . $accountMsg . '%")';
  10786. }
  10787. } elseif ($submitType == 2) {
  10788. if ($expenditureType != '') {
  10789. $accountType = $accountMsg = '';
  10790. $con .= ' and expenditureType=' . $expenditureType;
  10791. }
  10792. } else {
  10793. $accountType = $accountMsg = $expenditureType = '';
  10794. }
  10795. $sql = "" . $con;
  10796. $action = "paymentsAchieve";
  10797. $get = '/' . $expensesType; // "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  10798. $pageinfo = $this->get_page ( "CLD_accountBook", $sql, $page, $page_size, $action, $get, "" );
  10799. $limit = $pageinfo ['lower'] . ',' . $page_size;
  10800. $list = $accountBook->getAccountBookBySql ( $limit, $sql, 'desc' );
  10801. $data ['expenditureType'] = $expenditureType;
  10802. $data ['accountMsg'] = $accountMsg;
  10803. $data ['accountType'] = $accountType;
  10804. $data ['inputDate'] = $date;
  10805. $data ['price'] = $price;
  10806. $data ['expensesType'] = $expensesType;
  10807. $data ['page'] = $pageinfo;
  10808. $data ['list'] = $list;
  10809. $data ['memu'] = "receipt";
  10810. $data ['staff'] = $this->staff;
  10811. $data ['receiptMemu'] = 'payments';
  10812. $data ['verifyId'] = $this->verifyId;
  10813. $data ['executeId'] = $this->executeId;
  10814. $this->render ( "/expenses/paymentsAchieve", $data );
  10815. }
  10816. function paymentsIncomeUpdateDo() {
  10817. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  10818. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10819. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10820. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10821. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10822. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10823. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10824. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10825. if (! empty ( $aidKey ) && ! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10826. Doo::loadClass ( 'XDeode' );
  10827. $XDeode = new XDeode ( 5 );
  10828. $aid = $XDeode->decode ( $aidKey );
  10829. Doo::loadModel ( "accountBook" );
  10830. $accountBook = new accountBook ();
  10831. //
  10832. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  10833. $price = $receivedPrice - $abDetail [inComePrice];
  10834. Doo::loadModel ( "accountBookStatistics" );
  10835. $accountBookStatistics = new accountBookStatistics ();
  10836. if ($abDetail ['accountType'] == 7) {
  10837. $item += array (
  10838. 'date' => date ( "Y-m-d" ),
  10839. 'financingPrice' => - $price,
  10840. 'expensesType' => 3,
  10841. 'aid' => $abDetail ['aid']
  10842. );
  10843. } elseif ($abDetail ['accountType'] == 8) {
  10844. $item += array (
  10845. 'date' => date ( "Y-m-d" ),
  10846. 'expensesType' => $abDetail ['expensesType'],
  10847. 'inComePrice' => - $price,
  10848. 'aid' => $abDetail ['aid']
  10849. );
  10850. } else {
  10851. $item = array (
  10852. 'date' => date ( "Y-m-d" ),
  10853. 'expensesType' => $abDetail ['expensesType'],
  10854. 'inComePrice' => $price,
  10855. 'aid' => $abDetail ['aid']
  10856. );
  10857. }
  10858. $accountBookStatistics->setAccountBookStatistics ( $item );
  10859. $accountBook->accountType = $accountType;
  10860. $accountBook->accountMsg = $accountMsg;
  10861. $accountBook->receivedPrice = $receivedPrice;
  10862. $accountBook->receivedMsg = $receivedMsg;
  10863. $accountBook->receivedBank = $receivedBank;
  10864. $accountBook->receivedDate = $receivedDate;
  10865. $accountBook->remarks = $remarks;
  10866. $accountBook->aid = $aid;
  10867. $accountBook->update ();
  10868. }
  10869. return '/paymentsAchieve';
  10870. }
  10871. function paymentsExpenditureEdiDo() {
  10872. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  10873. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10874. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10875. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10876. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10877. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10878. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10879. if (! empty ( $aidKey ) && ! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10880. Doo::loadClass ( 'XDeode' );
  10881. $XDeode = new XDeode ( 5 );
  10882. $aid = $XDeode->decode ( $aidKey );
  10883. Doo::loadModel ( "accountBook" );
  10884. $accountBook = new accountBook ();
  10885. // 汇总信息
  10886. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  10887. $price = $expenditurePrice - $abDetail [expenditurePrice];
  10888. Doo::loadModel ( "accountBookStatistics" );
  10889. $accountBookStatistics = new accountBookStatistics ();
  10890. if ($abDetail ['expenditureType'] == 4) {
  10891. $item += array (
  10892. 'date' => date ( "Y-m-d" ),
  10893. 'financingPrice' => $price,
  10894. 'expensesType' => 3,
  10895. 'aid' => $abDetail ['aid']
  10896. );
  10897. } elseif ($abDetail ['expenditureType'] == 5) {
  10898. $item += array (
  10899. 'date' => date ( "Y-m-d" ),
  10900. 'expensesType' => $abDetail ['expensesType'],
  10901. 'payPrice' => $price,
  10902. 'aid' => $abDetail ['aid']
  10903. );
  10904. } else {
  10905. $item = array (
  10906. 'date' => date ( "Y-m-d" ),
  10907. 'expensesType' => $abDetail ['expensesType'],
  10908. 'payPrice' => $price,
  10909. 'aid' => $abDetail ['aid']
  10910. );
  10911. }
  10912. $accountBookStatistics->setAccountBookStatistics ( $item );
  10913. //
  10914. $accountBook->expenditureType = $expenditureType;
  10915. $accountBook->expenditureMsg = $expenditureMsg;
  10916. $accountBook->expenditurePrice = $expenditurePrice;
  10917. $accountBook->expenditureBank = $expenditureBank;
  10918. $accountBook->remarks = $remarks;
  10919. $accountBook->expenditureDate = $expenditureDate;
  10920. $accountBook->aid = $aid;
  10921. $id = $accountBook->update ();
  10922. }
  10923. return '/paymentsAchieve';
  10924. }
  10925. function paymentsDelDo() {
  10926. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  10927. if (! empty ( $aidKey )) {
  10928. Doo::loadClass ( 'XDeode' );
  10929. $XDeode = new XDeode ( 5 );
  10930. $aid = $XDeode->decode ( $aidKey );
  10931. Doo::loadModel ( "accountBook" );
  10932. $accountBook = new accountBook ();
  10933. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  10934. if (empty ( $abDetail ))
  10935. die ( 'illegal request' );
  10936. // 删除收支
  10937. Doo::loadModel ( "accountBookStatistics" );
  10938. $accountBookStatistics = new accountBookStatistics ();
  10939. $item = array (
  10940. 'date' => date ( "Y-m-d" ),
  10941. 'aid' => $abDetail ['aid']
  10942. );
  10943. $accountType = '';
  10944. if ($abDetail ['expensesType'] == 1) {
  10945. $accountType = 6;
  10946. if ($abDetail ['accountType'] != 7) {
  10947. $item += array (
  10948. 'expensesType' => $abDetail ['expensesType'],
  10949. 'inComePrice' => - $abDetail ['receivedPrice']
  10950. );
  10951. } else {
  10952. $item += array (
  10953. 'financingPrice' => $abDetail ['receivedPrice'],
  10954. 'expensesType' => 3
  10955. );
  10956. }
  10957. } elseif ($abDetail ['expensesType'] == 2) {
  10958. $accountType = 5;
  10959. if ($abDetail ['accountType'] != 7) {
  10960. $item += array (
  10961. 'expensesType' => $abDetail ['expensesType'],
  10962. 'payPrice' => - $abDetail ['expenditurePrice']
  10963. );
  10964. } else {
  10965. $item += array (
  10966. 'financingPrice' => - $abDetail ['expenditurePrice'],
  10967. 'expensesType' => 3
  10968. );
  10969. }
  10970. }
  10971. if (($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) && $abDetail ['expensesType'] == 2) {
  10972. if ($abDetail ['expenditureMsg'] == '公司固定')
  10973. $accountType = 9;
  10974. elseif ($abDetail ['expenditureMsg'] == '公司活期')
  10975. $accountType = 10;
  10976. }
  10977. if (($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) && $abDetail ['expensesType'] == 1) {
  10978. if ($abDetail ['accountMsg'] == '公司固定')
  10979. $accountType = 9;
  10980. elseif ($abDetail ['accountMsg'] == '公司活期')
  10981. $accountType = 10;
  10982. }
  10983. if ($abDetail ['accountMsg'] == '活期理财收益') {
  10984. $accountType = 10;
  10985. }
  10986. $accountBookStatistics->setAccountBookStatistics ( $item );
  10987. $accountBook->delete ( array (
  10988. 'where' => 'aid=' . $aid,
  10989. 'limit' => 1
  10990. ) );
  10991. // 删除收入流水
  10992. if (! empty ( $accountType )) {
  10993. Doo::loadModel ( 'wasteBook' );
  10994. $wasteBook = new wasteBook ();
  10995. $wasteBook->delete ( array (
  10996. 'where' => 'dataID=' . $aid . ' and accountType=' . $accountType,
  10997. 'limit' => 1
  10998. ) );
  10999. }
  11000. }
  11001. return '/paymentsAchieve';
  11002. }
  11003. function paymentsCollect() {
  11004. Doo::loadModel ( "execute" );
  11005. $execute = new execute ();
  11006. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11007. die ( 'illegal request' );
  11008. }
  11009. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11010. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  11011. Doo::loadModel ( "accountBookStatistics" );
  11012. $accountBookStatistics = new accountBookStatistics ();
  11013. Doo::loadClass ( 'receipt.func' );
  11014. $statisticsIncome = $accountBookStatistics->getStatisticsByCollect ( $year );
  11015. $html = _getPaymentsCollectByYearHtml ( $statisticsIncome );
  11016. $data ['html'] = $html ['html'];
  11017. $data ['inSum'] = $html ['sum'];
  11018. $statisticsPay = $accountBookStatistics->getStatisticsByCollect ( $year, 2 );
  11019. $html = _getPaymentsCollectPayByYearHtml ( $statisticsPay );
  11020. $data ['payHtml'] = $html ['html'];
  11021. $data ['paySum'] = $html ['sum'];
  11022. // 余额统计
  11023. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1 );
  11024. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2 );
  11025. include './protected/config/wasteBook.conf.php';
  11026. Doo::loadModel ( 'wasteBook' );
  11027. $wasteBook = new wasteBook ();
  11028. $inComePay = $wasteBook->getWasteBookByStatistics ( 1, $year );
  11029. $pay = $wasteBook->getWasteBookByStatistics ( 2, $year );
  11030. // 获得年份之前所有金额
  11031. $detail = $wasteBook->getWasteBookByStatisticsYear ( $year );
  11032. // print_r($detail);
  11033. // $waste['total'];
  11034. $lastBalanceHtml = '<tr><th colspan="2">截至上月余额</th>';
  11035. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11036. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11037. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11038. $inSum = $paySum = $showInSum = $showPaySum = $balanceSum = 0;
  11039. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11040. $limitMonth = date ( 'm' ); // 限制显示月份参数
  11041. if (date ( 'Y' ) > $year) {
  11042. $limitMonth = 12;
  11043. }
  11044. for($i = 1; $i <= 12; $i ++) {
  11045. $inComeA = $payB = 0;
  11046. $falg = true;
  11047. foreach ( $inComePay as $key => $value ) {
  11048. if ($value ['month'] == $i) {
  11049. $falg = false;
  11050. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11051. $inSum += $value ['accountPrice'];
  11052. $showInSum += $value ['accountPriceShow'];
  11053. $inComeA = $value ['accountPrice'];
  11054. break;
  11055. }
  11056. }
  11057. if ($falg)
  11058. $inComeHtml .= '<td class="taR">-</td>';
  11059. $payFalg = true;
  11060. foreach ( $pay as $key => $value ) {
  11061. if ($value ['month'] == $i) {
  11062. $payFalg = false;
  11063. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11064. $paySum += $value ['accountPrice'];
  11065. $showPaySum += $value ['accountPriceShow'];
  11066. $payB = $value ['accountPrice'];
  11067. break;
  11068. }
  11069. }
  11070. if ($payFalg)
  11071. $payHtml .= '<td class="taR">-</td>';
  11072. if (empty ( $balanceC ) || $limitMonth < $i)
  11073. $lastBalanceHtml .= '<td class="taR">-</td>';
  11074. else
  11075. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11076. $balanceC = $balanceC + $inComeA + $payB;
  11077. $balanceSum += $balanceC;
  11078. if (empty ( $balanceC ) || $limitMonth < $i)
  11079. $BalanceHtml .= '<td class="taR">-</td>';
  11080. else
  11081. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11082. // 余额统计
  11083. }
  11084. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11085. $data ['inComeHtml'] = $inComeHtml;
  11086. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11087. $data ['payBalanceHtml'] = $payHtml;
  11088. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11089. $data ['BalanceHtml'] = $BalanceHtml;
  11090. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11091. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11092. $mothHtml = "";
  11093. for($i = 1; $i <= 12; $i ++) {
  11094. if ($moth == $i)
  11095. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11096. else
  11097. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11098. }
  11099. $data ['mothHtml'] = $mothHtml;
  11100. $dateHtml = "";
  11101. $now = date ( "Y" );
  11102. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11103. if ($YEARD <= $now) {
  11104. $dateHtml .= '<option ';
  11105. if ($year == $YEARD) {
  11106. $dateHtml .= 'selected ';
  11107. }
  11108. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11109. }
  11110. }
  11111. $data ['dateHtml'] = $dateHtml;
  11112. $data ['year'] = $year;
  11113. $data ['memu'] = "receipt";
  11114. $data ['staff'] = $this->staff;
  11115. $data ['receiptMemu'] = 'paymentsCollect';
  11116. $data ['verifyId'] = $this->verifyId;
  11117. $data ['executeId'] = $this->executeId;
  11118. $this->render ( "/expenses/paymentsCollect", $data );
  11119. }
  11120. function paymentsCollectDay() {
  11121. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11122. $moth = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : '';
  11123. if (empty ( $moth ))
  11124. return 'paymentsCollect';
  11125. Doo::loadModel ( "accountBookStatistics" );
  11126. $accountBookStatistics = new accountBookStatistics ();
  11127. $i = 2;
  11128. $y = 2013;
  11129. $day = date ( "t", strtotime ( "$year-$moth" ) );
  11130. Doo::loadClass ( 'receipt.func' );
  11131. $statisticsIncome = $accountBookStatistics->getStatisticsByCollectDay ( $year, 1, $moth );
  11132. $html = _getPaymentsCollectByDayHtml ( $statisticsIncome, $day );
  11133. $data ['html'] = $html ['html'];
  11134. $data ['inSum'] = $html ['sum'];
  11135. $statisticsPay = $accountBookStatistics->getStatisticsByCollectDay ( $year, 2, $moth );
  11136. $html = _getPaymentsCollectPayByDayHtml ( $statisticsPay, $day );
  11137. $data ['payHtml'] = $html ['html'];
  11138. $data ['paySum'] = $html ['sum'];
  11139. $mothHtml = "";
  11140. for($i = 1; $i <= 12; $i ++) {
  11141. if ($moth == $i)
  11142. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11143. else
  11144. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11145. }
  11146. $data ['mothHtml'] = $mothHtml;
  11147. $data ['year'] = $year;
  11148. // 余额
  11149. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1, $moth );
  11150. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2, $moth );
  11151. include './protected/config/wasteBook.conf.php';
  11152. Doo::loadModel ( 'wasteBook' );
  11153. $wasteBook = new wasteBook ();
  11154. $inComePay = $wasteBook->getStatisticsByDay ( 1, $year, $moth );
  11155. $pay = $wasteBook->getStatisticsByDay ( 2, $year, $moth );
  11156. // 获得年份之前所有金额
  11157. $detail = $wasteBook->getWasteBookByStatisticsDay ( $year, $moth );
  11158. $lastBalanceHtml = '<tr><th colspan="2">截至上日余额</th>';
  11159. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11160. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11161. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11162. $dayHtml = '<tr><th class="taC" colspan="2">余额</th>';
  11163. $inSum = $paySum = $showPaySum = $showInSum = $balanceSum = 0;
  11164. // $balanceC = 0;
  11165. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11166. $limitDay = date ( 'd' );
  11167. $monthLK = ( int ) date ( 'm' );
  11168. if (date ( 'Y' ) > $year) {
  11169. $limitDay = cal_days_in_month ( CAL_GREGORIAN, date ( 'm' ), date ( 'Y' ) );
  11170. } elseif (date ( 'Y' ) <= $year && $monthLK < $moth) {
  11171. $limitDay = 0;
  11172. }
  11173. for($i = 1; $i <= $day; $i ++) {
  11174. $dayHtml .= '<td class="taC">' . $i . '日</td>';
  11175. $inComeA = $payB = 0;
  11176. $falg = true;
  11177. foreach ( $inComePay as $key => $value ) {
  11178. if ($value ['day'] == $i) {
  11179. $falg = false;
  11180. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11181. $inSum += $value ['accountPrice'];
  11182. $showInSum += $value ['accountPriceShow'];
  11183. $inComeA = $value ['accountPrice'];
  11184. break;
  11185. }
  11186. }
  11187. if ($falg)
  11188. $inComeHtml .= '<td class="taR">-</td>';
  11189. $payFalg = true;
  11190. foreach ( $pay as $key => $value ) {
  11191. if ($value ['day'] == $i) {
  11192. $payFalg = false;
  11193. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11194. $paySum += $value ['accountPrice'];
  11195. $showPaySum += $value ['accountPriceShow'];
  11196. $payB = $value ['accountPrice'];
  11197. break;
  11198. }
  11199. }
  11200. if ($payFalg)
  11201. $payHtml .= '<td class="taR">-</td>';
  11202. if (empty ( $balanceC ) || $limitDay < $i)
  11203. $lastBalanceHtml .= '<td class="taR">-</td>';
  11204. else
  11205. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11206. $balanceC = $balanceC + $inComeA + $payB;
  11207. $balanceSum += $balanceC;
  11208. if (empty ( $balanceC ) || $limitDay < $i)
  11209. $BalanceHtml .= '<td class="taR">-</td>';
  11210. else
  11211. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11212. }
  11213. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11214. $data ['inComeHtml'] = $inComeHtml;
  11215. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11216. $data ['payBalanceHtml'] = $payHtml;
  11217. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11218. $data ['BalanceHtml'] = $BalanceHtml;
  11219. $dayHtml .= '<td class="taR ">总计</td></tr>';
  11220. $data ['dayHtml'] = $dayHtml;
  11221. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11222. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11223. $dateHtml = "";
  11224. $now = date ( "Y" );
  11225. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11226. if ($YEARD <= $now) {
  11227. $dateHtml .= '<option ';
  11228. if ($year == $YEARD) {
  11229. $dateHtml .= 'selected ';
  11230. }
  11231. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11232. }
  11233. }
  11234. $data ['dateHtml'] = $dateHtml;
  11235. $data ['memu'] = "receipt";
  11236. $data ['staff'] = $this->staff;
  11237. $data ['receiptMemu'] = 'paymentsCollect';
  11238. $data ['verifyId'] = $this->verifyId;
  11239. $data ['executeId'] = $this->executeId;
  11240. $this->render ( "/expenses/paymentsCollectDay", $data );
  11241. }
  11242. // 公司流水
  11243. function wasteBook() {
  11244. Doo::loadModel ( "execute" );
  11245. $execute = new execute ();
  11246. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11247. die ( 'illegal request' );
  11248. }
  11249. include './protected/config/wasteBook.conf.php';
  11250. Doo::loadModel ( 'wasteBook' );
  11251. $wasteBook = new wasteBook ();
  11252. $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  11253. $waste = $this->getWasteBookStatistics ( $waste, $inComeStatistics );
  11254. $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'];
  11255. // print_r($waste);
  11256. $data ['waste'] = $waste;
  11257. $data ['total'] = $total;
  11258. // 月流水数据结构
  11259. $monthStatistics = array ();
  11260. $incomeMothStatistics = array ();
  11261. $expenditureMothStatistics = array ();
  11262. for($i = 1; $i <= 12; $i ++) {
  11263. $month = date ( 'Y' ) . '-' . $i;
  11264. if ($i < 10)
  11265. $month = date ( 'Y' ) . '-0' . $i;
  11266. array_push ( $monthStatistics, $month );
  11267. }
  11268. foreach ( $monthStatistics as $value ) {
  11269. $falg = true;
  11270. foreach ( $inComeStatistics ['incomeReport'] as $k => $v ) {
  11271. if ($value == $v ['inputDate']) {
  11272. array_push ( $incomeMothStatistics, $v ['accountPrice'] );
  11273. $falg = false;
  11274. }
  11275. }
  11276. if ($falg) {
  11277. array_push ( $incomeMothStatistics, '' );
  11278. }
  11279. $falgEx = true;
  11280. foreach ( $inComeStatistics ['expenditureReport'] as $k => $v ) {
  11281. if ($value == $v ['inputDate']) {
  11282. array_push ( $expenditureMothStatistics, $v ['accountPrice'] );
  11283. $falg = false;
  11284. }
  11285. }
  11286. if ($falgEx) {
  11287. array_push ( $expenditureMothStatistics, '' );
  11288. }
  11289. }
  11290. $data ['monthStatistics'] = json_encode ( $monthStatistics );
  11291. $data ['incomeMothStatistics'] = json_encode ( $incomeMothStatistics );
  11292. $data ['expenditureMothStatistics'] = json_encode ( $expenditureMothStatistics );
  11293. $expenditureList = $wasteBook->getAccountBookByExpensesType ( 4, 2 );
  11294. $incomeList = $wasteBook->getAccountBookByExpensesType ( 4, 1 );
  11295. // print_r($incomeList);
  11296. $data ['expenditureList'] = $expenditureList;
  11297. $data ['incomeList'] = $incomeList;
  11298. $data ['memu'] = "receipt";
  11299. $data ['staff'] = $this->staff;
  11300. $data ['receiptMemu'] = 'wasteBook';
  11301. $data ['verifyId'] = $this->verifyId;
  11302. $data ['executeId'] = $this->executeId;
  11303. $this->render ( "/expenses/wasteBook", $data );
  11304. }
  11305. function wasteBookIncome() {
  11306. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11307. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11308. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  11309. $dailyIncomeType = $this->get_args ( 'dailyIncomeType' ) ? $this->get_args ( 'dailyIncomeType' ) : "ALL";
  11310. $data ['dailyIncomeType'] = $dailyIncomeType;
  11311. Doo::loadModel ( 'wasteBook' );
  11312. $wasteBook = new wasteBook ();
  11313. Doo::loadModel ( 'L_category' );
  11314. $L_category = new L_category ();
  11315. Doo::loadClass ( 'XDeode' );
  11316. $XDeode = new XDeode ( 5 );
  11317. // echo $XDeode->encode(1).'<br>';
  11318. // echo $XDeode->encode(2).'<br>';
  11319. // echo $XDeode->encode(3).'<br>';
  11320. // echo $XDeode->encode(4).'<br>';
  11321. // echo $XDeode->encode(5).'<br>';
  11322. // echo $XDeode->encode(6).'<br>';
  11323. // echo $XDeode->encode(7).'<br>';
  11324. // echo $XDeode->encode(8).'<br>';
  11325. // echo $XDeode->encode(9).'<br>';
  11326. // echo $XDeode->encode(10).'<br>';
  11327. $dateArr = explode ( ':', $date );
  11328. $D1 = '';
  11329. $D2 = '';
  11330. $con = '';
  11331. if (! empty ( $date )) {
  11332. $D1 = $dateArr [0];
  11333. $D2 = $dateArr [1];
  11334. }
  11335. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11336. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11337. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11338. $con = ' and inputDate = "' . $D1 . '"';
  11339. if ($cid != 'ALL') {
  11340. $cid = $XDeode->decode ( $cid );
  11341. $con .= ' and cid = "' . $cid . '"';
  11342. }
  11343. if ($accountType != 'ALL') {
  11344. if ($accountType == 'INVOICE') {
  11345. $con .= ' and (accountType = 7 or accountType = 8)';
  11346. } elseif ($accountType == 'PAYMENTS') {
  11347. $con .= ' and (accountType = 6 or accountType = 9 or accountType = 10)';
  11348. if ($dailyIncomeType != 'ALL') {
  11349. $dailyIncomeType = $XDeode->decode ( $dailyIncomeType );
  11350. $con .= ' and dailyIncomeType = ' . $dailyIncomeType;
  11351. }
  11352. }
  11353. }
  11354. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 1, $con );
  11355. $sum = 0;
  11356. foreach ( $incomeList as $key => $value ) {
  11357. $sum += $value ['accountPrice'];
  11358. }
  11359. // print_r($incomeList);
  11360. // 获得办事和部门
  11361. $categoryList = $L_category->getCategory ();
  11362. $data ['accountType'] = $accountType;
  11363. $data ['cid'] = $cid;
  11364. $data ['categoryList'] = $categoryList;
  11365. $data ['sum'] = $sum;
  11366. $data ['incomeList'] = $incomeList;
  11367. $data ['inputDate'] = $date;
  11368. $data ['memu'] = "receipt";
  11369. $data ['staff'] = $this->staff;
  11370. $data ['receiptMemu'] = 'wasteBook';
  11371. $data ['verifyId'] = $this->verifyId;
  11372. $data ['executeId'] = $this->executeId;
  11373. $this->render ( "/expenses/wasteBookIncome", $data );
  11374. }
  11375. /**
  11376. * 所有支出
  11377. */
  11378. function wasteBookExpenditure() {
  11379. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11380. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11381. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  11382. $dailyExpenditureType = $this->get_args ( 'dailyExpenditureType' ) ? $this->get_args ( 'dailyExpenditureType' ) : "ALL";
  11383. $data ['dailyExpenditureType'] = $dailyExpenditureType;
  11384. $receiptType = $this->get_args ( 'receiptType' ) ? $this->get_args ( 'receiptType' ) : "ALL";
  11385. $data ['receiptType'] = $receiptType;
  11386. Doo::loadModel ( 'wasteBook' );
  11387. $wasteBook = new wasteBook ();
  11388. Doo::loadModel ( 'L_category' );
  11389. $L_category = new L_category ();
  11390. Doo::loadClass ( 'XDeode' );
  11391. $XDeode = new XDeode ( 5 );
  11392. $dateArr = explode ( ':', $date );
  11393. $D1 = '';
  11394. $D2 = '';
  11395. $con = '';
  11396. if (! empty ( $date )) {
  11397. $D1 = $dateArr [0];
  11398. $D2 = $dateArr [1];
  11399. }
  11400. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11401. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11402. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11403. $con = ' and inputDate = "' . $D1 . '"';
  11404. if ($cid != 'ALL') {
  11405. $cid = $XDeode->decode ( $cid );
  11406. $con .= ' and cid = "' . $cid . '"';
  11407. }
  11408. if ($accountType != 'ALL') {
  11409. if ($accountType == 'INVOICE') {
  11410. $con .= ' and accountType = 11';
  11411. } elseif ($accountType == 'PAYMENTS') {
  11412. $con .= ' and (accountType = 5 or accountType = 9 or accountType = 10)';
  11413. if ($dailyExpenditureType != 'ALL') {
  11414. $dailyExpenditureType = $XDeode->decode ( $dailyExpenditureType );
  11415. $con .= ' and dailyExpenditureType = ' . $dailyExpenditureType;
  11416. }
  11417. } elseif ($accountType == 'RECEIPT') {
  11418. if ($receiptType == 'ALL') {
  11419. $con .= ' and (accountType = 1 or accountType = 2 or accountType = 3 or accountType = 4)';
  11420. } else {
  11421. $receiptType = $XDeode->decode ( $receiptType );
  11422. echo $receiptType;
  11423. if ($receiptType == 1) {
  11424. $con .= ' and (accountType = 1 or accountType=2)';
  11425. } else {
  11426. $con .= ' and accountType = ' . $receiptType;
  11427. }
  11428. }
  11429. }
  11430. }
  11431. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 2, $con );
  11432. $sum = 0;
  11433. foreach ( $incomeList as $key => $value ) {
  11434. $sum += $value ['accountPriceShow'];
  11435. }
  11436. // print_r($incomeList);
  11437. // 获得办事和部门
  11438. $categoryList = $L_category->getCategory ();
  11439. $data ['accountType'] = $accountType;
  11440. $data ['cid'] = $cid;
  11441. $data ['categoryList'] = $categoryList;
  11442. $data ['sum'] = $sum;
  11443. $data ['incomeList'] = $incomeList;
  11444. $data ['inputDate'] = $date;
  11445. $data ['memu'] = "receipt";
  11446. $data ['staff'] = $this->staff;
  11447. $data ['receiptMemu'] = 'wasteBook';
  11448. $data ['verifyId'] = $this->verifyId;
  11449. $data ['executeId'] = $this->executeId;
  11450. $this->render ( "/expenses/wasteBookExpenditure", $data );
  11451. }
  11452. function ajaxGetWasteinvoiceReceivables() {
  11453. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11454. Doo::loadClass ( 'XDeode' );
  11455. $XDeode = new XDeode ( 5 );
  11456. $irid = $XDeode->decode ( $serial );
  11457. Doo::loadModel ( 'invoiceReceivables' );
  11458. $invoiceReceivables = new invoiceReceivables ();
  11459. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  11460. echo json_encode ( array (
  11461. 'status' => 1,
  11462. 'detail' => $detail
  11463. ) );
  11464. }
  11465. function ajaxGetPaymentsByAid() {
  11466. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11467. Doo::loadModel ( "accountBook" );
  11468. $accountBook = new accountBook ();
  11469. $detail = $accountBook->getAccountBookByAid ( $serial );
  11470. echo json_encode ( array (
  11471. 'status' => 1,
  11472. 'detail' => $detail
  11473. ) );
  11474. }
  11475. function ajaxGetWasteInvoice() {
  11476. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11477. Doo::loadModel ( 'invoice' );
  11478. $invoice = new invoice ();
  11479. Doo::loadModel ( 'invoiceReceivables' );
  11480. $invoiceReceivables = new invoiceReceivables ();
  11481. $detail = $invoice->getInvoiceByIid ( $serial );
  11482. $detailReceivables = $invoiceReceivables->getInvoiceReceivablesByIrid ( $detail ['irid'] );
  11483. $detail ['receivablesBank'] = $detailReceivables ['receivablesBank'];
  11484. echo json_encode ( array (
  11485. 'status' => 1,
  11486. 'detail' => $detail
  11487. ) );
  11488. }
  11489. /**
  11490. */
  11491. function ajaxGetWasteReceipt() {
  11492. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11493. Doo::loadModel ( 'receipt' );
  11494. $receipt = new receipt ();
  11495. Doo::loadClass ( 'XDeode' );
  11496. $XDeode = new XDeode ( 5 );
  11497. $rid = $XDeode->decode ( $serial );
  11498. // 获得个数据
  11499. $detail = $receipt->getReceiptByRid ( $rid );
  11500. // 初始化
  11501. $detail ['reviseDetail'] = array ();
  11502. if (! empty ( $value ['reviseDetail'] ))
  11503. $detail ['reviseDetail'] = json_decode ( $detail ['reviseDetail'], true );
  11504. $detail ['accountItem'] = json_decode ( $detail ['accountItem'], true );
  11505. $detail ['loanItem'] = json_decode ( $detail ['loanItem'], true );
  11506. $detail ['loanSumCN'] = $this->num_to_rmb ( $detail ['loanSum'] );
  11507. $detail ['sumCN'] = $this->num_to_rmb ( $detail ['sum'] );
  11508. // 获得费用html
  11509. $html = $this->getWasteReceiptHtml ( $detail );
  11510. // 获得费用审批人数据
  11511. $detail = $this->getReceiptApproverHtml ( $detail );
  11512. // 审批执行
  11513. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  11514. <th class="taC" width="90">审批人</th>
  11515. <th class="taC">审批意见</th></tr>';
  11516. foreach ( $detail ['verifyList'] as $key => $value ) {
  11517. $html .= '<tr>
  11518. <td>' . $value [1] . '</td>
  11519. <td>' . $value ['opinion'] . '</td>
  11520. </tr>
  11521. ';
  11522. }
  11523. $html .= ' </tbody></table>';
  11524. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  11525. <th class="taC" width="90">执行人</th>
  11526. <th class="taC">执行意见</th></tr>';
  11527. foreach ( $detail ['executeCopy'] as $key => $value ) {
  11528. $html .= '<tr>
  11529. <td>' . $value [1] . '</td>
  11530. <td>' . $value ['opinion'] . '</td>
  11531. </tr>
  11532. ';
  11533. }
  11534. $html .= ' </tbody></table>';
  11535. $html .= '<table class="table table-bordered table-condensed">
  11536. <tr class="warning">
  11537. <td class="taR"><b>汇款金额</b></td>
  11538. <td width="140" class="taR"><b style="font-size: 24px">¥' . $detail ['amount'] . '</b></td>
  11539. </tr>
  11540. </table>';
  11541. // print_r($detail['verifyList']);
  11542. // header ( 'Content-Type:text/html;charset=utf-8' );
  11543. // echo $html;
  11544. echo json_encode ( array (
  11545. 'status' => 1,
  11546. 'html' => $html,
  11547. 'detail' => $detail
  11548. ) );
  11549. }
  11550. function getReceiptApproverHtml($detail = array()) {
  11551. Doo::loadModel ( 'loanReceipt' );
  11552. $loanReceipt = new loanReceipt ();
  11553. Doo::loadModel ( 'verify' );
  11554. $verify = new verify ();
  11555. Doo::loadModel ( 'staff' );
  11556. $staff = new staff ();
  11557. if (empty ( $detail ))
  11558. return array ();
  11559. $loanList = $loanReceipt->getOne ( array (
  11560. 'where' => 'rid=' . $detail ['loanRid'],
  11561. 'desc' => 'rid',
  11562. 'asArray' => true
  11563. ) );
  11564. if ($detail ['status'] == 3 || $detail ['status'] == 1 || $detail ['status'] == 8 || $detail ['status'] == 9) {
  11565. if ($detail ['status'] == 8 && $detail ['Rtype'] == 1)
  11566. $verifyList ['staff'] = $loanList ['verifyBreakup'];
  11567. else
  11568. $verifyList ['staff'] = $detail ['verifyBreakup'];
  11569. } else
  11570. $verifyList = $verify->getOne ( array (
  11571. 'where' => 'vid=' . $detail ['verify'],
  11572. 'asArray' => true
  11573. ) );
  11574. $verifyList = json_decode ( $verifyList ['staff'], true );
  11575. Doo::loadModel ( 'role' );
  11576. $role = new role ();
  11577. $roleId = 0;
  11578. $flag = true;
  11579. $roleKey = 0;
  11580. $endStaffArray = array ();
  11581. $roleArrayCopy = array ();
  11582. foreach ( $verifyList as $k => $v ) {
  11583. // init verifyStaff
  11584. if ($v [1] == 'ROLE') {
  11585. if (! empty ( $verifyStaff )) {
  11586. $endStaffArray = end ( $verifyStaff );
  11587. }
  11588. $roleVerify = json_decode ( $v [3], true );
  11589. $roleKey = $k;
  11590. $roleArray = array ();
  11591. $rolename = $role->getOne ( array (
  11592. 'where' => 'rid=' . $v [0],
  11593. 'asArray' => true
  11594. ) );
  11595. foreach ( $roleVerify as $o => $p ) {
  11596. $staffID = explode ( '_', $p );
  11597. $staffInfo = $staff->getOne ( array (
  11598. 'where' => 'sid=' . $staffID [0],
  11599. 'asArray' => true
  11600. ) );
  11601. // print_r($staffID);
  11602. $exp = array (
  11603. 0 => $staffInfo ['sid'],
  11604. 1 => $staffID [1],
  11605. 2 => $staffInfo ['avatar'],
  11606. 'date' => '',
  11607. 'date' => '',
  11608. 'opinion' => '',
  11609. 'status' => '',
  11610. 'rolename' => $rolename ['name']
  11611. );
  11612. array_push ( $roleArray, $exp );
  11613. }
  11614. $roleArrayCopy [$v [0]] = $roleArray;
  11615. // $verifyList[$k]['roleArray']=$roleArray;
  11616. }
  11617. $verifyList [$k] ['date'] = "";
  11618. $verifyList [$k] ['opinion'] = "";
  11619. $verifyList [$k] ['status'] = "";
  11620. if (empty ( $verifyStaff )) {
  11621. $verifyList [$k] ['date'] = "";
  11622. $verifyList [$k] ['opinion'] = "";
  11623. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  11624. $verifyList [$k] ['status'] = 4;
  11625. $flag = false;
  11626. }
  11627. } else {
  11628. foreach ( $verifyStaff as $m => $u ) {
  11629. if ($v [0] == $m) {
  11630. $verifyList [$k] ['date'] = $u ['date'];
  11631. $verifyList [$k] ['opinion'] = $u ['opinion'];
  11632. $verifyList [$k] ['status'] = $u ['status'];
  11633. $flag = false;
  11634. break;
  11635. }
  11636. }
  11637. $endStaffArray = end ( $verifyStaff );
  11638. }
  11639. }
  11640. $rolename ['name'] = '';
  11641. if (! empty ( $roleId )) {
  11642. Doo::loadModel ( 'role' );
  11643. $role = new role ();
  11644. $rolename = $role->getOne ( array (
  11645. 'where' => 'rid=' . $roleId,
  11646. 'asArray' => true
  11647. ) );
  11648. }
  11649. if (! empty ( $verifyStaff ))
  11650. $endStaffArray = end ( $verifyStaff );
  11651. $KOP = false;
  11652. foreach ( $roleArrayCopy as $P => $A ) {
  11653. foreach ( $A as $MKI => $AVL ) {
  11654. if (! empty ( $verifyStaff )) {
  11655. // &&$rolename['rid']==$endStaffArray['nextStaff']
  11656. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  11657. $button = 4;
  11658. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  11659. }
  11660. foreach ( $verifyStaff as $m => $u ) {
  11661. $AVLFK = $AVL [0] . '_R';
  11662. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  11663. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  11664. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  11665. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  11666. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  11667. break;
  11668. }
  11669. }
  11670. } else {
  11671. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  11672. $button = 4;
  11673. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  11674. }
  11675. }
  11676. // $roleArray[$MKI]['rolename']=$rolename['name'];
  11677. $KOP = true;
  11678. }
  11679. }
  11680. foreach ( $roleArrayCopy as $k => $v ) {
  11681. foreach ( $verifyList as $m => $n ) {
  11682. if ($n [0] == $k) {
  11683. array_splice ( $verifyList, $m, 1, $v );
  11684. }
  11685. }
  11686. }
  11687. // 费用执行人相关数据
  11688. $executeCopy = json_decode ( $detail ['executeCopy'], true );
  11689. $executeStaff = json_decode ( $detail ['executeStaff'], true );
  11690. foreach ( $executeCopy as $k => $v ) {
  11691. $executeCopy [$k] ['date'] = '';
  11692. $executeCopy [$k] ['opinion'] = '';
  11693. $executeCopy [$k] ['status'] = '';
  11694. if (! empty ( $executeStaff ))
  11695. foreach ( $executeStaff as $m => $u ) {
  11696. if ($v [0] == $m) {
  11697. $executeCopy [$k] ['date'] = $u ['date'];
  11698. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  11699. $executeCopy [$k] ['status'] = $u ['status'];
  11700. break;
  11701. }
  11702. }
  11703. }
  11704. $detail ['executeCopy'] = $executeCopy;
  11705. $detail ['verifyList'] = $verifyList;
  11706. return $detail;
  11707. }
  11708. function getWasteReceiptHtml($detail = array()) {
  11709. if (empty ( $detail ))
  11710. return '';
  11711. $html = '';
  11712. if ($detail ['Rtype'] == 0) { // 报销单
  11713. $html .= '
  11714. <table class="table table-bordered table-condensed">
  11715. <tbody>
  11716. <tr>
  11717. <th colspan="2" class="taC">日常相关费用</th>
  11718. </tr>';
  11719. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  11720. $html .= '
  11721. <tr>
  11722. <th>' . $value ['name'] . '</th>
  11723. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11724. </tr>';
  11725. }
  11726. $html .= '
  11727. <tr>
  11728. <th class="taR">合计</th>
  11729. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  11730. </tr>';
  11731. $html .= '<tr>
  11732. <th colspan="2" class="taC">差旅相关费用</th>
  11733. </tr>';
  11734. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  11735. $html .= '
  11736. <tr>
  11737. <th>' . $value ['name'] . '</th>
  11738. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11739. </tr>';
  11740. }
  11741. $html .= '
  11742. <tr>
  11743. <th class="taR">合计</th>
  11744. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  11745. </tr>';
  11746. $html .= '<tr>
  11747. <th colspan="2" class="taC">培训班费用</th>
  11748. </tr>';
  11749. foreach ( $detail ['accountItem'] ['培训班费用'] as $key => $value ) {
  11750. $html .= '
  11751. <tr>
  11752. <th>' . $value ['name'] . '</th>
  11753. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11754. </tr>';
  11755. }
  11756. $html .= '
  11757. <tr>
  11758. <th class="taR">合计</th>
  11759. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['trainSum'] . '</td>
  11760. </tr>';
  11761. $html .= '<tr>
  11762. <th colspan="2" class="taC">其他</th>
  11763. </tr>';
  11764. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  11765. $html .= '
  11766. <tr>
  11767. <th>' . $value ['name'] . '</th>
  11768. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11769. </tr>';
  11770. }
  11771. $html .= '
  11772. <tr>
  11773. <th class="taR">合计</th>
  11774. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  11775. </tr>';
  11776. $html .= '<tr>
  11777. <th colspan="2" class="taC">报销金额调整</th>
  11778. </tr>';
  11779. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  11780. $html .= '
  11781. <tr>
  11782. <th>' . $value ['name'] . '</th>
  11783. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11784. </tr>';
  11785. }
  11786. $html .= '
  11787. <tr>
  11788. <th class="taR">合计</th>
  11789. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  11790. </tr>';
  11791. $html .= '
  11792. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  11793. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  11794. <tr><th class="taC" colspan="2">报销说明</th></tr>
  11795. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  11796. <tr class="warning">
  11797. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  11798. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  11799. </tr>
  11800. </tbody>
  11801. </table>';
  11802. } elseif ($detail ['Rtype'] == 2) {
  11803. $html .= '
  11804. <table class="table table-bordered table-condensed">
  11805. <tbody>
  11806. <tr>
  11807. <th colspan="2" class="taC">办事处相关费用</th>
  11808. </tr>';
  11809. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  11810. $html .= '
  11811. <tr>
  11812. <th>' . $value ['name'] . '</th>
  11813. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11814. </tr>';
  11815. }
  11816. $html .= '
  11817. <tr>
  11818. <th class="taR">合计</th>
  11819. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  11820. </tr>';
  11821. $html .= '
  11822. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  11823. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  11824. <tr><th class="taC" colspan="2">报销说明</th></tr>
  11825. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  11826. <tr class="warning">
  11827. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  11828. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  11829. </tr>
  11830. </tbody>
  11831. </table>';
  11832. } elseif ($detail ['Rtype'] == 1) {
  11833. if ($detail ['loanRid'] != 0 && ! empty ( $detail ['accountItem'] )) {
  11834. $html .= '<table class="table table-bordered table-condensed">
  11835. <tbody>
  11836. <tr>
  11837. <th colspan="2" class="taC">日常相关费用</th>
  11838. </tr>';
  11839. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  11840. $html .= '
  11841. <tr>
  11842. <th>' . $value ['name'] . '</th>
  11843. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11844. </tr>';
  11845. }
  11846. $html .= '
  11847. <tr>
  11848. <th class="taR">合计</th>
  11849. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  11850. </tr>';
  11851. $html .= '<tr>
  11852. <th colspan="2" class="taC">差旅相关费用</th>
  11853. </tr>';
  11854. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  11855. $html .= '
  11856. <tr>
  11857. <th>' . $value ['name'] . '</th>
  11858. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11859. </tr>';
  11860. }
  11861. $html .= '
  11862. <tr>
  11863. <th class="taR">合计</th>
  11864. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  11865. </tr>';
  11866. $html .= '<tr>
  11867. <th colspan="2" class="taC">培训班费用</th>
  11868. </tr>';
  11869. foreach ( $detail ['accountItem'] ['培训班费用'] as $key => $value ) {
  11870. $html .= '
  11871. <tr>
  11872. <th>' . $value ['name'] . '</th>
  11873. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11874. </tr>';
  11875. }
  11876. $html .= '
  11877. <tr>
  11878. <th class="taR">合计</th>
  11879. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['trainSum'] . '</td>
  11880. </tr>';
  11881. $html .= '<tr>
  11882. <th colspan="2" class="taC">其他</th>
  11883. </tr>';
  11884. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  11885. $html .= '
  11886. <tr>
  11887. <th>' . $value ['name'] . '</th>
  11888. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11889. </tr>';
  11890. }
  11891. $html .= '
  11892. <tr>
  11893. <th class="taR">合计</th>
  11894. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  11895. </tr>';
  11896. $html .= '<tr>
  11897. <th colspan="2" class="taC">报销金额调整</th>
  11898. </tr>';
  11899. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  11900. $html .= '
  11901. <tr>
  11902. <th>' . $value ['name'] . '</th>
  11903. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11904. </tr>';
  11905. }
  11906. $html .= '
  11907. <tr>
  11908. <th class="taR">合计</th>
  11909. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  11910. </tr>';
  11911. $html .= '
  11912. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  11913. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  11914. <tr><th class="taC" colspan="2">报销说明</th></tr>
  11915. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  11916. <tr class="warning">
  11917. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  11918. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  11919. </tr>
  11920. </tbody>
  11921. </table>';
  11922. }
  11923. Doo::loadModel ( 'loanReceipt' );
  11924. $loanReceipt = new loanReceipt ();
  11925. $loanList = $loanReceipt->getOne ( array (
  11926. 'where' => 'rid=' . $detail ['loanRid'],
  11927. 'desc' => 'rid',
  11928. 'asArray' => true
  11929. ) );
  11930. // print_r($loanList);
  11931. $html .= '<table class="table table-bordered table-condensed">
  11932. <tbody>
  11933. <tr>
  11934. <th colspan="2" class="taC">借款费用</th>
  11935. </tr>';
  11936. foreach ( $detail ['loanItem'] ['借款费用'] as $key => $value ) {
  11937. $html .= '<tr>
  11938. <th>' . $value ['name'] . '</th>
  11939. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11940. </tr>';
  11941. }
  11942. $html .= '<tr>
  11943. <th class="taC" colspan="2">产生费用所在办事处</th>
  11944. </tr>
  11945. <tr>
  11946. <th style="text-align: center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th>
  11947. </tr>
  11948. <tr>
  11949. <th class="taC" colspan="2">费用说明</th>
  11950. </tr>
  11951. <tr>
  11952. <td colspan="2">' . $loanList ['explanation'] . '</td>
  11953. </tr>
  11954. <tr class="warning">
  11955. <td class="taR"><b>(' . $loanList ['receiptOrder'] . ')本次费用合计</b></td>
  11956. <td class="taR"><b style="font-size: 24px">¥' . $detail ['loanSum'] . '</b><br>' . $detail ['loanSumCN'] . '</td>
  11957. </tr>
  11958. </tbody>
  11959. </table>
  11960. ';
  11961. }
  11962. return $html;
  11963. }
  11964. /**
  11965. * 计算流水
  11966. */
  11967. function getWasteBookStatistics($waste = array(), $inComeStatistics) {
  11968. $bakWaste ['bank'] = array (
  11969. 'CGBDeposit' => 0,
  11970. 'ICBCDeposit' => 0,
  11971. 'HUADeposit' => 0,
  11972. 'PersonalDeposit' => 0
  11973. );
  11974. $bakWaste ['financial'] = array (
  11975. 'current' => array (
  11976. 'CGBDeposit' => 0,
  11977. 'ICBCDeposit' => 0
  11978. ),
  11979. 'fixed' => array (
  11980. 'CGBDeposit' => 0,
  11981. 'ICBCDeposit' => 0
  11982. )
  11983. );
  11984. // 存款
  11985. foreach ( $waste ['bank'] as $key => $value ) {
  11986. // 收入
  11987. foreach ( $inComeStatistics ['incomeStatistics'] as $k => $v ) {
  11988. // 广发
  11989. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  11990. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  11991. }
  11992. // 工商
  11993. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  11994. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  11995. }
  11996. // 华润
  11997. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  11998. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  11999. }
  12000. // 个人
  12001. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12002. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12003. }
  12004. }
  12005. }
  12006. foreach ( $waste ['bank'] as $key => $value ) {
  12007. // 支出
  12008. foreach ( $inComeStatistics ['expenditureStatistics'] as $k => $v ) {
  12009. // 广发
  12010. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12011. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12012. }
  12013. // 工商
  12014. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12015. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12016. }
  12017. // 华润
  12018. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12019. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12020. }
  12021. // 个人
  12022. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12023. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12024. }
  12025. }
  12026. }
  12027. // 活期
  12028. foreach ( $waste ['financial'] ['current'] as $key => $value ) {
  12029. foreach ( $inComeStatistics ['currentStatistics'] as $k => $v ) {
  12030. // 广发
  12031. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12032. $waste ['financial'] ['current'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  12033. }
  12034. // 工商
  12035. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12036. $waste ['financial'] ['current'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  12037. }
  12038. // 个人
  12039. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12040. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  12041. }
  12042. }
  12043. }
  12044. // print_r($inComeStatistics ['fixedStatistics']);
  12045. // 固期
  12046. foreach ( $waste ['financial'] ['fixed'] as $key => $value ) {
  12047. foreach ( $inComeStatistics ['fixedStatistics'] as $k => $v ) {
  12048. // 广发
  12049. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12050. $waste ['financial'] ['fixed'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  12051. }
  12052. // 工商
  12053. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12054. $waste ['financial'] ['fixed'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  12055. }
  12056. // 个人
  12057. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12058. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  12059. }
  12060. }
  12061. }
  12062. return $waste;
  12063. }
  12064. function lyt() {
  12065. Doo::loadModel ( "receiptDetail" );
  12066. $receiptDetail = new receiptDetail ();
  12067. $receiptCollectList = $receiptDetail->find ( array (
  12068. 'where' => 'status=1 ',
  12069. 'asArray' => true
  12070. ) );
  12071. foreach ( $receiptCollectList as $key => $value ) {
  12072. $receiptDetail = new receiptDetail ();
  12073. $receiptDetail->pastDate = $value ['date'];
  12074. $receiptDetail->update ( array (
  12075. 'where' => "rdid= '" . $value ['rdid'] . "'"
  12076. ) );
  12077. }
  12078. }
  12079. function staffCollectMonthDetail() {
  12080. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12081. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12082. if (! $year)
  12083. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12084. if (! $month)
  12085. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12086. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  12087. if (! $nature){
  12088. $nature = isset ( $this->params ['nature'] ) ? $this->params ['nature'] : 'ONJOB';
  12089. }
  12090. Doo::loadModel ( 'staff' );
  12091. $staff = new staff ();
  12092. Doo::loadModel ( "receiptDetail" );
  12093. $receiptDetail = new receiptDetail ();
  12094. Doo::loadModel ( 'accountItem' );
  12095. $accountItem = new accountItem ();
  12096. Doo::loadModel ( 'statistics' );
  12097. $statistics = new statistics ();
  12098. Doo::loadModel ( 'L_category' );
  12099. $lCategory = new L_category ();
  12100. Doo::loadModel ( "receiptAuthorityManage" );
  12101. $receiptAuthorityManage = new receiptAuthorityManage ();
  12102. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  12103. $cidList = array ();
  12104. foreach ( $imcStaff as $key => $value ) {
  12105. array_push ( $cidList, $value ['cid'] );
  12106. }
  12107. $cidString = implode ( ',', $cidList );
  12108. $naturecon='';
  12109. if ($nature=='ONJOB'){
  12110. $naturecon=' and (nature!=4 )';
  12111. }elseif($nature=='LEAVEJOB'){
  12112. $naturecon=' and (nature=4 )';
  12113. }else{
  12114. die ( 'illegal request--nature' );
  12115. }
  12116. $staffList = $staff->find ( array (
  12117. 'where' => 'username!="admin" and cid in (' . $cidString . ')'.$naturecon,
  12118. 'asArray' => true
  12119. ) );
  12120. $categoryList = $staff->find ( array (
  12121. 'select' => 'COUNT(*) as count,cid,category',
  12122. 'where' => 'username !="admin" and cid in (' . $cidString . ')'.$naturecon,
  12123. 'groupby' => 'cid',
  12124. 'asArray' => true
  12125. ) );
  12126. $list = array ();
  12127. foreach ( $categoryList as $vlu ) {
  12128. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  12129. $r1 = 0;
  12130. $r2 = 0;
  12131. $r3 = 0;
  12132. $r4 = 0;
  12133. $r5 = 0;
  12134. $r6 = 0;
  12135. $r7 = 0;
  12136. $r8 = 0;
  12137. $r9 = 0;
  12138. $r10 = 0;
  12139. $r11 = 0;
  12140. $r12 = 0;
  12141. $r13 = 0;
  12142. $r14 = 0;
  12143. $r15 = 0;
  12144. $r16 = 0;
  12145. $r17 = 0;
  12146. $r18 = 0;
  12147. $c1 = 0;
  12148. $c2 = 0;
  12149. $c3 = 0;
  12150. $c4 = 0;
  12151. $c5 = 0;
  12152. $c6 = 0;
  12153. $p1 = 0;
  12154. $p2 = 0;
  12155. $p3 = 0;
  12156. $p4 = 0;
  12157. $p5 = 0;
  12158. $p6 = 0;
  12159. $p7 = 0;
  12160. $p8 = 0;
  12161. $p9 = 0;
  12162. $p10 = 0;
  12163. $p11 = 0;
  12164. $t1 = 0;
  12165. $t2 = 0;
  12166. $t3 = 0;
  12167. $t4 = 0;
  12168. $t5 = 0;
  12169. $s1 = 0;
  12170. $m1 = 0;
  12171. foreach ( $staffList as $value ) {
  12172. if ($vlu ['cid'] == $value ['cid']) {
  12173. // pastDate
  12174. $receiptCollectList = $receiptDetail->find ( array (
  12175. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12176. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12177. 'groupby' => 'item,Month(pastDate),itemCategory',
  12178. 'asArray' => true
  12179. ) );
  12180. // if ($value['sid']==42){
  12181. // print_r($receiptCollectList);die;
  12182. // }
  12183. if (! empty ( $receiptCollectList )) {
  12184. $receiptL = array (
  12185. '日常相关费用' => array (),
  12186. '差旅相关费用' => array (),
  12187. '培训班费用' => array (),
  12188. '其他' => array ()
  12189. );
  12190. $html = "";
  12191. $psum = 0;
  12192. $item = array (
  12193. '市内交通费',
  12194. '市内出租费',
  12195. '办事处房租',
  12196. '电话费',
  12197. '水费',
  12198. '电费',
  12199. '办公费用',
  12200. '邮寄费',
  12201. '其他费用',
  12202. '车辆费用',
  12203. '广告费',
  12204. '团队建设费',
  12205. '物业管理费',
  12206. '宽带费',
  12207. '人员薪酬',
  12208. '公积金',
  12209. '社保'
  12210. );
  12211. foreach ( $item as $va ) {
  12212. $falg = true;
  12213. foreach ( $receiptCollectList as $v ) {
  12214. if ($v ['itemCategory'] == '日常相关费用') {
  12215. if ($v ['item'] == $va) {
  12216. if ($va == '市内交通费')
  12217. $r1 += $v ['price'];
  12218. if ($va == '市内出租费')
  12219. $r2 += $v ['price'];
  12220. if ($va == '办事处房租')
  12221. $r3 += $v ['price'];
  12222. if ($va == '电话费')
  12223. $r4 += $v ['price'];
  12224. if ($va == '水费')
  12225. $r5 += $v ['price'];
  12226. if ($va == '电费')
  12227. $r6 += $v ['price'];
  12228. if ($va == '办公费用')
  12229. $r7 += $v ['price'];
  12230. if ($va == '邮寄费')
  12231. $r8 += $v ['price'];
  12232. if ($va == '其他费用')
  12233. $r9 += $v ['price'];
  12234. if ($va == '车辆费用')
  12235. $r10 += $v ['price'];
  12236. if ($va == '广告费')
  12237. $r11 += $v ['price'];
  12238. if ($va == '团队建设费')
  12239. $r13 += $v ['price'];
  12240. if ($va == '物业管理费')
  12241. $r14 += $v ['price'];
  12242. if ($va == '宽带费')
  12243. $r15 += $v ['price'];
  12244. if ($va == '公积金')
  12245. $r16 += $v ['price'];
  12246. if ($va == '社保')
  12247. $r17 += $v ['price'];
  12248. if ($va == '人员薪酬')
  12249. $r18 += $v ['price'];
  12250. $psum += $v ['price'];
  12251. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12252. $falg = false;
  12253. break;
  12254. }
  12255. }
  12256. }
  12257. if ($falg)
  12258. $html .= '<td class="taR">-</td>';
  12259. }
  12260. $r12 += $psum;
  12261. if (! empty ( $psum ))
  12262. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12263. else
  12264. $psum = '<td class="colGreen taR">-</td>';
  12265. $receiptL ['日常相关费用'] = $psum . $html;
  12266. /* ----------------------------------- */
  12267. $html = "";
  12268. $psum = 0;
  12269. $item = array (
  12270. '往来交通费',
  12271. '市内交通费',
  12272. '出差住宿费',
  12273. '出差补助',
  12274. '其他费用'
  12275. );
  12276. foreach ( $item as $va ) {
  12277. $falg = true;
  12278. foreach ( $receiptCollectList as $v ) {
  12279. if ($v ['itemCategory'] == '差旅相关费用') {
  12280. if ($v ['item'] == $va) {
  12281. if ($va == '往来交通费')
  12282. $c1 += $v ['price'];
  12283. if ($va == '市内交通费')
  12284. $c2 += $v ['price'];
  12285. if ($va == '出差住宿费')
  12286. $c3 += $v ['price'];
  12287. if ($va == '出差补助')
  12288. $c4 += $v ['price'];
  12289. if ($va == '其他费用')
  12290. $c5 += $v ['price'];
  12291. $psum += $v ['price'];
  12292. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12293. $falg = false;
  12294. break;
  12295. }
  12296. }
  12297. }
  12298. if ($falg)
  12299. $html .= '<td class="taR">-</td>';
  12300. }
  12301. $c6 += $psum;
  12302. if (! empty ( $psum ))
  12303. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12304. else
  12305. $psum = '<td class="colGreen taR">-</td>';
  12306. $receiptL ['差旅相关费用'] = $psum . $html;
  12307. /* ------------------------------------- */
  12308. $html = "";
  12309. $psum = 0;
  12310. $item = array (
  12311. '场租费',
  12312. '薪酬',
  12313. '住宿费',
  12314. '交通费',
  12315. '餐饮费',
  12316. '办公费',
  12317. '公关费',
  12318. '其他',
  12319. '电话费',
  12320. '邮寄费'
  12321. );
  12322. foreach ( $item as $va ) {
  12323. $falg = true;
  12324. foreach ( $receiptCollectList as $v ) {
  12325. if ($v ['itemCategory'] == '培训班费用') {
  12326. if ($v ['item'] == $va) {
  12327. if ($va == '场租费')
  12328. $p1 += $v ['price'];
  12329. if ($va == '薪酬')
  12330. $p2 += $v ['price'];
  12331. if ($va == '住宿费')
  12332. $p3 += $v ['price'];
  12333. if ($va == '交通费')
  12334. $p4 += $v ['price'];
  12335. if ($va == '餐饮费')
  12336. $p5 += $v ['price'];
  12337. if ($va == '办公费')
  12338. $p6 += $v ['price'];
  12339. if ($va == '公关费')
  12340. $p7 += $v ['price'];
  12341. if ($va == '其他')
  12342. $p8 += $v ['price'];
  12343. if ($va == '电话费')
  12344. $p9 += $v ['price'];
  12345. if ($va == '邮寄费')
  12346. $p10 += $v ['price'];
  12347. $psum += $v ['price'];
  12348. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12349. $falg = false;
  12350. break;
  12351. }
  12352. }
  12353. }
  12354. if ($falg)
  12355. $html .= '<td class="taR">-</td>';
  12356. }
  12357. $p11 += $psum;
  12358. if (! empty ( $psum ))
  12359. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12360. else
  12361. $psum = '<td class="colGreen taR">-</td>';
  12362. $receiptL ['培训班费用'] = $psum . $html;
  12363. /* ------------------------------------- */
  12364. $html = "";
  12365. $psum = 0;
  12366. $item = array (
  12367. '公关费',
  12368. '广告费',
  12369. '借款',
  12370. '可自加费用'
  12371. );
  12372. foreach ( $item as $va ) {
  12373. $falg = true;
  12374. foreach ( $receiptCollectList as $v ) {
  12375. if ($v ['itemCategory'] == '其他') {
  12376. // if ($value['sid']==42){
  12377. //
  12378. // echo var_dump($v['item']);
  12379. // echo var_dump($va);
  12380. // echo var_dump($v['item']==" ".$va);
  12381. // echo $v['item']."==".$va."/<br/>";
  12382. // //print_r( $receiptCollectList);//echo $va;
  12383. // }
  12384. if (trim ( $v ['item'] ) == $va) {
  12385. if ($va == '公关费')
  12386. $t1 += $v ['price'];
  12387. if ($va == '广告费') {
  12388. $t2 += $v ['price'];
  12389. }
  12390. if ($va == '借款')
  12391. $t3 += $v ['price'];
  12392. if ($va == '可自加费用')
  12393. $t4 += $v ['price'];
  12394. $psum += $v ['price'];
  12395. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12396. $falg = false;
  12397. break;
  12398. }
  12399. }
  12400. }
  12401. if ($falg)
  12402. $html .= '<td class="taR">-</td>';
  12403. }
  12404. $t5 += $psum;
  12405. if (! empty ( $psum ))
  12406. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12407. else
  12408. $psum = '<td class="colGreen taR">-</td>';
  12409. $receiptL ['其他'] = $psum . $html;
  12410. /* ------------------------------------- */
  12411. $html = "";
  12412. $psum = 0;
  12413. foreach ( $receiptCollectList as $v ) {
  12414. if ($v ['itemCategory'] == '报销金额调整') {
  12415. if (! empty ( $v ['price'] )) {
  12416. $psum += $v ['price'];
  12417. }
  12418. }
  12419. }
  12420. $s1 += $psum;
  12421. if (! empty ( $psum ))
  12422. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  12423. else
  12424. $psum = '<td class="taR colOrange">-</td>';
  12425. $receiptL ['报销金额调整'] = $psum . $html;
  12426. } else {
  12427. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  12428. <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>
  12429. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12430. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  12431. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12432. $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>
  12433. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12434. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12435. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  12436. }
  12437. $monthStaffPrice = $receiptDetail->find ( array (
  12438. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12439. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12440. 'groupby' => 'Month(pastDate)',
  12441. 'asArray' => true
  12442. ) );
  12443. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  12444. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  12445. $m1 += $monthStaffPrice [0] ['price'];
  12446. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  12447. } else
  12448. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  12449. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  12450. $list [$value ['username']] = $receiptL;
  12451. }
  12452. }
  12453. $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>
  12454. <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>
  12455. <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>';
  12456. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  12457. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  12458. $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>
  12459. <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>';
  12460. $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>';
  12461. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  12462. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  12463. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  12464. }
  12465. $data ['list'] = $list;
  12466. // print_r($list);
  12467. $receiptCollectList = $receiptDetail->find ( array (
  12468. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12469. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12470. 'groupby' => 'item,Month(pastDate),itemCategory',
  12471. 'asArray' => true
  12472. ) );
  12473. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  12474. // statistics html
  12475. $stList = $statistics->getOne ( array (
  12476. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  12477. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  12478. 'groupby' => 'Month(date)',
  12479. 'asArray' => true
  12480. ) );
  12481. if (empty ( $stList ))
  12482. $stList = array (
  12483. 'rePrice' => 0,
  12484. 'agPrice' => 0
  12485. );
  12486. $data ['stList'] = array (
  12487. 'rePrice' => $stList ['rePrice'],
  12488. 'agPrice' => $stList ['agPrice'],
  12489. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12490. );
  12491. $monthHtml = "";
  12492. for($i = 1; $i <= 12; $i ++) {
  12493. if ($i == $month)
  12494. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  12495. else
  12496. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  12497. }
  12498. $data ['monthHtml'] = $monthHtml;
  12499. $data ['year'] = $year;
  12500. $data ['month'] = $month;
  12501. $data ['nature'] = $nature;
  12502. $data ['memu'] = "receipt";
  12503. $data ['staff'] = $this->staff;
  12504. $data ['receiptMemu'] = 'companyCategoryCollect';
  12505. $data ['verifyId'] = $this->verifyId;
  12506. $data ['executeId'] = $this->executeId;
  12507. $this->render ( "/admin/staffCollectMonthDetail", $data );
  12508. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  12509. }
  12510. function staffCollectMonthDetail2() {
  12511. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12512. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12513. if (! $year)
  12514. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12515. if (! $month)
  12516. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12517. Doo::loadModel ( 'staff' );
  12518. $staff = new staff ();
  12519. Doo::loadModel ( "receiptDetail" );
  12520. $receiptDetail = new receiptDetail ();
  12521. Doo::loadModel ( 'accountItem' );
  12522. $accountItem = new accountItem ();
  12523. Doo::loadModel ( 'statistics' );
  12524. $statistics = new statistics ();
  12525. Doo::loadModel ( 'L_category' );
  12526. $lCategory = new L_category ();
  12527. $staffList = $staff->find ( array (
  12528. 'where' => 'username!="admin"',
  12529. 'asArray' => true
  12530. ) );
  12531. $categoryList = $staff->find ( array (
  12532. 'select' => 'COUNT(*) as count,cid,category',
  12533. 'where' => 'username !="admin"',
  12534. 'groupby' => 'cid',
  12535. 'asArray' => true
  12536. ) );
  12537. $list = array ();
  12538. foreach ( $categoryList as $vlu ) {
  12539. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  12540. $r1 = 0;
  12541. $r2 = 0;
  12542. $r3 = 0;
  12543. $r4 = 0;
  12544. $r5 = 0;
  12545. $r6 = 0;
  12546. $r7 = 0;
  12547. $r8 = 0;
  12548. $r9 = 0;
  12549. $r10 = 0;
  12550. $r11 = 0;
  12551. $r12 = 0;
  12552. $r13 = 0;
  12553. $r14 = 0;
  12554. $r15 = 0;
  12555. $c1 = 0;
  12556. $c2 = 0;
  12557. $c3 = 0;
  12558. $c4 = 0;
  12559. $c5 = 0;
  12560. $c6 = 0;
  12561. $p1 = 0;
  12562. $p2 = 0;
  12563. $p3 = 0;
  12564. $p4 = 0;
  12565. $p5 = 0;
  12566. $p6 = 0;
  12567. $p7 = 0;
  12568. $p8 = 0;
  12569. $p9 = 0;
  12570. $t1 = 0;
  12571. $t2 = 0;
  12572. $t3 = 0;
  12573. $t4 = 0;
  12574. $t5 = 0;
  12575. $s1 = 0;
  12576. $m1 = 0;
  12577. foreach ( $staffList as $value ) {
  12578. if ($vlu ['cid'] == $value ['cid']) {
  12579. $receiptCollectList = $receiptDetail->find ( array (
  12580. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  12581. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  12582. 'groupby' => 'item,Month(date),itemCategory',
  12583. 'asArray' => true
  12584. ) );
  12585. if (! empty ( $receiptCollectList )) {
  12586. $receiptL = array (
  12587. '日常相关费用' => array (),
  12588. '差旅相关费用' => array (),
  12589. '培训班费用' => array (),
  12590. '其他' => array ()
  12591. );
  12592. $html = "";
  12593. $psum = 0;
  12594. $item = array (
  12595. '市内交通费',
  12596. '市内出租费',
  12597. '办事处房租',
  12598. '电话费',
  12599. '水费',
  12600. '电费',
  12601. '办公费用',
  12602. '邮寄费',
  12603. '其他费用',
  12604. '车辆费用',
  12605. '广告费',
  12606. '团队建设费',
  12607. '物业管理费',
  12608. '宽带费'
  12609. );
  12610. foreach ( $item as $va ) {
  12611. $falg = true;
  12612. foreach ( $receiptCollectList as $v ) {
  12613. if ($v ['itemCategory'] == '日常相关费用') {
  12614. if ($v ['item'] == $va) {
  12615. if ($va == '市内交通费')
  12616. $r1 += $v ['price'];
  12617. if ($va == '市内出租费')
  12618. $r2 += $v ['price'];
  12619. if ($va == '办事处房租')
  12620. $r3 += $v ['price'];
  12621. if ($va == '电话费')
  12622. $r4 += $v ['price'];
  12623. if ($va == '水费')
  12624. $r5 += $v ['price'];
  12625. if ($va == '电费')
  12626. $r6 += $v ['price'];
  12627. if ($va == '办公费用')
  12628. $r7 += $v ['price'];
  12629. if ($va == '邮寄费')
  12630. $r8 += $v ['price'];
  12631. if ($va == '其他费用')
  12632. $r9 += $v ['price'];
  12633. if ($va == '车辆费用')
  12634. $r10 += $v ['price'];
  12635. if ($va == '广告费')
  12636. $r11 += $v ['price'];
  12637. if ($va == '团队建设费')
  12638. $r13 += $v ['price'];
  12639. if ($va == '物业管理费')
  12640. $r14 += $v ['price'];
  12641. if ($va == '宽带费')
  12642. $r15 += $v ['price'];
  12643. $psum += $v ['price'];
  12644. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12645. $falg = false;
  12646. break;
  12647. }
  12648. }
  12649. }
  12650. if ($falg)
  12651. $html .= '<td class="taR">-</td>';
  12652. }
  12653. $r12 += $psum;
  12654. if (! empty ( $psum ))
  12655. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12656. else
  12657. $psum = '<td class="colGreen taR">-</td>';
  12658. $receiptL ['日常相关费用'] = $psum . $html;
  12659. /* ----------------------------------- */
  12660. $html = "";
  12661. $psum = 0;
  12662. $item = array (
  12663. '往来交通费',
  12664. '市内交通费',
  12665. '出差住宿费',
  12666. '出差补助',
  12667. '其他费用'
  12668. );
  12669. foreach ( $item as $va ) {
  12670. $falg = true;
  12671. foreach ( $receiptCollectList as $v ) {
  12672. if ($v ['itemCategory'] == '差旅相关费用') {
  12673. if ($v ['item'] == $va) {
  12674. if ($va == '往来交通费')
  12675. $c1 += $v ['price'];
  12676. if ($va == '市内交通费')
  12677. $c2 += $v ['price'];
  12678. if ($va == '出差住宿费')
  12679. $c3 += $v ['price'];
  12680. if ($va == '出差补助')
  12681. $c4 += $v ['price'];
  12682. if ($va == '其他费用')
  12683. $c5 += $v ['price'];
  12684. $psum += $v ['price'];
  12685. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12686. $falg = false;
  12687. break;
  12688. }
  12689. }
  12690. }
  12691. if ($falg)
  12692. $html .= '<td class="taR">-</td>';
  12693. }
  12694. $c6 += $psum;
  12695. if (! empty ( $psum ))
  12696. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12697. else
  12698. $psum = '<td class="colGreen taR">-</td>';
  12699. $receiptL ['差旅相关费用'] = $psum . $html;
  12700. /* ------------------------------------- */
  12701. $html = "";
  12702. $psum = 0;
  12703. $item = array (
  12704. '场租费',
  12705. '薪酬',
  12706. '住宿费',
  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. $p1 += $v ['price'];
  12720. if ($va == '薪酬')
  12721. $p2 += $v ['price'];
  12722. if ($va == '住宿费')
  12723. $p3 += $v ['price'];
  12724. if ($va == '交通费')
  12725. $p4 += $v ['price'];
  12726. if ($va == '餐饮费')
  12727. $p5 += $v ['price'];
  12728. if ($va == '办公费')
  12729. $p6 += $v ['price'];
  12730. if ($va == '公关费')
  12731. $p7 += $v ['price'];
  12732. if ($va == '其他')
  12733. $p8 += $v ['price'];
  12734. $psum += $v ['price'];
  12735. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12736. $falg = false;
  12737. break;
  12738. }
  12739. }
  12740. }
  12741. if ($falg)
  12742. $html .= '<td class="taR">-</td>';
  12743. }
  12744. $p9 += $psum;
  12745. if (! empty ( $psum ))
  12746. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12747. else
  12748. $psum = '<td class="colGreen taR">-</td>';
  12749. $receiptL ['培训班费用'] = $psum . $html;
  12750. /* ------------------------------------- */
  12751. $html = "";
  12752. $psum = 0;
  12753. $item = array (
  12754. '公关费',
  12755. '广告费',
  12756. '借款',
  12757. '可自加费用'
  12758. );
  12759. foreach ( $item as $va ) {
  12760. $falg = true;
  12761. foreach ( $receiptCollectList as $v ) {
  12762. if ($v ['itemCategory'] == '其他') {
  12763. if ($v ['item'] == $va) {
  12764. if ($va == '公关费')
  12765. $t1 += $v ['price'];
  12766. if ($va == '广告费')
  12767. $t2 += $v ['price'];
  12768. if ($va == '借款')
  12769. $t3 += $v ['price'];
  12770. if ($va == '可自加费用')
  12771. $t4 += $v ['price'];
  12772. $psum += $v ['price'];
  12773. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12774. $falg = false;
  12775. break;
  12776. }
  12777. }
  12778. }
  12779. if ($falg)
  12780. $html .= '<td class="taR">-</td>';
  12781. }
  12782. $t5 += $psum;
  12783. if (! empty ( $psum ))
  12784. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12785. else
  12786. $psum = '<td class="colGreen taR">-</td>';
  12787. $receiptL ['其他'] = $psum . $html;
  12788. /* ------------------------------------- */
  12789. $html = "";
  12790. $psum = 0;
  12791. foreach ( $receiptCollectList as $v ) {
  12792. if ($v ['itemCategory'] == '报销金额调整') {
  12793. if (! empty ( $v ['price'] )) {
  12794. $psum += $v ['price'];
  12795. }
  12796. }
  12797. }
  12798. $s1 += $psum;
  12799. if (! empty ( $psum ))
  12800. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  12801. else
  12802. $psum = '<td class="taR colOrange">-</td>';
  12803. $receiptL ['报销金额调整'] = $psum . $html;
  12804. } else {
  12805. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  12806. <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>';
  12807. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  12808. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12809. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  12810. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12811. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12812. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  12813. }
  12814. $monthStaffPrice = $receiptDetail->find ( array (
  12815. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  12816. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  12817. 'asArray' => true
  12818. ) );
  12819. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  12820. $m1 += $monthStaffPrice [0] ['price'];
  12821. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  12822. } else
  12823. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  12824. $list [$value ['username']] = $receiptL;
  12825. }
  12826. }
  12827. $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>
  12828. <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>
  12829. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  12830. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  12831. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  12832. $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>
  12833. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  12834. $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>';
  12835. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  12836. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  12837. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  12838. }
  12839. $data ['list'] = $list;
  12840. $receiptCollectList = $receiptDetail->find ( array (
  12841. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  12842. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  12843. 'groupby' => 'item,Month(date),itemCategory',
  12844. 'asArray' => true
  12845. ) );
  12846. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  12847. // statistics html
  12848. $stList = $statistics->getOne ( array (
  12849. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  12850. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  12851. 'groupby' => 'Month(date)',
  12852. 'asArray' => true
  12853. ) );
  12854. if (empty ( $stList ))
  12855. $stList = array (
  12856. 'rePrice' => 0,
  12857. 'agPrice' => 0
  12858. );
  12859. $data ['stList'] = array (
  12860. 'rePrice' => $stList ['rePrice'],
  12861. 'agPrice' => $stList ['agPrice'],
  12862. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12863. );
  12864. $monthHtml = "";
  12865. for($i = 1; $i <= 12; $i ++) {
  12866. if ($i == $month)
  12867. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  12868. else
  12869. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  12870. }
  12871. $data ['monthHtml'] = $monthHtml;
  12872. $data ['year'] = $year;
  12873. $data ['month'] = $month;
  12874. $data ['memu'] = "receipt";
  12875. $data ['staff'] = $this->staff;
  12876. $data ['receiptMemu'] = 'companyCategoryCollect';
  12877. $data ['verifyId'] = $this->verifyId;
  12878. $data ['executeId'] = $this->executeId;
  12879. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  12880. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  12881. }
  12882. /**
  12883. * 用户报销单列表
  12884. */
  12885. function receiptStatisticsStaffDetail() {
  12886. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12887. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12888. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  12889. Doo::loadModel ( "receipt" );
  12890. $receipt = new receipt ();
  12891. Doo::loadModel ( "receiptDetail" );
  12892. $receiptDetail = new receiptDetail ();
  12893. Doo::loadModel ( 'staff' );
  12894. $staff = new staff ();
  12895. Doo::loadModel ( 'accountItem' );
  12896. $accountItem = new accountItem ();
  12897. Doo::loadModel ( 'statistics' );
  12898. $statistics = new statistics ();
  12899. if (! empty ( $username )) {
  12900. $username = addslashes ( urldecode ( $username ) );
  12901. $staffDetail = $staff->getStaffByName ( $username );
  12902. if (empty ( $staffDetail ))
  12903. die ( 'illegal request' );
  12904. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  12905. $itemList = $accountItem->getAccountItem ();
  12906. $itemHtml = '';
  12907. $categoryHtml = '';
  12908. $itemKeyList = array_keys ( $itemList );
  12909. $revisePrice = 0;
  12910. // 报销单内容详情
  12911. foreach ( $list as $key => $value ) {
  12912. $accountItemList = json_decode ( $value ['accountItem'], true );
  12913. $list [$key] ['accountItemList'] = $accountItemList;
  12914. $receiptItemHtml = '';
  12915. foreach ( $itemKeyList as $v ) {
  12916. if ($v == '日常相关费用')
  12917. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  12918. elseif ($v == '差旅相关费用')
  12919. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  12920. elseif ($v == '培训班费用')
  12921. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  12922. elseif ($v == '其他')
  12923. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  12924. foreach ( $itemList [$v] as $ke => $va ) {
  12925. $falg = true;
  12926. if (! empty ( $accountItemList [$v] )) {
  12927. foreach ( $accountItemList [$v] as $ve ) {
  12928. if ($va ['name'] == $ve ['name']) {
  12929. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  12930. $falg = false;
  12931. break;
  12932. }
  12933. }
  12934. }
  12935. if ($falg)
  12936. $receiptItemHtml .= '<td class="taR"></td>';
  12937. }
  12938. }
  12939. // 金额调整和费用查看
  12940. $revisePrice += $value ['revisePrice'];
  12941. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  12942. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" id="sen'.$key.'" data="' . htmlspecialchars($value ['explanation']) . '" onclick=showExplanation() >查看</a></td>';
  12943. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  12944. }
  12945. // 报销单合计
  12946. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  12947. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  12948. $receiptTotalHtml = '';
  12949. // 报销单项目抬头
  12950. foreach ( $itemKeyList as $value ) {
  12951. $count = count ( $itemList [$value] ) + 1;
  12952. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  12953. $categoryHtml .= '<th class="taC">合计</th>';
  12954. $sumfalg=true;
  12955. foreach ( $rtl as $rtlValue ) {
  12956. if ($rtlValue ['itemCategory'] == $value) {
  12957. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  12958. $sumfalg=false;
  12959. break;
  12960. }
  12961. }
  12962. if ($sumfalg)
  12963. $receiptTotalHtml .= '<th></th>';
  12964. foreach ( $itemList [$value] as $k => $v ) {
  12965. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  12966. // 合计
  12967. $falg = true;
  12968. foreach ( $receiptTotalList as $ve ) {
  12969. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  12970. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  12971. $falg = false;
  12972. break;
  12973. }
  12974. }
  12975. if ($falg)
  12976. $receiptTotalHtml .= '<th></th>';
  12977. }
  12978. }
  12979. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  12980. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  12981. if (empty ( $stList ))
  12982. $stList = array (
  12983. 'rePrice' => 0,
  12984. 'agPrice' => 0
  12985. );
  12986. $data ['stList'] = array (
  12987. 'rePrice' => $stList ['rePrice'],
  12988. 'agPrice' => $stList ['agPrice'],
  12989. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12990. );
  12991. $monthHtml = "";
  12992. for($i = 1; $i <= 12; $i ++) {
  12993. if ($i == $month)
  12994. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  12995. else
  12996. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  12997. }
  12998. $data ['username'] = urlencode ( $username );
  12999. $data ['usernameEN'] = $username;
  13000. $data ['monthHtml'] = $monthHtml;
  13001. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  13002. $data ['list'] = $list;
  13003. $data ['categoryHtml'] = $categoryHtml;
  13004. $data ['itemHtml'] = $itemHtml;
  13005. $data ['itemList'] = $itemList;
  13006. $data ['year'] = $year;
  13007. $data ['month'] = $month;
  13008. $data ['memu'] = "receipt";
  13009. $data ['staff'] = $this->staff;
  13010. $data ['receiptMemu'] = 'companyCategoryCollect';
  13011. $data ['verifyId'] = $this->verifyId;
  13012. $data ['executeId'] = $this->executeId;
  13013. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  13014. }
  13015. die ( 'illegal request' );
  13016. }
  13017. function companyMonthCollectDetail() {
  13018. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13019. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13020. if (! $year)
  13021. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13022. if (! $month)
  13023. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13024. Doo::loadModel ( 'staff' );
  13025. $staff = new staff ();
  13026. Doo::loadModel ( "receiptDetail" );
  13027. $receiptDetail = new receiptDetail ();
  13028. Doo::loadModel ( 'accountItem' );
  13029. $accountItem = new accountItem ();
  13030. Doo::loadModel ( 'statistics' );
  13031. $statistics = new statistics ();
  13032. Doo::loadModel ( 'L_category' );
  13033. $lCategory = new L_category ();
  13034. $staffList = $staff->find ( array (
  13035. 'where' => 'username!="admin"',
  13036. 'asArray' => true
  13037. ) );
  13038. $categoryList = $lCategory->find ( array (
  13039. 'asArray' => true
  13040. ) );
  13041. $list = array ();
  13042. foreach ( $categoryList as $value ) {
  13043. $receiptCollectList = $receiptDetail->find ( array (
  13044. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13045. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13046. 'groupby' => 'item,Month(pastDate),itemCategory',
  13047. 'asArray' => true
  13048. ) );
  13049. if (! empty ( $receiptCollectList )) {
  13050. $receiptL = array (
  13051. '日常相关费用' => array (),
  13052. '差旅相关费用' => array (),
  13053. '培训班费用' => array (),
  13054. '其他' => array ()
  13055. );
  13056. $html = "";
  13057. $psum = 0;
  13058. $item = array (
  13059. '市内交通费',
  13060. '市内出租费',
  13061. '办事处房租',
  13062. '电话费',
  13063. '水费',
  13064. '电费',
  13065. '办公费用',
  13066. '邮寄费',
  13067. '其他费用',
  13068. '车辆费用',
  13069. '广告费',
  13070. '团队建设费'
  13071. );
  13072. foreach ( $item as $va ) {
  13073. $falg = true;
  13074. foreach ( $receiptCollectList as $v ) {
  13075. if ($v ['itemCategory'] == '日常相关费用') {
  13076. if ($v ['item'] == $va) {
  13077. $psum += $v ['price'];
  13078. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13079. $falg = false;
  13080. break;
  13081. }
  13082. }
  13083. }
  13084. if ($falg)
  13085. $html .= '<td class="taR">-</td>';
  13086. }
  13087. if (! empty ( $psum ))
  13088. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13089. else
  13090. $psum = '<td class="colGreen taR">-</td>';
  13091. $receiptL ['日常相关费用'] = $psum . $html;
  13092. /* ----------------------------------- */
  13093. $html = "";
  13094. $psum = 0;
  13095. $item = array (
  13096. '往来交通费',
  13097. '市内交通费',
  13098. '出差住宿费',
  13099. '出差补助',
  13100. '其他费用'
  13101. );
  13102. foreach ( $item as $va ) {
  13103. $falg = true;
  13104. foreach ( $receiptCollectList as $v ) {
  13105. if ($v ['itemCategory'] == '差旅相关费用') {
  13106. if ($v ['item'] == $va) {
  13107. $psum += $v ['price'];
  13108. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13109. $falg = false;
  13110. break;
  13111. }
  13112. }
  13113. }
  13114. if ($falg)
  13115. $html .= '<td class="taR">-</td>';
  13116. }
  13117. if (! empty ( $psum ))
  13118. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13119. else
  13120. $psum = '<td class="colGreen taR">-</td>';
  13121. $receiptL ['差旅相关费用'] = $psum . $html;
  13122. /* ------------------------------------- */
  13123. $html = "";
  13124. $psum = 0;
  13125. $item = array (
  13126. '场租费',
  13127. '薪酬',
  13128. '住宿费',
  13129. '交通费',
  13130. '餐饮费',
  13131. '办公费',
  13132. '公关费',
  13133. '其他'
  13134. );
  13135. foreach ( $item as $va ) {
  13136. $falg = true;
  13137. foreach ( $receiptCollectList as $v ) {
  13138. if ($v ['itemCategory'] == '培训班费用') {
  13139. if ($v ['item'] == $va) {
  13140. $psum += $v ['price'];
  13141. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13142. $falg = false;
  13143. break;
  13144. }
  13145. }
  13146. }
  13147. if ($falg)
  13148. $html .= '<td class="taR">-</td>';
  13149. }
  13150. if (! empty ( $psum ))
  13151. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13152. else
  13153. $psum = '<td class="colGreen taR">-</td>';
  13154. $receiptL ['培训班费用'] = $psum . $html;
  13155. /* ------------------------------------- */
  13156. $html = "";
  13157. $psum = 0;
  13158. $item = array (
  13159. '公关费',
  13160. '广告费',
  13161. '借款',
  13162. '可自加费用'
  13163. );
  13164. foreach ( $item as $va ) {
  13165. $falg = true;
  13166. foreach ( $receiptCollectList as $v ) {
  13167. if ($v ['itemCategory'] == '其他') {
  13168. if ($v ['item'] == $va) {
  13169. $psum += $v ['price'];
  13170. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13171. $falg = false;
  13172. break;
  13173. }
  13174. }
  13175. }
  13176. if ($falg)
  13177. $html .= '<td class="taR">-</td>';
  13178. }
  13179. if (! empty ( $psum ))
  13180. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13181. else
  13182. $psum = '<td class="colGreen taR">-</td>';
  13183. $receiptL ['其他'] = $psum . $html;
  13184. /* ------------------------------------- */
  13185. $html = "";
  13186. $psum = 0;
  13187. foreach ( $receiptCollectList as $v ) {
  13188. if ($v ['itemCategory'] == '报销金额调整') {
  13189. if (! empty ( $v ['price'] ))
  13190. $psum += $v ['price'];
  13191. }
  13192. }
  13193. if (! empty ( $psum ))
  13194. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  13195. else
  13196. $psum = '<td class="taR colOrange">-</td>';
  13197. $receiptL ['报销金额调整'] = $psum . $html;
  13198. } else {
  13199. $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>
  13200. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13201. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  13202. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13203. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13204. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13205. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13206. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13207. }
  13208. $monthStaffPrice = $receiptDetail->find ( array (
  13209. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13210. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13211. 'asArray' => true
  13212. ) );
  13213. if (! empty ( $monthStaffPrice [0] ['price'] ))
  13214. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13215. else
  13216. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13217. $list [$value ['title']] = $receiptL;
  13218. }
  13219. $data ['list'] = $list;
  13220. $receiptCollectList = $receiptDetail->find ( array (
  13221. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13222. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13223. 'groupby' => 'item,Month(pastDate),itemCategory',
  13224. 'asArray' => true
  13225. ) );
  13226. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  13227. // print_r($data['monthPriceHtml']);
  13228. // foreach ($data['monthPriceHtml'] as $value){
  13229. // echo $value;
  13230. // }
  13231. // die;
  13232. // statistics html
  13233. $stList = $statistics->getOne ( array (
  13234. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13235. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13236. 'groupby' => 'Month(date)',
  13237. 'asArray' => true
  13238. ) );
  13239. if (empty ( $stList ))
  13240. $stList = array (
  13241. 'rePrice' => 0,
  13242. 'agPrice' => 0
  13243. );
  13244. $data ['stList'] = array (
  13245. 'rePrice' => $stList ['rePrice'],
  13246. 'agPrice' => $stList ['agPrice'],
  13247. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13248. );
  13249. $monthHtml = "";
  13250. for($i = 1; $i <= 12; $i ++) {
  13251. if ($i == $month)
  13252. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13253. else
  13254. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13255. }
  13256. $data ['monthHtml'] = $monthHtml;
  13257. $data ['year'] = $year;
  13258. $data ['month'] = $month;
  13259. $data ['memu'] = "receipt";
  13260. $data ['staff'] = $this->staff;
  13261. $data ['receiptMemu'] = 'companyCategoryCollect';
  13262. $data ['verifyId'] = $this->verifyId;
  13263. $data ['executeId'] = $this->executeId;
  13264. $this->render ( "/admin/companyMonthCollectDetail", $data );
  13265. }
  13266. function staffCollectDetail() {
  13267. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  13268. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13269. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  13270. if (! $staffname) {
  13271. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  13272. $staffname = urldecode ( $staffname );
  13273. }
  13274. Doo::loadModel ( 'staff' );
  13275. $staff = new staff ();
  13276. Doo::loadModel ( "receiptDetail" );
  13277. $receiptDetail = new receiptDetail ();
  13278. Doo::loadModel ( 'accountItem' );
  13279. $accountItem = new accountItem ();
  13280. Doo::loadModel ( 'statistics' );
  13281. $statistics = new statistics ();
  13282. Doo::loadModel ( 'L_category' );
  13283. $lCategory = new L_category ();
  13284. Doo::loadModel ( "receiptAuthorityManage" );
  13285. $receiptAuthorityManage = new receiptAuthorityManage ();
  13286. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  13287. $cidList = array ();
  13288. foreach ( $imcStaff as $key => $value ) {
  13289. array_push ( $cidList, $value ['cid'] );
  13290. }
  13291. $cidString = implode ( ',', $cidList );
  13292. $staffList = $staff->find ( array (
  13293. 'where' => ' cid in (' . $cidString . ')',
  13294. 'asArray' => true
  13295. ) );
  13296. $stHtml = '';
  13297. $stTitle = "";
  13298. $staffId = 0;
  13299. $cid = 0;
  13300. $ocid = 0;
  13301. foreach ( $staffList as $value ) {
  13302. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  13303. $stTitle = $value ['category'] . '-' . $value ['username'];
  13304. $staffId = $value ['sid'];
  13305. $cid = $value ['cid'];
  13306. $ocid = $value ['cid'];
  13307. if (! empty ( $value ['othercid'] ))
  13308. $cid = $value ['cid'] . ',' . $value ['othercid'];
  13309. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13310. } elseif ($value ['username'] != 'admin')
  13311. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13312. }
  13313. $data ['lCategoryHtml'] = $lCategory->find ( array (
  13314. 'where' => 'cid in(' . $cid . ')',
  13315. 'asArray' => true
  13316. ) );
  13317. if (empty ( $pcid ))
  13318. $pcid = $ocid;
  13319. $data ['ocid'] = $pcid;
  13320. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  13321. $this->showCache ( $path );
  13322. //
  13323. $receiptCollectList = $receiptDetail->find ( array (
  13324. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13325. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  13326. 'groupby' => 'item,Month(pastDate),itemCategory',
  13327. 'asArray' => true
  13328. ) );
  13329. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  13330. // print_r($receiptCollectList);
  13331. $accountList = $accountItem->find ( array (
  13332. 'asArray' => true
  13333. ) );
  13334. // create CollectDetail HTML
  13335. $collectHtml = array ();
  13336. foreach ( $accountList as $key => $value ) {
  13337. $html = "";
  13338. $asum = 0;
  13339. for($i = 1; $i <= 12; $i ++) {
  13340. $falg = true;
  13341. foreach ( $receiptCollectList as $v ) {
  13342. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  13343. if ($v ['item'] == '可自加费用') {
  13344. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  13345. }
  13346. $asum += $v ['price'];
  13347. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13348. $falg = false;
  13349. break;
  13350. }
  13351. }
  13352. if ($falg)
  13353. $html .= '<td class="taR">-</td>';
  13354. }
  13355. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  13356. $collectHtml [$value ['category']] [$value ['name']] = $html;
  13357. }
  13358. $data ['collectHtml'] = $collectHtml;
  13359. // print_r($collectHtml);
  13360. // create Adjustment price html
  13361. $receiptCollectList = $receiptDetail->find ( array (
  13362. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  13363. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  13364. 'groupby' => 'itemCategory,Month(pastDate)',
  13365. 'asArray' => true
  13366. ) );
  13367. $adjustment = array ();
  13368. $collectArray = array (
  13369. '日常相关费用' => array (),
  13370. '差旅相关费用' => array (),
  13371. '培训班费用' => array (),
  13372. '其他' => array ()
  13373. );
  13374. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  13375. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  13376. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  13377. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  13378. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  13379. array_push ( $collectArray ['培训班费用'], $collectHtml );
  13380. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  13381. array_push ( $collectArray ['其他'], $collectHtml );
  13382. $data ['collectArray'] = $collectArray;
  13383. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  13384. array_push ( $adjustment, $collectHtml );
  13385. $data ['adjustment'] = $adjustment;
  13386. // total price html
  13387. $collectHtml = "";
  13388. $total = 0;
  13389. for($i = 1; $i <= 12; $i ++) {
  13390. $sumPrice = 0;
  13391. foreach ( $receiptCollectList as $key => $value ) {
  13392. if ($value ['month'] == $i) {
  13393. $sumPrice += $value ['price'];
  13394. }
  13395. }
  13396. if ($sumPrice == 0)
  13397. $collectHtml .= '<td class="taR">-</td>';
  13398. else
  13399. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  13400. $total += $sumPrice;
  13401. }
  13402. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  13403. // statistics html
  13404. $stList = $statistics->statisticsByYear ( $year, $staffId );
  13405. if (empty ( $stList ))
  13406. $stList = array (
  13407. 'rePrice' => 0,
  13408. 'agPrice' => 0
  13409. );
  13410. $data ['stList'] = array (
  13411. 'rePrice' => $stList ['rePrice'],
  13412. 'agPrice' => $stList ['agPrice'],
  13413. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13414. );
  13415. $data ['totalPrice'] = $collectHtml;
  13416. $data ['totalYear'] = $total;
  13417. $data ['stHtml'] = $stHtml;
  13418. $data ['year'] = $year;
  13419. $data ['stTitle'] = $stTitle;
  13420. $data ['staffname'] = urlencode ( $staffname );
  13421. $data ['memu'] = "receipt";
  13422. $data ['staff'] = $this->staff;
  13423. $data ['receiptMemu'] = 'companyCategoryCollect';
  13424. $data ['verifyId'] = $this->verifyId;
  13425. $data ['executeId'] = $this->executeId;
  13426. if ($year < date ( "Y" )) {
  13427. Doo::loadModel ( 'receipt' );
  13428. $receipt = new receipt ();
  13429. $receiptList = $receipt->find ( array (
  13430. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  13431. 'asArray' => true
  13432. ) );
  13433. if (empty ( $receiptList )) { // generated files
  13434. ob_start ();
  13435. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13436. $this->cacheFile ( $path );
  13437. die ();
  13438. }
  13439. }
  13440. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13441. }
  13442. function BUGFLAG() {
  13443. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  13444. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  13445. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13446. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  13447. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  13448. if (empty ( $status ))
  13449. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  13450. $page_size = 12;
  13451. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  13452. $vidList = array ();
  13453. $button = 0;
  13454. Doo::loadModel ( 'verify' );
  13455. $verify = new verify ();
  13456. Doo::loadModel ( 'receipt' );
  13457. $receipt = new receipt ();
  13458. Doo::loadModel ( 'staff' );
  13459. $staff = new staff ();
  13460. Doo::loadModel ( 'L_category' );
  13461. $Lcategory = new L_category ();
  13462. $dateCondition = " and Year(date) =" . $year;
  13463. if (! empty ( $month ))
  13464. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  13465. $categoryList = $Lcategory->find ( array (
  13466. 'asArray' => true
  13467. ) );
  13468. $staffList = $staff->find ( array (
  13469. 'where' => 'cid=' . $cid,
  13470. 'asArray' => true
  13471. ) );
  13472. $cateCondition = "";
  13473. $staffCondition = "";
  13474. $approvalCondition = "";
  13475. if (! empty ( $cid ))
  13476. $cateCondition = ' and cid=' . $cid;
  13477. if (! empty ( $sid )) {
  13478. $staffCondition = ' and staff=' . $sid;
  13479. $cateCondition = "";
  13480. }
  13481. $approvalCondition = " and status=" . $status;
  13482. if ($status == 2) {
  13483. // 查找角色审批人
  13484. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  13485. }
  13486. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  13487. $approvalCondition = ' and status=2 ';
  13488. }
  13489. if ($status == 1) {
  13490. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  13491. }
  13492. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  13493. $pageinfo ['page'] = array (
  13494. 'previous' => ''
  13495. );
  13496. if ($status == 0) {
  13497. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  13498. $receiptList = $receipt->find ( array (
  13499. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  13500. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  13501. 'desc' => 'rid',
  13502. 'asArray' => true
  13503. ) );
  13504. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  13505. } else
  13506. $receiptList = $receipt->find ( array (
  13507. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  13508. 'desc' => 'rid',
  13509. 'asArray' => true
  13510. ) );
  13511. $rLRes = $receipt->find ( array (
  13512. '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,
  13513. 'desc' => 'rid',
  13514. 'asArray' => true
  13515. ) );
  13516. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  13517. // print_r($pageinfo);
  13518. $Locate = 0;
  13519. foreach ( $receiptList as $key => $value ) {
  13520. $receiptList [$key] ['Locate'] = $Locate;
  13521. $Locate ++;
  13522. $receiptList [$key] ['reviseDetail'] = array ();
  13523. if (! empty ( $value ['reviseDetail'] ))
  13524. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  13525. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  13526. $categoryDetil = $Lcategory->getOne ( array (
  13527. 'where' => 'cid=' . $value ['cid'],
  13528. 'asArray' => true
  13529. ) );
  13530. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  13531. $verifyList = $verify->getOne ( array (
  13532. 'where' => 'vid=' . $value ['verify'],
  13533. 'asArray' => true
  13534. ) );
  13535. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  13536. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  13537. foreach ( $verifyList as $k => $v ) {
  13538. // init verifyStaff
  13539. $verifyList [$k] ['date'] = "";
  13540. $verifyList [$k] ['opinion'] = "";
  13541. $verifyList [$k] ['status'] = "";
  13542. if (empty ( $verifyStaff )) {
  13543. $verifyList [$k] ['date'] = "";
  13544. $verifyList [$k] ['opinion'] = "";
  13545. if ($v [0] == $this->staff [0] ['sid']) {
  13546. $verifyList [$k] ['status'] = 4;
  13547. $button = 4;
  13548. }
  13549. } else {
  13550. $flag = true;
  13551. foreach ( $verifyStaff as $m => $u ) {
  13552. if ($v [0] == $m) {
  13553. $verifyList [$k] ['date'] = $u ['date'];
  13554. $verifyList [$k] ['opinion'] = $u ['opinion'];
  13555. $verifyList [$k] ['status'] = $u ['status'];
  13556. $flag = false;
  13557. break;
  13558. }
  13559. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  13560. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  13561. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  13562. }
  13563. if ($flag) { // 检测可编辑
  13564. if ($v [0] == $this->staff [0] ['sid']) {
  13565. $verifyList [$k] ['status'] = 4;
  13566. $button = 4;
  13567. }
  13568. }
  13569. }
  13570. }
  13571. $receiptList [$key] ['verifyList'] = $verifyList;
  13572. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  13573. 'where' => 'sid=' . $value ['staff'],
  13574. 'asArray' => true
  13575. ) );
  13576. $receiptList [$key] ['button'] = $button;
  13577. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  13578. }
  13579. // print_r($receiptList);die;
  13580. // $data['verifyDetail']=$verifyDetail;
  13581. $mothHtml = "";
  13582. for($i = 1; $i <= 12; $i ++) {
  13583. if ($month == $i)
  13584. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  13585. else
  13586. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  13587. }
  13588. $data ['mothHtml'] = $mothHtml;
  13589. $data ['page'] = $pageinfo;
  13590. $data ['receiptList'] = $receiptList;
  13591. $data ['receiptApprovalCount'] = count ( $rLRes );
  13592. $data ['status'] = $status;
  13593. $data ['year'] = $year;
  13594. $data ['categoryList'] = $categoryList;
  13595. $data ['staffList'] = $staffList;
  13596. $data ['cid'] = $cid;
  13597. $data ['sid'] = $sid;
  13598. // print_r($receiptList);
  13599. $data ['memu'] = "receipt";
  13600. $data ['staff'] = $this->staff;
  13601. $data ['receiptMemu'] = 'approvalExpenses';
  13602. $data ['verifyId'] = $this->verifyId;
  13603. $data ['executeId'] = $this->executeId;
  13604. $this->render ( "/admin/FALG", $data );
  13605. }
  13606. function ajaxGetReceiptOrder() {
  13607. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  13608. if (! empty ( $receiptOrder )) {
  13609. Doo::loadModel ( 'receipt' );
  13610. $receipt = new receipt ();
  13611. Doo::loadModel ( 'staff' );
  13612. $staff = new staff ();
  13613. $receiptInfo = $receipt->getOne ( array (
  13614. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  13615. 'asArray' => true
  13616. ) );
  13617. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  13618. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  13619. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  13620. </tbody></table><table class="table table table-bordered"><tbody>';
  13621. foreach ( $verifyStaff as $key => $value ) {
  13622. $staffInfo = $staff->getOne ( array (
  13623. 'select' => 'username',
  13624. 'where' => ' sid="' . $key . '"',
  13625. 'asArray' => true
  13626. ) );
  13627. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  13628. }
  13629. $html .= '</tbody></table></div></div>';
  13630. echo json_encode ( array (
  13631. 'status' => 1,
  13632. 'receiptHtml' => $html
  13633. ) );
  13634. die ();
  13635. }
  13636. echo json_encode ( array (
  13637. 'status' => 2,
  13638. 'receiptHtml' => ''
  13639. ) );
  13640. die ();
  13641. }
  13642. function _getMonthCollectDetail($receiptCollectList) {
  13643. if (! empty ( $receiptCollectList )) {
  13644. $receiptL = array (
  13645. '日常相关费用' => array (),
  13646. '差旅相关费用' => array (),
  13647. '培训班费用' => array (),
  13648. '其他' => array ()
  13649. );
  13650. $html = "";
  13651. $psum = 0;
  13652. $item = array (
  13653. '市内交通费',
  13654. '市内出租费',
  13655. '办事处房租',
  13656. '电话费',
  13657. '水费',
  13658. '电费',
  13659. '办公费用',
  13660. '邮寄费',
  13661. '其他费用',
  13662. '车辆费用',
  13663. '广告费',
  13664. '团队建设费',
  13665. '物业管理费',
  13666. '宽带费',
  13667. '人员薪酬',
  13668. '公积金',
  13669. '社保'
  13670. );
  13671. foreach ( $item as $value ) {
  13672. $falg = true;
  13673. foreach ( $receiptCollectList as $v ) {
  13674. if ($v ['itemCategory'] == '日常相关费用') {
  13675. if ($v ['item'] == $value) {
  13676. $psum += $v ['price'];
  13677. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13678. $falg = false;
  13679. break;
  13680. }
  13681. }
  13682. }
  13683. if ($falg)
  13684. $html .= '<td class="taR">-</td>';
  13685. }
  13686. if (! empty ( $psum ))
  13687. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13688. else
  13689. $psum = '<td class="colGreen taR">-</td>';
  13690. $receiptL ['日常相关费用'] = $psum . $html;
  13691. /* ----------------------------------- */
  13692. $html = "";
  13693. $psum = 0;
  13694. $item = array (
  13695. '往来交通费',
  13696. '市内交通费',
  13697. '出差住宿费',
  13698. '出差补助',
  13699. '其他费用'
  13700. );
  13701. foreach ( $item as $value ) {
  13702. $falg = true;
  13703. foreach ( $receiptCollectList as $v ) {
  13704. if ($v ['itemCategory'] == '差旅相关费用') {
  13705. if ($v ['item'] == $value) {
  13706. $psum += $v ['price'];
  13707. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13708. $falg = false;
  13709. break;
  13710. }
  13711. }
  13712. }
  13713. if ($falg)
  13714. $html .= '<td class="taR">-</td>';
  13715. }
  13716. if (! empty ( $psum ))
  13717. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13718. else
  13719. $psum = '<td class="colGreen taR">-</td>';
  13720. $receiptL ['差旅相关费用'] = $psum . $html;
  13721. /* ------------------------------------- */
  13722. $html = "";
  13723. $psum = 0;
  13724. $item = array (
  13725. '场租费',
  13726. '薪酬',
  13727. '住宿费',
  13728. '交通费',
  13729. '餐饮费',
  13730. '办公费',
  13731. '公关费',
  13732. '其他',
  13733. '电话费',
  13734. '邮寄费'
  13735. );
  13736. foreach ( $item as $value ) {
  13737. $falg = true;
  13738. foreach ( $receiptCollectList as $v ) {
  13739. if ($v ['itemCategory'] == '培训班费用') {
  13740. if ($v ['item'] == $value) {
  13741. $psum += $v ['price'];
  13742. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13743. $falg = false;
  13744. break;
  13745. }
  13746. }
  13747. }
  13748. if ($falg)
  13749. $html .= '<td class="taR">-</td>';
  13750. }
  13751. if (! empty ( $psum ))
  13752. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13753. else
  13754. $psum = '<td class="colGreen taR">-</td>';
  13755. $receiptL ['培训班费用'] = $psum . $html;
  13756. /* ------------------------------------- */
  13757. $html = "";
  13758. $psum = 0;
  13759. $item = array (
  13760. '公关费',
  13761. '广告费',
  13762. '借款',
  13763. '可自加费用'
  13764. );
  13765. foreach ( $item as $value ) {
  13766. $falg = true;
  13767. foreach ( $receiptCollectList as $v ) {
  13768. if ($v ['itemCategory'] == '其他') {
  13769. if ($v ['item'] == $value) {
  13770. $psum += $v ['price'];
  13771. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13772. $falg = false;
  13773. break;
  13774. }
  13775. }
  13776. }
  13777. if ($falg)
  13778. $html .= '<td class="taR">-</td>';
  13779. }
  13780. if (! empty ( $psum ))
  13781. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13782. else
  13783. $psum = '<td class="colGreen taR">-</td>';
  13784. $receiptL ['其他'] = $psum . $html;
  13785. /* ------------------------------------- */
  13786. $html = "";
  13787. $psum = 0;
  13788. foreach ( $receiptCollectList as $v ) {
  13789. if ($v ['itemCategory'] == '报销金额调整') {
  13790. if (! empty ( $v ['price'] ))
  13791. $psum += $v ['price'];
  13792. }
  13793. }
  13794. if (! empty ( $psum ))
  13795. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  13796. else
  13797. $psum = '<td class="taR colOrange">-</td>';
  13798. $receiptL ['报销金额调整'] = $psum . $html;
  13799. } else {
  13800. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td>
  13801. <td class="taR">-</td>
  13802. <td class="taR">-</td>
  13803. <td class="taR">-</td>
  13804. <td class="taR">-</td>
  13805. <td class="taR">-</td>
  13806. <td class="taR">-</td>
  13807. <td class="taR">-</td>
  13808. <td class="taR">-</td>
  13809. <td class="taR">-</td>
  13810. <td class="taR">-</td>
  13811. <td class="taR">-</td>
  13812. <td class="taR">-</td>';
  13813. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  13814. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13815. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td>
  13816. <td class="taR">-</td>
  13817. <td class="taR">-</td>
  13818. <td class="taR">-</td>
  13819. <td class="taR">-</td>
  13820. <td class="taR">-</td>
  13821. <td class="taR">-</td>
  13822. <td class="taR">-</td>
  13823. <td class="taR">-</td>';
  13824. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13825. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13826. }
  13827. return $receiptL;
  13828. }
  13829. function eMail() {
  13830. Doo::loadModel ( 'staff' );
  13831. $staff = new staff ();
  13832. Doo::loadModel ( 'receipt' );
  13833. $receipt = new receipt ();
  13834. Doo::loadModel ( 'L_category' );
  13835. $Lcategory = new L_category ();
  13836. Doo::loadModel ( "verify" );
  13837. $verify = new verify ();
  13838. $staffList = $staff->find ( array (
  13839. 'asArray' => true
  13840. ) );
  13841. foreach ( $staffList as $key => $value ) {
  13842. if ($value ['username'] != 'admin') {
  13843. // 提交人
  13844. $receiptList = $receipt->find ( array (
  13845. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  13846. 'asArray' => true
  13847. ) );
  13848. if (! empty ( $receiptList )) {
  13849. $html = '<br><div><style></style>
  13850. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  13851. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  13852. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  13853. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  13854. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  13855. <tbody><tr>
  13856. <td style="padding: 0 40px;" align="left">
  13857. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  13858. </td></tr><tr>
  13859. <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>
  13860. </tr>
  13861. </tbody> </table></td> </tr> <tr><td>
  13862. <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">
  13863. <tbody> <tr><td>
  13864. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  13865. 以下报销单完成了审批,等着收款吧:</p>
  13866. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  13867. foreach ( $receiptList as $k => $v ) {
  13868. $category = $Lcategory->getOne ( array (
  13869. 'where' => 'cid=' . $v ['cid'],
  13870. 'asArray' => true
  13871. ) );
  13872. $html .= '
  13873. <tr>
  13874. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  13875. <td align="left">
  13876. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  13877. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  13878. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  13879. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  13880. </tr>';
  13881. }
  13882. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  13883. <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>
  13884. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  13885. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  13886. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  13887. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  13888. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  13889. $receipt = new receipt ();
  13890. $receipt->notice = 1;
  13891. $receipt->update ( array (
  13892. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  13893. ) );
  13894. }
  13895. }
  13896. // 审批人
  13897. $verifyList = $verify->find ( array (
  13898. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  13899. 'asArray' => true
  13900. ) );
  13901. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  13902. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  13903. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  13904. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  13905. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  13906. <tbody><tr><td style="padding: 0 40px;" align="left">
  13907. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  13908. </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>
  13909. </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">
  13910. <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>
  13911. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  13912. foreach ( $verifyList as $k => $v ) {
  13913. $receiptList = $receipt->find ( array (
  13914. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  13915. 'asArray' => true
  13916. ) );
  13917. foreach ( $receiptList as $r => $l ) {
  13918. $category = $Lcategory->getOne ( array (
  13919. 'where' => 'cid=' . $l ['cid'],
  13920. 'asArray' => true
  13921. ) );
  13922. $staffDetile = $staff->getOne ( array (
  13923. 'where' => 'sid=' . $l ['staff'],
  13924. 'asArray' => true
  13925. ) );
  13926. $html .= '
  13927. <tr>
  13928. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  13929. <td align="left">
  13930. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  13931. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  13932. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  13933. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  13934. </tr>';
  13935. }
  13936. }
  13937. $html .= '
  13938. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  13939. <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>
  13940. </tr></tbody></table></td></tr></tbody></table></div><br>';
  13941. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  13942. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  13943. // $receipt=new receipt();
  13944. // $receipt->notice=1;
  13945. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  13946. }
  13947. }
  13948. }
  13949. }
  13950. function setWXMsg($rid, $type) {
  13951. Doo::loadModel ( "receipt" );
  13952. $receipt = new receipt ();
  13953. $receiptDetail = $receipt->getOne ( array (
  13954. 'where' => 'rid=' . $rid,
  13955. 'asArray' => true
  13956. ) );
  13957. if (! empty ( $receiptDetail )) {
  13958. Doo::loadModel ( 'staff' );
  13959. $staff = new staff ();
  13960. $staffmsg = $staff->getOne ( array (
  13961. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  13962. 'asArray' => TRUE
  13963. ) );
  13964. if (! empty ( $staffmsg ['wxid'] )) {
  13965. require_once (SITE_PATH . '/protected/class/client.php');
  13966. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  13967. $user = $staffmsg ['wxid'];
  13968. $receiptName = '';
  13969. $msg = '';
  13970. switch ($receiptDetail ['Rtype']) {
  13971. case 0 :
  13972. $receiptName = '报销';
  13973. break;
  13974. case 1 :
  13975. $receiptName = '借款';
  13976. break;
  13977. case 2 :
  13978. $receiptName = '对公汇款';
  13979. break;
  13980. }
  13981. switch ($type) {
  13982. case 1 :
  13983. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  13984. break;
  13985. case 2 :
  13986. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  13987. break;
  13988. case 3 :
  13989. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  13990. break;
  13991. }
  13992. // $result = $client->SendMsg ( $user, $msg, 'text' );
  13993. }
  13994. }
  13995. }
  13996. // Email发送函数
  13997. function SMail($toemail, $subject, $contents) {
  13998. Doo::loadClass ( 'class.phpmailer' );
  13999. $mail = new PHPMailer ();
  14000. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  14001. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  14002. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  14003. $mail->Password = "cDO1GjtY1seH"; // 密码
  14004. $mail->CharSet = "UTF8";
  14005. $mail->SMTPAuth = true;
  14006. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  14007. $mail->Mailer = "smtp";
  14008. $mail->Port = 25;
  14009. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  14010. $mail->MsgHTML ( $contents );
  14011. $mail->AddAddress ( $toemail );
  14012. $mail->CharSet = "UTF-8";
  14013. return $mail->Send ();
  14014. }
  14015. function h5Upload() {
  14016. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14017. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14018. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14019. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14020. header ( "HTTP/1.1 500 Internal Server Error" );
  14021. echo "POST exceeded maximum allowed size.";
  14022. exit ( 0 );
  14023. }
  14024. // Settings
  14025. $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)
  14026. $upload_name = "Filedata";
  14027. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14028. $extension_whitelist = array (
  14029. "doc",
  14030. "txt",
  14031. "jpg",
  14032. "gif",
  14033. "png"
  14034. ); // Allowed file extensions
  14035. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14036. // Other variables
  14037. $MAX_FILENAME_LENGTH = 260;
  14038. $file_name = "";
  14039. $file_extension = "";
  14040. $uploadErrors = array (
  14041. 0 => "文件上传成功",
  14042. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14043. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14044. 3 => "上传的文件仅为部分文件",
  14045. 4 => "没有文件上传",
  14046. 6 => "缺少临时文件夹"
  14047. );
  14048. $nk = time ();
  14049. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14050. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14051. echo "文件无法保存.";
  14052. exit ( 0 );
  14053. }
  14054. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14055. echo json_encode ( array (
  14056. 'filename' => $file_name,
  14057. 'id' => $nk
  14058. ) );
  14059. exit ( 0 );
  14060. }
  14061. function swfupload() {
  14062. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14063. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14064. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14065. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14066. header ( "HTTP/1.1 500 Internal Server Error" );
  14067. echo "POST exceeded maximum allowed size.";
  14068. exit ( 0 );
  14069. }
  14070. // Settings
  14071. $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)
  14072. $upload_name = "Filedata";
  14073. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14074. $extension_whitelist = array (
  14075. "doc",
  14076. "txt",
  14077. "jpg",
  14078. "gif",
  14079. "png"
  14080. ); // Allowed file extensions
  14081. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14082. // Other variables
  14083. $MAX_FILENAME_LENGTH = 260;
  14084. $file_name = "";
  14085. $file_extension = "";
  14086. $uploadErrors = array (
  14087. 0 => "文件上传成功",
  14088. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14089. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14090. 3 => "上传的文件仅为部分文件",
  14091. 4 => "没有文件上传",
  14092. 6 => "缺少临时文件夹"
  14093. );
  14094. $nk = time ();
  14095. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14096. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14097. echo "文件无法保存.";
  14098. exit ( 0 );
  14099. }
  14100. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14101. echo json_encode ( array (
  14102. 'filename' => $file_name,
  14103. 'id' => $nk
  14104. ) );
  14105. exit ( 0 );
  14106. }
  14107. function _GetFileEXT($filename) {
  14108. $pics = explode ( '.', $filename );
  14109. $num = count ( $pics );
  14110. return $pics [$num - 1];
  14111. }
  14112. /**
  14113. * 获取get或者POST值
  14114. * @param string $name 属性名称
  14115. * @return fixed 值
  14116. */
  14117. function get_args($name) {
  14118. if (isset ( $_GET [$name] )) {
  14119. if (is_array ( $_GET [$name] ))
  14120. return $_GET [$name];
  14121. else
  14122. return addslashes ( $_GET [$name] );
  14123. } elseif (isset ( $_POST [$name] )) {
  14124. if (is_array ( $_POST [$name] ))
  14125. return $_POST [$name];
  14126. else
  14127. return addslashes ( $_POST [$name] );
  14128. } else
  14129. return false;
  14130. }
  14131. function num_to_rmb($num) {
  14132. $c1 = "零壹贰叁肆伍陆柒捌玖";
  14133. $c2 = "分角元拾佰仟万拾佰仟亿";
  14134. // 精确到分后面就不要了,所以只留两个小数位
  14135. $num = round ( $num, 2 );
  14136. // 将数字转化为整数
  14137. $num = $num * 100;
  14138. if (strlen ( $num ) > 10) {
  14139. return "金额太大,请检查";
  14140. }
  14141. $i = 0;
  14142. $c = "";
  14143. while ( 1 ) {
  14144. if ($i == 0) {
  14145. // 获取最后一位数字
  14146. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  14147. } else {
  14148. $n = $num % 10;
  14149. }
  14150. // 每次将最后一位数字转化为中文
  14151. $p1 = substr ( $c1, 3 * $n, 3 );
  14152. $p2 = substr ( $c2, 3 * $i, 3 );
  14153. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  14154. $c = $p1 . $p2 . $c;
  14155. } else {
  14156. $c = $p1 . $c;
  14157. }
  14158. $i = $i + 1;
  14159. // 去掉数字最后一位了
  14160. $num = $num / 10;
  14161. // echo $num.'</br>';
  14162. $num = ( int ) $num;
  14163. // $num =floor($num);
  14164. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  14165. // echo $num.'</br>';
  14166. // 结束循环
  14167. if ($num == 0) {
  14168. break;
  14169. }
  14170. }
  14171. // echo $c.'</br>';
  14172. $j = 0;
  14173. $slen = strlen ( $c );
  14174. while ( $j < $slen ) {
  14175. // utf8一个汉字相当3个字符
  14176. $m = substr ( $c, $j, 6 );
  14177. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  14178. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  14179. $left = substr ( $c, 0, $j );
  14180. $right = substr ( $c, $j + 3 );
  14181. $c = $left . $right;
  14182. $j = $j - 3;
  14183. $slen = $slen - 3;
  14184. }
  14185. $j = $j + 3;
  14186. }
  14187. // 这个是为了去掉类似23.0中最后一个“零”字
  14188. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  14189. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  14190. }
  14191. // 将处理的汉字加上“整”
  14192. if (empty ( $c )) {
  14193. return "零元整";
  14194. } else {
  14195. return $c . "整";
  14196. }
  14197. }
  14198. /**
  14199. * 获得分页数据
  14200. * @param unknown_type $table
  14201. * @param unknown_type $condition
  14202. * @param unknown_type $on_page
  14203. * @param unknown_type $page_size
  14204. */
  14205. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  14206. $page_c = "";
  14207. $page ['previous'] = $this->get_previous ( $on_page );
  14208. $page ['on_page'] = $on_page;
  14209. $total_count = $this->get_table_count ( $table, $condition );
  14210. $total = intval ( $total_count / $page_size );
  14211. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  14212. $page ['total_data'] = $total_count;
  14213. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  14214. $i = 1;
  14215. $page_max = 1;
  14216. $page_width = 3;
  14217. if ($on_page >= $page_width) {
  14218. $page_max = intval ( $on_page / $page_width ) + 1;
  14219. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  14220. }
  14221. for(; $i <= $page ['total_page']; $i ++) {
  14222. if ($i == $on_page)
  14223. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  14224. else
  14225. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  14226. if ($i == ($page_width * $page_max))
  14227. break;
  14228. }
  14229. $page ['page'] = $page_c;
  14230. $page ['lower'] = (-- $on_page) * $page_size;
  14231. return $page;
  14232. }
  14233. /**
  14234. * 获取总页数
  14235. * @param unknown_type $table
  14236. * @param unknown_type $condition
  14237. */
  14238. public function get_table_count($table = "", $condition = "") {
  14239. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14240. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14241. // echo $sql;die;
  14242. $query = Doo::db ()->query ( $sql );
  14243. $result = $query->fetch ();
  14244. return $result ['count'];
  14245. }
  14246. /**
  14247. * 获取上一页
  14248. * @param unknown_type $on_page
  14249. */
  14250. function get_previous($on_page = 1) {
  14251. return $on_page != 0 ? $on_page - 1 : $on_page;
  14252. }
  14253. }
  14254. ?>