ReceiptController.php 521 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064
  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)
  1928. die ();
  1929. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  1930. // 汇总表合计
  1931. // 收入合计
  1932. Doo::loadModel ( 'invoiceTraining' );
  1933. $invoiceTraining = new invoiceTraining ();
  1934. $invoiceTrainingDetail=array('invoiceArriveAmount'=>0,'RIAmount'=>0,'invoiceTotalAmount'=>0);
  1935. if ($receiptDetail ['invoiceTrainId']!=0){
  1936. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  1937. }
  1938. // print_r($invoiceTrainingDetail);
  1939. $invoiceArriveAmount=$RIAmount=0;
  1940. if(!empty($invoiceTrainingDetail)){
  1941. $invoiceArriveAmount=$invoiceTrainingDetail ['invoiceArriveAmount'];
  1942. $RIAmount=$invoiceTrainingDetail ['RIAmount'];
  1943. }
  1944. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  1945. // 支出项目
  1946. Doo::loadModel ( 'accountItem' );
  1947. $accountItem = new accountItem ();
  1948. // 项目金额合计
  1949. Doo::loadModel ( 'RItem' );
  1950. $RItem = new RItem ();
  1951. // 讲师获得
  1952. Doo::loadModel ( 'RILecturer' );
  1953. $RILecturer = new RILecturer ();
  1954. $RItemList = $RItem->getRItemByRid ( $rid );
  1955. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  1956. // 支出项金额详情
  1957. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  1958. //print_r($aiData);
  1959. // 利润
  1960. $data ['profit'] = $invoiceArriveAmount - $aiData ['total'];
  1961. $data ['companyProfit'] = $data ['profit'] * 0.6;
  1962. $data ['categoryProfit'] = $data ['profit'] * 0.4;
  1963. // print_r($aiData['dataList']);
  1964. $data ['categoryActualExpenditure'] = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  1965. // 备用金
  1966. $sum=0;$data ['receiptLoanDetail']=array('sum'=>0);
  1967. if (!empty($receiptDetail ['trainLoanRid'])){
  1968. $data ['receiptLoanDetail'] = $receipt->getReceiptByRid ( $receiptDetail ['trainLoanRid'] );
  1969. $sum=$data ['receiptLoanDetail'] ['sum'];
  1970. }
  1971. $data ['payment'] = $sum + $RIAmount - $data ['categoryActualExpenditure'];
  1972. $data ['total'] = $aiData ['total'];
  1973. $data ['aiCount'] = count ( $aiData ['dataList'] ) + 5;
  1974. $data ['aiList'] = $aiData ['dataList'];
  1975. // 占比计算
  1976. if($invoiceArriveAmount!=0){
  1977. $data ['totalProportion'] = number_format ( $aiData ['total'] / $invoiceArriveAmount, 2, '.', '' ) * 100;
  1978. $data ['profitProportion'] = number_format ( $data ['profit'] / $invoiceArriveAmount, 2, '.', '' ) * 100;
  1979. $data ['sumProportion'] = number_format ( $sum / $invoiceArriveAmount, 2, '.', '' ) * 100;
  1980. $data ['invoiceTotalAmountProportion'] = number_format ( $data ['invoiceTrainingDetail'] ['invoiceTotalAmount'] / $invoiceArriveAmount, 2, '.', '' ) * 100;
  1981. $data ['RIAmountProportion'] = number_format ( $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceArriveAmount, 2, '.', '' ) * 100;
  1982. $data ['companyProfitProportion'] = number_format ( $data ['companyProfit'] / $invoiceArriveAmount, 2, '.', '' ) * 100;
  1983. $data ['categoryProportion'] = number_format ( $data ['categoryProfit'] / $invoiceArriveAmount, 2, '.', '' ) * 100;
  1984. $data ['categoryActualExpenditureProportion'] = number_format ( $data ['categoryActualExpenditure'] / $invoiceArriveAmount, 2, '.', '' ) * 100;
  1985. $data ['paymentProportion'] = number_format ( $data ['payment'] / $invoiceArriveAmount, 2, '.', '' ) * 100;
  1986. }else{
  1987. $data ['totalProportion'] =$data ['profitProportion'] = $data ['sumProportion'] = $data ['invoiceTotalAmountProportion'] = $data ['RIAmountProportion']
  1988. = $data ['companyProfitProportion'] = $data ['categoryActualExpenditureProportion'] = $data ['paymentProportion']=$data ['categoryProportion'] = 0;
  1989. }
  1990. // 审批组
  1991. Doo::loadModel ( 'verify' );
  1992. $verify = new verify ();
  1993. $veList = $verify->getVerifyByAll ();
  1994. // 办事处
  1995. Doo::loadModel ( 'L_category' );
  1996. $lCategory = new L_category ();
  1997. $data ['category'] = $lCategory->getCategory ();
  1998. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  1999. $data ['receiptDetail'] = $receiptDetail;
  2000. $data ['veList'] = $veList;
  2001. $data ['trainEdiType'] = $trainEdiType;
  2002. $data ['ridKey'] = $ridKey;
  2003. $data ['memu'] = "receipt";
  2004. $data ['staff'] = $this->staff;
  2005. $data ['receiptMemu'] = 'saeaBorad';
  2006. $data ['verifyId'] = $this->verifyId;
  2007. $data ['executeId'] = $this->executeId;
  2008. $this->render ( "/receipt/receiptTrainEdi", $data );
  2009. }
  2010. /**
  2011. * 培训班借款编辑
  2012. */
  2013. function receiptTrainLoanEdi() {
  2014. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2015. Doo::loadClass ( 'XDeode' );
  2016. $XDeode = new XDeode ( 7 );
  2017. $rid = $XDeode->decode ( $ridKey );
  2018. if (! is_numeric ( $rid ))
  2019. die ( 'illegal request' );
  2020. Doo::loadModel ( 'receipt' );
  2021. $receipt = new receipt ();
  2022. Doo::loadModel ( 'receiptTraining' );
  2023. $receiptTraining = new receiptTraining ();
  2024. Doo::loadModel ( 'verify' );
  2025. $verify = new verify ();
  2026. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2027. if ($receiptDetail ['status'] != 5)
  2028. die ();
  2029. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2030. // 借款详情HTML
  2031. // 获得借款信息
  2032. $receiptLoanHtml = '';
  2033. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  2034. $receiptLoanDetail = $receipt->getReceiptByRid ( $receiptDetail ['trainLoanRid'] );
  2035. // 获得某费用单审批信息
  2036. $verifylist = $verify->getVerifyByRid ( $receiptDetail ['trainLoanRid'] );
  2037. Doo::loadClass ( 'receipt.func' );
  2038. $extendHtml = '<p><a class="button" href="javascript:if(window.confirm(\'确认移除?\'))window.location=\'/receiptTrainLoanRemoveDo/' . $receiptDetail ['ridKey'] . '/' . $receiptDetail ['trainLoanRidKey'] . '.html\'" data-toggle="modal">移除借款</a></p>';
  2039. $receiptLoanHtml = _getReceiptLoanHtml ( $receiptLoanDetail, $verifylist, $extendHtml );
  2040. }
  2041. $data ['receiptLoanHtml'] = $receiptLoanHtml;
  2042. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2043. $data ['receiptDetail'] = $receiptDetail;
  2044. $data ['trainEdiType'] = "LOAN";
  2045. $data ['ridKey'] = $ridKey;
  2046. $data ['memu'] = "receipt";
  2047. $data ['staff'] = $this->staff;
  2048. $data ['receiptMemu'] = 'saeaBorad';
  2049. $data ['verifyId'] = $this->verifyId;
  2050. $data ['executeId'] = $this->executeId;
  2051. $this->render ( "/receipt/receiptTrainLoanEdi", $data );
  2052. }
  2053. /**
  2054. * 更新培训班结算基本信息
  2055. */
  2056. function receiptTrainInfoEdiDo() {
  2057. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  2058. $rtid = $this->get_args ( 'rtid' ) ? $this->get_args ( 'rtid' ) : "";
  2059. // 培训班信息
  2060. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  2061. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  2062. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  2063. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  2064. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  2065. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  2066. // 发票信息
  2067. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2068. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2069. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2070. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2071. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2072. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2073. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2074. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $participants ) && ! empty ( $trainAddress )) {
  2075. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2076. header ( 'Content-Type:text/html;charset=utf-8' );
  2077. die ( '请填写联行号' );
  2078. }
  2079. Doo::loadClass ( 'XDeode' );
  2080. $XDeode = new XDeode ( 5 );
  2081. $cid = $XDeode->decode ( $cid );
  2082. $rtid = $XDeode->decode ( $rtid );
  2083. $rid = $XDeode->decode ( $rid );
  2084. if (! is_numeric ( $rtid ) || ! is_numeric ( $rid )) {
  2085. die ( 'illegal request-IdError' );
  2086. }
  2087. Doo::loadModel ( 'receipt' );
  2088. $receipt = new receipt ();
  2089. Doo::loadModel ( 'receiptTraining' );
  2090. $receiptTraining = new receiptTraining ();
  2091. // 更新费用培训班
  2092. $item = array (
  2093. 'rtid' => $rtid,
  2094. 'trainName' => $trainName,
  2095. 'trainStartDate' => $trainStartDate,
  2096. 'trainEndDate' => $trainEndDate,
  2097. 'participants' => $participants,
  2098. 'trainAddress' => $trainAddress,
  2099. 'trainRemarks' => $trainRemarks
  2100. );
  2101. $irid = $receiptTraining->setReceiptTrainByCondition ( $item );
  2102. // 报销单
  2103. $receipt->rid = $rid;
  2104. $receipt->cid = $cid;
  2105. $receipt->verify = $verify;
  2106. $receipt->remittanceName = $remittanceName;
  2107. $receipt->bankName = $bankName;
  2108. $receipt->bankNumber = $bankNumber;
  2109. $receipt->remittanceBankType = $remittanceBankType;
  2110. if ($remittanceBankType == 1)
  2111. $receipt->coupletNumber = $coupletNumber;
  2112. $receipt->update ();
  2113. $XDeode = new XDeode ( 7 );
  2114. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html?trainEdiType=INFO";
  2115. } else
  2116. die ( 'illegal request' );
  2117. }
  2118. /**
  2119. * 编辑培训班结算---更新借款
  2120. */
  2121. function receiptTrainLoanEdiDo() {
  2122. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2123. $ridLoanKey = $this->get_args ( 'ridLoanKey' ) ? $this->get_args ( 'ridLoanKey' ) : "";
  2124. if (! empty ( $ridKey ) && ! empty ( $ridLoanKey )) {
  2125. Doo::loadModel ( 'receipt' );
  2126. $receipt = new receipt ();
  2127. Doo::loadClass ( 'XDeode' );
  2128. $XDeode = new XDeode ( 5 );
  2129. $rid = $XDeode->decode ( $ridKey );
  2130. $ridLoan = $XDeode->decode ( $ridLoanKey );
  2131. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  2132. die ( 'illegal request-ridError' );
  2133. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2134. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  2135. // 不合法的数据
  2136. if ($receiptDetail ['status'] != 5 || $receiptDetail ['Rtype'] != 3) {
  2137. die ( 'illegal request-receiptError' );
  2138. }
  2139. if ($receiptLoanDetail ['status'] != 8 || $receiptLoanDetail ['Rtype'] != 1) {
  2140. die ( 'illegal request-receipLoantError' );
  2141. }
  2142. // 培训班结算挂钩借款
  2143. $receipt = new receipt ();
  2144. $item = array (
  2145. 'rid' => $rid,
  2146. 'trainLoanRid' => $ridLoan
  2147. );
  2148. $receipt->setReceiptByCondition ( $item );
  2149. // 更新借款状态变成已挂钩
  2150. $receipt = new receipt ();
  2151. $item = array (
  2152. 'rid' => $ridLoan,
  2153. 'status' => 10,
  2154. 'statusTrain' => 1
  2155. );
  2156. $receipt->setReceiptByCondition ( $item );
  2157. $XDeode = new XDeode ( 7 );
  2158. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  2159. } else
  2160. die ( 'illegal request' );
  2161. }
  2162. /**
  2163. * 编辑培训班结算--移除借款
  2164. */
  2165. function receiptTrainLoanRemoveDo() {
  2166. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : 0;
  2167. $ridLoanKey = isset ( $this->params ['ridLoanKey'] ) ? $this->params ['ridLoanKey'] : 0;
  2168. if (! empty ( $ridKey ) || ! empty ( $ridLoanKey )) {
  2169. Doo::loadModel ( 'receipt' );
  2170. $receipt = new receipt ();
  2171. Doo::loadClass ( 'XDeode' );
  2172. $XDeode = new XDeode ( 5 );
  2173. $rid = $XDeode->decode ( $ridKey );
  2174. $ridLoan = $XDeode->decode ( $ridLoanKey );
  2175. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  2176. die ( 'illegal request-ridError' );
  2177. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2178. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  2179. // 不合法的数据
  2180. if ($receiptDetail ['status'] != 5 || $receiptDetail ['Rtype'] != 3) {
  2181. die ( 'illegal request-receiptError' );
  2182. }
  2183. if ($receiptLoanDetail ['status'] != 10 || $receiptLoanDetail ['Rtype'] != 1) {
  2184. die ( 'illegal request-receipLoantError' );
  2185. }
  2186. // 培训班结算挂钩借款
  2187. $receipt = new receipt ();
  2188. $item = array (
  2189. 'rid' => $rid,
  2190. 'trainLoanRid' => 0
  2191. );
  2192. $receipt->setReceiptByCondition ( $item );
  2193. // 更新借款状态变成已挂钩
  2194. $receipt = new receipt ();
  2195. $item = array (
  2196. 'rid' => $ridLoan,
  2197. 'status' => 8,
  2198. 'statusTrain' => 0
  2199. );
  2200. $receipt->setReceiptByCondition ( $item );
  2201. $XDeode = new XDeode ( 7 );
  2202. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  2203. } else
  2204. die ( 'illegal request' );
  2205. }
  2206. /**
  2207. * 编辑培训班结算 ---开票
  2208. */
  2209. function receiptTrainInvoiceEdi() {
  2210. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2211. Doo::loadClass ( 'XDeode' );
  2212. $XDeode = new XDeode ( 7 );
  2213. $rid = $XDeode->decode ( $ridKey );
  2214. if (! is_numeric ( $rid ))
  2215. die ( 'illegal request' );
  2216. Doo::loadModel ( 'receipt' );
  2217. $receipt = new receipt ();
  2218. Doo::loadModel ( 'receiptTraining' );
  2219. $receiptTraining = new receiptTraining ();
  2220. Doo::loadModel ( 'invoice' );
  2221. $invoice = new invoice ();
  2222. Doo::loadModel ( 'invoiceTraining' );
  2223. $invoiceTraining = new invoiceTraining ();
  2224. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2225. if ($receiptDetail ['status'] != 5)
  2226. die ();
  2227. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2228. $invoiceList = $invoiceTrainingDetail = array ();
  2229. if ($receiptDetail ['invoiceTrainId'] != 0) {
  2230. $invoiceList = $invoice->getInvoicePrintedByItid ( $receiptDetail ['invoiceTrainId'] );
  2231. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  2232. }
  2233. // print_r($invoiceList);
  2234. $data ['invoiceList'] = $invoiceList;
  2235. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  2236. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2237. $data ['receiptDetail'] = $receiptDetail;
  2238. $data ['trainEdiType'] = "INVOICE";
  2239. $data ['ridKey'] = $ridKey;
  2240. $data ['memu'] = "receipt";
  2241. $data ['staff'] = $this->staff;
  2242. $data ['receiptMemu'] = 'saeaBorad';
  2243. $data ['verifyId'] = $this->verifyId;
  2244. $data ['executeId'] = $this->executeId;
  2245. $this->render ( "/receipt/receiptTrainInvoiceEdi", $data );
  2246. }
  2247. /**
  2248. * 编辑培训班结算---更新开票
  2249. */
  2250. function receiptTrainInvoiceEdiDo() {
  2251. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2252. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : "";
  2253. if (! empty ( $ridKey ) && ! empty ( $itidKey )) {
  2254. Doo::loadModel ( 'receipt' );
  2255. $receipt = new receipt ();
  2256. Doo::loadModel ( 'invoiceTraining' );
  2257. $invoiceTraining = new invoiceTraining ();
  2258. Doo::loadClass ( 'XDeode' );
  2259. $XDeode = new XDeode ( 5 );
  2260. $rid = $XDeode->decode ( $ridKey );
  2261. $itid = $XDeode->decode ( $itidKey );
  2262. if (! is_numeric ( $rid ) || ! is_numeric ( $itid ))
  2263. die ( 'illegal request-idError' );
  2264. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2265. $invoiceTrainDetail = $invoiceTraining->getInvoiceTrainingByItid ( $itid );
  2266. // 不合法的数据
  2267. if ($receiptDetail ['status'] != 5 || $receiptDetail ['Rtype'] != 3) {
  2268. die ( 'illegal request-receiptError' );
  2269. }
  2270. if (empty ( $invoiceTrainDetail )) {
  2271. die ( 'illegal request-receipLoantError' );
  2272. }
  2273. // 培训班结算挂钩借款
  2274. $receipt = new receipt ();
  2275. $item = array (
  2276. 'rid' => $rid,
  2277. 'invoiceTrainId' => $itid
  2278. );
  2279. $receipt->setReceiptByCondition ( $item );
  2280. $XDeode = new XDeode ( 7 );
  2281. return "/receiptTrainInvoiceEdi/" . $XDeode->encode ( $rid ) . ".html";
  2282. } else
  2283. die ( 'illegal request' );
  2284. }
  2285. /**
  2286. * 更新培训班结算 收款和取消收款
  2287. */
  2288. function receiptTrainReceivables() {
  2289. $doType = isset ( $this->params ['doType'] ) ? $this->params ['doType'] : '';
  2290. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2291. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  2292. Doo::loadClass ( 'XDeode' );
  2293. $XDeode = new XDeode ( 5 );
  2294. $rid = $XDeode->decode ( $ridKey );
  2295. $iid = $XDeode->decode ( $iidKey );
  2296. if (! is_numeric ( $rid ) || ! is_numeric ( $iid ))
  2297. die ( 'illegal request-iid' );
  2298. Doo::loadModel ( 'RIExtend' );
  2299. $RIExtend = new RIExtend ();
  2300. if ($doType == 'CONFIRM') {
  2301. $RIExtend->rid = $rid;
  2302. $RIExtend->iid = $iid;
  2303. $RIExtend->RIstatus = 1;
  2304. $RIExtend->insert ();
  2305. $XDeode = new XDeode ( 7 );
  2306. return '/receiptTrainInvoiceEdi/' . $XDeode->encode ( $rid ) . '.html';
  2307. } elseif ($doType == 'CANCEL') {
  2308. $RIExtend->delete ( array (
  2309. 'where' => 'rid=' . $rid . ' and iid=' . $iid,
  2310. 'limit' => 1
  2311. ) );
  2312. $XDeode = new XDeode ( 7 );
  2313. return '/receiptTrainInvoiceEdi/' . $XDeode->encode ( $rid ) . '.html';
  2314. } else {
  2315. die ( 'illegal request' );
  2316. }
  2317. }
  2318. /**
  2319. * 移除挂钩的培训班发票
  2320. */
  2321. function receiptTrainReceivablesDelDo() {
  2322. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  2323. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : ""; // 发票培训班
  2324. Doo::loadModel ( 'receipt' );
  2325. $receipt = new receipt ();
  2326. Doo::loadModel ( 'RIExtend' );
  2327. $RIExtend = new RIExtend ();
  2328. Doo::loadClass ( 'XDeode' );
  2329. $XDeode = new XDeode ( 5 );
  2330. $rid = $XDeode->decode ( $ridKey );
  2331. $itid = $XDeode->decode ( $itidKey );
  2332. if (is_numeric ( $rid ) && is_numeric ( $itid )) {
  2333. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2334. if ($receiptDetail ['status'] != 5)
  2335. die ( 'illegal request-status' );
  2336. $receipt = new receipt ();
  2337. $receipt->rid = $rid;
  2338. $receipt->invoiceTrainId = 0;
  2339. $receipt->update ();
  2340. $RIExtend->delete ( array (
  2341. 'where' => 'rid=' . $rid
  2342. ) );
  2343. $XDeode = new XDeode ( 7 );
  2344. return '/receiptTrainInvoiceEdi/' . $XDeode->encode ( $rid ) . '.html';
  2345. } else
  2346. die ( 'illegal request-iid' );
  2347. }
  2348. /**
  2349. * 编辑培训班结算
  2350. */
  2351. function receiptTrainItemEdi() {
  2352. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2353. Doo::loadClass ( 'XDeode' );
  2354. $XDeode = new XDeode ( 7 );
  2355. $rid = $XDeode->decode ( $ridKey );
  2356. if (! is_numeric ( $rid ))
  2357. die ( 'illegal request' );
  2358. Doo::loadModel ( 'receipt' );
  2359. $receipt = new receipt ();
  2360. Doo::loadModel ( 'receiptTraining' );
  2361. $receiptTraining = new receiptTraining ();
  2362. Doo::loadModel ( 'RItem' );
  2363. $RItem = new RItem ();
  2364. Doo::loadModel ( 'accountItem' );
  2365. $accountItem = new accountItem ();
  2366. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2367. if ($receiptDetail ['status'] != 5)
  2368. die ();
  2369. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2370. $RItemList = $RItem->getRItemByRid ( $rid );
  2371. $aiList = $accountItem->getAccountBookByCategory ( '培训班费用' );
  2372. // print_r($RItemList);
  2373. $data ['RItemList'] = $RItemList;
  2374. $data ['aiList'] = $aiList;
  2375. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2376. $data ['receiptDetail'] = $receiptDetail;
  2377. $data ['trainEdiType'] = "ITEM";
  2378. $data ['ridKey'] = $ridKey;
  2379. $data ['memu'] = "receipt";
  2380. $data ['staff'] = $this->staff;
  2381. $data ['receiptMemu'] = 'saeaBorad';
  2382. $data ['verifyId'] = $this->verifyId;
  2383. $data ['executeId'] = $this->executeId;
  2384. $this->render ( "/receipt/receiptTrainItemEdi", $data );
  2385. }
  2386. /**
  2387. * 添加支出项
  2388. */
  2389. function receiptTrainItemAddDo() {
  2390. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2391. // 支出项信息
  2392. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  2393. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  2394. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  2395. $inputer = $this->get_args ( 'inputer' ) ? $this->get_args ( 'inputer' ) : "";
  2396. $describe = $this->get_args ( 'describe' ) ? $this->get_args ( 'describe' ) : "";
  2397. if (! empty ( $ridKey ) && ! empty ( $item ) && ! empty ( $price ) && ! empty ( $date ) && ! empty ( $inputer )) {
  2398. Doo::loadClass ( 'XDeode' );
  2399. $XDeode = new XDeode ( 5 );
  2400. Doo::loadModel ( 'RItem' );
  2401. $RItem = new RItem ();
  2402. $rid = $XDeode->decode ( $ridKey );
  2403. if (! is_numeric ( $rid ))
  2404. die ( 'illegal request' );
  2405. $RItem->rid = $rid;
  2406. $RItem->item = $item;
  2407. $RItem->price = $price;
  2408. $RItem->date = $date;
  2409. $RItem->inputer = $inputer;
  2410. $RItem->describe = $describe;
  2411. $RItem->insert ();
  2412. // 添加公司汇总
  2413. // 报销详情
  2414. Doo::loadModel ( 'receiptDetail' );
  2415. $receiptDetail = new receiptDetail ();
  2416. Doo::loadModel ( 'receipt' );
  2417. $receipt = new receipt ();
  2418. $rInfo = $receipt->getReceiptByRid ( $rid );
  2419. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, $item, '培训班费用' );
  2420. if (empty ( $rdInfo )) {
  2421. $receiptDetail = new receiptDetail ();
  2422. $receiptDetail->staff = $this->staff [0] ['sid'];
  2423. $receiptDetail->item = $item;
  2424. $receiptDetail->itemCategory = '培训班费用';
  2425. $receiptDetail->price = number_format ( $price, 2, '.', '' );
  2426. $receiptDetail->date = date ( "Y-m-d" );
  2427. $receiptDetail->cid = $rInfo ['cid'];
  2428. $receiptDetail->rid = $rid;
  2429. $receiptDetail->status = 4;
  2430. $receiptDetail->insert ();
  2431. } else {
  2432. $receiptDetail = new receiptDetail ();
  2433. $rdInfo ['price'] += number_format ( $price, 2, '.', '' );
  2434. $receiptDetail->price = $rdInfo ['price'];
  2435. $receiptDetail->update ( array (
  2436. 'where' => 'rid=' . $rid . ' and item like "' . $item . '" and itemCategory like "培训班费用"'
  2437. ) );
  2438. }
  2439. $XDeode = new XDeode ( 7 );
  2440. return '/receiptTrainItemEdi/' . $XDeode->encode ( $rid ) . '.html';
  2441. } else
  2442. die ( 'illegal request' );
  2443. }
  2444. /**
  2445. * 培训班结算-讲师
  2446. */
  2447. function receiptTrainLecturerEdi() {
  2448. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2449. Doo::loadClass ( 'XDeode' );
  2450. $XDeode = new XDeode ( 7 );
  2451. $rid = $XDeode->decode ( $ridKey );
  2452. if (! is_numeric ( $rid ))
  2453. die ( 'illegal request' );
  2454. Doo::loadModel ( 'receipt' );
  2455. $receipt = new receipt ();
  2456. Doo::loadModel ( 'receiptTraining' );
  2457. $receiptTraining = new receiptTraining ();
  2458. Doo::loadModel ( 'RILecturer' );
  2459. $RILecturer = new RILecturer ();
  2460. Doo::loadModel ( 'lecturer' );
  2461. $lecturer = new lecturer ();
  2462. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2463. if ($receiptDetail ['status'] != 5)
  2464. die ();
  2465. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2466. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2467. $lecturerList = $lecturer->getLecturerAll ();
  2468. $INSIDEhtml = $OUTSIDEhtml = '';
  2469. foreach ( $lecturerList as $key => $value ) {
  2470. if ($value ['ltype'] == 'INSIDE') {
  2471. $INSIDEhtml .= '<option value="' . $value ['category'] . '-' . $value ['staff'] . '">' . $value ['category'] . '-' . $value ['staff'] . '</option>';
  2472. } elseif ($value ['ltype'] == 'OUTSIDE') {
  2473. $OUTSIDEhtml .= '<option value="' . $value ['staff'] . '">' . $value ['staff'] . '</option>';
  2474. }
  2475. }
  2476. $data ['INSIDEhtml'] = $INSIDEhtml;
  2477. $data ['OUTSIDEhtml'] = $OUTSIDEhtml;
  2478. // print_r($RItemList);
  2479. $data ['RILecturerList'] = $RILecturerList;
  2480. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2481. $data ['receiptDetail'] = $receiptDetail;
  2482. $data ['trainEdiType'] = "LECTURER";
  2483. $data ['ridKey'] = $ridKey;
  2484. $data ['memu'] = "receipt";
  2485. $data ['staff'] = $this->staff;
  2486. $data ['receiptMemu'] = 'saeaBorad';
  2487. $data ['verifyId'] = $this->verifyId;
  2488. $data ['executeId'] = $this->executeId;
  2489. $this->render ( "/receipt/receiptTrainLecturerEdi", $data );
  2490. }
  2491. /**
  2492. * 添加讲师
  2493. */
  2494. function receiptTrainLecturerAddDo() {
  2495. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2496. // 支出项信息
  2497. $ltype = $this->get_args ( 'ltype' ) ? $this->get_args ( 'ltype' ) : "";
  2498. $lecturerName = $this->get_args ( 'lecturerName' ) ? $this->get_args ( 'lecturerName' ) : "";
  2499. $schoolDay = $this->get_args ( 'schoolDay' ) ? $this->get_args ( 'schoolDay' ) : "";
  2500. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  2501. $taxation = $this->get_args ( 'taxation' ) ? $this->get_args ( 'taxation' ) : "";
  2502. if (! empty ( $ridKey ) && ! empty ( $ltype ) && ! empty ( $lecturerName ) && ! empty ( $schoolDay ) && ! empty ( $price )) {
  2503. Doo::loadClass ( 'XDeode' );
  2504. $XDeode = new XDeode ( 5 );
  2505. Doo::loadModel ( 'RILecturer' );
  2506. $RILecturer = new RILecturer ();
  2507. $rid = $XDeode->decode ( $ridKey );
  2508. if (! is_numeric ( $rid ))
  2509. die ( 'illegal request' );
  2510. if ($ltype == 'OUTSIDE' && empty ( $taxation ))
  2511. die ( 'illegal request-taxationError' );
  2512. $RILecturer->rid = $rid;
  2513. $RILecturer->ltype = $ltype;
  2514. if ($ltype == 'OUTSIDE') {
  2515. if ($taxation == 'TAXATION') {
  2516. $RILecturer->taxation = 1;
  2517. } elseif ($taxation == 'NOTAXATION') {
  2518. $RILecturer->taxation = 0;
  2519. }
  2520. }
  2521. $RILecturer->lecturerName = $lecturerName;
  2522. $RILecturer->schoolDay = $schoolDay;
  2523. $RILecturer->price = $price;
  2524. $RILecturer->insert ();
  2525. // 添加公司汇总
  2526. // 报销详情
  2527. Doo::loadModel ( 'receiptDetail' );
  2528. $receiptDetail = new receiptDetail ();
  2529. Doo::loadModel ( 'receipt' );
  2530. $receipt = new receipt ();
  2531. // 金额总计
  2532. $price = $price * $schoolDay;
  2533. $rInfo = $receipt->getReceiptByRid ( $rid );
  2534. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  2535. if (empty ( $rdInfo )) {
  2536. $receiptDetail = new receiptDetail ();
  2537. $receiptDetail->staff = $this->staff [0] ['sid'];
  2538. $receiptDetail->item = '讲课费';
  2539. $receiptDetail->itemCategory = '培训班费用';
  2540. $receiptDetail->price = number_format ( $price, 2, '.', '' );
  2541. $receiptDetail->date = date ( "Y-m-d" );
  2542. $receiptDetail->cid = $rInfo ['cid'];
  2543. $receiptDetail->rid = $rid;
  2544. $receiptDetail->status = 4;
  2545. $receiptDetail->insert ();
  2546. } else {
  2547. $receiptDetail = new receiptDetail ();
  2548. $rdInfo ['price'] += number_format ( $price, 2, '.', '' );
  2549. $receiptDetail->price = $rdInfo ['price'];
  2550. $receiptDetail->update ( array (
  2551. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  2552. ) );
  2553. }
  2554. $XDeode = new XDeode ( 7 );
  2555. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  2556. } else
  2557. die ( 'illegal request' );
  2558. }
  2559. /**
  2560. * 移除讲师
  2561. */
  2562. function receiptTrainLecturerDelDo() {
  2563. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  2564. $rlidKey = $this->get_args ( 'rlidKey' ) ? $this->get_args ( 'rlidKey' ) : ""; // 发票培训班
  2565. Doo::loadModel ( 'receipt' );
  2566. $receipt = new receipt ();
  2567. Doo::loadModel ( 'RILecturer' );
  2568. $RILecturer = new RILecturer ();
  2569. Doo::loadClass ( 'XDeode' );
  2570. $XDeode = new XDeode ( 5 );
  2571. $rid = $XDeode->decode ( $ridKey );
  2572. $rlid = $XDeode->decode ( $rlidKey );
  2573. if (is_numeric ( $rid ) && is_numeric ( $rlid )) {
  2574. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2575. if ($receiptDetail ['status'] != 5)
  2576. die ( 'illegal request-status' );
  2577. $RILecturer->delete ( array (
  2578. 'where' => 'rid=' . $rid . ' and rlid=' . $rlid
  2579. ) );
  2580. $XDeode = new XDeode ( 7 );
  2581. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  2582. } else
  2583. die ( 'illegal request-iid' );
  2584. }
  2585. /**
  2586. * 培训班提交审批
  2587. */
  2588. function receiptTrainApprovalDo() {
  2589. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";;
  2590. Doo::loadClass ( 'XDeode' );
  2591. $XDeode = new XDeode ( 7 );
  2592. $rid = $XDeode->decode ( $ridKey );
  2593. Doo::loadModel ( 'receipt' );
  2594. $receipt = new receipt ();
  2595. Doo::loadModel ( 'receiptDetail' );
  2596. $receiptDetail = new receiptDetail ();
  2597. Doo::loadModel ( 'statistics' );
  2598. $statistics = new statistics ();
  2599. Doo::loadModel ( "verify" );
  2600. $verify = new verify ();
  2601. // 审批状态的判定
  2602. $receiptDetailList = $receipt->getOne ( array (
  2603. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  2604. 'asArray' => true
  2605. ) );
  2606. if (empty ( $receiptDetailList ))
  2607. return "/saeaBorad";
  2608. $verifyDetail = $verify->getOne ( array (
  2609. 'where' => ' vid =' . $receiptDetailList ['verify'],
  2610. 'asArray' => true
  2611. ) );
  2612. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  2613. if (empty ( $receiptDetailList ['nowStaff'] )) {
  2614. $nowStaff = "";
  2615. $nowStaffList = array ();
  2616. if ($verifyDetail [0] [1] == 'ROLE') {
  2617. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  2618. foreach ( $vStaffString as $key => $value ) {
  2619. $staffK = explode ( "_", $value );
  2620. array_push ( $nowStaffList, $staffK [0] );
  2621. }
  2622. $nowStaff = implode ( ',', $nowStaffList );
  2623. } else {
  2624. $nowStaff = $verifyDetail [0] [0];
  2625. }
  2626. $receipt->nowStaff = $nowStaff;
  2627. }
  2628. // echo $nowStaff;
  2629. // print_r($verifyDetail);die;
  2630. $receipt->rid = $receiptDetailList ['rid'];
  2631. $receipt->date = date ( "Y-m-d" );
  2632. $receipt->status = 2;
  2633. $receipt->update ();
  2634. $receiptDetail->status = 2;
  2635. $receiptDetail->update ( array (
  2636. 'where' => 'rid=' . $receiptDetailList ['rid']
  2637. ) );
  2638. Doo::loadModel ( "receiptLog" );
  2639. $receiptLog = new receiptLog ();
  2640. Doo::loadModel ( "verify" );
  2641. $verify = new verify ();
  2642. $vr = $verify->getOne ( array (
  2643. 'where' => 'vid=' . $receiptDetailList ['verify'],
  2644. 'asArray' => true
  2645. ) );
  2646. $jd = json_decode ( $vr ['staff'] );
  2647. $roleId = 0;
  2648. foreach ( $jd as $key => $value ) {
  2649. if ($value [1] == 'ROLE') {
  2650. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  2651. if ($pos !== false) {
  2652. $roleId = $value [0];
  2653. }
  2654. }
  2655. }
  2656. // 审批日志
  2657. // echo $roleId;die;
  2658. if (! empty ( $roleId )) {
  2659. Doo::loadModel ( "role" );
  2660. $role = new role ();
  2661. $roleInfo = $role->getOne ( array (
  2662. 'where' => 'rid=' . $roleId,
  2663. 'asArray' => true
  2664. ) );
  2665. // $receiptLog->rolename = $roleInfo ['name'];
  2666. }
  2667. $receiptLog->username = $this->staff [0] ['username'];
  2668. $receiptLog->uid = $this->staff [0] ['sid'];
  2669. $receiptLog->date = date ( "Y-m-d" );
  2670. $receiptLog->opinion = '提交审批';
  2671. $receiptLog->img = $this->staff [0] ['avatar'];
  2672. $receiptLog->status = 2;
  2673. $receiptLog->rid = $rid;
  2674. $receiptLog->insert ();
  2675. //写入列表项
  2676. Doo::loadModel ( 'accountItem' );
  2677. $accountItem = new accountItem ();
  2678. $aItem = $accountItem->getAccountBookByCategory ( '培训班费用' );
  2679. // 项目金额合计
  2680. Doo::loadModel ( 'RItem' );
  2681. $RItem = new RItem ();
  2682. // 讲师获得
  2683. Doo::loadModel ( 'RILecturer' );
  2684. $RILecturer = new RILecturer ();
  2685. $RItemList = $RItem->getRItemByRid ( $rid );
  2686. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2687. // 支出项金额详情
  2688. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, 0 );
  2689. //print_r($aItem);
  2690. //print_r($aiData);
  2691. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  2692. $ag = $tr = $ta = $ot = 0;
  2693. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  2694. foreach ( $aItem as $key => $value ) {
  2695. if ($value ['category'] == $this->TRAIN) {
  2696. foreach ($aiData['dataList'] as $k=>$v){
  2697. if ($value ['name'] == $v['name']) {
  2698. array_push ( $accountJson [$this->TRAIN], array (
  2699. 'aid' => $value ['aid'],
  2700. 'name' => $value ['name'],
  2701. 'price' => number_format ( $v['price'], 2, '.', '' )
  2702. ) );
  2703. $sum += $v['price'];
  2704. $trainSum += $v['price'];
  2705. unset($aiData['dataList'][$k]);
  2706. break;
  2707. }
  2708. }
  2709. }
  2710. }
  2711. $accountJson ['cSum'] = array (
  2712. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  2713. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  2714. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  2715. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  2716. );
  2717. // 报销单
  2718. $receipt = new receipt ();
  2719. $receipt->accountItem = json_encode ( $accountJson );
  2720. $receipt->sum = number_format ( $sum, 2, '.', '' );
  2721. $receipt->update ( array (
  2722. 'where' => 'rid=' . $rid
  2723. ) );
  2724. //print_r($accountJson);
  2725. // statistics item 统计写入
  2726. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  2727. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  2728. $accountItem = $accountJson ;
  2729. $stat = $statistics->getOne ( array (
  2730. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  2731. 'asArray' => true
  2732. ) );
  2733. if (empty ( $stat )) {
  2734. $statistics->date = date ( "Y-m-d" );
  2735. $statistics->cid = $this->staff [0] ['cid'];
  2736. $statistics->staff = $this->staff [0] ['sid'];
  2737. $statistics->agPrice = 0;
  2738. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  2739. $statistics->insert ();
  2740. } else {
  2741. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  2742. $statistics->update ( array (
  2743. 'where' => 'sid=' . $stat ['sid']
  2744. ) );
  2745. }
  2746. return "/saeaBorad";
  2747. }
  2748. function confirmation() {
  2749. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2750. Doo::loadModel ( 'receipt' );
  2751. Doo::loadModel ( 'receiptDetail' );
  2752. $receipt = new receipt ();
  2753. $receiptDetail = new receiptDetail ();
  2754. Doo::loadModel ( 'statistics' );
  2755. Doo::loadModel ( 'itemStatistics' );
  2756. $statistics = new statistics ();
  2757. $itemStatistics = new itemStatistics ();
  2758. Doo::loadModel ( "verify" );
  2759. $verify = new verify ();
  2760. $receiptDetailList = $receipt->getOne ( array (
  2761. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  2762. 'asArray' => true
  2763. ) );
  2764. if (empty ( $receiptDetailList ))
  2765. return "/saeaBorad";
  2766. $verifyDetail = $verify->getOne ( array (
  2767. 'where' => ' vid =' . $receiptDetailList ['verify'],
  2768. 'asArray' => true
  2769. ) );
  2770. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  2771. if (empty ( $receiptDetailList ['nowStaff'] )) {
  2772. $nowStaff = "";
  2773. $nowStaffList = array ();
  2774. if ($verifyDetail [0] [1] == 'ROLE') {
  2775. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  2776. foreach ( $vStaffString as $key => $value ) {
  2777. $staffK = explode ( "_", $value );
  2778. array_push ( $nowStaffList, $staffK [0] );
  2779. }
  2780. $nowStaff = implode ( ',', $nowStaffList );
  2781. } else {
  2782. $nowStaff = $verifyDetail [0] [0];
  2783. }
  2784. $receipt->nowStaff = $nowStaff;
  2785. }
  2786. // echo $nowStaff;
  2787. // print_r($verifyDetail);die;
  2788. $receipt->rid = $receiptDetailList ['rid'];
  2789. $receipt->status = 2;
  2790. $receipt->update ();
  2791. // 操作日志
  2792. Doo::loadModel ( "receiptLog" );
  2793. $receiptLog = new receiptLog ();
  2794. $verify = new verify ();
  2795. $receiptInfo = $receipt->getOne ( array (
  2796. 'where' => 'rid=' . $rid,
  2797. 'asArray' => true
  2798. ) );
  2799. $vr = $verify->getOne ( array (
  2800. 'where' => 'vid=' . $receiptInfo ['verify'],
  2801. 'asArray' => true
  2802. ) );
  2803. $jd = json_decode ( $vr ['staff'] );
  2804. $roleId = 0;
  2805. foreach ( $jd as $key => $value ) {
  2806. if ($value [1] == 'ROLE') {
  2807. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  2808. if ($pos !== false) {
  2809. $roleId = $value [0];
  2810. }
  2811. }
  2812. }
  2813. // 审批日志
  2814. // echo $roleId;die;
  2815. if (! empty ( $roleId )) {
  2816. Doo::loadModel ( "role" );
  2817. $role = new role ();
  2818. $roleInfo = $role->getOne ( array (
  2819. 'where' => 'rid=' . $roleId,
  2820. 'asArray' => true
  2821. ) );
  2822. // $receiptLog->rolename = $roleInfo ['name'];
  2823. }
  2824. $receiptLog->username = $this->staff [0] ['username'];
  2825. $receiptLog->uid = $this->staff [0] ['sid'];
  2826. $receiptLog->date = date ( "Y-m-d" );
  2827. $receiptLog->opinion = '提交审批';
  2828. $receiptLog->img = $this->staff [0] ['avatar'];
  2829. $receiptLog->status = 2;
  2830. $receiptLog->rid = $rid;
  2831. $receiptLog->insert ();
  2832. return "/expenses";
  2833. }
  2834. function expenses() {
  2835. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  2836. if (empty ( $item ))
  2837. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  2838. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  2839. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  2840. Doo::loadModel ( 'receipt' );
  2841. $receipt = new receipt ();
  2842. Doo::loadModel ( 'L_category' );
  2843. $Lcategory = new L_category ();
  2844. Doo::loadModel ( 'verify' );
  2845. Doo::loadModel ( 'statistics' );
  2846. $statistics = new statistics ();
  2847. $verify = new verify ();
  2848. Doo::loadModel ( 'staff' );
  2849. $staff = new staff ();
  2850. $condition = "";
  2851. if ($item == "expenses")
  2852. $condition = " and Rtype=1 ";
  2853. elseif ($item == "receipts")
  2854. $condition = " and Rtype=0 ";
  2855. elseif ($item == "remits")
  2856. $condition = " and Rtype=2 ";
  2857. $dateCondition = " and Year(date) =" . $year;
  2858. if (! empty ( $moth )) {
  2859. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  2860. $stList = $statistics->getOne ( array (
  2861. 'select' => 'rePrice ,agPrice',
  2862. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  2863. 'asArray' => true
  2864. ) );
  2865. } else
  2866. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  2867. if (empty ( $stList ))
  2868. $stList = array (
  2869. 'rePrice' => 0,
  2870. 'agPrice' => 0
  2871. );
  2872. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  2873. if (! isset ( $noPassSum ['sum'] ))
  2874. $noPassSum ['sum'] = 0;
  2875. $data ['stList'] = array (
  2876. 'rePrice' => $stList ['rePrice'],
  2877. 'agPrice' => $stList ['agPrice'],
  2878. 'skPrice' => ($noPassSum ['sum'])
  2879. );
  2880. $receiptList = $receipt->find ( array (
  2881. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  2882. 'desc' => 'rid',
  2883. 'asArray' => true
  2884. ) );
  2885. $Locate = 0;
  2886. $roleId = 0;
  2887. $button = 0;
  2888. foreach ( $receiptList as $key => $value ) {
  2889. $receiptList [$key] ['Locate'] = $Locate;
  2890. $Locate ++;
  2891. $receiptList [$key] ['reviseDetail'] = array ();
  2892. if (! empty ( $value ['reviseDetail'] ))
  2893. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2894. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2895. $categoryDetil = $Lcategory->getOne ( array (
  2896. 'where' => 'cid=' . $value ['cid'],
  2897. 'asArray' => true
  2898. ) );
  2899. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2900. // 检测编辑状态
  2901. $verifyList = $verify->getOne ( array (
  2902. 'where' => 'vid=' . $value ['verify'],
  2903. 'asArray' => true
  2904. ) );
  2905. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2906. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2907. Doo::loadModel ( 'role' );
  2908. $role = new role ();
  2909. $flag = true;
  2910. $roleKey = 0;
  2911. $endStaffArray = array ();
  2912. $roleArrayCopy = array ();
  2913. foreach ( $verifyList as $k => $v ) {
  2914. // init verifyStaff
  2915. if ($v [1] == 'ROLE') {
  2916. if (! empty ( $verifyStaff )) {
  2917. $endStaffArray = end ( $verifyStaff );
  2918. // if ($v[0]==$endStaffArray['nextStaff']){
  2919. // $roleId=$v[0];
  2920. // }
  2921. }
  2922. $roleVerify = json_decode ( $v [3], true );
  2923. $roleKey = $k;
  2924. $roleArray = array ();
  2925. $rolename = $role->getOne ( array (
  2926. 'where' => 'rid=' . $v [0],
  2927. 'asArray' => true
  2928. ) );
  2929. foreach ( $roleVerify as $o => $p ) {
  2930. $staffID = explode ( '_', $p );
  2931. $staffInfo = $staff->getOne ( array (
  2932. 'where' => 'sid=' . $staffID [0],
  2933. 'asArray' => true
  2934. ) );
  2935. // print_r($staffID);
  2936. $exp = array (
  2937. 0 => $staffInfo ['sid'],
  2938. 1 => $staffID [1],
  2939. 2 => $staffInfo ['avatar'],
  2940. 'date' => '',
  2941. 'date' => '',
  2942. 'opinion' => '',
  2943. 'status' => '',
  2944. 'rolename' => $rolename ['name']
  2945. );
  2946. array_push ( $roleArray, $exp );
  2947. }
  2948. $roleArrayCopy [$v [0]] = $roleArray;
  2949. // $verifyList[$k]['roleArray']=$roleArray;
  2950. }
  2951. $verifyList [$k] ['date'] = "";
  2952. $verifyList [$k] ['opinion'] = "";
  2953. $verifyList [$k] ['status'] = "";
  2954. if (empty ( $verifyStaff )) {
  2955. $verifyList [$k] ['date'] = "";
  2956. $verifyList [$k] ['opinion'] = "";
  2957. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2958. $verifyList [$k] ['status'] = 4;
  2959. $flag = false;
  2960. }
  2961. } else {
  2962. foreach ( $verifyStaff as $m => $u ) {
  2963. if ($v [0] == $m) {
  2964. $verifyList [$k] ['date'] = $u ['date'];
  2965. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2966. $verifyList [$k] ['status'] = $u ['status'];
  2967. $flag = false;
  2968. break;
  2969. }
  2970. }
  2971. $endStaffArray = end ( $verifyStaff );
  2972. if (isset ( $endStaffArray ['ROLE'] )) {
  2973. } else {
  2974. // $endKey=key($verifyStaff);
  2975. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2976. // $button=4;
  2977. // $verifyList[$k]['status']=4;
  2978. // }
  2979. }
  2980. }
  2981. }
  2982. $rolename ['name'] = '';
  2983. if (! empty ( $roleId )) {
  2984. Doo::loadModel ( 'role' );
  2985. $role = new role ();
  2986. $rolename = $role->getOne ( array (
  2987. 'where' => 'rid=' . $roleId,
  2988. 'asArray' => true
  2989. ) );
  2990. }
  2991. if (! empty ( $verifyStaff ))
  2992. $endStaffArray = end ( $verifyStaff );
  2993. $KOP = false;
  2994. foreach ( $roleArrayCopy as $P => $A ) {
  2995. foreach ( $A as $MKI => $AVL ) {
  2996. if (! empty ( $verifyStaff )) {
  2997. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2998. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2999. $button = 4;
  3000. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3001. }
  3002. foreach ( $verifyStaff as $m => $u ) {
  3003. $AVLFK = $AVL [0] . '_R';
  3004. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3005. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3006. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3007. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3008. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3009. break;
  3010. }
  3011. }
  3012. } else {
  3013. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3014. $button = 4;
  3015. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3016. }
  3017. }
  3018. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3019. $KOP = true;
  3020. }
  3021. }
  3022. foreach ( $roleArrayCopy as $k => $v ) {
  3023. foreach ( $verifyList as $m => $n ) {
  3024. if ($n [0] == $k) {
  3025. array_splice ( $verifyList, $m, 1, $v );
  3026. }
  3027. }
  3028. }
  3029. $receiptList [$key] ['verifyList'] = $verifyList;
  3030. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3031. 'where' => 'sid=' . $value ['staff'],
  3032. 'asArray' => true
  3033. ) );
  3034. $receiptList [$key] ['button'] = $button;
  3035. }
  3036. // print_r($receiptList);die;
  3037. $mothHtml = "";
  3038. for($i = 1; $i <= 12; $i ++) {
  3039. if ($moth == $i)
  3040. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3041. else
  3042. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3043. }
  3044. $dateHtml = "";
  3045. $now = date ( "Y" );
  3046. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  3047. if ($YEARD <= $now) {
  3048. $dateHtml .= '<option ';
  3049. if ($year == $YEARD) {
  3050. $dateHtml .= 'selected ';
  3051. }
  3052. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  3053. }
  3054. }
  3055. $data ['dateHtml'] = $dateHtml;
  3056. $data ['mothHtml'] = $mothHtml;
  3057. $data ['receiptList'] = $receiptList;
  3058. $data ['memu'] = "receipt";
  3059. $data ['staff'] = $this->staff;
  3060. $data ['receiptMemu'] = 'expenses';
  3061. $data ['verifyId'] = $this->verifyId;
  3062. $data ['executeId'] = $this->executeId;
  3063. $data ['item'] = $item;
  3064. $data ['year'] = $year;
  3065. $this->render ( "/admin/expenses", $data );
  3066. }
  3067. function expensesCollect() {
  3068. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3069. Doo::loadModel ( 'receipt' );
  3070. $receipt = new receipt ();
  3071. Doo::loadModel ( 'L_category' );
  3072. $Lcategory = new L_category ();
  3073. Doo::loadModel ( 'verify' );
  3074. Doo::loadModel ( 'statistics' );
  3075. $statistics = new statistics ();
  3076. $verify = new verify ();
  3077. Doo::loadModel ( 'staff' );
  3078. $staff = new staff ();
  3079. Doo::loadModel ( 'loanReceipt' );
  3080. $loanReceipt = new loanReceipt ();
  3081. $receiptList = $receipt->find ( array (
  3082. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  3083. 'desc' => 'rid',
  3084. 'asArray' => true
  3085. ) );
  3086. $loanList = $loanReceipt->find ( array (
  3087. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3088. 'desc' => 'rid',
  3089. 'asArray' => true
  3090. ) );
  3091. /*
  3092. * $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;
  3093. */
  3094. $data ['explanation'] = '';
  3095. if (! empty ( $loanList ))
  3096. $data ['explanation'] = $loanList [0] ['explanation'];
  3097. $Locate = 0;
  3098. $roleId = 0;
  3099. $button = 0;
  3100. foreach ( $receiptList as $key => $value ) {
  3101. $receiptList [$key] ['Locate'] = $Locate;
  3102. $Locate ++;
  3103. $receiptList [$key] ['reviseDetail'] = array ();
  3104. if (! empty ( $value ['reviseDetail'] ))
  3105. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3106. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3107. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3108. $categoryDetil = $Lcategory->getOne ( array (
  3109. 'where' => 'cid=' . $value ['cid'],
  3110. 'asArray' => true
  3111. ) );
  3112. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3113. // 检测编辑状态
  3114. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  3115. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  3116. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  3117. else
  3118. $verifyList ['staff'] = $value ['verifyBreakup'];
  3119. } else
  3120. $verifyList = $verify->getOne ( array (
  3121. 'where' => 'vid=' . $value ['verify'],
  3122. 'asArray' => true
  3123. ) );
  3124. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3125. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3126. Doo::loadModel ( 'role' );
  3127. $role = new role ();
  3128. $flag = true;
  3129. $roleKey = 0;
  3130. $endStaffArray = array ();
  3131. $roleArrayCopy = array ();
  3132. foreach ( $verifyList as $k => $v ) {
  3133. // init verifyStaff
  3134. if ($v [1] == 'ROLE') {
  3135. if (! empty ( $verifyStaff )) {
  3136. $endStaffArray = end ( $verifyStaff );
  3137. // if ($v[0]==$endStaffArray['nextStaff']){
  3138. // $roleId=$v[0];
  3139. // }
  3140. }
  3141. $roleVerify = json_decode ( $v [3], true );
  3142. $roleKey = $k;
  3143. $roleArray = array ();
  3144. $rolename = $role->getOne ( array (
  3145. 'where' => 'rid=' . $v [0],
  3146. 'asArray' => true
  3147. ) );
  3148. foreach ( $roleVerify as $o => $p ) {
  3149. $staffID = explode ( '_', $p );
  3150. $staffInfo = $staff->getOne ( array (
  3151. 'where' => 'sid=' . $staffID [0],
  3152. 'asArray' => true
  3153. ) );
  3154. // print_r($staffID);
  3155. $exp = array (
  3156. 0 => $staffInfo ['sid'],
  3157. 1 => $staffID [1],
  3158. 2 => $staffInfo ['avatar'],
  3159. 'date' => '',
  3160. 'date' => '',
  3161. 'opinion' => '',
  3162. 'status' => '',
  3163. 'rolename' => $rolename ['name']
  3164. );
  3165. array_push ( $roleArray, $exp );
  3166. }
  3167. $roleArrayCopy [$v [0]] = $roleArray;
  3168. // $verifyList[$k]['roleArray']=$roleArray;
  3169. }
  3170. $verifyList [$k] ['date'] = "";
  3171. $verifyList [$k] ['opinion'] = "";
  3172. $verifyList [$k] ['status'] = "";
  3173. if (empty ( $verifyStaff )) {
  3174. $verifyList [$k] ['date'] = "";
  3175. $verifyList [$k] ['opinion'] = "";
  3176. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3177. $verifyList [$k] ['status'] = 4;
  3178. $flag = false;
  3179. }
  3180. } else {
  3181. foreach ( $verifyStaff as $m => $u ) {
  3182. if ($v [0] == $m) {
  3183. $verifyList [$k] ['date'] = $u ['date'];
  3184. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3185. $verifyList [$k] ['status'] = $u ['status'];
  3186. $flag = false;
  3187. break;
  3188. }
  3189. }
  3190. $endStaffArray = end ( $verifyStaff );
  3191. if (isset ( $endStaffArray ['ROLE'] )) {
  3192. } else {
  3193. // $endKey=key($verifyStaff);
  3194. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3195. // $button=4;
  3196. // $verifyList[$k]['status']=4;
  3197. // }
  3198. }
  3199. }
  3200. }
  3201. $rolename ['name'] = '';
  3202. if (! empty ( $roleId )) {
  3203. Doo::loadModel ( 'role' );
  3204. $role = new role ();
  3205. $rolename = $role->getOne ( array (
  3206. 'where' => 'rid=' . $roleId,
  3207. 'asArray' => true
  3208. ) );
  3209. }
  3210. if (! empty ( $verifyStaff ))
  3211. $endStaffArray = end ( $verifyStaff );
  3212. $KOP = false;
  3213. foreach ( $roleArrayCopy as $P => $A ) {
  3214. foreach ( $A as $MKI => $AVL ) {
  3215. if (! empty ( $verifyStaff )) {
  3216. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3217. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3218. $button = 4;
  3219. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3220. }
  3221. foreach ( $verifyStaff as $m => $u ) {
  3222. $AVLFK = $AVL [0] . '_R';
  3223. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3224. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3225. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3226. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3227. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3228. break;
  3229. }
  3230. }
  3231. } else {
  3232. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3233. $button = 4;
  3234. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3235. }
  3236. }
  3237. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3238. $KOP = true;
  3239. }
  3240. }
  3241. foreach ( $roleArrayCopy as $k => $v ) {
  3242. foreach ( $verifyList as $m => $n ) {
  3243. if ($n [0] == $k) {
  3244. array_splice ( $verifyList, $m, 1, $v );
  3245. }
  3246. }
  3247. }
  3248. // 费用执行人相关数据
  3249. $executeCopy = json_decode ( $value ['executeCopy'], true );
  3250. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3251. foreach ( $executeCopy as $k => $v ) {
  3252. $executeCopy [$k] ['date'] = '';
  3253. $executeCopy [$k] ['opinion'] = '';
  3254. $executeCopy [$k] ['status'] = '';
  3255. if (! empty ( $executeStaff ))
  3256. foreach ( $executeStaff as $m => $u ) {
  3257. if ($v [0] == $m) {
  3258. $executeCopy [$k] ['date'] = $u ['date'];
  3259. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  3260. $executeCopy [$k] ['status'] = $u ['status'];
  3261. break;
  3262. }
  3263. }
  3264. }
  3265. $receiptList [$key] ['executeCopy'] = $executeCopy;
  3266. $receiptList [$key] ['verifyList'] = $verifyList;
  3267. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3268. 'where' => 'sid=' . $value ['staff'],
  3269. 'asArray' => true
  3270. ) );
  3271. $receiptList [$key] ['button'] = $button;
  3272. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3273. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3274. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  3275. $receiptList [$key] ['relust'] = $relust;
  3276. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  3277. }
  3278. Doo::loadModel ( 'enclosur' );
  3279. $enclosur = new enclosur ();
  3280. $enclosurList = $enclosur->find ( array (
  3281. 'where' => 'rid=' . $rid,
  3282. 'asArray' => true
  3283. ) );
  3284. $enclosurHtml = '';
  3285. foreach ( $enclosurList as $value ) {
  3286. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3287. }
  3288. $data ['enclosurHtml'] = $enclosurHtml;
  3289. // print_r($receiptList);
  3290. $data ['receiptList'] = $receiptList;
  3291. $data ['memu'] = "receipt";
  3292. $data ['staff'] = $this->staff;
  3293. $data ['receiptMemu'] = 'expenses';
  3294. $data ['verifyId'] = $this->verifyId;
  3295. $data ['executeId'] = $this->executeId;
  3296. $this->render ( "/admin/expensesCollect", $data );
  3297. }
  3298. function approvalExpenses() {
  3299. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  3300. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3301. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3302. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3303. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3304. // $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) :"";
  3305. // echo $rdate;
  3306. if (empty ( $status ))
  3307. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3308. $page_size = 2;
  3309. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  3310. $vidList = array ();
  3311. $button = 0;
  3312. Doo::loadModel ( 'verify' );
  3313. $verify = new verify ();
  3314. Doo::loadModel ( 'receipt' );
  3315. $receipt = new receipt ();
  3316. Doo::loadModel ( 'staff' );
  3317. $staff = new staff ();
  3318. Doo::loadModel ( 'L_category' );
  3319. $Lcategory = new L_category ();
  3320. // user verify ID
  3321. $verifyDetail = $verify->find ( array (
  3322. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  3323. 'asArray' => true
  3324. ) );
  3325. foreach ( $verifyDetail as $key => $value ) {
  3326. array_push ( $vidList, $value ['vid'] );
  3327. }
  3328. $vid = implode ( ",", $vidList );
  3329. if (empty ( $verifyDetail ))
  3330. $vid = 0;
  3331. // if ($status==0)
  3332. // $dateCondition="";
  3333. // else
  3334. $dateCondition = " ";
  3335. // if (! empty ( $month ))
  3336. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  3337. if ($status == 'done' || $status == 'termination') {
  3338. if (! empty ( $year )) {
  3339. $dateCondition = " and Year(pastDate) =" . $year;
  3340. if (! empty ( $month ))
  3341. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  3342. }
  3343. } elseif ($status == 'finish') {
  3344. if (! empty ( $year )) {
  3345. $dateCondition = " and Year(pastDate) =" . $year;
  3346. if (! empty ( $month ))
  3347. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  3348. }
  3349. }
  3350. // date ( 'Y-m' )
  3351. // if (! empty ( $rdate ) && $status == 'done')
  3352. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  3353. // elseif (! empty ( $rdate ))
  3354. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  3355. $categoryList = $Lcategory->find ( array (
  3356. 'asArray' => true
  3357. ) );
  3358. $staffList = $staff->find ( array (
  3359. 'where' => 'cid=' . $cid,
  3360. 'asArray' => true
  3361. ) );
  3362. $cateCondition = "";
  3363. $staffCondition = "";
  3364. $approvalCondition = "";
  3365. if (! empty ( $cid )) {
  3366. $cateCondition = ' and cid=' . $cid;
  3367. }
  3368. if (! empty ( $sid )) {
  3369. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  3370. $cateCondition = "";
  3371. }
  3372. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  3373. if ($status == 'pendApproval') {
  3374. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  3375. }
  3376. if ($status == 'ongoing') {
  3377. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  3378. }
  3379. if ($status == 'done') {
  3380. $approvalCondition = ' and (status=8 or status=9 ) ';
  3381. }
  3382. if ($status == 'termination') {
  3383. $approvalCondition = " and status=3";
  3384. }
  3385. if ($status == 'finish') {
  3386. $approvalCondition = " and (status=1 or status=8 or status=9)";
  3387. }
  3388. $pageinfo ['page'] = array (
  3389. 'previous' => ''
  3390. );
  3391. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  3392. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  3393. $receiptList = $receipt->find ( array ( // $dateCondition.
  3394. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  3395. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  3396. 'desc' => 'rid',
  3397. 'asArray' => true
  3398. ) );
  3399. } else {
  3400. $receiptList = $receipt->find ( array ( // $dateCondition
  3401. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  3402. 'desc' => 'rid',
  3403. 'asArray' => true
  3404. ) );
  3405. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  3406. }
  3407. $rLRes = $receipt->find ( array (
  3408. '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 . ')',
  3409. 'desc' => 'rid',
  3410. 'asArray' => true
  3411. ) );
  3412. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  3413. // print_r($receiptList);
  3414. Doo::loadClass ( 'XDeode' );
  3415. $XDeode = new XDeode ( 7 );
  3416. $Locate = 0;
  3417. $reportList = $reportCateList = array ();
  3418. foreach ( $receiptList as $key => $value ) {
  3419. $receiptList [$key] ['ridKey'] = $XDeode->encode( $value['rid'] );
  3420. $receiptList [$key] ['Locate'] = $Locate;
  3421. $Locate ++;
  3422. $receiptList [$key] ['reviseDetail'] = array ();
  3423. if (! empty ( $value ['reviseDetail'] ))
  3424. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3425. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3426. $categoryDetil = $Lcategory->getOne ( array (
  3427. 'where' => 'cid=' . $value ['cid'],
  3428. 'asArray' => true
  3429. ) );
  3430. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3431. $verifyList = $verify->getOne ( array (
  3432. 'where' => 'vid=' . $value ['verify'],
  3433. 'asArray' => true
  3434. ) );
  3435. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3436. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3437. foreach ( $verifyList as $k => $v ) {
  3438. // init verifyStaff
  3439. $verifyList [$k] ['date'] = "";
  3440. $verifyList [$k] ['opinion'] = "";
  3441. $verifyList [$k] ['status'] = "";
  3442. if (empty ( $verifyStaff )) {
  3443. $verifyList [$k] ['date'] = "";
  3444. $verifyList [$k] ['opinion'] = "";
  3445. if ($v [0] == $this->staff [0] ['sid']) {
  3446. $verifyList [$k] ['status'] = 4;
  3447. $button = 4;
  3448. }
  3449. } else {
  3450. $flag = true;
  3451. foreach ( $verifyStaff as $m => $u ) {
  3452. if ($v [0] == $m) {
  3453. $verifyList [$k] ['date'] = $u ['date'];
  3454. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3455. $verifyList [$k] ['status'] = $u ['status'];
  3456. $flag = false;
  3457. break;
  3458. }
  3459. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  3460. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  3461. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  3462. }
  3463. if ($flag) { // 检测可编辑
  3464. if ($v [0] == $this->staff [0] ['sid']) {
  3465. $verifyList [$k] ['status'] = 4;
  3466. $button = 4;
  3467. }
  3468. }
  3469. }
  3470. }
  3471. $receiptList [$key] ['verifyList'] = $verifyList;
  3472. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3473. 'where' => 'sid=' . $value ['staff'],
  3474. 'asArray' => true
  3475. ) );
  3476. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  3477. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  3478. $receiptList [$key] ['button'] = $button;
  3479. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  3480. }
  3481. $reportList = array_unique ( $reportList );
  3482. $reportHtml = '';
  3483. foreach ( $reportList as $key => $value ) {
  3484. $v = explode ( "-", $value );
  3485. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  3486. }
  3487. // print_r($reportList)
  3488. $data ['reportHtml'] = $reportHtml;
  3489. $reportCateList = array_unique ( $reportCateList );
  3490. $reportCateHtml = '';
  3491. foreach ( $reportCateList as $key => $value ) {
  3492. $v = explode ( "-", $value );
  3493. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  3494. }
  3495. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  3496. $data ['reportCateHtml'] = $reportCateHtml;
  3497. // print_r($receiptList);die;
  3498. // $data['verifyDetail']=$verifyDetail;
  3499. $mothHtml = "";
  3500. for($i = 1; $i <= 12; $i ++) {
  3501. if ($month == $i)
  3502. $mothHtml .= '<option selected value="0' . $i . '">' . $i . '月</option>';
  3503. else
  3504. $mothHtml .= '<option value="0' . $i . '">' . $i . '月</option>';
  3505. }
  3506. $data ['mothHtml'] = $mothHtml;
  3507. $dateHtml = "";
  3508. $now = date ( "Y" );
  3509. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  3510. if ($YEARD <= $now) {
  3511. $dateHtml .= '<option ';
  3512. if ($year == $YEARD) {
  3513. $dateHtml .= 'selected ';
  3514. }
  3515. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  3516. }
  3517. }
  3518. $data ['dateHtml'] = $dateHtml;
  3519. $data ['page'] = $pageinfo;
  3520. $data ['receiptList'] = $receiptList;
  3521. $data ['receiptApprovalCount'] = count ( $rLRes );
  3522. $data ['status'] = $status;
  3523. $data ['year'] = $year;
  3524. $data ['month'] = $month;
  3525. $data ['categoryList'] = $categoryList;
  3526. $data ['staffList'] = $staffList;
  3527. $data ['cid'] = $cid;
  3528. $data ['sid'] = $sid;
  3529. // print_r($receiptList);
  3530. $data ['memu'] = "receipt";
  3531. $data ['staff'] = $this->staff;
  3532. $data ['receiptMemu'] = 'approvalExpenses';
  3533. $data ['verifyId'] = $this->verifyId;
  3534. $data ['executeId'] = $this->executeId;
  3535. $this->render ( "/admin/approvalExpenses", $data );
  3536. }
  3537. function expensesDoc() {
  3538. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3539. Doo::loadClass ( 'XDeode' );
  3540. $XDeode = new XDeode ( 5 );
  3541. if (! empty ( $rid ) && ! is_numeric ( $rid ))
  3542. $rid = $XDeode->decode ( $rid );
  3543. if (! is_numeric ( $rid ))
  3544. die ( 'illegal request' );
  3545. Doo::loadModel ( 'receipt' );
  3546. $receipt = new receipt ();
  3547. Doo::loadModel ( 'L_category' );
  3548. $Lcategory = new L_category ();
  3549. Doo::loadModel ( 'verify' );
  3550. Doo::loadModel ( 'statistics' );
  3551. $statistics = new statistics ();
  3552. $verify = new verify ();
  3553. Doo::loadModel ( 'staff' );
  3554. $staff = new staff ();
  3555. Doo::loadModel ( 'loanReceipt' );
  3556. $loanReceipt = new loanReceipt ();
  3557. $receiptList = $receipt->find ( array (
  3558. 'where' => ' rid=' . $rid,
  3559. 'desc' => 'rid',
  3560. 'asArray' => true
  3561. ) );
  3562. $loanList = array ();
  3563. if (! empty ( $receiptList ))
  3564. $loanList = $loanReceipt->find ( array (
  3565. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3566. 'desc' => 'rid',
  3567. 'asArray' => true
  3568. ) );
  3569. $Locate = 0;
  3570. $roleId = 0;
  3571. $button = 0;
  3572. foreach ( $loanList as $key => $value ) {
  3573. $loanList [$key] ['Locate'] = $Locate;
  3574. $Locate ++;
  3575. $loanList [$key] ['reviseDetail'] = array ();
  3576. if (! empty ( $value ['reviseDetail'] ))
  3577. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3578. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3579. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3580. $categoryDetil = $Lcategory->getOne ( array (
  3581. 'where' => 'cid=' . $value ['cid'],
  3582. 'asArray' => true
  3583. ) );
  3584. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3585. // 检测编辑状态
  3586. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  3587. $verifyList ['staff'] = $value ['verifyBreakup'];
  3588. else
  3589. $verifyList = $verify->getOne ( array (
  3590. 'where' => 'vid=' . $value ['verify'],
  3591. 'asArray' => true
  3592. ) );
  3593. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3594. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3595. Doo::loadModel ( 'role' );
  3596. $role = new role ();
  3597. $flag = true;
  3598. $roleKey = 0;
  3599. $endStaffArray = array ();
  3600. $roleArrayCopy = array ();
  3601. foreach ( $verifyList as $k => $v ) {
  3602. // init verifyStaff
  3603. if ($v [1] == 'ROLE') {
  3604. if (! empty ( $verifyStaff )) {
  3605. $endStaffArray = end ( $verifyStaff );
  3606. // if ($v[0]==$endStaffArray['nextStaff']){
  3607. // $roleId=$v[0];
  3608. // }
  3609. }
  3610. $roleVerify = json_decode ( $v [3], true );
  3611. $roleKey = $k;
  3612. $roleArray = array ();
  3613. $rolename = $role->getOne ( array (
  3614. 'where' => 'rid=' . $v [0],
  3615. 'asArray' => true
  3616. ) );
  3617. foreach ( $roleVerify as $o => $p ) {
  3618. $staffID = explode ( '_', $p );
  3619. $staffInfo = $staff->getOne ( array (
  3620. 'where' => 'sid=' . $staffID [0],
  3621. 'asArray' => true
  3622. ) );
  3623. // print_r($staffID);
  3624. $exp = array (
  3625. 0 => $staffInfo ['sid'],
  3626. 1 => $staffID [1],
  3627. 2 => $staffInfo ['avatar'],
  3628. 'date' => '',
  3629. 'date' => '',
  3630. 'opinion' => '',
  3631. 'status' => '',
  3632. 'rolename' => $rolename ['name']
  3633. );
  3634. array_push ( $roleArray, $exp );
  3635. }
  3636. $roleArrayCopy [$v [0]] = $roleArray;
  3637. // $verifyList[$k]['roleArray']=$roleArray;
  3638. }
  3639. $verifyList [$k] ['date'] = "";
  3640. $verifyList [$k] ['opinion'] = "";
  3641. $verifyList [$k] ['status'] = "";
  3642. if (empty ( $verifyStaff )) {
  3643. $verifyList [$k] ['date'] = "";
  3644. $verifyList [$k] ['opinion'] = "";
  3645. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3646. $verifyList [$k] ['status'] = 4;
  3647. $flag = false;
  3648. }
  3649. } else {
  3650. foreach ( $verifyStaff as $m => $u ) {
  3651. if ($v [0] == $m) {
  3652. $verifyList [$k] ['date'] = $u ['date'];
  3653. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3654. $verifyList [$k] ['status'] = $u ['status'];
  3655. $flag = false;
  3656. break;
  3657. }
  3658. }
  3659. $endStaffArray = end ( $verifyStaff );
  3660. if (isset ( $endStaffArray ['ROLE'] )) {
  3661. } else {
  3662. // $endKey=key($verifyStaff);
  3663. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3664. // $button=4;
  3665. // $verifyList[$k]['status']=4;
  3666. // }
  3667. }
  3668. }
  3669. }
  3670. $rolename ['name'] = '';
  3671. if (! empty ( $roleId )) {
  3672. Doo::loadModel ( 'role' );
  3673. $role = new role ();
  3674. $rolename = $role->getOne ( array (
  3675. 'where' => 'rid=' . $roleId,
  3676. 'asArray' => true
  3677. ) );
  3678. }
  3679. if (! empty ( $verifyStaff ))
  3680. $endStaffArray = end ( $verifyStaff );
  3681. $KOP = false;
  3682. foreach ( $roleArrayCopy as $P => $A ) {
  3683. foreach ( $A as $MKI => $AVL ) {
  3684. if (! empty ( $verifyStaff )) {
  3685. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3686. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3687. $button = 4;
  3688. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3689. }
  3690. foreach ( $verifyStaff as $m => $u ) {
  3691. $AVLFK = $AVL [0] . '_R';
  3692. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3693. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3694. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3695. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3696. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3697. break;
  3698. }
  3699. }
  3700. } else {
  3701. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3702. $button = 4;
  3703. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3704. }
  3705. }
  3706. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3707. $KOP = true;
  3708. }
  3709. }
  3710. foreach ( $roleArrayCopy as $k => $v ) {
  3711. foreach ( $verifyList as $m => $n ) {
  3712. if ($n [0] == $k) {
  3713. array_splice ( $verifyList, $m, 1, $v );
  3714. }
  3715. }
  3716. }
  3717. $loanList [$key] ['verifyList'] = $verifyList;
  3718. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3719. 'where' => 'sid=' . $value ['staff'],
  3720. 'asArray' => true
  3721. ) );
  3722. $loanList [$key] ['button'] = $button;
  3723. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  3724. }
  3725. $data ['loanList'] = $loanList;
  3726. // print_r($loanList);
  3727. $Locate = 0;
  3728. $roleId = 0;
  3729. $button = 0;
  3730. foreach ( $receiptList as $key => $value ) {
  3731. $receiptList [$key] ['Locate'] = $Locate;
  3732. $Locate ++;
  3733. $receiptList [$key] ['reviseDetail'] = array ();
  3734. if (! empty ( $value ['reviseDetail'] ))
  3735. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3736. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3737. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3738. $categoryDetil = $Lcategory->getOne ( array (
  3739. 'where' => 'cid=' . $value ['cid'],
  3740. 'asArray' => true
  3741. ) );
  3742. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3743. // 检测编辑状态
  3744. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3745. $verifyList ['staff'] = $value ['verifyBreakup'];
  3746. } else
  3747. $verifyList = $verify->getOne ( array (
  3748. 'where' => 'vid=' . $value ['verify'],
  3749. 'asArray' => true
  3750. ) );
  3751. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3752. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3753. Doo::loadModel ( 'role' );
  3754. $role = new role ();
  3755. if ($verifyList == NULL)
  3756. $verifyList = array ();
  3757. $flag = true;
  3758. $roleKey = 0;
  3759. $endStaffArray = array ();
  3760. $roleArrayCopy = array ();
  3761. foreach ( $verifyList as $k => $v ) {
  3762. // init verifyStaff
  3763. if ($v [1] == 'ROLE') {
  3764. if (! empty ( $verifyStaff )) {
  3765. $endStaffArray = end ( $verifyStaff );
  3766. // if ($v[0]==$endStaffArray['nextStaff']){
  3767. // $roleId=$v[0];
  3768. // }
  3769. }
  3770. $roleVerify = json_decode ( $v [3], true );
  3771. $roleKey = $k;
  3772. $roleArray = array ();
  3773. $rolename = $role->getOne ( array (
  3774. 'where' => 'rid=' . $v [0],
  3775. 'asArray' => true
  3776. ) );
  3777. foreach ( $roleVerify as $o => $p ) {
  3778. $staffID = explode ( '_', $p );
  3779. $staffInfo = $staff->getOne ( array (
  3780. 'where' => 'sid=' . $staffID [0],
  3781. 'asArray' => true
  3782. ) );
  3783. // print_r($staffID);
  3784. $exp = array (
  3785. 0 => $staffInfo ['sid'],
  3786. 1 => $staffID [1],
  3787. 2 => $staffInfo ['avatar'],
  3788. 'date' => '',
  3789. 'date' => '',
  3790. 'opinion' => '',
  3791. 'status' => '',
  3792. 'rolename' => $rolename ['name']
  3793. );
  3794. array_push ( $roleArray, $exp );
  3795. }
  3796. $roleArrayCopy [$v [0]] = $roleArray;
  3797. // $verifyList[$k]['roleArray']=$roleArray;
  3798. }
  3799. $verifyList [$k] ['date'] = "";
  3800. $verifyList [$k] ['opinion'] = "";
  3801. $verifyList [$k] ['status'] = "";
  3802. if (empty ( $verifyStaff )) {
  3803. $verifyList [$k] ['date'] = "";
  3804. $verifyList [$k] ['opinion'] = "";
  3805. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3806. $verifyList [$k] ['status'] = 4;
  3807. $flag = false;
  3808. }
  3809. } else {
  3810. foreach ( $verifyStaff as $m => $u ) {
  3811. if ($v [0] == $m) {
  3812. $verifyList [$k] ['date'] = $u ['date'];
  3813. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3814. $verifyList [$k] ['status'] = $u ['status'];
  3815. $flag = false;
  3816. break;
  3817. }
  3818. }
  3819. $endStaffArray = end ( $verifyStaff );
  3820. if (isset ( $endStaffArray ['ROLE'] )) {
  3821. } else {
  3822. // $endKey=key($verifyStaff);
  3823. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3824. // $button=4;
  3825. // $verifyList[$k]['status']=4;
  3826. // }
  3827. }
  3828. }
  3829. }
  3830. $FC = @$rolename ['name'];
  3831. $rolename ['name'] = '';
  3832. if (! empty ( $roleId )) {
  3833. Doo::loadModel ( 'role' );
  3834. $role = new role ();
  3835. $rolename = $role->getOne ( array (
  3836. 'where' => 'rid=' . $roleId,
  3837. 'asArray' => true
  3838. ) );
  3839. }
  3840. if (! empty ( $verifyStaff ))
  3841. $endStaffArray = end ( $verifyStaff );
  3842. $KOP = false;
  3843. foreach ( $roleArrayCopy as $P => $A ) {
  3844. foreach ( $A as $MKI => $AVL ) {
  3845. if (! empty ( $verifyStaff )) {
  3846. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3847. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3848. $button = 4;
  3849. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3850. }
  3851. foreach ( $verifyStaff as $m => $u ) {
  3852. $AVLFK = $AVL [0] . '_R';
  3853. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3854. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3855. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3856. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3857. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3858. break;
  3859. }
  3860. }
  3861. } else {
  3862. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3863. $button = 4;
  3864. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3865. }
  3866. }
  3867. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3868. $KOP = true;
  3869. }
  3870. }
  3871. foreach ( $roleArrayCopy as $k => $v ) {
  3872. foreach ( $verifyList as $m => $n ) {
  3873. if ($n [0] == $k) {
  3874. array_splice ( $verifyList, $m, 1, $v );
  3875. }
  3876. }
  3877. }
  3878. // 费用执行人相关数据
  3879. $executeCopy = json_decode ( $value ['executeCopy'], true );
  3880. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3881. foreach ( $executeCopy as $k => $v ) {
  3882. $executeCopy [$k] ['date'] = '';
  3883. $executeCopy [$k] ['opinion'] = '';
  3884. $executeCopy [$k] ['status'] = '';
  3885. if (! empty ( $executeStaff ))
  3886. foreach ( $executeStaff as $m => $u ) {
  3887. if ($v [0] == $m) {
  3888. $executeCopy [$k] ['date'] = $u ['date'];
  3889. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  3890. $executeCopy [$k] ['status'] = $u ['status'];
  3891. break;
  3892. }
  3893. }
  3894. }
  3895. $receiptList [$key] ['executeCopy'] = $executeCopy;
  3896. // print_r($verifyList);
  3897. $receiptList [$key] ['verifyList'] = $verifyList;
  3898. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3899. 'where' => 'sid=' . $value ['staff'],
  3900. 'asArray' => true
  3901. ) );
  3902. $receiptList [$key] ['button'] = $button;
  3903. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3904. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3905. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  3906. $receiptList [$key] ['relust'] = $relust;
  3907. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  3908. }
  3909. // print_r($receiptList);
  3910. // 获取审批日志
  3911. Doo::loadModel ( 'receiptLog' );
  3912. $receiptLog = new receiptLog ();
  3913. $rlList = array ();
  3914. $rlInfo = $receiptLog->getOne ( array (
  3915. 'where' => 'rid=' . $rid . ' and status=4',
  3916. 'asArray' => true
  3917. ) );
  3918. $tijdate = $receiptLog->getOne ( array (
  3919. 'where' => 'rid=' . $rid . ' and status=2',
  3920. 'asc' => 'rlid',
  3921. 'asArray' => true
  3922. ) );
  3923. if (! empty ( $rlInfo )) {
  3924. $rlList = $receiptLog->find ( array (
  3925. 'where' => 'rid=' . $rid,
  3926. 'asc' => 'rlid',
  3927. 'asArray' => true
  3928. ) );
  3929. }
  3930. $RN = @json_decode ( $rolename ['staff'] );
  3931. //
  3932. foreach ( $rlList as $key => $value ) {
  3933. $rlList [$key] ['rolename'] = '';
  3934. foreach ( $RN as $k => $v ) {
  3935. $id = explode ( "_", $v );
  3936. if ($id [0] == $value ['uid']) {
  3937. $rlList [$key] ['rolename'] = $FC;
  3938. break;
  3939. }
  3940. }
  3941. }
  3942. Doo::loadModel ( 'enclosur' );
  3943. $enclosur = new enclosur ();
  3944. $enclosurList = $enclosur->find ( array (
  3945. 'where' => 'rid=' . $rid,
  3946. 'asArray' => true
  3947. ) );
  3948. $enclosurHtml = '';
  3949. foreach ( $enclosurList as $value ) {
  3950. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3951. }
  3952. $data ['enclosurHtml'] = $enclosurHtml;
  3953. $receiptList [0] ['rlList'] = $rlList;
  3954. $data ['receiptList'] = $receiptList;
  3955. // print_r($receiptList);
  3956. $data ['memu'] = "receipt";
  3957. $data ['staff'] = $this->staff;
  3958. $data ['receiptMemu'] = 'approvalExpenses';
  3959. $data ['verifyId'] = $this->verifyId;
  3960. $data ['executeId'] = $this->executeId;
  3961. $this->render ( "/admin/expensesDoc", $data );
  3962. }
  3963. function expensesEdi() {
  3964. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3965. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  3966. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3967. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3968. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3969. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3970. if (empty ( $status ))
  3971. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  3972. $vidList = array ();
  3973. $button = 0;
  3974. Doo::loadModel ( 'verify' );
  3975. Doo::loadModel ( 'receipt' );
  3976. Doo::loadModel ( 'staff' );
  3977. $staff = new staff ();
  3978. $receipt = new receipt ();
  3979. $verify = new verify ();
  3980. Doo::loadModel ( 'L_category' );
  3981. $Lcategory = new L_category ();
  3982. Doo::loadModel ( 'enclosur' );
  3983. $enclosur = new enclosur ();
  3984. // user verify ID
  3985. $verifyDetail = $verify->find ( array (
  3986. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  3987. 'asArray' => true
  3988. ) );
  3989. foreach ( $verifyDetail as $key => $value ) {
  3990. array_push ( $vidList, $value ['vid'] );
  3991. }
  3992. $vid = implode ( ",", $vidList );
  3993. if (empty ( $verifyDetail ))
  3994. $vid = 0;
  3995. $categoryList = $Lcategory->find ( array (
  3996. 'asArray' => true
  3997. ) );
  3998. $staffList = $staff->find ( array (
  3999. 'where' => 'cid=' . $cid,
  4000. 'asArray' => true
  4001. ) );
  4002. $ap = "";
  4003. if ($status == 4) {
  4004. $ap = 4;
  4005. $status = 2;
  4006. }
  4007. // get Receipt By verifyID status 2
  4008. $receiptList = $receipt->find ( array (
  4009. 'where' => 'rid =' . $rid . ' and status=2',
  4010. 'desc' => 'rid',
  4011. 'asArray' => true
  4012. ) );
  4013. if (empty ( $receiptList )) {
  4014. die ( 'illegal request' );
  4015. }
  4016. $Locate = 0;
  4017. $roleId = 0;
  4018. if ($ap == 4)
  4019. $status = 4;
  4020. foreach ( $receiptList as $key => $value ) {
  4021. $receiptList [$key] ['Locate'] = $Locate;
  4022. $Locate ++;
  4023. $receiptList [$key] ['reviseDetail'] = array ();
  4024. if (! empty ( $value ['reviseDetail'] ))
  4025. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4026. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4027. $categoryDetil = $Lcategory->getOne ( array (
  4028. 'where' => 'cid=' . $value ['cid'],
  4029. 'asArray' => true
  4030. ) );
  4031. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4032. // 检测编辑状态
  4033. $verifyList = $verify->getOne ( array (
  4034. 'where' => 'vid=' . $value ['verify'],
  4035. 'asArray' => true
  4036. ) );
  4037. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4038. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4039. Doo::loadModel ( 'role' );
  4040. $role = new role ();
  4041. // print_r($verifyList);
  4042. $flag = true;
  4043. $roleKey = 0;
  4044. $endStaffArray = array ();
  4045. $roleArrayCopy = array ();
  4046. foreach ( $verifyList as $k => $v ) {
  4047. // init verifyStaff
  4048. if ($v [1] == 'ROLE') {
  4049. if (! empty ( $verifyStaff )) {
  4050. $endStaffArray = end ( $verifyStaff );
  4051. if ($v [0] == $endStaffArray ['nextStaff']) {
  4052. $roleId = $v [0];
  4053. }
  4054. }
  4055. $roleVerify = json_decode ( $v [3], true );
  4056. $roleKey = $k;
  4057. $roleArray = array ();
  4058. $rolename = $role->getOne ( array (
  4059. 'where' => 'rid=' . $v [0],
  4060. 'asArray' => true
  4061. ) );
  4062. foreach ( $roleVerify as $o => $p ) {
  4063. $staffID = explode ( '_', $p );
  4064. $staffInfo = $staff->getOne ( array (
  4065. 'where' => 'sid=' . $staffID [0],
  4066. 'asArray' => true
  4067. ) );
  4068. // print_r($staffID);
  4069. $exp = array (
  4070. 0 => $staffInfo ['sid'],
  4071. 1 => $staffID [1],
  4072. 2 => $staffInfo ['avatar'],
  4073. 'date' => '',
  4074. 'date' => '',
  4075. 'opinion' => '',
  4076. 'status' => '',
  4077. 'rolename' => $rolename ['name']
  4078. );
  4079. array_push ( $roleArray, $exp );
  4080. }
  4081. $roleArrayCopy [$v [0]] = $roleArray;
  4082. // $verifyList[$k]['roleArray']=$roleArray;
  4083. }
  4084. // print_r($roleArray);
  4085. $verifyList [$k] ['date'] = "";
  4086. $verifyList [$k] ['opinion'] = "";
  4087. $verifyList [$k] ['status'] = "";
  4088. if (empty ( $verifyStaff )) {
  4089. $verifyList [$k] ['date'] = "";
  4090. $verifyList [$k] ['opinion'] = "";
  4091. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4092. $verifyList [$k] ['status'] = 4;
  4093. $button = 4;
  4094. $flag = false;
  4095. }
  4096. } else {
  4097. foreach ( $verifyStaff as $m => $u ) {
  4098. if ($v [0] == $m) {
  4099. $verifyList [$k] ['date'] = $u ['date'];
  4100. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4101. $verifyList [$k] ['status'] = $u ['status'];
  4102. $flag = false;
  4103. break;
  4104. }
  4105. }
  4106. $endStaffArray = end ( $verifyStaff );
  4107. if (isset ( $endStaffArray ['ROLE'] )) {
  4108. } else {
  4109. $endKey = key ( $verifyStaff );
  4110. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4111. $button = 4;
  4112. $verifyList [$k] ['status'] = 4;
  4113. }
  4114. }
  4115. }
  4116. }
  4117. $rolename ['name'] = '';
  4118. if (! empty ( $roleId )) {
  4119. Doo::loadModel ( 'role' );
  4120. $role = new role ();
  4121. $rolename = $role->getOne ( array (
  4122. 'where' => 'rid=' . $roleId,
  4123. 'asArray' => true
  4124. ) );
  4125. }
  4126. if (! empty ( $verifyStaff ))
  4127. $endStaffArray = end ( $verifyStaff );
  4128. $KOP = false;
  4129. foreach ( $roleArrayCopy as $P => $A ) {
  4130. foreach ( $A as $MKI => $AVL ) {
  4131. if (! empty ( $verifyStaff )) {
  4132. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4133. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4134. $button = 4;
  4135. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4136. }
  4137. foreach ( $verifyStaff as $m => $u ) {
  4138. $AVLFK = $AVL [0] . '_R';
  4139. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4140. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4141. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4142. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4143. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4144. break;
  4145. }
  4146. }
  4147. } else {
  4148. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4149. $button = 4;
  4150. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4151. }
  4152. }
  4153. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4154. $KOP = true;
  4155. }
  4156. }
  4157. // print_r($roleArrayCopy);
  4158. // echo $roleKey;
  4159. foreach ( $roleArrayCopy as $k => $v ) {
  4160. foreach ( $verifyList as $m => $n ) {
  4161. if ($n [0] == $k) {
  4162. array_splice ( $verifyList, $m, 1, $v );
  4163. }
  4164. }
  4165. }
  4166. $receiptList [$key] ['verifyList'] = $verifyList;
  4167. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4168. 'where' => 'sid=' . $value ['staff'],
  4169. 'asArray' => true
  4170. ) );
  4171. $receiptList [$key] ['button'] = $button;
  4172. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  4173. }
  4174. // $data['verifyDetail']=$verifyDetail;
  4175. $mothHtml = "";
  4176. for($i = 1; $i <= 12; $i ++) {
  4177. if ($month == $i)
  4178. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4179. else
  4180. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4181. }
  4182. // 获取审批日志
  4183. Doo::loadModel ( 'receiptLog' );
  4184. $receiptLog = new receiptLog ();
  4185. $rlList = array ();
  4186. $rlInfo = $receiptLog->getOne ( array (
  4187. 'where' => 'rid=' . $rid . ' and status=4',
  4188. 'asArray' => true
  4189. ) );
  4190. $tijdate = $receiptLog->getOne ( array (
  4191. 'where' => 'rid=' . $rid . ' and status=2',
  4192. 'asc' => 'rlid',
  4193. 'asArray' => true
  4194. ) );
  4195. if (! empty ( $rlInfo )) {
  4196. $rlList = $receiptLog->find ( array (
  4197. 'where' => 'rid=' . $rid,
  4198. 'asc' => 'rlid',
  4199. 'asArray' => true
  4200. ) );
  4201. }
  4202. $receiptList [0] ['rlList'] = $rlList;
  4203. $enclosurList = $enclosur->find ( array (
  4204. 'where' => 'rid=' . $rid,
  4205. 'asArray' => true
  4206. ) );
  4207. $enclosurHtml = '';
  4208. foreach ( $enclosurList as $value ) {
  4209. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4210. }
  4211. // print_r($receiptList);
  4212. $data ['rid'] = $rid;
  4213. $data ['enclosurHtml'] = $enclosurHtml;
  4214. $data ['rolename'] = $rolename ['name'];
  4215. $data ['datetij'] = $tijdate ['date'];
  4216. $data ['mothHtml'] = $mothHtml;
  4217. $data ['receiptList'] = $receiptList;
  4218. $data ['receiptApprovalCount'] = count ( $receiptList );
  4219. $data ['status'] = $status;
  4220. $data ['year'] = $year;
  4221. $data ['categoryList'] = $categoryList;
  4222. $data ['staffList'] = $staffList;
  4223. $data ['cid'] = $cid;
  4224. $data ['sid'] = $sid;
  4225. $data ['ap'] = $ap;
  4226. $data ['memu'] = "receipt";
  4227. $data ['staff'] = $this->staff;
  4228. $data ['receiptMemu'] = 'approvalExpenses';
  4229. $data ['verifyId'] = $this->verifyId;
  4230. $data ['executeId'] = $this->executeId;
  4231. $this->render ( "/admin/expensesEdi", $data );
  4232. }
  4233. function expensesDefray() {
  4234. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  4235. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  4236. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4237. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  4238. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  4239. if (! empty ( $rid )) {
  4240. Doo::loadModel ( "verify" );
  4241. $verify = new verify ();
  4242. Doo::loadModel ( "receiptDetail" );
  4243. $receiptDetailObj = new receiptDetail ();
  4244. Doo::loadModel ( "itemStatistics" );
  4245. Doo::loadModel ( "statistics" );
  4246. $statistics = new statistics ();
  4247. $itemStatistics = new itemStatistics ();
  4248. Doo::loadModel ( "receipt" );
  4249. $receipt = new receipt ();
  4250. Doo::loadModel ( "loanReceipt" );
  4251. $loanReceipt = new loanReceipt ();
  4252. $receiptDetail = $receipt->getOne ( array (
  4253. 'where' => 'rid=' . $rid . ' and status=2 ',
  4254. 'asArray' => true
  4255. ) );
  4256. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  4257. $nsflag = true;
  4258. foreach ( $nslist as $value ) {
  4259. if ($value == $this->staff ['0'] ['sid']) {
  4260. $nsflag = false;
  4261. break;
  4262. }
  4263. }
  4264. // print_r($nslist);die;
  4265. if (empty ( $receiptDetail ) || $nsflag)
  4266. return "/approvalExpenses/pendApproval";
  4267. $verifyDetail = $verify->getOne ( array (
  4268. 'where' => ' vid =' . $receiptDetail ['verify'],
  4269. 'asArray' => true
  4270. ) );
  4271. $verifyString = $verifyDetail ['staff'];
  4272. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  4273. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  4274. if (empty ( $opinion )) {
  4275. if ($status == 3)
  4276. $opinion = "终止";
  4277. else
  4278. $opinion = "同意支付";
  4279. }
  4280. $nowStaff = 0;
  4281. $nowStaffList = array ();
  4282. if (empty ( $verifyStaff )) {
  4283. // 还需加入是否已经进入角色审批
  4284. if ($verifyDetail [0] [1] == 'ROLE') {
  4285. // print_r($verifyDetail);echo "ddd";
  4286. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  4287. foreach ( $vStaffString as $key => $value ) {
  4288. $staffK = explode ( "_", $value );
  4289. if ($staffK [0] != $this->staff [0] ['sid'])
  4290. array_push ( $nowStaffList, $staffK [0] );
  4291. }
  4292. // print_r($verifyDetail);
  4293. // die;
  4294. if (! empty ( $nowStaffList )) {
  4295. $nowStaff = implode ( ',', $nowStaffList );
  4296. $verifyStaff = array (
  4297. $this->staff [0] ['sid'] . "_R" => array (
  4298. 'date' => date ( 'Y-m-d' ),
  4299. 'opinion' => $opinion,
  4300. 'status' => $status,
  4301. 'nextStaff' => $verifyDetail [0] [0],
  4302. 'ROLE' => 1
  4303. )
  4304. );
  4305. } else {
  4306. $nowStaff = $verifyDetail [1] [0];
  4307. $verifyStaff = array (
  4308. $this->staff [0] ['sid'] . "_R" => array (
  4309. 'date' => date ( 'Y-m-d' ),
  4310. 'opinion' => $opinion,
  4311. 'status' => $status,
  4312. 'nextStaff' => $verifyDetail [1] [0]
  4313. )
  4314. );
  4315. }
  4316. } else {
  4317. if ($verifyDetail [1] [1] == 'ROLE') {
  4318. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  4319. // echo "dd";
  4320. foreach ( $vStaffString as $key => $value ) {
  4321. $staffK = explode ( "_", $value );
  4322. array_push ( $nowStaffList, $staffK [0] );
  4323. }
  4324. $nowStaff = implode ( ',', $nowStaffList );
  4325. $verifyStaff = array (
  4326. $this->staff [0] ['sid'] => array (
  4327. 'date' => date ( 'Y-m-d' ),
  4328. 'opinion' => $opinion,
  4329. 'status' => $status,
  4330. 'nextStaff' => $verifyDetail [1] [0],
  4331. 'ROLE' => 1
  4332. )
  4333. );
  4334. } else {
  4335. $nowStaff = $verifyDetail [1] [0];
  4336. $verifyStaff = array (
  4337. $this->staff [0] ['sid'] => array (
  4338. 'date' => date ( 'Y-m-d' ),
  4339. 'opinion' => $opinion,
  4340. 'status' => $status,
  4341. 'nextStaff' => $verifyDetail [1] [0]
  4342. )
  4343. );
  4344. }
  4345. }
  4346. if ($status == 3)
  4347. $verifyStaff = array (
  4348. 'final' => $status,
  4349. $this->staff [0] ['sid'] => array (
  4350. 'date' => date ( 'Y-m-d' ),
  4351. 'opinion' => $opinion,
  4352. 'status' => $status
  4353. )
  4354. );
  4355. $vStaffString = json_encode ( $verifyStaff );
  4356. $receipt->nowStaff = $nowStaff;
  4357. $receipt->verifyStaff = $vStaffString;
  4358. $loanReceipt->nowStaff = $nowStaff;
  4359. $loanReceipt->verifyStaff = $vStaffString;
  4360. } else {
  4361. $VS = end ( $verifyStaff );
  4362. // 非角色审批
  4363. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  4364. $nextStaff = 0;
  4365. $roleSTF = false;
  4366. foreach ( $verifyDetail as $key => $value ) {
  4367. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  4368. if (isset ( $verifyDetail [$key + 1] )) {
  4369. $nextStaff = $verifyDetail [$key + 1] [0];
  4370. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  4371. $roleSTF = true;
  4372. }
  4373. break;
  4374. }
  4375. }
  4376. if (! $roleSTF) {
  4377. $nowStaff = $nextStaff;
  4378. $verifyStaff [$this->staff [0] ['sid']] = array (
  4379. 'date' => date ( 'Y-m-d' ),
  4380. 'opinion' => $opinion,
  4381. 'status' => $status,
  4382. 'nextStaff' => $nextStaff
  4383. );
  4384. } else {
  4385. // 获取角色下的所有用户ID
  4386. $nowStaffList = array ();
  4387. foreach ( $verifyDetail as $vfk ) {
  4388. if ($vfk [1] == 'ROLE') {
  4389. $vStaffString = json_decode ( $vfk [3] );
  4390. foreach ( $vStaffString as $key => $value ) {
  4391. $staffK = explode ( "_", $value );
  4392. array_push ( $nowStaffList, $staffK [0] );
  4393. }
  4394. }
  4395. }
  4396. $nowStaff = implode ( ',', $nowStaffList );
  4397. $verifyStaff [$this->staff [0] ['sid']] = array (
  4398. 'date' => date ( 'Y-m-d' ),
  4399. 'opinion' => $opinion,
  4400. 'status' => $status,
  4401. 'nextStaff' => $nextStaff,
  4402. 'ROLE' => 0
  4403. );
  4404. }
  4405. if ($status == 3) {
  4406. $verifyStaff ['final'] = $status;
  4407. $verifyStaff [$this->staff [0] ['sid']] = array (
  4408. 'date' => date ( 'Y-m-d' ),
  4409. 'opinion' => $opinion,
  4410. 'status' => $status
  4411. );
  4412. }
  4413. $vStaffString = json_encode ( $verifyStaff );
  4414. $receipt->nowStaff = $nowStaff;
  4415. $receipt->verifyStaff = $vStaffString;
  4416. $loanReceipt->nowStaff = $nowStaff;
  4417. $loanReceipt->verifyStaff = $vStaffString;
  4418. }
  4419. // 角色审批
  4420. if (isset ( $VS ['ROLE'] )) {
  4421. // 找出角色人 当前审批角色组
  4422. $verifyJSStaff = array ();
  4423. $nowStaffList2 = array ();
  4424. foreach ( $verifyDetail as $key => $value ) {
  4425. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  4426. $verifyJSStaff = json_decode ( $value [3] );
  4427. foreach ( $verifyJSStaff as $m ) {
  4428. $staffK = explode ( "_", $m );
  4429. array_push ( $nowStaffList2, $staffK [0] );
  4430. }
  4431. // print_r($nowStaffList2);
  4432. }
  4433. }
  4434. $RoleVerifyStaff = array ();
  4435. foreach ( $verifyStaff as $key => $value ) {
  4436. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  4437. foreach ( $nowStaffList2 as $m ) {
  4438. if ($key == $m . "_R")
  4439. $RoleVerifyStaff [$key] = $value;
  4440. }
  4441. }
  4442. }
  4443. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  4444. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  4445. // 下一个审批人ID
  4446. $nextStaff = 0;
  4447. $falg = false;
  4448. foreach ( $verifyDetail as $key => $value ) {
  4449. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  4450. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  4451. $falg = true;
  4452. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  4453. $nowStaffList = array ();
  4454. foreach ( $vStaffString as $v ) {
  4455. $staffK = explode ( "_", $v );
  4456. array_push ( $nowStaffList, $staffK [0] );
  4457. }
  4458. $nowStaff = implode ( ',', $nowStaffList );
  4459. $nextStaff = $verifyDetail [$key + 1] [0];
  4460. } elseif (isset ( $verifyDetail [$key + 1] )) {
  4461. $nextStaff = $verifyDetail [$key + 1] [0];
  4462. $nowStaff = $nextStaff;
  4463. } else
  4464. $nowStaff = '';
  4465. break;
  4466. }
  4467. }
  4468. if ($falg)
  4469. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  4470. 'date' => date ( 'Y-m-d' ),
  4471. 'opinion' => $opinion,
  4472. 'status' => $status,
  4473. 'nextStaff' => $nextStaff,
  4474. 'ROLE' => 1
  4475. );
  4476. else
  4477. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  4478. 'date' => date ( 'Y-m-d' ),
  4479. 'opinion' => $opinion,
  4480. 'status' => $status,
  4481. 'nextStaff' => $nextStaff
  4482. );
  4483. // print_r($verifyStaff);
  4484. // echo $nowStaff;die;
  4485. } else { // 进入下一个角色或者审批人
  4486. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  4487. //
  4488. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  4489. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  4490. 'date' => date ( 'Y-m-d' ),
  4491. 'opinion' => $opinion,
  4492. 'status' => $status,
  4493. 'nextStaff' => $VS ['nextStaff'],
  4494. 'ROLE' => 1
  4495. );
  4496. // print_r($verifyStaff);
  4497. // die;
  4498. }
  4499. if ($status == 3) {
  4500. $verifyStaff ['final'] = $status;
  4501. $verifyStaff [$this->staff [0] ['sid']] = array (
  4502. 'date' => date ( 'Y-m-d' ),
  4503. 'opinion' => $opinion,
  4504. 'status' => $status
  4505. );
  4506. }
  4507. $vStaffString = json_encode ( $verifyStaff );
  4508. $receipt->verifyStaff = $vStaffString;
  4509. $receipt->nowStaff = $nowStaff;
  4510. $loanReceipt->nowStaff = $nowStaff;
  4511. $loanReceipt->verifyStaff = $vStaffString;
  4512. // die;
  4513. // }
  4514. // print_r($verifyStaff);
  4515. // die;
  4516. }
  4517. // print_r($verifyStaff);die;
  4518. }
  4519. // print_r($verifyDetail);
  4520. $roleKey = 0;
  4521. $roleId = 0;
  4522. $verifyDetailCopy = array ();
  4523. foreach ( $verifyDetail as $k => $v ) {
  4524. if ($v [1] == 'ROLE') {
  4525. $roleId = $v [0];
  4526. $roleVerify = json_decode ( $v [3], true );
  4527. $roleKey = $k;
  4528. $roleArray = array ();
  4529. foreach ( $roleVerify as $o => $p ) {
  4530. $staffID = explode ( '_', $p );
  4531. $exp = array (
  4532. 0 => $staffID [0],
  4533. 1 => $staffID [1]
  4534. );
  4535. array_push ( $roleArray, $exp );
  4536. }
  4537. $verifyDetailCopy [$v [0]] = $roleArray;
  4538. }
  4539. }
  4540. // print_r($verifyDetail);
  4541. foreach ( $verifyDetailCopy as $k => $v ) {
  4542. foreach ( $verifyDetail as $m => $n ) {
  4543. if ($n [0] == $k) {
  4544. array_splice ( $verifyDetail, $m, 1, $v );
  4545. }
  4546. }
  4547. }
  4548. // 审批日志
  4549. if (! isset ( $verifyStaff ['final'] )) {
  4550. Doo::loadModel ( "receiptLog" );
  4551. $receiptLog = new receiptLog ();
  4552. if (! empty ( $roleId )) {
  4553. Doo::loadModel ( "role" );
  4554. $role = new role ();
  4555. $roleInfo = $role->getOne ( array (
  4556. 'where' => 'rid=' . $roleId,
  4557. 'asArray' => true
  4558. ) );
  4559. $receiptLog->rolename = $roleInfo ['name'];
  4560. }
  4561. $receiptLog->username = $this->staff [0] ['username'];
  4562. $receiptLog->uid = $this->staff [0] ['sid'];
  4563. $receiptLog->date = date ( "Y-m-d" );
  4564. $receiptLog->opinion = $opinion;
  4565. $receiptLog->img = $this->staff [0] ['avatar'];
  4566. $receiptLog->status = 1;
  4567. $receiptLog->rid = $rid;
  4568. $receiptLog->insert ();
  4569. }
  4570. if (isset ( $verifyStaff ['final'] )) { // rDetail
  4571. $receipt->status = 3;
  4572. $receipt->verifyBreakup = $verifyString;
  4573. $receiptDetailObj->status = 3;
  4574. $receiptDetailObj->update ( array (
  4575. 'where' => 'rid=' . $rid
  4576. ) );
  4577. // 微信企业号通知
  4578. $this->setWXMsg ( $rid, 3 );
  4579. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  4580. $receipt->status = 6;
  4581. $receipt->pastDate = date ( "Y-m-d" );
  4582. $receipt->isBK = 1;
  4583. $loanReceipt->verifyBreakup = $verifyString;
  4584. $loanReceipt->status = 1;
  4585. $loanReceipt->pastDate = date ( "Y-m-d" );
  4586. $loanReceipt->amount = $receiptDetail ['amount'];
  4587. $loanReceipt->update ( array (
  4588. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  4589. ) );
  4590. // 微信企业号通知
  4591. $this->setWXMsg ( $rid, 1 );
  4592. }
  4593. $receipt->amount = $amount;
  4594. $receipt->update ( array (
  4595. 'where' => ' rid = ' . $rid
  4596. ) );
  4597. // 进入下一条审批费用新加需求
  4598. $vidList = array ();
  4599. $verifyDetail = $verify->find ( array (
  4600. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  4601. 'asArray' => true
  4602. ) );
  4603. foreach ( $verifyDetail as $key => $value ) {
  4604. array_push ( $vidList, $value ['vid'] );
  4605. }
  4606. $vid = implode ( ",", $vidList );
  4607. if (empty ( $verifyDetail ))
  4608. $vid = 0;
  4609. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  4610. $receipt = new receipt ();
  4611. $rd = $receipt->getOne ( array (
  4612. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  4613. 'asc' => 'rid',
  4614. 'asArray' => true
  4615. ) );
  4616. if (empty ( $rd )) {
  4617. return '/approvalExpenses/pendApproval';
  4618. }
  4619. if ($rd ['Rtype'] == 1) {
  4620. if ($rd ['isBK'] == 1) {
  4621. return '/receiptburEdi/' . $rd ['rid'];
  4622. } else {
  4623. return '/expensesEdi/' . $rd ['rid'];
  4624. }
  4625. } elseif ($rd ['Rtype'] == 2) {
  4626. return '/remitApproval/' . $rd ['rid'];
  4627. } else {
  4628. return '/receiptburEdi/' . $rd ['rid'];
  4629. }
  4630. // return "/approvalExpenses/pendApproval";
  4631. }
  4632. }
  4633. function ajaxExamineExe() {
  4634. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4635. Doo::loadModel ( 'receipt' );
  4636. $receipt = new receipt ();
  4637. Doo::loadClass ( 'XDeode' );
  4638. $XDeode = new XDeode ( 5 );
  4639. if (! empty ( $rid )) {
  4640. $rLRes = $receipt->find ( array (
  4641. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  4642. 'asArray' => true
  4643. ) );
  4644. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  4645. echo json_encode ( array (
  4646. 'status' => 1,
  4647. 'receipt' => $rLRes [0]
  4648. ) );
  4649. die ();
  4650. }
  4651. echo json_encode ( array (
  4652. 'status' => 0,
  4653. 'receipt' => array ()
  4654. ) );
  4655. die ();
  4656. }
  4657. function implement() {
  4658. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4659. Doo::loadClass ( 'XDeode' );
  4660. $XDeode = new XDeode ( 5 );
  4661. Doo::loadModel ( 'receipt' );
  4662. $receipt = new receipt ();
  4663. Doo::loadModel ( 'L_category' );
  4664. $Lcategory = new L_category ();
  4665. Doo::loadModel ( 'verify' );
  4666. $verify = new verify ();
  4667. Doo::loadModel ( 'staff' );
  4668. $staff = new staff ();
  4669. Doo::loadModel ( "execute" );
  4670. $execute = new execute ();
  4671. $rid = $XDeode->decode ( $rid );
  4672. $receiptList = $receipt->find ( array (
  4673. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  4674. 'desc' => 'rid',
  4675. 'asArray' => true
  4676. ) );
  4677. Doo::loadModel ( 'loanReceipt' );
  4678. $loanReceipt = new loanReceipt ();
  4679. // print_r($receiptList);
  4680. $loanList = array ();
  4681. if (! isset ( $receiptList ))
  4682. $loanList = $loanReceipt->find ( array (
  4683. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4684. 'desc' => 'rid',
  4685. 'asArray' => true
  4686. ) );
  4687. $Locate = 0;
  4688. $roleId = 0;
  4689. $button = 0;
  4690. foreach ( $loanList as $key => $value ) {
  4691. $loanList [$key] ['Locate'] = $Locate;
  4692. $Locate ++;
  4693. $loanList [$key] ['reviseDetail'] = array ();
  4694. if (! empty ( $value ['reviseDetail'] ))
  4695. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4696. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4697. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4698. $categoryDetil = $Lcategory->getOne ( array (
  4699. 'where' => 'cid=' . $value ['cid'],
  4700. 'asArray' => true
  4701. ) );
  4702. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4703. // 检测编辑状态
  4704. $verifyList = $verify->getOne ( array (
  4705. 'where' => 'vid=' . $value ['verify'],
  4706. 'asArray' => true
  4707. ) );
  4708. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4709. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4710. Doo::loadModel ( 'role' );
  4711. $role = new role ();
  4712. $flag = true;
  4713. $roleKey = 0;
  4714. $endStaffArray = array ();
  4715. $roleArrayCopy = array ();
  4716. foreach ( $verifyList as $k => $v ) {
  4717. // init verifyStaff
  4718. if ($v [1] == 'ROLE') {
  4719. if (! empty ( $verifyStaff )) {
  4720. $endStaffArray = end ( $verifyStaff );
  4721. // if ($v[0]==$endStaffArray['nextStaff']){
  4722. // $roleId=$v[0];
  4723. // }
  4724. }
  4725. $roleVerify = json_decode ( $v [3], true );
  4726. $roleKey = $k;
  4727. $roleArray = array ();
  4728. $rolename = $role->getOne ( array (
  4729. 'where' => 'rid=' . $v [0],
  4730. 'asArray' => true
  4731. ) );
  4732. foreach ( $roleVerify as $o => $p ) {
  4733. $staffID = explode ( '_', $p );
  4734. $staffInfo = $staff->getOne ( array (
  4735. 'where' => 'sid=' . $staffID [0],
  4736. 'asArray' => true
  4737. ) );
  4738. // print_r($staffID);
  4739. $exp = array (
  4740. 0 => $staffInfo ['sid'],
  4741. 1 => $staffID [1],
  4742. 2 => $staffInfo ['avatar'],
  4743. 'date' => '',
  4744. 'date' => '',
  4745. 'opinion' => '',
  4746. 'status' => '',
  4747. 'rolename' => $rolename ['name']
  4748. );
  4749. array_push ( $roleArray, $exp );
  4750. }
  4751. $roleArrayCopy [$v [0]] = $roleArray;
  4752. // $verifyList[$k]['roleArray']=$roleArray;
  4753. }
  4754. $verifyList [$k] ['date'] = "";
  4755. $verifyList [$k] ['opinion'] = "";
  4756. $verifyList [$k] ['status'] = "";
  4757. if (empty ( $verifyStaff )) {
  4758. $verifyList [$k] ['date'] = "";
  4759. $verifyList [$k] ['opinion'] = "";
  4760. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4761. $verifyList [$k] ['status'] = 4;
  4762. $flag = false;
  4763. }
  4764. } else {
  4765. foreach ( $verifyStaff as $m => $u ) {
  4766. if ($v [0] == $m) {
  4767. $verifyList [$k] ['date'] = $u ['date'];
  4768. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4769. $verifyList [$k] ['status'] = $u ['status'];
  4770. $flag = false;
  4771. break;
  4772. }
  4773. }
  4774. $endStaffArray = end ( $verifyStaff );
  4775. if (isset ( $endStaffArray ['ROLE'] )) {
  4776. } else {
  4777. // $endKey=key($verifyStaff);
  4778. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4779. // $button=4;
  4780. // $verifyList[$k]['status']=4;
  4781. // }
  4782. }
  4783. }
  4784. }
  4785. $rolename ['name'] = '';
  4786. if (! empty ( $roleId )) {
  4787. Doo::loadModel ( 'role' );
  4788. $role = new role ();
  4789. $rolename = $role->getOne ( array (
  4790. 'where' => 'rid=' . $roleId,
  4791. 'asArray' => true
  4792. ) );
  4793. }
  4794. if (! empty ( $verifyStaff ))
  4795. $endStaffArray = end ( $verifyStaff );
  4796. $KOP = false;
  4797. foreach ( $roleArrayCopy as $P => $A ) {
  4798. foreach ( $A as $MKI => $AVL ) {
  4799. if (! empty ( $verifyStaff )) {
  4800. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4801. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4802. $button = 4;
  4803. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4804. }
  4805. foreach ( $verifyStaff as $m => $u ) {
  4806. $AVLFK = $AVL [0] . '_R';
  4807. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4808. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4809. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4810. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4811. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4812. break;
  4813. }
  4814. }
  4815. } else {
  4816. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4817. $button = 4;
  4818. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4819. }
  4820. }
  4821. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4822. $KOP = true;
  4823. }
  4824. }
  4825. foreach ( $roleArrayCopy as $k => $v ) {
  4826. foreach ( $verifyList as $m => $n ) {
  4827. if ($n [0] == $k) {
  4828. array_splice ( $verifyList, $m, 1, $v );
  4829. }
  4830. }
  4831. }
  4832. $loanList [$key] ['verifyList'] = $verifyList;
  4833. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  4834. 'where' => 'sid=' . $value ['staff'],
  4835. 'asArray' => true
  4836. ) );
  4837. }
  4838. $data ['loanList'] = $loanList;
  4839. $Locate = 0;
  4840. $roleId = 0;
  4841. $button = 0;
  4842. foreach ( $receiptList as $key => $value ) {
  4843. $button2 = 0;
  4844. $receiptList [$key] ['Locate'] = $Locate;
  4845. $Locate ++;
  4846. $receiptList [$key] ['reviseDetail'] = array ();
  4847. if (! empty ( $value ['reviseDetail'] ))
  4848. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4849. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4850. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4851. $categoryDetil = $Lcategory->getOne ( array (
  4852. 'where' => 'cid=' . $value ['cid'],
  4853. 'asArray' => true
  4854. ) );
  4855. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4856. $executeList = json_decode ( $value ['executeCopy'], true );
  4857. $executeStaff = array ();
  4858. if (! empty ( $value ['executeStaff'] ))
  4859. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4860. if (isset ( $executeList )) {
  4861. foreach ( $executeList as $op => $lo ) {
  4862. $executeList [$op] ['date'] = "";
  4863. $executeList [$op] ['opinion'] = "";
  4864. $executeList [$op] ['status'] = "";
  4865. foreach ( $executeStaff as $m => $u ) {
  4866. if ($lo [0] == $m) {
  4867. $executeList [$op] ['date'] = $u ['date'];
  4868. $executeList [$op] ['opinion'] = $u ['opinion'];
  4869. $executeList [$op] ['status'] = $u ['status'];
  4870. break;
  4871. }
  4872. }
  4873. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  4874. $button2 = 1;
  4875. $executeList [$op] ['status'] = 4;
  4876. }
  4877. }
  4878. }
  4879. // 检测编辑状态
  4880. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  4881. $verifyList ['staff'] = $value ['verifyBreakup'];
  4882. } else
  4883. $verifyList = $verify->getOne ( array (
  4884. 'where' => 'vid=' . $value ['verify'],
  4885. 'asArray' => true
  4886. ) );
  4887. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4888. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4889. Doo::loadModel ( 'role' );
  4890. $role = new role ();
  4891. if ($verifyList == NULL)
  4892. $verifyList = array ();
  4893. $flag = true;
  4894. $roleKey = 0;
  4895. $endStaffArray = array ();
  4896. $roleArrayCopy = array ();
  4897. foreach ( $verifyList as $k => $v ) {
  4898. // init verifyStaff
  4899. if ($v [1] == 'ROLE') {
  4900. if (! empty ( $verifyStaff )) {
  4901. $endStaffArray = end ( $verifyStaff );
  4902. // if ($v[0]==$endStaffArray['nextStaff']){
  4903. // $roleId=$v[0];
  4904. // }
  4905. }
  4906. $roleVerify = json_decode ( $v [3], true );
  4907. $roleKey = $k;
  4908. $roleArray = array ();
  4909. $rolename = $role->getOne ( array (
  4910. 'where' => 'rid=' . $v [0],
  4911. 'asArray' => true
  4912. ) );
  4913. foreach ( $roleVerify as $o => $p ) {
  4914. $staffID = explode ( '_', $p );
  4915. $staffInfo = $staff->getOne ( array (
  4916. 'where' => 'sid=' . $staffID [0],
  4917. 'asArray' => true
  4918. ) );
  4919. // print_r($staffID);
  4920. $exp = array (
  4921. 0 => $staffInfo ['sid'],
  4922. 1 => $staffID [1],
  4923. 2 => $staffInfo ['avatar'],
  4924. 'date' => '',
  4925. 'date' => '',
  4926. 'opinion' => '',
  4927. 'status' => '',
  4928. 'rolename' => $rolename ['name']
  4929. );
  4930. array_push ( $roleArray, $exp );
  4931. }
  4932. $roleArrayCopy [$v [0]] = $roleArray;
  4933. // $verifyList[$k]['roleArray']=$roleArray;
  4934. }
  4935. $verifyList [$k] ['date'] = "";
  4936. $verifyList [$k] ['opinion'] = "";
  4937. $verifyList [$k] ['status'] = "";
  4938. if (empty ( $verifyStaff )) {
  4939. $verifyList [$k] ['date'] = "";
  4940. $verifyList [$k] ['opinion'] = "";
  4941. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4942. $verifyList [$k] ['status'] = 4;
  4943. $flag = false;
  4944. }
  4945. } else {
  4946. foreach ( $verifyStaff as $m => $u ) {
  4947. if ($v [0] == $m) {
  4948. $verifyList [$k] ['date'] = $u ['date'];
  4949. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4950. $verifyList [$k] ['status'] = $u ['status'];
  4951. $flag = false;
  4952. break;
  4953. }
  4954. }
  4955. $endStaffArray = end ( $verifyStaff );
  4956. if (isset ( $endStaffArray ['ROLE'] )) {
  4957. } else {
  4958. // $endKey=key($verifyStaff);
  4959. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4960. // $button=4;
  4961. // $verifyList[$k]['status']=4;
  4962. // }
  4963. }
  4964. }
  4965. }
  4966. $rolename ['name'] = '';
  4967. if (! empty ( $roleId )) {
  4968. Doo::loadModel ( 'role' );
  4969. $role = new role ();
  4970. $rolename = $role->getOne ( array (
  4971. 'where' => 'rid=' . $roleId,
  4972. 'asArray' => true
  4973. ) );
  4974. }
  4975. if (! empty ( $verifyStaff ))
  4976. $endStaffArray = end ( $verifyStaff );
  4977. $KOP = false;
  4978. foreach ( $roleArrayCopy as $P => $A ) {
  4979. foreach ( $A as $MKI => $AVL ) {
  4980. if (! empty ( $verifyStaff )) {
  4981. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4982. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4983. $button = 4;
  4984. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4985. }
  4986. foreach ( $verifyStaff as $m => $u ) {
  4987. $AVLFK = $AVL [0] . '_R';
  4988. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4989. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4990. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4991. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4992. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4993. break;
  4994. }
  4995. }
  4996. } else {
  4997. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4998. $button = 4;
  4999. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5000. }
  5001. }
  5002. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5003. $KOP = true;
  5004. }
  5005. }
  5006. foreach ( $roleArrayCopy as $k => $v ) {
  5007. foreach ( $verifyList as $m => $n ) {
  5008. if ($n [0] == $k) {
  5009. array_splice ( $verifyList, $m, 1, $v );
  5010. }
  5011. }
  5012. }
  5013. $receiptList [$key] ['verifyList'] = $verifyList;
  5014. $receiptList [$key] ['executeList'] = $executeList;
  5015. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5016. 'where' => 'sid=' . $value ['staff'],
  5017. 'asArray' => true
  5018. ) );
  5019. $receiptList [$key] ['button2'] = $button2;
  5020. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5021. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5022. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5023. $receiptList [$key] ['relust'] = $relust;
  5024. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  5025. }
  5026. // print_r($receiptList[$key]['executeList']);
  5027. $data ['receiptList'] = $receiptList;
  5028. $data ['memu'] = "receipt";
  5029. $data ['staff'] = $this->staff;
  5030. $data ['receiptMemu'] = 'implement';
  5031. $data ['verifyId'] = $this->verifyId;
  5032. $data ['executeId'] = $this->executeId;
  5033. $this->render ( "/admin/implement", $data );
  5034. }
  5035. function implementDo() {
  5036. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5037. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  5038. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  5039. $accountBank = $this->get_args ( 'accountBank' ) ? $this->get_args ( 'accountBank' ) : "";
  5040. $ab = '';
  5041. if ($accountBank == 'CGBDeposit')
  5042. $ab = '纵横广发';
  5043. elseif ($accountBank == 'ICBCDeposit')
  5044. $ab = '纵横工行';
  5045. elseif ($accountBank == 'HUADeposit')
  5046. $ab = '华润银行';
  5047. elseif ($accountBank == 'PersonalDeposit')
  5048. $ab = '个人广发';
  5049. if (empty ( $ab ))
  5050. die ( 'illegal request' );
  5051. if (! empty ( $rid ) && $amount != '') {
  5052. Doo::loadModel ( 'receipt' );
  5053. $receipt = new receipt ();
  5054. Doo::loadClass ( 'XDeode' );
  5055. $XDeode = new XDeode ( 5 );
  5056. // $rinfo = $receipt->getOne ( array (
  5057. // 'where' => 'rid=' . $rid,
  5058. // 'asArray' => true
  5059. // ) );
  5060. $rinfo = $receipt->getReceiptByRid ( $rid );
  5061. $accountType = '';
  5062. if ($rinfo ['Rtype'] == 1) {
  5063. if ($rinfo ['loanRid'] != 0)
  5064. $accountType = 2;
  5065. else
  5066. $accountType = 1;
  5067. } elseif ($rinfo ['Rtype'] == 2) {
  5068. $accountType = 4;
  5069. } elseif ($rinfo ['Rtype'] == 0)
  5070. $accountType = 3;
  5071. if (empty ( $accountType ))
  5072. die ( 'illegal request' );
  5073. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  5074. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  5075. if (empty ( $executeStaff )) {
  5076. $executeStaff = array (
  5077. $this->staff [0] ['sid'] => array (
  5078. 'date' => date ( 'Y-m-d' ),
  5079. 'opinion' => $implementOpinions,
  5080. 'status' => 1
  5081. )
  5082. );
  5083. } else {
  5084. $executeStaff [$this->staff [0] ['sid']] = array (
  5085. 'date' => date ( 'Y-m-d' ),
  5086. 'opinion' => $implementOpinions,
  5087. 'status' => 1
  5088. );
  5089. }
  5090. if (count ( $executeStaff ) == count ( $executeCopy )) {
  5091. $receipt->executeStaff = json_encode ( $executeStaff );
  5092. $receipt->status = 8;
  5093. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  5094. $receipt->status = 9;
  5095. if ($rinfo ['status'] == 6) {
  5096. $receipt->loanDate = date ( "Y-m-d" );
  5097. }
  5098. $receipt->executeDate = date ( "Y-m-d" );
  5099. } else {
  5100. $receipt->executeStaff = json_encode ( $executeStaff );
  5101. }
  5102. $receipt->amount = $amount;
  5103. $receipt->update ( array (
  5104. 'where' => 'rid=' . $rid
  5105. ) );
  5106. // 公司流水记录
  5107. Doo::loadModel ( 'wasteBook' );
  5108. $wasteBook = new wasteBook ();
  5109. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountType, $rid );
  5110. // 银行
  5111. if (empty ( $abDetail ) && ! empty ( $amount )) {
  5112. $item = array (
  5113. 'dataID' => $rid,
  5114. 'expensesType' => 2,
  5115. 'accountType' => $accountType,
  5116. 'accountPriceShow' => $amount,
  5117. 'accountPrice' => - $amount,
  5118. 'accountBank' => $accountBank,
  5119. 'category' => $rinfo ['category'] [0] ['title'],
  5120. 'cid' => $rinfo ['category'] [0] ['cid'],
  5121. 'name' => $rinfo ['staffDetail'] ['username'],
  5122. 'sid' => $rinfo ['staffDetail'] ['sid'],
  5123. 'inputDate' => date ( "Y-m-d H:i:s" )
  5124. );
  5125. $wasteBook->setAccountBookStatistics ( $item );
  5126. }
  5127. }
  5128. $ridKey = $XDeode->encode ( $rid );
  5129. return "/hisImplement";
  5130. // return "/implement/" . $ridKey . ".html";
  5131. }
  5132. function receiptburEdi() {
  5133. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5134. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5135. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5136. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5137. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5138. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5139. if (empty ( $status ))
  5140. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5141. $vidList = array ();
  5142. $button = 0;
  5143. Doo::loadModel ( 'verify' );
  5144. Doo::loadModel ( 'receipt' );
  5145. Doo::loadModel ( 'staff' );
  5146. $staff = new staff ();
  5147. $receipt = new receipt ();
  5148. $verify = new verify ();
  5149. Doo::loadModel ( 'L_category' );
  5150. $Lcategory = new L_category ();
  5151. Doo::loadModel ( 'enclosur' );
  5152. $enclosur = new enclosur ();
  5153. Doo::loadModel ( 'loanReceipt' );
  5154. $loanReceipt = new loanReceipt ();
  5155. // user verify ID
  5156. $verifyDetail = $verify->find ( array (
  5157. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5158. 'asArray' => true
  5159. ) );
  5160. foreach ( $verifyDetail as $key => $value ) {
  5161. array_push ( $vidList, $value ['vid'] );
  5162. }
  5163. $vid = implode ( ",", $vidList );
  5164. if (empty ( $verifyDetail ))
  5165. $vid = 0;
  5166. $categoryList = $Lcategory->find ( array (
  5167. 'asArray' => true
  5168. ) );
  5169. $staffList = $staff->find ( array (
  5170. 'where' => 'cid=' . $cid,
  5171. 'asArray' => true
  5172. ) );
  5173. $ap = "";
  5174. if ($status == 4) {
  5175. $ap = 4;
  5176. $status = 2;
  5177. }
  5178. // get Receipt By verifyID status 2
  5179. $receiptList = $receipt->find ( array (
  5180. 'where' => 'rid =' . $rid . ' and status=2',
  5181. 'desc' => 'rid',
  5182. 'asArray' => true
  5183. ) );
  5184. if (empty ( $receiptList )) {
  5185. die ( 'illegal request' );
  5186. }
  5187. $loanList = $loanReceipt->find ( array (
  5188. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  5189. 'desc' => 'rid',
  5190. 'asArray' => true
  5191. ) );
  5192. $data ['explanation'] = '';
  5193. if (! empty ( $loanList ))
  5194. $data ['explanation'] = $loanList [0] ['explanation'];
  5195. $Locate = 0;
  5196. $roleId = 0;
  5197. $button = 0;
  5198. foreach ( $loanList as $key => $value ) {
  5199. $loanList [$key] ['Locate'] = $Locate;
  5200. $Locate ++;
  5201. $loanList [$key] ['reviseDetail'] = array ();
  5202. if (! empty ( $value ['reviseDetail'] ))
  5203. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5204. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5205. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5206. $categoryDetil = $Lcategory->getOne ( array (
  5207. 'where' => 'cid=' . $value ['cid'],
  5208. 'asArray' => true
  5209. ) );
  5210. $loanList [$key] ['category'] = $categoryDetil ['title'];
  5211. // 检测编辑状态
  5212. $verifyList = $verify->getOne ( array (
  5213. 'where' => 'vid=' . $value ['verify'],
  5214. 'asArray' => true
  5215. ) );
  5216. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5217. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5218. Doo::loadModel ( 'role' );
  5219. $role = new role ();
  5220. $flag = true;
  5221. $roleKey = 0;
  5222. $endStaffArray = array ();
  5223. $roleArrayCopy = array ();
  5224. foreach ( $verifyList as $k => $v ) {
  5225. // init verifyStaff
  5226. if ($v [1] == 'ROLE') {
  5227. if (! empty ( $verifyStaff )) {
  5228. $endStaffArray = end ( $verifyStaff );
  5229. }
  5230. $roleVerify = json_decode ( $v [3], true );
  5231. $roleKey = $k;
  5232. $roleArray = array ();
  5233. $rolename = $role->getOne ( array (
  5234. 'where' => 'rid=' . $v [0],
  5235. 'asArray' => true
  5236. ) );
  5237. foreach ( $roleVerify as $o => $p ) {
  5238. $staffID = explode ( '_', $p );
  5239. $staffInfo = $staff->getOne ( array (
  5240. 'where' => 'sid=' . $staffID [0],
  5241. 'asArray' => true
  5242. ) );
  5243. // print_r($staffID);
  5244. $exp = array (
  5245. 0 => $staffInfo ['sid'],
  5246. 1 => $staffID [1],
  5247. 2 => $staffInfo ['avatar'],
  5248. 'date' => '',
  5249. 'date' => '',
  5250. 'opinion' => '',
  5251. 'status' => '',
  5252. 'rolename' => $rolename ['name']
  5253. );
  5254. array_push ( $roleArray, $exp );
  5255. }
  5256. $roleArrayCopy [$v [0]] = $roleArray;
  5257. // $verifyList[$k]['roleArray']=$roleArray;
  5258. }
  5259. $verifyList [$k] ['date'] = "";
  5260. $verifyList [$k] ['opinion'] = "";
  5261. $verifyList [$k] ['status'] = "";
  5262. if (empty ( $verifyStaff )) {
  5263. $verifyList [$k] ['date'] = "";
  5264. $verifyList [$k] ['opinion'] = "";
  5265. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5266. $verifyList [$k] ['status'] = 4;
  5267. $flag = false;
  5268. }
  5269. } else {
  5270. foreach ( $verifyStaff as $m => $u ) {
  5271. if ($v [0] == $m) {
  5272. $verifyList [$k] ['date'] = $u ['date'];
  5273. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5274. $verifyList [$k] ['status'] = $u ['status'];
  5275. $flag = false;
  5276. break;
  5277. }
  5278. }
  5279. $endStaffArray = end ( $verifyStaff );
  5280. if (isset ( $endStaffArray ['ROLE'] )) {
  5281. } else {
  5282. }
  5283. }
  5284. }
  5285. $rolename ['name'] = '';
  5286. if (! empty ( $roleId )) {
  5287. Doo::loadModel ( 'role' );
  5288. $role = new role ();
  5289. $rolename = $role->getOne ( array (
  5290. 'where' => 'rid=' . $roleId,
  5291. 'asArray' => true
  5292. ) );
  5293. }
  5294. if (! empty ( $verifyStaff ))
  5295. $endStaffArray = end ( $verifyStaff );
  5296. $KOP = false;
  5297. foreach ( $roleArrayCopy as $P => $A ) {
  5298. foreach ( $A as $MKI => $AVL ) {
  5299. if (! empty ( $verifyStaff )) {
  5300. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5301. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5302. $button = 4;
  5303. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5304. }
  5305. foreach ( $verifyStaff as $m => $u ) {
  5306. $AVLFK = $AVL [0] . '_R';
  5307. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5308. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5309. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5310. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5311. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5312. break;
  5313. }
  5314. }
  5315. } else {
  5316. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5317. $button = 4;
  5318. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5319. }
  5320. }
  5321. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5322. $KOP = true;
  5323. }
  5324. }
  5325. foreach ( $roleArrayCopy as $k => $v ) {
  5326. foreach ( $verifyList as $m => $n ) {
  5327. if ($n [0] == $k) {
  5328. array_splice ( $verifyList, $m, 1, $v );
  5329. }
  5330. }
  5331. }
  5332. $loanList [$key] ['verifyList'] = $verifyList;
  5333. }
  5334. $htmlLoan = '';
  5335. $data ['loanReceiptDate'] = '';
  5336. if (isset ( $loanList [0] )) {
  5337. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  5338. if ($value ['status'] == 1)
  5339. $htmlLoan .= '<li class="done" >';
  5340. elseif ($value ['status'] == 3)
  5341. $htmlLoan .= '<li class="undone" >';
  5342. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  5343. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  5344. if (isset ( $value ['rolename'] ))
  5345. $htmlLoan .= $value ['rolename'];
  5346. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  5347. }
  5348. $data ['loanDate'] = $loanList [0] ['date'];
  5349. } else {
  5350. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  5351. }
  5352. $data ['htmlLoan'] = $htmlLoan;
  5353. // $data ['LoanReceipt']=$loanList[0];
  5354. // print_r($loanList);
  5355. $Locate = 0;
  5356. $roleId = 0;
  5357. $button = 0;
  5358. if ($ap == 4)
  5359. $status = 4;
  5360. Doo::loadClass ( 'XDeode' );
  5361. $XDeode = new XDeode ( 5 );
  5362. foreach ( $receiptList as $key => $value ) {
  5363. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  5364. $receiptList [$key] ['Locate'] = $Locate;
  5365. $Locate ++;
  5366. $receiptList [$key] ['reviseDetail'] = array ();
  5367. // 调整金额 代码调整
  5368. if (! empty ( $value ['reviseDetail'] )) {
  5369. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  5370. foreach ( $reviseDetail as $ry => $re ) {
  5371. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  5372. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  5373. }
  5374. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  5375. // print_r($reviseDetail);
  5376. }
  5377. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5378. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5379. $categoryDetil = $Lcategory->getOne ( array (
  5380. 'where' => 'cid=' . $value ['cid'],
  5381. 'asArray' => true
  5382. ) );
  5383. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5384. // 检测编辑状态
  5385. $verifyList = $verify->getOne ( array (
  5386. 'where' => 'vid=' . $value ['verify'],
  5387. 'asArray' => true
  5388. ) );
  5389. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5390. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5391. Doo::loadModel ( 'role' );
  5392. $role = new role ();
  5393. // print_r($verifyList);
  5394. $flag = true;
  5395. $roleKey = 0;
  5396. $endStaffArray = array ();
  5397. $roleArrayCopy = array ();
  5398. foreach ( $verifyList as $k => $v ) {
  5399. // init verifyStaff
  5400. if ($v [1] == 'ROLE') {
  5401. if (! empty ( $verifyStaff )) {
  5402. $endStaffArray = end ( $verifyStaff );
  5403. if ($v [0] == $endStaffArray ['nextStaff']) {
  5404. $roleId = $v [0];
  5405. }
  5406. }
  5407. $roleVerify = json_decode ( $v [3], true );
  5408. $roleKey = $k;
  5409. $roleArray = array ();
  5410. $rolename = $role->getOne ( array (
  5411. 'where' => 'rid=' . $v [0],
  5412. 'asArray' => true
  5413. ) );
  5414. foreach ( $roleVerify as $o => $p ) {
  5415. $staffID = explode ( '_', $p );
  5416. $staffInfo = $staff->getOne ( array (
  5417. 'where' => 'sid=' . $staffID [0],
  5418. 'asArray' => true
  5419. ) );
  5420. // print_r($staffID);
  5421. $exp = array (
  5422. 0 => $staffInfo ['sid'],
  5423. 1 => $staffID [1],
  5424. 2 => $staffInfo ['avatar'],
  5425. 'date' => '',
  5426. 'date' => '',
  5427. 'opinion' => '',
  5428. 'status' => '',
  5429. 'rolename' => $rolename ['name']
  5430. );
  5431. array_push ( $roleArray, $exp );
  5432. }
  5433. $roleArrayCopy [$v [0]] = $roleArray;
  5434. // $verifyList[$k]['roleArray']=$roleArray;
  5435. }
  5436. // print_r($roleArray);
  5437. $verifyList [$k] ['date'] = "";
  5438. $verifyList [$k] ['opinion'] = "";
  5439. $verifyList [$k] ['status'] = "";
  5440. if (empty ( $verifyStaff )) {
  5441. $verifyList [$k] ['date'] = "";
  5442. $verifyList [$k] ['opinion'] = "";
  5443. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5444. $verifyList [$k] ['status'] = 4;
  5445. $button = 4;
  5446. $flag = false;
  5447. }
  5448. } else {
  5449. foreach ( $verifyStaff as $m => $u ) {
  5450. if ($v [0] == $m) {
  5451. $verifyList [$k] ['date'] = $u ['date'];
  5452. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5453. $verifyList [$k] ['status'] = $u ['status'];
  5454. $flag = false;
  5455. break;
  5456. }
  5457. }
  5458. $endStaffArray = end ( $verifyStaff );
  5459. if (isset ( $endStaffArray ['ROLE'] )) {
  5460. } else {
  5461. $endKey = key ( $verifyStaff );
  5462. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5463. $button = 4;
  5464. $verifyList [$k] ['status'] = 4;
  5465. }
  5466. }
  5467. }
  5468. }
  5469. $rolename ['name'] = '';
  5470. if (! empty ( $roleId )) {
  5471. Doo::loadModel ( 'role' );
  5472. $role = new role ();
  5473. $rolename = $role->getOne ( array (
  5474. 'where' => 'rid=' . $roleId,
  5475. 'asArray' => true
  5476. ) );
  5477. }
  5478. if (! empty ( $verifyStaff ))
  5479. $endStaffArray = end ( $verifyStaff );
  5480. $KOP = false;
  5481. foreach ( $roleArrayCopy as $P => $A ) {
  5482. foreach ( $A as $MKI => $AVL ) {
  5483. if (! empty ( $verifyStaff )) {
  5484. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5485. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5486. $button = 4;
  5487. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5488. }
  5489. foreach ( $verifyStaff as $m => $u ) {
  5490. $AVLFK = $AVL [0] . '_R';
  5491. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5492. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5493. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5494. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5495. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5496. break;
  5497. }
  5498. }
  5499. } else {
  5500. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5501. $button = 4;
  5502. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5503. }
  5504. }
  5505. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5506. $KOP = true;
  5507. }
  5508. }
  5509. foreach ( $roleArrayCopy as $k => $v ) {
  5510. foreach ( $verifyList as $m => $n ) {
  5511. if ($n [0] == $k) {
  5512. array_splice ( $verifyList, $m, 1, $v );
  5513. }
  5514. }
  5515. }
  5516. // print_r($verifyList);
  5517. $receiptList [$key] ['verifyList'] = $verifyList;
  5518. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5519. 'where' => 'sid=' . $value ['staff'],
  5520. 'asArray' => true
  5521. ) );
  5522. $receiptList [$key] ['button'] = $button;
  5523. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5524. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5525. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5526. $receiptList [$key] ['relust'] = $relust;
  5527. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  5528. }
  5529. // print_r($receiptList);die;
  5530. // $data['verifyDetail']=$verifyDetail;
  5531. $mothHtml = "";
  5532. for($i = 1; $i <= 12; $i ++) {
  5533. if ($month == $i)
  5534. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5535. else
  5536. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5537. }
  5538. // 获取审批日志
  5539. Doo::loadModel ( 'receiptLog' );
  5540. $receiptLog = new receiptLog ();
  5541. $rlList = array ();
  5542. $rlInfo = $receiptLog->getOne ( array (
  5543. 'where' => 'rid=' . $rid . ' and status=4',
  5544. 'asArray' => true
  5545. ) );
  5546. $tijdate = $receiptLog->getOne ( array (
  5547. 'where' => 'rid=' . $rid . ' and status=2',
  5548. 'asc' => 'rlid',
  5549. 'asArray' => true
  5550. ) );
  5551. if (! empty ( $rlInfo )) {
  5552. $rlList = $receiptLog->find ( array (
  5553. 'where' => 'rid=' . $rid,
  5554. 'asc' => 'rlid',
  5555. 'asArray' => true
  5556. ) );
  5557. }
  5558. // echo $rid;
  5559. // print_r($receiptList);
  5560. $receiptList [0] ['rlList'] = $rlList;
  5561. // print_r($receiptList);
  5562. $enclosurList = $enclosur->find ( array (
  5563. 'where' => 'rid=' . $rid,
  5564. 'asArray' => true
  5565. ) );
  5566. $enclosurHtml = '';
  5567. foreach ( $enclosurList as $value ) {
  5568. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5569. }
  5570. $data ['enclosurHtml'] = $enclosurHtml;
  5571. $data ['rolename'] = $rolename ['name'];
  5572. $data ['mothHtml'] = $mothHtml;
  5573. // print_r($receiptList);
  5574. $data ['rid'] = $rid;
  5575. $data ['tijdate'] = $tijdate ['date'];
  5576. $data ['receiptList'] = $receiptList;
  5577. $data ['receiptApprovalCount'] = count ( $receiptList );
  5578. $data ['status'] = $status;
  5579. $data ['year'] = $year;
  5580. $data ['categoryList'] = $categoryList;
  5581. $data ['staffList'] = $staffList;
  5582. $data ['cid'] = $cid;
  5583. $data ['sid'] = $sid;
  5584. $data ['ap'] = $ap;
  5585. $data ['memu'] = "receipt";
  5586. $data ['staff'] = $this->staff;
  5587. $data ['receiptMemu'] = 'approvalExpenses';
  5588. $data ['verifyId'] = $this->verifyId;
  5589. $data ['executeId'] = $this->executeId;
  5590. $this->render ( "/admin/receiptburEdi", $data );
  5591. }
  5592. function hisImplement() {
  5593. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  5594. if (empty ( $item ))
  5595. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  5596. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  5597. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  5598. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  5599. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  5600. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  5601. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  5602. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  5603. Doo::loadClass ( 'XDeode' );
  5604. $XDeode = new XDeode ( 5 );
  5605. Doo::loadModel ( 'receipt' );
  5606. $receipt = new receipt ();
  5607. Doo::loadModel ( 'L_category' );
  5608. $Lcategory = new L_category ();
  5609. Doo::loadModel ( 'verify' );
  5610. Doo::loadModel ( 'statistics' );
  5611. $statistics = new statistics ();
  5612. $verify = new verify ();
  5613. Doo::loadModel ( 'staff' );
  5614. $staff = new staff ();
  5615. Doo::loadClass ( 'XDeode' );
  5616. $XDeode = new XDeode ( 5 );
  5617. $cid = $XDeode->decode ( $cidKey );
  5618. $condition = "";
  5619. if ($item == "expenses")
  5620. $condition = " and Rtype=1 ";
  5621. elseif ($item == "receipts")
  5622. $condition = " and Rtype=0 ";
  5623. elseif ($item == "remits")
  5624. $condition = " and Rtype=2 ";
  5625. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  5626. $sopString = $cidString = "";
  5627. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  5628. if (empty ( $rdate ))
  5629. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  5630. else
  5631. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  5632. if ($status == 'pendImplement') {
  5633. $condition .= ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  5634. } elseif ($status == 'alerpts') {
  5635. $statusCon = '(status=8 or status=9 )';
  5636. if (empty ( $rdate ))
  5637. $dateCondition .= " and Year(date) =" . $year;
  5638. else
  5639. $dateCondition .= " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  5640. }
  5641. if ($sop != 'SOP')
  5642. $sopString = " and staff=" . $sop;
  5643. if ($cidKey != 'ALL')
  5644. $cidString = " and cid=" . $cid;
  5645. $receiptList = $receipt->find ( array (
  5646. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  5647. 'desc' => 'rid',
  5648. 'asArray' => true
  5649. ) );
  5650. // 员工筛选
  5651. $receiptList2 = $receipt->find ( array (
  5652. 'where' => $statusCon . $condition . $dateCondition,
  5653. 'desc' => 'rid',
  5654. 'asArray' => true
  5655. ) );
  5656. $sopStaff = array ();
  5657. foreach ( $receiptList2 as $key => $value ) {
  5658. $staffDetail = $staff->getOne ( array (
  5659. 'select' => 'username',
  5660. 'where' => 'sid=' . $value ['staff'],
  5661. 'asArray' => true
  5662. ) );
  5663. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  5664. }
  5665. // 办事处筛选
  5666. $categoryScreen = array ();
  5667. $categorList = $Lcategory->getCategory ();
  5668. foreach ( $receiptList2 as $key => $value ) {
  5669. foreach ( $categorList as $k => $v ) {
  5670. if ($value ['cid'] == $v ['cid']) {
  5671. $categoryScreen [$v ['cidKey']] = $v ['title'];
  5672. break;
  5673. }
  5674. }
  5675. }
  5676. $categoryScreenHtml = "";
  5677. foreach ( $categoryScreen as $key => $value ) {
  5678. if ($cidKey == $key)
  5679. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  5680. else
  5681. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  5682. }
  5683. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  5684. $data ['cidKey'] = $cidKey;
  5685. $Locate = 0;
  5686. $roleId = 0;
  5687. $button = 0;
  5688. $staffBatchNumber = 100001;
  5689. $remittanceList = array ();
  5690. foreach ( $receiptList as $key => $value ) {
  5691. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  5692. $receiptList [$key] ['Texe'] = 'false';
  5693. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  5694. $receiptList [$key] ['Texe'] = 'true';
  5695. }
  5696. $receiptList [$key] ['TRexe'] = 'true';
  5697. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  5698. $receiptList [$key] ['TRexe'] = 'false';
  5699. }
  5700. $receiptList [$key] ['Locate'] = $Locate;
  5701. $Locate ++;
  5702. $receiptList [$key] ['reviseDetail'] = array ();
  5703. if (! empty ( $value ['reviseDetail'] ))
  5704. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5705. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5706. $categoryDetil = $Lcategory->getOne ( array (
  5707. 'where' => 'cid=' . $value ['cid'],
  5708. 'asArray' => true
  5709. ) );
  5710. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5711. // 检测编辑状态
  5712. $verifyList = $verify->getOne ( array (
  5713. 'where' => 'vid=' . $value ['verify'],
  5714. 'asArray' => true
  5715. ) );
  5716. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5717. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5718. Doo::loadModel ( 'role' );
  5719. $role = new role ();
  5720. $flag = true;
  5721. $roleKey = 0;
  5722. $endStaffArray = array ();
  5723. $roleArrayCopy = array ();
  5724. foreach ( $verifyList as $k => $v ) {
  5725. // init verifyStaff
  5726. if ($v [1] == 'ROLE') {
  5727. if (! empty ( $verifyStaff )) {
  5728. $endStaffArray = end ( $verifyStaff );
  5729. }
  5730. $roleVerify = json_decode ( $v [3], true );
  5731. $roleKey = $k;
  5732. $roleArray = array ();
  5733. $rolename = $role->getOne ( array (
  5734. 'where' => 'rid=' . $v [0],
  5735. 'asArray' => true
  5736. ) );
  5737. foreach ( $roleVerify as $o => $p ) {
  5738. $staffID = explode ( '_', $p );
  5739. $staffInfo = $staff->getOne ( array (
  5740. 'where' => 'sid=' . $staffID [0],
  5741. 'asArray' => true
  5742. ) );
  5743. $exp = array (
  5744. 0 => $staffInfo ['sid'],
  5745. 1 => $staffID [1],
  5746. 2 => $staffInfo ['avatar'],
  5747. 'date' => '',
  5748. 'date' => '',
  5749. 'opinion' => '',
  5750. 'status' => '',
  5751. 'rolename' => $rolename ['name']
  5752. );
  5753. array_push ( $roleArray, $exp );
  5754. }
  5755. $roleArrayCopy [$v [0]] = $roleArray;
  5756. }
  5757. $verifyList [$k] ['date'] = "";
  5758. $verifyList [$k] ['opinion'] = "";
  5759. $verifyList [$k] ['status'] = "";
  5760. if (empty ( $verifyStaff )) {
  5761. $verifyList [$k] ['date'] = "";
  5762. $verifyList [$k] ['opinion'] = "";
  5763. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5764. $verifyList [$k] ['status'] = 4;
  5765. $flag = false;
  5766. }
  5767. } else {
  5768. foreach ( $verifyStaff as $m => $u ) {
  5769. if ($v [0] == $m) {
  5770. $verifyList [$k] ['date'] = $u ['date'];
  5771. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5772. $verifyList [$k] ['status'] = $u ['status'];
  5773. $flag = false;
  5774. break;
  5775. }
  5776. }
  5777. $endStaffArray = end ( $verifyStaff );
  5778. }
  5779. }
  5780. $rolename ['name'] = '';
  5781. if (! empty ( $roleId )) {
  5782. Doo::loadModel ( 'role' );
  5783. $role = new role ();
  5784. $rolename = $role->getOne ( array (
  5785. 'where' => 'rid=' . $roleId,
  5786. 'asArray' => true
  5787. ) );
  5788. }
  5789. if (! empty ( $verifyStaff ))
  5790. $endStaffArray = end ( $verifyStaff );
  5791. $KOP = false;
  5792. foreach ( $roleArrayCopy as $P => $A ) {
  5793. foreach ( $A as $MKI => $AVL ) {
  5794. if (! empty ( $verifyStaff )) {
  5795. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5796. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5797. $button = 4;
  5798. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5799. }
  5800. foreach ( $verifyStaff as $m => $u ) {
  5801. $AVLFK = $AVL [0] . '_R';
  5802. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5803. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5804. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5805. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5806. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5807. break;
  5808. }
  5809. }
  5810. } else {
  5811. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5812. $button = 4;
  5813. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5814. }
  5815. }
  5816. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5817. $KOP = true;
  5818. }
  5819. }
  5820. foreach ( $roleArrayCopy as $k => $v ) {
  5821. foreach ( $verifyList as $m => $n ) {
  5822. if ($n [0] == $k) {
  5823. array_splice ( $verifyList, $m, 1, $v );
  5824. }
  5825. }
  5826. }
  5827. $receiptList [$key] ['verifyList'] = $verifyList;
  5828. $staffDetail = $staff->getOne ( array (
  5829. 'where' => 'sid=' . $value ['staff'],
  5830. 'asArray' => true
  5831. ) );
  5832. $receiptList [$key] ['staffDetail'] = $staffDetail;
  5833. $receiptList [$key] ['button'] = $button;
  5834. // 设置导出汇款execl
  5835. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  5836. $remittanceDetail = array (
  5837. $staffBatchNumber,
  5838. $value ['remittanceName'],
  5839. $value ['bankNumber'],
  5840. $value ['bankName'],
  5841. $value ['remittanceBankType'],
  5842. $value ['coupletNumber'],
  5843. $value ['sum']
  5844. );
  5845. array_push ( $remittanceList, $remittanceDetail );
  5846. $staffBatchNumber ++;
  5847. }
  5848. }
  5849. $data ['remittanceList'] = json_encode ( $remittanceList );
  5850. // print_r($receiptList);
  5851. $mothHtml = "";
  5852. for($i = 1; $i <= 12; $i ++) {
  5853. if ($moth == $i)
  5854. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5855. else
  5856. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5857. }
  5858. $dayHtml = "";
  5859. if ($day != "DAY" || $moth != "MONTH") {
  5860. for($i = 1; $i <= 31; $i ++) {
  5861. if ($day == $i)
  5862. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  5863. else
  5864. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  5865. }
  5866. }
  5867. $sopHtml = "";
  5868. foreach ( $sopStaff as $key => $value ) {
  5869. if ($sop == $key)
  5870. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  5871. else
  5872. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  5873. }
  5874. $data ['status'] = $status;
  5875. $data ['rdate'] = $rdate;
  5876. $data ['sopHtml'] = $sopHtml;
  5877. $data ['dayHtml'] = $dayHtml;
  5878. $data ['mothHtml'] = $mothHtml;
  5879. $data ['receiptList'] = $receiptList;
  5880. $data ['memu'] = "receipt";
  5881. $data ['staff'] = $this->staff;
  5882. $data ['receiptMemu'] = 'implement';
  5883. $data ['verifyId'] = $this->verifyId;
  5884. $data ['executeId'] = $this->executeId;
  5885. $data ['item'] = $item;
  5886. $data ['year'] = $year;
  5887. $data ['moth'] = $moth;
  5888. $data ['day'] = $day;
  5889. $data ['sop'] = $sop;
  5890. $this->render ( "/admin/hisImplement", $data );
  5891. }
  5892. /**
  5893. * 导出汇款信息的exelc
  5894. */
  5895. function exportRemittance() {
  5896. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  5897. if (empty ( $remittanceInfo ))
  5898. die ( 'illegal request' );
  5899. $title = array (
  5900. '员工编号',
  5901. '姓名',
  5902. '员工账号',
  5903. '员工账户开户行',
  5904. '转账类型',
  5905. '联行号',
  5906. '金额'
  5907. );
  5908. $data = json_decode ( $remittanceInfo, true );
  5909. if (empty ( $data ))
  5910. die ( 'illegal request' );
  5911. Doo::loadClass ( 'receipt.func' );
  5912. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  5913. header ( 'Content-Type:text/html;charset=utf-8' );
  5914. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  5915. }
  5916. function ajaxExamine() {
  5917. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5918. Doo::loadModel ( 'receipt' );
  5919. $receipt = new receipt ();
  5920. if (! empty ( $rid )) {
  5921. $rLRes = $receipt->find ( array (
  5922. '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,
  5923. 'asArray' => true
  5924. ) );
  5925. echo json_encode ( array (
  5926. 'status' => 1,
  5927. 'receipt' => $rLRes [0]
  5928. ) );
  5929. die ();
  5930. }
  5931. echo json_encode ( array (
  5932. 'status' => 0,
  5933. 'receipt' => array ()
  5934. ) );
  5935. die ();
  5936. }
  5937. /*
  5938. * 废弃
  5939. */
  5940. function myReceipt() {
  5941. // all approval past withdraw
  5942. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  5943. if (empty ( $item ))
  5944. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  5945. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  5946. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  5947. Doo::loadModel ( 'receipt' );
  5948. $receipt = new receipt ();
  5949. // pre-loaded
  5950. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  5951. // have cache
  5952. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  5953. if (! empty ( $moth )) // yearPage
  5954. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  5955. $this->showCache ( $path );
  5956. }
  5957. Doo::loadModel ( 'L_category' );
  5958. $Lcategory = new L_category ();
  5959. Doo::loadModel ( 'verify' );
  5960. Doo::loadModel ( 'statistics' );
  5961. $statistics = new statistics ();
  5962. $verify = new verify ();
  5963. Doo::loadModel ( 'staff' );
  5964. $staff = new staff ();
  5965. $condition = " and status!=0 ";
  5966. if ($item == "approval")
  5967. $condition = " and status=2 ";
  5968. elseif ($item == "withdraw")
  5969. $condition = " and status=3 ";
  5970. elseif ($item == "past")
  5971. $condition = " and status=1 ";
  5972. elseif ($item == "whdw")
  5973. $condition = " and status=4 ";
  5974. $dateCondition = " and Year(date) =" . $year;
  5975. if (! empty ( $moth )) {
  5976. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  5977. $stList = $statistics->getOne ( array (
  5978. 'select' => 'rePrice ,agPrice',
  5979. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5980. 'asArray' => true
  5981. ) );
  5982. } else
  5983. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  5984. if (empty ( $stList ))
  5985. $stList = array (
  5986. 'rePrice' => 0,
  5987. 'agPrice' => 0
  5988. );
  5989. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  5990. $data ['stList'] = array (
  5991. 'rePrice' => $stList ['rePrice'],
  5992. 'agPrice' => $stList ['agPrice'],
  5993. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  5994. );
  5995. $receiptList = $receipt->find ( array (
  5996. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  5997. 'desc' => 'rid',
  5998. 'asArray' => true
  5999. ) );
  6000. $Locate = 0;
  6001. $roleId = 0;
  6002. $button = 0;
  6003. foreach ( $receiptList as $key => $value ) {
  6004. $receiptList [$key] ['Locate'] = $Locate;
  6005. $Locate ++;
  6006. $receiptList [$key] ['reviseDetail'] = array ();
  6007. if (! empty ( $value ['reviseDetail'] ))
  6008. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6009. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6010. $categoryDetil = $Lcategory->getOne ( array (
  6011. 'where' => 'cid=' . $value ['cid'],
  6012. 'asArray' => true
  6013. ) );
  6014. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6015. // 检测编辑状态
  6016. $verifyList = $verify->getOne ( array (
  6017. 'where' => 'vid=' . $value ['verify'],
  6018. 'asArray' => true
  6019. ) );
  6020. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6021. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6022. Doo::loadModel ( 'role' );
  6023. $role = new role ();
  6024. $flag = true;
  6025. $roleKey = 0;
  6026. $endStaffArray = array ();
  6027. $roleArrayCopy = array ();
  6028. foreach ( $verifyList as $k => $v ) {
  6029. // init verifyStaff
  6030. if ($v [1] == 'ROLE') {
  6031. if (! empty ( $verifyStaff )) {
  6032. $endStaffArray = end ( $verifyStaff );
  6033. // if ($v[0]==$endStaffArray['nextStaff']){
  6034. // $roleId=$v[0];
  6035. // }
  6036. }
  6037. $roleVerify = json_decode ( $v [3], true );
  6038. $roleKey = $k;
  6039. $roleArray = array ();
  6040. $rolename = $role->getOne ( array (
  6041. 'where' => 'rid=' . $v [0],
  6042. 'asArray' => true
  6043. ) );
  6044. foreach ( $roleVerify as $o => $p ) {
  6045. $staffID = explode ( '_', $p );
  6046. $staffInfo = $staff->getOne ( array (
  6047. 'where' => 'sid=' . $staffID [0],
  6048. 'asArray' => true
  6049. ) );
  6050. // print_r($staffID);
  6051. $exp = array (
  6052. 0 => $staffInfo ['sid'],
  6053. 1 => $staffID [1],
  6054. 2 => $staffInfo ['avatar'],
  6055. 'date' => '',
  6056. 'date' => '',
  6057. 'opinion' => '',
  6058. 'status' => '',
  6059. 'rolename' => $rolename ['name']
  6060. );
  6061. array_push ( $roleArray, $exp );
  6062. }
  6063. $roleArrayCopy [$v [0]] = $roleArray;
  6064. // $verifyList[$k]['roleArray']=$roleArray;
  6065. }
  6066. $verifyList [$k] ['date'] = "";
  6067. $verifyList [$k] ['opinion'] = "";
  6068. $verifyList [$k] ['status'] = "";
  6069. if (empty ( $verifyStaff )) {
  6070. $verifyList [$k] ['date'] = "";
  6071. $verifyList [$k] ['opinion'] = "";
  6072. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6073. $verifyList [$k] ['status'] = 4;
  6074. $flag = false;
  6075. }
  6076. } else {
  6077. foreach ( $verifyStaff as $m => $u ) {
  6078. if ($v [0] == $m) {
  6079. $verifyList [$k] ['date'] = $u ['date'];
  6080. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6081. $verifyList [$k] ['status'] = $u ['status'];
  6082. $flag = false;
  6083. break;
  6084. }
  6085. }
  6086. $endStaffArray = end ( $verifyStaff );
  6087. if (isset ( $endStaffArray ['ROLE'] )) {
  6088. } else {
  6089. // $endKey=key($verifyStaff);
  6090. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  6091. // $button=4;
  6092. // $verifyList[$k]['status']=4;
  6093. // }
  6094. }
  6095. }
  6096. }
  6097. $rolename ['name'] = '';
  6098. if (! empty ( $roleId )) {
  6099. Doo::loadModel ( 'role' );
  6100. $role = new role ();
  6101. $rolename = $role->getOne ( array (
  6102. 'where' => 'rid=' . $roleId,
  6103. 'asArray' => true
  6104. ) );
  6105. }
  6106. if (! empty ( $verifyStaff ))
  6107. $endStaffArray = end ( $verifyStaff );
  6108. $KOP = false;
  6109. foreach ( $roleArrayCopy as $P => $A ) {
  6110. foreach ( $A as $MKI => $AVL ) {
  6111. if (! empty ( $verifyStaff )) {
  6112. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6113. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6114. $button = 4;
  6115. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6116. }
  6117. foreach ( $verifyStaff as $m => $u ) {
  6118. $AVLFK = $AVL [0] . '_R';
  6119. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6120. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6121. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6122. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6123. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6124. break;
  6125. }
  6126. }
  6127. } else {
  6128. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6129. $button = 4;
  6130. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6131. }
  6132. }
  6133. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6134. $KOP = true;
  6135. }
  6136. }
  6137. foreach ( $roleArrayCopy as $k => $v ) {
  6138. foreach ( $verifyList as $m => $n ) {
  6139. if ($n [0] == $k) {
  6140. array_splice ( $verifyList, $m, 1, $v );
  6141. }
  6142. }
  6143. }
  6144. $receiptList [$key] ['verifyList'] = $verifyList;
  6145. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6146. 'where' => 'sid=' . $value ['staff'],
  6147. 'asArray' => true
  6148. ) );
  6149. $receiptList [$key] ['button'] = $button;
  6150. }
  6151. // print_r($receiptList);die;
  6152. $mothHtml = "";
  6153. for($i = 1; $i <= 12; $i ++) {
  6154. if ($moth == $i)
  6155. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6156. else
  6157. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6158. }
  6159. $data ['mothHtml'] = $mothHtml;
  6160. $data ['receiptList'] = $receiptList;
  6161. $data ['memu'] = "receipt";
  6162. $data ['staff'] = $this->staff;
  6163. $data ['receiptMemu'] = 'receipt';
  6164. $data ['verifyId'] = $this->verifyId;
  6165. $data ['executeId'] = $this->executeId;
  6166. $data ['item'] = $item;
  6167. $data ['year'] = $year;
  6168. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  6169. // sufficient condition to generate cache
  6170. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  6171. $receiptList = $receipt->find ( array (
  6172. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  6173. 'asArray' => true
  6174. ) );
  6175. if (empty ( $receiptList )) { // generated files
  6176. ob_start ();
  6177. $this->render ( "/admin/saea_myList", $data );
  6178. $this->cacheFile ( $path );
  6179. die ();
  6180. // $content = ob_get_contents();
  6181. // $fp = fopen($path, "w");
  6182. // fwrite($fp, $content);
  6183. // fclose($fp);
  6184. }
  6185. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  6186. $receiptList = $receipt->find ( array (
  6187. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  6188. 'asArray' => true
  6189. ) );
  6190. if (empty ( $receiptList )) { // generated files
  6191. ob_start ();
  6192. $this->render ( "/admin/saea_myList", $data );
  6193. $this->cacheFile ( $path );
  6194. die ();
  6195. }
  6196. }
  6197. }
  6198. $this->render ( "/admin/saea_myList", $data );
  6199. }
  6200. function saeaCreate() {
  6201. Doo::loadModel ( 'accountItem' );
  6202. Doo::loadModel ( 'verify' );
  6203. Doo::loadModel ( 'receipt' );
  6204. Doo::loadModel ( 'L_category' );
  6205. $lCategory = new L_category ();
  6206. $receipt = new receipt ();
  6207. $verify = new verify ();
  6208. $accountItem = new accountItem ();
  6209. Doo::loadModel ( "role" );
  6210. $role = new role ();
  6211. $acItem = $accountItem->find ( array (
  6212. 'asArray' => true
  6213. ) );
  6214. $veList = $verify->find ( array (
  6215. 'asArray' => true
  6216. ) );
  6217. foreach ( $veList as $key => $value ) {
  6218. $v = json_decode ( $value ['staff'] );
  6219. $list = array ();
  6220. foreach ( $v as $n => $m ) {
  6221. if ($m ['1'] == 'ROLE') {
  6222. $roleInfo = $role->getOne ( array (
  6223. 'where' => 'rid=' . $m [0],
  6224. 'asArray' => true
  6225. ) );
  6226. $v [$n] [1] = $roleInfo ['name'];
  6227. array_push ( $list, $roleInfo ['name'] );
  6228. } else {
  6229. array_push ( $list, $v [$n] [1] );
  6230. }
  6231. }
  6232. $veList [$key] ['staff'] = implode ( '>', $list );
  6233. }
  6234. $data ['category'] = $lCategory->find ( array (
  6235. 'asArray' => true
  6236. ) );
  6237. $data ['veList'] = $veList;
  6238. $data ['acItem'] = $acItem;
  6239. $data ['memu'] = "receipt";
  6240. $data ['staff'] = $this->staff;
  6241. $data ['receiptMemu'] = 'saeaBorad';
  6242. $data ['verifyId'] = $this->verifyId;
  6243. $data ['executeId'] = $this->executeId;
  6244. $this->render ( "/admin/saea_create", $data );
  6245. }
  6246. function addReceipt() {
  6247. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  6248. $agency = $this->get_args ( 'agency' );
  6249. $travel = $this->get_args ( 'travel' );
  6250. $train = $this->get_args ( 'train' );
  6251. $other = $this->get_args ( 'other' );
  6252. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  6253. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  6254. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  6255. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  6256. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  6257. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  6258. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  6259. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  6260. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  6261. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  6262. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  6263. header ( 'Content-Type:text/html;charset=utf-8' );
  6264. die ( '请填写联行号' );
  6265. }
  6266. Doo::loadModel ( 'receipt' );
  6267. Doo::loadModel ( 'receiptDetail' );
  6268. Doo::loadModel ( 'accountItem' );
  6269. $accountItem = new accountItem ();
  6270. $receipt = new receipt ();
  6271. Doo::loadModel ( 'enclosur' );
  6272. Doo::loadModel ( 'execute' );
  6273. $execute = new execute ();
  6274. $executeDetail = $execute->getOne ( array (
  6275. 'where' => 'mold="报销单执行人"',
  6276. 'asArray' => true
  6277. ) );
  6278. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  6279. // if(!empty($receiptDetail))
  6280. // return "/referReceipt/".$receiptDetail['rid'];
  6281. $aItem = $accountItem->find ( array (
  6282. 'asArray' => true
  6283. ) );
  6284. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  6285. $ag = $tr = $ta = $ot = 0;
  6286. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  6287. foreach ( $aItem as $key => $value ) {
  6288. if ($value ['category'] == $this->AGENCY) {
  6289. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  6290. array_push ( $accountJson [$this->AGENCY], array (
  6291. 'aid' => $value ['aid'],
  6292. 'name' => $value ['name'],
  6293. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  6294. ) );
  6295. $sum += $agency [$ag];
  6296. $agencySum += $agency [$ag];
  6297. }
  6298. $ag ++;
  6299. }
  6300. if ($value ['category'] == $this->TRAVEL) {
  6301. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  6302. array_push ( $accountJson [$this->TRAVEL], array (
  6303. 'aid' => $value ['aid'],
  6304. 'name' => $value ['name'],
  6305. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  6306. ) );
  6307. $sum += $travel [$tr];
  6308. $travelSum += $travel [$tr];
  6309. }
  6310. $tr ++;
  6311. }
  6312. if ($value ['category'] == $this->TRAIN) {
  6313. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  6314. array_push ( $accountJson [$this->TRAIN], array (
  6315. 'aid' => $value ['aid'],
  6316. 'name' => $value ['name'],
  6317. 'price' => number_format ( $train [$ta], 2, '.', '' )
  6318. ) );
  6319. $sum += $train [$ta];
  6320. $trainSum += $train [$ta];
  6321. }
  6322. $ta ++;
  6323. }
  6324. if ($value ['category'] == $this->OTHER) {
  6325. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  6326. array_push ( $accountJson [$this->OTHER], array (
  6327. 'aid' => $value ['aid'],
  6328. 'name' => $value ['name'],
  6329. 'price' => number_format ( $other [$ot], 2, '.', '' )
  6330. ) );
  6331. $sum += $other [$ot];
  6332. $otherSum += $other [$ot];
  6333. }
  6334. $ot ++;
  6335. }
  6336. }
  6337. $accountJson ['cSum'] = array (
  6338. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  6339. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  6340. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  6341. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  6342. );
  6343. // 报销单
  6344. $receipt->accountItem = json_encode ( $accountJson );
  6345. $receipt->staff = $this->staff [0] ['sid'];
  6346. $receipt->sum = number_format ( $sum, 2, '.', '' );
  6347. $receipt->date = date ( "Y-m-d" );
  6348. $receipt->cid = $cid;
  6349. $receipt->status = 5;
  6350. // 修改审批流程加入角色
  6351. $receipt->verify = $verify;
  6352. $receipt->executeCopy = $executeDetail ['staff'];
  6353. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  6354. $order = array (
  6355. "\r\n",
  6356. "\n",
  6357. "\r"
  6358. );
  6359. $replace = '<br/>';
  6360. $explanation = str_replace ( $order, $replace, $explanation );
  6361. $receipt->explanation = $explanation;
  6362. $receipt->remittanceName = $remittanceName;
  6363. $receipt->bankName = $bankName;
  6364. $receipt->bankNumber = $bankNumber;
  6365. $receipt->remittanceBankType = $remittanceBankType;
  6366. if ($remittanceBankType == 1)
  6367. $receipt->coupletNumber = $coupletNumber;
  6368. $rid = $receipt->insert ();
  6369. // 附件
  6370. if (! empty ( $enclosurName )) {
  6371. $enclosurArray = explode ( '-', $enclosurName );
  6372. foreach ( $enclosurArray as $value ) {
  6373. $enclosur = new enclosur ();
  6374. $enclosur->name = $value;
  6375. $enclosur->rid = $rid;
  6376. $enclosur->insert ();
  6377. }
  6378. // print_r($enclosurArray);die;
  6379. }
  6380. // 报销详情
  6381. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  6382. $receiptDetail = new receiptDetail ();
  6383. $receiptDetail->staff = $this->staff [0] ['sid'];
  6384. $receiptDetail->item = $value ['name'];
  6385. $receiptDetail->itemCategory = $this->AGENCY;
  6386. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6387. $receiptDetail->date = date ( "Y-m-d" );
  6388. $receiptDetail->cid = $cid;
  6389. $receiptDetail->rid = $rid;
  6390. $receiptDetail->status = 4;
  6391. $receiptDetail->insert ();
  6392. }
  6393. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  6394. $receiptDetail = new receiptDetail ();
  6395. $receiptDetail->staff = $this->staff [0] ['sid'];
  6396. $receiptDetail->item = $value ['name'];
  6397. $receiptDetail->itemCategory = $this->TRAVEL;
  6398. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6399. $receiptDetail->date = date ( "Y-m-d" );
  6400. $receiptDetail->cid = $cid;
  6401. $receiptDetail->rid = $rid;
  6402. $receiptDetail->status = 4;
  6403. $receiptDetail->insert ();
  6404. }
  6405. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  6406. $receiptDetail = new receiptDetail ();
  6407. $receiptDetail->staff = $this->staff [0] ['sid'];
  6408. $receiptDetail->item = $value ['name'];
  6409. $receiptDetail->itemCategory = $this->TRAIN;
  6410. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6411. $receiptDetail->date = date ( "Y-m-d" );
  6412. $receiptDetail->cid = $cid;
  6413. $receiptDetail->rid = $rid;
  6414. $receiptDetail->status = 4;
  6415. $receiptDetail->insert ();
  6416. }
  6417. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  6418. $receiptDetail = new receiptDetail ();
  6419. $receiptDetail->staff = $this->staff [0] ['sid'];
  6420. $receiptDetail->item = $value ['name'];
  6421. $receiptDetail->itemCategory = $this->OTHER;
  6422. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6423. $receiptDetail->date = date ( "Y-m-d" );
  6424. $receiptDetail->cid = $cid;
  6425. $receiptDetail->rid = $rid;
  6426. $receiptDetail->status = 4;
  6427. $receiptDetail->insert ();
  6428. }
  6429. return "/saeaBorad";
  6430. } else
  6431. die ( 'illegal request' );
  6432. }
  6433. function referReceipt() {
  6434. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  6435. Doo::loadModel ( 'receipt' );
  6436. Doo::loadModel ( 'verify' );
  6437. $verify = new verify ();
  6438. $receipt = new receipt ();
  6439. Doo::loadModel ( 'L_category' );
  6440. $lCategory = new L_category ();
  6441. Doo::loadModel ( "role" );
  6442. $role = new role ();
  6443. $receiptDetail = $receipt->find ( array (
  6444. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  6445. 'asArray' => true
  6446. ) );
  6447. if (empty ( $receiptDetail ))
  6448. return "/addReceipt";
  6449. foreach ( $receiptDetail as $key => $value ) {
  6450. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6451. $veList = $verify->getOne ( array (
  6452. 'where' => 'vid=' . $value ['verify'],
  6453. 'asArray' => true
  6454. ) );
  6455. $v = json_decode ( $veList ['staff'] );
  6456. array_push ( $v [0], $veList ['description'] );
  6457. foreach ( $v as $n => $m ) {
  6458. if ($m ['1'] == 'ROLE') {
  6459. $roleInfo = $role->getOne ( array (
  6460. 'where' => 'rid=' . $m [0],
  6461. 'asArray' => true
  6462. ) );
  6463. $v [$n] [1] = $roleInfo ['name'];
  6464. }
  6465. }
  6466. $receiptDetail [$key] ['staff'] = $v;
  6467. $category = $lCategory->getOne ( array (
  6468. 'where' => 'cid=' . $value ['cid'],
  6469. 'asArray' => true
  6470. ) );
  6471. $receiptDetail [$key] ['category'] = $category ['title'];
  6472. }
  6473. // print_r($receiptDetail);
  6474. $data ['receiptDetail'] = $receiptDetail;
  6475. $data ['memu'] = "receipt";
  6476. $data ['staff'] = $this->staff;
  6477. $data ['receiptMemu'] = 'saeaCreate';
  6478. $data ['verifyId'] = $this->verifyId;
  6479. $data ['executeId'] = $this->executeId;
  6480. $this->render ( "/admin/saea_confirm", $data );
  6481. }
  6482. function editReceipt() {
  6483. // edit status 4
  6484. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  6485. Doo::loadClass ( 'XDeode' );
  6486. $XDeode = new XDeode ( 7 );
  6487. $rid = $XDeode->decode ( $ridKey );
  6488. if (empty ( $rid ))
  6489. die ( 'illegal request' );
  6490. // echo $rid.'sd';
  6491. Doo::loadModel ( 'accountItem' );
  6492. Doo::loadModel ( 'verify' );
  6493. Doo::loadModel ( 'receipt' );
  6494. $receipt = new receipt ();
  6495. $verify = new verify ();
  6496. $accountItem = new accountItem ();
  6497. Doo::loadModel ( 'L_category' );
  6498. $lCategory = new L_category ();
  6499. Doo::loadModel ( "role" );
  6500. $role = new role ();
  6501. Doo::loadModel ( 'enclosur' );
  6502. $enclosur = new enclosur ();
  6503. $receiptDetail = $receipt->getOne ( array (
  6504. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  6505. 'asArray' => true
  6506. ) );
  6507. if (empty ( $receiptDetail ))
  6508. die ( 'illegal request' );
  6509. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  6510. $acItem = $accountItem->find ( array (
  6511. 'asArray' => true
  6512. ) );
  6513. $veList = $verify->find ( array (
  6514. 'asArray' => true
  6515. ) );
  6516. foreach ( $veList as $key => $value ) {
  6517. $v = json_decode ( $value ['staff'] );
  6518. $list = array ();
  6519. foreach ( $v as $n => $m ) {
  6520. if ($m ['1'] == 'ROLE') {
  6521. $roleInfo = $role->getOne ( array (
  6522. 'where' => 'rid=' . $m [0],
  6523. 'asArray' => true
  6524. ) );
  6525. $v [$n] [1] = $roleInfo ['name'];
  6526. array_push ( $list, $roleInfo ['name'] );
  6527. } else {
  6528. array_push ( $list, $v [$n] [1] );
  6529. }
  6530. }
  6531. $veList [$key] ['staff'] = implode ( '>', $list );
  6532. }
  6533. // 配置编辑信息
  6534. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  6535. foreach ( $acItem as $key => $value ) {
  6536. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  6537. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  6538. $acItem [$key] ['price'] = $v ['price'];
  6539. }
  6540. }
  6541. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  6542. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  6543. $acItem [$key] ['price'] = $v ['price'];
  6544. }
  6545. }
  6546. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  6547. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  6548. $acItem [$key] ['price'] = $v ['price'];
  6549. }
  6550. }
  6551. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  6552. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  6553. $acItem [$key] ['price'] = $v ['price'];
  6554. }
  6555. }
  6556. }
  6557. $data ['category'] = $lCategory->find ( array (
  6558. 'asArray' => true
  6559. ) );
  6560. $data ['cSum'] = $accountItemList ['cSum'];
  6561. $data ['sum'] = $receiptDetail ['sum'];
  6562. $data ['enclosurList'] = $enclosurList;
  6563. $data ['receiptDetail'] = $receiptDetail;
  6564. $data ['veList'] = $veList;
  6565. $data ['acItem'] = $acItem;
  6566. $data ['memu'] = "receipt";
  6567. $data ['staff'] = $this->staff;
  6568. $data ['receiptMemu'] = 'saeaBorad';
  6569. $data ['verify'] = $receiptDetail ['verify'];
  6570. $data ['verifyId'] = $this->verifyId;
  6571. $data ['executeId'] = $this->executeId;
  6572. $data ['rid'] = $ridKey;
  6573. $this->render ( "/admin/saea_edit", $data );
  6574. }
  6575. function updateReceipt() {
  6576. $agency = $this->get_args ( 'agency' );
  6577. $travel = $this->get_args ( 'travel' );
  6578. $train = $this->get_args ( 'train' );
  6579. $other = $this->get_args ( 'other' );
  6580. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  6581. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  6582. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  6583. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  6584. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  6585. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  6586. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  6587. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  6588. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  6589. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  6590. Doo::loadClass ( 'XDeode' );
  6591. $XDeode = new XDeode ( 7 );
  6592. $rid = $XDeode->decode ( $ridKey );
  6593. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  6594. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  6595. header ( 'Content-Type:text/html;charset=utf-8' );
  6596. die ( '请填写联行号' );
  6597. }
  6598. Doo::loadModel ( 'receipt' );
  6599. Doo::loadModel ( 'receiptDetail' );
  6600. Doo::loadModel ( 'accountItem' );
  6601. $accountItem = new accountItem ();
  6602. $receipt = new receipt ();
  6603. Doo::loadModel ( 'enclosur' );
  6604. Doo::loadModel ( 'execute' );
  6605. $execute = new execute ();
  6606. $receiptDetail = $receipt->getOne ( array (
  6607. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  6608. 'asArray' => true
  6609. ) );
  6610. if (empty ( $receiptDetail ))
  6611. return "/saeaBorad";
  6612. if ($receiptDetail ['Rtype'] == 1)
  6613. $executeDetail = $execute->getOne ( array (
  6614. 'where' => 'mold="借款费用执行人"',
  6615. 'asArray' => true
  6616. ) );
  6617. else
  6618. $executeDetail = $execute->getOne ( array (
  6619. 'where' => 'mold="报销单执行人"',
  6620. 'asArray' => true
  6621. ) );
  6622. $aItem = $accountItem->find ( array (
  6623. 'asArray' => true
  6624. ) );
  6625. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  6626. $ag = $tr = $ta = $ot = 0;
  6627. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  6628. foreach ( $aItem as $key => $value ) {
  6629. if ($value ['category'] == $this->AGENCY) {
  6630. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  6631. array_push ( $accountJson [$this->AGENCY], array (
  6632. 'aid' => $value ['aid'],
  6633. 'name' => $value ['name'],
  6634. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  6635. ) );
  6636. $sum += $agency [$ag];
  6637. $agencySum += $agency [$ag];
  6638. }
  6639. $ag ++;
  6640. }
  6641. if ($value ['category'] == $this->TRAVEL) {
  6642. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  6643. array_push ( $accountJson [$this->TRAVEL], array (
  6644. 'aid' => $value ['aid'],
  6645. 'name' => $value ['name'],
  6646. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  6647. ) );
  6648. $sum += $travel [$tr];
  6649. $travelSum += $travel [$tr];
  6650. }
  6651. $tr ++;
  6652. }
  6653. if ($value ['category'] == $this->TRAIN) {
  6654. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  6655. array_push ( $accountJson [$this->TRAIN], array (
  6656. 'aid' => $value ['aid'],
  6657. 'name' => $value ['name'],
  6658. 'price' => number_format ( $train [$ta], 2, '.', '' )
  6659. ) );
  6660. $sum += $train [$ta];
  6661. $trainSum += $train [$ta];
  6662. }
  6663. $ta ++;
  6664. }
  6665. if ($value ['category'] == $this->OTHER) {
  6666. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  6667. array_push ( $accountJson [$this->OTHER], array (
  6668. 'aid' => $value ['aid'],
  6669. 'name' => $value ['name'],
  6670. 'price' => number_format ( $other [$ot], 2, '.', '' )
  6671. ) );
  6672. $sum += $other [$ot];
  6673. $otherSum += $other [$ot];
  6674. }
  6675. $ot ++;
  6676. }
  6677. }
  6678. $accountJson ['cSum'] = array (
  6679. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  6680. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  6681. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  6682. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  6683. );
  6684. // 报销单
  6685. $rid = $receipt->rid = $receiptDetail ['rid'];
  6686. $receipt->accountItem = json_encode ( $accountJson );
  6687. $receipt->staff = $this->staff [0] ['sid'];
  6688. $receipt->sum = number_format ( $sum, 2, '.', '' );
  6689. $receipt->date = date ( "Y-m-d" );
  6690. $receipt->cid = $cid;
  6691. if (($receiptDetail ['status'] != 4)) {
  6692. if ($receiptDetail ['Rtype'] == 1)
  6693. $receipt->status = 7;
  6694. else
  6695. $receipt->status = 5;
  6696. }
  6697. if ($receiptDetail != 4 && ! empty ( $verify ))
  6698. $receipt->verify = $verify;
  6699. $receipt->executeCopy = $executeDetail ['staff'];
  6700. $order = array (
  6701. "\r\n",
  6702. "\n",
  6703. "\r"
  6704. );
  6705. $replace = '<br/>';
  6706. $explanation = str_replace ( $order, $replace, $explanation );
  6707. $receipt->explanation = $explanation;
  6708. $receipt->remittanceName = $remittanceName;
  6709. $receipt->bankName = $bankName;
  6710. $receipt->bankNumber = $bankNumber;
  6711. $receipt->remittanceBankType = $remittanceBankType;
  6712. if ($remittanceBankType == 1)
  6713. $receipt->coupletNumber = $coupletNumber;
  6714. $receipt->update ();
  6715. $receiptDetail = new receiptDetail ();
  6716. $receiptDetail->delete ( array (
  6717. 'where' => 'rid=' . $rid
  6718. ) );
  6719. // 报销详情
  6720. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  6721. $receiptDetail = new receiptDetail ();
  6722. $receiptDetail->staff = $this->staff [0] ['sid'];
  6723. $receiptDetail->item = $value ['name'];
  6724. $receiptDetail->itemCategory = $this->AGENCY;
  6725. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6726. $receiptDetail->date = date ( "Y-m-d" );
  6727. $receiptDetail->cid = $cid;
  6728. $receiptDetail->rid = $rid;
  6729. $receiptDetail->status = 4;
  6730. $receiptDetail->insert ();
  6731. }
  6732. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  6733. $receiptDetail = new receiptDetail ();
  6734. $receiptDetail->staff = $this->staff [0] ['sid'];
  6735. $receiptDetail->item = $value ['name'];
  6736. $receiptDetail->itemCategory = $this->TRAVEL;
  6737. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6738. $receiptDetail->date = date ( "Y-m-d" );
  6739. $receiptDetail->cid = $cid;
  6740. $receiptDetail->rid = $rid;
  6741. $receiptDetail->status = 4;
  6742. $receiptDetail->insert ();
  6743. }
  6744. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  6745. $receiptDetail = new receiptDetail ();
  6746. $receiptDetail->staff = $this->staff [0] ['sid'];
  6747. $receiptDetail->item = $value ['name'];
  6748. $receiptDetail->itemCategory = $this->TRAIN;
  6749. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6750. $receiptDetail->date = date ( "Y-m-d" );
  6751. $receiptDetail->cid = $cid;
  6752. $receiptDetail->rid = $rid;
  6753. $receiptDetail->status = 4;
  6754. $receiptDetail->insert ();
  6755. }
  6756. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  6757. $receiptDetail = new receiptDetail ();
  6758. $receiptDetail->staff = $this->staff [0] ['sid'];
  6759. $receiptDetail->item = $value ['name'];
  6760. $receiptDetail->itemCategory = $this->OTHER;
  6761. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6762. $receiptDetail->date = date ( "Y-m-d" );
  6763. $receiptDetail->cid = $cid;
  6764. $receiptDetail->rid = $rid;
  6765. $receiptDetail->status = 4;
  6766. $receiptDetail->insert ();
  6767. }
  6768. // 附件
  6769. if (! empty ( $enclosurName )) {
  6770. $enclosurArray = explode ( '-', $enclosurName );
  6771. foreach ( $enclosurArray as $value ) {
  6772. $enclosur = new enclosur ();
  6773. $enclosur->name = $value;
  6774. $enclosur->rid = $rid;
  6775. $enclosur->insert ();
  6776. }
  6777. }
  6778. // return "/referReceipt/".$rid;
  6779. }
  6780. return "/saeaBorad";
  6781. }
  6782. function approvedReceipt() {
  6783. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6784. Doo::loadModel ( 'receipt' );
  6785. Doo::loadModel ( 'receiptDetail' );
  6786. $receipt = new receipt ();
  6787. $receiptDetail = new receiptDetail ();
  6788. Doo::loadModel ( 'statistics' );
  6789. Doo::loadModel ( 'itemStatistics' );
  6790. $statistics = new statistics ();
  6791. $itemStatistics = new itemStatistics ();
  6792. Doo::loadModel ( "verify" );
  6793. $verify = new verify ();
  6794. // 审批状态的判定
  6795. $receiptDetailList = $receipt->getOne ( array (
  6796. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  6797. 'asArray' => true
  6798. ) );
  6799. if (empty ( $receiptDetailList ))
  6800. return "/saeaBorad";
  6801. $verifyDetail = $verify->getOne ( array (
  6802. 'where' => ' vid =' . $receiptDetailList ['verify'],
  6803. 'asArray' => true
  6804. ) );
  6805. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  6806. if (empty ( $receiptDetailList ['nowStaff'] )) {
  6807. $nowStaff = "";
  6808. $nowStaffList = array ();
  6809. if ($verifyDetail [0] [1] == 'ROLE') {
  6810. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  6811. foreach ( $vStaffString as $key => $value ) {
  6812. $staffK = explode ( "_", $value );
  6813. array_push ( $nowStaffList, $staffK [0] );
  6814. }
  6815. $nowStaff = implode ( ',', $nowStaffList );
  6816. } else {
  6817. $nowStaff = $verifyDetail [0] [0];
  6818. }
  6819. $receipt->nowStaff = $nowStaff;
  6820. }
  6821. // echo $nowStaff;
  6822. // print_r($verifyDetail);die;
  6823. $receipt->rid = $receiptDetailList ['rid'];
  6824. $receipt->date = date ( "Y-m-d" );
  6825. $receipt->status = 2;
  6826. $receipt->update ();
  6827. $receiptDetail->status = 2;
  6828. $receiptDetail->update ( array (
  6829. 'where' => 'rid=' . $receiptDetailList ['rid']
  6830. ) );
  6831. Doo::loadModel ( "receiptLog" );
  6832. $receiptLog = new receiptLog ();
  6833. Doo::loadModel ( "verify" );
  6834. $verify = new verify ();
  6835. $receiptInfo = $receipt->getOne ( array (
  6836. 'where' => 'rid=' . $rid,
  6837. 'asArray' => true
  6838. ) );
  6839. $vr = $verify->getOne ( array (
  6840. 'where' => 'vid=' . $receiptInfo ['verify'],
  6841. 'asArray' => true
  6842. ) );
  6843. $jd = json_decode ( $vr ['staff'] );
  6844. $roleId = 0;
  6845. foreach ( $jd as $key => $value ) {
  6846. if ($value [1] == 'ROLE') {
  6847. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  6848. if ($pos !== false) {
  6849. $roleId = $value [0];
  6850. }
  6851. }
  6852. }
  6853. // 审批日志
  6854. // echo $roleId;die;
  6855. if (! empty ( $roleId )) {
  6856. Doo::loadModel ( "role" );
  6857. $role = new role ();
  6858. $roleInfo = $role->getOne ( array (
  6859. 'where' => 'rid=' . $roleId,
  6860. 'asArray' => true
  6861. ) );
  6862. // $receiptLog->rolename = $roleInfo ['name'];
  6863. }
  6864. $receiptLog->username = $this->staff [0] ['username'];
  6865. $receiptLog->uid = $this->staff [0] ['sid'];
  6866. $receiptLog->date = date ( "Y-m-d" );
  6867. $receiptLog->opinion = '提交审批';
  6868. $receiptLog->img = $this->staff [0] ['avatar'];
  6869. $receiptLog->status = 2;
  6870. $receiptLog->rid = $rid;
  6871. $receiptLog->insert ();
  6872. // statistics item
  6873. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  6874. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  6875. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  6876. $stat = $statistics->getOne ( array (
  6877. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  6878. 'asArray' => true
  6879. ) );
  6880. if (empty ( $stat )) {
  6881. $statistics->date = date ( "Y-m-d" );
  6882. $statistics->cid = $this->staff [0] ['cid'];
  6883. $statistics->staff = $this->staff [0] ['sid'];
  6884. $statistics->agPrice = 0;
  6885. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  6886. $statistics->insert ();
  6887. } else {
  6888. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  6889. $statistics->update ( array (
  6890. 'where' => 'sid=' . $stat ['sid']
  6891. ) );
  6892. }
  6893. return "/expenses";
  6894. }
  6895. function approval() {
  6896. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  6897. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6898. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6899. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6900. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6901. if (empty ( $status ))
  6902. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  6903. $vidList = array ();
  6904. $button = 0;
  6905. Doo::loadModel ( 'verify' );
  6906. $verify = new verify ();
  6907. Doo::loadModel ( 'receipt' );
  6908. $receipt = new receipt ();
  6909. Doo::loadModel ( 'staff' );
  6910. $staff = new staff ();
  6911. Doo::loadModel ( 'L_category' );
  6912. $Lcategory = new L_category ();
  6913. // user verify ID
  6914. $verifyDetail = $verify->find ( array (
  6915. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6916. 'asArray' => true
  6917. ) );
  6918. foreach ( $verifyDetail as $key => $value ) {
  6919. array_push ( $vidList, $value ['vid'] );
  6920. }
  6921. $vid = implode ( ",", $vidList );
  6922. if (empty ( $verifyDetail ))
  6923. $vid = 0;
  6924. /*
  6925. */
  6926. $dateCondition = " and Year(date) =" . $year;
  6927. if (! empty ( $month ))
  6928. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  6929. $categoryList = $Lcategory->find ( array (
  6930. 'asArray' => true
  6931. ) );
  6932. $staffList = $staff->find ( array (
  6933. 'where' => 'cid=' . $cid,
  6934. 'asArray' => true
  6935. ) );
  6936. $cateCondition = "";
  6937. $staffCondition = "";
  6938. $approvalCondition = "";
  6939. if (! empty ( $cid ))
  6940. $cateCondition = ' and cid=' . $cid;
  6941. if (! empty ( $sid )) {
  6942. $staffCondition = ' and staff=' . $sid;
  6943. $cateCondition = "";
  6944. }
  6945. // elseif($status==1){
  6946. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  6947. // }
  6948. if ($status == 2) {
  6949. // 查找角色审批人
  6950. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  6951. }
  6952. $ap = "";
  6953. if ($status == 4) {
  6954. $ap = 4;
  6955. $status = 2;
  6956. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  6957. }
  6958. if ($status == 5) {
  6959. $status = 4;
  6960. $ap = 5;
  6961. }
  6962. // echo $vid;
  6963. // get Receipt By verifyID status 2 .$approvalCondition
  6964. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  6965. $receiptList = $receipt->find ( array (
  6966. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  6967. 'desc' => 'rid',
  6968. 'asArray' => true
  6969. ) );
  6970. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  6971. $Locate = 0;
  6972. if ($ap == 4)
  6973. $status = 4;
  6974. elseif ($ap == 5)
  6975. $status = 5;
  6976. foreach ( $receiptList as $key => $value ) {
  6977. $receiptList [$key] ['Locate'] = $Locate;
  6978. $Locate ++;
  6979. $receiptList [$key] ['reviseDetail'] = array ();
  6980. if (! empty ( $value ['reviseDetail'] ))
  6981. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6982. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6983. $categoryDetil = $Lcategory->getOne ( array (
  6984. 'where' => 'cid=' . $value ['cid'],
  6985. 'asArray' => true
  6986. ) );
  6987. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6988. $verifyList = $verify->getOne ( array (
  6989. 'where' => 'vid=' . $value ['verify'],
  6990. 'asArray' => true
  6991. ) );
  6992. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6993. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6994. foreach ( $verifyList as $k => $v ) {
  6995. // init verifyStaff
  6996. $verifyList [$k] ['date'] = "";
  6997. $verifyList [$k] ['opinion'] = "";
  6998. $verifyList [$k] ['status'] = "";
  6999. if (empty ( $verifyStaff )) {
  7000. $verifyList [$k] ['date'] = "";
  7001. $verifyList [$k] ['opinion'] = "";
  7002. if ($v [0] == $this->staff [0] ['sid']) {
  7003. $verifyList [$k] ['status'] = 4;
  7004. $button = 4;
  7005. }
  7006. } else {
  7007. $flag = true;
  7008. foreach ( $verifyStaff as $m => $u ) {
  7009. if ($v [0] == $m) {
  7010. $verifyList [$k] ['date'] = $u ['date'];
  7011. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7012. $verifyList [$k] ['status'] = $u ['status'];
  7013. $flag = false;
  7014. break;
  7015. }
  7016. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  7017. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  7018. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  7019. }
  7020. if ($flag) { // 检测可编辑
  7021. if ($v [0] == $this->staff [0] ['sid']) {
  7022. $verifyList [$k] ['status'] = 4;
  7023. $button = 4;
  7024. }
  7025. }
  7026. }
  7027. }
  7028. $receiptList [$key] ['verifyList'] = $verifyList;
  7029. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7030. 'where' => 'sid=' . $value ['staff'],
  7031. 'asArray' => true
  7032. ) );
  7033. $receiptList [$key] ['button'] = $button;
  7034. }
  7035. // print_r($receiptList);die;
  7036. // $data['verifyDetail']=$verifyDetail;
  7037. $mothHtml = "";
  7038. for($i = 1; $i <= 12; $i ++) {
  7039. if ($month == $i)
  7040. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7041. else
  7042. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7043. }
  7044. $data ['mothHtml'] = $mothHtml;
  7045. $data ['receiptList'] = $receiptList;
  7046. $data ['receiptApprovalCount'] = count ( $receiptList );
  7047. $data ['status'] = $status;
  7048. $data ['year'] = $year;
  7049. $data ['categoryList'] = $categoryList;
  7050. $data ['staffList'] = $staffList;
  7051. $data ['cid'] = $cid;
  7052. $data ['sid'] = $sid;
  7053. $data ['ap'] = $ap;
  7054. $data ['memu'] = "receipt";
  7055. $data ['staff'] = $this->staff;
  7056. $data ['receiptMemu'] = 'approval';
  7057. $data ['verifyId'] = $this->verifyId;
  7058. $data ['executeId'] = $this->executeId;
  7059. $this->render ( "/admin/saea_reportList", $data );
  7060. }
  7061. function approvalDetails() {
  7062. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7063. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7064. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7065. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7066. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7067. Doo::loadModel ( 'verify' );
  7068. $verify = new verify ();
  7069. Doo::loadModel ( 'receipt' );
  7070. $receipt = new receipt ();
  7071. Doo::loadModel ( 'staff' );
  7072. $staff = new staff ();
  7073. Doo::loadModel ( 'L_category' );
  7074. $Lcategory = new L_category ();
  7075. Doo::loadModel ( 'enclosur' );
  7076. $enclosur = new enclosur ();
  7077. $vidList = array ();
  7078. $verifyDetail = $verify->find ( array (
  7079. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7080. 'asArray' => true
  7081. ) );
  7082. foreach ( $verifyDetail as $key => $value ) {
  7083. array_push ( $vidList, $value ['vid'] );
  7084. }
  7085. $vid = implode ( ",", $vidList );
  7086. if (empty ( $verifyDetail ))
  7087. $vid = 0;
  7088. $categoryList = $Lcategory->find ( array (
  7089. 'asArray' => true
  7090. ) );
  7091. $staffList = $staff->find ( array (
  7092. 'where' => 'cid=' . $cid,
  7093. 'asArray' => true
  7094. ) );
  7095. $ap = 0;
  7096. $receiptList = $receipt->find ( array (
  7097. 'where' => 'rid =' . $rid,
  7098. 'desc' => 'rid',
  7099. 'asArray' => true
  7100. ) );
  7101. $Locate = 0;
  7102. $roleId = 0;
  7103. $button = 0;
  7104. foreach ( $receiptList as $key => $value ) {
  7105. $receiptList [$key] ['Locate'] = $Locate;
  7106. $Locate ++;
  7107. $receiptList [$key] ['reviseDetail'] = array ();
  7108. if (! empty ( $value ['reviseDetail'] ))
  7109. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7110. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7111. $categoryDetil = $Lcategory->getOne ( array (
  7112. 'where' => 'cid=' . $value ['cid'],
  7113. 'asArray' => true
  7114. ) );
  7115. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7116. // 检测编辑状态
  7117. $verifyList = $verify->getOne ( array (
  7118. 'where' => 'vid=' . $value ['verify'],
  7119. 'asArray' => true
  7120. ) );
  7121. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7122. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7123. Doo::loadModel ( 'role' );
  7124. $role = new role ();
  7125. // print_r($verifyList);
  7126. $flag = true;
  7127. $roleKey = 0;
  7128. $endStaffArray = array ();
  7129. $roleArrayCopy = array ();
  7130. foreach ( $verifyList as $k => $v ) {
  7131. // init verifyStaff
  7132. if ($v [1] == 'ROLE') {
  7133. if (! empty ( $verifyStaff )) {
  7134. $endStaffArray = end ( $verifyStaff );
  7135. if ($v [0] == $endStaffArray ['nextStaff']) {
  7136. $roleId = $v [0];
  7137. }
  7138. }
  7139. $roleVerify = json_decode ( $v [3], true );
  7140. $roleKey = $k;
  7141. $roleArray = array ();
  7142. $rolename = $role->getOne ( array (
  7143. 'where' => 'rid=' . $v [0],
  7144. 'asArray' => true
  7145. ) );
  7146. foreach ( $roleVerify as $o => $p ) {
  7147. $staffID = explode ( '_', $p );
  7148. $staffInfo = $staff->getOne ( array (
  7149. 'where' => 'sid=' . $staffID [0],
  7150. 'asArray' => true
  7151. ) );
  7152. // print_r($staffID);
  7153. $exp = array (
  7154. 0 => $staffInfo ['sid'],
  7155. 1 => $staffID [1],
  7156. 2 => $staffInfo ['avatar'],
  7157. 'date' => '',
  7158. 'date' => '',
  7159. 'opinion' => '',
  7160. 'status' => '',
  7161. 'rolename' => $rolename ['name']
  7162. );
  7163. array_push ( $roleArray, $exp );
  7164. }
  7165. $roleArrayCopy [$v [0]] = $roleArray;
  7166. // $verifyList[$k]['roleArray']=$roleArray;
  7167. }
  7168. // print_r($roleArray);
  7169. $verifyList [$k] ['date'] = "";
  7170. $verifyList [$k] ['opinion'] = "";
  7171. $verifyList [$k] ['status'] = "";
  7172. if (empty ( $verifyStaff )) {
  7173. $verifyList [$k] ['date'] = "";
  7174. $verifyList [$k] ['opinion'] = "";
  7175. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7176. $verifyList [$k] ['status'] = 4;
  7177. $button = 4;
  7178. $flag = false;
  7179. }
  7180. } else {
  7181. foreach ( $verifyStaff as $m => $u ) {
  7182. if ($v [0] == $m) {
  7183. $verifyList [$k] ['date'] = $u ['date'];
  7184. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7185. $verifyList [$k] ['status'] = $u ['status'];
  7186. $flag = false;
  7187. break;
  7188. }
  7189. }
  7190. $endStaffArray = end ( $verifyStaff );
  7191. if (isset ( $endStaffArray ['ROLE'] )) {
  7192. } else {
  7193. $endKey = key ( $verifyStaff );
  7194. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7195. $button = 4;
  7196. $verifyList [$k] ['status'] = 4;
  7197. }
  7198. }
  7199. }
  7200. }
  7201. $rolename ['name'] = '';
  7202. if (! empty ( $roleId )) {
  7203. Doo::loadModel ( 'role' );
  7204. $role = new role ();
  7205. $rolename = $role->getOne ( array (
  7206. 'where' => 'rid=' . $roleId,
  7207. 'asArray' => true
  7208. ) );
  7209. }
  7210. if (! empty ( $verifyStaff ))
  7211. $endStaffArray = end ( $verifyStaff );
  7212. $KOP = false;
  7213. foreach ( $roleArrayCopy as $P => $A ) {
  7214. foreach ( $A as $MKI => $AVL ) {
  7215. if (! empty ( $verifyStaff )) {
  7216. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7217. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7218. $button = 4;
  7219. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7220. }
  7221. foreach ( $verifyStaff as $m => $u ) {
  7222. $AVLFK = $AVL [0] . '_R';
  7223. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7224. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7225. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7226. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7227. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7228. break;
  7229. }
  7230. }
  7231. } else {
  7232. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7233. $button = 4;
  7234. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7235. }
  7236. }
  7237. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7238. $KOP = true;
  7239. }
  7240. }
  7241. foreach ( $roleArrayCopy as $k => $v ) {
  7242. foreach ( $verifyList as $m => $n ) {
  7243. if ($n [0] == $k) {
  7244. array_splice ( $verifyList, $m, 1, $v );
  7245. }
  7246. }
  7247. }
  7248. $receiptList [$key] ['verifyList'] = $verifyList;
  7249. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7250. 'where' => 'sid=' . $value ['staff'],
  7251. 'asArray' => true
  7252. ) );
  7253. $receiptList [$key] ['button'] = $button;
  7254. }
  7255. $mothHtml = "";
  7256. for($i = 1; $i <= 12; $i ++) {
  7257. if ($month == $i)
  7258. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7259. else
  7260. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7261. }
  7262. // 获取审批日志
  7263. Doo::loadModel ( 'receiptLog' );
  7264. $receiptLog = new receiptLog ();
  7265. $rlList = array ();
  7266. $rlInfo = $receiptLog->getOne ( array (
  7267. 'where' => 'rid=' . $rid . ' and status=4',
  7268. 'asArray' => true
  7269. ) );
  7270. $tijdate = $receiptLog->getOne ( array (
  7271. 'where' => 'rid=' . $rid . ' and status=2',
  7272. 'asc' => 'rlid',
  7273. 'asArray' => true
  7274. ) );
  7275. if (! empty ( $rlInfo )) {
  7276. $rlList = $receiptLog->find ( array (
  7277. 'where' => 'rid=' . $rid,
  7278. 'asc' => 'rlid',
  7279. 'asArray' => true
  7280. ) );
  7281. }
  7282. $receiptList [0] ['rlList'] = $rlList;
  7283. $enclosurList = $enclosur->find ( array (
  7284. 'where' => 'rid=' . $rid,
  7285. 'asArray' => true
  7286. ) );
  7287. $enclosurHtml = '';
  7288. foreach ( $enclosurList as $value ) {
  7289. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  7290. }
  7291. $data ['enclosurHtml'] = $enclosurHtml;
  7292. $data ['rolename'] = $rolename ['name'];
  7293. $data ['datetij'] = $tijdate ['date'];
  7294. $data ['mothHtml'] = $mothHtml;
  7295. $data ['receiptList'] = $receiptList;
  7296. $data ['receiptApprovalCount'] = count ( $receiptList );
  7297. $data ['year'] = $year;
  7298. $data ['categoryList'] = $categoryList;
  7299. $data ['staffList'] = $staffList;
  7300. $data ['cid'] = $cid;
  7301. $data ['sid'] = $sid;
  7302. $data ['status'] = 0;
  7303. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  7304. $ap = 4;
  7305. } else
  7306. $data ['status'] = $receiptList [0] ['status'];
  7307. if ($receiptList [0] ['status'] == 4) {
  7308. $data ['status'] = 5;
  7309. $ap = 0;
  7310. }
  7311. $data ['ap'] = $ap;
  7312. $data ['memu'] = "receipt";
  7313. $data ['staff'] = $this->staff;
  7314. $data ['receiptMemu'] = 'approval';
  7315. $data ['verifyId'] = $this->verifyId;
  7316. $data ['executeId'] = $this->executeId;
  7317. $this->render ( "/admin/saeaReportListReport", $data );
  7318. }
  7319. function approvalEdi() {
  7320. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7321. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7322. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7323. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7324. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7325. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7326. if (empty ( $status ))
  7327. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7328. $vidList = array ();
  7329. $button = 0;
  7330. Doo::loadModel ( 'verify' );
  7331. Doo::loadModel ( 'receipt' );
  7332. Doo::loadModel ( 'staff' );
  7333. $staff = new staff ();
  7334. $receipt = new receipt ();
  7335. $verify = new verify ();
  7336. Doo::loadModel ( 'L_category' );
  7337. $Lcategory = new L_category ();
  7338. Doo::loadModel ( 'enclosur' );
  7339. $enclosur = new enclosur ();
  7340. // user verify ID
  7341. $verifyDetail = $verify->find ( array (
  7342. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7343. 'asArray' => true
  7344. ) );
  7345. foreach ( $verifyDetail as $key => $value ) {
  7346. array_push ( $vidList, $value ['vid'] );
  7347. }
  7348. $vid = implode ( ",", $vidList );
  7349. if (empty ( $verifyDetail ))
  7350. $vid = 0;
  7351. $categoryList = $Lcategory->find ( array (
  7352. 'asArray' => true
  7353. ) );
  7354. $staffList = $staff->find ( array (
  7355. 'where' => 'cid=' . $cid,
  7356. 'asArray' => true
  7357. ) );
  7358. $ap = "";
  7359. if ($status == 4) {
  7360. $ap = 4;
  7361. $status = 2;
  7362. }
  7363. // get Receipt By verifyID status 2
  7364. $receiptList = $receipt->find ( array (
  7365. 'where' => 'rid =' . $rid,
  7366. 'desc' => 'rid',
  7367. 'asArray' => true
  7368. ) );
  7369. $Locate = 0;
  7370. $roleId = 0;
  7371. if ($ap == 4)
  7372. $status = 4;
  7373. foreach ( $receiptList as $key => $value ) {
  7374. $receiptList [$key] ['Locate'] = $Locate;
  7375. $Locate ++;
  7376. $receiptList [$key] ['reviseDetail'] = array ();
  7377. if (! empty ( $value ['reviseDetail'] ))
  7378. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7379. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7380. $categoryDetil = $Lcategory->getOne ( array (
  7381. 'where' => 'cid=' . $value ['cid'],
  7382. 'asArray' => true
  7383. ) );
  7384. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7385. // 检测编辑状态
  7386. $verifyList = $verify->getOne ( array (
  7387. 'where' => 'vid=' . $value ['verify'],
  7388. 'asArray' => true
  7389. ) );
  7390. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7391. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7392. // print_r($verifyList);
  7393. //
  7394. // if (empty($verifyStaff)){
  7395. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  7396. // $verifyList[0]['status']=4;$button=4;
  7397. // }
  7398. //
  7399. // }else{
  7400. //
  7401. // }
  7402. // die;
  7403. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  7404. // echo array_search("green",$a);
  7405. //
  7406. Doo::loadModel ( 'role' );
  7407. $role = new role ();
  7408. // print_r($verifyList);
  7409. $flag = true;
  7410. $roleKey = 0;
  7411. $endStaffArray = array ();
  7412. $roleArrayCopy = array ();
  7413. foreach ( $verifyList as $k => $v ) {
  7414. // init verifyStaff
  7415. if ($v [1] == 'ROLE') {
  7416. if (! empty ( $verifyStaff )) {
  7417. $endStaffArray = end ( $verifyStaff );
  7418. if ($v [0] == $endStaffArray ['nextStaff']) {
  7419. $roleId = $v [0];
  7420. }
  7421. }
  7422. $roleVerify = json_decode ( $v [3], true );
  7423. $roleKey = $k;
  7424. $roleArray = array ();
  7425. $rolename = $role->getOne ( array (
  7426. 'where' => 'rid=' . $v [0],
  7427. 'asArray' => true
  7428. ) );
  7429. foreach ( $roleVerify as $o => $p ) {
  7430. $staffID = explode ( '_', $p );
  7431. $staffInfo = $staff->getOne ( array (
  7432. 'where' => 'sid=' . $staffID [0],
  7433. 'asArray' => true
  7434. ) );
  7435. // print_r($staffID);
  7436. $exp = array (
  7437. 0 => $staffInfo ['sid'],
  7438. 1 => $staffID [1],
  7439. 2 => $staffInfo ['avatar'],
  7440. 'date' => '',
  7441. 'date' => '',
  7442. 'opinion' => '',
  7443. 'status' => '',
  7444. 'rolename' => $rolename ['name']
  7445. );
  7446. array_push ( $roleArray, $exp );
  7447. }
  7448. $roleArrayCopy [$v [0]] = $roleArray;
  7449. // $verifyList[$k]['roleArray']=$roleArray;
  7450. }
  7451. // print_r($roleArray);
  7452. $verifyList [$k] ['date'] = "";
  7453. $verifyList [$k] ['opinion'] = "";
  7454. $verifyList [$k] ['status'] = "";
  7455. if (empty ( $verifyStaff )) {
  7456. $verifyList [$k] ['date'] = "";
  7457. $verifyList [$k] ['opinion'] = "";
  7458. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7459. $verifyList [$k] ['status'] = 4;
  7460. $button = 4;
  7461. $flag = false;
  7462. }
  7463. } else {
  7464. foreach ( $verifyStaff as $m => $u ) {
  7465. if ($v [0] == $m) {
  7466. $verifyList [$k] ['date'] = $u ['date'];
  7467. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7468. $verifyList [$k] ['status'] = $u ['status'];
  7469. $flag = false;
  7470. break;
  7471. }
  7472. }
  7473. $endStaffArray = end ( $verifyStaff );
  7474. if (isset ( $endStaffArray ['ROLE'] )) {
  7475. } else {
  7476. $endKey = key ( $verifyStaff );
  7477. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7478. $button = 4;
  7479. $verifyList [$k] ['status'] = 4;
  7480. }
  7481. }
  7482. // print_r($endStaffArray);die;
  7483. // if (empty($verifyStaff)){
  7484. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  7485. // $verifyList[$k]['status']=4;$button=4;
  7486. // }
  7487. //
  7488. // }else{
  7489. //
  7490. // }
  7491. // if($flag){//检测可编辑
  7492. // if($v[0]==$this->staff[0]['sid']){
  7493. // $verifyList[$k]['status']=4;$button=4;
  7494. // }
  7495. // }
  7496. }
  7497. }
  7498. $rolename ['name'] = '';
  7499. if (! empty ( $roleId )) {
  7500. Doo::loadModel ( 'role' );
  7501. $role = new role ();
  7502. $rolename = $role->getOne ( array (
  7503. 'where' => 'rid=' . $roleId,
  7504. 'asArray' => true
  7505. ) );
  7506. }
  7507. if (! empty ( $verifyStaff ))
  7508. $endStaffArray = end ( $verifyStaff );
  7509. $KOP = false;
  7510. foreach ( $roleArrayCopy as $P => $A ) {
  7511. foreach ( $A as $MKI => $AVL ) {
  7512. if (! empty ( $verifyStaff )) {
  7513. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7514. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7515. $button = 4;
  7516. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7517. }
  7518. foreach ( $verifyStaff as $m => $u ) {
  7519. $AVLFK = $AVL [0] . '_R';
  7520. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7521. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7522. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7523. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7524. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7525. break;
  7526. }
  7527. }
  7528. } else {
  7529. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7530. $button = 4;
  7531. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7532. }
  7533. }
  7534. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7535. $KOP = true;
  7536. }
  7537. }
  7538. // print_r($roleArrayCopy);
  7539. // echo $roleKey;
  7540. foreach ( $roleArrayCopy as $k => $v ) {
  7541. foreach ( $verifyList as $m => $n ) {
  7542. if ($n [0] == $k) {
  7543. array_splice ( $verifyList, $m, 1, $v );
  7544. }
  7545. }
  7546. }
  7547. // if ($KOP)
  7548. // array_splice($verifyList,$roleKey,1,$roleArray);
  7549. // print_r($verifyList);
  7550. $receiptList [$key] ['verifyList'] = $verifyList;
  7551. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7552. 'where' => 'sid=' . $value ['staff'],
  7553. 'asArray' => true
  7554. ) );
  7555. $receiptList [$key] ['button'] = $button;
  7556. }
  7557. // $data['verifyDetail']=$verifyDetail;
  7558. $mothHtml = "";
  7559. for($i = 1; $i <= 12; $i ++) {
  7560. if ($month == $i)
  7561. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7562. else
  7563. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7564. }
  7565. // 获取审批日志
  7566. Doo::loadModel ( 'receiptLog' );
  7567. $receiptLog = new receiptLog ();
  7568. $rlList = array ();
  7569. $rlInfo = $receiptLog->getOne ( array (
  7570. 'where' => 'rid=' . $rid . ' and status=4',
  7571. 'asArray' => true
  7572. ) );
  7573. $tijdate = $receiptLog->getOne ( array (
  7574. 'where' => 'rid=' . $rid . ' and status=2',
  7575. 'asc' => 'rlid',
  7576. 'asArray' => true
  7577. ) );
  7578. if (! empty ( $rlInfo )) {
  7579. $rlList = $receiptLog->find ( array (
  7580. 'where' => 'rid=' . $rid,
  7581. 'asc' => 'rlid',
  7582. 'asArray' => true
  7583. ) );
  7584. }
  7585. $receiptList [0] ['rlList'] = $rlList;
  7586. $enclosurList = $enclosur->find ( array (
  7587. 'where' => 'rid=' . $rid,
  7588. 'asArray' => true
  7589. ) );
  7590. $enclosurHtml = '';
  7591. foreach ( $enclosurList as $value ) {
  7592. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  7593. }
  7594. $data ['enclosurHtml'] = $enclosurHtml;
  7595. $data ['rolename'] = $rolename ['name'];
  7596. $data ['datetij'] = $tijdate ['date'];
  7597. $data ['mothHtml'] = $mothHtml;
  7598. $data ['receiptList'] = $receiptList;
  7599. $data ['receiptApprovalCount'] = count ( $receiptList );
  7600. $data ['status'] = $status;
  7601. $data ['year'] = $year;
  7602. $data ['categoryList'] = $categoryList;
  7603. $data ['staffList'] = $staffList;
  7604. $data ['cid'] = $cid;
  7605. $data ['sid'] = $sid;
  7606. $data ['ap'] = $ap;
  7607. $data ['memu'] = "receipt";
  7608. $data ['staff'] = $this->staff;
  7609. $data ['receiptMemu'] = 'approval';
  7610. $data ['verifyId'] = $this->verifyId;
  7611. $data ['executeId'] = $this->executeId;
  7612. $this->render ( "/admin/saeaReportListReport", $data );
  7613. }
  7614. function remittanceHky() {
  7615. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7616. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  7617. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  7618. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  7619. $page_size = 15;
  7620. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  7621. Doo::loadModel ( 'receipt' );
  7622. $receipt = new receipt ();
  7623. Doo::loadModel ( 'staff' );
  7624. $staff = new staff ();
  7625. $dateCondition = " and Year(executeDate) =" . $year;
  7626. if ($moth != 'MONTH')
  7627. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  7628. if ($day != 'DAY' && $moth != 'MONTH')
  7629. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  7630. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  7631. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  7632. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  7633. $limit = $pageinfo ['lower'] . ',' . $page_size;
  7634. $dayList = $receipt->find ( array (
  7635. 'select' => 'executeDate,sum(amount) as amount',
  7636. 'where' => $sql,
  7637. 'desc' => 'executeDate',
  7638. 'groupby' => 'executeDate',
  7639. 'limit' => $limit,
  7640. 'asArray' => true
  7641. ) );
  7642. // print_r($dayList);
  7643. foreach ( $dayList as $key => $value ) {
  7644. $remitString = "";
  7645. $receiptList = $receipt->find ( array (
  7646. 'select' => 'rid,executeDate,amount,staff,cid',
  7647. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  7648. 'desc' => 'executeDate',
  7649. 'asArray' => true
  7650. ) );
  7651. foreach ( $receiptList as $k => $v ) {
  7652. $sinfo = $staff->getOne ( array (
  7653. 'select' => 'username,category',
  7654. 'where' => ' sid=' . $v ['staff'],
  7655. 'asArray' => true
  7656. ) );
  7657. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  7658. }
  7659. $dayList [$key] ['staff'] = $remitString;
  7660. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  7661. }
  7662. // print_r($dayList);
  7663. $mothHtml = "";
  7664. for($i = 1; $i <= 12; $i ++) {
  7665. if ($moth == $i)
  7666. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7667. else
  7668. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7669. }
  7670. $dayHtml = "";
  7671. if ($day != "DAY" || $moth != "MONTH") {
  7672. for($i = 1; $i <= 31; $i ++) {
  7673. if ($day == $i)
  7674. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  7675. else
  7676. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  7677. }
  7678. }
  7679. $dateHtml = "";
  7680. $now = date ( "Y" );
  7681. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  7682. if ($YEARD <= $now) {
  7683. $dateHtml .= '<option ';
  7684. if ($year == $YEARD) {
  7685. $dateHtml .= 'selected ';
  7686. }
  7687. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  7688. }
  7689. }
  7690. $data ['dateHtml'] = $dateHtml;
  7691. $data ['page'] = $pageinfo;
  7692. $data ['year'] = $year;
  7693. $data ['moth'] = $moth;
  7694. $data ['day'] = $day;
  7695. $data ['get'] = $get;
  7696. $data ['dayHtml'] = $dayHtml;
  7697. $data ['mothHtml'] = $mothHtml;
  7698. $data ['receiptList'] = $dayList;
  7699. $data ['memu'] = "receipt";
  7700. $data ['staff'] = $this->staff;
  7701. $data ['receiptMemu'] = 'remittanceHky';
  7702. $data ['verifyId'] = $this->verifyId;
  7703. $data ['executeId'] = $this->executeId;
  7704. $this->render ( "/admin/remittanceHky", $data );
  7705. }
  7706. function remittancep() {
  7707. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  7708. Doo::loadModel ( 'receipt' );
  7709. $receipt = new receipt ();
  7710. Doo::loadModel ( 'staff' );
  7711. $staff = new staff ();
  7712. Doo::loadClass ( 'XDeode' );
  7713. $XDeode = new XDeode ( 5 );
  7714. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  7715. $rplist = $receipt->find ( array (
  7716. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  7717. 'asArray' => true
  7718. ) );
  7719. $dayList = $receipt->find ( array (
  7720. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  7721. 'desc' => 'executeDate',
  7722. 'groupby' => 'staff',
  7723. 'asArray' => true
  7724. ) );
  7725. $html = '';
  7726. foreach ( $dayList as $key => $value ) {
  7727. $sinfo = $staff->getOne ( array (
  7728. 'select' => 'username,category',
  7729. 'where' => ' sid=' . $value ['staff'],
  7730. 'asArray' => true
  7731. ) );
  7732. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  7733. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  7734. $au = 0;
  7735. foreach ( $rplist as $k => $v ) {
  7736. if ($value ['staff'] == $v ['staff']) {
  7737. $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>';
  7738. $au += $v ['amount'];
  7739. }
  7740. }
  7741. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  7742. }
  7743. $data ['html'] = $html;
  7744. $data ['memu'] = "receipt";
  7745. $data ['staff'] = $this->staff;
  7746. $data ['receiptMemu'] = 'remittanceHky';
  7747. $data ['verifyId'] = $this->verifyId;
  7748. $data ['executeId'] = $this->executeId;
  7749. $this->render ( "/admin/remittancep", $data );
  7750. }
  7751. function ajaxGetReceiptDetails() {
  7752. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  7753. Doo::loadClass ( 'XDeode' );
  7754. $XDeode = new XDeode ( 5 );
  7755. $rid = $XDeode->decode ( $rid );
  7756. if (empty ( $rid )) {
  7757. echo json_encode ( array (
  7758. 'status' => 2,
  7759. 'msg' => 'illegal request'
  7760. ) );
  7761. die ();
  7762. }
  7763. Doo::loadModel ( 'receipt' );
  7764. $receipt = new receipt ();
  7765. Doo::loadModel ( 'staff' );
  7766. $staff = new staff ();
  7767. $rinfo = $receipt->getOne ( array (
  7768. 'where' => 'rid= ' . $rid,
  7769. 'asArray' => true
  7770. ) );
  7771. $sinfo = $staff->getOne ( array (
  7772. 'select' => 'username,category',
  7773. 'where' => ' sid=' . $rinfo ['staff'],
  7774. 'asArray' => true
  7775. ) );
  7776. $rinfo ['reviseDetail'] = array ();
  7777. if (! empty ( $rinfo ['reviseDetail'] ))
  7778. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  7779. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  7780. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  7781. $rinfo ['category'] = $sinfo ['category'];
  7782. $verifyStaff = array ();
  7783. if (! empty ( $rinfo ['verifyStaff'] ))
  7784. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  7785. $relust = bcsub ( $rinfo ['sum'], $rinfo ['loanSum'], 2 );
  7786. $rinfo ['relust'] = $relust;
  7787. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  7788. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  7789. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  7790. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  7791. // 费用执行人相关数据
  7792. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  7793. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  7794. foreach ( $executeCopy as $k => $v ) {
  7795. $executeCopy [$k] ['date'] = '';
  7796. $executeCopy [$k] ['opinion'] = '';
  7797. $executeCopy [$k] ['status'] = '';
  7798. if (! empty ( $executeStaff ))
  7799. foreach ( $executeStaff as $m => $u ) {
  7800. if ($v [0] == $m) {
  7801. $executeCopy [$k] ['date'] = $u ['date'];
  7802. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  7803. $executeCopy [$k] ['status'] = $u ['status'];
  7804. break;
  7805. }
  7806. }
  7807. }
  7808. $rinfo ['executeCopy'] = $executeCopy;
  7809. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  7810. if ($rinfo ['Rtype'] == 1) { // 借款费用
  7811. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  7812. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  7813. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  7814. $html .= '<tr><th>' . $value ['name'] . '</th>
  7815. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7816. }
  7817. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  7818. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  7819. <tr><th class="taC" colspan="2">费用说明</th>
  7820. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  7821. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  7822. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  7823. </tbody></table>';
  7824. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  7825. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  7826. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  7827. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  7828. $html .= '<tr><th>' . $value ['name'] . '</th>
  7829. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7830. }
  7831. $html .= '<tr><th class="taR">合计</th>
  7832. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  7833. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  7834. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  7835. $html .= '<tr><th>' . $value ['name'] . '</th>
  7836. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7837. }
  7838. $html .= '<tr><th class="taR">合计</th>
  7839. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  7840. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  7841. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  7842. $html .= '<tr><th>' . $value ['name'] . '</th>
  7843. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7844. }
  7845. $html .= '<tr><th class="taR">合计</th>
  7846. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  7847. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  7848. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  7849. $html .= '<tr><th>' . $value ['name'] . '</th>
  7850. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7851. }
  7852. $html .= '<tr><th class="taR">合计</th>
  7853. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  7854. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  7855. foreach ( $rinfo ['reviseDetail'] as $value ) {
  7856. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  7857. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  7858. }
  7859. $html .= '<tr><th class="taR">合计</th>
  7860. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  7861. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  7862. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  7863. <tr><th class="taC" colspan="2">报销说明</th></tr>
  7864. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  7865. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  7866. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  7867. <tr';
  7868. if ($rinfo ['relust'] >= 0) {
  7869. $html .= 'class="success"';
  7870. } else {
  7871. $html .= 'class="error"';
  7872. }
  7873. $html .= '><td class="taR"><b>借款结余</b></td>
  7874. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  7875. </tbody></table>
  7876. ';
  7877. }
  7878. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  7879. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  7880. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  7881. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  7882. $html .= '<tr><th>' . $value ['name'] . '</th>
  7883. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7884. }
  7885. $html .= '<tr><th class="taR">合计</th>
  7886. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  7887. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  7888. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  7889. <tr><th class="taC" colspan="2">费用说明</th>
  7890. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  7891. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  7892. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  7893. </tbody></table>';
  7894. } else {
  7895. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  7896. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  7897. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  7898. $html .= '<tr><th>' . $value ['name'] . '</th>
  7899. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7900. }
  7901. $html .= '<tr><th class="taR">合计</th>
  7902. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  7903. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  7904. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  7905. $html .= '<tr><th>' . $value ['name'] . '</th>
  7906. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7907. }
  7908. $html .= '<tr><th class="taR">合计</th>
  7909. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  7910. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  7911. foreach ( $rinfo ['accountItem'] ['培训班费用'] 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="taR">合计</th>
  7916. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  7917. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  7918. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  7919. $html .= '<tr><th>' . $value ['name'] . '</th>
  7920. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7921. }
  7922. $html .= '<tr><th class="taR">合计</th>
  7923. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  7924. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  7925. foreach ( $rinfo ['reviseDetail'] as $value ) {
  7926. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  7927. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  7928. }
  7929. $html .= '<tr><th class="taR">合计</th>
  7930. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  7931. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  7932. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  7933. <tr><th class="taC" colspan="2">报销说明</th></tr>
  7934. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  7935. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  7936. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  7937. $html .= '</tbody></table>';
  7938. /*
  7939. * <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>
  7940. */
  7941. }
  7942. // print_r($verifyStaff);die;
  7943. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  7944. foreach ( $verifyStaff as $key => $value ) {
  7945. $key = trim ( strtr ( $key, '_R', ' ' ) );
  7946. $sinfo = $staff->getOne ( array (
  7947. 'select' => 'username',
  7948. 'where' => ' sid=' . $key,
  7949. 'asArray' => true
  7950. ) );
  7951. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  7952. }
  7953. $html .= '</tbody></table>';
  7954. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  7955. foreach ( $rinfo ['executeCopy'] as $value ) {
  7956. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  7957. }
  7958. $html .= '</tbody></table>';
  7959. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  7960. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  7961. </tr></table>';
  7962. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  7963. echo json_encode ( array (
  7964. 'status' => 1,
  7965. 'html' => $html
  7966. ) );
  7967. die ();
  7968. }
  7969. /**
  7970. * 删除附件
  7971. */
  7972. function ajaxRemEnclousur() {
  7973. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  7974. if (empty ( $key ))
  7975. echo json_encode ( array (
  7976. 'status' => 2
  7977. ) );
  7978. Doo::loadModel ( 'enclosur' );
  7979. $enclosur = new enclosur ();
  7980. $enclosur->delEnclosurByEid ( $key );
  7981. echo json_encode ( array (
  7982. 'status' => 1
  7983. ) );
  7984. }
  7985. function remittance() {
  7986. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7987. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7988. Doo::loadModel ( 'receipt' );
  7989. $receipt = new receipt ();
  7990. Doo::loadModel ( 'staff' );
  7991. $staff = new staff ();
  7992. $dateCondition = " and Year(pastDate) =" . $year;
  7993. if (! empty ( $month ))
  7994. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  7995. // get Receipt By verifyID status 1
  7996. $receiptList = $receipt->find ( array (
  7997. 'select' => 'sum(sum) as sum,staff,pastDate',
  7998. 'where' => ' status=1' . $dateCondition,
  7999. 'desc' => 'pastDate',
  8000. 'groupby' => 'staff,pastDate',
  8001. 'asArray' => true
  8002. ) );
  8003. $dateList = $receipt->find ( array (
  8004. 'select' => 'pastDate,verifyStaff',
  8005. 'where' => ' status=1' . $dateCondition,
  8006. 'desc' => 'pastDate',
  8007. 'groupby' => 'pastDate',
  8008. 'asArray' => true
  8009. ) );
  8010. $dataList = array ();
  8011. foreach ( $dateList as $d => $a ) {
  8012. $dataList [$a ['pastDate']] = array ();
  8013. $daySum = 0;
  8014. foreach ( $receiptList as $key => $value ) {
  8015. if ($a ['pastDate'] == $value ['pastDate']) {
  8016. $oderList = $receipt->find ( array (
  8017. 'select' => 'receiptOrder',
  8018. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  8019. 'asArray' => true
  8020. ) );
  8021. $list = array ();
  8022. $html = "";
  8023. foreach ( $oderList as $v ) {
  8024. array_push ( $list, $v ['receiptOrder'] );
  8025. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  8026. }
  8027. $receiptList [$key] ['receiptOrder'] = $html;
  8028. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  8029. $sinfo = $staff->getOne ( array (
  8030. 'select' => 'username ',
  8031. 'where' => ' sid=' . $value ['staff'],
  8032. 'asArray' => true
  8033. ) );
  8034. $receiptList [$key] ['username'] = $sinfo ['username'];
  8035. $daySum += $value ['sum'];
  8036. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  8037. }
  8038. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  8039. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  8040. }
  8041. }
  8042. // print_r($dataList);
  8043. $data ['dataList'] = $dataList;
  8044. $mothHtml = "";
  8045. for($i = 1; $i <= 12; $i ++) {
  8046. if ($month == $i)
  8047. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8048. else
  8049. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8050. }
  8051. $data ['year'] = $year;
  8052. $data ['mothHtml'] = $mothHtml;
  8053. $data ['memu'] = "receipt";
  8054. $data ['staff'] = $this->staff;
  8055. $data ['receiptMemu'] = 'approval';
  8056. $data ['verifyId'] = $this->verifyId;
  8057. $data ['executeId'] = $this->executeId;
  8058. $this->render ( "/admin/saeaReportListPay", $data );
  8059. }
  8060. /**
  8061. * 金额调整,提高稳定性
  8062. * @return string
  8063. */
  8064. function revocationAdjustment() {
  8065. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  8066. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  8067. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  8068. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  8069. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  8070. Doo::loadClass ( 'XDeode' );
  8071. $XDeode = new XDeode ( 5 );
  8072. Doo::loadModel ( 'receipt' );
  8073. $receipt = new receipt ();
  8074. $sid = $XDeode->decode ( $sidKey );
  8075. $rid = $XDeode->decode ( $ridKey );
  8076. $reviseKey = $XDeode->decode ( $reviseKey );
  8077. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  8078. die ( 'illegal request' );
  8079. $receiptDetail = $receipt->getOne ( array (
  8080. 'where' => 'rid=' . $rid,
  8081. 'asArray' => true
  8082. ) );
  8083. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  8084. die ( 'illegal request' );
  8085. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8086. if (! isset ( $reviseDetail [$reviseKey] ))
  8087. die ( 'illegal request' );
  8088. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  8089. unset ( $reviseDetail [$reviseKey] );
  8090. $revisePrice = 0;
  8091. foreach ( $reviseDetail as $key => $value ) {
  8092. $revisePrice += $value ['price'];
  8093. }
  8094. $reviseDetailString = json_encode ( $reviseDetail );
  8095. $receipt->reviseDetail = $reviseDetailString;
  8096. $receipt->sum = $receiptDetail ['sum'] - $price;
  8097. $receipt->revisePrice = $revisePrice;
  8098. $receipt->update ( array (
  8099. 'where' => 'rid=' . $rid
  8100. ) );
  8101. return '/receiptburEdi/' . $rid;
  8102. } else
  8103. die ( 'illegal request2' );
  8104. }
  8105. function updateApprovalReceipt() {
  8106. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  8107. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  8108. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8109. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  8110. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  8111. if (! empty ( $rid )) {
  8112. Doo::loadModel ( "verify" );
  8113. $verify = new verify ();
  8114. Doo::loadModel ( "receiptDetail" );
  8115. $receiptDetailObj = new receiptDetail ();
  8116. Doo::loadModel ( "itemStatistics" );
  8117. Doo::loadModel ( "statistics" );
  8118. $statistics = new statistics ();
  8119. $itemStatistics = new itemStatistics ();
  8120. Doo::loadModel ( "receipt" );
  8121. $receipt = new receipt ();
  8122. $receiptDetail = $receipt->getOne ( array (
  8123. 'where' => 'rid=' . $rid . ' and status=2 ',
  8124. 'asArray' => true
  8125. ) );
  8126. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  8127. $nsflag = true;
  8128. foreach ( $nslist as $value ) {
  8129. if ($value == $this->staff ['0'] ['sid']) {
  8130. $nsflag = false;
  8131. break;
  8132. }
  8133. }
  8134. if (empty ( $receiptDetail ) || $nsflag)
  8135. return "/approval";
  8136. $verifyDetail = $verify->getOne ( array (
  8137. 'where' => ' vid =' . $receiptDetail ['verify'],
  8138. 'asArray' => true
  8139. ) );
  8140. $verifyString = $verifyDetail ['staff'];
  8141. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  8142. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  8143. if (empty ( $opinion )) {
  8144. if ($status == 3)
  8145. $opinion = "终止";
  8146. else
  8147. $opinion = "同意支付";
  8148. }
  8149. $nowStaff = 0;
  8150. $nowStaffList = array ();
  8151. if (empty ( $verifyStaff )) {
  8152. // 还需加入是否已经进入角色审批
  8153. if ($verifyDetail [0] [1] == 'ROLE') {
  8154. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  8155. foreach ( $vStaffString as $key => $value ) {
  8156. $staffK = explode ( "_", $value );
  8157. if ($staffK [0] != $this->staff [0] ['sid'])
  8158. array_push ( $nowStaffList, $staffK [0] );
  8159. }
  8160. // print_r($verifyDetail);
  8161. // die;
  8162. if (! empty ( $nowStaffList )) {
  8163. $nowStaff = implode ( ',', $nowStaffList );
  8164. $verifyStaff = array (
  8165. $this->staff [0] ['sid'] . "_R" => array (
  8166. 'date' => date ( 'Y-m-d' ),
  8167. 'opinion' => $opinion,
  8168. 'status' => $status,
  8169. 'nextStaff' => $verifyDetail [0] [0],
  8170. 'ROLE' => 1
  8171. )
  8172. );
  8173. } else {
  8174. $nowStaff = $verifyDetail [1] [0];
  8175. $verifyStaff = array (
  8176. $this->staff [0] ['sid'] . "_R" => array (
  8177. 'date' => date ( 'Y-m-d' ),
  8178. 'opinion' => $opinion,
  8179. 'status' => $status,
  8180. 'nextStaff' => $verifyDetail [1] [0]
  8181. )
  8182. );
  8183. }
  8184. } else {
  8185. if ($verifyDetail [1] [1] == 'ROLE') {
  8186. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  8187. // echo "dd";
  8188. foreach ( $vStaffString as $key => $value ) {
  8189. $staffK = explode ( "_", $value );
  8190. array_push ( $nowStaffList, $staffK [0] );
  8191. }
  8192. $nowStaff = implode ( ',', $nowStaffList );
  8193. $verifyStaff = array (
  8194. $this->staff [0] ['sid'] => array (
  8195. 'date' => date ( 'Y-m-d' ),
  8196. 'opinion' => $opinion,
  8197. 'status' => $status,
  8198. 'nextStaff' => $verifyDetail [1] [0],
  8199. 'ROLE' => 1
  8200. )
  8201. );
  8202. } else {
  8203. $nowStaff = $verifyDetail [1] [0];
  8204. $verifyStaff = array (
  8205. $this->staff [0] ['sid'] => array (
  8206. 'date' => date ( 'Y-m-d' ),
  8207. 'opinion' => $opinion,
  8208. 'status' => $status,
  8209. 'nextStaff' => $verifyDetail [1] [0]
  8210. )
  8211. );
  8212. }
  8213. }
  8214. if ($status == 3)
  8215. $verifyStaff = array (
  8216. 'final' => $status,
  8217. $this->staff [0] ['sid'] => array (
  8218. 'date' => date ( 'Y-m-d' ),
  8219. 'opinion' => $opinion,
  8220. 'status' => $status
  8221. )
  8222. );
  8223. $vStaffString = json_encode ( $verifyStaff );
  8224. $receipt->nowStaff = $nowStaff;
  8225. $receipt->verifyStaff = $vStaffString;
  8226. } else {
  8227. $VS = end ( $verifyStaff );
  8228. // 非角色审批
  8229. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  8230. $nextStaff = 0;
  8231. $roleSTF = false;
  8232. foreach ( $verifyDetail as $key => $value ) {
  8233. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  8234. if (isset ( $verifyDetail [$key + 1] )) {
  8235. $nextStaff = $verifyDetail [$key + 1] [0];
  8236. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  8237. $roleSTF = true;
  8238. }
  8239. break;
  8240. }
  8241. }
  8242. if (! $roleSTF) {
  8243. $nowStaff = $nextStaff;
  8244. $verifyStaff [$this->staff [0] ['sid']] = array (
  8245. 'date' => date ( 'Y-m-d' ),
  8246. 'opinion' => $opinion,
  8247. 'status' => $status,
  8248. 'nextStaff' => $nextStaff
  8249. );
  8250. } else {
  8251. // 获取角色下的所有用户ID
  8252. $nowStaffList = array ();
  8253. foreach ( $verifyDetail as $vfk ) {
  8254. if ($vfk [1] == 'ROLE') {
  8255. $vStaffString = json_decode ( $vfk [3] );
  8256. foreach ( $vStaffString as $key => $value ) {
  8257. $staffK = explode ( "_", $value );
  8258. array_push ( $nowStaffList, $staffK [0] );
  8259. }
  8260. }
  8261. }
  8262. $nowStaff = implode ( ',', $nowStaffList );
  8263. $verifyStaff [$this->staff [0] ['sid']] = array (
  8264. 'date' => date ( 'Y-m-d' ),
  8265. 'opinion' => $opinion,
  8266. 'status' => $status,
  8267. 'nextStaff' => $nextStaff,
  8268. 'ROLE' => 0
  8269. );
  8270. }
  8271. if ($status == 3) {
  8272. $verifyStaff ['final'] = $status;
  8273. $verifyStaff [$this->staff [0] ['sid']] = array (
  8274. 'date' => date ( 'Y-m-d' ),
  8275. 'opinion' => $opinion,
  8276. 'status' => $status
  8277. );
  8278. }
  8279. $vStaffString = json_encode ( $verifyStaff );
  8280. $receipt->nowStaff = $nowStaff;
  8281. $receipt->verifyStaff = $vStaffString;
  8282. }
  8283. // 角色审批
  8284. if (isset ( $VS ['ROLE'] )) {
  8285. // 找出角色人 当前审批角色组
  8286. $verifyJSStaff = array ();
  8287. $nowStaffList2 = array ();
  8288. foreach ( $verifyDetail as $key => $value ) {
  8289. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  8290. $verifyJSStaff = json_decode ( $value [3] );
  8291. foreach ( $verifyJSStaff as $m ) {
  8292. $staffK = explode ( "_", $m );
  8293. array_push ( $nowStaffList2, $staffK [0] );
  8294. }
  8295. // print_r($nowStaffList2);
  8296. }
  8297. }
  8298. $RoleVerifyStaff = array ();
  8299. foreach ( $verifyStaff as $key => $value ) {
  8300. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  8301. foreach ( $nowStaffList2 as $m ) {
  8302. if ($key == $m . "_R")
  8303. $RoleVerifyStaff [$key] = $value;
  8304. }
  8305. }
  8306. }
  8307. // print_r($verifyStaff);
  8308. // print_r($nowStaffList2);
  8309. // print_r($RoleVerifyStaff);
  8310. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  8311. // print_r($verifyJSStaff);
  8312. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  8313. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  8314. // 下一个审批人ID
  8315. $nextStaff = 0;
  8316. $falg = false;
  8317. foreach ( $verifyDetail as $key => $value ) {
  8318. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  8319. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  8320. $falg = true;
  8321. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  8322. $nowStaffList = array ();
  8323. foreach ( $vStaffString as $v ) {
  8324. $staffK = explode ( "_", $v );
  8325. array_push ( $nowStaffList, $staffK [0] );
  8326. }
  8327. $nowStaff = implode ( ',', $nowStaffList );
  8328. $nextStaff = $verifyDetail [$key + 1] [0];
  8329. } elseif (isset ( $verifyDetail [$key + 1] )) {
  8330. $nextStaff = $verifyDetail [$key + 1] [0];
  8331. $nowStaff = $nextStaff;
  8332. } else
  8333. $nowStaff = '';
  8334. break;
  8335. }
  8336. }
  8337. if ($falg)
  8338. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8339. 'date' => date ( 'Y-m-d' ),
  8340. 'opinion' => $opinion,
  8341. 'status' => $status,
  8342. 'nextStaff' => $nextStaff,
  8343. 'ROLE' => 1
  8344. );
  8345. else
  8346. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8347. 'date' => date ( 'Y-m-d' ),
  8348. 'opinion' => $opinion,
  8349. 'status' => $status,
  8350. 'nextStaff' => $nextStaff
  8351. );
  8352. // print_r($verifyStaff);
  8353. // echo $nowStaff;die;
  8354. } else { // 进入下一个角色或者审批人
  8355. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  8356. //
  8357. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  8358. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8359. 'date' => date ( 'Y-m-d' ),
  8360. 'opinion' => $opinion,
  8361. 'status' => $status,
  8362. 'nextStaff' => $VS ['nextStaff'],
  8363. 'ROLE' => 1
  8364. );
  8365. // print_r($verifyStaff);
  8366. // die;
  8367. }
  8368. if ($status == 3) {
  8369. $verifyStaff ['final'] = $status;
  8370. $verifyStaff [$this->staff [0] ['sid']] = array (
  8371. 'date' => date ( 'Y-m-d' ),
  8372. 'opinion' => $opinion,
  8373. 'status' => $status
  8374. );
  8375. }
  8376. $vStaffString = json_encode ( $verifyStaff );
  8377. $receipt->verifyStaff = $vStaffString;
  8378. $receipt->nowStaff = $nowStaff;
  8379. // die;
  8380. // }
  8381. // print_r($verifyStaff);
  8382. // die;
  8383. }
  8384. // print_r($verifyStaff);die;
  8385. }
  8386. // print_r($verifyDetail);
  8387. $roleKey = 0;
  8388. $roleId = 0;
  8389. $verifyDetailCopy = array ();
  8390. foreach ( $verifyDetail as $k => $v ) {
  8391. if ($v [1] == 'ROLE') {
  8392. $roleId = $v [0];
  8393. $roleVerify = json_decode ( $v [3], true );
  8394. $roleKey = $k;
  8395. $roleArray = array ();
  8396. foreach ( $roleVerify as $o => $p ) {
  8397. $staffID = explode ( '_', $p );
  8398. $exp = array (
  8399. 0 => $staffID [0],
  8400. 1 => $staffID [1]
  8401. );
  8402. array_push ( $roleArray, $exp );
  8403. }
  8404. $verifyDetailCopy [$v [0]] = $roleArray;
  8405. }
  8406. }
  8407. // print_r($verifyDetail);
  8408. foreach ( $verifyDetailCopy as $k => $v ) {
  8409. foreach ( $verifyDetail as $m => $n ) {
  8410. if ($n [0] == $k) {
  8411. array_splice ( $verifyDetail, $m, 1, $v );
  8412. }
  8413. }
  8414. }
  8415. // die;
  8416. // if (!empty($roleArray))
  8417. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  8418. // echo $roleId;
  8419. // print_r($verifyStaff);
  8420. // print_r($verifyDetail);
  8421. // die;
  8422. Doo::loadModel ( "receiptLog" );
  8423. $receiptLog = new receiptLog ();
  8424. // 审批日志
  8425. if (! isset ( $verifyStaff ['final'] )) {
  8426. if (! empty ( $roleId )) {
  8427. Doo::loadModel ( "role" );
  8428. $role = new role ();
  8429. $roleInfo = $role->getOne ( array (
  8430. 'where' => 'rid=' . $roleId,
  8431. 'asArray' => true
  8432. ) );
  8433. $receiptLog->rolename = $roleInfo ['name'];
  8434. }
  8435. $receiptLog->username = $this->staff [0] ['username'];
  8436. $receiptLog->uid = $this->staff [0] ['sid'];
  8437. $receiptLog->date = date ( "Y-m-d" );
  8438. $receiptLog->opinion = $opinion;
  8439. $receiptLog->img = $this->staff [0] ['avatar'];
  8440. $receiptLog->status = 1;
  8441. $receiptLog->rid = $rid;
  8442. $receiptLog->insert ();
  8443. }
  8444. if (isset ( $verifyStaff ['final'] )) { // rDetail
  8445. $receipt->verifyBreakup = $verifyString;
  8446. $receipt->status = 3;
  8447. $receiptDetailObj->status = 3;
  8448. $receiptDetailObj->update ( array (
  8449. 'where' => 'rid=' . $rid
  8450. ) );
  8451. if (! empty ( $roleId )) {
  8452. Doo::loadModel ( "role" );
  8453. $role = new role ();
  8454. $roleInfo = $role->getOne ( array (
  8455. 'where' => 'rid=' . $roleId,
  8456. 'asArray' => true
  8457. ) );
  8458. $receiptLog->rolename = $roleInfo ['name'];
  8459. }
  8460. $receiptLog->username = $this->staff [0] ['username'];
  8461. $receiptLog->uid = $this->staff [0] ['sid'];
  8462. $receiptLog->date = date ( "Y-m-d" );
  8463. $receiptLog->opinion = $opinion;
  8464. $receiptLog->img = $this->staff [0] ['avatar'];
  8465. $receiptLog->status = 3;
  8466. $receiptLog->rid = $rid;
  8467. $receiptLog->insert ();
  8468. // 微信企业号通知
  8469. $this->setWXMsg ( $rid, 3 );
  8470. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  8471. $receipt->status = 1;
  8472. $reviseSum = 0;
  8473. $receipt->verifyBreakup = $verifyString;
  8474. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  8475. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8476. foreach ( $reviseDetail as $key => $value ) {
  8477. $receiptDetailObj = new receiptDetail ();
  8478. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8479. $receiptDetailObj->item = $value ['description'];
  8480. $receiptDetailObj->itemCategory = "报销金额调整";
  8481. $receiptDetailObj->price = $value ['price'];
  8482. $receiptDetailObj->date = $receiptDetail ['date'];
  8483. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  8484. $receiptDetailObj->rid = $rid;
  8485. $receiptDetailObj->status = 1;
  8486. $receiptDetailObj->insert ();
  8487. $reviseSum += $value ['price'];
  8488. }
  8489. $itemStatistics = new itemStatistics ();
  8490. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  8491. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8492. $itemStatistics->price = $reviseSum;
  8493. $itemStatistics->itemCategory = "报销金额调整";
  8494. $itemStatistics->date = $receiptDetail ['date'];
  8495. $itemStatistics->insert ();
  8496. }
  8497. $receiptDetailObj = new receiptDetail ();
  8498. $receiptDetailObj->status = 1;
  8499. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  8500. $receiptDetailObj->update ( array (
  8501. 'where' => 'rid=' . $rid
  8502. ) );
  8503. $dateArray = explode ( "-", $receiptDetail ['date'] );
  8504. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  8505. $stat = $statistics->getOne ( array (
  8506. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  8507. 'asArray' => true
  8508. ) );
  8509. if (empty ( $stat )) {
  8510. $statistics->date = $receiptDetail ['date'];
  8511. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  8512. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8513. $statistics->agPrice = $receiptDetail ['sum'];
  8514. $statistics->rePrice = $reviseSum;
  8515. $statistics->insert ();
  8516. } else {
  8517. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  8518. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  8519. $statistics->update ( array (
  8520. 'where' => 'sid=' . $stat ['sid']
  8521. ) );
  8522. }
  8523. $dateArray = explode ( "-", $receiptDetail ['date'] );
  8524. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  8525. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  8526. foreach ( $accountItem ['cSum'] as $key => $value ) {
  8527. if ($key == "agencySum") {
  8528. $iStatistics = $itemStatistics->getOne ( array (
  8529. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  8530. 'asArray' => true
  8531. ) );
  8532. if (empty ( $iStatistics )) {
  8533. $itemStatistics->cid = $receiptDetail ['cid'];
  8534. ;
  8535. $itemStatistics->staff = $receiptDetail ['staff'];
  8536. $itemStatistics->price = $value;
  8537. $itemStatistics->itemCategory = $this->AGENCY;
  8538. $itemStatistics->date = $receiptDetail ['date'];
  8539. $itemStatistics->insert ();
  8540. } else {
  8541. if (! empty ( $value )) {
  8542. $itemStatistics->price = $value + $iStatistics ['price'];
  8543. $itemStatistics->update ( array (
  8544. 'where' => 'sid=' . $iStatistics ['sid']
  8545. ) );
  8546. }
  8547. }
  8548. } elseif ($key == "travelSum") {
  8549. $iStatistics = $itemStatistics->getOne ( array (
  8550. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  8551. 'asArray' => true
  8552. ) );
  8553. if (empty ( $iStatistics )) {
  8554. $itemStatistics->cid = $receiptDetail ['cid'];
  8555. $itemStatistics->staff = $receiptDetail ['staff'];
  8556. $itemStatistics->price = $value;
  8557. $itemStatistics->itemCategory = $this->TRAVEL;
  8558. $itemStatistics->date = $receiptDetail ['date'];
  8559. $itemStatistics->insert ();
  8560. } else {
  8561. if (! empty ( $value )) {
  8562. $itemStatistics->price = $value + $iStatistics ['price'];
  8563. $itemStatistics->update ( array (
  8564. 'where' => 'sid=' . $iStatistics ['sid']
  8565. ) );
  8566. }
  8567. }
  8568. } elseif ($key == "trainSum") {
  8569. $iStatistics = $itemStatistics->getOne ( array (
  8570. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  8571. 'asArray' => true
  8572. ) );
  8573. if (empty ( $iStatistics )) {
  8574. $itemStatistics->cid = $receiptDetail ['cid'];
  8575. $itemStatistics->staff = $receiptDetail ['staff'];
  8576. $itemStatistics->price = $value;
  8577. $itemStatistics->itemCategory = $this->TRAIN;
  8578. $itemStatistics->date = $receiptDetail ['date'];
  8579. $itemStatistics->insert ();
  8580. } else {
  8581. if (! empty ( $value )) {
  8582. $itemStatistics->price = $value + $iStatistics ['price'];
  8583. $itemStatistics->update ( array (
  8584. 'where' => 'sid=' . $iStatistics ['sid']
  8585. ) );
  8586. }
  8587. }
  8588. } elseif ($key == "otherSum") {
  8589. $iStatistics = $itemStatistics->getOne ( array (
  8590. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  8591. 'asArray' => true
  8592. ) );
  8593. if (empty ( $iStatistics )) {
  8594. $itemStatistics->cid = $receiptDetail ['cid'];
  8595. $itemStatistics->staff = $receiptDetail ['staff'];
  8596. $itemStatistics->price = $value;
  8597. $itemStatistics->itemCategory = $this->OTHER;
  8598. $itemStatistics->date = $receiptDetail ['date'];
  8599. $itemStatistics->insert ();
  8600. } else {
  8601. if (! empty ( $value )) {
  8602. $itemStatistics->price = $value + $iStatistics ['price'];
  8603. $itemStatistics->update ( array (
  8604. 'where' => 'sid=' . $iStatistics ['sid']
  8605. ) );
  8606. }
  8607. }
  8608. }
  8609. }
  8610. $receipt->pastDate = date ( "Y-m-d" );
  8611. // 微信企业号通知
  8612. $this->setWXMsg ( $rid, 1 );
  8613. }
  8614. $receipt->amount = $amount;
  8615. $receipt->update ( array (
  8616. 'where' => ' rid = ' . $rid
  8617. ) );
  8618. // 进入下一条审批费用新加需求
  8619. $vidList = array ();
  8620. $verifyDetail = $verify->find ( array (
  8621. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  8622. 'asArray' => true
  8623. ) );
  8624. foreach ( $verifyDetail as $key => $value ) {
  8625. array_push ( $vidList, $value ['vid'] );
  8626. }
  8627. $vid = implode ( ",", $vidList );
  8628. if (empty ( $verifyDetail ))
  8629. $vid = 0;
  8630. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  8631. $receipt = new receipt ();
  8632. $rd = $receipt->getOne ( array (
  8633. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  8634. 'asc' => 'rid',
  8635. 'asArray' => true
  8636. ) );
  8637. if (empty ( $rd )) {
  8638. return '/approvalExpenses/pendApproval';
  8639. }
  8640. if ($rd ['Rtype'] == 1) {
  8641. if ($rd ['isBK'] == 1) {
  8642. return '/receiptburEdi/' . $rd ['rid'];
  8643. } else {
  8644. return '/expensesEdi/' . $rd ['rid'];
  8645. }
  8646. } elseif ($rd ['Rtype'] == 2) {
  8647. return '/remitApproval/' . $rd ['rid'];
  8648. } else {
  8649. return '/receiptburEdi/' . $rd ['rid'];
  8650. }
  8651. // return "/approvalExpenses/pendApproval";
  8652. }
  8653. }
  8654. function expensesRetreats() {
  8655. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  8656. if (! empty ( $rid )) {
  8657. // 操作记录
  8658. Doo::loadModel ( "receipt" );
  8659. $receipt = new receipt ();
  8660. Doo::loadModel ( "receiptLog" );
  8661. $receiptLog = new receiptLog ();
  8662. Doo::loadModel ( "verify" );
  8663. $verify = new verify ();
  8664. $receiptInfo = $receipt->getOne ( array (
  8665. 'where' => 'rid=' . $rid,
  8666. 'asArray' => true
  8667. ) );
  8668. $vr = $verify->getOne ( array (
  8669. 'where' => 'vid=' . $receiptInfo ['verify'],
  8670. 'asArray' => true
  8671. ) );
  8672. $jd = json_decode ( $vr ['staff'] );
  8673. $roleId = 0;
  8674. foreach ( $jd as $key => $value ) {
  8675. if ($value [1] == 'ROLE') {
  8676. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  8677. if ($pos !== false) {
  8678. $roleId = $value [0];
  8679. }
  8680. }
  8681. }
  8682. // 审批日志
  8683. // echo $roleId;die;
  8684. if (! empty ( $roleId )) {
  8685. Doo::loadModel ( "role" );
  8686. $role = new role ();
  8687. $roleInfo = $role->getOne ( array (
  8688. 'where' => 'rid=' . $roleId,
  8689. 'asArray' => true
  8690. ) );
  8691. $receiptLog->rolename = $roleInfo ['name'];
  8692. }
  8693. $receiptLog->username = $this->staff [0] ['username'];
  8694. $receiptLog->uid = $this->staff [0] ['sid'];
  8695. $receiptLog->date = date ( "Y-m-d" );
  8696. $receiptLog->opinion = '撤回';
  8697. $receiptLog->img = $this->staff [0] ['avatar'];
  8698. $receiptLog->status = 4;
  8699. $receiptLog->rid = $rid;
  8700. $receiptLog->insert ();
  8701. $receipt->status = 4;
  8702. $receipt->update ( array (
  8703. 'where' => 'rid=' . $rid
  8704. ) );
  8705. // 微信企业号通知
  8706. $this->setWXMsg ( $rid, 2 );
  8707. }
  8708. // echo "ddd";
  8709. return '/approvalExpenses/pendApproval';
  8710. }
  8711. function updateCheReceipt() {
  8712. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8713. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  8714. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  8715. if (! empty ( $rid )) {
  8716. // 操作记录
  8717. Doo::loadModel ( "receipt" );
  8718. $receipt = new receipt ();
  8719. Doo::loadModel ( "receiptLog" );
  8720. $receiptLog = new receiptLog ();
  8721. Doo::loadModel ( "verify" );
  8722. $verify = new verify ();
  8723. $receiptInfo = $receipt->getOne ( array (
  8724. 'where' => 'rid=' . $rid . ' and status=2',
  8725. 'asArray' => true
  8726. ) );
  8727. if (empty ( $receiptInfo )) {
  8728. echo json_encode ( array (
  8729. 'status' => 2
  8730. ) );
  8731. die ();
  8732. }
  8733. $vr = $verify->getOne ( array (
  8734. 'where' => 'vid=' . $receiptInfo ['verify'],
  8735. 'asArray' => true
  8736. ) );
  8737. $jd = json_decode ( $vr ['staff'] );
  8738. $roleId = 0;
  8739. foreach ( $jd as $key => $value ) {
  8740. if ($value [1] == 'ROLE') {
  8741. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  8742. if ($pos !== false) {
  8743. $roleId = $value [0];
  8744. }
  8745. }
  8746. }
  8747. // 审批日志
  8748. // echo $roleId;die;
  8749. if (! empty ( $roleId )) {
  8750. Doo::loadModel ( "role" );
  8751. $role = new role ();
  8752. $roleInfo = $role->getOne ( array (
  8753. 'where' => 'rid=' . $roleId,
  8754. 'asArray' => true
  8755. ) );
  8756. $receiptLog->rolename = $roleInfo ['name'];
  8757. }
  8758. $receiptLog->username = $this->staff [0] ['username'];
  8759. $receiptLog->uid = $this->staff [0] ['sid'];
  8760. $receiptLog->date = date ( "Y-m-d" );
  8761. $receiptLog->opinion = $opinion;
  8762. $receiptLog->img = $this->staff [0] ['avatar'];
  8763. $receiptLog->status = 4;
  8764. $receiptLog->rid = $rid;
  8765. $receiptLog->insert ();
  8766. $receipt->status = 4;
  8767. $receipt->update ( array (
  8768. 'where' => 'rid=' . $rid
  8769. ) );
  8770. // 微信企业号通知
  8771. $this->setWXMsg ( $rid, 2 );
  8772. echo json_encode ( array (
  8773. 'status' => 1
  8774. ) );
  8775. // Header("HTTP/1.1 303 See Other");
  8776. // Header("Location: /approvalExpenses/pendApproval");
  8777. die ();
  8778. }
  8779. echo json_encode ( array (
  8780. 'status' => 2
  8781. ) );
  8782. die ();
  8783. // echo "ddd";
  8784. // return '/saeaBorad';
  8785. }
  8786. function revisePrice() {
  8787. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  8788. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  8789. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8790. // echo $price;die;
  8791. if (! empty ( $rid )) {
  8792. Doo::loadModel ( "receipt" );
  8793. $receipt = new receipt ();
  8794. $receiptDetail = $receipt->getOne ( array (
  8795. 'where' => 'rid=' . $rid . ' and status=2 ',
  8796. 'asArray' => true
  8797. ) );
  8798. if (empty ( $receiptDetail ))
  8799. die ( 'illegal request' );
  8800. $reviseDetail = array ();
  8801. if (empty ( $receiptDetail ['reviseDetail'] )) {
  8802. array_push ( $reviseDetail, array (
  8803. 'sid' => $this->staff [0] ['sid'],
  8804. 'name' => $this->staff [0] ['username'],
  8805. 'description' => $description,
  8806. 'price' => $price
  8807. ) );
  8808. $reviseDetailString = json_encode ( $reviseDetail );
  8809. $receipt->reviseDetail = $reviseDetailString;
  8810. $receipt->revisePrice = $price;
  8811. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  8812. } else {
  8813. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8814. array_push ( $reviseDetail, array (
  8815. 'sid' => $this->staff [0] ['sid'],
  8816. 'name' => $this->staff [0] ['username'],
  8817. 'description' => $description,
  8818. 'price' => $price
  8819. ) );
  8820. $reviseDetailString = json_encode ( $reviseDetail );
  8821. $receipt->reviseDetail = $reviseDetailString;
  8822. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  8823. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  8824. }
  8825. $receipt->update ( array (
  8826. 'where' => 'rid=' . $rid
  8827. ) );
  8828. if ($receiptDetail ['Rtype'] == 1) {
  8829. if ($receiptDetail ['isBK'] == 1) {
  8830. return '/receiptburEdi/' . $receiptDetail ['rid'];
  8831. }
  8832. } elseif ($receiptDetail ['Rtype'] == 2) {
  8833. } else {
  8834. return '/receiptburEdi/' . $receiptDetail ['rid'];
  8835. }
  8836. }
  8837. die ( 'illegal request' );
  8838. }
  8839. function personalCollect() {
  8840. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8841. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  8842. $this->showCache ( $path );
  8843. Doo::loadModel ( "receiptDetail" );
  8844. Doo::loadModel ( "itemStatistics" );
  8845. Doo::loadModel ( 'statistics' );
  8846. $statistics = new statistics ();
  8847. $itemStatistics = new itemStatistics ();
  8848. $receiptDetail = new receiptDetail ();
  8849. $receiptCollectList = $receiptDetail->find ( array (
  8850. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  8851. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  8852. 'groupby' => 'itemCategory,Month(date)',
  8853. 'asArray' => true
  8854. ) );
  8855. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  8856. 'where' => 'staff=' . $this->staff [0] ['sid'],
  8857. 'asArray' => true
  8858. ) );
  8859. // create collect html
  8860. $collectArray = array (
  8861. '日常相关费用' => array (),
  8862. '差旅相关费用' => array (),
  8863. '培训班费用' => array (),
  8864. '其他' => array ()
  8865. );
  8866. $adjustment = array ();
  8867. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  8868. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  8869. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  8870. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  8871. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  8872. array_push ( $collectArray ['培训班费用'], $collectHtml );
  8873. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  8874. array_push ( $collectArray ['其他'], $collectHtml );
  8875. $data ['collectArray'] = $collectArray;
  8876. // statistics html
  8877. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  8878. if (empty ( $stList ))
  8879. $stList = array (
  8880. 'rePrice' => 0,
  8881. 'agPrice' => 0
  8882. );
  8883. $data ['stList'] = array (
  8884. 'rePrice' => $stList ['rePrice'],
  8885. 'agPrice' => $stList ['agPrice'],
  8886. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8887. );
  8888. // Adjustment price html
  8889. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  8890. array_push ( $adjustment, $collectHtml );
  8891. $data ['adjustment'] = $adjustment;
  8892. // total price html
  8893. $collectHtml = "";
  8894. $total = 0;
  8895. for($i = 1; $i <= 12; $i ++) {
  8896. $sumPrice = 0;
  8897. foreach ( $receiptCollectList as $key => $value ) {
  8898. if ($value ['month'] == $i) {
  8899. $sumPrice += $value ['price'];
  8900. }
  8901. }
  8902. if ($sumPrice == 0)
  8903. $collectHtml .= '<td class="taR">-</td>';
  8904. else
  8905. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8906. $total += $sumPrice;
  8907. }
  8908. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8909. $data ['totalPrice'] = $collectHtml;
  8910. $dateHtml = "";
  8911. $now = date ( "Y" );
  8912. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  8913. if ($YEARD <= $now) {
  8914. $dateHtml .= '<option ';
  8915. if ($year == $YEARD) {
  8916. $dateHtml .= 'selected ';
  8917. }
  8918. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  8919. }
  8920. }
  8921. $data ['dateHtml'] = $dateHtml;
  8922. $data ['year'] = $year;
  8923. $data ['totalYear'] = $total;
  8924. $data ['memu'] = "receipt";
  8925. $data ['staff'] = $this->staff;
  8926. $data ['receiptMemu'] = 'personalCollect';
  8927. $data ['verifyId'] = $this->verifyId;
  8928. $data ['executeId'] = $this->executeId;
  8929. // year staff status 2,4
  8930. if ($year < date ( "Y" )) {
  8931. Doo::loadModel ( 'receipt' );
  8932. $receipt = new receipt ();
  8933. $receiptList = $receipt->find ( array (
  8934. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  8935. 'asArray' => true
  8936. ) );
  8937. if (empty ( $receiptList )) {
  8938. ob_start ();
  8939. $this->render ( "/admin/saea_slist_collect", $data );
  8940. $this->cacheFile ( $path );
  8941. die ();
  8942. }
  8943. }
  8944. $this->render ( "/admin/saea_slist_collect", $data );
  8945. }
  8946. function personalCollectDetail() {
  8947. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8948. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  8949. $this->showCache ( $path );
  8950. Doo::loadModel ( "receiptDetail" );
  8951. Doo::loadModel ( "itemStatistics" );
  8952. Doo::loadModel ( 'statistics' );
  8953. Doo::loadModel ( 'accountItem' );
  8954. $accountItem = new accountItem ();
  8955. $statistics = new statistics ();
  8956. $itemStatistics = new itemStatistics ();
  8957. $receiptDetail = new receiptDetail ();
  8958. $receiptCollectList = $receiptDetail->find ( array (
  8959. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8960. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  8961. 'groupby' => 'item,Month(date)',
  8962. 'asArray' => true
  8963. ) );
  8964. $accountList = $accountItem->find ( array (
  8965. 'asArray' => true
  8966. ) );
  8967. // create CollectDetail HTML
  8968. $collectHtml = array ();
  8969. foreach ( $accountList as $key => $value ) {
  8970. $html = "";
  8971. $asum = 0;
  8972. for($i = 1; $i <= 12; $i ++) {
  8973. $falg = true;
  8974. foreach ( $receiptCollectList as $v ) {
  8975. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  8976. $asum += $v ['price'];
  8977. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8978. $falg = false;
  8979. break;
  8980. }
  8981. }
  8982. if ($falg)
  8983. $html .= '<td class="taR">-</td>';
  8984. }
  8985. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8986. $collectHtml [$value ['category']] [$value ['name']] = $html;
  8987. }
  8988. $data ['collectHtml'] = $collectHtml;
  8989. // create Adjustment price html
  8990. $receiptCollectList = $receiptDetail->find ( array (
  8991. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  8992. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  8993. 'groupby' => 'itemCategory,Month(date)',
  8994. 'asArray' => true
  8995. ) );
  8996. $adjustment = array ();
  8997. $collectArray = array (
  8998. '日常相关费用' => array (),
  8999. '差旅相关费用' => array (),
  9000. '培训班费用' => array (),
  9001. '其他' => array ()
  9002. );
  9003. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9004. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9005. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9006. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9007. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9008. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9009. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9010. array_push ( $collectArray ['其他'], $collectHtml );
  9011. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9012. array_push ( $adjustment, $collectHtml );
  9013. // total price html
  9014. $collectHtml = "";
  9015. $total = 0;
  9016. for($i = 1; $i <= 12; $i ++) {
  9017. $sumPrice = 0;
  9018. foreach ( $receiptCollectList as $key => $value ) {
  9019. if ($value ['month'] == $i) {
  9020. $sumPrice += $value ['price'];
  9021. }
  9022. }
  9023. if ($sumPrice == 0)
  9024. $collectHtml .= '<td class="taR">-</td>';
  9025. else
  9026. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9027. $total += $sumPrice;
  9028. }
  9029. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9030. // statistics html
  9031. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9032. if (empty ( $stList ))
  9033. $stList = array (
  9034. 'rePrice' => 0,
  9035. 'agPrice' => 0
  9036. );
  9037. $data ['stList'] = array (
  9038. 'rePrice' => $stList ['rePrice'],
  9039. 'agPrice' => $stList ['agPrice'],
  9040. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9041. );
  9042. $data ['collectArray'] = $collectArray;
  9043. $data ['adjustment'] = $adjustment;
  9044. $data ['totalPrice'] = $collectHtml;
  9045. $data ['totalYear'] = $total;
  9046. $data ['year'] = $year;
  9047. $dateHtml = "";
  9048. $now = date ( "Y" );
  9049. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9050. if ($YEARD <= $now) {
  9051. $dateHtml .= '<option ';
  9052. if ($year == $YEARD) {
  9053. $dateHtml .= 'selected ';
  9054. }
  9055. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9056. }
  9057. }
  9058. $data ['dateHtml'] = $dateHtml;
  9059. $data ['memu'] = "receipt";
  9060. $data ['staff'] = $this->staff;
  9061. $data ['receiptMemu'] = 'personalCollect';
  9062. $data ['verifyId'] = $this->verifyId;
  9063. $data ['executeId'] = $this->executeId;
  9064. // year staff status 2,4
  9065. if ($year < date ( "Y" )) {
  9066. Doo::loadModel ( 'receipt' );
  9067. $receipt = new receipt ();
  9068. $receiptList = $receipt->find ( array (
  9069. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9070. 'asArray' => true
  9071. ) );
  9072. if (empty ( $receiptList )) {
  9073. ob_start ();
  9074. $this->render ( "/admin/saeaCollectArticles", $data );
  9075. $this->cacheFile ( $path );
  9076. die ();
  9077. }
  9078. }
  9079. $this->render ( "/admin/saeaCollectArticles", $data );
  9080. }
  9081. function companyCategoryCollect() {
  9082. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9083. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  9084. $this->showCache ( $path );
  9085. Doo::loadModel ( 'L_category' );
  9086. Doo::loadModel ( 'itemStatistics' );
  9087. Doo::loadModel ( 'statistics' );
  9088. $statistics = new statistics ();
  9089. $Lcategory = new L_category ();
  9090. $itemStatistics = new itemStatistics ();
  9091. Doo::loadModel ( "receiptAuthorityManage" );
  9092. $receiptAuthorityManage = new receiptAuthorityManage ();
  9093. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9094. $cidList = array ();
  9095. foreach ( $imcStaff as $key => $value ) {
  9096. array_push ( $cidList, $value ['cid'] );
  9097. }
  9098. $cidString = implode ( ',', $cidList );
  9099. $LcategoryList = $Lcategory->find ( array (
  9100. 'where' => ' cid in (' . $cidString . ')',
  9101. 'asArray' => true
  9102. ) ); // 'staff='.$this->staff[0]['sid']." and
  9103. $itemStatisticsList = $itemStatistics->find ( array (
  9104. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9105. 'where' => " Year(date)=" . $year,
  9106. 'groupby' => 'cid,Month(date)',
  9107. 'asArray' => true
  9108. ) );
  9109. // ceatre companyCollectHtml
  9110. foreach ( $LcategoryList as $value ) {
  9111. $html = "";
  9112. $asum = 0;
  9113. for($i = 1; $i <= 12; $i ++) {
  9114. $falg = true;
  9115. foreach ( $itemStatisticsList as $v ) {
  9116. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  9117. $asum += $v ['price'];
  9118. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9119. $falg = false;
  9120. break;
  9121. }
  9122. }
  9123. if ($falg)
  9124. $html .= '<td class="taR">-</td>';
  9125. }
  9126. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9127. $collectHtml [$value ['title']] = array (
  9128. 'html' => $html,
  9129. 'cid' => $value ['cid']
  9130. );
  9131. }
  9132. $data ['companyHtml'] = $collectHtml;
  9133. // total price html
  9134. $collectHtml = "";
  9135. $total = 0;
  9136. for($i = 1; $i <= 12; $i ++) {
  9137. $sumPrice = 0;
  9138. foreach ( $itemStatisticsList as $key => $value ) {
  9139. if ($value ['month'] == $i) {
  9140. $sumPrice += $value ['price'];
  9141. }
  9142. }
  9143. if ($sumPrice == 0)
  9144. $collectHtml .= '<td class="taR">-</td>';
  9145. else
  9146. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9147. $total += $sumPrice;
  9148. }
  9149. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9150. $data ['companyTotalHtml'] = $collectHtml;
  9151. $data ['total'] = $total;
  9152. // statistics html
  9153. // echo $cidString;
  9154. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9155. if (empty ( $stList ))
  9156. $stList = array (
  9157. 'rePrice' => 0,
  9158. 'agPrice' => 0
  9159. );
  9160. $data ['stList'] = array (
  9161. 'rePrice' => $stList ['rePrice'],
  9162. 'agPrice' => $stList ['agPrice'],
  9163. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9164. );
  9165. $data ['year'] = $year;
  9166. $data ['memu'] = "receipt";
  9167. $data ['staff'] = $this->staff;
  9168. $data ['receiptMemu'] = 'companyCategoryCollect';
  9169. $data ['verifyId'] = $this->verifyId;
  9170. $data ['executeId'] = $this->executeId;
  9171. $dateHtml = "";
  9172. $now = date ( "Y" );
  9173. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9174. if ($YEARD <= $now) {
  9175. $dateHtml .= '<option ';
  9176. if ($year == $YEARD) {
  9177. $dateHtml .= 'selected ';
  9178. }
  9179. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9180. }
  9181. }
  9182. $data ['dateHtml'] = $dateHtml;
  9183. // year staff status 2,4
  9184. if ($year < date ( "Y" )) {
  9185. Doo::loadModel ( 'receipt' );
  9186. $receipt = new receipt ();
  9187. $receiptList = $receipt->find ( array (
  9188. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  9189. 'asArray' => true
  9190. ) );
  9191. if (empty ( $receiptList )) {
  9192. ob_start ();
  9193. $this->render ( "/admin/saeaCompanyCollect", $data );
  9194. $this->cacheFile ( $path );
  9195. die ();
  9196. }
  9197. }
  9198. $this->render ( "/admin/saeaCompanyCollect", $data );
  9199. }
  9200. function categoryCollectDetail() {
  9201. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9202. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  9203. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  9204. $this->showCache ( $path );
  9205. Doo::loadModel ( 'statistics' );
  9206. $statistics = new statistics ();
  9207. Doo::loadModel ( "receiptDetail" );
  9208. $receiptDetail = new receiptDetail ();
  9209. Doo::loadModel ( 'L_category' );
  9210. $Lcategory = new L_category ();
  9211. Doo::loadModel ( 'accountItem' );
  9212. $accountItem = new accountItem ();
  9213. Doo::loadModel ( "receiptAuthorityManage" );
  9214. $receiptAuthorityManage = new receiptAuthorityManage ();
  9215. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9216. $cidList = array ();
  9217. foreach ( $imcStaff as $key => $value ) {
  9218. array_push ( $cidList, $value ['cid'] );
  9219. }
  9220. $cidString = implode ( ',', $cidList );
  9221. $LcategoryList = $Lcategory->find ( array (
  9222. 'where' => 'cid in (' . $cidString . ')',
  9223. 'asArray' => true
  9224. ) );
  9225. if ($cid == 0) {
  9226. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9227. if ($cid == 0)
  9228. $cid = $LcategoryList [0] ['cid'];
  9229. }
  9230. $data ['LcategoryList'] = $LcategoryList;
  9231. $receiptCollectList = $receiptDetail->find ( array (
  9232. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9233. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9234. 'groupby' => 'item,Month(pastDate)',
  9235. 'asArray' => true
  9236. ) );
  9237. $accountList = $accountItem->find ( array (
  9238. 'asArray' => true
  9239. ) );
  9240. // create CollectDetail HTML
  9241. $collectHtml = array ();
  9242. foreach ( $accountList as $key => $value ) {
  9243. $html = "";
  9244. $asum = 0;
  9245. for($i = 1; $i <= 12; $i ++) {
  9246. $falg = true;
  9247. foreach ( $receiptCollectList as $v ) {
  9248. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9249. $asum += $v ['price'];
  9250. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9251. $falg = false;
  9252. break;
  9253. }
  9254. }
  9255. if ($falg)
  9256. $html .= '<td class="taR">-</td>';
  9257. }
  9258. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9259. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9260. }
  9261. $data ['collectHtml'] = $collectHtml;
  9262. // create Adjustment price html
  9263. $receiptCollectList = $receiptDetail->find ( array (
  9264. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9265. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9266. 'groupby' => 'itemCategory,Month(pastDate)',
  9267. 'asArray' => true
  9268. ) );
  9269. $adjustment = array ();
  9270. $collectArray = array (
  9271. '日常相关费用' => array (),
  9272. '差旅相关费用' => array (),
  9273. '培训班费用' => array (),
  9274. '其他' => array ()
  9275. );
  9276. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9277. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9278. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9279. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9280. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9281. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9282. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9283. array_push ( $collectArray ['其他'], $collectHtml );
  9284. $data ['collectArray'] = $collectArray;
  9285. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9286. array_push ( $adjustment, $collectHtml );
  9287. $data ['adjustment'] = $adjustment;
  9288. // total price html
  9289. $collectHtml = "";
  9290. $total = 0;
  9291. for($i = 1; $i <= 12; $i ++) {
  9292. $sumPrice = 0;
  9293. foreach ( $receiptCollectList as $key => $value ) {
  9294. if ($value ['month'] == $i) {
  9295. $sumPrice += $value ['price'];
  9296. }
  9297. }
  9298. if ($sumPrice == 0)
  9299. $collectHtml .= '<td class="taR">-</td>';
  9300. else
  9301. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9302. $total += $sumPrice;
  9303. }
  9304. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9305. // statistics html
  9306. $stList = $statistics->statisticsByCid ( $year, $cid );
  9307. if (empty ( $stList ))
  9308. $stList = array (
  9309. 'rePrice' => 0,
  9310. 'agPrice' => 0
  9311. );
  9312. $data ['stList'] = array (
  9313. 'rePrice' => $stList ['rePrice'],
  9314. 'agPrice' => $stList ['agPrice'],
  9315. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9316. );
  9317. $data ['totalYear'] = $total;
  9318. $data ['year'] = $year;
  9319. $data ['cid'] = $cid;
  9320. $data ['memu'] = "receipt";
  9321. $data ['staff'] = $this->staff;
  9322. $data ['receiptMemu'] = 'companyCategoryCollect';
  9323. $data ['verifyId'] = $this->verifyId;
  9324. $data ['executeId'] = $this->executeId;
  9325. // year staff status 2,4
  9326. if ($year < date ( "Y" )) {
  9327. Doo::loadModel ( 'receipt' );
  9328. $receipt = new receipt ();
  9329. $receiptList = $receipt->find ( array (
  9330. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  9331. 'asArray' => true
  9332. ) );
  9333. if (empty ( $receiptList )) {
  9334. ob_start ();
  9335. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  9336. $this->cacheFile ( $path );
  9337. die ();
  9338. }
  9339. }
  9340. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  9341. }
  9342. function staffCollect() {
  9343. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9344. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  9345. // $this->showCache($path);
  9346. Doo::loadModel ( 'statistics' );
  9347. $statistics = new statistics ();
  9348. Doo::loadModel ( "receiptDetail" );
  9349. $receiptDetail = new receiptDetail ();
  9350. Doo::loadModel ( 'L_category' );
  9351. $Lcategory = new L_category ();
  9352. Doo::loadModel ( 'accountItem' );
  9353. $accountItem = new accountItem ();
  9354. Doo::loadModel ( 'staff' );
  9355. $staff = new staff ();
  9356. Doo::loadModel ( 'itemStatistics' );
  9357. $itemStatistics = new itemStatistics ();
  9358. Doo::loadModel ( "receiptAuthorityManage" );
  9359. $receiptAuthorityManage = new receiptAuthorityManage ();
  9360. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9361. $cidList = array ();
  9362. foreach ( $imcStaff as $key => $value ) {
  9363. array_push ( $cidList, $value ['cid'] );
  9364. }
  9365. $cidString = implode ( ',', $cidList );
  9366. // statistics html
  9367. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9368. if (empty ( $stList ))
  9369. $stList = array (
  9370. 'rePrice' => 0,
  9371. 'agPrice' => 0
  9372. );
  9373. $data ['stList'] = array (
  9374. 'rePrice' => $stList ['rePrice'],
  9375. 'agPrice' => $stList ['agPrice'],
  9376. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9377. );
  9378. // ---
  9379. $staffList = $staff->find ( array (
  9380. 'where' => 'username !="admin"',
  9381. 'asArray' => true
  9382. ) );
  9383. $LcategoryList = $Lcategory->find ( array (
  9384. 'asArray' => true
  9385. ) ); // 'staff='.$this->staff[0]['sid']." and
  9386. $itemStatisticsList = $itemStatistics->find ( array (
  9387. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9388. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  9389. 'groupby' => 'staff,Month(date)',
  9390. 'asArray' => true
  9391. ) );
  9392. $categoryList = $staff->find ( array (
  9393. 'select' => 'COUNT(*) as count,cid,category',
  9394. 'where' => 'username !="admin" and cid in (' . $cidString . ')',
  9395. 'groupby' => 'cid',
  9396. 'asArray' => true
  9397. ) );
  9398. // print_r($itemStatisticsList);die;
  9399. // ceatre companyCollectHtml
  9400. foreach ( $categoryList as $vlu ) {
  9401. $count = $vlu ['count'] + 1;
  9402. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  9403. $m1 = 0;
  9404. $m2 = 0;
  9405. $m3 = 0;
  9406. $m4 = 0;
  9407. $m5 = 0;
  9408. $m6 = 0;
  9409. $m7 = 0;
  9410. $m8 = 0;
  9411. $m9 = 0;
  9412. $m10 = 0;
  9413. $m11 = 0;
  9414. $m12 = 0;
  9415. $m13 = 0;
  9416. foreach ( $staffList as $value ) {
  9417. if ($vlu ['cid'] == $value ['cid']) {
  9418. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  9419. $asum = 0;
  9420. for($i = 1; $i <= 12; $i ++) {
  9421. $falg = true;
  9422. foreach ( $itemStatisticsList as $v ) {
  9423. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  9424. if ($v ['month'] == 1)
  9425. $m1 += $v ['price'];
  9426. if ($v ['month'] == 2)
  9427. $m2 += $v ['price'];
  9428. if ($v ['month'] == 3)
  9429. $m3 += $v ['price'];
  9430. if ($v ['month'] == 4)
  9431. $m4 += $v ['price'];
  9432. if ($v ['month'] == 5)
  9433. $m5 += $v ['price'];
  9434. if ($v ['month'] == 6)
  9435. $m6 += $v ['price'];
  9436. if ($v ['month'] == 7)
  9437. $m7 += $v ['price'];
  9438. if ($v ['month'] == 8)
  9439. $m8 += $v ['price'];
  9440. if ($v ['month'] == 9)
  9441. $m9 += $v ['price'];
  9442. if ($v ['month'] == 10)
  9443. $m10 += $v ['price'];
  9444. if ($v ['month'] == 11)
  9445. $m11 += $v ['price'];
  9446. if ($v ['month'] == 12)
  9447. $m12 += $v ['price'];
  9448. $asum += $v ['price'];
  9449. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9450. $falg = false;
  9451. break;
  9452. }
  9453. }
  9454. if ($falg)
  9455. $html .= '<td class="taR">-</td>';
  9456. }
  9457. $m13 += $asum;
  9458. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9459. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  9460. 'html' => $html,
  9461. 'sid' => $value ['sid']
  9462. );
  9463. $html = "";
  9464. }
  9465. }
  9466. $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>
  9467. <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>
  9468. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  9469. $collectHtml [$vlu ['cid']] = array (
  9470. 'html' => $hl,
  9471. 'sid' => ''
  9472. );
  9473. }
  9474. $data ['companyHtml'] = $collectHtml;
  9475. // total price html
  9476. $collectHtml = "";
  9477. $total = 0;
  9478. for($i = 1; $i <= 12; $i ++) {
  9479. $sumPrice = 0;
  9480. foreach ( $itemStatisticsList as $key => $value ) {
  9481. if ($value ['month'] == $i) {
  9482. $sumPrice += $value ['price'];
  9483. }
  9484. }
  9485. if ($sumPrice == 0)
  9486. $collectHtml .= '<td class="taR">-</td>';
  9487. else
  9488. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9489. $total += $sumPrice;
  9490. }
  9491. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9492. $data ['companyTotalHtml'] = $collectHtml;
  9493. $data ['total'] = $total;
  9494. $data ['year'] = $year;
  9495. $data ['memu'] = "receipt";
  9496. $data ['staff'] = $this->staff;
  9497. $data ['receiptMemu'] = 'companyCategoryCollect';
  9498. $data ['verifyId'] = $this->verifyId;
  9499. $data ['executeId'] = $this->executeId;
  9500. if ($year <= date ( "Y" )) {
  9501. Doo::loadModel ( 'receipt' );
  9502. $receipt = new receipt ();
  9503. $receiptList = $receipt->find ( array (
  9504. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  9505. 'asArray' => true
  9506. ) );
  9507. if (empty ( $receiptList )) { // generated files
  9508. ob_start ();
  9509. $this->render ( "/admin/saeaStaffCollectB", $data );
  9510. $this->cacheFile ( $path );
  9511. die ();
  9512. }
  9513. }
  9514. $this->render ( "/admin/saeaStaffCollectB", $data );
  9515. }
  9516. function staffCollectBak() {
  9517. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9518. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  9519. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  9520. $this->showCache ( $path );
  9521. Doo::loadModel ( 'statistics' );
  9522. $statistics = new statistics ();
  9523. Doo::loadModel ( "receiptDetail" );
  9524. $receiptDetail = new receiptDetail ();
  9525. Doo::loadModel ( 'L_category' );
  9526. $Lcategory = new L_category ();
  9527. Doo::loadModel ( 'accountItem' );
  9528. $accountItem = new accountItem ();
  9529. Doo::loadModel ( 'staff' );
  9530. $staff = new staff ();
  9531. Doo::loadModel ( 'itemStatistics' );
  9532. $itemStatistics = new itemStatistics ();
  9533. $itemStatisticsList = $itemStatistics->find ( array (
  9534. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9535. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9536. 'groupby' => 'staff,itemCategory,Month(date)',
  9537. 'asArray' => true
  9538. ) );
  9539. $itemCategoryList = $itemStatistics->find ( array (
  9540. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9541. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9542. 'groupby' => 'cid,itemCategory,Month(date)',
  9543. 'asArray' => true
  9544. ) );
  9545. $LcategoryList = $Lcategory->find ( array (
  9546. 'asArray' => true
  9547. ) );
  9548. $staffList = $staff->find ( array (
  9549. 'asArray' => true
  9550. ) );
  9551. $htmlArray = array ();
  9552. foreach ( $LcategoryList as $value ) {
  9553. $htmlArray [$value ['title']] = array ();
  9554. foreach ( $staffList as $v ) {
  9555. if ($value ['cid'] == $v ['cid']) {
  9556. $html = "";
  9557. $falg = true;
  9558. $staffSumPrice = 0;
  9559. foreach ( $itemStatisticsList as $a ) {
  9560. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  9561. if (empty ( $a ['price'] )) {
  9562. $html .= '<td class="taR">-</td>';
  9563. $falg = false;
  9564. break;
  9565. } else {
  9566. $staffSumPrice += $a ['price'];
  9567. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9568. $falg = false;
  9569. break;
  9570. }
  9571. }
  9572. }
  9573. if ($falg) {
  9574. $html .= '<td class="taR">-</td>';
  9575. $falg = true;
  9576. }
  9577. $falg = true;
  9578. foreach ( $itemStatisticsList as $a ) {
  9579. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  9580. if (empty ( $a ['price'] )) {
  9581. $html .= '<td class="taR">-</td>';
  9582. $falg = false;
  9583. break;
  9584. } else {
  9585. $staffSumPrice += $a ['price'];
  9586. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9587. $falg = false;
  9588. break;
  9589. }
  9590. }
  9591. }
  9592. if ($falg) {
  9593. $html .= '<td class="taR">-</td>';
  9594. $falg = true;
  9595. }
  9596. $falg = true;
  9597. foreach ( $itemStatisticsList as $a ) {
  9598. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  9599. if (empty ( $a ['price'] )) {
  9600. $html .= '<td class="taR">-</td>';
  9601. $falg = false;
  9602. break;
  9603. } else {
  9604. $staffSumPrice += $a ['price'];
  9605. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9606. $falg = false;
  9607. break;
  9608. }
  9609. }
  9610. }
  9611. if ($falg) {
  9612. $html .= '<td class="taR">-</td>';
  9613. $falg = true;
  9614. }
  9615. $falg = true;
  9616. foreach ( $itemStatisticsList as $a ) {
  9617. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  9618. if (! empty ( $a ['price'] )) {
  9619. $staffSumPrice += $a ['price'];
  9620. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9621. $falg = false;
  9622. break;
  9623. } else {
  9624. $html .= '<td class="taR">-</td>';
  9625. $falg = false;
  9626. break;
  9627. }
  9628. }
  9629. }
  9630. if ($falg) {
  9631. $html .= '<td class="taR">-</td>';
  9632. $falg = true;
  9633. }
  9634. $falg = true;
  9635. foreach ( $itemStatisticsList as $a ) {
  9636. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  9637. if (! empty ( $a ['price'] )) {
  9638. $staffSumPrice += $a ['price'];
  9639. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9640. $falg = false;
  9641. break;
  9642. } else {
  9643. $html .= '<td class="taR">-</td>';
  9644. $falg = false;
  9645. break;
  9646. }
  9647. }
  9648. }
  9649. if ($falg) {
  9650. $html .= '<td class="taR">-</td>';
  9651. $falg = true;
  9652. }
  9653. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  9654. $htmlArray [$value ['title']] [$v ['username']] = $html;
  9655. }
  9656. }
  9657. /* -- --- */
  9658. // 合计费用
  9659. $cateHtml = "";
  9660. $catePrice = 0;
  9661. $cateFalg = true;
  9662. foreach ( $itemCategoryList as $l ) {
  9663. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  9664. if (empty ( $l ['price'] )) {
  9665. $cateHtml .= '<td class="colGreen taR">-</td>';
  9666. $cateFalg = false;
  9667. break;
  9668. } else {
  9669. $catePrice += $l ['price'];
  9670. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9671. $cateFalg = false;
  9672. break;
  9673. }
  9674. }
  9675. }
  9676. if ($cateFalg) {
  9677. $cateHtml .= '<td class="colGreen taR">-</td>';
  9678. $cateFalg = true;
  9679. }
  9680. $cateFalg = true;
  9681. foreach ( $itemCategoryList as $l ) {
  9682. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  9683. if (empty ( $l ['price'] )) {
  9684. $cateHtml .= '<td class="colGreen taR">-</td>';
  9685. $cateFalg = false;
  9686. break;
  9687. } else {
  9688. $catePrice += $l ['price'];
  9689. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9690. $cateFalg = false;
  9691. break;
  9692. }
  9693. }
  9694. }
  9695. if ($cateFalg) {
  9696. $cateHtml .= '<td class="colGreen taR">-</td>';
  9697. $cateFalg = true;
  9698. }
  9699. $cateFalg = true;
  9700. foreach ( $itemCategoryList as $l ) {
  9701. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  9702. if (empty ( $l ['price'] )) {
  9703. $cateHtml .= '<td class="colGreen taR">-</td>';
  9704. $cateFalg = false;
  9705. break;
  9706. } else {
  9707. $catePrice += $l ['price'];
  9708. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9709. $cateFalg = false;
  9710. break;
  9711. }
  9712. }
  9713. }
  9714. if ($cateFalg) {
  9715. $cateHtml .= '<td class="colGreen taR">-</td>';
  9716. $cateFalg = true;
  9717. }
  9718. $cateFalg = true;
  9719. foreach ( $itemCategoryList as $l ) {
  9720. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  9721. if (empty ( $l ['price'] )) {
  9722. $cateHtml .= '<td class="colGreen taR">-</td>';
  9723. $cateFalg = false;
  9724. break;
  9725. } else {
  9726. $catePrice += $l ['price'];
  9727. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9728. $cateFalg = false;
  9729. break;
  9730. }
  9731. }
  9732. }
  9733. if ($cateFalg) {
  9734. $cateHtml .= '<td class="colGreen taR">-</td>';
  9735. $cateFalg = true;
  9736. }
  9737. $cateFalg = true;
  9738. foreach ( $itemCategoryList as $l ) {
  9739. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  9740. if (empty ( $l ['price'] )) {
  9741. $cateHtml .= '<td class="colGreen taR">-</td>';
  9742. $cateFalg = false;
  9743. break;
  9744. } else {
  9745. $catePrice += $l ['price'];
  9746. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9747. $cateFalg = false;
  9748. break;
  9749. }
  9750. }
  9751. }
  9752. if ($cateFalg) {
  9753. $cateHtml .= '<td class="colGreen taR">-</td>';
  9754. $cateFalg = true;
  9755. }
  9756. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  9757. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  9758. /* -- --- */
  9759. }
  9760. // print_r($htmlArray);die;
  9761. $data ['htmlArray'] = $htmlArray;
  9762. // statistics html
  9763. $stList = $statistics->getOne ( array (
  9764. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9765. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9766. 'groupby' => 'Month(date)',
  9767. 'asArray' => true
  9768. ) );
  9769. if (empty ( $stList ))
  9770. $stList = array (
  9771. 'rePrice' => 0,
  9772. 'agPrice' => 0
  9773. );
  9774. $data ['stList'] = array (
  9775. 'rePrice' => $stList ['rePrice'],
  9776. 'agPrice' => $stList ['agPrice'],
  9777. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9778. );
  9779. $monthHtml = "";
  9780. for($i = 1; $i <= 12; $i ++) {
  9781. if ($i == $month)
  9782. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9783. else
  9784. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9785. }
  9786. $data ['monthHtml'] = $monthHtml;
  9787. $data ['year'] = $year;
  9788. $data ['month'] = $month;
  9789. $data ['memu'] = "receipt";
  9790. $data ['staff'] = $this->staff;
  9791. $data ['receiptMemu'] = 'companyCategoryCollect';
  9792. $data ['verifyId'] = $this->verifyId;
  9793. $data ['executeId'] = $this->executeId;
  9794. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  9795. Doo::loadModel ( 'receipt' );
  9796. $receipt = new receipt ();
  9797. $receiptList = $receipt->find ( array (
  9798. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  9799. 'asArray' => true
  9800. ) );
  9801. if (empty ( $receiptList )) { // generated files
  9802. ob_start ();
  9803. $this->render ( "/admin/saeaStaffCollect", $data );
  9804. $this->cacheFile ( $path );
  9805. die ();
  9806. }
  9807. }
  9808. $this->render ( "/admin/saeaStaffCollect", $data );
  9809. }
  9810. /**
  9811. * 日常收支
  9812. */
  9813. function payments() {
  9814. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  9815. Doo::loadModel ( "execute" );
  9816. $execute = new execute ();
  9817. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  9818. die ( 'illegal request' );
  9819. }
  9820. Doo::loadModel ( "accountBook" );
  9821. $accountBook = new accountBook ();
  9822. Doo::loadModel ( "accountBookStatistics" );
  9823. $accountBookStatistics = new accountBookStatistics ();
  9824. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  9825. $list = $accountBook->getAccountBookByLimit ( 10 );
  9826. $data ['date'] = date ( "Y-m-d" );
  9827. $data ['statisticsList'] = $statisticsList;
  9828. $data ['list'] = $list;
  9829. $data ['memu'] = "receipt";
  9830. $data ['staff'] = $this->staff;
  9831. $data ['receiptMemu'] = 'payments';
  9832. $data ['verifyId'] = $this->verifyId;
  9833. $data ['executeId'] = $this->executeId;
  9834. $this->render ( "/expenses/payments", $data );
  9835. }
  9836. function paymentsIncomeDo() {
  9837. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  9838. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  9839. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  9840. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  9841. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  9842. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  9843. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  9844. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  9845. Doo::loadClass ( 'XDeode' );
  9846. $XDeode = new XDeode ( 5 );
  9847. Doo::loadModel ( "accountBook" );
  9848. Doo::loadModel ( "accountBookStatistics" );
  9849. Doo::loadModel ( 'wasteBook' );
  9850. // 记录流水时银行的转换
  9851. $accountBank = '';
  9852. if ($receivedBank == '纵横广发') {
  9853. $accountBank = 'CGBDeposit';
  9854. } elseif ($receivedBank == '纵横工行') {
  9855. $accountBank = 'ICBCDeposit';
  9856. } elseif ($receivedBank == '华润银行') {
  9857. $accountBank = 'HUADeposit';
  9858. } elseif ($receivedBank == '个人广发') {
  9859. $accountBank = 'PersonalDeposit';
  9860. }
  9861. if (empty ( $accountBank ))
  9862. die ( 'illegal request' );
  9863. // 收入为理财时特殊处理
  9864. if ($accountType == 7 || $accountType == 9) {
  9865. if ($receivedBank == '个人广发') {
  9866. die ( '个人广发 illegal request' );
  9867. }
  9868. // 添加一条收入
  9869. $accountBook = new accountBook ();
  9870. $accountBook->accountType = 10;
  9871. $accountBook->accountMsg = $accountMsg;
  9872. $accountBook->receivedPrice = $receivedPrice;
  9873. $accountBook->receivedMsg = $receivedMsg;
  9874. $accountBook->receivedBank = $receivedBank;
  9875. $accountBook->receivedDate = $receivedDate;
  9876. $accountBook->remarks = $remarks;
  9877. $accountBook->expensesType = 1;
  9878. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9879. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9880. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9881. $inComeId = $accountBook->insert ();
  9882. // 收支汇总-添加一条收入日常汇总
  9883. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  9884. $accountBookStatistics = new accountBookStatistics ();
  9885. $item = array (
  9886. 'date' => date ( "Y-m-d" ),
  9887. 'accountType' => $abDetail ['accountType'],
  9888. 'accountMsg' => $abDetail ['accountMsg'],
  9889. 'aid' => $abDetail ['aid'],
  9890. 'inComePrice' => $abDetail ['receivedPrice'],
  9891. 'expensesType' => $abDetail ['expensesType']
  9892. );
  9893. $accountBookStatistics->setAccountBookStatistics ( $item );
  9894. // 添加收入流水
  9895. $wasteBook = new wasteBook ();
  9896. $itemWaste = array (
  9897. 'accountPriceShow' => $receivedPrice,
  9898. 'accountPrice' => $receivedPrice,
  9899. 'expensesType' => 1,
  9900. 'accountType' => 6, // 流水类型
  9901. 'dataID' => $inComeId,
  9902. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  9903. 'accountBank' => $accountBank,
  9904. 'category' => $this->staff [0] ['category'],
  9905. 'cid' => $this->staff [0] ['cid'],
  9906. 'name' => $this->staff [0] ['username'],
  9907. 'sid' => $this->staff [0] ['sid'],
  9908. 'inputDate' => date ( "Y-m-d H:i:s" )
  9909. );
  9910. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9911. // 添加一条理财支出
  9912. $accountBank = 'CGBDeposit';
  9913. $expenditureBank = '纵横广发';
  9914. $dailyExpenditureType = 4;
  9915. if ($accountType == 9) {
  9916. $accountBank = 'ICBCDeposit';
  9917. $expenditureBank = '纵横工行';
  9918. $dailyExpenditureType = 6;
  9919. }
  9920. $accountBook = new accountBook ();
  9921. $accountBook->expensesType = 2;
  9922. $accountBook->expenditureType = $dailyExpenditureType;
  9923. $accountBook->expenditureMsg = $accountMsg;
  9924. $accountBook->expenditurePrice = $receivedPrice;
  9925. $accountBook->expenditureBank = $expenditureBank;
  9926. $accountBook->expenditureDate = $receivedDate;
  9927. $accountBook->remarks = $remarks;
  9928. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9929. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9930. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9931. $id = $accountBook->insert ();
  9932. // 收支汇总-添加一条理财支出汇总
  9933. $abDetail = $accountBook->getAccountBookByAid ( $id );
  9934. $accountBookStatistics = new accountBookStatistics ();
  9935. $item = array (
  9936. 'date' => date ( "Y-m-d" ),
  9937. 'accountType' => $abDetail ['accountType'],
  9938. 'accountMsg' => $abDetail ['accountMsg'],
  9939. 'aid' => $abDetail ['aid'],
  9940. 'financingPrice' => - $receivedPrice,
  9941. 'expensesType' => 3
  9942. );
  9943. $accountBookStatistics->setAccountBookStatistics ( $item );
  9944. // 添加一条支出理财流水
  9945. $accountTypeWaste = 5;
  9946. if ($accountMsg == '公司固定') {
  9947. $accountTypeWaste = 9;
  9948. } elseif ($accountMsg == '公司活期') {
  9949. $accountTypeWaste = 10;
  9950. } elseif ($accountMsg == '个人(GR)') {
  9951. $accountBank = 'PersonalDeposit';
  9952. }
  9953. $itemWaste = array (
  9954. 'expensesType' => 2,
  9955. 'accountType' => $accountTypeWaste,
  9956. 'accountPriceShow' => $receivedPrice,
  9957. 'accountPrice' => - $receivedPrice,
  9958. 'dataID' => $id,
  9959. 'dailyExpenditureType' => $dailyExpenditureType,
  9960. 'accountBank' => $accountBank,
  9961. 'category' => $this->staff [0] ['category'],
  9962. 'cid' => $this->staff [0] ['cid'],
  9963. 'name' => $this->staff [0] ['username'],
  9964. 'sid' => $this->staff [0] ['sid'],
  9965. 'inputDate' => date ( "Y-m-d H:i:s" )
  9966. );
  9967. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9968. } elseif ($accountType == 1) {
  9969. if ($receivedBank == '个人广发')
  9970. die ( 'illegal request' );
  9971. // 添加一条收入
  9972. $accountBook = new accountBook ();
  9973. $accountBook->accountType = $accountType;
  9974. $accountBook->accountMsg = $accountMsg;
  9975. $accountBook->receivedPrice = $receivedPrice;
  9976. $accountBook->receivedMsg = $receivedMsg;
  9977. $accountBook->receivedBank = $receivedBank;
  9978. $accountBook->receivedDate = $receivedDate;
  9979. $accountBook->remarks = $remarks;
  9980. $accountBook->expensesType = 1;
  9981. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9982. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9983. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9984. $id = $accountBook->insert ();
  9985. $abDetail = $accountBook->getAccountBookByAid ( $id );
  9986. // 收支汇总-添加一条收入日常汇总
  9987. $accountBookStatistics = new accountBookStatistics ();
  9988. $item = array (
  9989. 'date' => date ( "Y-m-d" ),
  9990. 'accountType' => $abDetail ['accountType'],
  9991. 'accountMsg' => $abDetail ['accountMsg'],
  9992. 'aid' => $abDetail ['aid'],
  9993. 'expensesType' => $abDetail ['expensesType']
  9994. );
  9995. if ($abDetail ['accountType'] == 8) {
  9996. $item += array (
  9997. 'inComePrice' => $abDetail ['receivedPrice']
  9998. );
  9999. } else {
  10000. $item += array (
  10001. 'inComePrice' => $abDetail ['receivedPrice']
  10002. );
  10003. }
  10004. $accountBookStatistics->setAccountBookStatistics ( $item );
  10005. // 流水存储方向
  10006. $itemWaste = array (
  10007. 'accountType' => 6
  10008. ); // 流水类型
  10009. // if($accountMsg=='银行存款'||$accountMsg=='固定理财收益'){
  10010. // }else
  10011. if ($accountMsg == '活期理财收益') {
  10012. $itemWaste = array (
  10013. 'accountType' => 10
  10014. ); // 流水类型
  10015. }
  10016. // 添加收入流水
  10017. $wasteBook = new wasteBook ();
  10018. $itemWaste += array (
  10019. 'accountPrice' => $receivedPrice,
  10020. 'accountPriceShow' => $receivedPrice,
  10021. 'expensesType' => 1,
  10022. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10023. 'dataID' => $id,
  10024. 'accountBank' => $accountBank,
  10025. 'category' => $this->staff [0] ['category'],
  10026. 'cid' => $this->staff [0] ['cid'],
  10027. 'name' => $this->staff [0] ['username'],
  10028. 'sid' => $this->staff [0] ['sid'],
  10029. 'inputDate' => date ( "Y-m-d H:i:s" )
  10030. );
  10031. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10032. } else { // 普通日常收入处理
  10033. // 添加一条收入
  10034. $accountBook = new accountBook ();
  10035. $accountBook->accountType = $accountType;
  10036. $accountBook->accountMsg = $accountMsg;
  10037. $accountBook->receivedPrice = $receivedPrice;
  10038. $accountBook->receivedMsg = $receivedMsg;
  10039. $accountBook->receivedBank = $receivedBank;
  10040. $accountBook->receivedDate = $receivedDate;
  10041. $accountBook->remarks = $remarks;
  10042. $accountBook->expensesType = 1;
  10043. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10044. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10045. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10046. $id = $accountBook->insert ();
  10047. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10048. // 收支汇总-添加一条收入日常汇总
  10049. $accountBookStatistics = new accountBookStatistics ();
  10050. $item = array (
  10051. 'date' => date ( "Y-m-d" ),
  10052. 'accountType' => $abDetail ['accountType'],
  10053. 'accountMsg' => $abDetail ['accountMsg'],
  10054. 'aid' => $abDetail ['aid'],
  10055. 'expensesType' => $abDetail ['expensesType']
  10056. );
  10057. if ($abDetail ['accountType'] == 8) {
  10058. $item += array (
  10059. 'inComePrice' => $abDetail ['receivedPrice']
  10060. );
  10061. } else {
  10062. $item += array (
  10063. 'inComePrice' => $abDetail ['receivedPrice']
  10064. );
  10065. }
  10066. $accountBookStatistics->setAccountBookStatistics ( $item );
  10067. // 添加收入流水
  10068. $itemWaste = array (
  10069. 'accountPrice' => $receivedPrice
  10070. );
  10071. if ($receivedBank == '个人广发') {
  10072. $itemWaste = array (
  10073. 'accountPrice' => - $receivedPrice
  10074. );
  10075. }
  10076. $wasteBook = new wasteBook ();
  10077. $itemWaste += array (
  10078. 'accountPriceShow' => $receivedPrice,
  10079. 'expensesType' => 1,
  10080. 'accountType' => 6, // 流水类型
  10081. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10082. 'dataID' => $id,
  10083. 'accountBank' => $accountBank,
  10084. 'category' => $this->staff [0] ['category'],
  10085. 'cid' => $this->staff [0] ['cid'],
  10086. 'name' => $this->staff [0] ['username'],
  10087. 'sid' => $this->staff [0] ['sid'],
  10088. 'inputDate' => date ( "Y-m-d H:i:s" )
  10089. );
  10090. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10091. }
  10092. }
  10093. return '/payments';
  10094. }
  10095. /**
  10096. * 添加收入
  10097. * @return string
  10098. */
  10099. function paymentsIncomeDo_() {
  10100. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10101. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10102. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10103. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10104. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10105. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10106. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10107. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10108. Doo::loadClass ( 'XDeode' );
  10109. $XDeode = new XDeode ( 5 );
  10110. Doo::loadModel ( "accountBook" );
  10111. $accountBook = new accountBook ();
  10112. $accountBank = '';
  10113. $accountTypeWaste = 6;
  10114. if ($receivedBank == '纵横广发') {
  10115. $accountBank = 'CGBDeposit';
  10116. } elseif ($receivedBank == '纵横工行') {
  10117. $accountBank = 'ICBCDeposit';
  10118. } elseif ($receivedBank == '华润银行') {
  10119. $accountBank = 'HUADeposit';
  10120. } elseif ($receivedBank == '个人广发') {
  10121. $accountBank = 'PersonalDeposit';
  10122. }
  10123. if (empty ( $accountBank ))
  10124. die ( 'illegal request' );
  10125. $dailyIncomeType = '';
  10126. $itemWaste = array (
  10127. 'accountPrice' => $receivedPrice,
  10128. 'expensesType' => 1
  10129. );
  10130. if ($receivedBank == '个人广发') {
  10131. $itemWaste = array (
  10132. 'accountPrice' => - $receivedPrice,
  10133. 'expensesType' => 1
  10134. );
  10135. }
  10136. if ($accountType == 4) {
  10137. $dailyIncomeType = 4;
  10138. } elseif ($accountType == 1) {
  10139. $dailyIncomeType = 1;
  10140. } elseif ($accountType == 2) {
  10141. $dailyIncomeType = 2;
  10142. } elseif ($accountType == 3) {
  10143. $dailyIncomeType = 3;
  10144. } elseif ($accountType == 5) {
  10145. $dailyIncomeType = 5;
  10146. } elseif ($accountType == 6) {
  10147. $dailyIncomeType = 6;
  10148. } elseif ($accountType == 7 || $accountType == 9) {
  10149. $dailyIncomeType = 7;
  10150. if ($accountMsg == '公司固定') {
  10151. $accountTypeWaste = 9;
  10152. } elseif ($accountMsg == '公司活期') {
  10153. $accountTypeWaste = 10;
  10154. } elseif ($accountMsg == '个人(GR)') {
  10155. $accountBank = 'PersonalDeposit';
  10156. }
  10157. $itemWaste = array (
  10158. 'accountPrice' => - $receivedPrice,
  10159. 'expensesType' => 2
  10160. );
  10161. } elseif ($accountType == 8) {
  10162. $dailyIncomeType = 8;
  10163. }
  10164. if (empty ( $dailyIncomeType ))
  10165. die ( 'illegal request' );
  10166. $accountBook->accountType = $accountType;
  10167. $accountBook->accountMsg = $accountMsg;
  10168. $accountBook->receivedPrice = $receivedPrice;
  10169. $accountBook->receivedMsg = $receivedMsg;
  10170. $accountBook->receivedBank = $receivedBank;
  10171. $accountBook->receivedDate = $receivedDate;
  10172. $accountBook->remarks = $remarks;
  10173. $accountBook->expensesType = 1;
  10174. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10175. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10176. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10177. $id = $accountBook->insert ();
  10178. //
  10179. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10180. // 收支汇总
  10181. Doo::loadModel ( "accountBookStatistics" );
  10182. $accountBookStatistics = new accountBookStatistics ();
  10183. $item = array (
  10184. 'date' => date ( "Y-m-d" ),
  10185. 'accountType' => $abDetail ['accountType'],
  10186. 'accountMsg' => $abDetail ['accountMsg'],
  10187. 'aid' => $abDetail ['aid']
  10188. );
  10189. if ($abDetail ['expensesType'] == 1) {
  10190. if ($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) {
  10191. $item += array (
  10192. 'financingPrice' => - $receivedPrice,
  10193. 'expensesType' => 3
  10194. );
  10195. } else if ($abDetail ['accountType'] == 8) {
  10196. $item += array (
  10197. 'inComePrice' => - $abDetail ['receivedPrice'],
  10198. 'expensesType' => $abDetail ['expensesType']
  10199. );
  10200. } else {
  10201. $item += array (
  10202. 'inComePrice' => $abDetail ['receivedPrice'],
  10203. 'expensesType' => $abDetail ['expensesType']
  10204. );
  10205. }
  10206. }
  10207. $accountBookStatistics->setAccountBookStatistics ( $item );
  10208. // 为理财时需添加一条日常支出
  10209. if ($accountType == 7 || $accountType == 9) {
  10210. }
  10211. // 公司流水记录
  10212. Doo::loadModel ( 'wasteBook' );
  10213. $wasteBook = new wasteBook ();
  10214. // 银行
  10215. // if (empty($abDetail)){
  10216. $itemWaste += array (
  10217. 'accountPriceShow' => $receivedPrice,
  10218. 'dataID' => $id,
  10219. 'accountType' => $accountTypeWaste,
  10220. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10221. 'accountBank' => $accountBank,
  10222. 'category' => $this->staff [0] ['category'],
  10223. 'cid' => $this->staff [0] ['cid'],
  10224. 'name' => $this->staff [0] ['username'],
  10225. 'sid' => $this->staff [0] ['sid'],
  10226. 'inputDate' => date ( "Y-m-d H:i:s" )
  10227. );
  10228. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10229. // }
  10230. // 类型为理财7或者9 要添加一笔理财支出
  10231. if ($accountType == 7 || $accountType == 9) {
  10232. $accountBank = 'CGBDeposit';
  10233. $expenditureBank = '纵横广发';
  10234. $dailyExpenditureType = 4;
  10235. if ($accountType == 9) {
  10236. $accountBank = 'ICBCDeposit';
  10237. $expenditureBank = '纵横工行';
  10238. $dailyExpenditureType = 6;
  10239. }
  10240. // 添加一条支出
  10241. $accountBook = new accountBook ();
  10242. $accountBook->expenditureType = $dailyExpenditureType;
  10243. $accountBook->expenditureMsg = $accountMsg;
  10244. $accountBook->expenditurePrice = $receivedPrice;
  10245. $accountBook->expenditureBank = $expenditureBank;
  10246. $accountBook->expenditureDate = $receivedDate;
  10247. $accountBook->remarks = $remarks;
  10248. $accountBook->expensesType = 2;
  10249. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10250. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10251. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10252. $id = $accountBook->insert ();
  10253. // 添加一条收入流水
  10254. $itemWaste = array (
  10255. 'accountPriceShow' => $receivedPrice,
  10256. 'accountPrice' => $receivedPrice,
  10257. 'dataID' => $id,
  10258. 'expensesType' => 2,
  10259. 'accountType' => $accountTypeWaste,
  10260. 'dailyExpenditureType' => $dailyExpenditureType,
  10261. 'accountBank' => $accountBank,
  10262. 'category' => $this->staff [0] ['category'],
  10263. 'cid' => $this->staff [0] ['cid'],
  10264. 'name' => $this->staff [0] ['username'],
  10265. 'sid' => $this->staff [0] ['sid'],
  10266. 'inputDate' => date ( "Y-m-d H:i:s" )
  10267. );
  10268. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10269. }
  10270. }
  10271. return '/payments';
  10272. }
  10273. function paymentsExpenditureDo() {
  10274. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10275. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10276. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10277. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10278. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10279. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10280. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10281. // 理财支出特殊处理
  10282. Doo::loadModel ( "accountBook" );
  10283. Doo::loadModel ( "accountBookStatistics" );
  10284. Doo::loadModel ( 'wasteBook' );
  10285. $accountBank = '';
  10286. if ($expenditureBank == '纵横广发') {
  10287. $accountBank = 'CGBDeposit';
  10288. } elseif ($expenditureBank == '纵横工行') {
  10289. $accountBank = 'ICBCDeposit';
  10290. } elseif ($expenditureBank == '华润银行') {
  10291. $accountBank = 'HUADeposit';
  10292. } elseif ($expenditureBank == '个人广发') {
  10293. $accountBank = 'PersonalDeposit';
  10294. }
  10295. if (empty ( $accountBank ))
  10296. die ( 'illegal request' );
  10297. if ($expenditureType == 4 || $expenditureType == 6) {
  10298. if ($expenditureBank == '个人广发') {
  10299. die ( '个人广发 illegal request' );
  10300. }
  10301. // 添加一笔日常支出
  10302. $accountBook = new accountBook ();
  10303. $accountBook->expensesType = 2;
  10304. $accountBook->expenditureType = 7;
  10305. $accountBook->expenditureMsg = $expenditureMsg;
  10306. $accountBook->expenditurePrice = $expenditurePrice;
  10307. $accountBook->expenditureBank = $expenditureBank;
  10308. $accountBook->expenditureDate = $expenditureDate;
  10309. $accountBook->remarks = $remarks;
  10310. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10311. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10312. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10313. $expenditureId = $accountBook->insert ();
  10314. // 添加日常支出汇总
  10315. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  10316. $accountBookStatistics = new accountBookStatistics ();
  10317. $item = array (
  10318. 'date' => date ( "Y-m-d" ),
  10319. 'expenditureType' => $abDetail ['expenditureType'],
  10320. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10321. 'aid' => $abDetail ['aid'],
  10322. 'payPrice' => $abDetail ['expenditurePrice'],
  10323. 'expensesType' => $abDetail ['expensesType']
  10324. );
  10325. $accountBookStatistics->setAccountBookStatistics ( $item );
  10326. // 公司日常支出流水
  10327. $wasteBook = new wasteBook ();
  10328. $itemWaste = array (
  10329. 'accountPrice' => - $expenditurePrice
  10330. );
  10331. if ($expenditureBank == '个人广发') {
  10332. $itemWaste = array (
  10333. 'accountPrice' => $expenditurePrice
  10334. );
  10335. }
  10336. $itemWaste += array (
  10337. 'expensesType' => 2,
  10338. 'accountType' => 5,
  10339. 'dailyExpenditureType' => $expenditureType,
  10340. 'accountPriceShow' => $expenditurePrice,
  10341. 'accountPrice' => - $expenditurePrice,
  10342. 'dataID' => $expenditureId,
  10343. 'accountBank' => $accountBank,
  10344. 'category' => $this->staff [0] ['category'],
  10345. 'cid' => $this->staff [0] ['cid'],
  10346. 'name' => $this->staff [0] ['username'],
  10347. 'sid' => $this->staff [0] ['sid'],
  10348. 'inputDate' => date ( "Y-m-d H:i:s" )
  10349. );
  10350. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10351. // 添加一笔理财收入
  10352. $accountBank = 'CGBDeposit';
  10353. $dailyIncomeType = 7;
  10354. $receivedBank = '纵横广发';
  10355. if ($expenditureType == 6) {
  10356. $accountBank = 'ICBCDeposit';
  10357. $receivedBank = '纵横工行';
  10358. $dailyIncomeType = 9;
  10359. }
  10360. $accountBook = new accountBook ();
  10361. $accountBook->expensesType = 1;
  10362. $accountBook->accountType = $dailyIncomeType;
  10363. $accountBook->accountMsg = $expenditureMsg;
  10364. $accountBook->receivedPrice = $expenditurePrice;
  10365. $accountBook->receivedBank = $receivedBank;
  10366. $accountBook->receivedDate = $expenditureDate;
  10367. $accountBook->remarks = $remarks;
  10368. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10369. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10370. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10371. $id = $accountBook->insert ();
  10372. // 添加日常理财收入汇总
  10373. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  10374. $accountBookStatistics = new accountBookStatistics ();
  10375. $item = array (
  10376. 'date' => date ( "Y-m-d" ),
  10377. 'expenditureType' => $abDetail ['expenditureType'],
  10378. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10379. 'aid' => $abDetail ['aid'],
  10380. 'financingPrice' => $expenditurePrice,
  10381. 'expensesType' => 3
  10382. );
  10383. $accountBookStatistics->setAccountBookStatistics ( $item );
  10384. // 添加一笔收入流水
  10385. if ($expenditureMsg == '公司固定') {
  10386. $accountTypeWaste = 9;
  10387. } elseif ($expenditureMsg == '公司活期') {
  10388. $accountTypeWaste = 10;
  10389. } elseif ($expenditureMsg == '个人(GR)') {
  10390. $accountBank = 'PersonalDeposit';
  10391. }
  10392. $itemWaste = array (
  10393. 'expensesType' => 1,
  10394. 'accountType' => $accountTypeWaste,
  10395. 'accountPriceShow' => $expenditurePrice,
  10396. 'accountPrice' => $expenditurePrice,
  10397. 'dataID' => $id,
  10398. 'dailyIncomeType' => $dailyIncomeType,
  10399. 'accountBank' => $accountBank,
  10400. 'category' => $this->staff [0] ['category'],
  10401. 'cid' => $this->staff [0] ['cid'],
  10402. 'name' => $this->staff [0] ['username'],
  10403. 'sid' => $this->staff [0] ['sid'],
  10404. 'inputDate' => date ( "Y-m-d H:i:s" )
  10405. );
  10406. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10407. } else {
  10408. // 添加一笔日常支出
  10409. $accountBook = new accountBook ();
  10410. $accountBook->expensesType = 2;
  10411. $accountBook->expenditureType = $expenditureType;
  10412. $accountBook->expenditureMsg = $expenditureMsg;
  10413. $accountBook->expenditurePrice = $expenditurePrice;
  10414. $accountBook->expenditureBank = $expenditureBank;
  10415. $accountBook->expenditureDate = $expenditureDate;
  10416. $accountBook->remarks = $remarks;
  10417. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10418. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10419. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10420. $id = $accountBook->insert ();
  10421. // 添加日常支出汇总
  10422. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10423. $accountBookStatistics = new accountBookStatistics ();
  10424. $item = array (
  10425. 'date' => date ( "Y-m-d" ),
  10426. 'expenditureType' => $abDetail ['expenditureType'],
  10427. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10428. 'aid' => $abDetail ['aid'],
  10429. 'expensesType' => $abDetail ['expensesType']
  10430. );
  10431. if ($expenditureType == 5) {
  10432. $item += array (
  10433. 'payPrice' => - $abDetail ['expenditurePrice']
  10434. );
  10435. } else {
  10436. $item += array (
  10437. 'payPrice' => $abDetail ['expenditurePrice']
  10438. );
  10439. }
  10440. $accountBookStatistics->setAccountBookStatistics ( $item );
  10441. // 公司日常支出流水
  10442. $wasteBook = new wasteBook ();
  10443. $itemWaste = array (
  10444. 'accountPrice' => - $expenditurePrice
  10445. );
  10446. if ($expenditureBank == '个人广发') {
  10447. $itemWaste = array (
  10448. 'accountPrice' => $expenditurePrice
  10449. );
  10450. }
  10451. $itemWaste += array (
  10452. 'expensesType' => 2,
  10453. 'accountType' => 5,
  10454. 'accountPriceShow' => $expenditurePrice,
  10455. 'dataID' => $id,
  10456. 'dailyExpenditureType' => $expenditureType,
  10457. 'accountBank' => $accountBank,
  10458. 'category' => $this->staff [0] ['category'],
  10459. 'cid' => $this->staff [0] ['cid'],
  10460. 'name' => $this->staff [0] ['username'],
  10461. 'sid' => $this->staff [0] ['sid'],
  10462. 'inputDate' => date ( "Y-m-d H:i:s" )
  10463. );
  10464. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10465. }
  10466. }
  10467. return '/payments';
  10468. }
  10469. /**
  10470. * 添加支出
  10471. */
  10472. function paymentsExpenditureDo_() {
  10473. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10474. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10475. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10476. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10477. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10478. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10479. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10480. $dailyExpenditureType = '';
  10481. $accountTypeWaste = 5;
  10482. $accountBank = '';
  10483. if ($expenditureBank == '纵横广发') {
  10484. $accountBank = 'CGBDeposit';
  10485. } elseif ($expenditureBank == '纵横工行') {
  10486. $accountBank = 'ICBCDeposit';
  10487. } elseif ($expenditureBank == '华润银行') {
  10488. $accountBank = 'HUADeposit';
  10489. } elseif ($expenditureBank == '个人广发') {
  10490. $accountBank = 'PersonalDeposit';
  10491. }
  10492. if (empty ( $accountBank ))
  10493. die ( 'illegal request' );
  10494. $itemWaste = array (
  10495. 'accountPrice' => - $expenditurePrice
  10496. );
  10497. if ($expenditureBank == '个人广发') {
  10498. $itemWaste = array (
  10499. 'accountPrice' => $expenditurePrice
  10500. );
  10501. }
  10502. if ($expenditureType == 4 || $expenditureType == 6) {
  10503. $dailyExpenditureType = 4;
  10504. if ($expenditureMsg == '公司固定') {
  10505. $accountTypeWaste = 9;
  10506. } elseif ($expenditureMsg == '公司活期') {
  10507. $accountTypeWaste = 10;
  10508. } elseif ($expenditureMsg == '个人(GR)') {
  10509. $accountBank = 'PersonalDeposit';
  10510. }
  10511. $itemWaste = array (
  10512. 'accountPrice' => $expenditurePrice
  10513. );
  10514. } elseif ($expenditureType == 1) {
  10515. $dailyExpenditureType = 1;
  10516. } elseif ($expenditureType == 2) {
  10517. $dailyExpenditureType = 2;
  10518. } elseif ($expenditureType == 3) {
  10519. $dailyExpenditureType = 3;
  10520. } elseif ($expenditureType == 5) {
  10521. $dailyExpenditureType = 5;
  10522. }
  10523. if (empty ( $dailyExpenditureType ))
  10524. die ( 'illegal request' );
  10525. Doo::loadModel ( "accountBook" );
  10526. $accountBook = new accountBook ();
  10527. $accountBook->expenditureType = $expenditureType;
  10528. $accountBook->expenditureMsg = $expenditureMsg;
  10529. $accountBook->expenditurePrice = $expenditurePrice;
  10530. $accountBook->expenditureBank = $expenditureBank;
  10531. $accountBook->expenditureDate = $expenditureDate;
  10532. $accountBook->remarks = $remarks;
  10533. $accountBook->expensesType = 2;
  10534. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10535. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10536. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10537. $id = $accountBook->insert ();
  10538. //
  10539. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10540. Doo::loadModel ( "accountBookStatistics" );
  10541. $accountBookStatistics = new accountBookStatistics ();
  10542. $item = array (
  10543. 'date' => date ( "Y-m-d" ),
  10544. 'expenditureType' => $abDetail ['expenditureType'],
  10545. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10546. 'aid' => $abDetail ['aid']
  10547. );
  10548. if ($abDetail ['expensesType'] == 2) {
  10549. if ($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) {
  10550. $item += array (
  10551. 'financingPrice' => $expenditurePrice,
  10552. 'expensesType' => 3
  10553. );
  10554. } elseif ($abDetail ['expenditureType'] == 5) {
  10555. $item += array (
  10556. 'payPrice' => $abDetail ['expenditurePrice'],
  10557. 'expensesType' => $abDetail ['expensesType']
  10558. );
  10559. } else {
  10560. $item += array (
  10561. 'payPrice' => $abDetail ['expenditurePrice'],
  10562. 'expensesType' => $abDetail ['expensesType']
  10563. );
  10564. }
  10565. }
  10566. $accountBookStatistics->setAccountBookStatistics ( $item );
  10567. // 公司流水记录
  10568. Doo::loadModel ( 'wasteBook' );
  10569. $wasteBook = new wasteBook ();
  10570. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountTypeWaste, $id );
  10571. // 银行
  10572. if (empty ( $abDetail )) {
  10573. $itemWaste += array (
  10574. 'accountPriceShow' => $expenditurePrice,
  10575. 'dataID' => $id,
  10576. 'expensesType' => 2,
  10577. 'accountType' => $accountTypeWaste,
  10578. 'dailyExpenditureType' => $expenditureType,
  10579. 'accountBank' => $accountBank,
  10580. 'category' => $this->staff [0] ['category'],
  10581. 'cid' => $this->staff [0] ['cid'],
  10582. 'name' => $this->staff [0] ['username'],
  10583. 'sid' => $this->staff [0] ['sid'],
  10584. 'inputDate' => date ( "Y-m-d H:i:s" )
  10585. );
  10586. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10587. }
  10588. // 支出类型为4或者6 需要添加一笔收入和收入流水
  10589. if ($expenditureType == 4 || $expenditureType == 6) {
  10590. $accountBank = 'CGBDeposit';
  10591. $dailyIncomeType = 7;
  10592. $receivedBank = '纵横广发';
  10593. if ($expenditureType == 6) {
  10594. $accountBank = 'ICBCDeposit';
  10595. $receivedBank = '纵横工行';
  10596. $dailyIncomeType = 9;
  10597. }
  10598. // 添加一笔收入
  10599. $accountBook = new accountBook ();
  10600. $accountBook->accountType = $dailyIncomeType;
  10601. $accountBook->accountMsg = $expenditureMsg;
  10602. $accountBook->receivedPrice = $expenditurePrice;
  10603. $accountBook->receivedBank = $receivedBank;
  10604. $accountBook->receivedDate = $expenditureDate;
  10605. $accountBook->remarks = $remarks;
  10606. $accountBook->expensesType = 1;
  10607. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10608. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10609. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10610. $id = $accountBook->insert ();
  10611. // 添加一笔收入流水
  10612. $itemWaste = array (
  10613. 'accountPriceShow' => $expenditurePrice,
  10614. 'accountPrice' => - $expenditurePrice,
  10615. 'dataID' => $id,
  10616. 'expensesType' => 1,
  10617. 'accountType' => $accountTypeWaste,
  10618. 'dailyIncomeType' => $dailyIncomeType,
  10619. 'accountBank' => $accountBank,
  10620. 'category' => $this->staff [0] ['category'],
  10621. 'cid' => $this->staff [0] ['cid'],
  10622. 'name' => $this->staff [0] ['username'],
  10623. 'sid' => $this->staff [0] ['sid'],
  10624. 'inputDate' => date ( "Y-m-d H:i:s" )
  10625. );
  10626. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10627. }
  10628. }
  10629. return '/payments';
  10630. }
  10631. /**
  10632. * 所有收支
  10633. */
  10634. function paymentsAchieve() {
  10635. $page_size = 12;
  10636. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  10637. $expensesType = isset ( $this->params ['expensesType'] ) ? $this->params ['expensesType'] : 'ALL';
  10638. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  10639. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  10640. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10641. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10642. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10643. $submitType = $this->get_args ( 'submitType' ) ? $this->get_args ( 'submitType' ) : "";
  10644. Doo::loadModel ( "accountBookStatistics" );
  10645. $accountBookStatistics = new accountBookStatistics ();
  10646. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  10647. $data ['statisticsList'] = $statisticsList;
  10648. Doo::loadModel ( "accountBook" );
  10649. $accountBook = new accountBook ();
  10650. $con = '';
  10651. if ($expensesType == 'INCOME')
  10652. $con = ' and expensesType=1 ';
  10653. elseif ($expensesType == 'PAY')
  10654. $con = ' and expensesType=2 ';
  10655. $dateArr = explode ( ':', $date );
  10656. $D1 = $dateString = '';
  10657. $D2 = '';
  10658. if (! empty ( $date )) {
  10659. $D1 = $dateArr [0];
  10660. if (isset ( $dateArr [1] ))
  10661. $D2 = $dateArr [1];
  10662. else
  10663. $D2 = '';
  10664. $dateString = $D1 . " : " . $D2;
  10665. }
  10666. if (! empty ( $D1 ) && ! empty ( $D2 ))
  10667. $con .= ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  10668. elseif (! empty ( $D1 ) && empty ( $D2 ))
  10669. $con .= ' and inputDate like "%' . $D1 . '%" ';
  10670. if (! empty ( $price ))
  10671. $con .= ' and (receivedPrice=' . $price . ' or expenditurePrice=' . $price . ')';
  10672. if ($submitType == 1) {
  10673. if ($accountType != '') {
  10674. $expenditureType = '';
  10675. $con .= ' and accountType=' . $accountType;
  10676. if (! empty ( $accountMsg ))
  10677. $con .= ' and (accountType=' . $accountType . ' and accountMsg like "%' . $accountMsg . '%")';
  10678. }
  10679. } elseif ($submitType == 2) {
  10680. if ($expenditureType != '') {
  10681. $accountType = $accountMsg = '';
  10682. $con .= ' and expenditureType=' . $expenditureType;
  10683. }
  10684. } else {
  10685. $accountType = $accountMsg = $expenditureType = '';
  10686. }
  10687. $sql = "" . $con;
  10688. $action = "paymentsAchieve";
  10689. $get = '/' . $expensesType; // "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  10690. $pageinfo = $this->get_page ( "CLD_accountBook", $sql, $page, $page_size, $action, $get, "" );
  10691. $limit = $pageinfo ['lower'] . ',' . $page_size;
  10692. $list = $accountBook->getAccountBookBySql ( $limit, $sql, 'desc' );
  10693. $data ['expenditureType'] = $expenditureType;
  10694. $data ['accountMsg'] = $accountMsg;
  10695. $data ['accountType'] = $accountType;
  10696. $data ['inputDate'] = $date;
  10697. $data ['price'] = $price;
  10698. $data ['expensesType'] = $expensesType;
  10699. $data ['page'] = $pageinfo;
  10700. $data ['list'] = $list;
  10701. $data ['memu'] = "receipt";
  10702. $data ['staff'] = $this->staff;
  10703. $data ['receiptMemu'] = 'payments';
  10704. $data ['verifyId'] = $this->verifyId;
  10705. $data ['executeId'] = $this->executeId;
  10706. $this->render ( "/expenses/paymentsAchieve", $data );
  10707. }
  10708. function paymentsIncomeUpdateDo() {
  10709. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  10710. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10711. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10712. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10713. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10714. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10715. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10716. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10717. if (! empty ( $aidKey ) && ! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10718. Doo::loadClass ( 'XDeode' );
  10719. $XDeode = new XDeode ( 5 );
  10720. $aid = $XDeode->decode ( $aidKey );
  10721. Doo::loadModel ( "accountBook" );
  10722. $accountBook = new accountBook ();
  10723. //
  10724. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  10725. $price = $receivedPrice - $abDetail [inComePrice];
  10726. Doo::loadModel ( "accountBookStatistics" );
  10727. $accountBookStatistics = new accountBookStatistics ();
  10728. if ($abDetail ['accountType'] == 7) {
  10729. $item += array (
  10730. 'date' => date ( "Y-m-d" ),
  10731. 'financingPrice' => - $price,
  10732. 'expensesType' => 3,
  10733. 'aid' => $abDetail ['aid']
  10734. );
  10735. } elseif ($abDetail ['accountType'] == 8) {
  10736. $item += array (
  10737. 'date' => date ( "Y-m-d" ),
  10738. 'expensesType' => $abDetail ['expensesType'],
  10739. 'inComePrice' => - $price,
  10740. 'aid' => $abDetail ['aid']
  10741. );
  10742. } else {
  10743. $item = array (
  10744. 'date' => date ( "Y-m-d" ),
  10745. 'expensesType' => $abDetail ['expensesType'],
  10746. 'inComePrice' => $price,
  10747. 'aid' => $abDetail ['aid']
  10748. );
  10749. }
  10750. $accountBookStatistics->setAccountBookStatistics ( $item );
  10751. $accountBook->accountType = $accountType;
  10752. $accountBook->accountMsg = $accountMsg;
  10753. $accountBook->receivedPrice = $receivedPrice;
  10754. $accountBook->receivedMsg = $receivedMsg;
  10755. $accountBook->receivedBank = $receivedBank;
  10756. $accountBook->receivedDate = $receivedDate;
  10757. $accountBook->remarks = $remarks;
  10758. $accountBook->aid = $aid;
  10759. $accountBook->update ();
  10760. }
  10761. return '/paymentsAchieve';
  10762. }
  10763. function paymentsExpenditureEdiDo() {
  10764. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  10765. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10766. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10767. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10768. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10769. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10770. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10771. if (! empty ( $aidKey ) && ! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10772. Doo::loadClass ( 'XDeode' );
  10773. $XDeode = new XDeode ( 5 );
  10774. $aid = $XDeode->decode ( $aidKey );
  10775. Doo::loadModel ( "accountBook" );
  10776. $accountBook = new accountBook ();
  10777. // 汇总信息
  10778. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  10779. $price = $expenditurePrice - $abDetail [expenditurePrice];
  10780. Doo::loadModel ( "accountBookStatistics" );
  10781. $accountBookStatistics = new accountBookStatistics ();
  10782. if ($abDetail ['expenditureType'] == 4) {
  10783. $item += array (
  10784. 'date' => date ( "Y-m-d" ),
  10785. 'financingPrice' => $price,
  10786. 'expensesType' => 3,
  10787. 'aid' => $abDetail ['aid']
  10788. );
  10789. } elseif ($abDetail ['expenditureType'] == 5) {
  10790. $item += array (
  10791. 'date' => date ( "Y-m-d" ),
  10792. 'expensesType' => $abDetail ['expensesType'],
  10793. 'payPrice' => $price,
  10794. 'aid' => $abDetail ['aid']
  10795. );
  10796. } else {
  10797. $item = array (
  10798. 'date' => date ( "Y-m-d" ),
  10799. 'expensesType' => $abDetail ['expensesType'],
  10800. 'payPrice' => $price,
  10801. 'aid' => $abDetail ['aid']
  10802. );
  10803. }
  10804. $accountBookStatistics->setAccountBookStatistics ( $item );
  10805. //
  10806. $accountBook->expenditureType = $expenditureType;
  10807. $accountBook->expenditureMsg = $expenditureMsg;
  10808. $accountBook->expenditurePrice = $expenditurePrice;
  10809. $accountBook->expenditureBank = $expenditureBank;
  10810. $accountBook->remarks = $remarks;
  10811. $accountBook->expenditureDate = $expenditureDate;
  10812. $accountBook->aid = $aid;
  10813. $id = $accountBook->update ();
  10814. }
  10815. return '/paymentsAchieve';
  10816. }
  10817. function paymentsDelDo() {
  10818. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  10819. if (! empty ( $aidKey )) {
  10820. Doo::loadClass ( 'XDeode' );
  10821. $XDeode = new XDeode ( 5 );
  10822. $aid = $XDeode->decode ( $aidKey );
  10823. Doo::loadModel ( "accountBook" );
  10824. $accountBook = new accountBook ();
  10825. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  10826. if (empty ( $abDetail ))
  10827. die ( 'illegal request' );
  10828. // 删除收支
  10829. Doo::loadModel ( "accountBookStatistics" );
  10830. $accountBookStatistics = new accountBookStatistics ();
  10831. $item = array (
  10832. 'date' => date ( "Y-m-d" ),
  10833. 'aid' => $abDetail ['aid']
  10834. );
  10835. $accountType = '';
  10836. if ($abDetail ['expensesType'] == 1) {
  10837. $accountType = 6;
  10838. if ($abDetail ['accountType'] != 7) {
  10839. $item += array (
  10840. 'expensesType' => $abDetail ['expensesType'],
  10841. 'inComePrice' => - $abDetail ['receivedPrice']
  10842. );
  10843. } else {
  10844. $item += array (
  10845. 'financingPrice' => $abDetail ['receivedPrice'],
  10846. 'expensesType' => 3
  10847. );
  10848. }
  10849. } elseif ($abDetail ['expensesType'] == 2) {
  10850. $accountType = 5;
  10851. if ($abDetail ['accountType'] != 7) {
  10852. $item += array (
  10853. 'expensesType' => $abDetail ['expensesType'],
  10854. 'payPrice' => - $abDetail ['expenditurePrice']
  10855. );
  10856. } else {
  10857. $item += array (
  10858. 'financingPrice' => - $abDetail ['expenditurePrice'],
  10859. 'expensesType' => 3
  10860. );
  10861. }
  10862. }
  10863. if (($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) && $abDetail ['expensesType'] == 2) {
  10864. if ($abDetail ['expenditureMsg'] == '公司固定')
  10865. $accountType = 9;
  10866. elseif ($abDetail ['expenditureMsg'] == '公司活期')
  10867. $accountType = 10;
  10868. }
  10869. if (($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) && $abDetail ['expensesType'] == 1) {
  10870. if ($abDetail ['accountMsg'] == '公司固定')
  10871. $accountType = 9;
  10872. elseif ($abDetail ['accountMsg'] == '公司活期')
  10873. $accountType = 10;
  10874. }
  10875. if ($abDetail ['accountMsg'] == '活期理财收益') {
  10876. $accountType = 10;
  10877. }
  10878. $accountBookStatistics->setAccountBookStatistics ( $item );
  10879. $accountBook->delete ( array (
  10880. 'where' => 'aid=' . $aid,
  10881. 'limit' => 1
  10882. ) );
  10883. // 删除收入流水
  10884. if (! empty ( $accountType )) {
  10885. Doo::loadModel ( 'wasteBook' );
  10886. $wasteBook = new wasteBook ();
  10887. $wasteBook->delete ( array (
  10888. 'where' => 'dataID=' . $aid . ' and accountType=' . $accountType,
  10889. 'limit' => 1
  10890. ) );
  10891. }
  10892. }
  10893. return '/paymentsAchieve';
  10894. }
  10895. function paymentsCollect() {
  10896. Doo::loadModel ( "execute" );
  10897. $execute = new execute ();
  10898. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  10899. die ( 'illegal request' );
  10900. }
  10901. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10902. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  10903. Doo::loadModel ( "accountBookStatistics" );
  10904. $accountBookStatistics = new accountBookStatistics ();
  10905. Doo::loadClass ( 'receipt.func' );
  10906. $statisticsIncome = $accountBookStatistics->getStatisticsByCollect ( $year );
  10907. $html = _getPaymentsCollectByYearHtml ( $statisticsIncome );
  10908. $data ['html'] = $html ['html'];
  10909. $data ['inSum'] = $html ['sum'];
  10910. $statisticsPay = $accountBookStatistics->getStatisticsByCollect ( $year, 2 );
  10911. $html = _getPaymentsCollectPayByYearHtml ( $statisticsPay );
  10912. $data ['payHtml'] = $html ['html'];
  10913. $data ['paySum'] = $html ['sum'];
  10914. // 余额统计
  10915. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1 );
  10916. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2 );
  10917. include './protected/config/wasteBook.conf.php';
  10918. Doo::loadModel ( 'wasteBook' );
  10919. $wasteBook = new wasteBook ();
  10920. $inComePay = $wasteBook->getWasteBookByStatistics ( 1, $year );
  10921. $pay = $wasteBook->getWasteBookByStatistics ( 2, $year );
  10922. // 获得年份之前所有金额
  10923. $detail = $wasteBook->getWasteBookByStatisticsYear ( $year );
  10924. // print_r($detail);
  10925. // $waste['total'];
  10926. $lastBalanceHtml = '<tr><th colspan="2">截至上月余额</th>';
  10927. $inComeHtml = '<tr><th colspan="2">收入</th>';
  10928. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  10929. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  10930. $inSum = $paySum = $showInSum = $showPaySum = $balanceSum = 0;
  10931. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  10932. $limitMonth = date ( 'm' ); // 限制显示月份参数
  10933. if (date ( 'Y' ) > $year) {
  10934. $limitMonth = 12;
  10935. }
  10936. for($i = 1; $i <= 12; $i ++) {
  10937. $inComeA = $payB = 0;
  10938. $falg = true;
  10939. foreach ( $inComePay as $key => $value ) {
  10940. if ($value ['month'] == $i) {
  10941. $falg = false;
  10942. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  10943. $inSum += $value ['accountPrice'];
  10944. $showInSum += $value ['accountPriceShow'];
  10945. $inComeA = $value ['accountPrice'];
  10946. break;
  10947. }
  10948. }
  10949. if ($falg)
  10950. $inComeHtml .= '<td class="taR">-</td>';
  10951. $payFalg = true;
  10952. foreach ( $pay as $key => $value ) {
  10953. if ($value ['month'] == $i) {
  10954. $payFalg = false;
  10955. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  10956. $paySum += $value ['accountPrice'];
  10957. $showPaySum += $value ['accountPriceShow'];
  10958. $payB = $value ['accountPrice'];
  10959. break;
  10960. }
  10961. }
  10962. if ($payFalg)
  10963. $payHtml .= '<td class="taR">-</td>';
  10964. if (empty ( $balanceC ) || $limitMonth < $i)
  10965. $lastBalanceHtml .= '<td class="taR">-</td>';
  10966. else
  10967. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  10968. $balanceC = $balanceC + $inComeA + $payB;
  10969. $balanceSum += $balanceC;
  10970. if (empty ( $balanceC ) || $limitMonth < $i)
  10971. $BalanceHtml .= '<td class="taR">-</td>';
  10972. else
  10973. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  10974. // 余额统计
  10975. }
  10976. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  10977. $data ['inComeHtml'] = $inComeHtml;
  10978. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  10979. $data ['payBalanceHtml'] = $payHtml;
  10980. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  10981. $data ['BalanceHtml'] = $BalanceHtml;
  10982. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  10983. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  10984. $mothHtml = "";
  10985. for($i = 1; $i <= 12; $i ++) {
  10986. if ($moth == $i)
  10987. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  10988. else
  10989. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  10990. }
  10991. $data ['mothHtml'] = $mothHtml;
  10992. $dateHtml = "";
  10993. $now = date ( "Y" );
  10994. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  10995. if ($YEARD <= $now) {
  10996. $dateHtml .= '<option ';
  10997. if ($year == $YEARD) {
  10998. $dateHtml .= 'selected ';
  10999. }
  11000. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11001. }
  11002. }
  11003. $data ['dateHtml'] = $dateHtml;
  11004. $data ['year'] = $year;
  11005. $data ['memu'] = "receipt";
  11006. $data ['staff'] = $this->staff;
  11007. $data ['receiptMemu'] = 'paymentsCollect';
  11008. $data ['verifyId'] = $this->verifyId;
  11009. $data ['executeId'] = $this->executeId;
  11010. $this->render ( "/expenses/paymentsCollect", $data );
  11011. }
  11012. function paymentsCollectDay() {
  11013. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11014. $moth = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : '';
  11015. if (empty ( $moth ))
  11016. return 'paymentsCollect';
  11017. Doo::loadModel ( "accountBookStatistics" );
  11018. $accountBookStatistics = new accountBookStatistics ();
  11019. $i = 2;
  11020. $y = 2013;
  11021. $day = date ( "t", strtotime ( "$year-$moth" ) );
  11022. Doo::loadClass ( 'receipt.func' );
  11023. $statisticsIncome = $accountBookStatistics->getStatisticsByCollectDay ( $year, 1, $moth );
  11024. $html = _getPaymentsCollectByDayHtml ( $statisticsIncome, $day );
  11025. $data ['html'] = $html ['html'];
  11026. $data ['inSum'] = $html ['sum'];
  11027. $statisticsPay = $accountBookStatistics->getStatisticsByCollectDay ( $year, 2, $moth );
  11028. $html = _getPaymentsCollectPayByDayHtml ( $statisticsPay, $day );
  11029. $data ['payHtml'] = $html ['html'];
  11030. $data ['paySum'] = $html ['sum'];
  11031. $mothHtml = "";
  11032. for($i = 1; $i <= 12; $i ++) {
  11033. if ($moth == $i)
  11034. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11035. else
  11036. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11037. }
  11038. $data ['mothHtml'] = $mothHtml;
  11039. $data ['year'] = $year;
  11040. // 余额
  11041. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1, $moth );
  11042. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2, $moth );
  11043. include './protected/config/wasteBook.conf.php';
  11044. Doo::loadModel ( 'wasteBook' );
  11045. $wasteBook = new wasteBook ();
  11046. $inComePay = $wasteBook->getStatisticsByDay ( 1, $year, $moth );
  11047. $pay = $wasteBook->getStatisticsByDay ( 2, $year, $moth );
  11048. // 获得年份之前所有金额
  11049. $detail = $wasteBook->getWasteBookByStatisticsDay ( $year, $moth );
  11050. $lastBalanceHtml = '<tr><th colspan="2">截至上日余额</th>';
  11051. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11052. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11053. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11054. $dayHtml = '<tr><th class="taC" colspan="2">余额</th>';
  11055. $inSum = $paySum = $showPaySum = $showInSum = $balanceSum = 0;
  11056. // $balanceC = 0;
  11057. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11058. $limitDay = date ( 'd' );
  11059. $monthLK = ( int ) date ( 'm' );
  11060. if (date ( 'Y' ) > $year) {
  11061. $limitDay = cal_days_in_month ( CAL_GREGORIAN, date ( 'm' ), date ( 'Y' ) );
  11062. } elseif (date ( 'Y' ) <= $year && $monthLK < $moth) {
  11063. $limitDay = 0;
  11064. }
  11065. for($i = 1; $i <= $day; $i ++) {
  11066. $dayHtml .= '<td class="taC">' . $i . '日</td>';
  11067. $inComeA = $payB = 0;
  11068. $falg = true;
  11069. foreach ( $inComePay as $key => $value ) {
  11070. if ($value ['day'] == $i) {
  11071. $falg = false;
  11072. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11073. $inSum += $value ['accountPrice'];
  11074. $showInSum += $value ['accountPriceShow'];
  11075. $inComeA = $value ['accountPrice'];
  11076. break;
  11077. }
  11078. }
  11079. if ($falg)
  11080. $inComeHtml .= '<td class="taR">-</td>';
  11081. $payFalg = true;
  11082. foreach ( $pay as $key => $value ) {
  11083. if ($value ['day'] == $i) {
  11084. $payFalg = false;
  11085. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11086. $paySum += $value ['accountPrice'];
  11087. $showPaySum += $value ['accountPriceShow'];
  11088. $payB = $value ['accountPrice'];
  11089. break;
  11090. }
  11091. }
  11092. if ($payFalg)
  11093. $payHtml .= '<td class="taR">-</td>';
  11094. if (empty ( $balanceC ) || $limitDay < $i)
  11095. $lastBalanceHtml .= '<td class="taR">-</td>';
  11096. else
  11097. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11098. $balanceC = $balanceC + $inComeA + $payB;
  11099. $balanceSum += $balanceC;
  11100. if (empty ( $balanceC ) || $limitDay < $i)
  11101. $BalanceHtml .= '<td class="taR">-</td>';
  11102. else
  11103. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11104. }
  11105. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11106. $data ['inComeHtml'] = $inComeHtml;
  11107. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11108. $data ['payBalanceHtml'] = $payHtml;
  11109. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11110. $data ['BalanceHtml'] = $BalanceHtml;
  11111. $dayHtml .= '<td class="taR ">总计</td></tr>';
  11112. $data ['dayHtml'] = $dayHtml;
  11113. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11114. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11115. $dateHtml = "";
  11116. $now = date ( "Y" );
  11117. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11118. if ($YEARD <= $now) {
  11119. $dateHtml .= '<option ';
  11120. if ($year == $YEARD) {
  11121. $dateHtml .= 'selected ';
  11122. }
  11123. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11124. }
  11125. }
  11126. $data ['dateHtml'] = $dateHtml;
  11127. $data ['memu'] = "receipt";
  11128. $data ['staff'] = $this->staff;
  11129. $data ['receiptMemu'] = 'paymentsCollect';
  11130. $data ['verifyId'] = $this->verifyId;
  11131. $data ['executeId'] = $this->executeId;
  11132. $this->render ( "/expenses/paymentsCollectDay", $data );
  11133. }
  11134. function ajaxGetPaymentsByAid() {
  11135. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11136. Doo::loadModel ( "accountBook" );
  11137. $accountBook = new accountBook ();
  11138. $detail = $accountBook->getAccountBookByAid ( $serial );
  11139. echo json_encode ( array (
  11140. 'status' => 1,
  11141. 'detail' => $detail
  11142. ) );
  11143. }
  11144. // 公司流水
  11145. function wasteBook() {
  11146. Doo::loadModel ( "execute" );
  11147. $execute = new execute ();
  11148. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11149. die ( 'illegal request' );
  11150. }
  11151. include './protected/config/wasteBook.conf.php';
  11152. Doo::loadModel ( 'wasteBook' );
  11153. $wasteBook = new wasteBook ();
  11154. $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  11155. $waste = $this->getWasteBookStatistics ( $waste, $inComeStatistics );
  11156. $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'];
  11157. // print_r($waste);
  11158. $data ['waste'] = $waste;
  11159. $data ['total'] = $total;
  11160. // 月流水数据结构
  11161. $monthStatistics = array ();
  11162. $incomeMothStatistics = array ();
  11163. $expenditureMothStatistics = array ();
  11164. for($i = 1; $i <= 12; $i ++) {
  11165. $month = date ( 'Y' ) . '-' . $i;
  11166. if ($i < 10)
  11167. $month = date ( 'Y' ) . '-0' . $i;
  11168. array_push ( $monthStatistics, $month );
  11169. }
  11170. foreach ( $monthStatistics as $value ) {
  11171. $falg = true;
  11172. foreach ( $inComeStatistics ['incomeReport'] as $k => $v ) {
  11173. if ($value == $v ['inputDate']) {
  11174. array_push ( $incomeMothStatistics, $v ['accountPrice'] );
  11175. $falg = false;
  11176. }
  11177. }
  11178. if ($falg) {
  11179. array_push ( $incomeMothStatistics, '' );
  11180. }
  11181. $falgEx = true;
  11182. foreach ( $inComeStatistics ['expenditureReport'] as $k => $v ) {
  11183. if ($value == $v ['inputDate']) {
  11184. array_push ( $expenditureMothStatistics, $v ['accountPrice'] );
  11185. $falg = false;
  11186. }
  11187. }
  11188. if ($falgEx) {
  11189. array_push ( $expenditureMothStatistics, '' );
  11190. }
  11191. }
  11192. $data ['monthStatistics'] = json_encode ( $monthStatistics );
  11193. $data ['incomeMothStatistics'] = json_encode ( $incomeMothStatistics );
  11194. $data ['expenditureMothStatistics'] = json_encode ( $expenditureMothStatistics );
  11195. $expenditureList = $wasteBook->getAccountBookByExpensesType ( 4, 2 );
  11196. $incomeList = $wasteBook->getAccountBookByExpensesType ( 4, 1 );
  11197. // print_r($incomeList);
  11198. $data ['expenditureList'] = $expenditureList;
  11199. $data ['incomeList'] = $incomeList;
  11200. $data ['memu'] = "receipt";
  11201. $data ['staff'] = $this->staff;
  11202. $data ['receiptMemu'] = 'wasteBook';
  11203. $data ['verifyId'] = $this->verifyId;
  11204. $data ['executeId'] = $this->executeId;
  11205. $this->render ( "/expenses/wasteBook", $data );
  11206. }
  11207. function wasteBookIncome() {
  11208. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11209. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11210. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  11211. $dailyIncomeType = $this->get_args ( 'dailyIncomeType' ) ? $this->get_args ( 'dailyIncomeType' ) : "ALL";
  11212. $data ['dailyIncomeType'] = $dailyIncomeType;
  11213. Doo::loadModel ( 'wasteBook' );
  11214. $wasteBook = new wasteBook ();
  11215. Doo::loadModel ( 'L_category' );
  11216. $L_category = new L_category ();
  11217. Doo::loadClass ( 'XDeode' );
  11218. $XDeode = new XDeode ( 5 );
  11219. // echo $XDeode->encode(1).'<br>';
  11220. // echo $XDeode->encode(2).'<br>';
  11221. // echo $XDeode->encode(3).'<br>';
  11222. // echo $XDeode->encode(4).'<br>';
  11223. // echo $XDeode->encode(5).'<br>';
  11224. // echo $XDeode->encode(6).'<br>';
  11225. // echo $XDeode->encode(7).'<br>';
  11226. // echo $XDeode->encode(8).'<br>';
  11227. // echo $XDeode->encode(9).'<br>';
  11228. // echo $XDeode->encode(10).'<br>';
  11229. $dateArr = explode ( ':', $date );
  11230. $D1 = '';
  11231. $D2 = '';
  11232. $con = '';
  11233. if (! empty ( $date )) {
  11234. $D1 = $dateArr [0];
  11235. $D2 = $dateArr [1];
  11236. }
  11237. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11238. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11239. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11240. $con = ' and inputDate = "' . $D1 . '"';
  11241. if ($cid != 'ALL') {
  11242. $cid = $XDeode->decode ( $cid );
  11243. $con .= ' and cid = "' . $cid . '"';
  11244. }
  11245. if ($accountType != 'ALL') {
  11246. if ($accountType == 'INVOICE') {
  11247. $con .= ' and (accountType = 7 or accountType = 8)';
  11248. } elseif ($accountType == 'PAYMENTS') {
  11249. $con .= ' and (accountType = 6 or accountType = 9 or accountType = 10)';
  11250. if ($dailyIncomeType != 'ALL') {
  11251. $dailyIncomeType = $XDeode->decode ( $dailyIncomeType );
  11252. $con .= ' and dailyIncomeType = ' . $dailyIncomeType;
  11253. }
  11254. }
  11255. }
  11256. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 1, $con );
  11257. $sum = 0;
  11258. foreach ( $incomeList as $key => $value ) {
  11259. $sum += $value ['accountPrice'];
  11260. }
  11261. // print_r($incomeList);
  11262. // 获得办事和部门
  11263. $categoryList = $L_category->getCategory ();
  11264. $data ['accountType'] = $accountType;
  11265. $data ['cid'] = $cid;
  11266. $data ['categoryList'] = $categoryList;
  11267. $data ['sum'] = $sum;
  11268. $data ['incomeList'] = $incomeList;
  11269. $data ['inputDate'] = $date;
  11270. $data ['memu'] = "receipt";
  11271. $data ['staff'] = $this->staff;
  11272. $data ['receiptMemu'] = 'wasteBook';
  11273. $data ['verifyId'] = $this->verifyId;
  11274. $data ['executeId'] = $this->executeId;
  11275. $this->render ( "/expenses/wasteBookIncome", $data );
  11276. }
  11277. /**
  11278. * 所有支出
  11279. */
  11280. function wasteBookExpenditure() {
  11281. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11282. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11283. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  11284. $dailyExpenditureType = $this->get_args ( 'dailyExpenditureType' ) ? $this->get_args ( 'dailyExpenditureType' ) : "ALL";
  11285. $data ['dailyExpenditureType'] = $dailyExpenditureType;
  11286. $receiptType = $this->get_args ( 'receiptType' ) ? $this->get_args ( 'receiptType' ) : "ALL";
  11287. $data ['receiptType'] = $receiptType;
  11288. Doo::loadModel ( 'wasteBook' );
  11289. $wasteBook = new wasteBook ();
  11290. Doo::loadModel ( 'L_category' );
  11291. $L_category = new L_category ();
  11292. Doo::loadClass ( 'XDeode' );
  11293. $XDeode = new XDeode ( 5 );
  11294. $dateArr = explode ( ':', $date );
  11295. $D1 = '';
  11296. $D2 = '';
  11297. $con = '';
  11298. if (! empty ( $date )) {
  11299. $D1 = $dateArr [0];
  11300. $D2 = $dateArr [1];
  11301. }
  11302. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11303. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11304. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11305. $con = ' and inputDate = "' . $D1 . '"';
  11306. if ($cid != 'ALL') {
  11307. $cid = $XDeode->decode ( $cid );
  11308. $con .= ' and cid = "' . $cid . '"';
  11309. }
  11310. if ($accountType != 'ALL') {
  11311. if ($accountType == 'INVOICE') {
  11312. $con .= ' and accountType = 11';
  11313. } elseif ($accountType == 'PAYMENTS') {
  11314. $con .= ' and (accountType = 5 or accountType = 9 or accountType = 10)';
  11315. if ($dailyExpenditureType != 'ALL') {
  11316. $dailyExpenditureType = $XDeode->decode ( $dailyExpenditureType );
  11317. $con .= ' and dailyExpenditureType = ' . $dailyExpenditureType;
  11318. }
  11319. } elseif ($accountType == 'RECEIPT') {
  11320. if ($receiptType == 'ALL') {
  11321. $con .= ' and (accountType = 1 or accountType = 2 or accountType = 3 or accountType = 4)';
  11322. } else {
  11323. $receiptType = $XDeode->decode ( $receiptType );
  11324. echo $receiptType;
  11325. if ($receiptType == 1) {
  11326. $con .= ' and (accountType = 1 or accountType=2)';
  11327. } else {
  11328. $con .= ' and accountType = ' . $receiptType;
  11329. }
  11330. }
  11331. }
  11332. }
  11333. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 2, $con );
  11334. $sum = 0;
  11335. foreach ( $incomeList as $key => $value ) {
  11336. $sum += $value ['accountPriceShow'];
  11337. }
  11338. // print_r($incomeList);
  11339. // 获得办事和部门
  11340. $categoryList = $L_category->getCategory ();
  11341. $data ['accountType'] = $accountType;
  11342. $data ['cid'] = $cid;
  11343. $data ['categoryList'] = $categoryList;
  11344. $data ['sum'] = $sum;
  11345. $data ['incomeList'] = $incomeList;
  11346. $data ['inputDate'] = $date;
  11347. $data ['memu'] = "receipt";
  11348. $data ['staff'] = $this->staff;
  11349. $data ['receiptMemu'] = 'wasteBook';
  11350. $data ['verifyId'] = $this->verifyId;
  11351. $data ['executeId'] = $this->executeId;
  11352. $this->render ( "/expenses/wasteBookExpenditure", $data );
  11353. }
  11354. function ajaxGetWasteinvoiceReceivables() {
  11355. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11356. Doo::loadClass ( 'XDeode' );
  11357. $XDeode = new XDeode ( 5 );
  11358. $irid = $XDeode->decode ( $serial );
  11359. Doo::loadModel ( 'invoiceReceivables' );
  11360. $invoiceReceivables = new invoiceReceivables ();
  11361. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  11362. echo json_encode ( array (
  11363. 'status' => 1,
  11364. 'detail' => $detail
  11365. ) );
  11366. }
  11367. function ajaxGetWasteInvoice() {
  11368. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11369. Doo::loadModel ( 'invoice' );
  11370. $invoice = new invoice ();
  11371. Doo::loadModel ( 'invoiceReceivables' );
  11372. $invoiceReceivables = new invoiceReceivables ();
  11373. $detail = $invoice->getInvoiceByIid ( $serial );
  11374. $detailReceivables = $invoiceReceivables->getInvoiceReceivablesByIrid ( $detail ['irid'] );
  11375. $detail ['receivablesBank'] = $detailReceivables ['receivablesBank'];
  11376. echo json_encode ( array (
  11377. 'status' => 1,
  11378. 'detail' => $detail
  11379. ) );
  11380. }
  11381. /**
  11382. */
  11383. function ajaxGetWasteReceipt() {
  11384. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11385. Doo::loadModel ( 'receipt' );
  11386. $receipt = new receipt ();
  11387. Doo::loadClass ( 'XDeode' );
  11388. $XDeode = new XDeode ( 5 );
  11389. $rid = $XDeode->decode ( $serial );
  11390. // 获得个数据
  11391. $detail = $receipt->getReceiptByRid ( $rid );
  11392. // 初始化
  11393. $detail ['reviseDetail'] = array ();
  11394. if (! empty ( $value ['reviseDetail'] ))
  11395. $detail ['reviseDetail'] = json_decode ( $detail ['reviseDetail'], true );
  11396. $detail ['accountItem'] = json_decode ( $detail ['accountItem'], true );
  11397. $detail ['loanItem'] = json_decode ( $detail ['loanItem'], true );
  11398. $detail ['loanSumCN'] = $this->num_to_rmb ( $detail ['loanSum'] );
  11399. $detail ['sumCN'] = $this->num_to_rmb ( $detail ['sum'] );
  11400. // 获得费用html
  11401. $html = $this->getWasteReceiptHtml ( $detail );
  11402. // 获得费用审批人数据
  11403. $detail = $this->getReceiptApproverHtml ( $detail );
  11404. // 审批执行
  11405. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  11406. <th class="taC" width="90">审批人</th>
  11407. <th class="taC">审批意见</th></tr>';
  11408. foreach ( $detail ['verifyList'] as $key => $value ) {
  11409. $html .= '<tr>
  11410. <td>' . $value [1] . '</td>
  11411. <td>' . $value ['opinion'] . '</td>
  11412. </tr>
  11413. ';
  11414. }
  11415. $html .= ' </tbody></table>';
  11416. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  11417. <th class="taC" width="90">执行人</th>
  11418. <th class="taC">执行意见</th></tr>';
  11419. foreach ( $detail ['executeCopy'] as $key => $value ) {
  11420. $html .= '<tr>
  11421. <td>' . $value [1] . '</td>
  11422. <td>' . $value ['opinion'] . '</td>
  11423. </tr>
  11424. ';
  11425. }
  11426. $html .= ' </tbody></table>';
  11427. $html .= '<table class="table table-bordered table-condensed">
  11428. <tr class="warning">
  11429. <td class="taR"><b>汇款金额</b></td>
  11430. <td width="140" class="taR"><b style="font-size: 24px">¥' . $detail ['amount'] . '</b></td>
  11431. </tr>
  11432. </table>';
  11433. // print_r($detail['verifyList']);
  11434. // header ( 'Content-Type:text/html;charset=utf-8' );
  11435. // echo $html;
  11436. echo json_encode ( array (
  11437. 'status' => 1,
  11438. 'html' => $html,
  11439. 'detail' => $detail
  11440. ) );
  11441. }
  11442. function getReceiptApproverHtml($detail = array()) {
  11443. Doo::loadModel ( 'loanReceipt' );
  11444. $loanReceipt = new loanReceipt ();
  11445. Doo::loadModel ( 'verify' );
  11446. $verify = new verify ();
  11447. Doo::loadModel ( 'staff' );
  11448. $staff = new staff ();
  11449. if (empty ( $detail ))
  11450. return array ();
  11451. $loanList = $loanReceipt->getOne ( array (
  11452. 'where' => 'rid=' . $detail ['loanRid'],
  11453. 'desc' => 'rid',
  11454. 'asArray' => true
  11455. ) );
  11456. if ($detail ['status'] == 3 || $detail ['status'] == 1 || $detail ['status'] == 8 || $detail ['status'] == 9) {
  11457. if ($detail ['status'] == 8 && $detail ['Rtype'] == 1)
  11458. $verifyList ['staff'] = $loanList ['verifyBreakup'];
  11459. else
  11460. $verifyList ['staff'] = $detail ['verifyBreakup'];
  11461. } else
  11462. $verifyList = $verify->getOne ( array (
  11463. 'where' => 'vid=' . $detail ['verify'],
  11464. 'asArray' => true
  11465. ) );
  11466. $verifyList = json_decode ( $verifyList ['staff'], true );
  11467. Doo::loadModel ( 'role' );
  11468. $role = new role ();
  11469. $roleId = 0;
  11470. $flag = true;
  11471. $roleKey = 0;
  11472. $endStaffArray = array ();
  11473. $roleArrayCopy = array ();
  11474. foreach ( $verifyList as $k => $v ) {
  11475. // init verifyStaff
  11476. if ($v [1] == 'ROLE') {
  11477. if (! empty ( $verifyStaff )) {
  11478. $endStaffArray = end ( $verifyStaff );
  11479. }
  11480. $roleVerify = json_decode ( $v [3], true );
  11481. $roleKey = $k;
  11482. $roleArray = array ();
  11483. $rolename = $role->getOne ( array (
  11484. 'where' => 'rid=' . $v [0],
  11485. 'asArray' => true
  11486. ) );
  11487. foreach ( $roleVerify as $o => $p ) {
  11488. $staffID = explode ( '_', $p );
  11489. $staffInfo = $staff->getOne ( array (
  11490. 'where' => 'sid=' . $staffID [0],
  11491. 'asArray' => true
  11492. ) );
  11493. // print_r($staffID);
  11494. $exp = array (
  11495. 0 => $staffInfo ['sid'],
  11496. 1 => $staffID [1],
  11497. 2 => $staffInfo ['avatar'],
  11498. 'date' => '',
  11499. 'date' => '',
  11500. 'opinion' => '',
  11501. 'status' => '',
  11502. 'rolename' => $rolename ['name']
  11503. );
  11504. array_push ( $roleArray, $exp );
  11505. }
  11506. $roleArrayCopy [$v [0]] = $roleArray;
  11507. // $verifyList[$k]['roleArray']=$roleArray;
  11508. }
  11509. $verifyList [$k] ['date'] = "";
  11510. $verifyList [$k] ['opinion'] = "";
  11511. $verifyList [$k] ['status'] = "";
  11512. if (empty ( $verifyStaff )) {
  11513. $verifyList [$k] ['date'] = "";
  11514. $verifyList [$k] ['opinion'] = "";
  11515. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  11516. $verifyList [$k] ['status'] = 4;
  11517. $flag = false;
  11518. }
  11519. } else {
  11520. foreach ( $verifyStaff as $m => $u ) {
  11521. if ($v [0] == $m) {
  11522. $verifyList [$k] ['date'] = $u ['date'];
  11523. $verifyList [$k] ['opinion'] = $u ['opinion'];
  11524. $verifyList [$k] ['status'] = $u ['status'];
  11525. $flag = false;
  11526. break;
  11527. }
  11528. }
  11529. $endStaffArray = end ( $verifyStaff );
  11530. }
  11531. }
  11532. $rolename ['name'] = '';
  11533. if (! empty ( $roleId )) {
  11534. Doo::loadModel ( 'role' );
  11535. $role = new role ();
  11536. $rolename = $role->getOne ( array (
  11537. 'where' => 'rid=' . $roleId,
  11538. 'asArray' => true
  11539. ) );
  11540. }
  11541. if (! empty ( $verifyStaff ))
  11542. $endStaffArray = end ( $verifyStaff );
  11543. $KOP = false;
  11544. foreach ( $roleArrayCopy as $P => $A ) {
  11545. foreach ( $A as $MKI => $AVL ) {
  11546. if (! empty ( $verifyStaff )) {
  11547. // &&$rolename['rid']==$endStaffArray['nextStaff']
  11548. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  11549. $button = 4;
  11550. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  11551. }
  11552. foreach ( $verifyStaff as $m => $u ) {
  11553. $AVLFK = $AVL [0] . '_R';
  11554. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  11555. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  11556. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  11557. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  11558. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  11559. break;
  11560. }
  11561. }
  11562. } else {
  11563. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  11564. $button = 4;
  11565. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  11566. }
  11567. }
  11568. // $roleArray[$MKI]['rolename']=$rolename['name'];
  11569. $KOP = true;
  11570. }
  11571. }
  11572. foreach ( $roleArrayCopy as $k => $v ) {
  11573. foreach ( $verifyList as $m => $n ) {
  11574. if ($n [0] == $k) {
  11575. array_splice ( $verifyList, $m, 1, $v );
  11576. }
  11577. }
  11578. }
  11579. // 费用执行人相关数据
  11580. $executeCopy = json_decode ( $detail ['executeCopy'], true );
  11581. $executeStaff = json_decode ( $detail ['executeStaff'], true );
  11582. foreach ( $executeCopy as $k => $v ) {
  11583. $executeCopy [$k] ['date'] = '';
  11584. $executeCopy [$k] ['opinion'] = '';
  11585. $executeCopy [$k] ['status'] = '';
  11586. if (! empty ( $executeStaff ))
  11587. foreach ( $executeStaff as $m => $u ) {
  11588. if ($v [0] == $m) {
  11589. $executeCopy [$k] ['date'] = $u ['date'];
  11590. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  11591. $executeCopy [$k] ['status'] = $u ['status'];
  11592. break;
  11593. }
  11594. }
  11595. }
  11596. $detail ['executeCopy'] = $executeCopy;
  11597. $detail ['verifyList'] = $verifyList;
  11598. return $detail;
  11599. }
  11600. function getWasteReceiptHtml($detail = array()) {
  11601. if (empty ( $detail ))
  11602. return '';
  11603. $html = '';
  11604. if ($detail ['Rtype'] == 0) { // 报销单
  11605. $html .= '
  11606. <table class="table table-bordered table-condensed">
  11607. <tbody>
  11608. <tr>
  11609. <th colspan="2" class="taC">日常相关费用</th>
  11610. </tr>';
  11611. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  11612. $html .= '
  11613. <tr>
  11614. <th>' . $value ['name'] . '</th>
  11615. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11616. </tr>';
  11617. }
  11618. $html .= '
  11619. <tr>
  11620. <th class="taR">合计</th>
  11621. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  11622. </tr>';
  11623. $html .= '<tr>
  11624. <th colspan="2" class="taC">差旅相关费用</th>
  11625. </tr>';
  11626. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  11627. $html .= '
  11628. <tr>
  11629. <th>' . $value ['name'] . '</th>
  11630. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11631. </tr>';
  11632. }
  11633. $html .= '
  11634. <tr>
  11635. <th class="taR">合计</th>
  11636. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  11637. </tr>';
  11638. $html .= '<tr>
  11639. <th colspan="2" class="taC">培训班费用</th>
  11640. </tr>';
  11641. foreach ( $detail ['accountItem'] ['培训班费用'] as $key => $value ) {
  11642. $html .= '
  11643. <tr>
  11644. <th>' . $value ['name'] . '</th>
  11645. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11646. </tr>';
  11647. }
  11648. $html .= '
  11649. <tr>
  11650. <th class="taR">合计</th>
  11651. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['trainSum'] . '</td>
  11652. </tr>';
  11653. $html .= '<tr>
  11654. <th colspan="2" class="taC">其他</th>
  11655. </tr>';
  11656. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  11657. $html .= '
  11658. <tr>
  11659. <th>' . $value ['name'] . '</th>
  11660. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11661. </tr>';
  11662. }
  11663. $html .= '
  11664. <tr>
  11665. <th class="taR">合计</th>
  11666. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  11667. </tr>';
  11668. $html .= '<tr>
  11669. <th colspan="2" class="taC">报销金额调整</th>
  11670. </tr>';
  11671. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  11672. $html .= '
  11673. <tr>
  11674. <th>' . $value ['name'] . '</th>
  11675. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11676. </tr>';
  11677. }
  11678. $html .= '
  11679. <tr>
  11680. <th class="taR">合计</th>
  11681. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  11682. </tr>';
  11683. $html .= '
  11684. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  11685. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  11686. <tr><th class="taC" colspan="2">报销说明</th></tr>
  11687. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  11688. <tr class="warning">
  11689. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  11690. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  11691. </tr>
  11692. </tbody>
  11693. </table>';
  11694. } elseif ($detail ['Rtype'] == 2) {
  11695. $html .= '
  11696. <table class="table table-bordered table-condensed">
  11697. <tbody>
  11698. <tr>
  11699. <th colspan="2" class="taC">办事处相关费用</th>
  11700. </tr>';
  11701. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  11702. $html .= '
  11703. <tr>
  11704. <th>' . $value ['name'] . '</th>
  11705. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11706. </tr>';
  11707. }
  11708. $html .= '
  11709. <tr>
  11710. <th class="taR">合计</th>
  11711. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  11712. </tr>';
  11713. $html .= '
  11714. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  11715. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  11716. <tr><th class="taC" colspan="2">报销说明</th></tr>
  11717. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  11718. <tr class="warning">
  11719. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  11720. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  11721. </tr>
  11722. </tbody>
  11723. </table>';
  11724. } elseif ($detail ['Rtype'] == 1) {
  11725. if ($detail ['loanRid'] != 0 && ! empty ( $detail ['accountItem'] )) {
  11726. $html .= '<table class="table table-bordered table-condensed">
  11727. <tbody>
  11728. <tr>
  11729. <th colspan="2" class="taC">日常相关费用</th>
  11730. </tr>';
  11731. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  11732. $html .= '
  11733. <tr>
  11734. <th>' . $value ['name'] . '</th>
  11735. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11736. </tr>';
  11737. }
  11738. $html .= '
  11739. <tr>
  11740. <th class="taR">合计</th>
  11741. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  11742. </tr>';
  11743. $html .= '<tr>
  11744. <th colspan="2" class="taC">差旅相关费用</th>
  11745. </tr>';
  11746. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  11747. $html .= '
  11748. <tr>
  11749. <th>' . $value ['name'] . '</th>
  11750. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11751. </tr>';
  11752. }
  11753. $html .= '
  11754. <tr>
  11755. <th class="taR">合计</th>
  11756. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  11757. </tr>';
  11758. $html .= '<tr>
  11759. <th colspan="2" class="taC">培训班费用</th>
  11760. </tr>';
  11761. foreach ( $detail ['accountItem'] ['培训班费用'] as $key => $value ) {
  11762. $html .= '
  11763. <tr>
  11764. <th>' . $value ['name'] . '</th>
  11765. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11766. </tr>';
  11767. }
  11768. $html .= '
  11769. <tr>
  11770. <th class="taR">合计</th>
  11771. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['trainSum'] . '</td>
  11772. </tr>';
  11773. $html .= '<tr>
  11774. <th colspan="2" class="taC">其他</th>
  11775. </tr>';
  11776. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  11777. $html .= '
  11778. <tr>
  11779. <th>' . $value ['name'] . '</th>
  11780. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11781. </tr>';
  11782. }
  11783. $html .= '
  11784. <tr>
  11785. <th class="taR">合计</th>
  11786. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  11787. </tr>';
  11788. $html .= '<tr>
  11789. <th colspan="2" class="taC">报销金额调整</th>
  11790. </tr>';
  11791. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  11792. $html .= '
  11793. <tr>
  11794. <th>' . $value ['name'] . '</th>
  11795. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11796. </tr>';
  11797. }
  11798. $html .= '
  11799. <tr>
  11800. <th class="taR">合计</th>
  11801. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  11802. </tr>';
  11803. $html .= '
  11804. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  11805. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  11806. <tr><th class="taC" colspan="2">报销说明</th></tr>
  11807. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  11808. <tr class="warning">
  11809. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  11810. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  11811. </tr>
  11812. </tbody>
  11813. </table>';
  11814. }
  11815. Doo::loadModel ( 'loanReceipt' );
  11816. $loanReceipt = new loanReceipt ();
  11817. $loanList = $loanReceipt->getOne ( array (
  11818. 'where' => 'rid=' . $detail ['loanRid'],
  11819. 'desc' => 'rid',
  11820. 'asArray' => true
  11821. ) );
  11822. // print_r($loanList);
  11823. $html .= '<table class="table table-bordered table-condensed">
  11824. <tbody>
  11825. <tr>
  11826. <th colspan="2" class="taC">借款费用</th>
  11827. </tr>';
  11828. foreach ( $detail ['loanItem'] ['借款费用'] as $key => $value ) {
  11829. $html .= '<tr>
  11830. <th>' . $value ['name'] . '</th>
  11831. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11832. </tr>';
  11833. }
  11834. $html .= '<tr>
  11835. <th class="taC" colspan="2">产生费用所在办事处</th>
  11836. </tr>
  11837. <tr>
  11838. <th style="text-align: center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th>
  11839. </tr>
  11840. <tr>
  11841. <th class="taC" colspan="2">费用说明</th>
  11842. </tr>
  11843. <tr>
  11844. <td colspan="2">' . $loanList ['explanation'] . '</td>
  11845. </tr>
  11846. <tr class="warning">
  11847. <td class="taR"><b>(' . $loanList ['receiptOrder'] . ')本次费用合计</b></td>
  11848. <td class="taR"><b style="font-size: 24px">¥' . $detail ['loanSum'] . '</b><br>' . $detail ['loanSumCN'] . '</td>
  11849. </tr>
  11850. </tbody>
  11851. </table>
  11852. ';
  11853. }
  11854. return $html;
  11855. }
  11856. /**
  11857. * 计算流水
  11858. */
  11859. function getWasteBookStatistics($waste = array(), $inComeStatistics) {
  11860. $bakWaste ['bank'] = array (
  11861. 'CGBDeposit' => 0,
  11862. 'ICBCDeposit' => 0,
  11863. 'HUADeposit' => 0,
  11864. 'PersonalDeposit' => 0
  11865. );
  11866. $bakWaste ['financial'] = array (
  11867. 'current' => array (
  11868. 'CGBDeposit' => 0,
  11869. 'ICBCDeposit' => 0
  11870. ),
  11871. 'fixed' => array (
  11872. 'CGBDeposit' => 0,
  11873. 'ICBCDeposit' => 0
  11874. )
  11875. );
  11876. // 存款
  11877. foreach ( $waste ['bank'] as $key => $value ) {
  11878. // 收入
  11879. foreach ( $inComeStatistics ['incomeStatistics'] as $k => $v ) {
  11880. // 广发
  11881. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  11882. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  11883. }
  11884. // 工商
  11885. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  11886. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  11887. }
  11888. // 华润
  11889. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  11890. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  11891. }
  11892. // 个人
  11893. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  11894. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  11895. }
  11896. }
  11897. }
  11898. foreach ( $waste ['bank'] as $key => $value ) {
  11899. // 支出
  11900. foreach ( $inComeStatistics ['expenditureStatistics'] as $k => $v ) {
  11901. // 广发
  11902. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  11903. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  11904. }
  11905. // 工商
  11906. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  11907. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  11908. }
  11909. // 华润
  11910. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  11911. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  11912. }
  11913. // 个人
  11914. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  11915. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  11916. }
  11917. }
  11918. }
  11919. // 活期
  11920. foreach ( $waste ['financial'] ['current'] as $key => $value ) {
  11921. foreach ( $inComeStatistics ['currentStatistics'] as $k => $v ) {
  11922. // 广发
  11923. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  11924. $waste ['financial'] ['current'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  11925. }
  11926. // 工商
  11927. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  11928. $waste ['financial'] ['current'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  11929. }
  11930. // 个人
  11931. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  11932. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  11933. }
  11934. }
  11935. }
  11936. // print_r($inComeStatistics ['fixedStatistics']);
  11937. // 固期
  11938. foreach ( $waste ['financial'] ['fixed'] as $key => $value ) {
  11939. foreach ( $inComeStatistics ['fixedStatistics'] as $k => $v ) {
  11940. // 广发
  11941. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  11942. $waste ['financial'] ['fixed'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  11943. }
  11944. // 工商
  11945. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  11946. $waste ['financial'] ['fixed'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  11947. }
  11948. // 个人
  11949. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  11950. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  11951. }
  11952. }
  11953. }
  11954. return $waste;
  11955. }
  11956. function lyt() {
  11957. Doo::loadModel ( "receiptDetail" );
  11958. $receiptDetail = new receiptDetail ();
  11959. $receiptCollectList = $receiptDetail->find ( array (
  11960. 'where' => 'status=1 ',
  11961. 'asArray' => true
  11962. ) );
  11963. foreach ( $receiptCollectList as $key => $value ) {
  11964. $receiptDetail = new receiptDetail ();
  11965. $receiptDetail->pastDate = $value ['date'];
  11966. $receiptDetail->update ( array (
  11967. 'where' => "rdid= '" . $value ['rdid'] . "'"
  11968. ) );
  11969. }
  11970. }
  11971. function staffCollectMonthDetail() {
  11972. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  11973. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  11974. if (! $year)
  11975. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  11976. if (! $month)
  11977. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  11978. Doo::loadModel ( 'staff' );
  11979. $staff = new staff ();
  11980. Doo::loadModel ( "receiptDetail" );
  11981. $receiptDetail = new receiptDetail ();
  11982. Doo::loadModel ( 'accountItem' );
  11983. $accountItem = new accountItem ();
  11984. Doo::loadModel ( 'statistics' );
  11985. $statistics = new statistics ();
  11986. Doo::loadModel ( 'L_category' );
  11987. $lCategory = new L_category ();
  11988. Doo::loadModel ( "receiptAuthorityManage" );
  11989. $receiptAuthorityManage = new receiptAuthorityManage ();
  11990. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  11991. $cidList = array ();
  11992. foreach ( $imcStaff as $key => $value ) {
  11993. array_push ( $cidList, $value ['cid'] );
  11994. }
  11995. $cidString = implode ( ',', $cidList );
  11996. $staffList = $staff->find ( array (
  11997. 'where' => 'username!="admin" and cid in (' . $cidString . ')',
  11998. 'asArray' => true
  11999. ) );
  12000. $categoryList = $staff->find ( array (
  12001. 'select' => 'COUNT(*) as count,cid,category',
  12002. 'where' => 'username !="admin" and cid in (' . $cidString . ')',
  12003. 'groupby' => 'cid',
  12004. 'asArray' => true
  12005. ) );
  12006. $list = array ();
  12007. foreach ( $categoryList as $vlu ) {
  12008. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  12009. $r1 = 0;
  12010. $r2 = 0;
  12011. $r3 = 0;
  12012. $r4 = 0;
  12013. $r5 = 0;
  12014. $r6 = 0;
  12015. $r7 = 0;
  12016. $r8 = 0;
  12017. $r9 = 0;
  12018. $r10 = 0;
  12019. $r11 = 0;
  12020. $r12 = 0;
  12021. $r13 = 0;
  12022. $r14 = 0;
  12023. $r15 = 0;
  12024. $r16 = 0;
  12025. $r17 = 0;
  12026. $r18 = 0;
  12027. $c1 = 0;
  12028. $c2 = 0;
  12029. $c3 = 0;
  12030. $c4 = 0;
  12031. $c5 = 0;
  12032. $c6 = 0;
  12033. $p1 = 0;
  12034. $p2 = 0;
  12035. $p3 = 0;
  12036. $p4 = 0;
  12037. $p5 = 0;
  12038. $p6 = 0;
  12039. $p7 = 0;
  12040. $p8 = 0;
  12041. $p9 = 0;
  12042. $p10 = 0;
  12043. $p11 = 0;
  12044. $t1 = 0;
  12045. $t2 = 0;
  12046. $t3 = 0;
  12047. $t4 = 0;
  12048. $t5 = 0;
  12049. $s1 = 0;
  12050. $m1 = 0;
  12051. foreach ( $staffList as $value ) {
  12052. if ($vlu ['cid'] == $value ['cid']) {
  12053. // pastDate
  12054. $receiptCollectList = $receiptDetail->find ( array (
  12055. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12056. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12057. 'groupby' => 'item,Month(pastDate),itemCategory',
  12058. 'asArray' => true
  12059. ) );
  12060. // if ($value['sid']==42){
  12061. // print_r($receiptCollectList);die;
  12062. // }
  12063. if (! empty ( $receiptCollectList )) {
  12064. $receiptL = array (
  12065. '日常相关费用' => array (),
  12066. '差旅相关费用' => array (),
  12067. '培训班费用' => array (),
  12068. '其他' => array ()
  12069. );
  12070. $html = "";
  12071. $psum = 0;
  12072. $item = array (
  12073. '市内交通费',
  12074. '市内出租费',
  12075. '办事处房租',
  12076. '电话费',
  12077. '水费',
  12078. '电费',
  12079. '办公费用',
  12080. '邮寄费',
  12081. '其他费用',
  12082. '车辆费用',
  12083. '广告费',
  12084. '团队建设费',
  12085. '物业管理费',
  12086. '宽带费',
  12087. '人员薪酬',
  12088. '公积金',
  12089. '社保'
  12090. );
  12091. foreach ( $item as $va ) {
  12092. $falg = true;
  12093. foreach ( $receiptCollectList as $v ) {
  12094. if ($v ['itemCategory'] == '日常相关费用') {
  12095. if ($v ['item'] == $va) {
  12096. if ($va == '市内交通费')
  12097. $r1 += $v ['price'];
  12098. if ($va == '市内出租费')
  12099. $r2 += $v ['price'];
  12100. if ($va == '办事处房租')
  12101. $r3 += $v ['price'];
  12102. if ($va == '电话费')
  12103. $r4 += $v ['price'];
  12104. if ($va == '水费')
  12105. $r5 += $v ['price'];
  12106. if ($va == '电费')
  12107. $r6 += $v ['price'];
  12108. if ($va == '办公费用')
  12109. $r7 += $v ['price'];
  12110. if ($va == '邮寄费')
  12111. $r8 += $v ['price'];
  12112. if ($va == '其他费用')
  12113. $r9 += $v ['price'];
  12114. if ($va == '车辆费用')
  12115. $r10 += $v ['price'];
  12116. if ($va == '广告费')
  12117. $r11 += $v ['price'];
  12118. if ($va == '团队建设费')
  12119. $r13 += $v ['price'];
  12120. if ($va == '物业管理费')
  12121. $r14 += $v ['price'];
  12122. if ($va == '宽带费')
  12123. $r15 += $v ['price'];
  12124. if ($va == '公积金')
  12125. $r16 += $v ['price'];
  12126. if ($va == '社保')
  12127. $r17 += $v ['price'];
  12128. if ($va == '人员薪酬')
  12129. $r18 += $v ['price'];
  12130. $psum += $v ['price'];
  12131. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12132. $falg = false;
  12133. break;
  12134. }
  12135. }
  12136. }
  12137. if ($falg)
  12138. $html .= '<td class="taR">-</td>';
  12139. }
  12140. $r12 += $psum;
  12141. if (! empty ( $psum ))
  12142. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12143. else
  12144. $psum = '<td class="colGreen taR">-</td>';
  12145. $receiptL ['日常相关费用'] = $psum . $html;
  12146. /* ----------------------------------- */
  12147. $html = "";
  12148. $psum = 0;
  12149. $item = array (
  12150. '往来交通费',
  12151. '市内交通费',
  12152. '出差住宿费',
  12153. '出差补助',
  12154. '其他费用'
  12155. );
  12156. foreach ( $item as $va ) {
  12157. $falg = true;
  12158. foreach ( $receiptCollectList as $v ) {
  12159. if ($v ['itemCategory'] == '差旅相关费用') {
  12160. if ($v ['item'] == $va) {
  12161. if ($va == '往来交通费')
  12162. $c1 += $v ['price'];
  12163. if ($va == '市内交通费')
  12164. $c2 += $v ['price'];
  12165. if ($va == '出差住宿费')
  12166. $c3 += $v ['price'];
  12167. if ($va == '出差补助')
  12168. $c4 += $v ['price'];
  12169. if ($va == '其他费用')
  12170. $c5 += $v ['price'];
  12171. $psum += $v ['price'];
  12172. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12173. $falg = false;
  12174. break;
  12175. }
  12176. }
  12177. }
  12178. if ($falg)
  12179. $html .= '<td class="taR">-</td>';
  12180. }
  12181. $c6 += $psum;
  12182. if (! empty ( $psum ))
  12183. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12184. else
  12185. $psum = '<td class="colGreen taR">-</td>';
  12186. $receiptL ['差旅相关费用'] = $psum . $html;
  12187. /* ------------------------------------- */
  12188. $html = "";
  12189. $psum = 0;
  12190. $item = array (
  12191. '场租费',
  12192. '薪酬',
  12193. '住宿费',
  12194. '交通费',
  12195. '餐饮费',
  12196. '办公费',
  12197. '公关费',
  12198. '其他',
  12199. '电话费',
  12200. '邮寄费'
  12201. );
  12202. foreach ( $item as $va ) {
  12203. $falg = true;
  12204. foreach ( $receiptCollectList as $v ) {
  12205. if ($v ['itemCategory'] == '培训班费用') {
  12206. if ($v ['item'] == $va) {
  12207. if ($va == '场租费')
  12208. $p1 += $v ['price'];
  12209. if ($va == '薪酬')
  12210. $p2 += $v ['price'];
  12211. if ($va == '住宿费')
  12212. $p3 += $v ['price'];
  12213. if ($va == '交通费')
  12214. $p4 += $v ['price'];
  12215. if ($va == '餐饮费')
  12216. $p5 += $v ['price'];
  12217. if ($va == '办公费')
  12218. $p6 += $v ['price'];
  12219. if ($va == '公关费')
  12220. $p7 += $v ['price'];
  12221. if ($va == '其他')
  12222. $p8 += $v ['price'];
  12223. if ($va == '电话费')
  12224. $p9 += $v ['price'];
  12225. if ($va == '邮寄费')
  12226. $p10 += $v ['price'];
  12227. $psum += $v ['price'];
  12228. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12229. $falg = false;
  12230. break;
  12231. }
  12232. }
  12233. }
  12234. if ($falg)
  12235. $html .= '<td class="taR">-</td>';
  12236. }
  12237. $p11 += $psum;
  12238. if (! empty ( $psum ))
  12239. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12240. else
  12241. $psum = '<td class="colGreen taR">-</td>';
  12242. $receiptL ['培训班费用'] = $psum . $html;
  12243. /* ------------------------------------- */
  12244. $html = "";
  12245. $psum = 0;
  12246. $item = array (
  12247. '公关费',
  12248. '广告费',
  12249. '借款',
  12250. '可自加费用'
  12251. );
  12252. foreach ( $item as $va ) {
  12253. $falg = true;
  12254. foreach ( $receiptCollectList as $v ) {
  12255. if ($v ['itemCategory'] == '其他') {
  12256. // if ($value['sid']==42){
  12257. //
  12258. // echo var_dump($v['item']);
  12259. // echo var_dump($va);
  12260. // echo var_dump($v['item']==" ".$va);
  12261. // echo $v['item']."==".$va."/<br/>";
  12262. // //print_r( $receiptCollectList);//echo $va;
  12263. // }
  12264. if (trim ( $v ['item'] ) == $va) {
  12265. if ($va == '公关费')
  12266. $t1 += $v ['price'];
  12267. if ($va == '广告费') {
  12268. $t2 += $v ['price'];
  12269. }
  12270. if ($va == '借款')
  12271. $t3 += $v ['price'];
  12272. if ($va == '可自加费用')
  12273. $t4 += $v ['price'];
  12274. $psum += $v ['price'];
  12275. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12276. $falg = false;
  12277. break;
  12278. }
  12279. }
  12280. }
  12281. if ($falg)
  12282. $html .= '<td class="taR">-</td>';
  12283. }
  12284. $t5 += $psum;
  12285. if (! empty ( $psum ))
  12286. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12287. else
  12288. $psum = '<td class="colGreen taR">-</td>';
  12289. $receiptL ['其他'] = $psum . $html;
  12290. /* ------------------------------------- */
  12291. $html = "";
  12292. $psum = 0;
  12293. foreach ( $receiptCollectList as $v ) {
  12294. if ($v ['itemCategory'] == '报销金额调整') {
  12295. if (! empty ( $v ['price'] )) {
  12296. $psum += $v ['price'];
  12297. }
  12298. }
  12299. }
  12300. $s1 += $psum;
  12301. if (! empty ( $psum ))
  12302. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  12303. else
  12304. $psum = '<td class="taR colOrange">-</td>';
  12305. $receiptL ['报销金额调整'] = $psum . $html;
  12306. } else {
  12307. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  12308. <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>
  12309. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12310. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  12311. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12312. $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>
  12313. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12314. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12315. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  12316. }
  12317. $monthStaffPrice = $receiptDetail->find ( array (
  12318. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12319. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12320. 'groupby' => 'Month(pastDate)',
  12321. 'asArray' => true
  12322. ) );
  12323. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  12324. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  12325. $m1 += $monthStaffPrice [0] ['price'];
  12326. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  12327. } else
  12328. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  12329. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  12330. $list [$value ['username']] = $receiptL;
  12331. }
  12332. }
  12333. $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>
  12334. <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>
  12335. <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>';
  12336. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  12337. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  12338. $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>
  12339. <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>';
  12340. $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>';
  12341. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  12342. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  12343. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  12344. }
  12345. $data ['list'] = $list;
  12346. // print_r($list);
  12347. $receiptCollectList = $receiptDetail->find ( array (
  12348. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12349. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12350. 'groupby' => 'item,Month(pastDate),itemCategory',
  12351. 'asArray' => true
  12352. ) );
  12353. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  12354. // statistics html
  12355. $stList = $statistics->getOne ( array (
  12356. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  12357. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  12358. 'groupby' => 'Month(date)',
  12359. 'asArray' => true
  12360. ) );
  12361. if (empty ( $stList ))
  12362. $stList = array (
  12363. 'rePrice' => 0,
  12364. 'agPrice' => 0
  12365. );
  12366. $data ['stList'] = array (
  12367. 'rePrice' => $stList ['rePrice'],
  12368. 'agPrice' => $stList ['agPrice'],
  12369. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12370. );
  12371. $monthHtml = "";
  12372. for($i = 1; $i <= 12; $i ++) {
  12373. if ($i == $month)
  12374. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  12375. else
  12376. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  12377. }
  12378. $data ['monthHtml'] = $monthHtml;
  12379. $data ['year'] = $year;
  12380. $data ['month'] = $month;
  12381. $data ['memu'] = "receipt";
  12382. $data ['staff'] = $this->staff;
  12383. $data ['receiptMemu'] = 'companyCategoryCollect';
  12384. $data ['verifyId'] = $this->verifyId;
  12385. $data ['executeId'] = $this->executeId;
  12386. $this->render ( "/admin/staffCollectMonthDetail", $data );
  12387. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  12388. }
  12389. function staffCollectMonthDetail2() {
  12390. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12391. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12392. if (! $year)
  12393. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12394. if (! $month)
  12395. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12396. Doo::loadModel ( 'staff' );
  12397. $staff = new staff ();
  12398. Doo::loadModel ( "receiptDetail" );
  12399. $receiptDetail = new receiptDetail ();
  12400. Doo::loadModel ( 'accountItem' );
  12401. $accountItem = new accountItem ();
  12402. Doo::loadModel ( 'statistics' );
  12403. $statistics = new statistics ();
  12404. Doo::loadModel ( 'L_category' );
  12405. $lCategory = new L_category ();
  12406. $staffList = $staff->find ( array (
  12407. 'where' => 'username!="admin"',
  12408. 'asArray' => true
  12409. ) );
  12410. $categoryList = $staff->find ( array (
  12411. 'select' => 'COUNT(*) as count,cid,category',
  12412. 'where' => 'username !="admin"',
  12413. 'groupby' => 'cid',
  12414. 'asArray' => true
  12415. ) );
  12416. $list = array ();
  12417. foreach ( $categoryList as $vlu ) {
  12418. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  12419. $r1 = 0;
  12420. $r2 = 0;
  12421. $r3 = 0;
  12422. $r4 = 0;
  12423. $r5 = 0;
  12424. $r6 = 0;
  12425. $r7 = 0;
  12426. $r8 = 0;
  12427. $r9 = 0;
  12428. $r10 = 0;
  12429. $r11 = 0;
  12430. $r12 = 0;
  12431. $r13 = 0;
  12432. $r14 = 0;
  12433. $r15 = 0;
  12434. $c1 = 0;
  12435. $c2 = 0;
  12436. $c3 = 0;
  12437. $c4 = 0;
  12438. $c5 = 0;
  12439. $c6 = 0;
  12440. $p1 = 0;
  12441. $p2 = 0;
  12442. $p3 = 0;
  12443. $p4 = 0;
  12444. $p5 = 0;
  12445. $p6 = 0;
  12446. $p7 = 0;
  12447. $p8 = 0;
  12448. $p9 = 0;
  12449. $t1 = 0;
  12450. $t2 = 0;
  12451. $t3 = 0;
  12452. $t4 = 0;
  12453. $t5 = 0;
  12454. $s1 = 0;
  12455. $m1 = 0;
  12456. foreach ( $staffList as $value ) {
  12457. if ($vlu ['cid'] == $value ['cid']) {
  12458. $receiptCollectList = $receiptDetail->find ( array (
  12459. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  12460. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  12461. 'groupby' => 'item,Month(date),itemCategory',
  12462. 'asArray' => true
  12463. ) );
  12464. if (! empty ( $receiptCollectList )) {
  12465. $receiptL = array (
  12466. '日常相关费用' => array (),
  12467. '差旅相关费用' => array (),
  12468. '培训班费用' => array (),
  12469. '其他' => array ()
  12470. );
  12471. $html = "";
  12472. $psum = 0;
  12473. $item = array (
  12474. '市内交通费',
  12475. '市内出租费',
  12476. '办事处房租',
  12477. '电话费',
  12478. '水费',
  12479. '电费',
  12480. '办公费用',
  12481. '邮寄费',
  12482. '其他费用',
  12483. '车辆费用',
  12484. '广告费',
  12485. '团队建设费',
  12486. '物业管理费',
  12487. '宽带费'
  12488. );
  12489. foreach ( $item as $va ) {
  12490. $falg = true;
  12491. foreach ( $receiptCollectList as $v ) {
  12492. if ($v ['itemCategory'] == '日常相关费用') {
  12493. if ($v ['item'] == $va) {
  12494. if ($va == '市内交通费')
  12495. $r1 += $v ['price'];
  12496. if ($va == '市内出租费')
  12497. $r2 += $v ['price'];
  12498. if ($va == '办事处房租')
  12499. $r3 += $v ['price'];
  12500. if ($va == '电话费')
  12501. $r4 += $v ['price'];
  12502. if ($va == '水费')
  12503. $r5 += $v ['price'];
  12504. if ($va == '电费')
  12505. $r6 += $v ['price'];
  12506. if ($va == '办公费用')
  12507. $r7 += $v ['price'];
  12508. if ($va == '邮寄费')
  12509. $r8 += $v ['price'];
  12510. if ($va == '其他费用')
  12511. $r9 += $v ['price'];
  12512. if ($va == '车辆费用')
  12513. $r10 += $v ['price'];
  12514. if ($va == '广告费')
  12515. $r11 += $v ['price'];
  12516. if ($va == '团队建设费')
  12517. $r13 += $v ['price'];
  12518. if ($va == '物业管理费')
  12519. $r14 += $v ['price'];
  12520. if ($va == '宽带费')
  12521. $r15 += $v ['price'];
  12522. $psum += $v ['price'];
  12523. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12524. $falg = false;
  12525. break;
  12526. }
  12527. }
  12528. }
  12529. if ($falg)
  12530. $html .= '<td class="taR">-</td>';
  12531. }
  12532. $r12 += $psum;
  12533. if (! empty ( $psum ))
  12534. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12535. else
  12536. $psum = '<td class="colGreen taR">-</td>';
  12537. $receiptL ['日常相关费用'] = $psum . $html;
  12538. /* ----------------------------------- */
  12539. $html = "";
  12540. $psum = 0;
  12541. $item = array (
  12542. '往来交通费',
  12543. '市内交通费',
  12544. '出差住宿费',
  12545. '出差补助',
  12546. '其他费用'
  12547. );
  12548. foreach ( $item as $va ) {
  12549. $falg = true;
  12550. foreach ( $receiptCollectList as $v ) {
  12551. if ($v ['itemCategory'] == '差旅相关费用') {
  12552. if ($v ['item'] == $va) {
  12553. if ($va == '往来交通费')
  12554. $c1 += $v ['price'];
  12555. if ($va == '市内交通费')
  12556. $c2 += $v ['price'];
  12557. if ($va == '出差住宿费')
  12558. $c3 += $v ['price'];
  12559. if ($va == '出差补助')
  12560. $c4 += $v ['price'];
  12561. if ($va == '其他费用')
  12562. $c5 += $v ['price'];
  12563. $psum += $v ['price'];
  12564. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12565. $falg = false;
  12566. break;
  12567. }
  12568. }
  12569. }
  12570. if ($falg)
  12571. $html .= '<td class="taR">-</td>';
  12572. }
  12573. $c6 += $psum;
  12574. if (! empty ( $psum ))
  12575. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12576. else
  12577. $psum = '<td class="colGreen taR">-</td>';
  12578. $receiptL ['差旅相关费用'] = $psum . $html;
  12579. /* ------------------------------------- */
  12580. $html = "";
  12581. $psum = 0;
  12582. $item = array (
  12583. '场租费',
  12584. '薪酬',
  12585. '住宿费',
  12586. '交通费',
  12587. '餐饮费',
  12588. '办公费',
  12589. '公关费',
  12590. '其他'
  12591. );
  12592. foreach ( $item as $va ) {
  12593. $falg = true;
  12594. foreach ( $receiptCollectList as $v ) {
  12595. if ($v ['itemCategory'] == '培训班费用') {
  12596. if ($v ['item'] == $va) {
  12597. if ($va == '场租费')
  12598. $p1 += $v ['price'];
  12599. if ($va == '薪酬')
  12600. $p2 += $v ['price'];
  12601. if ($va == '住宿费')
  12602. $p3 += $v ['price'];
  12603. if ($va == '交通费')
  12604. $p4 += $v ['price'];
  12605. if ($va == '餐饮费')
  12606. $p5 += $v ['price'];
  12607. if ($va == '办公费')
  12608. $p6 += $v ['price'];
  12609. if ($va == '公关费')
  12610. $p7 += $v ['price'];
  12611. if ($va == '其他')
  12612. $p8 += $v ['price'];
  12613. $psum += $v ['price'];
  12614. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12615. $falg = false;
  12616. break;
  12617. }
  12618. }
  12619. }
  12620. if ($falg)
  12621. $html .= '<td class="taR">-</td>';
  12622. }
  12623. $p9 += $psum;
  12624. if (! empty ( $psum ))
  12625. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12626. else
  12627. $psum = '<td class="colGreen taR">-</td>';
  12628. $receiptL ['培训班费用'] = $psum . $html;
  12629. /* ------------------------------------- */
  12630. $html = "";
  12631. $psum = 0;
  12632. $item = array (
  12633. '公关费',
  12634. '广告费',
  12635. '借款',
  12636. '可自加费用'
  12637. );
  12638. foreach ( $item as $va ) {
  12639. $falg = true;
  12640. foreach ( $receiptCollectList as $v ) {
  12641. if ($v ['itemCategory'] == '其他') {
  12642. if ($v ['item'] == $va) {
  12643. if ($va == '公关费')
  12644. $t1 += $v ['price'];
  12645. if ($va == '广告费')
  12646. $t2 += $v ['price'];
  12647. if ($va == '借款')
  12648. $t3 += $v ['price'];
  12649. if ($va == '可自加费用')
  12650. $t4 += $v ['price'];
  12651. $psum += $v ['price'];
  12652. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12653. $falg = false;
  12654. break;
  12655. }
  12656. }
  12657. }
  12658. if ($falg)
  12659. $html .= '<td class="taR">-</td>';
  12660. }
  12661. $t5 += $psum;
  12662. if (! empty ( $psum ))
  12663. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12664. else
  12665. $psum = '<td class="colGreen taR">-</td>';
  12666. $receiptL ['其他'] = $psum . $html;
  12667. /* ------------------------------------- */
  12668. $html = "";
  12669. $psum = 0;
  12670. foreach ( $receiptCollectList as $v ) {
  12671. if ($v ['itemCategory'] == '报销金额调整') {
  12672. if (! empty ( $v ['price'] )) {
  12673. $psum += $v ['price'];
  12674. }
  12675. }
  12676. }
  12677. $s1 += $psum;
  12678. if (! empty ( $psum ))
  12679. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  12680. else
  12681. $psum = '<td class="taR colOrange">-</td>';
  12682. $receiptL ['报销金额调整'] = $psum . $html;
  12683. } else {
  12684. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  12685. <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>';
  12686. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  12687. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12688. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  12689. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12690. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12691. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  12692. }
  12693. $monthStaffPrice = $receiptDetail->find ( array (
  12694. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  12695. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  12696. 'asArray' => true
  12697. ) );
  12698. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  12699. $m1 += $monthStaffPrice [0] ['price'];
  12700. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  12701. } else
  12702. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  12703. $list [$value ['username']] = $receiptL;
  12704. }
  12705. }
  12706. $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>
  12707. <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>
  12708. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  12709. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  12710. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  12711. $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>
  12712. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  12713. $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>';
  12714. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  12715. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  12716. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  12717. }
  12718. $data ['list'] = $list;
  12719. $receiptCollectList = $receiptDetail->find ( array (
  12720. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  12721. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  12722. 'groupby' => 'item,Month(date),itemCategory',
  12723. 'asArray' => true
  12724. ) );
  12725. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  12726. // statistics html
  12727. $stList = $statistics->getOne ( array (
  12728. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  12729. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  12730. 'groupby' => 'Month(date)',
  12731. 'asArray' => true
  12732. ) );
  12733. if (empty ( $stList ))
  12734. $stList = array (
  12735. 'rePrice' => 0,
  12736. 'agPrice' => 0
  12737. );
  12738. $data ['stList'] = array (
  12739. 'rePrice' => $stList ['rePrice'],
  12740. 'agPrice' => $stList ['agPrice'],
  12741. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12742. );
  12743. $monthHtml = "";
  12744. for($i = 1; $i <= 12; $i ++) {
  12745. if ($i == $month)
  12746. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  12747. else
  12748. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  12749. }
  12750. $data ['monthHtml'] = $monthHtml;
  12751. $data ['year'] = $year;
  12752. $data ['month'] = $month;
  12753. $data ['memu'] = "receipt";
  12754. $data ['staff'] = $this->staff;
  12755. $data ['receiptMemu'] = 'companyCategoryCollect';
  12756. $data ['verifyId'] = $this->verifyId;
  12757. $data ['executeId'] = $this->executeId;
  12758. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  12759. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  12760. }
  12761. /**
  12762. * 用户报销单列表
  12763. */
  12764. function receiptStatisticsStaffDetail() {
  12765. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12766. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12767. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  12768. Doo::loadModel ( "receipt" );
  12769. $receipt = new receipt ();
  12770. Doo::loadModel ( "receiptDetail" );
  12771. $receiptDetail = new receiptDetail ();
  12772. Doo::loadModel ( 'staff' );
  12773. $staff = new staff ();
  12774. Doo::loadModel ( 'accountItem' );
  12775. $accountItem = new accountItem ();
  12776. Doo::loadModel ( 'statistics' );
  12777. $statistics = new statistics ();
  12778. if (! empty ( $username )) {
  12779. $username = addslashes ( urldecode ( $username ) );
  12780. $staffDetail = $staff->getStaffByName ( $username );
  12781. if (empty ( $staffDetail ))
  12782. die ( 'illegal request' );
  12783. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  12784. $itemList = $accountItem->getAccountItem ();
  12785. $itemHtml = '';
  12786. $categoryHtml = '';
  12787. $itemKeyList = array_keys ( $itemList );
  12788. $revisePrice = 0;
  12789. // 报销单内容详情
  12790. foreach ( $list as $key => $value ) {
  12791. $accountItemList = json_decode ( $value ['accountItem'], true );
  12792. $list [$key] ['accountItemList'] = $accountItemList;
  12793. $receiptItemHtml = '';
  12794. foreach ( $itemKeyList as $v ) {
  12795. if ($v == '日常相关费用')
  12796. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  12797. elseif ($v == '差旅相关费用')
  12798. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  12799. elseif ($v == '培训班费用')
  12800. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  12801. elseif ($v == '其他')
  12802. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  12803. foreach ( $itemList [$v] as $ke => $va ) {
  12804. $falg = true;
  12805. if (! empty ( $accountItemList [$v] )) {
  12806. foreach ( $accountItemList [$v] as $ve ) {
  12807. if ($va ['name'] == $ve ['name']) {
  12808. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  12809. $falg = false;
  12810. break;
  12811. }
  12812. }
  12813. }
  12814. if ($falg)
  12815. $receiptItemHtml .= '<td class="taR"></td>';
  12816. }
  12817. }
  12818. // 金额调整和费用查看
  12819. $revisePrice += $value ['revisePrice'];
  12820. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  12821. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" onclick=showExplanation("' . $value ['explanation'] . '")>查看</a></td>';
  12822. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  12823. }
  12824. // 报销单合计
  12825. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  12826. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  12827. $receiptTotalHtml = '';
  12828. // 报销单项目抬头
  12829. foreach ( $itemKeyList as $value ) {
  12830. $count = count ( $itemList [$value] ) + 1;
  12831. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  12832. $categoryHtml .= '<th class="taC">合计</th>';
  12833. foreach ( $rtl as $rtlValue ) {
  12834. if ($rtlValue ['itemCategory'] == $value) {
  12835. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  12836. break;
  12837. }
  12838. }
  12839. foreach ( $itemList [$value] as $k => $v ) {
  12840. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  12841. // 合计
  12842. $falg = true;
  12843. foreach ( $receiptTotalList as $ve ) {
  12844. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  12845. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  12846. $falg = false;
  12847. break;
  12848. }
  12849. }
  12850. if ($falg)
  12851. $receiptTotalHtml .= '<th></th>';
  12852. }
  12853. }
  12854. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  12855. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  12856. if (empty ( $stList ))
  12857. $stList = array (
  12858. 'rePrice' => 0,
  12859. 'agPrice' => 0
  12860. );
  12861. $data ['stList'] = array (
  12862. 'rePrice' => $stList ['rePrice'],
  12863. 'agPrice' => $stList ['agPrice'],
  12864. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12865. );
  12866. $monthHtml = "";
  12867. for($i = 1; $i <= 12; $i ++) {
  12868. if ($i == $month)
  12869. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  12870. else
  12871. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  12872. }
  12873. $data ['username'] = urlencode ( $username );
  12874. $data ['usernameEN'] = $username;
  12875. $data ['monthHtml'] = $monthHtml;
  12876. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  12877. $data ['list'] = $list;
  12878. $data ['categoryHtml'] = $categoryHtml;
  12879. $data ['itemHtml'] = $itemHtml;
  12880. $data ['itemList'] = $itemList;
  12881. $data ['year'] = $year;
  12882. $data ['month'] = $month;
  12883. $data ['memu'] = "receipt";
  12884. $data ['staff'] = $this->staff;
  12885. $data ['receiptMemu'] = 'companyCategoryCollect';
  12886. $data ['verifyId'] = $this->verifyId;
  12887. $data ['executeId'] = $this->executeId;
  12888. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  12889. }
  12890. die ( 'illegal request' );
  12891. }
  12892. function companyMonthCollectDetail() {
  12893. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12894. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12895. if (! $year)
  12896. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12897. if (! $month)
  12898. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12899. Doo::loadModel ( 'staff' );
  12900. $staff = new staff ();
  12901. Doo::loadModel ( "receiptDetail" );
  12902. $receiptDetail = new receiptDetail ();
  12903. Doo::loadModel ( 'accountItem' );
  12904. $accountItem = new accountItem ();
  12905. Doo::loadModel ( 'statistics' );
  12906. $statistics = new statistics ();
  12907. Doo::loadModel ( 'L_category' );
  12908. $lCategory = new L_category ();
  12909. $staffList = $staff->find ( array (
  12910. 'where' => 'username!="admin"',
  12911. 'asArray' => true
  12912. ) );
  12913. $categoryList = $lCategory->find ( array (
  12914. 'asArray' => true
  12915. ) );
  12916. $list = array ();
  12917. foreach ( $categoryList as $value ) {
  12918. $receiptCollectList = $receiptDetail->find ( array (
  12919. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12920. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12921. 'groupby' => 'item,Month(pastDate),itemCategory',
  12922. 'asArray' => true
  12923. ) );
  12924. if (! empty ( $receiptCollectList )) {
  12925. $receiptL = array (
  12926. '日常相关费用' => array (),
  12927. '差旅相关费用' => array (),
  12928. '培训班费用' => array (),
  12929. '其他' => array ()
  12930. );
  12931. $html = "";
  12932. $psum = 0;
  12933. $item = array (
  12934. '市内交通费',
  12935. '市内出租费',
  12936. '办事处房租',
  12937. '电话费',
  12938. '水费',
  12939. '电费',
  12940. '办公费用',
  12941. '邮寄费',
  12942. '其他费用',
  12943. '车辆费用',
  12944. '广告费',
  12945. '团队建设费'
  12946. );
  12947. foreach ( $item as $va ) {
  12948. $falg = true;
  12949. foreach ( $receiptCollectList as $v ) {
  12950. if ($v ['itemCategory'] == '日常相关费用') {
  12951. if ($v ['item'] == $va) {
  12952. $psum += $v ['price'];
  12953. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12954. $falg = false;
  12955. break;
  12956. }
  12957. }
  12958. }
  12959. if ($falg)
  12960. $html .= '<td class="taR">-</td>';
  12961. }
  12962. if (! empty ( $psum ))
  12963. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  12964. else
  12965. $psum = '<td class="colGreen taR">-</td>';
  12966. $receiptL ['日常相关费用'] = $psum . $html;
  12967. /* ----------------------------------- */
  12968. $html = "";
  12969. $psum = 0;
  12970. $item = array (
  12971. '往来交通费',
  12972. '市内交通费',
  12973. '出差住宿费',
  12974. '出差补助',
  12975. '其他费用'
  12976. );
  12977. foreach ( $item as $va ) {
  12978. $falg = true;
  12979. foreach ( $receiptCollectList as $v ) {
  12980. if ($v ['itemCategory'] == '差旅相关费用') {
  12981. if ($v ['item'] == $va) {
  12982. $psum += $v ['price'];
  12983. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12984. $falg = false;
  12985. break;
  12986. }
  12987. }
  12988. }
  12989. if ($falg)
  12990. $html .= '<td class="taR">-</td>';
  12991. }
  12992. if (! empty ( $psum ))
  12993. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  12994. else
  12995. $psum = '<td class="colGreen taR">-</td>';
  12996. $receiptL ['差旅相关费用'] = $psum . $html;
  12997. /* ------------------------------------- */
  12998. $html = "";
  12999. $psum = 0;
  13000. $item = array (
  13001. '场租费',
  13002. '薪酬',
  13003. '住宿费',
  13004. '交通费',
  13005. '餐饮费',
  13006. '办公费',
  13007. '公关费',
  13008. '其他'
  13009. );
  13010. foreach ( $item as $va ) {
  13011. $falg = true;
  13012. foreach ( $receiptCollectList as $v ) {
  13013. if ($v ['itemCategory'] == '培训班费用') {
  13014. if ($v ['item'] == $va) {
  13015. $psum += $v ['price'];
  13016. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13017. $falg = false;
  13018. break;
  13019. }
  13020. }
  13021. }
  13022. if ($falg)
  13023. $html .= '<td class="taR">-</td>';
  13024. }
  13025. if (! empty ( $psum ))
  13026. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13027. else
  13028. $psum = '<td class="colGreen taR">-</td>';
  13029. $receiptL ['培训班费用'] = $psum . $html;
  13030. /* ------------------------------------- */
  13031. $html = "";
  13032. $psum = 0;
  13033. $item = array (
  13034. '公关费',
  13035. '广告费',
  13036. '借款',
  13037. '可自加费用'
  13038. );
  13039. foreach ( $item as $va ) {
  13040. $falg = true;
  13041. foreach ( $receiptCollectList as $v ) {
  13042. if ($v ['itemCategory'] == '其他') {
  13043. if ($v ['item'] == $va) {
  13044. $psum += $v ['price'];
  13045. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13046. $falg = false;
  13047. break;
  13048. }
  13049. }
  13050. }
  13051. if ($falg)
  13052. $html .= '<td class="taR">-</td>';
  13053. }
  13054. if (! empty ( $psum ))
  13055. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13056. else
  13057. $psum = '<td class="colGreen taR">-</td>';
  13058. $receiptL ['其他'] = $psum . $html;
  13059. /* ------------------------------------- */
  13060. $html = "";
  13061. $psum = 0;
  13062. foreach ( $receiptCollectList as $v ) {
  13063. if ($v ['itemCategory'] == '报销金额调整') {
  13064. if (! empty ( $v ['price'] ))
  13065. $psum += $v ['price'];
  13066. }
  13067. }
  13068. if (! empty ( $psum ))
  13069. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  13070. else
  13071. $psum = '<td class="taR colOrange">-</td>';
  13072. $receiptL ['报销金额调整'] = $psum . $html;
  13073. } else {
  13074. $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>
  13075. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13076. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  13077. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13078. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13079. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13080. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13081. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13082. }
  13083. $monthStaffPrice = $receiptDetail->find ( array (
  13084. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13085. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13086. 'asArray' => true
  13087. ) );
  13088. if (! empty ( $monthStaffPrice [0] ['price'] ))
  13089. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13090. else
  13091. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13092. $list [$value ['title']] = $receiptL;
  13093. }
  13094. $data ['list'] = $list;
  13095. $receiptCollectList = $receiptDetail->find ( array (
  13096. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13097. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13098. 'groupby' => 'item,Month(pastDate),itemCategory',
  13099. 'asArray' => true
  13100. ) );
  13101. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  13102. // print_r($data['monthPriceHtml']);
  13103. // foreach ($data['monthPriceHtml'] as $value){
  13104. // echo $value;
  13105. // }
  13106. // die;
  13107. // statistics html
  13108. $stList = $statistics->getOne ( array (
  13109. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13110. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13111. 'groupby' => 'Month(date)',
  13112. 'asArray' => true
  13113. ) );
  13114. if (empty ( $stList ))
  13115. $stList = array (
  13116. 'rePrice' => 0,
  13117. 'agPrice' => 0
  13118. );
  13119. $data ['stList'] = array (
  13120. 'rePrice' => $stList ['rePrice'],
  13121. 'agPrice' => $stList ['agPrice'],
  13122. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13123. );
  13124. $monthHtml = "";
  13125. for($i = 1; $i <= 12; $i ++) {
  13126. if ($i == $month)
  13127. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13128. else
  13129. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13130. }
  13131. $data ['monthHtml'] = $monthHtml;
  13132. $data ['year'] = $year;
  13133. $data ['month'] = $month;
  13134. $data ['memu'] = "receipt";
  13135. $data ['staff'] = $this->staff;
  13136. $data ['receiptMemu'] = 'companyCategoryCollect';
  13137. $data ['verifyId'] = $this->verifyId;
  13138. $data ['executeId'] = $this->executeId;
  13139. $this->render ( "/admin/companyMonthCollectDetail", $data );
  13140. }
  13141. function staffCollectDetail() {
  13142. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  13143. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13144. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  13145. if (! $staffname) {
  13146. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  13147. $staffname = urldecode ( $staffname );
  13148. }
  13149. Doo::loadModel ( 'staff' );
  13150. $staff = new staff ();
  13151. Doo::loadModel ( "receiptDetail" );
  13152. $receiptDetail = new receiptDetail ();
  13153. Doo::loadModel ( 'accountItem' );
  13154. $accountItem = new accountItem ();
  13155. Doo::loadModel ( 'statistics' );
  13156. $statistics = new statistics ();
  13157. Doo::loadModel ( 'L_category' );
  13158. $lCategory = new L_category ();
  13159. Doo::loadModel ( "receiptAuthorityManage" );
  13160. $receiptAuthorityManage = new receiptAuthorityManage ();
  13161. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  13162. $cidList = array ();
  13163. foreach ( $imcStaff as $key => $value ) {
  13164. array_push ( $cidList, $value ['cid'] );
  13165. }
  13166. $cidString = implode ( ',', $cidList );
  13167. $staffList = $staff->find ( array (
  13168. 'where' => ' cid in (' . $cidString . ')',
  13169. 'asArray' => true
  13170. ) );
  13171. $stHtml = '';
  13172. $stTitle = "";
  13173. $staffId = 0;
  13174. $cid = 0;
  13175. $ocid = 0;
  13176. foreach ( $staffList as $value ) {
  13177. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  13178. $stTitle = $value ['category'] . '-' . $value ['username'];
  13179. $staffId = $value ['sid'];
  13180. $cid = $value ['cid'];
  13181. $ocid = $value ['cid'];
  13182. if (! empty ( $value ['othercid'] ))
  13183. $cid = $value ['cid'] . ',' . $value ['othercid'];
  13184. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13185. } elseif ($value ['username'] != 'admin')
  13186. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13187. }
  13188. $data ['lCategoryHtml'] = $lCategory->find ( array (
  13189. 'where' => 'cid in(' . $cid . ')',
  13190. 'asArray' => true
  13191. ) );
  13192. if (empty ( $pcid ))
  13193. $pcid = $ocid;
  13194. $data ['ocid'] = $pcid;
  13195. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  13196. $this->showCache ( $path );
  13197. //
  13198. $receiptCollectList = $receiptDetail->find ( array (
  13199. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13200. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  13201. 'groupby' => 'item,Month(pastDate),itemCategory',
  13202. 'asArray' => true
  13203. ) );
  13204. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  13205. // print_r($receiptCollectList);
  13206. $accountList = $accountItem->find ( array (
  13207. 'asArray' => true
  13208. ) );
  13209. // create CollectDetail HTML
  13210. $collectHtml = array ();
  13211. foreach ( $accountList as $key => $value ) {
  13212. $html = "";
  13213. $asum = 0;
  13214. for($i = 1; $i <= 12; $i ++) {
  13215. $falg = true;
  13216. foreach ( $receiptCollectList as $v ) {
  13217. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  13218. if ($v ['item'] == '可自加费用') {
  13219. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  13220. }
  13221. $asum += $v ['price'];
  13222. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13223. $falg = false;
  13224. break;
  13225. }
  13226. }
  13227. if ($falg)
  13228. $html .= '<td class="taR">-</td>';
  13229. }
  13230. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  13231. $collectHtml [$value ['category']] [$value ['name']] = $html;
  13232. }
  13233. $data ['collectHtml'] = $collectHtml;
  13234. // print_r($collectHtml);
  13235. // create Adjustment price html
  13236. $receiptCollectList = $receiptDetail->find ( array (
  13237. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  13238. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  13239. 'groupby' => 'itemCategory,Month(pastDate)',
  13240. 'asArray' => true
  13241. ) );
  13242. $adjustment = array ();
  13243. $collectArray = array (
  13244. '日常相关费用' => array (),
  13245. '差旅相关费用' => array (),
  13246. '培训班费用' => array (),
  13247. '其他' => array ()
  13248. );
  13249. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  13250. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  13251. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  13252. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  13253. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  13254. array_push ( $collectArray ['培训班费用'], $collectHtml );
  13255. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  13256. array_push ( $collectArray ['其他'], $collectHtml );
  13257. $data ['collectArray'] = $collectArray;
  13258. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  13259. array_push ( $adjustment, $collectHtml );
  13260. $data ['adjustment'] = $adjustment;
  13261. // total price html
  13262. $collectHtml = "";
  13263. $total = 0;
  13264. for($i = 1; $i <= 12; $i ++) {
  13265. $sumPrice = 0;
  13266. foreach ( $receiptCollectList as $key => $value ) {
  13267. if ($value ['month'] == $i) {
  13268. $sumPrice += $value ['price'];
  13269. }
  13270. }
  13271. if ($sumPrice == 0)
  13272. $collectHtml .= '<td class="taR">-</td>';
  13273. else
  13274. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  13275. $total += $sumPrice;
  13276. }
  13277. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  13278. // statistics html
  13279. $stList = $statistics->statisticsByYear ( $year, $staffId );
  13280. if (empty ( $stList ))
  13281. $stList = array (
  13282. 'rePrice' => 0,
  13283. 'agPrice' => 0
  13284. );
  13285. $data ['stList'] = array (
  13286. 'rePrice' => $stList ['rePrice'],
  13287. 'agPrice' => $stList ['agPrice'],
  13288. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13289. );
  13290. $data ['totalPrice'] = $collectHtml;
  13291. $data ['totalYear'] = $total;
  13292. $data ['stHtml'] = $stHtml;
  13293. $data ['year'] = $year;
  13294. $data ['stTitle'] = $stTitle;
  13295. $data ['staffname'] = urlencode ( $staffname );
  13296. $data ['memu'] = "receipt";
  13297. $data ['staff'] = $this->staff;
  13298. $data ['receiptMemu'] = 'companyCategoryCollect';
  13299. $data ['verifyId'] = $this->verifyId;
  13300. $data ['executeId'] = $this->executeId;
  13301. if ($year < date ( "Y" )) {
  13302. Doo::loadModel ( 'receipt' );
  13303. $receipt = new receipt ();
  13304. $receiptList = $receipt->find ( array (
  13305. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  13306. 'asArray' => true
  13307. ) );
  13308. if (empty ( $receiptList )) { // generated files
  13309. ob_start ();
  13310. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13311. $this->cacheFile ( $path );
  13312. die ();
  13313. }
  13314. }
  13315. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13316. }
  13317. function BUGFLAG() {
  13318. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  13319. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  13320. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13321. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  13322. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  13323. if (empty ( $status ))
  13324. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  13325. $page_size = 12;
  13326. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  13327. $vidList = array ();
  13328. $button = 0;
  13329. Doo::loadModel ( 'verify' );
  13330. $verify = new verify ();
  13331. Doo::loadModel ( 'receipt' );
  13332. $receipt = new receipt ();
  13333. Doo::loadModel ( 'staff' );
  13334. $staff = new staff ();
  13335. Doo::loadModel ( 'L_category' );
  13336. $Lcategory = new L_category ();
  13337. $dateCondition = " and Year(date) =" . $year;
  13338. if (! empty ( $month ))
  13339. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  13340. $categoryList = $Lcategory->find ( array (
  13341. 'asArray' => true
  13342. ) );
  13343. $staffList = $staff->find ( array (
  13344. 'where' => 'cid=' . $cid,
  13345. 'asArray' => true
  13346. ) );
  13347. $cateCondition = "";
  13348. $staffCondition = "";
  13349. $approvalCondition = "";
  13350. if (! empty ( $cid ))
  13351. $cateCondition = ' and cid=' . $cid;
  13352. if (! empty ( $sid )) {
  13353. $staffCondition = ' and staff=' . $sid;
  13354. $cateCondition = "";
  13355. }
  13356. $approvalCondition = " and status=" . $status;
  13357. if ($status == 2) {
  13358. // 查找角色审批人
  13359. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  13360. }
  13361. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  13362. $approvalCondition = ' and status=2 ';
  13363. }
  13364. if ($status == 1) {
  13365. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  13366. }
  13367. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  13368. $pageinfo ['page'] = array (
  13369. 'previous' => ''
  13370. );
  13371. if ($status == 0) {
  13372. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  13373. $receiptList = $receipt->find ( array (
  13374. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  13375. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  13376. 'desc' => 'rid',
  13377. 'asArray' => true
  13378. ) );
  13379. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  13380. } else
  13381. $receiptList = $receipt->find ( array (
  13382. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  13383. 'desc' => 'rid',
  13384. 'asArray' => true
  13385. ) );
  13386. $rLRes = $receipt->find ( array (
  13387. '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,
  13388. 'desc' => 'rid',
  13389. 'asArray' => true
  13390. ) );
  13391. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  13392. // print_r($pageinfo);
  13393. $Locate = 0;
  13394. foreach ( $receiptList as $key => $value ) {
  13395. $receiptList [$key] ['Locate'] = $Locate;
  13396. $Locate ++;
  13397. $receiptList [$key] ['reviseDetail'] = array ();
  13398. if (! empty ( $value ['reviseDetail'] ))
  13399. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  13400. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  13401. $categoryDetil = $Lcategory->getOne ( array (
  13402. 'where' => 'cid=' . $value ['cid'],
  13403. 'asArray' => true
  13404. ) );
  13405. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  13406. $verifyList = $verify->getOne ( array (
  13407. 'where' => 'vid=' . $value ['verify'],
  13408. 'asArray' => true
  13409. ) );
  13410. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  13411. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  13412. foreach ( $verifyList as $k => $v ) {
  13413. // init verifyStaff
  13414. $verifyList [$k] ['date'] = "";
  13415. $verifyList [$k] ['opinion'] = "";
  13416. $verifyList [$k] ['status'] = "";
  13417. if (empty ( $verifyStaff )) {
  13418. $verifyList [$k] ['date'] = "";
  13419. $verifyList [$k] ['opinion'] = "";
  13420. if ($v [0] == $this->staff [0] ['sid']) {
  13421. $verifyList [$k] ['status'] = 4;
  13422. $button = 4;
  13423. }
  13424. } else {
  13425. $flag = true;
  13426. foreach ( $verifyStaff as $m => $u ) {
  13427. if ($v [0] == $m) {
  13428. $verifyList [$k] ['date'] = $u ['date'];
  13429. $verifyList [$k] ['opinion'] = $u ['opinion'];
  13430. $verifyList [$k] ['status'] = $u ['status'];
  13431. $flag = false;
  13432. break;
  13433. }
  13434. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  13435. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  13436. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  13437. }
  13438. if ($flag) { // 检测可编辑
  13439. if ($v [0] == $this->staff [0] ['sid']) {
  13440. $verifyList [$k] ['status'] = 4;
  13441. $button = 4;
  13442. }
  13443. }
  13444. }
  13445. }
  13446. $receiptList [$key] ['verifyList'] = $verifyList;
  13447. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  13448. 'where' => 'sid=' . $value ['staff'],
  13449. 'asArray' => true
  13450. ) );
  13451. $receiptList [$key] ['button'] = $button;
  13452. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  13453. }
  13454. // print_r($receiptList);die;
  13455. // $data['verifyDetail']=$verifyDetail;
  13456. $mothHtml = "";
  13457. for($i = 1; $i <= 12; $i ++) {
  13458. if ($month == $i)
  13459. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  13460. else
  13461. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  13462. }
  13463. $data ['mothHtml'] = $mothHtml;
  13464. $data ['page'] = $pageinfo;
  13465. $data ['receiptList'] = $receiptList;
  13466. $data ['receiptApprovalCount'] = count ( $rLRes );
  13467. $data ['status'] = $status;
  13468. $data ['year'] = $year;
  13469. $data ['categoryList'] = $categoryList;
  13470. $data ['staffList'] = $staffList;
  13471. $data ['cid'] = $cid;
  13472. $data ['sid'] = $sid;
  13473. // print_r($receiptList);
  13474. $data ['memu'] = "receipt";
  13475. $data ['staff'] = $this->staff;
  13476. $data ['receiptMemu'] = 'approvalExpenses';
  13477. $data ['verifyId'] = $this->verifyId;
  13478. $data ['executeId'] = $this->executeId;
  13479. $this->render ( "/admin/FALG", $data );
  13480. }
  13481. function ajaxGetReceiptOrder() {
  13482. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  13483. if (! empty ( $receiptOrder )) {
  13484. Doo::loadModel ( 'receipt' );
  13485. $receipt = new receipt ();
  13486. Doo::loadModel ( 'staff' );
  13487. $staff = new staff ();
  13488. $receiptInfo = $receipt->getOne ( array (
  13489. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  13490. 'asArray' => true
  13491. ) );
  13492. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  13493. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  13494. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  13495. </tbody></table><table class="table table table-bordered"><tbody>';
  13496. foreach ( $verifyStaff as $key => $value ) {
  13497. $staffInfo = $staff->getOne ( array (
  13498. 'select' => 'username',
  13499. 'where' => ' sid="' . $key . '"',
  13500. 'asArray' => true
  13501. ) );
  13502. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  13503. }
  13504. $html .= '</tbody></table></div></div>';
  13505. echo json_encode ( array (
  13506. 'status' => 1,
  13507. 'receiptHtml' => $html
  13508. ) );
  13509. die ();
  13510. }
  13511. echo json_encode ( array (
  13512. 'status' => 2,
  13513. 'receiptHtml' => ''
  13514. ) );
  13515. die ();
  13516. }
  13517. function _getMonthCollectDetail($receiptCollectList) {
  13518. if (! empty ( $receiptCollectList )) {
  13519. $receiptL = array (
  13520. '日常相关费用' => array (),
  13521. '差旅相关费用' => array (),
  13522. '培训班费用' => array (),
  13523. '其他' => array ()
  13524. );
  13525. $html = "";
  13526. $psum = 0;
  13527. $item = array (
  13528. '市内交通费',
  13529. '市内出租费',
  13530. '办事处房租',
  13531. '电话费',
  13532. '水费',
  13533. '电费',
  13534. '办公费用',
  13535. '邮寄费',
  13536. '其他费用',
  13537. '车辆费用',
  13538. '广告费',
  13539. '团队建设费',
  13540. '物业管理费',
  13541. '宽带费',
  13542. '人员薪酬',
  13543. '公积金',
  13544. '社保'
  13545. );
  13546. foreach ( $item as $value ) {
  13547. $falg = true;
  13548. foreach ( $receiptCollectList as $v ) {
  13549. if ($v ['itemCategory'] == '日常相关费用') {
  13550. if ($v ['item'] == $value) {
  13551. $psum += $v ['price'];
  13552. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13553. $falg = false;
  13554. break;
  13555. }
  13556. }
  13557. }
  13558. if ($falg)
  13559. $html .= '<td class="taR">-</td>';
  13560. }
  13561. if (! empty ( $psum ))
  13562. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13563. else
  13564. $psum = '<td class="colGreen taR">-</td>';
  13565. $receiptL ['日常相关费用'] = $psum . $html;
  13566. /* ----------------------------------- */
  13567. $html = "";
  13568. $psum = 0;
  13569. $item = array (
  13570. '往来交通费',
  13571. '市内交通费',
  13572. '出差住宿费',
  13573. '出差补助',
  13574. '其他费用'
  13575. );
  13576. foreach ( $item as $value ) {
  13577. $falg = true;
  13578. foreach ( $receiptCollectList as $v ) {
  13579. if ($v ['itemCategory'] == '差旅相关费用') {
  13580. if ($v ['item'] == $value) {
  13581. $psum += $v ['price'];
  13582. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13583. $falg = false;
  13584. break;
  13585. }
  13586. }
  13587. }
  13588. if ($falg)
  13589. $html .= '<td class="taR">-</td>';
  13590. }
  13591. if (! empty ( $psum ))
  13592. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13593. else
  13594. $psum = '<td class="colGreen taR">-</td>';
  13595. $receiptL ['差旅相关费用'] = $psum . $html;
  13596. /* ------------------------------------- */
  13597. $html = "";
  13598. $psum = 0;
  13599. $item = array (
  13600. '场租费',
  13601. '薪酬',
  13602. '住宿费',
  13603. '交通费',
  13604. '餐饮费',
  13605. '办公费',
  13606. '公关费',
  13607. '其他',
  13608. '电话费',
  13609. '邮寄费'
  13610. );
  13611. foreach ( $item as $value ) {
  13612. $falg = true;
  13613. foreach ( $receiptCollectList as $v ) {
  13614. if ($v ['itemCategory'] == '培训班费用') {
  13615. if ($v ['item'] == $value) {
  13616. $psum += $v ['price'];
  13617. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13618. $falg = false;
  13619. break;
  13620. }
  13621. }
  13622. }
  13623. if ($falg)
  13624. $html .= '<td class="taR">-</td>';
  13625. }
  13626. if (! empty ( $psum ))
  13627. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13628. else
  13629. $psum = '<td class="colGreen taR">-</td>';
  13630. $receiptL ['培训班费用'] = $psum . $html;
  13631. /* ------------------------------------- */
  13632. $html = "";
  13633. $psum = 0;
  13634. $item = array (
  13635. '公关费',
  13636. '广告费',
  13637. '借款',
  13638. '可自加费用'
  13639. );
  13640. foreach ( $item as $value ) {
  13641. $falg = true;
  13642. foreach ( $receiptCollectList as $v ) {
  13643. if ($v ['itemCategory'] == '其他') {
  13644. if ($v ['item'] == $value) {
  13645. $psum += $v ['price'];
  13646. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13647. $falg = false;
  13648. break;
  13649. }
  13650. }
  13651. }
  13652. if ($falg)
  13653. $html .= '<td class="taR">-</td>';
  13654. }
  13655. if (! empty ( $psum ))
  13656. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13657. else
  13658. $psum = '<td class="colGreen taR">-</td>';
  13659. $receiptL ['其他'] = $psum . $html;
  13660. /* ------------------------------------- */
  13661. $html = "";
  13662. $psum = 0;
  13663. foreach ( $receiptCollectList as $v ) {
  13664. if ($v ['itemCategory'] == '报销金额调整') {
  13665. if (! empty ( $v ['price'] ))
  13666. $psum += $v ['price'];
  13667. }
  13668. }
  13669. if (! empty ( $psum ))
  13670. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  13671. else
  13672. $psum = '<td class="taR colOrange">-</td>';
  13673. $receiptL ['报销金额调整'] = $psum . $html;
  13674. } else {
  13675. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td>
  13676. <td class="taR">-</td>
  13677. <td class="taR">-</td>
  13678. <td class="taR">-</td>
  13679. <td class="taR">-</td>
  13680. <td class="taR">-</td>
  13681. <td class="taR">-</td>
  13682. <td class="taR">-</td>
  13683. <td class="taR">-</td>
  13684. <td class="taR">-</td>
  13685. <td class="taR">-</td>
  13686. <td class="taR">-</td>
  13687. <td class="taR">-</td>';
  13688. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  13689. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13690. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td>
  13691. <td class="taR">-</td>
  13692. <td class="taR">-</td>
  13693. <td class="taR">-</td>
  13694. <td class="taR">-</td>
  13695. <td class="taR">-</td>
  13696. <td class="taR">-</td>
  13697. <td class="taR">-</td>
  13698. <td class="taR">-</td>';
  13699. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13700. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13701. }
  13702. return $receiptL;
  13703. }
  13704. function eMail() {
  13705. Doo::loadModel ( 'staff' );
  13706. $staff = new staff ();
  13707. Doo::loadModel ( 'receipt' );
  13708. $receipt = new receipt ();
  13709. Doo::loadModel ( 'L_category' );
  13710. $Lcategory = new L_category ();
  13711. Doo::loadModel ( "verify" );
  13712. $verify = new verify ();
  13713. $staffList = $staff->find ( array (
  13714. 'asArray' => true
  13715. ) );
  13716. foreach ( $staffList as $key => $value ) {
  13717. if ($value ['username'] != 'admin') {
  13718. // 提交人
  13719. $receiptList = $receipt->find ( array (
  13720. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  13721. 'asArray' => true
  13722. ) );
  13723. if (! empty ( $receiptList )) {
  13724. $html = '<br><div><style></style>
  13725. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  13726. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  13727. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  13728. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  13729. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  13730. <tbody><tr>
  13731. <td style="padding: 0 40px;" align="left">
  13732. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  13733. </td></tr><tr>
  13734. <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>
  13735. </tr>
  13736. </tbody> </table></td> </tr> <tr><td>
  13737. <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">
  13738. <tbody> <tr><td>
  13739. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  13740. 以下报销单完成了审批,等着收款吧:</p>
  13741. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  13742. foreach ( $receiptList as $k => $v ) {
  13743. $category = $Lcategory->getOne ( array (
  13744. 'where' => 'cid=' . $v ['cid'],
  13745. 'asArray' => true
  13746. ) );
  13747. $html .= '
  13748. <tr>
  13749. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  13750. <td align="left">
  13751. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  13752. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  13753. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  13754. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  13755. </tr>';
  13756. }
  13757. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  13758. <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>
  13759. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  13760. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  13761. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  13762. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  13763. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  13764. $receipt = new receipt ();
  13765. $receipt->notice = 1;
  13766. $receipt->update ( array (
  13767. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  13768. ) );
  13769. }
  13770. }
  13771. // 审批人
  13772. $verifyList = $verify->find ( array (
  13773. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  13774. 'asArray' => true
  13775. ) );
  13776. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  13777. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  13778. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  13779. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  13780. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  13781. <tbody><tr><td style="padding: 0 40px;" align="left">
  13782. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  13783. </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>
  13784. </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">
  13785. <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>
  13786. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  13787. foreach ( $verifyList as $k => $v ) {
  13788. $receiptList = $receipt->find ( array (
  13789. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  13790. 'asArray' => true
  13791. ) );
  13792. foreach ( $receiptList as $r => $l ) {
  13793. $category = $Lcategory->getOne ( array (
  13794. 'where' => 'cid=' . $l ['cid'],
  13795. 'asArray' => true
  13796. ) );
  13797. $staffDetile = $staff->getOne ( array (
  13798. 'where' => 'sid=' . $l ['staff'],
  13799. 'asArray' => true
  13800. ) );
  13801. $html .= '
  13802. <tr>
  13803. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  13804. <td align="left">
  13805. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  13806. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  13807. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  13808. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  13809. </tr>';
  13810. }
  13811. }
  13812. $html .= '
  13813. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  13814. <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>
  13815. </tr></tbody></table></td></tr></tbody></table></div><br>';
  13816. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  13817. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  13818. // $receipt=new receipt();
  13819. // $receipt->notice=1;
  13820. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  13821. }
  13822. }
  13823. }
  13824. }
  13825. function setWXMsg($rid, $type) {
  13826. Doo::loadModel ( "receipt" );
  13827. $receipt = new receipt ();
  13828. $receiptDetail = $receipt->getOne ( array (
  13829. 'where' => 'rid=' . $rid,
  13830. 'asArray' => true
  13831. ) );
  13832. if (! empty ( $receiptDetail )) {
  13833. Doo::loadModel ( 'staff' );
  13834. $staff = new staff ();
  13835. $staffmsg = $staff->getOne ( array (
  13836. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  13837. 'asArray' => TRUE
  13838. ) );
  13839. if (! empty ( $staffmsg ['wxid'] )) {
  13840. require_once (SITE_PATH . '/protected/class/client.php');
  13841. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  13842. $user = $staffmsg ['wxid'];
  13843. $receiptName = '';
  13844. $msg = '';
  13845. switch ($receiptDetail ['Rtype']) {
  13846. case 0 :
  13847. $receiptName = '报销';
  13848. break;
  13849. case 1 :
  13850. $receiptName = '借款';
  13851. break;
  13852. case 2 :
  13853. $receiptName = '对公汇款';
  13854. break;
  13855. }
  13856. switch ($type) {
  13857. case 1 :
  13858. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  13859. break;
  13860. case 2 :
  13861. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  13862. break;
  13863. case 3 :
  13864. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  13865. break;
  13866. }
  13867. // $result = $client->SendMsg ( $user, $msg, 'text' );
  13868. }
  13869. }
  13870. }
  13871. // Email发送函数
  13872. function SMail($toemail, $subject, $contents) {
  13873. Doo::loadClass ( 'class.phpmailer' );
  13874. $mail = new PHPMailer ();
  13875. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  13876. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  13877. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  13878. $mail->Password = "cDO1GjtY1seH"; // 密码
  13879. $mail->CharSet = "UTF8";
  13880. $mail->SMTPAuth = true;
  13881. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  13882. $mail->Mailer = "smtp";
  13883. $mail->Port = 25;
  13884. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  13885. $mail->MsgHTML ( $contents );
  13886. $mail->AddAddress ( $toemail );
  13887. $mail->CharSet = "UTF-8";
  13888. return $mail->Send ();
  13889. }
  13890. function h5Upload() {
  13891. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  13892. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  13893. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  13894. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  13895. header ( "HTTP/1.1 500 Internal Server Error" );
  13896. echo "POST exceeded maximum allowed size.";
  13897. exit ( 0 );
  13898. }
  13899. // Settings
  13900. $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)
  13901. $upload_name = "Filedata";
  13902. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  13903. $extension_whitelist = array (
  13904. "doc",
  13905. "txt",
  13906. "jpg",
  13907. "gif",
  13908. "png"
  13909. ); // Allowed file extensions
  13910. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  13911. // Other variables
  13912. $MAX_FILENAME_LENGTH = 260;
  13913. $file_name = "";
  13914. $file_extension = "";
  13915. $uploadErrors = array (
  13916. 0 => "文件上传成功",
  13917. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  13918. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  13919. 3 => "上传的文件仅为部分文件",
  13920. 4 => "没有文件上传",
  13921. 6 => "缺少临时文件夹"
  13922. );
  13923. $nk = time ();
  13924. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  13925. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  13926. echo "文件无法保存.";
  13927. exit ( 0 );
  13928. }
  13929. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  13930. echo json_encode ( array (
  13931. 'filename' => $file_name,
  13932. 'id' => $nk
  13933. ) );
  13934. exit ( 0 );
  13935. }
  13936. function swfupload() {
  13937. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  13938. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  13939. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  13940. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  13941. header ( "HTTP/1.1 500 Internal Server Error" );
  13942. echo "POST exceeded maximum allowed size.";
  13943. exit ( 0 );
  13944. }
  13945. // Settings
  13946. $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)
  13947. $upload_name = "Filedata";
  13948. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  13949. $extension_whitelist = array (
  13950. "doc",
  13951. "txt",
  13952. "jpg",
  13953. "gif",
  13954. "png"
  13955. ); // Allowed file extensions
  13956. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  13957. // Other variables
  13958. $MAX_FILENAME_LENGTH = 260;
  13959. $file_name = "";
  13960. $file_extension = "";
  13961. $uploadErrors = array (
  13962. 0 => "文件上传成功",
  13963. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  13964. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  13965. 3 => "上传的文件仅为部分文件",
  13966. 4 => "没有文件上传",
  13967. 6 => "缺少临时文件夹"
  13968. );
  13969. $nk = time ();
  13970. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  13971. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  13972. echo "文件无法保存.";
  13973. exit ( 0 );
  13974. }
  13975. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  13976. echo json_encode ( array (
  13977. 'filename' => $file_name,
  13978. 'id' => $nk
  13979. ) );
  13980. exit ( 0 );
  13981. }
  13982. function _GetFileEXT($filename) {
  13983. $pics = explode ( '.', $filename );
  13984. $num = count ( $pics );
  13985. return $pics [$num - 1];
  13986. }
  13987. /**
  13988. * 获取get或者POST值
  13989. * @param string $name 属性名称
  13990. * @return fixed 值
  13991. */
  13992. function get_args($name) {
  13993. if (isset ( $_GET [$name] )) {
  13994. if (is_array ( $_GET [$name] ))
  13995. return $_GET [$name];
  13996. else
  13997. return addslashes ( $_GET [$name] );
  13998. } elseif (isset ( $_POST [$name] )) {
  13999. if (is_array ( $_POST [$name] ))
  14000. return $_POST [$name];
  14001. else
  14002. return addslashes ( $_POST [$name] );
  14003. } else
  14004. return false;
  14005. }
  14006. function num_to_rmb($num) {
  14007. $c1 = "零壹贰叁肆伍陆柒捌玖";
  14008. $c2 = "分角元拾佰仟万拾佰仟亿";
  14009. // 精确到分后面就不要了,所以只留两个小数位
  14010. $num = round ( $num, 2 );
  14011. // 将数字转化为整数
  14012. $num = $num * 100;
  14013. if (strlen ( $num ) > 10) {
  14014. return "金额太大,请检查";
  14015. }
  14016. $i = 0;
  14017. $c = "";
  14018. while ( 1 ) {
  14019. if ($i == 0) {
  14020. // 获取最后一位数字
  14021. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  14022. } else {
  14023. $n = $num % 10;
  14024. }
  14025. // 每次将最后一位数字转化为中文
  14026. $p1 = substr ( $c1, 3 * $n, 3 );
  14027. $p2 = substr ( $c2, 3 * $i, 3 );
  14028. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  14029. $c = $p1 . $p2 . $c;
  14030. } else {
  14031. $c = $p1 . $c;
  14032. }
  14033. $i = $i + 1;
  14034. // 去掉数字最后一位了
  14035. $num = $num / 10;
  14036. // echo $num.'</br>';
  14037. $num = ( int ) $num;
  14038. // $num =floor($num);
  14039. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  14040. // echo $num.'</br>';
  14041. // 结束循环
  14042. if ($num == 0) {
  14043. break;
  14044. }
  14045. }
  14046. // echo $c.'</br>';
  14047. $j = 0;
  14048. $slen = strlen ( $c );
  14049. while ( $j < $slen ) {
  14050. // utf8一个汉字相当3个字符
  14051. $m = substr ( $c, $j, 6 );
  14052. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  14053. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  14054. $left = substr ( $c, 0, $j );
  14055. $right = substr ( $c, $j + 3 );
  14056. $c = $left . $right;
  14057. $j = $j - 3;
  14058. $slen = $slen - 3;
  14059. }
  14060. $j = $j + 3;
  14061. }
  14062. // 这个是为了去掉类似23.0中最后一个“零”字
  14063. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  14064. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  14065. }
  14066. // 将处理的汉字加上“整”
  14067. if (empty ( $c )) {
  14068. return "零元整";
  14069. } else {
  14070. return $c . "整";
  14071. }
  14072. }
  14073. /**
  14074. * 获得分页数据
  14075. * @param unknown_type $table
  14076. * @param unknown_type $condition
  14077. * @param unknown_type $on_page
  14078. * @param unknown_type $page_size
  14079. */
  14080. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  14081. $page_c = "";
  14082. $page ['previous'] = $this->get_previous ( $on_page );
  14083. $page ['on_page'] = $on_page;
  14084. $total_count = $this->get_table_count ( $table, $condition );
  14085. $total = intval ( $total_count / $page_size );
  14086. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  14087. $page ['total_data'] = $total_count;
  14088. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  14089. $i = 1;
  14090. $page_max = 1;
  14091. $page_width = 3;
  14092. if ($on_page >= $page_width) {
  14093. $page_max = intval ( $on_page / $page_width ) + 1;
  14094. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  14095. }
  14096. for(; $i <= $page ['total_page']; $i ++) {
  14097. if ($i == $on_page)
  14098. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  14099. else
  14100. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  14101. if ($i == ($page_width * $page_max))
  14102. break;
  14103. }
  14104. $page ['page'] = $page_c;
  14105. $page ['lower'] = (-- $on_page) * $page_size;
  14106. return $page;
  14107. }
  14108. /**
  14109. * 获取总页数
  14110. * @param unknown_type $table
  14111. * @param unknown_type $condition
  14112. */
  14113. public function get_table_count($table = "", $condition = "") {
  14114. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14115. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14116. // echo $sql;die;
  14117. $query = Doo::db ()->query ( $sql );
  14118. $result = $query->fetch ();
  14119. return $result ['count'];
  14120. }
  14121. /**
  14122. * 获取上一页
  14123. * @param unknown_type $on_page
  14124. */
  14125. function get_previous($on_page = 1) {
  14126. return $on_page != 0 ? $on_page - 1 : $on_page;
  14127. }
  14128. }
  14129. ?>