ReceiptController.php 544 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class ReceiptController extends DooController {
  6. public $staff;
  7. public $verifyId;
  8. public $executeId;
  9. // public static $NEW2 = 0;
  10. public $AGENCY = "日常相关费用";
  11. public $TRAVEL = "差旅相关费用";
  12. public $TRAIN = "培训班费用";
  13. public $OTHER = "其他";
  14. public $INTTRAIN='内部培训费用';
  15. private $MYREVEIPTCACHEPATH = "protected/cache/myReceipt/";
  16. private $PERSONALCOLLECTCACHEPATH = "protected/cache/personalCollect/";
  17. private $CATEGORYCOLLECTPATH = "protected/cache/categoryCollect/";
  18. private $STAFFCOLLECTPATH = "protected/cache/staffCollect/";
  19. private function showCache($path) {
  20. if (file_exists ( $path )) {
  21. echo "<!DOCTYPE html>";
  22. include $path;
  23. die ();
  24. }
  25. }
  26. private function cacheFile($path) {
  27. $content = ob_get_contents ();
  28. $fp = fopen ( $path, "w" );
  29. fwrite ( $fp, $content );
  30. fclose ( $fp );
  31. }
  32. private function collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {
  33. $collectHtml = "";
  34. $sumPrice = 0.00;
  35. for($i = 1; $i <= 12; $i ++) {
  36. $falg = true;
  37. foreach ( $receiptCollectList as $key => $value ) {
  38. if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {
  39. $sumPrice += $value ['price'];
  40. if ($classType == "b") {
  41. $collectHtml .= '<td class="colGreen taR">¥' . $value ['price'] . '</td>';
  42. $falg = false;
  43. break;
  44. } else {
  45. $collectHtml .= '<td class="taR">¥' . $value ['price'] . '</td>';
  46. $falg = false;
  47. break;
  48. }
  49. }
  50. }
  51. if ($falg)
  52. $collectHtml .= '<td class="taR">-</td>';
  53. }
  54. $collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';
  55. return $collectHtml;
  56. }
  57. public function beforeRun($resource, $action) {
  58. Doo::loadClass ( 'XDeode' );
  59. $XDeode = new XDeode ( 5 );
  60. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  61. // 单独判断公司汇总的访问权限
  62. if ($action == 'companyCategoryCollect') {
  63. Doo::loadModel ( "receiptAuthorityManage" );
  64. $invoiceCompanyManage = new receiptAuthorityManage ();
  65. $icm = $invoiceCompanyManage->getInvoiceCMByStaff ( $sid );
  66. if (empty ( $icm ))
  67. die ( 'illegal request-statistics' );
  68. }
  69. Doo::loadModel ( 'staff' );
  70. $staff = new staff ();
  71. $detail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  72. $accessModular = 'RECEIPTS';
  73. if (empty ( $detail ['cldAccessArray'] ))
  74. die ( 'illegal request' );
  75. else {
  76. if (in_array ( $accessModular, $detail ['cldAccessArray'] )) {
  77. if (Doo::acl ()->isAllowed ( $accessModular, $resource, $action )) {
  78. $flag = true;
  79. } else {
  80. $flag = false;
  81. }
  82. } else {
  83. die ( 'illegal request' );
  84. }
  85. }
  86. if (! $flag)
  87. die ( 'illegal request' );
  88. }
  89. function __construct() {
  90. if (isset ( $_COOKIE ["staff"] )) {
  91. if (! empty ( $_COOKIE ["staff"] )) {
  92. Doo::loadModel ( 'staff' );
  93. Doo::loadModel ( 'verify' );
  94. $verify = new verify ();
  95. $staff = new staff ();
  96. Doo::loadModel ( "execute" );
  97. $execute = new execute ();
  98. $verifyList = $verify->find ( array (
  99. 'select' => 'staff',
  100. 'asArray' => true
  101. ) );
  102. $list = array ();
  103. // 判断角色的审批权限
  104. foreach ( $verifyList as $key => $value ) {
  105. $ver = json_decode ( $value ['staff'] );
  106. foreach ( $ver as $k => $v ) {
  107. if ($v [1] == 'ROLE') {
  108. $roleList = json_decode ( $v [3] );
  109. foreach ( $roleList as $t => $g ) {
  110. $gList = explode ( "_", $g );
  111. array_push ( $list, $gList [0] );
  112. // print_r($list);
  113. }
  114. } else
  115. array_push ( $list, $v [0] );
  116. }
  117. }
  118. // 判断执行人的审批权限
  119. $executeList = $execute->find ( array (
  120. 'where'=>'mold !="日常收支"',
  121. 'select' => 'staff',
  122. 'asArray' => true
  123. ) );
  124. $list2 = array ();
  125. foreach ( $executeList as $key => $value ) {
  126. $ver = json_decode ( $value ['staff'] );
  127. foreach ( $ver as $k => $v ) {
  128. array_push ( $list2, $v [0] );
  129. }
  130. }
  131. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  132. $eidList = array_filter ( explode ( ",", $eidList ) );
  133. $this->executeId = array_merge ( $list2, $eidList );
  134. //print_r($this->executeId);
  135. $this->verifyId = $list;
  136. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  137. // 检测用户信息完成
  138. $this->data ['isStaffCompleteMsg'] = false;
  139. $detail = $staff->checkStaffInfoIsComplete ( $_COOKIE ["staff"] );
  140. if (! empty ( $detail ))
  141. $this->data ['isStaffCompleteMsg'] = true;
  142. return "/";
  143. }
  144. }
  145. Doo::loadCore ( 'uri/DooUriRouter' );
  146. $router = new DooUriRouter ();
  147. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  148. if ($routeRs ['1'] != "login") {
  149. header ( 'Content-Type:text/html;charset=utf-8' );
  150. @header ( "Location: /login" );
  151. }
  152. }
  153. /**
  154. * 费用首页
  155. */
  156. function saeaBorad() {
  157. Doo::loadModel ( 'receipt' );
  158. $receipt = new receipt ();
  159. Doo::loadModel ( 'verify' );
  160. $verify = new verify ();
  161. Doo::loadModel ( 'L_category' );
  162. $lCategory = new L_category ();
  163. Doo::loadModel ( "role" );
  164. $role = new role ();
  165. Doo::loadModel ( "receiptLog" );
  166. $receiptLog = new receiptLog ();
  167. Doo::loadModel ( 'accountItem' );
  168. $accountItem = new accountItem ();
  169. Doo::loadClass ( 'XDeode' );
  170. $XDeode = new XDeode ( 7 );
  171. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  172. $receiptDetail = $receipt->find ( array (
  173. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  174. 'desc' => 'rid',
  175. 'asArray' => true
  176. ) );
  177. foreach ( $receiptDetail as $key => $value ) {
  178. $receiptDetail [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  179. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  180. $veList = $verify->getOne ( array (
  181. 'where' => 'vid=' . $value ['verify'],
  182. 'asArray' => true
  183. ) );
  184. $v = json_decode ( $veList ['staff'] );
  185. array_push ( $v [0], $veList ['description'] );
  186. foreach ( $v as $n => $m ) {
  187. if ($m ['1'] == 'ROLE') {
  188. $roleInfo = $role->getOne ( array (
  189. 'where' => 'rid=' . $m [0],
  190. 'asArray' => true
  191. ) );
  192. $v [$n] [1] = $roleInfo ['name'];
  193. }
  194. }
  195. $receiptDetail [$key] ['staff'] = $v;
  196. $category = $lCategory->getOne ( array (
  197. 'where' => 'cid=' . $value ['cid'],
  198. 'asArray' => true
  199. ) );
  200. $receiptDetail [$key] ['category'] = $category ['title'];
  201. }
  202. // print_r($receiptLogList);
  203. Doo::loadModel ( 'RAssist' );
  204. $RAssist = new RAssist ();
  205. $receiptExtendList=$RAssist->getRAssistBySid($this->staff[0]['sid']);
  206. //费用项目
  207. $acItem = $accountItem->find ( array ('asArray' => true) );
  208. $data ['acItem'] = $acItem;
  209. $data ['receiptExtendList'] = $receiptExtendList;
  210. $data ['receiptLogList'] = $receiptLogList;
  211. $data ['receiptDetail'] = $receiptDetail;
  212. $data ['memu'] = "receipt";
  213. $data ['staff'] = $this->staff;
  214. $data ['receiptMemu'] = 'saeaBorad';
  215. $data ['verifyId'] = $this->verifyId;
  216. $data ['executeId'] = $this->executeId;
  217. $this->render ( "/receipt/receiptFee", $data );
  218. }
  219. /**
  220. * 添加费用报销单页面
  221. */
  222. function saeaCreate() {
  223. Doo::loadModel ( 'accountItem' );
  224. Doo::loadModel ( 'verify' );
  225. Doo::loadModel ( 'receipt' );
  226. Doo::loadModel ( 'L_category' );
  227. $lCategory = new L_category ();
  228. $receipt = new receipt ();
  229. $verify = new verify ();
  230. $accountItem = new accountItem ();
  231. Doo::loadModel ( "role" );
  232. $role = new role ();
  233. $acItem = $accountItem->find ( array (
  234. 'asArray' => true
  235. ) );
  236. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  237. $data ['category'] = $lCategory->find ( array (
  238. 'asArray' => true
  239. ) );
  240. $data ['veList'] = $veList;
  241. $data ['acItem'] = $acItem;
  242. $data ['memu'] = "receipt";
  243. $data ['staff'] = $this->staff;
  244. $data ['receiptMemu'] = 'saeaBorad';
  245. $data ['verifyId'] = $this->verifyId;
  246. $data ['executeId'] = $this->executeId;
  247. $this->render ( "/admin/saea_create", $data );
  248. }
  249. function addReceipt() {
  250. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  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. $inttrain = $this->get_args ( 'inttrain' );
  256. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  257. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  258. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  259. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  260. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  261. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  262. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  263. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  264. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  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. // if(!empty($receiptDetail))
  284. // return "/referReceipt/".$receiptDetail['rid'];
  285. $aItem = $accountItem->find ( array (
  286. 'asArray' => true
  287. ) );
  288. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  289. $ag = $tr = $ta = $ot= $it = 0;
  290. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  291. foreach ( $aItem as $key => $value ) {
  292. if ($value ['category'] == $this->AGENCY) {
  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. $ag ++;
  303. }
  304. if ($value ['category'] == $this->TRAVEL) {
  305. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  306. array_push ( $accountJson [$this->TRAVEL], array (
  307. 'aid' => $value ['aid'],
  308. 'name' => $value ['name'],
  309. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  310. ) );
  311. $sum += $travel [$tr];
  312. $travelSum += $travel [$tr];
  313. }
  314. $tr ++;
  315. }
  316. if ($value ['category'] == $this->TRAIN) {
  317. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  318. array_push ( $accountJson [$this->TRAIN], array (
  319. 'aid' => $value ['aid'],
  320. 'name' => $value ['name'],
  321. 'price' => number_format ( $train [$ta], 2, '.', '' )
  322. ) );
  323. $sum += $train [$ta];
  324. $trainSum += $train [$ta];
  325. }
  326. $ta ++;
  327. }
  328. if ($value ['category'] == $this->INTTRAIN) {
  329. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  330. array_push ( $accountJson [$this->INTTRAIN], array (
  331. 'aid' => $value ['aid'],
  332. 'name' => $value ['name'],
  333. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  334. ) );
  335. $sum += $inttrain [$it];
  336. $inttrainSum += $inttrain [$it];
  337. }
  338. $it ++;
  339. }
  340. if ($value ['category'] == $this->OTHER) {
  341. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  342. array_push ( $accountJson [$this->OTHER], array (
  343. 'aid' => $value ['aid'],
  344. 'name' => $value ['name'],
  345. 'price' => number_format ( $other [$ot], 2, '.', '' )
  346. ) );
  347. $sum += $other [$ot];
  348. $otherSum += $other [$ot];
  349. }
  350. $ot ++;
  351. }
  352. }
  353. $accountJson ['cSum'] = array (
  354. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  355. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  356. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  357. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  358. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  359. );
  360. // 报销单
  361. $receipt->accountItem = json_encode ( $accountJson );
  362. $receipt->staff = $this->staff [0] ['sid'];
  363. $receipt->sum = number_format ( $sum, 2, '.', '' );
  364. $receipt->date = date ( "Y-m-d" );
  365. $receipt->cid = $cid;
  366. $receipt->status = 5;
  367. // 修改审批流程加入角色
  368. $receipt->verify = $verify;
  369. $receipt->executeCopy = $executeDetail ['staff'];
  370. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  371. $order = array (
  372. "\r\n",
  373. "\n",
  374. "\r"
  375. );
  376. $replace = '<br/>';
  377. $explanation = str_replace ( $order, $replace, $explanation );
  378. $receipt->explanation = $explanation;
  379. $receipt->remittanceName = $remittanceName;
  380. $receipt->bankName = $bankName;
  381. $receipt->bankNumber = $bankNumber;
  382. $receipt->remittanceBankType = $remittanceBankType;
  383. if ($remittanceBankType == 1)
  384. $receipt->coupletNumber = $coupletNumber;
  385. $rid = $receipt->insert ();
  386. // 附件
  387. if (! empty ( $enclosurName )) {
  388. $enclosurArray = explode ( '-', $enclosurName );
  389. foreach ( $enclosurArray as $value ) {
  390. $enclosur = new enclosur ();
  391. $enclosur->name = $value;
  392. $enclosur->rid = $rid;
  393. $enclosur->insert ();
  394. }
  395. // print_r($enclosurArray);die;
  396. }
  397. // 报销详情
  398. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  399. $receiptDetail = new receiptDetail ();
  400. $receiptDetail->staff = $this->staff [0] ['sid'];
  401. $receiptDetail->item = $value ['name'];
  402. $receiptDetail->itemCategory = $this->AGENCY;
  403. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  404. $receiptDetail->date = date ( "Y-m-d" );
  405. $receiptDetail->cid = $cid;
  406. $receiptDetail->rid = $rid;
  407. $receiptDetail->status = 4;
  408. $receiptDetail->insert ();
  409. }
  410. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  411. $receiptDetail = new receiptDetail ();
  412. $receiptDetail->staff = $this->staff [0] ['sid'];
  413. $receiptDetail->item = $value ['name'];
  414. $receiptDetail->itemCategory = $this->TRAVEL;
  415. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  416. $receiptDetail->date = date ( "Y-m-d" );
  417. $receiptDetail->cid = $cid;
  418. $receiptDetail->rid = $rid;
  419. $receiptDetail->status = 4;
  420. $receiptDetail->insert ();
  421. }
  422. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  423. $receiptDetail = new receiptDetail ();
  424. $receiptDetail->staff = $this->staff [0] ['sid'];
  425. $receiptDetail->item = $value ['name'];
  426. $receiptDetail->itemCategory = $this->TRAIN;
  427. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  428. $receiptDetail->date = date ( "Y-m-d" );
  429. $receiptDetail->cid = $cid;
  430. $receiptDetail->rid = $rid;
  431. $receiptDetail->status = 4;
  432. $receiptDetail->insert ();
  433. }
  434. //内训
  435. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  436. $receiptDetail = new receiptDetail ();
  437. $receiptDetail->staff = $this->staff [0] ['sid'];
  438. $receiptDetail->item = $value ['name'];
  439. $receiptDetail->itemCategory = $this->INTTRAIN;
  440. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  441. $receiptDetail->date = date ( "Y-m-d" );
  442. $receiptDetail->cid = $cid;
  443. $receiptDetail->rid = $rid;
  444. $receiptDetail->status = 4;
  445. $receiptDetail->insert ();
  446. }
  447. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  448. $receiptDetail = new receiptDetail ();
  449. $receiptDetail->staff = $this->staff [0] ['sid'];
  450. $receiptDetail->item = $value ['name'];
  451. $receiptDetail->itemCategory = $this->OTHER;
  452. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  453. $receiptDetail->date = date ( "Y-m-d" );
  454. $receiptDetail->cid = $cid;
  455. $receiptDetail->rid = $rid;
  456. $receiptDetail->status = 4;
  457. $receiptDetail->insert ();
  458. }
  459. return "/saeaBorad";
  460. } else
  461. die ( 'illegal request' );
  462. }
  463. function referReceipt() {
  464. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  465. Doo::loadModel ( 'receipt' );
  466. Doo::loadModel ( 'verify' );
  467. $verify = new verify ();
  468. $receipt = new receipt ();
  469. Doo::loadModel ( 'L_category' );
  470. $lCategory = new L_category ();
  471. Doo::loadModel ( "role" );
  472. $role = new role ();
  473. $receiptDetail = $receipt->find ( array (
  474. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  475. 'asArray' => true
  476. ) );
  477. if (empty ( $receiptDetail ))
  478. return "/addReceipt";
  479. foreach ( $receiptDetail as $key => $value ) {
  480. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  481. $veList = $verify->getOne ( array (
  482. 'where' => 'vid=' . $value ['verify'],
  483. 'asArray' => true
  484. ) );
  485. $v = json_decode ( $veList ['staff'] );
  486. array_push ( $v [0], $veList ['description'] );
  487. foreach ( $v as $n => $m ) {
  488. if ($m ['1'] == 'ROLE') {
  489. $roleInfo = $role->getOne ( array (
  490. 'where' => 'rid=' . $m [0],
  491. 'asArray' => true
  492. ) );
  493. $v [$n] [1] = $roleInfo ['name'];
  494. }
  495. }
  496. $receiptDetail [$key] ['staff'] = $v;
  497. $category = $lCategory->getOne ( array (
  498. 'where' => 'cid=' . $value ['cid'],
  499. 'asArray' => true
  500. ) );
  501. $receiptDetail [$key] ['category'] = $category ['title'];
  502. }
  503. // print_r($receiptDetail);
  504. $data ['receiptDetail'] = $receiptDetail;
  505. $data ['memu'] = "receipt";
  506. $data ['staff'] = $this->staff;
  507. $data ['receiptMemu'] = 'saeaCreate';
  508. $data ['verifyId'] = $this->verifyId;
  509. $data ['executeId'] = $this->executeId;
  510. $this->render ( "/admin/saea_confirm", $data );
  511. }
  512. function editReceipt() {
  513. // edit status 4
  514. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  515. Doo::loadClass ( 'XDeode' );
  516. $XDeode = new XDeode ( 7 );
  517. $rid = $XDeode->decode ( $ridKey );
  518. if (empty ( $rid ))
  519. die ( 'illegal request' );
  520. // echo $rid.'sd';
  521. Doo::loadModel ( 'accountItem' );
  522. Doo::loadModel ( 'verify' );
  523. Doo::loadModel ( 'receipt' );
  524. $receipt = new receipt ();
  525. $verify = new verify ();
  526. $accountItem = new accountItem ();
  527. Doo::loadModel ( 'L_category' );
  528. $lCategory = new L_category ();
  529. Doo::loadModel ( "role" );
  530. $role = new role ();
  531. Doo::loadModel ( 'enclosur' );
  532. $enclosur = new enclosur ();
  533. $receiptDetail = $receipt->getOne ( array (
  534. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  535. 'asArray' => true
  536. ) );
  537. if (empty ( $receiptDetail ))
  538. die ( 'illegal request' );
  539. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  540. $acItem = $accountItem->find ( array (
  541. 'asArray' => true
  542. ) );
  543. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  544. // 配置编辑信息
  545. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  546. foreach ( $acItem as $key => $value ) {
  547. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  548. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  549. $acItem [$key] ['price'] = $v ['price'];
  550. }
  551. }
  552. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  553. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  554. $acItem [$key] ['price'] = $v ['price'];
  555. }
  556. }
  557. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  558. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  559. $acItem [$key] ['price'] = $v ['price'];
  560. }
  561. }
  562. //内训
  563. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  564. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  565. $acItem [$key] ['price'] = $v ['price'];
  566. }
  567. }
  568. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  569. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  570. $acItem [$key] ['price'] = $v ['price'];
  571. }
  572. }
  573. }
  574. $data ['category'] = $lCategory->find ( array (
  575. 'asArray' => true
  576. ) );
  577. $data ['cSum'] = $accountItemList ['cSum'];
  578. $data ['sum'] = $receiptDetail ['sum'];
  579. $data ['enclosurList'] = $enclosurList;
  580. $data ['receiptDetail'] = $receiptDetail;
  581. $data ['veList'] = $veList;
  582. $data ['acItem'] = $acItem;
  583. $data ['memu'] = "receipt";
  584. $data ['staff'] = $this->staff;
  585. $data ['receiptMemu'] = 'saeaBorad';
  586. $data ['verify'] = $receiptDetail ['verify'];
  587. $data ['verifyId'] = $this->verifyId;
  588. $data ['executeId'] = $this->executeId;
  589. $data ['rid'] = $ridKey;
  590. $this->render ( "/admin/saea_edit", $data );
  591. }
  592. function updateReceipt() {
  593. $agency = $this->get_args ( 'agency' );
  594. $travel = $this->get_args ( 'travel' );
  595. $train = $this->get_args ( 'train' );
  596. $other = $this->get_args ( 'other' );
  597. $inttrain = $this->get_args ( 'inttrain' );
  598. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  599. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  600. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  601. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  602. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  603. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  604. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  605. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  606. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  607. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  608. Doo::loadClass ( 'XDeode' );
  609. $XDeode = new XDeode ( 7 );
  610. $rid = $XDeode->decode ( $ridKey );
  611. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  612. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  613. header ( 'Content-Type:text/html;charset=utf-8' );
  614. die ( '请填写联行号' );
  615. }
  616. Doo::loadModel ( 'receipt' );
  617. Doo::loadModel ( 'receiptDetail' );
  618. Doo::loadModel ( 'accountItem' );
  619. $accountItem = new accountItem ();
  620. $receipt = new receipt ();
  621. Doo::loadModel ( 'enclosur' );
  622. Doo::loadModel ( 'execute' );
  623. $execute = new execute ();
  624. $receiptDetail = $receipt->getOne ( array (
  625. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  626. 'asArray' => true
  627. ) );
  628. if (empty ( $receiptDetail ))
  629. return "/saeaBorad";
  630. if ($receiptDetail ['Rtype'] == 1)
  631. $executeDetail = $execute->getOne ( array (
  632. 'where' => 'mold="借款费用执行人"',
  633. 'asArray' => true
  634. ) );
  635. else
  636. $executeDetail = $execute->getOne ( array (
  637. 'where' => 'mold="报销单执行人"',
  638. 'asArray' => true
  639. ) );
  640. $aItem = $accountItem->find ( array (
  641. 'asArray' => true
  642. ) );
  643. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  644. $ag = $tr = $ta = $ot = $it = 0 ;
  645. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum = $otherSum = 0;
  646. foreach ( $aItem as $key => $value ) {
  647. if ($value ['category'] == $this->AGENCY) {
  648. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  649. array_push ( $accountJson [$this->AGENCY], array (
  650. 'aid' => $value ['aid'],
  651. 'name' => $value ['name'],
  652. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  653. ) );
  654. $sum += $agency [$ag];
  655. $agencySum += $agency [$ag];
  656. }
  657. $ag ++;
  658. }
  659. if ($value ['category'] == $this->TRAVEL) {
  660. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  661. array_push ( $accountJson [$this->TRAVEL], array (
  662. 'aid' => $value ['aid'],
  663. 'name' => $value ['name'],
  664. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  665. ) );
  666. $sum += $travel [$tr];
  667. $travelSum += $travel [$tr];
  668. }
  669. $tr ++;
  670. }
  671. if ($value ['category'] == $this->TRAIN) {
  672. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  673. array_push ( $accountJson [$this->TRAIN], array (
  674. 'aid' => $value ['aid'],
  675. 'name' => $value ['name'],
  676. 'price' => number_format ( $train [$ta], 2, '.', '' )
  677. ) );
  678. $sum += $train [$ta];
  679. $trainSum += $train [$ta];
  680. }
  681. $ta ++;
  682. }
  683. if ($value ['category'] == $this->INTTRAIN) {
  684. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  685. array_push ( $accountJson [$this->INTTRAIN], array (
  686. 'aid' => $value ['aid'],
  687. 'name' => $value ['name'],
  688. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  689. ) );
  690. $sum += $inttrain [$it];
  691. $inttrainSum += $inttrain [$it];
  692. }
  693. $it ++;
  694. }
  695. if ($value ['category'] == $this->OTHER) {
  696. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  697. array_push ( $accountJson [$this->OTHER], array (
  698. 'aid' => $value ['aid'],
  699. 'name' => $value ['name'],
  700. 'price' => number_format ( $other [$ot], 2, '.', '' )
  701. ) );
  702. $sum += $other [$ot];
  703. $otherSum += $other [$ot];
  704. }
  705. $ot ++;
  706. }
  707. }
  708. $accountJson ['cSum'] = array (
  709. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  710. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  711. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  712. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  713. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  714. );
  715. // 报销单
  716. $rid = $receipt->rid = $receiptDetail ['rid'];
  717. $receipt->accountItem = json_encode ( $accountJson );
  718. $receipt->staff = $this->staff [0] ['sid'];
  719. $receipt->sum = number_format ( $sum, 2, '.', '' );
  720. $receipt->date = date ( "Y-m-d" );
  721. $receipt->cid = $cid;
  722. if (($receiptDetail ['status'] != 4)) {
  723. if ($receiptDetail ['Rtype'] == 1)
  724. $receipt->status = 7;
  725. else
  726. $receipt->status = 5;
  727. }
  728. if ($receiptDetail != 4 && ! empty ( $verify ))
  729. $receipt->verify = $verify;
  730. $receipt->executeCopy = $executeDetail ['staff'];
  731. $order = array (
  732. "\r\n",
  733. "\n",
  734. "\r"
  735. );
  736. $replace = '<br/>';
  737. $explanation = str_replace ( $order, $replace, $explanation );
  738. $receipt->explanation = $explanation;
  739. $receipt->remittanceName = $remittanceName;
  740. $receipt->bankName = $bankName;
  741. $receipt->bankNumber = $bankNumber;
  742. $receipt->remittanceBankType = $remittanceBankType;
  743. if ($remittanceBankType == 1)
  744. $receipt->coupletNumber = $coupletNumber;
  745. $receipt->update ();
  746. $receiptDetail = new receiptDetail ();
  747. $receiptDetail->delete ( array (
  748. 'where' => 'rid=' . $rid
  749. ) );
  750. // 报销详情
  751. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  752. $receiptDetail = new receiptDetail ();
  753. $receiptDetail->staff = $this->staff [0] ['sid'];
  754. $receiptDetail->item = $value ['name'];
  755. $receiptDetail->itemCategory = $this->AGENCY;
  756. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  757. $receiptDetail->date = date ( "Y-m-d" );
  758. $receiptDetail->cid = $cid;
  759. $receiptDetail->rid = $rid;
  760. $receiptDetail->status = 4;
  761. $receiptDetail->insert ();
  762. }
  763. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  764. $receiptDetail = new receiptDetail ();
  765. $receiptDetail->staff = $this->staff [0] ['sid'];
  766. $receiptDetail->item = $value ['name'];
  767. $receiptDetail->itemCategory = $this->TRAVEL;
  768. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  769. $receiptDetail->date = date ( "Y-m-d" );
  770. $receiptDetail->cid = $cid;
  771. $receiptDetail->rid = $rid;
  772. $receiptDetail->status = 4;
  773. $receiptDetail->insert ();
  774. }
  775. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  776. $receiptDetail = new receiptDetail ();
  777. $receiptDetail->staff = $this->staff [0] ['sid'];
  778. $receiptDetail->item = $value ['name'];
  779. $receiptDetail->itemCategory = $this->TRAIN;
  780. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  781. $receiptDetail->date = date ( "Y-m-d" );
  782. $receiptDetail->cid = $cid;
  783. $receiptDetail->rid = $rid;
  784. $receiptDetail->status = 4;
  785. $receiptDetail->insert ();
  786. }
  787. //内训
  788. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  789. $receiptDetail = new receiptDetail ();
  790. $receiptDetail->staff = $this->staff [0] ['sid'];
  791. $receiptDetail->item = $value ['name'];
  792. $receiptDetail->itemCategory = $this->INTTRAIN;
  793. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  794. $receiptDetail->date = date ( "Y-m-d" );
  795. $receiptDetail->cid = $cid;
  796. $receiptDetail->rid = $rid;
  797. $receiptDetail->status = 4;
  798. $receiptDetail->insert ();
  799. }
  800. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  801. $receiptDetail = new receiptDetail ();
  802. $receiptDetail->staff = $this->staff [0] ['sid'];
  803. $receiptDetail->item = $value ['name'];
  804. $receiptDetail->itemCategory = $this->OTHER;
  805. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  806. $receiptDetail->date = date ( "Y-m-d" );
  807. $receiptDetail->cid = $cid;
  808. $receiptDetail->rid = $rid;
  809. $receiptDetail->status = 4;
  810. $receiptDetail->insert ();
  811. }
  812. // 附件
  813. if (! empty ( $enclosurName )) {
  814. $enclosurArray = explode ( '-', $enclosurName );
  815. foreach ( $enclosurArray as $value ) {
  816. $enclosur = new enclosur ();
  817. $enclosur->name = $value;
  818. $enclosur->rid = $rid;
  819. $enclosur->insert ();
  820. }
  821. }
  822. // return "/referReceipt/".$rid;
  823. }
  824. return "/saeaBorad";
  825. }
  826. function remitAdd() {
  827. Doo::loadModel ( 'accountItem' );
  828. Doo::loadModel ( 'verify' );
  829. Doo::loadModel ( 'receipt' );
  830. Doo::loadModel ( 'L_category' );
  831. $lCategory = new L_category ();
  832. $receipt = new receipt ();
  833. $verify = new verify ();
  834. $accountItem = new accountItem ();
  835. Doo::loadModel ( "role" );
  836. $role = new role ();
  837. $acItem = $accountItem->find ( array (
  838. 'asArray' => true
  839. ) );
  840. $veList = $verify->getVerifyBySubordinate('REMIT');
  841. $data ['category'] = $lCategory->find ( array (
  842. 'asArray' => true
  843. ) );
  844. $data ['veList'] = $veList;
  845. $data ['acItem'] = $acItem;
  846. $data ['memu'] = "receipt";
  847. $data ['staff'] = $this->staff;
  848. $data ['receiptMemu'] = 'saeaBorad';
  849. $data ['verifyId'] = $this->verifyId;
  850. $data ['executeId'] = $this->executeId;
  851. $this->render ( "/admin/remitAdd", $data );
  852. }
  853. function remitAddDo() {
  854. $agency = $this->get_args ( 'agency' );
  855. $travel = $this->get_args ( 'travel' );
  856. $train = $this->get_args ( 'train' );
  857. $other = $this->get_args ( 'other' );
  858. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  859. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  860. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  861. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  862. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  863. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  864. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  865. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  866. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  867. // print_r($agency);die;
  868. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  869. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  870. header ( 'Content-Type:text/html;charset=utf-8' );
  871. die ( '请填写联行号' );
  872. }
  873. Doo::loadModel ( 'receipt' );
  874. Doo::loadModel ( 'receiptDetail' );
  875. Doo::loadModel ( 'accountItem' );
  876. $accountItem = new accountItem ();
  877. $receipt = new receipt ();
  878. Doo::loadModel ( 'enclosur' );
  879. Doo::loadModel ( 'execute' );
  880. $execute = new execute ();
  881. $executeDetail = $execute->getOne ( array (
  882. 'where' => 'mold="对公汇款执行人"',
  883. 'asArray' => true
  884. ) );
  885. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  886. $aItem = $accountItem->find ( array (
  887. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  888. 'asArray' => true
  889. ) );
  890. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  891. $ag = $tr = $ta = $ot = 0;
  892. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  893. print_r($aItem);
  894. foreach ( $aItem as $key => $value ) {
  895. if ($value ['category'] == $this->AGENCY) {
  896. if (isset ( $agency [$ag] )) {
  897. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  898. array_push ( $accountJson [$this->AGENCY], array (
  899. 'aid' => $value ['aid'],
  900. 'name' => $value ['name'],
  901. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  902. ) );
  903. $sum += $agency [$ag];
  904. $agencySum += $agency [$ag];
  905. }
  906. }
  907. $ag ++;
  908. }
  909. }
  910. $accountJson ['cSum'] = array (
  911. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  912. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  913. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  914. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  915. );
  916. //die;
  917. // 报销单
  918. $receipt->accountItem = json_encode ( $accountJson );
  919. $receipt->staff = $this->staff [0] ['sid'];
  920. $receipt->sum = number_format ( $sum, 2, '.', '' );
  921. $receipt->date = date ( "Y-m-d" );
  922. $receipt->cid = $cid;
  923. $receipt->status = 5;
  924. $receipt->Rtype = 2;
  925. // 修改审批流程加入角色
  926. $receipt->verify = $verify;
  927. $receipt->executeCopy = $executeDetail ['staff'];
  928. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  929. $order = array (
  930. "\r\n",
  931. "\n",
  932. "\r"
  933. );
  934. $replace = '<br/>';
  935. $explanation = str_replace ( $order, $replace, $explanation );
  936. $receipt->explanation = $explanation;
  937. $receipt->remittanceName = $remittanceName;
  938. $receipt->bankName = $bankName;
  939. $receipt->bankNumber = $bankNumber;
  940. $receipt->remittanceBankType = $remittanceBankType;
  941. if ($remittanceBankType == 1)
  942. $receipt->coupletNumber = $coupletNumber;
  943. $rid = $receipt->insert ();
  944. // 附件
  945. if (! empty ( $enclosurName )) {
  946. $enclosurArray = explode ( '-', $enclosurName );
  947. foreach ( $enclosurArray as $value ) {
  948. $enclosur = new enclosur ();
  949. $enclosur->name = $value;
  950. $enclosur->rid = $rid;
  951. $enclosur->insert ();
  952. }
  953. // print_r($enclosurArray);die;
  954. }
  955. // 报销详情
  956. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  957. $receiptDetail = new receiptDetail ();
  958. $receiptDetail->staff = $this->staff [0] ['sid'];
  959. $receiptDetail->item = $value ['name'];
  960. $receiptDetail->itemCategory = $this->AGENCY;
  961. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  962. $receiptDetail->date = date ( "Y-m-d" );
  963. $receiptDetail->cid = $cid;
  964. $receiptDetail->rid = $rid;
  965. $receiptDetail->status = 4;
  966. $receiptDetail->insert ();
  967. }
  968. return "/saeaBorad";
  969. } else
  970. die ( 'illegal request' );
  971. }
  972. function remitEdit() {
  973. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  974. Doo::loadClass ( 'XDeode' );
  975. $XDeode = new XDeode ( 7 );
  976. $rid = $XDeode->decode ( $ridKey );
  977. if (! is_numeric ( $rid ))
  978. die ( 'illegal request' );
  979. Doo::loadModel ( 'accountItem' );
  980. Doo::loadModel ( 'verify' );
  981. Doo::loadModel ( 'receipt' );
  982. $receipt = new receipt ();
  983. $verify = new verify ();
  984. $accountItem = new accountItem ();
  985. Doo::loadModel ( 'L_category' );
  986. $lCategory = new L_category ();
  987. Doo::loadModel ( "role" );
  988. $role = new role ();
  989. Doo::loadModel ( 'enclosur' );
  990. $enclosur = new enclosur ();
  991. $receiptDetail = $receipt->getOne ( array (
  992. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  993. 'asArray' => true
  994. ) );
  995. if (empty ( $receiptDetail ))
  996. return "/saeaCreate";
  997. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  998. $acItem = $accountItem->find ( array (
  999. 'asArray' => true
  1000. ) );
  1001. $veList = $verify->getVerifyBySubordinate('REMIT');
  1002. // 配置编辑信息
  1003. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1004. foreach ( $acItem as $key => $value ) {
  1005. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1006. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1007. $acItem [$key] ['price'] = $v ['price'];
  1008. }
  1009. }
  1010. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1011. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1012. $acItem [$key] ['price'] = $v ['price'];
  1013. }
  1014. }
  1015. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1016. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1017. $acItem [$key] ['price'] = $v ['price'];
  1018. }
  1019. }
  1020. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1021. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1022. $acItem [$key] ['price'] = $v ['price'];
  1023. }
  1024. }
  1025. }
  1026. $data ['category'] = $lCategory->find ( array (
  1027. 'asArray' => true
  1028. ) );
  1029. $data ['enclosurList'] = $enclosurList;
  1030. $data ['cSum'] = $accountItemList ['cSum'];
  1031. $data ['sum'] = $receiptDetail ['sum'];
  1032. $data ['receiptDetail'] = $receiptDetail;
  1033. $data ['veList'] = $veList;
  1034. $data ['acItem'] = $acItem;
  1035. $data ['memu'] = "receipt";
  1036. $data ['staff'] = $this->staff;
  1037. $data ['receiptMemu'] = 'saeaBorad';
  1038. $data ['verify'] = $receiptDetail ['verify'];
  1039. $data ['verifyId'] = $this->verifyId;
  1040. $data ['executeId'] = $this->executeId;
  1041. $data ['rid'] = $rid;
  1042. $data ['ridKey'] = $ridKey;
  1043. $this->render ( "/admin/remitEdit", $data );
  1044. }
  1045. function remitEdiDo() {
  1046. $agency = $this->get_args ( 'agency' );
  1047. $travel = $this->get_args ( 'travel' );
  1048. $train = $this->get_args ( 'train' );
  1049. $other = $this->get_args ( 'other' );
  1050. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1051. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1052. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1053. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1054. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1055. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1056. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1057. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1058. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1059. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1060. Doo::loadClass ( 'XDeode' );
  1061. $XDeode = new XDeode ( 7 );
  1062. $rid = $XDeode->decode ( $ridKey );
  1063. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1064. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1065. header ( 'Content-Type:text/html;charset=utf-8' );
  1066. die ( '请填写联行号' );
  1067. }
  1068. Doo::loadModel ( 'receipt' );
  1069. Doo::loadModel ( 'receiptDetail' );
  1070. Doo::loadModel ( 'accountItem' );
  1071. $accountItem = new accountItem ();
  1072. $receipt = new receipt ();
  1073. Doo::loadModel ( 'enclosur' );
  1074. $enclosur = new enclosur ();
  1075. Doo::loadModel ( 'execute' );
  1076. $execute = new execute ();
  1077. $executeDetail = $execute->getOne ( array (
  1078. 'where' => 'mold="对公汇款执行人"',
  1079. 'asArray' => true
  1080. ) );
  1081. $receiptDetail = $receipt->getOne ( array (
  1082. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  1083. 'asArray' => true
  1084. ) );
  1085. if (empty ( $receiptDetail ))
  1086. return "/saeaBorad";
  1087. $aItem = $accountItem->find ( array (
  1088. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  1089. 'asArray' => true
  1090. ) );
  1091. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1092. $ag = $tr = $ta = $ot = 0;
  1093. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1094. foreach ( $aItem as $key => $value ) {
  1095. if ($value ['category'] == $this->AGENCY) {
  1096. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1097. array_push ( $accountJson [$this->AGENCY], array (
  1098. 'aid' => $value ['aid'],
  1099. 'name' => $value ['name'],
  1100. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1101. ) );
  1102. $sum += $agency [$ag];
  1103. $agencySum += $agency [$ag];
  1104. }
  1105. $ag ++;
  1106. }
  1107. }
  1108. $accountJson ['cSum'] = array (
  1109. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1110. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1111. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1112. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1113. );
  1114. // 报销单
  1115. $rid = $receipt->rid = $receiptDetail ['rid'];
  1116. $receipt->accountItem = json_encode ( $accountJson );
  1117. $receipt->staff = $this->staff [0] ['sid'];
  1118. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1119. $receipt->date = date ( "Y-m-d" );
  1120. $receipt->cid = $cid;
  1121. if ($receiptDetail ['Rtype'] == 1)
  1122. $receipt->status = 7;
  1123. else
  1124. $receipt->status = 5;
  1125. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  1126. $receipt->verify = $verify;
  1127. $receipt->executeCopy = $executeDetail ['staff'];
  1128. $order = array (
  1129. "\r\n",
  1130. "\n",
  1131. "\r"
  1132. );
  1133. $replace = '<br/>';
  1134. $explanation = str_replace ( $order, $replace, $explanation );
  1135. $receipt->explanation = $explanation;
  1136. $receipt->remittanceName = $remittanceName;
  1137. $receipt->bankName = $bankName;
  1138. $receipt->bankNumber = $bankNumber;
  1139. $receipt->remittanceBankType = $remittanceBankType;
  1140. if ($remittanceBankType == 1)
  1141. $receipt->coupletNumber = $coupletNumber;
  1142. $receipt->update ();
  1143. $receiptDetail = new receiptDetail ();
  1144. $receiptDetail->delete ( array (
  1145. 'where' => 'rid=' . $rid
  1146. ) );
  1147. // 报销详情
  1148. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1149. $receiptDetail = new receiptDetail ();
  1150. $receiptDetail->staff = $this->staff [0] ['sid'];
  1151. $receiptDetail->item = $value ['name'];
  1152. $receiptDetail->itemCategory = $this->AGENCY;
  1153. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1154. $receiptDetail->date = date ( "Y-m-d" );
  1155. $receiptDetail->cid = $cid;
  1156. $receiptDetail->rid = $rid;
  1157. $receiptDetail->status = 4;
  1158. $receiptDetail->insert ();
  1159. }
  1160. // 附件
  1161. if (! empty ( $enclosurName )) {
  1162. $enclosurArray = explode ( '-', $enclosurName );
  1163. foreach ( $enclosurArray as $value ) {
  1164. $enclosur = new enclosur ();
  1165. $enclosur->name = $value;
  1166. $enclosur->rid = $rid;
  1167. $enclosur->insert ();
  1168. }
  1169. }
  1170. }
  1171. return "/saeaBorad";
  1172. }
  1173. function remitApproval() {
  1174. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1175. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  1176. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  1177. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  1178. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  1179. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  1180. if (empty ( $status ))
  1181. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  1182. $vidList = array ();
  1183. $button = 0;
  1184. Doo::loadModel ( 'verify' );
  1185. Doo::loadModel ( 'receipt' );
  1186. Doo::loadModel ( 'staff' );
  1187. $staff = new staff ();
  1188. $receipt = new receipt ();
  1189. $verify = new verify ();
  1190. Doo::loadModel ( 'L_category' );
  1191. $Lcategory = new L_category ();
  1192. Doo::loadModel ( 'enclosur' );
  1193. $enclosur = new enclosur ();
  1194. // user verify ID
  1195. $verifyDetail = $verify->find ( array (
  1196. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  1197. 'asArray' => true
  1198. ) );
  1199. foreach ( $verifyDetail as $key => $value ) {
  1200. array_push ( $vidList, $value ['vid'] );
  1201. }
  1202. $vid = implode ( ",", $vidList );
  1203. if (empty ( $verifyDetail ))
  1204. $vid = 0;
  1205. $categoryList = $Lcategory->find ( array (
  1206. 'asArray' => true
  1207. ) );
  1208. $staffList = $staff->find ( array (
  1209. 'where' => 'cid=' . $cid,
  1210. 'asArray' => true
  1211. ) );
  1212. $ap = "";
  1213. if ($status == 4) {
  1214. $ap = 4;
  1215. $status = 2;
  1216. }
  1217. // get Receipt By verifyID status 2
  1218. $receiptList = $receipt->find ( array (
  1219. 'where' => 'rid =' . $rid . ' and status=2',
  1220. 'desc' => 'rid',
  1221. 'asArray' => true
  1222. ) );
  1223. if (empty ( $receiptList )) {
  1224. die ( 'illegal request' );
  1225. }
  1226. $Locate = 0;
  1227. $roleId = 0;
  1228. if ($ap == 4)
  1229. $status = 4;
  1230. foreach ( $receiptList as $key => $value ) {
  1231. $receiptList [$key] ['Locate'] = $Locate;
  1232. $Locate ++;
  1233. $receiptList [$key] ['reviseDetail'] = array ();
  1234. if (! empty ( $value ['reviseDetail'] ))
  1235. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1236. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1237. $categoryDetil = $Lcategory->getOne ( array (
  1238. 'where' => 'cid=' . $value ['cid'],
  1239. 'asArray' => true
  1240. ) );
  1241. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1242. // 检测编辑状态
  1243. $verifyList = $verify->getOne ( array (
  1244. 'where' => 'vid=' . $value ['verify'],
  1245. 'asArray' => true
  1246. ) );
  1247. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1248. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1249. Doo::loadModel ( 'role' );
  1250. $role = new role ();
  1251. // print_r($verifyList);
  1252. $flag = true;
  1253. $roleKey = 0;
  1254. $endStaffArray = array ();
  1255. $roleArrayCopy = array ();
  1256. foreach ( $verifyList as $k => $v ) {
  1257. // init verifyStaff
  1258. if ($v [1] == 'ROLE') {
  1259. if (! empty ( $verifyStaff )) {
  1260. $endStaffArray = end ( $verifyStaff );
  1261. if ($v [0] == $endStaffArray ['nextStaff']) {
  1262. $roleId = $v [0];
  1263. }
  1264. }
  1265. $roleVerify = json_decode ( $v [3], true );
  1266. $roleKey = $k;
  1267. $roleArray = array ();
  1268. $rolename = $role->getOne ( array (
  1269. 'where' => 'rid=' . $v [0],
  1270. 'asArray' => true
  1271. ) );
  1272. foreach ( $roleVerify as $o => $p ) {
  1273. $staffID = explode ( '_', $p );
  1274. $staffInfo = $staff->getOne ( array (
  1275. 'where' => 'sid=' . $staffID [0],
  1276. 'asArray' => true
  1277. ) );
  1278. // print_r($staffID);
  1279. $exp = array (
  1280. 0 => $staffInfo ['sid'],
  1281. 1 => $staffID [1],
  1282. 2 => $staffInfo ['avatar'],
  1283. 'date' => '',
  1284. 'date' => '',
  1285. 'opinion' => '',
  1286. 'status' => '',
  1287. 'rolename' => $rolename ['name']
  1288. );
  1289. array_push ( $roleArray, $exp );
  1290. }
  1291. $roleArrayCopy [$v [0]] = $roleArray;
  1292. // $verifyList[$k]['roleArray']=$roleArray;
  1293. }
  1294. // print_r($roleArray);
  1295. $verifyList [$k] ['date'] = "";
  1296. $verifyList [$k] ['opinion'] = "";
  1297. $verifyList [$k] ['status'] = "";
  1298. if (empty ( $verifyStaff )) {
  1299. $verifyList [$k] ['date'] = "";
  1300. $verifyList [$k] ['opinion'] = "";
  1301. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1302. $verifyList [$k] ['status'] = 4;
  1303. $button = 4;
  1304. $flag = false;
  1305. }
  1306. } else {
  1307. foreach ( $verifyStaff as $m => $u ) {
  1308. if ($v [0] == $m) {
  1309. $verifyList [$k] ['date'] = $u ['date'];
  1310. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1311. $verifyList [$k] ['status'] = $u ['status'];
  1312. $flag = false;
  1313. break;
  1314. }
  1315. }
  1316. $endStaffArray = end ( $verifyStaff );
  1317. if (isset ( $endStaffArray ['ROLE'] )) {
  1318. } else {
  1319. $endKey = key ( $verifyStaff );
  1320. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  1321. $button = 4;
  1322. $verifyList [$k] ['status'] = 4;
  1323. }
  1324. }
  1325. }
  1326. }
  1327. $rolename ['name'] = '';
  1328. if (! empty ( $roleId )) {
  1329. Doo::loadModel ( 'role' );
  1330. $role = new role ();
  1331. $rolename = $role->getOne ( array (
  1332. 'where' => 'rid=' . $roleId,
  1333. 'asArray' => true
  1334. ) );
  1335. }
  1336. if (! empty ( $verifyStaff ))
  1337. $endStaffArray = end ( $verifyStaff );
  1338. $KOP = false;
  1339. foreach ( $roleArrayCopy as $P => $A ) {
  1340. foreach ( $A as $MKI => $AVL ) {
  1341. if (! empty ( $verifyStaff )) {
  1342. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1343. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1344. $button = 4;
  1345. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1346. }
  1347. foreach ( $verifyStaff as $m => $u ) {
  1348. $AVLFK = $AVL [0] . '_R';
  1349. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1350. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1351. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1352. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1353. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1354. break;
  1355. }
  1356. }
  1357. } else {
  1358. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1359. $button = 4;
  1360. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1361. }
  1362. }
  1363. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1364. $KOP = true;
  1365. }
  1366. }
  1367. foreach ( $roleArrayCopy as $k => $v ) {
  1368. foreach ( $verifyList as $m => $n ) {
  1369. if ($n [0] == $k) {
  1370. array_splice ( $verifyList, $m, 1, $v );
  1371. }
  1372. }
  1373. }
  1374. $receiptList [$key] ['verifyList'] = $verifyList;
  1375. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1376. 'where' => 'sid=' . $value ['staff'],
  1377. 'asArray' => true
  1378. ) );
  1379. $receiptList [$key] ['button'] = $button;
  1380. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1381. }
  1382. $mothHtml = "";
  1383. for($i = 1; $i <= 12; $i ++) {
  1384. if ($month == $i)
  1385. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  1386. else
  1387. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  1388. }
  1389. // 获取审批日志
  1390. Doo::loadModel ( 'receiptLog' );
  1391. $receiptLog = new receiptLog ();
  1392. $rlList = array ();
  1393. $rlInfo = $receiptLog->getOne ( array (
  1394. 'where' => 'rid=' . $rid . ' and status=4',
  1395. 'asArray' => true
  1396. ) );
  1397. $tijdate = $receiptLog->getOne ( array (
  1398. 'where' => 'rid=' . $rid . ' and status=2',
  1399. 'asc' => 'rlid',
  1400. 'asArray' => true
  1401. ) );
  1402. if (! empty ( $rlInfo )) {
  1403. $rlList = $receiptLog->find ( array (
  1404. 'where' => 'rid=' . $rid,
  1405. 'asc' => 'rlid',
  1406. 'asArray' => true
  1407. ) );
  1408. }
  1409. $receiptList [0] ['rlList'] = $rlList;
  1410. $enclosurList = $enclosur->find ( array (
  1411. 'where' => 'rid=' . $rid,
  1412. 'asArray' => true
  1413. ) );
  1414. $enclosurHtml = '';
  1415. foreach ( $enclosurList as $value ) {
  1416. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  1417. }
  1418. // print_r($receiptList);
  1419. $data ['enclosurHtml'] = $enclosurHtml;
  1420. $data ['rolename'] = $rolename ['name'];
  1421. $data ['datetij'] = $tijdate ['date'];
  1422. $data ['mothHtml'] = $mothHtml;
  1423. $data ['rid'] = $rid;
  1424. $data ['receiptList'] = $receiptList;
  1425. $data ['receiptApprovalCount'] = count ( $receiptList );
  1426. $data ['status'] = $status;
  1427. $data ['year'] = $year;
  1428. $data ['categoryList'] = $categoryList;
  1429. $data ['staffList'] = $staffList;
  1430. $data ['cid'] = $cid;
  1431. $data ['sid'] = $sid;
  1432. $data ['ap'] = $ap;
  1433. $data ['memu'] = "receipt";
  1434. $data ['staff'] = $this->staff;
  1435. $data ['receiptMemu'] = 'approvalExpenses';
  1436. $data ['verifyId'] = $this->verifyId;
  1437. $data ['executeId'] = $this->executeId;
  1438. $this->render ( "/admin/remitApproval", $data );
  1439. }
  1440. function saeaLoanAdd() {
  1441. Doo::loadModel ( 'verify' );
  1442. $verify = new verify ();
  1443. Doo::loadModel ( "role" );
  1444. $role = new role ();
  1445. Doo::loadModel ( 'L_category' );
  1446. $lCategory = new L_category ();
  1447. $veList = $verify->getVerifyBySubordinate('LOAN');
  1448. $data ['category'] = $lCategory->find ( array (
  1449. 'asArray' => true
  1450. ) );
  1451. $data ['veList'] = $veList;
  1452. $data ['memu'] = "receipt";
  1453. $data ['staff'] = $this->staff;
  1454. $data ['receiptMemu'] = 'saeaBorad';
  1455. $data ['verifyId'] = $this->verifyId;
  1456. $data ['executeId'] = $this->executeId;
  1457. $this->render ( "/admin/saeaLoanAdd", $data );
  1458. }
  1459. function saeaLoanAddDo() {
  1460. $agency = $this->get_args ( 'agency' );
  1461. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1462. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1463. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1464. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1465. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1466. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1467. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1468. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1469. // die;
  1470. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1471. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1472. header ( 'Content-Type:text/html;charset=utf-8' );
  1473. die ( '请填写联行号' );
  1474. }
  1475. Doo::loadModel ( 'receipt' );
  1476. Doo::loadModel ( 'receiptDetail' );
  1477. Doo::loadModel ( 'accountItem' );
  1478. $accountItem = new accountItem ();
  1479. $receipt = new receipt ();
  1480. Doo::loadModel ( 'loanReceipt' );
  1481. $loanReceipt = new loanReceipt ();
  1482. Doo::loadModel ( 'execute' );
  1483. $execute = new execute ();
  1484. Doo::loadModel ( 'enclosur' );
  1485. $executeDetail = $execute->getOne ( array (
  1486. 'where' => 'mold="借款执行人"',
  1487. 'asArray' => true
  1488. ) );
  1489. $aItem = $accountItem->find ( array (
  1490. 'asArray' => true
  1491. ) );
  1492. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1493. $ag = $tr = $ta = $ot = 0;
  1494. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1495. array_push ( $accountJson ['借款费用'], array (
  1496. 'aid' => 0,
  1497. 'name' => '申请金额',
  1498. 'price' => number_format ( $agency, 2, '.', '' )
  1499. ) );
  1500. $sum += $agency;
  1501. $agencySum += $agency;
  1502. $accountJson ['cSum'] = array (
  1503. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1504. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1505. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1506. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1507. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1508. );
  1509. // 借款数据备份
  1510. $loanReceipt->loanItem = json_encode ( $accountJson );
  1511. $loanReceipt->staff = $this->staff [0] ['sid'];
  1512. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1513. $loanReceipt->date = date ( "Y-m-d" );
  1514. $loanReceipt->cid = $cid;
  1515. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1516. $loanReceipt->status = 5;
  1517. $loanReceipt->Rtype = 1;
  1518. $loanReceipt->verify = $verify;
  1519. $receipt->receiptOrder = $receipt->receiptOrder;
  1520. // 添加HTML换行符
  1521. // var_dump($explanation);
  1522. $order = array (
  1523. "\r\n",
  1524. "\n",
  1525. "\r"
  1526. );
  1527. $replace = '<br/>';
  1528. $explanation = str_replace ( $order, $replace, $explanation );
  1529. // $explanation=str_replace('\r',"<br/>",$explanation);
  1530. // $explanation=str_replace('\r\n',"<br/>",$explanation);
  1531. $loanReceipt->explanation = $explanation;
  1532. $loanRid = $loanReceipt->insert ();
  1533. // 报销单
  1534. $receipt->loanItem = json_encode ( $accountJson );
  1535. $receipt->staff = $this->staff [0] ['sid'];
  1536. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1537. $receipt->date = date ( "Y-m-d" );
  1538. $receipt->cid = $cid;
  1539. // 特殊状态
  1540. $receipt->status = 5;
  1541. $receipt->Rtype = 1;
  1542. $receipt->loanRid = $loanRid;
  1543. // 修改审批流程加入角色
  1544. $receipt->verify = $verify;
  1545. $receipt->executeCopy = $executeDetail ['staff'];
  1546. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  1547. $receipt->explanation = $explanation;
  1548. $receipt->remittanceName = $remittanceName;
  1549. $receipt->bankName = $bankName;
  1550. $receipt->bankNumber = $bankNumber;
  1551. $receipt->remittanceBankType = $remittanceBankType;
  1552. if ($remittanceBankType == 1)
  1553. $receipt->coupletNumber = $coupletNumber;
  1554. $rid = $receipt->insert ();
  1555. return "/saeaBorad";
  1556. } else
  1557. die ( 'illegal request' );
  1558. }
  1559. function saeaLoanEdi() {
  1560. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1561. Doo::loadClass ( 'XDeode' );
  1562. $XDeode = new XDeode ( 7 );
  1563. $rid = $XDeode->decode ( $ridKey );
  1564. if (! is_numeric ( $rid ))
  1565. die ( 'illegal request' );
  1566. Doo::loadModel ( 'verify' );
  1567. $verify = new verify ();
  1568. Doo::loadModel ( "role" );
  1569. $role = new role ();
  1570. Doo::loadModel ( 'L_category' );
  1571. $lCategory = new L_category ();
  1572. Doo::loadModel ( 'receipt' );
  1573. $receipt = new receipt ();
  1574. $receiptInfo = $receipt->getOne ( array (
  1575. 'where' => 'rid=' . $rid,
  1576. 'asArray' => true
  1577. ) );
  1578. $veList = $verify->find ( array (
  1579. 'where'=>'subordinate like "%LOAN%"',
  1580. 'asArray' => true
  1581. ) );
  1582. foreach ( $veList as $key => $value ) {
  1583. $v = json_decode ( $value ['staff'] );
  1584. $list = array ();
  1585. foreach ( $v as $n => $m ) {
  1586. if ($m ['1'] == 'ROLE') {
  1587. $roleInfo = $role->getOne ( array (
  1588. 'where' => 'rid=' . $m [0],
  1589. 'asArray' => true
  1590. ) );
  1591. $v [$n] [1] = $roleInfo ['name'];
  1592. array_push ( $list, $roleInfo ['name'] );
  1593. } else {
  1594. array_push ( $list, $v [$n] [1] );
  1595. }
  1596. }
  1597. $veList [$key] ['staff'] = implode ( '>', $list );
  1598. }
  1599. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  1600. // print_r($receiptInfo);
  1601. $data ['receiptInfo'] = $receiptInfo;
  1602. $data ['category'] = $lCategory->find ( array (
  1603. 'asArray' => true
  1604. ) );
  1605. $data ['veList'] = $veList;
  1606. $data ['ridKey'] = $ridKey;
  1607. $data ['memu'] = "receipt";
  1608. $data ['staff'] = $this->staff;
  1609. $data ['receiptMemu'] = 'saeaBorad';
  1610. $data ['verifyId'] = $this->verifyId;
  1611. $data ['executeId'] = $this->executeId;
  1612. $this->render ( "/admin/saeaLoanEdi", $data );
  1613. }
  1614. function saeaLoanEdiDo() {
  1615. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1616. $agency = $this->get_args ( 'agency' );
  1617. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1618. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1619. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1620. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1621. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1622. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1623. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1624. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1625. // die;
  1626. Doo::loadClass ( 'XDeode' );
  1627. $XDeode = new XDeode ( 7 );
  1628. $rid = $XDeode->decode ( $ridKey );
  1629. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1630. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1631. header ( 'Content-Type:text/html;charset=utf-8' );
  1632. die ( '请填写联行号' );
  1633. }
  1634. Doo::loadModel ( 'receipt' );
  1635. Doo::loadModel ( 'receiptDetail' );
  1636. Doo::loadModel ( 'accountItem' );
  1637. $accountItem = new accountItem ();
  1638. $receipt = new receipt ();
  1639. Doo::loadModel ( 'loanReceipt' );
  1640. $loanReceipt = new loanReceipt ();
  1641. Doo::loadModel ( 'enclosur' );
  1642. Doo::loadModel ( 'execute' );
  1643. $execute = new execute ();
  1644. $executeDetail = $execute->getOne ( array (
  1645. 'where' => 'mold="借款执行人"',
  1646. 'asArray' => true
  1647. ) );
  1648. $receiptDetail = $receipt->getOne ( array (
  1649. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  1650. 'asArray' => true
  1651. ) );
  1652. if (empty ( $receiptDetail ))
  1653. die ( '参数错误' );
  1654. $aItem = $accountItem->find ( array (
  1655. 'asArray' => true
  1656. ) );
  1657. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1658. $ag = $tr = $ta = $ot = 0;
  1659. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1660. array_push ( $accountJson ['借款费用'], array (
  1661. 'aid' => 0,
  1662. 'name' => '申请金额',
  1663. 'price' => number_format ( $agency, 2, '.', '' )
  1664. ) );
  1665. $sum += $agency;
  1666. $agencySum += $agency;
  1667. $accountJson ['cSum'] = array (
  1668. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1669. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1670. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1671. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1672. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1673. );
  1674. // 报销单
  1675. $receipt->loanItem = json_encode ( $accountJson );
  1676. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1677. $receipt->cid = $cid;
  1678. // 特殊状态
  1679. // 修改审批流程加入角色
  1680. if ($receiptDetail ['status'] != 4)
  1681. $receipt->verify = $verify;
  1682. $order = array (
  1683. "\r\n",
  1684. "\n",
  1685. "\r"
  1686. );
  1687. $replace = '<br/>';
  1688. $explanation = str_replace ( $order, $replace, $explanation );
  1689. $receipt->explanation = $explanation;
  1690. $receipt->remittanceName = $remittanceName;
  1691. $receipt->bankName = $bankName;
  1692. $receipt->bankNumber = $bankNumber;
  1693. $receipt->remittanceBankType = $remittanceBankType;
  1694. if ($remittanceBankType == 1)
  1695. $receipt->coupletNumber = $coupletNumber;
  1696. $receipt->update ( array (
  1697. 'where' => 'rid=' . $rid
  1698. ) );
  1699. // 借款数据更新
  1700. $loanReceipt->loanItem = json_encode ( $accountJson );
  1701. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1702. $loanReceipt->cid = $cid;
  1703. if ($receiptDetail ['status'] != 4)
  1704. $loanReceipt->verify = $verify;
  1705. $loanReceipt->explanation = $explanation;
  1706. $receipt->executeCopy = $executeDetail ['staff'];
  1707. $loanReceipt->update ( array (
  1708. 'where' => 'rid=' . $receiptDetail ['loanRid']
  1709. ) );
  1710. }
  1711. return "/saeaBorad";
  1712. }
  1713. function saeaLoanReceiptAdd() {
  1714. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1715. Doo::loadModel ( 'receipt' );
  1716. $receipt = new receipt ();
  1717. Doo::loadModel ( 'loanReceipt' );
  1718. $loanReceipt = new loanReceipt ();
  1719. Doo::loadModel ( 'L_category' );
  1720. $Lcategory = new L_category ();
  1721. Doo::loadModel ( 'verify' );
  1722. Doo::loadModel ( 'statistics' );
  1723. $statistics = new statistics ();
  1724. $verify = new verify ();
  1725. Doo::loadModel ( 'staff' );
  1726. $staff = new staff ();
  1727. $receiptDetail = $receipt->getOne ( array (
  1728. 'where' => 'rid=' . $rid,
  1729. 'desc' => 'rid',
  1730. 'asArray' => true
  1731. ) );
  1732. $receiptList = $loanReceipt->find ( array (
  1733. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1734. 'desc' => 'rid',
  1735. 'asArray' => true
  1736. ) );
  1737. $Locate = 0;
  1738. $roleId = 0;
  1739. $button = 0;
  1740. foreach ( $receiptList as $key => $value ) {
  1741. $receiptList [$key] ['Locate'] = $Locate;
  1742. $Locate ++;
  1743. $receiptList [$key] ['reviseDetail'] = array ();
  1744. if (! empty ( $value ['reviseDetail'] ))
  1745. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1746. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1747. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1748. $categoryDetil = $Lcategory->getOne ( array (
  1749. 'where' => 'cid=' . $value ['cid'],
  1750. 'asArray' => true
  1751. ) );
  1752. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1753. // 检测编辑状态
  1754. $verifyList = $verify->getOne ( array (
  1755. 'where' => 'vid=' . $value ['verify'],
  1756. 'asArray' => true
  1757. ) );
  1758. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1759. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1760. Doo::loadModel ( 'role' );
  1761. $role = new role ();
  1762. $flag = true;
  1763. $roleKey = 0;
  1764. $endStaffArray = array ();
  1765. $roleArrayCopy = array ();
  1766. foreach ( $verifyList as $k => $v ) {
  1767. // init verifyStaff
  1768. if ($v [1] == 'ROLE') {
  1769. if (! empty ( $verifyStaff )) {
  1770. $endStaffArray = end ( $verifyStaff );
  1771. // if ($v[0]==$endStaffArray['nextStaff']){
  1772. // $roleId=$v[0];
  1773. // }
  1774. }
  1775. $roleVerify = json_decode ( $v [3], true );
  1776. $roleKey = $k;
  1777. $roleArray = array ();
  1778. $rolename = $role->getOne ( array (
  1779. 'where' => 'rid=' . $v [0],
  1780. 'asArray' => true
  1781. ) );
  1782. foreach ( $roleVerify as $o => $p ) {
  1783. $staffID = explode ( '_', $p );
  1784. $staffInfo = $staff->getOne ( array (
  1785. 'where' => 'sid=' . $staffID [0],
  1786. 'asArray' => true
  1787. ) );
  1788. // print_r($staffID);
  1789. $exp = array (
  1790. 0 => $staffInfo ['sid'],
  1791. 1 => $staffID [1],
  1792. 2 => $staffInfo ['avatar'],
  1793. 'date' => '',
  1794. 'date' => '',
  1795. 'opinion' => '',
  1796. 'status' => '',
  1797. 'rolename' => $rolename ['name']
  1798. );
  1799. array_push ( $roleArray, $exp );
  1800. }
  1801. $roleArrayCopy [$v [0]] = $roleArray;
  1802. // $verifyList[$k]['roleArray']=$roleArray;
  1803. }
  1804. $verifyList [$k] ['date'] = "";
  1805. $verifyList [$k] ['opinion'] = "";
  1806. $verifyList [$k] ['status'] = "";
  1807. if (empty ( $verifyStaff )) {
  1808. $verifyList [$k] ['date'] = "";
  1809. $verifyList [$k] ['opinion'] = "";
  1810. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1811. $verifyList [$k] ['status'] = 4;
  1812. $flag = false;
  1813. }
  1814. } else {
  1815. foreach ( $verifyStaff as $m => $u ) {
  1816. if ($v [0] == $m) {
  1817. $verifyList [$k] ['date'] = $u ['date'];
  1818. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1819. $verifyList [$k] ['status'] = $u ['status'];
  1820. $flag = false;
  1821. break;
  1822. }
  1823. }
  1824. $endStaffArray = end ( $verifyStaff );
  1825. if (isset ( $endStaffArray ['ROLE'] )) {
  1826. } else {
  1827. // $endKey=key($verifyStaff);
  1828. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1829. // $button=4;
  1830. // $verifyList[$k]['status']=4;
  1831. // }
  1832. }
  1833. }
  1834. }
  1835. $rolename ['name'] = '';
  1836. if (! empty ( $roleId )) {
  1837. Doo::loadModel ( 'role' );
  1838. $role = new role ();
  1839. $rolename = $role->getOne ( array (
  1840. 'where' => 'rid=' . $roleId,
  1841. 'asArray' => true
  1842. ) );
  1843. }
  1844. if (! empty ( $verifyStaff ))
  1845. $endStaffArray = end ( $verifyStaff );
  1846. $KOP = false;
  1847. foreach ( $roleArrayCopy as $P => $A ) {
  1848. foreach ( $A as $MKI => $AVL ) {
  1849. if (! empty ( $verifyStaff )) {
  1850. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1851. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1852. $button = 4;
  1853. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1854. }
  1855. foreach ( $verifyStaff as $m => $u ) {
  1856. $AVLFK = $AVL [0] . '_R';
  1857. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1858. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1859. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1860. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1861. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1862. break;
  1863. }
  1864. }
  1865. } else {
  1866. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1867. $button = 4;
  1868. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1869. }
  1870. }
  1871. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1872. $KOP = true;
  1873. }
  1874. }
  1875. foreach ( $roleArrayCopy as $k => $v ) {
  1876. foreach ( $verifyList as $m => $n ) {
  1877. if ($n [0] == $k) {
  1878. array_splice ( $verifyList, $m, 1, $v );
  1879. }
  1880. }
  1881. }
  1882. $receiptList [$key] ['verifyList'] = $verifyList;
  1883. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1884. 'where' => 'sid=' . $value ['staff'],
  1885. 'asArray' => true
  1886. ) );
  1887. $receiptList [$key] ['button'] = $button;
  1888. //
  1889. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1890. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1891. }
  1892. $data ['receiptList'] = $receiptList;
  1893. $data ['receiptDetail'] = $receiptDetail;
  1894. Doo::loadModel ( 'L_category' );
  1895. $lCategory = new L_category ();
  1896. Doo::loadModel ( 'accountItem' );
  1897. $accountItem = new accountItem ();
  1898. $acItem = $accountItem->find ( array (
  1899. 'asArray' => true
  1900. ) );
  1901. $veList = $verify->getVerifyBySubordinate('RECEIPT','LOAN');
  1902. $data ['rid'] = $rid;
  1903. $data ['category'] = $lCategory->find ( array (
  1904. 'asArray' => true
  1905. ) );
  1906. $data ['veList'] = $veList;
  1907. $data ['acItem'] = $acItem;
  1908. $data ['memu'] = "receipt";
  1909. $data ['staff'] = $this->staff;
  1910. $data ['receiptMemu'] = 'saeaBorad';
  1911. $data ['verifyId'] = $this->verifyId;
  1912. $data ['executeId'] = $this->executeId;
  1913. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1914. }
  1915. function saeaLoanReceiptAddDo() {
  1916. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1917. $agency = $this->get_args ( 'agency' );
  1918. $travel = $this->get_args ( 'travel' );
  1919. $train = $this->get_args ( 'train' );
  1920. $other = $this->get_args ( 'other' );
  1921. $inttrain = $this->get_args ( 'inttrain' );
  1922. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1923. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1924. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1925. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1926. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1927. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1928. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1929. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1930. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1931. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1932. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1933. header ( 'Content-Type:text/html;charset=utf-8' );
  1934. die ( '请填写联行号' );
  1935. }
  1936. Doo::loadModel ( 'receipt' );
  1937. Doo::loadModel ( 'receiptDetail' );
  1938. Doo::loadModel ( 'accountItem' );
  1939. $accountItem = new accountItem ();
  1940. $receipt = new receipt ();
  1941. Doo::loadModel ( 'enclosur' );
  1942. Doo::loadModel ( 'execute' );
  1943. $execute = new execute ();
  1944. $executeDetail = $execute->getOne ( array (
  1945. 'where' => 'mold="借款费用执行人"',
  1946. 'asArray' => true
  1947. ) );
  1948. $receiptDet = $receipt->getOne ( array (
  1949. 'where' => 'rid=' . $rid,
  1950. 'asArray' => true
  1951. ) );
  1952. // if(!empty($receiptDetail))
  1953. // return "/referReceipt/".$receiptDetail['rid'];
  1954. $aItem = $accountItem->find ( array (
  1955. 'asArray' => true
  1956. ) );
  1957. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1958. $ag = $tr = $ta = $ot =$it = 0;
  1959. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  1960. foreach ( $aItem as $key => $value ) {
  1961. if ($value ['category'] == $this->AGENCY) {
  1962. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1963. array_push ( $accountJson [$this->AGENCY], array (
  1964. 'aid' => $value ['aid'],
  1965. 'name' => $value ['name'],
  1966. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1967. ) );
  1968. $sum += $agency [$ag];
  1969. $agencySum += $agency [$ag];
  1970. }
  1971. $ag ++;
  1972. }
  1973. if ($value ['category'] == $this->TRAVEL) {
  1974. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1975. array_push ( $accountJson [$this->TRAVEL], array (
  1976. 'aid' => $value ['aid'],
  1977. 'name' => $value ['name'],
  1978. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1979. ) );
  1980. $sum += $travel [$tr];
  1981. $travelSum += $travel [$tr];
  1982. }
  1983. $tr ++;
  1984. }
  1985. if ($value ['category'] == $this->INTTRAIN) {
  1986. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  1987. array_push ( $accountJson [$this->INTTRAIN], array (
  1988. 'aid' => $value ['aid'],
  1989. 'name' => $value ['name'],
  1990. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  1991. ) );
  1992. $sum += $inttrain [$it];
  1993. $inttrainSum += $inttrain [$it];
  1994. }
  1995. $it ++;
  1996. }
  1997. if ($value ['category'] == $this->TRAIN) {
  1998. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1999. array_push ( $accountJson [$this->TRAIN], array (
  2000. 'aid' => $value ['aid'],
  2001. 'name' => $value ['name'],
  2002. 'price' => number_format ( $train [$ta], 2, '.', '' )
  2003. ) );
  2004. $sum += $train [$ta];
  2005. $trainSum += $train [$ta];
  2006. }
  2007. $ta ++;
  2008. }
  2009. if ($value ['category'] == $this->OTHER) {
  2010. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  2011. array_push ( $accountJson [$this->OTHER], array (
  2012. 'aid' => $value ['aid'],
  2013. 'name' => $value ['name'],
  2014. 'price' => number_format ( $other [$ot], 2, '.', '' )
  2015. ) );
  2016. $sum += $other [$ot];
  2017. $otherSum += $other [$ot];
  2018. }
  2019. $ot ++;
  2020. }
  2021. }
  2022. $accountJson ['cSum'] = array (
  2023. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  2024. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  2025. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  2026. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  2027. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  2028. );
  2029. // 报销单
  2030. $receipt->accountItem = json_encode ( $accountJson );
  2031. $receipt->staff = $this->staff [0] ['sid'];
  2032. $receipt->loanSum = $receiptDet ['sum'];
  2033. $receipt->sum = number_format ( $sum, 2, '.', '' );
  2034. $receipt->date = date ( "Y-m-d" );
  2035. $receipt->pastDate = '';
  2036. $receipt->cid = $cid;
  2037. $receipt->status = 7;
  2038. // 修改审批流程加入角色
  2039. $receipt->verify = $verify;
  2040. $receipt->verifyStaff = '';
  2041. $receipt->executeStaff = '';
  2042. $receipt->executeCopy = $executeDetail ['staff'];
  2043. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  2044. $receipt->explanation = $explanation;
  2045. $receipt->remittanceName = $remittanceName;
  2046. $receipt->bankName = $bankName;
  2047. $receipt->bankNumber = $bankNumber;
  2048. $receipt->remittanceBankType = $remittanceBankType;
  2049. if ($remittanceBankType == 1)
  2050. $receipt->coupletNumber = $coupletNumber;
  2051. $receipt->update ( array (
  2052. 'where' => 'rid=' . $rid
  2053. ) );
  2054. // 附件
  2055. if (! empty ( $enclosurName )) {
  2056. $enclosurArray = explode ( '-', $enclosurName );
  2057. foreach ( $enclosurArray as $value ) {
  2058. $enclosur = new enclosur ();
  2059. $enclosur->name = $value;
  2060. $enclosur->rid = $rid;
  2061. $enclosur->insert ();
  2062. }
  2063. // print_r($enclosurArray);die;
  2064. }
  2065. // 报销详情
  2066. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  2067. $receiptDetail = new receiptDetail ();
  2068. $receiptDetail->staff = $this->staff [0] ['sid'];
  2069. $receiptDetail->item = $value ['name'];
  2070. $receiptDetail->itemCategory = $this->AGENCY;
  2071. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2072. $receiptDetail->date = date ( "Y-m-d" );
  2073. $receiptDetail->cid = $cid;
  2074. $receiptDetail->rid = $rid;
  2075. $receiptDetail->status = 4;
  2076. $receiptDetail->insert ();
  2077. }
  2078. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  2079. $receiptDetail = new receiptDetail ();
  2080. $receiptDetail->staff = $this->staff [0] ['sid'];
  2081. $receiptDetail->item = $value ['name'];
  2082. $receiptDetail->itemCategory = $this->TRAVEL;
  2083. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2084. $receiptDetail->date = date ( "Y-m-d" );
  2085. $receiptDetail->cid = $cid;
  2086. $receiptDetail->rid = $rid;
  2087. $receiptDetail->status = 4;
  2088. $receiptDetail->insert ();
  2089. }
  2090. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  2091. $receiptDetail = new receiptDetail ();
  2092. $receiptDetail->staff = $this->staff [0] ['sid'];
  2093. $receiptDetail->item = $value ['name'];
  2094. $receiptDetail->itemCategory = $this->TRAIN;
  2095. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2096. $receiptDetail->date = date ( "Y-m-d" );
  2097. $receiptDetail->cid = $cid;
  2098. $receiptDetail->rid = $rid;
  2099. $receiptDetail->status = 4;
  2100. $receiptDetail->insert ();
  2101. }
  2102. //内训
  2103. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  2104. $receiptDetail = new receiptDetail ();
  2105. $receiptDetail->staff = $this->staff [0] ['sid'];
  2106. $receiptDetail->item = $value ['name'];
  2107. $receiptDetail->itemCategory = $this->INTTRAIN;
  2108. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2109. $receiptDetail->date = date ( "Y-m-d" );
  2110. $receiptDetail->cid = $cid;
  2111. $receiptDetail->rid = $rid;
  2112. $receiptDetail->status = 4;
  2113. $receiptDetail->insert ();
  2114. }
  2115. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  2116. $receiptDetail = new receiptDetail ();
  2117. $receiptDetail->staff = $this->staff [0] ['sid'];
  2118. $receiptDetail->item = $value ['name'];
  2119. $receiptDetail->itemCategory = $this->OTHER;
  2120. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2121. $receiptDetail->date = date ( "Y-m-d" );
  2122. $receiptDetail->cid = $cid;
  2123. $receiptDetail->rid = $rid;
  2124. $receiptDetail->status = 4;
  2125. $receiptDetail->insert ();
  2126. }
  2127. return "/saeaBorad";
  2128. }
  2129. return "/saeaLoanReceiptAdd/" . $rid;
  2130. }
  2131. function saeaLoanReceiptEdi() {
  2132. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2133. Doo::loadClass ( 'XDeode' );
  2134. $XDeode = new XDeode ( 7 );
  2135. $rid = $XDeode->decode ( $ridKey );
  2136. if (! is_numeric ( $rid ))
  2137. die ( 'illegal request' );
  2138. Doo::loadModel ( 'accountItem' );
  2139. Doo::loadModel ( 'verify' );
  2140. Doo::loadModel ( 'receipt' );
  2141. $receipt = new receipt ();
  2142. $verify = new verify ();
  2143. $accountItem = new accountItem ();
  2144. Doo::loadModel ( 'L_category' );
  2145. $Lcategory = new L_category ();
  2146. Doo::loadModel ( "role" );
  2147. $role = new role ();
  2148. Doo::loadModel ( 'loanReceipt' );
  2149. $loanReceipt = new loanReceipt ();
  2150. Doo::loadModel ( 'staff' );
  2151. $staff = new staff ();
  2152. $receiptDetail = $receipt->getOne ( array (
  2153. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  2154. 'asArray' => true
  2155. ) );
  2156. if (empty ( $receiptDetail ))
  2157. return "/saeaBorad";
  2158. $receiptList = $loanReceipt->find ( array (
  2159. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  2160. 'desc' => 'rid',
  2161. 'asArray' => true
  2162. ) );
  2163. $Locate = 0;
  2164. $roleId = 0;
  2165. $button = 0;
  2166. foreach ( $receiptList as $key => $value ) {
  2167. $receiptList [$key] ['Locate'] = $Locate;
  2168. $Locate ++;
  2169. $receiptList [$key] ['reviseDetail'] = array ();
  2170. if (! empty ( $value ['reviseDetail'] ))
  2171. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2172. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2173. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2174. $categoryDetil = $Lcategory->getOne ( array (
  2175. 'where' => 'cid=' . $value ['cid'],
  2176. 'asArray' => true
  2177. ) );
  2178. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2179. // 检测编辑状态
  2180. $verifyList = $verify->getOne ( array (
  2181. 'where' => 'vid=' . $value ['verify'],
  2182. 'asArray' => true
  2183. ) );
  2184. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2185. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2186. Doo::loadModel ( 'role' );
  2187. $role = new role ();
  2188. $flag = true;
  2189. $roleKey = 0;
  2190. $endStaffArray = array ();
  2191. $roleArrayCopy = array ();
  2192. foreach ( $verifyList as $k => $v ) {
  2193. // init verifyStaff
  2194. if ($v [1] == 'ROLE') {
  2195. if (! empty ( $verifyStaff )) {
  2196. $endStaffArray = end ( $verifyStaff );
  2197. // if ($v[0]==$endStaffArray['nextStaff']){
  2198. // $roleId=$v[0];
  2199. // }
  2200. }
  2201. $roleVerify = json_decode ( $v [3], true );
  2202. $roleKey = $k;
  2203. $roleArray = array ();
  2204. $rolename = $role->getOne ( array (
  2205. 'where' => 'rid=' . $v [0],
  2206. 'asArray' => true
  2207. ) );
  2208. foreach ( $roleVerify as $o => $p ) {
  2209. $staffID = explode ( '_', $p );
  2210. $staffInfo = $staff->getOne ( array (
  2211. 'where' => 'sid=' . $staffID [0],
  2212. 'asArray' => true
  2213. ) );
  2214. // print_r($staffID);
  2215. $exp = array (
  2216. 0 => $staffInfo ['sid'],
  2217. 1 => $staffID [1],
  2218. 2 => $staffInfo ['avatar'],
  2219. 'date' => '',
  2220. 'date' => '',
  2221. 'opinion' => '',
  2222. 'status' => '',
  2223. 'rolename' => $rolename ['name']
  2224. );
  2225. array_push ( $roleArray, $exp );
  2226. }
  2227. $roleArrayCopy [$v [0]] = $roleArray;
  2228. // $verifyList[$k]['roleArray']=$roleArray;
  2229. }
  2230. $verifyList [$k] ['date'] = "";
  2231. $verifyList [$k] ['opinion'] = "";
  2232. $verifyList [$k] ['status'] = "";
  2233. if (empty ( $verifyStaff )) {
  2234. $verifyList [$k] ['date'] = "";
  2235. $verifyList [$k] ['opinion'] = "";
  2236. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2237. $verifyList [$k] ['status'] = 4;
  2238. $flag = false;
  2239. }
  2240. } else {
  2241. foreach ( $verifyStaff as $m => $u ) {
  2242. if ($v [0] == $m) {
  2243. $verifyList [$k] ['date'] = $u ['date'];
  2244. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2245. $verifyList [$k] ['status'] = $u ['status'];
  2246. $flag = false;
  2247. break;
  2248. }
  2249. }
  2250. $endStaffArray = end ( $verifyStaff );
  2251. if (isset ( $endStaffArray ['ROLE'] )) {
  2252. } else {
  2253. // $endKey=key($verifyStaff);
  2254. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2255. // $button=4;
  2256. // $verifyList[$k]['status']=4;
  2257. // }
  2258. }
  2259. }
  2260. }
  2261. $rolename ['name'] = '';
  2262. if (! empty ( $roleId )) {
  2263. Doo::loadModel ( 'role' );
  2264. $role = new role ();
  2265. $rolename = $role->getOne ( array (
  2266. 'where' => 'rid=' . $roleId,
  2267. 'asArray' => true
  2268. ) );
  2269. }
  2270. if (! empty ( $verifyStaff ))
  2271. $endStaffArray = end ( $verifyStaff );
  2272. $KOP = false;
  2273. foreach ( $roleArrayCopy as $P => $A ) {
  2274. foreach ( $A as $MKI => $AVL ) {
  2275. if (! empty ( $verifyStaff )) {
  2276. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2277. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2278. $button = 4;
  2279. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2280. }
  2281. foreach ( $verifyStaff as $m => $u ) {
  2282. $AVLFK = $AVL [0] . '_R';
  2283. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2284. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2285. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2286. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2287. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2288. break;
  2289. }
  2290. }
  2291. } else {
  2292. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2293. $button = 4;
  2294. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2295. }
  2296. }
  2297. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2298. $KOP = true;
  2299. }
  2300. }
  2301. foreach ( $roleArrayCopy as $k => $v ) {
  2302. foreach ( $verifyList as $m => $n ) {
  2303. if ($n [0] == $k) {
  2304. array_splice ( $verifyList, $m, 1, $v );
  2305. }
  2306. }
  2307. }
  2308. $receiptList [$key] ['verifyList'] = $verifyList;
  2309. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2310. 'where' => 'sid=' . $value ['staff'],
  2311. 'asArray' => true
  2312. ) );
  2313. $receiptList [$key] ['button'] = $button;
  2314. //
  2315. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  2316. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  2317. }
  2318. $data ['receiptList'] = $receiptList;
  2319. $acItem = $accountItem->find ( array (
  2320. 'asArray' => true
  2321. ) );
  2322. $veList = $verify->find ( array (
  2323. 'asArray' => true
  2324. ) );
  2325. foreach ( $veList as $key => $value ) {
  2326. $v = json_decode ( $value ['staff'] );
  2327. $list = array ();
  2328. foreach ( $v as $n => $m ) {
  2329. if ($m ['1'] == 'ROLE') {
  2330. $roleInfo = $role->getOne ( array (
  2331. 'where' => 'rid=' . $m [0],
  2332. 'asArray' => true
  2333. ) );
  2334. $v [$n] [1] = $roleInfo ['name'];
  2335. array_push ( $list, $roleInfo ['name'] );
  2336. } else {
  2337. array_push ( $list, $v [$n] [1] );
  2338. }
  2339. }
  2340. $veList [$key] ['staff'] = implode ( '>', $list );
  2341. }
  2342. // 配置编辑信息
  2343. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  2344. foreach ( $acItem as $key => $value ) {
  2345. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  2346. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  2347. $acItem [$key] ['price'] = $v ['price'];
  2348. }
  2349. }
  2350. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  2351. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  2352. $acItem [$key] ['price'] = $v ['price'];
  2353. }
  2354. }
  2355. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  2356. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  2357. $acItem [$key] ['price'] = $v ['price'];
  2358. }
  2359. }
  2360. //内训
  2361. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  2362. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  2363. $acItem [$key] ['price'] = $v ['price'];
  2364. }
  2365. }
  2366. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  2367. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  2368. $acItem [$key] ['price'] = $v ['price'];
  2369. }
  2370. }
  2371. }
  2372. $data ['category'] = $Lcategory->find ( array (
  2373. 'asArray' => true
  2374. ) );
  2375. $data ['ridKey'] = $ridKey;
  2376. $data ['cSum'] = $accountItemList ['cSum'];
  2377. $data ['sum'] = $receiptDetail ['sum'];
  2378. $data ['receiptDetail'] = $receiptDetail;
  2379. $data ['veList'] = $veList;
  2380. $data ['acItem'] = $acItem;
  2381. $data ['memu'] = "receipt";
  2382. $data ['staff'] = $this->staff;
  2383. $data ['receiptMemu'] = 'saeaBorad';
  2384. $data ['verify'] = $receiptDetail ['verify'];
  2385. $data ['verifyId'] = $this->verifyId;
  2386. $data ['executeId'] = $this->executeId;
  2387. $data ['rid'] = $rid;
  2388. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  2389. }
  2390. /**
  2391. * 培训班结算
  2392. */
  2393. function receiptTrainAdd() {
  2394. Doo::loadModel ( 'accountItem' );
  2395. $accountItem = new accountItem ();
  2396. $acItem = $accountItem->find ( array (
  2397. 'asArray' => true
  2398. ) );
  2399. // 审批组
  2400. Doo::loadModel ( 'verify' );
  2401. $verify = new verify ();
  2402. $veList = $verify->getVerifyBySubordinate('TRAIN');
  2403. // 办事处
  2404. Doo::loadModel ( 'L_category' );
  2405. $lCategory = new L_category ();
  2406. $data ['category'] = $lCategory->getCategory ();
  2407. $data ['veList'] = $veList;
  2408. $data ['memu'] = "receipt";
  2409. $data ['staff'] = $this->staff;
  2410. $data ['acItem'] = $acItem;
  2411. $data ['receiptMemu'] = 'saeaBorad';
  2412. $data ['verifyId'] = $this->verifyId;
  2413. $data ['executeId'] = $this->executeId;
  2414. $this->render ( "/receipt/receiptTrainAdd", $data );
  2415. }
  2416. /**
  2417. * 添加培训班结算
  2418. */
  2419. function receiptTrainAddDo() {//include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  2420. // 培训班信息
  2421. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  2422. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  2423. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  2424. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  2425. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  2426. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  2427. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  2428. // 发票信息
  2429. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2430. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2431. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2432. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2433. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2434. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2435. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2436. //&&! empty ( $participants )
  2437. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  2438. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2439. header ( 'Content-Type:text/html;charset=utf-8' );
  2440. die ( '请填写联行号' );
  2441. }
  2442. Doo::loadModel ( 'execute' );
  2443. $execute = new execute ();
  2444. $executeDetail = $execute->getOne ( array (
  2445. 'where' => 'mold="培训班结算"',
  2446. 'asArray' => true
  2447. ) );
  2448. if (empty ( $executeDetail )) {
  2449. header ( 'Content-Type:text/html;charset=utf-8' );
  2450. die ( '未设置执行人' );
  2451. }
  2452. Doo::loadClass ( 'XDeode' );
  2453. $XDeode = new XDeode ( 5 );
  2454. $cid = $XDeode->decode ( $cid );
  2455. Doo::loadModel ( 'receipt' );
  2456. $receipt = new receipt ();
  2457. Doo::loadModel ( 'receiptTraining' );
  2458. $receiptTraining = new receiptTraining ();
  2459. // 创建费用培训班
  2460. $item = array (
  2461. 'cid' => $this->staff [0] ['cid'],
  2462. 'categoryName' => $this->staff [0] ['category'],
  2463. 'trainName' => $trainName,
  2464. 'trainStartDate' => $trainStartDate,
  2465. 'trainEndDate' => $trainEndDate,
  2466. 'participants' => $participants,
  2467. 'freeParticipants'=>$freeParticipants,
  2468. 'trainAddress' => $trainAddress,
  2469. 'trainRemarks' => $trainRemarks,
  2470. 'creator' => $this->staff [0] ['sid'],
  2471. 'creatorDate' => date ( "Y-m-d H:i:s" )
  2472. );
  2473. $irid = $receiptTraining->addReceiptTraining ( $item );
  2474. // 报销单
  2475. $receipt->status = 5;
  2476. $receipt->trainId = $irid;
  2477. $receipt->Rtype = 3;
  2478. $receipt->staff = $this->staff [0] ['sid'];
  2479. $receipt->cid = $cid;
  2480. $receipt->verify = $verify;
  2481. $receipt->date = date ( "Y-m-d" );
  2482. $receipt->executeCopy = $executeDetail ['staff'];
  2483. $receipt->receiptOrder = "#P" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  2484. $receipt->remittanceName = $remittanceName;
  2485. $receipt->bankName = $bankName;
  2486. $receipt->bankNumber = $bankNumber;
  2487. $receipt->remittanceBankType = $remittanceBankType;
  2488. if ($remittanceBankType == 1)
  2489. $receipt->coupletNumber = $coupletNumber;
  2490. $rid = $receipt->insert ();
  2491. $XDeode = new XDeode ( 7 );
  2492. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html";
  2493. } else
  2494. die ( 'illegal request' );
  2495. }
  2496. /**
  2497. * 培训班编辑
  2498. */
  2499. function receiptTrainEdi() {
  2500. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2501. $trainEdiType = $this->get_args ( 'trainEdiType' ) ? $this->get_args ( 'trainEdiType' ) : "INFO";
  2502. Doo::loadClass ( 'XDeode' );
  2503. $XDeode = new XDeode ( 7 );
  2504. $rid = $XDeode->decode ( $ridKey );
  2505. if (! is_numeric ( $rid ))
  2506. die ( 'illegal request' );
  2507. Doo::loadModel ( 'receipt' );
  2508. $receipt = new receipt ();
  2509. Doo::loadModel ( 'receiptTraining' );
  2510. $receiptTraining = new receiptTraining ();
  2511. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2512. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)){
  2513. die ('illegal request--status');
  2514. }
  2515. //如有已入账已收款的发票,自动取消办事处已收款
  2516. // Doo::loadModel ( 'RIExtend' );
  2517. // $RIExtend = new RIExtend ();
  2518. // $RIExtendList=$RIExtend->getRIExtendByRid($rid);
  2519. // if (!empty($RIExtendList)){
  2520. // foreach ($RIExtendList as $key=>$value){
  2521. // $RIExtend = new RIExtend ();
  2522. // $RIExtend->delete(array (
  2523. // 'where' => 'iid=' . $value['iid'],
  2524. // 'limit' => 1
  2525. // ));
  2526. // }
  2527. // }
  2528. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2529. // 汇总表合计
  2530. // 收入合计--加入开票合计
  2531. Doo::loadModel ( 'invoiceTraining' );
  2532. $invoiceTraining = new invoiceTraining ();
  2533. $invoiceTrainingDetail = array (
  2534. 'invoiceArriveAmount' => 0,
  2535. 'RIAmount' => 0,
  2536. 'invoiceTotalAmount' => 0,
  2537. 'invoiceCompanyAmount'=>0
  2538. );
  2539. if ($receiptDetail ['invoiceTrainId'] != 0) {
  2540. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  2541. }
  2542. // print_r($invoiceTrainingDetail);
  2543. $invoiceArriveAmount = $RIAmount = 0;
  2544. if (! empty ( $invoiceTrainingDetail )) {
  2545. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  2546. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  2547. }
  2548. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  2549. //print_r($invoiceTrainingDetail);
  2550. // 支出项目
  2551. Doo::loadModel ( 'accountItem' );
  2552. $accountItem = new accountItem ();
  2553. // 项目金额合计
  2554. Doo::loadModel ( 'RItem' );
  2555. $RItem = new RItem ();
  2556. // 讲师获得
  2557. Doo::loadModel ( 'RILecturer' );
  2558. $RILecturer = new RILecturer ();
  2559. $RItemList = $RItem->getRItemByRid ( $rid );
  2560. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2561. // 支出项金额详情
  2562. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  2563. // print_r($aiData);
  2564. // 利润
  2565. $profit=$invoiceArriveAmount - $aiData ['total'];
  2566. $companyProfit=$profit * 0.6;
  2567. $categoryProfit=$profit * 0.4;
  2568. $data ['profit'] = sprintf("%.2f",$profit);
  2569. $data ['companyProfit'] = sprintf("%.2f",$companyProfit);
  2570. $data ['categoryProfit'] = sprintf("%.2f",$categoryProfit);
  2571. //发票利润
  2572. $data ['invoiceProfit'] = $invoiceTrainingDetail ['invoiceTotalAmount'] - $aiData ['total'];
  2573. //发票公司利润
  2574. $invoiceCompanyProfit=$data ['invoiceProfit'] * 0.6;
  2575. $data ['invoiceCompanyProfit'] = sprintf("%.2f",$invoiceCompanyProfit);
  2576. //办事处利润
  2577. $invoiceCategoryProfit=$data ['invoiceProfit'] * 0.4;
  2578. $data ['invoiceCategoryProfit'] = sprintf("%.2f",$invoiceCategoryProfit);
  2579. // print_r($aiData['dataList']);
  2580. $categoryActualExpenditure= $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  2581. $data ['categoryActualExpenditure'] = sprintf("%.2f",$categoryActualExpenditure);
  2582. // 备用金
  2583. $sum = 0;
  2584. $data ['receiptLoanDetail'] = array (
  2585. 'sum' => '0.00'
  2586. );
  2587. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  2588. //$data ['receiptLoanDetail'] = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2589. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2590. $sum=0;
  2591. foreach ($receiptLoanList as $key=>$value){
  2592. $sum+=$value['sum'];
  2593. }
  2594. $data ['receiptLoanDetail'] = array (
  2595. 'sum' => $sum
  2596. );
  2597. //$sum = $data ['receiptLoanDetail'] ['sum'];
  2598. }
  2599. $payment=$sum + $RIAmount - $categoryActualExpenditure;
  2600. $data ['payment'] = sprintf("%.2f",$payment);
  2601. $data ['total'] = sprintf("%.2f",$aiData ['total']);
  2602. $data ['aiCount'] = count ( $aiData ['dataList'] ) + 5;
  2603. $data ['aiList'] = $aiData ['dataList'];
  2604. // 占比计算
  2605. if ($invoiceArriveAmount != 0) {
  2606. $data ['totalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceArriveAmount* 100) ;
  2607. $data ['profitProportion'] = sprintf("%.2f",$profit / $invoiceArriveAmount*100) ; //number_format ( $profit / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2608. $data ['sumProportion'] = sprintf("%.2f",$sum / $invoiceArriveAmount*100) ; //number_format ( $sum / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2609. $data ['invoiceTotalAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceArriveAmount*100) ;
  2610. $data ['RIAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceArriveAmount*100) ;
  2611. $data ['companyProfitProportion'] = sprintf("%.2f",$companyProfit / $invoiceArriveAmount*100) ;
  2612. $data ['categoryProportion'] = sprintf("%.2f",$categoryProfit / $invoiceArriveAmount*100) ;
  2613. $data ['categoryActualExpenditureProportion'] = sprintf("%.2f",$categoryActualExpenditure / $invoiceArriveAmount*100) ;
  2614. $data ['paymentProportion'] = sprintf("%.2f",$payment / $invoiceArriveAmount*100) ;
  2615. } else {
  2616. $data ['totalProportion'] = $data ['profitProportion'] = $data ['sumProportion'] = $data ['invoiceTotalAmountProportion'] = $data ['RIAmountProportion'] = $data ['companyProfitProportion'] = $data ['categoryActualExpenditureProportion'] = $data ['paymentProportion'] = $data ['categoryProportion'] = 0;
  2617. }
  2618. //发票金额占比计算
  2619. if ($invoiceTrainingDetail ['invoiceTotalAmount'] != 0) {
  2620. //支出
  2621. $data ['invoicetotalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2622. //利润
  2623. $data ['invoiceprofitProportion'] = sprintf("%.2f",$data ['invoiceProfit'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2624. //公司利润
  2625. $data ['invoicecompanyProfitProportion'] = sprintf("%.2f", $invoiceCompanyProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2626. //办事处利润
  2627. $data ['invoicecategoryProportion'] = sprintf("%.2f", $invoiceCategoryProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2628. //公司收款
  2629. $data ['invoiceTotalAmountProportionB'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2630. //备用金
  2631. $data ['invoicesumProportion'] = sprintf("%.2f", $sum / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2632. //办事处收款
  2633. $data ['invoiceRIAmountProportion'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2634. //办事处实际支出
  2635. $data ['ICAEP'] = sprintf("%.2f", $categoryActualExpenditure / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2636. //付总部款
  2637. $data ['invoicepaymentProportion'] = sprintf("%.2f", $payment / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2638. }else{
  2639. $data ['invoiceprofitProportion'] =$data ['invoiceRIAmountProportion'] =$data ['invoicetotalProportion'] =$data ['invoiceTotalAmountProportionB'] =$data ['invoicesumProportion'] =$data ['ICAEP'] =$data ['invoicepaymentProportion'] =$data ['invoicecompanyProfitProportion'] =$data ['invoicecategoryProportion'] =0;
  2640. }
  2641. //讲师人数
  2642. Doo::loadModel ( 'RILecturer' );
  2643. $RILecturer = new RILecturer ();
  2644. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2645. $data['lectureCount']=count($RILecturerList);
  2646. // 审批组
  2647. Doo::loadModel ( 'verify' );
  2648. $verify = new verify ();
  2649. $veList = $verify->getVerifyBySubordinate('TRAIN');
  2650. // 办事处
  2651. Doo::loadModel ( 'L_category' );
  2652. $lCategory = new L_category ();
  2653. $data ['category'] = $lCategory->getCategory ();
  2654. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2655. $data ['receiptDetail'] = $receiptDetail;
  2656. $data ['veList'] = $veList;
  2657. $data ['trainEdiType'] = $trainEdiType;
  2658. $data ['ridKey'] = $ridKey;
  2659. $data ['memu'] = "receipt";
  2660. $data ['staff'] = $this->staff;
  2661. $data ['receiptMemu'] = 'saeaBorad';
  2662. $data ['verifyId'] = $this->verifyId;
  2663. $data ['executeId'] = $this->executeId;
  2664. $this->render ( "/receipt/receiptTrainEdi", $data );
  2665. }
  2666. /**
  2667. * 培训班借款编辑
  2668. */
  2669. function receiptTrainLoanEdi() {
  2670. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2671. Doo::loadClass ( 'XDeode' );
  2672. $XDeode = new XDeode ( 7 );
  2673. $rid = $XDeode->decode ( $ridKey );
  2674. if (! is_numeric ( $rid ))
  2675. die ( 'illegal request' );
  2676. Doo::loadModel ( 'receipt' );
  2677. $receipt = new receipt ();
  2678. Doo::loadModel ( 'receiptTraining' );
  2679. $receiptTraining = new receiptTraining ();
  2680. Doo::loadModel ( 'verify' );
  2681. $verify = new verify ();
  2682. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2683. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  2684. die ();
  2685. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2686. // 借款详情HTML
  2687. // 获得借款信息
  2688. $receiptLoanHtml = '';
  2689. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  2690. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2691. foreach ($receiptLoanList as $key=>$value){
  2692. // 获得某费用单审批信息
  2693. $verifylist = $verify->getVerifyByRid ( $value ['rid'] );
  2694. Doo::loadClass ( 'receipt.func' );
  2695. $extendHtml = '<p><a class="button"
  2696. href="javascript:if(window.confirm(\'确认移除?\'))window.location=\'/receiptTrainLoanRemoveDo/' . $receiptDetail ['ridKey'] . '/' . $value ['ridKey'] . '.html\'" data-toggle="modal">移除借款</a></p>';
  2697. $receiptLoanHtml .= _getReceiptLoanHtml ( $value, $verifylist, $extendHtml );
  2698. }
  2699. }
  2700. $data ['receiptLoanHtml'] = $receiptLoanHtml;
  2701. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2702. $data ['receiptDetail'] = $receiptDetail;
  2703. $data ['trainEdiType'] = "LOAN";
  2704. $data ['ridKey'] = $ridKey;
  2705. $data ['memu'] = "receipt";
  2706. $data ['staff'] = $this->staff;
  2707. $data ['receiptMemu'] = 'saeaBorad';
  2708. $data ['verifyId'] = $this->verifyId;
  2709. $data ['executeId'] = $this->executeId;
  2710. $this->render ( "/receipt/receiptTrainLoanEdi", $data );
  2711. }
  2712. /**
  2713. * 更新培训班结算基本信息
  2714. */
  2715. function receiptTrainInfoEdiDo() {
  2716. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  2717. $rtid = $this->get_args ( 'rtid' ) ? $this->get_args ( 'rtid' ) : "";
  2718. // 培训班信息
  2719. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  2720. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  2721. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  2722. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  2723. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  2724. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  2725. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  2726. // 发票信息
  2727. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2728. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2729. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2730. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2731. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2732. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2733. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2734. //&& ! empty ( $participants )
  2735. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  2736. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2737. header ( 'Content-Type:text/html;charset=utf-8' );
  2738. die ( '请填写联行号' );
  2739. }
  2740. Doo::loadClass ( 'XDeode' );
  2741. $XDeode = new XDeode ( 5 );
  2742. $cid = $XDeode->decode ( $cid );
  2743. $rtid = $XDeode->decode ( $rtid );
  2744. $rid = $XDeode->decode ( $rid );
  2745. if (! is_numeric ( $rtid ) || ! is_numeric ( $rid )) {
  2746. die ( 'illegal request-IdError' );
  2747. }
  2748. Doo::loadModel ( 'receipt' );
  2749. $receipt = new receipt ();
  2750. Doo::loadModel ( 'receiptTraining' );
  2751. $receiptTraining = new receiptTraining ();
  2752. // 更新费用培训班
  2753. $item = array (
  2754. 'rtid' => $rtid,
  2755. 'trainName' => $trainName,
  2756. 'trainStartDate' => $trainStartDate,
  2757. 'trainEndDate' => $trainEndDate,
  2758. 'participants' => $participants,
  2759. 'freeParticipants'=>$freeParticipants,
  2760. 'trainAddress' => $trainAddress,
  2761. 'trainRemarks' => $trainRemarks
  2762. );
  2763. $irid = $receiptTraining->setReceiptTrainByCondition ( $item );
  2764. // 报销单
  2765. $receipt->rid = $rid;
  2766. $receipt->cid = $cid;
  2767. $receipt->verify = $verify;
  2768. $receipt->remittanceName = $remittanceName;
  2769. $receipt->bankName = $bankName;
  2770. $receipt->bankNumber = $bankNumber;
  2771. $receipt->remittanceBankType = $remittanceBankType;
  2772. if ($remittanceBankType == 1)
  2773. $receipt->coupletNumber = $coupletNumber;
  2774. $receipt->update ();
  2775. $XDeode = new XDeode ( 7 );
  2776. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html?trainEdiType=INFO";
  2777. } else
  2778. die ( 'illegal request' );
  2779. }
  2780. /**
  2781. * 编辑培训班结算---更新借款
  2782. */
  2783. function receiptTrainLoanEdiDo() {
  2784. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2785. $ridLoanKey = $this->get_args ( 'ridLoanKey' ) ? $this->get_args ( 'ridLoanKey' ) : "";
  2786. if (! empty ( $ridKey ) && ! empty ( $ridLoanKey )) {
  2787. Doo::loadModel ( 'receipt' );
  2788. $receipt = new receipt ();
  2789. Doo::loadClass ( 'XDeode' );
  2790. $XDeode = new XDeode ( 5 );
  2791. $rid = $XDeode->decode ( $ridKey );
  2792. $ridLoan = $XDeode->decode ( $ridLoanKey );
  2793. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  2794. die ( 'illegal request-ridError' );
  2795. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2796. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  2797. // 不合法的数据if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  2798. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2799. die ( 'illegal request-receiptError' );
  2800. }
  2801. if ($receiptLoanDetail ['status'] != 8 || $receiptLoanDetail ['Rtype'] != 1) {
  2802. die ( 'illegal request-receipLoantError' );
  2803. }
  2804. // 培训班结算挂钩借款
  2805. $receipt = new receipt ();
  2806. $trainLoanRid=$ridLoan;
  2807. if (!empty($receiptDetail['trainLoanRid'])){
  2808. $trainLoanRid=$receiptDetail['trainLoanRid'].','.$ridLoan;
  2809. }
  2810. $item = array (
  2811. 'rid' => $rid,
  2812. 'trainLoanRid' => $trainLoanRid
  2813. );
  2814. $receipt->setReceiptByCondition ( $item );
  2815. // 更新借款状态变成已挂钩
  2816. $receipt = new receipt ();
  2817. $item = array (
  2818. 'rid' => $ridLoan,
  2819. 'status' => 10,
  2820. 'statusTrain' => 1
  2821. );
  2822. $receipt->setReceiptByCondition ( $item );
  2823. $XDeode = new XDeode ( 7 );
  2824. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  2825. } else
  2826. die ( 'illegal request' );
  2827. }
  2828. /**
  2829. * 编辑培训班结算--移除借款
  2830. */
  2831. function receiptTrainLoanRemoveDo() {
  2832. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : 0;
  2833. $ridLoanKey = isset ( $this->params ['ridLoanKey'] ) ? $this->params ['ridLoanKey'] : 0;
  2834. if (! empty ( $ridKey ) || ! empty ( $ridLoanKey )) {
  2835. Doo::loadModel ( 'receipt' );
  2836. $receipt = new receipt ();
  2837. Doo::loadClass ( 'XDeode' );
  2838. $XDeode = new XDeode ( 5 );
  2839. $rid = $XDeode->decode ( $ridKey );
  2840. $ridLoan = $XDeode->decode ( $ridLoanKey );
  2841. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  2842. die ( 'illegal request-ridError' );
  2843. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2844. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  2845. // 不合法的数据 !($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)
  2846. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2847. die ( 'illegal request-receiptError' );
  2848. }
  2849. if ($receiptLoanDetail ['status'] != 10 || $receiptLoanDetail ['Rtype'] != 1) {
  2850. die ( 'illegal request-receipLoantError' );
  2851. }
  2852. // 培训班结算挂钩借款
  2853. $receipt = new receipt ();
  2854. $trainLoanRidArray=explode(",", $receiptDetail['trainLoanRid']);
  2855. foreach ($trainLoanRidArray as $key=>$value){
  2856. if($value==$ridLoan){
  2857. unset($trainLoanRidArray[$key]);
  2858. }
  2859. }
  2860. $trainLoanRidString=implode(",", $trainLoanRidArray);
  2861. $item = array (
  2862. 'rid' => $rid,
  2863. 'trainLoanRid' => $trainLoanRidString
  2864. );
  2865. $receipt->setReceiptByCondition ( $item );
  2866. // 更新借款状态变成已挂钩
  2867. $receipt = new receipt ();
  2868. $item = array (
  2869. 'rid' => $ridLoan,
  2870. 'status' => 8,
  2871. 'statusTrain' => 0
  2872. );
  2873. $receipt->setReceiptByCondition ( $item );
  2874. $XDeode = new XDeode ( 7 );
  2875. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  2876. } else
  2877. die ( 'illegal request' );
  2878. }
  2879. /**
  2880. * 编辑培训班结算 ---开票
  2881. */
  2882. function receiptTrainInvoiceEdi() {
  2883. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2884. Doo::loadClass ( 'XDeode' );
  2885. $XDeode = new XDeode ( 7 );
  2886. $rid = $XDeode->decode ( $ridKey );
  2887. if (! is_numeric ( $rid ))
  2888. die ( 'illegal request' );
  2889. Doo::loadModel ( 'receipt' );
  2890. $receipt = new receipt ();
  2891. Doo::loadModel ( 'receiptTraining' );
  2892. $receiptTraining = new receiptTraining ();
  2893. Doo::loadModel ( 'invoice' );
  2894. $invoice = new invoice ();
  2895. Doo::loadModel ( 'invoiceTraining' );
  2896. $invoiceTraining = new invoiceTraining ();
  2897. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2898. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  2899. die ();
  2900. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2901. $invoiceList = $invoiceTrainingDetail = array ();
  2902. if ($receiptDetail ['invoiceTrainId'] != 0) {
  2903. $invoiceList = $invoice->getInvoicePrintedByItid ( $receiptDetail ['invoiceTrainId'] );
  2904. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  2905. }
  2906. //print_r($invoiceList);
  2907. $data ['invoiceList'] = $invoiceList;
  2908. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  2909. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2910. $data ['receiptDetail'] = $receiptDetail;
  2911. $data ['trainEdiType'] = "INVOICE";
  2912. $data ['ridKey'] = $ridKey;
  2913. $data ['memu'] = "receipt";
  2914. $data ['staff'] = $this->staff;
  2915. $data ['receiptMemu'] = 'saeaBorad';
  2916. $data ['verifyId'] = $this->verifyId;
  2917. $data ['executeId'] = $this->executeId;
  2918. $this->render ( "/receipt/receiptTrainInvoiceEdi", $data );
  2919. }
  2920. /**
  2921. * 编辑培训班结算---更新开票
  2922. */
  2923. function receiptTrainInvoiceEdiDo() {
  2924. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2925. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : "";
  2926. if (! empty ( $ridKey ) && ! empty ( $itidKey )) {
  2927. Doo::loadModel ( 'receipt' );
  2928. $receipt = new receipt ();
  2929. Doo::loadModel ( 'invoiceTraining' );
  2930. $invoiceTraining = new invoiceTraining ();
  2931. Doo::loadClass ( 'XDeode' );
  2932. $XDeode = new XDeode ( 5 );
  2933. $rid = $XDeode->decode ( $ridKey );
  2934. $itid = $XDeode->decode ( $itidKey );
  2935. if (! is_numeric ( $rid ) || ! is_numeric ( $itid ))
  2936. die ( 'illegal request-idError' );
  2937. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2938. $invoiceTrainDetail = $invoiceTraining->getInvoiceTrainingByItid ( $itid );
  2939. // 不合法的数据
  2940. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2941. die ( 'illegal request-receiptError' );
  2942. }
  2943. if (empty ( $invoiceTrainDetail ) || $invoiceTrainDetail ['bindReceipt'] == 1) {
  2944. die ( 'illegal request-receipLoantError' );
  2945. }
  2946. // 培训班结算挂钩借款
  2947. $receipt = new receipt ();
  2948. $item = array (
  2949. 'rid' => $rid,
  2950. 'invoiceTrainId' => $itid
  2951. );
  2952. $receipt->setReceiptByCondition ( $item );
  2953. $invoiceTraining = new invoiceTraining ();
  2954. $item = array (
  2955. 'bindReceipt' => 1,
  2956. 'itid' => $itid
  2957. );
  2958. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  2959. $XDeode = new XDeode ( 7 );
  2960. return "/receiptTrainInvoiceEdi/" . $XDeode->encode ( $rid ) . ".html";
  2961. } else
  2962. die ( 'illegal request' );
  2963. }
  2964. /**
  2965. * 更新培训班结算 收款和取消收款
  2966. */
  2967. function receiptTrainReceivables() {
  2968. $doType = isset ( $this->params ['doType'] ) ? $this->params ['doType'] : '';
  2969. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2970. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  2971. Doo::loadClass ( 'XDeode' );
  2972. $XDeode = new XDeode ( 5 );
  2973. $rid = $XDeode->decode ( $ridKey );
  2974. $iid = $XDeode->decode ( $iidKey );
  2975. if (! is_numeric ( $rid ) || ! is_numeric ( $iid ))
  2976. die ( 'illegal request-iid' );
  2977. Doo::loadModel ( 'RIExtend' );
  2978. $RIExtend = new RIExtend ();
  2979. if ($doType == 'CONFIRM') {
  2980. $RIExtend->rid = $rid;
  2981. $RIExtend->iid = $iid;
  2982. $RIExtend->RIstatus = 1;
  2983. $RIExtend->insert ();
  2984. echo json_encode ( array (
  2985. 'status' => 1,
  2986. ) );
  2987. die ( );
  2988. } elseif ($doType == 'CANCEL') {
  2989. $RIExtend->delete ( array (
  2990. 'where' => 'rid=' . $rid . ' and iid=' . $iid,
  2991. 'limit' => 1
  2992. ) );
  2993. echo json_encode ( array (
  2994. 'status' => 1,
  2995. ) );
  2996. die ( );
  2997. } else {
  2998. echo json_encode ( array (
  2999. 'status' => 2,
  3000. ) );
  3001. die ( );
  3002. }
  3003. }
  3004. /**
  3005. * 移除挂钩的培训班发票
  3006. */
  3007. function receiptTrainReceivablesDelDo() {
  3008. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  3009. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : ""; // 发票培训班
  3010. Doo::loadModel ( 'receipt' );
  3011. $receipt = new receipt ();
  3012. Doo::loadModel ( 'RIExtend' );
  3013. $RIExtend = new RIExtend ();
  3014. Doo::loadClass ( 'XDeode' );
  3015. $XDeode = new XDeode ( 5 );
  3016. $rid = $XDeode->decode ( $ridKey );
  3017. $itid = $XDeode->decode ( $itidKey );
  3018. if (is_numeric ( $rid ) && is_numeric ( $itid )) {
  3019. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3020. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  3021. die ( 'illegal request-status' );
  3022. }
  3023. $receipt = new receipt ();
  3024. $receipt->rid = $rid;
  3025. $receipt->invoiceTrainId = 0;
  3026. $receipt->update ();
  3027. Doo::loadModel ( 'invoiceTraining' );
  3028. $invoiceTraining = new invoiceTraining ();
  3029. $item = array (
  3030. 'bindReceipt' => 0,
  3031. 'itid' => $itid
  3032. );
  3033. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  3034. $RIExtend->delete ( array (
  3035. 'where' => 'rid=' . $rid
  3036. ) );
  3037. $XDeode = new XDeode ( 7 );
  3038. return '/receiptTrainInvoiceEdi/' . $XDeode->encode ( $rid ) . '.html';
  3039. } else
  3040. die ( 'illegal request-iid' );
  3041. }
  3042. /**
  3043. * 编辑培训班结算
  3044. */
  3045. function receiptTrainItemEdi() {
  3046. //include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  3047. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3048. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : '';
  3049. Doo::loadClass ( 'XDeode' );
  3050. $XDeode = new XDeode ( 7 );
  3051. $rid = $XDeode->decode ( $ridKey );
  3052. if (! is_numeric ( $rid ))
  3053. die ( 'illegal request' );
  3054. Doo::loadModel ( 'receipt' );
  3055. $receipt = new receipt ();
  3056. Doo::loadModel ( 'receiptTraining' );
  3057. $receiptTraining = new receiptTraining ();
  3058. Doo::loadModel ( 'RItem' );
  3059. $RItem = new RItem ();
  3060. Doo::loadModel ( 'accountItem' );
  3061. $accountItem = new accountItem ();
  3062. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3063. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3064. die ();
  3065. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3066. $RItemList = $RItem->getRItemByRid ( $rid,$name );
  3067. $aiList = $accountItem->getAccountBookByCategory ( '培训班费用' );//print_r($aiList);
  3068. // foreach ($aiList as $key=>$value){//不需要添加税款,在添加收入时自动添加
  3069. // if($value['name']=='税款'){
  3070. // unset($aiList[$key]);break;
  3071. // }
  3072. // }
  3073. //print_r($RItemList);
  3074. $data ['name'] = $name;
  3075. $data ['RItemList'] = $RItemList;
  3076. $data ['aiList'] = $aiList;
  3077. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3078. $data ['receiptDetail'] = $receiptDetail;
  3079. $data ['trainEdiType'] = "ITEM";
  3080. $data ['ridKey'] = $ridKey;
  3081. $data ['memu'] = "receipt";
  3082. $data ['staff'] = $this->staff;
  3083. $data ['receiptMemu'] = 'saeaBorad';
  3084. $data ['verifyId'] = $this->verifyId;
  3085. $data ['executeId'] = $this->executeId;
  3086. $this->render ( "/receipt/receiptTrainItemEdi", $data );
  3087. }
  3088. /**
  3089. * 添加支出项 需要修改 费用金额合计
  3090. */
  3091. function receiptTrainItemAddDo() {
  3092. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3093. $rtidKey = $this->get_args ( 'rtidKey' ) ? $this->get_args ( 'rtidKey' ) : "";
  3094. // 支出项信息
  3095. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  3096. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : 0;
  3097. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  3098. $inputer = $this->get_args ( 'inputer' ) ? $this->get_args ( 'inputer' ) : "";
  3099. $describe = $this->get_args ( 'describe' ) ? $this->get_args ( 'describe' ) : "";
  3100. //$identifyingTotal = $this->get_args ( 'identifyingTotal' )&&is_numeric($this->get_args ( 'identifyingTotal' )) ? $this->get_args ( 'identifyingTotal' ) : 0;
  3101. $payType = isset ( $this->params ['payType'] ) ? $this->params ['payType'] : '';
  3102. if (! empty ( $ridKey ) && ! empty ( $item ) && is_numeric( $price ) && ! empty ( $date ) && ! empty ( $inputer )) {
  3103. Doo::loadClass ( 'XDeode' );
  3104. $XDeode = new XDeode ( 5 );
  3105. Doo::loadModel ( 'RItem' );
  3106. $RItem = new RItem ();
  3107. $rid = $XDeode->decode ( $ridKey );
  3108. $rtid= $XDeode->decode ( $rtidKey );
  3109. if (! is_numeric ( $rid )){
  3110. die ( 'illegal request' );
  3111. }
  3112. Doo::loadModel ( 'receiptDetail' );
  3113. $receiptDetail = new receiptDetail ();
  3114. Doo::loadModel ( 'receipt' );
  3115. $receipt = new receipt ();
  3116. Doo::loadModel ( 'receiptTraining' );
  3117. $receiptTraining = new receiptTraining ();
  3118. $rtDetail=$receiptTraining->getReceiptTrainingByRtid($rtid);
  3119. $identifyingTotal=$rtDetail['identifyingTotal']+1;
  3120. $order = array (
  3121. "\r\n",
  3122. "\n",
  3123. "\r"
  3124. );
  3125. $replace = '<br/>';
  3126. $describe = str_replace ( $order, $replace, $describe );
  3127. $itemData = array (
  3128. 'rid' => $rid,
  3129. 'item' => $item,
  3130. 'price' => $price,
  3131. 'date' => $date,
  3132. 'inputer' => $inputer,
  3133. 'describe' => $describe,
  3134. 'creater' => $this->staff['0']['username'],
  3135. 'createrId' => $this->staff['0']['sid'],
  3136. 'creatDate' => date ( "Y-m-d H:i:s" ),
  3137. 'identifying'=>$identifyingTotal
  3138. );
  3139. if($payType=='company'){
  3140. $itemData += array (
  3141. 'payType' => 1
  3142. );
  3143. }
  3144. $RItem->addRItem($itemData, $receipt, $receiptDetail, $rid, $item, $price, $payType);
  3145. //更新支出项标识总数
  3146. $itemData = array (
  3147. 'rtid'=>$rtid,
  3148. 'identifyingTotal'=>$identifyingTotal
  3149. );
  3150. $receiptTraining->setReceiptTrainByCondition($itemData);
  3151. $XDeode = new XDeode ( 7 );
  3152. if($payType=='company'){
  3153. return '/receiptTrainItem/approval/' . $XDeode->encode ( $rid ) . '.html';
  3154. }else{
  3155. return '/receiptTrainItemEdi/' . $XDeode->encode ( $rid ) . '.html';
  3156. }
  3157. } else
  3158. die ( 'illegal request-dataError' );
  3159. }
  3160. /**
  3161. * 培训班结算-讲师
  3162. */
  3163. function receiptTrainLecturerEdi() {
  3164. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3165. Doo::loadClass ( 'XDeode' );
  3166. $XDeode = new XDeode ( 7 );
  3167. $rid = $XDeode->decode ( $ridKey );
  3168. if (! is_numeric ( $rid ))
  3169. die ( 'illegal request' );
  3170. Doo::loadModel ( 'receipt' );
  3171. $receipt = new receipt ();
  3172. Doo::loadModel ( 'receiptTraining' );
  3173. $receiptTraining = new receiptTraining ();
  3174. Doo::loadModel ( 'RILecturer' );
  3175. $RILecturer = new RILecturer ();
  3176. Doo::loadModel ( 'lecturer' );
  3177. $lecturer = new lecturer ();
  3178. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3179. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3180. die ();
  3181. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3182. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  3183. $lecturerList = $lecturer->getLecturerAll ();
  3184. $INSIDEhtml = $OUTSIDEhtml = '';
  3185. foreach ( $lecturerList as $key => $value ) {
  3186. if ($value ['ltype'] == 'INSIDE') {
  3187. $INSIDEhtml .= '<option value="' . $value ['category'] . '-' . $value ['staff'] . '">' . $value ['category'] . '-' . $value ['staff'] . '</option>';
  3188. } elseif ($value ['ltype'] == 'OUTSIDE') {
  3189. $OUTSIDEhtml .= '<option value="' . $value ['staff'] . '">' . $value ['staff'] . '</option>';
  3190. }
  3191. }
  3192. $data ['INSIDEhtml'] = $INSIDEhtml;
  3193. $data ['OUTSIDEhtml'] = $OUTSIDEhtml;
  3194. // print_r($RItemList);
  3195. $data ['RILecturerList'] = $RILecturerList;
  3196. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3197. $data ['receiptDetail'] = $receiptDetail;
  3198. $data ['trainEdiType'] = "LECTURER";
  3199. $data ['ridKey'] = $ridKey;
  3200. $data ['memu'] = "receipt";
  3201. $data ['staff'] = $this->staff;
  3202. $data ['receiptMemu'] = 'saeaBorad';
  3203. $data ['verifyId'] = $this->verifyId;
  3204. $data ['executeId'] = $this->executeId;
  3205. $this->render ( "/receipt/receiptTrainLecturerEdi", $data );
  3206. }
  3207. /**
  3208. * 添加讲师
  3209. */
  3210. function receiptTrainLecturerAddDo() {
  3211. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3212. // 支出项信息
  3213. $ltype = $this->get_args ( 'ltype' ) ? $this->get_args ( 'ltype' ) : "";
  3214. $lecturerName = $this->get_args ( 'lecturerName' ) ? $this->get_args ( 'lecturerName' ) : "";
  3215. $schoolDay = $this->get_args ( 'schoolDay' ) ? $this->get_args ( 'schoolDay' ) : "";
  3216. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  3217. $taxation = $this->get_args ( 'taxation' ) ? $this->get_args ( 'taxation' ) : "";
  3218. $fees = $this->get_args ( 'fees' ) ? $this->get_args ( 'fees' ) : "";
  3219. if (! empty ( $ridKey ) && ! empty ( $ltype ) && ! empty ( $lecturerName ) && ! empty ( $schoolDay ) && ! empty ( $price )) {
  3220. Doo::loadClass ( 'XDeode' );
  3221. $XDeode = new XDeode ( 5 );
  3222. Doo::loadModel ( 'RILecturer' );
  3223. $RILecturer = new RILecturer ();
  3224. $rid = $XDeode->decode ( $ridKey );
  3225. if (! is_numeric ( $rid ))
  3226. die ( 'illegal request' );
  3227. if ($ltype == 'OUTSIDE' && empty ( $taxation ))
  3228. die ( 'illegal request-taxationError' );
  3229. $RILecturer->rid = $rid;
  3230. $RILecturer->ltype = $ltype;
  3231. if ($ltype == 'OUTSIDE') {
  3232. if ($taxation == 'TAXATION') {
  3233. $RILecturer->taxation = 1;
  3234. } elseif ($taxation == 'NOTAXATION') {
  3235. $RILecturer->taxation = 0;
  3236. }
  3237. }
  3238. $RILecturer->lecturerName = $lecturerName;
  3239. $RILecturer->schoolDay = $schoolDay;
  3240. $RILecturer->price = $price;
  3241. $RILecturer->fees=$fees;
  3242. $RILecturer->insert ();
  3243. // 添加公司汇总
  3244. // 报销详情
  3245. Doo::loadModel ( 'receiptDetail' );
  3246. $receiptDetail = new receiptDetail ();
  3247. Doo::loadModel ( 'receipt' );
  3248. $receipt = new receipt ();
  3249. // 金额总计
  3250. $price = $price * $schoolDay;
  3251. $rInfo = $receipt->getReceiptByRid ( $rid );
  3252. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  3253. if (empty ( $rdInfo )) {
  3254. $receiptDetail = new receiptDetail ();
  3255. $receiptDetail->staff = $rInfo ['staff'];
  3256. $receiptDetail->item = '讲课费';
  3257. $receiptDetail->itemCategory = '培训班费用';
  3258. $receiptDetail->price = number_format ( $fees, 2, '.', '' );
  3259. $receiptDetail->date = date ( "Y-m-d" );
  3260. $receiptDetail->cid = $rInfo ['cid'];
  3261. $receiptDetail->rid = $rid;
  3262. $receiptDetail->status = 4;
  3263. $receiptDetail->insert ();
  3264. } else {
  3265. $receiptDetail = new receiptDetail ();
  3266. $rdInfo ['price'] += $fees;
  3267. $receiptDetail->price = $rdInfo ['price'];
  3268. $receiptDetail->update ( array (
  3269. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  3270. ) );
  3271. }
  3272. $receipt = new receipt ();
  3273. $receipt->sum=$rInfo['sum']+$fees;
  3274. $receipt->update ( array (
  3275. 'where' => 'rid=' . $rid
  3276. ) );
  3277. $XDeode = new XDeode ( 7 );
  3278. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  3279. } else
  3280. die ( 'illegal request' );
  3281. }
  3282. /**
  3283. * 移除讲师
  3284. */
  3285. function receiptTrainLecturerDelDo() {
  3286. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  3287. $rlidKey = $this->get_args ( 'rlidKey' ) ? $this->get_args ( 'rlidKey' ) : ""; // 发票培训班
  3288. Doo::loadModel ( 'receipt' );
  3289. $receipt = new receipt ();
  3290. Doo::loadModel ( 'RILecturer' );
  3291. $RILecturer = new RILecturer ();
  3292. Doo::loadClass ( 'XDeode' );
  3293. $XDeode = new XDeode ( 5 );
  3294. $rid = $XDeode->decode ( $ridKey );
  3295. $rlid = $XDeode->decode ( $rlidKey );
  3296. if (is_numeric ( $rid ) && is_numeric ( $rlid )) {
  3297. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3298. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  3299. die ( 'illegal request-status' );
  3300. }
  3301. $detail=$RILecturer->getRILecturerByRlid($rlid);
  3302. if (empty($detail)){
  3303. die ( 'illegal request-data' );
  3304. }
  3305. $RILecturer->delete ( array (
  3306. 'where' => 'rid=' . $rid . ' and rlid=' . $rlid
  3307. ) );
  3308. //更新费用合计金额
  3309. $rInfo = $receipt->getReceiptByRid ( $rid );
  3310. $receipt = new receipt ();
  3311. $receipt->sum= $receiptDetail['sum']-$detail['price'];
  3312. $receipt->update ( array (
  3313. 'where' => 'rid=' . $rid
  3314. ) );
  3315. Doo::loadModel ( 'receiptDetail' );
  3316. $receiptDetail = new receiptDetail ();
  3317. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  3318. $receiptDetail = new receiptDetail ();
  3319. $rdInfo ['price'] -= number_format ( $detail['price'], 2, '.', '' );
  3320. $receiptDetail->price = $rdInfo ['price'];
  3321. $receiptDetail->update ( array (
  3322. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  3323. ) );
  3324. $XDeode = new XDeode ( 7 );
  3325. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  3326. } else
  3327. die ( 'illegal request-iid' );
  3328. }
  3329. /**
  3330. * 培训班提交审批
  3331. */
  3332. function receiptTrainDo() {
  3333. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3334. Doo::loadClass ( 'XDeode' );
  3335. $XDeode = new XDeode ( 7 );
  3336. $rid = $XDeode->decode ( $ridKey );
  3337. Doo::loadModel ( 'receipt' );
  3338. $receipt = new receipt ();
  3339. Doo::loadModel ( 'receiptDetail' );
  3340. $receiptDetail = new receiptDetail ();
  3341. Doo::loadModel ( 'statistics' );
  3342. $statistics = new statistics ();
  3343. Doo::loadModel ( "verify" );
  3344. $verify = new verify ();
  3345. // 审批状态的判定
  3346. $receiptDetailList = $receipt->getOne ( array (
  3347. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  3348. 'asArray' => true
  3349. ) );
  3350. if (empty ( $receiptDetailList ))
  3351. return "/saeaBorad";
  3352. $verifyDetail = $verify->getOne ( array (
  3353. 'where' => ' vid =' . $receiptDetailList ['verify'],
  3354. 'asArray' => true
  3355. ) );
  3356. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3357. if (empty ( $receiptDetailList ['nowStaff'] )) {
  3358. $nowStaff = "";
  3359. $nowStaffList = array ();
  3360. if ($verifyDetail [0] [1] == 'ROLE') {
  3361. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3362. foreach ( $vStaffString as $key => $value ) {
  3363. $staffK = explode ( "_", $value );
  3364. array_push ( $nowStaffList, $staffK [0] );
  3365. }
  3366. $nowStaff = implode ( ',', $nowStaffList );
  3367. } else {
  3368. $nowStaff = $verifyDetail [0] [0];
  3369. }
  3370. $receipt->nowStaff = $nowStaff;
  3371. }
  3372. // echo $nowStaff;
  3373. // print_r($verifyDetail);die;
  3374. $receipt->rid = $receiptDetailList ['rid'];
  3375. $receipt->date = date ( "Y-m-d" );
  3376. $receipt->status = 2;
  3377. $receipt->update ();
  3378. $receiptDetail->status = 2;
  3379. $receiptDetail->update ( array (
  3380. 'where' => 'rid=' . $receiptDetailList ['rid']
  3381. ) );
  3382. Doo::loadModel ( "receiptLog" );
  3383. $receiptLog = new receiptLog ();
  3384. Doo::loadModel ( "verify" );
  3385. $verify = new verify ();
  3386. $vr = $verify->getOne ( array (
  3387. 'where' => 'vid=' . $receiptDetailList ['verify'],
  3388. 'asArray' => true
  3389. ) );
  3390. $jd = json_decode ( $vr ['staff'] );
  3391. $roleId = 0;
  3392. foreach ( $jd as $key => $value ) {
  3393. if ($value [1] == 'ROLE') {
  3394. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  3395. if ($pos !== false) {
  3396. $roleId = $value [0];
  3397. }
  3398. }
  3399. }
  3400. // 审批日志
  3401. // echo $roleId;die;
  3402. if (! empty ( $roleId )) {
  3403. Doo::loadModel ( "role" );
  3404. $role = new role ();
  3405. $roleInfo = $role->getOne ( array (
  3406. 'where' => 'rid=' . $roleId,
  3407. 'asArray' => true
  3408. ) );
  3409. // $receiptLog->rolename = $roleInfo ['name'];
  3410. }
  3411. $receiptLog->username = $this->staff [0] ['username'];
  3412. $receiptLog->uid = $this->staff [0] ['sid'];
  3413. $receiptLog->date = date ( "Y-m-d" );
  3414. $receiptLog->opinion = '提交审批';
  3415. $receiptLog->img = $this->staff [0] ['avatar'];
  3416. $receiptLog->status = 2;
  3417. $receiptLog->rid = $rid;
  3418. $receiptLog->insert ();
  3419. // 写入列表项
  3420. Doo::loadModel ( 'accountItem' );
  3421. $accountItem = new accountItem ();
  3422. $aItem = $accountItem->getAccountBookByCategory ( '培训班费用' );
  3423. // 项目金额合计
  3424. Doo::loadModel ( 'RItem' );
  3425. $RItem = new RItem ();
  3426. // 讲师获得
  3427. Doo::loadModel ( 'RILecturer' );
  3428. $RILecturer = new RILecturer ();
  3429. $RItemList = $RItem->getRItemByRid ( $rid );
  3430. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  3431. // 支出项金额详情
  3432. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, 0 );
  3433. // print_r($aItem);
  3434. // print_r($aiData);
  3435. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  3436. $ag = $tr = $ta = $ot = 0;
  3437. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  3438. foreach ( $aItem as $key => $value ) {
  3439. if ($value ['category'] == $this->TRAIN) {
  3440. foreach ( $aiData ['dataList'] as $k => $v ) {
  3441. if ($value ['name'] == $v ['name']) {
  3442. array_push ( $accountJson [$this->TRAIN], array (
  3443. 'aid' => $value ['aid'],
  3444. 'name' => $value ['name'],
  3445. 'price' => number_format ( $v ['price'], 2, '.', '' )
  3446. ) );
  3447. $sum += $v ['price'];
  3448. $trainSum += $v ['price'];
  3449. unset ( $aiData ['dataList'] [$k] );
  3450. break;
  3451. }
  3452. }
  3453. }
  3454. }
  3455. $accountJson ['cSum'] = array (
  3456. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  3457. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  3458. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  3459. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  3460. );
  3461. // 报销单
  3462. $receipt = new receipt ();
  3463. $receipt->accountItem = json_encode ( $accountJson );
  3464. $receipt->sum = number_format ( $sum, 2, '.', '' );
  3465. $receipt->update ( array (
  3466. 'where' => 'rid=' . $rid
  3467. ) );
  3468. // print_r($accountJson);
  3469. // statistics item 统计写入
  3470. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  3471. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  3472. $accountItem = $accountJson;
  3473. $stat = $statistics->getOne ( array (
  3474. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  3475. 'asArray' => true
  3476. ) );
  3477. if (empty ( $stat )) {
  3478. $statistics->date = date ( "Y-m-d" );
  3479. $statistics->cid = $this->staff [0] ['cid'];
  3480. $statistics->staff = $this->staff [0] ['sid'];
  3481. $statistics->agPrice = 0;
  3482. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  3483. $statistics->insert ();
  3484. } else {
  3485. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  3486. $statistics->update ( array (
  3487. 'where' => 'sid=' . $stat ['sid']
  3488. ) );
  3489. }
  3490. return "/saeaBorad";
  3491. }
  3492. function confirmation() {
  3493. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3494. Doo::loadModel ( 'receipt' );
  3495. Doo::loadModel ( 'receiptDetail' );
  3496. $receipt = new receipt ();
  3497. $receiptDetail = new receiptDetail ();
  3498. Doo::loadModel ( 'statistics' );
  3499. Doo::loadModel ( 'itemStatistics' );
  3500. $statistics = new statistics ();
  3501. $itemStatistics = new itemStatistics ();
  3502. Doo::loadModel ( "verify" );
  3503. $verify = new verify ();
  3504. $receiptDetailList = $receipt->getOne ( array (
  3505. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  3506. 'asArray' => true
  3507. ) );
  3508. if (empty ( $receiptDetailList ))
  3509. return "/saeaBorad";
  3510. $verifyDetail = $verify->getOne ( array (
  3511. 'where' => ' vid =' . $receiptDetailList ['verify'],
  3512. 'asArray' => true
  3513. ) );
  3514. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3515. if (empty ( $receiptDetailList ['nowStaff'] )) {
  3516. $nowStaff = "";
  3517. $nowStaffList = array ();
  3518. if ($verifyDetail [0] [1] == 'ROLE') {
  3519. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3520. foreach ( $vStaffString as $key => $value ) {
  3521. $staffK = explode ( "_", $value );
  3522. array_push ( $nowStaffList, $staffK [0] );
  3523. }
  3524. $nowStaff = implode ( ',', $nowStaffList );
  3525. } else {
  3526. $nowStaff = $verifyDetail [0] [0];
  3527. }
  3528. $receipt->nowStaff = $nowStaff;
  3529. }
  3530. // echo $nowStaff;
  3531. // print_r($verifyDetail);die;
  3532. $receipt->rid = $receiptDetailList ['rid'];
  3533. $receipt->status = 2;
  3534. $receipt->update ();
  3535. // 操作日志
  3536. Doo::loadModel ( "receiptLog" );
  3537. $receiptLog = new receiptLog ();
  3538. $verify = new verify ();
  3539. $receiptInfo = $receipt->getOne ( array (
  3540. 'where' => 'rid=' . $rid,
  3541. 'asArray' => true
  3542. ) );
  3543. $vr = $verify->getOne ( array (
  3544. 'where' => 'vid=' . $receiptInfo ['verify'],
  3545. 'asArray' => true
  3546. ) );
  3547. $jd = json_decode ( $vr ['staff'] );
  3548. $roleId = 0;
  3549. foreach ( $jd as $key => $value ) {
  3550. if ($value [1] == 'ROLE') {
  3551. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  3552. if ($pos !== false) {
  3553. $roleId = $value [0];
  3554. }
  3555. }
  3556. }
  3557. // 审批日志
  3558. // echo $roleId;die;
  3559. if (! empty ( $roleId )) {
  3560. Doo::loadModel ( "role" );
  3561. $role = new role ();
  3562. $roleInfo = $role->getOne ( array (
  3563. 'where' => 'rid=' . $roleId,
  3564. 'asArray' => true
  3565. ) );
  3566. // $receiptLog->rolename = $roleInfo ['name'];
  3567. }
  3568. $receiptLog->username = $this->staff [0] ['username'];
  3569. $receiptLog->uid = $this->staff [0] ['sid'];
  3570. $receiptLog->date = date ( "Y-m-d" );
  3571. $receiptLog->opinion = '提交审批';
  3572. $receiptLog->img = $this->staff [0] ['avatar'];
  3573. $receiptLog->status = 2;
  3574. $receiptLog->rid = $rid;
  3575. $receiptLog->insert ();
  3576. return "/expenses";
  3577. }
  3578. function expenses() {
  3579. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  3580. if (empty ( $item ))
  3581. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  3582. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  3583. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  3584. Doo::loadClass ( 'XDeode' );
  3585. $XDeode = new XDeode ( 7 );
  3586. Doo::loadModel ( 'receipt' );
  3587. $receipt = new receipt ();
  3588. Doo::loadModel ( 'L_category' );
  3589. $Lcategory = new L_category ();
  3590. Doo::loadModel ( 'verify' );
  3591. Doo::loadModel ( 'statistics' );
  3592. $statistics = new statistics ();
  3593. $verify = new verify ();
  3594. Doo::loadModel ( 'staff' );
  3595. $staff = new staff ();
  3596. $condition = "";
  3597. if ($item == "expenses")
  3598. $condition = " and Rtype=1 ";
  3599. elseif ($item == "receipts")
  3600. $condition = " and Rtype=0 ";
  3601. elseif ($item == "remits")
  3602. $condition = " and Rtype=2 ";
  3603. elseif ($item == "train")
  3604. $condition = " and Rtype=3 ";
  3605. $dateCondition = " and Year(date) =" . $year;
  3606. if (! empty ( $moth )) {
  3607. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  3608. $stList = $statistics->getOne ( array (
  3609. 'select' => 'rePrice ,agPrice',
  3610. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  3611. 'asArray' => true
  3612. ) );
  3613. } else
  3614. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  3615. if (empty ( $stList ))
  3616. $stList = array (
  3617. 'rePrice' => 0,
  3618. 'agPrice' => 0
  3619. );
  3620. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  3621. if (! isset ( $noPassSum ['sum'] ))
  3622. $noPassSum ['sum'] = 0;
  3623. $data ['stList'] = array (
  3624. 'rePrice' => $stList ['rePrice'],
  3625. 'agPrice' => $stList ['agPrice'],
  3626. 'skPrice' => ($noPassSum ['sum'])
  3627. );
  3628. $receiptList = $receipt->find ( array (
  3629. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  3630. 'desc' => 'rid',
  3631. 'asArray' => true
  3632. ) );
  3633. $Locate = 0;
  3634. $roleId = 0;
  3635. $button = 0;
  3636. foreach ( $receiptList as $key => $value ) {
  3637. $receiptList[$key]['balance']='';
  3638. if($value['Rtype']==1){
  3639. $receiptList[$key]['balance']=$value['sum']-=$value['loanSum'];
  3640. $receiptList[$key]['balanceABS']=abs($receiptList[$key]['balance']);
  3641. }elseif($value['Rtype']==3){
  3642. $payment=$this->_getReceiptTrainPayment($value['invoiceTrainId'],$value['trainLoanRid'],$value['rid']);
  3643. $receiptList[$key]['payment']=$payment;
  3644. $receiptList[$key]['paymentABS']=abs($payment);
  3645. }
  3646. $receiptList [$key] ['Locate'] = $Locate;
  3647. $Locate ++;
  3648. $receiptList [$key] ['reviseDetail'] = array ();
  3649. if (! empty ( $value ['reviseDetail'] ))
  3650. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3651. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3652. $categoryDetil = $Lcategory->getOne ( array (
  3653. 'where' => 'cid=' . $value ['cid'],
  3654. 'asArray' => true
  3655. ) );
  3656. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3657. // 检测编辑状态
  3658. $verifyList = $verify->getOne ( array (
  3659. 'where' => 'vid=' . $value ['verify'],
  3660. 'asArray' => true
  3661. ) );
  3662. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3663. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3664. Doo::loadModel ( 'role' );
  3665. $role = new role ();
  3666. $flag = true;
  3667. $roleKey = 0;
  3668. $endStaffArray = array ();
  3669. $roleArrayCopy = array ();
  3670. foreach ( $verifyList as $k => $v ) {
  3671. // init verifyStaff
  3672. if ($v [1] == 'ROLE') {
  3673. if (! empty ( $verifyStaff )) {
  3674. $endStaffArray = end ( $verifyStaff );
  3675. // if ($v[0]==$endStaffArray['nextStaff']){
  3676. // $roleId=$v[0];
  3677. // }
  3678. }
  3679. $roleVerify = json_decode ( $v [3], true );
  3680. $roleKey = $k;
  3681. $roleArray = array ();
  3682. $rolename = $role->getOne ( array (
  3683. 'where' => 'rid=' . $v [0],
  3684. 'asArray' => true
  3685. ) );
  3686. foreach ( $roleVerify as $o => $p ) {
  3687. $staffID = explode ( '_', $p );
  3688. $staffInfo = $staff->getOne ( array (
  3689. 'where' => 'sid=' . $staffID [0],
  3690. 'asArray' => true
  3691. ) );
  3692. // print_r($staffID);
  3693. $exp = array (
  3694. 0 => $staffInfo ['sid'],
  3695. 1 => $staffID [1],
  3696. 2 => $staffInfo ['avatar'],
  3697. 'date' => '',
  3698. 'date' => '',
  3699. 'opinion' => '',
  3700. 'status' => '',
  3701. 'rolename' => $rolename ['name']
  3702. );
  3703. array_push ( $roleArray, $exp );
  3704. }
  3705. $roleArrayCopy [$v [0]] = $roleArray;
  3706. // $verifyList[$k]['roleArray']=$roleArray;
  3707. }
  3708. $verifyList [$k] ['date'] = "";
  3709. $verifyList [$k] ['opinion'] = "";
  3710. $verifyList [$k] ['status'] = "";
  3711. if (empty ( $verifyStaff )) {
  3712. $verifyList [$k] ['date'] = "";
  3713. $verifyList [$k] ['opinion'] = "";
  3714. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3715. $verifyList [$k] ['status'] = 4;
  3716. $flag = false;
  3717. }
  3718. } else {
  3719. foreach ( $verifyStaff as $m => $u ) {
  3720. if ($v [0] == $m) {
  3721. $verifyList [$k] ['date'] = $u ['date'];
  3722. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3723. $verifyList [$k] ['status'] = $u ['status'];
  3724. $flag = false;
  3725. break;
  3726. }
  3727. }
  3728. $endStaffArray = end ( $verifyStaff );
  3729. if (isset ( $endStaffArray ['ROLE'] )) {
  3730. } else {
  3731. // $endKey=key($verifyStaff);
  3732. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3733. // $button=4;
  3734. // $verifyList[$k]['status']=4;
  3735. // }
  3736. }
  3737. }
  3738. }
  3739. $rolename ['name'] = '';
  3740. if (! empty ( $roleId )) {
  3741. Doo::loadModel ( 'role' );
  3742. $role = new role ();
  3743. $rolename = $role->getOne ( array (
  3744. 'where' => 'rid=' . $roleId,
  3745. 'asArray' => true
  3746. ) );
  3747. }
  3748. if (! empty ( $verifyStaff ))
  3749. $endStaffArray = end ( $verifyStaff );
  3750. $KOP = false;
  3751. foreach ( $roleArrayCopy as $P => $A ) {
  3752. foreach ( $A as $MKI => $AVL ) {
  3753. if (! empty ( $verifyStaff )) {
  3754. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3755. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3756. $button = 4;
  3757. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3758. }
  3759. foreach ( $verifyStaff as $m => $u ) {
  3760. $AVLFK = $AVL [0] . '_R';
  3761. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3762. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3763. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3764. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3765. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3766. break;
  3767. }
  3768. }
  3769. } else {
  3770. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3771. $button = 4;
  3772. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3773. }
  3774. }
  3775. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3776. $KOP = true;
  3777. }
  3778. }
  3779. foreach ( $roleArrayCopy as $k => $v ) {
  3780. foreach ( $verifyList as $m => $n ) {
  3781. if ($n [0] == $k) {
  3782. array_splice ( $verifyList, $m, 1, $v );
  3783. }
  3784. }
  3785. }
  3786. $receiptList [$key] ['verifyList'] = $verifyList;
  3787. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3788. 'where' => 'sid=' . $value ['staff'],
  3789. 'asArray' => true
  3790. ) );
  3791. $receiptList [$key] ['button'] = $button;
  3792. $receiptList [$key] ['ridKey'] =$XDeode->encode( $value ['rid'] );
  3793. }
  3794. // print_r($receiptList);die;
  3795. $mothHtml = "";
  3796. for($i = 1; $i <= 12; $i ++) {
  3797. if ($moth == $i)
  3798. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3799. else
  3800. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3801. }
  3802. $dateHtml = "";
  3803. $now = date ( "Y" );
  3804. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  3805. if ($YEARD <= $now) {
  3806. $dateHtml .= '<option ';
  3807. if ($year == $YEARD) {
  3808. $dateHtml .= 'selected ';
  3809. }
  3810. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  3811. }
  3812. }
  3813. $data ['dateHtml'] = $dateHtml;
  3814. $data ['mothHtml'] = $mothHtml;
  3815. $data ['receiptList'] = $receiptList;
  3816. $data ['memu'] = "receipt";
  3817. $data ['staff'] = $this->staff;
  3818. $data ['receiptMemu'] = 'expenses';
  3819. $data ['verifyId'] = $this->verifyId;
  3820. $data ['executeId'] = $this->executeId;
  3821. $data ['item'] = $item;
  3822. $data ['year'] = $year;
  3823. $this->render ( "/admin/expenses", $data );
  3824. }
  3825. function expensesCollect() {
  3826. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3827. Doo::loadModel ( 'receipt' );
  3828. $receipt = new receipt ();
  3829. Doo::loadModel ( 'L_category' );
  3830. $Lcategory = new L_category ();
  3831. Doo::loadModel ( 'verify' );
  3832. Doo::loadModel ( 'statistics' );
  3833. $statistics = new statistics ();
  3834. $verify = new verify ();
  3835. Doo::loadModel ( 'staff' );
  3836. $staff = new staff ();
  3837. Doo::loadModel ( 'loanReceipt' );
  3838. $loanReceipt = new loanReceipt ();
  3839. $receiptList = $receipt->find ( array (//去掉
  3840. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  3841. 'desc' => 'rid',
  3842. 'asArray' => true
  3843. ) );
  3844. $loanList = $loanReceipt->find ( array (
  3845. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3846. 'desc' => 'rid',
  3847. 'asArray' => true
  3848. ) );
  3849. /*
  3850. * $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;
  3851. */
  3852. $data ['explanation'] = '';
  3853. if (! empty ( $loanList ))
  3854. $data ['explanation'] = $loanList [0] ['explanation'];
  3855. $Locate = 0;
  3856. $roleId = 0;
  3857. $button = 0;
  3858. foreach ( $receiptList as $key => $value ) {
  3859. $receiptList [$key] ['Locate'] = $Locate;
  3860. $Locate ++;
  3861. $receiptList [$key] ['reviseDetail'] = array ();
  3862. if (! empty ( $value ['reviseDetail'] ))
  3863. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3864. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3865. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3866. $categoryDetil = $Lcategory->getOne ( array (
  3867. 'where' => 'cid=' . $value ['cid'],
  3868. 'asArray' => true
  3869. ) );
  3870. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3871. // 检测编辑状态
  3872. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  3873. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  3874. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  3875. else
  3876. $verifyList ['staff'] = $value ['verifyBreakup'];
  3877. } else
  3878. $verifyList = $verify->getOne ( array (
  3879. 'where' => 'vid=' . $value ['verify'],
  3880. 'asArray' => true
  3881. ) );
  3882. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3883. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3884. Doo::loadModel ( 'role' );
  3885. $role = new role ();
  3886. $flag = true;
  3887. $roleKey = 0;
  3888. $endStaffArray = array ();
  3889. $roleArrayCopy = array ();
  3890. foreach ( $verifyList as $k => $v ) {
  3891. // init verifyStaff
  3892. if ($v [1] == 'ROLE') {
  3893. if (! empty ( $verifyStaff )) {
  3894. $endStaffArray = end ( $verifyStaff );
  3895. // if ($v[0]==$endStaffArray['nextStaff']){
  3896. // $roleId=$v[0];
  3897. // }
  3898. }
  3899. $roleVerify = json_decode ( $v [3], true );
  3900. $roleKey = $k;
  3901. $roleArray = array ();
  3902. $rolename = $role->getOne ( array (
  3903. 'where' => 'rid=' . $v [0],
  3904. 'asArray' => true
  3905. ) );
  3906. foreach ( $roleVerify as $o => $p ) {
  3907. $staffID = explode ( '_', $p );
  3908. $staffInfo = $staff->getOne ( array (
  3909. 'where' => 'sid=' . $staffID [0],
  3910. 'asArray' => true
  3911. ) );
  3912. // print_r($staffID);
  3913. $exp = array (
  3914. 0 => $staffInfo ['sid'],
  3915. 1 => $staffID [1],
  3916. 2 => $staffInfo ['avatar'],
  3917. 'date' => '',
  3918. 'date' => '',
  3919. 'opinion' => '',
  3920. 'status' => '',
  3921. 'rolename' => $rolename ['name']
  3922. );
  3923. array_push ( $roleArray, $exp );
  3924. }
  3925. $roleArrayCopy [$v [0]] = $roleArray;
  3926. // $verifyList[$k]['roleArray']=$roleArray;
  3927. }
  3928. $verifyList [$k] ['date'] = "";
  3929. $verifyList [$k] ['opinion'] = "";
  3930. $verifyList [$k] ['status'] = "";
  3931. if (empty ( $verifyStaff )) {
  3932. $verifyList [$k] ['date'] = "";
  3933. $verifyList [$k] ['opinion'] = "";
  3934. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3935. $verifyList [$k] ['status'] = 4;
  3936. $flag = false;
  3937. }
  3938. } else {
  3939. foreach ( $verifyStaff as $m => $u ) {
  3940. if ($v [0] == $m) {
  3941. $verifyList [$k] ['date'] = $u ['date'];
  3942. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3943. $verifyList [$k] ['status'] = $u ['status'];
  3944. $flag = false;
  3945. break;
  3946. }
  3947. }
  3948. $endStaffArray = end ( $verifyStaff );
  3949. if (isset ( $endStaffArray ['ROLE'] )) {
  3950. } else {
  3951. // $endKey=key($verifyStaff);
  3952. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3953. // $button=4;
  3954. // $verifyList[$k]['status']=4;
  3955. // }
  3956. }
  3957. }
  3958. }
  3959. $rolename ['name'] = '';
  3960. if (! empty ( $roleId )) {
  3961. Doo::loadModel ( 'role' );
  3962. $role = new role ();
  3963. $rolename = $role->getOne ( array (
  3964. 'where' => 'rid=' . $roleId,
  3965. 'asArray' => true
  3966. ) );
  3967. }
  3968. if (! empty ( $verifyStaff ))
  3969. $endStaffArray = end ( $verifyStaff );
  3970. $KOP = false;
  3971. foreach ( $roleArrayCopy as $P => $A ) {
  3972. foreach ( $A as $MKI => $AVL ) {
  3973. if (! empty ( $verifyStaff )) {
  3974. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3975. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3976. $button = 4;
  3977. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3978. }
  3979. foreach ( $verifyStaff as $m => $u ) {
  3980. $AVLFK = $AVL [0] . '_R';
  3981. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3982. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3983. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3984. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3985. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3986. break;
  3987. }
  3988. }
  3989. } else {
  3990. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3991. $button = 4;
  3992. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3993. }
  3994. }
  3995. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3996. $KOP = true;
  3997. }
  3998. }
  3999. foreach ( $roleArrayCopy as $k => $v ) {
  4000. foreach ( $verifyList as $m => $n ) {
  4001. if ($n [0] == $k) {
  4002. array_splice ( $verifyList, $m, 1, $v );
  4003. }
  4004. }
  4005. }
  4006. // 费用执行人相关数据
  4007. $executeCopy = json_decode ( $value ['executeCopy'], true );
  4008. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4009. foreach ( $executeCopy as $k => $v ) {
  4010. $executeCopy [$k] ['date'] = '';
  4011. $executeCopy [$k] ['opinion'] = '';
  4012. $executeCopy [$k] ['status'] = '';
  4013. if (! empty ( $executeStaff ))
  4014. foreach ( $executeStaff as $m => $u ) {
  4015. if ($v [0] == $m) {
  4016. $executeCopy [$k] ['date'] = $u ['date'];
  4017. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  4018. $executeCopy [$k] ['status'] = $u ['status'];
  4019. break;
  4020. }
  4021. }
  4022. }
  4023. $receiptList [$key] ['executeCopy'] = $executeCopy;
  4024. $receiptList [$key] ['verifyList'] = $verifyList;
  4025. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4026. 'where' => 'sid=' . $value ['staff'],
  4027. 'asArray' => true
  4028. ) );
  4029. $receiptList [$key] ['button'] = $button;
  4030. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4031. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4032. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4033. $receiptList [$key] ['relust'] = $relust;
  4034. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4035. }
  4036. Doo::loadModel ( 'enclosur' );
  4037. $enclosur = new enclosur ();
  4038. $enclosurList = $enclosur->find ( array (
  4039. 'where' => 'rid=' . $rid,
  4040. 'asArray' => true
  4041. ) );
  4042. $enclosurHtml = '';
  4043. foreach ( $enclosurList as $value ) {
  4044. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4045. }
  4046. $data ['enclosurHtml'] = $enclosurHtml;
  4047. //print_r($receiptList[0]['accountItem']['内部培训费用']);
  4048. $data ['receiptList'] = $receiptList;
  4049. $data ['memu'] = "receipt";
  4050. $data ['staff'] = $this->staff;
  4051. $data ['receiptMemu'] = 'expenses';
  4052. $data ['verifyId'] = $this->verifyId;
  4053. $data ['executeId'] = $this->executeId;
  4054. $this->render ( "/admin/expensesCollect", $data );
  4055. }
  4056. function approvalExpenses() {
  4057. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  4058. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4059. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4060. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4061. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4062. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  4063. // echo $rdate;
  4064. if (empty ( $status ))
  4065. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  4066. $page_size = 8;
  4067. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  4068. $vidList = array ();
  4069. $button = 0;
  4070. Doo::loadModel ( 'verify' );
  4071. $verify = new verify ();
  4072. Doo::loadModel ( 'receipt' );
  4073. $receipt = new receipt ();
  4074. Doo::loadModel ( 'staff' );
  4075. $staff = new staff ();
  4076. Doo::loadModel ( 'L_category' );
  4077. $Lcategory = new L_category ();
  4078. // user verify ID
  4079. $verifyDetail = $verify->find ( array (
  4080. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  4081. 'asArray' => true
  4082. ) );
  4083. foreach ( $verifyDetail as $key => $value ) {
  4084. array_push ( $vidList, $value ['vid'] );
  4085. }
  4086. $vid = implode ( ",", $vidList );
  4087. if (empty ( $verifyDetail ))
  4088. $vid = 0;
  4089. // if ($status==0)
  4090. // $dateCondition="";
  4091. // else
  4092. $dateCondition = " ";
  4093. // if (! empty ( $month ))
  4094. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  4095. if ($status == 'done' || $status == 'termination') {
  4096. if (! empty ( $year )) {
  4097. $dateCondition = " and Year(pastDate) =" . $year;
  4098. if (! empty ( $month ))
  4099. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  4100. }
  4101. } elseif ($status == 'finish') {
  4102. if (! empty ( $year )) {
  4103. $dateCondition = " and Year(pastDate) =" . $year;
  4104. if (! empty ( $month ))
  4105. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  4106. }
  4107. }
  4108. // date ( 'Y-m' )
  4109. // if (! empty ( $rdate ) && $status == 'done')
  4110. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  4111. // elseif (! empty ( $rdate ))
  4112. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  4113. $categoryList = $Lcategory->find ( array (
  4114. 'asArray' => true
  4115. ) );
  4116. $staffList = $staff->find ( array (
  4117. 'where' => 'cid=' . $cid,
  4118. 'asArray' => true
  4119. ) );
  4120. $cateCondition = "";
  4121. $staffCondition = "";
  4122. $approvalCondition = "";
  4123. if (! empty ( $cid )) {
  4124. $cateCondition = ' and cid=' . $cid;
  4125. }
  4126. if (! empty ( $sid )) {
  4127. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  4128. $cateCondition = "";
  4129. }
  4130. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  4131. if ($status == 'pendApproval') {
  4132. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  4133. }
  4134. if ($status == 'ongoing') {
  4135. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  4136. }
  4137. if ($status == 'done') {
  4138. $approvalCondition = ' and (status=8 or status=9 ) ';
  4139. }
  4140. if ($status == 'termination') {
  4141. $approvalCondition = " and status=3";
  4142. }
  4143. if ($status == 'finish') {
  4144. $approvalCondition = " and (status=1 or status=8 or status=9 or status=10)";
  4145. }
  4146. $pageinfo ['page'] = array (
  4147. 'previous' => ''
  4148. );
  4149. if(!empty($receiptOrder)){
  4150. $pageinfo = $this->get_page ( "CLD_receipt", ' and receiptOrder like "%' . $receiptOrder . '%"', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  4151. $receiptList = $receipt->find ( array ( // $dateCondition
  4152. 'where' => 'receiptOrder like "%' . $receiptOrder . '%"',
  4153. 'desc' => 'rid',
  4154. 'asArray' => true
  4155. ) );
  4156. }else{
  4157. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  4158. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  4159. $receiptList = $receipt->find ( array ( // $dateCondition.
  4160. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  4161. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  4162. 'desc' => 'rid',
  4163. 'asArray' => true
  4164. ) );
  4165. } else {
  4166. $receiptList = $receipt->find ( array ( // $dateCondition
  4167. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  4168. 'desc' => 'rid',
  4169. 'asArray' => true
  4170. ) );
  4171. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  4172. }
  4173. }
  4174. $rLRes = $receipt->find ( array (
  4175. '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 . ')',
  4176. 'desc' => 'rid',
  4177. 'asArray' => true
  4178. ) );
  4179. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  4180. // print_r($receiptList);
  4181. Doo::loadClass ( 'XDeode' );
  4182. $XDeode = new XDeode ( 7 );
  4183. $Locate = 0;
  4184. //
  4185. $reportList = $reportCateList = array ();
  4186. foreach ( $receiptList as $key => $value ) {
  4187. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4188. $receiptList [$key] ['Locate'] = $Locate;
  4189. $Locate ++;
  4190. $receiptList [$key] ['reviseDetail'] = array ();
  4191. if (! empty ( $value ['reviseDetail'] ))
  4192. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4193. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4194. $categoryDetil = $Lcategory->getOne ( array (
  4195. 'where' => 'cid=' . $value ['cid'],
  4196. 'asArray' => true
  4197. ) );
  4198. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4199. $verifyList = $verify->getOne ( array (
  4200. 'where' => 'vid=' . $value ['verify'],
  4201. 'asArray' => true
  4202. ) );
  4203. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4204. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4205. foreach ( $verifyList as $k => $v ) {
  4206. // init verifyStaff
  4207. $verifyList [$k] ['date'] = "";
  4208. $verifyList [$k] ['opinion'] = "";
  4209. $verifyList [$k] ['status'] = "";
  4210. if (empty ( $verifyStaff )) {
  4211. $verifyList [$k] ['date'] = "";
  4212. $verifyList [$k] ['opinion'] = "";
  4213. if ($v [0] == $this->staff [0] ['sid']) {
  4214. $verifyList [$k] ['status'] = 4;
  4215. $button = 4;
  4216. }
  4217. } else {
  4218. $flag = true;
  4219. foreach ( $verifyStaff as $m => $u ) {
  4220. if ($v [0] == $m) {
  4221. $verifyList [$k] ['date'] = $u ['date'];
  4222. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4223. $verifyList [$k] ['status'] = $u ['status'];
  4224. $flag = false;
  4225. break;
  4226. }
  4227. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  4228. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  4229. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  4230. }
  4231. if ($flag) { // 检测可编辑
  4232. if ($v [0] == $this->staff [0] ['sid']) {
  4233. $verifyList [$k] ['status'] = 4;
  4234. $button = 4;
  4235. }
  4236. }
  4237. }
  4238. }
  4239. $receiptList [$key] ['verifyList'] = $verifyList;
  4240. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4241. 'where' => 'sid=' . $value ['staff'],
  4242. 'asArray' => true
  4243. ) );
  4244. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  4245. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  4246. $receiptList [$key] ['button'] = $button;
  4247. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  4248. //获得培训班结算RID 借款费用--已经锁定
  4249. if($value['status']==10){
  4250. $trainRD=$receipt->getReceiptByTrainLoanRid($value['rid']);
  4251. $receiptList [$key]['trainRidKey7']=$trainRD['ridKey7'];
  4252. }
  4253. }
  4254. $reportList = array_unique ( $reportList );
  4255. $reportHtml = '';
  4256. foreach ( $reportList as $key => $value ) {
  4257. $v = explode ( "-", $value );
  4258. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  4259. }
  4260. // print_r($reportList)
  4261. $data ['reportHtml'] = $reportHtml;
  4262. $reportCateList = array_unique ( $reportCateList );
  4263. $reportCateHtml = '';
  4264. foreach ( $reportCateList as $key => $value ) {
  4265. $v = explode ( "-", $value );
  4266. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  4267. }
  4268. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  4269. $data ['reportCateHtml'] = $reportCateHtml;
  4270. // print_r($receiptList);die;
  4271. // $data['verifyDetail']=$verifyDetail;
  4272. $mothHtml = "";
  4273. for($i = 1; $i <= 12; $i ++) {
  4274. if ($month == $i)
  4275. $mothHtml .= '<option selected value="0' . $i . '">' . $i . '月</option>';
  4276. else
  4277. $mothHtml .= '<option value="0' . $i . '">' . $i . '月</option>';
  4278. }
  4279. $data ['mothHtml'] = $mothHtml;
  4280. $dateHtml = "";
  4281. $now = date ( "Y" );
  4282. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  4283. if ($YEARD <= $now) {
  4284. $dateHtml .= '<option ';
  4285. if ($year == $YEARD) {
  4286. $dateHtml .= 'selected ';
  4287. }
  4288. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  4289. }
  4290. }
  4291. $data ['dateHtml'] = $dateHtml;
  4292. $data ['page'] = $pageinfo;
  4293. $data ['receiptList'] = $receiptList;
  4294. $data ['receiptApprovalCount'] = count ( $rLRes );
  4295. $data ['status'] = $status;
  4296. $data ['year'] = $year;
  4297. $data ['month'] = $month;
  4298. $data ['categoryList'] = $categoryList;
  4299. $data ['staffList'] = $staffList;
  4300. $data ['cid'] = $cid;
  4301. $data ['sid'] = $sid;
  4302. // print_r($receiptList);
  4303. $data['receiptOrder']=$receiptOrder;
  4304. $data ['memu'] = "receipt";
  4305. $data ['staff'] = $this->staff;
  4306. $data ['receiptMemu'] = 'approvalExpenses';
  4307. $data ['verifyId'] = $this->verifyId;
  4308. $data ['executeId'] = $this->executeId;
  4309. $this->render ( "/admin/approvalExpenses", $data );
  4310. }
  4311. function expensesDoc() {
  4312. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  4313. Doo::loadClass ( 'XDeode' );
  4314. $XDeode = new XDeode ( 5 );
  4315. if (! empty ( $rid ) && ! is_numeric ( $rid ))
  4316. $rid = $XDeode->decode ( $rid );
  4317. if (! is_numeric ( $rid ))
  4318. die ( 'illegal request' );
  4319. Doo::loadModel ( 'receipt' );
  4320. $receipt = new receipt ();
  4321. Doo::loadModel ( 'L_category' );
  4322. $Lcategory = new L_category ();
  4323. Doo::loadModel ( 'verify' );
  4324. Doo::loadModel ( 'statistics' );
  4325. $statistics = new statistics ();
  4326. $verify = new verify ();
  4327. Doo::loadModel ( 'staff' );
  4328. $staff = new staff ();
  4329. Doo::loadModel ( 'loanReceipt' );
  4330. $loanReceipt = new loanReceipt ();
  4331. $receiptList = $receipt->find ( array (
  4332. 'where' => ' rid=' . $rid,
  4333. 'desc' => 'rid',
  4334. 'asArray' => true
  4335. ) );
  4336. $loanList = array ();
  4337. if (! empty ( $receiptList ))
  4338. $loanList = $loanReceipt->find ( array (
  4339. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4340. 'desc' => 'rid',
  4341. 'asArray' => true
  4342. ) );
  4343. $Locate = 0;
  4344. $roleId = 0;
  4345. $button = 0;
  4346. foreach ( $loanList as $key => $value ) {
  4347. $loanList [$key] ['Locate'] = $Locate;
  4348. $Locate ++;
  4349. $loanList [$key] ['reviseDetail'] = array ();
  4350. if (! empty ( $value ['reviseDetail'] ))
  4351. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4352. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4353. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4354. $categoryDetil = $Lcategory->getOne ( array (
  4355. 'where' => 'cid=' . $value ['cid'],
  4356. 'asArray' => true
  4357. ) );
  4358. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4359. // 检测编辑状态
  4360. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  4361. $verifyList ['staff'] = $value ['verifyBreakup'];
  4362. else
  4363. $verifyList = $verify->getOne ( array (
  4364. 'where' => 'vid=' . $value ['verify'],
  4365. 'asArray' => true
  4366. ) );
  4367. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4368. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4369. Doo::loadModel ( 'role' );
  4370. $role = new role ();
  4371. $flag = true;
  4372. $roleKey = 0;
  4373. $endStaffArray = array ();
  4374. $roleArrayCopy = array ();
  4375. foreach ( $verifyList as $k => $v ) {
  4376. // init verifyStaff
  4377. if ($v [1] == 'ROLE') {
  4378. if (! empty ( $verifyStaff )) {
  4379. $endStaffArray = end ( $verifyStaff );
  4380. // if ($v[0]==$endStaffArray['nextStaff']){
  4381. // $roleId=$v[0];
  4382. // }
  4383. }
  4384. $roleVerify = json_decode ( $v [3], true );
  4385. $roleKey = $k;
  4386. $roleArray = array ();
  4387. $rolename = $role->getOne ( array (
  4388. 'where' => 'rid=' . $v [0],
  4389. 'asArray' => true
  4390. ) );
  4391. foreach ( $roleVerify as $o => $p ) {
  4392. $staffID = explode ( '_', $p );
  4393. $staffInfo = $staff->getOne ( array (
  4394. 'where' => 'sid=' . $staffID [0],
  4395. 'asArray' => true
  4396. ) );
  4397. // print_r($staffID);
  4398. $exp = array (
  4399. 0 => $staffInfo ['sid'],
  4400. 1 => $staffID [1],
  4401. 2 => $staffInfo ['avatar'],
  4402. 'date' => '',
  4403. 'date' => '',
  4404. 'opinion' => '',
  4405. 'status' => '',
  4406. 'rolename' => $rolename ['name']
  4407. );
  4408. array_push ( $roleArray, $exp );
  4409. }
  4410. $roleArrayCopy [$v [0]] = $roleArray;
  4411. // $verifyList[$k]['roleArray']=$roleArray;
  4412. }
  4413. $verifyList [$k] ['date'] = "";
  4414. $verifyList [$k] ['opinion'] = "";
  4415. $verifyList [$k] ['status'] = "";
  4416. if (empty ( $verifyStaff )) {
  4417. $verifyList [$k] ['date'] = "";
  4418. $verifyList [$k] ['opinion'] = "";
  4419. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4420. $verifyList [$k] ['status'] = 4;
  4421. $flag = false;
  4422. }
  4423. } else {
  4424. foreach ( $verifyStaff as $m => $u ) {
  4425. if ($v [0] == $m) {
  4426. $verifyList [$k] ['date'] = $u ['date'];
  4427. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4428. $verifyList [$k] ['status'] = $u ['status'];
  4429. $flag = false;
  4430. break;
  4431. }
  4432. }
  4433. $endStaffArray = end ( $verifyStaff );
  4434. if (isset ( $endStaffArray ['ROLE'] )) {
  4435. } else {
  4436. // $endKey=key($verifyStaff);
  4437. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4438. // $button=4;
  4439. // $verifyList[$k]['status']=4;
  4440. // }
  4441. }
  4442. }
  4443. }
  4444. $rolename ['name'] = '';
  4445. if (! empty ( $roleId )) {
  4446. Doo::loadModel ( 'role' );
  4447. $role = new role ();
  4448. $rolename = $role->getOne ( array (
  4449. 'where' => 'rid=' . $roleId,
  4450. 'asArray' => true
  4451. ) );
  4452. }
  4453. if (! empty ( $verifyStaff ))
  4454. $endStaffArray = end ( $verifyStaff );
  4455. $KOP = false;
  4456. foreach ( $roleArrayCopy as $P => $A ) {
  4457. foreach ( $A as $MKI => $AVL ) {
  4458. if (! empty ( $verifyStaff )) {
  4459. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4460. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4461. $button = 4;
  4462. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4463. }
  4464. foreach ( $verifyStaff as $m => $u ) {
  4465. $AVLFK = $AVL [0] . '_R';
  4466. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4467. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4468. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4469. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4470. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4471. break;
  4472. }
  4473. }
  4474. } else {
  4475. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4476. $button = 4;
  4477. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4478. }
  4479. }
  4480. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4481. $KOP = true;
  4482. }
  4483. }
  4484. foreach ( $roleArrayCopy as $k => $v ) {
  4485. foreach ( $verifyList as $m => $n ) {
  4486. if ($n [0] == $k) {
  4487. array_splice ( $verifyList, $m, 1, $v );
  4488. }
  4489. }
  4490. }
  4491. $loanList [$key] ['verifyList'] = $verifyList;
  4492. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  4493. 'where' => 'sid=' . $value ['staff'],
  4494. 'asArray' => true
  4495. ) );
  4496. $loanList [$key] ['button'] = $button;
  4497. //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  4498. }
  4499. $data ['loanList'] = $loanList;
  4500. //print_r($loanList);
  4501. $Locate = 0;
  4502. $roleId = 0;
  4503. $button = 0;
  4504. foreach ( $receiptList as $key => $value ) {
  4505. $receiptList [$key] ['Locate'] = $Locate;
  4506. $Locate ++;
  4507. $receiptList [$key] ['reviseDetail'] = array ();
  4508. if (! empty ( $value ['reviseDetail'] ))
  4509. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4510. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4511. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4512. $categoryDetil = $Lcategory->getOne ( array (
  4513. 'where' => 'cid=' . $value ['cid'],
  4514. 'asArray' => true
  4515. ) );
  4516. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4517. // 检测编辑状态
  4518. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  4519. $verifyList ['staff'] = $value ['verifyBreakup'];
  4520. } else
  4521. $verifyList = $verify->getOne ( array (
  4522. 'where' => 'vid=' . $value ['verify'],
  4523. 'asArray' => true
  4524. ) );
  4525. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4526. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4527. Doo::loadModel ( 'role' );
  4528. $role = new role ();
  4529. if ($verifyList == NULL)
  4530. $verifyList = array ();
  4531. $flag = true;
  4532. $roleKey = 0;
  4533. $endStaffArray = array ();
  4534. $roleArrayCopy = array ();
  4535. foreach ( $verifyList as $k => $v ) {
  4536. // init verifyStaff
  4537. if ($v [1] == 'ROLE') {
  4538. if (! empty ( $verifyStaff )) {
  4539. $endStaffArray = end ( $verifyStaff );
  4540. // if ($v[0]==$endStaffArray['nextStaff']){
  4541. // $roleId=$v[0];
  4542. // }
  4543. }
  4544. $roleVerify = json_decode ( $v [3], true );
  4545. $roleKey = $k;
  4546. $roleArray = array ();
  4547. $rolename = $role->getOne ( array (
  4548. 'where' => 'rid=' . $v [0],
  4549. 'asArray' => true
  4550. ) );
  4551. foreach ( $roleVerify as $o => $p ) {
  4552. $staffID = explode ( '_', $p );
  4553. $staffInfo = $staff->getOne ( array (
  4554. 'where' => 'sid=' . $staffID [0],
  4555. 'asArray' => true
  4556. ) );
  4557. // print_r($staffID);
  4558. $exp = array (
  4559. 0 => $staffInfo ['sid'],
  4560. 1 => $staffID [1],
  4561. 2 => $staffInfo ['avatar'],
  4562. 'date' => '',
  4563. 'date' => '',
  4564. 'opinion' => '',
  4565. 'status' => '',
  4566. 'rolename' => $rolename ['name']
  4567. );
  4568. array_push ( $roleArray, $exp );
  4569. }
  4570. $roleArrayCopy [$v [0]] = $roleArray;
  4571. // $verifyList[$k]['roleArray']=$roleArray;
  4572. }
  4573. $verifyList [$k] ['date'] = "";
  4574. $verifyList [$k] ['opinion'] = "";
  4575. $verifyList [$k] ['status'] = "";
  4576. if (empty ( $verifyStaff )) {
  4577. $verifyList [$k] ['date'] = "";
  4578. $verifyList [$k] ['opinion'] = "";
  4579. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4580. $verifyList [$k] ['status'] = 4;
  4581. $flag = false;
  4582. }
  4583. } else {
  4584. foreach ( $verifyStaff as $m => $u ) {
  4585. if ($v [0] == $m) {
  4586. $verifyList [$k] ['date'] = $u ['date'];
  4587. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4588. $verifyList [$k] ['status'] = $u ['status'];
  4589. $flag = false;
  4590. break;
  4591. }
  4592. }
  4593. $endStaffArray = end ( $verifyStaff );
  4594. if (isset ( $endStaffArray ['ROLE'] )) {
  4595. } else {
  4596. // $endKey=key($verifyStaff);
  4597. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4598. // $button=4;
  4599. // $verifyList[$k]['status']=4;
  4600. // }
  4601. }
  4602. }
  4603. }
  4604. $FC = @$rolename ['name'];
  4605. $rolename ['name'] = '';
  4606. if (! empty ( $roleId )) {
  4607. Doo::loadModel ( 'role' );
  4608. $role = new role ();
  4609. $rolename = $role->getOne ( array (
  4610. 'where' => 'rid=' . $roleId,
  4611. 'asArray' => true
  4612. ) );
  4613. }
  4614. if (! empty ( $verifyStaff ))
  4615. $endStaffArray = end ( $verifyStaff );
  4616. $KOP = false;
  4617. foreach ( $roleArrayCopy as $P => $A ) {
  4618. foreach ( $A as $MKI => $AVL ) {
  4619. if (! empty ( $verifyStaff )) {
  4620. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4621. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4622. $button = 4;
  4623. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4624. }
  4625. foreach ( $verifyStaff as $m => $u ) {
  4626. $AVLFK = $AVL [0] . '_R';
  4627. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4628. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4629. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4630. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4631. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4632. break;
  4633. }
  4634. }
  4635. } else {
  4636. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4637. $button = 4;
  4638. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4639. }
  4640. }
  4641. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4642. $KOP = true;
  4643. }
  4644. }
  4645. foreach ( $roleArrayCopy as $k => $v ) {
  4646. foreach ( $verifyList as $m => $n ) {
  4647. if ($n [0] == $k) {
  4648. array_splice ( $verifyList, $m, 1, $v );
  4649. }
  4650. }
  4651. }
  4652. // 费用执行人相关数据
  4653. $executeCopy = json_decode ( $value ['executeCopy'], true );
  4654. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4655. foreach ( $executeCopy as $k => $v ) {
  4656. $executeCopy [$k] ['date'] = '';
  4657. $executeCopy [$k] ['opinion'] = '';
  4658. $executeCopy [$k] ['status'] = '';
  4659. if (! empty ( $executeStaff ))
  4660. foreach ( $executeStaff as $m => $u ) {
  4661. if ($v [0] == $m) {
  4662. $executeCopy [$k] ['date'] = $u ['date'];
  4663. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  4664. $executeCopy [$k] ['status'] = $u ['status'];
  4665. break;
  4666. }
  4667. }
  4668. }
  4669. $receiptList [$key] ['executeCopy'] = $executeCopy;
  4670. // print_r($verifyList);
  4671. $receiptList [$key] ['verifyList'] = $verifyList;
  4672. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4673. 'where' => 'sid=' . $value ['staff'],
  4674. 'asArray' => true
  4675. ) );
  4676. $receiptList [$key] ['button'] = $button;
  4677. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4678. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4679. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4680. $receiptList [$key] ['relust'] = $relust;
  4681. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4682. }
  4683. // print_r($receiptList);
  4684. // 获取审批日志
  4685. Doo::loadModel ( 'receiptLog' );
  4686. $receiptLog = new receiptLog ();
  4687. $rlList = array ();
  4688. $rlInfo = $receiptLog->getOne ( array (
  4689. 'where' => 'rid=' . $rid . ' and status=4',
  4690. 'asArray' => true
  4691. ) );
  4692. // $tijdate = $receiptLog->getOne ( array (
  4693. // 'where' => 'rid=' . $rid . ' and status=2',
  4694. // 'asc' => 'rlid',
  4695. // 'asArray' => true
  4696. // ) );
  4697. if (! empty ( $rlInfo )) {
  4698. $rlList = $receiptLog->find ( array (
  4699. 'where' => 'rid=' . $rid,
  4700. 'asc' => 'rlid',
  4701. 'asArray' => true
  4702. ) );
  4703. }
  4704. $RN=array();
  4705. if (!empty( $rolename ['staff'])){
  4706. $RN = @json_decode ( $rolename ['staff'] );
  4707. }
  4708. //
  4709. foreach ( $rlList as $key => $value ) {
  4710. $rlList [$key] ['rolename'] = '';
  4711. foreach ( $RN as $k => $v ) {
  4712. $id = explode ( "_", $v );
  4713. if ($id [0] == $value ['uid']) {
  4714. $rlList [$key] ['rolename'] = $FC;
  4715. break;
  4716. }
  4717. }
  4718. }
  4719. Doo::loadModel ( 'enclosur' );
  4720. $enclosur = new enclosur ();
  4721. $enclosurList = $enclosur->find ( array (
  4722. 'where' => 'rid=' . $rid,
  4723. 'asArray' => true
  4724. ) );
  4725. $enclosurHtml = '';
  4726. foreach ( $enclosurList as $value ) {
  4727. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4728. }
  4729. $data ['enclosurHtml'] = $enclosurHtml;
  4730. $receiptList [0] ['rlList'] = $rlList;
  4731. $data ['receiptList'] = $receiptList;
  4732. // print_r($receiptList);
  4733. $data ['memu'] = "receipt";
  4734. $data ['staff'] = $this->staff;
  4735. $data ['receiptMemu'] = 'approvalExpenses';
  4736. $data ['verifyId'] = $this->verifyId;
  4737. $data ['executeId'] = $this->executeId;
  4738. $this->render ( "/admin/expensesDoc", $data );
  4739. }
  4740. function expensesEdi() {
  4741. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4742. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  4743. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4744. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4745. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4746. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4747. if (empty ( $status ))
  4748. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  4749. $vidList = array ();
  4750. $button = 0;
  4751. Doo::loadModel ( 'verify' );
  4752. Doo::loadModel ( 'receipt' );
  4753. Doo::loadModel ( 'staff' );
  4754. $staff = new staff ();
  4755. $receipt = new receipt ();
  4756. $verify = new verify ();
  4757. Doo::loadModel ( 'L_category' );
  4758. $Lcategory = new L_category ();
  4759. Doo::loadModel ( 'enclosur' );
  4760. $enclosur = new enclosur ();
  4761. // user verify ID
  4762. $verifyDetail = $verify->find ( array (
  4763. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  4764. 'asArray' => true
  4765. ) );
  4766. foreach ( $verifyDetail as $key => $value ) {
  4767. array_push ( $vidList, $value ['vid'] );
  4768. }
  4769. $vid = implode ( ",", $vidList );
  4770. if (empty ( $verifyDetail ))
  4771. $vid = 0;
  4772. $categoryList = $Lcategory->find ( array (
  4773. 'asArray' => true
  4774. ) );
  4775. $staffList = $staff->find ( array (
  4776. 'where' => 'cid=' . $cid,
  4777. 'asArray' => true
  4778. ) );
  4779. $ap = "";
  4780. if ($status == 4) {
  4781. $ap = 4;
  4782. $status = 2;
  4783. }
  4784. // get Receipt By verifyID status 2
  4785. $receiptList = $receipt->find ( array (
  4786. 'where' => 'rid =' . $rid . ' and status=2',
  4787. 'desc' => 'rid',
  4788. 'asArray' => true
  4789. ) );
  4790. if (empty ( $receiptList )) {
  4791. die ( 'illegal request' );
  4792. }
  4793. $Locate = 0;
  4794. $roleId = 0;
  4795. if ($ap == 4)
  4796. $status = 4;
  4797. foreach ( $receiptList as $key => $value ) {
  4798. $receiptList [$key] ['Locate'] = $Locate;
  4799. $Locate ++;
  4800. $receiptList [$key] ['reviseDetail'] = array ();
  4801. if (! empty ( $value ['reviseDetail'] ))
  4802. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4803. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4804. $categoryDetil = $Lcategory->getOne ( array (
  4805. 'where' => 'cid=' . $value ['cid'],
  4806. 'asArray' => true
  4807. ) );
  4808. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4809. // 检测编辑状态
  4810. $verifyList = $verify->getOne ( array (
  4811. 'where' => 'vid=' . $value ['verify'],
  4812. 'asArray' => true
  4813. ) );
  4814. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4815. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4816. Doo::loadModel ( 'role' );
  4817. $role = new role ();
  4818. // print_r($verifyList);
  4819. $flag = true;
  4820. $roleKey = 0;
  4821. $endStaffArray = array ();
  4822. $roleArrayCopy = array ();
  4823. foreach ( $verifyList as $k => $v ) {
  4824. // init verifyStaff
  4825. if ($v [1] == 'ROLE') {
  4826. if (! empty ( $verifyStaff )) {
  4827. $endStaffArray = end ( $verifyStaff );
  4828. if ($v [0] == $endStaffArray ['nextStaff']) {
  4829. $roleId = $v [0];
  4830. }
  4831. }
  4832. $roleVerify = json_decode ( $v [3], true );
  4833. $roleKey = $k;
  4834. $roleArray = array ();
  4835. $rolename = $role->getOne ( array (
  4836. 'where' => 'rid=' . $v [0],
  4837. 'asArray' => true
  4838. ) );
  4839. foreach ( $roleVerify as $o => $p ) {
  4840. $staffID = explode ( '_', $p );
  4841. $staffInfo = $staff->getOne ( array (
  4842. 'where' => 'sid=' . $staffID [0],
  4843. 'asArray' => true
  4844. ) );
  4845. // print_r($staffID);
  4846. $exp = array (
  4847. 0 => $staffInfo ['sid'],
  4848. 1 => $staffID [1],
  4849. 2 => $staffInfo ['avatar'],
  4850. 'date' => '',
  4851. 'date' => '',
  4852. 'opinion' => '',
  4853. 'status' => '',
  4854. 'rolename' => $rolename ['name']
  4855. );
  4856. array_push ( $roleArray, $exp );
  4857. }
  4858. $roleArrayCopy [$v [0]] = $roleArray;
  4859. // $verifyList[$k]['roleArray']=$roleArray;
  4860. }
  4861. // print_r($roleArray);
  4862. $verifyList [$k] ['date'] = "";
  4863. $verifyList [$k] ['opinion'] = "";
  4864. $verifyList [$k] ['status'] = "";
  4865. if (empty ( $verifyStaff )) {
  4866. $verifyList [$k] ['date'] = "";
  4867. $verifyList [$k] ['opinion'] = "";
  4868. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4869. $verifyList [$k] ['status'] = 4;
  4870. $button = 4;
  4871. $flag = false;
  4872. }
  4873. } else {
  4874. foreach ( $verifyStaff as $m => $u ) {
  4875. if ($v [0] == $m) {
  4876. $verifyList [$k] ['date'] = $u ['date'];
  4877. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4878. $verifyList [$k] ['status'] = $u ['status'];
  4879. $flag = false;
  4880. break;
  4881. }
  4882. }
  4883. $endStaffArray = end ( $verifyStaff );
  4884. if (isset ( $endStaffArray ['ROLE'] )) {
  4885. } else {
  4886. $endKey = key ( $verifyStaff );
  4887. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4888. $button = 4;
  4889. $verifyList [$k] ['status'] = 4;
  4890. }
  4891. }
  4892. }
  4893. }
  4894. $rolename ['name'] = '';
  4895. if (! empty ( $roleId )) {
  4896. Doo::loadModel ( 'role' );
  4897. $role = new role ();
  4898. $rolename = $role->getOne ( array (
  4899. 'where' => 'rid=' . $roleId,
  4900. 'asArray' => true
  4901. ) );
  4902. }
  4903. if (! empty ( $verifyStaff ))
  4904. $endStaffArray = end ( $verifyStaff );
  4905. $KOP = false;
  4906. foreach ( $roleArrayCopy as $P => $A ) {
  4907. foreach ( $A as $MKI => $AVL ) {
  4908. if (! empty ( $verifyStaff )) {
  4909. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4910. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4911. $button = 4;
  4912. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4913. }
  4914. foreach ( $verifyStaff as $m => $u ) {
  4915. $AVLFK = $AVL [0] . '_R';
  4916. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4917. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4918. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4919. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4920. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4921. break;
  4922. }
  4923. }
  4924. } else {
  4925. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4926. $button = 4;
  4927. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4928. }
  4929. }
  4930. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4931. $KOP = true;
  4932. }
  4933. }
  4934. // print_r($roleArrayCopy);
  4935. // echo $roleKey;
  4936. foreach ( $roleArrayCopy as $k => $v ) {
  4937. foreach ( $verifyList as $m => $n ) {
  4938. if ($n [0] == $k) {
  4939. array_splice ( $verifyList, $m, 1, $v );
  4940. }
  4941. }
  4942. }
  4943. $receiptList [$key] ['verifyList'] = $verifyList;
  4944. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4945. 'where' => 'sid=' . $value ['staff'],
  4946. 'asArray' => true
  4947. ) );
  4948. $receiptList [$key] ['button'] = $button;
  4949. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  4950. }
  4951. // $data['verifyDetail']=$verifyDetail;
  4952. $mothHtml = "";
  4953. for($i = 1; $i <= 12; $i ++) {
  4954. if ($month == $i)
  4955. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4956. else
  4957. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4958. }
  4959. // 获取审批日志
  4960. Doo::loadModel ( 'receiptLog' );
  4961. $receiptLog = new receiptLog ();
  4962. $rlList = array ();
  4963. $rlInfo = $receiptLog->getOne ( array (
  4964. 'where' => 'rid=' . $rid . ' and status=4',
  4965. 'asArray' => true
  4966. ) );
  4967. $tijdate = $receiptLog->getOne ( array (
  4968. 'where' => 'rid=' . $rid . ' and status=2',
  4969. 'asc' => 'rlid',
  4970. 'asArray' => true
  4971. ) );
  4972. if (! empty ( $rlInfo )) {
  4973. $rlList = $receiptLog->find ( array (
  4974. 'where' => 'rid=' . $rid,
  4975. 'asc' => 'rlid',
  4976. 'asArray' => true
  4977. ) );
  4978. }
  4979. $receiptList [0] ['rlList'] = $rlList;
  4980. $enclosurList = $enclosur->find ( array (
  4981. 'where' => 'rid=' . $rid,
  4982. 'asArray' => true
  4983. ) );
  4984. $enclosurHtml = '';
  4985. foreach ( $enclosurList as $value ) {
  4986. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4987. }
  4988. // print_r($receiptList);
  4989. $data ['rid'] = $rid;
  4990. $data ['enclosurHtml'] = $enclosurHtml;
  4991. $data ['rolename'] = $rolename ['name'];
  4992. $data ['datetij'] = $tijdate ['date'];
  4993. $data ['mothHtml'] = $mothHtml;
  4994. $data ['receiptList'] = $receiptList;
  4995. $data ['receiptApprovalCount'] = count ( $receiptList );
  4996. $data ['status'] = $status;
  4997. $data ['year'] = $year;
  4998. $data ['categoryList'] = $categoryList;
  4999. $data ['staffList'] = $staffList;
  5000. $data ['cid'] = $cid;
  5001. $data ['sid'] = $sid;
  5002. $data ['ap'] = $ap;
  5003. $data ['memu'] = "receipt";
  5004. $data ['staff'] = $this->staff;
  5005. $data ['receiptMemu'] = 'approvalExpenses';
  5006. $data ['verifyId'] = $this->verifyId;
  5007. $data ['executeId'] = $this->executeId;
  5008. $this->render ( "/admin/expensesEdi", $data );
  5009. }
  5010. function expensesDefray() {
  5011. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  5012. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  5013. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5014. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  5015. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  5016. if (! empty ( $rid )) {
  5017. Doo::loadModel ( "verify" );
  5018. $verify = new verify ();
  5019. Doo::loadModel ( "receiptDetail" );
  5020. $receiptDetailObj = new receiptDetail ();
  5021. Doo::loadModel ( "itemStatistics" );
  5022. Doo::loadModel ( "statistics" );
  5023. $statistics = new statistics ();
  5024. $itemStatistics = new itemStatistics ();
  5025. Doo::loadModel ( "receipt" );
  5026. $receipt = new receipt ();
  5027. Doo::loadModel ( "loanReceipt" );
  5028. $loanReceipt = new loanReceipt ();
  5029. $receiptDetail = $receipt->getOne ( array (
  5030. 'where' => 'rid=' . $rid . ' and status=2 ',
  5031. 'asArray' => true
  5032. ) );
  5033. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  5034. $nsflag = true;
  5035. foreach ( $nslist as $value ) {
  5036. if ($value == $this->staff ['0'] ['sid']) {
  5037. $nsflag = false;
  5038. break;
  5039. }
  5040. }
  5041. // print_r($nslist);die;
  5042. if (empty ( $receiptDetail ) || $nsflag)
  5043. return "/approvalExpenses/pendApproval";
  5044. $verifyDetail = $verify->getOne ( array (
  5045. 'where' => ' vid =' . $receiptDetail ['verify'],
  5046. 'asArray' => true
  5047. ) );
  5048. $verifyString = $verifyDetail ['staff'];
  5049. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5050. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  5051. if (empty ( $opinion )) {
  5052. if ($status == 3)
  5053. $opinion = "终止";
  5054. else
  5055. $opinion = "同意支付";
  5056. }
  5057. $nowStaff = 0;
  5058. $nowStaffList = array ();
  5059. if (empty ( $verifyStaff )) {
  5060. // 还需加入是否已经进入角色审批
  5061. if ($verifyDetail [0] [1] == 'ROLE') {
  5062. // print_r($verifyDetail);echo "ddd";
  5063. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5064. foreach ( $vStaffString as $key => $value ) {
  5065. $staffK = explode ( "_", $value );
  5066. if ($staffK [0] != $this->staff [0] ['sid'])
  5067. array_push ( $nowStaffList, $staffK [0] );
  5068. }
  5069. // print_r($verifyDetail);
  5070. // die;
  5071. if (! empty ( $nowStaffList )) {
  5072. $nowStaff = implode ( ',', $nowStaffList );
  5073. $verifyStaff = array (
  5074. $this->staff [0] ['sid'] . "_R" => array (
  5075. 'date' => date ( 'Y-m-d' ),
  5076. 'opinion' => $opinion,
  5077. 'status' => $status,
  5078. 'nextStaff' => $verifyDetail [0] [0],
  5079. 'ROLE' => 1
  5080. )
  5081. );
  5082. } else {
  5083. $nowStaff = $verifyDetail [1] [0];
  5084. $verifyStaff = array (
  5085. $this->staff [0] ['sid'] . "_R" => array (
  5086. 'date' => date ( 'Y-m-d' ),
  5087. 'opinion' => $opinion,
  5088. 'status' => $status,
  5089. 'nextStaff' => $verifyDetail [1] [0]
  5090. )
  5091. );
  5092. }
  5093. } else {
  5094. if ($verifyDetail [1] [1] == 'ROLE') {
  5095. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  5096. // echo "dd";
  5097. foreach ( $vStaffString as $key => $value ) {
  5098. $staffK = explode ( "_", $value );
  5099. array_push ( $nowStaffList, $staffK [0] );
  5100. }
  5101. $nowStaff = implode ( ',', $nowStaffList );
  5102. $verifyStaff = array (
  5103. $this->staff [0] ['sid'] => array (
  5104. 'date' => date ( 'Y-m-d' ),
  5105. 'opinion' => $opinion,
  5106. 'status' => $status,
  5107. 'nextStaff' => $verifyDetail [1] [0],
  5108. 'ROLE' => 1
  5109. )
  5110. );
  5111. } else {
  5112. $nowStaff = $verifyDetail [1] [0];
  5113. $verifyStaff = array (
  5114. $this->staff [0] ['sid'] => array (
  5115. 'date' => date ( 'Y-m-d' ),
  5116. 'opinion' => $opinion,
  5117. 'status' => $status,
  5118. 'nextStaff' => $verifyDetail [1] [0]
  5119. )
  5120. );
  5121. }
  5122. }
  5123. if ($status == 3)
  5124. $verifyStaff = array (
  5125. 'final' => $status,
  5126. $this->staff [0] ['sid'] => array (
  5127. 'date' => date ( 'Y-m-d' ),
  5128. 'opinion' => $opinion,
  5129. 'status' => $status
  5130. )
  5131. );
  5132. $vStaffString = json_encode ( $verifyStaff );
  5133. $receipt->nowStaff = $nowStaff;
  5134. $receipt->verifyStaff = $vStaffString;
  5135. $loanReceipt->nowStaff = $nowStaff;
  5136. $loanReceipt->verifyStaff = $vStaffString;
  5137. } else {
  5138. $VS = end ( $verifyStaff );
  5139. // 非角色审批
  5140. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  5141. $nextStaff = 0;
  5142. $roleSTF = false;
  5143. foreach ( $verifyDetail as $key => $value ) {
  5144. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  5145. if (isset ( $verifyDetail [$key + 1] )) {
  5146. $nextStaff = $verifyDetail [$key + 1] [0];
  5147. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  5148. $roleSTF = true;
  5149. }
  5150. break;
  5151. }
  5152. }
  5153. if (! $roleSTF) {
  5154. $nowStaff = $nextStaff;
  5155. $verifyStaff [$this->staff [0] ['sid']] = array (
  5156. 'date' => date ( 'Y-m-d' ),
  5157. 'opinion' => $opinion,
  5158. 'status' => $status,
  5159. 'nextStaff' => $nextStaff
  5160. );
  5161. } else {
  5162. // 获取角色下的所有用户ID
  5163. $nowStaffList = array ();
  5164. foreach ( $verifyDetail as $vfk ) {
  5165. if ($vfk [1] == 'ROLE') {
  5166. $vStaffString = json_decode ( $vfk [3] );
  5167. foreach ( $vStaffString as $key => $value ) {
  5168. $staffK = explode ( "_", $value );
  5169. array_push ( $nowStaffList, $staffK [0] );
  5170. }
  5171. }
  5172. }
  5173. $nowStaff = implode ( ',', $nowStaffList );
  5174. $verifyStaff [$this->staff [0] ['sid']] = array (
  5175. 'date' => date ( 'Y-m-d' ),
  5176. 'opinion' => $opinion,
  5177. 'status' => $status,
  5178. 'nextStaff' => $nextStaff,
  5179. 'ROLE' => 0
  5180. );
  5181. }
  5182. if ($status == 3) {
  5183. $verifyStaff ['final'] = $status;
  5184. $verifyStaff [$this->staff [0] ['sid']] = array (
  5185. 'date' => date ( 'Y-m-d' ),
  5186. 'opinion' => $opinion,
  5187. 'status' => $status
  5188. );
  5189. }
  5190. $vStaffString = json_encode ( $verifyStaff );
  5191. $receipt->nowStaff = $nowStaff;
  5192. $receipt->verifyStaff = $vStaffString;
  5193. $loanReceipt->nowStaff = $nowStaff;
  5194. $loanReceipt->verifyStaff = $vStaffString;
  5195. }
  5196. // 角色审批
  5197. if (isset ( $VS ['ROLE'] )) {
  5198. // 找出角色人 当前审批角色组
  5199. $verifyJSStaff = array ();
  5200. $nowStaffList2 = array ();
  5201. foreach ( $verifyDetail as $key => $value ) {
  5202. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  5203. $verifyJSStaff = json_decode ( $value [3] );
  5204. foreach ( $verifyJSStaff as $m ) {
  5205. $staffK = explode ( "_", $m );
  5206. array_push ( $nowStaffList2, $staffK [0] );
  5207. }
  5208. // print_r($nowStaffList2);
  5209. }
  5210. }
  5211. $RoleVerifyStaff = array ();
  5212. foreach ( $verifyStaff as $key => $value ) {
  5213. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  5214. foreach ( $nowStaffList2 as $m ) {
  5215. if ($key == $m . "_R")
  5216. $RoleVerifyStaff [$key] = $value;
  5217. }
  5218. }
  5219. }
  5220. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  5221. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  5222. // 下一个审批人ID
  5223. $nextStaff = 0;
  5224. $falg = false;
  5225. foreach ( $verifyDetail as $key => $value ) {
  5226. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  5227. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  5228. $falg = true;
  5229. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  5230. $nowStaffList = array ();
  5231. foreach ( $vStaffString as $v ) {
  5232. $staffK = explode ( "_", $v );
  5233. array_push ( $nowStaffList, $staffK [0] );
  5234. }
  5235. $nowStaff = implode ( ',', $nowStaffList );
  5236. $nextStaff = $verifyDetail [$key + 1] [0];
  5237. } elseif (isset ( $verifyDetail [$key + 1] )) {
  5238. $nextStaff = $verifyDetail [$key + 1] [0];
  5239. $nowStaff = $nextStaff;
  5240. } else
  5241. $nowStaff = '';
  5242. break;
  5243. }
  5244. }
  5245. if ($falg)
  5246. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5247. 'date' => date ( 'Y-m-d' ),
  5248. 'opinion' => $opinion,
  5249. 'status' => $status,
  5250. 'nextStaff' => $nextStaff,
  5251. 'ROLE' => 1
  5252. );
  5253. else
  5254. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5255. 'date' => date ( 'Y-m-d' ),
  5256. 'opinion' => $opinion,
  5257. 'status' => $status,
  5258. 'nextStaff' => $nextStaff
  5259. );
  5260. // print_r($verifyStaff);
  5261. // echo $nowStaff;die;
  5262. } else { // 进入下一个角色或者审批人
  5263. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  5264. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5265. 'date' => date ( 'Y-m-d' ),
  5266. 'opinion' => $opinion,
  5267. 'status' => $status,
  5268. 'nextStaff' => $VS ['nextStaff'],
  5269. 'ROLE' => 1
  5270. );
  5271. }
  5272. if ($status == 3) {
  5273. $verifyStaff ['final'] = $status;
  5274. $verifyStaff [$this->staff [0] ['sid']] = array (
  5275. 'date' => date ( 'Y-m-d' ),
  5276. 'opinion' => $opinion,
  5277. 'status' => $status
  5278. );
  5279. }
  5280. $vStaffString = json_encode ( $verifyStaff );
  5281. $receipt->verifyStaff = $vStaffString;
  5282. $receipt->nowStaff = $nowStaff;
  5283. $loanReceipt->nowStaff = $nowStaff;
  5284. $loanReceipt->verifyStaff = $vStaffString;
  5285. }
  5286. // print_r($verifyStaff);die;
  5287. }
  5288. $roleKey = 0;
  5289. $roleId = 0;
  5290. $verifyDetailCopy = array ();
  5291. foreach ( $verifyDetail as $k => $v ) {
  5292. if ($v [1] == 'ROLE') {
  5293. $roleId = $v [0];
  5294. $roleVerify = json_decode ( $v [3], true );
  5295. $roleKey = $k;
  5296. $roleArray = array ();
  5297. foreach ( $roleVerify as $o => $p ) {
  5298. $staffID = explode ( '_', $p );
  5299. $exp = array (
  5300. 0 => $staffID [0],
  5301. 1 => $staffID [1]
  5302. );
  5303. array_push ( $roleArray, $exp );
  5304. }
  5305. $verifyDetailCopy [$v [0]] = $roleArray;
  5306. }
  5307. }
  5308. // print_r($verifyDetail);
  5309. foreach ( $verifyDetailCopy as $k => $v ) {
  5310. foreach ( $verifyDetail as $m => $n ) {
  5311. if ($n [0] == $k) {
  5312. array_splice ( $verifyDetail, $m, 1, $v );
  5313. }
  5314. }
  5315. }
  5316. // 审批日志
  5317. if (! isset ( $verifyStaff ['final'] )) {
  5318. Doo::loadModel ( "receiptLog" );
  5319. $receiptLog = new receiptLog ();
  5320. if (! empty ( $roleId )) {
  5321. Doo::loadModel ( "role" );
  5322. $role = new role ();
  5323. $roleInfo = $role->getOne ( array (
  5324. 'where' => 'rid=' . $roleId,
  5325. 'asArray' => true
  5326. ) );
  5327. $receiptLog->rolename = $roleInfo ['name'];
  5328. }
  5329. $receiptLog->username = $this->staff [0] ['username'];
  5330. $receiptLog->uid = $this->staff [0] ['sid'];
  5331. $receiptLog->date = date ( "Y-m-d" );
  5332. $receiptLog->opinion = $opinion;
  5333. $receiptLog->img = $this->staff [0] ['avatar'];
  5334. $receiptLog->status = 1;
  5335. $receiptLog->rid = $rid;
  5336. $receiptLog->insert ();
  5337. }
  5338. if (isset ( $verifyStaff ['final'] )) { // rDetail
  5339. $receipt->status = 3;
  5340. $receipt->verifyBreakup = $verifyString;
  5341. $receiptDetailObj->status = 3;
  5342. $receiptDetailObj->update ( array (
  5343. 'where' => 'rid=' . $rid
  5344. ) );
  5345. // 微信企业号通知
  5346. $this->setWXMsg ( $rid, 3 );
  5347. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  5348. $receipt->status = 6;
  5349. $receipt->pastDate = date ( "Y-m-d" );
  5350. $receipt->isBK = 1;
  5351. $loanReceipt->verifyBreakup = $verifyString;
  5352. $loanReceipt->status = 1;
  5353. $loanReceipt->pastDate = date ( "Y-m-d" );
  5354. //生成流水后 不更新汇款金额
  5355. Doo::loadModel ( 'wasteBook' );
  5356. $wasteBook = new wasteBook ();
  5357. $wbDetail = $wasteBook->getWateBookByAD ( 1, $rid );
  5358. if (empty($wbDetail)){
  5359. $loanReceipt->amount = $receiptDetail ['amount'];
  5360. }
  5361. $loanReceipt->update ( array (
  5362. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  5363. ) );
  5364. // 微信企业号通知
  5365. $this->setWXMsg ( $rid, 1 );
  5366. }
  5367. $receipt->amount = $receiptDetail['sum'];
  5368. $receipt->update ( array (
  5369. 'where' => ' rid = ' . $rid
  5370. ) );
  5371. // 进入下一条审批费用新加需求
  5372. $vidList = array ();
  5373. $verifyDetail = $verify->find ( array (
  5374. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  5375. 'asArray' => true
  5376. ) );
  5377. foreach ( $verifyDetail as $key => $value ) {
  5378. array_push ( $vidList, $value ['vid'] );
  5379. }
  5380. $vid = implode ( ",", $vidList );
  5381. if (empty ( $verifyDetail ))
  5382. $vid = 0;
  5383. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  5384. $receipt = new receipt ();
  5385. $rd = $receipt->getOne ( array (
  5386. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  5387. 'asc' => 'rid',
  5388. 'asArray' => true
  5389. ) );
  5390. if (empty ( $rd )) {
  5391. return '/approvalExpenses/pendApproval';
  5392. }
  5393. if ($rd ['Rtype'] == 1) {
  5394. if ($rd ['isBK'] == 1) {
  5395. return '/receiptburEdi/' . $rd ['rid'];
  5396. } else {
  5397. return '/expensesEdi/' . $rd ['rid'];
  5398. }
  5399. } elseif ($rd ['Rtype'] == 2) {
  5400. return '/remitApproval/' . $rd ['rid'];
  5401. } else {
  5402. return '/receiptburEdi/' . $rd ['rid'];
  5403. }
  5404. // return "/approvalExpenses/pendApproval";
  5405. }
  5406. }
  5407. function ajaxExamineExe() {
  5408. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5409. Doo::loadModel ( 'receipt' );
  5410. $receipt = new receipt ();
  5411. Doo::loadClass ( 'XDeode' );
  5412. $XDeode = new XDeode ( 5 );
  5413. if (! empty ( $rid )) {
  5414. $rLRes = $receipt->find ( array (
  5415. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  5416. 'asArray' => true
  5417. ) );
  5418. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  5419. echo json_encode ( array (
  5420. 'status' => 1,
  5421. 'receipt' => $rLRes [0]
  5422. ) );
  5423. die ();
  5424. }
  5425. echo json_encode ( array (
  5426. 'status' => 0,
  5427. 'receipt' => array ()
  5428. ) );
  5429. die ();
  5430. }
  5431. function implement() {
  5432. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5433. $Rtype = isset ( $this->params ['Rtype'] ) ? $this->params ['Rtype'] : '';
  5434. Doo::loadClass ( 'XDeode' );
  5435. $XDeode = new XDeode ( 5 );
  5436. Doo::loadModel ( 'receipt' );
  5437. $receipt = new receipt ();
  5438. Doo::loadModel ( 'L_category' );
  5439. $Lcategory = new L_category ();
  5440. Doo::loadModel ( 'verify' );
  5441. $verify = new verify ();
  5442. Doo::loadModel ( 'staff' );
  5443. $staff = new staff ();
  5444. Doo::loadModel ( "execute" );
  5445. $execute = new execute ();
  5446. $rid = $XDeode->decode ( $rid );
  5447. $receiptList = $receipt->find ( array (
  5448. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  5449. 'desc' => 'rid',
  5450. 'asArray' => true
  5451. ) );
  5452. Doo::loadModel ( 'loanReceipt' );
  5453. $loanReceipt = new loanReceipt ();
  5454. // print_r($receiptList);
  5455. $loanList = array ();
  5456. if (! isset ( $receiptList ))
  5457. $loanList = $loanReceipt->find ( array (
  5458. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  5459. 'desc' => 'rid',
  5460. 'asArray' => true
  5461. ) );
  5462. $Locate = 0;
  5463. $roleId = 0;
  5464. $button = 0;
  5465. foreach ( $loanList as $key => $value ) {
  5466. $loanList [$key] ['Locate'] = $Locate;
  5467. $Locate ++;
  5468. $loanList [$key] ['reviseDetail'] = array ();
  5469. if (! empty ( $value ['reviseDetail'] ))
  5470. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5471. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5472. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5473. $categoryDetil = $Lcategory->getOne ( array (
  5474. 'where' => 'cid=' . $value ['cid'],
  5475. 'asArray' => true
  5476. ) );
  5477. $loanList [$key] ['category'] = $categoryDetil ['title'];
  5478. // 检测编辑状态
  5479. $verifyList = $verify->getOne ( array (
  5480. 'where' => 'vid=' . $value ['verify'],
  5481. 'asArray' => true
  5482. ) );
  5483. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5484. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5485. Doo::loadModel ( 'role' );
  5486. $role = new role ();
  5487. $flag = true;
  5488. $roleKey = 0;
  5489. $endStaffArray = array ();
  5490. $roleArrayCopy = array ();
  5491. foreach ( $verifyList as $k => $v ) {
  5492. // init verifyStaff
  5493. if ($v [1] == 'ROLE') {
  5494. if (! empty ( $verifyStaff )) {
  5495. $endStaffArray = end ( $verifyStaff );
  5496. // if ($v[0]==$endStaffArray['nextStaff']){
  5497. // $roleId=$v[0];
  5498. // }
  5499. }
  5500. $roleVerify = json_decode ( $v [3], true );
  5501. $roleKey = $k;
  5502. $roleArray = array ();
  5503. $rolename = $role->getOne ( array (
  5504. 'where' => 'rid=' . $v [0],
  5505. 'asArray' => true
  5506. ) );
  5507. foreach ( $roleVerify as $o => $p ) {
  5508. $staffID = explode ( '_', $p );
  5509. $staffInfo = $staff->getOne ( array (
  5510. 'where' => 'sid=' . $staffID [0],
  5511. 'asArray' => true
  5512. ) );
  5513. // print_r($staffID);
  5514. $exp = array (
  5515. 0 => $staffInfo ['sid'],
  5516. 1 => $staffID [1],
  5517. 2 => $staffInfo ['avatar'],
  5518. 'date' => '',
  5519. 'date' => '',
  5520. 'opinion' => '',
  5521. 'status' => '',
  5522. 'rolename' => $rolename ['name']
  5523. );
  5524. array_push ( $roleArray, $exp );
  5525. }
  5526. $roleArrayCopy [$v [0]] = $roleArray;
  5527. // $verifyList[$k]['roleArray']=$roleArray;
  5528. }
  5529. $verifyList [$k] ['date'] = "";
  5530. $verifyList [$k] ['opinion'] = "";
  5531. $verifyList [$k] ['status'] = "";
  5532. if (empty ( $verifyStaff )) {
  5533. $verifyList [$k] ['date'] = "";
  5534. $verifyList [$k] ['opinion'] = "";
  5535. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5536. $verifyList [$k] ['status'] = 4;
  5537. $flag = false;
  5538. }
  5539. } else {
  5540. foreach ( $verifyStaff as $m => $u ) {
  5541. if ($v [0] == $m) {
  5542. $verifyList [$k] ['date'] = $u ['date'];
  5543. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5544. $verifyList [$k] ['status'] = $u ['status'];
  5545. $flag = false;
  5546. break;
  5547. }
  5548. }
  5549. $endStaffArray = end ( $verifyStaff );
  5550. if (isset ( $endStaffArray ['ROLE'] )) {
  5551. } else {
  5552. // $endKey=key($verifyStaff);
  5553. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5554. // $button=4;
  5555. // $verifyList[$k]['status']=4;
  5556. // }
  5557. }
  5558. }
  5559. }
  5560. $rolename ['name'] = '';
  5561. if (! empty ( $roleId )) {
  5562. Doo::loadModel ( 'role' );
  5563. $role = new role ();
  5564. $rolename = $role->getOne ( array (
  5565. 'where' => 'rid=' . $roleId,
  5566. 'asArray' => true
  5567. ) );
  5568. }
  5569. if (! empty ( $verifyStaff ))
  5570. $endStaffArray = end ( $verifyStaff );
  5571. $KOP = false;
  5572. foreach ( $roleArrayCopy as $P => $A ) {
  5573. foreach ( $A as $MKI => $AVL ) {
  5574. if (! empty ( $verifyStaff )) {
  5575. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5576. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5577. $button = 4;
  5578. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5579. }
  5580. foreach ( $verifyStaff as $m => $u ) {
  5581. $AVLFK = $AVL [0] . '_R';
  5582. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5583. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5584. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5585. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5586. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5587. break;
  5588. }
  5589. }
  5590. } else {
  5591. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5592. $button = 4;
  5593. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5594. }
  5595. }
  5596. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5597. $KOP = true;
  5598. }
  5599. }
  5600. foreach ( $roleArrayCopy as $k => $v ) {
  5601. foreach ( $verifyList as $m => $n ) {
  5602. if ($n [0] == $k) {
  5603. array_splice ( $verifyList, $m, 1, $v );
  5604. }
  5605. }
  5606. }
  5607. $loanList [$key] ['verifyList'] = $verifyList;
  5608. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  5609. 'where' => 'sid=' . $value ['staff'],
  5610. 'asArray' => true
  5611. ) );
  5612. }
  5613. $data ['loanList'] = $loanList;
  5614. $Locate = 0;
  5615. $roleId = 0;
  5616. $button = 0;
  5617. Doo::loadClass ( 'XDeode' );
  5618. $XDeode = new XDeode ( 5 );
  5619. foreach ( $receiptList as $key => $value ) {
  5620. $receiptList[$key]['ridKey']=$XDeode->encode ( $value['rid'] );
  5621. $button2 = 0;
  5622. $receiptList [$key] ['Locate'] = $Locate;
  5623. $Locate ++;
  5624. $receiptList [$key] ['reviseDetail'] = array ();
  5625. if (! empty ( $value ['reviseDetail'] ))
  5626. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5627. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5628. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5629. $categoryDetil = $Lcategory->getOne ( array (
  5630. 'where' => 'cid=' . $value ['cid'],
  5631. 'asArray' => true
  5632. ) );
  5633. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5634. $executeList = json_decode ( $value ['executeCopy'], true );
  5635. $executeStaff = array ();
  5636. if (! empty ( $value ['executeStaff'] ))
  5637. $executeStaff = json_decode ( $value ['executeStaff'], true );
  5638. if (isset ( $executeList )) {
  5639. foreach ( $executeList as $op => $lo ) {
  5640. $executeList [$op] ['date'] = "";
  5641. $executeList [$op] ['opinion'] = "";
  5642. $executeList [$op] ['status'] = "";
  5643. foreach ( $executeStaff as $m => $u ) {
  5644. if ($lo [0] == $m) {
  5645. $executeList [$op] ['date'] = $u ['date'];
  5646. $executeList [$op] ['opinion'] = $u ['opinion'];
  5647. $executeList [$op] ['status'] = $u ['status'];
  5648. break;
  5649. }
  5650. }
  5651. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  5652. $button2 = 1;
  5653. $executeList [$op] ['status'] = 4;
  5654. }
  5655. }
  5656. }
  5657. // 检测编辑状态
  5658. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  5659. $verifyList ['staff'] = $value ['verifyBreakup'];
  5660. } else
  5661. $verifyList = $verify->getOne ( array (
  5662. 'where' => 'vid=' . $value ['verify'],
  5663. 'asArray' => true
  5664. ) );
  5665. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5666. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5667. Doo::loadModel ( 'role' );
  5668. $role = new role ();
  5669. if ($verifyList == NULL)
  5670. $verifyList = array ();
  5671. $flag = true;
  5672. $roleKey = 0;
  5673. $endStaffArray = array ();
  5674. $roleArrayCopy = array ();
  5675. foreach ( $verifyList as $k => $v ) {
  5676. // init verifyStaff
  5677. if ($v [1] == 'ROLE') {
  5678. if (! empty ( $verifyStaff )) {
  5679. $endStaffArray = end ( $verifyStaff );
  5680. // if ($v[0]==$endStaffArray['nextStaff']){
  5681. // $roleId=$v[0];
  5682. // }
  5683. }
  5684. $roleVerify = json_decode ( $v [3], true );
  5685. $roleKey = $k;
  5686. $roleArray = array ();
  5687. $rolename = $role->getOne ( array (
  5688. 'where' => 'rid=' . $v [0],
  5689. 'asArray' => true
  5690. ) );
  5691. foreach ( $roleVerify as $o => $p ) {
  5692. $staffID = explode ( '_', $p );
  5693. $staffInfo = $staff->getOne ( array (
  5694. 'where' => 'sid=' . $staffID [0],
  5695. 'asArray' => true
  5696. ) );
  5697. // print_r($staffID);
  5698. $exp = array (
  5699. 0 => $staffInfo ['sid'],
  5700. 1 => $staffID [1],
  5701. 2 => $staffInfo ['avatar'],
  5702. 'date' => '',
  5703. 'date' => '',
  5704. 'opinion' => '',
  5705. 'status' => '',
  5706. 'rolename' => $rolename ['name']
  5707. );
  5708. array_push ( $roleArray, $exp );
  5709. }
  5710. $roleArrayCopy [$v [0]] = $roleArray;
  5711. // $verifyList[$k]['roleArray']=$roleArray;
  5712. }
  5713. $verifyList [$k] ['date'] = "";
  5714. $verifyList [$k] ['opinion'] = "";
  5715. $verifyList [$k] ['status'] = "";
  5716. if (empty ( $verifyStaff )) {
  5717. $verifyList [$k] ['date'] = "";
  5718. $verifyList [$k] ['opinion'] = "";
  5719. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5720. $verifyList [$k] ['status'] = 4;
  5721. $flag = false;
  5722. }
  5723. } else {
  5724. foreach ( $verifyStaff as $m => $u ) {
  5725. if ($v [0] == $m) {
  5726. $verifyList [$k] ['date'] = $u ['date'];
  5727. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5728. $verifyList [$k] ['status'] = $u ['status'];
  5729. $flag = false;
  5730. break;
  5731. }
  5732. }
  5733. $endStaffArray = end ( $verifyStaff );
  5734. if (isset ( $endStaffArray ['ROLE'] )) {
  5735. } else {
  5736. // $endKey=key($verifyStaff);
  5737. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5738. // $button=4;
  5739. // $verifyList[$k]['status']=4;
  5740. // }
  5741. }
  5742. }
  5743. }
  5744. $rolename ['name'] = '';
  5745. if (! empty ( $roleId )) {
  5746. Doo::loadModel ( 'role' );
  5747. $role = new role ();
  5748. $rolename = $role->getOne ( array (
  5749. 'where' => 'rid=' . $roleId,
  5750. 'asArray' => true
  5751. ) );
  5752. }
  5753. if (! empty ( $verifyStaff ))
  5754. $endStaffArray = end ( $verifyStaff );
  5755. $KOP = false;
  5756. foreach ( $roleArrayCopy as $P => $A ) {
  5757. foreach ( $A as $MKI => $AVL ) {
  5758. if (! empty ( $verifyStaff )) {
  5759. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5760. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5761. $button = 4;
  5762. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5763. }
  5764. foreach ( $verifyStaff as $m => $u ) {
  5765. $AVLFK = $AVL [0] . '_R';
  5766. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5767. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5768. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5769. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5770. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5771. break;
  5772. }
  5773. }
  5774. } else {
  5775. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5776. $button = 4;
  5777. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5778. }
  5779. }
  5780. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5781. $KOP = true;
  5782. }
  5783. }
  5784. foreach ( $roleArrayCopy as $k => $v ) {
  5785. foreach ( $verifyList as $m => $n ) {
  5786. if ($n [0] == $k) {
  5787. array_splice ( $verifyList, $m, 1, $v );
  5788. }
  5789. }
  5790. }
  5791. $receiptList [$key] ['verifyList'] = $verifyList;
  5792. $receiptList [$key] ['executeList'] = $executeList;
  5793. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5794. 'where' => 'sid=' . $value ['staff'],
  5795. 'asArray' => true
  5796. ) );
  5797. $receiptList [$key] ['button2'] = $button2;
  5798. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5799. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5800. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5801. $receiptList [$key] ['relust'] = $relust;
  5802. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  5803. $receiptList [$key] ['amountABS'] = abs ( $value ['amount'] );
  5804. }
  5805. //执行人是否是最后一位
  5806. $executeCopy = json_decode ( $receiptList [0] ['executeCopy'], true );
  5807. $executeStaff = json_decode ( $receiptList [0] ['executeStaff'], true );
  5808. $executePrimary=count($executeCopy)-1;
  5809. $lastOne=true;
  5810. if($executePrimary!=count($executeStaff)){
  5811. $lastOne=false;
  5812. }
  5813. $data['lastOne']=$lastOne;
  5814. // 是否写入过流水
  5815. $accountType = 0;
  5816. if ($receiptList [0] ['Rtype'] == 0) {
  5817. $accountType = 3;
  5818. } elseif ($receiptList [0] ['Rtype'] == 1) {
  5819. if (!empty($receiptList [0]['accountItem']) )
  5820. $accountType = 2;
  5821. else
  5822. $accountType = 1;
  5823. } elseif ($receiptList [0] ['Rtype'] == 2) {
  5824. $accountType = 4;
  5825. } elseif ($receiptList [0] ['Rtype'] == 3) {
  5826. $accountType = 12;
  5827. }
  5828. Doo::loadModel ( 'wasteBook' );
  5829. $wasteBook = new wasteBook ();
  5830. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $receiptList [0] ['rid'] );
  5831. $data ['wbDetail'] = $wbDetail;
  5832. $wbDetailLoan=array();
  5833. if ($accountType==2){
  5834. $wbDetailLoan = $wasteBook->getWateBookByAD ( 1, $receiptList [0] ['rid'] );
  5835. }
  5836. $data ['wbDetailLoan'] = $wbDetailLoan;
  5837. $data['inputDate']=date ( "Y-m-d H:i:s" );
  5838. //print_r($wbDetail);
  5839. $data ['receiptList'] = $receiptList;
  5840. $data ['memu'] = "receipt";
  5841. $data ['staff'] = $this->staff;
  5842. $data ['receiptMemu'] = 'implement';
  5843. $data ['verifyId'] = $this->verifyId;
  5844. $data ['executeId'] = $this->executeId;
  5845. if ($Rtype=="loan"){
  5846. $this->render ( "/receipt/receiptImplementLoan", $data );
  5847. }elseif($Rtype=="receipt"){
  5848. $this->render ( "/receipt/receiptImplement", $data );
  5849. }elseif($Rtype=="public"){
  5850. $this->render ( "/receipt/receiptImplementPublic", $data );
  5851. }else{
  5852. //$this->render ( "/admin/implement", $data );
  5853. }
  5854. }
  5855. function implementDo() {
  5856. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  5857. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  5858. // $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  5859. // $accountBank = $this->get_args ( 'accountBank' ) ? $this->get_args ( 'accountBank' ) : "";
  5860. // $ab = '';
  5861. // if ($accountBank == 'CGBDeposit')
  5862. // $ab = '纵横广发';
  5863. // elseif ($accountBank == 'ICBCDeposit')
  5864. // $ab = '纵横工行';
  5865. // elseif ($accountBank == 'HUADeposit')
  5866. // $ab = '华润银行';
  5867. // elseif ($accountBank == 'PersonalDeposit')
  5868. // $ab = '个人广发';
  5869. // if (empty ( $ab ))
  5870. // die ( 'illegal request--22' );
  5871. if (! empty ( $rid )) {
  5872. Doo::loadModel ( 'receipt' );
  5873. $receipt = new receipt ();
  5874. Doo::loadClass ( 'XDeode' );
  5875. $XDeode = new XDeode ( 5 );
  5876. $rid=$XDeode->decode($rid);
  5877. if (!is_numeric($rid)){
  5878. die;
  5879. }
  5880. // $rinfo = $receipt->getOne ( array (
  5881. // 'where' => 'rid=' . $rid,
  5882. // 'asArray' => true
  5883. // ) );
  5884. $rinfo = $receipt->getReceiptByRid ( $rid );
  5885. // $accountType = '';
  5886. // if ($rinfo ['Rtype'] == 1) {
  5887. // if ($rinfo ['loanRid'] != 0)//判断有问题
  5888. // $accountType = 2;
  5889. // else
  5890. // $accountType = 1;
  5891. // } elseif ($rinfo ['Rtype'] == 2) {
  5892. // $accountType = 4;
  5893. // } elseif ($rinfo ['Rtype'] == 0)
  5894. // $accountType = 3;
  5895. // if (empty ( $accountType ))
  5896. // die ( 'illegal request' );
  5897. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  5898. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  5899. if (empty ( $executeStaff )) {
  5900. $executeStaff = array (
  5901. $this->staff [0] ['sid'] => array (
  5902. 'date' => date ( 'Y-m-d' ),
  5903. 'opinion' => $implementOpinions,
  5904. 'status' => 1
  5905. )
  5906. );
  5907. } else {
  5908. $executeStaff [$this->staff [0] ['sid']] = array (
  5909. 'date' => date ( 'Y-m-d' ),
  5910. 'opinion' => $implementOpinions,
  5911. 'status' => 1
  5912. );
  5913. }
  5914. if (count ( $executeStaff ) == count ( $executeCopy )) {
  5915. $receipt->executeStaff = json_encode ( $executeStaff );
  5916. $receipt->status = 8;
  5917. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  5918. $receipt->status = 9;
  5919. if ($rinfo ['status'] == 6) {
  5920. $receipt->loanDate = date ( "Y-m-d" );
  5921. }
  5922. $receipt->executeDate = date ( "Y-m-d" );
  5923. } else {
  5924. $receipt->executeStaff = json_encode ( $executeStaff );
  5925. }
  5926. //$receipt->amount = $amount;
  5927. $receipt->update ( array (
  5928. 'where' => 'rid=' . $rid
  5929. ) );
  5930. // 公司流水记录
  5931. // Doo::loadModel ( 'wasteBook' );
  5932. // $wasteBook = new wasteBook ();
  5933. // $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountType, $rid );
  5934. // // 银行
  5935. // if (empty ( $abDetail ) && ! empty ( $amount )) {
  5936. // $item = array (
  5937. // 'dataID' => $rid,
  5938. // 'expensesType' => 2,
  5939. // 'accountType' => $accountType,
  5940. // 'accountPriceShow' => $amount,
  5941. // 'accountPrice' => - $amount,
  5942. // 'accountBank' => $accountBank,
  5943. // 'category' => $rinfo ['category'] [0] ['title'],
  5944. // 'cid' => $rinfo ['category'] [0] ['cid'],
  5945. // 'name' => $rinfo ['staffDetail'] ['username'],
  5946. // 'sid' => $rinfo ['staffDetail'] ['sid'],
  5947. // 'inputDate' => date ( "Y-m-d H:i:s" )
  5948. // );
  5949. // $wasteBook->setAccountBookStatistics ( $item );
  5950. // }
  5951. }
  5952. //$ridKey = $XDeode->encode ( $rid );
  5953. return "/hisImplement";
  5954. // return "/implement/" . $ridKey . ".html";
  5955. }
  5956. function receiptburEdi() {
  5957. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5958. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5959. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5960. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5961. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5962. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5963. if (empty ( $status ))
  5964. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5965. $vidList = array ();
  5966. $button = 0;
  5967. Doo::loadModel ( 'verify' );
  5968. Doo::loadModel ( 'receipt' );
  5969. Doo::loadModel ( 'staff' );
  5970. $staff = new staff ();
  5971. $receipt = new receipt ();
  5972. $verify = new verify ();
  5973. Doo::loadModel ( 'L_category' );
  5974. $Lcategory = new L_category ();
  5975. Doo::loadModel ( 'enclosur' );
  5976. $enclosur = new enclosur ();
  5977. Doo::loadModel ( 'loanReceipt' );
  5978. $loanReceipt = new loanReceipt ();
  5979. // user verify ID
  5980. $verifyDetail = $verify->find ( array (
  5981. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5982. 'asArray' => true
  5983. ) );
  5984. foreach ( $verifyDetail as $key => $value ) {
  5985. array_push ( $vidList, $value ['vid'] );
  5986. }
  5987. $vid = implode ( ",", $vidList );
  5988. if (empty ( $verifyDetail ))
  5989. $vid = 0;
  5990. $categoryList = $Lcategory->find ( array (
  5991. 'asArray' => true
  5992. ) );
  5993. $staffList = $staff->find ( array (
  5994. 'where' => 'cid=' . $cid,
  5995. 'asArray' => true
  5996. ) );
  5997. $ap = "";
  5998. if ($status == 4) {
  5999. $ap = 4;
  6000. $status = 2;
  6001. }
  6002. // get Receipt By verifyID status 2
  6003. $receiptList = $receipt->find ( array (
  6004. 'where' => 'rid =' . $rid . ' and status=2',
  6005. 'desc' => 'rid',
  6006. 'asArray' => true
  6007. ) );
  6008. if (empty ( $receiptList )) {
  6009. die ( 'illegal request' );
  6010. }
  6011. $loanList = $loanReceipt->find ( array (
  6012. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  6013. 'desc' => 'rid',
  6014. 'asArray' => true
  6015. ) );
  6016. $data ['explanation'] = '';
  6017. if (! empty ( $loanList ))
  6018. $data ['explanation'] = $loanList [0] ['explanation'];
  6019. $Locate = 0;
  6020. $roleId = 0;
  6021. $button = 0;
  6022. foreach ( $loanList as $key => $value ) {
  6023. $loanList [$key] ['Locate'] = $Locate;
  6024. $Locate ++;
  6025. $loanList [$key] ['reviseDetail'] = array ();
  6026. if (! empty ( $value ['reviseDetail'] ))
  6027. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6028. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6029. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6030. $categoryDetil = $Lcategory->getOne ( array (
  6031. 'where' => 'cid=' . $value ['cid'],
  6032. 'asArray' => true
  6033. ) );
  6034. $loanList [$key] ['category'] = $categoryDetil ['title'];
  6035. // 检测编辑状态
  6036. $verifyList = $verify->getOne ( array (
  6037. 'where' => 'vid=' . $value ['verify'],
  6038. 'asArray' => true
  6039. ) );
  6040. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6041. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6042. Doo::loadModel ( 'role' );
  6043. $role = new role ();
  6044. $flag = true;
  6045. $roleKey = 0;
  6046. $endStaffArray = array ();
  6047. $roleArrayCopy = array ();
  6048. foreach ( $verifyList as $k => $v ) {
  6049. // init verifyStaff
  6050. if ($v [1] == 'ROLE') {
  6051. if (! empty ( $verifyStaff )) {
  6052. $endStaffArray = end ( $verifyStaff );
  6053. }
  6054. $roleVerify = json_decode ( $v [3], true );
  6055. $roleKey = $k;
  6056. $roleArray = array ();
  6057. $rolename = $role->getOne ( array (
  6058. 'where' => 'rid=' . $v [0],
  6059. 'asArray' => true
  6060. ) );
  6061. foreach ( $roleVerify as $o => $p ) {
  6062. $staffID = explode ( '_', $p );
  6063. $staffInfo = $staff->getOne ( array (
  6064. 'where' => 'sid=' . $staffID [0],
  6065. 'asArray' => true
  6066. ) );
  6067. // print_r($staffID);
  6068. $exp = array (
  6069. 0 => $staffInfo ['sid'],
  6070. 1 => $staffID [1],
  6071. 2 => $staffInfo ['avatar'],
  6072. 'date' => '',
  6073. 'date' => '',
  6074. 'opinion' => '',
  6075. 'status' => '',
  6076. 'rolename' => $rolename ['name']
  6077. );
  6078. array_push ( $roleArray, $exp );
  6079. }
  6080. $roleArrayCopy [$v [0]] = $roleArray;
  6081. // $verifyList[$k]['roleArray']=$roleArray;
  6082. }
  6083. $verifyList [$k] ['date'] = "";
  6084. $verifyList [$k] ['opinion'] = "";
  6085. $verifyList [$k] ['status'] = "";
  6086. if (empty ( $verifyStaff )) {
  6087. $verifyList [$k] ['date'] = "";
  6088. $verifyList [$k] ['opinion'] = "";
  6089. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6090. $verifyList [$k] ['status'] = 4;
  6091. $flag = false;
  6092. }
  6093. } else {
  6094. foreach ( $verifyStaff as $m => $u ) {
  6095. if ($v [0] == $m) {
  6096. $verifyList [$k] ['date'] = $u ['date'];
  6097. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6098. $verifyList [$k] ['status'] = $u ['status'];
  6099. $flag = false;
  6100. break;
  6101. }
  6102. }
  6103. $endStaffArray = end ( $verifyStaff );
  6104. if (isset ( $endStaffArray ['ROLE'] )) {
  6105. } else {
  6106. }
  6107. }
  6108. }
  6109. $rolename ['name'] = '';
  6110. if (! empty ( $roleId )) {
  6111. Doo::loadModel ( 'role' );
  6112. $role = new role ();
  6113. $rolename = $role->getOne ( array (
  6114. 'where' => 'rid=' . $roleId,
  6115. 'asArray' => true
  6116. ) );
  6117. }
  6118. if (! empty ( $verifyStaff ))
  6119. $endStaffArray = end ( $verifyStaff );
  6120. $KOP = false;
  6121. foreach ( $roleArrayCopy as $P => $A ) {
  6122. foreach ( $A as $MKI => $AVL ) {
  6123. if (! empty ( $verifyStaff )) {
  6124. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6125. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6126. $button = 4;
  6127. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6128. }
  6129. foreach ( $verifyStaff as $m => $u ) {
  6130. $AVLFK = $AVL [0] . '_R';
  6131. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6132. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6133. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6134. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6135. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6136. break;
  6137. }
  6138. }
  6139. } else {
  6140. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6141. $button = 4;
  6142. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6143. }
  6144. }
  6145. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6146. $KOP = true;
  6147. }
  6148. }
  6149. foreach ( $roleArrayCopy as $k => $v ) {
  6150. foreach ( $verifyList as $m => $n ) {
  6151. if ($n [0] == $k) {
  6152. array_splice ( $verifyList, $m, 1, $v );
  6153. }
  6154. }
  6155. }
  6156. $loanList [$key] ['verifyList'] = $verifyList;
  6157. }
  6158. $htmlLoan = '';
  6159. $data ['loanReceiptDate'] = '';
  6160. if (isset ( $loanList [0] )) {
  6161. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  6162. if ($value ['status'] == 1)
  6163. $htmlLoan .= '<li class="done" >';
  6164. elseif ($value ['status'] == 3)
  6165. $htmlLoan .= '<li class="undone" >';
  6166. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  6167. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  6168. if (isset ( $value ['rolename'] ))
  6169. $htmlLoan .= $value ['rolename'];
  6170. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  6171. }
  6172. $data ['loanDate'] = $loanList [0] ['date'];
  6173. } else {
  6174. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  6175. }
  6176. $data ['htmlLoan'] = $htmlLoan;
  6177. // $data ['LoanReceipt']=$loanList[0];
  6178. // print_r($loanList);
  6179. $Locate = 0;
  6180. $roleId = 0;
  6181. $button = 0;
  6182. if ($ap == 4)
  6183. $status = 4;
  6184. Doo::loadClass ( 'XDeode' );
  6185. $XDeode = new XDeode ( 5 );
  6186. foreach ( $receiptList as $key => $value ) {
  6187. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  6188. $receiptList [$key] ['Locate'] = $Locate;
  6189. $Locate ++;
  6190. $receiptList [$key] ['reviseDetail'] = array ();
  6191. // 调整金额 代码调整
  6192. if (! empty ( $value ['reviseDetail'] )) {
  6193. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  6194. foreach ( $reviseDetail as $ry => $re ) {
  6195. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  6196. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  6197. }
  6198. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  6199. // print_r($reviseDetail);
  6200. }
  6201. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6202. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6203. $categoryDetil = $Lcategory->getOne ( array (
  6204. 'where' => 'cid=' . $value ['cid'],
  6205. 'asArray' => true
  6206. ) );
  6207. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6208. // 检测编辑状态
  6209. $verifyList = $verify->getOne ( array (
  6210. 'where' => 'vid=' . $value ['verify'],
  6211. 'asArray' => true
  6212. ) );
  6213. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6214. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6215. Doo::loadModel ( 'role' );
  6216. $role = new role ();
  6217. // print_r($verifyList);
  6218. $flag = true;
  6219. $roleKey = 0;
  6220. $endStaffArray = array ();
  6221. $roleArrayCopy = array ();
  6222. foreach ( $verifyList as $k => $v ) {
  6223. // init verifyStaff
  6224. if ($v [1] == 'ROLE') {
  6225. if (! empty ( $verifyStaff )) {
  6226. $endStaffArray = end ( $verifyStaff );
  6227. if ($v [0] == $endStaffArray ['nextStaff']) {
  6228. $roleId = $v [0];
  6229. }
  6230. }
  6231. $roleVerify = json_decode ( $v [3], true );
  6232. $roleKey = $k;
  6233. $roleArray = array ();
  6234. $rolename = $role->getOne ( array (
  6235. 'where' => 'rid=' . $v [0],
  6236. 'asArray' => true
  6237. ) );
  6238. foreach ( $roleVerify as $o => $p ) {
  6239. $staffID = explode ( '_', $p );
  6240. $staffInfo = $staff->getOne ( array (
  6241. 'where' => 'sid=' . $staffID [0],
  6242. 'asArray' => true
  6243. ) );
  6244. // print_r($staffID);
  6245. $exp = array (
  6246. 0 => $staffInfo ['sid'],
  6247. 1 => $staffID [1],
  6248. 2 => $staffInfo ['avatar'],
  6249. 'date' => '',
  6250. 'date' => '',
  6251. 'opinion' => '',
  6252. 'status' => '',
  6253. 'rolename' => $rolename ['name']
  6254. );
  6255. array_push ( $roleArray, $exp );
  6256. }
  6257. $roleArrayCopy [$v [0]] = $roleArray;
  6258. // $verifyList[$k]['roleArray']=$roleArray;
  6259. }
  6260. // print_r($roleArray);
  6261. $verifyList [$k] ['date'] = "";
  6262. $verifyList [$k] ['opinion'] = "";
  6263. $verifyList [$k] ['status'] = "";
  6264. if (empty ( $verifyStaff )) {
  6265. $verifyList [$k] ['date'] = "";
  6266. $verifyList [$k] ['opinion'] = "";
  6267. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6268. $verifyList [$k] ['status'] = 4;
  6269. $button = 4;
  6270. $flag = false;
  6271. }
  6272. } else {
  6273. foreach ( $verifyStaff as $m => $u ) {
  6274. if ($v [0] == $m) {
  6275. $verifyList [$k] ['date'] = $u ['date'];
  6276. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6277. $verifyList [$k] ['status'] = $u ['status'];
  6278. $flag = false;
  6279. break;
  6280. }
  6281. }
  6282. $endStaffArray = end ( $verifyStaff );
  6283. if (isset ( $endStaffArray ['ROLE'] )) {
  6284. } else {
  6285. $endKey = key ( $verifyStaff );
  6286. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6287. $button = 4;
  6288. $verifyList [$k] ['status'] = 4;
  6289. }
  6290. }
  6291. }
  6292. }
  6293. $rolename ['name'] = '';
  6294. if (! empty ( $roleId )) {
  6295. Doo::loadModel ( 'role' );
  6296. $role = new role ();
  6297. $rolename = $role->getOne ( array (
  6298. 'where' => 'rid=' . $roleId,
  6299. 'asArray' => true
  6300. ) );
  6301. }
  6302. if (! empty ( $verifyStaff ))
  6303. $endStaffArray = end ( $verifyStaff );
  6304. $KOP = false;
  6305. foreach ( $roleArrayCopy as $P => $A ) {
  6306. foreach ( $A as $MKI => $AVL ) {
  6307. if (! empty ( $verifyStaff )) {
  6308. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6309. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6310. $button = 4;
  6311. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6312. }
  6313. foreach ( $verifyStaff as $m => $u ) {
  6314. $AVLFK = $AVL [0] . '_R';
  6315. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6316. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6317. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6318. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6319. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6320. break;
  6321. }
  6322. }
  6323. } else {
  6324. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6325. $button = 4;
  6326. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6327. }
  6328. }
  6329. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6330. $KOP = true;
  6331. }
  6332. }
  6333. foreach ( $roleArrayCopy as $k => $v ) {
  6334. foreach ( $verifyList as $m => $n ) {
  6335. if ($n [0] == $k) {
  6336. array_splice ( $verifyList, $m, 1, $v );
  6337. }
  6338. }
  6339. }
  6340. // print_r($verifyList);
  6341. $receiptList [$key] ['verifyList'] = $verifyList;
  6342. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6343. 'where' => 'sid=' . $value ['staff'],
  6344. 'asArray' => true
  6345. ) );
  6346. $receiptList [$key] ['button'] = $button;
  6347. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  6348. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  6349. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  6350. $receiptList [$key] ['relust'] = $relust;
  6351. $receiptList [$key] ['relustABS'] = abs ( $relust );
  6352. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  6353. }
  6354. //print_r($receiptList);die;
  6355. // $data['verifyDetail']=$verifyDetail;
  6356. $mothHtml = "";
  6357. for($i = 1; $i <= 12; $i ++) {
  6358. if ($month == $i)
  6359. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6360. else
  6361. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6362. }
  6363. // 获取审批日志
  6364. Doo::loadModel ( 'receiptLog' );
  6365. $receiptLog = new receiptLog ();
  6366. $rlList = array ();
  6367. $rlInfo = $receiptLog->getOne ( array (
  6368. 'where' => 'rid=' . $rid . ' and status=4',
  6369. 'asArray' => true
  6370. ) );
  6371. $tijdate = $receiptLog->getOne ( array (
  6372. 'where' => 'rid=' . $rid . ' and status=2',
  6373. 'asc' => 'rlid',
  6374. 'asArray' => true
  6375. ) );
  6376. if (! empty ( $rlInfo )) {
  6377. $rlList = $receiptLog->find ( array (
  6378. 'where' => 'rid=' . $rid,
  6379. 'asc' => 'rlid',
  6380. 'asArray' => true
  6381. ) );
  6382. }
  6383. // echo $rid;
  6384. // print_r($receiptList);
  6385. $receiptList [0] ['rlList'] = $rlList;
  6386. // print_r($receiptList);
  6387. $enclosurList = $enclosur->find ( array (
  6388. 'where' => 'rid=' . $rid,
  6389. 'asArray' => true
  6390. ) );
  6391. $enclosurHtml = '';
  6392. foreach ( $enclosurList as $value ) {
  6393. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6394. }
  6395. $data ['enclosurHtml'] = $enclosurHtml;
  6396. $data ['rolename'] = $rolename ['name'];
  6397. $data ['mothHtml'] = $mothHtml;
  6398. // print_r($receiptList);
  6399. $data ['rid'] = $rid;
  6400. $data ['tijdate'] = $tijdate ['date'];
  6401. $data ['receiptList'] = $receiptList;
  6402. $data ['receiptApprovalCount'] = count ( $receiptList );
  6403. $data ['status'] = $status;
  6404. $data ['year'] = $year;
  6405. $data ['categoryList'] = $categoryList;
  6406. $data ['staffList'] = $staffList;
  6407. $data ['cid'] = $cid;
  6408. $data ['sid'] = $sid;
  6409. $data ['ap'] = $ap;
  6410. $data ['memu'] = "receipt";
  6411. $data ['staff'] = $this->staff;
  6412. $data ['receiptMemu'] = 'approvalExpenses';
  6413. $data ['verifyId'] = $this->verifyId;
  6414. $data ['executeId'] = $this->executeId;
  6415. $this->render ( "/admin/receiptburEdi", $data );
  6416. }
  6417. function hisImplement() {
  6418. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  6419. if (empty ( $item ))
  6420. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  6421. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  6422. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6423. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  6424. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6425. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  6426. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  6427. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  6428. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  6429. Doo::loadClass ( 'XDeode' );
  6430. $XDeode = new XDeode ( 5 );
  6431. Doo::loadModel ( 'receipt' );
  6432. $receipt = new receipt ();
  6433. Doo::loadModel ( 'L_category' );
  6434. $Lcategory = new L_category ();
  6435. Doo::loadModel ( 'verify' );
  6436. Doo::loadModel ( 'statistics' );
  6437. $statistics = new statistics ();
  6438. $verify = new verify ();
  6439. Doo::loadModel ( 'staff' );
  6440. $staff = new staff ();
  6441. Doo::loadClass ( 'XDeode' );
  6442. $XDeode = new XDeode ( 5 );
  6443. $XDeode7 = new XDeode ( 7 );
  6444. $cid = $XDeode->decode ( $cidKey );
  6445. $condition = "";
  6446. if ($item == "expenses")
  6447. $condition = " and Rtype=1 ";
  6448. elseif ($item == "receipts")
  6449. $condition = " and Rtype=0 ";
  6450. elseif ($item == "remits")
  6451. $condition = " and Rtype=2 ";
  6452. elseif($item == "train")
  6453. $condition = " and Rtype=3 ";
  6454. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  6455. $sopString = $cidString = "";
  6456. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  6457. if (empty ( $rdate ))
  6458. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  6459. else
  6460. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  6461. if ($status == 'pendImplement') {
  6462. $condition .= ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  6463. } elseif ($status == 'alerpts') {
  6464. $statusCon = '(status=8 or status=9 )';
  6465. if (empty ( $rdate ))
  6466. $dateCondition .= " and Year(date) =" . $year;
  6467. else
  6468. $dateCondition .= " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  6469. }
  6470. if ($sop != 'SOP')
  6471. $sopString = " and staff=" . $sop;
  6472. if ($cidKey != 'ALL')
  6473. $cidString = " and cid=" . $cid;
  6474. //汇款信息需要提取出来
  6475. if(!empty($receiptOrder)){
  6476. $receiptList = $receipt->find ( array (
  6477. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  6478. 'desc' => 'rid',
  6479. 'asArray' => true
  6480. ) );
  6481. // 员工筛选
  6482. $receiptList2 = $receipt->find ( array (
  6483. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  6484. 'desc' => 'rid',
  6485. 'asArray' => true
  6486. ) );
  6487. }else{
  6488. $receiptList = $receipt->find ( array (
  6489. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  6490. 'desc' => 'rid',
  6491. 'asArray' => true
  6492. ) );
  6493. // 员工筛选
  6494. $receiptList2 = $receipt->find ( array (
  6495. 'where' => $statusCon . $condition . $dateCondition,
  6496. 'desc' => 'rid',
  6497. 'asArray' => true
  6498. ) );
  6499. }
  6500. $sopStaff = array ();
  6501. foreach ( $receiptList2 as $key => $value ) {
  6502. $staffDetail = $staff->getOne ( array (
  6503. 'select' => 'username',
  6504. 'where' => 'sid=' . $value ['staff'],
  6505. 'asArray' => true
  6506. ) );
  6507. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  6508. }
  6509. // 办事处筛选
  6510. $categoryScreen = array ();
  6511. $categorList = $Lcategory->getCategory ();
  6512. foreach ( $receiptList2 as $key => $value ) {
  6513. foreach ( $categorList as $k => $v ) {
  6514. if ($value ['cid'] == $v ['cid']) {
  6515. $categoryScreen [$v ['cidKey']] = $v ['title'];
  6516. break;
  6517. }
  6518. }
  6519. }
  6520. $categoryScreenHtml = "";
  6521. foreach ( $categoryScreen as $key => $value ) {
  6522. if ($cidKey == $key)
  6523. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  6524. else
  6525. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  6526. }
  6527. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  6528. $data ['cidKey'] = $cidKey;
  6529. $Locate = 0;
  6530. $roleId = 0;
  6531. $button = 0;
  6532. $staffBatchNumber = 100001;
  6533. $remittanceList = array ();
  6534. foreach ( $receiptList as $key => $value ) {
  6535. $receiptList [$key] ['ridKey7'] = $XDeode7->encode ( $value ['rid'] );
  6536. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  6537. $receiptList [$key] ['Texe'] = 'false';
  6538. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  6539. $receiptList [$key] ['Texe'] = 'true';
  6540. }
  6541. $receiptList [$key] ['TRexe'] = 'true';
  6542. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  6543. $receiptList [$key] ['TRexe'] = 'false';
  6544. }
  6545. $receiptList [$key] ['Locate'] = $Locate;
  6546. $Locate ++;
  6547. $receiptList [$key] ['reviseDetail'] = array ();
  6548. if (! empty ( $value ['reviseDetail'] ))
  6549. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6550. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6551. $categoryDetil = $Lcategory->getOne ( array (
  6552. 'where' => 'cid=' . $value ['cid'],
  6553. 'asArray' => true
  6554. ) );
  6555. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6556. // 检测编辑状态
  6557. $verifyList = $verify->getOne ( array (
  6558. 'where' => 'vid=' . $value ['verify'],
  6559. 'asArray' => true
  6560. ) );
  6561. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6562. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6563. Doo::loadModel ( 'role' );
  6564. $role = new role ();
  6565. $flag = true;
  6566. $roleKey = 0;
  6567. $endStaffArray = array ();
  6568. $roleArrayCopy = array ();
  6569. foreach ( $verifyList as $k => $v ) {
  6570. // init verifyStaff
  6571. if ($v [1] == 'ROLE') {
  6572. if (! empty ( $verifyStaff )) {
  6573. $endStaffArray = end ( $verifyStaff );
  6574. }
  6575. $roleVerify = json_decode ( $v [3], true );
  6576. $roleKey = $k;
  6577. $roleArray = array ();
  6578. $rolename = $role->getOne ( array (
  6579. 'where' => 'rid=' . $v [0],
  6580. 'asArray' => true
  6581. ) );
  6582. foreach ( $roleVerify as $o => $p ) {
  6583. $staffID = explode ( '_', $p );
  6584. $staffInfo = $staff->getOne ( array (
  6585. 'where' => 'sid=' . $staffID [0],
  6586. 'asArray' => true
  6587. ) );
  6588. $exp = array (
  6589. 0 => $staffInfo ['sid'],
  6590. 1 => $staffID [1],
  6591. 2 => $staffInfo ['avatar'],
  6592. 'date' => '',
  6593. 'date' => '',
  6594. 'opinion' => '',
  6595. 'status' => '',
  6596. 'rolename' => $rolename ['name']
  6597. );
  6598. array_push ( $roleArray, $exp );
  6599. }
  6600. $roleArrayCopy [$v [0]] = $roleArray;
  6601. }
  6602. $verifyList [$k] ['date'] = "";
  6603. $verifyList [$k] ['opinion'] = "";
  6604. $verifyList [$k] ['status'] = "";
  6605. if (empty ( $verifyStaff )) {
  6606. $verifyList [$k] ['date'] = "";
  6607. $verifyList [$k] ['opinion'] = "";
  6608. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6609. $verifyList [$k] ['status'] = 4;
  6610. $flag = false;
  6611. }
  6612. } else {
  6613. foreach ( $verifyStaff as $m => $u ) {
  6614. if ($v [0] == $m) {
  6615. $verifyList [$k] ['date'] = $u ['date'];
  6616. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6617. $verifyList [$k] ['status'] = $u ['status'];
  6618. $flag = false;
  6619. break;
  6620. }
  6621. }
  6622. $endStaffArray = end ( $verifyStaff );
  6623. }
  6624. }
  6625. $rolename ['name'] = '';
  6626. if (! empty ( $roleId )) {
  6627. Doo::loadModel ( 'role' );
  6628. $role = new role ();
  6629. $rolename = $role->getOne ( array (
  6630. 'where' => 'rid=' . $roleId,
  6631. 'asArray' => true
  6632. ) );
  6633. }
  6634. if (! empty ( $verifyStaff ))
  6635. $endStaffArray = end ( $verifyStaff );
  6636. $KOP = false;
  6637. foreach ( $roleArrayCopy as $P => $A ) {
  6638. foreach ( $A as $MKI => $AVL ) {
  6639. if (! empty ( $verifyStaff )) {
  6640. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6641. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6642. $button = 4;
  6643. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6644. }
  6645. foreach ( $verifyStaff as $m => $u ) {
  6646. $AVLFK = $AVL [0] . '_R';
  6647. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6648. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6649. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6650. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6651. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6652. break;
  6653. }
  6654. }
  6655. } else {
  6656. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6657. $button = 4;
  6658. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6659. }
  6660. }
  6661. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6662. $KOP = true;
  6663. }
  6664. }
  6665. foreach ( $roleArrayCopy as $k => $v ) {
  6666. foreach ( $verifyList as $m => $n ) {
  6667. if ($n [0] == $k) {
  6668. array_splice ( $verifyList, $m, 1, $v );
  6669. }
  6670. }
  6671. }
  6672. $receiptList [$key] ['verifyList'] = $verifyList;
  6673. $staffDetail = $staff->getOne ( array (
  6674. 'where' => 'sid=' . $value ['staff'],
  6675. 'asArray' => true
  6676. ) );
  6677. $receiptList [$key] ['staffDetail'] = $staffDetail;
  6678. $receiptList [$key] ['button'] = $button;
  6679. if ($value['Rtype']==1){
  6680. $receiptList [$key] ['relust'] = $value['sum']-$value['loanSum'];
  6681. $receiptList [$key] ['relustABS'] = abs($receiptList [$key] ['relust']);
  6682. }elseif($value['Rtype']==3){
  6683. // 收入合计
  6684. Doo::loadModel ( 'invoiceTraining' );
  6685. $invoiceTraining = new invoiceTraining ();
  6686. $invoiceTrainingDetail = array (
  6687. 'invoiceArriveAmount' => '0.00',
  6688. 'RIAmount' => '0.00',
  6689. 'invoiceTotalAmount' => '0.00',
  6690. 'invoiceCompanyAmount' => '0.00',
  6691. 'invoiceArriveAmountM'=>'0.00',
  6692. 'invoiceCompanyAmountM'=>'0.00'
  6693. );
  6694. if ($value ['invoiceTrainId'] != 0) {
  6695. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $value['invoiceTrainId'] );
  6696. }
  6697. $invoiceArriveAmount = $RIAmount = 0;
  6698. if (! empty ( $invoiceTrainingDetail )) {
  6699. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  6700. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  6701. }
  6702. // 备用金
  6703. $sum = 0;
  6704. if (! empty ( $value ['trainLoanRid'] )) {
  6705. $receiptLoanList = $receipt->getReceiptInRid ( $value ['trainLoanRid'] );
  6706. foreach ($receiptLoanList as $kll=>$vll){
  6707. $sum+=$vll['sum'];
  6708. }
  6709. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $value ['trainLoanRid'] );
  6710. // $sum = $receiptLoanDetailBak ['sum'];
  6711. }
  6712. // 支出项金额详情
  6713. // 项目金额合计
  6714. Doo::loadModel ( 'RItem' );
  6715. $RItem = new RItem ();
  6716. Doo::loadModel ( 'accountItem' );
  6717. $accountItem = new accountItem ();
  6718. // 讲师获得
  6719. Doo::loadModel ( 'RILecturer' );
  6720. $RILecturer = new RILecturer ();
  6721. $RItemList = $RItem->getRItemByRid ( $value['rid'] );
  6722. $RILecturerList = $RILecturer->getRILecturerByRid ( $value['rid'] );
  6723. // 支出项金额详情
  6724. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  6725. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  6726. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  6727. $receiptList [$key] ['payment'] =$payment;
  6728. $receiptList [$key] ['paymentABS'] =sprintf("%.2f",abs($payment));
  6729. }
  6730. // 设置导出汇款execl
  6731. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  6732. $remittanceDetail = array (
  6733. $staffBatchNumber,
  6734. $value ['remittanceName'],
  6735. $value ['bankNumber'],
  6736. $value ['bankName'],
  6737. $value ['remittanceBankType'],
  6738. $value ['coupletNumber'],
  6739. $value ['sum']
  6740. );
  6741. array_push ( $remittanceList, $remittanceDetail );
  6742. $staffBatchNumber ++;
  6743. }
  6744. }
  6745. $data ['remittanceList'] = json_encode ( $remittanceList );
  6746. // print_r($receiptList);
  6747. $mothHtml = "";
  6748. for($i = 1; $i <= 12; $i ++) {
  6749. if ($moth == $i)
  6750. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6751. else
  6752. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6753. }
  6754. $dayHtml = "";
  6755. if ($day != "DAY" || $moth != "MONTH") {
  6756. for($i = 1; $i <= 31; $i ++) {
  6757. if ($day == $i)
  6758. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6759. else
  6760. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6761. }
  6762. }
  6763. $sopHtml = "";
  6764. foreach ( $sopStaff as $key => $value ) {
  6765. if ($sop == $key)
  6766. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  6767. else
  6768. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  6769. }
  6770. $data ['status'] = $status;
  6771. $data ['rdate'] = $rdate;
  6772. $data ['sopHtml'] = $sopHtml;
  6773. $data ['dayHtml'] = $dayHtml;
  6774. $data ['mothHtml'] = $mothHtml;
  6775. $data ['receiptList'] = $receiptList;
  6776. $data ['memu'] = "receipt";
  6777. $data ['staff'] = $this->staff;
  6778. $data ['receiptMemu'] = 'implement';
  6779. $data ['verifyId'] = $this->verifyId;
  6780. $data ['executeId'] = $this->executeId;
  6781. $data ['item'] = $item;
  6782. $data ['year'] = $year;
  6783. $data ['moth'] = $moth;
  6784. $data['receiptOrder']=$receiptOrder;
  6785. $data ['day'] = $day;
  6786. $data ['sop'] = $sop;
  6787. $this->render ( "/admin/hisImplement", $data );
  6788. }
  6789. /**
  6790. * 导出汇款信息的exelc
  6791. */
  6792. function exportRemittance() {
  6793. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  6794. if (empty ( $remittanceInfo ))
  6795. die ( 'illegal request' );
  6796. $title = array (
  6797. '员工编号',
  6798. '姓名',
  6799. '员工账号',
  6800. '员工账户开户行',
  6801. '转账类型',
  6802. '联行号',
  6803. '金额'
  6804. );
  6805. $data = json_decode ( $remittanceInfo, true );
  6806. if (empty ( $data ))
  6807. die ( 'illegal request' );
  6808. Doo::loadClass ( 'receipt.func' );
  6809. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  6810. header ( 'Content-Type:text/html;charset=utf-8' );
  6811. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  6812. }
  6813. function ajaxExamine() {
  6814. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6815. Doo::loadModel ( 'receipt' );
  6816. $receipt = new receipt ();
  6817. if (! empty ( $rid )) {
  6818. $rLRes = $receipt->find ( array (
  6819. '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,
  6820. 'asArray' => true
  6821. ) );
  6822. if(!empty($rLRes)){
  6823. Doo::loadClass ( 'XDeode' );
  6824. $XDeode = new XDeode ( 7 );
  6825. $rLRes [0]['ridKey'] = $XDeode->encode( $rLRes [0]['rid'] );
  6826. echo json_encode ( array (
  6827. 'status' => 1,
  6828. 'receipt' => $rLRes [0]
  6829. ) );
  6830. die ();
  6831. }else{
  6832. echo json_encode ( array (
  6833. 'status' => 1,
  6834. 'receipt' => array ()
  6835. ) );
  6836. die ();
  6837. }
  6838. }
  6839. echo json_encode ( array (
  6840. 'status' => 0,
  6841. 'receipt' => array ()
  6842. ) );
  6843. die ();
  6844. }
  6845. /*
  6846. * 废弃
  6847. */
  6848. function myReceipt() {
  6849. // all approval past withdraw
  6850. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  6851. if (empty ( $item ))
  6852. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  6853. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6854. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  6855. Doo::loadModel ( 'receipt' );
  6856. $receipt = new receipt ();
  6857. // pre-loaded
  6858. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  6859. // have cache
  6860. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  6861. if (! empty ( $moth )) // yearPage
  6862. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  6863. $this->showCache ( $path );
  6864. }
  6865. Doo::loadModel ( 'L_category' );
  6866. $Lcategory = new L_category ();
  6867. Doo::loadModel ( 'verify' );
  6868. Doo::loadModel ( 'statistics' );
  6869. $statistics = new statistics ();
  6870. $verify = new verify ();
  6871. Doo::loadModel ( 'staff' );
  6872. $staff = new staff ();
  6873. $condition = " and status!=0 ";
  6874. if ($item == "approval")
  6875. $condition = " and status=2 ";
  6876. elseif ($item == "withdraw")
  6877. $condition = " and status=3 ";
  6878. elseif ($item == "past")
  6879. $condition = " and status=1 ";
  6880. elseif ($item == "whdw")
  6881. $condition = " and status=4 ";
  6882. $dateCondition = " and Year(date) =" . $year;
  6883. if (! empty ( $moth )) {
  6884. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  6885. $stList = $statistics->getOne ( array (
  6886. 'select' => 'rePrice ,agPrice',
  6887. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  6888. 'asArray' => true
  6889. ) );
  6890. } else
  6891. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  6892. if (empty ( $stList ))
  6893. $stList = array (
  6894. 'rePrice' => 0,
  6895. 'agPrice' => 0
  6896. );
  6897. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  6898. $data ['stList'] = array (
  6899. 'rePrice' => $stList ['rePrice'],
  6900. 'agPrice' => $stList ['agPrice'],
  6901. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  6902. );
  6903. $receiptList = $receipt->find ( array (
  6904. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  6905. 'desc' => 'rid',
  6906. 'asArray' => true
  6907. ) );
  6908. $Locate = 0;
  6909. $roleId = 0;
  6910. $button = 0;
  6911. foreach ( $receiptList as $key => $value ) {
  6912. $receiptList [$key] ['Locate'] = $Locate;
  6913. $Locate ++;
  6914. $receiptList [$key] ['reviseDetail'] = array ();
  6915. if (! empty ( $value ['reviseDetail'] ))
  6916. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6917. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6918. $categoryDetil = $Lcategory->getOne ( array (
  6919. 'where' => 'cid=' . $value ['cid'],
  6920. 'asArray' => true
  6921. ) );
  6922. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6923. // 检测编辑状态
  6924. $verifyList = $verify->getOne ( array (
  6925. 'where' => 'vid=' . $value ['verify'],
  6926. 'asArray' => true
  6927. ) );
  6928. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6929. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6930. Doo::loadModel ( 'role' );
  6931. $role = new role ();
  6932. $flag = true;
  6933. $roleKey = 0;
  6934. $endStaffArray = array ();
  6935. $roleArrayCopy = array ();
  6936. foreach ( $verifyList as $k => $v ) {
  6937. // init verifyStaff
  6938. if ($v [1] == 'ROLE') {
  6939. if (! empty ( $verifyStaff )) {
  6940. $endStaffArray = end ( $verifyStaff );
  6941. // if ($v[0]==$endStaffArray['nextStaff']){
  6942. // $roleId=$v[0];
  6943. // }
  6944. }
  6945. $roleVerify = json_decode ( $v [3], true );
  6946. $roleKey = $k;
  6947. $roleArray = array ();
  6948. $rolename = $role->getOne ( array (
  6949. 'where' => 'rid=' . $v [0],
  6950. 'asArray' => true
  6951. ) );
  6952. foreach ( $roleVerify as $o => $p ) {
  6953. $staffID = explode ( '_', $p );
  6954. $staffInfo = $staff->getOne ( array (
  6955. 'where' => 'sid=' . $staffID [0],
  6956. 'asArray' => true
  6957. ) );
  6958. // print_r($staffID);
  6959. $exp = array (
  6960. 0 => $staffInfo ['sid'],
  6961. 1 => $staffID [1],
  6962. 2 => $staffInfo ['avatar'],
  6963. 'date' => '',
  6964. 'date' => '',
  6965. 'opinion' => '',
  6966. 'status' => '',
  6967. 'rolename' => $rolename ['name']
  6968. );
  6969. array_push ( $roleArray, $exp );
  6970. }
  6971. $roleArrayCopy [$v [0]] = $roleArray;
  6972. // $verifyList[$k]['roleArray']=$roleArray;
  6973. }
  6974. $verifyList [$k] ['date'] = "";
  6975. $verifyList [$k] ['opinion'] = "";
  6976. $verifyList [$k] ['status'] = "";
  6977. if (empty ( $verifyStaff )) {
  6978. $verifyList [$k] ['date'] = "";
  6979. $verifyList [$k] ['opinion'] = "";
  6980. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6981. $verifyList [$k] ['status'] = 4;
  6982. $flag = false;
  6983. }
  6984. } else {
  6985. foreach ( $verifyStaff as $m => $u ) {
  6986. if ($v [0] == $m) {
  6987. $verifyList [$k] ['date'] = $u ['date'];
  6988. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6989. $verifyList [$k] ['status'] = $u ['status'];
  6990. $flag = false;
  6991. break;
  6992. }
  6993. }
  6994. $endStaffArray = end ( $verifyStaff );
  6995. if (isset ( $endStaffArray ['ROLE'] )) {
  6996. } else {
  6997. // $endKey=key($verifyStaff);
  6998. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  6999. // $button=4;
  7000. // $verifyList[$k]['status']=4;
  7001. // }
  7002. }
  7003. }
  7004. }
  7005. $rolename ['name'] = '';
  7006. if (! empty ( $roleId )) {
  7007. Doo::loadModel ( 'role' );
  7008. $role = new role ();
  7009. $rolename = $role->getOne ( array (
  7010. 'where' => 'rid=' . $roleId,
  7011. 'asArray' => true
  7012. ) );
  7013. }
  7014. if (! empty ( $verifyStaff ))
  7015. $endStaffArray = end ( $verifyStaff );
  7016. $KOP = false;
  7017. foreach ( $roleArrayCopy as $P => $A ) {
  7018. foreach ( $A as $MKI => $AVL ) {
  7019. if (! empty ( $verifyStaff )) {
  7020. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7021. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7022. $button = 4;
  7023. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7024. }
  7025. foreach ( $verifyStaff as $m => $u ) {
  7026. $AVLFK = $AVL [0] . '_R';
  7027. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7028. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7029. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7030. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7031. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7032. break;
  7033. }
  7034. }
  7035. } else {
  7036. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7037. $button = 4;
  7038. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7039. }
  7040. }
  7041. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7042. $KOP = true;
  7043. }
  7044. }
  7045. foreach ( $roleArrayCopy as $k => $v ) {
  7046. foreach ( $verifyList as $m => $n ) {
  7047. if ($n [0] == $k) {
  7048. array_splice ( $verifyList, $m, 1, $v );
  7049. }
  7050. }
  7051. }
  7052. $receiptList [$key] ['verifyList'] = $verifyList;
  7053. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7054. 'where' => 'sid=' . $value ['staff'],
  7055. 'asArray' => true
  7056. ) );
  7057. $receiptList [$key] ['button'] = $button;
  7058. }
  7059. // print_r($receiptList);die;
  7060. $mothHtml = "";
  7061. for($i = 1; $i <= 12; $i ++) {
  7062. if ($moth == $i)
  7063. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7064. else
  7065. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7066. }
  7067. $data ['mothHtml'] = $mothHtml;
  7068. $data ['receiptList'] = $receiptList;
  7069. $data ['memu'] = "receipt";
  7070. $data ['staff'] = $this->staff;
  7071. $data ['receiptMemu'] = 'receipt';
  7072. $data ['verifyId'] = $this->verifyId;
  7073. $data ['executeId'] = $this->executeId;
  7074. $data ['item'] = $item;
  7075. $data ['year'] = $year;
  7076. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  7077. // sufficient condition to generate cache
  7078. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  7079. $receiptList = $receipt->find ( array (
  7080. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7081. 'asArray' => true
  7082. ) );
  7083. if (empty ( $receiptList )) { // generated files
  7084. ob_start ();
  7085. $this->render ( "/admin/saea_myList", $data );
  7086. $this->cacheFile ( $path );
  7087. die ();
  7088. // $content = ob_get_contents();
  7089. // $fp = fopen($path, "w");
  7090. // fwrite($fp, $content);
  7091. // fclose($fp);
  7092. }
  7093. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  7094. $receiptList = $receipt->find ( array (
  7095. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  7096. 'asArray' => true
  7097. ) );
  7098. if (empty ( $receiptList )) { // generated files
  7099. ob_start ();
  7100. $this->render ( "/admin/saea_myList", $data );
  7101. $this->cacheFile ( $path );
  7102. die ();
  7103. }
  7104. }
  7105. }
  7106. $this->render ( "/admin/saea_myList", $data );
  7107. }
  7108. function approvedReceipt() {
  7109. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7110. Doo::loadModel ( 'receipt' );
  7111. Doo::loadModel ( 'receiptDetail' );
  7112. $receipt = new receipt ();
  7113. $receiptDetail = new receiptDetail ();
  7114. Doo::loadModel ( 'statistics' );
  7115. Doo::loadModel ( 'itemStatistics' );
  7116. $statistics = new statistics ();
  7117. $itemStatistics = new itemStatistics ();
  7118. Doo::loadModel ( "verify" );
  7119. $verify = new verify ();
  7120. // 审批状态的判定
  7121. $receiptDetailList = $receipt->getOne ( array (
  7122. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  7123. 'asArray' => true
  7124. ) );
  7125. if (empty ( $receiptDetailList ))
  7126. return "/saeaBorad";
  7127. $verifyDetail = $verify->getOne ( array (
  7128. 'where' => ' vid =' . $receiptDetailList ['verify'],
  7129. 'asArray' => true
  7130. ) );
  7131. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7132. if (empty ( $receiptDetailList ['nowStaff'] )) {
  7133. $nowStaff = "";
  7134. $nowStaffList = array ();
  7135. if ($verifyDetail [0] [1] == 'ROLE') {
  7136. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7137. foreach ( $vStaffString as $key => $value ) {
  7138. $staffK = explode ( "_", $value );
  7139. array_push ( $nowStaffList, $staffK [0] );
  7140. }
  7141. $nowStaff = implode ( ',', $nowStaffList );
  7142. } else {
  7143. $nowStaff = $verifyDetail [0] [0];
  7144. }
  7145. $receipt->nowStaff = $nowStaff;
  7146. }
  7147. // echo $nowStaff;
  7148. // print_r($verifyDetail);die;
  7149. $receipt->rid = $receiptDetailList ['rid'];
  7150. $receipt->date = date ( "Y-m-d" );
  7151. $receipt->status = 2;
  7152. $receipt->update ();
  7153. $receiptDetail->status = 2;
  7154. $receiptDetail->update ( array (
  7155. 'where' => 'rid=' . $receiptDetailList ['rid']
  7156. ) );
  7157. Doo::loadModel ( "receiptLog" );
  7158. $receiptLog = new receiptLog ();
  7159. Doo::loadModel ( "verify" );
  7160. $verify = new verify ();
  7161. $receiptInfo = $receipt->getOne ( array (
  7162. 'where' => 'rid=' . $rid,
  7163. 'asArray' => true
  7164. ) );
  7165. $vr = $verify->getOne ( array (
  7166. 'where' => 'vid=' . $receiptInfo ['verify'],
  7167. 'asArray' => true
  7168. ) );
  7169. $jd = json_decode ( $vr ['staff'] );
  7170. $roleId = 0;
  7171. foreach ( $jd as $key => $value ) {
  7172. if ($value [1] == 'ROLE') {
  7173. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7174. if ($pos !== false) {
  7175. $roleId = $value [0];
  7176. }
  7177. }
  7178. }
  7179. // 审批日志
  7180. // echo $roleId;die;
  7181. if (! empty ( $roleId )) {
  7182. Doo::loadModel ( "role" );
  7183. $role = new role ();
  7184. $roleInfo = $role->getOne ( array (
  7185. 'where' => 'rid=' . $roleId,
  7186. 'asArray' => true
  7187. ) );
  7188. // $receiptLog->rolename = $roleInfo ['name'];
  7189. }
  7190. $receiptLog->username = $this->staff [0] ['username'];
  7191. $receiptLog->uid = $this->staff [0] ['sid'];
  7192. $receiptLog->date = date ( "Y-m-d" );
  7193. $receiptLog->opinion = '提交审批';
  7194. $receiptLog->img = $this->staff [0] ['avatar'];
  7195. $receiptLog->status = 2;
  7196. $receiptLog->rid = $rid;
  7197. $receiptLog->insert ();
  7198. // statistics item
  7199. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  7200. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7201. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  7202. $stat = $statistics->getOne ( array (
  7203. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7204. 'asArray' => true
  7205. ) );
  7206. if (empty ( $stat )) {
  7207. $statistics->date = date ( "Y-m-d" );
  7208. $statistics->cid = $this->staff [0] ['cid'];
  7209. $statistics->staff = $this->staff [0] ['sid'];
  7210. $statistics->agPrice = 0;
  7211. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7212. $statistics->insert ();
  7213. } else {
  7214. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7215. $statistics->update ( array (
  7216. 'where' => 'sid=' . $stat ['sid']
  7217. ) );
  7218. }
  7219. return "/expenses";
  7220. }
  7221. function approval() {
  7222. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7223. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7224. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7225. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7226. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7227. if (empty ( $status ))
  7228. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7229. $vidList = array ();
  7230. $button = 0;
  7231. Doo::loadModel ( 'verify' );
  7232. $verify = new verify ();
  7233. Doo::loadModel ( 'receipt' );
  7234. $receipt = new receipt ();
  7235. Doo::loadModel ( 'staff' );
  7236. $staff = new staff ();
  7237. Doo::loadModel ( 'L_category' );
  7238. $Lcategory = new L_category ();
  7239. // user verify ID
  7240. $verifyDetail = $verify->find ( array (
  7241. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7242. 'asArray' => true
  7243. ) );
  7244. foreach ( $verifyDetail as $key => $value ) {
  7245. array_push ( $vidList, $value ['vid'] );
  7246. }
  7247. $vid = implode ( ",", $vidList );
  7248. if (empty ( $verifyDetail ))
  7249. $vid = 0;
  7250. /*
  7251. */
  7252. $dateCondition = " and Year(date) =" . $year;
  7253. if (! empty ( $month ))
  7254. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  7255. $categoryList = $Lcategory->find ( array (
  7256. 'asArray' => true
  7257. ) );
  7258. $staffList = $staff->find ( array (
  7259. 'where' => 'cid=' . $cid,
  7260. 'asArray' => true
  7261. ) );
  7262. $cateCondition = "";
  7263. $staffCondition = "";
  7264. $approvalCondition = "";
  7265. if (! empty ( $cid ))
  7266. $cateCondition = ' and cid=' . $cid;
  7267. if (! empty ( $sid )) {
  7268. $staffCondition = ' and staff=' . $sid;
  7269. $cateCondition = "";
  7270. }
  7271. // elseif($status==1){
  7272. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  7273. // }
  7274. if ($status == 2) {
  7275. // 查找角色审批人
  7276. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  7277. }
  7278. $ap = "";
  7279. if ($status == 4) {
  7280. $ap = 4;
  7281. $status = 2;
  7282. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  7283. }
  7284. if ($status == 5) {
  7285. $status = 4;
  7286. $ap = 5;
  7287. }
  7288. // echo $vid;
  7289. // get Receipt By verifyID status 2 .$approvalCondition
  7290. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  7291. $receiptList = $receipt->find ( array (
  7292. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  7293. 'desc' => 'rid',
  7294. 'asArray' => true
  7295. ) );
  7296. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  7297. $Locate = 0;
  7298. if ($ap == 4)
  7299. $status = 4;
  7300. elseif ($ap == 5)
  7301. $status = 5;
  7302. foreach ( $receiptList as $key => $value ) {
  7303. $receiptList [$key] ['Locate'] = $Locate;
  7304. $Locate ++;
  7305. $receiptList [$key] ['reviseDetail'] = array ();
  7306. if (! empty ( $value ['reviseDetail'] ))
  7307. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7308. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7309. $categoryDetil = $Lcategory->getOne ( array (
  7310. 'where' => 'cid=' . $value ['cid'],
  7311. 'asArray' => true
  7312. ) );
  7313. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7314. $verifyList = $verify->getOne ( array (
  7315. 'where' => 'vid=' . $value ['verify'],
  7316. 'asArray' => true
  7317. ) );
  7318. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7319. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7320. foreach ( $verifyList as $k => $v ) {
  7321. // init verifyStaff
  7322. $verifyList [$k] ['date'] = "";
  7323. $verifyList [$k] ['opinion'] = "";
  7324. $verifyList [$k] ['status'] = "";
  7325. if (empty ( $verifyStaff )) {
  7326. $verifyList [$k] ['date'] = "";
  7327. $verifyList [$k] ['opinion'] = "";
  7328. if ($v [0] == $this->staff [0] ['sid']) {
  7329. $verifyList [$k] ['status'] = 4;
  7330. $button = 4;
  7331. }
  7332. } else {
  7333. $flag = true;
  7334. foreach ( $verifyStaff as $m => $u ) {
  7335. if ($v [0] == $m) {
  7336. $verifyList [$k] ['date'] = $u ['date'];
  7337. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7338. $verifyList [$k] ['status'] = $u ['status'];
  7339. $flag = false;
  7340. break;
  7341. }
  7342. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  7343. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  7344. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  7345. }
  7346. if ($flag) { // 检测可编辑
  7347. if ($v [0] == $this->staff [0] ['sid']) {
  7348. $verifyList [$k] ['status'] = 4;
  7349. $button = 4;
  7350. }
  7351. }
  7352. }
  7353. }
  7354. $receiptList [$key] ['verifyList'] = $verifyList;
  7355. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7356. 'where' => 'sid=' . $value ['staff'],
  7357. 'asArray' => true
  7358. ) );
  7359. $receiptList [$key] ['button'] = $button;
  7360. }
  7361. // print_r($receiptList);die;
  7362. // $data['verifyDetail']=$verifyDetail;
  7363. $mothHtml = "";
  7364. for($i = 1; $i <= 12; $i ++) {
  7365. if ($month == $i)
  7366. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7367. else
  7368. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7369. }
  7370. $data ['mothHtml'] = $mothHtml;
  7371. $data ['receiptList'] = $receiptList;
  7372. $data ['receiptApprovalCount'] = count ( $receiptList );
  7373. $data ['status'] = $status;
  7374. $data ['year'] = $year;
  7375. $data ['categoryList'] = $categoryList;
  7376. $data ['staffList'] = $staffList;
  7377. $data ['cid'] = $cid;
  7378. $data ['sid'] = $sid;
  7379. $data ['ap'] = $ap;
  7380. $data ['memu'] = "receipt";
  7381. $data ['staff'] = $this->staff;
  7382. $data ['receiptMemu'] = 'approval';
  7383. $data ['verifyId'] = $this->verifyId;
  7384. $data ['executeId'] = $this->executeId;
  7385. $this->render ( "/admin/saea_reportList", $data );
  7386. }
  7387. function approvalDetails() {
  7388. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7389. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7390. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7391. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7392. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7393. Doo::loadModel ( 'verify' );
  7394. $verify = new verify ();
  7395. Doo::loadModel ( 'receipt' );
  7396. $receipt = new receipt ();
  7397. Doo::loadModel ( 'staff' );
  7398. $staff = new staff ();
  7399. Doo::loadModel ( 'L_category' );
  7400. $Lcategory = new L_category ();
  7401. Doo::loadModel ( 'enclosur' );
  7402. $enclosur = new enclosur ();
  7403. $vidList = array ();
  7404. $verifyDetail = $verify->find ( array (
  7405. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7406. 'asArray' => true
  7407. ) );
  7408. foreach ( $verifyDetail as $key => $value ) {
  7409. array_push ( $vidList, $value ['vid'] );
  7410. }
  7411. $vid = implode ( ",", $vidList );
  7412. if (empty ( $verifyDetail ))
  7413. $vid = 0;
  7414. $categoryList = $Lcategory->find ( array (
  7415. 'asArray' => true
  7416. ) );
  7417. $staffList = $staff->find ( array (
  7418. 'where' => 'cid=' . $cid,
  7419. 'asArray' => true
  7420. ) );
  7421. $ap = 0;
  7422. $receiptList = $receipt->find ( array (
  7423. 'where' => 'rid =' . $rid,
  7424. 'desc' => 'rid',
  7425. 'asArray' => true
  7426. ) );
  7427. $Locate = 0;
  7428. $roleId = 0;
  7429. $button = 0;
  7430. foreach ( $receiptList as $key => $value ) {
  7431. $receiptList [$key] ['Locate'] = $Locate;
  7432. $Locate ++;
  7433. $receiptList [$key] ['reviseDetail'] = array ();
  7434. if (! empty ( $value ['reviseDetail'] ))
  7435. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7436. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7437. $categoryDetil = $Lcategory->getOne ( array (
  7438. 'where' => 'cid=' . $value ['cid'],
  7439. 'asArray' => true
  7440. ) );
  7441. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7442. // 检测编辑状态
  7443. $verifyList = $verify->getOne ( array (
  7444. 'where' => 'vid=' . $value ['verify'],
  7445. 'asArray' => true
  7446. ) );
  7447. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7448. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7449. Doo::loadModel ( 'role' );
  7450. $role = new role ();
  7451. // print_r($verifyList);
  7452. $flag = true;
  7453. $roleKey = 0;
  7454. $endStaffArray = array ();
  7455. $roleArrayCopy = array ();
  7456. foreach ( $verifyList as $k => $v ) {
  7457. // init verifyStaff
  7458. if ($v [1] == 'ROLE') {
  7459. if (! empty ( $verifyStaff )) {
  7460. $endStaffArray = end ( $verifyStaff );
  7461. if ($v [0] == $endStaffArray ['nextStaff']) {
  7462. $roleId = $v [0];
  7463. }
  7464. }
  7465. $roleVerify = json_decode ( $v [3], true );
  7466. $roleKey = $k;
  7467. $roleArray = array ();
  7468. $rolename = $role->getOne ( array (
  7469. 'where' => 'rid=' . $v [0],
  7470. 'asArray' => true
  7471. ) );
  7472. foreach ( $roleVerify as $o => $p ) {
  7473. $staffID = explode ( '_', $p );
  7474. $staffInfo = $staff->getOne ( array (
  7475. 'where' => 'sid=' . $staffID [0],
  7476. 'asArray' => true
  7477. ) );
  7478. // print_r($staffID);
  7479. $exp = array (
  7480. 0 => $staffInfo ['sid'],
  7481. 1 => $staffID [1],
  7482. 2 => $staffInfo ['avatar'],
  7483. 'date' => '',
  7484. 'date' => '',
  7485. 'opinion' => '',
  7486. 'status' => '',
  7487. 'rolename' => $rolename ['name']
  7488. );
  7489. array_push ( $roleArray, $exp );
  7490. }
  7491. $roleArrayCopy [$v [0]] = $roleArray;
  7492. // $verifyList[$k]['roleArray']=$roleArray;
  7493. }
  7494. // print_r($roleArray);
  7495. $verifyList [$k] ['date'] = "";
  7496. $verifyList [$k] ['opinion'] = "";
  7497. $verifyList [$k] ['status'] = "";
  7498. if (empty ( $verifyStaff )) {
  7499. $verifyList [$k] ['date'] = "";
  7500. $verifyList [$k] ['opinion'] = "";
  7501. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7502. $verifyList [$k] ['status'] = 4;
  7503. $button = 4;
  7504. $flag = false;
  7505. }
  7506. } else {
  7507. foreach ( $verifyStaff as $m => $u ) {
  7508. if ($v [0] == $m) {
  7509. $verifyList [$k] ['date'] = $u ['date'];
  7510. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7511. $verifyList [$k] ['status'] = $u ['status'];
  7512. $flag = false;
  7513. break;
  7514. }
  7515. }
  7516. $endStaffArray = end ( $verifyStaff );
  7517. if (isset ( $endStaffArray ['ROLE'] )) {
  7518. } else {
  7519. $endKey = key ( $verifyStaff );
  7520. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7521. $button = 4;
  7522. $verifyList [$k] ['status'] = 4;
  7523. }
  7524. }
  7525. }
  7526. }
  7527. $rolename ['name'] = '';
  7528. if (! empty ( $roleId )) {
  7529. Doo::loadModel ( 'role' );
  7530. $role = new role ();
  7531. $rolename = $role->getOne ( array (
  7532. 'where' => 'rid=' . $roleId,
  7533. 'asArray' => true
  7534. ) );
  7535. }
  7536. if (! empty ( $verifyStaff ))
  7537. $endStaffArray = end ( $verifyStaff );
  7538. $KOP = false;
  7539. foreach ( $roleArrayCopy as $P => $A ) {
  7540. foreach ( $A as $MKI => $AVL ) {
  7541. if (! empty ( $verifyStaff )) {
  7542. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7543. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7544. $button = 4;
  7545. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7546. }
  7547. foreach ( $verifyStaff as $m => $u ) {
  7548. $AVLFK = $AVL [0] . '_R';
  7549. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7550. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7551. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7552. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7553. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7554. break;
  7555. }
  7556. }
  7557. } else {
  7558. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7559. $button = 4;
  7560. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7561. }
  7562. }
  7563. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7564. $KOP = true;
  7565. }
  7566. }
  7567. foreach ( $roleArrayCopy as $k => $v ) {
  7568. foreach ( $verifyList as $m => $n ) {
  7569. if ($n [0] == $k) {
  7570. array_splice ( $verifyList, $m, 1, $v );
  7571. }
  7572. }
  7573. }
  7574. $receiptList [$key] ['verifyList'] = $verifyList;
  7575. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7576. 'where' => 'sid=' . $value ['staff'],
  7577. 'asArray' => true
  7578. ) );
  7579. $receiptList [$key] ['button'] = $button;
  7580. }
  7581. $mothHtml = "";
  7582. for($i = 1; $i <= 12; $i ++) {
  7583. if ($month == $i)
  7584. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7585. else
  7586. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7587. }
  7588. // 获取审批日志
  7589. Doo::loadModel ( 'receiptLog' );
  7590. $receiptLog = new receiptLog ();
  7591. $rlList = array ();
  7592. $rlInfo = $receiptLog->getOne ( array (
  7593. 'where' => 'rid=' . $rid . ' and status=4',
  7594. 'asArray' => true
  7595. ) );
  7596. $tijdate = $receiptLog->getOne ( array (
  7597. 'where' => 'rid=' . $rid . ' and status=2',
  7598. 'asc' => 'rlid',
  7599. 'asArray' => true
  7600. ) );
  7601. if (! empty ( $rlInfo )) {
  7602. $rlList = $receiptLog->find ( array (
  7603. 'where' => 'rid=' . $rid,
  7604. 'asc' => 'rlid',
  7605. 'asArray' => true
  7606. ) );
  7607. }
  7608. $receiptList [0] ['rlList'] = $rlList;
  7609. $enclosurList = $enclosur->find ( array (
  7610. 'where' => 'rid=' . $rid,
  7611. 'asArray' => true
  7612. ) );
  7613. $enclosurHtml = '';
  7614. foreach ( $enclosurList as $value ) {
  7615. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  7616. }
  7617. $data ['enclosurHtml'] = $enclosurHtml;
  7618. $data ['rolename'] = $rolename ['name'];
  7619. $data ['datetij'] = $tijdate ['date'];
  7620. $data ['mothHtml'] = $mothHtml;
  7621. $data ['receiptList'] = $receiptList;
  7622. $data ['receiptApprovalCount'] = count ( $receiptList );
  7623. $data ['year'] = $year;
  7624. $data ['categoryList'] = $categoryList;
  7625. $data ['staffList'] = $staffList;
  7626. $data ['cid'] = $cid;
  7627. $data ['sid'] = $sid;
  7628. $data ['status'] = 0;
  7629. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  7630. $ap = 4;
  7631. } else
  7632. $data ['status'] = $receiptList [0] ['status'];
  7633. if ($receiptList [0] ['status'] == 4) {
  7634. $data ['status'] = 5;
  7635. $ap = 0;
  7636. }
  7637. $data ['ap'] = $ap;
  7638. $data ['memu'] = "receipt";
  7639. $data ['staff'] = $this->staff;
  7640. $data ['receiptMemu'] = 'approval';
  7641. $data ['verifyId'] = $this->verifyId;
  7642. $data ['executeId'] = $this->executeId;
  7643. $this->render ( "/admin/saeaReportListReport", $data );
  7644. }
  7645. function approvalEdi() {
  7646. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7647. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7648. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7649. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7650. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7651. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7652. if (empty ( $status ))
  7653. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7654. $vidList = array ();
  7655. $button = 0;
  7656. Doo::loadModel ( 'verify' );
  7657. Doo::loadModel ( 'receipt' );
  7658. Doo::loadModel ( 'staff' );
  7659. $staff = new staff ();
  7660. $receipt = new receipt ();
  7661. $verify = new verify ();
  7662. Doo::loadModel ( 'L_category' );
  7663. $Lcategory = new L_category ();
  7664. Doo::loadModel ( 'enclosur' );
  7665. $enclosur = new enclosur ();
  7666. // user verify ID
  7667. $verifyDetail = $verify->find ( array (
  7668. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7669. 'asArray' => true
  7670. ) );
  7671. foreach ( $verifyDetail as $key => $value ) {
  7672. array_push ( $vidList, $value ['vid'] );
  7673. }
  7674. $vid = implode ( ",", $vidList );
  7675. if (empty ( $verifyDetail ))
  7676. $vid = 0;
  7677. $categoryList = $Lcategory->find ( array (
  7678. 'asArray' => true
  7679. ) );
  7680. $staffList = $staff->find ( array (
  7681. 'where' => 'cid=' . $cid,
  7682. 'asArray' => true
  7683. ) );
  7684. $ap = "";
  7685. if ($status == 4) {
  7686. $ap = 4;
  7687. $status = 2;
  7688. }
  7689. // get Receipt By verifyID status 2
  7690. $receiptList = $receipt->find ( array (
  7691. 'where' => 'rid =' . $rid,
  7692. 'desc' => 'rid',
  7693. 'asArray' => true
  7694. ) );
  7695. $Locate = 0;
  7696. $roleId = 0;
  7697. if ($ap == 4)
  7698. $status = 4;
  7699. foreach ( $receiptList as $key => $value ) {
  7700. $receiptList [$key] ['Locate'] = $Locate;
  7701. $Locate ++;
  7702. $receiptList [$key] ['reviseDetail'] = array ();
  7703. if (! empty ( $value ['reviseDetail'] ))
  7704. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7705. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7706. $categoryDetil = $Lcategory->getOne ( array (
  7707. 'where' => 'cid=' . $value ['cid'],
  7708. 'asArray' => true
  7709. ) );
  7710. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7711. // 检测编辑状态
  7712. $verifyList = $verify->getOne ( array (
  7713. 'where' => 'vid=' . $value ['verify'],
  7714. 'asArray' => true
  7715. ) );
  7716. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7717. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7718. // print_r($verifyList);
  7719. //
  7720. // if (empty($verifyStaff)){
  7721. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  7722. // $verifyList[0]['status']=4;$button=4;
  7723. // }
  7724. //
  7725. // }else{
  7726. //
  7727. // }
  7728. // die;
  7729. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  7730. // echo array_search("green",$a);
  7731. //
  7732. Doo::loadModel ( 'role' );
  7733. $role = new role ();
  7734. // print_r($verifyList);
  7735. $flag = true;
  7736. $roleKey = 0;
  7737. $endStaffArray = array ();
  7738. $roleArrayCopy = array ();
  7739. foreach ( $verifyList as $k => $v ) {
  7740. // init verifyStaff
  7741. if ($v [1] == 'ROLE') {
  7742. if (! empty ( $verifyStaff )) {
  7743. $endStaffArray = end ( $verifyStaff );
  7744. if ($v [0] == $endStaffArray ['nextStaff']) {
  7745. $roleId = $v [0];
  7746. }
  7747. }
  7748. $roleVerify = json_decode ( $v [3], true );
  7749. $roleKey = $k;
  7750. $roleArray = array ();
  7751. $rolename = $role->getOne ( array (
  7752. 'where' => 'rid=' . $v [0],
  7753. 'asArray' => true
  7754. ) );
  7755. foreach ( $roleVerify as $o => $p ) {
  7756. $staffID = explode ( '_', $p );
  7757. $staffInfo = $staff->getOne ( array (
  7758. 'where' => 'sid=' . $staffID [0],
  7759. 'asArray' => true
  7760. ) );
  7761. // print_r($staffID);
  7762. $exp = array (
  7763. 0 => $staffInfo ['sid'],
  7764. 1 => $staffID [1],
  7765. 2 => $staffInfo ['avatar'],
  7766. 'date' => '',
  7767. 'date' => '',
  7768. 'opinion' => '',
  7769. 'status' => '',
  7770. 'rolename' => $rolename ['name']
  7771. );
  7772. array_push ( $roleArray, $exp );
  7773. }
  7774. $roleArrayCopy [$v [0]] = $roleArray;
  7775. // $verifyList[$k]['roleArray']=$roleArray;
  7776. }
  7777. // print_r($roleArray);
  7778. $verifyList [$k] ['date'] = "";
  7779. $verifyList [$k] ['opinion'] = "";
  7780. $verifyList [$k] ['status'] = "";
  7781. if (empty ( $verifyStaff )) {
  7782. $verifyList [$k] ['date'] = "";
  7783. $verifyList [$k] ['opinion'] = "";
  7784. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7785. $verifyList [$k] ['status'] = 4;
  7786. $button = 4;
  7787. $flag = false;
  7788. }
  7789. } else {
  7790. foreach ( $verifyStaff as $m => $u ) {
  7791. if ($v [0] == $m) {
  7792. $verifyList [$k] ['date'] = $u ['date'];
  7793. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7794. $verifyList [$k] ['status'] = $u ['status'];
  7795. $flag = false;
  7796. break;
  7797. }
  7798. }
  7799. $endStaffArray = end ( $verifyStaff );
  7800. if (isset ( $endStaffArray ['ROLE'] )) {
  7801. } else {
  7802. $endKey = key ( $verifyStaff );
  7803. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7804. $button = 4;
  7805. $verifyList [$k] ['status'] = 4;
  7806. }
  7807. }
  7808. // print_r($endStaffArray);die;
  7809. // if (empty($verifyStaff)){
  7810. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  7811. // $verifyList[$k]['status']=4;$button=4;
  7812. // }
  7813. //
  7814. // }else{
  7815. //
  7816. // }
  7817. // if($flag){//检测可编辑
  7818. // if($v[0]==$this->staff[0]['sid']){
  7819. // $verifyList[$k]['status']=4;$button=4;
  7820. // }
  7821. // }
  7822. }
  7823. }
  7824. $rolename ['name'] = '';
  7825. if (! empty ( $roleId )) {
  7826. Doo::loadModel ( 'role' );
  7827. $role = new role ();
  7828. $rolename = $role->getOne ( array (
  7829. 'where' => 'rid=' . $roleId,
  7830. 'asArray' => true
  7831. ) );
  7832. }
  7833. if (! empty ( $verifyStaff ))
  7834. $endStaffArray = end ( $verifyStaff );
  7835. $KOP = false;
  7836. foreach ( $roleArrayCopy as $P => $A ) {
  7837. foreach ( $A as $MKI => $AVL ) {
  7838. if (! empty ( $verifyStaff )) {
  7839. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7840. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7841. $button = 4;
  7842. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7843. }
  7844. foreach ( $verifyStaff as $m => $u ) {
  7845. $AVLFK = $AVL [0] . '_R';
  7846. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7847. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7848. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7849. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7850. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7851. break;
  7852. }
  7853. }
  7854. } else {
  7855. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7856. $button = 4;
  7857. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7858. }
  7859. }
  7860. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7861. $KOP = true;
  7862. }
  7863. }
  7864. // print_r($roleArrayCopy);
  7865. // echo $roleKey;
  7866. foreach ( $roleArrayCopy as $k => $v ) {
  7867. foreach ( $verifyList as $m => $n ) {
  7868. if ($n [0] == $k) {
  7869. array_splice ( $verifyList, $m, 1, $v );
  7870. }
  7871. }
  7872. }
  7873. // if ($KOP)
  7874. // array_splice($verifyList,$roleKey,1,$roleArray);
  7875. // print_r($verifyList);
  7876. $receiptList [$key] ['verifyList'] = $verifyList;
  7877. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7878. 'where' => 'sid=' . $value ['staff'],
  7879. 'asArray' => true
  7880. ) );
  7881. $receiptList [$key] ['button'] = $button;
  7882. }
  7883. // $data['verifyDetail']=$verifyDetail;
  7884. $mothHtml = "";
  7885. for($i = 1; $i <= 12; $i ++) {
  7886. if ($month == $i)
  7887. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7888. else
  7889. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7890. }
  7891. // 获取审批日志
  7892. Doo::loadModel ( 'receiptLog' );
  7893. $receiptLog = new receiptLog ();
  7894. $rlList = array ();
  7895. $rlInfo = $receiptLog->getOne ( array (
  7896. 'where' => 'rid=' . $rid . ' and status=4',
  7897. 'asArray' => true
  7898. ) );
  7899. $tijdate = $receiptLog->getOne ( array (
  7900. 'where' => 'rid=' . $rid . ' and status=2',
  7901. 'asc' => 'rlid',
  7902. 'asArray' => true
  7903. ) );
  7904. if (! empty ( $rlInfo )) {
  7905. $rlList = $receiptLog->find ( array (
  7906. 'where' => 'rid=' . $rid,
  7907. 'asc' => 'rlid',
  7908. 'asArray' => true
  7909. ) );
  7910. }
  7911. $receiptList [0] ['rlList'] = $rlList;
  7912. $enclosurList = $enclosur->find ( array (
  7913. 'where' => 'rid=' . $rid,
  7914. 'asArray' => true
  7915. ) );
  7916. $enclosurHtml = '';
  7917. foreach ( $enclosurList as $value ) {
  7918. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  7919. }
  7920. $data ['enclosurHtml'] = $enclosurHtml;
  7921. $data ['rolename'] = $rolename ['name'];
  7922. $data ['datetij'] = $tijdate ['date'];
  7923. $data ['mothHtml'] = $mothHtml;
  7924. $data ['receiptList'] = $receiptList;
  7925. $data ['receiptApprovalCount'] = count ( $receiptList );
  7926. $data ['status'] = $status;
  7927. $data ['year'] = $year;
  7928. $data ['categoryList'] = $categoryList;
  7929. $data ['staffList'] = $staffList;
  7930. $data ['cid'] = $cid;
  7931. $data ['sid'] = $sid;
  7932. $data ['ap'] = $ap;
  7933. $data ['memu'] = "receipt";
  7934. $data ['staff'] = $this->staff;
  7935. $data ['receiptMemu'] = 'approval';
  7936. $data ['verifyId'] = $this->verifyId;
  7937. $data ['executeId'] = $this->executeId;
  7938. $this->render ( "/admin/saeaReportListReport", $data );
  7939. }
  7940. function remittanceHky() {
  7941. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7942. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  7943. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  7944. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  7945. $page_size = 15;
  7946. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  7947. Doo::loadModel ( 'receipt' );
  7948. $receipt = new receipt ();
  7949. Doo::loadModel ( 'staff' );
  7950. $staff = new staff ();
  7951. $dateCondition = " and Year(executeDate) =" . $year;
  7952. if ($moth != 'MONTH')
  7953. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  7954. if ($day != 'DAY' && $moth != 'MONTH')
  7955. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  7956. $sql = ' (status =8 or status=9 ) and amount>0 ' . $dateCondition;
  7957. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  7958. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  7959. $limit = $pageinfo ['lower'] . ',' . $page_size;
  7960. $dayList = $receipt->find ( array (
  7961. 'select' => 'executeDate,sum(amount) as amount',
  7962. 'where' => $sql,
  7963. 'desc' => 'executeDate',
  7964. 'groupby' => 'executeDate',
  7965. 'limit' => $limit,
  7966. 'asArray' => true
  7967. ) );
  7968. // print_r($dayList);
  7969. foreach ( $dayList as $key => $value ) {
  7970. $remitString = "";
  7971. $receiptList = $receipt->find ( array (
  7972. 'select' => 'rid,executeDate,amount,staff,cid',
  7973. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  7974. 'desc' => 'executeDate',
  7975. 'asArray' => true
  7976. ) );
  7977. foreach ( $receiptList as $k => $v ) {
  7978. $sinfo = $staff->getOne ( array (
  7979. 'select' => 'username,category',
  7980. 'where' => ' sid=' . $v ['staff'],
  7981. 'asArray' => true
  7982. ) );
  7983. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  7984. }
  7985. $dayList [$key] ['staff'] = $remitString;
  7986. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  7987. }
  7988. // print_r($dayList);
  7989. $mothHtml = "";
  7990. for($i = 1; $i <= 12; $i ++) {
  7991. if ($moth == $i)
  7992. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7993. else
  7994. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7995. }
  7996. $dayHtml = "";
  7997. if ($day != "DAY" || $moth != "MONTH") {
  7998. for($i = 1; $i <= 31; $i ++) {
  7999. if ($day == $i)
  8000. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  8001. else
  8002. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  8003. }
  8004. }
  8005. $dateHtml = "";
  8006. $now = date ( "Y" );
  8007. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  8008. if ($YEARD <= $now) {
  8009. $dateHtml .= '<option ';
  8010. if ($year == $YEARD) {
  8011. $dateHtml .= 'selected ';
  8012. }
  8013. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  8014. }
  8015. }
  8016. $data ['dateHtml'] = $dateHtml;
  8017. $data ['page'] = $pageinfo;
  8018. $data ['year'] = $year;
  8019. $data ['moth'] = $moth;
  8020. $data ['day'] = $day;
  8021. $data ['get'] = $get;
  8022. $data ['dayHtml'] = $dayHtml;
  8023. $data ['mothHtml'] = $mothHtml;
  8024. $data ['receiptList'] = $dayList;
  8025. $data ['memu'] = "receipt";
  8026. $data ['staff'] = $this->staff;
  8027. $data ['receiptMemu'] = 'remittanceHky';
  8028. $data ['verifyId'] = $this->verifyId;
  8029. $data ['executeId'] = $this->executeId;
  8030. $this->render ( "/admin/remittanceHky", $data );
  8031. }
  8032. function remittancep() {
  8033. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  8034. Doo::loadModel ( 'receipt' );
  8035. $receipt = new receipt ();
  8036. Doo::loadModel ( 'staff' );
  8037. $staff = new staff ();
  8038. Doo::loadClass ( 'XDeode' );
  8039. $XDeode = new XDeode ( 5 );
  8040. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  8041. $rplist = $receipt->find ( array (
  8042. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8043. 'asArray' => true
  8044. ) );
  8045. $dayList = $receipt->find ( array (
  8046. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8047. 'desc' => 'executeDate',
  8048. 'groupby' => 'staff',
  8049. 'asArray' => true
  8050. ) );
  8051. $html = '';
  8052. foreach ( $dayList as $key => $value ) {
  8053. $sinfo = $staff->getOne ( array (
  8054. 'select' => 'username,category',
  8055. 'where' => ' sid=' . $value ['staff'],
  8056. 'asArray' => true
  8057. ) );
  8058. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  8059. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  8060. $au = 0;
  8061. foreach ( $rplist as $k => $v ) {
  8062. if ($value ['staff'] == $v ['staff']) {
  8063. $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>';
  8064. $au += $v ['amount'];
  8065. }
  8066. }
  8067. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  8068. }
  8069. $data ['html'] = $html;
  8070. $data ['memu'] = "receipt";
  8071. $data ['staff'] = $this->staff;
  8072. $data ['receiptMemu'] = 'remittanceHky';
  8073. $data ['verifyId'] = $this->verifyId;
  8074. $data ['executeId'] = $this->executeId;
  8075. $this->render ( "/admin/remittancep", $data );
  8076. }
  8077. function ajaxGetReceiptDetails() {
  8078. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  8079. Doo::loadClass ( 'XDeode' );
  8080. $XDeode = new XDeode ( 5 );
  8081. $rid = $XDeode->decode ( $rid );
  8082. if (empty ( $rid )) {
  8083. echo json_encode ( array (
  8084. 'status' => 2,
  8085. 'msg' => 'illegal request'
  8086. ) );
  8087. die ();
  8088. }
  8089. Doo::loadModel ( 'receipt' );
  8090. $receipt = new receipt ();
  8091. Doo::loadModel ( 'staff' );
  8092. $staff = new staff ();
  8093. $rinfo = $receipt->getOne ( array (
  8094. 'where' => 'rid= ' . $rid,
  8095. 'asArray' => true
  8096. ) );
  8097. $sinfo = $staff->getOne ( array (
  8098. 'select' => 'username,category',
  8099. 'where' => ' sid=' . $rinfo ['staff'],
  8100. 'asArray' => true
  8101. ) );
  8102. $rinfo ['reviseDetail'] = array ();
  8103. if (! empty ( $rinfo ['reviseDetail'] ))
  8104. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  8105. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  8106. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  8107. $rinfo ['category'] = $sinfo ['category'];
  8108. $verifyStaff = array ();
  8109. if (! empty ( $rinfo ['verifyStaff'] ))
  8110. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  8111. $relust = bcsub ( $rinfo ['sum'], $rinfo ['loanSum'], 2 );
  8112. $rinfo ['relust'] = $relust;
  8113. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  8114. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  8115. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  8116. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  8117. // 费用执行人相关数据
  8118. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  8119. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  8120. foreach ( $executeCopy as $k => $v ) {
  8121. $executeCopy [$k] ['date'] = '';
  8122. $executeCopy [$k] ['opinion'] = '';
  8123. $executeCopy [$k] ['status'] = '';
  8124. if (! empty ( $executeStaff ))
  8125. foreach ( $executeStaff as $m => $u ) {
  8126. if ($v [0] == $m) {
  8127. $executeCopy [$k] ['date'] = $u ['date'];
  8128. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  8129. $executeCopy [$k] ['status'] = $u ['status'];
  8130. break;
  8131. }
  8132. }
  8133. }
  8134. $rinfo ['executeCopy'] = $executeCopy;
  8135. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  8136. if ($rinfo ['Rtype'] == 1) { // 借款费用
  8137. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8138. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  8139. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  8140. $html .= '<tr><th>' . $value ['name'] . '</th>
  8141. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8142. }
  8143. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8144. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8145. <tr><th class="taC" colspan="2">费用说明</th>
  8146. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8147. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8148. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  8149. </tbody></table>';
  8150. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  8151. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8152. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8153. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8154. $html .= '<tr><th>' . $value ['name'] . '</th>
  8155. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8156. }
  8157. $html .= '<tr><th class="taR">合计</th>
  8158. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8159. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8160. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8161. $html .= '<tr><th>' . $value ['name'] . '</th>
  8162. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8163. }
  8164. $html .= '<tr><th class="taR">合计</th>
  8165. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8166. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8167. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8168. $html .= '<tr><th>' . $value ['name'] . '</th>
  8169. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8170. }
  8171. $html .= '<tr><th class="taR">合计</th>
  8172. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8173. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8174. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8175. $html .= '<tr><th>' . $value ['name'] . '</th>
  8176. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8177. }
  8178. $html .= '<tr><th class="taR">合计</th>
  8179. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8180. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8181. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8182. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8183. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8184. }
  8185. $html .= '<tr><th class="taR">合计</th>
  8186. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8187. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8188. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8189. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8190. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8191. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8192. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8193. <tr';
  8194. if ($rinfo ['relust'] >= 0) {
  8195. $html .= 'class="success"';
  8196. } else {
  8197. $html .= 'class="error"';
  8198. }
  8199. $html .= '><td class="taR"><b>借款结余</b></td>
  8200. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  8201. </tbody></table>
  8202. ';
  8203. }
  8204. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  8205. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8206. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  8207. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8208. $html .= '<tr><th>' . $value ['name'] . '</th>
  8209. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8210. }
  8211. $html .= '<tr><th class="taR">合计</th>
  8212. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8213. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8214. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8215. <tr><th class="taC" colspan="2">费用说明</th>
  8216. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8217. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8218. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8219. </tbody></table>';
  8220. } else {
  8221. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8222. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8223. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8224. $html .= '<tr><th>' . $value ['name'] . '</th>
  8225. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8226. }
  8227. $html .= '<tr><th class="taR">合计</th>
  8228. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8229. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8230. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8231. $html .= '<tr><th>' . $value ['name'] . '</th>
  8232. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8233. }
  8234. $html .= '<tr><th class="taR">合计</th>
  8235. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8236. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8237. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8238. $html .= '<tr><th>' . $value ['name'] . '</th>
  8239. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8240. }
  8241. $html .= '<tr><th class="taR">合计</th>
  8242. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8243. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8244. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8245. $html .= '<tr><th>' . $value ['name'] . '</th>
  8246. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8247. }
  8248. $html .= '<tr><th class="taR">合计</th>
  8249. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8250. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8251. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8252. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8253. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8254. }
  8255. $html .= '<tr><th class="taR">合计</th>
  8256. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8257. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8258. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8259. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8260. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8261. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8262. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  8263. $html .= '</tbody></table>';
  8264. /*
  8265. * <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>
  8266. */
  8267. }
  8268. // print_r($verifyStaff);die;
  8269. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  8270. foreach ( $verifyStaff as $key => $value ) {
  8271. $key = trim ( strtr ( $key, '_R', ' ' ) );
  8272. $sinfo = $staff->getOne ( array (
  8273. 'select' => 'username',
  8274. 'where' => ' sid=' . $key,
  8275. 'asArray' => true
  8276. ) );
  8277. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8278. }
  8279. $html .= '</tbody></table>';
  8280. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  8281. foreach ( $rinfo ['executeCopy'] as $value ) {
  8282. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8283. }
  8284. $html .= '</tbody></table>';
  8285. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  8286. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  8287. </tr></table>';
  8288. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  8289. echo json_encode ( array (
  8290. 'status' => 1,
  8291. 'html' => $html
  8292. ) );
  8293. die ();
  8294. }
  8295. /**
  8296. * 删除附件
  8297. */
  8298. function ajaxRemEnclousur() {
  8299. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  8300. if (empty ( $key ))
  8301. echo json_encode ( array (
  8302. 'status' => 2
  8303. ) );
  8304. Doo::loadModel ( 'enclosur' );
  8305. $enclosur = new enclosur ();
  8306. $enclosur->delEnclosurByEid ( $key );
  8307. echo json_encode ( array (
  8308. 'status' => 1
  8309. ) );
  8310. }
  8311. function remittance() {
  8312. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8313. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8314. Doo::loadModel ( 'receipt' );
  8315. $receipt = new receipt ();
  8316. Doo::loadModel ( 'staff' );
  8317. $staff = new staff ();
  8318. $dateCondition = " and Year(pastDate) =" . $year;
  8319. if (! empty ( $month ))
  8320. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  8321. // get Receipt By verifyID status 1
  8322. $receiptList = $receipt->find ( array (
  8323. 'select' => 'sum(sum) as sum,staff,pastDate',
  8324. 'where' => ' status=1' . $dateCondition,
  8325. 'desc' => 'pastDate',
  8326. 'groupby' => 'staff,pastDate',
  8327. 'asArray' => true
  8328. ) );
  8329. $dateList = $receipt->find ( array (
  8330. 'select' => 'pastDate,verifyStaff',
  8331. 'where' => ' status=1' . $dateCondition,
  8332. 'desc' => 'pastDate',
  8333. 'groupby' => 'pastDate',
  8334. 'asArray' => true
  8335. ) );
  8336. $dataList = array ();
  8337. foreach ( $dateList as $d => $a ) {
  8338. $dataList [$a ['pastDate']] = array ();
  8339. $daySum = 0;
  8340. foreach ( $receiptList as $key => $value ) {
  8341. if ($a ['pastDate'] == $value ['pastDate']) {
  8342. $oderList = $receipt->find ( array (
  8343. 'select' => 'receiptOrder',
  8344. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  8345. 'asArray' => true
  8346. ) );
  8347. $list = array ();
  8348. $html = "";
  8349. foreach ( $oderList as $v ) {
  8350. array_push ( $list, $v ['receiptOrder'] );
  8351. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  8352. }
  8353. $receiptList [$key] ['receiptOrder'] = $html;
  8354. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  8355. $sinfo = $staff->getOne ( array (
  8356. 'select' => 'username ',
  8357. 'where' => ' sid=' . $value ['staff'],
  8358. 'asArray' => true
  8359. ) );
  8360. $receiptList [$key] ['username'] = $sinfo ['username'];
  8361. $daySum += $value ['sum'];
  8362. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  8363. }
  8364. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  8365. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  8366. }
  8367. }
  8368. // print_r($dataList);
  8369. $data ['dataList'] = $dataList;
  8370. $mothHtml = "";
  8371. for($i = 1; $i <= 12; $i ++) {
  8372. if ($month == $i)
  8373. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8374. else
  8375. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8376. }
  8377. $data ['year'] = $year;
  8378. $data ['mothHtml'] = $mothHtml;
  8379. $data ['memu'] = "receipt";
  8380. $data ['staff'] = $this->staff;
  8381. $data ['receiptMemu'] = 'approval';
  8382. $data ['verifyId'] = $this->verifyId;
  8383. $data ['executeId'] = $this->executeId;
  8384. $this->render ( "/admin/saeaReportListPay", $data );
  8385. }
  8386. /**
  8387. * 金额调整,提高稳定性
  8388. * @return string
  8389. */
  8390. function revocationAdjustment() {
  8391. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  8392. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  8393. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  8394. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  8395. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  8396. Doo::loadClass ( 'XDeode' );
  8397. $XDeode = new XDeode ( 5 );
  8398. Doo::loadModel ( 'receipt' );
  8399. $receipt = new receipt ();
  8400. $sid = $XDeode->decode ( $sidKey );
  8401. $rid = $XDeode->decode ( $ridKey );
  8402. $reviseKey = $XDeode->decode ( $reviseKey );
  8403. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  8404. die ( 'illegal request' );
  8405. $receiptDetail = $receipt->getOne ( array (
  8406. 'where' => 'rid=' . $rid,
  8407. 'asArray' => true
  8408. ) );
  8409. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  8410. die ( 'illegal request' );
  8411. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8412. if (! isset ( $reviseDetail [$reviseKey] ))
  8413. die ( 'illegal request' );
  8414. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  8415. unset ( $reviseDetail [$reviseKey] );
  8416. $revisePrice = 0;
  8417. foreach ( $reviseDetail as $key => $value ) {
  8418. $revisePrice += $value ['price'];
  8419. }
  8420. $reviseDetailString = json_encode ( $reviseDetail );
  8421. $receipt->reviseDetail = $reviseDetailString;
  8422. $receipt->sum = $receiptDetail ['sum'] - $price;
  8423. $receipt->revisePrice = $revisePrice;
  8424. $receipt->update ( array (
  8425. 'where' => 'rid=' . $rid
  8426. ) );
  8427. return '/receiptburEdi/' . $rid;
  8428. } else
  8429. die ( 'illegal request2' );
  8430. }
  8431. function updateApprovalReceipt() {
  8432. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  8433. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  8434. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8435. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  8436. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  8437. if (! empty ( $rid )) {
  8438. Doo::loadModel ( "verify" );
  8439. $verify = new verify ();
  8440. Doo::loadModel ( "receiptDetail" );
  8441. $receiptDetailObj = new receiptDetail ();
  8442. Doo::loadModel ( "itemStatistics" );
  8443. Doo::loadModel ( "statistics" );
  8444. $statistics = new statistics ();
  8445. $itemStatistics = new itemStatistics ();
  8446. Doo::loadModel ( "receipt" );
  8447. $receipt = new receipt ();
  8448. $receiptDetail = $receipt->getOne ( array (
  8449. 'where' => 'rid=' . $rid . ' and status=2 ',
  8450. 'asArray' => true
  8451. ) );
  8452. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  8453. $nsflag = true;
  8454. foreach ( $nslist as $value ) {
  8455. if ($value == $this->staff ['0'] ['sid']) {
  8456. $nsflag = false;
  8457. break;
  8458. }
  8459. }
  8460. if (empty ( $receiptDetail ) || $nsflag)
  8461. return "/approvalExpenses/pendApproval";
  8462. $verifyDetail = $verify->getOne ( array (
  8463. 'where' => ' vid =' . $receiptDetail ['verify'],
  8464. 'asArray' => true
  8465. ) );
  8466. $verifyString = $verifyDetail ['staff'];
  8467. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  8468. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  8469. if (empty ( $opinion )) {
  8470. if ($status == 3)
  8471. $opinion = "终止";
  8472. else
  8473. $opinion = "同意支付";
  8474. }
  8475. $nowStaff = 0;
  8476. $nowStaffList = array ();
  8477. if (empty ( $verifyStaff )) {
  8478. // 还需加入是否已经进入角色审批
  8479. if ($verifyDetail [0] [1] == 'ROLE') {
  8480. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  8481. foreach ( $vStaffString as $key => $value ) {
  8482. $staffK = explode ( "_", $value );
  8483. if ($staffK [0] != $this->staff [0] ['sid'])
  8484. array_push ( $nowStaffList, $staffK [0] );
  8485. }
  8486. // print_r($verifyDetail);
  8487. // die;
  8488. if (! empty ( $nowStaffList )) {
  8489. $nowStaff = implode ( ',', $nowStaffList );
  8490. $verifyStaff = array (
  8491. $this->staff [0] ['sid'] . "_R" => array (
  8492. 'date' => date ( 'Y-m-d' ),
  8493. 'opinion' => $opinion,
  8494. 'status' => $status,
  8495. 'nextStaff' => $verifyDetail [0] [0],
  8496. 'ROLE' => 1
  8497. )
  8498. );
  8499. } else {
  8500. $nowStaff = $verifyDetail [1] [0];
  8501. $verifyStaff = array (
  8502. $this->staff [0] ['sid'] . "_R" => array (
  8503. 'date' => date ( 'Y-m-d' ),
  8504. 'opinion' => $opinion,
  8505. 'status' => $status,
  8506. 'nextStaff' => $verifyDetail [1] [0]
  8507. )
  8508. );
  8509. }
  8510. } else {
  8511. if ($verifyDetail [1] [1] == 'ROLE') {
  8512. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  8513. // echo "dd";
  8514. foreach ( $vStaffString as $key => $value ) {
  8515. $staffK = explode ( "_", $value );
  8516. array_push ( $nowStaffList, $staffK [0] );
  8517. }
  8518. $nowStaff = implode ( ',', $nowStaffList );
  8519. $verifyStaff = array (
  8520. $this->staff [0] ['sid'] => array (
  8521. 'date' => date ( 'Y-m-d' ),
  8522. 'opinion' => $opinion,
  8523. 'status' => $status,
  8524. 'nextStaff' => $verifyDetail [1] [0],
  8525. 'ROLE' => 1
  8526. )
  8527. );
  8528. } else {
  8529. $nowStaff = $verifyDetail [1] [0];
  8530. $verifyStaff = array (
  8531. $this->staff [0] ['sid'] => array (
  8532. 'date' => date ( 'Y-m-d' ),
  8533. 'opinion' => $opinion,
  8534. 'status' => $status,
  8535. 'nextStaff' => $verifyDetail [1] [0]
  8536. )
  8537. );
  8538. }
  8539. }
  8540. if ($status == 3)
  8541. $verifyStaff = array (
  8542. 'final' => $status,
  8543. $this->staff [0] ['sid'] => array (
  8544. 'date' => date ( 'Y-m-d' ),
  8545. 'opinion' => $opinion,
  8546. 'status' => $status
  8547. )
  8548. );
  8549. $vStaffString = json_encode ( $verifyStaff );
  8550. $receipt->nowStaff = $nowStaff;
  8551. $receipt->verifyStaff = $vStaffString;
  8552. } else {
  8553. $VS = end ( $verifyStaff );
  8554. // 非角色审批
  8555. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  8556. $nextStaff = 0;
  8557. $roleSTF = false;
  8558. foreach ( $verifyDetail as $key => $value ) {
  8559. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  8560. if (isset ( $verifyDetail [$key + 1] )) {
  8561. $nextStaff = $verifyDetail [$key + 1] [0];
  8562. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  8563. $roleSTF = true;
  8564. }
  8565. break;
  8566. }
  8567. }
  8568. if (! $roleSTF) {
  8569. $nowStaff = $nextStaff;
  8570. $verifyStaff [$this->staff [0] ['sid']] = array (
  8571. 'date' => date ( 'Y-m-d' ),
  8572. 'opinion' => $opinion,
  8573. 'status' => $status,
  8574. 'nextStaff' => $nextStaff
  8575. );
  8576. } else {
  8577. // 获取角色下的所有用户ID
  8578. $nowStaffList = array ();
  8579. foreach ( $verifyDetail as $vfk ) {
  8580. if ($vfk [1] == 'ROLE') {
  8581. $vStaffString = json_decode ( $vfk [3] );
  8582. foreach ( $vStaffString as $key => $value ) {
  8583. $staffK = explode ( "_", $value );
  8584. array_push ( $nowStaffList, $staffK [0] );
  8585. }
  8586. }
  8587. }
  8588. $nowStaff = implode ( ',', $nowStaffList );
  8589. $verifyStaff [$this->staff [0] ['sid']] = array (
  8590. 'date' => date ( 'Y-m-d' ),
  8591. 'opinion' => $opinion,
  8592. 'status' => $status,
  8593. 'nextStaff' => $nextStaff,
  8594. 'ROLE' => 0
  8595. );
  8596. }
  8597. if ($status == 3) {
  8598. $verifyStaff ['final'] = $status;
  8599. $verifyStaff [$this->staff [0] ['sid']] = array (
  8600. 'date' => date ( 'Y-m-d' ),
  8601. 'opinion' => $opinion,
  8602. 'status' => $status
  8603. );
  8604. }
  8605. $vStaffString = json_encode ( $verifyStaff );
  8606. $receipt->nowStaff = $nowStaff;
  8607. $receipt->verifyStaff = $vStaffString;
  8608. }
  8609. // 角色审批
  8610. if (isset ( $VS ['ROLE'] )) {
  8611. // 找出角色人 当前审批角色组
  8612. $verifyJSStaff = array ();
  8613. $nowStaffList2 = array ();
  8614. foreach ( $verifyDetail as $key => $value ) {
  8615. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  8616. $verifyJSStaff = json_decode ( $value [3] );
  8617. foreach ( $verifyJSStaff as $m ) {
  8618. $staffK = explode ( "_", $m );
  8619. array_push ( $nowStaffList2, $staffK [0] );
  8620. }
  8621. // print_r($nowStaffList2);
  8622. }
  8623. }
  8624. $RoleVerifyStaff = array ();
  8625. foreach ( $verifyStaff as $key => $value ) {
  8626. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  8627. foreach ( $nowStaffList2 as $m ) {
  8628. if ($key == $m . "_R")
  8629. $RoleVerifyStaff [$key] = $value;
  8630. }
  8631. }
  8632. }
  8633. // print_r($verifyStaff);
  8634. // print_r($nowStaffList2);
  8635. // print_r($RoleVerifyStaff);
  8636. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  8637. // print_r($verifyJSStaff);
  8638. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  8639. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  8640. // 下一个审批人ID
  8641. $nextStaff = 0;
  8642. $falg = false;
  8643. foreach ( $verifyDetail as $key => $value ) {
  8644. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  8645. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  8646. $falg = true;
  8647. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  8648. $nowStaffList = array ();
  8649. foreach ( $vStaffString as $v ) {
  8650. $staffK = explode ( "_", $v );
  8651. array_push ( $nowStaffList, $staffK [0] );
  8652. }
  8653. $nowStaff = implode ( ',', $nowStaffList );
  8654. $nextStaff = $verifyDetail [$key + 1] [0];
  8655. } elseif (isset ( $verifyDetail [$key + 1] )) {
  8656. $nextStaff = $verifyDetail [$key + 1] [0];
  8657. $nowStaff = $nextStaff;
  8658. } else
  8659. $nowStaff = '';
  8660. break;
  8661. }
  8662. }
  8663. if ($falg)
  8664. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8665. 'date' => date ( 'Y-m-d' ),
  8666. 'opinion' => $opinion,
  8667. 'status' => $status,
  8668. 'nextStaff' => $nextStaff,
  8669. 'ROLE' => 1
  8670. );
  8671. else
  8672. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8673. 'date' => date ( 'Y-m-d' ),
  8674. 'opinion' => $opinion,
  8675. 'status' => $status,
  8676. 'nextStaff' => $nextStaff
  8677. );
  8678. // print_r($verifyStaff);
  8679. // echo $nowStaff;die;
  8680. } else { // 进入下一个角色或者审批人
  8681. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  8682. //
  8683. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  8684. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8685. 'date' => date ( 'Y-m-d' ),
  8686. 'opinion' => $opinion,
  8687. 'status' => $status,
  8688. 'nextStaff' => $VS ['nextStaff'],
  8689. 'ROLE' => 1
  8690. );
  8691. // print_r($verifyStaff);
  8692. // die;
  8693. }
  8694. if ($status == 3) {
  8695. $verifyStaff ['final'] = $status;
  8696. $verifyStaff [$this->staff [0] ['sid']] = array (
  8697. 'date' => date ( 'Y-m-d' ),
  8698. 'opinion' => $opinion,
  8699. 'status' => $status
  8700. );
  8701. }
  8702. $vStaffString = json_encode ( $verifyStaff );
  8703. $receipt->verifyStaff = $vStaffString;
  8704. $receipt->nowStaff = $nowStaff;
  8705. // die;
  8706. // }
  8707. // print_r($verifyStaff);
  8708. // die;
  8709. }
  8710. // print_r($verifyStaff);die;
  8711. }
  8712. // print_r($verifyDetail);
  8713. $roleKey = 0;
  8714. $roleId = 0;
  8715. $verifyDetailCopy = array ();
  8716. foreach ( $verifyDetail as $k => $v ) {
  8717. if ($v [1] == 'ROLE') {
  8718. $roleId = $v [0];
  8719. $roleVerify = json_decode ( $v [3], true );
  8720. $roleKey = $k;
  8721. $roleArray = array ();
  8722. foreach ( $roleVerify as $o => $p ) {
  8723. $staffID = explode ( '_', $p );
  8724. $exp = array (
  8725. 0 => $staffID [0],
  8726. 1 => $staffID [1]
  8727. );
  8728. array_push ( $roleArray, $exp );
  8729. }
  8730. $verifyDetailCopy [$v [0]] = $roleArray;
  8731. }
  8732. }
  8733. // print_r($verifyDetail);
  8734. foreach ( $verifyDetailCopy as $k => $v ) {
  8735. foreach ( $verifyDetail as $m => $n ) {
  8736. if ($n [0] == $k) {
  8737. array_splice ( $verifyDetail, $m, 1, $v );
  8738. }
  8739. }
  8740. }
  8741. // die;
  8742. // if (!empty($roleArray))
  8743. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  8744. // echo $roleId;
  8745. // print_r($verifyStaff);
  8746. // print_r($verifyDetail);
  8747. // die;
  8748. Doo::loadModel ( "receiptLog" );
  8749. $receiptLog = new receiptLog ();
  8750. // 审批日志
  8751. if (! isset ( $verifyStaff ['final'] )) {
  8752. if (! empty ( $roleId )) {
  8753. Doo::loadModel ( "role" );
  8754. $role = new role ();
  8755. $roleInfo = $role->getOne ( array (
  8756. 'where' => 'rid=' . $roleId,
  8757. 'asArray' => true
  8758. ) );
  8759. $receiptLog->rolename = $roleInfo ['name'];
  8760. }
  8761. $receiptLog->username = $this->staff [0] ['username'];
  8762. $receiptLog->uid = $this->staff [0] ['sid'];
  8763. $receiptLog->date = date ( "Y-m-d" );
  8764. $receiptLog->opinion = $opinion;
  8765. $receiptLog->img = $this->staff [0] ['avatar'];
  8766. $receiptLog->status = 1;
  8767. $receiptLog->rid = $rid;
  8768. $receiptLog->insert ();
  8769. }
  8770. if (isset ( $verifyStaff ['final'] )) { // rDetail
  8771. $receipt->verifyBreakup = $verifyString;
  8772. $receipt->status = 3;
  8773. $receiptDetailObj->status = 3;
  8774. $receiptDetailObj->update ( array (
  8775. 'where' => 'rid=' . $rid
  8776. ) );
  8777. if (! empty ( $roleId )) {
  8778. Doo::loadModel ( "role" );
  8779. $role = new role ();
  8780. $roleInfo = $role->getOne ( array (
  8781. 'where' => 'rid=' . $roleId,
  8782. 'asArray' => true
  8783. ) );
  8784. $receiptLog->rolename = $roleInfo ['name'];
  8785. }
  8786. $receiptLog->username = $this->staff [0] ['username'];
  8787. $receiptLog->uid = $this->staff [0] ['sid'];
  8788. $receiptLog->date = date ( "Y-m-d" );
  8789. $receiptLog->opinion = $opinion;
  8790. $receiptLog->img = $this->staff [0] ['avatar'];
  8791. $receiptLog->status = 3;
  8792. $receiptLog->rid = $rid;
  8793. $receiptLog->insert ();
  8794. // 微信企业号通知
  8795. $this->setWXMsg ( $rid, 3 );
  8796. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  8797. $receipt->status = 1;
  8798. $reviseSum = 0;
  8799. $receipt->verifyBreakup = $verifyString;
  8800. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  8801. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8802. foreach ( $reviseDetail as $key => $value ) {
  8803. $receiptDetailObj = new receiptDetail ();
  8804. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8805. $receiptDetailObj->item = $value ['description'];
  8806. $receiptDetailObj->itemCategory = "报销金额调整";
  8807. $receiptDetailObj->price = $value ['price'];
  8808. $receiptDetailObj->date = $receiptDetail ['date'];
  8809. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  8810. $receiptDetailObj->rid = $rid;
  8811. $receiptDetailObj->status = 1;
  8812. $receiptDetailObj->insert ();
  8813. $reviseSum += $value ['price'];
  8814. }
  8815. $itemStatistics = new itemStatistics ();
  8816. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  8817. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8818. $itemStatistics->price = $reviseSum;
  8819. $itemStatistics->itemCategory = "报销金额调整";
  8820. $itemStatistics->date = $receiptDetail ['date'];
  8821. $itemStatistics->insert ();
  8822. }
  8823. $receiptDetailObj = new receiptDetail ();
  8824. $receiptDetailObj->status = 1;
  8825. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  8826. $receiptDetailObj->update ( array (
  8827. 'where' => 'rid=' . $rid
  8828. ) );
  8829. $dateArray = explode ( "-", $receiptDetail ['date'] );
  8830. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  8831. $stat = $statistics->getOne ( array (
  8832. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  8833. 'asArray' => true
  8834. ) );
  8835. if (empty ( $stat )) {
  8836. $statistics->date = $receiptDetail ['date'];
  8837. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  8838. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8839. $statistics->agPrice = $receiptDetail ['sum'];
  8840. $statistics->rePrice = $reviseSum;
  8841. $statistics->insert ();
  8842. } else {
  8843. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  8844. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  8845. $statistics->update ( array (
  8846. 'where' => 'sid=' . $stat ['sid']
  8847. ) );
  8848. }
  8849. $dateArray = explode ( "-", $receiptDetail ['date'] );
  8850. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  8851. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  8852. foreach ( $accountItem ['cSum'] as $key => $value ) {
  8853. if ($key == "agencySum") {
  8854. $iStatistics = $itemStatistics->getOne ( array (
  8855. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  8856. 'asArray' => true
  8857. ) );
  8858. if (empty ( $iStatistics )) {
  8859. $itemStatistics->cid = $receiptDetail ['cid'];
  8860. ;
  8861. $itemStatistics->staff = $receiptDetail ['staff'];
  8862. $itemStatistics->price = $value;
  8863. $itemStatistics->itemCategory = $this->AGENCY;
  8864. $itemStatistics->date = $receiptDetail ['date'];
  8865. $itemStatistics->insert ();
  8866. } else {
  8867. if (! empty ( $value )) {
  8868. $itemStatistics->price = $value + $iStatistics ['price'];
  8869. $itemStatistics->update ( array (
  8870. 'where' => 'sid=' . $iStatistics ['sid']
  8871. ) );
  8872. }
  8873. }
  8874. } elseif ($key == "travelSum") {
  8875. $iStatistics = $itemStatistics->getOne ( array (
  8876. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  8877. 'asArray' => true
  8878. ) );
  8879. if (empty ( $iStatistics )) {
  8880. $itemStatistics->cid = $receiptDetail ['cid'];
  8881. $itemStatistics->staff = $receiptDetail ['staff'];
  8882. $itemStatistics->price = $value;
  8883. $itemStatistics->itemCategory = $this->TRAVEL;
  8884. $itemStatistics->date = $receiptDetail ['date'];
  8885. $itemStatistics->insert ();
  8886. } else {
  8887. if (! empty ( $value )) {
  8888. $itemStatistics->price = $value + $iStatistics ['price'];
  8889. $itemStatistics->update ( array (
  8890. 'where' => 'sid=' . $iStatistics ['sid']
  8891. ) );
  8892. }
  8893. }
  8894. } elseif ($key == "trainSum") {
  8895. $iStatistics = $itemStatistics->getOne ( array (
  8896. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  8897. 'asArray' => true
  8898. ) );
  8899. if (empty ( $iStatistics )) {
  8900. $itemStatistics->cid = $receiptDetail ['cid'];
  8901. $itemStatistics->staff = $receiptDetail ['staff'];
  8902. $itemStatistics->price = $value;
  8903. $itemStatistics->itemCategory = $this->TRAIN;
  8904. $itemStatistics->date = $receiptDetail ['date'];
  8905. $itemStatistics->insert ();
  8906. } else {
  8907. if (! empty ( $value )) {
  8908. $itemStatistics->price = $value + $iStatistics ['price'];
  8909. $itemStatistics->update ( array (
  8910. 'where' => 'sid=' . $iStatistics ['sid']
  8911. ) );
  8912. }
  8913. }
  8914. } elseif ($key == "otherSum") {
  8915. $iStatistics = $itemStatistics->getOne ( array (
  8916. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  8917. 'asArray' => true
  8918. ) );
  8919. if (empty ( $iStatistics )) {
  8920. $itemStatistics->cid = $receiptDetail ['cid'];
  8921. $itemStatistics->staff = $receiptDetail ['staff'];
  8922. $itemStatistics->price = $value;
  8923. $itemStatistics->itemCategory = $this->OTHER;
  8924. $itemStatistics->date = $receiptDetail ['date'];
  8925. $itemStatistics->insert ();
  8926. } else {
  8927. if (! empty ( $value )) {
  8928. $itemStatistics->price = $value + $iStatistics ['price'];
  8929. $itemStatistics->update ( array (
  8930. 'where' => 'sid=' . $iStatistics ['sid']
  8931. ) );
  8932. }
  8933. }
  8934. }
  8935. }
  8936. $receipt->pastDate = date ( "Y-m-d" );
  8937. // 微信企业号通知
  8938. $this->setWXMsg ( $rid, 1 );
  8939. }
  8940. //是否有流水
  8941. Doo::loadModel ( 'wasteBook' );
  8942. $wasteBook = new wasteBook ();
  8943. $accountType=3;
  8944. if ($receiptDetail['Rtype']==1){
  8945. $accountType=2;
  8946. }elseif($receiptDetail['Rtype']==2){
  8947. $accountType=4;
  8948. }
  8949. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $rid );
  8950. if (empty($wbDetail)){
  8951. $rsum=$receiptDetail['sum']-$receiptDetail['loanSum'];
  8952. $receipt->amount = $rsum;//$amount;
  8953. }
  8954. $receipt->update ( array (
  8955. 'where' => ' rid = ' . $rid
  8956. ) );
  8957. // 进入下一条审批费用新加需求
  8958. $vidList = array ();
  8959. $verifyDetail = $verify->find ( array (
  8960. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  8961. 'asArray' => true
  8962. ) );
  8963. foreach ( $verifyDetail as $key => $value ) {
  8964. array_push ( $vidList, $value ['vid'] );
  8965. }
  8966. $vid = implode ( ",", $vidList );
  8967. if (empty ( $verifyDetail ))
  8968. $vid = 0;
  8969. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  8970. $receipt = new receipt ();
  8971. $rd = $receipt->getOne ( array (
  8972. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ') and Rtype!=3',
  8973. 'asc' => 'rid',
  8974. 'asArray' => true
  8975. ) );
  8976. if (empty ( $rd )) {
  8977. return '/approvalExpenses/pendApproval';
  8978. }
  8979. if ($rd ['Rtype'] == 1) {
  8980. if ($rd ['isBK'] == 1) {
  8981. return '/receiptburEdi/' . $rd ['rid'];
  8982. } else {
  8983. return '/expensesEdi/' . $rd ['rid'];
  8984. }
  8985. } elseif ($rd ['Rtype'] == 2) {
  8986. return '/remitApproval/' . $rd ['rid'];
  8987. } else {
  8988. return '/receiptburEdi/' . $rd ['rid'];
  8989. }
  8990. // return "/approvalExpenses/pendApproval";
  8991. }
  8992. }
  8993. function expensesRetreats() {
  8994. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  8995. if (! empty ( $rid )) {
  8996. // 操作记录
  8997. Doo::loadModel ( "receipt" );
  8998. $receipt = new receipt ();
  8999. Doo::loadModel ( "receiptLog" );
  9000. $receiptLog = new receiptLog ();
  9001. Doo::loadModel ( "verify" );
  9002. $verify = new verify ();
  9003. $receiptInfo = $receipt->getOne ( array (
  9004. 'where' => 'rid=' . $rid,
  9005. 'asArray' => true
  9006. ) );
  9007. $vr = $verify->getOne ( array (
  9008. 'where' => 'vid=' . $receiptInfo ['verify'],
  9009. 'asArray' => true
  9010. ) );
  9011. $jd = json_decode ( $vr ['staff'] );
  9012. $roleId = 0;
  9013. foreach ( $jd as $key => $value ) {
  9014. if ($value [1] == 'ROLE') {
  9015. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9016. if ($pos !== false) {
  9017. $roleId = $value [0];
  9018. }
  9019. }
  9020. }
  9021. // 审批日志
  9022. // echo $roleId;die;
  9023. if (! empty ( $roleId )) {
  9024. Doo::loadModel ( "role" );
  9025. $role = new role ();
  9026. $roleInfo = $role->getOne ( array (
  9027. 'where' => 'rid=' . $roleId,
  9028. 'asArray' => true
  9029. ) );
  9030. $receiptLog->rolename = $roleInfo ['name'];
  9031. }
  9032. $receiptLog->username = $this->staff [0] ['username'];
  9033. $receiptLog->uid = $this->staff [0] ['sid'];
  9034. $receiptLog->date = date ( "Y-m-d" );
  9035. $receiptLog->opinion = '撤回';
  9036. $receiptLog->img = $this->staff [0] ['avatar'];
  9037. $receiptLog->status = 4;
  9038. $receiptLog->rid = $rid;
  9039. $receiptLog->insert ();
  9040. $receipt->status = 4;
  9041. $receipt->update ( array (
  9042. 'where' => 'rid=' . $rid
  9043. ) );
  9044. // 微信企业号通知
  9045. $this->setWXMsg ( $rid, 2 );
  9046. }
  9047. // echo "ddd";
  9048. return '/approvalExpenses/pendApproval';
  9049. }
  9050. function updateCheReceipt() {
  9051. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9052. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  9053. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  9054. if (! empty ( $rid )) {
  9055. // 操作记录
  9056. Doo::loadModel ( "receipt" );
  9057. $receipt = new receipt ();
  9058. Doo::loadModel ( "receiptLog" );
  9059. $receiptLog = new receiptLog ();
  9060. Doo::loadModel ( "verify" );
  9061. $verify = new verify ();
  9062. $receiptInfo = $receipt->getOne ( array (
  9063. 'where' => 'rid=' . $rid . ' and status=2',
  9064. 'asArray' => true
  9065. ) );
  9066. if (empty ( $receiptInfo )) {
  9067. echo json_encode ( array (
  9068. 'status' => 2
  9069. ) );
  9070. die ();
  9071. }
  9072. $vr = $verify->getOne ( array (
  9073. 'where' => 'vid=' . $receiptInfo ['verify'],
  9074. 'asArray' => true
  9075. ) );
  9076. $jd = json_decode ( $vr ['staff'] );
  9077. $roleId = 0;
  9078. foreach ( $jd as $key => $value ) {
  9079. if ($value [1] == 'ROLE') {
  9080. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9081. if ($pos !== false) {
  9082. $roleId = $value [0];
  9083. }
  9084. }
  9085. }
  9086. // 审批日志
  9087. // echo $roleId;die;
  9088. if (! empty ( $roleId )) {
  9089. Doo::loadModel ( "role" );
  9090. $role = new role ();
  9091. $roleInfo = $role->getOne ( array (
  9092. 'where' => 'rid=' . $roleId,
  9093. 'asArray' => true
  9094. ) );
  9095. $receiptLog->rolename = $roleInfo ['name'];
  9096. }
  9097. $receiptLog->username = $this->staff [0] ['username'];
  9098. $receiptLog->uid = $this->staff [0] ['sid'];
  9099. $receiptLog->date = date ( "Y-m-d" );
  9100. $receiptLog->opinion = $opinion;
  9101. $receiptLog->img = $this->staff [0] ['avatar'];
  9102. $receiptLog->status = 4;
  9103. $receiptLog->rid = $rid;
  9104. $receiptLog->insert ();
  9105. $receipt->status = 4;
  9106. $receipt->update ( array (
  9107. 'where' => 'rid=' . $rid
  9108. ) );
  9109. // 微信企业号通知
  9110. $this->setWXMsg ( $rid, 2 );
  9111. echo json_encode ( array (
  9112. 'status' => 1
  9113. ) );
  9114. // Header("HTTP/1.1 303 See Other");
  9115. // Header("Location: /approvalExpenses/pendApproval");
  9116. die ();
  9117. }
  9118. echo json_encode ( array (
  9119. 'status' => 2
  9120. ) );
  9121. die ();
  9122. // echo "ddd";
  9123. // return '/saeaBorad';
  9124. }
  9125. function revisePrice() {
  9126. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  9127. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  9128. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9129. // echo $price;die;
  9130. if (! empty ( $rid )) {
  9131. Doo::loadModel ( "receipt" );
  9132. $receipt = new receipt ();
  9133. $receiptDetail = $receipt->getOne ( array (
  9134. 'where' => 'rid=' . $rid . ' and status=2 ',
  9135. 'asArray' => true
  9136. ) );
  9137. if (empty ( $receiptDetail ))
  9138. die ( 'illegal request' );
  9139. $reviseDetail = array ();
  9140. if (empty ( $receiptDetail ['reviseDetail'] )) {
  9141. array_push ( $reviseDetail, array (
  9142. 'sid' => $this->staff [0] ['sid'],
  9143. 'name' => $this->staff [0] ['username'],
  9144. 'description' => $description,
  9145. 'price' => $price
  9146. ) );
  9147. $reviseDetailString = json_encode ( $reviseDetail );
  9148. $receipt->reviseDetail = $reviseDetailString;
  9149. $receipt->revisePrice = $price;
  9150. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9151. } else {
  9152. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9153. array_push ( $reviseDetail, array (
  9154. 'sid' => $this->staff [0] ['sid'],
  9155. 'name' => $this->staff [0] ['username'],
  9156. 'description' => $description,
  9157. 'price' => $price
  9158. ) );
  9159. $reviseDetailString = json_encode ( $reviseDetail );
  9160. $receipt->reviseDetail = $reviseDetailString;
  9161. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  9162. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9163. }
  9164. $receipt->update ( array (
  9165. 'where' => 'rid=' . $rid
  9166. ) );
  9167. if ($receiptDetail ['Rtype'] == 1) {
  9168. if ($receiptDetail ['isBK'] == 1) {
  9169. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9170. }
  9171. } elseif ($receiptDetail ['Rtype'] == 2) {
  9172. } else {
  9173. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9174. }
  9175. }
  9176. die ( 'illegal request' );
  9177. }
  9178. function personalCollect() {
  9179. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9180. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  9181. $this->showCache ( $path );
  9182. Doo::loadModel ( "receiptDetail" );
  9183. Doo::loadModel ( "itemStatistics" );
  9184. Doo::loadModel ( 'statistics' );
  9185. $statistics = new statistics ();
  9186. $itemStatistics = new itemStatistics ();
  9187. $receiptDetail = new receiptDetail ();
  9188. $receiptCollectList = $receiptDetail->find ( array (
  9189. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9190. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9191. 'groupby' => 'itemCategory,Month(date)',
  9192. 'asArray' => true
  9193. ) );
  9194. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  9195. 'where' => 'staff=' . $this->staff [0] ['sid'],
  9196. 'asArray' => true
  9197. ) );
  9198. // create collect html
  9199. $collectArray = array (
  9200. '日常相关费用' => array (),
  9201. '差旅相关费用' => array (),
  9202. '培训班费用' => array (),
  9203. '其他' => array ()
  9204. );
  9205. $adjustment = array ();
  9206. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  9207. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9208. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  9209. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9210. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  9211. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9212. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  9213. array_push ( $collectArray ['其他'], $collectHtml );
  9214. $data ['collectArray'] = $collectArray;
  9215. // statistics html
  9216. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9217. if (empty ( $stList ))
  9218. $stList = array (
  9219. 'rePrice' => 0,
  9220. 'agPrice' => 0
  9221. );
  9222. $data ['stList'] = array (
  9223. 'rePrice' => $stList ['rePrice'],
  9224. 'agPrice' => $stList ['agPrice'],
  9225. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9226. );
  9227. // Adjustment price html
  9228. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9229. array_push ( $adjustment, $collectHtml );
  9230. $data ['adjustment'] = $adjustment;
  9231. // total price html
  9232. $collectHtml = "";
  9233. $total = 0;
  9234. for($i = 1; $i <= 12; $i ++) {
  9235. $sumPrice = 0;
  9236. foreach ( $receiptCollectList as $key => $value ) {
  9237. if ($value ['month'] == $i) {
  9238. $sumPrice += $value ['price'];
  9239. }
  9240. }
  9241. if ($sumPrice == 0)
  9242. $collectHtml .= '<td class="taR">-</td>';
  9243. else
  9244. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9245. $total += $sumPrice;
  9246. }
  9247. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9248. $data ['totalPrice'] = $collectHtml;
  9249. $dateHtml = "";
  9250. $now = date ( "Y" );
  9251. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9252. if ($YEARD <= $now) {
  9253. $dateHtml .= '<option ';
  9254. if ($year == $YEARD) {
  9255. $dateHtml .= 'selected ';
  9256. }
  9257. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9258. }
  9259. }
  9260. $data ['dateHtml'] = $dateHtml;
  9261. $data ['year'] = $year;
  9262. $data ['totalYear'] = $total;
  9263. $data ['memu'] = "receipt";
  9264. $data ['staff'] = $this->staff;
  9265. $data ['receiptMemu'] = 'personalCollect';
  9266. $data ['verifyId'] = $this->verifyId;
  9267. $data ['executeId'] = $this->executeId;
  9268. // year staff status 2,4
  9269. if ($year < date ( "Y" )) {
  9270. Doo::loadModel ( 'receipt' );
  9271. $receipt = new receipt ();
  9272. $receiptList = $receipt->find ( array (
  9273. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9274. 'asArray' => true
  9275. ) );
  9276. if (empty ( $receiptList )) {
  9277. ob_start ();
  9278. $this->render ( "/admin/saea_slist_collect", $data );
  9279. $this->cacheFile ( $path );
  9280. die ();
  9281. }
  9282. }
  9283. $this->render ( "/admin/saea_slist_collect", $data );
  9284. }
  9285. function personalCollectDetail() {
  9286. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9287. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  9288. $this->showCache ( $path );
  9289. Doo::loadModel ( "receiptDetail" );
  9290. Doo::loadModel ( "itemStatistics" );
  9291. Doo::loadModel ( 'statistics' );
  9292. Doo::loadModel ( 'accountItem' );
  9293. $accountItem = new accountItem ();
  9294. $statistics = new statistics ();
  9295. $itemStatistics = new itemStatistics ();
  9296. $receiptDetail = new receiptDetail ();
  9297. $receiptCollectList = $receiptDetail->find ( array (
  9298. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9299. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9300. 'groupby' => 'item,Month(date)',
  9301. 'asArray' => true
  9302. ) );
  9303. $accountList = $accountItem->find ( array (
  9304. 'asArray' => true
  9305. ) );
  9306. // create CollectDetail HTML
  9307. $collectHtml = array ();
  9308. foreach ( $accountList as $key => $value ) {
  9309. $html = "";
  9310. $asum = 0;
  9311. for($i = 1; $i <= 12; $i ++) {
  9312. $falg = true;
  9313. foreach ( $receiptCollectList as $v ) {
  9314. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9315. $asum += $v ['price'];
  9316. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9317. $falg = false;
  9318. break;
  9319. }
  9320. }
  9321. if ($falg)
  9322. $html .= '<td class="taR">-</td>';
  9323. }
  9324. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9325. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9326. }
  9327. $data ['collectHtml'] = $collectHtml;
  9328. // create Adjustment price html
  9329. $receiptCollectList = $receiptDetail->find ( array (
  9330. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9331. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9332. 'groupby' => 'itemCategory,Month(date)',
  9333. 'asArray' => true
  9334. ) );
  9335. $adjustment = array ();
  9336. $collectArray = array (
  9337. '日常相关费用' => array (),
  9338. '差旅相关费用' => array (),
  9339. '培训班费用' => array (),
  9340. '其他' => array ()
  9341. );
  9342. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9343. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9344. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9345. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9346. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9347. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9348. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9349. array_push ( $collectArray ['其他'], $collectHtml );
  9350. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9351. array_push ( $adjustment, $collectHtml );
  9352. // total price html
  9353. $collectHtml = "";
  9354. $total = 0;
  9355. for($i = 1; $i <= 12; $i ++) {
  9356. $sumPrice = 0;
  9357. foreach ( $receiptCollectList as $key => $value ) {
  9358. if ($value ['month'] == $i) {
  9359. $sumPrice += $value ['price'];
  9360. }
  9361. }
  9362. if ($sumPrice == 0)
  9363. $collectHtml .= '<td class="taR">-</td>';
  9364. else
  9365. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9366. $total += $sumPrice;
  9367. }
  9368. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9369. // statistics html
  9370. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9371. if (empty ( $stList ))
  9372. $stList = array (
  9373. 'rePrice' => 0,
  9374. 'agPrice' => 0
  9375. );
  9376. $data ['stList'] = array (
  9377. 'rePrice' => $stList ['rePrice'],
  9378. 'agPrice' => $stList ['agPrice'],
  9379. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9380. );
  9381. $data ['collectArray'] = $collectArray;
  9382. $data ['adjustment'] = $adjustment;
  9383. $data ['totalPrice'] = $collectHtml;
  9384. $data ['totalYear'] = $total;
  9385. $data ['year'] = $year;
  9386. $dateHtml = "";
  9387. $now = date ( "Y" );
  9388. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9389. if ($YEARD <= $now) {
  9390. $dateHtml .= '<option ';
  9391. if ($year == $YEARD) {
  9392. $dateHtml .= 'selected ';
  9393. }
  9394. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9395. }
  9396. }
  9397. $data ['dateHtml'] = $dateHtml;
  9398. $data ['memu'] = "receipt";
  9399. $data ['staff'] = $this->staff;
  9400. $data ['receiptMemu'] = 'personalCollect';
  9401. $data ['verifyId'] = $this->verifyId;
  9402. $data ['executeId'] = $this->executeId;
  9403. // year staff status 2,4
  9404. if ($year < date ( "Y" )) {
  9405. Doo::loadModel ( 'receipt' );
  9406. $receipt = new receipt ();
  9407. $receiptList = $receipt->find ( array (
  9408. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9409. 'asArray' => true
  9410. ) );
  9411. if (empty ( $receiptList )) {
  9412. ob_start ();
  9413. $this->render ( "/admin/saeaCollectArticles", $data );
  9414. $this->cacheFile ( $path );
  9415. die ();
  9416. }
  9417. }
  9418. $this->render ( "/admin/saeaCollectArticles", $data );
  9419. }
  9420. function companyCategoryCollect() {
  9421. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9422. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  9423. $this->showCache ( $path );
  9424. Doo::loadModel ( 'L_category' );
  9425. Doo::loadModel ( 'itemStatistics' );
  9426. Doo::loadModel ( 'statistics' );
  9427. $statistics = new statistics ();
  9428. $Lcategory = new L_category ();
  9429. $itemStatistics = new itemStatistics ();
  9430. Doo::loadModel ( "receiptAuthorityManage" );
  9431. $receiptAuthorityManage = new receiptAuthorityManage ();
  9432. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9433. $cidList = array ();
  9434. foreach ( $imcStaff as $key => $value ) {
  9435. array_push ( $cidList, $value ['cid'] );
  9436. }
  9437. $cidString = implode ( ',', $cidList );
  9438. $LcategoryList = $Lcategory->find ( array (
  9439. 'where' => ' cid in (' . $cidString . ')',
  9440. 'asArray' => true
  9441. ) ); // 'staff='.$this->staff[0]['sid']." and
  9442. $itemStatisticsList = $itemStatistics->find ( array (
  9443. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9444. 'where' => " Year(date)=" . $year,
  9445. 'groupby' => 'cid,Month(date)',
  9446. 'asArray' => true
  9447. ) );
  9448. // ceatre companyCollectHtml
  9449. foreach ( $LcategoryList as $value ) {
  9450. $html = "";
  9451. $asum = 0;
  9452. for($i = 1; $i <= 12; $i ++) {
  9453. $falg = true;
  9454. foreach ( $itemStatisticsList as $v ) {
  9455. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  9456. $asum += $v ['price'];
  9457. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9458. $falg = false;
  9459. break;
  9460. }
  9461. }
  9462. if ($falg)
  9463. $html .= '<td class="taR">-</td>';
  9464. }
  9465. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9466. $collectHtml [$value ['title']] = array (
  9467. 'html' => $html,
  9468. 'cid' => $value ['cid']
  9469. );
  9470. }
  9471. $data ['companyHtml'] = $collectHtml;
  9472. // total price html
  9473. $collectHtml = "";
  9474. $total = 0;
  9475. for($i = 1; $i <= 12; $i ++) {
  9476. $sumPrice = 0;
  9477. foreach ( $itemStatisticsList as $key => $value ) {
  9478. if ($value ['month'] == $i) {
  9479. $sumPrice += $value ['price'];
  9480. }
  9481. }
  9482. if ($sumPrice == 0)
  9483. $collectHtml .= '<td class="taR">-</td>';
  9484. else
  9485. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9486. $total += $sumPrice;
  9487. }
  9488. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9489. $data ['companyTotalHtml'] = $collectHtml;
  9490. $data ['total'] = $total;
  9491. // statistics html
  9492. // echo $cidString;
  9493. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9494. if (empty ( $stList ))
  9495. $stList = array (
  9496. 'rePrice' => 0,
  9497. 'agPrice' => 0
  9498. );
  9499. $data ['stList'] = array (
  9500. 'rePrice' => $stList ['rePrice'],
  9501. 'agPrice' => $stList ['agPrice'],
  9502. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9503. );
  9504. $data ['year'] = $year;
  9505. $data ['memu'] = "receipt";
  9506. $data ['staff'] = $this->staff;
  9507. $data ['receiptMemu'] = 'companyCategoryCollect';
  9508. $data ['verifyId'] = $this->verifyId;
  9509. $data ['executeId'] = $this->executeId;
  9510. $dateHtml = "";
  9511. $now = date ( "Y" );
  9512. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9513. if ($YEARD <= $now) {
  9514. $dateHtml .= '<option ';
  9515. if ($year == $YEARD) {
  9516. $dateHtml .= 'selected ';
  9517. }
  9518. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9519. }
  9520. }
  9521. $data ['dateHtml'] = $dateHtml;
  9522. // year staff status 2,4
  9523. if ($year < date ( "Y" )) {
  9524. Doo::loadModel ( 'receipt' );
  9525. $receipt = new receipt ();
  9526. $receiptList = $receipt->find ( array (
  9527. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  9528. 'asArray' => true
  9529. ) );
  9530. if (empty ( $receiptList )) {
  9531. ob_start ();
  9532. $this->render ( "/admin/saeaCompanyCollect", $data );
  9533. $this->cacheFile ( $path );
  9534. die ();
  9535. }
  9536. }
  9537. $this->render ( "/admin/saeaCompanyCollect", $data );
  9538. }
  9539. function categoryCollectDetail() {
  9540. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9541. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  9542. /* $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  9543. $this->showCache ( $path ); */
  9544. Doo::loadModel ( 'statistics' );
  9545. $statistics = new statistics ();
  9546. Doo::loadModel ( "receiptDetail" );
  9547. $receiptDetail = new receiptDetail ();
  9548. Doo::loadModel ( 'L_category' );
  9549. $Lcategory = new L_category ();
  9550. Doo::loadModel ( 'accountItem' );
  9551. $accountItem = new accountItem ();
  9552. Doo::loadModel ( "receiptAuthorityManage" );
  9553. $receiptAuthorityManage = new receiptAuthorityManage ();
  9554. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9555. $cidList = array ();
  9556. foreach ( $imcStaff as $key => $value ) {
  9557. array_push ( $cidList, $value ['cid'] );
  9558. }
  9559. $cidString = implode ( ',', $cidList );
  9560. $LcategoryList = $Lcategory->find ( array (
  9561. 'where' => 'cid in (' . $cidString . ')',
  9562. 'asArray' => true
  9563. ) );
  9564. if ($cid == 0) {
  9565. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9566. if ($cid == 0)
  9567. $cid = $LcategoryList [0] ['cid'];
  9568. }
  9569. $data ['LcategoryList'] = $LcategoryList;
  9570. $receiptCollectList = $receiptDetail->find ( array (
  9571. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9572. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9573. 'groupby' => 'item,Month(pastDate)',
  9574. 'asArray' => true
  9575. ) );
  9576. $accountList = $accountItem->find ( array (
  9577. 'asArray' => true
  9578. ) );
  9579. // create CollectDetail HTML
  9580. $collectHtml = array ();
  9581. foreach ( $accountList as $key => $value ) {
  9582. $html = "";
  9583. $asum = 0;
  9584. for($i = 1; $i <= 12; $i ++) {
  9585. $falg = true;
  9586. foreach ( $receiptCollectList as $v ) {
  9587. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9588. $asum += $v ['price'];
  9589. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9590. $falg = false;
  9591. break;
  9592. }
  9593. }
  9594. if ($falg)
  9595. $html .= '<td class="taR">-</td>';
  9596. }
  9597. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9598. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9599. }
  9600. $data ['collectHtml'] = $collectHtml;
  9601. // create Adjustment price html
  9602. $receiptCollectList = $receiptDetail->find ( array (
  9603. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9604. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9605. 'groupby' => 'itemCategory,Month(pastDate)',
  9606. 'asArray' => true
  9607. ) );
  9608. $adjustment = array ();
  9609. $collectArray = array (
  9610. '日常相关费用' => array (),
  9611. '差旅相关费用' => array (),
  9612. '培训班费用' => array (),
  9613. '内部培训费用'=>array(),
  9614. '其他' => array ()
  9615. );
  9616. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9617. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9618. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9619. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9620. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9621. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9622. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  9623. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  9624. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9625. array_push ( $collectArray ['其他'], $collectHtml );
  9626. $data ['collectArray'] = $collectArray;
  9627. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9628. array_push ( $adjustment, $collectHtml );
  9629. $data ['adjustment'] = $adjustment;
  9630. // total price html
  9631. $collectHtml = "";
  9632. $total = 0;
  9633. for($i = 1; $i <= 12; $i ++) {
  9634. $sumPrice = 0;
  9635. foreach ( $receiptCollectList as $key => $value ) {
  9636. if ($value ['month'] == $i) {
  9637. $sumPrice += $value ['price'];
  9638. }
  9639. }
  9640. if ($sumPrice == 0)
  9641. $collectHtml .= '<td class="taR">-</td>';
  9642. else
  9643. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9644. $total += $sumPrice;
  9645. }
  9646. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9647. // statistics html
  9648. $stList = $statistics->statisticsByCid ( $year, $cid );
  9649. if (empty ( $stList ))
  9650. $stList = array (
  9651. 'rePrice' => 0,
  9652. 'agPrice' => 0
  9653. );
  9654. $data ['stList'] = array (
  9655. 'rePrice' => $stList ['rePrice'],
  9656. 'agPrice' => $stList ['agPrice'],
  9657. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9658. );
  9659. $data ['totalYear'] = $total;
  9660. $data ['year'] = $year;
  9661. $data ['cid'] = $cid;
  9662. $data ['memu'] = "receipt";
  9663. $data ['staff'] = $this->staff;
  9664. $data ['receiptMemu'] = 'companyCategoryCollect';
  9665. $data ['verifyId'] = $this->verifyId;
  9666. $data ['executeId'] = $this->executeId;
  9667. // year staff status 2,4
  9668. /* if ($year < date ( "Y" )) {
  9669. Doo::loadModel ( 'receipt' );
  9670. $receipt = new receipt ();
  9671. $receiptList = $receipt->find ( array (
  9672. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  9673. 'asArray' => true
  9674. ) );
  9675. if (empty ( $receiptList )) {
  9676. ob_start ();
  9677. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  9678. $this->cacheFile ( $path );
  9679. die ();
  9680. }
  9681. } */
  9682. $dateHtml = "";
  9683. $now = date ( "Y" );
  9684. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9685. if ($YEARD <= $now) {
  9686. $dateHtml .= '<option ';
  9687. if ($year == $YEARD) {
  9688. $dateHtml .= 'selected ';
  9689. }
  9690. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9691. }
  9692. }
  9693. $data ['dateHtml'] = $dateHtml;
  9694. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  9695. }
  9696. function staffCollect() {
  9697. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9698. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ONJOB';//
  9699. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  9700. // $this->showCache($path);
  9701. Doo::loadModel ( 'statistics' );
  9702. $statistics = new statistics ();
  9703. Doo::loadModel ( "receiptDetail" );
  9704. $receiptDetail = new receiptDetail ();
  9705. Doo::loadModel ( 'L_category' );
  9706. $Lcategory = new L_category ();
  9707. Doo::loadModel ( 'accountItem' );
  9708. $accountItem = new accountItem ();
  9709. Doo::loadModel ( 'staff' );
  9710. $staff = new staff ();
  9711. Doo::loadModel ( 'itemStatistics' );
  9712. $itemStatistics = new itemStatistics ();
  9713. Doo::loadModel ( "receiptAuthorityManage" );
  9714. $receiptAuthorityManage = new receiptAuthorityManage ();
  9715. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9716. $cidList = array ();
  9717. foreach ( $imcStaff as $key => $value ) {
  9718. array_push ( $cidList, $value ['cid'] );
  9719. }
  9720. $cidString = implode ( ',', $cidList );
  9721. $naturecon='';
  9722. if ($nature=='ONJOB'){
  9723. $naturecon=' and (nature!=4 )';
  9724. }elseif($nature=='LEAVEJOB'){
  9725. $naturecon=' and (nature=4 )';
  9726. }else{
  9727. die ( 'illegal request--nature' );
  9728. }
  9729. // statistics html
  9730. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9731. if (empty ( $stList ))
  9732. $stList = array (
  9733. 'rePrice' => 0,
  9734. 'agPrice' => 0
  9735. );
  9736. $data ['stList'] = array (
  9737. 'rePrice' => $stList ['rePrice'],
  9738. 'agPrice' => $stList ['agPrice'],
  9739. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9740. );
  9741. // ---
  9742. $staffList = $staff->find ( array (
  9743. 'where' => 'username !="admin" '.$naturecon,
  9744. 'asArray' => true
  9745. ) );
  9746. $LcategoryList = $Lcategory->find ( array (
  9747. 'asArray' => true
  9748. ) ); // 'staff='.$this->staff[0]['sid']." and
  9749. $itemStatisticsList = $itemStatistics->find ( array (
  9750. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9751. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  9752. 'groupby' => 'staff,Month(date)',
  9753. 'asArray' => true
  9754. ) );
  9755. $categoryList = $staff->find ( array (
  9756. 'select' => 'COUNT(*) as count,cid,category',
  9757. 'where' => 'username !="admin" and cid in (' . $cidString . ') '.$naturecon,
  9758. 'groupby' => 'cid',
  9759. 'asArray' => true
  9760. ) );
  9761. // print_r($itemStatisticsList);die;
  9762. // ceatre companyCollectHtml
  9763. foreach ( $categoryList as $vlu ) {
  9764. $count = $vlu ['count'] + 1;
  9765. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  9766. $m1 = 0;
  9767. $m2 = 0;
  9768. $m3 = 0;
  9769. $m4 = 0;
  9770. $m5 = 0;
  9771. $m6 = 0;
  9772. $m7 = 0;
  9773. $m8 = 0;
  9774. $m9 = 0;
  9775. $m10 = 0;
  9776. $m11 = 0;
  9777. $m12 = 0;
  9778. $m13 = 0;
  9779. foreach ( $staffList as $value ) {
  9780. if ($vlu ['cid'] == $value ['cid']) {
  9781. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  9782. $asum = 0;
  9783. for($i = 1; $i <= 12; $i ++) {
  9784. $falg = true;
  9785. foreach ( $itemStatisticsList as $v ) {
  9786. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  9787. if ($v ['month'] == 1)
  9788. $m1 += $v ['price'];
  9789. if ($v ['month'] == 2)
  9790. $m2 += $v ['price'];
  9791. if ($v ['month'] == 3)
  9792. $m3 += $v ['price'];
  9793. if ($v ['month'] == 4)
  9794. $m4 += $v ['price'];
  9795. if ($v ['month'] == 5)
  9796. $m5 += $v ['price'];
  9797. if ($v ['month'] == 6)
  9798. $m6 += $v ['price'];
  9799. if ($v ['month'] == 7)
  9800. $m7 += $v ['price'];
  9801. if ($v ['month'] == 8)
  9802. $m8 += $v ['price'];
  9803. if ($v ['month'] == 9)
  9804. $m9 += $v ['price'];
  9805. if ($v ['month'] == 10)
  9806. $m10 += $v ['price'];
  9807. if ($v ['month'] == 11)
  9808. $m11 += $v ['price'];
  9809. if ($v ['month'] == 12)
  9810. $m12 += $v ['price'];
  9811. $asum += $v ['price'];
  9812. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9813. $falg = false;
  9814. break;
  9815. }
  9816. }
  9817. if ($falg)
  9818. $html .= '<td class="taR">-</td>';
  9819. }
  9820. $m13 += $asum;
  9821. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9822. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  9823. 'html' => $html,
  9824. 'sid' => $value ['sid']
  9825. );
  9826. $html = "";
  9827. }
  9828. }
  9829. $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>
  9830. <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>
  9831. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  9832. $collectHtml [$vlu ['cid']] = array (
  9833. 'html' => $hl,
  9834. 'sid' => ''
  9835. );
  9836. }
  9837. $data ['companyHtml'] = $collectHtml;
  9838. // total price html
  9839. $collectHtml = "";
  9840. $total = 0;
  9841. for($i = 1; $i <= 12; $i ++) {
  9842. $sumPrice = 0;
  9843. foreach ( $itemStatisticsList as $key => $value ) {
  9844. if ($value ['month'] == $i) {
  9845. $sumPrice += $value ['price'];
  9846. }
  9847. }
  9848. if ($sumPrice == 0)
  9849. $collectHtml .= '<td class="taR">-</td>';
  9850. else
  9851. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9852. $total += $sumPrice;
  9853. }
  9854. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9855. $data ['companyTotalHtml'] = $collectHtml;
  9856. $data ['total'] = $total;
  9857. $data ['nature'] =$nature;
  9858. $data ['year'] = $year;
  9859. $data ['memu'] = "receipt";
  9860. $data ['staff'] = $this->staff;
  9861. $data ['receiptMemu'] = 'companyCategoryCollect';
  9862. $data ['verifyId'] = $this->verifyId;
  9863. $data ['executeId'] = $this->executeId;
  9864. if ($year <= date ( "Y" )) {
  9865. Doo::loadModel ( 'receipt' );
  9866. $receipt = new receipt ();
  9867. $receiptList = $receipt->find ( array (
  9868. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  9869. 'asArray' => true
  9870. ) );
  9871. if (empty ( $receiptList )) { // generated files
  9872. ob_start ();
  9873. $this->render ( "/admin/saeaStaffCollectB", $data );
  9874. $this->cacheFile ( $path );
  9875. die ();
  9876. }
  9877. }
  9878. $this->render ( "/admin/saeaStaffCollectB", $data );
  9879. }
  9880. function staffCollectBak() {
  9881. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9882. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  9883. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  9884. $this->showCache ( $path );
  9885. Doo::loadModel ( 'statistics' );
  9886. $statistics = new statistics ();
  9887. Doo::loadModel ( "receiptDetail" );
  9888. $receiptDetail = new receiptDetail ();
  9889. Doo::loadModel ( 'L_category' );
  9890. $Lcategory = new L_category ();
  9891. Doo::loadModel ( 'accountItem' );
  9892. $accountItem = new accountItem ();
  9893. Doo::loadModel ( 'staff' );
  9894. $staff = new staff ();
  9895. Doo::loadModel ( 'itemStatistics' );
  9896. $itemStatistics = new itemStatistics ();
  9897. $itemStatisticsList = $itemStatistics->find ( array (
  9898. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9899. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9900. 'groupby' => 'staff,itemCategory,Month(date)',
  9901. 'asArray' => true
  9902. ) );
  9903. $itemCategoryList = $itemStatistics->find ( array (
  9904. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9905. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9906. 'groupby' => 'cid,itemCategory,Month(date)',
  9907. 'asArray' => true
  9908. ) );
  9909. $LcategoryList = $Lcategory->find ( array (
  9910. 'asArray' => true
  9911. ) );
  9912. $staffList = $staff->find ( array (
  9913. 'asArray' => true
  9914. ) );
  9915. $htmlArray = array ();
  9916. foreach ( $LcategoryList as $value ) {
  9917. $htmlArray [$value ['title']] = array ();
  9918. foreach ( $staffList as $v ) {
  9919. if ($value ['cid'] == $v ['cid']) {
  9920. $html = "";
  9921. $falg = true;
  9922. $staffSumPrice = 0;
  9923. foreach ( $itemStatisticsList as $a ) {
  9924. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  9925. if (empty ( $a ['price'] )) {
  9926. $html .= '<td class="taR">-</td>';
  9927. $falg = false;
  9928. break;
  9929. } else {
  9930. $staffSumPrice += $a ['price'];
  9931. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9932. $falg = false;
  9933. break;
  9934. }
  9935. }
  9936. }
  9937. if ($falg) {
  9938. $html .= '<td class="taR">-</td>';
  9939. $falg = true;
  9940. }
  9941. $falg = true;
  9942. foreach ( $itemStatisticsList as $a ) {
  9943. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  9944. if (empty ( $a ['price'] )) {
  9945. $html .= '<td class="taR">-</td>';
  9946. $falg = false;
  9947. break;
  9948. } else {
  9949. $staffSumPrice += $a ['price'];
  9950. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9951. $falg = false;
  9952. break;
  9953. }
  9954. }
  9955. }
  9956. if ($falg) {
  9957. $html .= '<td class="taR">-</td>';
  9958. $falg = true;
  9959. }
  9960. $falg = true;
  9961. foreach ( $itemStatisticsList as $a ) {
  9962. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  9963. if (empty ( $a ['price'] )) {
  9964. $html .= '<td class="taR">-</td>';
  9965. $falg = false;
  9966. break;
  9967. } else {
  9968. $staffSumPrice += $a ['price'];
  9969. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9970. $falg = false;
  9971. break;
  9972. }
  9973. }
  9974. }
  9975. if ($falg) {
  9976. $html .= '<td class="taR">-</td>';
  9977. $falg = true;
  9978. }
  9979. $falg = true;
  9980. foreach ( $itemStatisticsList as $a ) {
  9981. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  9982. if (! empty ( $a ['price'] )) {
  9983. $staffSumPrice += $a ['price'];
  9984. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9985. $falg = false;
  9986. break;
  9987. } else {
  9988. $html .= '<td class="taR">-</td>';
  9989. $falg = false;
  9990. break;
  9991. }
  9992. }
  9993. }
  9994. if ($falg) {
  9995. $html .= '<td class="taR">-</td>';
  9996. $falg = true;
  9997. }
  9998. $falg = true;
  9999. foreach ( $itemStatisticsList as $a ) {
  10000. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  10001. if (! empty ( $a ['price'] )) {
  10002. $staffSumPrice += $a ['price'];
  10003. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10004. $falg = false;
  10005. break;
  10006. } else {
  10007. $html .= '<td class="taR">-</td>';
  10008. $falg = false;
  10009. break;
  10010. }
  10011. }
  10012. }
  10013. if ($falg) {
  10014. $html .= '<td class="taR">-</td>';
  10015. $falg = true;
  10016. }
  10017. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  10018. $htmlArray [$value ['title']] [$v ['username']] = $html;
  10019. }
  10020. }
  10021. /* -- --- */
  10022. // 合计费用
  10023. $cateHtml = "";
  10024. $catePrice = 0;
  10025. $cateFalg = true;
  10026. foreach ( $itemCategoryList as $l ) {
  10027. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  10028. if (empty ( $l ['price'] )) {
  10029. $cateHtml .= '<td class="colGreen taR">-</td>';
  10030. $cateFalg = false;
  10031. break;
  10032. } else {
  10033. $catePrice += $l ['price'];
  10034. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10035. $cateFalg = false;
  10036. break;
  10037. }
  10038. }
  10039. }
  10040. if ($cateFalg) {
  10041. $cateHtml .= '<td class="colGreen taR">-</td>';
  10042. $cateFalg = true;
  10043. }
  10044. $cateFalg = true;
  10045. foreach ( $itemCategoryList as $l ) {
  10046. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  10047. if (empty ( $l ['price'] )) {
  10048. $cateHtml .= '<td class="colGreen taR">-</td>';
  10049. $cateFalg = false;
  10050. break;
  10051. } else {
  10052. $catePrice += $l ['price'];
  10053. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10054. $cateFalg = false;
  10055. break;
  10056. }
  10057. }
  10058. }
  10059. if ($cateFalg) {
  10060. $cateHtml .= '<td class="colGreen taR">-</td>';
  10061. $cateFalg = true;
  10062. }
  10063. $cateFalg = true;
  10064. foreach ( $itemCategoryList as $l ) {
  10065. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  10066. if (empty ( $l ['price'] )) {
  10067. $cateHtml .= '<td class="colGreen taR">-</td>';
  10068. $cateFalg = false;
  10069. break;
  10070. } else {
  10071. $catePrice += $l ['price'];
  10072. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10073. $cateFalg = false;
  10074. break;
  10075. }
  10076. }
  10077. }
  10078. if ($cateFalg) {
  10079. $cateHtml .= '<td class="colGreen taR">-</td>';
  10080. $cateFalg = true;
  10081. }
  10082. $cateFalg = true;
  10083. foreach ( $itemCategoryList as $l ) {
  10084. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  10085. if (empty ( $l ['price'] )) {
  10086. $cateHtml .= '<td class="colGreen taR">-</td>';
  10087. $cateFalg = false;
  10088. break;
  10089. } else {
  10090. $catePrice += $l ['price'];
  10091. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10092. $cateFalg = false;
  10093. break;
  10094. }
  10095. }
  10096. }
  10097. if ($cateFalg) {
  10098. $cateHtml .= '<td class="colGreen taR">-</td>';
  10099. $cateFalg = true;
  10100. }
  10101. $cateFalg = true;
  10102. foreach ( $itemCategoryList as $l ) {
  10103. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  10104. if (empty ( $l ['price'] )) {
  10105. $cateHtml .= '<td class="colGreen taR">-</td>';
  10106. $cateFalg = false;
  10107. break;
  10108. } else {
  10109. $catePrice += $l ['price'];
  10110. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10111. $cateFalg = false;
  10112. break;
  10113. }
  10114. }
  10115. }
  10116. if ($cateFalg) {
  10117. $cateHtml .= '<td class="colGreen taR">-</td>';
  10118. $cateFalg = true;
  10119. }
  10120. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  10121. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  10122. /* -- --- */
  10123. }
  10124. // print_r($htmlArray);die;
  10125. $data ['htmlArray'] = $htmlArray;
  10126. // statistics html
  10127. $stList = $statistics->getOne ( array (
  10128. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  10129. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10130. 'groupby' => 'Month(date)',
  10131. 'asArray' => true
  10132. ) );
  10133. if (empty ( $stList ))
  10134. $stList = array (
  10135. 'rePrice' => 0,
  10136. 'agPrice' => 0
  10137. );
  10138. $data ['stList'] = array (
  10139. 'rePrice' => $stList ['rePrice'],
  10140. 'agPrice' => $stList ['agPrice'],
  10141. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10142. );
  10143. $monthHtml = "";
  10144. for($i = 1; $i <= 12; $i ++) {
  10145. if ($i == $month)
  10146. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  10147. else
  10148. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  10149. }
  10150. $data ['monthHtml'] = $monthHtml;
  10151. $data ['year'] = $year;
  10152. $data ['month'] = $month;
  10153. $data ['memu'] = "receipt";
  10154. $data ['staff'] = $this->staff;
  10155. $data ['receiptMemu'] = 'companyCategoryCollect';
  10156. $data ['verifyId'] = $this->verifyId;
  10157. $data ['executeId'] = $this->executeId;
  10158. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  10159. Doo::loadModel ( 'receipt' );
  10160. $receipt = new receipt ();
  10161. $receiptList = $receipt->find ( array (
  10162. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  10163. 'asArray' => true
  10164. ) );
  10165. if (empty ( $receiptList )) { // generated files
  10166. ob_start ();
  10167. $this->render ( "/admin/saeaStaffCollect", $data );
  10168. $this->cacheFile ( $path );
  10169. die ();
  10170. }
  10171. }
  10172. $this->render ( "/admin/saeaStaffCollect", $data );
  10173. }
  10174. /**
  10175. * 日常收支
  10176. */
  10177. function payments() {
  10178. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  10179. Doo::loadModel ( "execute" );
  10180. $execute = new execute ();
  10181. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  10182. die ( 'illegal request' );
  10183. }
  10184. Doo::loadModel ( "accountBook" );
  10185. $accountBook = new accountBook ();
  10186. Doo::loadModel ( "accountBookStatistics" );
  10187. $accountBookStatistics = new accountBookStatistics ();
  10188. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  10189. $list = $accountBook->getAccountBookByLimit ( 10 );
  10190. $data ['date'] = date ( "Y-m-d" );
  10191. $data ['statisticsList'] = $statisticsList;
  10192. $data ['list'] = $list;
  10193. $data ['memu'] = "receipt";
  10194. $data ['staff'] = $this->staff;
  10195. $data ['receiptMemu'] = 'payments';
  10196. $data ['verifyId'] = $this->verifyId;
  10197. $data ['executeId'] = $this->executeId;
  10198. $this->render ( "/expenses/payments", $data );
  10199. }
  10200. function paymentsIncomeDo() {
  10201. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10202. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10203. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10204. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10205. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10206. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10207. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10208. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10209. Doo::loadClass ( 'XDeode' );
  10210. $XDeode = new XDeode ( 5 );
  10211. Doo::loadModel ( "accountBook" );
  10212. Doo::loadModel ( "accountBookStatistics" );
  10213. Doo::loadModel ( 'wasteBook' );
  10214. // 记录流水时银行的转换
  10215. $accountBank = '';
  10216. if ($receivedBank == '纵横广发') {
  10217. $accountBank = 'CGBDeposit';
  10218. } elseif ($receivedBank == '纵横工行') {
  10219. $accountBank = 'ICBCDeposit';
  10220. } elseif ($receivedBank == '华润银行') {
  10221. $accountBank = 'HUADeposit';
  10222. } elseif ($receivedBank == '个人广发') {
  10223. $accountBank = 'PersonalDeposit';
  10224. }
  10225. if (empty ( $accountBank ))
  10226. die ( 'illegal request' );
  10227. // 收入为理财时特殊处理
  10228. if ($accountType == 7 || $accountType == 9) {
  10229. if ($receivedBank == '个人广发') {
  10230. die ( '个人广发 illegal request' );
  10231. }
  10232. // 添加一条收入
  10233. $accountBook = new accountBook ();
  10234. $accountBook->accountType = 10;
  10235. $accountBook->accountMsg = $accountMsg;
  10236. $accountBook->receivedPrice = $receivedPrice;
  10237. $accountBook->receivedMsg = $receivedMsg;
  10238. $accountBook->receivedBank = $receivedBank;
  10239. $accountBook->receivedDate = $receivedDate;
  10240. $accountBook->remarks = $remarks;
  10241. $accountBook->expensesType = 1;
  10242. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10243. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10244. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10245. $inComeId = $accountBook->insert ();
  10246. // 收支汇总-添加一条收入日常汇总
  10247. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10248. $accountBookStatistics = new accountBookStatistics ();
  10249. $item = array (
  10250. 'date' => date ( "Y-m-d" ),
  10251. 'accountType' => $abDetail ['accountType'],
  10252. 'accountMsg' => $abDetail ['accountMsg'],
  10253. 'aid' => $abDetail ['aid'],
  10254. 'inComePrice' => $abDetail ['receivedPrice'],
  10255. 'expensesType' => $abDetail ['expensesType']
  10256. );
  10257. $accountBookStatistics->setAccountBookStatistics ( $item );
  10258. // 添加收入流水
  10259. $wasteBook = new wasteBook ();
  10260. $itemWaste = array (
  10261. 'accountPriceShow' => $receivedPrice,
  10262. 'accountPrice' => $receivedPrice,
  10263. 'expensesType' => 1,
  10264. 'accountType' => 6, // 流水类型
  10265. 'dataID' => $inComeId,
  10266. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10267. 'accountBank' => $accountBank,
  10268. 'category' => $this->staff [0] ['category'],
  10269. 'cid' => $this->staff [0] ['cid'],
  10270. 'name' => $this->staff [0] ['username'],
  10271. 'sid' => $this->staff [0] ['sid'],
  10272. 'inputDate' => date ( "Y-m-d H:i:s" )
  10273. );
  10274. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10275. // 添加一条理财支出
  10276. $accountBank = 'CGBDeposit';
  10277. $expenditureBank = '纵横广发';
  10278. $dailyExpenditureType = 4;
  10279. if ($accountType == 9) {
  10280. $accountBank = 'ICBCDeposit';
  10281. $expenditureBank = '纵横工行';
  10282. $dailyExpenditureType = 6;
  10283. }
  10284. $accountBook = new accountBook ();
  10285. $accountBook->expensesType = 2;
  10286. $accountBook->expenditureType = $dailyExpenditureType;
  10287. $accountBook->expenditureMsg = $accountMsg;
  10288. $accountBook->expenditurePrice = $receivedPrice;
  10289. $accountBook->expenditureBank = $expenditureBank;
  10290. $accountBook->expenditureDate = $receivedDate;
  10291. $accountBook->remarks = $remarks;
  10292. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10293. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10294. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10295. $id = $accountBook->insert ();
  10296. // 收支汇总-添加一条理财支出汇总
  10297. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10298. $accountBookStatistics = new accountBookStatistics ();
  10299. $item = array (
  10300. 'date' => date ( "Y-m-d" ),
  10301. 'accountType' => $abDetail ['accountType'],
  10302. 'accountMsg' => $abDetail ['accountMsg'],
  10303. 'aid' => $abDetail ['aid'],
  10304. 'financingPrice' => - $receivedPrice,
  10305. 'expensesType' => 3
  10306. );
  10307. $accountBookStatistics->setAccountBookStatistics ( $item );
  10308. // 添加一条支出理财流水
  10309. $accountTypeWaste = 5;
  10310. if ($accountMsg == '公司固定') {
  10311. $accountTypeWaste = 9;
  10312. } elseif ($accountMsg == '公司活期') {
  10313. $accountTypeWaste = 10;
  10314. } elseif ($accountMsg == '个人(GR)') {
  10315. $accountBank = 'PersonalDeposit';
  10316. }
  10317. $itemWaste = array (
  10318. 'expensesType' => 2,
  10319. 'accountType' => $accountTypeWaste,
  10320. 'accountPriceShow' => $receivedPrice,
  10321. 'accountPrice' => - $receivedPrice,
  10322. 'dataID' => $id,
  10323. 'dailyExpenditureType' => $dailyExpenditureType,
  10324. 'accountBank' => $accountBank,
  10325. 'category' => $this->staff [0] ['category'],
  10326. 'cid' => $this->staff [0] ['cid'],
  10327. 'name' => $this->staff [0] ['username'],
  10328. 'sid' => $this->staff [0] ['sid'],
  10329. 'inputDate' => date ( "Y-m-d H:i:s" )
  10330. );
  10331. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10332. } elseif ($accountType == 1) {
  10333. if ($receivedBank == '个人广发')
  10334. die ( 'illegal request' );
  10335. // 添加一条收入
  10336. $accountBook = new accountBook ();
  10337. $accountBook->accountType = $accountType;
  10338. $accountBook->accountMsg = $accountMsg;
  10339. $accountBook->receivedPrice = $receivedPrice;
  10340. $accountBook->receivedMsg = $receivedMsg;
  10341. $accountBook->receivedBank = $receivedBank;
  10342. $accountBook->receivedDate = $receivedDate;
  10343. $accountBook->remarks = $remarks;
  10344. $accountBook->expensesType = 1;
  10345. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10346. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10347. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10348. $id = $accountBook->insert ();
  10349. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10350. // 收支汇总-添加一条收入日常汇总
  10351. $accountBookStatistics = new accountBookStatistics ();
  10352. $item = array (
  10353. 'date' => date ( "Y-m-d" ),
  10354. 'accountType' => $abDetail ['accountType'],
  10355. 'accountMsg' => $abDetail ['accountMsg'],
  10356. 'aid' => $abDetail ['aid'],
  10357. 'expensesType' => $abDetail ['expensesType']
  10358. );
  10359. if ($abDetail ['accountType'] == 8) {
  10360. $item += array (
  10361. 'inComePrice' => $abDetail ['receivedPrice']
  10362. );
  10363. } else {
  10364. $item += array (
  10365. 'inComePrice' => $abDetail ['receivedPrice']
  10366. );
  10367. }
  10368. $accountBookStatistics->setAccountBookStatistics ( $item );
  10369. // 流水存储方向
  10370. $itemWaste = array (
  10371. 'accountType' => 6
  10372. ); // 流水类型
  10373. // if($accountMsg=='银行存款'||$accountMsg=='固定理财收益'){
  10374. // }else
  10375. if ($accountMsg == '活期理财收益') {
  10376. $itemWaste = array (
  10377. 'accountType' => 10
  10378. ); // 流水类型
  10379. }
  10380. // 添加收入流水
  10381. $wasteBook = new wasteBook ();
  10382. $itemWaste += array (
  10383. 'accountPrice' => $receivedPrice,
  10384. 'accountPriceShow' => $receivedPrice,
  10385. 'expensesType' => 1,
  10386. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10387. 'dataID' => $id,
  10388. 'accountBank' => $accountBank,
  10389. 'category' => $this->staff [0] ['category'],
  10390. 'cid' => $this->staff [0] ['cid'],
  10391. 'name' => $this->staff [0] ['username'],
  10392. 'sid' => $this->staff [0] ['sid'],
  10393. 'inputDate' => date ( "Y-m-d H:i:s" )
  10394. );
  10395. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10396. } else { // 普通日常收入处理
  10397. // 添加一条收入
  10398. $accountBook = new accountBook ();
  10399. $accountBook->accountType = $accountType;
  10400. $accountBook->accountMsg = $accountMsg;
  10401. $accountBook->receivedPrice = $receivedPrice;
  10402. $accountBook->receivedMsg = $receivedMsg;
  10403. $accountBook->receivedBank = $receivedBank;
  10404. $accountBook->receivedDate = $receivedDate;
  10405. $accountBook->remarks = $remarks;
  10406. $accountBook->expensesType = 1;
  10407. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10408. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10409. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10410. $id = $accountBook->insert ();
  10411. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10412. // 收支汇总-添加一条收入日常汇总
  10413. $accountBookStatistics = new accountBookStatistics ();
  10414. $item = array (
  10415. 'date' => date ( "Y-m-d" ),
  10416. 'accountType' => $abDetail ['accountType'],
  10417. 'accountMsg' => $abDetail ['accountMsg'],
  10418. 'aid' => $abDetail ['aid'],
  10419. 'expensesType' => $abDetail ['expensesType']
  10420. );
  10421. if ($abDetail ['accountType'] == 8) {
  10422. $item += array (
  10423. 'inComePrice' => $abDetail ['receivedPrice']
  10424. );
  10425. } else {
  10426. $item += array (
  10427. 'inComePrice' => $abDetail ['receivedPrice']
  10428. );
  10429. }
  10430. $accountBookStatistics->setAccountBookStatistics ( $item );
  10431. // 添加收入流水
  10432. $itemWaste = array (
  10433. 'accountPrice' => $receivedPrice
  10434. );
  10435. if ($receivedBank == '个人广发') {
  10436. $itemWaste = array (
  10437. 'accountPrice' => - $receivedPrice
  10438. );
  10439. }
  10440. $wasteBook = new wasteBook ();
  10441. $itemWaste += array (
  10442. 'accountPriceShow' => $receivedPrice,
  10443. 'expensesType' => 1,
  10444. 'accountType' => 6, // 流水类型
  10445. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10446. 'dataID' => $id,
  10447. 'accountBank' => $accountBank,
  10448. 'category' => $this->staff [0] ['category'],
  10449. 'cid' => $this->staff [0] ['cid'],
  10450. 'name' => $this->staff [0] ['username'],
  10451. 'sid' => $this->staff [0] ['sid'],
  10452. 'inputDate' => date ( "Y-m-d H:i:s" )
  10453. );
  10454. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10455. }
  10456. }
  10457. return '/payments';
  10458. }
  10459. /**
  10460. * 添加收入
  10461. * @return string
  10462. */
  10463. function paymentsIncomeDo_() {
  10464. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10465. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10466. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10467. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10468. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10469. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10470. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10471. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10472. Doo::loadClass ( 'XDeode' );
  10473. $XDeode = new XDeode ( 5 );
  10474. Doo::loadModel ( "accountBook" );
  10475. $accountBook = new accountBook ();
  10476. $accountBank = '';
  10477. $accountTypeWaste = 6;
  10478. if ($receivedBank == '纵横广发') {
  10479. $accountBank = 'CGBDeposit';
  10480. } elseif ($receivedBank == '纵横工行') {
  10481. $accountBank = 'ICBCDeposit';
  10482. } elseif ($receivedBank == '华润银行') {
  10483. $accountBank = 'HUADeposit';
  10484. } elseif ($receivedBank == '个人广发') {
  10485. $accountBank = 'PersonalDeposit';
  10486. }
  10487. if (empty ( $accountBank ))
  10488. die ( 'illegal request' );
  10489. $dailyIncomeType = '';
  10490. $itemWaste = array (
  10491. 'accountPrice' => $receivedPrice,
  10492. 'expensesType' => 1
  10493. );
  10494. if ($receivedBank == '个人广发') {
  10495. $itemWaste = array (
  10496. 'accountPrice' => - $receivedPrice,
  10497. 'expensesType' => 1
  10498. );
  10499. }
  10500. if ($accountType == 4) {
  10501. $dailyIncomeType = 4;
  10502. } elseif ($accountType == 1) {
  10503. $dailyIncomeType = 1;
  10504. } elseif ($accountType == 2) {
  10505. $dailyIncomeType = 2;
  10506. } elseif ($accountType == 3) {
  10507. $dailyIncomeType = 3;
  10508. } elseif ($accountType == 5) {
  10509. $dailyIncomeType = 5;
  10510. } elseif ($accountType == 6) {
  10511. $dailyIncomeType = 6;
  10512. } elseif ($accountType == 7 || $accountType == 9) {
  10513. $dailyIncomeType = 7;
  10514. if ($accountMsg == '公司固定') {
  10515. $accountTypeWaste = 9;
  10516. } elseif ($accountMsg == '公司活期') {
  10517. $accountTypeWaste = 10;
  10518. } elseif ($accountMsg == '个人(GR)') {
  10519. $accountBank = 'PersonalDeposit';
  10520. }
  10521. $itemWaste = array (
  10522. 'accountPrice' => - $receivedPrice,
  10523. 'expensesType' => 2
  10524. );
  10525. } elseif ($accountType == 8) {
  10526. $dailyIncomeType = 8;
  10527. }
  10528. if (empty ( $dailyIncomeType ))
  10529. die ( 'illegal request' );
  10530. $accountBook->accountType = $accountType;
  10531. $accountBook->accountMsg = $accountMsg;
  10532. $accountBook->receivedPrice = $receivedPrice;
  10533. $accountBook->receivedMsg = $receivedMsg;
  10534. $accountBook->receivedBank = $receivedBank;
  10535. $accountBook->receivedDate = $receivedDate;
  10536. $accountBook->remarks = $remarks;
  10537. $accountBook->expensesType = 1;
  10538. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10539. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10540. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10541. $id = $accountBook->insert ();
  10542. //
  10543. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10544. // 收支汇总
  10545. Doo::loadModel ( "accountBookStatistics" );
  10546. $accountBookStatistics = new accountBookStatistics ();
  10547. $item = array (
  10548. 'date' => date ( "Y-m-d" ),
  10549. 'accountType' => $abDetail ['accountType'],
  10550. 'accountMsg' => $abDetail ['accountMsg'],
  10551. 'aid' => $abDetail ['aid']
  10552. );
  10553. if ($abDetail ['expensesType'] == 1) {
  10554. if ($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) {
  10555. $item += array (
  10556. 'financingPrice' => - $receivedPrice,
  10557. 'expensesType' => 3
  10558. );
  10559. } else if ($abDetail ['accountType'] == 8) {
  10560. $item += array (
  10561. 'inComePrice' => - $abDetail ['receivedPrice'],
  10562. 'expensesType' => $abDetail ['expensesType']
  10563. );
  10564. } else {
  10565. $item += array (
  10566. 'inComePrice' => $abDetail ['receivedPrice'],
  10567. 'expensesType' => $abDetail ['expensesType']
  10568. );
  10569. }
  10570. }
  10571. $accountBookStatistics->setAccountBookStatistics ( $item );
  10572. // 为理财时需添加一条日常支出
  10573. if ($accountType == 7 || $accountType == 9) {
  10574. }
  10575. // 公司流水记录
  10576. Doo::loadModel ( 'wasteBook' );
  10577. $wasteBook = new wasteBook ();
  10578. // 银行
  10579. // if (empty($abDetail)){
  10580. $itemWaste += array (
  10581. 'accountPriceShow' => $receivedPrice,
  10582. 'dataID' => $id,
  10583. 'accountType' => $accountTypeWaste,
  10584. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10585. 'accountBank' => $accountBank,
  10586. 'category' => $this->staff [0] ['category'],
  10587. 'cid' => $this->staff [0] ['cid'],
  10588. 'name' => $this->staff [0] ['username'],
  10589. 'sid' => $this->staff [0] ['sid'],
  10590. 'inputDate' => date ( "Y-m-d H:i:s" )
  10591. );
  10592. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10593. // }
  10594. // 类型为理财7或者9 要添加一笔理财支出
  10595. if ($accountType == 7 || $accountType == 9) {
  10596. $accountBank = 'CGBDeposit';
  10597. $expenditureBank = '纵横广发';
  10598. $dailyExpenditureType = 4;
  10599. if ($accountType == 9) {
  10600. $accountBank = 'ICBCDeposit';
  10601. $expenditureBank = '纵横工行';
  10602. $dailyExpenditureType = 6;
  10603. }
  10604. // 添加一条支出
  10605. $accountBook = new accountBook ();
  10606. $accountBook->expenditureType = $dailyExpenditureType;
  10607. $accountBook->expenditureMsg = $accountMsg;
  10608. $accountBook->expenditurePrice = $receivedPrice;
  10609. $accountBook->expenditureBank = $expenditureBank;
  10610. $accountBook->expenditureDate = $receivedDate;
  10611. $accountBook->remarks = $remarks;
  10612. $accountBook->expensesType = 2;
  10613. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10614. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10615. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10616. $id = $accountBook->insert ();
  10617. // 添加一条收入流水
  10618. $itemWaste = array (
  10619. 'accountPriceShow' => $receivedPrice,
  10620. 'accountPrice' => $receivedPrice,
  10621. 'dataID' => $id,
  10622. 'expensesType' => 2,
  10623. 'accountType' => $accountTypeWaste,
  10624. 'dailyExpenditureType' => $dailyExpenditureType,
  10625. 'accountBank' => $accountBank,
  10626. 'category' => $this->staff [0] ['category'],
  10627. 'cid' => $this->staff [0] ['cid'],
  10628. 'name' => $this->staff [0] ['username'],
  10629. 'sid' => $this->staff [0] ['sid'],
  10630. 'inputDate' => date ( "Y-m-d H:i:s" )
  10631. );
  10632. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10633. }
  10634. }
  10635. return '/payments';
  10636. }
  10637. function paymentsExpenditureDo() {
  10638. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10639. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10640. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10641. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10642. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10643. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10644. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10645. // 理财支出特殊处理
  10646. Doo::loadModel ( "accountBook" );
  10647. Doo::loadModel ( "accountBookStatistics" );
  10648. Doo::loadModel ( 'wasteBook' );
  10649. $accountBank = '';
  10650. if ($expenditureBank == '纵横广发') {
  10651. $accountBank = 'CGBDeposit';
  10652. } elseif ($expenditureBank == '纵横工行') {
  10653. $accountBank = 'ICBCDeposit';
  10654. } elseif ($expenditureBank == '华润银行') {
  10655. $accountBank = 'HUADeposit';
  10656. } elseif ($expenditureBank == '个人广发') {
  10657. $accountBank = 'PersonalDeposit';
  10658. }
  10659. if (empty ( $accountBank ))
  10660. die ( 'illegal request' );
  10661. if ($expenditureType == 4 || $expenditureType == 6) {
  10662. if ($expenditureBank == '个人广发') {
  10663. die ( '个人广发 illegal request' );
  10664. }
  10665. // 添加一笔日常支出
  10666. $accountBook = new accountBook ();
  10667. $accountBook->expensesType = 2;
  10668. $accountBook->expenditureType = 7;
  10669. $accountBook->expenditureMsg = $expenditureMsg;
  10670. $accountBook->expenditurePrice = $expenditurePrice;
  10671. $accountBook->expenditureBank = $expenditureBank;
  10672. $accountBook->expenditureDate = $expenditureDate;
  10673. $accountBook->remarks = $remarks;
  10674. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10675. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10676. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10677. $expenditureId = $accountBook->insert ();
  10678. // 添加日常支出汇总
  10679. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  10680. $accountBookStatistics = new accountBookStatistics ();
  10681. $item = array (
  10682. 'date' => date ( "Y-m-d" ),
  10683. 'expenditureType' => $abDetail ['expenditureType'],
  10684. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10685. 'aid' => $abDetail ['aid'],
  10686. 'payPrice' => $abDetail ['expenditurePrice'],
  10687. 'expensesType' => $abDetail ['expensesType']
  10688. );
  10689. $accountBookStatistics->setAccountBookStatistics ( $item );
  10690. // 公司日常支出流水
  10691. $wasteBook = new wasteBook ();
  10692. $itemWaste = array (
  10693. 'accountPrice' => - $expenditurePrice
  10694. );
  10695. if ($expenditureBank == '个人广发') {
  10696. $itemWaste = array (
  10697. 'accountPrice' => $expenditurePrice
  10698. );
  10699. }
  10700. $itemWaste += array (
  10701. 'expensesType' => 2,
  10702. 'accountType' => 5,
  10703. 'dailyExpenditureType' => $expenditureType,
  10704. 'accountPriceShow' => $expenditurePrice,
  10705. 'accountPrice' => - $expenditurePrice,
  10706. 'dataID' => $expenditureId,
  10707. 'accountBank' => $accountBank,
  10708. 'category' => $this->staff [0] ['category'],
  10709. 'cid' => $this->staff [0] ['cid'],
  10710. 'name' => $this->staff [0] ['username'],
  10711. 'sid' => $this->staff [0] ['sid'],
  10712. 'inputDate' => date ( "Y-m-d H:i:s" )
  10713. );
  10714. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10715. // 添加一笔理财收入
  10716. $accountBank = 'CGBDeposit';
  10717. $dailyIncomeType = 7;
  10718. $receivedBank = '纵横广发';
  10719. if ($expenditureType == 6) {
  10720. $accountBank = 'ICBCDeposit';
  10721. $receivedBank = '纵横工行';
  10722. $dailyIncomeType = 9;
  10723. }
  10724. $accountBook = new accountBook ();
  10725. $accountBook->expensesType = 1;
  10726. $accountBook->accountType = $dailyIncomeType;
  10727. $accountBook->accountMsg = $expenditureMsg;
  10728. $accountBook->receivedPrice = $expenditurePrice;
  10729. $accountBook->receivedBank = $receivedBank;
  10730. $accountBook->receivedDate = $expenditureDate;
  10731. $accountBook->remarks = $remarks;
  10732. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10733. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10734. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10735. $id = $accountBook->insert ();
  10736. // 添加日常理财收入汇总
  10737. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  10738. $accountBookStatistics = new accountBookStatistics ();
  10739. $item = array (
  10740. 'date' => date ( "Y-m-d" ),
  10741. 'expenditureType' => $abDetail ['expenditureType'],
  10742. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10743. 'aid' => $abDetail ['aid'],
  10744. 'financingPrice' => $expenditurePrice,
  10745. 'expensesType' => 3
  10746. );
  10747. $accountBookStatistics->setAccountBookStatistics ( $item );
  10748. // 添加一笔收入流水
  10749. if ($expenditureMsg == '公司固定') {
  10750. $accountTypeWaste = 9;
  10751. } elseif ($expenditureMsg == '公司活期') {
  10752. $accountTypeWaste = 10;
  10753. } elseif ($expenditureMsg == '个人(GR)') {
  10754. $accountBank = 'PersonalDeposit';
  10755. }
  10756. $itemWaste = array (
  10757. 'expensesType' => 1,
  10758. 'accountType' => $accountTypeWaste,
  10759. 'accountPriceShow' => $expenditurePrice,
  10760. 'accountPrice' => $expenditurePrice,
  10761. 'dataID' => $id,
  10762. 'dailyIncomeType' => $dailyIncomeType,
  10763. 'accountBank' => $accountBank,
  10764. 'category' => $this->staff [0] ['category'],
  10765. 'cid' => $this->staff [0] ['cid'],
  10766. 'name' => $this->staff [0] ['username'],
  10767. 'sid' => $this->staff [0] ['sid'],
  10768. 'inputDate' => date ( "Y-m-d H:i:s" )
  10769. );
  10770. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10771. } else {
  10772. // 添加一笔日常支出
  10773. $accountBook = new accountBook ();
  10774. $accountBook->expensesType = 2;
  10775. $accountBook->expenditureType = $expenditureType;
  10776. $accountBook->expenditureMsg = $expenditureMsg;
  10777. $accountBook->expenditurePrice = $expenditurePrice;
  10778. $accountBook->expenditureBank = $expenditureBank;
  10779. $accountBook->expenditureDate = $expenditureDate;
  10780. $accountBook->remarks = $remarks;
  10781. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10782. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10783. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10784. $id = $accountBook->insert ();
  10785. // 添加日常支出汇总
  10786. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10787. $accountBookStatistics = new accountBookStatistics ();
  10788. $item = array (
  10789. 'date' => date ( "Y-m-d" ),
  10790. 'expenditureType' => $abDetail ['expenditureType'],
  10791. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10792. 'aid' => $abDetail ['aid'],
  10793. 'expensesType' => $abDetail ['expensesType']
  10794. );
  10795. if ($expenditureType == 5) {
  10796. $item += array (
  10797. 'payPrice' => - $abDetail ['expenditurePrice']
  10798. );
  10799. } else {
  10800. $item += array (
  10801. 'payPrice' => $abDetail ['expenditurePrice']
  10802. );
  10803. }
  10804. $accountBookStatistics->setAccountBookStatistics ( $item );
  10805. // 公司日常支出流水
  10806. $wasteBook = new wasteBook ();
  10807. $itemWaste = array (
  10808. 'accountPrice' => - $expenditurePrice
  10809. );
  10810. if ($expenditureBank == '个人广发') {
  10811. $itemWaste = array (
  10812. 'accountPrice' => $expenditurePrice
  10813. );
  10814. }
  10815. $itemWaste += array (
  10816. 'expensesType' => 2,
  10817. 'accountType' => 5,
  10818. 'accountPriceShow' => $expenditurePrice,
  10819. 'dataID' => $id,
  10820. 'dailyExpenditureType' => $expenditureType,
  10821. 'accountBank' => $accountBank,
  10822. 'category' => $this->staff [0] ['category'],
  10823. 'cid' => $this->staff [0] ['cid'],
  10824. 'name' => $this->staff [0] ['username'],
  10825. 'sid' => $this->staff [0] ['sid'],
  10826. 'inputDate' => date ( "Y-m-d H:i:s" )
  10827. );
  10828. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10829. }
  10830. }
  10831. return '/payments';
  10832. }
  10833. /**
  10834. * 添加支出
  10835. */
  10836. function paymentsExpenditureDo_() {
  10837. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10838. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10839. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10840. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10841. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10842. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10843. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10844. $dailyExpenditureType = '';
  10845. $accountTypeWaste = 5;
  10846. $accountBank = '';
  10847. if ($expenditureBank == '纵横广发') {
  10848. $accountBank = 'CGBDeposit';
  10849. } elseif ($expenditureBank == '纵横工行') {
  10850. $accountBank = 'ICBCDeposit';
  10851. } elseif ($expenditureBank == '华润银行') {
  10852. $accountBank = 'HUADeposit';
  10853. } elseif ($expenditureBank == '个人广发') {
  10854. $accountBank = 'PersonalDeposit';
  10855. }
  10856. if (empty ( $accountBank ))
  10857. die ( 'illegal request' );
  10858. $itemWaste = array (
  10859. 'accountPrice' => - $expenditurePrice
  10860. );
  10861. if ($expenditureBank == '个人广发') {
  10862. $itemWaste = array (
  10863. 'accountPrice' => $expenditurePrice
  10864. );
  10865. }
  10866. if ($expenditureType == 4 || $expenditureType == 6) {
  10867. $dailyExpenditureType = 4;
  10868. if ($expenditureMsg == '公司固定') {
  10869. $accountTypeWaste = 9;
  10870. } elseif ($expenditureMsg == '公司活期') {
  10871. $accountTypeWaste = 10;
  10872. } elseif ($expenditureMsg == '个人(GR)') {
  10873. $accountBank = 'PersonalDeposit';
  10874. }
  10875. $itemWaste = array (
  10876. 'accountPrice' => $expenditurePrice
  10877. );
  10878. } elseif ($expenditureType == 1) {
  10879. $dailyExpenditureType = 1;
  10880. } elseif ($expenditureType == 2) {
  10881. $dailyExpenditureType = 2;
  10882. } elseif ($expenditureType == 3) {
  10883. $dailyExpenditureType = 3;
  10884. } elseif ($expenditureType == 5) {
  10885. $dailyExpenditureType = 5;
  10886. }
  10887. if (empty ( $dailyExpenditureType ))
  10888. die ( 'illegal request' );
  10889. Doo::loadModel ( "accountBook" );
  10890. $accountBook = new accountBook ();
  10891. $accountBook->expenditureType = $expenditureType;
  10892. $accountBook->expenditureMsg = $expenditureMsg;
  10893. $accountBook->expenditurePrice = $expenditurePrice;
  10894. $accountBook->expenditureBank = $expenditureBank;
  10895. $accountBook->expenditureDate = $expenditureDate;
  10896. $accountBook->remarks = $remarks;
  10897. $accountBook->expensesType = 2;
  10898. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10899. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10900. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10901. $id = $accountBook->insert ();
  10902. //
  10903. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10904. Doo::loadModel ( "accountBookStatistics" );
  10905. $accountBookStatistics = new accountBookStatistics ();
  10906. $item = array (
  10907. 'date' => date ( "Y-m-d" ),
  10908. 'expenditureType' => $abDetail ['expenditureType'],
  10909. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10910. 'aid' => $abDetail ['aid']
  10911. );
  10912. if ($abDetail ['expensesType'] == 2) {
  10913. if ($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) {
  10914. $item += array (
  10915. 'financingPrice' => $expenditurePrice,
  10916. 'expensesType' => 3
  10917. );
  10918. } elseif ($abDetail ['expenditureType'] == 5) {
  10919. $item += array (
  10920. 'payPrice' => $abDetail ['expenditurePrice'],
  10921. 'expensesType' => $abDetail ['expensesType']
  10922. );
  10923. } else {
  10924. $item += array (
  10925. 'payPrice' => $abDetail ['expenditurePrice'],
  10926. 'expensesType' => $abDetail ['expensesType']
  10927. );
  10928. }
  10929. }
  10930. $accountBookStatistics->setAccountBookStatistics ( $item );
  10931. // 公司流水记录
  10932. Doo::loadModel ( 'wasteBook' );
  10933. $wasteBook = new wasteBook ();
  10934. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountTypeWaste, $id );
  10935. // 银行
  10936. if (empty ( $abDetail )) {
  10937. $itemWaste += array (
  10938. 'accountPriceShow' => $expenditurePrice,
  10939. 'dataID' => $id,
  10940. 'expensesType' => 2,
  10941. 'accountType' => $accountTypeWaste,
  10942. 'dailyExpenditureType' => $expenditureType,
  10943. 'accountBank' => $accountBank,
  10944. 'category' => $this->staff [0] ['category'],
  10945. 'cid' => $this->staff [0] ['cid'],
  10946. 'name' => $this->staff [0] ['username'],
  10947. 'sid' => $this->staff [0] ['sid'],
  10948. 'inputDate' => date ( "Y-m-d H:i:s" )
  10949. );
  10950. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10951. }
  10952. // 支出类型为4或者6 需要添加一笔收入和收入流水
  10953. if ($expenditureType == 4 || $expenditureType == 6) {
  10954. $accountBank = 'CGBDeposit';
  10955. $dailyIncomeType = 7;
  10956. $receivedBank = '纵横广发';
  10957. if ($expenditureType == 6) {
  10958. $accountBank = 'ICBCDeposit';
  10959. $receivedBank = '纵横工行';
  10960. $dailyIncomeType = 9;
  10961. }
  10962. // 添加一笔收入
  10963. $accountBook = new accountBook ();
  10964. $accountBook->accountType = $dailyIncomeType;
  10965. $accountBook->accountMsg = $expenditureMsg;
  10966. $accountBook->receivedPrice = $expenditurePrice;
  10967. $accountBook->receivedBank = $receivedBank;
  10968. $accountBook->receivedDate = $expenditureDate;
  10969. $accountBook->remarks = $remarks;
  10970. $accountBook->expensesType = 1;
  10971. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10972. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10973. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10974. $id = $accountBook->insert ();
  10975. // 添加一笔收入流水
  10976. $itemWaste = array (
  10977. 'accountPriceShow' => $expenditurePrice,
  10978. 'accountPrice' => - $expenditurePrice,
  10979. 'dataID' => $id,
  10980. 'expensesType' => 1,
  10981. 'accountType' => $accountTypeWaste,
  10982. 'dailyIncomeType' => $dailyIncomeType,
  10983. 'accountBank' => $accountBank,
  10984. 'category' => $this->staff [0] ['category'],
  10985. 'cid' => $this->staff [0] ['cid'],
  10986. 'name' => $this->staff [0] ['username'],
  10987. 'sid' => $this->staff [0] ['sid'],
  10988. 'inputDate' => date ( "Y-m-d H:i:s" )
  10989. );
  10990. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10991. }
  10992. }
  10993. return '/payments';
  10994. }
  10995. /**
  10996. * 所有收支
  10997. */
  10998. function paymentsAchieve() {
  10999. $page_size = 12;
  11000. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  11001. $expensesType = isset ( $this->params ['expensesType'] ) ? $this->params ['expensesType'] : 'ALL';
  11002. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11003. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  11004. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11005. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11006. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11007. $submitType = $this->get_args ( 'submitType' ) ? $this->get_args ( 'submitType' ) : "";
  11008. Doo::loadModel ( "accountBookStatistics" );
  11009. $accountBookStatistics = new accountBookStatistics ();
  11010. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  11011. $data ['statisticsList'] = $statisticsList;
  11012. Doo::loadModel ( "accountBook" );
  11013. $accountBook = new accountBook ();
  11014. $con = '';
  11015. if ($expensesType == 'INCOME')
  11016. $con = ' and expensesType=1 ';
  11017. elseif ($expensesType == 'PAY')
  11018. $con = ' and expensesType=2 ';
  11019. $dateArr = explode ( ':', $date );
  11020. $D1 = $dateString = '';
  11021. $D2 = '';
  11022. if (! empty ( $date )) {
  11023. $D1 = $dateArr [0];
  11024. if (isset ( $dateArr [1] ))
  11025. $D2 = $dateArr [1];
  11026. else
  11027. $D2 = '';
  11028. $dateString = $D1 . " : " . $D2;
  11029. }
  11030. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11031. $con .= ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11032. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11033. $con .= ' and inputDate like "%' . $D1 . '%" ';
  11034. if (! empty ( $price ))
  11035. $con .= ' and (receivedPrice=' . $price . ' or expenditurePrice=' . $price . ')';
  11036. if ($submitType == 1) {
  11037. if ($accountType != '') {
  11038. $expenditureType = '';
  11039. $con .= ' and accountType=' . $accountType;
  11040. if (! empty ( $accountMsg ))
  11041. $con .= ' and (accountType=' . $accountType . ' and accountMsg like "%' . $accountMsg . '%")';
  11042. }
  11043. } elseif ($submitType == 2) {
  11044. if ($expenditureType != '') {
  11045. $accountType = $accountMsg = '';
  11046. $con .= ' and expenditureType=' . $expenditureType;
  11047. }
  11048. } else {
  11049. $accountType = $accountMsg = $expenditureType = '';
  11050. }
  11051. $sql = "" . $con;
  11052. $action = "paymentsAchieve";
  11053. $get = '/' . $expensesType; // "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  11054. $pageinfo = $this->get_page ( "CLD_accountBook", $sql, $page, $page_size, $action, $get, "" );
  11055. $limit = $pageinfo ['lower'] . ',' . $page_size;
  11056. $list = $accountBook->getAccountBookBySql ( $limit, $sql, 'desc' );
  11057. $data ['expenditureType'] = $expenditureType;
  11058. $data ['accountMsg'] = $accountMsg;
  11059. $data ['accountType'] = $accountType;
  11060. $data ['inputDate'] = $date;
  11061. $data ['price'] = $price;
  11062. $data ['expensesType'] = $expensesType;
  11063. $data ['page'] = $pageinfo;
  11064. $data ['list'] = $list;
  11065. $data ['memu'] = "receipt";
  11066. $data ['staff'] = $this->staff;
  11067. $data ['receiptMemu'] = 'payments';
  11068. $data ['verifyId'] = $this->verifyId;
  11069. $data ['executeId'] = $this->executeId;
  11070. $this->render ( "/expenses/paymentsAchieve", $data );
  11071. }
  11072. function paymentsIncomeUpdateDo() {
  11073. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11074. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11075. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11076. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  11077. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  11078. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  11079. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  11080. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11081. if (! empty ( $aidKey ) && ! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  11082. Doo::loadClass ( 'XDeode' );
  11083. $XDeode = new XDeode ( 5 );
  11084. $aid = $XDeode->decode ( $aidKey );
  11085. Doo::loadModel ( "accountBook" );
  11086. $accountBook = new accountBook ();
  11087. //
  11088. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11089. $price = $receivedPrice - $abDetail [inComePrice];
  11090. Doo::loadModel ( "accountBookStatistics" );
  11091. $accountBookStatistics = new accountBookStatistics ();
  11092. if ($abDetail ['accountType'] == 7) {
  11093. $item += array (
  11094. 'date' => date ( "Y-m-d" ),
  11095. 'financingPrice' => - $price,
  11096. 'expensesType' => 3,
  11097. 'aid' => $abDetail ['aid']
  11098. );
  11099. } elseif ($abDetail ['accountType'] == 8) {
  11100. $item += array (
  11101. 'date' => date ( "Y-m-d" ),
  11102. 'expensesType' => $abDetail ['expensesType'],
  11103. 'inComePrice' => - $price,
  11104. 'aid' => $abDetail ['aid']
  11105. );
  11106. } else {
  11107. $item = array (
  11108. 'date' => date ( "Y-m-d" ),
  11109. 'expensesType' => $abDetail ['expensesType'],
  11110. 'inComePrice' => $price,
  11111. 'aid' => $abDetail ['aid']
  11112. );
  11113. }
  11114. $accountBookStatistics->setAccountBookStatistics ( $item );
  11115. $accountBook->accountType = $accountType;
  11116. $accountBook->accountMsg = $accountMsg;
  11117. $accountBook->receivedPrice = $receivedPrice;
  11118. $accountBook->receivedMsg = $receivedMsg;
  11119. $accountBook->receivedBank = $receivedBank;
  11120. $accountBook->receivedDate = $receivedDate;
  11121. $accountBook->remarks = $remarks;
  11122. $accountBook->aid = $aid;
  11123. $accountBook->update ();
  11124. }
  11125. return '/paymentsAchieve';
  11126. }
  11127. function paymentsExpenditureEdiDo() {
  11128. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11129. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11130. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11131. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11132. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11133. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11134. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11135. if (! empty ( $aidKey ) && ! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11136. Doo::loadClass ( 'XDeode' );
  11137. $XDeode = new XDeode ( 5 );
  11138. $aid = $XDeode->decode ( $aidKey );
  11139. Doo::loadModel ( "accountBook" );
  11140. $accountBook = new accountBook ();
  11141. // 汇总信息
  11142. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11143. $price = $expenditurePrice - $abDetail [expenditurePrice];
  11144. Doo::loadModel ( "accountBookStatistics" );
  11145. $accountBookStatistics = new accountBookStatistics ();
  11146. if ($abDetail ['expenditureType'] == 4) {
  11147. $item += array (
  11148. 'date' => date ( "Y-m-d" ),
  11149. 'financingPrice' => $price,
  11150. 'expensesType' => 3,
  11151. 'aid' => $abDetail ['aid']
  11152. );
  11153. } elseif ($abDetail ['expenditureType'] == 5) {
  11154. $item += array (
  11155. 'date' => date ( "Y-m-d" ),
  11156. 'expensesType' => $abDetail ['expensesType'],
  11157. 'payPrice' => $price,
  11158. 'aid' => $abDetail ['aid']
  11159. );
  11160. } else {
  11161. $item = array (
  11162. 'date' => date ( "Y-m-d" ),
  11163. 'expensesType' => $abDetail ['expensesType'],
  11164. 'payPrice' => $price,
  11165. 'aid' => $abDetail ['aid']
  11166. );
  11167. }
  11168. $accountBookStatistics->setAccountBookStatistics ( $item );
  11169. //
  11170. $accountBook->expenditureType = $expenditureType;
  11171. $accountBook->expenditureMsg = $expenditureMsg;
  11172. $accountBook->expenditurePrice = $expenditurePrice;
  11173. $accountBook->expenditureBank = $expenditureBank;
  11174. $accountBook->remarks = $remarks;
  11175. $accountBook->expenditureDate = $expenditureDate;
  11176. $accountBook->aid = $aid;
  11177. $id = $accountBook->update ();
  11178. }
  11179. return '/paymentsAchieve';
  11180. }
  11181. function paymentsDelDo() {
  11182. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11183. if (! empty ( $aidKey )) {
  11184. Doo::loadClass ( 'XDeode' );
  11185. $XDeode = new XDeode ( 5 );
  11186. $aid = $XDeode->decode ( $aidKey );
  11187. Doo::loadModel ( "accountBook" );
  11188. $accountBook = new accountBook ();
  11189. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11190. if (empty ( $abDetail ))
  11191. die ( 'illegal request' );
  11192. // 删除收支
  11193. Doo::loadModel ( "accountBookStatistics" );
  11194. $accountBookStatistics = new accountBookStatistics ();
  11195. $item = array (
  11196. 'date' => date ( "Y-m-d" ),
  11197. 'aid' => $abDetail ['aid']
  11198. );
  11199. $accountType = '';
  11200. if ($abDetail ['expensesType'] == 1) {
  11201. $accountType = 6;
  11202. if ($abDetail ['accountType'] != 7) {
  11203. $item += array (
  11204. 'expensesType' => $abDetail ['expensesType'],
  11205. 'inComePrice' => - $abDetail ['receivedPrice']
  11206. );
  11207. } else {
  11208. $item += array (
  11209. 'financingPrice' => $abDetail ['receivedPrice'],
  11210. 'expensesType' => 3
  11211. );
  11212. }
  11213. } elseif ($abDetail ['expensesType'] == 2) {
  11214. $accountType = 5;
  11215. if ($abDetail ['accountType'] != 7) {
  11216. $item += array (
  11217. 'expensesType' => $abDetail ['expensesType'],
  11218. 'payPrice' => - $abDetail ['expenditurePrice']
  11219. );
  11220. } else {
  11221. $item += array (
  11222. 'financingPrice' => - $abDetail ['expenditurePrice'],
  11223. 'expensesType' => 3
  11224. );
  11225. }
  11226. }
  11227. if (($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) && $abDetail ['expensesType'] == 2) {
  11228. if ($abDetail ['expenditureMsg'] == '公司固定')
  11229. $accountType = 9;
  11230. elseif ($abDetail ['expenditureMsg'] == '公司活期')
  11231. $accountType = 10;
  11232. }
  11233. if (($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) && $abDetail ['expensesType'] == 1) {
  11234. if ($abDetail ['accountMsg'] == '公司固定')
  11235. $accountType = 9;
  11236. elseif ($abDetail ['accountMsg'] == '公司活期')
  11237. $accountType = 10;
  11238. }
  11239. if ($abDetail ['accountMsg'] == '活期理财收益') {
  11240. $accountType = 10;
  11241. }
  11242. $accountBookStatistics->setAccountBookStatistics ( $item );
  11243. $accountBook->delete ( array (
  11244. 'where' => 'aid=' . $aid,
  11245. 'limit' => 1
  11246. ) );
  11247. // 删除收入流水
  11248. if (! empty ( $accountType )) {
  11249. Doo::loadModel ( 'wasteBook' );
  11250. $wasteBook = new wasteBook ();
  11251. $wasteBook->delete ( array (
  11252. 'where' => 'dataID=' . $aid . ' and accountType=' . $accountType,
  11253. 'limit' => 1
  11254. ) );
  11255. }
  11256. }
  11257. return '/paymentsAchieve';
  11258. }
  11259. function paymentsCollect() {
  11260. Doo::loadModel ( "execute" );
  11261. $execute = new execute ();
  11262. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11263. die ( 'illegal request' );
  11264. }
  11265. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11266. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  11267. Doo::loadModel ( "accountBookStatistics" );
  11268. $accountBookStatistics = new accountBookStatistics ();
  11269. Doo::loadClass ( 'receipt.func' );
  11270. $statisticsIncome = $accountBookStatistics->getStatisticsByCollect ( $year );
  11271. $html = _getPaymentsCollectByYearHtml ( $statisticsIncome );
  11272. $data ['html'] = $html ['html'];
  11273. $data ['inSum'] = $html ['sum'];
  11274. $statisticsPay = $accountBookStatistics->getStatisticsByCollect ( $year, 2 );
  11275. $html = _getPaymentsCollectPayByYearHtml ( $statisticsPay );
  11276. $data ['payHtml'] = $html ['html'];
  11277. $data ['paySum'] = $html ['sum'];
  11278. // 余额统计
  11279. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1 );
  11280. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2 );
  11281. include './protected/config/wasteBook.conf.php';
  11282. Doo::loadModel ( 'wasteBook' );
  11283. $wasteBook = new wasteBook ();
  11284. $inComePay = $wasteBook->getWasteBookByStatistics ( 1, $year );
  11285. $pay = $wasteBook->getWasteBookByStatistics ( 2, $year );
  11286. // 获得年份之前所有金额
  11287. $detail = $wasteBook->getWasteBookByStatisticsYear ( $year );
  11288. // print_r($detail);
  11289. // $waste['total'];
  11290. $lastBalanceHtml = '<tr><th colspan="2">截至上月余额</th>';
  11291. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11292. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11293. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11294. $inSum = $paySum = $showInSum = $showPaySum = $balanceSum = 0;
  11295. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11296. $limitMonth = date ( 'm' ); // 限制显示月份参数
  11297. if (date ( 'Y' ) > $year) {
  11298. $limitMonth = 12;
  11299. }
  11300. for($i = 1; $i <= 12; $i ++) {
  11301. $inComeA = $payB = 0;
  11302. $falg = true;
  11303. foreach ( $inComePay as $key => $value ) {
  11304. if ($value ['month'] == $i) {
  11305. $falg = false;
  11306. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11307. $inSum += $value ['accountPrice'];
  11308. $showInSum += $value ['accountPriceShow'];
  11309. $inComeA = $value ['accountPrice'];
  11310. break;
  11311. }
  11312. }
  11313. if ($falg)
  11314. $inComeHtml .= '<td class="taR">-</td>';
  11315. $payFalg = true;
  11316. foreach ( $pay as $key => $value ) {
  11317. if ($value ['month'] == $i) {
  11318. $payFalg = false;
  11319. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11320. $paySum += $value ['accountPrice'];
  11321. $showPaySum += $value ['accountPriceShow'];
  11322. $payB = $value ['accountPrice'];
  11323. break;
  11324. }
  11325. }
  11326. if ($payFalg)
  11327. $payHtml .= '<td class="taR">-</td>';
  11328. if (empty ( $balanceC ) || $limitMonth < $i)
  11329. $lastBalanceHtml .= '<td class="taR">-</td>';
  11330. else
  11331. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11332. $balanceC = $balanceC + $inComeA + $payB;
  11333. $balanceSum += $balanceC;
  11334. if (empty ( $balanceC ) || $limitMonth < $i)
  11335. $BalanceHtml .= '<td class="taR">-</td>';
  11336. else
  11337. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11338. // 余额统计
  11339. }
  11340. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11341. $data ['inComeHtml'] = $inComeHtml;
  11342. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11343. $data ['payBalanceHtml'] = $payHtml;
  11344. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11345. $data ['BalanceHtml'] = $BalanceHtml;
  11346. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11347. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11348. $mothHtml = "";
  11349. for($i = 1; $i <= 12; $i ++) {
  11350. if ($moth == $i)
  11351. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11352. else
  11353. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11354. }
  11355. $data ['mothHtml'] = $mothHtml;
  11356. $dateHtml = "";
  11357. $now = date ( "Y" );
  11358. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11359. if ($YEARD <= $now) {
  11360. $dateHtml .= '<option ';
  11361. if ($year == $YEARD) {
  11362. $dateHtml .= 'selected ';
  11363. }
  11364. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11365. }
  11366. }
  11367. $data ['dateHtml'] = $dateHtml;
  11368. $data ['year'] = $year;
  11369. $data ['memu'] = "receipt";
  11370. $data ['staff'] = $this->staff;
  11371. $data ['receiptMemu'] = 'paymentsCollect';
  11372. $data ['verifyId'] = $this->verifyId;
  11373. $data ['executeId'] = $this->executeId;
  11374. $this->render ( "/expenses/paymentsCollect", $data );
  11375. }
  11376. function paymentsCollectDay() {
  11377. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11378. $moth = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : '';
  11379. if (empty ( $moth ))
  11380. return 'paymentsCollect';
  11381. Doo::loadModel ( "accountBookStatistics" );
  11382. $accountBookStatistics = new accountBookStatistics ();
  11383. $i = 2;
  11384. $y = 2013;
  11385. $day = date ( "t", strtotime ( "$year-$moth" ) );
  11386. Doo::loadClass ( 'receipt.func' );
  11387. $statisticsIncome = $accountBookStatistics->getStatisticsByCollectDay ( $year, 1, $moth );
  11388. $html = _getPaymentsCollectByDayHtml ( $statisticsIncome, $day );
  11389. $data ['html'] = $html ['html'];
  11390. $data ['inSum'] = $html ['sum'];
  11391. $statisticsPay = $accountBookStatistics->getStatisticsByCollectDay ( $year, 2, $moth );
  11392. $html = _getPaymentsCollectPayByDayHtml ( $statisticsPay, $day );
  11393. $data ['payHtml'] = $html ['html'];
  11394. $data ['paySum'] = $html ['sum'];
  11395. $mothHtml = "";
  11396. for($i = 1; $i <= 12; $i ++) {
  11397. if ($moth == $i)
  11398. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11399. else
  11400. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11401. }
  11402. $data ['mothHtml'] = $mothHtml;
  11403. $data ['year'] = $year;
  11404. // 余额
  11405. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1, $moth );
  11406. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2, $moth );
  11407. include './protected/config/wasteBook.conf.php';
  11408. Doo::loadModel ( 'wasteBook' );
  11409. $wasteBook = new wasteBook ();
  11410. $inComePay = $wasteBook->getStatisticsByDay ( 1, $year, $moth );
  11411. $pay = $wasteBook->getStatisticsByDay ( 2, $year, $moth );
  11412. // 获得年份之前所有金额
  11413. $detail = $wasteBook->getWasteBookByStatisticsDay ( $year, $moth );
  11414. $lastBalanceHtml = '<tr><th colspan="2">截至上日余额</th>';
  11415. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11416. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11417. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11418. $dayHtml = '<tr><th class="taC" colspan="2">余额</th>';
  11419. $inSum = $paySum = $showPaySum = $showInSum = $balanceSum = 0;
  11420. // $balanceC = 0;
  11421. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11422. $limitDay = date ( 'd' );
  11423. $monthLK = ( int ) date ( 'm' );
  11424. if (date ( 'Y' ) > $year) {
  11425. $limitDay = cal_days_in_month ( CAL_GREGORIAN, date ( 'm' ), date ( 'Y' ) );
  11426. } elseif (date ( 'Y' ) <= $year && $monthLK < $moth) {
  11427. $limitDay = 0;
  11428. }
  11429. for($i = 1; $i <= $day; $i ++) {
  11430. $dayHtml .= '<td class="taC">' . $i . '日</td>';
  11431. $inComeA = $payB = 0;
  11432. $falg = true;
  11433. foreach ( $inComePay as $key => $value ) {
  11434. if ($value ['day'] == $i) {
  11435. $falg = false;
  11436. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11437. $inSum += $value ['accountPrice'];
  11438. $showInSum += $value ['accountPriceShow'];
  11439. $inComeA = $value ['accountPrice'];
  11440. break;
  11441. }
  11442. }
  11443. if ($falg)
  11444. $inComeHtml .= '<td class="taR">-</td>';
  11445. $payFalg = true;
  11446. foreach ( $pay as $key => $value ) {
  11447. if ($value ['day'] == $i) {
  11448. $payFalg = false;
  11449. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11450. $paySum += $value ['accountPrice'];
  11451. $showPaySum += $value ['accountPriceShow'];
  11452. $payB = $value ['accountPrice'];
  11453. break;
  11454. }
  11455. }
  11456. if ($payFalg)
  11457. $payHtml .= '<td class="taR">-</td>';
  11458. if (empty ( $balanceC ) || $limitDay < $i)
  11459. $lastBalanceHtml .= '<td class="taR">-</td>';
  11460. else
  11461. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11462. $balanceC = $balanceC + $inComeA + $payB;
  11463. $balanceSum += $balanceC;
  11464. if (empty ( $balanceC ) || $limitDay < $i)
  11465. $BalanceHtml .= '<td class="taR">-</td>';
  11466. else
  11467. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11468. }
  11469. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11470. $data ['inComeHtml'] = $inComeHtml;
  11471. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11472. $data ['payBalanceHtml'] = $payHtml;
  11473. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11474. $data ['BalanceHtml'] = $BalanceHtml;
  11475. $dayHtml .= '<td class="taR ">总计</td></tr>';
  11476. $data ['dayHtml'] = $dayHtml;
  11477. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11478. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11479. $dateHtml = "";
  11480. $now = date ( "Y" );
  11481. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11482. if ($YEARD <= $now) {
  11483. $dateHtml .= '<option ';
  11484. if ($year == $YEARD) {
  11485. $dateHtml .= 'selected ';
  11486. }
  11487. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11488. }
  11489. }
  11490. $data ['dateHtml'] = $dateHtml;
  11491. $data ['memu'] = "receipt";
  11492. $data ['staff'] = $this->staff;
  11493. $data ['receiptMemu'] = 'paymentsCollect';
  11494. $data ['verifyId'] = $this->verifyId;
  11495. $data ['executeId'] = $this->executeId;
  11496. $this->render ( "/expenses/paymentsCollectDay", $data );
  11497. }
  11498. // 公司流水
  11499. function wasteBook() {
  11500. Doo::loadModel ( "execute" );
  11501. $execute = new execute ();
  11502. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11503. die ( 'illegal request' );
  11504. }
  11505. include './protected/config/wasteBook.conf.php';
  11506. Doo::loadModel ( 'wasteBook' );
  11507. $wasteBook = new wasteBook ();
  11508. $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  11509. $waste = $this->getWasteBookStatistics ( $waste, $inComeStatistics );
  11510. $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'];
  11511. // print_r($waste);
  11512. $data ['waste'] = $waste;
  11513. $data ['total'] = $total;
  11514. // 月流水数据结构
  11515. $monthStatistics = array ();
  11516. $incomeMothStatistics = array ();
  11517. $expenditureMothStatistics = array ();
  11518. for($i = 1; $i <= 12; $i ++) {
  11519. $month = date ( 'Y' ) . '-' . $i;
  11520. if ($i < 10)
  11521. $month = date ( 'Y' ) . '-0' . $i;
  11522. array_push ( $monthStatistics, $month );
  11523. }
  11524. foreach ( $monthStatistics as $value ) {
  11525. $falg = true;
  11526. foreach ( $inComeStatistics ['incomeReport'] as $k => $v ) {
  11527. if ($value == $v ['inputDate']) {
  11528. array_push ( $incomeMothStatistics, $v ['accountPrice'] );
  11529. $falg = false;
  11530. }
  11531. }
  11532. if ($falg) {
  11533. array_push ( $incomeMothStatistics, '' );
  11534. }
  11535. $falgEx = true;
  11536. foreach ( $inComeStatistics ['expenditureReport'] as $k => $v ) {
  11537. if ($value == $v ['inputDate']) {
  11538. array_push ( $expenditureMothStatistics, $v ['accountPrice'] );
  11539. $falg = false;
  11540. }
  11541. }
  11542. if ($falgEx) {
  11543. array_push ( $expenditureMothStatistics, '' );
  11544. }
  11545. }
  11546. $data ['monthStatistics'] = json_encode ( $monthStatistics );
  11547. $data ['incomeMothStatistics'] = json_encode ( $incomeMothStatistics );
  11548. $data ['expenditureMothStatistics'] = json_encode ( $expenditureMothStatistics );
  11549. $expenditureList = $wasteBook->getAccountBookByExpensesType ( 4, 2 );
  11550. $incomeList = $wasteBook->getAccountBookByExpensesType ( 4, 1 );
  11551. // print_r($incomeList);
  11552. $data ['expenditureList'] = $expenditureList;
  11553. $data ['incomeList'] = $incomeList;
  11554. $data ['memu'] = "receipt";
  11555. $data ['staff'] = $this->staff;
  11556. $data ['receiptMemu'] = 'wasteBook';
  11557. $data ['verifyId'] = $this->verifyId;
  11558. $data ['executeId'] = $this->executeId;
  11559. $this->render ( "/expenses/wasteBook", $data );
  11560. }
  11561. function wasteBookIncome() {
  11562. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11563. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11564. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  11565. $dailyIncomeType = $this->get_args ( 'dailyIncomeType' ) ? $this->get_args ( 'dailyIncomeType' ) : "ALL";
  11566. $data ['dailyIncomeType'] = $dailyIncomeType;
  11567. Doo::loadModel ( 'wasteBook' );
  11568. $wasteBook = new wasteBook ();
  11569. Doo::loadModel ( 'L_category' );
  11570. $L_category = new L_category ();
  11571. Doo::loadClass ( 'XDeode' );
  11572. $XDeode = new XDeode ( 5 );
  11573. // echo $XDeode->encode(1).'<br>';
  11574. // echo $XDeode->encode(2).'<br>';
  11575. // echo $XDeode->encode(3).'<br>';
  11576. // echo $XDeode->encode(4).'<br>';
  11577. // echo $XDeode->encode(5).'<br>';
  11578. // echo $XDeode->encode(6).'<br>';
  11579. // echo $XDeode->encode(7).'<br>';
  11580. // echo $XDeode->encode(8).'<br>';
  11581. // echo $XDeode->encode(9).'<br>';
  11582. // echo $XDeode->encode(10).'<br>';
  11583. $year=date("Y");
  11584. $theDay=date("Y-m-d");
  11585. $dateArr = explode ( ':', $date );
  11586. $D1 = '';
  11587. $D2 = '';
  11588. $con = '';
  11589. if (! empty ( $date )) {
  11590. $D1 = $dateArr [0];
  11591. $D2 = $dateArr [1];
  11592. }
  11593. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11594. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11595. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11596. $con = ' and inputDate = "' . $D1 . '"';
  11597. else{
  11598. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  11599. }
  11600. if ($cid != 'ALL') {
  11601. $cid = $XDeode->decode ( $cid );
  11602. $con .= ' and cid = "' . $cid . '"';
  11603. }
  11604. if ($accountType != 'ALL') {
  11605. if ($accountType == 'INVOICE') {
  11606. $con .= ' and (accountType = 7 or accountType = 8)';
  11607. } elseif ($accountType == 'PAYMENTS') {
  11608. $con .= ' and (accountType = 6 or accountType = 9 or accountType = 10)';
  11609. if ($dailyIncomeType != 'ALL') {
  11610. $dailyIncomeType = $XDeode->decode ( $dailyIncomeType );
  11611. $con .= ' and dailyIncomeType = ' . $dailyIncomeType;
  11612. }
  11613. }
  11614. }
  11615. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 1, $con );
  11616. $sum = 0;$thsDaySum=0;
  11617. foreach ( $incomeList as $key => $value ) {
  11618. $sum += $value ['accountPrice'];
  11619. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  11620. $thsDaySum+=$value ['accountPrice'];
  11621. }
  11622. }
  11623. // print_r($incomeList);
  11624. // 获得办事和部门
  11625. $categoryList = $L_category->getCategory ();
  11626. $data ['accountType'] = $accountType;
  11627. $data ['cid'] = $cid;
  11628. $data ['categoryList'] = $categoryList;
  11629. $data ['sum'] = $sum;
  11630. $data ['incomeList'] = $incomeList;
  11631. $data ['inputDate'] = $date;
  11632. $data['year']=$year;
  11633. $data ['thsDay'] =$theDay;
  11634. $data ['thsDaySum'] =$thsDaySum;
  11635. $data ['memu'] = "receipt";
  11636. $data ['staff'] = $this->staff;
  11637. $data ['receiptMemu'] = 'wasteBook';
  11638. $data ['verifyId'] = $this->verifyId;
  11639. $data ['executeId'] = $this->executeId;
  11640. $this->render ( "/expenses/wasteBookIncome", $data );
  11641. }
  11642. /**
  11643. * 所有支出
  11644. */
  11645. function wasteBookExpenditure() {
  11646. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11647. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11648. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  11649. $dailyExpenditureType = $this->get_args ( 'dailyExpenditureType' ) ? $this->get_args ( 'dailyExpenditureType' ) : "ALL";
  11650. $data ['dailyExpenditureType'] = $dailyExpenditureType;
  11651. $receiptType = $this->get_args ( 'receiptType' ) ? $this->get_args ( 'receiptType' ) : "ALL";
  11652. $data ['receiptType'] = $receiptType;
  11653. Doo::loadModel ( 'wasteBook' );
  11654. $wasteBook = new wasteBook ();
  11655. Doo::loadModel ( 'L_category' );
  11656. $L_category = new L_category ();
  11657. Doo::loadClass ( 'XDeode' );
  11658. $XDeode = new XDeode ( 5 );
  11659. $year=date("Y");
  11660. $theDay=date("Y-m-d");
  11661. $dateArr = explode ( ':', $date );
  11662. $D1 = '';
  11663. $D2 = '';
  11664. $con = '';
  11665. if (! empty ( $date )) {
  11666. $D1 = $dateArr [0];
  11667. $D2 = $dateArr [1];
  11668. }
  11669. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11670. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11671. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11672. $con = ' and inputDate = "' . $D1 . '"';
  11673. else{
  11674. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  11675. }
  11676. if ($cid != 'ALL') {
  11677. $cid = $XDeode->decode ( $cid );
  11678. $con .= ' and cid = "' . $cid . '"';
  11679. }
  11680. if ($accountType != 'ALL') {
  11681. if ($accountType == 'INVOICE') {
  11682. $con .= ' and accountType = 11';
  11683. } elseif ($accountType == 'PAYMENTS') {
  11684. $con .= ' and (accountType = 5 or accountType = 9 or accountType = 10)';
  11685. if ($dailyExpenditureType != 'ALL') {
  11686. $dailyExpenditureType = $XDeode->decode ( $dailyExpenditureType );
  11687. $con .= ' and dailyExpenditureType = ' . $dailyExpenditureType;
  11688. }
  11689. } elseif ($accountType == 'RECEIPT') {
  11690. if ($receiptType == 'ALL') {
  11691. $con .= ' and (accountType = 1 or accountType = 2 or accountType = 3 or accountType = 4)';
  11692. } else {
  11693. $receiptType = $XDeode->decode ( $receiptType );
  11694. echo $receiptType;
  11695. if ($receiptType == 1) {
  11696. $con .= ' and (accountType = 1 or accountType=2)';
  11697. } else {
  11698. $con .= ' and accountType = ' . $receiptType;
  11699. }
  11700. }
  11701. }
  11702. }
  11703. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 2, $con );
  11704. $sum = 0;$thsDaySum=0;
  11705. foreach ( $incomeList as $key => $value ) {
  11706. $sum += $value ['accountPriceShow'];
  11707. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  11708. $thsDaySum+=$value ['accountPriceShow'];
  11709. }
  11710. }
  11711. // print_r($incomeList);
  11712. // 获得办事和部门
  11713. $categoryList = $L_category->getCategory ();
  11714. $data ['accountType'] = $accountType;
  11715. $data ['cid'] = $cid;
  11716. $data ['categoryList'] = $categoryList;
  11717. $data ['sum'] = $sum;
  11718. $data ['incomeList'] = $incomeList;
  11719. $data ['inputDate'] = $date;
  11720. $data['year']=$year;
  11721. $data ['thsDay'] =$theDay;
  11722. $data ['thsDaySum'] =$thsDaySum;
  11723. $data ['memu'] = "receipt";
  11724. $data ['staff'] = $this->staff;
  11725. $data ['receiptMemu'] = 'wasteBook';
  11726. $data ['verifyId'] = $this->verifyId;
  11727. $data ['executeId'] = $this->executeId;
  11728. $this->render ( "/expenses/wasteBookExpenditure", $data );
  11729. }
  11730. function ajaxGetWasteinvoiceReceivables() {
  11731. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11732. Doo::loadClass ( 'XDeode' );
  11733. $XDeode = new XDeode ( 5 );
  11734. $irid = $XDeode->decode ( $serial );
  11735. Doo::loadModel ( 'invoiceReceivables' );
  11736. $invoiceReceivables = new invoiceReceivables ();
  11737. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  11738. echo json_encode ( array (
  11739. 'status' => 1,
  11740. 'detail' => $detail
  11741. ) );
  11742. }
  11743. function ajaxGetPaymentsByAid() {
  11744. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11745. Doo::loadModel ( "accountBook" );
  11746. $accountBook = new accountBook ();
  11747. $detail = $accountBook->getAccountBookByAid ( $serial );
  11748. echo json_encode ( array (
  11749. 'status' => 1,
  11750. 'detail' => $detail
  11751. ) );
  11752. }
  11753. function ajaxGetWasteInvoice() {
  11754. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11755. Doo::loadModel ( 'invoice' );
  11756. $invoice = new invoice ();
  11757. Doo::loadModel ( 'invoiceReceivables' );
  11758. $invoiceReceivables = new invoiceReceivables ();
  11759. $detail = $invoice->getInvoiceByIid ( $serial );
  11760. $detailReceivables = $invoiceReceivables->getInvoiceReceivablesByIrid ( $detail ['irid'] );
  11761. $detail ['receivablesBank'] = $detailReceivables ['receivablesBank'];
  11762. echo json_encode ( array (
  11763. 'status' => 1,
  11764. 'detail' => $detail
  11765. ) );
  11766. }
  11767. /**
  11768. */
  11769. function ajaxGetWasteReceipt() {
  11770. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11771. $accountTypeKey = $this->get_args ( 'accountTypeKey' ) ? $this->get_args ( 'accountTypeKey' ) : "";
  11772. Doo::loadModel ( 'receipt' );
  11773. $receipt = new receipt ();
  11774. Doo::loadClass ( 'XDeode' );
  11775. $XDeode = new XDeode ( 5 );
  11776. $rid = $XDeode->decode ( $serial );
  11777. $accountType= $XDeode->decode ( $accountTypeKey );
  11778. // 获得个数据
  11779. $detail = $receipt->getReceiptByRid ( $rid );
  11780. // 初始化
  11781. $detail ['reviseDetail'] = array ();
  11782. if (! empty ( $value ['reviseDetail'] ))
  11783. $detail ['reviseDetail'] = json_decode ( $detail ['reviseDetail'], true );
  11784. $detail ['accountItem'] = json_decode ( $detail ['accountItem'], true );
  11785. $detail ['loanItem'] = json_decode ( $detail ['loanItem'], true );
  11786. $detail ['loanSumCN'] = $this->num_to_rmb ( $detail ['loanSum'] );
  11787. $detail ['sumCN'] = $this->num_to_rmb ( $detail ['sum'] );
  11788. // 获得费用html
  11789. $html = $this->getWasteReceiptHtml ( $detail ,$accountType);
  11790. // 获得费用审批人数据
  11791. $detail = $this->getReceiptApproverHtml ( $detail );
  11792. // 审批执行
  11793. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  11794. <th class="taC" width="90">审批人</th>
  11795. <th class="taC">审批意见</th></tr>';
  11796. foreach ( $detail ['verifyList'] as $key => $value ) {
  11797. $html .= '<tr>
  11798. <td>' . $value [1] . '</td>
  11799. <td>' . $value ['opinion'] . '</td>
  11800. </tr>
  11801. ';
  11802. }
  11803. $html .= ' </tbody></table>';
  11804. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  11805. <th class="taC" width="90">执行人</th>
  11806. <th class="taC">执行意见</th></tr>';
  11807. foreach ( $detail ['executeCopy'] as $key => $value ) {
  11808. $html .= '<tr>
  11809. <td>' . $value [1] . '</td>
  11810. <td>' . $value ['opinion'] . '</td>
  11811. </tr>
  11812. ';
  11813. }
  11814. $html .= ' </tbody></table>';
  11815. if($accountType==1){
  11816. Doo::loadModel ( 'loanReceipt' );
  11817. $loanReceipt = new loanReceipt ();
  11818. $loanList = $loanReceipt->getOne ( array (
  11819. 'where' => 'rid=' . $detail ['loanRid'],
  11820. 'desc' => 'rid',
  11821. 'asArray' => true
  11822. ) );
  11823. $html .= '<table class="table table-bordered table-condensed">
  11824. <tr class="warning">
  11825. <td class="taR"><b>汇款金额</b></td>
  11826. <td width="140" class="taR"><b style="font-size: 24px">¥'.$loanList['amount'].'</b></td>
  11827. </tr>
  11828. </table>';
  11829. }else{
  11830. $html .= '<table class="table table-bordered table-condensed">
  11831. <tr class="warning">
  11832. <td class="taR"><b>汇款金额</b></td>
  11833. <td width="140" class="taR"><b style="font-size: 24px">¥' . $detail ['amount'] . '</b></td>
  11834. </tr>
  11835. </table>';
  11836. }
  11837. // print_r($detail['verifyList']);
  11838. // header ( 'Content-Type:text/html;charset=utf-8' );
  11839. // echo $html;
  11840. echo json_encode ( array (
  11841. 'status' => 1,
  11842. 'html' => $html,
  11843. 'detail' => $detail
  11844. ) );
  11845. }
  11846. function getReceiptApproverHtml($detail = array()) {
  11847. Doo::loadModel ( 'loanReceipt' );
  11848. $loanReceipt = new loanReceipt ();
  11849. Doo::loadModel ( 'verify' );
  11850. $verify = new verify ();
  11851. Doo::loadModel ( 'staff' );
  11852. $staff = new staff ();
  11853. if (empty ( $detail ))
  11854. return array ();
  11855. $loanList = $loanReceipt->getOne ( array (
  11856. 'where' => 'rid=' . $detail ['loanRid'],
  11857. 'desc' => 'rid',
  11858. 'asArray' => true
  11859. ) );
  11860. if ($detail ['status'] == 3 || $detail ['status'] == 1 || $detail ['status'] == 8 || $detail ['status'] == 9) {
  11861. if ($detail ['status'] == 8 && $detail ['Rtype'] == 1)
  11862. $verifyList ['staff'] = $loanList ['verifyBreakup'];
  11863. else
  11864. $verifyList ['staff'] = $detail ['verifyBreakup'];
  11865. } else
  11866. $verifyList = $verify->getOne ( array (
  11867. 'where' => 'vid=' . $detail ['verify'],
  11868. 'asArray' => true
  11869. ) );
  11870. $verifyList = json_decode ( $verifyList ['staff'], true );
  11871. Doo::loadModel ( 'role' );
  11872. $role = new role ();
  11873. $roleId = 0;
  11874. $flag = true;
  11875. $roleKey = 0;
  11876. $endStaffArray = array ();
  11877. $roleArrayCopy = array ();
  11878. foreach ( $verifyList as $k => $v ) {
  11879. // init verifyStaff
  11880. if ($v [1] == 'ROLE') {
  11881. if (! empty ( $verifyStaff )) {
  11882. $endStaffArray = end ( $verifyStaff );
  11883. }
  11884. $roleVerify = json_decode ( $v [3], true );
  11885. $roleKey = $k;
  11886. $roleArray = array ();
  11887. $rolename = $role->getOne ( array (
  11888. 'where' => 'rid=' . $v [0],
  11889. 'asArray' => true
  11890. ) );
  11891. foreach ( $roleVerify as $o => $p ) {
  11892. $staffID = explode ( '_', $p );
  11893. $staffInfo = $staff->getOne ( array (
  11894. 'where' => 'sid=' . $staffID [0],
  11895. 'asArray' => true
  11896. ) );
  11897. // print_r($staffID);
  11898. $exp = array (
  11899. 0 => $staffInfo ['sid'],
  11900. 1 => $staffID [1],
  11901. 2 => $staffInfo ['avatar'],
  11902. 'date' => '',
  11903. 'date' => '',
  11904. 'opinion' => '',
  11905. 'status' => '',
  11906. 'rolename' => $rolename ['name']
  11907. );
  11908. array_push ( $roleArray, $exp );
  11909. }
  11910. $roleArrayCopy [$v [0]] = $roleArray;
  11911. // $verifyList[$k]['roleArray']=$roleArray;
  11912. }
  11913. $verifyList [$k] ['date'] = "";
  11914. $verifyList [$k] ['opinion'] = "";
  11915. $verifyList [$k] ['status'] = "";
  11916. if (empty ( $verifyStaff )) {
  11917. $verifyList [$k] ['date'] = "";
  11918. $verifyList [$k] ['opinion'] = "";
  11919. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  11920. $verifyList [$k] ['status'] = 4;
  11921. $flag = false;
  11922. }
  11923. } else {
  11924. foreach ( $verifyStaff as $m => $u ) {
  11925. if ($v [0] == $m) {
  11926. $verifyList [$k] ['date'] = $u ['date'];
  11927. $verifyList [$k] ['opinion'] = $u ['opinion'];
  11928. $verifyList [$k] ['status'] = $u ['status'];
  11929. $flag = false;
  11930. break;
  11931. }
  11932. }
  11933. $endStaffArray = end ( $verifyStaff );
  11934. }
  11935. }
  11936. $rolename ['name'] = '';
  11937. if (! empty ( $roleId )) {
  11938. Doo::loadModel ( 'role' );
  11939. $role = new role ();
  11940. $rolename = $role->getOne ( array (
  11941. 'where' => 'rid=' . $roleId,
  11942. 'asArray' => true
  11943. ) );
  11944. }
  11945. if (! empty ( $verifyStaff ))
  11946. $endStaffArray = end ( $verifyStaff );
  11947. $KOP = false;
  11948. foreach ( $roleArrayCopy as $P => $A ) {
  11949. foreach ( $A as $MKI => $AVL ) {
  11950. if (! empty ( $verifyStaff )) {
  11951. // &&$rolename['rid']==$endStaffArray['nextStaff']
  11952. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  11953. $button = 4;
  11954. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  11955. }
  11956. foreach ( $verifyStaff as $m => $u ) {
  11957. $AVLFK = $AVL [0] . '_R';
  11958. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  11959. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  11960. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  11961. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  11962. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  11963. break;
  11964. }
  11965. }
  11966. } else {
  11967. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  11968. $button = 4;
  11969. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  11970. }
  11971. }
  11972. // $roleArray[$MKI]['rolename']=$rolename['name'];
  11973. $KOP = true;
  11974. }
  11975. }
  11976. foreach ( $roleArrayCopy as $k => $v ) {
  11977. foreach ( $verifyList as $m => $n ) {
  11978. if ($n [0] == $k) {
  11979. array_splice ( $verifyList, $m, 1, $v );
  11980. }
  11981. }
  11982. }
  11983. // 费用执行人相关数据
  11984. $executeCopy = json_decode ( $detail ['executeCopy'], true );
  11985. $executeStaff = json_decode ( $detail ['executeStaff'], true );
  11986. foreach ( $executeCopy as $k => $v ) {
  11987. $executeCopy [$k] ['date'] = '';
  11988. $executeCopy [$k] ['opinion'] = '';
  11989. $executeCopy [$k] ['status'] = '';
  11990. if (! empty ( $executeStaff ))
  11991. foreach ( $executeStaff as $m => $u ) {
  11992. if ($v [0] == $m) {
  11993. $executeCopy [$k] ['date'] = $u ['date'];
  11994. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  11995. $executeCopy [$k] ['status'] = $u ['status'];
  11996. break;
  11997. }
  11998. }
  11999. }
  12000. $detail ['executeCopy'] = $executeCopy;
  12001. $detail ['verifyList'] = $verifyList;
  12002. return $detail;
  12003. }
  12004. function getWasteReceiptHtml($detail = array(),$accountType=1) {
  12005. if (empty ( $detail ))
  12006. return '';
  12007. $html = '';
  12008. if ($detail ['Rtype'] == 0) { // 报销单
  12009. $html .= '<table class="table table-bordered table-condensed">
  12010. <tbody>
  12011. <tr>
  12012. <th colspan="2" class="taC">日常相关费用</th>
  12013. </tr>';
  12014. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12015. $html .= '
  12016. <tr>
  12017. <th>' . $value ['name'] . '</th>
  12018. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12019. </tr>';
  12020. }
  12021. $html .= '
  12022. <tr>
  12023. <th class="taR">合计</th>
  12024. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12025. </tr>';
  12026. $html .= '<tr>
  12027. <th colspan="2" class="taC">差旅相关费用</th>
  12028. </tr>';
  12029. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12030. $html .= '
  12031. <tr>
  12032. <th>' . $value ['name'] . '</th>
  12033. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12034. </tr>';
  12035. }
  12036. $html .= '
  12037. <tr>
  12038. <th class="taR">合计</th>
  12039. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12040. </tr>';
  12041. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12042. $html .= '<tr>
  12043. <th colspan="2" class="taC">内部培训费用</th>
  12044. </tr>';
  12045. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12046. $html .= '
  12047. <tr>
  12048. <th>' . $value ['name'] . '</th>
  12049. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12050. </tr>';
  12051. }
  12052. $html .= '
  12053. <tr>
  12054. <th class="taR">合计</th>
  12055. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12056. </tr>';
  12057. }
  12058. $html .= '<tr>
  12059. <th colspan="2" class="taC">其他</th>
  12060. </tr>';
  12061. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12062. $html .= '
  12063. <tr>
  12064. <th>' . $value ['name'] . '</th>
  12065. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12066. </tr>';
  12067. }
  12068. $html .= '
  12069. <tr>
  12070. <th class="taR">合计</th>
  12071. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12072. </tr>';
  12073. $html .= '<tr>
  12074. <th colspan="2" class="taC">报销金额调整</th>
  12075. </tr>';
  12076. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12077. $html .= '
  12078. <tr>
  12079. <th>' . $value ['name'] . '</th>
  12080. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12081. </tr>';
  12082. }
  12083. $html .= '
  12084. <tr>
  12085. <th class="taR">合计</th>
  12086. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12087. </tr>';
  12088. $html .= '
  12089. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12090. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12091. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12092. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12093. <tr class="warning">
  12094. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12095. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12096. </tr>
  12097. </tbody>
  12098. </table>';
  12099. } elseif ($detail ['Rtype'] == 2) {//对公汇款
  12100. $html .= '
  12101. <table class="table table-bordered table-condensed">
  12102. <tbody>
  12103. <tr>
  12104. <th colspan="2" class="taC">办事处相关费用</th>
  12105. </tr>';
  12106. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12107. $html .= '
  12108. <tr>
  12109. <th>' . $value ['name'] . '</th>
  12110. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12111. </tr>';
  12112. }
  12113. $html .= '
  12114. <tr>
  12115. <th class="taR">合计</th>
  12116. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12117. </tr>';
  12118. $html .= '
  12119. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12120. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12121. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12122. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12123. <tr class="warning">
  12124. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12125. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12126. </tr>
  12127. </tbody>
  12128. </table>';
  12129. } elseif ($detail ['Rtype'] == 1) {//借款 或者借款报销
  12130. Doo::loadModel ( 'loanReceipt' );
  12131. $loanReceipt = new loanReceipt ();
  12132. $loanList = $loanReceipt->getOne ( array (
  12133. 'where' => 'rid=' . $detail ['loanRid'],
  12134. 'desc' => 'rid',
  12135. 'asArray' => true
  12136. ) );
  12137. // print_r($loanList);
  12138. $loanList ['sumCN']=$this->num_to_rmb($loanList ['sum']);
  12139. $html .= '<table class="table table-bordered table-condensed">
  12140. <tbody>
  12141. <tr>
  12142. <th colspan="2" class="taC">借款费用</th>
  12143. </tr>';
  12144. foreach ( $detail ['loanItem'] ['借款费用'] as $key => $value ) {
  12145. $html .= '<tr>
  12146. <th>' . $value ['name'] . '</th>
  12147. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12148. </tr>';
  12149. }
  12150. $html .= '<tr>
  12151. <th class="taC" colspan="2">产生费用所在办事处</th>
  12152. </tr>
  12153. <tr>
  12154. <th style="text-align: center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th>
  12155. </tr>
  12156. <tr>
  12157. <th class="taC" colspan="2">费用说明</th>
  12158. </tr>
  12159. <tr>
  12160. <td colspan="2">' . $loanList ['explanation'] . '</td>
  12161. </tr>
  12162. <tr class="warning">
  12163. <td class="taR"><b>(' . $loanList ['receiptOrder'] . ')本次费用合计</b></td>
  12164. <td class="taR"><b style="font-size: 24px">¥' . $loanList ['sum'] . '</b><br>' . $loanList ['sumCN'] . '</td>
  12165. </tr>
  12166. </tbody>
  12167. </table>
  12168. ';
  12169. if ( $accountType==2) {
  12170. $balance=$detail ['sum']-$loanList ['sum'];
  12171. $balanceCN=$this->num_to_rmb($balance);
  12172. $html .= '<table class="table table-bordered table-condensed">
  12173. <tbody>
  12174. <tr>
  12175. <th colspan="2" class="taC">日常相关费用</th>
  12176. </tr>';
  12177. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12178. $html .= '
  12179. <tr>
  12180. <th>' . $value ['name'] . '</th>
  12181. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12182. </tr>';
  12183. }
  12184. $html .= '
  12185. <tr>
  12186. <th class="taR">合计</th>
  12187. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12188. </tr>';
  12189. $html .= '<tr>
  12190. <th colspan="2" class="taC">差旅相关费用</th>
  12191. </tr>';
  12192. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12193. $html .= '
  12194. <tr>
  12195. <th>' . $value ['name'] . '</th>
  12196. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12197. </tr>';
  12198. }
  12199. $html .= '
  12200. <tr>
  12201. <th class="taR">合计</th>
  12202. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12203. </tr>';
  12204. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12205. $html .= '<tr>
  12206. <th colspan="2" class="taC">内部培训费用</th>
  12207. </tr>';
  12208. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12209. $html .= '
  12210. <tr>
  12211. <th>' . $value ['name'] . '</th>
  12212. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12213. </tr>';
  12214. }
  12215. $html .= '
  12216. <tr>
  12217. <th class="taR">合计</th>
  12218. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12219. </tr>';
  12220. }
  12221. $html .= '<tr>
  12222. <th colspan="2" class="taC">其他</th>
  12223. </tr>';
  12224. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12225. $html .= '
  12226. <tr>
  12227. <th>' . $value ['name'] . '</th>
  12228. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12229. </tr>';
  12230. }
  12231. $html .= '
  12232. <tr>
  12233. <th class="taR">合计</th>
  12234. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12235. </tr>';
  12236. $html .= '<tr>
  12237. <th colspan="2" class="taC">报销金额调整</th>
  12238. </tr>';
  12239. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12240. $html .= '
  12241. <tr>
  12242. <th>' . $value ['name'] . '</th>
  12243. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12244. </tr>';
  12245. }
  12246. $html .= '
  12247. <tr>
  12248. <th class="taR">合计</th>
  12249. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12250. </tr>';
  12251. $html .= '
  12252. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12253. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12254. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12255. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12256. <tr class="warning">
  12257. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12258. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12259. </tr>
  12260. <tr class="success">
  12261. <td class="taR"><b>借款结余</b></td>
  12262. <td class="taR"><b style="font-size:24px">¥'.$balance.'</b><br>'.$balanceCN.'</td>
  12263. </tr>
  12264. </tbody>
  12265. </table>';
  12266. }
  12267. }
  12268. return $html;
  12269. }
  12270. /**
  12271. * 计算流水
  12272. */
  12273. function getWasteBookStatistics($waste = array(), $inComeStatistics) {
  12274. $bakWaste ['bank'] = array (
  12275. 'CGBDeposit' => 0,
  12276. 'ICBCDeposit' => 0,
  12277. 'HUADeposit' => 0,
  12278. 'PersonalDeposit' => 0
  12279. );
  12280. $bakWaste ['financial'] = array (
  12281. 'current' => array (
  12282. 'CGBDeposit' => 0,
  12283. 'ICBCDeposit' => 0
  12284. ),
  12285. 'fixed' => array (
  12286. 'CGBDeposit' => 0,
  12287. 'ICBCDeposit' => 0
  12288. )
  12289. );
  12290. // 存款
  12291. foreach ( $waste ['bank'] as $key => $value ) {
  12292. // 收入
  12293. foreach ( $inComeStatistics ['incomeStatistics'] as $k => $v ) {
  12294. // 广发
  12295. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12296. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12297. }
  12298. // 工商
  12299. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12300. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12301. }
  12302. // 华润
  12303. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12304. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12305. }
  12306. // 个人
  12307. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12308. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12309. }
  12310. }
  12311. }
  12312. foreach ( $waste ['bank'] as $key => $value ) {
  12313. // 支出
  12314. foreach ( $inComeStatistics ['expenditureStatistics'] as $k => $v ) {
  12315. // 广发
  12316. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12317. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12318. }
  12319. // 工商
  12320. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12321. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12322. }
  12323. // 华润
  12324. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12325. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12326. }
  12327. // 个人
  12328. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12329. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12330. }
  12331. }
  12332. }
  12333. // 活期
  12334. foreach ( $waste ['financial'] ['current'] as $key => $value ) {
  12335. foreach ( $inComeStatistics ['currentStatistics'] as $k => $v ) {
  12336. // 广发
  12337. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12338. $waste ['financial'] ['current'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  12339. }
  12340. // 工商
  12341. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12342. $waste ['financial'] ['current'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  12343. }
  12344. // 个人
  12345. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12346. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  12347. }
  12348. }
  12349. }
  12350. // print_r($inComeStatistics ['fixedStatistics']);
  12351. // 固期
  12352. foreach ( $waste ['financial'] ['fixed'] as $key => $value ) {
  12353. foreach ( $inComeStatistics ['fixedStatistics'] as $k => $v ) {
  12354. // 广发
  12355. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12356. $waste ['financial'] ['fixed'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  12357. }
  12358. // 工商
  12359. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12360. $waste ['financial'] ['fixed'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  12361. }
  12362. // 个人
  12363. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12364. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  12365. }
  12366. }
  12367. }
  12368. return $waste;
  12369. }
  12370. function lyt() {
  12371. Doo::loadModel ( "receiptDetail" );
  12372. $receiptDetail = new receiptDetail ();
  12373. $receiptCollectList = $receiptDetail->find ( array (
  12374. 'where' => 'status=1 ',
  12375. 'asArray' => true
  12376. ) );
  12377. foreach ( $receiptCollectList as $key => $value ) {
  12378. $receiptDetail = new receiptDetail ();
  12379. $receiptDetail->pastDate = $value ['date'];
  12380. $receiptDetail->update ( array (
  12381. 'where' => "rdid= '" . $value ['rdid'] . "'"
  12382. ) );
  12383. }
  12384. }
  12385. function staffCollectMonthDetail() {
  12386. //include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  12387. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12388. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12389. if (! $year)
  12390. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12391. if (! $month)
  12392. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12393. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  12394. if (! $nature){
  12395. $nature = isset ( $this->params ['nature'] ) ? $this->params ['nature'] : 'ONJOB';
  12396. }
  12397. Doo::loadModel ( 'staff' );
  12398. $staff = new staff ();
  12399. Doo::loadModel ( "receiptDetail" );
  12400. $receiptDetail = new receiptDetail ();
  12401. Doo::loadModel ( 'accountItem' );
  12402. $accountItem = new accountItem ();
  12403. Doo::loadModel ( 'statistics' );
  12404. $statistics = new statistics ();
  12405. Doo::loadModel ( "receiptAuthorityManage" );
  12406. $receiptAuthorityManage = new receiptAuthorityManage ();
  12407. $aiList=$accountItem->getAccountItem();
  12408. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  12409. $cidList = array ();
  12410. foreach ( $imcStaff as $key => $value ) {
  12411. array_push ( $cidList, $value ['cid'] );
  12412. }
  12413. $cidString = implode ( ',', $cidList );
  12414. $naturecon='';
  12415. if ($nature=='ONJOB'){
  12416. $naturecon=' and (nature!=4 )';
  12417. }elseif($nature=='LEAVEJOB'){
  12418. $naturecon=' and (nature=4 )';
  12419. }else{
  12420. die ( 'illegal request--nature' );
  12421. }
  12422. $staffList = $staff->find ( array (
  12423. 'where' => 'username!="admin" and cid in (' . $cidString . ')'.$naturecon,
  12424. 'asArray' => true
  12425. ) );
  12426. $categoryList = $staff->find ( array (
  12427. 'select' => 'COUNT(*) as count,cid,category',
  12428. 'where' => 'username !="admin" and cid in (' . $cidString . ')'.$naturecon,
  12429. 'groupby' => 'cid',
  12430. 'asArray' => true
  12431. ) );
  12432. $list = array ();
  12433. foreach($aiList as $key=>$value){
  12434. foreach ($value as $v){
  12435. $subtotal[$key][$v['name']]=0;
  12436. }
  12437. }
  12438. foreach ( $categoryList as $vlu ) {
  12439. $s1 = 0;
  12440. $m1 = 0;
  12441. $subtotal[$this->AGENCY]['AGENCY']=$subtotal[$this->TRAVEL]['TRAVEL']=$subtotal[$this->INTTRAIN]['INTTRAIN']=$subtotal[$this->TRAIN]['TRAIN']=$subtotal[$this->OTHER]['OTHER']=0;
  12442. foreach ( $staffList as $value ) {
  12443. if ($vlu ['cid'] == $value ['cid']) {
  12444. // pastDate
  12445. $receiptCollectList = $receiptDetail->find ( array (
  12446. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12447. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12448. 'groupby' => 'item,Month(pastDate),itemCategory',
  12449. 'asArray' => true
  12450. ) );
  12451. if (! empty ( $receiptCollectList )) {
  12452. $receiptL = array (
  12453. '日常相关费用' => array (),
  12454. '差旅相关费用' => array (),
  12455. '内部培训费用' => array (),
  12456. '培训班费用' => array (),
  12457. '其他' => array ()
  12458. );
  12459. $html = "";
  12460. $psum = 0;
  12461. foreach ( $aiList[$this->AGENCY] as $va ) {
  12462. $falg = true;
  12463. foreach ( $receiptCollectList as $v ) {
  12464. if ($v ['itemCategory'] == '日常相关费用') {
  12465. if ($v ['item'] == $va['name']) {
  12466. $subtotal[$this->AGENCY][$va['name']]+=$v ['price'];
  12467. $psum += $v ['price'];
  12468. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12469. $falg = false;
  12470. break;
  12471. }
  12472. }
  12473. }
  12474. if ($falg)
  12475. $html .= '<td class="taR">-</td>';
  12476. }
  12477. $subtotal[$this->AGENCY]['AGENCY'] += $psum;
  12478. if (! empty ( $psum ))
  12479. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12480. else
  12481. $psum = '<td class="colGreen taR">-</td>';
  12482. $receiptL ['日常相关费用'] = $psum . $html;
  12483. /* ----------------------------------- */
  12484. $html = "";
  12485. $psum = 0;
  12486. foreach ( $aiList[$this->TRAVEL] as $va ) {
  12487. $falg = true;
  12488. foreach ( $receiptCollectList as $v ) {
  12489. if ($v ['itemCategory'] == '差旅相关费用') {
  12490. if ($v ['item'] == $va['name']) {
  12491. $subtotal[$this->TRAVEL][$va['name']]+=$v ['price'];
  12492. $psum += $v ['price'];
  12493. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12494. $falg = false;
  12495. break;
  12496. }
  12497. }
  12498. }
  12499. if ($falg)
  12500. $html .= '<td class="taR">-</td>';
  12501. }
  12502. $subtotal[$this->TRAVEL]['TRAVEL'] += $psum;
  12503. if (! empty ( $psum ))
  12504. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12505. else
  12506. $psum = '<td class="colGreen taR">-</td>';
  12507. $receiptL ['差旅相关费用'] = $psum . $html;
  12508. /* ------------------------------------- */
  12509. $html = "";
  12510. $psum = 0;
  12511. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  12512. $falg = true;
  12513. foreach ( $receiptCollectList as $v ) {
  12514. if ($v ['itemCategory'] == '内部培训费用') {
  12515. if ($v ['item'] == $va['name']) {
  12516. $subtotal[$this->INTTRAIN][$va['name']]+=$v ['price'];
  12517. $psum += $v ['price'];
  12518. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12519. $falg = false;
  12520. break;
  12521. }
  12522. }
  12523. }
  12524. if ($falg)
  12525. $html .= '<td class="taR">-</td>';
  12526. }
  12527. $subtotal[$this->INTTRAIN]['INTTRAIN'] += $psum;
  12528. if (! empty ( $psum ))
  12529. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12530. else
  12531. $psum = '<td class="colGreen taR">-</td>';
  12532. $receiptL ['内部培训费用'] = $psum . $html;
  12533. /* ----------------------------------- */
  12534. $html = "";
  12535. $psum = 0;
  12536. foreach ( $aiList[$this->TRAIN] as $va ) {
  12537. $falg = true;
  12538. foreach ( $receiptCollectList as $v ) {
  12539. if ($v ['itemCategory'] == '培训班费用') {
  12540. if ($v ['item'] == $va['name']) {
  12541. $subtotal[$this->TRAIN][$va['name']]+=$v ['price'];
  12542. $psum += $v ['price'];
  12543. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12544. $falg = false;
  12545. break;
  12546. }
  12547. }
  12548. }
  12549. if ($falg)
  12550. $html .= '<td class="taR">-</td>';
  12551. }
  12552. $subtotal[$this->TRAIN]['TRAIN'] += $psum;
  12553. if (! empty ( $psum ))
  12554. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12555. else
  12556. $psum = '<td class="colGreen taR">-</td>';
  12557. $receiptL ['培训班费用'] = $psum . $html;
  12558. /* ------------------------------------- */
  12559. $html = "";
  12560. $psum = 0;
  12561. foreach ( $aiList[$this->OTHER] as $va ) {
  12562. $falg = true;
  12563. foreach ( $receiptCollectList as $v ) {
  12564. if ($v ['itemCategory'] == '其他') {
  12565. if (trim ( $v ['item'] ) == $va['name']) {
  12566. $subtotal[$this->OTHER][$va['name']]+=$v ['price'];
  12567. $psum += $v ['price'];
  12568. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12569. $falg = false;
  12570. break;
  12571. }
  12572. }
  12573. }
  12574. if ($falg)
  12575. $html .= '<td class="taR">-</td>';
  12576. }
  12577. $subtotal[$this->OTHER]['OTHER'] += $psum;
  12578. if (! empty ( $psum ))
  12579. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12580. else
  12581. $psum = '<td class="colGreen taR">-</td>';
  12582. $receiptL ['其他'] = $psum . $html;
  12583. /* ------------------------------------- */
  12584. $html = "";
  12585. $psum = 0;
  12586. foreach ( $receiptCollectList as $v ) {
  12587. if ($v ['itemCategory'] == '报销金额调整') {
  12588. if (! empty ( $v ['price'] )) {
  12589. $psum += $v ['price'];
  12590. }
  12591. }
  12592. }
  12593. $s1 += $psum;
  12594. if (! empty ( $psum ))
  12595. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  12596. else
  12597. $psum = '<td class="taR colOrange">-</td>';
  12598. $receiptL ['报销金额调整'] = $psum . $html;
  12599. } else {
  12600. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  12601. foreach ( $aiList[$this->AGENCY] as $va ) {
  12602. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  12603. }
  12604. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  12605. foreach ( $aiList[$this->TRAVEL] as $va ) {
  12606. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  12607. }
  12608. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  12609. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  12610. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  12611. }
  12612. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  12613. foreach ( $aiList[$this->TRAIN] as $va ) {
  12614. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  12615. }
  12616. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  12617. foreach ( $aiList[$this->OTHER] as $va ) {
  12618. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  12619. }
  12620. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  12621. }
  12622. $monthStaffPrice = $receiptDetail->find ( array (
  12623. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12624. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12625. 'groupby' => 'Month(pastDate)',
  12626. 'asArray' => true
  12627. ) );
  12628. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  12629. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  12630. $m1 += $monthStaffPrice [0] ['price'];
  12631. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  12632. } else
  12633. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  12634. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  12635. $list [$value ['username']] = $receiptL;
  12636. }
  12637. }
  12638. $receiptL [$this->AGENCY] ='<td class="colGreen taR">'.$subtotal[$this->AGENCY]['AGENCY'].'</td>';
  12639. foreach ( $aiList[$this->AGENCY] as $va ) {
  12640. $receiptL [$this->AGENCY] .='<td class="taR">' . $subtotal[$this->AGENCY][$va['name']] . '</td>';
  12641. $subtotal[$this->AGENCY][$va['name']]=0;
  12642. }
  12643. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">'.$subtotal[$this->TRAVEL]['TRAVEL'].'</td>';
  12644. foreach ( $aiList[$this->TRAVEL] as $va ) {
  12645. $receiptL [$this->TRAVEL] .='<td class="taR">' . $subtotal[$this->TRAVEL][$va['name']] . '</td>';
  12646. $subtotal[$this->TRAVEL][$va['name']]=0;
  12647. }
  12648. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">'.$subtotal[$this->INTTRAIN]['INTTRAIN'].'</td>';
  12649. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  12650. $receiptL [$this->INTTRAIN] .='<td class="taR">' . $subtotal[$this->INTTRAIN][$va['name']] . '</td>';
  12651. $subtotal[$this->INTTRAIN][$va['name']]=0;
  12652. }
  12653. $receiptL [$this->TRAIN] ='<td class="colGreen taR">'.$subtotal[$this->TRAIN]['TRAIN'].'</td>';
  12654. foreach ( $aiList[$this->TRAIN] as $va ) {
  12655. $receiptL [$this->TRAIN] .='<td class="taR">' . $subtotal[$this->TRAIN][$va['name']] . '</td>';
  12656. $subtotal[$this->TRAIN][$va['name']]=0;
  12657. }
  12658. $receiptL [$this->OTHER] ='<td class="colGreen taR">'.$subtotal[$this->OTHER]['OTHER'].'</td>';
  12659. foreach ( $aiList[$this->OTHER] as $va ) {
  12660. $receiptL [$this->OTHER] .='<td class="taR">' . $subtotal[$this->OTHER][$va['name']] . '</td>';
  12661. $subtotal[$this->OTHER][$va['name']]=0;
  12662. }
  12663. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  12664. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  12665. $receiptL ['usernameEn'] =false;
  12666. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  12667. }
  12668. $data ['list'] = $list;
  12669. // print_r($list);
  12670. $receiptCollectList = $receiptDetail->find ( array (
  12671. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12672. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12673. 'groupby' => 'item,Month(pastDate),itemCategory',
  12674. 'asArray' => true
  12675. ) );
  12676. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  12677. // statistics html
  12678. $stList = $statistics->getOne ( array (
  12679. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  12680. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  12681. 'groupby' => 'Month(date)',
  12682. 'asArray' => true
  12683. ) );
  12684. if (empty ( $stList ))
  12685. $stList = array (
  12686. 'rePrice' => 0,
  12687. 'agPrice' => 0
  12688. );
  12689. $data ['stList'] = array (
  12690. 'rePrice' => $stList ['rePrice'],
  12691. 'agPrice' => $stList ['agPrice'],
  12692. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12693. );
  12694. $monthHtml = "";
  12695. for($i = 1; $i <= 12; $i ++) {
  12696. if ($i == $month)
  12697. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  12698. else
  12699. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  12700. }
  12701. $data ['monthHtml'] = $monthHtml;
  12702. $data ['year'] = $year;
  12703. $data ['month'] = $month;
  12704. $data ['nature'] = $nature;
  12705. $data ['aiList'] = $aiList;
  12706. $data ['memu'] = "receipt";
  12707. $data ['staff'] = $this->staff;
  12708. $data ['receiptMemu'] = 'companyCategoryCollect';
  12709. $data ['verifyId'] = $this->verifyId;
  12710. $data ['executeId'] = $this->executeId;
  12711. $this->render ( "/admin/staffCollectMonthDetail", $data );
  12712. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  12713. }
  12714. function staffCollectMonthDetail2() {
  12715. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12716. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12717. if (! $year)
  12718. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12719. if (! $month)
  12720. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12721. Doo::loadModel ( 'staff' );
  12722. $staff = new staff ();
  12723. Doo::loadModel ( "receiptDetail" );
  12724. $receiptDetail = new receiptDetail ();
  12725. Doo::loadModel ( 'accountItem' );
  12726. $accountItem = new accountItem ();
  12727. Doo::loadModel ( 'statistics' );
  12728. $statistics = new statistics ();
  12729. Doo::loadModel ( 'L_category' );
  12730. $lCategory = new L_category ();
  12731. $staffList = $staff->find ( array (
  12732. 'where' => 'username!="admin"',
  12733. 'asArray' => true
  12734. ) );
  12735. $categoryList = $staff->find ( array (
  12736. 'select' => 'COUNT(*) as count,cid,category',
  12737. 'where' => 'username !="admin"',
  12738. 'groupby' => 'cid',
  12739. 'asArray' => true
  12740. ) );
  12741. $list = array ();
  12742. foreach ( $categoryList as $vlu ) {
  12743. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  12744. $r1 = 0;
  12745. $r2 = 0;
  12746. $r3 = 0;
  12747. $r4 = 0;
  12748. $r5 = 0;
  12749. $r6 = 0;
  12750. $r7 = 0;
  12751. $r8 = 0;
  12752. $r9 = 0;
  12753. $r10 = 0;
  12754. $r11 = 0;
  12755. $r12 = 0;
  12756. $r13 = 0;
  12757. $r14 = 0;
  12758. $r15 = 0;
  12759. $c1 = 0;
  12760. $c2 = 0;
  12761. $c3 = 0;
  12762. $c4 = 0;
  12763. $c5 = 0;
  12764. $c6 = 0;
  12765. $p1 = 0;
  12766. $p2 = 0;
  12767. $p3 = 0;
  12768. $p4 = 0;
  12769. $p5 = 0;
  12770. $p6 = 0;
  12771. $p7 = 0;
  12772. $p8 = 0;
  12773. $p9 = 0;
  12774. $t1 = 0;
  12775. $t2 = 0;
  12776. $t3 = 0;
  12777. $t4 = 0;
  12778. $t5 = 0;
  12779. $s1 = 0;
  12780. $m1 = 0;
  12781. foreach ( $staffList as $value ) {
  12782. if ($vlu ['cid'] == $value ['cid']) {
  12783. $receiptCollectList = $receiptDetail->find ( array (
  12784. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  12785. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  12786. 'groupby' => 'item,Month(date),itemCategory',
  12787. 'asArray' => true
  12788. ) );
  12789. if (! empty ( $receiptCollectList )) {
  12790. $receiptL = array (
  12791. '日常相关费用' => array (),
  12792. '差旅相关费用' => array (),
  12793. '培训班费用' => array (),
  12794. '其他' => array ()
  12795. );
  12796. $html = "";
  12797. $psum = 0;
  12798. $item = array (
  12799. '市内交通费',
  12800. '市内出租费',
  12801. '办事处房租',
  12802. '电话费',
  12803. '水费',
  12804. '电费',
  12805. '办公费用',
  12806. '邮寄费',
  12807. '其他费用',
  12808. '车辆费用',
  12809. '广告费',
  12810. '团队建设费',
  12811. '物业管理费',
  12812. '宽带费'
  12813. );
  12814. foreach ( $item as $va ) {
  12815. $falg = true;
  12816. foreach ( $receiptCollectList as $v ) {
  12817. if ($v ['itemCategory'] == '日常相关费用') {
  12818. if ($v ['item'] == $va) {
  12819. if ($va == '市内交通费')
  12820. $r1 += $v ['price'];
  12821. if ($va == '市内出租费')
  12822. $r2 += $v ['price'];
  12823. if ($va == '办事处房租')
  12824. $r3 += $v ['price'];
  12825. if ($va == '电话费')
  12826. $r4 += $v ['price'];
  12827. if ($va == '水费')
  12828. $r5 += $v ['price'];
  12829. if ($va == '电费')
  12830. $r6 += $v ['price'];
  12831. if ($va == '办公费用')
  12832. $r7 += $v ['price'];
  12833. if ($va == '邮寄费')
  12834. $r8 += $v ['price'];
  12835. if ($va == '其他费用')
  12836. $r9 += $v ['price'];
  12837. if ($va == '车辆费用')
  12838. $r10 += $v ['price'];
  12839. if ($va == '广告费')
  12840. $r11 += $v ['price'];
  12841. if ($va == '团队建设费')
  12842. $r13 += $v ['price'];
  12843. if ($va == '物业管理费')
  12844. $r14 += $v ['price'];
  12845. if ($va == '宽带费')
  12846. $r15 += $v ['price'];
  12847. $psum += $v ['price'];
  12848. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12849. $falg = false;
  12850. break;
  12851. }
  12852. }
  12853. }
  12854. if ($falg)
  12855. $html .= '<td class="taR">-</td>';
  12856. }
  12857. $r12 += $psum;
  12858. if (! empty ( $psum ))
  12859. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12860. else
  12861. $psum = '<td class="colGreen taR">-</td>';
  12862. $receiptL ['日常相关费用'] = $psum . $html;
  12863. /* ----------------------------------- */
  12864. $html = "";
  12865. $psum = 0;
  12866. $item = array (
  12867. '往来交通费',
  12868. '市内交通费',
  12869. '出差住宿费',
  12870. '出差补助',
  12871. '其他费用'
  12872. );
  12873. foreach ( $item as $va ) {
  12874. $falg = true;
  12875. foreach ( $receiptCollectList as $v ) {
  12876. if ($v ['itemCategory'] == '差旅相关费用') {
  12877. if ($v ['item'] == $va) {
  12878. if ($va == '往来交通费')
  12879. $c1 += $v ['price'];
  12880. if ($va == '市内交通费')
  12881. $c2 += $v ['price'];
  12882. if ($va == '出差住宿费')
  12883. $c3 += $v ['price'];
  12884. if ($va == '出差补助')
  12885. $c4 += $v ['price'];
  12886. if ($va == '其他费用')
  12887. $c5 += $v ['price'];
  12888. $psum += $v ['price'];
  12889. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12890. $falg = false;
  12891. break;
  12892. }
  12893. }
  12894. }
  12895. if ($falg)
  12896. $html .= '<td class="taR">-</td>';
  12897. }
  12898. $c6 += $psum;
  12899. if (! empty ( $psum ))
  12900. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12901. else
  12902. $psum = '<td class="colGreen taR">-</td>';
  12903. $receiptL ['差旅相关费用'] = $psum . $html;
  12904. /* ------------------------------------- */
  12905. $html = "";
  12906. $psum = 0;
  12907. $item = array (
  12908. '场租费',
  12909. '薪酬',
  12910. '住宿费',
  12911. '交通费',
  12912. '餐饮费',
  12913. '办公费',
  12914. '公关费',
  12915. '其他'
  12916. );
  12917. foreach ( $item as $va ) {
  12918. $falg = true;
  12919. foreach ( $receiptCollectList as $v ) {
  12920. if ($v ['itemCategory'] == '培训班费用') {
  12921. if ($v ['item'] == $va) {
  12922. if ($va == '场租费')
  12923. $p1 += $v ['price'];
  12924. if ($va == '薪酬')
  12925. $p2 += $v ['price'];
  12926. if ($va == '住宿费')
  12927. $p3 += $v ['price'];
  12928. if ($va == '交通费')
  12929. $p4 += $v ['price'];
  12930. if ($va == '餐饮费')
  12931. $p5 += $v ['price'];
  12932. if ($va == '办公费')
  12933. $p6 += $v ['price'];
  12934. if ($va == '公关费')
  12935. $p7 += $v ['price'];
  12936. if ($va == '其他')
  12937. $p8 += $v ['price'];
  12938. $psum += $v ['price'];
  12939. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12940. $falg = false;
  12941. break;
  12942. }
  12943. }
  12944. }
  12945. if ($falg)
  12946. $html .= '<td class="taR">-</td>';
  12947. }
  12948. $p9 += $psum;
  12949. if (! empty ( $psum ))
  12950. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12951. else
  12952. $psum = '<td class="colGreen taR">-</td>';
  12953. $receiptL ['培训班费用'] = $psum . $html;
  12954. /* ------------------------------------- */
  12955. $html = "";
  12956. $psum = 0;
  12957. $item = array (
  12958. '公关费',
  12959. '广告费',
  12960. '借款',
  12961. '可自加费用'
  12962. );
  12963. foreach ( $item as $va ) {
  12964. $falg = true;
  12965. foreach ( $receiptCollectList as $v ) {
  12966. if ($v ['itemCategory'] == '其他') {
  12967. if ($v ['item'] == $va) {
  12968. if ($va == '公关费')
  12969. $t1 += $v ['price'];
  12970. if ($va == '广告费')
  12971. $t2 += $v ['price'];
  12972. if ($va == '借款')
  12973. $t3 += $v ['price'];
  12974. if ($va == '可自加费用')
  12975. $t4 += $v ['price'];
  12976. $psum += $v ['price'];
  12977. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12978. $falg = false;
  12979. break;
  12980. }
  12981. }
  12982. }
  12983. if ($falg)
  12984. $html .= '<td class="taR">-</td>';
  12985. }
  12986. $t5 += $psum;
  12987. if (! empty ( $psum ))
  12988. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12989. else
  12990. $psum = '<td class="colGreen taR">-</td>';
  12991. $receiptL ['其他'] = $psum . $html;
  12992. /* ------------------------------------- */
  12993. $html = "";
  12994. $psum = 0;
  12995. foreach ( $receiptCollectList as $v ) {
  12996. if ($v ['itemCategory'] == '报销金额调整') {
  12997. if (! empty ( $v ['price'] )) {
  12998. $psum += $v ['price'];
  12999. }
  13000. }
  13001. }
  13002. $s1 += $psum;
  13003. if (! empty ( $psum ))
  13004. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  13005. else
  13006. $psum = '<td class="taR colOrange">-</td>';
  13007. $receiptL ['报销金额调整'] = $psum . $html;
  13008. } else {
  13009. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13010. <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>';
  13011. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  13012. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13013. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13014. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13015. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13016. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13017. }
  13018. $monthStaffPrice = $receiptDetail->find ( array (
  13019. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13020. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13021. 'asArray' => true
  13022. ) );
  13023. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  13024. $m1 += $monthStaffPrice [0] ['price'];
  13025. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13026. } else
  13027. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13028. $list [$value ['username']] = $receiptL;
  13029. }
  13030. }
  13031. $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>
  13032. <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>
  13033. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  13034. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  13035. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  13036. $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>
  13037. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  13038. $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>';
  13039. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  13040. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  13041. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  13042. }
  13043. $data ['list'] = $list;
  13044. $receiptCollectList = $receiptDetail->find ( array (
  13045. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13046. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13047. 'groupby' => 'item,Month(date),itemCategory',
  13048. 'asArray' => true
  13049. ) );
  13050. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  13051. // statistics html
  13052. $stList = $statistics->getOne ( array (
  13053. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13054. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13055. 'groupby' => 'Month(date)',
  13056. 'asArray' => true
  13057. ) );
  13058. if (empty ( $stList ))
  13059. $stList = array (
  13060. 'rePrice' => 0,
  13061. 'agPrice' => 0
  13062. );
  13063. $data ['stList'] = array (
  13064. 'rePrice' => $stList ['rePrice'],
  13065. 'agPrice' => $stList ['agPrice'],
  13066. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13067. );
  13068. $monthHtml = "";
  13069. for($i = 1; $i <= 12; $i ++) {
  13070. if ($i == $month)
  13071. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13072. else
  13073. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13074. }
  13075. $data ['monthHtml'] = $monthHtml;
  13076. $data ['year'] = $year;
  13077. $data ['month'] = $month;
  13078. $data ['memu'] = "receipt";
  13079. $data ['staff'] = $this->staff;
  13080. $data ['receiptMemu'] = 'companyCategoryCollect';
  13081. $data ['verifyId'] = $this->verifyId;
  13082. $data ['executeId'] = $this->executeId;
  13083. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  13084. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13085. }
  13086. /**
  13087. * 用户报销单列表
  13088. */
  13089. function receiptStatisticsStaffDetail() {
  13090. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13091. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13092. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13093. Doo::loadModel ( "receipt" );
  13094. $receipt = new receipt ();
  13095. Doo::loadModel ( "receiptDetail" );
  13096. $receiptDetail = new receiptDetail ();
  13097. Doo::loadModel ( 'staff' );
  13098. $staff = new staff ();
  13099. Doo::loadModel ( 'accountItem' );
  13100. $accountItem = new accountItem ();
  13101. Doo::loadModel ( 'statistics' );
  13102. $statistics = new statistics ();
  13103. if (! empty ( $username )) {
  13104. $username = addslashes ( urldecode ( $username ) );
  13105. $staffDetail = $staff->getStaffByName ( $username );
  13106. if (empty ( $staffDetail ))
  13107. die ( 'illegal request' );
  13108. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  13109. $itemList = $accountItem->getAccountItem ();
  13110. $itemHtml = '';
  13111. $categoryHtml = '';
  13112. $itemKeyList = array_keys ( $itemList );
  13113. $revisePrice = 0;
  13114. // 报销单内容详情
  13115. foreach ( $list as $key => $value ) {
  13116. $accountItemList = json_decode ( $value ['accountItem'], true );
  13117. $list [$key] ['accountItemList'] = $accountItemList;
  13118. $receiptItemHtml = '';
  13119. foreach ( $itemKeyList as $v ) {
  13120. if ($v == '日常相关费用')
  13121. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  13122. elseif ($v == '差旅相关费用')
  13123. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  13124. elseif ($v == '培训班费用')
  13125. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  13126. elseif ($v == '内部培训费用'){
  13127. if (isset($accountItemList ['cSum'] ['inttrainSum'])){
  13128. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['inttrainSum'] . '</td>';
  13129. }else{
  13130. $receiptItemHtml .= '<td class="colGreen taR">0</td>';
  13131. }
  13132. }elseif ($v == '其他')
  13133. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  13134. foreach ( $itemList [$v] as $ke => $va ) {
  13135. $falg = true;
  13136. if (! empty ( $accountItemList [$v] )) {
  13137. foreach ( $accountItemList [$v] as $ve ) {
  13138. if ($va ['name'] == $ve ['name']) {
  13139. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  13140. $falg = false;
  13141. break;
  13142. }
  13143. }
  13144. }
  13145. if ($falg)
  13146. $receiptItemHtml .= '<td class="taR"></td>';
  13147. }
  13148. }
  13149. // 金额调整和费用查看
  13150. $revisePrice += $value ['revisePrice'];
  13151. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  13152. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" id="sen'.$key.'" data="' . htmlspecialchars($value ['explanation']) . '" onclick=showExplanation() >查看</a></td>';
  13153. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  13154. }
  13155. // 报销单合计
  13156. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  13157. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  13158. $receiptTotalHtml = '';
  13159. // 报销单项目抬头
  13160. foreach ( $itemKeyList as $value ) {
  13161. $count = count ( $itemList [$value] ) + 1;
  13162. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  13163. $categoryHtml .= '<th class="taC">合计</th>';
  13164. $sumfalg=true;
  13165. foreach ( $rtl as $rtlValue ) {
  13166. if ($rtlValue ['itemCategory'] == $value) {
  13167. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  13168. $sumfalg=false;
  13169. break;
  13170. }
  13171. }
  13172. if ($sumfalg)
  13173. $receiptTotalHtml .= '<th></th>';
  13174. foreach ( $itemList [$value] as $k => $v ) {
  13175. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  13176. // 合计
  13177. $falg = true;
  13178. foreach ( $receiptTotalList as $ve ) {
  13179. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  13180. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  13181. $falg = false;
  13182. break;
  13183. }
  13184. }
  13185. if ($falg)
  13186. $receiptTotalHtml .= '<th></th>';
  13187. }
  13188. }
  13189. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  13190. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  13191. if (empty ( $stList ))
  13192. $stList = array (
  13193. 'rePrice' => 0,
  13194. 'agPrice' => 0
  13195. );
  13196. $data ['stList'] = array (
  13197. 'rePrice' => $stList ['rePrice'],
  13198. 'agPrice' => $stList ['agPrice'],
  13199. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13200. );
  13201. $monthHtml = "";
  13202. for($i = 1; $i <= 12; $i ++) {
  13203. if ($i == $month)
  13204. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13205. else
  13206. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13207. }
  13208. $data ['username'] = urlencode ( $username );
  13209. $data ['usernameEN'] = $username;
  13210. $data ['monthHtml'] = $monthHtml;
  13211. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  13212. $data ['list'] = $list;
  13213. $data ['categoryHtml'] = $categoryHtml;
  13214. $data ['itemHtml'] = $itemHtml;
  13215. $data ['itemList'] = $itemList;
  13216. $data ['year'] = $year;
  13217. $data ['month'] = $month;
  13218. $data ['memu'] = "receipt";
  13219. $data ['staff'] = $this->staff;
  13220. $data ['receiptMemu'] = 'companyCategoryCollect';
  13221. $data ['verifyId'] = $this->verifyId;
  13222. $data ['executeId'] = $this->executeId;
  13223. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  13224. }
  13225. die ( 'illegal request' );
  13226. }
  13227. function companyMonthCollectDetail() {
  13228. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13229. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13230. if (! $year)
  13231. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13232. if (! $month)
  13233. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13234. Doo::loadModel ( 'staff' );
  13235. $staff = new staff ();
  13236. Doo::loadModel ( "receiptDetail" );
  13237. $receiptDetail = new receiptDetail ();
  13238. Doo::loadModel ( 'accountItem' );
  13239. $accountItem = new accountItem ();
  13240. Doo::loadModel ( 'statistics' );
  13241. $statistics = new statistics ();
  13242. Doo::loadModel ( 'L_category' );
  13243. $lCategory = new L_category ();
  13244. $staffList = $staff->find ( array (
  13245. 'where' => 'username!="admin"',
  13246. 'asArray' => true
  13247. ) );
  13248. $categoryList = $lCategory->find ( array (
  13249. 'asArray' => true
  13250. ) );
  13251. $aiList=$accountItem->getAccountItem();
  13252. $list = array ();
  13253. foreach ( $categoryList as $value ) {
  13254. $receiptCollectList = $receiptDetail->find ( array (
  13255. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13256. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13257. 'groupby' => 'item,Month(pastDate),itemCategory',
  13258. 'asArray' => true
  13259. ) );
  13260. if (! empty ( $receiptCollectList )) {
  13261. $receiptL = array (
  13262. '日常相关费用' => array (),
  13263. '差旅相关费用' => array (),
  13264. '内部培训费用' => array (),
  13265. '培训班费用' => array (),
  13266. '其他' => array ()
  13267. );
  13268. $html = "";
  13269. $psum = 0;
  13270. foreach ( $aiList[$this->AGENCY] as $va ) {
  13271. $falg = true;
  13272. foreach ( $receiptCollectList as $v ) {
  13273. if ($v ['itemCategory'] == $this->AGENCY) {
  13274. if ($v ['item'] == $va['name']) {
  13275. $psum += $v ['price'];
  13276. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13277. $falg = false;
  13278. break;
  13279. }
  13280. }
  13281. }
  13282. if ($falg)
  13283. $html .= '<td class="taR">-</td>';
  13284. }
  13285. if (! empty ( $psum ))
  13286. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13287. else
  13288. $psum = '<td class="colGreen taR">-</td>';
  13289. $receiptL [$this->AGENCY] = $psum . $html;
  13290. /* ----------------------------------- */
  13291. $html = "";
  13292. $psum = 0;
  13293. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13294. $falg = true;
  13295. foreach ( $receiptCollectList as $v ) {
  13296. if ($v ['itemCategory'] == $this->TRAVEL) {
  13297. if ($v ['item'] == $va['name']) {
  13298. $psum += $v ['price'];
  13299. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13300. $falg = false;
  13301. break;
  13302. }
  13303. }
  13304. }
  13305. if ($falg)
  13306. $html .= '<td class="taR">-</td>';
  13307. }
  13308. if (! empty ( $psum ))
  13309. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13310. else
  13311. $psum = '<td class="colGreen taR">-</td>';
  13312. $receiptL [$this->TRAVEL] = $psum . $html;
  13313. /* ------------------------------------- */
  13314. $html = "";
  13315. $psum = 0;
  13316. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13317. $falg = true;
  13318. foreach ( $receiptCollectList as $v ) {
  13319. if ($v ['itemCategory'] == $this->INTTRAIN) {
  13320. if ($v ['item'] == $va['name']) {
  13321. $psum += $v ['price'];
  13322. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13323. $falg = false;
  13324. break;
  13325. }
  13326. }
  13327. }
  13328. if ($falg)
  13329. $html .= '<td class="taR">-</td>';
  13330. }
  13331. if (! empty ( $psum ))
  13332. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13333. else
  13334. $psum = '<td class="colGreen taR">-</td>';
  13335. $receiptL [$this->INTTRAIN] = $psum . $html;
  13336. /* ------------------------------------- */
  13337. $html = "";
  13338. $psum = 0;
  13339. foreach ( $aiList[$this->TRAIN] as $va ) {
  13340. $falg = true;
  13341. foreach ( $receiptCollectList as $v ) {
  13342. if ($v ['itemCategory'] == $this->TRAIN) {
  13343. if ($v ['item'] == $va['name']) {
  13344. $psum += $v ['price'];
  13345. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13346. $falg = false;
  13347. break;
  13348. }
  13349. }
  13350. }
  13351. if ($falg)
  13352. $html .= '<td class="taR">-</td>';
  13353. }
  13354. if (! empty ( $psum ))
  13355. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13356. else
  13357. $psum = '<td class="colGreen taR">-</td>';
  13358. $receiptL [$this->TRAIN] = $psum . $html;
  13359. /* ------------------------------------- */
  13360. $html = "";
  13361. $psum = 0;
  13362. foreach ( $aiList[$this->OTHER] as $va ) {
  13363. $falg = true;
  13364. foreach ( $receiptCollectList as $v ) {
  13365. if ($v ['itemCategory'] == $this->OTHER) {
  13366. if ($v ['item'] == $va['name']) {
  13367. $psum += $v ['price'];
  13368. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13369. $falg = false;
  13370. break;
  13371. }
  13372. }
  13373. }
  13374. if ($falg)
  13375. $html .= '<td class="taR">-</td>';
  13376. }
  13377. if (! empty ( $psum ))
  13378. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13379. else
  13380. $psum = '<td class="colGreen taR">-</td>';
  13381. $receiptL [$this->OTHER] = $psum . $html;
  13382. /* ------------------------------------- */
  13383. $html = "";
  13384. $psum = 0;
  13385. foreach ( $receiptCollectList as $v ) {
  13386. if ($v ['itemCategory'] == '报销金额调整') {
  13387. if (! empty ( $v ['price'] ))
  13388. $psum += $v ['price'];
  13389. }
  13390. }
  13391. if (! empty ( $psum ))
  13392. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  13393. else
  13394. $psum = '<td class="taR colOrange">-</td>';
  13395. $receiptL ['报销金额调整'] = $psum . $html;
  13396. } else {
  13397. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  13398. foreach ( $aiList[$this->AGENCY] as $va ) {
  13399. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  13400. }
  13401. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  13402. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13403. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  13404. }
  13405. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  13406. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13407. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  13408. }
  13409. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  13410. foreach ( $aiList[$this->TRAIN] as $va ) {
  13411. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  13412. }
  13413. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  13414. foreach ( $aiList[$this->OTHER] as $va ) {
  13415. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  13416. }
  13417. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13418. }
  13419. $monthStaffPrice = $receiptDetail->find ( array (
  13420. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13421. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13422. 'asArray' => true
  13423. ) );
  13424. if (! empty ( $monthStaffPrice [0] ['price'] ))
  13425. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13426. else
  13427. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13428. $list [$value ['title']] = $receiptL;
  13429. }
  13430. $data ['list'] = $list;
  13431. $receiptCollectList = $receiptDetail->find ( array (
  13432. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13433. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13434. 'groupby' => 'item,Month(pastDate),itemCategory',
  13435. 'asArray' => true
  13436. ) );
  13437. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  13438. //print_r($data['monthPriceHtml']);
  13439. // foreach ($data['monthPriceHtml'] as $value){
  13440. // echo $value;
  13441. // }
  13442. // die;
  13443. // statistics html
  13444. $stList = $statistics->getOne ( array (
  13445. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13446. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13447. 'groupby' => 'Month(date)',
  13448. 'asArray' => true
  13449. ) );
  13450. if (empty ( $stList ))
  13451. $stList = array (
  13452. 'rePrice' => 0,
  13453. 'agPrice' => 0
  13454. );
  13455. $data ['stList'] = array (
  13456. 'rePrice' => $stList ['rePrice'],
  13457. 'agPrice' => $stList ['agPrice'],
  13458. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13459. );
  13460. $monthHtml = "";
  13461. for($i = 1; $i <= 12; $i ++) {
  13462. if ($i == $month)
  13463. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13464. else
  13465. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13466. }
  13467. $data ['aiList'] = $aiList;
  13468. $dateHtml = "";
  13469. $now = date ( "Y" );
  13470. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  13471. if ($YEARD <= $now) {
  13472. $dateHtml .= '<option ';
  13473. if ($year == $YEARD) {
  13474. $dateHtml .= 'selected ';
  13475. }
  13476. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  13477. }
  13478. }
  13479. $data ['dateHtml'] = $dateHtml;
  13480. $data ['monthHtml'] = $monthHtml;
  13481. $data ['year'] = $year;
  13482. $data ['month'] = $month;
  13483. $data ['memu'] = "receipt";
  13484. $data ['staff'] = $this->staff;
  13485. $data ['receiptMemu'] = 'companyCategoryCollect';
  13486. $data ['verifyId'] = $this->verifyId;
  13487. $data ['executeId'] = $this->executeId;
  13488. $this->render ( "/admin/companyMonthCollectDetail", $data );
  13489. }
  13490. function staffCollectDetail() {
  13491. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  13492. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13493. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  13494. if (! $staffname) {
  13495. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  13496. $staffname = urldecode ( $staffname );
  13497. }
  13498. Doo::loadModel ( 'staff' );
  13499. $staff = new staff ();
  13500. Doo::loadModel ( "receiptDetail" );
  13501. $receiptDetail = new receiptDetail ();
  13502. Doo::loadModel ( 'accountItem' );
  13503. $accountItem = new accountItem ();
  13504. Doo::loadModel ( 'statistics' );
  13505. $statistics = new statistics ();
  13506. Doo::loadModel ( 'L_category' );
  13507. $lCategory = new L_category ();
  13508. Doo::loadModel ( "receiptAuthorityManage" );
  13509. $receiptAuthorityManage = new receiptAuthorityManage ();
  13510. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  13511. $cidList = array ();
  13512. foreach ( $imcStaff as $key => $value ) {
  13513. array_push ( $cidList, $value ['cid'] );
  13514. }
  13515. $cidString = implode ( ',', $cidList );
  13516. $staffList = $staff->find ( array (
  13517. 'where' => ' cid in (' . $cidString . ')',
  13518. 'asArray' => true
  13519. ) );
  13520. $stHtml = '';
  13521. $stTitle = "";
  13522. $staffId = 0;
  13523. $cid = 0;
  13524. $ocid = 0;
  13525. foreach ( $staffList as $value ) {
  13526. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  13527. $stTitle = $value ['category'] . '-' . $value ['username'];
  13528. $staffId = $value ['sid'];
  13529. $cid = $value ['cid'];
  13530. $ocid = $value ['cid'];
  13531. if (! empty ( $value ['othercid'] ))
  13532. $cid = $value ['cid'] . ',' . $value ['othercid'];
  13533. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13534. } elseif ($value ['username'] != 'admin')
  13535. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13536. }
  13537. $data ['lCategoryHtml'] = $lCategory->find ( array (
  13538. 'where' => 'cid in(' . $cid . ')',
  13539. 'asArray' => true
  13540. ) );
  13541. if (empty ( $pcid ))
  13542. $pcid = $ocid;
  13543. $data ['ocid'] = $pcid;
  13544. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  13545. $this->showCache ( $path );
  13546. //
  13547. $receiptCollectList = $receiptDetail->find ( array (
  13548. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13549. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  13550. 'groupby' => 'item,Month(pastDate),itemCategory',
  13551. 'asArray' => true
  13552. ) );
  13553. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  13554. // print_r($receiptCollectList);
  13555. $accountList = $accountItem->find ( array (
  13556. 'asArray' => true
  13557. ) );
  13558. // create CollectDetail HTML
  13559. $collectHtml = array ();
  13560. foreach ( $accountList as $key => $value ) {
  13561. $html = "";
  13562. $asum = 0;
  13563. for($i = 1; $i <= 12; $i ++) {
  13564. $falg = true;
  13565. foreach ( $receiptCollectList as $v ) {
  13566. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  13567. if ($v ['item'] == '可自加费用') {
  13568. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  13569. }
  13570. $asum += $v ['price'];
  13571. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13572. $falg = false;
  13573. break;
  13574. }
  13575. }
  13576. if ($falg)
  13577. $html .= '<td class="taR">-</td>';
  13578. }
  13579. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  13580. $collectHtml [$value ['category']] [$value ['name']] = $html;
  13581. }
  13582. $data ['collectHtml'] = $collectHtml;
  13583. // print_r($collectHtml);
  13584. // create Adjustment price html
  13585. $receiptCollectList = $receiptDetail->find ( array (
  13586. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  13587. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  13588. 'groupby' => 'itemCategory,Month(pastDate)',
  13589. 'asArray' => true
  13590. ) );
  13591. $adjustment = array ();
  13592. $collectArray = array (
  13593. '日常相关费用' => array (),
  13594. '差旅相关费用' => array (),
  13595. '培训班费用' => array (),
  13596. '内部培训费用'=>array(),
  13597. '其他' => array ()
  13598. );
  13599. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  13600. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  13601. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  13602. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  13603. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  13604. array_push ( $collectArray ['培训班费用'], $collectHtml );
  13605. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  13606. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  13607. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  13608. array_push ( $collectArray ['其他'], $collectHtml );
  13609. $data ['collectArray'] = $collectArray;
  13610. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  13611. array_push ( $adjustment, $collectHtml );
  13612. $data ['adjustment'] = $adjustment;
  13613. // total price html
  13614. $collectHtml = "";
  13615. $total = 0;
  13616. for($i = 1; $i <= 12; $i ++) {
  13617. $sumPrice = 0;
  13618. foreach ( $receiptCollectList as $key => $value ) {
  13619. if ($value ['month'] == $i) {
  13620. $sumPrice += $value ['price'];
  13621. }
  13622. }
  13623. if ($sumPrice == 0)
  13624. $collectHtml .= '<td class="taR">-</td>';
  13625. else
  13626. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  13627. $total += $sumPrice;
  13628. }
  13629. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  13630. // statistics html
  13631. $stList = $statistics->statisticsByYear ( $year, $staffId );
  13632. if (empty ( $stList ))
  13633. $stList = array (
  13634. 'rePrice' => 0,
  13635. 'agPrice' => 0
  13636. );
  13637. $data ['stList'] = array (
  13638. 'rePrice' => $stList ['rePrice'],
  13639. 'agPrice' => $stList ['agPrice'],
  13640. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13641. );
  13642. $data ['totalPrice'] = $collectHtml;
  13643. $data ['totalYear'] = $total;
  13644. $data ['stHtml'] = $stHtml;
  13645. $data ['year'] = $year;
  13646. $data ['stTitle'] = $stTitle;
  13647. $data ['staffname'] = urlencode ( $staffname );
  13648. $data ['memu'] = "receipt";
  13649. $data ['staff'] = $this->staff;
  13650. $data ['receiptMemu'] = 'companyCategoryCollect';
  13651. $data ['verifyId'] = $this->verifyId;
  13652. $data ['executeId'] = $this->executeId;
  13653. if ($year < date ( "Y" )) {
  13654. Doo::loadModel ( 'receipt' );
  13655. $receipt = new receipt ();
  13656. $receiptList = $receipt->find ( array (
  13657. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  13658. 'asArray' => true
  13659. ) );
  13660. if (empty ( $receiptList )) { // generated files
  13661. ob_start ();
  13662. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13663. $this->cacheFile ( $path );
  13664. die ();
  13665. }
  13666. }
  13667. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13668. }
  13669. function BUGFLAG() {
  13670. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  13671. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  13672. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13673. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  13674. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  13675. if (empty ( $status ))
  13676. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  13677. $page_size = 12;
  13678. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  13679. $vidList = array ();
  13680. $button = 0;
  13681. Doo::loadModel ( 'verify' );
  13682. $verify = new verify ();
  13683. Doo::loadModel ( 'receipt' );
  13684. $receipt = new receipt ();
  13685. Doo::loadModel ( 'staff' );
  13686. $staff = new staff ();
  13687. Doo::loadModel ( 'L_category' );
  13688. $Lcategory = new L_category ();
  13689. $dateCondition = " and Year(date) =" . $year;
  13690. if (! empty ( $month ))
  13691. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  13692. $categoryList = $Lcategory->find ( array (
  13693. 'asArray' => true
  13694. ) );
  13695. $staffList = $staff->find ( array (
  13696. 'where' => 'cid=' . $cid,
  13697. 'asArray' => true
  13698. ) );
  13699. $cateCondition = "";
  13700. $staffCondition = "";
  13701. $approvalCondition = "";
  13702. if (! empty ( $cid ))
  13703. $cateCondition = ' and cid=' . $cid;
  13704. if (! empty ( $sid )) {
  13705. $staffCondition = ' and staff=' . $sid;
  13706. $cateCondition = "";
  13707. }
  13708. $approvalCondition = " and status=" . $status;
  13709. if ($status == 2) {
  13710. // 查找角色审批人
  13711. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  13712. }
  13713. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  13714. $approvalCondition = ' and status=2 ';
  13715. }
  13716. if ($status == 1) {
  13717. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  13718. }
  13719. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  13720. $pageinfo ['page'] = array (
  13721. 'previous' => ''
  13722. );
  13723. if ($status == 0) {
  13724. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  13725. $receiptList = $receipt->find ( array (
  13726. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  13727. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  13728. 'desc' => 'rid',
  13729. 'asArray' => true
  13730. ) );
  13731. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  13732. } else
  13733. $receiptList = $receipt->find ( array (
  13734. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  13735. 'desc' => 'rid',
  13736. 'asArray' => true
  13737. ) );
  13738. $rLRes = $receipt->find ( array (
  13739. '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,
  13740. 'desc' => 'rid',
  13741. 'asArray' => true
  13742. ) );
  13743. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  13744. // print_r($pageinfo);
  13745. $Locate = 0;
  13746. foreach ( $receiptList as $key => $value ) {
  13747. $receiptList [$key] ['Locate'] = $Locate;
  13748. $Locate ++;
  13749. $receiptList [$key] ['reviseDetail'] = array ();
  13750. if (! empty ( $value ['reviseDetail'] ))
  13751. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  13752. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  13753. $categoryDetil = $Lcategory->getOne ( array (
  13754. 'where' => 'cid=' . $value ['cid'],
  13755. 'asArray' => true
  13756. ) );
  13757. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  13758. $verifyList = $verify->getOne ( array (
  13759. 'where' => 'vid=' . $value ['verify'],
  13760. 'asArray' => true
  13761. ) );
  13762. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  13763. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  13764. foreach ( $verifyList as $k => $v ) {
  13765. // init verifyStaff
  13766. $verifyList [$k] ['date'] = "";
  13767. $verifyList [$k] ['opinion'] = "";
  13768. $verifyList [$k] ['status'] = "";
  13769. if (empty ( $verifyStaff )) {
  13770. $verifyList [$k] ['date'] = "";
  13771. $verifyList [$k] ['opinion'] = "";
  13772. if ($v [0] == $this->staff [0] ['sid']) {
  13773. $verifyList [$k] ['status'] = 4;
  13774. $button = 4;
  13775. }
  13776. } else {
  13777. $flag = true;
  13778. foreach ( $verifyStaff as $m => $u ) {
  13779. if ($v [0] == $m) {
  13780. $verifyList [$k] ['date'] = $u ['date'];
  13781. $verifyList [$k] ['opinion'] = $u ['opinion'];
  13782. $verifyList [$k] ['status'] = $u ['status'];
  13783. $flag = false;
  13784. break;
  13785. }
  13786. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  13787. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  13788. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  13789. }
  13790. if ($flag) { // 检测可编辑
  13791. if ($v [0] == $this->staff [0] ['sid']) {
  13792. $verifyList [$k] ['status'] = 4;
  13793. $button = 4;
  13794. }
  13795. }
  13796. }
  13797. }
  13798. $receiptList [$key] ['verifyList'] = $verifyList;
  13799. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  13800. 'where' => 'sid=' . $value ['staff'],
  13801. 'asArray' => true
  13802. ) );
  13803. $receiptList [$key] ['button'] = $button;
  13804. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  13805. }
  13806. // print_r($receiptList);die;
  13807. // $data['verifyDetail']=$verifyDetail;
  13808. $mothHtml = "";
  13809. for($i = 1; $i <= 12; $i ++) {
  13810. if ($month == $i)
  13811. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  13812. else
  13813. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  13814. }
  13815. $data ['mothHtml'] = $mothHtml;
  13816. $data ['page'] = $pageinfo;
  13817. $data ['receiptList'] = $receiptList;
  13818. $data ['receiptApprovalCount'] = count ( $rLRes );
  13819. $data ['status'] = $status;
  13820. $data ['year'] = $year;
  13821. $data ['categoryList'] = $categoryList;
  13822. $data ['staffList'] = $staffList;
  13823. $data ['cid'] = $cid;
  13824. $data ['sid'] = $sid;
  13825. // print_r($receiptList);
  13826. $data ['memu'] = "receipt";
  13827. $data ['staff'] = $this->staff;
  13828. $data ['receiptMemu'] = 'approvalExpenses';
  13829. $data ['verifyId'] = $this->verifyId;
  13830. $data ['executeId'] = $this->executeId;
  13831. $this->render ( "/admin/FALG", $data );
  13832. }
  13833. function ajaxGetReceiptOrder() {
  13834. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  13835. if (! empty ( $receiptOrder )) {
  13836. Doo::loadModel ( 'receipt' );
  13837. $receipt = new receipt ();
  13838. Doo::loadModel ( 'staff' );
  13839. $staff = new staff ();
  13840. $receiptInfo = $receipt->getOne ( array (
  13841. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  13842. 'asArray' => true
  13843. ) );
  13844. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  13845. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  13846. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  13847. </tbody></table><table class="table table table-bordered"><tbody>';
  13848. foreach ( $verifyStaff as $key => $value ) {
  13849. $staffInfo = $staff->getOne ( array (
  13850. 'select' => 'username',
  13851. 'where' => ' sid="' . $key . '"',
  13852. 'asArray' => true
  13853. ) );
  13854. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  13855. }
  13856. $html .= '</tbody></table></div></div>';
  13857. echo json_encode ( array (
  13858. 'status' => 1,
  13859. 'receiptHtml' => $html
  13860. ) );
  13861. die ();
  13862. }
  13863. echo json_encode ( array (
  13864. 'status' => 2,
  13865. 'receiptHtml' => ''
  13866. ) );
  13867. die ();
  13868. }
  13869. function _getMonthCollectDetail($receiptCollectList,$aiList) {
  13870. if (! empty ( $receiptCollectList )) {
  13871. $receiptL = array (
  13872. '日常相关费用' => array (),
  13873. '差旅相关费用' => array (),
  13874. '内部培训费用'=>array(),
  13875. '培训班费用' => array (),
  13876. '其他' => array ()
  13877. );
  13878. $html = "";
  13879. $psum = 0;
  13880. foreach ( $aiList[$this->AGENCY] as $value ) {
  13881. $falg = true;
  13882. foreach ( $receiptCollectList as $v ) {
  13883. if ($v ['itemCategory'] == '日常相关费用') {
  13884. if ($v ['item'] == $value['name']) {
  13885. $psum += $v ['price'];
  13886. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13887. $falg = false;
  13888. break;
  13889. }
  13890. }
  13891. }
  13892. if ($falg)
  13893. $html .= '<td class="taR">-</td>';
  13894. }
  13895. if (! empty ( $psum ))
  13896. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13897. else
  13898. $psum = '<td class="colGreen taR">-</td>';
  13899. $receiptL ['日常相关费用'] = $psum . $html;
  13900. /* ----------------------------------- */
  13901. $html = "";
  13902. $psum = 0;
  13903. foreach ( $aiList[$this->TRAVEL] as $value ) {
  13904. $falg = true;
  13905. foreach ( $receiptCollectList as $v ) {
  13906. if ($v ['itemCategory'] == '差旅相关费用') {
  13907. if ($v ['item'] == $value['name']) {
  13908. $psum += $v ['price'];
  13909. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13910. $falg = false;
  13911. break;
  13912. }
  13913. }
  13914. }
  13915. if ($falg)
  13916. $html .= '<td class="taR">-</td>';
  13917. }
  13918. if (! empty ( $psum ))
  13919. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13920. else
  13921. $psum = '<td class="colGreen taR">-</td>';
  13922. $receiptL ['差旅相关费用'] = $psum . $html;
  13923. /* ----------------------------------- */
  13924. $html = "";
  13925. $psum = 0;
  13926. foreach ( $aiList[$this->INTTRAIN] as $value ) {
  13927. $falg = true;
  13928. foreach ( $receiptCollectList as $v ) {
  13929. if ($v ['itemCategory'] == '内部培训费用') {
  13930. if ($v ['item'] == $value['name']) {
  13931. $psum += $v ['price'];
  13932. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13933. $falg = false;
  13934. break;
  13935. }
  13936. }
  13937. }
  13938. if ($falg)
  13939. $html .= '<td class="taR">-</td>';
  13940. }
  13941. if (! empty ( $psum ))
  13942. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13943. else
  13944. $psum = '<td class="colGreen taR">-</td>';
  13945. $receiptL ['内部培训费用'] = $psum . $html;
  13946. /* ------------------------------------- */
  13947. $html = "";
  13948. $psum = 0;
  13949. foreach ( $aiList[$this->TRAIN] as $value ) {
  13950. $falg = true;
  13951. foreach ( $receiptCollectList as $v ) {
  13952. if ($v ['itemCategory'] == '培训班费用') {
  13953. if ($v ['item'] == $value['name']) {
  13954. $psum += $v ['price'];
  13955. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13956. $falg = false;
  13957. break;
  13958. }
  13959. }
  13960. }
  13961. if ($falg)
  13962. $html .= '<td class="taR">-</td>';
  13963. }
  13964. if (! empty ( $psum ))
  13965. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13966. else
  13967. $psum = '<td class="colGreen taR">-</td>';
  13968. $receiptL ['培训班费用'] = $psum . $html;
  13969. /* ------------------------------------- */
  13970. $html = "";
  13971. $psum = 0;
  13972. foreach ( $aiList[$this->OTHER] as $value ) {
  13973. $falg = true;
  13974. foreach ( $receiptCollectList as $v ) {
  13975. if ($v ['itemCategory'] == '其他') {
  13976. if ($v ['item'] == $value['name']) {
  13977. $psum += $v ['price'];
  13978. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13979. $falg = false;
  13980. break;
  13981. }
  13982. }
  13983. }
  13984. if ($falg)
  13985. $html .= '<td class="taR">-</td>';
  13986. }
  13987. if (! empty ( $psum ))
  13988. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13989. else
  13990. $psum = '<td class="colGreen taR">-</td>';
  13991. $receiptL ['其他'] = $psum . $html;
  13992. /* ------------------------------------- */
  13993. $html = "";
  13994. $psum = 0;
  13995. foreach ( $receiptCollectList as $v ) {
  13996. if ($v ['itemCategory'] == '报销金额调整') {
  13997. if (! empty ( $v ['price'] ))
  13998. $psum += $v ['price'];
  13999. }
  14000. }
  14001. if (! empty ( $psum ))
  14002. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  14003. else
  14004. $psum = '<td class="taR colOrange">-</td>';
  14005. $receiptL ['报销金额调整'] = $psum . $html;
  14006. } else {
  14007. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  14008. foreach ( $aiList[$this->AGENCY] as $va ) {
  14009. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  14010. }
  14011. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  14012. foreach ( $aiList[$this->TRAVEL] as $va ) {
  14013. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  14014. }
  14015. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  14016. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  14017. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  14018. }
  14019. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  14020. foreach ( $aiList[$this->TRAIN] as $va ) {
  14021. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  14022. }
  14023. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  14024. foreach ( $aiList[$this->OTHER] as $va ) {
  14025. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  14026. }
  14027. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  14028. }
  14029. return $receiptL;
  14030. }
  14031. function eMail() {
  14032. Doo::loadModel ( 'staff' );
  14033. $staff = new staff ();
  14034. Doo::loadModel ( 'receipt' );
  14035. $receipt = new receipt ();
  14036. Doo::loadModel ( 'L_category' );
  14037. $Lcategory = new L_category ();
  14038. Doo::loadModel ( "verify" );
  14039. $verify = new verify ();
  14040. $staffList = $staff->find ( array (
  14041. 'asArray' => true
  14042. ) );
  14043. foreach ( $staffList as $key => $value ) {
  14044. if ($value ['username'] != 'admin') {
  14045. // 提交人
  14046. $receiptList = $receipt->find ( array (
  14047. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  14048. 'asArray' => true
  14049. ) );
  14050. if (! empty ( $receiptList )) {
  14051. $html = '<br><div><style></style>
  14052. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  14053. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  14054. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14055. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  14056. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14057. <tbody><tr>
  14058. <td style="padding: 0 40px;" align="left">
  14059. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14060. </td></tr><tr>
  14061. <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>
  14062. </tr>
  14063. </tbody> </table></td> </tr> <tr><td>
  14064. <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">
  14065. <tbody> <tr><td>
  14066. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  14067. 以下报销单完成了审批,等着收款吧:</p>
  14068. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  14069. foreach ( $receiptList as $k => $v ) {
  14070. $category = $Lcategory->getOne ( array (
  14071. 'where' => 'cid=' . $v ['cid'],
  14072. 'asArray' => true
  14073. ) );
  14074. $html .= '
  14075. <tr>
  14076. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14077. <td align="left">
  14078. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  14079. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  14080. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  14081. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  14082. </tr>';
  14083. }
  14084. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  14085. <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>
  14086. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  14087. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  14088. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  14089. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14090. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14091. $receipt = new receipt ();
  14092. $receipt->notice = 1;
  14093. $receipt->update ( array (
  14094. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  14095. ) );
  14096. }
  14097. }
  14098. // 审批人
  14099. $verifyList = $verify->find ( array (
  14100. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  14101. 'asArray' => true
  14102. ) );
  14103. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  14104. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  14105. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14106. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  14107. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14108. <tbody><tr><td style="padding: 0 40px;" align="left">
  14109. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14110. </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>
  14111. </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">
  14112. <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>
  14113. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  14114. foreach ( $verifyList as $k => $v ) {
  14115. $receiptList = $receipt->find ( array (
  14116. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  14117. 'asArray' => true
  14118. ) );
  14119. foreach ( $receiptList as $r => $l ) {
  14120. $category = $Lcategory->getOne ( array (
  14121. 'where' => 'cid=' . $l ['cid'],
  14122. 'asArray' => true
  14123. ) );
  14124. $staffDetile = $staff->getOne ( array (
  14125. 'where' => 'sid=' . $l ['staff'],
  14126. 'asArray' => true
  14127. ) );
  14128. $html .= '
  14129. <tr>
  14130. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14131. <td align="left">
  14132. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  14133. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  14134. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  14135. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  14136. </tr>';
  14137. }
  14138. }
  14139. $html .= '
  14140. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  14141. <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>
  14142. </tr></tbody></table></td></tr></tbody></table></div><br>';
  14143. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  14144. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  14145. // $receipt=new receipt();
  14146. // $receipt->notice=1;
  14147. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  14148. }
  14149. }
  14150. }
  14151. }
  14152. function setWXMsg($rid, $type) {
  14153. Doo::loadModel ( "receipt" );
  14154. $receipt = new receipt ();
  14155. $receiptDetail = $receipt->getOne ( array (
  14156. 'where' => 'rid=' . $rid,
  14157. 'asArray' => true
  14158. ) );
  14159. if (! empty ( $receiptDetail )) {
  14160. Doo::loadModel ( 'staff' );
  14161. $staff = new staff ();
  14162. $staffmsg = $staff->getOne ( array (
  14163. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  14164. 'asArray' => TRUE
  14165. ) );
  14166. if (! empty ( $staffmsg ['wxid'] )) {
  14167. require_once (SITE_PATH . '/protected/class/client.php');
  14168. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  14169. $user = $staffmsg ['wxid'];
  14170. $receiptName = '';
  14171. $msg = '';
  14172. switch ($receiptDetail ['Rtype']) {
  14173. case 0 :
  14174. $receiptName = '报销';
  14175. break;
  14176. case 1 :
  14177. $receiptName = '借款';
  14178. break;
  14179. case 2 :
  14180. $receiptName = '对公汇款';
  14181. break;
  14182. }
  14183. switch ($type) {
  14184. case 1 :
  14185. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  14186. break;
  14187. case 2 :
  14188. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  14189. break;
  14190. case 3 :
  14191. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  14192. break;
  14193. }
  14194. // $result = $client->SendMsg ( $user, $msg, 'text' );
  14195. }
  14196. }
  14197. }
  14198. // Email发送函数
  14199. function SMail($toemail, $subject, $contents) {
  14200. Doo::loadClass ( 'class.phpmailer' );
  14201. $mail = new PHPMailer ();
  14202. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  14203. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  14204. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  14205. $mail->Password = "cDO1GjtY1seH"; // 密码
  14206. $mail->CharSet = "UTF8";
  14207. $mail->SMTPAuth = true;
  14208. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  14209. $mail->Mailer = "smtp";
  14210. $mail->Port = 25;
  14211. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  14212. $mail->MsgHTML ( $contents );
  14213. $mail->AddAddress ( $toemail );
  14214. $mail->CharSet = "UTF-8";
  14215. return $mail->Send ();
  14216. }
  14217. function h5Upload() {
  14218. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14219. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14220. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14221. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14222. header ( "HTTP/1.1 500 Internal Server Error" );
  14223. echo "POST exceeded maximum allowed size.";
  14224. exit ( 0 );
  14225. }
  14226. // Settings
  14227. $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)
  14228. $upload_name = "Filedata";
  14229. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14230. $extension_whitelist = array (
  14231. "doc",
  14232. "txt",
  14233. "jpg",
  14234. "gif",
  14235. "png"
  14236. ); // Allowed file extensions
  14237. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14238. // Other variables
  14239. $MAX_FILENAME_LENGTH = 260;
  14240. $file_name = "";
  14241. $file_extension = "";
  14242. $uploadErrors = array (
  14243. 0 => "文件上传成功",
  14244. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14245. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14246. 3 => "上传的文件仅为部分文件",
  14247. 4 => "没有文件上传",
  14248. 6 => "缺少临时文件夹"
  14249. );
  14250. $nk = time ();
  14251. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14252. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14253. echo "文件无法保存.";
  14254. exit ( 0 );
  14255. }
  14256. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14257. echo json_encode ( array (
  14258. 'filename' => $file_name,
  14259. 'id' => $nk
  14260. ) );
  14261. exit ( 0 );
  14262. }
  14263. function swfupload() {
  14264. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14265. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14266. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14267. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14268. header ( "HTTP/1.1 500 Internal Server Error" );
  14269. echo "POST exceeded maximum allowed size.";
  14270. exit ( 0 );
  14271. }
  14272. // Settings
  14273. $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)
  14274. $upload_name = "Filedata";
  14275. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14276. $extension_whitelist = array (
  14277. "doc",
  14278. "txt",
  14279. "jpg",
  14280. "gif",
  14281. "png"
  14282. ); // Allowed file extensions
  14283. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14284. // Other variables
  14285. $MAX_FILENAME_LENGTH = 260;
  14286. $file_name = "";
  14287. $file_extension = "";
  14288. $uploadErrors = array (
  14289. 0 => "文件上传成功",
  14290. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14291. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14292. 3 => "上传的文件仅为部分文件",
  14293. 4 => "没有文件上传",
  14294. 6 => "缺少临时文件夹"
  14295. );
  14296. $nk = time ();
  14297. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14298. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14299. echo "文件无法保存.";
  14300. exit ( 0 );
  14301. }
  14302. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14303. echo json_encode ( array (
  14304. 'filename' => $file_name,
  14305. 'id' => $nk
  14306. ) );
  14307. exit ( 0 );
  14308. }
  14309. function _GetFileEXT($filename) {
  14310. $pics = explode ( '.', $filename );
  14311. $num = count ( $pics );
  14312. return $pics [$num - 1];
  14313. }
  14314. /**
  14315. * 获取get或者POST值
  14316. * @param string $name 属性名称
  14317. * @return fixed 值
  14318. */
  14319. function get_args($name) {
  14320. if (isset ( $_GET [$name] )) {
  14321. if (is_array ( $_GET [$name] ))
  14322. return $_GET [$name];
  14323. else
  14324. return addslashes ( $_GET [$name] );
  14325. } elseif (isset ( $_POST [$name] )) {
  14326. if (is_array ( $_POST [$name] ))
  14327. return $_POST [$name];
  14328. else
  14329. return addslashes ( $_POST [$name] );
  14330. } else
  14331. return false;
  14332. }
  14333. function num_to_rmb($num) {
  14334. $c1 = "零壹贰叁肆伍陆柒捌玖";
  14335. $c2 = "分角元拾佰仟万拾佰仟亿";
  14336. // 精确到分后面就不要了,所以只留两个小数位
  14337. $num = round ( $num, 2 );
  14338. // 将数字转化为整数
  14339. $num = $num * 100;
  14340. if (strlen ( $num ) > 10) {
  14341. return "金额太大,请检查";
  14342. }
  14343. $i = 0;
  14344. $c = "";
  14345. while ( 1 ) {
  14346. if ($i == 0) {
  14347. // 获取最后一位数字
  14348. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  14349. } else {
  14350. $n = $num % 10;
  14351. }
  14352. // 每次将最后一位数字转化为中文
  14353. $p1 = substr ( $c1, 3 * $n, 3 );
  14354. $p2 = substr ( $c2, 3 * $i, 3 );
  14355. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  14356. $c = $p1 . $p2 . $c;
  14357. } else {
  14358. $c = $p1 . $c;
  14359. }
  14360. $i = $i + 1;
  14361. // 去掉数字最后一位了
  14362. $num = $num / 10;
  14363. // echo $num.'</br>';
  14364. $num = ( int ) $num;
  14365. // $num =floor($num);
  14366. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  14367. // echo $num.'</br>';
  14368. // 结束循环
  14369. if ($num == 0) {
  14370. break;
  14371. }
  14372. }
  14373. // echo $c.'</br>';
  14374. $j = 0;
  14375. $slen = strlen ( $c );
  14376. while ( $j < $slen ) {
  14377. // utf8一个汉字相当3个字符
  14378. $m = substr ( $c, $j, 6 );
  14379. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  14380. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  14381. $left = substr ( $c, 0, $j );
  14382. $right = substr ( $c, $j + 3 );
  14383. $c = $left . $right;
  14384. $j = $j - 3;
  14385. $slen = $slen - 3;
  14386. }
  14387. $j = $j + 3;
  14388. }
  14389. // 这个是为了去掉类似23.0中最后一个“零”字
  14390. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  14391. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  14392. }
  14393. // 将处理的汉字加上“整”
  14394. if (empty ( $c )) {
  14395. return "零元整";
  14396. } else {
  14397. return $c . "整";
  14398. }
  14399. }
  14400. /**
  14401. * 获得分页数据
  14402. * @param unknown_type $table
  14403. * @param unknown_type $condition
  14404. * @param unknown_type $on_page
  14405. * @param unknown_type $page_size
  14406. */
  14407. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  14408. $page_c = "";
  14409. $page ['previous'] = $this->get_previous ( $on_page );
  14410. $page ['on_page'] = $on_page;
  14411. $total_count = $this->get_table_count ( $table, $condition );
  14412. $total = intval ( $total_count / $page_size );
  14413. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  14414. $page ['total_data'] = $total_count;
  14415. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  14416. $i = 1;
  14417. $page_max = 1;
  14418. $page_width = 3;
  14419. if ($on_page >= $page_width) {
  14420. $page_max = intval ( $on_page / $page_width ) + 1;
  14421. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  14422. }
  14423. for(; $i <= $page ['total_page']; $i ++) {
  14424. if ($i == $on_page)
  14425. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  14426. else
  14427. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  14428. if ($i == ($page_width * $page_max))
  14429. break;
  14430. }
  14431. $page ['page'] = $page_c;
  14432. $page ['lower'] = (-- $on_page) * $page_size;
  14433. return $page;
  14434. }
  14435. /**
  14436. * 获取总页数
  14437. * @param unknown_type $table
  14438. * @param unknown_type $condition
  14439. */
  14440. public function get_table_count($table = "", $condition = "") {
  14441. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14442. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14443. // echo $sql;die;
  14444. $query = Doo::db ()->query ( $sql );
  14445. $result = $query->fetch ();
  14446. return $result ['count'];
  14447. }
  14448. /**
  14449. * 获取上一页
  14450. * @param unknown_type $on_page
  14451. */
  14452. function get_previous($on_page = 1) {
  14453. return $on_page != 0 ? $on_page - 1 : $on_page;
  14454. }
  14455. function _getReceiptTrainPayment($invoiceTrainId,$trainLoanRid,$rid){
  14456. // 收入合计
  14457. Doo::loadModel ( 'invoiceTraining' );
  14458. $invoiceTraining = new invoiceTraining ();
  14459. Doo::loadModel ( 'receipt' );
  14460. $receipt = new receipt ();
  14461. $invoiceTrainingDetail = array (
  14462. 'invoiceArriveAmount' => '0.00',
  14463. 'RIAmount' => '0.00',
  14464. 'invoiceTotalAmount' => '0.00',
  14465. 'invoiceCompanyAmount' => '0.00',
  14466. 'invoiceArriveAmountM'=>'0.00',
  14467. 'invoiceCompanyAmountM'=>'0.00'
  14468. );
  14469. if ($invoiceTrainId != 0) {
  14470. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $invoiceTrainId );
  14471. }
  14472. $invoiceArriveAmount = $RIAmount = 0;
  14473. if (! empty ( $invoiceTrainingDetail )) {
  14474. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  14475. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  14476. }
  14477. // 备用金
  14478. $sum = 0;
  14479. if (! empty ( $trainLoanRid )) {
  14480. $receiptLoanList = $receipt->getReceiptInRid ( $trainLoanRid );
  14481. foreach ($receiptLoanList as $key=>$value){
  14482. $sum+=$value['sum'];
  14483. }
  14484. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $trainLoanRid );
  14485. // $sum = $receiptLoanDetailBak ['sum'];
  14486. }
  14487. // 支出项金额详情
  14488. // 项目金额合计
  14489. Doo::loadModel ( 'RItem' );
  14490. $RItem = new RItem ();
  14491. Doo::loadModel ( 'accountItem' );
  14492. $accountItem = new accountItem ();
  14493. // 讲师获得
  14494. Doo::loadModel ( 'RILecturer' );
  14495. $RILecturer = new RILecturer ();
  14496. $RItemList = $RItem->getRItemByRid ($rid );
  14497. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  14498. // 支出项金额详情
  14499. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  14500. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  14501. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  14502. return $payment;
  14503. }
  14504. }
  14505. ?>