ReceiptController.php 543 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572
  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. function saeaBorad() {
  154. Doo::loadModel ( 'receipt' );
  155. $receipt = new receipt ();
  156. Doo::loadModel ( 'verify' );
  157. $verify = new verify ();
  158. Doo::loadModel ( 'L_category' );
  159. $lCategory = new L_category ();
  160. Doo::loadModel ( "role" );
  161. $role = new role ();
  162. Doo::loadModel ( "receiptLog" );
  163. $receiptLog = new receiptLog ();
  164. Doo::loadClass ( 'XDeode' );
  165. $XDeode = new XDeode ( 7 );
  166. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  167. $receiptDetail = $receipt->find ( array (
  168. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  169. 'desc' => 'rid',
  170. 'asArray' => true
  171. ) );
  172. foreach ( $receiptDetail as $key => $value ) {
  173. $receiptDetail [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  174. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  175. $veList = $verify->getOne ( array (
  176. 'where' => 'vid=' . $value ['verify'],
  177. 'asArray' => true
  178. ) );
  179. $v = json_decode ( $veList ['staff'] );
  180. array_push ( $v [0], $veList ['description'] );
  181. foreach ( $v as $n => $m ) {
  182. if ($m ['1'] == 'ROLE') {
  183. $roleInfo = $role->getOne ( array (
  184. 'where' => 'rid=' . $m [0],
  185. 'asArray' => true
  186. ) );
  187. $v [$n] [1] = $roleInfo ['name'];
  188. }
  189. }
  190. $receiptDetail [$key] ['staff'] = $v;
  191. $category = $lCategory->getOne ( array (
  192. 'where' => 'cid=' . $value ['cid'],
  193. 'asArray' => true
  194. ) );
  195. $receiptDetail [$key] ['category'] = $category ['title'];
  196. }
  197. // print_r($receiptLogList);
  198. Doo::loadModel ( 'RAssist' );
  199. $RAssist = new RAssist ();
  200. $receiptExtendList=$RAssist->getRAssistBySid($this->staff[0]['sid']);
  201. $data ['receiptExtendList'] = $receiptExtendList;
  202. $data ['receiptLogList'] = $receiptLogList;
  203. $data ['receiptDetail'] = $receiptDetail;
  204. $data ['memu'] = "receipt";
  205. $data ['staff'] = $this->staff;
  206. $data ['receiptMemu'] = 'saeaBorad';
  207. $data ['verifyId'] = $this->verifyId;
  208. $data ['executeId'] = $this->executeId;
  209. $this->render ( "/receipt/receiptFee", $data );
  210. }
  211. function remitAdd() {
  212. Doo::loadModel ( 'accountItem' );
  213. Doo::loadModel ( 'verify' );
  214. Doo::loadModel ( 'receipt' );
  215. Doo::loadModel ( 'L_category' );
  216. $lCategory = new L_category ();
  217. $receipt = new receipt ();
  218. $verify = new verify ();
  219. $accountItem = new accountItem ();
  220. Doo::loadModel ( "role" );
  221. $role = new role ();
  222. $acItem = $accountItem->find ( array (
  223. 'asArray' => true
  224. ) );
  225. $veList = $verify->getVerifyBySubordinate('REMIT');
  226. $data ['category'] = $lCategory->find ( array (
  227. 'asArray' => true
  228. ) );
  229. $data ['veList'] = $veList;
  230. $data ['acItem'] = $acItem;
  231. $data ['memu'] = "receipt";
  232. $data ['staff'] = $this->staff;
  233. $data ['receiptMemu'] = 'saeaBorad';
  234. $data ['verifyId'] = $this->verifyId;
  235. $data ['executeId'] = $this->executeId;
  236. $this->render ( "/admin/remitAdd", $data );
  237. }
  238. function remitAddDo() {
  239. $agency = $this->get_args ( 'agency' );
  240. $travel = $this->get_args ( 'travel' );
  241. $train = $this->get_args ( 'train' );
  242. $other = $this->get_args ( 'other' );
  243. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  244. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  245. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  246. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  247. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  248. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  249. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  250. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  251. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  252. // print_r($agency);die;
  253. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  254. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  255. header ( 'Content-Type:text/html;charset=utf-8' );
  256. die ( '请填写联行号' );
  257. }
  258. Doo::loadModel ( 'receipt' );
  259. Doo::loadModel ( 'receiptDetail' );
  260. Doo::loadModel ( 'accountItem' );
  261. $accountItem = new accountItem ();
  262. $receipt = new receipt ();
  263. Doo::loadModel ( 'enclosur' );
  264. Doo::loadModel ( 'execute' );
  265. $execute = new execute ();
  266. $executeDetail = $execute->getOne ( array (
  267. 'where' => 'mold="对公汇款执行人"',
  268. 'asArray' => true
  269. ) );
  270. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  271. $aItem = $accountItem->find ( array (
  272. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  273. 'asArray' => true
  274. ) );
  275. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  276. $ag = $tr = $ta = $ot = 0;
  277. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  278. print_r($aItem);
  279. foreach ( $aItem as $key => $value ) {
  280. if ($value ['category'] == $this->AGENCY) {
  281. if (isset ( $agency [$ag] )) {
  282. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  283. array_push ( $accountJson [$this->AGENCY], array (
  284. 'aid' => $value ['aid'],
  285. 'name' => $value ['name'],
  286. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  287. ) );
  288. $sum += $agency [$ag];
  289. $agencySum += $agency [$ag];
  290. }
  291. }
  292. $ag ++;
  293. }
  294. }
  295. $accountJson ['cSum'] = array (
  296. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  297. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  298. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  299. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  300. );
  301. //die;
  302. // 报销单
  303. $receipt->accountItem = json_encode ( $accountJson );
  304. $receipt->staff = $this->staff [0] ['sid'];
  305. $receipt->sum = number_format ( $sum, 2, '.', '' );
  306. $receipt->date = date ( "Y-m-d" );
  307. $receipt->cid = $cid;
  308. $receipt->status = 5;
  309. $receipt->Rtype = 2;
  310. // 修改审批流程加入角色
  311. $receipt->verify = $verify;
  312. $receipt->executeCopy = $executeDetail ['staff'];
  313. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  314. $order = array (
  315. "\r\n",
  316. "\n",
  317. "\r"
  318. );
  319. $replace = '<br/>';
  320. $explanation = str_replace ( $order, $replace, $explanation );
  321. $receipt->explanation = $explanation;
  322. $receipt->remittanceName = $remittanceName;
  323. $receipt->bankName = $bankName;
  324. $receipt->bankNumber = $bankNumber;
  325. $receipt->remittanceBankType = $remittanceBankType;
  326. if ($remittanceBankType == 1)
  327. $receipt->coupletNumber = $coupletNumber;
  328. $rid = $receipt->insert ();
  329. // 附件
  330. if (! empty ( $enclosurName )) {
  331. $enclosurArray = explode ( '-', $enclosurName );
  332. foreach ( $enclosurArray as $value ) {
  333. $enclosur = new enclosur ();
  334. $enclosur->name = $value;
  335. $enclosur->rid = $rid;
  336. $enclosur->insert ();
  337. }
  338. // print_r($enclosurArray);die;
  339. }
  340. // 报销详情
  341. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  342. $receiptDetail = new receiptDetail ();
  343. $receiptDetail->staff = $this->staff [0] ['sid'];
  344. $receiptDetail->item = $value ['name'];
  345. $receiptDetail->itemCategory = $this->AGENCY;
  346. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  347. $receiptDetail->date = date ( "Y-m-d" );
  348. $receiptDetail->cid = $cid;
  349. $receiptDetail->rid = $rid;
  350. $receiptDetail->status = 4;
  351. $receiptDetail->insert ();
  352. }
  353. return "/saeaBorad";
  354. } else
  355. die ( 'illegal request' );
  356. }
  357. function remitEdit() {
  358. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  359. Doo::loadClass ( 'XDeode' );
  360. $XDeode = new XDeode ( 7 );
  361. $rid = $XDeode->decode ( $ridKey );
  362. if (! is_numeric ( $rid ))
  363. die ( 'illegal request' );
  364. Doo::loadModel ( 'accountItem' );
  365. Doo::loadModel ( 'verify' );
  366. Doo::loadModel ( 'receipt' );
  367. $receipt = new receipt ();
  368. $verify = new verify ();
  369. $accountItem = new accountItem ();
  370. Doo::loadModel ( 'L_category' );
  371. $lCategory = new L_category ();
  372. Doo::loadModel ( "role" );
  373. $role = new role ();
  374. Doo::loadModel ( 'enclosur' );
  375. $enclosur = new enclosur ();
  376. $receiptDetail = $receipt->getOne ( array (
  377. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  378. 'asArray' => true
  379. ) );
  380. if (empty ( $receiptDetail ))
  381. return "/saeaCreate";
  382. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  383. $acItem = $accountItem->find ( array (
  384. 'asArray' => true
  385. ) );
  386. $veList = $verify->getVerifyBySubordinate('REMIT');
  387. // 配置编辑信息
  388. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  389. foreach ( $acItem as $key => $value ) {
  390. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  391. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  392. $acItem [$key] ['price'] = $v ['price'];
  393. }
  394. }
  395. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  396. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  397. $acItem [$key] ['price'] = $v ['price'];
  398. }
  399. }
  400. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  401. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  402. $acItem [$key] ['price'] = $v ['price'];
  403. }
  404. }
  405. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  406. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  407. $acItem [$key] ['price'] = $v ['price'];
  408. }
  409. }
  410. }
  411. $data ['category'] = $lCategory->find ( array (
  412. 'asArray' => true
  413. ) );
  414. $data ['enclosurList'] = $enclosurList;
  415. $data ['cSum'] = $accountItemList ['cSum'];
  416. $data ['sum'] = $receiptDetail ['sum'];
  417. $data ['receiptDetail'] = $receiptDetail;
  418. $data ['veList'] = $veList;
  419. $data ['acItem'] = $acItem;
  420. $data ['memu'] = "receipt";
  421. $data ['staff'] = $this->staff;
  422. $data ['receiptMemu'] = 'saeaBorad';
  423. $data ['verify'] = $receiptDetail ['verify'];
  424. $data ['verifyId'] = $this->verifyId;
  425. $data ['executeId'] = $this->executeId;
  426. $data ['rid'] = $rid;
  427. $data ['ridKey'] = $ridKey;
  428. $this->render ( "/admin/remitEdit", $data );
  429. }
  430. function remitEdiDo() {
  431. $agency = $this->get_args ( 'agency' );
  432. $travel = $this->get_args ( 'travel' );
  433. $train = $this->get_args ( 'train' );
  434. $other = $this->get_args ( 'other' );
  435. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  436. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  437. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  438. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  439. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  440. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  441. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  442. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  443. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  444. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  445. Doo::loadClass ( 'XDeode' );
  446. $XDeode = new XDeode ( 7 );
  447. $rid = $XDeode->decode ( $ridKey );
  448. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  449. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  450. header ( 'Content-Type:text/html;charset=utf-8' );
  451. die ( '请填写联行号' );
  452. }
  453. Doo::loadModel ( 'receipt' );
  454. Doo::loadModel ( 'receiptDetail' );
  455. Doo::loadModel ( 'accountItem' );
  456. $accountItem = new accountItem ();
  457. $receipt = new receipt ();
  458. Doo::loadModel ( 'enclosur' );
  459. $enclosur = new enclosur ();
  460. Doo::loadModel ( 'execute' );
  461. $execute = new execute ();
  462. $executeDetail = $execute->getOne ( array (
  463. 'where' => 'mold="对公汇款执行人"',
  464. 'asArray' => true
  465. ) );
  466. $receiptDetail = $receipt->getOne ( array (
  467. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  468. 'asArray' => true
  469. ) );
  470. if (empty ( $receiptDetail ))
  471. return "/saeaBorad";
  472. $aItem = $accountItem->find ( array (
  473. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  474. 'asArray' => true
  475. ) );
  476. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  477. $ag = $tr = $ta = $ot = 0;
  478. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  479. foreach ( $aItem as $key => $value ) {
  480. if ($value ['category'] == $this->AGENCY) {
  481. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  482. array_push ( $accountJson [$this->AGENCY], array (
  483. 'aid' => $value ['aid'],
  484. 'name' => $value ['name'],
  485. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  486. ) );
  487. $sum += $agency [$ag];
  488. $agencySum += $agency [$ag];
  489. }
  490. $ag ++;
  491. }
  492. }
  493. $accountJson ['cSum'] = array (
  494. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  495. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  496. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  497. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  498. );
  499. // 报销单
  500. $rid = $receipt->rid = $receiptDetail ['rid'];
  501. $receipt->accountItem = json_encode ( $accountJson );
  502. $receipt->staff = $this->staff [0] ['sid'];
  503. $receipt->sum = number_format ( $sum, 2, '.', '' );
  504. $receipt->date = date ( "Y-m-d" );
  505. $receipt->cid = $cid;
  506. if ($receiptDetail ['Rtype'] == 1)
  507. $receipt->status = 7;
  508. else
  509. $receipt->status = 5;
  510. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  511. $receipt->verify = $verify;
  512. $receipt->executeCopy = $executeDetail ['staff'];
  513. $order = array (
  514. "\r\n",
  515. "\n",
  516. "\r"
  517. );
  518. $replace = '<br/>';
  519. $explanation = str_replace ( $order, $replace, $explanation );
  520. $receipt->explanation = $explanation;
  521. $receipt->remittanceName = $remittanceName;
  522. $receipt->bankName = $bankName;
  523. $receipt->bankNumber = $bankNumber;
  524. $receipt->remittanceBankType = $remittanceBankType;
  525. if ($remittanceBankType == 1)
  526. $receipt->coupletNumber = $coupletNumber;
  527. $receipt->update ();
  528. $receiptDetail = new receiptDetail ();
  529. $receiptDetail->delete ( array (
  530. 'where' => 'rid=' . $rid
  531. ) );
  532. // 报销详情
  533. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  534. $receiptDetail = new receiptDetail ();
  535. $receiptDetail->staff = $this->staff [0] ['sid'];
  536. $receiptDetail->item = $value ['name'];
  537. $receiptDetail->itemCategory = $this->AGENCY;
  538. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  539. $receiptDetail->date = date ( "Y-m-d" );
  540. $receiptDetail->cid = $cid;
  541. $receiptDetail->rid = $rid;
  542. $receiptDetail->status = 4;
  543. $receiptDetail->insert ();
  544. }
  545. // 附件
  546. if (! empty ( $enclosurName )) {
  547. $enclosurArray = explode ( '-', $enclosurName );
  548. foreach ( $enclosurArray as $value ) {
  549. $enclosur = new enclosur ();
  550. $enclosur->name = $value;
  551. $enclosur->rid = $rid;
  552. $enclosur->insert ();
  553. }
  554. }
  555. }
  556. return "/saeaBorad";
  557. }
  558. function remitApproval() {
  559. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  560. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  561. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  562. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  563. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  564. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  565. if (empty ( $status ))
  566. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  567. $vidList = array ();
  568. $button = 0;
  569. Doo::loadModel ( 'verify' );
  570. Doo::loadModel ( 'receipt' );
  571. Doo::loadModel ( 'staff' );
  572. $staff = new staff ();
  573. $receipt = new receipt ();
  574. $verify = new verify ();
  575. Doo::loadModel ( 'L_category' );
  576. $Lcategory = new L_category ();
  577. Doo::loadModel ( 'enclosur' );
  578. $enclosur = new enclosur ();
  579. // user verify ID
  580. $verifyDetail = $verify->find ( array (
  581. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  582. 'asArray' => true
  583. ) );
  584. foreach ( $verifyDetail as $key => $value ) {
  585. array_push ( $vidList, $value ['vid'] );
  586. }
  587. $vid = implode ( ",", $vidList );
  588. if (empty ( $verifyDetail ))
  589. $vid = 0;
  590. $categoryList = $Lcategory->find ( array (
  591. 'asArray' => true
  592. ) );
  593. $staffList = $staff->find ( array (
  594. 'where' => 'cid=' . $cid,
  595. 'asArray' => true
  596. ) );
  597. $ap = "";
  598. if ($status == 4) {
  599. $ap = 4;
  600. $status = 2;
  601. }
  602. // get Receipt By verifyID status 2
  603. $receiptList = $receipt->find ( array (
  604. 'where' => 'rid =' . $rid . ' and status=2',
  605. 'desc' => 'rid',
  606. 'asArray' => true
  607. ) );
  608. if (empty ( $receiptList )) {
  609. die ( 'illegal request' );
  610. }
  611. $Locate = 0;
  612. $roleId = 0;
  613. if ($ap == 4)
  614. $status = 4;
  615. foreach ( $receiptList as $key => $value ) {
  616. $receiptList [$key] ['Locate'] = $Locate;
  617. $Locate ++;
  618. $receiptList [$key] ['reviseDetail'] = array ();
  619. if (! empty ( $value ['reviseDetail'] ))
  620. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  621. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  622. $categoryDetil = $Lcategory->getOne ( array (
  623. 'where' => 'cid=' . $value ['cid'],
  624. 'asArray' => true
  625. ) );
  626. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  627. // 检测编辑状态
  628. $verifyList = $verify->getOne ( array (
  629. 'where' => 'vid=' . $value ['verify'],
  630. 'asArray' => true
  631. ) );
  632. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  633. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  634. Doo::loadModel ( 'role' );
  635. $role = new role ();
  636. // print_r($verifyList);
  637. $flag = true;
  638. $roleKey = 0;
  639. $endStaffArray = array ();
  640. $roleArrayCopy = array ();
  641. foreach ( $verifyList as $k => $v ) {
  642. // init verifyStaff
  643. if ($v [1] == 'ROLE') {
  644. if (! empty ( $verifyStaff )) {
  645. $endStaffArray = end ( $verifyStaff );
  646. if ($v [0] == $endStaffArray ['nextStaff']) {
  647. $roleId = $v [0];
  648. }
  649. }
  650. $roleVerify = json_decode ( $v [3], true );
  651. $roleKey = $k;
  652. $roleArray = array ();
  653. $rolename = $role->getOne ( array (
  654. 'where' => 'rid=' . $v [0],
  655. 'asArray' => true
  656. ) );
  657. foreach ( $roleVerify as $o => $p ) {
  658. $staffID = explode ( '_', $p );
  659. $staffInfo = $staff->getOne ( array (
  660. 'where' => 'sid=' . $staffID [0],
  661. 'asArray' => true
  662. ) );
  663. // print_r($staffID);
  664. $exp = array (
  665. 0 => $staffInfo ['sid'],
  666. 1 => $staffID [1],
  667. 2 => $staffInfo ['avatar'],
  668. 'date' => '',
  669. 'date' => '',
  670. 'opinion' => '',
  671. 'status' => '',
  672. 'rolename' => $rolename ['name']
  673. );
  674. array_push ( $roleArray, $exp );
  675. }
  676. $roleArrayCopy [$v [0]] = $roleArray;
  677. // $verifyList[$k]['roleArray']=$roleArray;
  678. }
  679. // print_r($roleArray);
  680. $verifyList [$k] ['date'] = "";
  681. $verifyList [$k] ['opinion'] = "";
  682. $verifyList [$k] ['status'] = "";
  683. if (empty ( $verifyStaff )) {
  684. $verifyList [$k] ['date'] = "";
  685. $verifyList [$k] ['opinion'] = "";
  686. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  687. $verifyList [$k] ['status'] = 4;
  688. $button = 4;
  689. $flag = false;
  690. }
  691. } else {
  692. foreach ( $verifyStaff as $m => $u ) {
  693. if ($v [0] == $m) {
  694. $verifyList [$k] ['date'] = $u ['date'];
  695. $verifyList [$k] ['opinion'] = $u ['opinion'];
  696. $verifyList [$k] ['status'] = $u ['status'];
  697. $flag = false;
  698. break;
  699. }
  700. }
  701. $endStaffArray = end ( $verifyStaff );
  702. if (isset ( $endStaffArray ['ROLE'] )) {
  703. } else {
  704. $endKey = key ( $verifyStaff );
  705. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  706. $button = 4;
  707. $verifyList [$k] ['status'] = 4;
  708. }
  709. }
  710. }
  711. }
  712. $rolename ['name'] = '';
  713. if (! empty ( $roleId )) {
  714. Doo::loadModel ( 'role' );
  715. $role = new role ();
  716. $rolename = $role->getOne ( array (
  717. 'where' => 'rid=' . $roleId,
  718. 'asArray' => true
  719. ) );
  720. }
  721. if (! empty ( $verifyStaff ))
  722. $endStaffArray = end ( $verifyStaff );
  723. $KOP = false;
  724. foreach ( $roleArrayCopy as $P => $A ) {
  725. foreach ( $A as $MKI => $AVL ) {
  726. if (! empty ( $verifyStaff )) {
  727. // &&$rolename['rid']==$endStaffArray['nextStaff']
  728. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  729. $button = 4;
  730. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  731. }
  732. foreach ( $verifyStaff as $m => $u ) {
  733. $AVLFK = $AVL [0] . '_R';
  734. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  735. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  736. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  737. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  738. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  739. break;
  740. }
  741. }
  742. } else {
  743. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  744. $button = 4;
  745. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  746. }
  747. }
  748. // $roleArray[$MKI]['rolename']=$rolename['name'];
  749. $KOP = true;
  750. }
  751. }
  752. foreach ( $roleArrayCopy as $k => $v ) {
  753. foreach ( $verifyList as $m => $n ) {
  754. if ($n [0] == $k) {
  755. array_splice ( $verifyList, $m, 1, $v );
  756. }
  757. }
  758. }
  759. $receiptList [$key] ['verifyList'] = $verifyList;
  760. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  761. 'where' => 'sid=' . $value ['staff'],
  762. 'asArray' => true
  763. ) );
  764. $receiptList [$key] ['button'] = $button;
  765. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  766. }
  767. $mothHtml = "";
  768. for($i = 1; $i <= 12; $i ++) {
  769. if ($month == $i)
  770. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  771. else
  772. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  773. }
  774. // 获取审批日志
  775. Doo::loadModel ( 'receiptLog' );
  776. $receiptLog = new receiptLog ();
  777. $rlList = array ();
  778. $rlInfo = $receiptLog->getOne ( array (
  779. 'where' => 'rid=' . $rid . ' and status=4',
  780. 'asArray' => true
  781. ) );
  782. $tijdate = $receiptLog->getOne ( array (
  783. 'where' => 'rid=' . $rid . ' and status=2',
  784. 'asc' => 'rlid',
  785. 'asArray' => true
  786. ) );
  787. if (! empty ( $rlInfo )) {
  788. $rlList = $receiptLog->find ( array (
  789. 'where' => 'rid=' . $rid,
  790. 'asc' => 'rlid',
  791. 'asArray' => true
  792. ) );
  793. }
  794. $receiptList [0] ['rlList'] = $rlList;
  795. $enclosurList = $enclosur->find ( array (
  796. 'where' => 'rid=' . $rid,
  797. 'asArray' => true
  798. ) );
  799. $enclosurHtml = '';
  800. foreach ( $enclosurList as $value ) {
  801. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  802. }
  803. // print_r($receiptList);
  804. $data ['enclosurHtml'] = $enclosurHtml;
  805. $data ['rolename'] = $rolename ['name'];
  806. $data ['datetij'] = $tijdate ['date'];
  807. $data ['mothHtml'] = $mothHtml;
  808. $data ['rid'] = $rid;
  809. $data ['receiptList'] = $receiptList;
  810. $data ['receiptApprovalCount'] = count ( $receiptList );
  811. $data ['status'] = $status;
  812. $data ['year'] = $year;
  813. $data ['categoryList'] = $categoryList;
  814. $data ['staffList'] = $staffList;
  815. $data ['cid'] = $cid;
  816. $data ['sid'] = $sid;
  817. $data ['ap'] = $ap;
  818. $data ['memu'] = "receipt";
  819. $data ['staff'] = $this->staff;
  820. $data ['receiptMemu'] = 'approvalExpenses';
  821. $data ['verifyId'] = $this->verifyId;
  822. $data ['executeId'] = $this->executeId;
  823. $this->render ( "/admin/remitApproval", $data );
  824. }
  825. function saeaLoanAdd() {
  826. Doo::loadModel ( 'verify' );
  827. $verify = new verify ();
  828. Doo::loadModel ( "role" );
  829. $role = new role ();
  830. Doo::loadModel ( 'L_category' );
  831. $lCategory = new L_category ();
  832. $veList = $verify->getVerifyBySubordinate('LOAN');
  833. $data ['category'] = $lCategory->find ( array (
  834. 'asArray' => true
  835. ) );
  836. $data ['veList'] = $veList;
  837. $data ['memu'] = "receipt";
  838. $data ['staff'] = $this->staff;
  839. $data ['receiptMemu'] = 'saeaBorad';
  840. $data ['verifyId'] = $this->verifyId;
  841. $data ['executeId'] = $this->executeId;
  842. $this->render ( "/admin/saeaLoanAdd", $data );
  843. }
  844. function saeaLoanAddDo() {
  845. $agency = $this->get_args ( 'agency' );
  846. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  847. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  848. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  849. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  850. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  851. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  852. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  853. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  854. // die;
  855. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  856. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  857. header ( 'Content-Type:text/html;charset=utf-8' );
  858. die ( '请填写联行号' );
  859. }
  860. Doo::loadModel ( 'receipt' );
  861. Doo::loadModel ( 'receiptDetail' );
  862. Doo::loadModel ( 'accountItem' );
  863. $accountItem = new accountItem ();
  864. $receipt = new receipt ();
  865. Doo::loadModel ( 'loanReceipt' );
  866. $loanReceipt = new loanReceipt ();
  867. Doo::loadModel ( 'execute' );
  868. $execute = new execute ();
  869. Doo::loadModel ( 'enclosur' );
  870. $executeDetail = $execute->getOne ( array (
  871. 'where' => 'mold="借款执行人"',
  872. 'asArray' => true
  873. ) );
  874. $aItem = $accountItem->find ( array (
  875. 'asArray' => true
  876. ) );
  877. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  878. $ag = $tr = $ta = $ot = 0;
  879. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  880. array_push ( $accountJson ['借款费用'], array (
  881. 'aid' => 0,
  882. 'name' => '申请金额',
  883. 'price' => number_format ( $agency, 2, '.', '' )
  884. ) );
  885. $sum += $agency;
  886. $agencySum += $agency;
  887. $accountJson ['cSum'] = array (
  888. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  889. 'agencySum' => number_format ( 0, 2, '.', '' ),
  890. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  891. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  892. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  893. );
  894. // 借款数据备份
  895. $loanReceipt->loanItem = json_encode ( $accountJson );
  896. $loanReceipt->staff = $this->staff [0] ['sid'];
  897. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  898. $loanReceipt->date = date ( "Y-m-d" );
  899. $loanReceipt->cid = $cid;
  900. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  901. $loanReceipt->status = 5;
  902. $loanReceipt->Rtype = 1;
  903. $loanReceipt->verify = $verify;
  904. $receipt->receiptOrder = $receipt->receiptOrder;
  905. // 添加HTML换行符
  906. // var_dump($explanation);
  907. $order = array (
  908. "\r\n",
  909. "\n",
  910. "\r"
  911. );
  912. $replace = '<br/>';
  913. $explanation = str_replace ( $order, $replace, $explanation );
  914. // $explanation=str_replace('\r',"<br/>",$explanation);
  915. // $explanation=str_replace('\r\n',"<br/>",$explanation);
  916. $loanReceipt->explanation = $explanation;
  917. $loanRid = $loanReceipt->insert ();
  918. // 报销单
  919. $receipt->loanItem = json_encode ( $accountJson );
  920. $receipt->staff = $this->staff [0] ['sid'];
  921. $receipt->sum = number_format ( $sum, 2, '.', '' );
  922. $receipt->date = date ( "Y-m-d" );
  923. $receipt->cid = $cid;
  924. // 特殊状态
  925. $receipt->status = 5;
  926. $receipt->Rtype = 1;
  927. $receipt->loanRid = $loanRid;
  928. // 修改审批流程加入角色
  929. $receipt->verify = $verify;
  930. $receipt->executeCopy = $executeDetail ['staff'];
  931. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  932. $receipt->explanation = $explanation;
  933. $receipt->remittanceName = $remittanceName;
  934. $receipt->bankName = $bankName;
  935. $receipt->bankNumber = $bankNumber;
  936. $receipt->remittanceBankType = $remittanceBankType;
  937. if ($remittanceBankType == 1)
  938. $receipt->coupletNumber = $coupletNumber;
  939. $rid = $receipt->insert ();
  940. return "/saeaBorad";
  941. } else
  942. die ( 'illegal request' );
  943. }
  944. function saeaLoanEdi() {
  945. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  946. Doo::loadClass ( 'XDeode' );
  947. $XDeode = new XDeode ( 7 );
  948. $rid = $XDeode->decode ( $ridKey );
  949. if (! is_numeric ( $rid ))
  950. die ( 'illegal request' );
  951. Doo::loadModel ( 'verify' );
  952. $verify = new verify ();
  953. Doo::loadModel ( "role" );
  954. $role = new role ();
  955. Doo::loadModel ( 'L_category' );
  956. $lCategory = new L_category ();
  957. Doo::loadModel ( 'receipt' );
  958. $receipt = new receipt ();
  959. $receiptInfo = $receipt->getOne ( array (
  960. 'where' => 'rid=' . $rid,
  961. 'asArray' => true
  962. ) );
  963. $veList = $verify->find ( array (
  964. 'where'=>'subordinate like "%LOAN%"',
  965. 'asArray' => true
  966. ) );
  967. foreach ( $veList as $key => $value ) {
  968. $v = json_decode ( $value ['staff'] );
  969. $list = array ();
  970. foreach ( $v as $n => $m ) {
  971. if ($m ['1'] == 'ROLE') {
  972. $roleInfo = $role->getOne ( array (
  973. 'where' => 'rid=' . $m [0],
  974. 'asArray' => true
  975. ) );
  976. $v [$n] [1] = $roleInfo ['name'];
  977. array_push ( $list, $roleInfo ['name'] );
  978. } else {
  979. array_push ( $list, $v [$n] [1] );
  980. }
  981. }
  982. $veList [$key] ['staff'] = implode ( '>', $list );
  983. }
  984. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  985. // print_r($receiptInfo);
  986. $data ['receiptInfo'] = $receiptInfo;
  987. $data ['category'] = $lCategory->find ( array (
  988. 'asArray' => true
  989. ) );
  990. $data ['veList'] = $veList;
  991. $data ['ridKey'] = $ridKey;
  992. $data ['memu'] = "receipt";
  993. $data ['staff'] = $this->staff;
  994. $data ['receiptMemu'] = 'saeaBorad';
  995. $data ['verifyId'] = $this->verifyId;
  996. $data ['executeId'] = $this->executeId;
  997. $this->render ( "/admin/saeaLoanEdi", $data );
  998. }
  999. function saeaLoanEdiDo() {
  1000. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1001. $agency = $this->get_args ( 'agency' );
  1002. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1003. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1004. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1005. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1006. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1007. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1008. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1009. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1010. // die;
  1011. Doo::loadClass ( 'XDeode' );
  1012. $XDeode = new XDeode ( 7 );
  1013. $rid = $XDeode->decode ( $ridKey );
  1014. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1015. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1016. header ( 'Content-Type:text/html;charset=utf-8' );
  1017. die ( '请填写联行号' );
  1018. }
  1019. Doo::loadModel ( 'receipt' );
  1020. Doo::loadModel ( 'receiptDetail' );
  1021. Doo::loadModel ( 'accountItem' );
  1022. $accountItem = new accountItem ();
  1023. $receipt = new receipt ();
  1024. Doo::loadModel ( 'loanReceipt' );
  1025. $loanReceipt = new loanReceipt ();
  1026. Doo::loadModel ( 'enclosur' );
  1027. Doo::loadModel ( 'execute' );
  1028. $execute = new execute ();
  1029. $executeDetail = $execute->getOne ( array (
  1030. 'where' => 'mold="借款执行人"',
  1031. 'asArray' => true
  1032. ) );
  1033. $receiptDetail = $receipt->getOne ( array (
  1034. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  1035. 'asArray' => true
  1036. ) );
  1037. if (empty ( $receiptDetail ))
  1038. die ( '参数错误' );
  1039. $aItem = $accountItem->find ( array (
  1040. 'asArray' => true
  1041. ) );
  1042. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1043. $ag = $tr = $ta = $ot = 0;
  1044. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1045. array_push ( $accountJson ['借款费用'], array (
  1046. 'aid' => 0,
  1047. 'name' => '申请金额',
  1048. 'price' => number_format ( $agency, 2, '.', '' )
  1049. ) );
  1050. $sum += $agency;
  1051. $agencySum += $agency;
  1052. $accountJson ['cSum'] = array (
  1053. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1054. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1055. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1056. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1057. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1058. );
  1059. // 报销单
  1060. $receipt->loanItem = json_encode ( $accountJson );
  1061. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1062. $receipt->cid = $cid;
  1063. // 特殊状态
  1064. // 修改审批流程加入角色
  1065. if ($receiptDetail ['status'] != 4)
  1066. $receipt->verify = $verify;
  1067. $order = array (
  1068. "\r\n",
  1069. "\n",
  1070. "\r"
  1071. );
  1072. $replace = '<br/>';
  1073. $explanation = str_replace ( $order, $replace, $explanation );
  1074. $receipt->explanation = $explanation;
  1075. $receipt->remittanceName = $remittanceName;
  1076. $receipt->bankName = $bankName;
  1077. $receipt->bankNumber = $bankNumber;
  1078. $receipt->remittanceBankType = $remittanceBankType;
  1079. if ($remittanceBankType == 1)
  1080. $receipt->coupletNumber = $coupletNumber;
  1081. $receipt->update ( array (
  1082. 'where' => 'rid=' . $rid
  1083. ) );
  1084. // 借款数据更新
  1085. $loanReceipt->loanItem = json_encode ( $accountJson );
  1086. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1087. $loanReceipt->cid = $cid;
  1088. if ($receiptDetail ['status'] != 4)
  1089. $loanReceipt->verify = $verify;
  1090. $loanReceipt->explanation = $explanation;
  1091. $receipt->executeCopy = $executeDetail ['staff'];
  1092. $loanReceipt->update ( array (
  1093. 'where' => 'rid=' . $receiptDetail ['loanRid']
  1094. ) );
  1095. }
  1096. return "/saeaBorad";
  1097. }
  1098. function saeaLoanReceiptAdd() {
  1099. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1100. Doo::loadModel ( 'receipt' );
  1101. $receipt = new receipt ();
  1102. Doo::loadModel ( 'loanReceipt' );
  1103. $loanReceipt = new loanReceipt ();
  1104. Doo::loadModel ( 'L_category' );
  1105. $Lcategory = new L_category ();
  1106. Doo::loadModel ( 'verify' );
  1107. Doo::loadModel ( 'statistics' );
  1108. $statistics = new statistics ();
  1109. $verify = new verify ();
  1110. Doo::loadModel ( 'staff' );
  1111. $staff = new staff ();
  1112. $receiptDetail = $receipt->getOne ( array (
  1113. 'where' => 'rid=' . $rid,
  1114. 'desc' => 'rid',
  1115. 'asArray' => true
  1116. ) );
  1117. $receiptList = $loanReceipt->find ( array (
  1118. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1119. 'desc' => 'rid',
  1120. 'asArray' => true
  1121. ) );
  1122. $Locate = 0;
  1123. $roleId = 0;
  1124. $button = 0;
  1125. foreach ( $receiptList as $key => $value ) {
  1126. $receiptList [$key] ['Locate'] = $Locate;
  1127. $Locate ++;
  1128. $receiptList [$key] ['reviseDetail'] = array ();
  1129. if (! empty ( $value ['reviseDetail'] ))
  1130. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1131. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1132. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1133. $categoryDetil = $Lcategory->getOne ( array (
  1134. 'where' => 'cid=' . $value ['cid'],
  1135. 'asArray' => true
  1136. ) );
  1137. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1138. // 检测编辑状态
  1139. $verifyList = $verify->getOne ( array (
  1140. 'where' => 'vid=' . $value ['verify'],
  1141. 'asArray' => true
  1142. ) );
  1143. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1144. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1145. Doo::loadModel ( 'role' );
  1146. $role = new role ();
  1147. $flag = true;
  1148. $roleKey = 0;
  1149. $endStaffArray = array ();
  1150. $roleArrayCopy = array ();
  1151. foreach ( $verifyList as $k => $v ) {
  1152. // init verifyStaff
  1153. if ($v [1] == 'ROLE') {
  1154. if (! empty ( $verifyStaff )) {
  1155. $endStaffArray = end ( $verifyStaff );
  1156. // if ($v[0]==$endStaffArray['nextStaff']){
  1157. // $roleId=$v[0];
  1158. // }
  1159. }
  1160. $roleVerify = json_decode ( $v [3], true );
  1161. $roleKey = $k;
  1162. $roleArray = array ();
  1163. $rolename = $role->getOne ( array (
  1164. 'where' => 'rid=' . $v [0],
  1165. 'asArray' => true
  1166. ) );
  1167. foreach ( $roleVerify as $o => $p ) {
  1168. $staffID = explode ( '_', $p );
  1169. $staffInfo = $staff->getOne ( array (
  1170. 'where' => 'sid=' . $staffID [0],
  1171. 'asArray' => true
  1172. ) );
  1173. // print_r($staffID);
  1174. $exp = array (
  1175. 0 => $staffInfo ['sid'],
  1176. 1 => $staffID [1],
  1177. 2 => $staffInfo ['avatar'],
  1178. 'date' => '',
  1179. 'date' => '',
  1180. 'opinion' => '',
  1181. 'status' => '',
  1182. 'rolename' => $rolename ['name']
  1183. );
  1184. array_push ( $roleArray, $exp );
  1185. }
  1186. $roleArrayCopy [$v [0]] = $roleArray;
  1187. // $verifyList[$k]['roleArray']=$roleArray;
  1188. }
  1189. $verifyList [$k] ['date'] = "";
  1190. $verifyList [$k] ['opinion'] = "";
  1191. $verifyList [$k] ['status'] = "";
  1192. if (empty ( $verifyStaff )) {
  1193. $verifyList [$k] ['date'] = "";
  1194. $verifyList [$k] ['opinion'] = "";
  1195. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1196. $verifyList [$k] ['status'] = 4;
  1197. $flag = false;
  1198. }
  1199. } else {
  1200. foreach ( $verifyStaff as $m => $u ) {
  1201. if ($v [0] == $m) {
  1202. $verifyList [$k] ['date'] = $u ['date'];
  1203. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1204. $verifyList [$k] ['status'] = $u ['status'];
  1205. $flag = false;
  1206. break;
  1207. }
  1208. }
  1209. $endStaffArray = end ( $verifyStaff );
  1210. if (isset ( $endStaffArray ['ROLE'] )) {
  1211. } else {
  1212. // $endKey=key($verifyStaff);
  1213. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1214. // $button=4;
  1215. // $verifyList[$k]['status']=4;
  1216. // }
  1217. }
  1218. }
  1219. }
  1220. $rolename ['name'] = '';
  1221. if (! empty ( $roleId )) {
  1222. Doo::loadModel ( 'role' );
  1223. $role = new role ();
  1224. $rolename = $role->getOne ( array (
  1225. 'where' => 'rid=' . $roleId,
  1226. 'asArray' => true
  1227. ) );
  1228. }
  1229. if (! empty ( $verifyStaff ))
  1230. $endStaffArray = end ( $verifyStaff );
  1231. $KOP = false;
  1232. foreach ( $roleArrayCopy as $P => $A ) {
  1233. foreach ( $A as $MKI => $AVL ) {
  1234. if (! empty ( $verifyStaff )) {
  1235. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1236. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1237. $button = 4;
  1238. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1239. }
  1240. foreach ( $verifyStaff as $m => $u ) {
  1241. $AVLFK = $AVL [0] . '_R';
  1242. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1243. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1244. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1245. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1246. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1247. break;
  1248. }
  1249. }
  1250. } else {
  1251. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1252. $button = 4;
  1253. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1254. }
  1255. }
  1256. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1257. $KOP = true;
  1258. }
  1259. }
  1260. foreach ( $roleArrayCopy as $k => $v ) {
  1261. foreach ( $verifyList as $m => $n ) {
  1262. if ($n [0] == $k) {
  1263. array_splice ( $verifyList, $m, 1, $v );
  1264. }
  1265. }
  1266. }
  1267. $receiptList [$key] ['verifyList'] = $verifyList;
  1268. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1269. 'where' => 'sid=' . $value ['staff'],
  1270. 'asArray' => true
  1271. ) );
  1272. $receiptList [$key] ['button'] = $button;
  1273. //
  1274. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1275. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1276. }
  1277. $data ['receiptList'] = $receiptList;
  1278. $data ['receiptDetail'] = $receiptDetail;
  1279. Doo::loadModel ( 'L_category' );
  1280. $lCategory = new L_category ();
  1281. Doo::loadModel ( 'accountItem' );
  1282. $accountItem = new accountItem ();
  1283. $acItem = $accountItem->find ( array (
  1284. 'asArray' => true
  1285. ) );
  1286. $veList = $verify->getVerifyBySubordinate('RECEIPT','LOAN');
  1287. $data ['rid'] = $rid;
  1288. $data ['category'] = $lCategory->find ( array (
  1289. 'asArray' => true
  1290. ) );
  1291. $data ['veList'] = $veList;
  1292. $data ['acItem'] = $acItem;
  1293. $data ['memu'] = "receipt";
  1294. $data ['staff'] = $this->staff;
  1295. $data ['receiptMemu'] = 'saeaBorad';
  1296. $data ['verifyId'] = $this->verifyId;
  1297. $data ['executeId'] = $this->executeId;
  1298. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1299. }
  1300. function saeaLoanReceiptAddDo() {
  1301. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1302. $agency = $this->get_args ( 'agency' );
  1303. $travel = $this->get_args ( 'travel' );
  1304. $train = $this->get_args ( 'train' );
  1305. $other = $this->get_args ( 'other' );
  1306. $inttrain = $this->get_args ( 'inttrain' );
  1307. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1308. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1309. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1310. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1311. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1312. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1313. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1314. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1315. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1316. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1317. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1318. header ( 'Content-Type:text/html;charset=utf-8' );
  1319. die ( '请填写联行号' );
  1320. }
  1321. Doo::loadModel ( 'receipt' );
  1322. Doo::loadModel ( 'receiptDetail' );
  1323. Doo::loadModel ( 'accountItem' );
  1324. $accountItem = new accountItem ();
  1325. $receipt = new receipt ();
  1326. Doo::loadModel ( 'enclosur' );
  1327. Doo::loadModel ( 'execute' );
  1328. $execute = new execute ();
  1329. $executeDetail = $execute->getOne ( array (
  1330. 'where' => 'mold="借款费用执行人"',
  1331. 'asArray' => true
  1332. ) );
  1333. $receiptDet = $receipt->getOne ( array (
  1334. 'where' => 'rid=' . $rid,
  1335. 'asArray' => true
  1336. ) );
  1337. // if(!empty($receiptDetail))
  1338. // return "/referReceipt/".$receiptDetail['rid'];
  1339. $aItem = $accountItem->find ( array (
  1340. 'asArray' => true
  1341. ) );
  1342. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1343. $ag = $tr = $ta = $ot =$it = 0;
  1344. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  1345. foreach ( $aItem as $key => $value ) {
  1346. if ($value ['category'] == $this->AGENCY) {
  1347. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1348. array_push ( $accountJson [$this->AGENCY], array (
  1349. 'aid' => $value ['aid'],
  1350. 'name' => $value ['name'],
  1351. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1352. ) );
  1353. $sum += $agency [$ag];
  1354. $agencySum += $agency [$ag];
  1355. }
  1356. $ag ++;
  1357. }
  1358. if ($value ['category'] == $this->TRAVEL) {
  1359. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1360. array_push ( $accountJson [$this->TRAVEL], array (
  1361. 'aid' => $value ['aid'],
  1362. 'name' => $value ['name'],
  1363. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1364. ) );
  1365. $sum += $travel [$tr];
  1366. $travelSum += $travel [$tr];
  1367. }
  1368. $tr ++;
  1369. }
  1370. if ($value ['category'] == $this->INTTRAIN) {
  1371. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  1372. array_push ( $accountJson [$this->INTTRAIN], array (
  1373. 'aid' => $value ['aid'],
  1374. 'name' => $value ['name'],
  1375. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  1376. ) );
  1377. $sum += $inttrain [$it];
  1378. $inttrainSum += $inttrain [$it];
  1379. }
  1380. $it ++;
  1381. }
  1382. if ($value ['category'] == $this->TRAIN) {
  1383. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1384. array_push ( $accountJson [$this->TRAIN], array (
  1385. 'aid' => $value ['aid'],
  1386. 'name' => $value ['name'],
  1387. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1388. ) );
  1389. $sum += $train [$ta];
  1390. $trainSum += $train [$ta];
  1391. }
  1392. $ta ++;
  1393. }
  1394. if ($value ['category'] == $this->OTHER) {
  1395. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1396. array_push ( $accountJson [$this->OTHER], array (
  1397. 'aid' => $value ['aid'],
  1398. 'name' => $value ['name'],
  1399. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1400. ) );
  1401. $sum += $other [$ot];
  1402. $otherSum += $other [$ot];
  1403. }
  1404. $ot ++;
  1405. }
  1406. }
  1407. $accountJson ['cSum'] = array (
  1408. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1409. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1410. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1411. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  1412. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1413. );
  1414. // 报销单
  1415. $receipt->accountItem = json_encode ( $accountJson );
  1416. $receipt->staff = $this->staff [0] ['sid'];
  1417. $receipt->loanSum = $receiptDet ['sum'];
  1418. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1419. $receipt->date = date ( "Y-m-d" );
  1420. $receipt->pastDate = '';
  1421. $receipt->cid = $cid;
  1422. $receipt->status = 7;
  1423. // 修改审批流程加入角色
  1424. $receipt->verify = $verify;
  1425. $receipt->verifyStaff = '';
  1426. $receipt->executeStaff = '';
  1427. $receipt->executeCopy = $executeDetail ['staff'];
  1428. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1429. $receipt->explanation = $explanation;
  1430. $receipt->remittanceName = $remittanceName;
  1431. $receipt->bankName = $bankName;
  1432. $receipt->bankNumber = $bankNumber;
  1433. $receipt->remittanceBankType = $remittanceBankType;
  1434. if ($remittanceBankType == 1)
  1435. $receipt->coupletNumber = $coupletNumber;
  1436. $receipt->update ( array (
  1437. 'where' => 'rid=' . $rid
  1438. ) );
  1439. // 附件
  1440. if (! empty ( $enclosurName )) {
  1441. $enclosurArray = explode ( '-', $enclosurName );
  1442. foreach ( $enclosurArray as $value ) {
  1443. $enclosur = new enclosur ();
  1444. $enclosur->name = $value;
  1445. $enclosur->rid = $rid;
  1446. $enclosur->insert ();
  1447. }
  1448. // print_r($enclosurArray);die;
  1449. }
  1450. // 报销详情
  1451. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1452. $receiptDetail = new receiptDetail ();
  1453. $receiptDetail->staff = $this->staff [0] ['sid'];
  1454. $receiptDetail->item = $value ['name'];
  1455. $receiptDetail->itemCategory = $this->AGENCY;
  1456. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1457. $receiptDetail->date = date ( "Y-m-d" );
  1458. $receiptDetail->cid = $cid;
  1459. $receiptDetail->rid = $rid;
  1460. $receiptDetail->status = 4;
  1461. $receiptDetail->insert ();
  1462. }
  1463. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1464. $receiptDetail = new receiptDetail ();
  1465. $receiptDetail->staff = $this->staff [0] ['sid'];
  1466. $receiptDetail->item = $value ['name'];
  1467. $receiptDetail->itemCategory = $this->TRAVEL;
  1468. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1469. $receiptDetail->date = date ( "Y-m-d" );
  1470. $receiptDetail->cid = $cid;
  1471. $receiptDetail->rid = $rid;
  1472. $receiptDetail->status = 4;
  1473. $receiptDetail->insert ();
  1474. }
  1475. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1476. $receiptDetail = new receiptDetail ();
  1477. $receiptDetail->staff = $this->staff [0] ['sid'];
  1478. $receiptDetail->item = $value ['name'];
  1479. $receiptDetail->itemCategory = $this->TRAIN;
  1480. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1481. $receiptDetail->date = date ( "Y-m-d" );
  1482. $receiptDetail->cid = $cid;
  1483. $receiptDetail->rid = $rid;
  1484. $receiptDetail->status = 4;
  1485. $receiptDetail->insert ();
  1486. }
  1487. //内训
  1488. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  1489. $receiptDetail = new receiptDetail ();
  1490. $receiptDetail->staff = $this->staff [0] ['sid'];
  1491. $receiptDetail->item = $value ['name'];
  1492. $receiptDetail->itemCategory = $this->INTTRAIN;
  1493. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1494. $receiptDetail->date = date ( "Y-m-d" );
  1495. $receiptDetail->cid = $cid;
  1496. $receiptDetail->rid = $rid;
  1497. $receiptDetail->status = 4;
  1498. $receiptDetail->insert ();
  1499. }
  1500. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1501. $receiptDetail = new receiptDetail ();
  1502. $receiptDetail->staff = $this->staff [0] ['sid'];
  1503. $receiptDetail->item = $value ['name'];
  1504. $receiptDetail->itemCategory = $this->OTHER;
  1505. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1506. $receiptDetail->date = date ( "Y-m-d" );
  1507. $receiptDetail->cid = $cid;
  1508. $receiptDetail->rid = $rid;
  1509. $receiptDetail->status = 4;
  1510. $receiptDetail->insert ();
  1511. }
  1512. return "/saeaBorad";
  1513. }
  1514. return "/saeaLoanReceiptAdd/" . $rid;
  1515. }
  1516. function saeaLoanReceiptEdi() {
  1517. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1518. Doo::loadClass ( 'XDeode' );
  1519. $XDeode = new XDeode ( 7 );
  1520. $rid = $XDeode->decode ( $ridKey );
  1521. if (! is_numeric ( $rid ))
  1522. die ( 'illegal request' );
  1523. Doo::loadModel ( 'accountItem' );
  1524. Doo::loadModel ( 'verify' );
  1525. Doo::loadModel ( 'receipt' );
  1526. $receipt = new receipt ();
  1527. $verify = new verify ();
  1528. $accountItem = new accountItem ();
  1529. Doo::loadModel ( 'L_category' );
  1530. $Lcategory = new L_category ();
  1531. Doo::loadModel ( "role" );
  1532. $role = new role ();
  1533. Doo::loadModel ( 'loanReceipt' );
  1534. $loanReceipt = new loanReceipt ();
  1535. Doo::loadModel ( 'staff' );
  1536. $staff = new staff ();
  1537. $receiptDetail = $receipt->getOne ( array (
  1538. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1539. 'asArray' => true
  1540. ) );
  1541. if (empty ( $receiptDetail ))
  1542. return "/saeaBorad";
  1543. $receiptList = $loanReceipt->find ( array (
  1544. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1545. 'desc' => 'rid',
  1546. 'asArray' => true
  1547. ) );
  1548. $Locate = 0;
  1549. $roleId = 0;
  1550. $button = 0;
  1551. foreach ( $receiptList as $key => $value ) {
  1552. $receiptList [$key] ['Locate'] = $Locate;
  1553. $Locate ++;
  1554. $receiptList [$key] ['reviseDetail'] = array ();
  1555. if (! empty ( $value ['reviseDetail'] ))
  1556. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1557. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1558. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1559. $categoryDetil = $Lcategory->getOne ( array (
  1560. 'where' => 'cid=' . $value ['cid'],
  1561. 'asArray' => true
  1562. ) );
  1563. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1564. // 检测编辑状态
  1565. $verifyList = $verify->getOne ( array (
  1566. 'where' => 'vid=' . $value ['verify'],
  1567. 'asArray' => true
  1568. ) );
  1569. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1570. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1571. Doo::loadModel ( 'role' );
  1572. $role = new role ();
  1573. $flag = true;
  1574. $roleKey = 0;
  1575. $endStaffArray = array ();
  1576. $roleArrayCopy = array ();
  1577. foreach ( $verifyList as $k => $v ) {
  1578. // init verifyStaff
  1579. if ($v [1] == 'ROLE') {
  1580. if (! empty ( $verifyStaff )) {
  1581. $endStaffArray = end ( $verifyStaff );
  1582. // if ($v[0]==$endStaffArray['nextStaff']){
  1583. // $roleId=$v[0];
  1584. // }
  1585. }
  1586. $roleVerify = json_decode ( $v [3], true );
  1587. $roleKey = $k;
  1588. $roleArray = array ();
  1589. $rolename = $role->getOne ( array (
  1590. 'where' => 'rid=' . $v [0],
  1591. 'asArray' => true
  1592. ) );
  1593. foreach ( $roleVerify as $o => $p ) {
  1594. $staffID = explode ( '_', $p );
  1595. $staffInfo = $staff->getOne ( array (
  1596. 'where' => 'sid=' . $staffID [0],
  1597. 'asArray' => true
  1598. ) );
  1599. // print_r($staffID);
  1600. $exp = array (
  1601. 0 => $staffInfo ['sid'],
  1602. 1 => $staffID [1],
  1603. 2 => $staffInfo ['avatar'],
  1604. 'date' => '',
  1605. 'date' => '',
  1606. 'opinion' => '',
  1607. 'status' => '',
  1608. 'rolename' => $rolename ['name']
  1609. );
  1610. array_push ( $roleArray, $exp );
  1611. }
  1612. $roleArrayCopy [$v [0]] = $roleArray;
  1613. // $verifyList[$k]['roleArray']=$roleArray;
  1614. }
  1615. $verifyList [$k] ['date'] = "";
  1616. $verifyList [$k] ['opinion'] = "";
  1617. $verifyList [$k] ['status'] = "";
  1618. if (empty ( $verifyStaff )) {
  1619. $verifyList [$k] ['date'] = "";
  1620. $verifyList [$k] ['opinion'] = "";
  1621. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1622. $verifyList [$k] ['status'] = 4;
  1623. $flag = false;
  1624. }
  1625. } else {
  1626. foreach ( $verifyStaff as $m => $u ) {
  1627. if ($v [0] == $m) {
  1628. $verifyList [$k] ['date'] = $u ['date'];
  1629. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1630. $verifyList [$k] ['status'] = $u ['status'];
  1631. $flag = false;
  1632. break;
  1633. }
  1634. }
  1635. $endStaffArray = end ( $verifyStaff );
  1636. if (isset ( $endStaffArray ['ROLE'] )) {
  1637. } else {
  1638. // $endKey=key($verifyStaff);
  1639. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1640. // $button=4;
  1641. // $verifyList[$k]['status']=4;
  1642. // }
  1643. }
  1644. }
  1645. }
  1646. $rolename ['name'] = '';
  1647. if (! empty ( $roleId )) {
  1648. Doo::loadModel ( 'role' );
  1649. $role = new role ();
  1650. $rolename = $role->getOne ( array (
  1651. 'where' => 'rid=' . $roleId,
  1652. 'asArray' => true
  1653. ) );
  1654. }
  1655. if (! empty ( $verifyStaff ))
  1656. $endStaffArray = end ( $verifyStaff );
  1657. $KOP = false;
  1658. foreach ( $roleArrayCopy as $P => $A ) {
  1659. foreach ( $A as $MKI => $AVL ) {
  1660. if (! empty ( $verifyStaff )) {
  1661. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1662. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1663. $button = 4;
  1664. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1665. }
  1666. foreach ( $verifyStaff as $m => $u ) {
  1667. $AVLFK = $AVL [0] . '_R';
  1668. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1669. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1670. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1671. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1672. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1673. break;
  1674. }
  1675. }
  1676. } else {
  1677. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1678. $button = 4;
  1679. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1680. }
  1681. }
  1682. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1683. $KOP = true;
  1684. }
  1685. }
  1686. foreach ( $roleArrayCopy as $k => $v ) {
  1687. foreach ( $verifyList as $m => $n ) {
  1688. if ($n [0] == $k) {
  1689. array_splice ( $verifyList, $m, 1, $v );
  1690. }
  1691. }
  1692. }
  1693. $receiptList [$key] ['verifyList'] = $verifyList;
  1694. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1695. 'where' => 'sid=' . $value ['staff'],
  1696. 'asArray' => true
  1697. ) );
  1698. $receiptList [$key] ['button'] = $button;
  1699. //
  1700. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1701. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1702. }
  1703. $data ['receiptList'] = $receiptList;
  1704. $acItem = $accountItem->find ( array (
  1705. 'asArray' => true
  1706. ) );
  1707. $veList = $verify->find ( array (
  1708. 'asArray' => true
  1709. ) );
  1710. foreach ( $veList as $key => $value ) {
  1711. $v = json_decode ( $value ['staff'] );
  1712. $list = array ();
  1713. foreach ( $v as $n => $m ) {
  1714. if ($m ['1'] == 'ROLE') {
  1715. $roleInfo = $role->getOne ( array (
  1716. 'where' => 'rid=' . $m [0],
  1717. 'asArray' => true
  1718. ) );
  1719. $v [$n] [1] = $roleInfo ['name'];
  1720. array_push ( $list, $roleInfo ['name'] );
  1721. } else {
  1722. array_push ( $list, $v [$n] [1] );
  1723. }
  1724. }
  1725. $veList [$key] ['staff'] = implode ( '>', $list );
  1726. }
  1727. // 配置编辑信息
  1728. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1729. foreach ( $acItem as $key => $value ) {
  1730. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1731. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1732. $acItem [$key] ['price'] = $v ['price'];
  1733. }
  1734. }
  1735. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1736. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1737. $acItem [$key] ['price'] = $v ['price'];
  1738. }
  1739. }
  1740. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1741. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1742. $acItem [$key] ['price'] = $v ['price'];
  1743. }
  1744. }
  1745. //内训
  1746. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  1747. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1748. $acItem [$key] ['price'] = $v ['price'];
  1749. }
  1750. }
  1751. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1752. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1753. $acItem [$key] ['price'] = $v ['price'];
  1754. }
  1755. }
  1756. }
  1757. $data ['category'] = $Lcategory->find ( array (
  1758. 'asArray' => true
  1759. ) );
  1760. $data ['ridKey'] = $ridKey;
  1761. $data ['cSum'] = $accountItemList ['cSum'];
  1762. $data ['sum'] = $receiptDetail ['sum'];
  1763. $data ['receiptDetail'] = $receiptDetail;
  1764. $data ['veList'] = $veList;
  1765. $data ['acItem'] = $acItem;
  1766. $data ['memu'] = "receipt";
  1767. $data ['staff'] = $this->staff;
  1768. $data ['receiptMemu'] = 'saeaBorad';
  1769. $data ['verify'] = $receiptDetail ['verify'];
  1770. $data ['verifyId'] = $this->verifyId;
  1771. $data ['executeId'] = $this->executeId;
  1772. $data ['rid'] = $rid;
  1773. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1774. }
  1775. /**
  1776. * 培训班结算
  1777. */
  1778. function receiptTrainAdd() {
  1779. Doo::loadModel ( 'accountItem' );
  1780. $accountItem = new accountItem ();
  1781. $acItem = $accountItem->find ( array (
  1782. 'asArray' => true
  1783. ) );
  1784. // 审批组
  1785. Doo::loadModel ( 'verify' );
  1786. $verify = new verify ();
  1787. $veList = $verify->getVerifyBySubordinate('TRAIN');
  1788. // 办事处
  1789. Doo::loadModel ( 'L_category' );
  1790. $lCategory = new L_category ();
  1791. $data ['category'] = $lCategory->getCategory ();
  1792. $data ['veList'] = $veList;
  1793. $data ['memu'] = "receipt";
  1794. $data ['staff'] = $this->staff;
  1795. $data ['acItem'] = $acItem;
  1796. $data ['receiptMemu'] = 'saeaBorad';
  1797. $data ['verifyId'] = $this->verifyId;
  1798. $data ['executeId'] = $this->executeId;
  1799. $this->render ( "/receipt/receiptTrainAdd", $data );
  1800. }
  1801. /**
  1802. * 添加培训班结算
  1803. */
  1804. function receiptTrainAddDo() {//include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  1805. // 培训班信息
  1806. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  1807. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  1808. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  1809. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  1810. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  1811. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  1812. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  1813. // 发票信息
  1814. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1815. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  1816. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1817. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1818. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1819. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1820. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1821. //&&! empty ( $participants )
  1822. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  1823. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1824. header ( 'Content-Type:text/html;charset=utf-8' );
  1825. die ( '请填写联行号' );
  1826. }
  1827. Doo::loadModel ( 'execute' );
  1828. $execute = new execute ();
  1829. $executeDetail = $execute->getOne ( array (
  1830. 'where' => 'mold="培训班结算"',
  1831. 'asArray' => true
  1832. ) );
  1833. if (empty ( $executeDetail )) {
  1834. header ( 'Content-Type:text/html;charset=utf-8' );
  1835. die ( '未设置执行人' );
  1836. }
  1837. Doo::loadClass ( 'XDeode' );
  1838. $XDeode = new XDeode ( 5 );
  1839. $cid = $XDeode->decode ( $cid );
  1840. Doo::loadModel ( 'receipt' );
  1841. $receipt = new receipt ();
  1842. Doo::loadModel ( 'receiptTraining' );
  1843. $receiptTraining = new receiptTraining ();
  1844. // 创建费用培训班
  1845. $item = array (
  1846. 'cid' => $this->staff [0] ['cid'],
  1847. 'categoryName' => $this->staff [0] ['category'],
  1848. 'trainName' => $trainName,
  1849. 'trainStartDate' => $trainStartDate,
  1850. 'trainEndDate' => $trainEndDate,
  1851. 'participants' => $participants,
  1852. 'freeParticipants'=>$freeParticipants,
  1853. 'trainAddress' => $trainAddress,
  1854. 'trainRemarks' => $trainRemarks,
  1855. 'creator' => $this->staff [0] ['sid'],
  1856. 'creatorDate' => date ( "Y-m-d H:i:s" )
  1857. );
  1858. $irid = $receiptTraining->addReceiptTraining ( $item );
  1859. // 报销单
  1860. $receipt->status = 5;
  1861. $receipt->trainId = $irid;
  1862. $receipt->Rtype = 3;
  1863. $receipt->staff = $this->staff [0] ['sid'];
  1864. $receipt->cid = $cid;
  1865. $receipt->verify = $verify;
  1866. $receipt->date = date ( "Y-m-d" );
  1867. $receipt->executeCopy = $executeDetail ['staff'];
  1868. $receipt->receiptOrder = "#P" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1869. $receipt->remittanceName = $remittanceName;
  1870. $receipt->bankName = $bankName;
  1871. $receipt->bankNumber = $bankNumber;
  1872. $receipt->remittanceBankType = $remittanceBankType;
  1873. if ($remittanceBankType == 1)
  1874. $receipt->coupletNumber = $coupletNumber;
  1875. $rid = $receipt->insert ();
  1876. $XDeode = new XDeode ( 7 );
  1877. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html";
  1878. } else
  1879. die ( 'illegal request' );
  1880. }
  1881. /**
  1882. * 培训班编辑
  1883. */
  1884. function receiptTrainEdi() {
  1885. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  1886. $trainEdiType = $this->get_args ( 'trainEdiType' ) ? $this->get_args ( 'trainEdiType' ) : "INFO";
  1887. Doo::loadClass ( 'XDeode' );
  1888. $XDeode = new XDeode ( 7 );
  1889. $rid = $XDeode->decode ( $ridKey );
  1890. if (! is_numeric ( $rid ))
  1891. die ( 'illegal request' );
  1892. Doo::loadModel ( 'receipt' );
  1893. $receipt = new receipt ();
  1894. Doo::loadModel ( 'receiptTraining' );
  1895. $receiptTraining = new receiptTraining ();
  1896. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  1897. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)){
  1898. die ('illegal request--status');
  1899. }
  1900. //如有已入账已收款的发票,自动取消办事处已收款
  1901. // Doo::loadModel ( 'RIExtend' );
  1902. // $RIExtend = new RIExtend ();
  1903. // $RIExtendList=$RIExtend->getRIExtendByRid($rid);
  1904. // if (!empty($RIExtendList)){
  1905. // foreach ($RIExtendList as $key=>$value){
  1906. // $RIExtend = new RIExtend ();
  1907. // $RIExtend->delete(array (
  1908. // 'where' => 'iid=' . $value['iid'],
  1909. // 'limit' => 1
  1910. // ));
  1911. // }
  1912. // }
  1913. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  1914. // 汇总表合计
  1915. // 收入合计--加入开票合计
  1916. Doo::loadModel ( 'invoiceTraining' );
  1917. $invoiceTraining = new invoiceTraining ();
  1918. $invoiceTrainingDetail = array (
  1919. 'invoiceArriveAmount' => 0,
  1920. 'RIAmount' => 0,
  1921. 'invoiceTotalAmount' => 0,
  1922. 'invoiceCompanyAmount'=>0
  1923. );
  1924. if ($receiptDetail ['invoiceTrainId'] != 0) {
  1925. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  1926. }
  1927. // print_r($invoiceTrainingDetail);
  1928. $invoiceArriveAmount = $RIAmount = 0;
  1929. if (! empty ( $invoiceTrainingDetail )) {
  1930. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  1931. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  1932. }
  1933. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  1934. //print_r($invoiceTrainingDetail);
  1935. // 支出项目
  1936. Doo::loadModel ( 'accountItem' );
  1937. $accountItem = new accountItem ();
  1938. // 项目金额合计
  1939. Doo::loadModel ( 'RItem' );
  1940. $RItem = new RItem ();
  1941. // 讲师获得
  1942. Doo::loadModel ( 'RILecturer' );
  1943. $RILecturer = new RILecturer ();
  1944. $RItemList = $RItem->getRItemByRid ( $rid );
  1945. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  1946. // 支出项金额详情
  1947. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  1948. // print_r($aiData);
  1949. // 利润
  1950. $profit=$invoiceArriveAmount - $aiData ['total'];
  1951. $companyProfit=$profit * 0.6;
  1952. $categoryProfit=$profit * 0.4;
  1953. $data ['profit'] = sprintf("%.2f",$profit);
  1954. $data ['companyProfit'] = sprintf("%.2f",$companyProfit);
  1955. $data ['categoryProfit'] = sprintf("%.2f",$categoryProfit);
  1956. //发票利润
  1957. $data ['invoiceProfit'] = $invoiceTrainingDetail ['invoiceTotalAmount'] - $aiData ['total'];
  1958. //发票公司利润
  1959. $invoiceCompanyProfit=$data ['invoiceProfit'] * 0.6;
  1960. $data ['invoiceCompanyProfit'] = sprintf("%.2f",$invoiceCompanyProfit);
  1961. //办事处利润
  1962. $invoiceCategoryProfit=$data ['invoiceProfit'] * 0.4;
  1963. $data ['invoiceCategoryProfit'] = sprintf("%.2f",$invoiceCategoryProfit);
  1964. // print_r($aiData['dataList']);
  1965. $categoryActualExpenditure= $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  1966. $data ['categoryActualExpenditure'] = sprintf("%.2f",$categoryActualExpenditure);
  1967. // 备用金
  1968. $sum = 0;
  1969. $data ['receiptLoanDetail'] = array (
  1970. 'sum' => '0.00'
  1971. );
  1972. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  1973. //$data ['receiptLoanDetail'] = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  1974. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  1975. $sum=0;
  1976. foreach ($receiptLoanList as $key=>$value){
  1977. $sum+=$value['sum'];
  1978. }
  1979. $data ['receiptLoanDetail'] = array (
  1980. 'sum' => $sum
  1981. );
  1982. //$sum = $data ['receiptLoanDetail'] ['sum'];
  1983. }
  1984. $payment=$sum + $RIAmount - $categoryActualExpenditure;
  1985. $data ['payment'] = sprintf("%.2f",$payment);
  1986. $data ['total'] = sprintf("%.2f",$aiData ['total']);
  1987. $data ['aiCount'] = count ( $aiData ['dataList'] ) + 5;
  1988. $data ['aiList'] = $aiData ['dataList'];
  1989. // 占比计算
  1990. if ($invoiceArriveAmount != 0) {
  1991. $data ['totalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceArriveAmount* 100) ;
  1992. $data ['profitProportion'] = sprintf("%.2f",$profit / $invoiceArriveAmount*100) ; //number_format ( $profit / $invoiceArriveAmount, 2, '.', '' ) * 100;
  1993. $data ['sumProportion'] = sprintf("%.2f",$sum / $invoiceArriveAmount*100) ; //number_format ( $sum / $invoiceArriveAmount, 2, '.', '' ) * 100;
  1994. $data ['invoiceTotalAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceArriveAmount*100) ;
  1995. $data ['RIAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceArriveAmount*100) ;
  1996. $data ['companyProfitProportion'] = sprintf("%.2f",$companyProfit / $invoiceArriveAmount*100) ;
  1997. $data ['categoryProportion'] = sprintf("%.2f",$categoryProfit / $invoiceArriveAmount*100) ;
  1998. $data ['categoryActualExpenditureProportion'] = sprintf("%.2f",$categoryActualExpenditure / $invoiceArriveAmount*100) ;
  1999. $data ['paymentProportion'] = sprintf("%.2f",$payment / $invoiceArriveAmount*100) ;
  2000. } else {
  2001. $data ['totalProportion'] = $data ['profitProportion'] = $data ['sumProportion'] = $data ['invoiceTotalAmountProportion'] = $data ['RIAmountProportion'] = $data ['companyProfitProportion'] = $data ['categoryActualExpenditureProportion'] = $data ['paymentProportion'] = $data ['categoryProportion'] = 0;
  2002. }
  2003. //发票金额占比计算
  2004. if ($invoiceTrainingDetail ['invoiceTotalAmount'] != 0) {
  2005. //支出
  2006. $data ['invoicetotalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2007. //利润
  2008. $data ['invoiceprofitProportion'] = sprintf("%.2f",$data ['invoiceProfit'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2009. //公司利润
  2010. $data ['invoicecompanyProfitProportion'] = sprintf("%.2f", $invoiceCompanyProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2011. //办事处利润
  2012. $data ['invoicecategoryProportion'] = sprintf("%.2f", $invoiceCategoryProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2013. //公司收款
  2014. $data ['invoiceTotalAmountProportionB'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2015. //备用金
  2016. $data ['invoicesumProportion'] = sprintf("%.2f", $sum / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2017. //办事处收款
  2018. $data ['invoiceRIAmountProportion'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2019. //办事处实际支出
  2020. $data ['ICAEP'] = sprintf("%.2f", $categoryActualExpenditure / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2021. //付总部款
  2022. $data ['invoicepaymentProportion'] = sprintf("%.2f", $payment / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2023. }else{
  2024. $data ['invoiceprofitProportion'] =$data ['invoiceRIAmountProportion'] =$data ['invoicetotalProportion'] =$data ['invoiceTotalAmountProportionB'] =$data ['invoicesumProportion'] =$data ['ICAEP'] =$data ['invoicepaymentProportion'] =$data ['invoicecompanyProfitProportion'] =$data ['invoicecategoryProportion'] =0;
  2025. }
  2026. //讲师人数
  2027. Doo::loadModel ( 'RILecturer' );
  2028. $RILecturer = new RILecturer ();
  2029. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2030. $data['lectureCount']=count($RILecturerList);
  2031. // 审批组
  2032. Doo::loadModel ( 'verify' );
  2033. $verify = new verify ();
  2034. $veList = $verify->getVerifyBySubordinate('TRAIN');
  2035. // 办事处
  2036. Doo::loadModel ( 'L_category' );
  2037. $lCategory = new L_category ();
  2038. $data ['category'] = $lCategory->getCategory ();
  2039. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2040. $data ['receiptDetail'] = $receiptDetail;
  2041. $data ['veList'] = $veList;
  2042. $data ['trainEdiType'] = $trainEdiType;
  2043. $data ['ridKey'] = $ridKey;
  2044. $data ['memu'] = "receipt";
  2045. $data ['staff'] = $this->staff;
  2046. $data ['receiptMemu'] = 'saeaBorad';
  2047. $data ['verifyId'] = $this->verifyId;
  2048. $data ['executeId'] = $this->executeId;
  2049. $this->render ( "/receipt/receiptTrainEdi", $data );
  2050. }
  2051. /**
  2052. * 培训班借款编辑
  2053. */
  2054. function receiptTrainLoanEdi() {
  2055. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2056. Doo::loadClass ( 'XDeode' );
  2057. $XDeode = new XDeode ( 7 );
  2058. $rid = $XDeode->decode ( $ridKey );
  2059. if (! is_numeric ( $rid ))
  2060. die ( 'illegal request' );
  2061. Doo::loadModel ( 'receipt' );
  2062. $receipt = new receipt ();
  2063. Doo::loadModel ( 'receiptTraining' );
  2064. $receiptTraining = new receiptTraining ();
  2065. Doo::loadModel ( 'verify' );
  2066. $verify = new verify ();
  2067. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2068. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  2069. die ();
  2070. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2071. // 借款详情HTML
  2072. // 获得借款信息
  2073. $receiptLoanHtml = '';
  2074. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  2075. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2076. foreach ($receiptLoanList as $key=>$value){
  2077. // 获得某费用单审批信息
  2078. $verifylist = $verify->getVerifyByRid ( $value ['rid'] );
  2079. Doo::loadClass ( 'receipt.func' );
  2080. $extendHtml = '<p><a class="button"
  2081. href="javascript:if(window.confirm(\'确认移除?\'))window.location=\'/receiptTrainLoanRemoveDo/' . $receiptDetail ['ridKey'] . '/' . $value ['ridKey'] . '.html\'" data-toggle="modal">移除借款</a></p>';
  2082. $receiptLoanHtml .= _getReceiptLoanHtml ( $value, $verifylist, $extendHtml );
  2083. }
  2084. }
  2085. $data ['receiptLoanHtml'] = $receiptLoanHtml;
  2086. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2087. $data ['receiptDetail'] = $receiptDetail;
  2088. $data ['trainEdiType'] = "LOAN";
  2089. $data ['ridKey'] = $ridKey;
  2090. $data ['memu'] = "receipt";
  2091. $data ['staff'] = $this->staff;
  2092. $data ['receiptMemu'] = 'saeaBorad';
  2093. $data ['verifyId'] = $this->verifyId;
  2094. $data ['executeId'] = $this->executeId;
  2095. $this->render ( "/receipt/receiptTrainLoanEdi", $data );
  2096. }
  2097. /**
  2098. * 更新培训班结算基本信息
  2099. */
  2100. function receiptTrainInfoEdiDo() {
  2101. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  2102. $rtid = $this->get_args ( 'rtid' ) ? $this->get_args ( 'rtid' ) : "";
  2103. // 培训班信息
  2104. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  2105. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  2106. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  2107. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  2108. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  2109. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  2110. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  2111. // 发票信息
  2112. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2113. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2114. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2115. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2116. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2117. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2118. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2119. //&& ! empty ( $participants )
  2120. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  2121. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2122. header ( 'Content-Type:text/html;charset=utf-8' );
  2123. die ( '请填写联行号' );
  2124. }
  2125. Doo::loadClass ( 'XDeode' );
  2126. $XDeode = new XDeode ( 5 );
  2127. $cid = $XDeode->decode ( $cid );
  2128. $rtid = $XDeode->decode ( $rtid );
  2129. $rid = $XDeode->decode ( $rid );
  2130. if (! is_numeric ( $rtid ) || ! is_numeric ( $rid )) {
  2131. die ( 'illegal request-IdError' );
  2132. }
  2133. Doo::loadModel ( 'receipt' );
  2134. $receipt = new receipt ();
  2135. Doo::loadModel ( 'receiptTraining' );
  2136. $receiptTraining = new receiptTraining ();
  2137. // 更新费用培训班
  2138. $item = array (
  2139. 'rtid' => $rtid,
  2140. 'trainName' => $trainName,
  2141. 'trainStartDate' => $trainStartDate,
  2142. 'trainEndDate' => $trainEndDate,
  2143. 'participants' => $participants,
  2144. 'freeParticipants'=>$freeParticipants,
  2145. 'trainAddress' => $trainAddress,
  2146. 'trainRemarks' => $trainRemarks
  2147. );
  2148. $irid = $receiptTraining->setReceiptTrainByCondition ( $item );
  2149. // 报销单
  2150. $receipt->rid = $rid;
  2151. $receipt->cid = $cid;
  2152. $receipt->verify = $verify;
  2153. $receipt->remittanceName = $remittanceName;
  2154. $receipt->bankName = $bankName;
  2155. $receipt->bankNumber = $bankNumber;
  2156. $receipt->remittanceBankType = $remittanceBankType;
  2157. if ($remittanceBankType == 1)
  2158. $receipt->coupletNumber = $coupletNumber;
  2159. $receipt->update ();
  2160. $XDeode = new XDeode ( 7 );
  2161. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html?trainEdiType=INFO";
  2162. } else
  2163. die ( 'illegal request' );
  2164. }
  2165. /**
  2166. * 编辑培训班结算---更新借款
  2167. */
  2168. function receiptTrainLoanEdiDo() {
  2169. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2170. $ridLoanKey = $this->get_args ( 'ridLoanKey' ) ? $this->get_args ( 'ridLoanKey' ) : "";
  2171. if (! empty ( $ridKey ) && ! empty ( $ridLoanKey )) {
  2172. Doo::loadModel ( 'receipt' );
  2173. $receipt = new receipt ();
  2174. Doo::loadClass ( 'XDeode' );
  2175. $XDeode = new XDeode ( 5 );
  2176. $rid = $XDeode->decode ( $ridKey );
  2177. $ridLoan = $XDeode->decode ( $ridLoanKey );
  2178. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  2179. die ( 'illegal request-ridError' );
  2180. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2181. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  2182. // 不合法的数据if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  2183. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2184. die ( 'illegal request-receiptError' );
  2185. }
  2186. if ($receiptLoanDetail ['status'] != 8 || $receiptLoanDetail ['Rtype'] != 1) {
  2187. die ( 'illegal request-receipLoantError' );
  2188. }
  2189. // 培训班结算挂钩借款
  2190. $receipt = new receipt ();
  2191. $trainLoanRid=$ridLoan;
  2192. if (!empty($receiptDetail['trainLoanRid'])){
  2193. $trainLoanRid=$receiptDetail['trainLoanRid'].','.$ridLoan;
  2194. }
  2195. $item = array (
  2196. 'rid' => $rid,
  2197. 'trainLoanRid' => $trainLoanRid
  2198. );
  2199. $receipt->setReceiptByCondition ( $item );
  2200. // 更新借款状态变成已挂钩
  2201. $receipt = new receipt ();
  2202. $item = array (
  2203. 'rid' => $ridLoan,
  2204. 'status' => 10,
  2205. 'statusTrain' => 1
  2206. );
  2207. $receipt->setReceiptByCondition ( $item );
  2208. $XDeode = new XDeode ( 7 );
  2209. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  2210. } else
  2211. die ( 'illegal request' );
  2212. }
  2213. /**
  2214. * 编辑培训班结算--移除借款
  2215. */
  2216. function receiptTrainLoanRemoveDo() {
  2217. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : 0;
  2218. $ridLoanKey = isset ( $this->params ['ridLoanKey'] ) ? $this->params ['ridLoanKey'] : 0;
  2219. if (! empty ( $ridKey ) || ! empty ( $ridLoanKey )) {
  2220. Doo::loadModel ( 'receipt' );
  2221. $receipt = new receipt ();
  2222. Doo::loadClass ( 'XDeode' );
  2223. $XDeode = new XDeode ( 5 );
  2224. $rid = $XDeode->decode ( $ridKey );
  2225. $ridLoan = $XDeode->decode ( $ridLoanKey );
  2226. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  2227. die ( 'illegal request-ridError' );
  2228. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2229. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  2230. // 不合法的数据 !($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)
  2231. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2232. die ( 'illegal request-receiptError' );
  2233. }
  2234. if ($receiptLoanDetail ['status'] != 10 || $receiptLoanDetail ['Rtype'] != 1) {
  2235. die ( 'illegal request-receipLoantError' );
  2236. }
  2237. // 培训班结算挂钩借款
  2238. $receipt = new receipt ();
  2239. $trainLoanRidArray=explode(",", $receiptDetail['trainLoanRid']);
  2240. foreach ($trainLoanRidArray as $key=>$value){
  2241. if($value==$ridLoan){
  2242. unset($trainLoanRidArray[$key]);
  2243. }
  2244. }
  2245. $trainLoanRidString=implode(",", $trainLoanRidArray);
  2246. $item = array (
  2247. 'rid' => $rid,
  2248. 'trainLoanRid' => $trainLoanRidString
  2249. );
  2250. $receipt->setReceiptByCondition ( $item );
  2251. // 更新借款状态变成已挂钩
  2252. $receipt = new receipt ();
  2253. $item = array (
  2254. 'rid' => $ridLoan,
  2255. 'status' => 8,
  2256. 'statusTrain' => 0
  2257. );
  2258. $receipt->setReceiptByCondition ( $item );
  2259. $XDeode = new XDeode ( 7 );
  2260. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  2261. } else
  2262. die ( 'illegal request' );
  2263. }
  2264. /**
  2265. * 编辑培训班结算 ---开票
  2266. */
  2267. function receiptTrainInvoiceEdi() {
  2268. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2269. Doo::loadClass ( 'XDeode' );
  2270. $XDeode = new XDeode ( 7 );
  2271. $rid = $XDeode->decode ( $ridKey );
  2272. if (! is_numeric ( $rid ))
  2273. die ( 'illegal request' );
  2274. Doo::loadModel ( 'receipt' );
  2275. $receipt = new receipt ();
  2276. Doo::loadModel ( 'receiptTraining' );
  2277. $receiptTraining = new receiptTraining ();
  2278. Doo::loadModel ( 'invoice' );
  2279. $invoice = new invoice ();
  2280. Doo::loadModel ( 'invoiceTraining' );
  2281. $invoiceTraining = new invoiceTraining ();
  2282. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2283. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  2284. die ();
  2285. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2286. $invoiceList = $invoiceTrainingDetail = array ();
  2287. if ($receiptDetail ['invoiceTrainId'] != 0) {
  2288. $invoiceList = $invoice->getInvoicePrintedByItid ( $receiptDetail ['invoiceTrainId'] );
  2289. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  2290. }
  2291. //print_r($invoiceList);
  2292. $data ['invoiceList'] = $invoiceList;
  2293. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  2294. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2295. $data ['receiptDetail'] = $receiptDetail;
  2296. $data ['trainEdiType'] = "INVOICE";
  2297. $data ['ridKey'] = $ridKey;
  2298. $data ['memu'] = "receipt";
  2299. $data ['staff'] = $this->staff;
  2300. $data ['receiptMemu'] = 'saeaBorad';
  2301. $data ['verifyId'] = $this->verifyId;
  2302. $data ['executeId'] = $this->executeId;
  2303. $this->render ( "/receipt/receiptTrainInvoiceEdi", $data );
  2304. }
  2305. /**
  2306. * 编辑培训班结算---更新开票
  2307. */
  2308. function receiptTrainInvoiceEdiDo() {
  2309. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2310. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : "";
  2311. if (! empty ( $ridKey ) && ! empty ( $itidKey )) {
  2312. Doo::loadModel ( 'receipt' );
  2313. $receipt = new receipt ();
  2314. Doo::loadModel ( 'invoiceTraining' );
  2315. $invoiceTraining = new invoiceTraining ();
  2316. Doo::loadClass ( 'XDeode' );
  2317. $XDeode = new XDeode ( 5 );
  2318. $rid = $XDeode->decode ( $ridKey );
  2319. $itid = $XDeode->decode ( $itidKey );
  2320. if (! is_numeric ( $rid ) || ! is_numeric ( $itid ))
  2321. die ( 'illegal request-idError' );
  2322. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2323. $invoiceTrainDetail = $invoiceTraining->getInvoiceTrainingByItid ( $itid );
  2324. // 不合法的数据
  2325. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2326. die ( 'illegal request-receiptError' );
  2327. }
  2328. if (empty ( $invoiceTrainDetail ) || $invoiceTrainDetail ['bindReceipt'] == 1) {
  2329. die ( 'illegal request-receipLoantError' );
  2330. }
  2331. // 培训班结算挂钩借款
  2332. $receipt = new receipt ();
  2333. $item = array (
  2334. 'rid' => $rid,
  2335. 'invoiceTrainId' => $itid
  2336. );
  2337. $receipt->setReceiptByCondition ( $item );
  2338. $invoiceTraining = new invoiceTraining ();
  2339. $item = array (
  2340. 'bindReceipt' => 1,
  2341. 'itid' => $itid
  2342. );
  2343. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  2344. $XDeode = new XDeode ( 7 );
  2345. return "/receiptTrainInvoiceEdi/" . $XDeode->encode ( $rid ) . ".html";
  2346. } else
  2347. die ( 'illegal request' );
  2348. }
  2349. /**
  2350. * 更新培训班结算 收款和取消收款
  2351. */
  2352. function receiptTrainReceivables() {
  2353. $doType = isset ( $this->params ['doType'] ) ? $this->params ['doType'] : '';
  2354. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2355. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  2356. Doo::loadClass ( 'XDeode' );
  2357. $XDeode = new XDeode ( 5 );
  2358. $rid = $XDeode->decode ( $ridKey );
  2359. $iid = $XDeode->decode ( $iidKey );
  2360. if (! is_numeric ( $rid ) || ! is_numeric ( $iid ))
  2361. die ( 'illegal request-iid' );
  2362. Doo::loadModel ( 'RIExtend' );
  2363. $RIExtend = new RIExtend ();
  2364. if ($doType == 'CONFIRM') {
  2365. $RIExtend->rid = $rid;
  2366. $RIExtend->iid = $iid;
  2367. $RIExtend->RIstatus = 1;
  2368. $RIExtend->insert ();
  2369. echo json_encode ( array (
  2370. 'status' => 1,
  2371. ) );
  2372. die ( );
  2373. } elseif ($doType == 'CANCEL') {
  2374. $RIExtend->delete ( array (
  2375. 'where' => 'rid=' . $rid . ' and iid=' . $iid,
  2376. 'limit' => 1
  2377. ) );
  2378. echo json_encode ( array (
  2379. 'status' => 1,
  2380. ) );
  2381. die ( );
  2382. } else {
  2383. echo json_encode ( array (
  2384. 'status' => 2,
  2385. ) );
  2386. die ( );
  2387. }
  2388. }
  2389. /**
  2390. * 移除挂钩的培训班发票
  2391. */
  2392. function receiptTrainReceivablesDelDo() {
  2393. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  2394. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : ""; // 发票培训班
  2395. Doo::loadModel ( 'receipt' );
  2396. $receipt = new receipt ();
  2397. Doo::loadModel ( 'RIExtend' );
  2398. $RIExtend = new RIExtend ();
  2399. Doo::loadClass ( 'XDeode' );
  2400. $XDeode = new XDeode ( 5 );
  2401. $rid = $XDeode->decode ( $ridKey );
  2402. $itid = $XDeode->decode ( $itidKey );
  2403. if (is_numeric ( $rid ) && is_numeric ( $itid )) {
  2404. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2405. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  2406. die ( 'illegal request-status' );
  2407. }
  2408. $receipt = new receipt ();
  2409. $receipt->rid = $rid;
  2410. $receipt->invoiceTrainId = 0;
  2411. $receipt->update ();
  2412. Doo::loadModel ( 'invoiceTraining' );
  2413. $invoiceTraining = new invoiceTraining ();
  2414. $item = array (
  2415. 'bindReceipt' => 0,
  2416. 'itid' => $itid
  2417. );
  2418. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  2419. $RIExtend->delete ( array (
  2420. 'where' => 'rid=' . $rid
  2421. ) );
  2422. $XDeode = new XDeode ( 7 );
  2423. return '/receiptTrainInvoiceEdi/' . $XDeode->encode ( $rid ) . '.html';
  2424. } else
  2425. die ( 'illegal request-iid' );
  2426. }
  2427. /**
  2428. * 编辑培训班结算
  2429. */
  2430. function receiptTrainItemEdi() {
  2431. //include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  2432. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2433. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : '';
  2434. Doo::loadClass ( 'XDeode' );
  2435. $XDeode = new XDeode ( 7 );
  2436. $rid = $XDeode->decode ( $ridKey );
  2437. if (! is_numeric ( $rid ))
  2438. die ( 'illegal request' );
  2439. Doo::loadModel ( 'receipt' );
  2440. $receipt = new receipt ();
  2441. Doo::loadModel ( 'receiptTraining' );
  2442. $receiptTraining = new receiptTraining ();
  2443. Doo::loadModel ( 'RItem' );
  2444. $RItem = new RItem ();
  2445. Doo::loadModel ( 'accountItem' );
  2446. $accountItem = new accountItem ();
  2447. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2448. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  2449. die ();
  2450. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2451. $RItemList = $RItem->getRItemByRid ( $rid,$name );
  2452. $aiList = $accountItem->getAccountBookByCategory ( '培训班费用' );//print_r($aiList);
  2453. // foreach ($aiList as $key=>$value){//不需要添加税款,在添加收入时自动添加
  2454. // if($value['name']=='税款'){
  2455. // unset($aiList[$key]);break;
  2456. // }
  2457. // }
  2458. //print_r($RItemList);
  2459. $data ['name'] = $name;
  2460. $data ['RItemList'] = $RItemList;
  2461. $data ['aiList'] = $aiList;
  2462. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2463. $data ['receiptDetail'] = $receiptDetail;
  2464. $data ['trainEdiType'] = "ITEM";
  2465. $data ['ridKey'] = $ridKey;
  2466. $data ['memu'] = "receipt";
  2467. $data ['staff'] = $this->staff;
  2468. $data ['receiptMemu'] = 'saeaBorad';
  2469. $data ['verifyId'] = $this->verifyId;
  2470. $data ['executeId'] = $this->executeId;
  2471. $this->render ( "/receipt/receiptTrainItemEdi", $data );
  2472. }
  2473. /**
  2474. * 添加支出项 需要修改 费用金额合计
  2475. */
  2476. function receiptTrainItemAddDo() {
  2477. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2478. $rtidKey = $this->get_args ( 'rtidKey' ) ? $this->get_args ( 'rtidKey' ) : "";
  2479. // 支出项信息
  2480. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  2481. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : 0;
  2482. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  2483. $inputer = $this->get_args ( 'inputer' ) ? $this->get_args ( 'inputer' ) : "";
  2484. $describe = $this->get_args ( 'describe' ) ? $this->get_args ( 'describe' ) : "";
  2485. //$identifyingTotal = $this->get_args ( 'identifyingTotal' )&&is_numeric($this->get_args ( 'identifyingTotal' )) ? $this->get_args ( 'identifyingTotal' ) : 0;
  2486. $payType = isset ( $this->params ['payType'] ) ? $this->params ['payType'] : '';
  2487. if (! empty ( $ridKey ) && ! empty ( $item ) && is_numeric( $price ) && ! empty ( $date ) && ! empty ( $inputer )) {
  2488. Doo::loadClass ( 'XDeode' );
  2489. $XDeode = new XDeode ( 5 );
  2490. Doo::loadModel ( 'RItem' );
  2491. $RItem = new RItem ();
  2492. $rid = $XDeode->decode ( $ridKey );
  2493. $rtid= $XDeode->decode ( $rtidKey );
  2494. if (! is_numeric ( $rid )){
  2495. die ( 'illegal request' );
  2496. }
  2497. Doo::loadModel ( 'receiptDetail' );
  2498. $receiptDetail = new receiptDetail ();
  2499. Doo::loadModel ( 'receipt' );
  2500. $receipt = new receipt ();
  2501. Doo::loadModel ( 'receiptTraining' );
  2502. $receiptTraining = new receiptTraining ();
  2503. $rtDetail=$receiptTraining->getReceiptTrainingByRtid($rtid);
  2504. $identifyingTotal=$rtDetail['identifyingTotal']+1;
  2505. $order = array (
  2506. "\r\n",
  2507. "\n",
  2508. "\r"
  2509. );
  2510. $replace = '<br/>';
  2511. $describe = str_replace ( $order, $replace, $describe );
  2512. $itemData = array (
  2513. 'rid' => $rid,
  2514. 'item' => $item,
  2515. 'price' => $price,
  2516. 'date' => $date,
  2517. 'inputer' => $inputer,
  2518. 'describe' => $describe,
  2519. 'creater' => $this->staff['0']['username'],
  2520. 'createrId' => $this->staff['0']['sid'],
  2521. 'creatDate' => date ( "Y-m-d H:i:s" ),
  2522. 'identifying'=>$identifyingTotal
  2523. );
  2524. if($payType=='company'){
  2525. $itemData += array (
  2526. 'payType' => 1
  2527. );
  2528. }
  2529. $RItem->addRItem($itemData, $receipt, $receiptDetail, $rid, $item, $price, $payType);
  2530. //更新支出项标识总数
  2531. $itemData = array (
  2532. 'rtid'=>$rtid,
  2533. 'identifyingTotal'=>$identifyingTotal
  2534. );
  2535. $receiptTraining->setReceiptTrainByCondition($itemData);
  2536. $XDeode = new XDeode ( 7 );
  2537. if($payType=='company'){
  2538. return '/receiptTrainItem/approval/' . $XDeode->encode ( $rid ) . '.html';
  2539. }else{
  2540. return '/receiptTrainItemEdi/' . $XDeode->encode ( $rid ) . '.html';
  2541. }
  2542. } else
  2543. die ( 'illegal request-dataError' );
  2544. }
  2545. /**
  2546. * 培训班结算-讲师
  2547. */
  2548. function receiptTrainLecturerEdi() {
  2549. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2550. Doo::loadClass ( 'XDeode' );
  2551. $XDeode = new XDeode ( 7 );
  2552. $rid = $XDeode->decode ( $ridKey );
  2553. if (! is_numeric ( $rid ))
  2554. die ( 'illegal request' );
  2555. Doo::loadModel ( 'receipt' );
  2556. $receipt = new receipt ();
  2557. Doo::loadModel ( 'receiptTraining' );
  2558. $receiptTraining = new receiptTraining ();
  2559. Doo::loadModel ( 'RILecturer' );
  2560. $RILecturer = new RILecturer ();
  2561. Doo::loadModel ( 'lecturer' );
  2562. $lecturer = new lecturer ();
  2563. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2564. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  2565. die ();
  2566. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2567. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2568. $lecturerList = $lecturer->getLecturerAll ();
  2569. $INSIDEhtml = $OUTSIDEhtml = '';
  2570. foreach ( $lecturerList as $key => $value ) {
  2571. if ($value ['ltype'] == 'INSIDE') {
  2572. $INSIDEhtml .= '<option value="' . $value ['category'] . '-' . $value ['staff'] . '">' . $value ['category'] . '-' . $value ['staff'] . '</option>';
  2573. } elseif ($value ['ltype'] == 'OUTSIDE') {
  2574. $OUTSIDEhtml .= '<option value="' . $value ['staff'] . '">' . $value ['staff'] . '</option>';
  2575. }
  2576. }
  2577. $data ['INSIDEhtml'] = $INSIDEhtml;
  2578. $data ['OUTSIDEhtml'] = $OUTSIDEhtml;
  2579. // print_r($RItemList);
  2580. $data ['RILecturerList'] = $RILecturerList;
  2581. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2582. $data ['receiptDetail'] = $receiptDetail;
  2583. $data ['trainEdiType'] = "LECTURER";
  2584. $data ['ridKey'] = $ridKey;
  2585. $data ['memu'] = "receipt";
  2586. $data ['staff'] = $this->staff;
  2587. $data ['receiptMemu'] = 'saeaBorad';
  2588. $data ['verifyId'] = $this->verifyId;
  2589. $data ['executeId'] = $this->executeId;
  2590. $this->render ( "/receipt/receiptTrainLecturerEdi", $data );
  2591. }
  2592. /**
  2593. * 添加讲师
  2594. */
  2595. function receiptTrainLecturerAddDo() {
  2596. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2597. // 支出项信息
  2598. $ltype = $this->get_args ( 'ltype' ) ? $this->get_args ( 'ltype' ) : "";
  2599. $lecturerName = $this->get_args ( 'lecturerName' ) ? $this->get_args ( 'lecturerName' ) : "";
  2600. $schoolDay = $this->get_args ( 'schoolDay' ) ? $this->get_args ( 'schoolDay' ) : "";
  2601. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  2602. $taxation = $this->get_args ( 'taxation' ) ? $this->get_args ( 'taxation' ) : "";
  2603. $fees = $this->get_args ( 'fees' ) ? $this->get_args ( 'fees' ) : "";
  2604. if (! empty ( $ridKey ) && ! empty ( $ltype ) && ! empty ( $lecturerName ) && ! empty ( $schoolDay ) && ! empty ( $price )) {
  2605. Doo::loadClass ( 'XDeode' );
  2606. $XDeode = new XDeode ( 5 );
  2607. Doo::loadModel ( 'RILecturer' );
  2608. $RILecturer = new RILecturer ();
  2609. $rid = $XDeode->decode ( $ridKey );
  2610. if (! is_numeric ( $rid ))
  2611. die ( 'illegal request' );
  2612. if ($ltype == 'OUTSIDE' && empty ( $taxation ))
  2613. die ( 'illegal request-taxationError' );
  2614. $RILecturer->rid = $rid;
  2615. $RILecturer->ltype = $ltype;
  2616. if ($ltype == 'OUTSIDE') {
  2617. if ($taxation == 'TAXATION') {
  2618. $RILecturer->taxation = 1;
  2619. } elseif ($taxation == 'NOTAXATION') {
  2620. $RILecturer->taxation = 0;
  2621. }
  2622. }
  2623. $RILecturer->lecturerName = $lecturerName;
  2624. $RILecturer->schoolDay = $schoolDay;
  2625. $RILecturer->price = $price;
  2626. $RILecturer->fees=$fees;
  2627. $RILecturer->insert ();
  2628. // 添加公司汇总
  2629. // 报销详情
  2630. Doo::loadModel ( 'receiptDetail' );
  2631. $receiptDetail = new receiptDetail ();
  2632. Doo::loadModel ( 'receipt' );
  2633. $receipt = new receipt ();
  2634. // 金额总计
  2635. $price = $price * $schoolDay;
  2636. $rInfo = $receipt->getReceiptByRid ( $rid );
  2637. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  2638. if (empty ( $rdInfo )) {
  2639. $receiptDetail = new receiptDetail ();
  2640. $receiptDetail->staff = $rInfo ['staff'];
  2641. $receiptDetail->item = '讲课费';
  2642. $receiptDetail->itemCategory = '培训班费用';
  2643. $receiptDetail->price = number_format ( $fees, 2, '.', '' );
  2644. $receiptDetail->date = date ( "Y-m-d" );
  2645. $receiptDetail->cid = $rInfo ['cid'];
  2646. $receiptDetail->rid = $rid;
  2647. $receiptDetail->status = 4;
  2648. $receiptDetail->insert ();
  2649. } else {
  2650. $receiptDetail = new receiptDetail ();
  2651. $rdInfo ['price'] += $fees;
  2652. $receiptDetail->price = $rdInfo ['price'];
  2653. $receiptDetail->update ( array (
  2654. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  2655. ) );
  2656. }
  2657. $receipt = new receipt ();
  2658. $receipt->sum=$rInfo['sum']+$fees;
  2659. $receipt->update ( array (
  2660. 'where' => 'rid=' . $rid
  2661. ) );
  2662. $XDeode = new XDeode ( 7 );
  2663. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  2664. } else
  2665. die ( 'illegal request' );
  2666. }
  2667. /**
  2668. * 移除讲师
  2669. */
  2670. function receiptTrainLecturerDelDo() {
  2671. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  2672. $rlidKey = $this->get_args ( 'rlidKey' ) ? $this->get_args ( 'rlidKey' ) : ""; // 发票培训班
  2673. Doo::loadModel ( 'receipt' );
  2674. $receipt = new receipt ();
  2675. Doo::loadModel ( 'RILecturer' );
  2676. $RILecturer = new RILecturer ();
  2677. Doo::loadClass ( 'XDeode' );
  2678. $XDeode = new XDeode ( 5 );
  2679. $rid = $XDeode->decode ( $ridKey );
  2680. $rlid = $XDeode->decode ( $rlidKey );
  2681. if (is_numeric ( $rid ) && is_numeric ( $rlid )) {
  2682. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2683. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  2684. die ( 'illegal request-status' );
  2685. }
  2686. $detail=$RILecturer->getRILecturerByRlid($rlid);
  2687. if (empty($detail)){
  2688. die ( 'illegal request-data' );
  2689. }
  2690. $RILecturer->delete ( array (
  2691. 'where' => 'rid=' . $rid . ' and rlid=' . $rlid
  2692. ) );
  2693. //更新费用合计金额
  2694. $rInfo = $receipt->getReceiptByRid ( $rid );
  2695. $receipt = new receipt ();
  2696. $receipt->sum= $receiptDetail['sum']-$detail['price'];
  2697. $receipt->update ( array (
  2698. 'where' => 'rid=' . $rid
  2699. ) );
  2700. Doo::loadModel ( 'receiptDetail' );
  2701. $receiptDetail = new receiptDetail ();
  2702. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  2703. $receiptDetail = new receiptDetail ();
  2704. $rdInfo ['price'] -= number_format ( $detail['price'], 2, '.', '' );
  2705. $receiptDetail->price = $rdInfo ['price'];
  2706. $receiptDetail->update ( array (
  2707. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  2708. ) );
  2709. $XDeode = new XDeode ( 7 );
  2710. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  2711. } else
  2712. die ( 'illegal request-iid' );
  2713. }
  2714. /**
  2715. * 培训班提交审批
  2716. */
  2717. function receiptTrainDo() {
  2718. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2719. Doo::loadClass ( 'XDeode' );
  2720. $XDeode = new XDeode ( 7 );
  2721. $rid = $XDeode->decode ( $ridKey );
  2722. Doo::loadModel ( 'receipt' );
  2723. $receipt = new receipt ();
  2724. Doo::loadModel ( 'receiptDetail' );
  2725. $receiptDetail = new receiptDetail ();
  2726. Doo::loadModel ( 'statistics' );
  2727. $statistics = new statistics ();
  2728. Doo::loadModel ( "verify" );
  2729. $verify = new verify ();
  2730. // 审批状态的判定
  2731. $receiptDetailList = $receipt->getOne ( array (
  2732. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  2733. 'asArray' => true
  2734. ) );
  2735. if (empty ( $receiptDetailList ))
  2736. return "/saeaBorad";
  2737. $verifyDetail = $verify->getOne ( array (
  2738. 'where' => ' vid =' . $receiptDetailList ['verify'],
  2739. 'asArray' => true
  2740. ) );
  2741. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  2742. if (empty ( $receiptDetailList ['nowStaff'] )) {
  2743. $nowStaff = "";
  2744. $nowStaffList = array ();
  2745. if ($verifyDetail [0] [1] == 'ROLE') {
  2746. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  2747. foreach ( $vStaffString as $key => $value ) {
  2748. $staffK = explode ( "_", $value );
  2749. array_push ( $nowStaffList, $staffK [0] );
  2750. }
  2751. $nowStaff = implode ( ',', $nowStaffList );
  2752. } else {
  2753. $nowStaff = $verifyDetail [0] [0];
  2754. }
  2755. $receipt->nowStaff = $nowStaff;
  2756. }
  2757. // echo $nowStaff;
  2758. // print_r($verifyDetail);die;
  2759. $receipt->rid = $receiptDetailList ['rid'];
  2760. $receipt->date = date ( "Y-m-d" );
  2761. $receipt->status = 2;
  2762. $receipt->update ();
  2763. $receiptDetail->status = 2;
  2764. $receiptDetail->update ( array (
  2765. 'where' => 'rid=' . $receiptDetailList ['rid']
  2766. ) );
  2767. Doo::loadModel ( "receiptLog" );
  2768. $receiptLog = new receiptLog ();
  2769. Doo::loadModel ( "verify" );
  2770. $verify = new verify ();
  2771. $vr = $verify->getOne ( array (
  2772. 'where' => 'vid=' . $receiptDetailList ['verify'],
  2773. 'asArray' => true
  2774. ) );
  2775. $jd = json_decode ( $vr ['staff'] );
  2776. $roleId = 0;
  2777. foreach ( $jd as $key => $value ) {
  2778. if ($value [1] == 'ROLE') {
  2779. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  2780. if ($pos !== false) {
  2781. $roleId = $value [0];
  2782. }
  2783. }
  2784. }
  2785. // 审批日志
  2786. // echo $roleId;die;
  2787. if (! empty ( $roleId )) {
  2788. Doo::loadModel ( "role" );
  2789. $role = new role ();
  2790. $roleInfo = $role->getOne ( array (
  2791. 'where' => 'rid=' . $roleId,
  2792. 'asArray' => true
  2793. ) );
  2794. // $receiptLog->rolename = $roleInfo ['name'];
  2795. }
  2796. $receiptLog->username = $this->staff [0] ['username'];
  2797. $receiptLog->uid = $this->staff [0] ['sid'];
  2798. $receiptLog->date = date ( "Y-m-d" );
  2799. $receiptLog->opinion = '提交审批';
  2800. $receiptLog->img = $this->staff [0] ['avatar'];
  2801. $receiptLog->status = 2;
  2802. $receiptLog->rid = $rid;
  2803. $receiptLog->insert ();
  2804. // 写入列表项
  2805. Doo::loadModel ( 'accountItem' );
  2806. $accountItem = new accountItem ();
  2807. $aItem = $accountItem->getAccountBookByCategory ( '培训班费用' );
  2808. // 项目金额合计
  2809. Doo::loadModel ( 'RItem' );
  2810. $RItem = new RItem ();
  2811. // 讲师获得
  2812. Doo::loadModel ( 'RILecturer' );
  2813. $RILecturer = new RILecturer ();
  2814. $RItemList = $RItem->getRItemByRid ( $rid );
  2815. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2816. // 支出项金额详情
  2817. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, 0 );
  2818. // print_r($aItem);
  2819. // print_r($aiData);
  2820. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  2821. $ag = $tr = $ta = $ot = 0;
  2822. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  2823. foreach ( $aItem as $key => $value ) {
  2824. if ($value ['category'] == $this->TRAIN) {
  2825. foreach ( $aiData ['dataList'] as $k => $v ) {
  2826. if ($value ['name'] == $v ['name']) {
  2827. array_push ( $accountJson [$this->TRAIN], array (
  2828. 'aid' => $value ['aid'],
  2829. 'name' => $value ['name'],
  2830. 'price' => number_format ( $v ['price'], 2, '.', '' )
  2831. ) );
  2832. $sum += $v ['price'];
  2833. $trainSum += $v ['price'];
  2834. unset ( $aiData ['dataList'] [$k] );
  2835. break;
  2836. }
  2837. }
  2838. }
  2839. }
  2840. $accountJson ['cSum'] = array (
  2841. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  2842. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  2843. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  2844. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  2845. );
  2846. // 报销单
  2847. $receipt = new receipt ();
  2848. $receipt->accountItem = json_encode ( $accountJson );
  2849. $receipt->sum = number_format ( $sum, 2, '.', '' );
  2850. $receipt->update ( array (
  2851. 'where' => 'rid=' . $rid
  2852. ) );
  2853. // print_r($accountJson);
  2854. // statistics item 统计写入
  2855. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  2856. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  2857. $accountItem = $accountJson;
  2858. $stat = $statistics->getOne ( array (
  2859. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  2860. 'asArray' => true
  2861. ) );
  2862. if (empty ( $stat )) {
  2863. $statistics->date = date ( "Y-m-d" );
  2864. $statistics->cid = $this->staff [0] ['cid'];
  2865. $statistics->staff = $this->staff [0] ['sid'];
  2866. $statistics->agPrice = 0;
  2867. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  2868. $statistics->insert ();
  2869. } else {
  2870. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  2871. $statistics->update ( array (
  2872. 'where' => 'sid=' . $stat ['sid']
  2873. ) );
  2874. }
  2875. return "/saeaBorad";
  2876. }
  2877. function confirmation() {
  2878. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2879. Doo::loadModel ( 'receipt' );
  2880. Doo::loadModel ( 'receiptDetail' );
  2881. $receipt = new receipt ();
  2882. $receiptDetail = new receiptDetail ();
  2883. Doo::loadModel ( 'statistics' );
  2884. Doo::loadModel ( 'itemStatistics' );
  2885. $statistics = new statistics ();
  2886. $itemStatistics = new itemStatistics ();
  2887. Doo::loadModel ( "verify" );
  2888. $verify = new verify ();
  2889. $receiptDetailList = $receipt->getOne ( array (
  2890. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  2891. 'asArray' => true
  2892. ) );
  2893. if (empty ( $receiptDetailList ))
  2894. return "/saeaBorad";
  2895. $verifyDetail = $verify->getOne ( array (
  2896. 'where' => ' vid =' . $receiptDetailList ['verify'],
  2897. 'asArray' => true
  2898. ) );
  2899. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  2900. if (empty ( $receiptDetailList ['nowStaff'] )) {
  2901. $nowStaff = "";
  2902. $nowStaffList = array ();
  2903. if ($verifyDetail [0] [1] == 'ROLE') {
  2904. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  2905. foreach ( $vStaffString as $key => $value ) {
  2906. $staffK = explode ( "_", $value );
  2907. array_push ( $nowStaffList, $staffK [0] );
  2908. }
  2909. $nowStaff = implode ( ',', $nowStaffList );
  2910. } else {
  2911. $nowStaff = $verifyDetail [0] [0];
  2912. }
  2913. $receipt->nowStaff = $nowStaff;
  2914. }
  2915. // echo $nowStaff;
  2916. // print_r($verifyDetail);die;
  2917. $receipt->rid = $receiptDetailList ['rid'];
  2918. $receipt->status = 2;
  2919. $receipt->update ();
  2920. // 操作日志
  2921. Doo::loadModel ( "receiptLog" );
  2922. $receiptLog = new receiptLog ();
  2923. $verify = new verify ();
  2924. $receiptInfo = $receipt->getOne ( array (
  2925. 'where' => 'rid=' . $rid,
  2926. 'asArray' => true
  2927. ) );
  2928. $vr = $verify->getOne ( array (
  2929. 'where' => 'vid=' . $receiptInfo ['verify'],
  2930. 'asArray' => true
  2931. ) );
  2932. $jd = json_decode ( $vr ['staff'] );
  2933. $roleId = 0;
  2934. foreach ( $jd as $key => $value ) {
  2935. if ($value [1] == 'ROLE') {
  2936. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  2937. if ($pos !== false) {
  2938. $roleId = $value [0];
  2939. }
  2940. }
  2941. }
  2942. // 审批日志
  2943. // echo $roleId;die;
  2944. if (! empty ( $roleId )) {
  2945. Doo::loadModel ( "role" );
  2946. $role = new role ();
  2947. $roleInfo = $role->getOne ( array (
  2948. 'where' => 'rid=' . $roleId,
  2949. 'asArray' => true
  2950. ) );
  2951. // $receiptLog->rolename = $roleInfo ['name'];
  2952. }
  2953. $receiptLog->username = $this->staff [0] ['username'];
  2954. $receiptLog->uid = $this->staff [0] ['sid'];
  2955. $receiptLog->date = date ( "Y-m-d" );
  2956. $receiptLog->opinion = '提交审批';
  2957. $receiptLog->img = $this->staff [0] ['avatar'];
  2958. $receiptLog->status = 2;
  2959. $receiptLog->rid = $rid;
  2960. $receiptLog->insert ();
  2961. return "/expenses";
  2962. }
  2963. function expenses() {
  2964. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  2965. if (empty ( $item ))
  2966. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  2967. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  2968. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  2969. Doo::loadClass ( 'XDeode' );
  2970. $XDeode = new XDeode ( 7 );
  2971. Doo::loadModel ( 'receipt' );
  2972. $receipt = new receipt ();
  2973. Doo::loadModel ( 'L_category' );
  2974. $Lcategory = new L_category ();
  2975. Doo::loadModel ( 'verify' );
  2976. Doo::loadModel ( 'statistics' );
  2977. $statistics = new statistics ();
  2978. $verify = new verify ();
  2979. Doo::loadModel ( 'staff' );
  2980. $staff = new staff ();
  2981. $condition = "";
  2982. if ($item == "expenses")
  2983. $condition = " and Rtype=1 ";
  2984. elseif ($item == "receipts")
  2985. $condition = " and Rtype=0 ";
  2986. elseif ($item == "remits")
  2987. $condition = " and Rtype=2 ";
  2988. elseif ($item == "train")
  2989. $condition = " and Rtype=3 ";
  2990. $dateCondition = " and Year(date) =" . $year;
  2991. if (! empty ( $moth )) {
  2992. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  2993. $stList = $statistics->getOne ( array (
  2994. 'select' => 'rePrice ,agPrice',
  2995. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  2996. 'asArray' => true
  2997. ) );
  2998. } else
  2999. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  3000. if (empty ( $stList ))
  3001. $stList = array (
  3002. 'rePrice' => 0,
  3003. 'agPrice' => 0
  3004. );
  3005. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  3006. if (! isset ( $noPassSum ['sum'] ))
  3007. $noPassSum ['sum'] = 0;
  3008. $data ['stList'] = array (
  3009. 'rePrice' => $stList ['rePrice'],
  3010. 'agPrice' => $stList ['agPrice'],
  3011. 'skPrice' => ($noPassSum ['sum'])
  3012. );
  3013. $receiptList = $receipt->find ( array (
  3014. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  3015. 'desc' => 'rid',
  3016. 'asArray' => true
  3017. ) );
  3018. $Locate = 0;
  3019. $roleId = 0;
  3020. $button = 0;
  3021. foreach ( $receiptList as $key => $value ) {
  3022. $receiptList[$key]['balance']='';
  3023. if($value['Rtype']==1){
  3024. $receiptList[$key]['balance']=$value['sum']-=$value['loanSum'];
  3025. $receiptList[$key]['balanceABS']=abs($receiptList[$key]['balance']);
  3026. }elseif($value['Rtype']==3){
  3027. $payment=$this->_getReceiptTrainPayment($value['invoiceTrainId'],$value['trainLoanRid'],$value['rid']);
  3028. $receiptList[$key]['payment']=$payment;
  3029. $receiptList[$key]['paymentABS']=abs($payment);
  3030. }
  3031. $receiptList [$key] ['Locate'] = $Locate;
  3032. $Locate ++;
  3033. $receiptList [$key] ['reviseDetail'] = array ();
  3034. if (! empty ( $value ['reviseDetail'] ))
  3035. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3036. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3037. $categoryDetil = $Lcategory->getOne ( array (
  3038. 'where' => 'cid=' . $value ['cid'],
  3039. 'asArray' => true
  3040. ) );
  3041. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3042. // 检测编辑状态
  3043. $verifyList = $verify->getOne ( array (
  3044. 'where' => 'vid=' . $value ['verify'],
  3045. 'asArray' => true
  3046. ) );
  3047. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3048. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3049. Doo::loadModel ( 'role' );
  3050. $role = new role ();
  3051. $flag = true;
  3052. $roleKey = 0;
  3053. $endStaffArray = array ();
  3054. $roleArrayCopy = array ();
  3055. foreach ( $verifyList as $k => $v ) {
  3056. // init verifyStaff
  3057. if ($v [1] == 'ROLE') {
  3058. if (! empty ( $verifyStaff )) {
  3059. $endStaffArray = end ( $verifyStaff );
  3060. // if ($v[0]==$endStaffArray['nextStaff']){
  3061. // $roleId=$v[0];
  3062. // }
  3063. }
  3064. $roleVerify = json_decode ( $v [3], true );
  3065. $roleKey = $k;
  3066. $roleArray = array ();
  3067. $rolename = $role->getOne ( array (
  3068. 'where' => 'rid=' . $v [0],
  3069. 'asArray' => true
  3070. ) );
  3071. foreach ( $roleVerify as $o => $p ) {
  3072. $staffID = explode ( '_', $p );
  3073. $staffInfo = $staff->getOne ( array (
  3074. 'where' => 'sid=' . $staffID [0],
  3075. 'asArray' => true
  3076. ) );
  3077. // print_r($staffID);
  3078. $exp = array (
  3079. 0 => $staffInfo ['sid'],
  3080. 1 => $staffID [1],
  3081. 2 => $staffInfo ['avatar'],
  3082. 'date' => '',
  3083. 'date' => '',
  3084. 'opinion' => '',
  3085. 'status' => '',
  3086. 'rolename' => $rolename ['name']
  3087. );
  3088. array_push ( $roleArray, $exp );
  3089. }
  3090. $roleArrayCopy [$v [0]] = $roleArray;
  3091. // $verifyList[$k]['roleArray']=$roleArray;
  3092. }
  3093. $verifyList [$k] ['date'] = "";
  3094. $verifyList [$k] ['opinion'] = "";
  3095. $verifyList [$k] ['status'] = "";
  3096. if (empty ( $verifyStaff )) {
  3097. $verifyList [$k] ['date'] = "";
  3098. $verifyList [$k] ['opinion'] = "";
  3099. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3100. $verifyList [$k] ['status'] = 4;
  3101. $flag = false;
  3102. }
  3103. } else {
  3104. foreach ( $verifyStaff as $m => $u ) {
  3105. if ($v [0] == $m) {
  3106. $verifyList [$k] ['date'] = $u ['date'];
  3107. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3108. $verifyList [$k] ['status'] = $u ['status'];
  3109. $flag = false;
  3110. break;
  3111. }
  3112. }
  3113. $endStaffArray = end ( $verifyStaff );
  3114. if (isset ( $endStaffArray ['ROLE'] )) {
  3115. } else {
  3116. // $endKey=key($verifyStaff);
  3117. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3118. // $button=4;
  3119. // $verifyList[$k]['status']=4;
  3120. // }
  3121. }
  3122. }
  3123. }
  3124. $rolename ['name'] = '';
  3125. if (! empty ( $roleId )) {
  3126. Doo::loadModel ( 'role' );
  3127. $role = new role ();
  3128. $rolename = $role->getOne ( array (
  3129. 'where' => 'rid=' . $roleId,
  3130. 'asArray' => true
  3131. ) );
  3132. }
  3133. if (! empty ( $verifyStaff ))
  3134. $endStaffArray = end ( $verifyStaff );
  3135. $KOP = false;
  3136. foreach ( $roleArrayCopy as $P => $A ) {
  3137. foreach ( $A as $MKI => $AVL ) {
  3138. if (! empty ( $verifyStaff )) {
  3139. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3140. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3141. $button = 4;
  3142. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3143. }
  3144. foreach ( $verifyStaff as $m => $u ) {
  3145. $AVLFK = $AVL [0] . '_R';
  3146. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3147. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3148. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3149. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3150. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3151. break;
  3152. }
  3153. }
  3154. } else {
  3155. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3156. $button = 4;
  3157. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3158. }
  3159. }
  3160. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3161. $KOP = true;
  3162. }
  3163. }
  3164. foreach ( $roleArrayCopy as $k => $v ) {
  3165. foreach ( $verifyList as $m => $n ) {
  3166. if ($n [0] == $k) {
  3167. array_splice ( $verifyList, $m, 1, $v );
  3168. }
  3169. }
  3170. }
  3171. $receiptList [$key] ['verifyList'] = $verifyList;
  3172. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3173. 'where' => 'sid=' . $value ['staff'],
  3174. 'asArray' => true
  3175. ) );
  3176. $receiptList [$key] ['button'] = $button;
  3177. $receiptList [$key] ['ridKey'] =$XDeode->encode( $value ['rid'] );
  3178. }
  3179. // print_r($receiptList);die;
  3180. $mothHtml = "";
  3181. for($i = 1; $i <= 12; $i ++) {
  3182. if ($moth == $i)
  3183. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3184. else
  3185. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3186. }
  3187. $dateHtml = "";
  3188. $now = date ( "Y" );
  3189. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  3190. if ($YEARD <= $now) {
  3191. $dateHtml .= '<option ';
  3192. if ($year == $YEARD) {
  3193. $dateHtml .= 'selected ';
  3194. }
  3195. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  3196. }
  3197. }
  3198. $data ['dateHtml'] = $dateHtml;
  3199. $data ['mothHtml'] = $mothHtml;
  3200. $data ['receiptList'] = $receiptList;
  3201. $data ['memu'] = "receipt";
  3202. $data ['staff'] = $this->staff;
  3203. $data ['receiptMemu'] = 'expenses';
  3204. $data ['verifyId'] = $this->verifyId;
  3205. $data ['executeId'] = $this->executeId;
  3206. $data ['item'] = $item;
  3207. $data ['year'] = $year;
  3208. $this->render ( "/admin/expenses", $data );
  3209. }
  3210. function expensesCollect() {
  3211. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3212. Doo::loadModel ( 'receipt' );
  3213. $receipt = new receipt ();
  3214. Doo::loadModel ( 'L_category' );
  3215. $Lcategory = new L_category ();
  3216. Doo::loadModel ( 'verify' );
  3217. Doo::loadModel ( 'statistics' );
  3218. $statistics = new statistics ();
  3219. $verify = new verify ();
  3220. Doo::loadModel ( 'staff' );
  3221. $staff = new staff ();
  3222. Doo::loadModel ( 'loanReceipt' );
  3223. $loanReceipt = new loanReceipt ();
  3224. $receiptList = $receipt->find ( array (//去掉
  3225. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  3226. 'desc' => 'rid',
  3227. 'asArray' => true
  3228. ) );
  3229. $loanList = $loanReceipt->find ( array (
  3230. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3231. 'desc' => 'rid',
  3232. 'asArray' => true
  3233. ) );
  3234. /*
  3235. * $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;
  3236. */
  3237. $data ['explanation'] = '';
  3238. if (! empty ( $loanList ))
  3239. $data ['explanation'] = $loanList [0] ['explanation'];
  3240. $Locate = 0;
  3241. $roleId = 0;
  3242. $button = 0;
  3243. foreach ( $receiptList as $key => $value ) {
  3244. $receiptList [$key] ['Locate'] = $Locate;
  3245. $Locate ++;
  3246. $receiptList [$key] ['reviseDetail'] = array ();
  3247. if (! empty ( $value ['reviseDetail'] ))
  3248. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3249. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3250. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3251. $categoryDetil = $Lcategory->getOne ( array (
  3252. 'where' => 'cid=' . $value ['cid'],
  3253. 'asArray' => true
  3254. ) );
  3255. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3256. // 检测编辑状态
  3257. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  3258. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  3259. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  3260. else
  3261. $verifyList ['staff'] = $value ['verifyBreakup'];
  3262. } else
  3263. $verifyList = $verify->getOne ( array (
  3264. 'where' => 'vid=' . $value ['verify'],
  3265. 'asArray' => true
  3266. ) );
  3267. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3268. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3269. Doo::loadModel ( 'role' );
  3270. $role = new role ();
  3271. $flag = true;
  3272. $roleKey = 0;
  3273. $endStaffArray = array ();
  3274. $roleArrayCopy = array ();
  3275. foreach ( $verifyList as $k => $v ) {
  3276. // init verifyStaff
  3277. if ($v [1] == 'ROLE') {
  3278. if (! empty ( $verifyStaff )) {
  3279. $endStaffArray = end ( $verifyStaff );
  3280. // if ($v[0]==$endStaffArray['nextStaff']){
  3281. // $roleId=$v[0];
  3282. // }
  3283. }
  3284. $roleVerify = json_decode ( $v [3], true );
  3285. $roleKey = $k;
  3286. $roleArray = array ();
  3287. $rolename = $role->getOne ( array (
  3288. 'where' => 'rid=' . $v [0],
  3289. 'asArray' => true
  3290. ) );
  3291. foreach ( $roleVerify as $o => $p ) {
  3292. $staffID = explode ( '_', $p );
  3293. $staffInfo = $staff->getOne ( array (
  3294. 'where' => 'sid=' . $staffID [0],
  3295. 'asArray' => true
  3296. ) );
  3297. // print_r($staffID);
  3298. $exp = array (
  3299. 0 => $staffInfo ['sid'],
  3300. 1 => $staffID [1],
  3301. 2 => $staffInfo ['avatar'],
  3302. 'date' => '',
  3303. 'date' => '',
  3304. 'opinion' => '',
  3305. 'status' => '',
  3306. 'rolename' => $rolename ['name']
  3307. );
  3308. array_push ( $roleArray, $exp );
  3309. }
  3310. $roleArrayCopy [$v [0]] = $roleArray;
  3311. // $verifyList[$k]['roleArray']=$roleArray;
  3312. }
  3313. $verifyList [$k] ['date'] = "";
  3314. $verifyList [$k] ['opinion'] = "";
  3315. $verifyList [$k] ['status'] = "";
  3316. if (empty ( $verifyStaff )) {
  3317. $verifyList [$k] ['date'] = "";
  3318. $verifyList [$k] ['opinion'] = "";
  3319. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3320. $verifyList [$k] ['status'] = 4;
  3321. $flag = false;
  3322. }
  3323. } else {
  3324. foreach ( $verifyStaff as $m => $u ) {
  3325. if ($v [0] == $m) {
  3326. $verifyList [$k] ['date'] = $u ['date'];
  3327. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3328. $verifyList [$k] ['status'] = $u ['status'];
  3329. $flag = false;
  3330. break;
  3331. }
  3332. }
  3333. $endStaffArray = end ( $verifyStaff );
  3334. if (isset ( $endStaffArray ['ROLE'] )) {
  3335. } else {
  3336. // $endKey=key($verifyStaff);
  3337. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3338. // $button=4;
  3339. // $verifyList[$k]['status']=4;
  3340. // }
  3341. }
  3342. }
  3343. }
  3344. $rolename ['name'] = '';
  3345. if (! empty ( $roleId )) {
  3346. Doo::loadModel ( 'role' );
  3347. $role = new role ();
  3348. $rolename = $role->getOne ( array (
  3349. 'where' => 'rid=' . $roleId,
  3350. 'asArray' => true
  3351. ) );
  3352. }
  3353. if (! empty ( $verifyStaff ))
  3354. $endStaffArray = end ( $verifyStaff );
  3355. $KOP = false;
  3356. foreach ( $roleArrayCopy as $P => $A ) {
  3357. foreach ( $A as $MKI => $AVL ) {
  3358. if (! empty ( $verifyStaff )) {
  3359. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3360. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3361. $button = 4;
  3362. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3363. }
  3364. foreach ( $verifyStaff as $m => $u ) {
  3365. $AVLFK = $AVL [0] . '_R';
  3366. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3367. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3368. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3369. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3370. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3371. break;
  3372. }
  3373. }
  3374. } else {
  3375. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3376. $button = 4;
  3377. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3378. }
  3379. }
  3380. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3381. $KOP = true;
  3382. }
  3383. }
  3384. foreach ( $roleArrayCopy as $k => $v ) {
  3385. foreach ( $verifyList as $m => $n ) {
  3386. if ($n [0] == $k) {
  3387. array_splice ( $verifyList, $m, 1, $v );
  3388. }
  3389. }
  3390. }
  3391. // 费用执行人相关数据
  3392. $executeCopy = json_decode ( $value ['executeCopy'], true );
  3393. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3394. foreach ( $executeCopy as $k => $v ) {
  3395. $executeCopy [$k] ['date'] = '';
  3396. $executeCopy [$k] ['opinion'] = '';
  3397. $executeCopy [$k] ['status'] = '';
  3398. if (! empty ( $executeStaff ))
  3399. foreach ( $executeStaff as $m => $u ) {
  3400. if ($v [0] == $m) {
  3401. $executeCopy [$k] ['date'] = $u ['date'];
  3402. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  3403. $executeCopy [$k] ['status'] = $u ['status'];
  3404. break;
  3405. }
  3406. }
  3407. }
  3408. $receiptList [$key] ['executeCopy'] = $executeCopy;
  3409. $receiptList [$key] ['verifyList'] = $verifyList;
  3410. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3411. 'where' => 'sid=' . $value ['staff'],
  3412. 'asArray' => true
  3413. ) );
  3414. $receiptList [$key] ['button'] = $button;
  3415. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3416. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3417. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  3418. $receiptList [$key] ['relust'] = $relust;
  3419. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  3420. }
  3421. Doo::loadModel ( 'enclosur' );
  3422. $enclosur = new enclosur ();
  3423. $enclosurList = $enclosur->find ( array (
  3424. 'where' => 'rid=' . $rid,
  3425. 'asArray' => true
  3426. ) );
  3427. $enclosurHtml = '';
  3428. foreach ( $enclosurList as $value ) {
  3429. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3430. }
  3431. $data ['enclosurHtml'] = $enclosurHtml;
  3432. //print_r($receiptList[0]['accountItem']['内部培训费用']);
  3433. $data ['receiptList'] = $receiptList;
  3434. $data ['memu'] = "receipt";
  3435. $data ['staff'] = $this->staff;
  3436. $data ['receiptMemu'] = 'expenses';
  3437. $data ['verifyId'] = $this->verifyId;
  3438. $data ['executeId'] = $this->executeId;
  3439. $this->render ( "/admin/expensesCollect", $data );
  3440. }
  3441. function approvalExpenses() {
  3442. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  3443. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3444. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3445. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3446. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3447. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  3448. // echo $rdate;
  3449. if (empty ( $status ))
  3450. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3451. $page_size = 8;
  3452. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  3453. $vidList = array ();
  3454. $button = 0;
  3455. Doo::loadModel ( 'verify' );
  3456. $verify = new verify ();
  3457. Doo::loadModel ( 'receipt' );
  3458. $receipt = new receipt ();
  3459. Doo::loadModel ( 'staff' );
  3460. $staff = new staff ();
  3461. Doo::loadModel ( 'L_category' );
  3462. $Lcategory = new L_category ();
  3463. // user verify ID
  3464. $verifyDetail = $verify->find ( array (
  3465. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  3466. 'asArray' => true
  3467. ) );
  3468. foreach ( $verifyDetail as $key => $value ) {
  3469. array_push ( $vidList, $value ['vid'] );
  3470. }
  3471. $vid = implode ( ",", $vidList );
  3472. if (empty ( $verifyDetail ))
  3473. $vid = 0;
  3474. // if ($status==0)
  3475. // $dateCondition="";
  3476. // else
  3477. $dateCondition = " ";
  3478. // if (! empty ( $month ))
  3479. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  3480. if ($status == 'done' || $status == 'termination') {
  3481. if (! empty ( $year )) {
  3482. $dateCondition = " and Year(pastDate) =" . $year;
  3483. if (! empty ( $month ))
  3484. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  3485. }
  3486. } elseif ($status == 'finish') {
  3487. if (! empty ( $year )) {
  3488. $dateCondition = " and Year(pastDate) =" . $year;
  3489. if (! empty ( $month ))
  3490. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  3491. }
  3492. }
  3493. // date ( 'Y-m' )
  3494. // if (! empty ( $rdate ) && $status == 'done')
  3495. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  3496. // elseif (! empty ( $rdate ))
  3497. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  3498. $categoryList = $Lcategory->find ( array (
  3499. 'asArray' => true
  3500. ) );
  3501. $staffList = $staff->find ( array (
  3502. 'where' => 'cid=' . $cid,
  3503. 'asArray' => true
  3504. ) );
  3505. $cateCondition = "";
  3506. $staffCondition = "";
  3507. $approvalCondition = "";
  3508. if (! empty ( $cid )) {
  3509. $cateCondition = ' and cid=' . $cid;
  3510. }
  3511. if (! empty ( $sid )) {
  3512. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  3513. $cateCondition = "";
  3514. }
  3515. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  3516. if ($status == 'pendApproval') {
  3517. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  3518. }
  3519. if ($status == 'ongoing') {
  3520. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  3521. }
  3522. if ($status == 'done') {
  3523. $approvalCondition = ' and (status=8 or status=9 ) ';
  3524. }
  3525. if ($status == 'termination') {
  3526. $approvalCondition = " and status=3";
  3527. }
  3528. if ($status == 'finish') {
  3529. $approvalCondition = " and (status=1 or status=8 or status=9 or status=10)";
  3530. }
  3531. $pageinfo ['page'] = array (
  3532. 'previous' => ''
  3533. );
  3534. if(!empty($receiptOrder)){
  3535. $pageinfo = $this->get_page ( "CLD_receipt", ' and receiptOrder like "%' . $receiptOrder . '%"', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  3536. $receiptList = $receipt->find ( array ( // $dateCondition
  3537. 'where' => 'receiptOrder like "%' . $receiptOrder . '%"',
  3538. 'desc' => 'rid',
  3539. 'asArray' => true
  3540. ) );
  3541. }else{
  3542. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  3543. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  3544. $receiptList = $receipt->find ( array ( // $dateCondition.
  3545. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  3546. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  3547. 'desc' => 'rid',
  3548. 'asArray' => true
  3549. ) );
  3550. } else {
  3551. $receiptList = $receipt->find ( array ( // $dateCondition
  3552. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  3553. 'desc' => 'rid',
  3554. 'asArray' => true
  3555. ) );
  3556. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  3557. }
  3558. }
  3559. $rLRes = $receipt->find ( array (
  3560. '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 . ')',
  3561. 'desc' => 'rid',
  3562. 'asArray' => true
  3563. ) );
  3564. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  3565. // print_r($receiptList);
  3566. Doo::loadClass ( 'XDeode' );
  3567. $XDeode = new XDeode ( 7 );
  3568. $Locate = 0;
  3569. //
  3570. $reportList = $reportCateList = array ();
  3571. foreach ( $receiptList as $key => $value ) {
  3572. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  3573. $receiptList [$key] ['Locate'] = $Locate;
  3574. $Locate ++;
  3575. $receiptList [$key] ['reviseDetail'] = array ();
  3576. if (! empty ( $value ['reviseDetail'] ))
  3577. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3578. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3579. $categoryDetil = $Lcategory->getOne ( array (
  3580. 'where' => 'cid=' . $value ['cid'],
  3581. 'asArray' => true
  3582. ) );
  3583. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3584. $verifyList = $verify->getOne ( array (
  3585. 'where' => 'vid=' . $value ['verify'],
  3586. 'asArray' => true
  3587. ) );
  3588. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3589. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3590. foreach ( $verifyList as $k => $v ) {
  3591. // init verifyStaff
  3592. $verifyList [$k] ['date'] = "";
  3593. $verifyList [$k] ['opinion'] = "";
  3594. $verifyList [$k] ['status'] = "";
  3595. if (empty ( $verifyStaff )) {
  3596. $verifyList [$k] ['date'] = "";
  3597. $verifyList [$k] ['opinion'] = "";
  3598. if ($v [0] == $this->staff [0] ['sid']) {
  3599. $verifyList [$k] ['status'] = 4;
  3600. $button = 4;
  3601. }
  3602. } else {
  3603. $flag = true;
  3604. foreach ( $verifyStaff as $m => $u ) {
  3605. if ($v [0] == $m) {
  3606. $verifyList [$k] ['date'] = $u ['date'];
  3607. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3608. $verifyList [$k] ['status'] = $u ['status'];
  3609. $flag = false;
  3610. break;
  3611. }
  3612. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  3613. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  3614. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  3615. }
  3616. if ($flag) { // 检测可编辑
  3617. if ($v [0] == $this->staff [0] ['sid']) {
  3618. $verifyList [$k] ['status'] = 4;
  3619. $button = 4;
  3620. }
  3621. }
  3622. }
  3623. }
  3624. $receiptList [$key] ['verifyList'] = $verifyList;
  3625. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3626. 'where' => 'sid=' . $value ['staff'],
  3627. 'asArray' => true
  3628. ) );
  3629. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  3630. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  3631. $receiptList [$key] ['button'] = $button;
  3632. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  3633. //获得培训班结算RID 借款费用--已经锁定
  3634. if($value['status']==10){
  3635. $trainRD=$receipt->getReceiptByTrainLoanRid($value['rid']);
  3636. $receiptList [$key]['trainRidKey7']=$trainRD['ridKey7'];
  3637. }
  3638. }
  3639. $reportList = array_unique ( $reportList );
  3640. $reportHtml = '';
  3641. foreach ( $reportList as $key => $value ) {
  3642. $v = explode ( "-", $value );
  3643. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  3644. }
  3645. // print_r($reportList)
  3646. $data ['reportHtml'] = $reportHtml;
  3647. $reportCateList = array_unique ( $reportCateList );
  3648. $reportCateHtml = '';
  3649. foreach ( $reportCateList as $key => $value ) {
  3650. $v = explode ( "-", $value );
  3651. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  3652. }
  3653. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  3654. $data ['reportCateHtml'] = $reportCateHtml;
  3655. // print_r($receiptList);die;
  3656. // $data['verifyDetail']=$verifyDetail;
  3657. $mothHtml = "";
  3658. for($i = 1; $i <= 12; $i ++) {
  3659. if ($month == $i)
  3660. $mothHtml .= '<option selected value="0' . $i . '">' . $i . '月</option>';
  3661. else
  3662. $mothHtml .= '<option value="0' . $i . '">' . $i . '月</option>';
  3663. }
  3664. $data ['mothHtml'] = $mothHtml;
  3665. $dateHtml = "";
  3666. $now = date ( "Y" );
  3667. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  3668. if ($YEARD <= $now) {
  3669. $dateHtml .= '<option ';
  3670. if ($year == $YEARD) {
  3671. $dateHtml .= 'selected ';
  3672. }
  3673. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  3674. }
  3675. }
  3676. $data ['dateHtml'] = $dateHtml;
  3677. $data ['page'] = $pageinfo;
  3678. $data ['receiptList'] = $receiptList;
  3679. $data ['receiptApprovalCount'] = count ( $rLRes );
  3680. $data ['status'] = $status;
  3681. $data ['year'] = $year;
  3682. $data ['month'] = $month;
  3683. $data ['categoryList'] = $categoryList;
  3684. $data ['staffList'] = $staffList;
  3685. $data ['cid'] = $cid;
  3686. $data ['sid'] = $sid;
  3687. // print_r($receiptList);
  3688. $data['receiptOrder']=$receiptOrder;
  3689. $data ['memu'] = "receipt";
  3690. $data ['staff'] = $this->staff;
  3691. $data ['receiptMemu'] = 'approvalExpenses';
  3692. $data ['verifyId'] = $this->verifyId;
  3693. $data ['executeId'] = $this->executeId;
  3694. $this->render ( "/admin/approvalExpenses", $data );
  3695. }
  3696. function expensesDoc() {
  3697. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3698. Doo::loadClass ( 'XDeode' );
  3699. $XDeode = new XDeode ( 5 );
  3700. if (! empty ( $rid ) && ! is_numeric ( $rid ))
  3701. $rid = $XDeode->decode ( $rid );
  3702. if (! is_numeric ( $rid ))
  3703. die ( 'illegal request' );
  3704. Doo::loadModel ( 'receipt' );
  3705. $receipt = new receipt ();
  3706. Doo::loadModel ( 'L_category' );
  3707. $Lcategory = new L_category ();
  3708. Doo::loadModel ( 'verify' );
  3709. Doo::loadModel ( 'statistics' );
  3710. $statistics = new statistics ();
  3711. $verify = new verify ();
  3712. Doo::loadModel ( 'staff' );
  3713. $staff = new staff ();
  3714. Doo::loadModel ( 'loanReceipt' );
  3715. $loanReceipt = new loanReceipt ();
  3716. $receiptList = $receipt->find ( array (
  3717. 'where' => ' rid=' . $rid,
  3718. 'desc' => 'rid',
  3719. 'asArray' => true
  3720. ) );
  3721. $loanList = array ();
  3722. if (! empty ( $receiptList ))
  3723. $loanList = $loanReceipt->find ( array (
  3724. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3725. 'desc' => 'rid',
  3726. 'asArray' => true
  3727. ) );
  3728. $Locate = 0;
  3729. $roleId = 0;
  3730. $button = 0;
  3731. foreach ( $loanList as $key => $value ) {
  3732. $loanList [$key] ['Locate'] = $Locate;
  3733. $Locate ++;
  3734. $loanList [$key] ['reviseDetail'] = array ();
  3735. if (! empty ( $value ['reviseDetail'] ))
  3736. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3737. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3738. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3739. $categoryDetil = $Lcategory->getOne ( array (
  3740. 'where' => 'cid=' . $value ['cid'],
  3741. 'asArray' => true
  3742. ) );
  3743. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3744. // 检测编辑状态
  3745. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  3746. $verifyList ['staff'] = $value ['verifyBreakup'];
  3747. else
  3748. $verifyList = $verify->getOne ( array (
  3749. 'where' => 'vid=' . $value ['verify'],
  3750. 'asArray' => true
  3751. ) );
  3752. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3753. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3754. Doo::loadModel ( 'role' );
  3755. $role = new role ();
  3756. $flag = true;
  3757. $roleKey = 0;
  3758. $endStaffArray = array ();
  3759. $roleArrayCopy = array ();
  3760. foreach ( $verifyList as $k => $v ) {
  3761. // init verifyStaff
  3762. if ($v [1] == 'ROLE') {
  3763. if (! empty ( $verifyStaff )) {
  3764. $endStaffArray = end ( $verifyStaff );
  3765. // if ($v[0]==$endStaffArray['nextStaff']){
  3766. // $roleId=$v[0];
  3767. // }
  3768. }
  3769. $roleVerify = json_decode ( $v [3], true );
  3770. $roleKey = $k;
  3771. $roleArray = array ();
  3772. $rolename = $role->getOne ( array (
  3773. 'where' => 'rid=' . $v [0],
  3774. 'asArray' => true
  3775. ) );
  3776. foreach ( $roleVerify as $o => $p ) {
  3777. $staffID = explode ( '_', $p );
  3778. $staffInfo = $staff->getOne ( array (
  3779. 'where' => 'sid=' . $staffID [0],
  3780. 'asArray' => true
  3781. ) );
  3782. // print_r($staffID);
  3783. $exp = array (
  3784. 0 => $staffInfo ['sid'],
  3785. 1 => $staffID [1],
  3786. 2 => $staffInfo ['avatar'],
  3787. 'date' => '',
  3788. 'date' => '',
  3789. 'opinion' => '',
  3790. 'status' => '',
  3791. 'rolename' => $rolename ['name']
  3792. );
  3793. array_push ( $roleArray, $exp );
  3794. }
  3795. $roleArrayCopy [$v [0]] = $roleArray;
  3796. // $verifyList[$k]['roleArray']=$roleArray;
  3797. }
  3798. $verifyList [$k] ['date'] = "";
  3799. $verifyList [$k] ['opinion'] = "";
  3800. $verifyList [$k] ['status'] = "";
  3801. if (empty ( $verifyStaff )) {
  3802. $verifyList [$k] ['date'] = "";
  3803. $verifyList [$k] ['opinion'] = "";
  3804. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3805. $verifyList [$k] ['status'] = 4;
  3806. $flag = false;
  3807. }
  3808. } else {
  3809. foreach ( $verifyStaff as $m => $u ) {
  3810. if ($v [0] == $m) {
  3811. $verifyList [$k] ['date'] = $u ['date'];
  3812. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3813. $verifyList [$k] ['status'] = $u ['status'];
  3814. $flag = false;
  3815. break;
  3816. }
  3817. }
  3818. $endStaffArray = end ( $verifyStaff );
  3819. if (isset ( $endStaffArray ['ROLE'] )) {
  3820. } else {
  3821. // $endKey=key($verifyStaff);
  3822. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3823. // $button=4;
  3824. // $verifyList[$k]['status']=4;
  3825. // }
  3826. }
  3827. }
  3828. }
  3829. $rolename ['name'] = '';
  3830. if (! empty ( $roleId )) {
  3831. Doo::loadModel ( 'role' );
  3832. $role = new role ();
  3833. $rolename = $role->getOne ( array (
  3834. 'where' => 'rid=' . $roleId,
  3835. 'asArray' => true
  3836. ) );
  3837. }
  3838. if (! empty ( $verifyStaff ))
  3839. $endStaffArray = end ( $verifyStaff );
  3840. $KOP = false;
  3841. foreach ( $roleArrayCopy as $P => $A ) {
  3842. foreach ( $A as $MKI => $AVL ) {
  3843. if (! empty ( $verifyStaff )) {
  3844. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3845. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3846. $button = 4;
  3847. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3848. }
  3849. foreach ( $verifyStaff as $m => $u ) {
  3850. $AVLFK = $AVL [0] . '_R';
  3851. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3852. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3853. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3854. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3855. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3856. break;
  3857. }
  3858. }
  3859. } else {
  3860. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3861. $button = 4;
  3862. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3863. }
  3864. }
  3865. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3866. $KOP = true;
  3867. }
  3868. }
  3869. foreach ( $roleArrayCopy as $k => $v ) {
  3870. foreach ( $verifyList as $m => $n ) {
  3871. if ($n [0] == $k) {
  3872. array_splice ( $verifyList, $m, 1, $v );
  3873. }
  3874. }
  3875. }
  3876. $loanList [$key] ['verifyList'] = $verifyList;
  3877. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3878. 'where' => 'sid=' . $value ['staff'],
  3879. 'asArray' => true
  3880. ) );
  3881. $loanList [$key] ['button'] = $button;
  3882. //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  3883. }
  3884. $data ['loanList'] = $loanList;
  3885. //print_r($loanList);
  3886. $Locate = 0;
  3887. $roleId = 0;
  3888. $button = 0;
  3889. foreach ( $receiptList as $key => $value ) {
  3890. $receiptList [$key] ['Locate'] = $Locate;
  3891. $Locate ++;
  3892. $receiptList [$key] ['reviseDetail'] = array ();
  3893. if (! empty ( $value ['reviseDetail'] ))
  3894. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3895. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3896. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3897. $categoryDetil = $Lcategory->getOne ( array (
  3898. 'where' => 'cid=' . $value ['cid'],
  3899. 'asArray' => true
  3900. ) );
  3901. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3902. // 检测编辑状态
  3903. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3904. $verifyList ['staff'] = $value ['verifyBreakup'];
  3905. } else
  3906. $verifyList = $verify->getOne ( array (
  3907. 'where' => 'vid=' . $value ['verify'],
  3908. 'asArray' => true
  3909. ) );
  3910. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3911. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3912. Doo::loadModel ( 'role' );
  3913. $role = new role ();
  3914. if ($verifyList == NULL)
  3915. $verifyList = array ();
  3916. $flag = true;
  3917. $roleKey = 0;
  3918. $endStaffArray = array ();
  3919. $roleArrayCopy = array ();
  3920. foreach ( $verifyList as $k => $v ) {
  3921. // init verifyStaff
  3922. if ($v [1] == 'ROLE') {
  3923. if (! empty ( $verifyStaff )) {
  3924. $endStaffArray = end ( $verifyStaff );
  3925. // if ($v[0]==$endStaffArray['nextStaff']){
  3926. // $roleId=$v[0];
  3927. // }
  3928. }
  3929. $roleVerify = json_decode ( $v [3], true );
  3930. $roleKey = $k;
  3931. $roleArray = array ();
  3932. $rolename = $role->getOne ( array (
  3933. 'where' => 'rid=' . $v [0],
  3934. 'asArray' => true
  3935. ) );
  3936. foreach ( $roleVerify as $o => $p ) {
  3937. $staffID = explode ( '_', $p );
  3938. $staffInfo = $staff->getOne ( array (
  3939. 'where' => 'sid=' . $staffID [0],
  3940. 'asArray' => true
  3941. ) );
  3942. // print_r($staffID);
  3943. $exp = array (
  3944. 0 => $staffInfo ['sid'],
  3945. 1 => $staffID [1],
  3946. 2 => $staffInfo ['avatar'],
  3947. 'date' => '',
  3948. 'date' => '',
  3949. 'opinion' => '',
  3950. 'status' => '',
  3951. 'rolename' => $rolename ['name']
  3952. );
  3953. array_push ( $roleArray, $exp );
  3954. }
  3955. $roleArrayCopy [$v [0]] = $roleArray;
  3956. // $verifyList[$k]['roleArray']=$roleArray;
  3957. }
  3958. $verifyList [$k] ['date'] = "";
  3959. $verifyList [$k] ['opinion'] = "";
  3960. $verifyList [$k] ['status'] = "";
  3961. if (empty ( $verifyStaff )) {
  3962. $verifyList [$k] ['date'] = "";
  3963. $verifyList [$k] ['opinion'] = "";
  3964. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3965. $verifyList [$k] ['status'] = 4;
  3966. $flag = false;
  3967. }
  3968. } else {
  3969. foreach ( $verifyStaff as $m => $u ) {
  3970. if ($v [0] == $m) {
  3971. $verifyList [$k] ['date'] = $u ['date'];
  3972. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3973. $verifyList [$k] ['status'] = $u ['status'];
  3974. $flag = false;
  3975. break;
  3976. }
  3977. }
  3978. $endStaffArray = end ( $verifyStaff );
  3979. if (isset ( $endStaffArray ['ROLE'] )) {
  3980. } else {
  3981. // $endKey=key($verifyStaff);
  3982. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3983. // $button=4;
  3984. // $verifyList[$k]['status']=4;
  3985. // }
  3986. }
  3987. }
  3988. }
  3989. $FC = @$rolename ['name'];
  3990. $rolename ['name'] = '';
  3991. if (! empty ( $roleId )) {
  3992. Doo::loadModel ( 'role' );
  3993. $role = new role ();
  3994. $rolename = $role->getOne ( array (
  3995. 'where' => 'rid=' . $roleId,
  3996. 'asArray' => true
  3997. ) );
  3998. }
  3999. if (! empty ( $verifyStaff ))
  4000. $endStaffArray = end ( $verifyStaff );
  4001. $KOP = false;
  4002. foreach ( $roleArrayCopy as $P => $A ) {
  4003. foreach ( $A as $MKI => $AVL ) {
  4004. if (! empty ( $verifyStaff )) {
  4005. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4006. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4007. $button = 4;
  4008. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4009. }
  4010. foreach ( $verifyStaff as $m => $u ) {
  4011. $AVLFK = $AVL [0] . '_R';
  4012. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4013. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4014. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4015. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4016. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4017. break;
  4018. }
  4019. }
  4020. } else {
  4021. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4022. $button = 4;
  4023. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4024. }
  4025. }
  4026. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4027. $KOP = true;
  4028. }
  4029. }
  4030. foreach ( $roleArrayCopy as $k => $v ) {
  4031. foreach ( $verifyList as $m => $n ) {
  4032. if ($n [0] == $k) {
  4033. array_splice ( $verifyList, $m, 1, $v );
  4034. }
  4035. }
  4036. }
  4037. // 费用执行人相关数据
  4038. $executeCopy = json_decode ( $value ['executeCopy'], true );
  4039. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4040. foreach ( $executeCopy as $k => $v ) {
  4041. $executeCopy [$k] ['date'] = '';
  4042. $executeCopy [$k] ['opinion'] = '';
  4043. $executeCopy [$k] ['status'] = '';
  4044. if (! empty ( $executeStaff ))
  4045. foreach ( $executeStaff as $m => $u ) {
  4046. if ($v [0] == $m) {
  4047. $executeCopy [$k] ['date'] = $u ['date'];
  4048. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  4049. $executeCopy [$k] ['status'] = $u ['status'];
  4050. break;
  4051. }
  4052. }
  4053. }
  4054. $receiptList [$key] ['executeCopy'] = $executeCopy;
  4055. // print_r($verifyList);
  4056. $receiptList [$key] ['verifyList'] = $verifyList;
  4057. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4058. 'where' => 'sid=' . $value ['staff'],
  4059. 'asArray' => true
  4060. ) );
  4061. $receiptList [$key] ['button'] = $button;
  4062. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4063. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4064. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4065. $receiptList [$key] ['relust'] = $relust;
  4066. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4067. }
  4068. // print_r($receiptList);
  4069. // 获取审批日志
  4070. Doo::loadModel ( 'receiptLog' );
  4071. $receiptLog = new receiptLog ();
  4072. $rlList = array ();
  4073. $rlInfo = $receiptLog->getOne ( array (
  4074. 'where' => 'rid=' . $rid . ' and status=4',
  4075. 'asArray' => true
  4076. ) );
  4077. // $tijdate = $receiptLog->getOne ( array (
  4078. // 'where' => 'rid=' . $rid . ' and status=2',
  4079. // 'asc' => 'rlid',
  4080. // 'asArray' => true
  4081. // ) );
  4082. if (! empty ( $rlInfo )) {
  4083. $rlList = $receiptLog->find ( array (
  4084. 'where' => 'rid=' . $rid,
  4085. 'asc' => 'rlid',
  4086. 'asArray' => true
  4087. ) );
  4088. }
  4089. $RN=array();
  4090. if (!empty( $rolename ['staff'])){
  4091. $RN = @json_decode ( $rolename ['staff'] );
  4092. }
  4093. //
  4094. foreach ( $rlList as $key => $value ) {
  4095. $rlList [$key] ['rolename'] = '';
  4096. foreach ( $RN as $k => $v ) {
  4097. $id = explode ( "_", $v );
  4098. if ($id [0] == $value ['uid']) {
  4099. $rlList [$key] ['rolename'] = $FC;
  4100. break;
  4101. }
  4102. }
  4103. }
  4104. Doo::loadModel ( 'enclosur' );
  4105. $enclosur = new enclosur ();
  4106. $enclosurList = $enclosur->find ( array (
  4107. 'where' => 'rid=' . $rid,
  4108. 'asArray' => true
  4109. ) );
  4110. $enclosurHtml = '';
  4111. foreach ( $enclosurList as $value ) {
  4112. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4113. }
  4114. $data ['enclosurHtml'] = $enclosurHtml;
  4115. $receiptList [0] ['rlList'] = $rlList;
  4116. $data ['receiptList'] = $receiptList;
  4117. // print_r($receiptList);
  4118. $data ['memu'] = "receipt";
  4119. $data ['staff'] = $this->staff;
  4120. $data ['receiptMemu'] = 'approvalExpenses';
  4121. $data ['verifyId'] = $this->verifyId;
  4122. $data ['executeId'] = $this->executeId;
  4123. $this->render ( "/admin/expensesDoc", $data );
  4124. }
  4125. function expensesEdi() {
  4126. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4127. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  4128. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4129. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4130. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4131. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4132. if (empty ( $status ))
  4133. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  4134. $vidList = array ();
  4135. $button = 0;
  4136. Doo::loadModel ( 'verify' );
  4137. Doo::loadModel ( 'receipt' );
  4138. Doo::loadModel ( 'staff' );
  4139. $staff = new staff ();
  4140. $receipt = new receipt ();
  4141. $verify = new verify ();
  4142. Doo::loadModel ( 'L_category' );
  4143. $Lcategory = new L_category ();
  4144. Doo::loadModel ( 'enclosur' );
  4145. $enclosur = new enclosur ();
  4146. // user verify ID
  4147. $verifyDetail = $verify->find ( array (
  4148. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  4149. 'asArray' => true
  4150. ) );
  4151. foreach ( $verifyDetail as $key => $value ) {
  4152. array_push ( $vidList, $value ['vid'] );
  4153. }
  4154. $vid = implode ( ",", $vidList );
  4155. if (empty ( $verifyDetail ))
  4156. $vid = 0;
  4157. $categoryList = $Lcategory->find ( array (
  4158. 'asArray' => true
  4159. ) );
  4160. $staffList = $staff->find ( array (
  4161. 'where' => 'cid=' . $cid,
  4162. 'asArray' => true
  4163. ) );
  4164. $ap = "";
  4165. if ($status == 4) {
  4166. $ap = 4;
  4167. $status = 2;
  4168. }
  4169. // get Receipt By verifyID status 2
  4170. $receiptList = $receipt->find ( array (
  4171. 'where' => 'rid =' . $rid . ' and status=2',
  4172. 'desc' => 'rid',
  4173. 'asArray' => true
  4174. ) );
  4175. if (empty ( $receiptList )) {
  4176. die ( 'illegal request' );
  4177. }
  4178. $Locate = 0;
  4179. $roleId = 0;
  4180. if ($ap == 4)
  4181. $status = 4;
  4182. foreach ( $receiptList as $key => $value ) {
  4183. $receiptList [$key] ['Locate'] = $Locate;
  4184. $Locate ++;
  4185. $receiptList [$key] ['reviseDetail'] = array ();
  4186. if (! empty ( $value ['reviseDetail'] ))
  4187. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4188. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4189. $categoryDetil = $Lcategory->getOne ( array (
  4190. 'where' => 'cid=' . $value ['cid'],
  4191. 'asArray' => true
  4192. ) );
  4193. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4194. // 检测编辑状态
  4195. $verifyList = $verify->getOne ( array (
  4196. 'where' => 'vid=' . $value ['verify'],
  4197. 'asArray' => true
  4198. ) );
  4199. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4200. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4201. Doo::loadModel ( 'role' );
  4202. $role = new role ();
  4203. // print_r($verifyList);
  4204. $flag = true;
  4205. $roleKey = 0;
  4206. $endStaffArray = array ();
  4207. $roleArrayCopy = array ();
  4208. foreach ( $verifyList as $k => $v ) {
  4209. // init verifyStaff
  4210. if ($v [1] == 'ROLE') {
  4211. if (! empty ( $verifyStaff )) {
  4212. $endStaffArray = end ( $verifyStaff );
  4213. if ($v [0] == $endStaffArray ['nextStaff']) {
  4214. $roleId = $v [0];
  4215. }
  4216. }
  4217. $roleVerify = json_decode ( $v [3], true );
  4218. $roleKey = $k;
  4219. $roleArray = array ();
  4220. $rolename = $role->getOne ( array (
  4221. 'where' => 'rid=' . $v [0],
  4222. 'asArray' => true
  4223. ) );
  4224. foreach ( $roleVerify as $o => $p ) {
  4225. $staffID = explode ( '_', $p );
  4226. $staffInfo = $staff->getOne ( array (
  4227. 'where' => 'sid=' . $staffID [0],
  4228. 'asArray' => true
  4229. ) );
  4230. // print_r($staffID);
  4231. $exp = array (
  4232. 0 => $staffInfo ['sid'],
  4233. 1 => $staffID [1],
  4234. 2 => $staffInfo ['avatar'],
  4235. 'date' => '',
  4236. 'date' => '',
  4237. 'opinion' => '',
  4238. 'status' => '',
  4239. 'rolename' => $rolename ['name']
  4240. );
  4241. array_push ( $roleArray, $exp );
  4242. }
  4243. $roleArrayCopy [$v [0]] = $roleArray;
  4244. // $verifyList[$k]['roleArray']=$roleArray;
  4245. }
  4246. // print_r($roleArray);
  4247. $verifyList [$k] ['date'] = "";
  4248. $verifyList [$k] ['opinion'] = "";
  4249. $verifyList [$k] ['status'] = "";
  4250. if (empty ( $verifyStaff )) {
  4251. $verifyList [$k] ['date'] = "";
  4252. $verifyList [$k] ['opinion'] = "";
  4253. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4254. $verifyList [$k] ['status'] = 4;
  4255. $button = 4;
  4256. $flag = false;
  4257. }
  4258. } else {
  4259. foreach ( $verifyStaff as $m => $u ) {
  4260. if ($v [0] == $m) {
  4261. $verifyList [$k] ['date'] = $u ['date'];
  4262. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4263. $verifyList [$k] ['status'] = $u ['status'];
  4264. $flag = false;
  4265. break;
  4266. }
  4267. }
  4268. $endStaffArray = end ( $verifyStaff );
  4269. if (isset ( $endStaffArray ['ROLE'] )) {
  4270. } else {
  4271. $endKey = key ( $verifyStaff );
  4272. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4273. $button = 4;
  4274. $verifyList [$k] ['status'] = 4;
  4275. }
  4276. }
  4277. }
  4278. }
  4279. $rolename ['name'] = '';
  4280. if (! empty ( $roleId )) {
  4281. Doo::loadModel ( 'role' );
  4282. $role = new role ();
  4283. $rolename = $role->getOne ( array (
  4284. 'where' => 'rid=' . $roleId,
  4285. 'asArray' => true
  4286. ) );
  4287. }
  4288. if (! empty ( $verifyStaff ))
  4289. $endStaffArray = end ( $verifyStaff );
  4290. $KOP = false;
  4291. foreach ( $roleArrayCopy as $P => $A ) {
  4292. foreach ( $A as $MKI => $AVL ) {
  4293. if (! empty ( $verifyStaff )) {
  4294. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4295. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4296. $button = 4;
  4297. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4298. }
  4299. foreach ( $verifyStaff as $m => $u ) {
  4300. $AVLFK = $AVL [0] . '_R';
  4301. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4302. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4303. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4304. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4305. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4306. break;
  4307. }
  4308. }
  4309. } else {
  4310. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4311. $button = 4;
  4312. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4313. }
  4314. }
  4315. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4316. $KOP = true;
  4317. }
  4318. }
  4319. // print_r($roleArrayCopy);
  4320. // echo $roleKey;
  4321. foreach ( $roleArrayCopy as $k => $v ) {
  4322. foreach ( $verifyList as $m => $n ) {
  4323. if ($n [0] == $k) {
  4324. array_splice ( $verifyList, $m, 1, $v );
  4325. }
  4326. }
  4327. }
  4328. $receiptList [$key] ['verifyList'] = $verifyList;
  4329. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4330. 'where' => 'sid=' . $value ['staff'],
  4331. 'asArray' => true
  4332. ) );
  4333. $receiptList [$key] ['button'] = $button;
  4334. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  4335. }
  4336. // $data['verifyDetail']=$verifyDetail;
  4337. $mothHtml = "";
  4338. for($i = 1; $i <= 12; $i ++) {
  4339. if ($month == $i)
  4340. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4341. else
  4342. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4343. }
  4344. // 获取审批日志
  4345. Doo::loadModel ( 'receiptLog' );
  4346. $receiptLog = new receiptLog ();
  4347. $rlList = array ();
  4348. $rlInfo = $receiptLog->getOne ( array (
  4349. 'where' => 'rid=' . $rid . ' and status=4',
  4350. 'asArray' => true
  4351. ) );
  4352. $tijdate = $receiptLog->getOne ( array (
  4353. 'where' => 'rid=' . $rid . ' and status=2',
  4354. 'asc' => 'rlid',
  4355. 'asArray' => true
  4356. ) );
  4357. if (! empty ( $rlInfo )) {
  4358. $rlList = $receiptLog->find ( array (
  4359. 'where' => 'rid=' . $rid,
  4360. 'asc' => 'rlid',
  4361. 'asArray' => true
  4362. ) );
  4363. }
  4364. $receiptList [0] ['rlList'] = $rlList;
  4365. $enclosurList = $enclosur->find ( array (
  4366. 'where' => 'rid=' . $rid,
  4367. 'asArray' => true
  4368. ) );
  4369. $enclosurHtml = '';
  4370. foreach ( $enclosurList as $value ) {
  4371. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4372. }
  4373. // print_r($receiptList);
  4374. $data ['rid'] = $rid;
  4375. $data ['enclosurHtml'] = $enclosurHtml;
  4376. $data ['rolename'] = $rolename ['name'];
  4377. $data ['datetij'] = $tijdate ['date'];
  4378. $data ['mothHtml'] = $mothHtml;
  4379. $data ['receiptList'] = $receiptList;
  4380. $data ['receiptApprovalCount'] = count ( $receiptList );
  4381. $data ['status'] = $status;
  4382. $data ['year'] = $year;
  4383. $data ['categoryList'] = $categoryList;
  4384. $data ['staffList'] = $staffList;
  4385. $data ['cid'] = $cid;
  4386. $data ['sid'] = $sid;
  4387. $data ['ap'] = $ap;
  4388. $data ['memu'] = "receipt";
  4389. $data ['staff'] = $this->staff;
  4390. $data ['receiptMemu'] = 'approvalExpenses';
  4391. $data ['verifyId'] = $this->verifyId;
  4392. $data ['executeId'] = $this->executeId;
  4393. $this->render ( "/admin/expensesEdi", $data );
  4394. }
  4395. function expensesDefray() {
  4396. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  4397. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  4398. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4399. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  4400. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  4401. if (! empty ( $rid )) {
  4402. Doo::loadModel ( "verify" );
  4403. $verify = new verify ();
  4404. Doo::loadModel ( "receiptDetail" );
  4405. $receiptDetailObj = new receiptDetail ();
  4406. Doo::loadModel ( "itemStatistics" );
  4407. Doo::loadModel ( "statistics" );
  4408. $statistics = new statistics ();
  4409. $itemStatistics = new itemStatistics ();
  4410. Doo::loadModel ( "receipt" );
  4411. $receipt = new receipt ();
  4412. Doo::loadModel ( "loanReceipt" );
  4413. $loanReceipt = new loanReceipt ();
  4414. $receiptDetail = $receipt->getOne ( array (
  4415. 'where' => 'rid=' . $rid . ' and status=2 ',
  4416. 'asArray' => true
  4417. ) );
  4418. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  4419. $nsflag = true;
  4420. foreach ( $nslist as $value ) {
  4421. if ($value == $this->staff ['0'] ['sid']) {
  4422. $nsflag = false;
  4423. break;
  4424. }
  4425. }
  4426. // print_r($nslist);die;
  4427. if (empty ( $receiptDetail ) || $nsflag)
  4428. return "/approvalExpenses/pendApproval";
  4429. $verifyDetail = $verify->getOne ( array (
  4430. 'where' => ' vid =' . $receiptDetail ['verify'],
  4431. 'asArray' => true
  4432. ) );
  4433. $verifyString = $verifyDetail ['staff'];
  4434. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  4435. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  4436. if (empty ( $opinion )) {
  4437. if ($status == 3)
  4438. $opinion = "终止";
  4439. else
  4440. $opinion = "同意支付";
  4441. }
  4442. $nowStaff = 0;
  4443. $nowStaffList = array ();
  4444. if (empty ( $verifyStaff )) {
  4445. // 还需加入是否已经进入角色审批
  4446. if ($verifyDetail [0] [1] == 'ROLE') {
  4447. // print_r($verifyDetail);echo "ddd";
  4448. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  4449. foreach ( $vStaffString as $key => $value ) {
  4450. $staffK = explode ( "_", $value );
  4451. if ($staffK [0] != $this->staff [0] ['sid'])
  4452. array_push ( $nowStaffList, $staffK [0] );
  4453. }
  4454. // print_r($verifyDetail);
  4455. // die;
  4456. if (! empty ( $nowStaffList )) {
  4457. $nowStaff = implode ( ',', $nowStaffList );
  4458. $verifyStaff = array (
  4459. $this->staff [0] ['sid'] . "_R" => array (
  4460. 'date' => date ( 'Y-m-d' ),
  4461. 'opinion' => $opinion,
  4462. 'status' => $status,
  4463. 'nextStaff' => $verifyDetail [0] [0],
  4464. 'ROLE' => 1
  4465. )
  4466. );
  4467. } else {
  4468. $nowStaff = $verifyDetail [1] [0];
  4469. $verifyStaff = array (
  4470. $this->staff [0] ['sid'] . "_R" => array (
  4471. 'date' => date ( 'Y-m-d' ),
  4472. 'opinion' => $opinion,
  4473. 'status' => $status,
  4474. 'nextStaff' => $verifyDetail [1] [0]
  4475. )
  4476. );
  4477. }
  4478. } else {
  4479. if ($verifyDetail [1] [1] == 'ROLE') {
  4480. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  4481. // echo "dd";
  4482. foreach ( $vStaffString as $key => $value ) {
  4483. $staffK = explode ( "_", $value );
  4484. array_push ( $nowStaffList, $staffK [0] );
  4485. }
  4486. $nowStaff = implode ( ',', $nowStaffList );
  4487. $verifyStaff = array (
  4488. $this->staff [0] ['sid'] => array (
  4489. 'date' => date ( 'Y-m-d' ),
  4490. 'opinion' => $opinion,
  4491. 'status' => $status,
  4492. 'nextStaff' => $verifyDetail [1] [0],
  4493. 'ROLE' => 1
  4494. )
  4495. );
  4496. } else {
  4497. $nowStaff = $verifyDetail [1] [0];
  4498. $verifyStaff = array (
  4499. $this->staff [0] ['sid'] => array (
  4500. 'date' => date ( 'Y-m-d' ),
  4501. 'opinion' => $opinion,
  4502. 'status' => $status,
  4503. 'nextStaff' => $verifyDetail [1] [0]
  4504. )
  4505. );
  4506. }
  4507. }
  4508. if ($status == 3)
  4509. $verifyStaff = array (
  4510. 'final' => $status,
  4511. $this->staff [0] ['sid'] => array (
  4512. 'date' => date ( 'Y-m-d' ),
  4513. 'opinion' => $opinion,
  4514. 'status' => $status
  4515. )
  4516. );
  4517. $vStaffString = json_encode ( $verifyStaff );
  4518. $receipt->nowStaff = $nowStaff;
  4519. $receipt->verifyStaff = $vStaffString;
  4520. $loanReceipt->nowStaff = $nowStaff;
  4521. $loanReceipt->verifyStaff = $vStaffString;
  4522. } else {
  4523. $VS = end ( $verifyStaff );
  4524. // 非角色审批
  4525. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  4526. $nextStaff = 0;
  4527. $roleSTF = false;
  4528. foreach ( $verifyDetail as $key => $value ) {
  4529. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  4530. if (isset ( $verifyDetail [$key + 1] )) {
  4531. $nextStaff = $verifyDetail [$key + 1] [0];
  4532. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  4533. $roleSTF = true;
  4534. }
  4535. break;
  4536. }
  4537. }
  4538. if (! $roleSTF) {
  4539. $nowStaff = $nextStaff;
  4540. $verifyStaff [$this->staff [0] ['sid']] = array (
  4541. 'date' => date ( 'Y-m-d' ),
  4542. 'opinion' => $opinion,
  4543. 'status' => $status,
  4544. 'nextStaff' => $nextStaff
  4545. );
  4546. } else {
  4547. // 获取角色下的所有用户ID
  4548. $nowStaffList = array ();
  4549. foreach ( $verifyDetail as $vfk ) {
  4550. if ($vfk [1] == 'ROLE') {
  4551. $vStaffString = json_decode ( $vfk [3] );
  4552. foreach ( $vStaffString as $key => $value ) {
  4553. $staffK = explode ( "_", $value );
  4554. array_push ( $nowStaffList, $staffK [0] );
  4555. }
  4556. }
  4557. }
  4558. $nowStaff = implode ( ',', $nowStaffList );
  4559. $verifyStaff [$this->staff [0] ['sid']] = array (
  4560. 'date' => date ( 'Y-m-d' ),
  4561. 'opinion' => $opinion,
  4562. 'status' => $status,
  4563. 'nextStaff' => $nextStaff,
  4564. 'ROLE' => 0
  4565. );
  4566. }
  4567. if ($status == 3) {
  4568. $verifyStaff ['final'] = $status;
  4569. $verifyStaff [$this->staff [0] ['sid']] = array (
  4570. 'date' => date ( 'Y-m-d' ),
  4571. 'opinion' => $opinion,
  4572. 'status' => $status
  4573. );
  4574. }
  4575. $vStaffString = json_encode ( $verifyStaff );
  4576. $receipt->nowStaff = $nowStaff;
  4577. $receipt->verifyStaff = $vStaffString;
  4578. $loanReceipt->nowStaff = $nowStaff;
  4579. $loanReceipt->verifyStaff = $vStaffString;
  4580. }
  4581. // 角色审批
  4582. if (isset ( $VS ['ROLE'] )) {
  4583. // 找出角色人 当前审批角色组
  4584. $verifyJSStaff = array ();
  4585. $nowStaffList2 = array ();
  4586. foreach ( $verifyDetail as $key => $value ) {
  4587. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  4588. $verifyJSStaff = json_decode ( $value [3] );
  4589. foreach ( $verifyJSStaff as $m ) {
  4590. $staffK = explode ( "_", $m );
  4591. array_push ( $nowStaffList2, $staffK [0] );
  4592. }
  4593. // print_r($nowStaffList2);
  4594. }
  4595. }
  4596. $RoleVerifyStaff = array ();
  4597. foreach ( $verifyStaff as $key => $value ) {
  4598. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  4599. foreach ( $nowStaffList2 as $m ) {
  4600. if ($key == $m . "_R")
  4601. $RoleVerifyStaff [$key] = $value;
  4602. }
  4603. }
  4604. }
  4605. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  4606. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  4607. // 下一个审批人ID
  4608. $nextStaff = 0;
  4609. $falg = false;
  4610. foreach ( $verifyDetail as $key => $value ) {
  4611. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  4612. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  4613. $falg = true;
  4614. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  4615. $nowStaffList = array ();
  4616. foreach ( $vStaffString as $v ) {
  4617. $staffK = explode ( "_", $v );
  4618. array_push ( $nowStaffList, $staffK [0] );
  4619. }
  4620. $nowStaff = implode ( ',', $nowStaffList );
  4621. $nextStaff = $verifyDetail [$key + 1] [0];
  4622. } elseif (isset ( $verifyDetail [$key + 1] )) {
  4623. $nextStaff = $verifyDetail [$key + 1] [0];
  4624. $nowStaff = $nextStaff;
  4625. } else
  4626. $nowStaff = '';
  4627. break;
  4628. }
  4629. }
  4630. if ($falg)
  4631. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  4632. 'date' => date ( 'Y-m-d' ),
  4633. 'opinion' => $opinion,
  4634. 'status' => $status,
  4635. 'nextStaff' => $nextStaff,
  4636. 'ROLE' => 1
  4637. );
  4638. else
  4639. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  4640. 'date' => date ( 'Y-m-d' ),
  4641. 'opinion' => $opinion,
  4642. 'status' => $status,
  4643. 'nextStaff' => $nextStaff
  4644. );
  4645. // print_r($verifyStaff);
  4646. // echo $nowStaff;die;
  4647. } else { // 进入下一个角色或者审批人
  4648. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  4649. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  4650. 'date' => date ( 'Y-m-d' ),
  4651. 'opinion' => $opinion,
  4652. 'status' => $status,
  4653. 'nextStaff' => $VS ['nextStaff'],
  4654. 'ROLE' => 1
  4655. );
  4656. }
  4657. if ($status == 3) {
  4658. $verifyStaff ['final'] = $status;
  4659. $verifyStaff [$this->staff [0] ['sid']] = array (
  4660. 'date' => date ( 'Y-m-d' ),
  4661. 'opinion' => $opinion,
  4662. 'status' => $status
  4663. );
  4664. }
  4665. $vStaffString = json_encode ( $verifyStaff );
  4666. $receipt->verifyStaff = $vStaffString;
  4667. $receipt->nowStaff = $nowStaff;
  4668. $loanReceipt->nowStaff = $nowStaff;
  4669. $loanReceipt->verifyStaff = $vStaffString;
  4670. }
  4671. // print_r($verifyStaff);die;
  4672. }
  4673. $roleKey = 0;
  4674. $roleId = 0;
  4675. $verifyDetailCopy = array ();
  4676. foreach ( $verifyDetail as $k => $v ) {
  4677. if ($v [1] == 'ROLE') {
  4678. $roleId = $v [0];
  4679. $roleVerify = json_decode ( $v [3], true );
  4680. $roleKey = $k;
  4681. $roleArray = array ();
  4682. foreach ( $roleVerify as $o => $p ) {
  4683. $staffID = explode ( '_', $p );
  4684. $exp = array (
  4685. 0 => $staffID [0],
  4686. 1 => $staffID [1]
  4687. );
  4688. array_push ( $roleArray, $exp );
  4689. }
  4690. $verifyDetailCopy [$v [0]] = $roleArray;
  4691. }
  4692. }
  4693. // print_r($verifyDetail);
  4694. foreach ( $verifyDetailCopy as $k => $v ) {
  4695. foreach ( $verifyDetail as $m => $n ) {
  4696. if ($n [0] == $k) {
  4697. array_splice ( $verifyDetail, $m, 1, $v );
  4698. }
  4699. }
  4700. }
  4701. // 审批日志
  4702. if (! isset ( $verifyStaff ['final'] )) {
  4703. Doo::loadModel ( "receiptLog" );
  4704. $receiptLog = new receiptLog ();
  4705. if (! empty ( $roleId )) {
  4706. Doo::loadModel ( "role" );
  4707. $role = new role ();
  4708. $roleInfo = $role->getOne ( array (
  4709. 'where' => 'rid=' . $roleId,
  4710. 'asArray' => true
  4711. ) );
  4712. $receiptLog->rolename = $roleInfo ['name'];
  4713. }
  4714. $receiptLog->username = $this->staff [0] ['username'];
  4715. $receiptLog->uid = $this->staff [0] ['sid'];
  4716. $receiptLog->date = date ( "Y-m-d" );
  4717. $receiptLog->opinion = $opinion;
  4718. $receiptLog->img = $this->staff [0] ['avatar'];
  4719. $receiptLog->status = 1;
  4720. $receiptLog->rid = $rid;
  4721. $receiptLog->insert ();
  4722. }
  4723. if (isset ( $verifyStaff ['final'] )) { // rDetail
  4724. $receipt->status = 3;
  4725. $receipt->verifyBreakup = $verifyString;
  4726. $receiptDetailObj->status = 3;
  4727. $receiptDetailObj->update ( array (
  4728. 'where' => 'rid=' . $rid
  4729. ) );
  4730. // 微信企业号通知
  4731. $this->setWXMsg ( $rid, 3 );
  4732. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  4733. $receipt->status = 6;
  4734. $receipt->pastDate = date ( "Y-m-d" );
  4735. $receipt->isBK = 1;
  4736. $loanReceipt->verifyBreakup = $verifyString;
  4737. $loanReceipt->status = 1;
  4738. $loanReceipt->pastDate = date ( "Y-m-d" );
  4739. //生成流水后 不更新汇款金额
  4740. Doo::loadModel ( 'wasteBook' );
  4741. $wasteBook = new wasteBook ();
  4742. $wbDetail = $wasteBook->getWateBookByAD ( 1, $rid );
  4743. if (empty($wbDetail)){
  4744. $loanReceipt->amount = $receiptDetail ['amount'];
  4745. }
  4746. $loanReceipt->update ( array (
  4747. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  4748. ) );
  4749. // 微信企业号通知
  4750. $this->setWXMsg ( $rid, 1 );
  4751. }
  4752. $receipt->amount = $receiptDetail['sum'];
  4753. $receipt->update ( array (
  4754. 'where' => ' rid = ' . $rid
  4755. ) );
  4756. // 进入下一条审批费用新加需求
  4757. $vidList = array ();
  4758. $verifyDetail = $verify->find ( array (
  4759. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  4760. 'asArray' => true
  4761. ) );
  4762. foreach ( $verifyDetail as $key => $value ) {
  4763. array_push ( $vidList, $value ['vid'] );
  4764. }
  4765. $vid = implode ( ",", $vidList );
  4766. if (empty ( $verifyDetail ))
  4767. $vid = 0;
  4768. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  4769. $receipt = new receipt ();
  4770. $rd = $receipt->getOne ( array (
  4771. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  4772. 'asc' => 'rid',
  4773. 'asArray' => true
  4774. ) );
  4775. if (empty ( $rd )) {
  4776. return '/approvalExpenses/pendApproval';
  4777. }
  4778. if ($rd ['Rtype'] == 1) {
  4779. if ($rd ['isBK'] == 1) {
  4780. return '/receiptburEdi/' . $rd ['rid'];
  4781. } else {
  4782. return '/expensesEdi/' . $rd ['rid'];
  4783. }
  4784. } elseif ($rd ['Rtype'] == 2) {
  4785. return '/remitApproval/' . $rd ['rid'];
  4786. } else {
  4787. return '/receiptburEdi/' . $rd ['rid'];
  4788. }
  4789. // return "/approvalExpenses/pendApproval";
  4790. }
  4791. }
  4792. function ajaxExamineExe() {
  4793. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4794. Doo::loadModel ( 'receipt' );
  4795. $receipt = new receipt ();
  4796. Doo::loadClass ( 'XDeode' );
  4797. $XDeode = new XDeode ( 5 );
  4798. if (! empty ( $rid )) {
  4799. $rLRes = $receipt->find ( array (
  4800. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  4801. 'asArray' => true
  4802. ) );
  4803. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  4804. echo json_encode ( array (
  4805. 'status' => 1,
  4806. 'receipt' => $rLRes [0]
  4807. ) );
  4808. die ();
  4809. }
  4810. echo json_encode ( array (
  4811. 'status' => 0,
  4812. 'receipt' => array ()
  4813. ) );
  4814. die ();
  4815. }
  4816. function implement() {
  4817. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4818. $Rtype = isset ( $this->params ['Rtype'] ) ? $this->params ['Rtype'] : '';
  4819. Doo::loadClass ( 'XDeode' );
  4820. $XDeode = new XDeode ( 5 );
  4821. Doo::loadModel ( 'receipt' );
  4822. $receipt = new receipt ();
  4823. Doo::loadModel ( 'L_category' );
  4824. $Lcategory = new L_category ();
  4825. Doo::loadModel ( 'verify' );
  4826. $verify = new verify ();
  4827. Doo::loadModel ( 'staff' );
  4828. $staff = new staff ();
  4829. Doo::loadModel ( "execute" );
  4830. $execute = new execute ();
  4831. $rid = $XDeode->decode ( $rid );
  4832. $receiptList = $receipt->find ( array (
  4833. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  4834. 'desc' => 'rid',
  4835. 'asArray' => true
  4836. ) );
  4837. Doo::loadModel ( 'loanReceipt' );
  4838. $loanReceipt = new loanReceipt ();
  4839. // print_r($receiptList);
  4840. $loanList = array ();
  4841. if (! isset ( $receiptList ))
  4842. $loanList = $loanReceipt->find ( array (
  4843. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4844. 'desc' => 'rid',
  4845. 'asArray' => true
  4846. ) );
  4847. $Locate = 0;
  4848. $roleId = 0;
  4849. $button = 0;
  4850. foreach ( $loanList as $key => $value ) {
  4851. $loanList [$key] ['Locate'] = $Locate;
  4852. $Locate ++;
  4853. $loanList [$key] ['reviseDetail'] = array ();
  4854. if (! empty ( $value ['reviseDetail'] ))
  4855. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4856. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4857. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4858. $categoryDetil = $Lcategory->getOne ( array (
  4859. 'where' => 'cid=' . $value ['cid'],
  4860. 'asArray' => true
  4861. ) );
  4862. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4863. // 检测编辑状态
  4864. $verifyList = $verify->getOne ( array (
  4865. 'where' => 'vid=' . $value ['verify'],
  4866. 'asArray' => true
  4867. ) );
  4868. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4869. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4870. Doo::loadModel ( 'role' );
  4871. $role = new role ();
  4872. $flag = true;
  4873. $roleKey = 0;
  4874. $endStaffArray = array ();
  4875. $roleArrayCopy = array ();
  4876. foreach ( $verifyList as $k => $v ) {
  4877. // init verifyStaff
  4878. if ($v [1] == 'ROLE') {
  4879. if (! empty ( $verifyStaff )) {
  4880. $endStaffArray = end ( $verifyStaff );
  4881. // if ($v[0]==$endStaffArray['nextStaff']){
  4882. // $roleId=$v[0];
  4883. // }
  4884. }
  4885. $roleVerify = json_decode ( $v [3], true );
  4886. $roleKey = $k;
  4887. $roleArray = array ();
  4888. $rolename = $role->getOne ( array (
  4889. 'where' => 'rid=' . $v [0],
  4890. 'asArray' => true
  4891. ) );
  4892. foreach ( $roleVerify as $o => $p ) {
  4893. $staffID = explode ( '_', $p );
  4894. $staffInfo = $staff->getOne ( array (
  4895. 'where' => 'sid=' . $staffID [0],
  4896. 'asArray' => true
  4897. ) );
  4898. // print_r($staffID);
  4899. $exp = array (
  4900. 0 => $staffInfo ['sid'],
  4901. 1 => $staffID [1],
  4902. 2 => $staffInfo ['avatar'],
  4903. 'date' => '',
  4904. 'date' => '',
  4905. 'opinion' => '',
  4906. 'status' => '',
  4907. 'rolename' => $rolename ['name']
  4908. );
  4909. array_push ( $roleArray, $exp );
  4910. }
  4911. $roleArrayCopy [$v [0]] = $roleArray;
  4912. // $verifyList[$k]['roleArray']=$roleArray;
  4913. }
  4914. $verifyList [$k] ['date'] = "";
  4915. $verifyList [$k] ['opinion'] = "";
  4916. $verifyList [$k] ['status'] = "";
  4917. if (empty ( $verifyStaff )) {
  4918. $verifyList [$k] ['date'] = "";
  4919. $verifyList [$k] ['opinion'] = "";
  4920. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4921. $verifyList [$k] ['status'] = 4;
  4922. $flag = false;
  4923. }
  4924. } else {
  4925. foreach ( $verifyStaff as $m => $u ) {
  4926. if ($v [0] == $m) {
  4927. $verifyList [$k] ['date'] = $u ['date'];
  4928. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4929. $verifyList [$k] ['status'] = $u ['status'];
  4930. $flag = false;
  4931. break;
  4932. }
  4933. }
  4934. $endStaffArray = end ( $verifyStaff );
  4935. if (isset ( $endStaffArray ['ROLE'] )) {
  4936. } else {
  4937. // $endKey=key($verifyStaff);
  4938. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4939. // $button=4;
  4940. // $verifyList[$k]['status']=4;
  4941. // }
  4942. }
  4943. }
  4944. }
  4945. $rolename ['name'] = '';
  4946. if (! empty ( $roleId )) {
  4947. Doo::loadModel ( 'role' );
  4948. $role = new role ();
  4949. $rolename = $role->getOne ( array (
  4950. 'where' => 'rid=' . $roleId,
  4951. 'asArray' => true
  4952. ) );
  4953. }
  4954. if (! empty ( $verifyStaff ))
  4955. $endStaffArray = end ( $verifyStaff );
  4956. $KOP = false;
  4957. foreach ( $roleArrayCopy as $P => $A ) {
  4958. foreach ( $A as $MKI => $AVL ) {
  4959. if (! empty ( $verifyStaff )) {
  4960. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4961. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4962. $button = 4;
  4963. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4964. }
  4965. foreach ( $verifyStaff as $m => $u ) {
  4966. $AVLFK = $AVL [0] . '_R';
  4967. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4968. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4969. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4970. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4971. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4972. break;
  4973. }
  4974. }
  4975. } else {
  4976. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4977. $button = 4;
  4978. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4979. }
  4980. }
  4981. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4982. $KOP = true;
  4983. }
  4984. }
  4985. foreach ( $roleArrayCopy as $k => $v ) {
  4986. foreach ( $verifyList as $m => $n ) {
  4987. if ($n [0] == $k) {
  4988. array_splice ( $verifyList, $m, 1, $v );
  4989. }
  4990. }
  4991. }
  4992. $loanList [$key] ['verifyList'] = $verifyList;
  4993. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  4994. 'where' => 'sid=' . $value ['staff'],
  4995. 'asArray' => true
  4996. ) );
  4997. }
  4998. $data ['loanList'] = $loanList;
  4999. $Locate = 0;
  5000. $roleId = 0;
  5001. $button = 0;
  5002. Doo::loadClass ( 'XDeode' );
  5003. $XDeode = new XDeode ( 5 );
  5004. foreach ( $receiptList as $key => $value ) {
  5005. $receiptList[$key]['ridKey']=$XDeode->encode ( $value['rid'] );
  5006. $button2 = 0;
  5007. $receiptList [$key] ['Locate'] = $Locate;
  5008. $Locate ++;
  5009. $receiptList [$key] ['reviseDetail'] = array ();
  5010. if (! empty ( $value ['reviseDetail'] ))
  5011. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5012. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5013. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5014. $categoryDetil = $Lcategory->getOne ( array (
  5015. 'where' => 'cid=' . $value ['cid'],
  5016. 'asArray' => true
  5017. ) );
  5018. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5019. $executeList = json_decode ( $value ['executeCopy'], true );
  5020. $executeStaff = array ();
  5021. if (! empty ( $value ['executeStaff'] ))
  5022. $executeStaff = json_decode ( $value ['executeStaff'], true );
  5023. if (isset ( $executeList )) {
  5024. foreach ( $executeList as $op => $lo ) {
  5025. $executeList [$op] ['date'] = "";
  5026. $executeList [$op] ['opinion'] = "";
  5027. $executeList [$op] ['status'] = "";
  5028. foreach ( $executeStaff as $m => $u ) {
  5029. if ($lo [0] == $m) {
  5030. $executeList [$op] ['date'] = $u ['date'];
  5031. $executeList [$op] ['opinion'] = $u ['opinion'];
  5032. $executeList [$op] ['status'] = $u ['status'];
  5033. break;
  5034. }
  5035. }
  5036. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  5037. $button2 = 1;
  5038. $executeList [$op] ['status'] = 4;
  5039. }
  5040. }
  5041. }
  5042. // 检测编辑状态
  5043. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  5044. $verifyList ['staff'] = $value ['verifyBreakup'];
  5045. } else
  5046. $verifyList = $verify->getOne ( array (
  5047. 'where' => 'vid=' . $value ['verify'],
  5048. 'asArray' => true
  5049. ) );
  5050. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5051. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5052. Doo::loadModel ( 'role' );
  5053. $role = new role ();
  5054. if ($verifyList == NULL)
  5055. $verifyList = array ();
  5056. $flag = true;
  5057. $roleKey = 0;
  5058. $endStaffArray = array ();
  5059. $roleArrayCopy = array ();
  5060. foreach ( $verifyList as $k => $v ) {
  5061. // init verifyStaff
  5062. if ($v [1] == 'ROLE') {
  5063. if (! empty ( $verifyStaff )) {
  5064. $endStaffArray = end ( $verifyStaff );
  5065. // if ($v[0]==$endStaffArray['nextStaff']){
  5066. // $roleId=$v[0];
  5067. // }
  5068. }
  5069. $roleVerify = json_decode ( $v [3], true );
  5070. $roleKey = $k;
  5071. $roleArray = array ();
  5072. $rolename = $role->getOne ( array (
  5073. 'where' => 'rid=' . $v [0],
  5074. 'asArray' => true
  5075. ) );
  5076. foreach ( $roleVerify as $o => $p ) {
  5077. $staffID = explode ( '_', $p );
  5078. $staffInfo = $staff->getOne ( array (
  5079. 'where' => 'sid=' . $staffID [0],
  5080. 'asArray' => true
  5081. ) );
  5082. // print_r($staffID);
  5083. $exp = array (
  5084. 0 => $staffInfo ['sid'],
  5085. 1 => $staffID [1],
  5086. 2 => $staffInfo ['avatar'],
  5087. 'date' => '',
  5088. 'date' => '',
  5089. 'opinion' => '',
  5090. 'status' => '',
  5091. 'rolename' => $rolename ['name']
  5092. );
  5093. array_push ( $roleArray, $exp );
  5094. }
  5095. $roleArrayCopy [$v [0]] = $roleArray;
  5096. // $verifyList[$k]['roleArray']=$roleArray;
  5097. }
  5098. $verifyList [$k] ['date'] = "";
  5099. $verifyList [$k] ['opinion'] = "";
  5100. $verifyList [$k] ['status'] = "";
  5101. if (empty ( $verifyStaff )) {
  5102. $verifyList [$k] ['date'] = "";
  5103. $verifyList [$k] ['opinion'] = "";
  5104. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5105. $verifyList [$k] ['status'] = 4;
  5106. $flag = false;
  5107. }
  5108. } else {
  5109. foreach ( $verifyStaff as $m => $u ) {
  5110. if ($v [0] == $m) {
  5111. $verifyList [$k] ['date'] = $u ['date'];
  5112. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5113. $verifyList [$k] ['status'] = $u ['status'];
  5114. $flag = false;
  5115. break;
  5116. }
  5117. }
  5118. $endStaffArray = end ( $verifyStaff );
  5119. if (isset ( $endStaffArray ['ROLE'] )) {
  5120. } else {
  5121. // $endKey=key($verifyStaff);
  5122. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5123. // $button=4;
  5124. // $verifyList[$k]['status']=4;
  5125. // }
  5126. }
  5127. }
  5128. }
  5129. $rolename ['name'] = '';
  5130. if (! empty ( $roleId )) {
  5131. Doo::loadModel ( 'role' );
  5132. $role = new role ();
  5133. $rolename = $role->getOne ( array (
  5134. 'where' => 'rid=' . $roleId,
  5135. 'asArray' => true
  5136. ) );
  5137. }
  5138. if (! empty ( $verifyStaff ))
  5139. $endStaffArray = end ( $verifyStaff );
  5140. $KOP = false;
  5141. foreach ( $roleArrayCopy as $P => $A ) {
  5142. foreach ( $A as $MKI => $AVL ) {
  5143. if (! empty ( $verifyStaff )) {
  5144. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5145. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5146. $button = 4;
  5147. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5148. }
  5149. foreach ( $verifyStaff as $m => $u ) {
  5150. $AVLFK = $AVL [0] . '_R';
  5151. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5152. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5153. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5154. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5155. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5156. break;
  5157. }
  5158. }
  5159. } else {
  5160. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5161. $button = 4;
  5162. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5163. }
  5164. }
  5165. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5166. $KOP = true;
  5167. }
  5168. }
  5169. foreach ( $roleArrayCopy as $k => $v ) {
  5170. foreach ( $verifyList as $m => $n ) {
  5171. if ($n [0] == $k) {
  5172. array_splice ( $verifyList, $m, 1, $v );
  5173. }
  5174. }
  5175. }
  5176. $receiptList [$key] ['verifyList'] = $verifyList;
  5177. $receiptList [$key] ['executeList'] = $executeList;
  5178. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5179. 'where' => 'sid=' . $value ['staff'],
  5180. 'asArray' => true
  5181. ) );
  5182. $receiptList [$key] ['button2'] = $button2;
  5183. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5184. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5185. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5186. $receiptList [$key] ['relust'] = $relust;
  5187. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  5188. $receiptList [$key] ['amountABS'] = abs ( $value ['amount'] );
  5189. }
  5190. //执行人是否是最后一位
  5191. $executeCopy = json_decode ( $receiptList [0] ['executeCopy'], true );
  5192. $executeStaff = json_decode ( $receiptList [0] ['executeStaff'], true );
  5193. $executePrimary=count($executeCopy)-1;
  5194. $lastOne=true;
  5195. if($executePrimary!=count($executeStaff)){
  5196. $lastOne=false;
  5197. }
  5198. $data['lastOne']=$lastOne;
  5199. // 是否写入过流水
  5200. $accountType = 0;
  5201. if ($receiptList [0] ['Rtype'] == 0) {
  5202. $accountType = 3;
  5203. } elseif ($receiptList [0] ['Rtype'] == 1) {
  5204. if (!empty($receiptList [0]['accountItem']) )
  5205. $accountType = 2;
  5206. else
  5207. $accountType = 1;
  5208. } elseif ($receiptList [0] ['Rtype'] == 2) {
  5209. $accountType = 4;
  5210. } elseif ($receiptList [0] ['Rtype'] == 3) {
  5211. $accountType = 12;
  5212. }
  5213. Doo::loadModel ( 'wasteBook' );
  5214. $wasteBook = new wasteBook ();
  5215. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $receiptList [0] ['rid'] );
  5216. $data ['wbDetail'] = $wbDetail;
  5217. $wbDetailLoan=array();
  5218. if ($accountType==2){
  5219. $wbDetailLoan = $wasteBook->getWateBookByAD ( 1, $receiptList [0] ['rid'] );
  5220. }
  5221. $data ['wbDetailLoan'] = $wbDetailLoan;
  5222. $data['inputDate']=date ( "Y-m-d H:i:s" );
  5223. //print_r($wbDetail);
  5224. $data ['receiptList'] = $receiptList;
  5225. $data ['memu'] = "receipt";
  5226. $data ['staff'] = $this->staff;
  5227. $data ['receiptMemu'] = 'implement';
  5228. $data ['verifyId'] = $this->verifyId;
  5229. $data ['executeId'] = $this->executeId;
  5230. if ($Rtype=="loan"){
  5231. $this->render ( "/receipt/receiptImplementLoan", $data );
  5232. }elseif($Rtype=="receipt"){
  5233. $this->render ( "/receipt/receiptImplement", $data );
  5234. }elseif($Rtype=="public"){
  5235. $this->render ( "/receipt/receiptImplementPublic", $data );
  5236. }else{
  5237. //$this->render ( "/admin/implement", $data );
  5238. }
  5239. }
  5240. function implementDo() {
  5241. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  5242. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  5243. // $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  5244. // $accountBank = $this->get_args ( 'accountBank' ) ? $this->get_args ( 'accountBank' ) : "";
  5245. // $ab = '';
  5246. // if ($accountBank == 'CGBDeposit')
  5247. // $ab = '纵横广发';
  5248. // elseif ($accountBank == 'ICBCDeposit')
  5249. // $ab = '纵横工行';
  5250. // elseif ($accountBank == 'HUADeposit')
  5251. // $ab = '华润银行';
  5252. // elseif ($accountBank == 'PersonalDeposit')
  5253. // $ab = '个人广发';
  5254. // if (empty ( $ab ))
  5255. // die ( 'illegal request--22' );
  5256. if (! empty ( $rid )) {
  5257. Doo::loadModel ( 'receipt' );
  5258. $receipt = new receipt ();
  5259. Doo::loadClass ( 'XDeode' );
  5260. $XDeode = new XDeode ( 5 );
  5261. $rid=$XDeode->decode($rid);
  5262. if (!is_numeric($rid)){
  5263. die;
  5264. }
  5265. // $rinfo = $receipt->getOne ( array (
  5266. // 'where' => 'rid=' . $rid,
  5267. // 'asArray' => true
  5268. // ) );
  5269. $rinfo = $receipt->getReceiptByRid ( $rid );
  5270. // $accountType = '';
  5271. // if ($rinfo ['Rtype'] == 1) {
  5272. // if ($rinfo ['loanRid'] != 0)//判断有问题
  5273. // $accountType = 2;
  5274. // else
  5275. // $accountType = 1;
  5276. // } elseif ($rinfo ['Rtype'] == 2) {
  5277. // $accountType = 4;
  5278. // } elseif ($rinfo ['Rtype'] == 0)
  5279. // $accountType = 3;
  5280. // if (empty ( $accountType ))
  5281. // die ( 'illegal request' );
  5282. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  5283. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  5284. if (empty ( $executeStaff )) {
  5285. $executeStaff = array (
  5286. $this->staff [0] ['sid'] => array (
  5287. 'date' => date ( 'Y-m-d' ),
  5288. 'opinion' => $implementOpinions,
  5289. 'status' => 1
  5290. )
  5291. );
  5292. } else {
  5293. $executeStaff [$this->staff [0] ['sid']] = array (
  5294. 'date' => date ( 'Y-m-d' ),
  5295. 'opinion' => $implementOpinions,
  5296. 'status' => 1
  5297. );
  5298. }
  5299. if (count ( $executeStaff ) == count ( $executeCopy )) {
  5300. $receipt->executeStaff = json_encode ( $executeStaff );
  5301. $receipt->status = 8;
  5302. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  5303. $receipt->status = 9;
  5304. if ($rinfo ['status'] == 6) {
  5305. $receipt->loanDate = date ( "Y-m-d" );
  5306. }
  5307. $receipt->executeDate = date ( "Y-m-d" );
  5308. } else {
  5309. $receipt->executeStaff = json_encode ( $executeStaff );
  5310. }
  5311. //$receipt->amount = $amount;
  5312. $receipt->update ( array (
  5313. 'where' => 'rid=' . $rid
  5314. ) );
  5315. // 公司流水记录
  5316. // Doo::loadModel ( 'wasteBook' );
  5317. // $wasteBook = new wasteBook ();
  5318. // $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountType, $rid );
  5319. // // 银行
  5320. // if (empty ( $abDetail ) && ! empty ( $amount )) {
  5321. // $item = array (
  5322. // 'dataID' => $rid,
  5323. // 'expensesType' => 2,
  5324. // 'accountType' => $accountType,
  5325. // 'accountPriceShow' => $amount,
  5326. // 'accountPrice' => - $amount,
  5327. // 'accountBank' => $accountBank,
  5328. // 'category' => $rinfo ['category'] [0] ['title'],
  5329. // 'cid' => $rinfo ['category'] [0] ['cid'],
  5330. // 'name' => $rinfo ['staffDetail'] ['username'],
  5331. // 'sid' => $rinfo ['staffDetail'] ['sid'],
  5332. // 'inputDate' => date ( "Y-m-d H:i:s" )
  5333. // );
  5334. // $wasteBook->setAccountBookStatistics ( $item );
  5335. // }
  5336. }
  5337. //$ridKey = $XDeode->encode ( $rid );
  5338. return "/hisImplement";
  5339. // return "/implement/" . $ridKey . ".html";
  5340. }
  5341. function receiptburEdi() {
  5342. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5343. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5344. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5345. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5346. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5347. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5348. if (empty ( $status ))
  5349. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5350. $vidList = array ();
  5351. $button = 0;
  5352. Doo::loadModel ( 'verify' );
  5353. Doo::loadModel ( 'receipt' );
  5354. Doo::loadModel ( 'staff' );
  5355. $staff = new staff ();
  5356. $receipt = new receipt ();
  5357. $verify = new verify ();
  5358. Doo::loadModel ( 'L_category' );
  5359. $Lcategory = new L_category ();
  5360. Doo::loadModel ( 'enclosur' );
  5361. $enclosur = new enclosur ();
  5362. Doo::loadModel ( 'loanReceipt' );
  5363. $loanReceipt = new loanReceipt ();
  5364. // user verify ID
  5365. $verifyDetail = $verify->find ( array (
  5366. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5367. 'asArray' => true
  5368. ) );
  5369. foreach ( $verifyDetail as $key => $value ) {
  5370. array_push ( $vidList, $value ['vid'] );
  5371. }
  5372. $vid = implode ( ",", $vidList );
  5373. if (empty ( $verifyDetail ))
  5374. $vid = 0;
  5375. $categoryList = $Lcategory->find ( array (
  5376. 'asArray' => true
  5377. ) );
  5378. $staffList = $staff->find ( array (
  5379. 'where' => 'cid=' . $cid,
  5380. 'asArray' => true
  5381. ) );
  5382. $ap = "";
  5383. if ($status == 4) {
  5384. $ap = 4;
  5385. $status = 2;
  5386. }
  5387. // get Receipt By verifyID status 2
  5388. $receiptList = $receipt->find ( array (
  5389. 'where' => 'rid =' . $rid . ' and status=2',
  5390. 'desc' => 'rid',
  5391. 'asArray' => true
  5392. ) );
  5393. if (empty ( $receiptList )) {
  5394. die ( 'illegal request' );
  5395. }
  5396. $loanList = $loanReceipt->find ( array (
  5397. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  5398. 'desc' => 'rid',
  5399. 'asArray' => true
  5400. ) );
  5401. $data ['explanation'] = '';
  5402. if (! empty ( $loanList ))
  5403. $data ['explanation'] = $loanList [0] ['explanation'];
  5404. $Locate = 0;
  5405. $roleId = 0;
  5406. $button = 0;
  5407. foreach ( $loanList as $key => $value ) {
  5408. $loanList [$key] ['Locate'] = $Locate;
  5409. $Locate ++;
  5410. $loanList [$key] ['reviseDetail'] = array ();
  5411. if (! empty ( $value ['reviseDetail'] ))
  5412. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5413. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5414. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5415. $categoryDetil = $Lcategory->getOne ( array (
  5416. 'where' => 'cid=' . $value ['cid'],
  5417. 'asArray' => true
  5418. ) );
  5419. $loanList [$key] ['category'] = $categoryDetil ['title'];
  5420. // 检测编辑状态
  5421. $verifyList = $verify->getOne ( array (
  5422. 'where' => 'vid=' . $value ['verify'],
  5423. 'asArray' => true
  5424. ) );
  5425. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5426. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5427. Doo::loadModel ( 'role' );
  5428. $role = new role ();
  5429. $flag = true;
  5430. $roleKey = 0;
  5431. $endStaffArray = array ();
  5432. $roleArrayCopy = array ();
  5433. foreach ( $verifyList as $k => $v ) {
  5434. // init verifyStaff
  5435. if ($v [1] == 'ROLE') {
  5436. if (! empty ( $verifyStaff )) {
  5437. $endStaffArray = end ( $verifyStaff );
  5438. }
  5439. $roleVerify = json_decode ( $v [3], true );
  5440. $roleKey = $k;
  5441. $roleArray = array ();
  5442. $rolename = $role->getOne ( array (
  5443. 'where' => 'rid=' . $v [0],
  5444. 'asArray' => true
  5445. ) );
  5446. foreach ( $roleVerify as $o => $p ) {
  5447. $staffID = explode ( '_', $p );
  5448. $staffInfo = $staff->getOne ( array (
  5449. 'where' => 'sid=' . $staffID [0],
  5450. 'asArray' => true
  5451. ) );
  5452. // print_r($staffID);
  5453. $exp = array (
  5454. 0 => $staffInfo ['sid'],
  5455. 1 => $staffID [1],
  5456. 2 => $staffInfo ['avatar'],
  5457. 'date' => '',
  5458. 'date' => '',
  5459. 'opinion' => '',
  5460. 'status' => '',
  5461. 'rolename' => $rolename ['name']
  5462. );
  5463. array_push ( $roleArray, $exp );
  5464. }
  5465. $roleArrayCopy [$v [0]] = $roleArray;
  5466. // $verifyList[$k]['roleArray']=$roleArray;
  5467. }
  5468. $verifyList [$k] ['date'] = "";
  5469. $verifyList [$k] ['opinion'] = "";
  5470. $verifyList [$k] ['status'] = "";
  5471. if (empty ( $verifyStaff )) {
  5472. $verifyList [$k] ['date'] = "";
  5473. $verifyList [$k] ['opinion'] = "";
  5474. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5475. $verifyList [$k] ['status'] = 4;
  5476. $flag = false;
  5477. }
  5478. } else {
  5479. foreach ( $verifyStaff as $m => $u ) {
  5480. if ($v [0] == $m) {
  5481. $verifyList [$k] ['date'] = $u ['date'];
  5482. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5483. $verifyList [$k] ['status'] = $u ['status'];
  5484. $flag = false;
  5485. break;
  5486. }
  5487. }
  5488. $endStaffArray = end ( $verifyStaff );
  5489. if (isset ( $endStaffArray ['ROLE'] )) {
  5490. } else {
  5491. }
  5492. }
  5493. }
  5494. $rolename ['name'] = '';
  5495. if (! empty ( $roleId )) {
  5496. Doo::loadModel ( 'role' );
  5497. $role = new role ();
  5498. $rolename = $role->getOne ( array (
  5499. 'where' => 'rid=' . $roleId,
  5500. 'asArray' => true
  5501. ) );
  5502. }
  5503. if (! empty ( $verifyStaff ))
  5504. $endStaffArray = end ( $verifyStaff );
  5505. $KOP = false;
  5506. foreach ( $roleArrayCopy as $P => $A ) {
  5507. foreach ( $A as $MKI => $AVL ) {
  5508. if (! empty ( $verifyStaff )) {
  5509. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5510. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5511. $button = 4;
  5512. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5513. }
  5514. foreach ( $verifyStaff as $m => $u ) {
  5515. $AVLFK = $AVL [0] . '_R';
  5516. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5517. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5518. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5519. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5520. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5521. break;
  5522. }
  5523. }
  5524. } else {
  5525. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5526. $button = 4;
  5527. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5528. }
  5529. }
  5530. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5531. $KOP = true;
  5532. }
  5533. }
  5534. foreach ( $roleArrayCopy as $k => $v ) {
  5535. foreach ( $verifyList as $m => $n ) {
  5536. if ($n [0] == $k) {
  5537. array_splice ( $verifyList, $m, 1, $v );
  5538. }
  5539. }
  5540. }
  5541. $loanList [$key] ['verifyList'] = $verifyList;
  5542. }
  5543. $htmlLoan = '';
  5544. $data ['loanReceiptDate'] = '';
  5545. if (isset ( $loanList [0] )) {
  5546. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  5547. if ($value ['status'] == 1)
  5548. $htmlLoan .= '<li class="done" >';
  5549. elseif ($value ['status'] == 3)
  5550. $htmlLoan .= '<li class="undone" >';
  5551. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  5552. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  5553. if (isset ( $value ['rolename'] ))
  5554. $htmlLoan .= $value ['rolename'];
  5555. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  5556. }
  5557. $data ['loanDate'] = $loanList [0] ['date'];
  5558. } else {
  5559. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  5560. }
  5561. $data ['htmlLoan'] = $htmlLoan;
  5562. // $data ['LoanReceipt']=$loanList[0];
  5563. // print_r($loanList);
  5564. $Locate = 0;
  5565. $roleId = 0;
  5566. $button = 0;
  5567. if ($ap == 4)
  5568. $status = 4;
  5569. Doo::loadClass ( 'XDeode' );
  5570. $XDeode = new XDeode ( 5 );
  5571. foreach ( $receiptList as $key => $value ) {
  5572. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  5573. $receiptList [$key] ['Locate'] = $Locate;
  5574. $Locate ++;
  5575. $receiptList [$key] ['reviseDetail'] = array ();
  5576. // 调整金额 代码调整
  5577. if (! empty ( $value ['reviseDetail'] )) {
  5578. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  5579. foreach ( $reviseDetail as $ry => $re ) {
  5580. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  5581. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  5582. }
  5583. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  5584. // print_r($reviseDetail);
  5585. }
  5586. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5587. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5588. $categoryDetil = $Lcategory->getOne ( array (
  5589. 'where' => 'cid=' . $value ['cid'],
  5590. 'asArray' => true
  5591. ) );
  5592. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5593. // 检测编辑状态
  5594. $verifyList = $verify->getOne ( array (
  5595. 'where' => 'vid=' . $value ['verify'],
  5596. 'asArray' => true
  5597. ) );
  5598. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5599. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5600. Doo::loadModel ( 'role' );
  5601. $role = new role ();
  5602. // print_r($verifyList);
  5603. $flag = true;
  5604. $roleKey = 0;
  5605. $endStaffArray = array ();
  5606. $roleArrayCopy = array ();
  5607. foreach ( $verifyList as $k => $v ) {
  5608. // init verifyStaff
  5609. if ($v [1] == 'ROLE') {
  5610. if (! empty ( $verifyStaff )) {
  5611. $endStaffArray = end ( $verifyStaff );
  5612. if ($v [0] == $endStaffArray ['nextStaff']) {
  5613. $roleId = $v [0];
  5614. }
  5615. }
  5616. $roleVerify = json_decode ( $v [3], true );
  5617. $roleKey = $k;
  5618. $roleArray = array ();
  5619. $rolename = $role->getOne ( array (
  5620. 'where' => 'rid=' . $v [0],
  5621. 'asArray' => true
  5622. ) );
  5623. foreach ( $roleVerify as $o => $p ) {
  5624. $staffID = explode ( '_', $p );
  5625. $staffInfo = $staff->getOne ( array (
  5626. 'where' => 'sid=' . $staffID [0],
  5627. 'asArray' => true
  5628. ) );
  5629. // print_r($staffID);
  5630. $exp = array (
  5631. 0 => $staffInfo ['sid'],
  5632. 1 => $staffID [1],
  5633. 2 => $staffInfo ['avatar'],
  5634. 'date' => '',
  5635. 'date' => '',
  5636. 'opinion' => '',
  5637. 'status' => '',
  5638. 'rolename' => $rolename ['name']
  5639. );
  5640. array_push ( $roleArray, $exp );
  5641. }
  5642. $roleArrayCopy [$v [0]] = $roleArray;
  5643. // $verifyList[$k]['roleArray']=$roleArray;
  5644. }
  5645. // print_r($roleArray);
  5646. $verifyList [$k] ['date'] = "";
  5647. $verifyList [$k] ['opinion'] = "";
  5648. $verifyList [$k] ['status'] = "";
  5649. if (empty ( $verifyStaff )) {
  5650. $verifyList [$k] ['date'] = "";
  5651. $verifyList [$k] ['opinion'] = "";
  5652. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5653. $verifyList [$k] ['status'] = 4;
  5654. $button = 4;
  5655. $flag = false;
  5656. }
  5657. } else {
  5658. foreach ( $verifyStaff as $m => $u ) {
  5659. if ($v [0] == $m) {
  5660. $verifyList [$k] ['date'] = $u ['date'];
  5661. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5662. $verifyList [$k] ['status'] = $u ['status'];
  5663. $flag = false;
  5664. break;
  5665. }
  5666. }
  5667. $endStaffArray = end ( $verifyStaff );
  5668. if (isset ( $endStaffArray ['ROLE'] )) {
  5669. } else {
  5670. $endKey = key ( $verifyStaff );
  5671. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5672. $button = 4;
  5673. $verifyList [$k] ['status'] = 4;
  5674. }
  5675. }
  5676. }
  5677. }
  5678. $rolename ['name'] = '';
  5679. if (! empty ( $roleId )) {
  5680. Doo::loadModel ( 'role' );
  5681. $role = new role ();
  5682. $rolename = $role->getOne ( array (
  5683. 'where' => 'rid=' . $roleId,
  5684. 'asArray' => true
  5685. ) );
  5686. }
  5687. if (! empty ( $verifyStaff ))
  5688. $endStaffArray = end ( $verifyStaff );
  5689. $KOP = false;
  5690. foreach ( $roleArrayCopy as $P => $A ) {
  5691. foreach ( $A as $MKI => $AVL ) {
  5692. if (! empty ( $verifyStaff )) {
  5693. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5694. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5695. $button = 4;
  5696. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5697. }
  5698. foreach ( $verifyStaff as $m => $u ) {
  5699. $AVLFK = $AVL [0] . '_R';
  5700. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5701. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5702. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5703. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5704. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5705. break;
  5706. }
  5707. }
  5708. } else {
  5709. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5710. $button = 4;
  5711. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5712. }
  5713. }
  5714. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5715. $KOP = true;
  5716. }
  5717. }
  5718. foreach ( $roleArrayCopy as $k => $v ) {
  5719. foreach ( $verifyList as $m => $n ) {
  5720. if ($n [0] == $k) {
  5721. array_splice ( $verifyList, $m, 1, $v );
  5722. }
  5723. }
  5724. }
  5725. // print_r($verifyList);
  5726. $receiptList [$key] ['verifyList'] = $verifyList;
  5727. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5728. 'where' => 'sid=' . $value ['staff'],
  5729. 'asArray' => true
  5730. ) );
  5731. $receiptList [$key] ['button'] = $button;
  5732. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5733. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5734. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5735. $receiptList [$key] ['relust'] = $relust;
  5736. $receiptList [$key] ['relustABS'] = abs ( $relust );
  5737. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  5738. }
  5739. //print_r($receiptList);die;
  5740. // $data['verifyDetail']=$verifyDetail;
  5741. $mothHtml = "";
  5742. for($i = 1; $i <= 12; $i ++) {
  5743. if ($month == $i)
  5744. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5745. else
  5746. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5747. }
  5748. // 获取审批日志
  5749. Doo::loadModel ( 'receiptLog' );
  5750. $receiptLog = new receiptLog ();
  5751. $rlList = array ();
  5752. $rlInfo = $receiptLog->getOne ( array (
  5753. 'where' => 'rid=' . $rid . ' and status=4',
  5754. 'asArray' => true
  5755. ) );
  5756. $tijdate = $receiptLog->getOne ( array (
  5757. 'where' => 'rid=' . $rid . ' and status=2',
  5758. 'asc' => 'rlid',
  5759. 'asArray' => true
  5760. ) );
  5761. if (! empty ( $rlInfo )) {
  5762. $rlList = $receiptLog->find ( array (
  5763. 'where' => 'rid=' . $rid,
  5764. 'asc' => 'rlid',
  5765. 'asArray' => true
  5766. ) );
  5767. }
  5768. // echo $rid;
  5769. // print_r($receiptList);
  5770. $receiptList [0] ['rlList'] = $rlList;
  5771. // print_r($receiptList);
  5772. $enclosurList = $enclosur->find ( array (
  5773. 'where' => 'rid=' . $rid,
  5774. 'asArray' => true
  5775. ) );
  5776. $enclosurHtml = '';
  5777. foreach ( $enclosurList as $value ) {
  5778. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5779. }
  5780. $data ['enclosurHtml'] = $enclosurHtml;
  5781. $data ['rolename'] = $rolename ['name'];
  5782. $data ['mothHtml'] = $mothHtml;
  5783. // print_r($receiptList);
  5784. $data ['rid'] = $rid;
  5785. $data ['tijdate'] = $tijdate ['date'];
  5786. $data ['receiptList'] = $receiptList;
  5787. $data ['receiptApprovalCount'] = count ( $receiptList );
  5788. $data ['status'] = $status;
  5789. $data ['year'] = $year;
  5790. $data ['categoryList'] = $categoryList;
  5791. $data ['staffList'] = $staffList;
  5792. $data ['cid'] = $cid;
  5793. $data ['sid'] = $sid;
  5794. $data ['ap'] = $ap;
  5795. $data ['memu'] = "receipt";
  5796. $data ['staff'] = $this->staff;
  5797. $data ['receiptMemu'] = 'approvalExpenses';
  5798. $data ['verifyId'] = $this->verifyId;
  5799. $data ['executeId'] = $this->executeId;
  5800. $this->render ( "/admin/receiptburEdi", $data );
  5801. }
  5802. function hisImplement() {
  5803. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  5804. if (empty ( $item ))
  5805. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  5806. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  5807. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  5808. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  5809. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  5810. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  5811. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  5812. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  5813. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  5814. Doo::loadClass ( 'XDeode' );
  5815. $XDeode = new XDeode ( 5 );
  5816. Doo::loadModel ( 'receipt' );
  5817. $receipt = new receipt ();
  5818. Doo::loadModel ( 'L_category' );
  5819. $Lcategory = new L_category ();
  5820. Doo::loadModel ( 'verify' );
  5821. Doo::loadModel ( 'statistics' );
  5822. $statistics = new statistics ();
  5823. $verify = new verify ();
  5824. Doo::loadModel ( 'staff' );
  5825. $staff = new staff ();
  5826. Doo::loadClass ( 'XDeode' );
  5827. $XDeode = new XDeode ( 5 );
  5828. $XDeode7 = new XDeode ( 7 );
  5829. $cid = $XDeode->decode ( $cidKey );
  5830. $condition = "";
  5831. if ($item == "expenses")
  5832. $condition = " and Rtype=1 ";
  5833. elseif ($item == "receipts")
  5834. $condition = " and Rtype=0 ";
  5835. elseif ($item == "remits")
  5836. $condition = " and Rtype=2 ";
  5837. elseif($item == "train")
  5838. $condition = " and Rtype=3 ";
  5839. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  5840. $sopString = $cidString = "";
  5841. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  5842. if (empty ( $rdate ))
  5843. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  5844. else
  5845. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  5846. if ($status == 'pendImplement') {
  5847. $condition .= ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  5848. } elseif ($status == 'alerpts') {
  5849. $statusCon = '(status=8 or status=9 )';
  5850. if (empty ( $rdate ))
  5851. $dateCondition .= " and Year(date) =" . $year;
  5852. else
  5853. $dateCondition .= " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  5854. }
  5855. if ($sop != 'SOP')
  5856. $sopString = " and staff=" . $sop;
  5857. if ($cidKey != 'ALL')
  5858. $cidString = " and cid=" . $cid;
  5859. //汇款信息需要提取出来
  5860. if(!empty($receiptOrder)){
  5861. $receiptList = $receipt->find ( array (
  5862. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  5863. 'desc' => 'rid',
  5864. 'asArray' => true
  5865. ) );
  5866. // 员工筛选
  5867. $receiptList2 = $receipt->find ( array (
  5868. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  5869. 'desc' => 'rid',
  5870. 'asArray' => true
  5871. ) );
  5872. }else{
  5873. $receiptList = $receipt->find ( array (
  5874. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  5875. 'desc' => 'rid',
  5876. 'asArray' => true
  5877. ) );
  5878. // 员工筛选
  5879. $receiptList2 = $receipt->find ( array (
  5880. 'where' => $statusCon . $condition . $dateCondition,
  5881. 'desc' => 'rid',
  5882. 'asArray' => true
  5883. ) );
  5884. }
  5885. $sopStaff = array ();
  5886. foreach ( $receiptList2 as $key => $value ) {
  5887. $staffDetail = $staff->getOne ( array (
  5888. 'select' => 'username',
  5889. 'where' => 'sid=' . $value ['staff'],
  5890. 'asArray' => true
  5891. ) );
  5892. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  5893. }
  5894. // 办事处筛选
  5895. $categoryScreen = array ();
  5896. $categorList = $Lcategory->getCategory ();
  5897. foreach ( $receiptList2 as $key => $value ) {
  5898. foreach ( $categorList as $k => $v ) {
  5899. if ($value ['cid'] == $v ['cid']) {
  5900. $categoryScreen [$v ['cidKey']] = $v ['title'];
  5901. break;
  5902. }
  5903. }
  5904. }
  5905. $categoryScreenHtml = "";
  5906. foreach ( $categoryScreen as $key => $value ) {
  5907. if ($cidKey == $key)
  5908. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  5909. else
  5910. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  5911. }
  5912. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  5913. $data ['cidKey'] = $cidKey;
  5914. $Locate = 0;
  5915. $roleId = 0;
  5916. $button = 0;
  5917. $staffBatchNumber = 100001;
  5918. $remittanceList = array ();
  5919. foreach ( $receiptList as $key => $value ) {
  5920. $receiptList [$key] ['ridKey7'] = $XDeode7->encode ( $value ['rid'] );
  5921. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  5922. $receiptList [$key] ['Texe'] = 'false';
  5923. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  5924. $receiptList [$key] ['Texe'] = 'true';
  5925. }
  5926. $receiptList [$key] ['TRexe'] = 'true';
  5927. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  5928. $receiptList [$key] ['TRexe'] = 'false';
  5929. }
  5930. $receiptList [$key] ['Locate'] = $Locate;
  5931. $Locate ++;
  5932. $receiptList [$key] ['reviseDetail'] = array ();
  5933. if (! empty ( $value ['reviseDetail'] ))
  5934. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5935. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5936. $categoryDetil = $Lcategory->getOne ( array (
  5937. 'where' => 'cid=' . $value ['cid'],
  5938. 'asArray' => true
  5939. ) );
  5940. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5941. // 检测编辑状态
  5942. $verifyList = $verify->getOne ( array (
  5943. 'where' => 'vid=' . $value ['verify'],
  5944. 'asArray' => true
  5945. ) );
  5946. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5947. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5948. Doo::loadModel ( 'role' );
  5949. $role = new role ();
  5950. $flag = true;
  5951. $roleKey = 0;
  5952. $endStaffArray = array ();
  5953. $roleArrayCopy = array ();
  5954. foreach ( $verifyList as $k => $v ) {
  5955. // init verifyStaff
  5956. if ($v [1] == 'ROLE') {
  5957. if (! empty ( $verifyStaff )) {
  5958. $endStaffArray = end ( $verifyStaff );
  5959. }
  5960. $roleVerify = json_decode ( $v [3], true );
  5961. $roleKey = $k;
  5962. $roleArray = array ();
  5963. $rolename = $role->getOne ( array (
  5964. 'where' => 'rid=' . $v [0],
  5965. 'asArray' => true
  5966. ) );
  5967. foreach ( $roleVerify as $o => $p ) {
  5968. $staffID = explode ( '_', $p );
  5969. $staffInfo = $staff->getOne ( array (
  5970. 'where' => 'sid=' . $staffID [0],
  5971. 'asArray' => true
  5972. ) );
  5973. $exp = array (
  5974. 0 => $staffInfo ['sid'],
  5975. 1 => $staffID [1],
  5976. 2 => $staffInfo ['avatar'],
  5977. 'date' => '',
  5978. 'date' => '',
  5979. 'opinion' => '',
  5980. 'status' => '',
  5981. 'rolename' => $rolename ['name']
  5982. );
  5983. array_push ( $roleArray, $exp );
  5984. }
  5985. $roleArrayCopy [$v [0]] = $roleArray;
  5986. }
  5987. $verifyList [$k] ['date'] = "";
  5988. $verifyList [$k] ['opinion'] = "";
  5989. $verifyList [$k] ['status'] = "";
  5990. if (empty ( $verifyStaff )) {
  5991. $verifyList [$k] ['date'] = "";
  5992. $verifyList [$k] ['opinion'] = "";
  5993. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5994. $verifyList [$k] ['status'] = 4;
  5995. $flag = false;
  5996. }
  5997. } else {
  5998. foreach ( $verifyStaff as $m => $u ) {
  5999. if ($v [0] == $m) {
  6000. $verifyList [$k] ['date'] = $u ['date'];
  6001. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6002. $verifyList [$k] ['status'] = $u ['status'];
  6003. $flag = false;
  6004. break;
  6005. }
  6006. }
  6007. $endStaffArray = end ( $verifyStaff );
  6008. }
  6009. }
  6010. $rolename ['name'] = '';
  6011. if (! empty ( $roleId )) {
  6012. Doo::loadModel ( 'role' );
  6013. $role = new role ();
  6014. $rolename = $role->getOne ( array (
  6015. 'where' => 'rid=' . $roleId,
  6016. 'asArray' => true
  6017. ) );
  6018. }
  6019. if (! empty ( $verifyStaff ))
  6020. $endStaffArray = end ( $verifyStaff );
  6021. $KOP = false;
  6022. foreach ( $roleArrayCopy as $P => $A ) {
  6023. foreach ( $A as $MKI => $AVL ) {
  6024. if (! empty ( $verifyStaff )) {
  6025. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6026. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6027. $button = 4;
  6028. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6029. }
  6030. foreach ( $verifyStaff as $m => $u ) {
  6031. $AVLFK = $AVL [0] . '_R';
  6032. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6033. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6034. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6035. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6036. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6037. break;
  6038. }
  6039. }
  6040. } else {
  6041. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6042. $button = 4;
  6043. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6044. }
  6045. }
  6046. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6047. $KOP = true;
  6048. }
  6049. }
  6050. foreach ( $roleArrayCopy as $k => $v ) {
  6051. foreach ( $verifyList as $m => $n ) {
  6052. if ($n [0] == $k) {
  6053. array_splice ( $verifyList, $m, 1, $v );
  6054. }
  6055. }
  6056. }
  6057. $receiptList [$key] ['verifyList'] = $verifyList;
  6058. $staffDetail = $staff->getOne ( array (
  6059. 'where' => 'sid=' . $value ['staff'],
  6060. 'asArray' => true
  6061. ) );
  6062. $receiptList [$key] ['staffDetail'] = $staffDetail;
  6063. $receiptList [$key] ['button'] = $button;
  6064. if ($value['Rtype']==1){
  6065. $receiptList [$key] ['relust'] = $value['sum']-$value['loanSum'];
  6066. $receiptList [$key] ['relustABS'] = abs($receiptList [$key] ['relust']);
  6067. }elseif($value['Rtype']==3){
  6068. // 收入合计
  6069. Doo::loadModel ( 'invoiceTraining' );
  6070. $invoiceTraining = new invoiceTraining ();
  6071. $invoiceTrainingDetail = array (
  6072. 'invoiceArriveAmount' => '0.00',
  6073. 'RIAmount' => '0.00',
  6074. 'invoiceTotalAmount' => '0.00',
  6075. 'invoiceCompanyAmount' => '0.00',
  6076. 'invoiceArriveAmountM'=>'0.00',
  6077. 'invoiceCompanyAmountM'=>'0.00'
  6078. );
  6079. if ($value ['invoiceTrainId'] != 0) {
  6080. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $value['invoiceTrainId'] );
  6081. }
  6082. $invoiceArriveAmount = $RIAmount = 0;
  6083. if (! empty ( $invoiceTrainingDetail )) {
  6084. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  6085. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  6086. }
  6087. // 备用金
  6088. $sum = 0;
  6089. if (! empty ( $value ['trainLoanRid'] )) {
  6090. $receiptLoanList = $receipt->getReceiptInRid ( $value ['trainLoanRid'] );
  6091. foreach ($receiptLoanList as $kll=>$vll){
  6092. $sum+=$vll['sum'];
  6093. }
  6094. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $value ['trainLoanRid'] );
  6095. // $sum = $receiptLoanDetailBak ['sum'];
  6096. }
  6097. // 支出项金额详情
  6098. // 项目金额合计
  6099. Doo::loadModel ( 'RItem' );
  6100. $RItem = new RItem ();
  6101. Doo::loadModel ( 'accountItem' );
  6102. $accountItem = new accountItem ();
  6103. // 讲师获得
  6104. Doo::loadModel ( 'RILecturer' );
  6105. $RILecturer = new RILecturer ();
  6106. $RItemList = $RItem->getRItemByRid ( $value['rid'] );
  6107. $RILecturerList = $RILecturer->getRILecturerByRid ( $value['rid'] );
  6108. // 支出项金额详情
  6109. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  6110. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  6111. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  6112. $receiptList [$key] ['payment'] =$payment;
  6113. $receiptList [$key] ['paymentABS'] =sprintf("%.2f",abs($payment));
  6114. }
  6115. // 设置导出汇款execl
  6116. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  6117. $remittanceDetail = array (
  6118. $staffBatchNumber,
  6119. $value ['remittanceName'],
  6120. $value ['bankNumber'],
  6121. $value ['bankName'],
  6122. $value ['remittanceBankType'],
  6123. $value ['coupletNumber'],
  6124. $value ['sum']
  6125. );
  6126. array_push ( $remittanceList, $remittanceDetail );
  6127. $staffBatchNumber ++;
  6128. }
  6129. }
  6130. $data ['remittanceList'] = json_encode ( $remittanceList );
  6131. // print_r($receiptList);
  6132. $mothHtml = "";
  6133. for($i = 1; $i <= 12; $i ++) {
  6134. if ($moth == $i)
  6135. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6136. else
  6137. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6138. }
  6139. $dayHtml = "";
  6140. if ($day != "DAY" || $moth != "MONTH") {
  6141. for($i = 1; $i <= 31; $i ++) {
  6142. if ($day == $i)
  6143. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6144. else
  6145. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6146. }
  6147. }
  6148. $sopHtml = "";
  6149. foreach ( $sopStaff as $key => $value ) {
  6150. if ($sop == $key)
  6151. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  6152. else
  6153. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  6154. }
  6155. $data ['status'] = $status;
  6156. $data ['rdate'] = $rdate;
  6157. $data ['sopHtml'] = $sopHtml;
  6158. $data ['dayHtml'] = $dayHtml;
  6159. $data ['mothHtml'] = $mothHtml;
  6160. $data ['receiptList'] = $receiptList;
  6161. $data ['memu'] = "receipt";
  6162. $data ['staff'] = $this->staff;
  6163. $data ['receiptMemu'] = 'implement';
  6164. $data ['verifyId'] = $this->verifyId;
  6165. $data ['executeId'] = $this->executeId;
  6166. $data ['item'] = $item;
  6167. $data ['year'] = $year;
  6168. $data ['moth'] = $moth;
  6169. $data['receiptOrder']=$receiptOrder;
  6170. $data ['day'] = $day;
  6171. $data ['sop'] = $sop;
  6172. $this->render ( "/admin/hisImplement", $data );
  6173. }
  6174. /**
  6175. * 导出汇款信息的exelc
  6176. */
  6177. function exportRemittance() {
  6178. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  6179. if (empty ( $remittanceInfo ))
  6180. die ( 'illegal request' );
  6181. $title = array (
  6182. '员工编号',
  6183. '姓名',
  6184. '员工账号',
  6185. '员工账户开户行',
  6186. '转账类型',
  6187. '联行号',
  6188. '金额'
  6189. );
  6190. $data = json_decode ( $remittanceInfo, true );
  6191. if (empty ( $data ))
  6192. die ( 'illegal request' );
  6193. Doo::loadClass ( 'receipt.func' );
  6194. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  6195. header ( 'Content-Type:text/html;charset=utf-8' );
  6196. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  6197. }
  6198. function ajaxExamine() {
  6199. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6200. Doo::loadModel ( 'receipt' );
  6201. $receipt = new receipt ();
  6202. if (! empty ( $rid )) {
  6203. $rLRes = $receipt->find ( array (
  6204. '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,
  6205. 'asArray' => true
  6206. ) );
  6207. if(!empty($rLRes)){
  6208. Doo::loadClass ( 'XDeode' );
  6209. $XDeode = new XDeode ( 7 );
  6210. $rLRes [0]['ridKey'] = $XDeode->encode( $rLRes [0]['rid'] );
  6211. echo json_encode ( array (
  6212. 'status' => 1,
  6213. 'receipt' => $rLRes [0]
  6214. ) );
  6215. die ();
  6216. }else{
  6217. echo json_encode ( array (
  6218. 'status' => 1,
  6219. 'receipt' => array ()
  6220. ) );
  6221. die ();
  6222. }
  6223. }
  6224. echo json_encode ( array (
  6225. 'status' => 0,
  6226. 'receipt' => array ()
  6227. ) );
  6228. die ();
  6229. }
  6230. /*
  6231. * 废弃
  6232. */
  6233. function myReceipt() {
  6234. // all approval past withdraw
  6235. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  6236. if (empty ( $item ))
  6237. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  6238. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6239. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  6240. Doo::loadModel ( 'receipt' );
  6241. $receipt = new receipt ();
  6242. // pre-loaded
  6243. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  6244. // have cache
  6245. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  6246. if (! empty ( $moth )) // yearPage
  6247. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  6248. $this->showCache ( $path );
  6249. }
  6250. Doo::loadModel ( 'L_category' );
  6251. $Lcategory = new L_category ();
  6252. Doo::loadModel ( 'verify' );
  6253. Doo::loadModel ( 'statistics' );
  6254. $statistics = new statistics ();
  6255. $verify = new verify ();
  6256. Doo::loadModel ( 'staff' );
  6257. $staff = new staff ();
  6258. $condition = " and status!=0 ";
  6259. if ($item == "approval")
  6260. $condition = " and status=2 ";
  6261. elseif ($item == "withdraw")
  6262. $condition = " and status=3 ";
  6263. elseif ($item == "past")
  6264. $condition = " and status=1 ";
  6265. elseif ($item == "whdw")
  6266. $condition = " and status=4 ";
  6267. $dateCondition = " and Year(date) =" . $year;
  6268. if (! empty ( $moth )) {
  6269. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  6270. $stList = $statistics->getOne ( array (
  6271. 'select' => 'rePrice ,agPrice',
  6272. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  6273. 'asArray' => true
  6274. ) );
  6275. } else
  6276. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  6277. if (empty ( $stList ))
  6278. $stList = array (
  6279. 'rePrice' => 0,
  6280. 'agPrice' => 0
  6281. );
  6282. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  6283. $data ['stList'] = array (
  6284. 'rePrice' => $stList ['rePrice'],
  6285. 'agPrice' => $stList ['agPrice'],
  6286. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  6287. );
  6288. $receiptList = $receipt->find ( array (
  6289. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  6290. 'desc' => 'rid',
  6291. 'asArray' => true
  6292. ) );
  6293. $Locate = 0;
  6294. $roleId = 0;
  6295. $button = 0;
  6296. foreach ( $receiptList as $key => $value ) {
  6297. $receiptList [$key] ['Locate'] = $Locate;
  6298. $Locate ++;
  6299. $receiptList [$key] ['reviseDetail'] = array ();
  6300. if (! empty ( $value ['reviseDetail'] ))
  6301. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6302. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6303. $categoryDetil = $Lcategory->getOne ( array (
  6304. 'where' => 'cid=' . $value ['cid'],
  6305. 'asArray' => true
  6306. ) );
  6307. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6308. // 检测编辑状态
  6309. $verifyList = $verify->getOne ( array (
  6310. 'where' => 'vid=' . $value ['verify'],
  6311. 'asArray' => true
  6312. ) );
  6313. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6314. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6315. Doo::loadModel ( 'role' );
  6316. $role = new role ();
  6317. $flag = true;
  6318. $roleKey = 0;
  6319. $endStaffArray = array ();
  6320. $roleArrayCopy = array ();
  6321. foreach ( $verifyList as $k => $v ) {
  6322. // init verifyStaff
  6323. if ($v [1] == 'ROLE') {
  6324. if (! empty ( $verifyStaff )) {
  6325. $endStaffArray = end ( $verifyStaff );
  6326. // if ($v[0]==$endStaffArray['nextStaff']){
  6327. // $roleId=$v[0];
  6328. // }
  6329. }
  6330. $roleVerify = json_decode ( $v [3], true );
  6331. $roleKey = $k;
  6332. $roleArray = array ();
  6333. $rolename = $role->getOne ( array (
  6334. 'where' => 'rid=' . $v [0],
  6335. 'asArray' => true
  6336. ) );
  6337. foreach ( $roleVerify as $o => $p ) {
  6338. $staffID = explode ( '_', $p );
  6339. $staffInfo = $staff->getOne ( array (
  6340. 'where' => 'sid=' . $staffID [0],
  6341. 'asArray' => true
  6342. ) );
  6343. // print_r($staffID);
  6344. $exp = array (
  6345. 0 => $staffInfo ['sid'],
  6346. 1 => $staffID [1],
  6347. 2 => $staffInfo ['avatar'],
  6348. 'date' => '',
  6349. 'date' => '',
  6350. 'opinion' => '',
  6351. 'status' => '',
  6352. 'rolename' => $rolename ['name']
  6353. );
  6354. array_push ( $roleArray, $exp );
  6355. }
  6356. $roleArrayCopy [$v [0]] = $roleArray;
  6357. // $verifyList[$k]['roleArray']=$roleArray;
  6358. }
  6359. $verifyList [$k] ['date'] = "";
  6360. $verifyList [$k] ['opinion'] = "";
  6361. $verifyList [$k] ['status'] = "";
  6362. if (empty ( $verifyStaff )) {
  6363. $verifyList [$k] ['date'] = "";
  6364. $verifyList [$k] ['opinion'] = "";
  6365. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6366. $verifyList [$k] ['status'] = 4;
  6367. $flag = false;
  6368. }
  6369. } else {
  6370. foreach ( $verifyStaff as $m => $u ) {
  6371. if ($v [0] == $m) {
  6372. $verifyList [$k] ['date'] = $u ['date'];
  6373. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6374. $verifyList [$k] ['status'] = $u ['status'];
  6375. $flag = false;
  6376. break;
  6377. }
  6378. }
  6379. $endStaffArray = end ( $verifyStaff );
  6380. if (isset ( $endStaffArray ['ROLE'] )) {
  6381. } else {
  6382. // $endKey=key($verifyStaff);
  6383. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  6384. // $button=4;
  6385. // $verifyList[$k]['status']=4;
  6386. // }
  6387. }
  6388. }
  6389. }
  6390. $rolename ['name'] = '';
  6391. if (! empty ( $roleId )) {
  6392. Doo::loadModel ( 'role' );
  6393. $role = new role ();
  6394. $rolename = $role->getOne ( array (
  6395. 'where' => 'rid=' . $roleId,
  6396. 'asArray' => true
  6397. ) );
  6398. }
  6399. if (! empty ( $verifyStaff ))
  6400. $endStaffArray = end ( $verifyStaff );
  6401. $KOP = false;
  6402. foreach ( $roleArrayCopy as $P => $A ) {
  6403. foreach ( $A as $MKI => $AVL ) {
  6404. if (! empty ( $verifyStaff )) {
  6405. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6406. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6407. $button = 4;
  6408. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6409. }
  6410. foreach ( $verifyStaff as $m => $u ) {
  6411. $AVLFK = $AVL [0] . '_R';
  6412. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6413. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6414. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6415. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6416. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6417. break;
  6418. }
  6419. }
  6420. } else {
  6421. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6422. $button = 4;
  6423. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6424. }
  6425. }
  6426. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6427. $KOP = true;
  6428. }
  6429. }
  6430. foreach ( $roleArrayCopy as $k => $v ) {
  6431. foreach ( $verifyList as $m => $n ) {
  6432. if ($n [0] == $k) {
  6433. array_splice ( $verifyList, $m, 1, $v );
  6434. }
  6435. }
  6436. }
  6437. $receiptList [$key] ['verifyList'] = $verifyList;
  6438. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6439. 'where' => 'sid=' . $value ['staff'],
  6440. 'asArray' => true
  6441. ) );
  6442. $receiptList [$key] ['button'] = $button;
  6443. }
  6444. // print_r($receiptList);die;
  6445. $mothHtml = "";
  6446. for($i = 1; $i <= 12; $i ++) {
  6447. if ($moth == $i)
  6448. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6449. else
  6450. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6451. }
  6452. $data ['mothHtml'] = $mothHtml;
  6453. $data ['receiptList'] = $receiptList;
  6454. $data ['memu'] = "receipt";
  6455. $data ['staff'] = $this->staff;
  6456. $data ['receiptMemu'] = 'receipt';
  6457. $data ['verifyId'] = $this->verifyId;
  6458. $data ['executeId'] = $this->executeId;
  6459. $data ['item'] = $item;
  6460. $data ['year'] = $year;
  6461. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  6462. // sufficient condition to generate cache
  6463. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  6464. $receiptList = $receipt->find ( array (
  6465. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  6466. 'asArray' => true
  6467. ) );
  6468. if (empty ( $receiptList )) { // generated files
  6469. ob_start ();
  6470. $this->render ( "/admin/saea_myList", $data );
  6471. $this->cacheFile ( $path );
  6472. die ();
  6473. // $content = ob_get_contents();
  6474. // $fp = fopen($path, "w");
  6475. // fwrite($fp, $content);
  6476. // fclose($fp);
  6477. }
  6478. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  6479. $receiptList = $receipt->find ( array (
  6480. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  6481. 'asArray' => true
  6482. ) );
  6483. if (empty ( $receiptList )) { // generated files
  6484. ob_start ();
  6485. $this->render ( "/admin/saea_myList", $data );
  6486. $this->cacheFile ( $path );
  6487. die ();
  6488. }
  6489. }
  6490. }
  6491. $this->render ( "/admin/saea_myList", $data );
  6492. }
  6493. function saeaCreate() {
  6494. Doo::loadModel ( 'accountItem' );
  6495. Doo::loadModel ( 'verify' );
  6496. Doo::loadModel ( 'receipt' );
  6497. Doo::loadModel ( 'L_category' );
  6498. $lCategory = new L_category ();
  6499. $receipt = new receipt ();
  6500. $verify = new verify ();
  6501. $accountItem = new accountItem ();
  6502. Doo::loadModel ( "role" );
  6503. $role = new role ();
  6504. $acItem = $accountItem->find ( array (
  6505. 'asArray' => true
  6506. ) );
  6507. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  6508. $data ['category'] = $lCategory->find ( array (
  6509. 'asArray' => true
  6510. ) );
  6511. $data ['veList'] = $veList;
  6512. $data ['acItem'] = $acItem;
  6513. $data ['memu'] = "receipt";
  6514. $data ['staff'] = $this->staff;
  6515. $data ['receiptMemu'] = 'saeaBorad';
  6516. $data ['verifyId'] = $this->verifyId;
  6517. $data ['executeId'] = $this->executeId;
  6518. $this->render ( "/admin/saea_create", $data );
  6519. }
  6520. function addReceipt() {
  6521. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  6522. $agency = $this->get_args ( 'agency' );
  6523. $travel = $this->get_args ( 'travel' );
  6524. $train = $this->get_args ( 'train' );
  6525. $other = $this->get_args ( 'other' );
  6526. $inttrain = $this->get_args ( 'inttrain' );
  6527. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  6528. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  6529. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  6530. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  6531. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  6532. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  6533. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  6534. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  6535. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  6536. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  6537. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  6538. header ( 'Content-Type:text/html;charset=utf-8' );
  6539. die ( '请填写联行号' );
  6540. }
  6541. Doo::loadModel ( 'receipt' );
  6542. Doo::loadModel ( 'receiptDetail' );
  6543. Doo::loadModel ( 'accountItem' );
  6544. $accountItem = new accountItem ();
  6545. $receipt = new receipt ();
  6546. Doo::loadModel ( 'enclosur' );
  6547. Doo::loadModel ( 'execute' );
  6548. $execute = new execute ();
  6549. $executeDetail = $execute->getOne ( array (
  6550. 'where' => 'mold="报销单执行人"',
  6551. 'asArray' => true
  6552. ) );
  6553. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  6554. // if(!empty($receiptDetail))
  6555. // return "/referReceipt/".$receiptDetail['rid'];
  6556. $aItem = $accountItem->find ( array (
  6557. 'asArray' => true
  6558. ) );
  6559. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  6560. $ag = $tr = $ta = $ot= $it = 0;
  6561. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  6562. foreach ( $aItem as $key => $value ) {
  6563. if ($value ['category'] == $this->AGENCY) {
  6564. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  6565. array_push ( $accountJson [$this->AGENCY], array (
  6566. 'aid' => $value ['aid'],
  6567. 'name' => $value ['name'],
  6568. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  6569. ) );
  6570. $sum += $agency [$ag];
  6571. $agencySum += $agency [$ag];
  6572. }
  6573. $ag ++;
  6574. }
  6575. if ($value ['category'] == $this->TRAVEL) {
  6576. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  6577. array_push ( $accountJson [$this->TRAVEL], array (
  6578. 'aid' => $value ['aid'],
  6579. 'name' => $value ['name'],
  6580. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  6581. ) );
  6582. $sum += $travel [$tr];
  6583. $travelSum += $travel [$tr];
  6584. }
  6585. $tr ++;
  6586. }
  6587. if ($value ['category'] == $this->TRAIN) {
  6588. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  6589. array_push ( $accountJson [$this->TRAIN], array (
  6590. 'aid' => $value ['aid'],
  6591. 'name' => $value ['name'],
  6592. 'price' => number_format ( $train [$ta], 2, '.', '' )
  6593. ) );
  6594. $sum += $train [$ta];
  6595. $trainSum += $train [$ta];
  6596. }
  6597. $ta ++;
  6598. }
  6599. if ($value ['category'] == $this->INTTRAIN) {
  6600. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  6601. array_push ( $accountJson [$this->INTTRAIN], array (
  6602. 'aid' => $value ['aid'],
  6603. 'name' => $value ['name'],
  6604. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  6605. ) );
  6606. $sum += $inttrain [$it];
  6607. $inttrainSum += $inttrain [$it];
  6608. }
  6609. $it ++;
  6610. }
  6611. if ($value ['category'] == $this->OTHER) {
  6612. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  6613. array_push ( $accountJson [$this->OTHER], array (
  6614. 'aid' => $value ['aid'],
  6615. 'name' => $value ['name'],
  6616. 'price' => number_format ( $other [$ot], 2, '.', '' )
  6617. ) );
  6618. $sum += $other [$ot];
  6619. $otherSum += $other [$ot];
  6620. }
  6621. $ot ++;
  6622. }
  6623. }
  6624. $accountJson ['cSum'] = array (
  6625. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  6626. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  6627. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  6628. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  6629. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  6630. );
  6631. // 报销单
  6632. $receipt->accountItem = json_encode ( $accountJson );
  6633. $receipt->staff = $this->staff [0] ['sid'];
  6634. $receipt->sum = number_format ( $sum, 2, '.', '' );
  6635. $receipt->date = date ( "Y-m-d" );
  6636. $receipt->cid = $cid;
  6637. $receipt->status = 5;
  6638. // 修改审批流程加入角色
  6639. $receipt->verify = $verify;
  6640. $receipt->executeCopy = $executeDetail ['staff'];
  6641. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  6642. $order = array (
  6643. "\r\n",
  6644. "\n",
  6645. "\r"
  6646. );
  6647. $replace = '<br/>';
  6648. $explanation = str_replace ( $order, $replace, $explanation );
  6649. $receipt->explanation = $explanation;
  6650. $receipt->remittanceName = $remittanceName;
  6651. $receipt->bankName = $bankName;
  6652. $receipt->bankNumber = $bankNumber;
  6653. $receipt->remittanceBankType = $remittanceBankType;
  6654. if ($remittanceBankType == 1)
  6655. $receipt->coupletNumber = $coupletNumber;
  6656. $rid = $receipt->insert ();
  6657. // 附件
  6658. if (! empty ( $enclosurName )) {
  6659. $enclosurArray = explode ( '-', $enclosurName );
  6660. foreach ( $enclosurArray as $value ) {
  6661. $enclosur = new enclosur ();
  6662. $enclosur->name = $value;
  6663. $enclosur->rid = $rid;
  6664. $enclosur->insert ();
  6665. }
  6666. // print_r($enclosurArray);die;
  6667. }
  6668. // 报销详情
  6669. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  6670. $receiptDetail = new receiptDetail ();
  6671. $receiptDetail->staff = $this->staff [0] ['sid'];
  6672. $receiptDetail->item = $value ['name'];
  6673. $receiptDetail->itemCategory = $this->AGENCY;
  6674. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6675. $receiptDetail->date = date ( "Y-m-d" );
  6676. $receiptDetail->cid = $cid;
  6677. $receiptDetail->rid = $rid;
  6678. $receiptDetail->status = 4;
  6679. $receiptDetail->insert ();
  6680. }
  6681. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  6682. $receiptDetail = new receiptDetail ();
  6683. $receiptDetail->staff = $this->staff [0] ['sid'];
  6684. $receiptDetail->item = $value ['name'];
  6685. $receiptDetail->itemCategory = $this->TRAVEL;
  6686. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6687. $receiptDetail->date = date ( "Y-m-d" );
  6688. $receiptDetail->cid = $cid;
  6689. $receiptDetail->rid = $rid;
  6690. $receiptDetail->status = 4;
  6691. $receiptDetail->insert ();
  6692. }
  6693. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  6694. $receiptDetail = new receiptDetail ();
  6695. $receiptDetail->staff = $this->staff [0] ['sid'];
  6696. $receiptDetail->item = $value ['name'];
  6697. $receiptDetail->itemCategory = $this->TRAIN;
  6698. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6699. $receiptDetail->date = date ( "Y-m-d" );
  6700. $receiptDetail->cid = $cid;
  6701. $receiptDetail->rid = $rid;
  6702. $receiptDetail->status = 4;
  6703. $receiptDetail->insert ();
  6704. }
  6705. //内训
  6706. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  6707. $receiptDetail = new receiptDetail ();
  6708. $receiptDetail->staff = $this->staff [0] ['sid'];
  6709. $receiptDetail->item = $value ['name'];
  6710. $receiptDetail->itemCategory = $this->INTTRAIN;
  6711. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6712. $receiptDetail->date = date ( "Y-m-d" );
  6713. $receiptDetail->cid = $cid;
  6714. $receiptDetail->rid = $rid;
  6715. $receiptDetail->status = 4;
  6716. $receiptDetail->insert ();
  6717. }
  6718. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  6719. $receiptDetail = new receiptDetail ();
  6720. $receiptDetail->staff = $this->staff [0] ['sid'];
  6721. $receiptDetail->item = $value ['name'];
  6722. $receiptDetail->itemCategory = $this->OTHER;
  6723. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6724. $receiptDetail->date = date ( "Y-m-d" );
  6725. $receiptDetail->cid = $cid;
  6726. $receiptDetail->rid = $rid;
  6727. $receiptDetail->status = 4;
  6728. $receiptDetail->insert ();
  6729. }
  6730. return "/saeaBorad";
  6731. } else
  6732. die ( 'illegal request' );
  6733. }
  6734. function referReceipt() {
  6735. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  6736. Doo::loadModel ( 'receipt' );
  6737. Doo::loadModel ( 'verify' );
  6738. $verify = new verify ();
  6739. $receipt = new receipt ();
  6740. Doo::loadModel ( 'L_category' );
  6741. $lCategory = new L_category ();
  6742. Doo::loadModel ( "role" );
  6743. $role = new role ();
  6744. $receiptDetail = $receipt->find ( array (
  6745. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  6746. 'asArray' => true
  6747. ) );
  6748. if (empty ( $receiptDetail ))
  6749. return "/addReceipt";
  6750. foreach ( $receiptDetail as $key => $value ) {
  6751. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6752. $veList = $verify->getOne ( array (
  6753. 'where' => 'vid=' . $value ['verify'],
  6754. 'asArray' => true
  6755. ) );
  6756. $v = json_decode ( $veList ['staff'] );
  6757. array_push ( $v [0], $veList ['description'] );
  6758. foreach ( $v as $n => $m ) {
  6759. if ($m ['1'] == 'ROLE') {
  6760. $roleInfo = $role->getOne ( array (
  6761. 'where' => 'rid=' . $m [0],
  6762. 'asArray' => true
  6763. ) );
  6764. $v [$n] [1] = $roleInfo ['name'];
  6765. }
  6766. }
  6767. $receiptDetail [$key] ['staff'] = $v;
  6768. $category = $lCategory->getOne ( array (
  6769. 'where' => 'cid=' . $value ['cid'],
  6770. 'asArray' => true
  6771. ) );
  6772. $receiptDetail [$key] ['category'] = $category ['title'];
  6773. }
  6774. // print_r($receiptDetail);
  6775. $data ['receiptDetail'] = $receiptDetail;
  6776. $data ['memu'] = "receipt";
  6777. $data ['staff'] = $this->staff;
  6778. $data ['receiptMemu'] = 'saeaCreate';
  6779. $data ['verifyId'] = $this->verifyId;
  6780. $data ['executeId'] = $this->executeId;
  6781. $this->render ( "/admin/saea_confirm", $data );
  6782. }
  6783. function editReceipt() {
  6784. // edit status 4
  6785. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  6786. Doo::loadClass ( 'XDeode' );
  6787. $XDeode = new XDeode ( 7 );
  6788. $rid = $XDeode->decode ( $ridKey );
  6789. if (empty ( $rid ))
  6790. die ( 'illegal request' );
  6791. // echo $rid.'sd';
  6792. Doo::loadModel ( 'accountItem' );
  6793. Doo::loadModel ( 'verify' );
  6794. Doo::loadModel ( 'receipt' );
  6795. $receipt = new receipt ();
  6796. $verify = new verify ();
  6797. $accountItem = new accountItem ();
  6798. Doo::loadModel ( 'L_category' );
  6799. $lCategory = new L_category ();
  6800. Doo::loadModel ( "role" );
  6801. $role = new role ();
  6802. Doo::loadModel ( 'enclosur' );
  6803. $enclosur = new enclosur ();
  6804. $receiptDetail = $receipt->getOne ( array (
  6805. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  6806. 'asArray' => true
  6807. ) );
  6808. if (empty ( $receiptDetail ))
  6809. die ( 'illegal request' );
  6810. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  6811. $acItem = $accountItem->find ( array (
  6812. 'asArray' => true
  6813. ) );
  6814. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  6815. // 配置编辑信息
  6816. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  6817. foreach ( $acItem as $key => $value ) {
  6818. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  6819. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  6820. $acItem [$key] ['price'] = $v ['price'];
  6821. }
  6822. }
  6823. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  6824. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  6825. $acItem [$key] ['price'] = $v ['price'];
  6826. }
  6827. }
  6828. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  6829. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  6830. $acItem [$key] ['price'] = $v ['price'];
  6831. }
  6832. }
  6833. //内训
  6834. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  6835. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  6836. $acItem [$key] ['price'] = $v ['price'];
  6837. }
  6838. }
  6839. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  6840. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  6841. $acItem [$key] ['price'] = $v ['price'];
  6842. }
  6843. }
  6844. }
  6845. $data ['category'] = $lCategory->find ( array (
  6846. 'asArray' => true
  6847. ) );
  6848. $data ['cSum'] = $accountItemList ['cSum'];
  6849. $data ['sum'] = $receiptDetail ['sum'];
  6850. $data ['enclosurList'] = $enclosurList;
  6851. $data ['receiptDetail'] = $receiptDetail;
  6852. $data ['veList'] = $veList;
  6853. $data ['acItem'] = $acItem;
  6854. $data ['memu'] = "receipt";
  6855. $data ['staff'] = $this->staff;
  6856. $data ['receiptMemu'] = 'saeaBorad';
  6857. $data ['verify'] = $receiptDetail ['verify'];
  6858. $data ['verifyId'] = $this->verifyId;
  6859. $data ['executeId'] = $this->executeId;
  6860. $data ['rid'] = $ridKey;
  6861. $this->render ( "/admin/saea_edit", $data );
  6862. }
  6863. function updateReceipt() {
  6864. $agency = $this->get_args ( 'agency' );
  6865. $travel = $this->get_args ( 'travel' );
  6866. $train = $this->get_args ( 'train' );
  6867. $other = $this->get_args ( 'other' );
  6868. $inttrain = $this->get_args ( 'inttrain' );
  6869. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  6870. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  6871. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  6872. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  6873. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  6874. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  6875. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  6876. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  6877. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  6878. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  6879. Doo::loadClass ( 'XDeode' );
  6880. $XDeode = new XDeode ( 7 );
  6881. $rid = $XDeode->decode ( $ridKey );
  6882. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  6883. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  6884. header ( 'Content-Type:text/html;charset=utf-8' );
  6885. die ( '请填写联行号' );
  6886. }
  6887. Doo::loadModel ( 'receipt' );
  6888. Doo::loadModel ( 'receiptDetail' );
  6889. Doo::loadModel ( 'accountItem' );
  6890. $accountItem = new accountItem ();
  6891. $receipt = new receipt ();
  6892. Doo::loadModel ( 'enclosur' );
  6893. Doo::loadModel ( 'execute' );
  6894. $execute = new execute ();
  6895. $receiptDetail = $receipt->getOne ( array (
  6896. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  6897. 'asArray' => true
  6898. ) );
  6899. if (empty ( $receiptDetail ))
  6900. return "/saeaBorad";
  6901. if ($receiptDetail ['Rtype'] == 1)
  6902. $executeDetail = $execute->getOne ( array (
  6903. 'where' => 'mold="借款费用执行人"',
  6904. 'asArray' => true
  6905. ) );
  6906. else
  6907. $executeDetail = $execute->getOne ( array (
  6908. 'where' => 'mold="报销单执行人"',
  6909. 'asArray' => true
  6910. ) );
  6911. $aItem = $accountItem->find ( array (
  6912. 'asArray' => true
  6913. ) );
  6914. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  6915. $ag = $tr = $ta = $ot = $it = 0 ;
  6916. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum = $otherSum = 0;
  6917. foreach ( $aItem as $key => $value ) {
  6918. if ($value ['category'] == $this->AGENCY) {
  6919. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  6920. array_push ( $accountJson [$this->AGENCY], array (
  6921. 'aid' => $value ['aid'],
  6922. 'name' => $value ['name'],
  6923. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  6924. ) );
  6925. $sum += $agency [$ag];
  6926. $agencySum += $agency [$ag];
  6927. }
  6928. $ag ++;
  6929. }
  6930. if ($value ['category'] == $this->TRAVEL) {
  6931. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  6932. array_push ( $accountJson [$this->TRAVEL], array (
  6933. 'aid' => $value ['aid'],
  6934. 'name' => $value ['name'],
  6935. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  6936. ) );
  6937. $sum += $travel [$tr];
  6938. $travelSum += $travel [$tr];
  6939. }
  6940. $tr ++;
  6941. }
  6942. if ($value ['category'] == $this->TRAIN) {
  6943. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  6944. array_push ( $accountJson [$this->TRAIN], array (
  6945. 'aid' => $value ['aid'],
  6946. 'name' => $value ['name'],
  6947. 'price' => number_format ( $train [$ta], 2, '.', '' )
  6948. ) );
  6949. $sum += $train [$ta];
  6950. $trainSum += $train [$ta];
  6951. }
  6952. $ta ++;
  6953. }
  6954. if ($value ['category'] == $this->INTTRAIN) {
  6955. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  6956. array_push ( $accountJson [$this->INTTRAIN], array (
  6957. 'aid' => $value ['aid'],
  6958. 'name' => $value ['name'],
  6959. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  6960. ) );
  6961. $sum += $inttrain [$it];
  6962. $inttrainSum += $inttrain [$it];
  6963. }
  6964. $it ++;
  6965. }
  6966. if ($value ['category'] == $this->OTHER) {
  6967. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  6968. array_push ( $accountJson [$this->OTHER], array (
  6969. 'aid' => $value ['aid'],
  6970. 'name' => $value ['name'],
  6971. 'price' => number_format ( $other [$ot], 2, '.', '' )
  6972. ) );
  6973. $sum += $other [$ot];
  6974. $otherSum += $other [$ot];
  6975. }
  6976. $ot ++;
  6977. }
  6978. }
  6979. $accountJson ['cSum'] = array (
  6980. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  6981. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  6982. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  6983. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  6984. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  6985. );
  6986. // 报销单
  6987. $rid = $receipt->rid = $receiptDetail ['rid'];
  6988. $receipt->accountItem = json_encode ( $accountJson );
  6989. $receipt->staff = $this->staff [0] ['sid'];
  6990. $receipt->sum = number_format ( $sum, 2, '.', '' );
  6991. $receipt->date = date ( "Y-m-d" );
  6992. $receipt->cid = $cid;
  6993. if (($receiptDetail ['status'] != 4)) {
  6994. if ($receiptDetail ['Rtype'] == 1)
  6995. $receipt->status = 7;
  6996. else
  6997. $receipt->status = 5;
  6998. }
  6999. if ($receiptDetail != 4 && ! empty ( $verify ))
  7000. $receipt->verify = $verify;
  7001. $receipt->executeCopy = $executeDetail ['staff'];
  7002. $order = array (
  7003. "\r\n",
  7004. "\n",
  7005. "\r"
  7006. );
  7007. $replace = '<br/>';
  7008. $explanation = str_replace ( $order, $replace, $explanation );
  7009. $receipt->explanation = $explanation;
  7010. $receipt->remittanceName = $remittanceName;
  7011. $receipt->bankName = $bankName;
  7012. $receipt->bankNumber = $bankNumber;
  7013. $receipt->remittanceBankType = $remittanceBankType;
  7014. if ($remittanceBankType == 1)
  7015. $receipt->coupletNumber = $coupletNumber;
  7016. $receipt->update ();
  7017. $receiptDetail = new receiptDetail ();
  7018. $receiptDetail->delete ( array (
  7019. 'where' => 'rid=' . $rid
  7020. ) );
  7021. // 报销详情
  7022. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  7023. $receiptDetail = new receiptDetail ();
  7024. $receiptDetail->staff = $this->staff [0] ['sid'];
  7025. $receiptDetail->item = $value ['name'];
  7026. $receiptDetail->itemCategory = $this->AGENCY;
  7027. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  7028. $receiptDetail->date = date ( "Y-m-d" );
  7029. $receiptDetail->cid = $cid;
  7030. $receiptDetail->rid = $rid;
  7031. $receiptDetail->status = 4;
  7032. $receiptDetail->insert ();
  7033. }
  7034. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  7035. $receiptDetail = new receiptDetail ();
  7036. $receiptDetail->staff = $this->staff [0] ['sid'];
  7037. $receiptDetail->item = $value ['name'];
  7038. $receiptDetail->itemCategory = $this->TRAVEL;
  7039. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  7040. $receiptDetail->date = date ( "Y-m-d" );
  7041. $receiptDetail->cid = $cid;
  7042. $receiptDetail->rid = $rid;
  7043. $receiptDetail->status = 4;
  7044. $receiptDetail->insert ();
  7045. }
  7046. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  7047. $receiptDetail = new receiptDetail ();
  7048. $receiptDetail->staff = $this->staff [0] ['sid'];
  7049. $receiptDetail->item = $value ['name'];
  7050. $receiptDetail->itemCategory = $this->TRAIN;
  7051. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  7052. $receiptDetail->date = date ( "Y-m-d" );
  7053. $receiptDetail->cid = $cid;
  7054. $receiptDetail->rid = $rid;
  7055. $receiptDetail->status = 4;
  7056. $receiptDetail->insert ();
  7057. }
  7058. //内训
  7059. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  7060. $receiptDetail = new receiptDetail ();
  7061. $receiptDetail->staff = $this->staff [0] ['sid'];
  7062. $receiptDetail->item = $value ['name'];
  7063. $receiptDetail->itemCategory = $this->INTTRAIN;
  7064. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  7065. $receiptDetail->date = date ( "Y-m-d" );
  7066. $receiptDetail->cid = $cid;
  7067. $receiptDetail->rid = $rid;
  7068. $receiptDetail->status = 4;
  7069. $receiptDetail->insert ();
  7070. }
  7071. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  7072. $receiptDetail = new receiptDetail ();
  7073. $receiptDetail->staff = $this->staff [0] ['sid'];
  7074. $receiptDetail->item = $value ['name'];
  7075. $receiptDetail->itemCategory = $this->OTHER;
  7076. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  7077. $receiptDetail->date = date ( "Y-m-d" );
  7078. $receiptDetail->cid = $cid;
  7079. $receiptDetail->rid = $rid;
  7080. $receiptDetail->status = 4;
  7081. $receiptDetail->insert ();
  7082. }
  7083. // 附件
  7084. if (! empty ( $enclosurName )) {
  7085. $enclosurArray = explode ( '-', $enclosurName );
  7086. foreach ( $enclosurArray as $value ) {
  7087. $enclosur = new enclosur ();
  7088. $enclosur->name = $value;
  7089. $enclosur->rid = $rid;
  7090. $enclosur->insert ();
  7091. }
  7092. }
  7093. // return "/referReceipt/".$rid;
  7094. }
  7095. return "/saeaBorad";
  7096. }
  7097. function approvedReceipt() {
  7098. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7099. Doo::loadModel ( 'receipt' );
  7100. Doo::loadModel ( 'receiptDetail' );
  7101. $receipt = new receipt ();
  7102. $receiptDetail = new receiptDetail ();
  7103. Doo::loadModel ( 'statistics' );
  7104. Doo::loadModel ( 'itemStatistics' );
  7105. $statistics = new statistics ();
  7106. $itemStatistics = new itemStatistics ();
  7107. Doo::loadModel ( "verify" );
  7108. $verify = new verify ();
  7109. // 审批状态的判定
  7110. $receiptDetailList = $receipt->getOne ( array (
  7111. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  7112. 'asArray' => true
  7113. ) );
  7114. if (empty ( $receiptDetailList ))
  7115. return "/saeaBorad";
  7116. $verifyDetail = $verify->getOne ( array (
  7117. 'where' => ' vid =' . $receiptDetailList ['verify'],
  7118. 'asArray' => true
  7119. ) );
  7120. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7121. if (empty ( $receiptDetailList ['nowStaff'] )) {
  7122. $nowStaff = "";
  7123. $nowStaffList = array ();
  7124. if ($verifyDetail [0] [1] == 'ROLE') {
  7125. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7126. foreach ( $vStaffString as $key => $value ) {
  7127. $staffK = explode ( "_", $value );
  7128. array_push ( $nowStaffList, $staffK [0] );
  7129. }
  7130. $nowStaff = implode ( ',', $nowStaffList );
  7131. } else {
  7132. $nowStaff = $verifyDetail [0] [0];
  7133. }
  7134. $receipt->nowStaff = $nowStaff;
  7135. }
  7136. // echo $nowStaff;
  7137. // print_r($verifyDetail);die;
  7138. $receipt->rid = $receiptDetailList ['rid'];
  7139. $receipt->date = date ( "Y-m-d" );
  7140. $receipt->status = 2;
  7141. $receipt->update ();
  7142. $receiptDetail->status = 2;
  7143. $receiptDetail->update ( array (
  7144. 'where' => 'rid=' . $receiptDetailList ['rid']
  7145. ) );
  7146. Doo::loadModel ( "receiptLog" );
  7147. $receiptLog = new receiptLog ();
  7148. Doo::loadModel ( "verify" );
  7149. $verify = new verify ();
  7150. $receiptInfo = $receipt->getOne ( array (
  7151. 'where' => 'rid=' . $rid,
  7152. 'asArray' => true
  7153. ) );
  7154. $vr = $verify->getOne ( array (
  7155. 'where' => 'vid=' . $receiptInfo ['verify'],
  7156. 'asArray' => true
  7157. ) );
  7158. $jd = json_decode ( $vr ['staff'] );
  7159. $roleId = 0;
  7160. foreach ( $jd as $key => $value ) {
  7161. if ($value [1] == 'ROLE') {
  7162. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7163. if ($pos !== false) {
  7164. $roleId = $value [0];
  7165. }
  7166. }
  7167. }
  7168. // 审批日志
  7169. // echo $roleId;die;
  7170. if (! empty ( $roleId )) {
  7171. Doo::loadModel ( "role" );
  7172. $role = new role ();
  7173. $roleInfo = $role->getOne ( array (
  7174. 'where' => 'rid=' . $roleId,
  7175. 'asArray' => true
  7176. ) );
  7177. // $receiptLog->rolename = $roleInfo ['name'];
  7178. }
  7179. $receiptLog->username = $this->staff [0] ['username'];
  7180. $receiptLog->uid = $this->staff [0] ['sid'];
  7181. $receiptLog->date = date ( "Y-m-d" );
  7182. $receiptLog->opinion = '提交审批';
  7183. $receiptLog->img = $this->staff [0] ['avatar'];
  7184. $receiptLog->status = 2;
  7185. $receiptLog->rid = $rid;
  7186. $receiptLog->insert ();
  7187. // statistics item
  7188. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  7189. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7190. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  7191. $stat = $statistics->getOne ( array (
  7192. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7193. 'asArray' => true
  7194. ) );
  7195. if (empty ( $stat )) {
  7196. $statistics->date = date ( "Y-m-d" );
  7197. $statistics->cid = $this->staff [0] ['cid'];
  7198. $statistics->staff = $this->staff [0] ['sid'];
  7199. $statistics->agPrice = 0;
  7200. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7201. $statistics->insert ();
  7202. } else {
  7203. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7204. $statistics->update ( array (
  7205. 'where' => 'sid=' . $stat ['sid']
  7206. ) );
  7207. }
  7208. return "/expenses";
  7209. }
  7210. function approval() {
  7211. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7212. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7213. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7214. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7215. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7216. if (empty ( $status ))
  7217. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7218. $vidList = array ();
  7219. $button = 0;
  7220. Doo::loadModel ( 'verify' );
  7221. $verify = new verify ();
  7222. Doo::loadModel ( 'receipt' );
  7223. $receipt = new receipt ();
  7224. Doo::loadModel ( 'staff' );
  7225. $staff = new staff ();
  7226. Doo::loadModel ( 'L_category' );
  7227. $Lcategory = new L_category ();
  7228. // user verify ID
  7229. $verifyDetail = $verify->find ( array (
  7230. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7231. 'asArray' => true
  7232. ) );
  7233. foreach ( $verifyDetail as $key => $value ) {
  7234. array_push ( $vidList, $value ['vid'] );
  7235. }
  7236. $vid = implode ( ",", $vidList );
  7237. if (empty ( $verifyDetail ))
  7238. $vid = 0;
  7239. /*
  7240. */
  7241. $dateCondition = " and Year(date) =" . $year;
  7242. if (! empty ( $month ))
  7243. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  7244. $categoryList = $Lcategory->find ( array (
  7245. 'asArray' => true
  7246. ) );
  7247. $staffList = $staff->find ( array (
  7248. 'where' => 'cid=' . $cid,
  7249. 'asArray' => true
  7250. ) );
  7251. $cateCondition = "";
  7252. $staffCondition = "";
  7253. $approvalCondition = "";
  7254. if (! empty ( $cid ))
  7255. $cateCondition = ' and cid=' . $cid;
  7256. if (! empty ( $sid )) {
  7257. $staffCondition = ' and staff=' . $sid;
  7258. $cateCondition = "";
  7259. }
  7260. // elseif($status==1){
  7261. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  7262. // }
  7263. if ($status == 2) {
  7264. // 查找角色审批人
  7265. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  7266. }
  7267. $ap = "";
  7268. if ($status == 4) {
  7269. $ap = 4;
  7270. $status = 2;
  7271. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  7272. }
  7273. if ($status == 5) {
  7274. $status = 4;
  7275. $ap = 5;
  7276. }
  7277. // echo $vid;
  7278. // get Receipt By verifyID status 2 .$approvalCondition
  7279. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  7280. $receiptList = $receipt->find ( array (
  7281. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  7282. 'desc' => 'rid',
  7283. 'asArray' => true
  7284. ) );
  7285. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  7286. $Locate = 0;
  7287. if ($ap == 4)
  7288. $status = 4;
  7289. elseif ($ap == 5)
  7290. $status = 5;
  7291. foreach ( $receiptList as $key => $value ) {
  7292. $receiptList [$key] ['Locate'] = $Locate;
  7293. $Locate ++;
  7294. $receiptList [$key] ['reviseDetail'] = array ();
  7295. if (! empty ( $value ['reviseDetail'] ))
  7296. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7297. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7298. $categoryDetil = $Lcategory->getOne ( array (
  7299. 'where' => 'cid=' . $value ['cid'],
  7300. 'asArray' => true
  7301. ) );
  7302. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7303. $verifyList = $verify->getOne ( array (
  7304. 'where' => 'vid=' . $value ['verify'],
  7305. 'asArray' => true
  7306. ) );
  7307. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7308. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7309. foreach ( $verifyList as $k => $v ) {
  7310. // init verifyStaff
  7311. $verifyList [$k] ['date'] = "";
  7312. $verifyList [$k] ['opinion'] = "";
  7313. $verifyList [$k] ['status'] = "";
  7314. if (empty ( $verifyStaff )) {
  7315. $verifyList [$k] ['date'] = "";
  7316. $verifyList [$k] ['opinion'] = "";
  7317. if ($v [0] == $this->staff [0] ['sid']) {
  7318. $verifyList [$k] ['status'] = 4;
  7319. $button = 4;
  7320. }
  7321. } else {
  7322. $flag = true;
  7323. foreach ( $verifyStaff as $m => $u ) {
  7324. if ($v [0] == $m) {
  7325. $verifyList [$k] ['date'] = $u ['date'];
  7326. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7327. $verifyList [$k] ['status'] = $u ['status'];
  7328. $flag = false;
  7329. break;
  7330. }
  7331. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  7332. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  7333. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  7334. }
  7335. if ($flag) { // 检测可编辑
  7336. if ($v [0] == $this->staff [0] ['sid']) {
  7337. $verifyList [$k] ['status'] = 4;
  7338. $button = 4;
  7339. }
  7340. }
  7341. }
  7342. }
  7343. $receiptList [$key] ['verifyList'] = $verifyList;
  7344. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7345. 'where' => 'sid=' . $value ['staff'],
  7346. 'asArray' => true
  7347. ) );
  7348. $receiptList [$key] ['button'] = $button;
  7349. }
  7350. // print_r($receiptList);die;
  7351. // $data['verifyDetail']=$verifyDetail;
  7352. $mothHtml = "";
  7353. for($i = 1; $i <= 12; $i ++) {
  7354. if ($month == $i)
  7355. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7356. else
  7357. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7358. }
  7359. $data ['mothHtml'] = $mothHtml;
  7360. $data ['receiptList'] = $receiptList;
  7361. $data ['receiptApprovalCount'] = count ( $receiptList );
  7362. $data ['status'] = $status;
  7363. $data ['year'] = $year;
  7364. $data ['categoryList'] = $categoryList;
  7365. $data ['staffList'] = $staffList;
  7366. $data ['cid'] = $cid;
  7367. $data ['sid'] = $sid;
  7368. $data ['ap'] = $ap;
  7369. $data ['memu'] = "receipt";
  7370. $data ['staff'] = $this->staff;
  7371. $data ['receiptMemu'] = 'approval';
  7372. $data ['verifyId'] = $this->verifyId;
  7373. $data ['executeId'] = $this->executeId;
  7374. $this->render ( "/admin/saea_reportList", $data );
  7375. }
  7376. function approvalDetails() {
  7377. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7378. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7379. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7380. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7381. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7382. Doo::loadModel ( 'verify' );
  7383. $verify = new verify ();
  7384. Doo::loadModel ( 'receipt' );
  7385. $receipt = new receipt ();
  7386. Doo::loadModel ( 'staff' );
  7387. $staff = new staff ();
  7388. Doo::loadModel ( 'L_category' );
  7389. $Lcategory = new L_category ();
  7390. Doo::loadModel ( 'enclosur' );
  7391. $enclosur = new enclosur ();
  7392. $vidList = array ();
  7393. $verifyDetail = $verify->find ( array (
  7394. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7395. 'asArray' => true
  7396. ) );
  7397. foreach ( $verifyDetail as $key => $value ) {
  7398. array_push ( $vidList, $value ['vid'] );
  7399. }
  7400. $vid = implode ( ",", $vidList );
  7401. if (empty ( $verifyDetail ))
  7402. $vid = 0;
  7403. $categoryList = $Lcategory->find ( array (
  7404. 'asArray' => true
  7405. ) );
  7406. $staffList = $staff->find ( array (
  7407. 'where' => 'cid=' . $cid,
  7408. 'asArray' => true
  7409. ) );
  7410. $ap = 0;
  7411. $receiptList = $receipt->find ( array (
  7412. 'where' => 'rid =' . $rid,
  7413. 'desc' => 'rid',
  7414. 'asArray' => true
  7415. ) );
  7416. $Locate = 0;
  7417. $roleId = 0;
  7418. $button = 0;
  7419. foreach ( $receiptList as $key => $value ) {
  7420. $receiptList [$key] ['Locate'] = $Locate;
  7421. $Locate ++;
  7422. $receiptList [$key] ['reviseDetail'] = array ();
  7423. if (! empty ( $value ['reviseDetail'] ))
  7424. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7425. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7426. $categoryDetil = $Lcategory->getOne ( array (
  7427. 'where' => 'cid=' . $value ['cid'],
  7428. 'asArray' => true
  7429. ) );
  7430. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7431. // 检测编辑状态
  7432. $verifyList = $verify->getOne ( array (
  7433. 'where' => 'vid=' . $value ['verify'],
  7434. 'asArray' => true
  7435. ) );
  7436. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7437. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7438. Doo::loadModel ( 'role' );
  7439. $role = new role ();
  7440. // print_r($verifyList);
  7441. $flag = true;
  7442. $roleKey = 0;
  7443. $endStaffArray = array ();
  7444. $roleArrayCopy = array ();
  7445. foreach ( $verifyList as $k => $v ) {
  7446. // init verifyStaff
  7447. if ($v [1] == 'ROLE') {
  7448. if (! empty ( $verifyStaff )) {
  7449. $endStaffArray = end ( $verifyStaff );
  7450. if ($v [0] == $endStaffArray ['nextStaff']) {
  7451. $roleId = $v [0];
  7452. }
  7453. }
  7454. $roleVerify = json_decode ( $v [3], true );
  7455. $roleKey = $k;
  7456. $roleArray = array ();
  7457. $rolename = $role->getOne ( array (
  7458. 'where' => 'rid=' . $v [0],
  7459. 'asArray' => true
  7460. ) );
  7461. foreach ( $roleVerify as $o => $p ) {
  7462. $staffID = explode ( '_', $p );
  7463. $staffInfo = $staff->getOne ( array (
  7464. 'where' => 'sid=' . $staffID [0],
  7465. 'asArray' => true
  7466. ) );
  7467. // print_r($staffID);
  7468. $exp = array (
  7469. 0 => $staffInfo ['sid'],
  7470. 1 => $staffID [1],
  7471. 2 => $staffInfo ['avatar'],
  7472. 'date' => '',
  7473. 'date' => '',
  7474. 'opinion' => '',
  7475. 'status' => '',
  7476. 'rolename' => $rolename ['name']
  7477. );
  7478. array_push ( $roleArray, $exp );
  7479. }
  7480. $roleArrayCopy [$v [0]] = $roleArray;
  7481. // $verifyList[$k]['roleArray']=$roleArray;
  7482. }
  7483. // print_r($roleArray);
  7484. $verifyList [$k] ['date'] = "";
  7485. $verifyList [$k] ['opinion'] = "";
  7486. $verifyList [$k] ['status'] = "";
  7487. if (empty ( $verifyStaff )) {
  7488. $verifyList [$k] ['date'] = "";
  7489. $verifyList [$k] ['opinion'] = "";
  7490. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7491. $verifyList [$k] ['status'] = 4;
  7492. $button = 4;
  7493. $flag = false;
  7494. }
  7495. } else {
  7496. foreach ( $verifyStaff as $m => $u ) {
  7497. if ($v [0] == $m) {
  7498. $verifyList [$k] ['date'] = $u ['date'];
  7499. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7500. $verifyList [$k] ['status'] = $u ['status'];
  7501. $flag = false;
  7502. break;
  7503. }
  7504. }
  7505. $endStaffArray = end ( $verifyStaff );
  7506. if (isset ( $endStaffArray ['ROLE'] )) {
  7507. } else {
  7508. $endKey = key ( $verifyStaff );
  7509. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7510. $button = 4;
  7511. $verifyList [$k] ['status'] = 4;
  7512. }
  7513. }
  7514. }
  7515. }
  7516. $rolename ['name'] = '';
  7517. if (! empty ( $roleId )) {
  7518. Doo::loadModel ( 'role' );
  7519. $role = new role ();
  7520. $rolename = $role->getOne ( array (
  7521. 'where' => 'rid=' . $roleId,
  7522. 'asArray' => true
  7523. ) );
  7524. }
  7525. if (! empty ( $verifyStaff ))
  7526. $endStaffArray = end ( $verifyStaff );
  7527. $KOP = false;
  7528. foreach ( $roleArrayCopy as $P => $A ) {
  7529. foreach ( $A as $MKI => $AVL ) {
  7530. if (! empty ( $verifyStaff )) {
  7531. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7532. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7533. $button = 4;
  7534. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7535. }
  7536. foreach ( $verifyStaff as $m => $u ) {
  7537. $AVLFK = $AVL [0] . '_R';
  7538. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7539. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7540. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7541. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7542. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7543. break;
  7544. }
  7545. }
  7546. } else {
  7547. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7548. $button = 4;
  7549. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7550. }
  7551. }
  7552. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7553. $KOP = true;
  7554. }
  7555. }
  7556. foreach ( $roleArrayCopy as $k => $v ) {
  7557. foreach ( $verifyList as $m => $n ) {
  7558. if ($n [0] == $k) {
  7559. array_splice ( $verifyList, $m, 1, $v );
  7560. }
  7561. }
  7562. }
  7563. $receiptList [$key] ['verifyList'] = $verifyList;
  7564. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7565. 'where' => 'sid=' . $value ['staff'],
  7566. 'asArray' => true
  7567. ) );
  7568. $receiptList [$key] ['button'] = $button;
  7569. }
  7570. $mothHtml = "";
  7571. for($i = 1; $i <= 12; $i ++) {
  7572. if ($month == $i)
  7573. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7574. else
  7575. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7576. }
  7577. // 获取审批日志
  7578. Doo::loadModel ( 'receiptLog' );
  7579. $receiptLog = new receiptLog ();
  7580. $rlList = array ();
  7581. $rlInfo = $receiptLog->getOne ( array (
  7582. 'where' => 'rid=' . $rid . ' and status=4',
  7583. 'asArray' => true
  7584. ) );
  7585. $tijdate = $receiptLog->getOne ( array (
  7586. 'where' => 'rid=' . $rid . ' and status=2',
  7587. 'asc' => 'rlid',
  7588. 'asArray' => true
  7589. ) );
  7590. if (! empty ( $rlInfo )) {
  7591. $rlList = $receiptLog->find ( array (
  7592. 'where' => 'rid=' . $rid,
  7593. 'asc' => 'rlid',
  7594. 'asArray' => true
  7595. ) );
  7596. }
  7597. $receiptList [0] ['rlList'] = $rlList;
  7598. $enclosurList = $enclosur->find ( array (
  7599. 'where' => 'rid=' . $rid,
  7600. 'asArray' => true
  7601. ) );
  7602. $enclosurHtml = '';
  7603. foreach ( $enclosurList as $value ) {
  7604. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  7605. }
  7606. $data ['enclosurHtml'] = $enclosurHtml;
  7607. $data ['rolename'] = $rolename ['name'];
  7608. $data ['datetij'] = $tijdate ['date'];
  7609. $data ['mothHtml'] = $mothHtml;
  7610. $data ['receiptList'] = $receiptList;
  7611. $data ['receiptApprovalCount'] = count ( $receiptList );
  7612. $data ['year'] = $year;
  7613. $data ['categoryList'] = $categoryList;
  7614. $data ['staffList'] = $staffList;
  7615. $data ['cid'] = $cid;
  7616. $data ['sid'] = $sid;
  7617. $data ['status'] = 0;
  7618. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  7619. $ap = 4;
  7620. } else
  7621. $data ['status'] = $receiptList [0] ['status'];
  7622. if ($receiptList [0] ['status'] == 4) {
  7623. $data ['status'] = 5;
  7624. $ap = 0;
  7625. }
  7626. $data ['ap'] = $ap;
  7627. $data ['memu'] = "receipt";
  7628. $data ['staff'] = $this->staff;
  7629. $data ['receiptMemu'] = 'approval';
  7630. $data ['verifyId'] = $this->verifyId;
  7631. $data ['executeId'] = $this->executeId;
  7632. $this->render ( "/admin/saeaReportListReport", $data );
  7633. }
  7634. function approvalEdi() {
  7635. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7636. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7637. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7638. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7639. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7640. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7641. if (empty ( $status ))
  7642. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7643. $vidList = array ();
  7644. $button = 0;
  7645. Doo::loadModel ( 'verify' );
  7646. Doo::loadModel ( 'receipt' );
  7647. Doo::loadModel ( 'staff' );
  7648. $staff = new staff ();
  7649. $receipt = new receipt ();
  7650. $verify = new verify ();
  7651. Doo::loadModel ( 'L_category' );
  7652. $Lcategory = new L_category ();
  7653. Doo::loadModel ( 'enclosur' );
  7654. $enclosur = new enclosur ();
  7655. // user verify ID
  7656. $verifyDetail = $verify->find ( array (
  7657. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7658. 'asArray' => true
  7659. ) );
  7660. foreach ( $verifyDetail as $key => $value ) {
  7661. array_push ( $vidList, $value ['vid'] );
  7662. }
  7663. $vid = implode ( ",", $vidList );
  7664. if (empty ( $verifyDetail ))
  7665. $vid = 0;
  7666. $categoryList = $Lcategory->find ( array (
  7667. 'asArray' => true
  7668. ) );
  7669. $staffList = $staff->find ( array (
  7670. 'where' => 'cid=' . $cid,
  7671. 'asArray' => true
  7672. ) );
  7673. $ap = "";
  7674. if ($status == 4) {
  7675. $ap = 4;
  7676. $status = 2;
  7677. }
  7678. // get Receipt By verifyID status 2
  7679. $receiptList = $receipt->find ( array (
  7680. 'where' => 'rid =' . $rid,
  7681. 'desc' => 'rid',
  7682. 'asArray' => true
  7683. ) );
  7684. $Locate = 0;
  7685. $roleId = 0;
  7686. if ($ap == 4)
  7687. $status = 4;
  7688. foreach ( $receiptList as $key => $value ) {
  7689. $receiptList [$key] ['Locate'] = $Locate;
  7690. $Locate ++;
  7691. $receiptList [$key] ['reviseDetail'] = array ();
  7692. if (! empty ( $value ['reviseDetail'] ))
  7693. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7694. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7695. $categoryDetil = $Lcategory->getOne ( array (
  7696. 'where' => 'cid=' . $value ['cid'],
  7697. 'asArray' => true
  7698. ) );
  7699. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7700. // 检测编辑状态
  7701. $verifyList = $verify->getOne ( array (
  7702. 'where' => 'vid=' . $value ['verify'],
  7703. 'asArray' => true
  7704. ) );
  7705. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7706. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7707. // print_r($verifyList);
  7708. //
  7709. // if (empty($verifyStaff)){
  7710. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  7711. // $verifyList[0]['status']=4;$button=4;
  7712. // }
  7713. //
  7714. // }else{
  7715. //
  7716. // }
  7717. // die;
  7718. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  7719. // echo array_search("green",$a);
  7720. //
  7721. Doo::loadModel ( 'role' );
  7722. $role = new role ();
  7723. // print_r($verifyList);
  7724. $flag = true;
  7725. $roleKey = 0;
  7726. $endStaffArray = array ();
  7727. $roleArrayCopy = array ();
  7728. foreach ( $verifyList as $k => $v ) {
  7729. // init verifyStaff
  7730. if ($v [1] == 'ROLE') {
  7731. if (! empty ( $verifyStaff )) {
  7732. $endStaffArray = end ( $verifyStaff );
  7733. if ($v [0] == $endStaffArray ['nextStaff']) {
  7734. $roleId = $v [0];
  7735. }
  7736. }
  7737. $roleVerify = json_decode ( $v [3], true );
  7738. $roleKey = $k;
  7739. $roleArray = array ();
  7740. $rolename = $role->getOne ( array (
  7741. 'where' => 'rid=' . $v [0],
  7742. 'asArray' => true
  7743. ) );
  7744. foreach ( $roleVerify as $o => $p ) {
  7745. $staffID = explode ( '_', $p );
  7746. $staffInfo = $staff->getOne ( array (
  7747. 'where' => 'sid=' . $staffID [0],
  7748. 'asArray' => true
  7749. ) );
  7750. // print_r($staffID);
  7751. $exp = array (
  7752. 0 => $staffInfo ['sid'],
  7753. 1 => $staffID [1],
  7754. 2 => $staffInfo ['avatar'],
  7755. 'date' => '',
  7756. 'date' => '',
  7757. 'opinion' => '',
  7758. 'status' => '',
  7759. 'rolename' => $rolename ['name']
  7760. );
  7761. array_push ( $roleArray, $exp );
  7762. }
  7763. $roleArrayCopy [$v [0]] = $roleArray;
  7764. // $verifyList[$k]['roleArray']=$roleArray;
  7765. }
  7766. // print_r($roleArray);
  7767. $verifyList [$k] ['date'] = "";
  7768. $verifyList [$k] ['opinion'] = "";
  7769. $verifyList [$k] ['status'] = "";
  7770. if (empty ( $verifyStaff )) {
  7771. $verifyList [$k] ['date'] = "";
  7772. $verifyList [$k] ['opinion'] = "";
  7773. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7774. $verifyList [$k] ['status'] = 4;
  7775. $button = 4;
  7776. $flag = false;
  7777. }
  7778. } else {
  7779. foreach ( $verifyStaff as $m => $u ) {
  7780. if ($v [0] == $m) {
  7781. $verifyList [$k] ['date'] = $u ['date'];
  7782. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7783. $verifyList [$k] ['status'] = $u ['status'];
  7784. $flag = false;
  7785. break;
  7786. }
  7787. }
  7788. $endStaffArray = end ( $verifyStaff );
  7789. if (isset ( $endStaffArray ['ROLE'] )) {
  7790. } else {
  7791. $endKey = key ( $verifyStaff );
  7792. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7793. $button = 4;
  7794. $verifyList [$k] ['status'] = 4;
  7795. }
  7796. }
  7797. // print_r($endStaffArray);die;
  7798. // if (empty($verifyStaff)){
  7799. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  7800. // $verifyList[$k]['status']=4;$button=4;
  7801. // }
  7802. //
  7803. // }else{
  7804. //
  7805. // }
  7806. // if($flag){//检测可编辑
  7807. // if($v[0]==$this->staff[0]['sid']){
  7808. // $verifyList[$k]['status']=4;$button=4;
  7809. // }
  7810. // }
  7811. }
  7812. }
  7813. $rolename ['name'] = '';
  7814. if (! empty ( $roleId )) {
  7815. Doo::loadModel ( 'role' );
  7816. $role = new role ();
  7817. $rolename = $role->getOne ( array (
  7818. 'where' => 'rid=' . $roleId,
  7819. 'asArray' => true
  7820. ) );
  7821. }
  7822. if (! empty ( $verifyStaff ))
  7823. $endStaffArray = end ( $verifyStaff );
  7824. $KOP = false;
  7825. foreach ( $roleArrayCopy as $P => $A ) {
  7826. foreach ( $A as $MKI => $AVL ) {
  7827. if (! empty ( $verifyStaff )) {
  7828. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7829. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7830. $button = 4;
  7831. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7832. }
  7833. foreach ( $verifyStaff as $m => $u ) {
  7834. $AVLFK = $AVL [0] . '_R';
  7835. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7836. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7837. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7838. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7839. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7840. break;
  7841. }
  7842. }
  7843. } else {
  7844. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7845. $button = 4;
  7846. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7847. }
  7848. }
  7849. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7850. $KOP = true;
  7851. }
  7852. }
  7853. // print_r($roleArrayCopy);
  7854. // echo $roleKey;
  7855. foreach ( $roleArrayCopy as $k => $v ) {
  7856. foreach ( $verifyList as $m => $n ) {
  7857. if ($n [0] == $k) {
  7858. array_splice ( $verifyList, $m, 1, $v );
  7859. }
  7860. }
  7861. }
  7862. // if ($KOP)
  7863. // array_splice($verifyList,$roleKey,1,$roleArray);
  7864. // print_r($verifyList);
  7865. $receiptList [$key] ['verifyList'] = $verifyList;
  7866. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7867. 'where' => 'sid=' . $value ['staff'],
  7868. 'asArray' => true
  7869. ) );
  7870. $receiptList [$key] ['button'] = $button;
  7871. }
  7872. // $data['verifyDetail']=$verifyDetail;
  7873. $mothHtml = "";
  7874. for($i = 1; $i <= 12; $i ++) {
  7875. if ($month == $i)
  7876. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7877. else
  7878. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7879. }
  7880. // 获取审批日志
  7881. Doo::loadModel ( 'receiptLog' );
  7882. $receiptLog = new receiptLog ();
  7883. $rlList = array ();
  7884. $rlInfo = $receiptLog->getOne ( array (
  7885. 'where' => 'rid=' . $rid . ' and status=4',
  7886. 'asArray' => true
  7887. ) );
  7888. $tijdate = $receiptLog->getOne ( array (
  7889. 'where' => 'rid=' . $rid . ' and status=2',
  7890. 'asc' => 'rlid',
  7891. 'asArray' => true
  7892. ) );
  7893. if (! empty ( $rlInfo )) {
  7894. $rlList = $receiptLog->find ( array (
  7895. 'where' => 'rid=' . $rid,
  7896. 'asc' => 'rlid',
  7897. 'asArray' => true
  7898. ) );
  7899. }
  7900. $receiptList [0] ['rlList'] = $rlList;
  7901. $enclosurList = $enclosur->find ( array (
  7902. 'where' => 'rid=' . $rid,
  7903. 'asArray' => true
  7904. ) );
  7905. $enclosurHtml = '';
  7906. foreach ( $enclosurList as $value ) {
  7907. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  7908. }
  7909. $data ['enclosurHtml'] = $enclosurHtml;
  7910. $data ['rolename'] = $rolename ['name'];
  7911. $data ['datetij'] = $tijdate ['date'];
  7912. $data ['mothHtml'] = $mothHtml;
  7913. $data ['receiptList'] = $receiptList;
  7914. $data ['receiptApprovalCount'] = count ( $receiptList );
  7915. $data ['status'] = $status;
  7916. $data ['year'] = $year;
  7917. $data ['categoryList'] = $categoryList;
  7918. $data ['staffList'] = $staffList;
  7919. $data ['cid'] = $cid;
  7920. $data ['sid'] = $sid;
  7921. $data ['ap'] = $ap;
  7922. $data ['memu'] = "receipt";
  7923. $data ['staff'] = $this->staff;
  7924. $data ['receiptMemu'] = 'approval';
  7925. $data ['verifyId'] = $this->verifyId;
  7926. $data ['executeId'] = $this->executeId;
  7927. $this->render ( "/admin/saeaReportListReport", $data );
  7928. }
  7929. function remittanceHky() {
  7930. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7931. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  7932. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  7933. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  7934. $page_size = 15;
  7935. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  7936. Doo::loadModel ( 'receipt' );
  7937. $receipt = new receipt ();
  7938. Doo::loadModel ( 'staff' );
  7939. $staff = new staff ();
  7940. $dateCondition = " and Year(executeDate) =" . $year;
  7941. if ($moth != 'MONTH')
  7942. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  7943. if ($day != 'DAY' && $moth != 'MONTH')
  7944. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  7945. $sql = ' (status =8 or status=9 ) and amount>0 ' . $dateCondition;
  7946. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  7947. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  7948. $limit = $pageinfo ['lower'] . ',' . $page_size;
  7949. $dayList = $receipt->find ( array (
  7950. 'select' => 'executeDate,sum(amount) as amount',
  7951. 'where' => $sql,
  7952. 'desc' => 'executeDate',
  7953. 'groupby' => 'executeDate',
  7954. 'limit' => $limit,
  7955. 'asArray' => true
  7956. ) );
  7957. // print_r($dayList);
  7958. foreach ( $dayList as $key => $value ) {
  7959. $remitString = "";
  7960. $receiptList = $receipt->find ( array (
  7961. 'select' => 'rid,executeDate,amount,staff,cid',
  7962. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  7963. 'desc' => 'executeDate',
  7964. 'asArray' => true
  7965. ) );
  7966. foreach ( $receiptList as $k => $v ) {
  7967. $sinfo = $staff->getOne ( array (
  7968. 'select' => 'username,category',
  7969. 'where' => ' sid=' . $v ['staff'],
  7970. 'asArray' => true
  7971. ) );
  7972. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  7973. }
  7974. $dayList [$key] ['staff'] = $remitString;
  7975. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  7976. }
  7977. // print_r($dayList);
  7978. $mothHtml = "";
  7979. for($i = 1; $i <= 12; $i ++) {
  7980. if ($moth == $i)
  7981. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7982. else
  7983. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7984. }
  7985. $dayHtml = "";
  7986. if ($day != "DAY" || $moth != "MONTH") {
  7987. for($i = 1; $i <= 31; $i ++) {
  7988. if ($day == $i)
  7989. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  7990. else
  7991. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  7992. }
  7993. }
  7994. $dateHtml = "";
  7995. $now = date ( "Y" );
  7996. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  7997. if ($YEARD <= $now) {
  7998. $dateHtml .= '<option ';
  7999. if ($year == $YEARD) {
  8000. $dateHtml .= 'selected ';
  8001. }
  8002. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  8003. }
  8004. }
  8005. $data ['dateHtml'] = $dateHtml;
  8006. $data ['page'] = $pageinfo;
  8007. $data ['year'] = $year;
  8008. $data ['moth'] = $moth;
  8009. $data ['day'] = $day;
  8010. $data ['get'] = $get;
  8011. $data ['dayHtml'] = $dayHtml;
  8012. $data ['mothHtml'] = $mothHtml;
  8013. $data ['receiptList'] = $dayList;
  8014. $data ['memu'] = "receipt";
  8015. $data ['staff'] = $this->staff;
  8016. $data ['receiptMemu'] = 'remittanceHky';
  8017. $data ['verifyId'] = $this->verifyId;
  8018. $data ['executeId'] = $this->executeId;
  8019. $this->render ( "/admin/remittanceHky", $data );
  8020. }
  8021. function remittancep() {
  8022. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  8023. Doo::loadModel ( 'receipt' );
  8024. $receipt = new receipt ();
  8025. Doo::loadModel ( 'staff' );
  8026. $staff = new staff ();
  8027. Doo::loadClass ( 'XDeode' );
  8028. $XDeode = new XDeode ( 5 );
  8029. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  8030. $rplist = $receipt->find ( array (
  8031. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8032. 'asArray' => true
  8033. ) );
  8034. $dayList = $receipt->find ( array (
  8035. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8036. 'desc' => 'executeDate',
  8037. 'groupby' => 'staff',
  8038. 'asArray' => true
  8039. ) );
  8040. $html = '';
  8041. foreach ( $dayList as $key => $value ) {
  8042. $sinfo = $staff->getOne ( array (
  8043. 'select' => 'username,category',
  8044. 'where' => ' sid=' . $value ['staff'],
  8045. 'asArray' => true
  8046. ) );
  8047. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  8048. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  8049. $au = 0;
  8050. foreach ( $rplist as $k => $v ) {
  8051. if ($value ['staff'] == $v ['staff']) {
  8052. $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>';
  8053. $au += $v ['amount'];
  8054. }
  8055. }
  8056. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  8057. }
  8058. $data ['html'] = $html;
  8059. $data ['memu'] = "receipt";
  8060. $data ['staff'] = $this->staff;
  8061. $data ['receiptMemu'] = 'remittanceHky';
  8062. $data ['verifyId'] = $this->verifyId;
  8063. $data ['executeId'] = $this->executeId;
  8064. $this->render ( "/admin/remittancep", $data );
  8065. }
  8066. function ajaxGetReceiptDetails() {
  8067. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  8068. Doo::loadClass ( 'XDeode' );
  8069. $XDeode = new XDeode ( 5 );
  8070. $rid = $XDeode->decode ( $rid );
  8071. if (empty ( $rid )) {
  8072. echo json_encode ( array (
  8073. 'status' => 2,
  8074. 'msg' => 'illegal request'
  8075. ) );
  8076. die ();
  8077. }
  8078. Doo::loadModel ( 'receipt' );
  8079. $receipt = new receipt ();
  8080. Doo::loadModel ( 'staff' );
  8081. $staff = new staff ();
  8082. $rinfo = $receipt->getOne ( array (
  8083. 'where' => 'rid= ' . $rid,
  8084. 'asArray' => true
  8085. ) );
  8086. $sinfo = $staff->getOne ( array (
  8087. 'select' => 'username,category',
  8088. 'where' => ' sid=' . $rinfo ['staff'],
  8089. 'asArray' => true
  8090. ) );
  8091. $rinfo ['reviseDetail'] = array ();
  8092. if (! empty ( $rinfo ['reviseDetail'] ))
  8093. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  8094. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  8095. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  8096. $rinfo ['category'] = $sinfo ['category'];
  8097. $verifyStaff = array ();
  8098. if (! empty ( $rinfo ['verifyStaff'] ))
  8099. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  8100. $relust = bcsub ( $rinfo ['sum'], $rinfo ['loanSum'], 2 );
  8101. $rinfo ['relust'] = $relust;
  8102. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  8103. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  8104. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  8105. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  8106. // 费用执行人相关数据
  8107. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  8108. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  8109. foreach ( $executeCopy as $k => $v ) {
  8110. $executeCopy [$k] ['date'] = '';
  8111. $executeCopy [$k] ['opinion'] = '';
  8112. $executeCopy [$k] ['status'] = '';
  8113. if (! empty ( $executeStaff ))
  8114. foreach ( $executeStaff as $m => $u ) {
  8115. if ($v [0] == $m) {
  8116. $executeCopy [$k] ['date'] = $u ['date'];
  8117. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  8118. $executeCopy [$k] ['status'] = $u ['status'];
  8119. break;
  8120. }
  8121. }
  8122. }
  8123. $rinfo ['executeCopy'] = $executeCopy;
  8124. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  8125. if ($rinfo ['Rtype'] == 1) { // 借款费用
  8126. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8127. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  8128. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  8129. $html .= '<tr><th>' . $value ['name'] . '</th>
  8130. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8131. }
  8132. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8133. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8134. <tr><th class="taC" colspan="2">费用说明</th>
  8135. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8136. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8137. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  8138. </tbody></table>';
  8139. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  8140. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8141. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8142. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8143. $html .= '<tr><th>' . $value ['name'] . '</th>
  8144. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8145. }
  8146. $html .= '<tr><th class="taR">合计</th>
  8147. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8148. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8149. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8150. $html .= '<tr><th>' . $value ['name'] . '</th>
  8151. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8152. }
  8153. $html .= '<tr><th class="taR">合计</th>
  8154. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8155. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8156. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8157. $html .= '<tr><th>' . $value ['name'] . '</th>
  8158. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8159. }
  8160. $html .= '<tr><th class="taR">合计</th>
  8161. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8162. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8163. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8164. $html .= '<tr><th>' . $value ['name'] . '</th>
  8165. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8166. }
  8167. $html .= '<tr><th class="taR">合计</th>
  8168. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8169. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8170. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8171. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8172. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8173. }
  8174. $html .= '<tr><th class="taR">合计</th>
  8175. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8176. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8177. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8178. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8179. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8180. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8181. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8182. <tr';
  8183. if ($rinfo ['relust'] >= 0) {
  8184. $html .= 'class="success"';
  8185. } else {
  8186. $html .= 'class="error"';
  8187. }
  8188. $html .= '><td class="taR"><b>借款结余</b></td>
  8189. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  8190. </tbody></table>
  8191. ';
  8192. }
  8193. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  8194. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8195. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  8196. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8197. $html .= '<tr><th>' . $value ['name'] . '</th>
  8198. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8199. }
  8200. $html .= '<tr><th class="taR">合计</th>
  8201. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8202. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8203. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8204. <tr><th class="taC" colspan="2">费用说明</th>
  8205. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8206. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8207. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8208. </tbody></table>';
  8209. } else {
  8210. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8211. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8212. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8213. $html .= '<tr><th>' . $value ['name'] . '</th>
  8214. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8215. }
  8216. $html .= '<tr><th class="taR">合计</th>
  8217. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8218. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8219. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8220. $html .= '<tr><th>' . $value ['name'] . '</th>
  8221. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8222. }
  8223. $html .= '<tr><th class="taR">合计</th>
  8224. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8225. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8226. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8227. $html .= '<tr><th>' . $value ['name'] . '</th>
  8228. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8229. }
  8230. $html .= '<tr><th class="taR">合计</th>
  8231. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8232. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8233. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8234. $html .= '<tr><th>' . $value ['name'] . '</th>
  8235. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8236. }
  8237. $html .= '<tr><th class="taR">合计</th>
  8238. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8239. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8240. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8241. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8242. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8243. }
  8244. $html .= '<tr><th class="taR">合计</th>
  8245. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8246. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8247. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8248. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8249. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8250. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8251. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  8252. $html .= '</tbody></table>';
  8253. /*
  8254. * <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>
  8255. */
  8256. }
  8257. // print_r($verifyStaff);die;
  8258. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  8259. foreach ( $verifyStaff as $key => $value ) {
  8260. $key = trim ( strtr ( $key, '_R', ' ' ) );
  8261. $sinfo = $staff->getOne ( array (
  8262. 'select' => 'username',
  8263. 'where' => ' sid=' . $key,
  8264. 'asArray' => true
  8265. ) );
  8266. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8267. }
  8268. $html .= '</tbody></table>';
  8269. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  8270. foreach ( $rinfo ['executeCopy'] as $value ) {
  8271. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8272. }
  8273. $html .= '</tbody></table>';
  8274. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  8275. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  8276. </tr></table>';
  8277. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  8278. echo json_encode ( array (
  8279. 'status' => 1,
  8280. 'html' => $html
  8281. ) );
  8282. die ();
  8283. }
  8284. /**
  8285. * 删除附件
  8286. */
  8287. function ajaxRemEnclousur() {
  8288. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  8289. if (empty ( $key ))
  8290. echo json_encode ( array (
  8291. 'status' => 2
  8292. ) );
  8293. Doo::loadModel ( 'enclosur' );
  8294. $enclosur = new enclosur ();
  8295. $enclosur->delEnclosurByEid ( $key );
  8296. echo json_encode ( array (
  8297. 'status' => 1
  8298. ) );
  8299. }
  8300. function remittance() {
  8301. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8302. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8303. Doo::loadModel ( 'receipt' );
  8304. $receipt = new receipt ();
  8305. Doo::loadModel ( 'staff' );
  8306. $staff = new staff ();
  8307. $dateCondition = " and Year(pastDate) =" . $year;
  8308. if (! empty ( $month ))
  8309. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  8310. // get Receipt By verifyID status 1
  8311. $receiptList = $receipt->find ( array (
  8312. 'select' => 'sum(sum) as sum,staff,pastDate',
  8313. 'where' => ' status=1' . $dateCondition,
  8314. 'desc' => 'pastDate',
  8315. 'groupby' => 'staff,pastDate',
  8316. 'asArray' => true
  8317. ) );
  8318. $dateList = $receipt->find ( array (
  8319. 'select' => 'pastDate,verifyStaff',
  8320. 'where' => ' status=1' . $dateCondition,
  8321. 'desc' => 'pastDate',
  8322. 'groupby' => 'pastDate',
  8323. 'asArray' => true
  8324. ) );
  8325. $dataList = array ();
  8326. foreach ( $dateList as $d => $a ) {
  8327. $dataList [$a ['pastDate']] = array ();
  8328. $daySum = 0;
  8329. foreach ( $receiptList as $key => $value ) {
  8330. if ($a ['pastDate'] == $value ['pastDate']) {
  8331. $oderList = $receipt->find ( array (
  8332. 'select' => 'receiptOrder',
  8333. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  8334. 'asArray' => true
  8335. ) );
  8336. $list = array ();
  8337. $html = "";
  8338. foreach ( $oderList as $v ) {
  8339. array_push ( $list, $v ['receiptOrder'] );
  8340. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  8341. }
  8342. $receiptList [$key] ['receiptOrder'] = $html;
  8343. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  8344. $sinfo = $staff->getOne ( array (
  8345. 'select' => 'username ',
  8346. 'where' => ' sid=' . $value ['staff'],
  8347. 'asArray' => true
  8348. ) );
  8349. $receiptList [$key] ['username'] = $sinfo ['username'];
  8350. $daySum += $value ['sum'];
  8351. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  8352. }
  8353. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  8354. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  8355. }
  8356. }
  8357. // print_r($dataList);
  8358. $data ['dataList'] = $dataList;
  8359. $mothHtml = "";
  8360. for($i = 1; $i <= 12; $i ++) {
  8361. if ($month == $i)
  8362. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8363. else
  8364. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8365. }
  8366. $data ['year'] = $year;
  8367. $data ['mothHtml'] = $mothHtml;
  8368. $data ['memu'] = "receipt";
  8369. $data ['staff'] = $this->staff;
  8370. $data ['receiptMemu'] = 'approval';
  8371. $data ['verifyId'] = $this->verifyId;
  8372. $data ['executeId'] = $this->executeId;
  8373. $this->render ( "/admin/saeaReportListPay", $data );
  8374. }
  8375. /**
  8376. * 金额调整,提高稳定性
  8377. * @return string
  8378. */
  8379. function revocationAdjustment() {
  8380. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  8381. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  8382. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  8383. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  8384. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  8385. Doo::loadClass ( 'XDeode' );
  8386. $XDeode = new XDeode ( 5 );
  8387. Doo::loadModel ( 'receipt' );
  8388. $receipt = new receipt ();
  8389. $sid = $XDeode->decode ( $sidKey );
  8390. $rid = $XDeode->decode ( $ridKey );
  8391. $reviseKey = $XDeode->decode ( $reviseKey );
  8392. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  8393. die ( 'illegal request' );
  8394. $receiptDetail = $receipt->getOne ( array (
  8395. 'where' => 'rid=' . $rid,
  8396. 'asArray' => true
  8397. ) );
  8398. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  8399. die ( 'illegal request' );
  8400. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8401. if (! isset ( $reviseDetail [$reviseKey] ))
  8402. die ( 'illegal request' );
  8403. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  8404. unset ( $reviseDetail [$reviseKey] );
  8405. $revisePrice = 0;
  8406. foreach ( $reviseDetail as $key => $value ) {
  8407. $revisePrice += $value ['price'];
  8408. }
  8409. $reviseDetailString = json_encode ( $reviseDetail );
  8410. $receipt->reviseDetail = $reviseDetailString;
  8411. $receipt->sum = $receiptDetail ['sum'] - $price;
  8412. $receipt->revisePrice = $revisePrice;
  8413. $receipt->update ( array (
  8414. 'where' => 'rid=' . $rid
  8415. ) );
  8416. return '/receiptburEdi/' . $rid;
  8417. } else
  8418. die ( 'illegal request2' );
  8419. }
  8420. function updateApprovalReceipt() {
  8421. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  8422. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  8423. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8424. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  8425. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  8426. if (! empty ( $rid )) {
  8427. Doo::loadModel ( "verify" );
  8428. $verify = new verify ();
  8429. Doo::loadModel ( "receiptDetail" );
  8430. $receiptDetailObj = new receiptDetail ();
  8431. Doo::loadModel ( "itemStatistics" );
  8432. Doo::loadModel ( "statistics" );
  8433. $statistics = new statistics ();
  8434. $itemStatistics = new itemStatistics ();
  8435. Doo::loadModel ( "receipt" );
  8436. $receipt = new receipt ();
  8437. $receiptDetail = $receipt->getOne ( array (
  8438. 'where' => 'rid=' . $rid . ' and status=2 ',
  8439. 'asArray' => true
  8440. ) );
  8441. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  8442. $nsflag = true;
  8443. foreach ( $nslist as $value ) {
  8444. if ($value == $this->staff ['0'] ['sid']) {
  8445. $nsflag = false;
  8446. break;
  8447. }
  8448. }
  8449. if (empty ( $receiptDetail ) || $nsflag)
  8450. return "/approvalExpenses/pendApproval";
  8451. $verifyDetail = $verify->getOne ( array (
  8452. 'where' => ' vid =' . $receiptDetail ['verify'],
  8453. 'asArray' => true
  8454. ) );
  8455. $verifyString = $verifyDetail ['staff'];
  8456. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  8457. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  8458. if (empty ( $opinion )) {
  8459. if ($status == 3)
  8460. $opinion = "终止";
  8461. else
  8462. $opinion = "同意支付";
  8463. }
  8464. $nowStaff = 0;
  8465. $nowStaffList = array ();
  8466. if (empty ( $verifyStaff )) {
  8467. // 还需加入是否已经进入角色审批
  8468. if ($verifyDetail [0] [1] == 'ROLE') {
  8469. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  8470. foreach ( $vStaffString as $key => $value ) {
  8471. $staffK = explode ( "_", $value );
  8472. if ($staffK [0] != $this->staff [0] ['sid'])
  8473. array_push ( $nowStaffList, $staffK [0] );
  8474. }
  8475. // print_r($verifyDetail);
  8476. // die;
  8477. if (! empty ( $nowStaffList )) {
  8478. $nowStaff = implode ( ',', $nowStaffList );
  8479. $verifyStaff = array (
  8480. $this->staff [0] ['sid'] . "_R" => array (
  8481. 'date' => date ( 'Y-m-d' ),
  8482. 'opinion' => $opinion,
  8483. 'status' => $status,
  8484. 'nextStaff' => $verifyDetail [0] [0],
  8485. 'ROLE' => 1
  8486. )
  8487. );
  8488. } else {
  8489. $nowStaff = $verifyDetail [1] [0];
  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 [1] [0]
  8496. )
  8497. );
  8498. }
  8499. } else {
  8500. if ($verifyDetail [1] [1] == 'ROLE') {
  8501. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  8502. // echo "dd";
  8503. foreach ( $vStaffString as $key => $value ) {
  8504. $staffK = explode ( "_", $value );
  8505. array_push ( $nowStaffList, $staffK [0] );
  8506. }
  8507. $nowStaff = implode ( ',', $nowStaffList );
  8508. $verifyStaff = array (
  8509. $this->staff [0] ['sid'] => array (
  8510. 'date' => date ( 'Y-m-d' ),
  8511. 'opinion' => $opinion,
  8512. 'status' => $status,
  8513. 'nextStaff' => $verifyDetail [1] [0],
  8514. 'ROLE' => 1
  8515. )
  8516. );
  8517. } else {
  8518. $nowStaff = $verifyDetail [1] [0];
  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. )
  8526. );
  8527. }
  8528. }
  8529. if ($status == 3)
  8530. $verifyStaff = array (
  8531. 'final' => $status,
  8532. $this->staff [0] ['sid'] => array (
  8533. 'date' => date ( 'Y-m-d' ),
  8534. 'opinion' => $opinion,
  8535. 'status' => $status
  8536. )
  8537. );
  8538. $vStaffString = json_encode ( $verifyStaff );
  8539. $receipt->nowStaff = $nowStaff;
  8540. $receipt->verifyStaff = $vStaffString;
  8541. } else {
  8542. $VS = end ( $verifyStaff );
  8543. // 非角色审批
  8544. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  8545. $nextStaff = 0;
  8546. $roleSTF = false;
  8547. foreach ( $verifyDetail as $key => $value ) {
  8548. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  8549. if (isset ( $verifyDetail [$key + 1] )) {
  8550. $nextStaff = $verifyDetail [$key + 1] [0];
  8551. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  8552. $roleSTF = true;
  8553. }
  8554. break;
  8555. }
  8556. }
  8557. if (! $roleSTF) {
  8558. $nowStaff = $nextStaff;
  8559. $verifyStaff [$this->staff [0] ['sid']] = array (
  8560. 'date' => date ( 'Y-m-d' ),
  8561. 'opinion' => $opinion,
  8562. 'status' => $status,
  8563. 'nextStaff' => $nextStaff
  8564. );
  8565. } else {
  8566. // 获取角色下的所有用户ID
  8567. $nowStaffList = array ();
  8568. foreach ( $verifyDetail as $vfk ) {
  8569. if ($vfk [1] == 'ROLE') {
  8570. $vStaffString = json_decode ( $vfk [3] );
  8571. foreach ( $vStaffString as $key => $value ) {
  8572. $staffK = explode ( "_", $value );
  8573. array_push ( $nowStaffList, $staffK [0] );
  8574. }
  8575. }
  8576. }
  8577. $nowStaff = implode ( ',', $nowStaffList );
  8578. $verifyStaff [$this->staff [0] ['sid']] = array (
  8579. 'date' => date ( 'Y-m-d' ),
  8580. 'opinion' => $opinion,
  8581. 'status' => $status,
  8582. 'nextStaff' => $nextStaff,
  8583. 'ROLE' => 0
  8584. );
  8585. }
  8586. if ($status == 3) {
  8587. $verifyStaff ['final'] = $status;
  8588. $verifyStaff [$this->staff [0] ['sid']] = array (
  8589. 'date' => date ( 'Y-m-d' ),
  8590. 'opinion' => $opinion,
  8591. 'status' => $status
  8592. );
  8593. }
  8594. $vStaffString = json_encode ( $verifyStaff );
  8595. $receipt->nowStaff = $nowStaff;
  8596. $receipt->verifyStaff = $vStaffString;
  8597. }
  8598. // 角色审批
  8599. if (isset ( $VS ['ROLE'] )) {
  8600. // 找出角色人 当前审批角色组
  8601. $verifyJSStaff = array ();
  8602. $nowStaffList2 = array ();
  8603. foreach ( $verifyDetail as $key => $value ) {
  8604. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  8605. $verifyJSStaff = json_decode ( $value [3] );
  8606. foreach ( $verifyJSStaff as $m ) {
  8607. $staffK = explode ( "_", $m );
  8608. array_push ( $nowStaffList2, $staffK [0] );
  8609. }
  8610. // print_r($nowStaffList2);
  8611. }
  8612. }
  8613. $RoleVerifyStaff = array ();
  8614. foreach ( $verifyStaff as $key => $value ) {
  8615. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  8616. foreach ( $nowStaffList2 as $m ) {
  8617. if ($key == $m . "_R")
  8618. $RoleVerifyStaff [$key] = $value;
  8619. }
  8620. }
  8621. }
  8622. // print_r($verifyStaff);
  8623. // print_r($nowStaffList2);
  8624. // print_r($RoleVerifyStaff);
  8625. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  8626. // print_r($verifyJSStaff);
  8627. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  8628. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  8629. // 下一个审批人ID
  8630. $nextStaff = 0;
  8631. $falg = false;
  8632. foreach ( $verifyDetail as $key => $value ) {
  8633. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  8634. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  8635. $falg = true;
  8636. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  8637. $nowStaffList = array ();
  8638. foreach ( $vStaffString as $v ) {
  8639. $staffK = explode ( "_", $v );
  8640. array_push ( $nowStaffList, $staffK [0] );
  8641. }
  8642. $nowStaff = implode ( ',', $nowStaffList );
  8643. $nextStaff = $verifyDetail [$key + 1] [0];
  8644. } elseif (isset ( $verifyDetail [$key + 1] )) {
  8645. $nextStaff = $verifyDetail [$key + 1] [0];
  8646. $nowStaff = $nextStaff;
  8647. } else
  8648. $nowStaff = '';
  8649. break;
  8650. }
  8651. }
  8652. if ($falg)
  8653. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8654. 'date' => date ( 'Y-m-d' ),
  8655. 'opinion' => $opinion,
  8656. 'status' => $status,
  8657. 'nextStaff' => $nextStaff,
  8658. 'ROLE' => 1
  8659. );
  8660. else
  8661. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8662. 'date' => date ( 'Y-m-d' ),
  8663. 'opinion' => $opinion,
  8664. 'status' => $status,
  8665. 'nextStaff' => $nextStaff
  8666. );
  8667. // print_r($verifyStaff);
  8668. // echo $nowStaff;die;
  8669. } else { // 进入下一个角色或者审批人
  8670. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  8671. //
  8672. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  8673. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8674. 'date' => date ( 'Y-m-d' ),
  8675. 'opinion' => $opinion,
  8676. 'status' => $status,
  8677. 'nextStaff' => $VS ['nextStaff'],
  8678. 'ROLE' => 1
  8679. );
  8680. // print_r($verifyStaff);
  8681. // die;
  8682. }
  8683. if ($status == 3) {
  8684. $verifyStaff ['final'] = $status;
  8685. $verifyStaff [$this->staff [0] ['sid']] = array (
  8686. 'date' => date ( 'Y-m-d' ),
  8687. 'opinion' => $opinion,
  8688. 'status' => $status
  8689. );
  8690. }
  8691. $vStaffString = json_encode ( $verifyStaff );
  8692. $receipt->verifyStaff = $vStaffString;
  8693. $receipt->nowStaff = $nowStaff;
  8694. // die;
  8695. // }
  8696. // print_r($verifyStaff);
  8697. // die;
  8698. }
  8699. // print_r($verifyStaff);die;
  8700. }
  8701. // print_r($verifyDetail);
  8702. $roleKey = 0;
  8703. $roleId = 0;
  8704. $verifyDetailCopy = array ();
  8705. foreach ( $verifyDetail as $k => $v ) {
  8706. if ($v [1] == 'ROLE') {
  8707. $roleId = $v [0];
  8708. $roleVerify = json_decode ( $v [3], true );
  8709. $roleKey = $k;
  8710. $roleArray = array ();
  8711. foreach ( $roleVerify as $o => $p ) {
  8712. $staffID = explode ( '_', $p );
  8713. $exp = array (
  8714. 0 => $staffID [0],
  8715. 1 => $staffID [1]
  8716. );
  8717. array_push ( $roleArray, $exp );
  8718. }
  8719. $verifyDetailCopy [$v [0]] = $roleArray;
  8720. }
  8721. }
  8722. // print_r($verifyDetail);
  8723. foreach ( $verifyDetailCopy as $k => $v ) {
  8724. foreach ( $verifyDetail as $m => $n ) {
  8725. if ($n [0] == $k) {
  8726. array_splice ( $verifyDetail, $m, 1, $v );
  8727. }
  8728. }
  8729. }
  8730. // die;
  8731. // if (!empty($roleArray))
  8732. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  8733. // echo $roleId;
  8734. // print_r($verifyStaff);
  8735. // print_r($verifyDetail);
  8736. // die;
  8737. Doo::loadModel ( "receiptLog" );
  8738. $receiptLog = new receiptLog ();
  8739. // 审批日志
  8740. if (! isset ( $verifyStaff ['final'] )) {
  8741. if (! empty ( $roleId )) {
  8742. Doo::loadModel ( "role" );
  8743. $role = new role ();
  8744. $roleInfo = $role->getOne ( array (
  8745. 'where' => 'rid=' . $roleId,
  8746. 'asArray' => true
  8747. ) );
  8748. $receiptLog->rolename = $roleInfo ['name'];
  8749. }
  8750. $receiptLog->username = $this->staff [0] ['username'];
  8751. $receiptLog->uid = $this->staff [0] ['sid'];
  8752. $receiptLog->date = date ( "Y-m-d" );
  8753. $receiptLog->opinion = $opinion;
  8754. $receiptLog->img = $this->staff [0] ['avatar'];
  8755. $receiptLog->status = 1;
  8756. $receiptLog->rid = $rid;
  8757. $receiptLog->insert ();
  8758. }
  8759. if (isset ( $verifyStaff ['final'] )) { // rDetail
  8760. $receipt->verifyBreakup = $verifyString;
  8761. $receipt->status = 3;
  8762. $receiptDetailObj->status = 3;
  8763. $receiptDetailObj->update ( array (
  8764. 'where' => 'rid=' . $rid
  8765. ) );
  8766. if (! empty ( $roleId )) {
  8767. Doo::loadModel ( "role" );
  8768. $role = new role ();
  8769. $roleInfo = $role->getOne ( array (
  8770. 'where' => 'rid=' . $roleId,
  8771. 'asArray' => true
  8772. ) );
  8773. $receiptLog->rolename = $roleInfo ['name'];
  8774. }
  8775. $receiptLog->username = $this->staff [0] ['username'];
  8776. $receiptLog->uid = $this->staff [0] ['sid'];
  8777. $receiptLog->date = date ( "Y-m-d" );
  8778. $receiptLog->opinion = $opinion;
  8779. $receiptLog->img = $this->staff [0] ['avatar'];
  8780. $receiptLog->status = 3;
  8781. $receiptLog->rid = $rid;
  8782. $receiptLog->insert ();
  8783. // 微信企业号通知
  8784. $this->setWXMsg ( $rid, 3 );
  8785. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  8786. $receipt->status = 1;
  8787. $reviseSum = 0;
  8788. $receipt->verifyBreakup = $verifyString;
  8789. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  8790. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8791. foreach ( $reviseDetail as $key => $value ) {
  8792. $receiptDetailObj = new receiptDetail ();
  8793. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8794. $receiptDetailObj->item = $value ['description'];
  8795. $receiptDetailObj->itemCategory = "报销金额调整";
  8796. $receiptDetailObj->price = $value ['price'];
  8797. $receiptDetailObj->date = $receiptDetail ['date'];
  8798. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  8799. $receiptDetailObj->rid = $rid;
  8800. $receiptDetailObj->status = 1;
  8801. $receiptDetailObj->insert ();
  8802. $reviseSum += $value ['price'];
  8803. }
  8804. $itemStatistics = new itemStatistics ();
  8805. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  8806. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8807. $itemStatistics->price = $reviseSum;
  8808. $itemStatistics->itemCategory = "报销金额调整";
  8809. $itemStatistics->date = $receiptDetail ['date'];
  8810. $itemStatistics->insert ();
  8811. }
  8812. $receiptDetailObj = new receiptDetail ();
  8813. $receiptDetailObj->status = 1;
  8814. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  8815. $receiptDetailObj->update ( array (
  8816. 'where' => 'rid=' . $rid
  8817. ) );
  8818. $dateArray = explode ( "-", $receiptDetail ['date'] );
  8819. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  8820. $stat = $statistics->getOne ( array (
  8821. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  8822. 'asArray' => true
  8823. ) );
  8824. if (empty ( $stat )) {
  8825. $statistics->date = $receiptDetail ['date'];
  8826. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  8827. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8828. $statistics->agPrice = $receiptDetail ['sum'];
  8829. $statistics->rePrice = $reviseSum;
  8830. $statistics->insert ();
  8831. } else {
  8832. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  8833. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  8834. $statistics->update ( array (
  8835. 'where' => 'sid=' . $stat ['sid']
  8836. ) );
  8837. }
  8838. $dateArray = explode ( "-", $receiptDetail ['date'] );
  8839. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  8840. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  8841. foreach ( $accountItem ['cSum'] as $key => $value ) {
  8842. if ($key == "agencySum") {
  8843. $iStatistics = $itemStatistics->getOne ( array (
  8844. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  8845. 'asArray' => true
  8846. ) );
  8847. if (empty ( $iStatistics )) {
  8848. $itemStatistics->cid = $receiptDetail ['cid'];
  8849. ;
  8850. $itemStatistics->staff = $receiptDetail ['staff'];
  8851. $itemStatistics->price = $value;
  8852. $itemStatistics->itemCategory = $this->AGENCY;
  8853. $itemStatistics->date = $receiptDetail ['date'];
  8854. $itemStatistics->insert ();
  8855. } else {
  8856. if (! empty ( $value )) {
  8857. $itemStatistics->price = $value + $iStatistics ['price'];
  8858. $itemStatistics->update ( array (
  8859. 'where' => 'sid=' . $iStatistics ['sid']
  8860. ) );
  8861. }
  8862. }
  8863. } elseif ($key == "travelSum") {
  8864. $iStatistics = $itemStatistics->getOne ( array (
  8865. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  8866. 'asArray' => true
  8867. ) );
  8868. if (empty ( $iStatistics )) {
  8869. $itemStatistics->cid = $receiptDetail ['cid'];
  8870. $itemStatistics->staff = $receiptDetail ['staff'];
  8871. $itemStatistics->price = $value;
  8872. $itemStatistics->itemCategory = $this->TRAVEL;
  8873. $itemStatistics->date = $receiptDetail ['date'];
  8874. $itemStatistics->insert ();
  8875. } else {
  8876. if (! empty ( $value )) {
  8877. $itemStatistics->price = $value + $iStatistics ['price'];
  8878. $itemStatistics->update ( array (
  8879. 'where' => 'sid=' . $iStatistics ['sid']
  8880. ) );
  8881. }
  8882. }
  8883. } elseif ($key == "trainSum") {
  8884. $iStatistics = $itemStatistics->getOne ( array (
  8885. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  8886. 'asArray' => true
  8887. ) );
  8888. if (empty ( $iStatistics )) {
  8889. $itemStatistics->cid = $receiptDetail ['cid'];
  8890. $itemStatistics->staff = $receiptDetail ['staff'];
  8891. $itemStatistics->price = $value;
  8892. $itemStatistics->itemCategory = $this->TRAIN;
  8893. $itemStatistics->date = $receiptDetail ['date'];
  8894. $itemStatistics->insert ();
  8895. } else {
  8896. if (! empty ( $value )) {
  8897. $itemStatistics->price = $value + $iStatistics ['price'];
  8898. $itemStatistics->update ( array (
  8899. 'where' => 'sid=' . $iStatistics ['sid']
  8900. ) );
  8901. }
  8902. }
  8903. } elseif ($key == "otherSum") {
  8904. $iStatistics = $itemStatistics->getOne ( array (
  8905. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  8906. 'asArray' => true
  8907. ) );
  8908. if (empty ( $iStatistics )) {
  8909. $itemStatistics->cid = $receiptDetail ['cid'];
  8910. $itemStatistics->staff = $receiptDetail ['staff'];
  8911. $itemStatistics->price = $value;
  8912. $itemStatistics->itemCategory = $this->OTHER;
  8913. $itemStatistics->date = $receiptDetail ['date'];
  8914. $itemStatistics->insert ();
  8915. } else {
  8916. if (! empty ( $value )) {
  8917. $itemStatistics->price = $value + $iStatistics ['price'];
  8918. $itemStatistics->update ( array (
  8919. 'where' => 'sid=' . $iStatistics ['sid']
  8920. ) );
  8921. }
  8922. }
  8923. }
  8924. }
  8925. $receipt->pastDate = date ( "Y-m-d" );
  8926. // 微信企业号通知
  8927. $this->setWXMsg ( $rid, 1 );
  8928. }
  8929. //是否有流水
  8930. Doo::loadModel ( 'wasteBook' );
  8931. $wasteBook = new wasteBook ();
  8932. $accountType=3;
  8933. if ($receiptDetail['Rtype']==1){
  8934. $accountType=2;
  8935. }elseif($receiptDetail['Rtype']==2){
  8936. $accountType=4;
  8937. }
  8938. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $rid );
  8939. if (empty($wbDetail)){
  8940. $rsum=$receiptDetail['sum']-$receiptDetail['loanSum'];
  8941. $receipt->amount = $rsum;//$amount;
  8942. }
  8943. $receipt->update ( array (
  8944. 'where' => ' rid = ' . $rid
  8945. ) );
  8946. // 进入下一条审批费用新加需求
  8947. $vidList = array ();
  8948. $verifyDetail = $verify->find ( array (
  8949. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  8950. 'asArray' => true
  8951. ) );
  8952. foreach ( $verifyDetail as $key => $value ) {
  8953. array_push ( $vidList, $value ['vid'] );
  8954. }
  8955. $vid = implode ( ",", $vidList );
  8956. if (empty ( $verifyDetail ))
  8957. $vid = 0;
  8958. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  8959. $receipt = new receipt ();
  8960. $rd = $receipt->getOne ( array (
  8961. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ') and Rtype!=3',
  8962. 'asc' => 'rid',
  8963. 'asArray' => true
  8964. ) );
  8965. if (empty ( $rd )) {
  8966. return '/approvalExpenses/pendApproval';
  8967. }
  8968. if ($rd ['Rtype'] == 1) {
  8969. if ($rd ['isBK'] == 1) {
  8970. return '/receiptburEdi/' . $rd ['rid'];
  8971. } else {
  8972. return '/expensesEdi/' . $rd ['rid'];
  8973. }
  8974. } elseif ($rd ['Rtype'] == 2) {
  8975. return '/remitApproval/' . $rd ['rid'];
  8976. } else {
  8977. return '/receiptburEdi/' . $rd ['rid'];
  8978. }
  8979. // return "/approvalExpenses/pendApproval";
  8980. }
  8981. }
  8982. function expensesRetreats() {
  8983. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  8984. if (! empty ( $rid )) {
  8985. // 操作记录
  8986. Doo::loadModel ( "receipt" );
  8987. $receipt = new receipt ();
  8988. Doo::loadModel ( "receiptLog" );
  8989. $receiptLog = new receiptLog ();
  8990. Doo::loadModel ( "verify" );
  8991. $verify = new verify ();
  8992. $receiptInfo = $receipt->getOne ( array (
  8993. 'where' => 'rid=' . $rid,
  8994. 'asArray' => true
  8995. ) );
  8996. $vr = $verify->getOne ( array (
  8997. 'where' => 'vid=' . $receiptInfo ['verify'],
  8998. 'asArray' => true
  8999. ) );
  9000. $jd = json_decode ( $vr ['staff'] );
  9001. $roleId = 0;
  9002. foreach ( $jd as $key => $value ) {
  9003. if ($value [1] == 'ROLE') {
  9004. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9005. if ($pos !== false) {
  9006. $roleId = $value [0];
  9007. }
  9008. }
  9009. }
  9010. // 审批日志
  9011. // echo $roleId;die;
  9012. if (! empty ( $roleId )) {
  9013. Doo::loadModel ( "role" );
  9014. $role = new role ();
  9015. $roleInfo = $role->getOne ( array (
  9016. 'where' => 'rid=' . $roleId,
  9017. 'asArray' => true
  9018. ) );
  9019. $receiptLog->rolename = $roleInfo ['name'];
  9020. }
  9021. $receiptLog->username = $this->staff [0] ['username'];
  9022. $receiptLog->uid = $this->staff [0] ['sid'];
  9023. $receiptLog->date = date ( "Y-m-d" );
  9024. $receiptLog->opinion = '撤回';
  9025. $receiptLog->img = $this->staff [0] ['avatar'];
  9026. $receiptLog->status = 4;
  9027. $receiptLog->rid = $rid;
  9028. $receiptLog->insert ();
  9029. $receipt->status = 4;
  9030. $receipt->update ( array (
  9031. 'where' => 'rid=' . $rid
  9032. ) );
  9033. // 微信企业号通知
  9034. $this->setWXMsg ( $rid, 2 );
  9035. }
  9036. // echo "ddd";
  9037. return '/approvalExpenses/pendApproval';
  9038. }
  9039. function updateCheReceipt() {
  9040. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9041. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  9042. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  9043. if (! empty ( $rid )) {
  9044. // 操作记录
  9045. Doo::loadModel ( "receipt" );
  9046. $receipt = new receipt ();
  9047. Doo::loadModel ( "receiptLog" );
  9048. $receiptLog = new receiptLog ();
  9049. Doo::loadModel ( "verify" );
  9050. $verify = new verify ();
  9051. $receiptInfo = $receipt->getOne ( array (
  9052. 'where' => 'rid=' . $rid . ' and status=2',
  9053. 'asArray' => true
  9054. ) );
  9055. if (empty ( $receiptInfo )) {
  9056. echo json_encode ( array (
  9057. 'status' => 2
  9058. ) );
  9059. die ();
  9060. }
  9061. $vr = $verify->getOne ( array (
  9062. 'where' => 'vid=' . $receiptInfo ['verify'],
  9063. 'asArray' => true
  9064. ) );
  9065. $jd = json_decode ( $vr ['staff'] );
  9066. $roleId = 0;
  9067. foreach ( $jd as $key => $value ) {
  9068. if ($value [1] == 'ROLE') {
  9069. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9070. if ($pos !== false) {
  9071. $roleId = $value [0];
  9072. }
  9073. }
  9074. }
  9075. // 审批日志
  9076. // echo $roleId;die;
  9077. if (! empty ( $roleId )) {
  9078. Doo::loadModel ( "role" );
  9079. $role = new role ();
  9080. $roleInfo = $role->getOne ( array (
  9081. 'where' => 'rid=' . $roleId,
  9082. 'asArray' => true
  9083. ) );
  9084. $receiptLog->rolename = $roleInfo ['name'];
  9085. }
  9086. $receiptLog->username = $this->staff [0] ['username'];
  9087. $receiptLog->uid = $this->staff [0] ['sid'];
  9088. $receiptLog->date = date ( "Y-m-d" );
  9089. $receiptLog->opinion = $opinion;
  9090. $receiptLog->img = $this->staff [0] ['avatar'];
  9091. $receiptLog->status = 4;
  9092. $receiptLog->rid = $rid;
  9093. $receiptLog->insert ();
  9094. $receipt->status = 4;
  9095. $receipt->update ( array (
  9096. 'where' => 'rid=' . $rid
  9097. ) );
  9098. // 微信企业号通知
  9099. $this->setWXMsg ( $rid, 2 );
  9100. echo json_encode ( array (
  9101. 'status' => 1
  9102. ) );
  9103. // Header("HTTP/1.1 303 See Other");
  9104. // Header("Location: /approvalExpenses/pendApproval");
  9105. die ();
  9106. }
  9107. echo json_encode ( array (
  9108. 'status' => 2
  9109. ) );
  9110. die ();
  9111. // echo "ddd";
  9112. // return '/saeaBorad';
  9113. }
  9114. function revisePrice() {
  9115. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  9116. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  9117. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9118. // echo $price;die;
  9119. if (! empty ( $rid )) {
  9120. Doo::loadModel ( "receipt" );
  9121. $receipt = new receipt ();
  9122. $receiptDetail = $receipt->getOne ( array (
  9123. 'where' => 'rid=' . $rid . ' and status=2 ',
  9124. 'asArray' => true
  9125. ) );
  9126. if (empty ( $receiptDetail ))
  9127. die ( 'illegal request' );
  9128. $reviseDetail = array ();
  9129. if (empty ( $receiptDetail ['reviseDetail'] )) {
  9130. array_push ( $reviseDetail, array (
  9131. 'sid' => $this->staff [0] ['sid'],
  9132. 'name' => $this->staff [0] ['username'],
  9133. 'description' => $description,
  9134. 'price' => $price
  9135. ) );
  9136. $reviseDetailString = json_encode ( $reviseDetail );
  9137. $receipt->reviseDetail = $reviseDetailString;
  9138. $receipt->revisePrice = $price;
  9139. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9140. } else {
  9141. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9142. array_push ( $reviseDetail, array (
  9143. 'sid' => $this->staff [0] ['sid'],
  9144. 'name' => $this->staff [0] ['username'],
  9145. 'description' => $description,
  9146. 'price' => $price
  9147. ) );
  9148. $reviseDetailString = json_encode ( $reviseDetail );
  9149. $receipt->reviseDetail = $reviseDetailString;
  9150. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  9151. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9152. }
  9153. $receipt->update ( array (
  9154. 'where' => 'rid=' . $rid
  9155. ) );
  9156. if ($receiptDetail ['Rtype'] == 1) {
  9157. if ($receiptDetail ['isBK'] == 1) {
  9158. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9159. }
  9160. } elseif ($receiptDetail ['Rtype'] == 2) {
  9161. } else {
  9162. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9163. }
  9164. }
  9165. die ( 'illegal request' );
  9166. }
  9167. function personalCollect() {
  9168. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9169. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  9170. $this->showCache ( $path );
  9171. Doo::loadModel ( "receiptDetail" );
  9172. Doo::loadModel ( "itemStatistics" );
  9173. Doo::loadModel ( 'statistics' );
  9174. $statistics = new statistics ();
  9175. $itemStatistics = new itemStatistics ();
  9176. $receiptDetail = new receiptDetail ();
  9177. $receiptCollectList = $receiptDetail->find ( array (
  9178. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9179. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9180. 'groupby' => 'itemCategory,Month(date)',
  9181. 'asArray' => true
  9182. ) );
  9183. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  9184. 'where' => 'staff=' . $this->staff [0] ['sid'],
  9185. 'asArray' => true
  9186. ) );
  9187. // create collect html
  9188. $collectArray = array (
  9189. '日常相关费用' => array (),
  9190. '差旅相关费用' => array (),
  9191. '培训班费用' => array (),
  9192. '其他' => array ()
  9193. );
  9194. $adjustment = array ();
  9195. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  9196. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9197. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  9198. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9199. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  9200. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9201. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  9202. array_push ( $collectArray ['其他'], $collectHtml );
  9203. $data ['collectArray'] = $collectArray;
  9204. // statistics html
  9205. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9206. if (empty ( $stList ))
  9207. $stList = array (
  9208. 'rePrice' => 0,
  9209. 'agPrice' => 0
  9210. );
  9211. $data ['stList'] = array (
  9212. 'rePrice' => $stList ['rePrice'],
  9213. 'agPrice' => $stList ['agPrice'],
  9214. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9215. );
  9216. // Adjustment price html
  9217. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9218. array_push ( $adjustment, $collectHtml );
  9219. $data ['adjustment'] = $adjustment;
  9220. // total price html
  9221. $collectHtml = "";
  9222. $total = 0;
  9223. for($i = 1; $i <= 12; $i ++) {
  9224. $sumPrice = 0;
  9225. foreach ( $receiptCollectList as $key => $value ) {
  9226. if ($value ['month'] == $i) {
  9227. $sumPrice += $value ['price'];
  9228. }
  9229. }
  9230. if ($sumPrice == 0)
  9231. $collectHtml .= '<td class="taR">-</td>';
  9232. else
  9233. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9234. $total += $sumPrice;
  9235. }
  9236. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9237. $data ['totalPrice'] = $collectHtml;
  9238. $dateHtml = "";
  9239. $now = date ( "Y" );
  9240. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9241. if ($YEARD <= $now) {
  9242. $dateHtml .= '<option ';
  9243. if ($year == $YEARD) {
  9244. $dateHtml .= 'selected ';
  9245. }
  9246. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9247. }
  9248. }
  9249. $data ['dateHtml'] = $dateHtml;
  9250. $data ['year'] = $year;
  9251. $data ['totalYear'] = $total;
  9252. $data ['memu'] = "receipt";
  9253. $data ['staff'] = $this->staff;
  9254. $data ['receiptMemu'] = 'personalCollect';
  9255. $data ['verifyId'] = $this->verifyId;
  9256. $data ['executeId'] = $this->executeId;
  9257. // year staff status 2,4
  9258. if ($year < date ( "Y" )) {
  9259. Doo::loadModel ( 'receipt' );
  9260. $receipt = new receipt ();
  9261. $receiptList = $receipt->find ( array (
  9262. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9263. 'asArray' => true
  9264. ) );
  9265. if (empty ( $receiptList )) {
  9266. ob_start ();
  9267. $this->render ( "/admin/saea_slist_collect", $data );
  9268. $this->cacheFile ( $path );
  9269. die ();
  9270. }
  9271. }
  9272. $this->render ( "/admin/saea_slist_collect", $data );
  9273. }
  9274. function personalCollectDetail() {
  9275. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9276. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  9277. $this->showCache ( $path );
  9278. Doo::loadModel ( "receiptDetail" );
  9279. Doo::loadModel ( "itemStatistics" );
  9280. Doo::loadModel ( 'statistics' );
  9281. Doo::loadModel ( 'accountItem' );
  9282. $accountItem = new accountItem ();
  9283. $statistics = new statistics ();
  9284. $itemStatistics = new itemStatistics ();
  9285. $receiptDetail = new receiptDetail ();
  9286. $receiptCollectList = $receiptDetail->find ( array (
  9287. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9288. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9289. 'groupby' => 'item,Month(date)',
  9290. 'asArray' => true
  9291. ) );
  9292. $accountList = $accountItem->find ( array (
  9293. 'asArray' => true
  9294. ) );
  9295. // create CollectDetail HTML
  9296. $collectHtml = array ();
  9297. foreach ( $accountList as $key => $value ) {
  9298. $html = "";
  9299. $asum = 0;
  9300. for($i = 1; $i <= 12; $i ++) {
  9301. $falg = true;
  9302. foreach ( $receiptCollectList as $v ) {
  9303. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9304. $asum += $v ['price'];
  9305. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9306. $falg = false;
  9307. break;
  9308. }
  9309. }
  9310. if ($falg)
  9311. $html .= '<td class="taR">-</td>';
  9312. }
  9313. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9314. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9315. }
  9316. $data ['collectHtml'] = $collectHtml;
  9317. // create Adjustment price html
  9318. $receiptCollectList = $receiptDetail->find ( array (
  9319. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9320. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9321. 'groupby' => 'itemCategory,Month(date)',
  9322. 'asArray' => true
  9323. ) );
  9324. $adjustment = array ();
  9325. $collectArray = array (
  9326. '日常相关费用' => array (),
  9327. '差旅相关费用' => array (),
  9328. '培训班费用' => array (),
  9329. '其他' => array ()
  9330. );
  9331. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9332. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9333. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9334. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9335. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9336. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9337. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9338. array_push ( $collectArray ['其他'], $collectHtml );
  9339. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9340. array_push ( $adjustment, $collectHtml );
  9341. // total price html
  9342. $collectHtml = "";
  9343. $total = 0;
  9344. for($i = 1; $i <= 12; $i ++) {
  9345. $sumPrice = 0;
  9346. foreach ( $receiptCollectList as $key => $value ) {
  9347. if ($value ['month'] == $i) {
  9348. $sumPrice += $value ['price'];
  9349. }
  9350. }
  9351. if ($sumPrice == 0)
  9352. $collectHtml .= '<td class="taR">-</td>';
  9353. else
  9354. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9355. $total += $sumPrice;
  9356. }
  9357. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9358. // statistics html
  9359. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9360. if (empty ( $stList ))
  9361. $stList = array (
  9362. 'rePrice' => 0,
  9363. 'agPrice' => 0
  9364. );
  9365. $data ['stList'] = array (
  9366. 'rePrice' => $stList ['rePrice'],
  9367. 'agPrice' => $stList ['agPrice'],
  9368. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9369. );
  9370. $data ['collectArray'] = $collectArray;
  9371. $data ['adjustment'] = $adjustment;
  9372. $data ['totalPrice'] = $collectHtml;
  9373. $data ['totalYear'] = $total;
  9374. $data ['year'] = $year;
  9375. $dateHtml = "";
  9376. $now = date ( "Y" );
  9377. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9378. if ($YEARD <= $now) {
  9379. $dateHtml .= '<option ';
  9380. if ($year == $YEARD) {
  9381. $dateHtml .= 'selected ';
  9382. }
  9383. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9384. }
  9385. }
  9386. $data ['dateHtml'] = $dateHtml;
  9387. $data ['memu'] = "receipt";
  9388. $data ['staff'] = $this->staff;
  9389. $data ['receiptMemu'] = 'personalCollect';
  9390. $data ['verifyId'] = $this->verifyId;
  9391. $data ['executeId'] = $this->executeId;
  9392. // year staff status 2,4
  9393. if ($year < date ( "Y" )) {
  9394. Doo::loadModel ( 'receipt' );
  9395. $receipt = new receipt ();
  9396. $receiptList = $receipt->find ( array (
  9397. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9398. 'asArray' => true
  9399. ) );
  9400. if (empty ( $receiptList )) {
  9401. ob_start ();
  9402. $this->render ( "/admin/saeaCollectArticles", $data );
  9403. $this->cacheFile ( $path );
  9404. die ();
  9405. }
  9406. }
  9407. $this->render ( "/admin/saeaCollectArticles", $data );
  9408. }
  9409. function companyCategoryCollect() {
  9410. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9411. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  9412. $this->showCache ( $path );
  9413. Doo::loadModel ( 'L_category' );
  9414. Doo::loadModel ( 'itemStatistics' );
  9415. Doo::loadModel ( 'statistics' );
  9416. $statistics = new statistics ();
  9417. $Lcategory = new L_category ();
  9418. $itemStatistics = new itemStatistics ();
  9419. Doo::loadModel ( "receiptAuthorityManage" );
  9420. $receiptAuthorityManage = new receiptAuthorityManage ();
  9421. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9422. $cidList = array ();
  9423. foreach ( $imcStaff as $key => $value ) {
  9424. array_push ( $cidList, $value ['cid'] );
  9425. }
  9426. $cidString = implode ( ',', $cidList );
  9427. $LcategoryList = $Lcategory->find ( array (
  9428. 'where' => ' cid in (' . $cidString . ')',
  9429. 'asArray' => true
  9430. ) ); // 'staff='.$this->staff[0]['sid']." and
  9431. $itemStatisticsList = $itemStatistics->find ( array (
  9432. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9433. 'where' => " Year(date)=" . $year,
  9434. 'groupby' => 'cid,Month(date)',
  9435. 'asArray' => true
  9436. ) );
  9437. // ceatre companyCollectHtml
  9438. foreach ( $LcategoryList as $value ) {
  9439. $html = "";
  9440. $asum = 0;
  9441. for($i = 1; $i <= 12; $i ++) {
  9442. $falg = true;
  9443. foreach ( $itemStatisticsList as $v ) {
  9444. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  9445. $asum += $v ['price'];
  9446. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9447. $falg = false;
  9448. break;
  9449. }
  9450. }
  9451. if ($falg)
  9452. $html .= '<td class="taR">-</td>';
  9453. }
  9454. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9455. $collectHtml [$value ['title']] = array (
  9456. 'html' => $html,
  9457. 'cid' => $value ['cid']
  9458. );
  9459. }
  9460. $data ['companyHtml'] = $collectHtml;
  9461. // total price html
  9462. $collectHtml = "";
  9463. $total = 0;
  9464. for($i = 1; $i <= 12; $i ++) {
  9465. $sumPrice = 0;
  9466. foreach ( $itemStatisticsList as $key => $value ) {
  9467. if ($value ['month'] == $i) {
  9468. $sumPrice += $value ['price'];
  9469. }
  9470. }
  9471. if ($sumPrice == 0)
  9472. $collectHtml .= '<td class="taR">-</td>';
  9473. else
  9474. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9475. $total += $sumPrice;
  9476. }
  9477. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9478. $data ['companyTotalHtml'] = $collectHtml;
  9479. $data ['total'] = $total;
  9480. // statistics html
  9481. // echo $cidString;
  9482. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9483. if (empty ( $stList ))
  9484. $stList = array (
  9485. 'rePrice' => 0,
  9486. 'agPrice' => 0
  9487. );
  9488. $data ['stList'] = array (
  9489. 'rePrice' => $stList ['rePrice'],
  9490. 'agPrice' => $stList ['agPrice'],
  9491. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9492. );
  9493. $data ['year'] = $year;
  9494. $data ['memu'] = "receipt";
  9495. $data ['staff'] = $this->staff;
  9496. $data ['receiptMemu'] = 'companyCategoryCollect';
  9497. $data ['verifyId'] = $this->verifyId;
  9498. $data ['executeId'] = $this->executeId;
  9499. $dateHtml = "";
  9500. $now = date ( "Y" );
  9501. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9502. if ($YEARD <= $now) {
  9503. $dateHtml .= '<option ';
  9504. if ($year == $YEARD) {
  9505. $dateHtml .= 'selected ';
  9506. }
  9507. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9508. }
  9509. }
  9510. $data ['dateHtml'] = $dateHtml;
  9511. // year staff status 2,4
  9512. if ($year < date ( "Y" )) {
  9513. Doo::loadModel ( 'receipt' );
  9514. $receipt = new receipt ();
  9515. $receiptList = $receipt->find ( array (
  9516. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  9517. 'asArray' => true
  9518. ) );
  9519. if (empty ( $receiptList )) {
  9520. ob_start ();
  9521. $this->render ( "/admin/saeaCompanyCollect", $data );
  9522. $this->cacheFile ( $path );
  9523. die ();
  9524. }
  9525. }
  9526. $this->render ( "/admin/saeaCompanyCollect", $data );
  9527. }
  9528. function categoryCollectDetail() {
  9529. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9530. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  9531. /* $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  9532. $this->showCache ( $path ); */
  9533. Doo::loadModel ( 'statistics' );
  9534. $statistics = new statistics ();
  9535. Doo::loadModel ( "receiptDetail" );
  9536. $receiptDetail = new receiptDetail ();
  9537. Doo::loadModel ( 'L_category' );
  9538. $Lcategory = new L_category ();
  9539. Doo::loadModel ( 'accountItem' );
  9540. $accountItem = new accountItem ();
  9541. Doo::loadModel ( "receiptAuthorityManage" );
  9542. $receiptAuthorityManage = new receiptAuthorityManage ();
  9543. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9544. $cidList = array ();
  9545. foreach ( $imcStaff as $key => $value ) {
  9546. array_push ( $cidList, $value ['cid'] );
  9547. }
  9548. $cidString = implode ( ',', $cidList );
  9549. $LcategoryList = $Lcategory->find ( array (
  9550. 'where' => 'cid in (' . $cidString . ')',
  9551. 'asArray' => true
  9552. ) );
  9553. if ($cid == 0) {
  9554. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9555. if ($cid == 0)
  9556. $cid = $LcategoryList [0] ['cid'];
  9557. }
  9558. $data ['LcategoryList'] = $LcategoryList;
  9559. $receiptCollectList = $receiptDetail->find ( array (
  9560. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9561. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9562. 'groupby' => 'item,Month(pastDate)',
  9563. 'asArray' => true
  9564. ) );
  9565. $accountList = $accountItem->find ( array (
  9566. 'asArray' => true
  9567. ) );
  9568. // create CollectDetail HTML
  9569. $collectHtml = array ();
  9570. foreach ( $accountList as $key => $value ) {
  9571. $html = "";
  9572. $asum = 0;
  9573. for($i = 1; $i <= 12; $i ++) {
  9574. $falg = true;
  9575. foreach ( $receiptCollectList as $v ) {
  9576. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9577. $asum += $v ['price'];
  9578. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9579. $falg = false;
  9580. break;
  9581. }
  9582. }
  9583. if ($falg)
  9584. $html .= '<td class="taR">-</td>';
  9585. }
  9586. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9587. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9588. }
  9589. $data ['collectHtml'] = $collectHtml;
  9590. // create Adjustment price html
  9591. $receiptCollectList = $receiptDetail->find ( array (
  9592. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9593. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9594. 'groupby' => 'itemCategory,Month(pastDate)',
  9595. 'asArray' => true
  9596. ) );
  9597. $adjustment = array ();
  9598. $collectArray = array (
  9599. '日常相关费用' => array (),
  9600. '差旅相关费用' => array (),
  9601. '培训班费用' => array (),
  9602. '内部培训费用'=>array(),
  9603. '其他' => array ()
  9604. );
  9605. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9606. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9607. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9608. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9609. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9610. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9611. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  9612. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  9613. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9614. array_push ( $collectArray ['其他'], $collectHtml );
  9615. $data ['collectArray'] = $collectArray;
  9616. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9617. array_push ( $adjustment, $collectHtml );
  9618. $data ['adjustment'] = $adjustment;
  9619. // total price html
  9620. $collectHtml = "";
  9621. $total = 0;
  9622. for($i = 1; $i <= 12; $i ++) {
  9623. $sumPrice = 0;
  9624. foreach ( $receiptCollectList as $key => $value ) {
  9625. if ($value ['month'] == $i) {
  9626. $sumPrice += $value ['price'];
  9627. }
  9628. }
  9629. if ($sumPrice == 0)
  9630. $collectHtml .= '<td class="taR">-</td>';
  9631. else
  9632. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9633. $total += $sumPrice;
  9634. }
  9635. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9636. // statistics html
  9637. $stList = $statistics->statisticsByCid ( $year, $cid );
  9638. if (empty ( $stList ))
  9639. $stList = array (
  9640. 'rePrice' => 0,
  9641. 'agPrice' => 0
  9642. );
  9643. $data ['stList'] = array (
  9644. 'rePrice' => $stList ['rePrice'],
  9645. 'agPrice' => $stList ['agPrice'],
  9646. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9647. );
  9648. $data ['totalYear'] = $total;
  9649. $data ['year'] = $year;
  9650. $data ['cid'] = $cid;
  9651. $data ['memu'] = "receipt";
  9652. $data ['staff'] = $this->staff;
  9653. $data ['receiptMemu'] = 'companyCategoryCollect';
  9654. $data ['verifyId'] = $this->verifyId;
  9655. $data ['executeId'] = $this->executeId;
  9656. // year staff status 2,4
  9657. /* if ($year < date ( "Y" )) {
  9658. Doo::loadModel ( 'receipt' );
  9659. $receipt = new receipt ();
  9660. $receiptList = $receipt->find ( array (
  9661. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  9662. 'asArray' => true
  9663. ) );
  9664. if (empty ( $receiptList )) {
  9665. ob_start ();
  9666. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  9667. $this->cacheFile ( $path );
  9668. die ();
  9669. }
  9670. } */
  9671. $dateHtml = "";
  9672. $now = date ( "Y" );
  9673. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9674. if ($YEARD <= $now) {
  9675. $dateHtml .= '<option ';
  9676. if ($year == $YEARD) {
  9677. $dateHtml .= 'selected ';
  9678. }
  9679. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9680. }
  9681. }
  9682. $data ['dateHtml'] = $dateHtml;
  9683. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  9684. }
  9685. function staffCollect() {
  9686. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9687. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ONJOB';//
  9688. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  9689. // $this->showCache($path);
  9690. Doo::loadModel ( 'statistics' );
  9691. $statistics = new statistics ();
  9692. Doo::loadModel ( "receiptDetail" );
  9693. $receiptDetail = new receiptDetail ();
  9694. Doo::loadModel ( 'L_category' );
  9695. $Lcategory = new L_category ();
  9696. Doo::loadModel ( 'accountItem' );
  9697. $accountItem = new accountItem ();
  9698. Doo::loadModel ( 'staff' );
  9699. $staff = new staff ();
  9700. Doo::loadModel ( 'itemStatistics' );
  9701. $itemStatistics = new itemStatistics ();
  9702. Doo::loadModel ( "receiptAuthorityManage" );
  9703. $receiptAuthorityManage = new receiptAuthorityManage ();
  9704. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9705. $cidList = array ();
  9706. foreach ( $imcStaff as $key => $value ) {
  9707. array_push ( $cidList, $value ['cid'] );
  9708. }
  9709. $cidString = implode ( ',', $cidList );
  9710. $naturecon='';
  9711. if ($nature=='ONJOB'){
  9712. $naturecon=' and (nature!=4 )';
  9713. }elseif($nature=='LEAVEJOB'){
  9714. $naturecon=' and (nature=4 )';
  9715. }else{
  9716. die ( 'illegal request--nature' );
  9717. }
  9718. // statistics html
  9719. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9720. if (empty ( $stList ))
  9721. $stList = array (
  9722. 'rePrice' => 0,
  9723. 'agPrice' => 0
  9724. );
  9725. $data ['stList'] = array (
  9726. 'rePrice' => $stList ['rePrice'],
  9727. 'agPrice' => $stList ['agPrice'],
  9728. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9729. );
  9730. // ---
  9731. $staffList = $staff->find ( array (
  9732. 'where' => 'username !="admin" '.$naturecon,
  9733. 'asArray' => true
  9734. ) );
  9735. $LcategoryList = $Lcategory->find ( array (
  9736. 'asArray' => true
  9737. ) ); // 'staff='.$this->staff[0]['sid']." and
  9738. $itemStatisticsList = $itemStatistics->find ( array (
  9739. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9740. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  9741. 'groupby' => 'staff,Month(date)',
  9742. 'asArray' => true
  9743. ) );
  9744. $categoryList = $staff->find ( array (
  9745. 'select' => 'COUNT(*) as count,cid,category',
  9746. 'where' => 'username !="admin" and cid in (' . $cidString . ') '.$naturecon,
  9747. 'groupby' => 'cid',
  9748. 'asArray' => true
  9749. ) );
  9750. // print_r($itemStatisticsList);die;
  9751. // ceatre companyCollectHtml
  9752. foreach ( $categoryList as $vlu ) {
  9753. $count = $vlu ['count'] + 1;
  9754. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  9755. $m1 = 0;
  9756. $m2 = 0;
  9757. $m3 = 0;
  9758. $m4 = 0;
  9759. $m5 = 0;
  9760. $m6 = 0;
  9761. $m7 = 0;
  9762. $m8 = 0;
  9763. $m9 = 0;
  9764. $m10 = 0;
  9765. $m11 = 0;
  9766. $m12 = 0;
  9767. $m13 = 0;
  9768. foreach ( $staffList as $value ) {
  9769. if ($vlu ['cid'] == $value ['cid']) {
  9770. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  9771. $asum = 0;
  9772. for($i = 1; $i <= 12; $i ++) {
  9773. $falg = true;
  9774. foreach ( $itemStatisticsList as $v ) {
  9775. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  9776. if ($v ['month'] == 1)
  9777. $m1 += $v ['price'];
  9778. if ($v ['month'] == 2)
  9779. $m2 += $v ['price'];
  9780. if ($v ['month'] == 3)
  9781. $m3 += $v ['price'];
  9782. if ($v ['month'] == 4)
  9783. $m4 += $v ['price'];
  9784. if ($v ['month'] == 5)
  9785. $m5 += $v ['price'];
  9786. if ($v ['month'] == 6)
  9787. $m6 += $v ['price'];
  9788. if ($v ['month'] == 7)
  9789. $m7 += $v ['price'];
  9790. if ($v ['month'] == 8)
  9791. $m8 += $v ['price'];
  9792. if ($v ['month'] == 9)
  9793. $m9 += $v ['price'];
  9794. if ($v ['month'] == 10)
  9795. $m10 += $v ['price'];
  9796. if ($v ['month'] == 11)
  9797. $m11 += $v ['price'];
  9798. if ($v ['month'] == 12)
  9799. $m12 += $v ['price'];
  9800. $asum += $v ['price'];
  9801. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9802. $falg = false;
  9803. break;
  9804. }
  9805. }
  9806. if ($falg)
  9807. $html .= '<td class="taR">-</td>';
  9808. }
  9809. $m13 += $asum;
  9810. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9811. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  9812. 'html' => $html,
  9813. 'sid' => $value ['sid']
  9814. );
  9815. $html = "";
  9816. }
  9817. }
  9818. $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>
  9819. <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>
  9820. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  9821. $collectHtml [$vlu ['cid']] = array (
  9822. 'html' => $hl,
  9823. 'sid' => ''
  9824. );
  9825. }
  9826. $data ['companyHtml'] = $collectHtml;
  9827. // total price html
  9828. $collectHtml = "";
  9829. $total = 0;
  9830. for($i = 1; $i <= 12; $i ++) {
  9831. $sumPrice = 0;
  9832. foreach ( $itemStatisticsList as $key => $value ) {
  9833. if ($value ['month'] == $i) {
  9834. $sumPrice += $value ['price'];
  9835. }
  9836. }
  9837. if ($sumPrice == 0)
  9838. $collectHtml .= '<td class="taR">-</td>';
  9839. else
  9840. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9841. $total += $sumPrice;
  9842. }
  9843. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9844. $data ['companyTotalHtml'] = $collectHtml;
  9845. $data ['total'] = $total;
  9846. $data ['nature'] =$nature;
  9847. $data ['year'] = $year;
  9848. $data ['memu'] = "receipt";
  9849. $data ['staff'] = $this->staff;
  9850. $data ['receiptMemu'] = 'companyCategoryCollect';
  9851. $data ['verifyId'] = $this->verifyId;
  9852. $data ['executeId'] = $this->executeId;
  9853. if ($year <= date ( "Y" )) {
  9854. Doo::loadModel ( 'receipt' );
  9855. $receipt = new receipt ();
  9856. $receiptList = $receipt->find ( array (
  9857. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  9858. 'asArray' => true
  9859. ) );
  9860. if (empty ( $receiptList )) { // generated files
  9861. ob_start ();
  9862. $this->render ( "/admin/saeaStaffCollectB", $data );
  9863. $this->cacheFile ( $path );
  9864. die ();
  9865. }
  9866. }
  9867. $this->render ( "/admin/saeaStaffCollectB", $data );
  9868. }
  9869. function staffCollectBak() {
  9870. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9871. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  9872. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  9873. $this->showCache ( $path );
  9874. Doo::loadModel ( 'statistics' );
  9875. $statistics = new statistics ();
  9876. Doo::loadModel ( "receiptDetail" );
  9877. $receiptDetail = new receiptDetail ();
  9878. Doo::loadModel ( 'L_category' );
  9879. $Lcategory = new L_category ();
  9880. Doo::loadModel ( 'accountItem' );
  9881. $accountItem = new accountItem ();
  9882. Doo::loadModel ( 'staff' );
  9883. $staff = new staff ();
  9884. Doo::loadModel ( 'itemStatistics' );
  9885. $itemStatistics = new itemStatistics ();
  9886. $itemStatisticsList = $itemStatistics->find ( array (
  9887. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9888. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9889. 'groupby' => 'staff,itemCategory,Month(date)',
  9890. 'asArray' => true
  9891. ) );
  9892. $itemCategoryList = $itemStatistics->find ( array (
  9893. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9894. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9895. 'groupby' => 'cid,itemCategory,Month(date)',
  9896. 'asArray' => true
  9897. ) );
  9898. $LcategoryList = $Lcategory->find ( array (
  9899. 'asArray' => true
  9900. ) );
  9901. $staffList = $staff->find ( array (
  9902. 'asArray' => true
  9903. ) );
  9904. $htmlArray = array ();
  9905. foreach ( $LcategoryList as $value ) {
  9906. $htmlArray [$value ['title']] = array ();
  9907. foreach ( $staffList as $v ) {
  9908. if ($value ['cid'] == $v ['cid']) {
  9909. $html = "";
  9910. $falg = true;
  9911. $staffSumPrice = 0;
  9912. foreach ( $itemStatisticsList as $a ) {
  9913. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  9914. if (empty ( $a ['price'] )) {
  9915. $html .= '<td class="taR">-</td>';
  9916. $falg = false;
  9917. break;
  9918. } else {
  9919. $staffSumPrice += $a ['price'];
  9920. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9921. $falg = false;
  9922. break;
  9923. }
  9924. }
  9925. }
  9926. if ($falg) {
  9927. $html .= '<td class="taR">-</td>';
  9928. $falg = true;
  9929. }
  9930. $falg = true;
  9931. foreach ( $itemStatisticsList as $a ) {
  9932. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  9933. if (empty ( $a ['price'] )) {
  9934. $html .= '<td class="taR">-</td>';
  9935. $falg = false;
  9936. break;
  9937. } else {
  9938. $staffSumPrice += $a ['price'];
  9939. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9940. $falg = false;
  9941. break;
  9942. }
  9943. }
  9944. }
  9945. if ($falg) {
  9946. $html .= '<td class="taR">-</td>';
  9947. $falg = true;
  9948. }
  9949. $falg = true;
  9950. foreach ( $itemStatisticsList as $a ) {
  9951. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  9952. if (empty ( $a ['price'] )) {
  9953. $html .= '<td class="taR">-</td>';
  9954. $falg = false;
  9955. break;
  9956. } else {
  9957. $staffSumPrice += $a ['price'];
  9958. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9959. $falg = false;
  9960. break;
  9961. }
  9962. }
  9963. }
  9964. if ($falg) {
  9965. $html .= '<td class="taR">-</td>';
  9966. $falg = true;
  9967. }
  9968. $falg = true;
  9969. foreach ( $itemStatisticsList as $a ) {
  9970. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  9971. if (! empty ( $a ['price'] )) {
  9972. $staffSumPrice += $a ['price'];
  9973. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9974. $falg = false;
  9975. break;
  9976. } else {
  9977. $html .= '<td class="taR">-</td>';
  9978. $falg = false;
  9979. break;
  9980. }
  9981. }
  9982. }
  9983. if ($falg) {
  9984. $html .= '<td class="taR">-</td>';
  9985. $falg = true;
  9986. }
  9987. $falg = true;
  9988. foreach ( $itemStatisticsList as $a ) {
  9989. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  9990. if (! empty ( $a ['price'] )) {
  9991. $staffSumPrice += $a ['price'];
  9992. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9993. $falg = false;
  9994. break;
  9995. } else {
  9996. $html .= '<td class="taR">-</td>';
  9997. $falg = false;
  9998. break;
  9999. }
  10000. }
  10001. }
  10002. if ($falg) {
  10003. $html .= '<td class="taR">-</td>';
  10004. $falg = true;
  10005. }
  10006. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  10007. $htmlArray [$value ['title']] [$v ['username']] = $html;
  10008. }
  10009. }
  10010. /* -- --- */
  10011. // 合计费用
  10012. $cateHtml = "";
  10013. $catePrice = 0;
  10014. $cateFalg = true;
  10015. foreach ( $itemCategoryList as $l ) {
  10016. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  10017. if (empty ( $l ['price'] )) {
  10018. $cateHtml .= '<td class="colGreen taR">-</td>';
  10019. $cateFalg = false;
  10020. break;
  10021. } else {
  10022. $catePrice += $l ['price'];
  10023. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10024. $cateFalg = false;
  10025. break;
  10026. }
  10027. }
  10028. }
  10029. if ($cateFalg) {
  10030. $cateHtml .= '<td class="colGreen taR">-</td>';
  10031. $cateFalg = true;
  10032. }
  10033. $cateFalg = true;
  10034. foreach ( $itemCategoryList as $l ) {
  10035. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  10036. if (empty ( $l ['price'] )) {
  10037. $cateHtml .= '<td class="colGreen taR">-</td>';
  10038. $cateFalg = false;
  10039. break;
  10040. } else {
  10041. $catePrice += $l ['price'];
  10042. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10043. $cateFalg = false;
  10044. break;
  10045. }
  10046. }
  10047. }
  10048. if ($cateFalg) {
  10049. $cateHtml .= '<td class="colGreen taR">-</td>';
  10050. $cateFalg = true;
  10051. }
  10052. $cateFalg = true;
  10053. foreach ( $itemCategoryList as $l ) {
  10054. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  10055. if (empty ( $l ['price'] )) {
  10056. $cateHtml .= '<td class="colGreen taR">-</td>';
  10057. $cateFalg = false;
  10058. break;
  10059. } else {
  10060. $catePrice += $l ['price'];
  10061. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10062. $cateFalg = false;
  10063. break;
  10064. }
  10065. }
  10066. }
  10067. if ($cateFalg) {
  10068. $cateHtml .= '<td class="colGreen taR">-</td>';
  10069. $cateFalg = true;
  10070. }
  10071. $cateFalg = true;
  10072. foreach ( $itemCategoryList as $l ) {
  10073. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  10074. if (empty ( $l ['price'] )) {
  10075. $cateHtml .= '<td class="colGreen taR">-</td>';
  10076. $cateFalg = false;
  10077. break;
  10078. } else {
  10079. $catePrice += $l ['price'];
  10080. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10081. $cateFalg = false;
  10082. break;
  10083. }
  10084. }
  10085. }
  10086. if ($cateFalg) {
  10087. $cateHtml .= '<td class="colGreen taR">-</td>';
  10088. $cateFalg = true;
  10089. }
  10090. $cateFalg = true;
  10091. foreach ( $itemCategoryList as $l ) {
  10092. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  10093. if (empty ( $l ['price'] )) {
  10094. $cateHtml .= '<td class="colGreen taR">-</td>';
  10095. $cateFalg = false;
  10096. break;
  10097. } else {
  10098. $catePrice += $l ['price'];
  10099. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10100. $cateFalg = false;
  10101. break;
  10102. }
  10103. }
  10104. }
  10105. if ($cateFalg) {
  10106. $cateHtml .= '<td class="colGreen taR">-</td>';
  10107. $cateFalg = true;
  10108. }
  10109. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  10110. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  10111. /* -- --- */
  10112. }
  10113. // print_r($htmlArray);die;
  10114. $data ['htmlArray'] = $htmlArray;
  10115. // statistics html
  10116. $stList = $statistics->getOne ( array (
  10117. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  10118. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10119. 'groupby' => 'Month(date)',
  10120. 'asArray' => true
  10121. ) );
  10122. if (empty ( $stList ))
  10123. $stList = array (
  10124. 'rePrice' => 0,
  10125. 'agPrice' => 0
  10126. );
  10127. $data ['stList'] = array (
  10128. 'rePrice' => $stList ['rePrice'],
  10129. 'agPrice' => $stList ['agPrice'],
  10130. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10131. );
  10132. $monthHtml = "";
  10133. for($i = 1; $i <= 12; $i ++) {
  10134. if ($i == $month)
  10135. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  10136. else
  10137. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  10138. }
  10139. $data ['monthHtml'] = $monthHtml;
  10140. $data ['year'] = $year;
  10141. $data ['month'] = $month;
  10142. $data ['memu'] = "receipt";
  10143. $data ['staff'] = $this->staff;
  10144. $data ['receiptMemu'] = 'companyCategoryCollect';
  10145. $data ['verifyId'] = $this->verifyId;
  10146. $data ['executeId'] = $this->executeId;
  10147. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  10148. Doo::loadModel ( 'receipt' );
  10149. $receipt = new receipt ();
  10150. $receiptList = $receipt->find ( array (
  10151. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  10152. 'asArray' => true
  10153. ) );
  10154. if (empty ( $receiptList )) { // generated files
  10155. ob_start ();
  10156. $this->render ( "/admin/saeaStaffCollect", $data );
  10157. $this->cacheFile ( $path );
  10158. die ();
  10159. }
  10160. }
  10161. $this->render ( "/admin/saeaStaffCollect", $data );
  10162. }
  10163. /**
  10164. * 日常收支
  10165. */
  10166. function payments() {
  10167. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  10168. Doo::loadModel ( "execute" );
  10169. $execute = new execute ();
  10170. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  10171. die ( 'illegal request' );
  10172. }
  10173. Doo::loadModel ( "accountBook" );
  10174. $accountBook = new accountBook ();
  10175. Doo::loadModel ( "accountBookStatistics" );
  10176. $accountBookStatistics = new accountBookStatistics ();
  10177. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  10178. $list = $accountBook->getAccountBookByLimit ( 10 );
  10179. $data ['date'] = date ( "Y-m-d" );
  10180. $data ['statisticsList'] = $statisticsList;
  10181. $data ['list'] = $list;
  10182. $data ['memu'] = "receipt";
  10183. $data ['staff'] = $this->staff;
  10184. $data ['receiptMemu'] = 'payments';
  10185. $data ['verifyId'] = $this->verifyId;
  10186. $data ['executeId'] = $this->executeId;
  10187. $this->render ( "/expenses/payments", $data );
  10188. }
  10189. function paymentsIncomeDo() {
  10190. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10191. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10192. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10193. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10194. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10195. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10196. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10197. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10198. Doo::loadClass ( 'XDeode' );
  10199. $XDeode = new XDeode ( 5 );
  10200. Doo::loadModel ( "accountBook" );
  10201. Doo::loadModel ( "accountBookStatistics" );
  10202. Doo::loadModel ( 'wasteBook' );
  10203. // 记录流水时银行的转换
  10204. $accountBank = '';
  10205. if ($receivedBank == '纵横广发') {
  10206. $accountBank = 'CGBDeposit';
  10207. } elseif ($receivedBank == '纵横工行') {
  10208. $accountBank = 'ICBCDeposit';
  10209. } elseif ($receivedBank == '华润银行') {
  10210. $accountBank = 'HUADeposit';
  10211. } elseif ($receivedBank == '个人广发') {
  10212. $accountBank = 'PersonalDeposit';
  10213. }
  10214. if (empty ( $accountBank ))
  10215. die ( 'illegal request' );
  10216. // 收入为理财时特殊处理
  10217. if ($accountType == 7 || $accountType == 9) {
  10218. if ($receivedBank == '个人广发') {
  10219. die ( '个人广发 illegal request' );
  10220. }
  10221. // 添加一条收入
  10222. $accountBook = new accountBook ();
  10223. $accountBook->accountType = 10;
  10224. $accountBook->accountMsg = $accountMsg;
  10225. $accountBook->receivedPrice = $receivedPrice;
  10226. $accountBook->receivedMsg = $receivedMsg;
  10227. $accountBook->receivedBank = $receivedBank;
  10228. $accountBook->receivedDate = $receivedDate;
  10229. $accountBook->remarks = $remarks;
  10230. $accountBook->expensesType = 1;
  10231. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10232. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10233. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10234. $inComeId = $accountBook->insert ();
  10235. // 收支汇总-添加一条收入日常汇总
  10236. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10237. $accountBookStatistics = new accountBookStatistics ();
  10238. $item = array (
  10239. 'date' => date ( "Y-m-d" ),
  10240. 'accountType' => $abDetail ['accountType'],
  10241. 'accountMsg' => $abDetail ['accountMsg'],
  10242. 'aid' => $abDetail ['aid'],
  10243. 'inComePrice' => $abDetail ['receivedPrice'],
  10244. 'expensesType' => $abDetail ['expensesType']
  10245. );
  10246. $accountBookStatistics->setAccountBookStatistics ( $item );
  10247. // 添加收入流水
  10248. $wasteBook = new wasteBook ();
  10249. $itemWaste = array (
  10250. 'accountPriceShow' => $receivedPrice,
  10251. 'accountPrice' => $receivedPrice,
  10252. 'expensesType' => 1,
  10253. 'accountType' => 6, // 流水类型
  10254. 'dataID' => $inComeId,
  10255. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10256. 'accountBank' => $accountBank,
  10257. 'category' => $this->staff [0] ['category'],
  10258. 'cid' => $this->staff [0] ['cid'],
  10259. 'name' => $this->staff [0] ['username'],
  10260. 'sid' => $this->staff [0] ['sid'],
  10261. 'inputDate' => date ( "Y-m-d H:i:s" )
  10262. );
  10263. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10264. // 添加一条理财支出
  10265. $accountBank = 'CGBDeposit';
  10266. $expenditureBank = '纵横广发';
  10267. $dailyExpenditureType = 4;
  10268. if ($accountType == 9) {
  10269. $accountBank = 'ICBCDeposit';
  10270. $expenditureBank = '纵横工行';
  10271. $dailyExpenditureType = 6;
  10272. }
  10273. $accountBook = new accountBook ();
  10274. $accountBook->expensesType = 2;
  10275. $accountBook->expenditureType = $dailyExpenditureType;
  10276. $accountBook->expenditureMsg = $accountMsg;
  10277. $accountBook->expenditurePrice = $receivedPrice;
  10278. $accountBook->expenditureBank = $expenditureBank;
  10279. $accountBook->expenditureDate = $receivedDate;
  10280. $accountBook->remarks = $remarks;
  10281. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10282. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10283. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10284. $id = $accountBook->insert ();
  10285. // 收支汇总-添加一条理财支出汇总
  10286. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10287. $accountBookStatistics = new accountBookStatistics ();
  10288. $item = array (
  10289. 'date' => date ( "Y-m-d" ),
  10290. 'accountType' => $abDetail ['accountType'],
  10291. 'accountMsg' => $abDetail ['accountMsg'],
  10292. 'aid' => $abDetail ['aid'],
  10293. 'financingPrice' => - $receivedPrice,
  10294. 'expensesType' => 3
  10295. );
  10296. $accountBookStatistics->setAccountBookStatistics ( $item );
  10297. // 添加一条支出理财流水
  10298. $accountTypeWaste = 5;
  10299. if ($accountMsg == '公司固定') {
  10300. $accountTypeWaste = 9;
  10301. } elseif ($accountMsg == '公司活期') {
  10302. $accountTypeWaste = 10;
  10303. } elseif ($accountMsg == '个人(GR)') {
  10304. $accountBank = 'PersonalDeposit';
  10305. }
  10306. $itemWaste = array (
  10307. 'expensesType' => 2,
  10308. 'accountType' => $accountTypeWaste,
  10309. 'accountPriceShow' => $receivedPrice,
  10310. 'accountPrice' => - $receivedPrice,
  10311. 'dataID' => $id,
  10312. 'dailyExpenditureType' => $dailyExpenditureType,
  10313. 'accountBank' => $accountBank,
  10314. 'category' => $this->staff [0] ['category'],
  10315. 'cid' => $this->staff [0] ['cid'],
  10316. 'name' => $this->staff [0] ['username'],
  10317. 'sid' => $this->staff [0] ['sid'],
  10318. 'inputDate' => date ( "Y-m-d H:i:s" )
  10319. );
  10320. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10321. } elseif ($accountType == 1) {
  10322. if ($receivedBank == '个人广发')
  10323. die ( 'illegal request' );
  10324. // 添加一条收入
  10325. $accountBook = new accountBook ();
  10326. $accountBook->accountType = $accountType;
  10327. $accountBook->accountMsg = $accountMsg;
  10328. $accountBook->receivedPrice = $receivedPrice;
  10329. $accountBook->receivedMsg = $receivedMsg;
  10330. $accountBook->receivedBank = $receivedBank;
  10331. $accountBook->receivedDate = $receivedDate;
  10332. $accountBook->remarks = $remarks;
  10333. $accountBook->expensesType = 1;
  10334. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10335. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10336. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10337. $id = $accountBook->insert ();
  10338. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10339. // 收支汇总-添加一条收入日常汇总
  10340. $accountBookStatistics = new accountBookStatistics ();
  10341. $item = array (
  10342. 'date' => date ( "Y-m-d" ),
  10343. 'accountType' => $abDetail ['accountType'],
  10344. 'accountMsg' => $abDetail ['accountMsg'],
  10345. 'aid' => $abDetail ['aid'],
  10346. 'expensesType' => $abDetail ['expensesType']
  10347. );
  10348. if ($abDetail ['accountType'] == 8) {
  10349. $item += array (
  10350. 'inComePrice' => $abDetail ['receivedPrice']
  10351. );
  10352. } else {
  10353. $item += array (
  10354. 'inComePrice' => $abDetail ['receivedPrice']
  10355. );
  10356. }
  10357. $accountBookStatistics->setAccountBookStatistics ( $item );
  10358. // 流水存储方向
  10359. $itemWaste = array (
  10360. 'accountType' => 6
  10361. ); // 流水类型
  10362. // if($accountMsg=='银行存款'||$accountMsg=='固定理财收益'){
  10363. // }else
  10364. if ($accountMsg == '活期理财收益') {
  10365. $itemWaste = array (
  10366. 'accountType' => 10
  10367. ); // 流水类型
  10368. }
  10369. // 添加收入流水
  10370. $wasteBook = new wasteBook ();
  10371. $itemWaste += array (
  10372. 'accountPrice' => $receivedPrice,
  10373. 'accountPriceShow' => $receivedPrice,
  10374. 'expensesType' => 1,
  10375. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10376. 'dataID' => $id,
  10377. 'accountBank' => $accountBank,
  10378. 'category' => $this->staff [0] ['category'],
  10379. 'cid' => $this->staff [0] ['cid'],
  10380. 'name' => $this->staff [0] ['username'],
  10381. 'sid' => $this->staff [0] ['sid'],
  10382. 'inputDate' => date ( "Y-m-d H:i:s" )
  10383. );
  10384. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10385. } else { // 普通日常收入处理
  10386. // 添加一条收入
  10387. $accountBook = new accountBook ();
  10388. $accountBook->accountType = $accountType;
  10389. $accountBook->accountMsg = $accountMsg;
  10390. $accountBook->receivedPrice = $receivedPrice;
  10391. $accountBook->receivedMsg = $receivedMsg;
  10392. $accountBook->receivedBank = $receivedBank;
  10393. $accountBook->receivedDate = $receivedDate;
  10394. $accountBook->remarks = $remarks;
  10395. $accountBook->expensesType = 1;
  10396. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10397. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10398. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10399. $id = $accountBook->insert ();
  10400. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10401. // 收支汇总-添加一条收入日常汇总
  10402. $accountBookStatistics = new accountBookStatistics ();
  10403. $item = array (
  10404. 'date' => date ( "Y-m-d" ),
  10405. 'accountType' => $abDetail ['accountType'],
  10406. 'accountMsg' => $abDetail ['accountMsg'],
  10407. 'aid' => $abDetail ['aid'],
  10408. 'expensesType' => $abDetail ['expensesType']
  10409. );
  10410. if ($abDetail ['accountType'] == 8) {
  10411. $item += array (
  10412. 'inComePrice' => $abDetail ['receivedPrice']
  10413. );
  10414. } else {
  10415. $item += array (
  10416. 'inComePrice' => $abDetail ['receivedPrice']
  10417. );
  10418. }
  10419. $accountBookStatistics->setAccountBookStatistics ( $item );
  10420. // 添加收入流水
  10421. $itemWaste = array (
  10422. 'accountPrice' => $receivedPrice
  10423. );
  10424. if ($receivedBank == '个人广发') {
  10425. $itemWaste = array (
  10426. 'accountPrice' => - $receivedPrice
  10427. );
  10428. }
  10429. $wasteBook = new wasteBook ();
  10430. $itemWaste += array (
  10431. 'accountPriceShow' => $receivedPrice,
  10432. 'expensesType' => 1,
  10433. 'accountType' => 6, // 流水类型
  10434. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10435. 'dataID' => $id,
  10436. 'accountBank' => $accountBank,
  10437. 'category' => $this->staff [0] ['category'],
  10438. 'cid' => $this->staff [0] ['cid'],
  10439. 'name' => $this->staff [0] ['username'],
  10440. 'sid' => $this->staff [0] ['sid'],
  10441. 'inputDate' => date ( "Y-m-d H:i:s" )
  10442. );
  10443. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10444. }
  10445. }
  10446. return '/payments';
  10447. }
  10448. /**
  10449. * 添加收入
  10450. * @return string
  10451. */
  10452. function paymentsIncomeDo_() {
  10453. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10454. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10455. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10456. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10457. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10458. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10459. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10460. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10461. Doo::loadClass ( 'XDeode' );
  10462. $XDeode = new XDeode ( 5 );
  10463. Doo::loadModel ( "accountBook" );
  10464. $accountBook = new accountBook ();
  10465. $accountBank = '';
  10466. $accountTypeWaste = 6;
  10467. if ($receivedBank == '纵横广发') {
  10468. $accountBank = 'CGBDeposit';
  10469. } elseif ($receivedBank == '纵横工行') {
  10470. $accountBank = 'ICBCDeposit';
  10471. } elseif ($receivedBank == '华润银行') {
  10472. $accountBank = 'HUADeposit';
  10473. } elseif ($receivedBank == '个人广发') {
  10474. $accountBank = 'PersonalDeposit';
  10475. }
  10476. if (empty ( $accountBank ))
  10477. die ( 'illegal request' );
  10478. $dailyIncomeType = '';
  10479. $itemWaste = array (
  10480. 'accountPrice' => $receivedPrice,
  10481. 'expensesType' => 1
  10482. );
  10483. if ($receivedBank == '个人广发') {
  10484. $itemWaste = array (
  10485. 'accountPrice' => - $receivedPrice,
  10486. 'expensesType' => 1
  10487. );
  10488. }
  10489. if ($accountType == 4) {
  10490. $dailyIncomeType = 4;
  10491. } elseif ($accountType == 1) {
  10492. $dailyIncomeType = 1;
  10493. } elseif ($accountType == 2) {
  10494. $dailyIncomeType = 2;
  10495. } elseif ($accountType == 3) {
  10496. $dailyIncomeType = 3;
  10497. } elseif ($accountType == 5) {
  10498. $dailyIncomeType = 5;
  10499. } elseif ($accountType == 6) {
  10500. $dailyIncomeType = 6;
  10501. } elseif ($accountType == 7 || $accountType == 9) {
  10502. $dailyIncomeType = 7;
  10503. if ($accountMsg == '公司固定') {
  10504. $accountTypeWaste = 9;
  10505. } elseif ($accountMsg == '公司活期') {
  10506. $accountTypeWaste = 10;
  10507. } elseif ($accountMsg == '个人(GR)') {
  10508. $accountBank = 'PersonalDeposit';
  10509. }
  10510. $itemWaste = array (
  10511. 'accountPrice' => - $receivedPrice,
  10512. 'expensesType' => 2
  10513. );
  10514. } elseif ($accountType == 8) {
  10515. $dailyIncomeType = 8;
  10516. }
  10517. if (empty ( $dailyIncomeType ))
  10518. die ( 'illegal request' );
  10519. $accountBook->accountType = $accountType;
  10520. $accountBook->accountMsg = $accountMsg;
  10521. $accountBook->receivedPrice = $receivedPrice;
  10522. $accountBook->receivedMsg = $receivedMsg;
  10523. $accountBook->receivedBank = $receivedBank;
  10524. $accountBook->receivedDate = $receivedDate;
  10525. $accountBook->remarks = $remarks;
  10526. $accountBook->expensesType = 1;
  10527. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10528. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10529. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10530. $id = $accountBook->insert ();
  10531. //
  10532. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10533. // 收支汇总
  10534. Doo::loadModel ( "accountBookStatistics" );
  10535. $accountBookStatistics = new accountBookStatistics ();
  10536. $item = array (
  10537. 'date' => date ( "Y-m-d" ),
  10538. 'accountType' => $abDetail ['accountType'],
  10539. 'accountMsg' => $abDetail ['accountMsg'],
  10540. 'aid' => $abDetail ['aid']
  10541. );
  10542. if ($abDetail ['expensesType'] == 1) {
  10543. if ($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) {
  10544. $item += array (
  10545. 'financingPrice' => - $receivedPrice,
  10546. 'expensesType' => 3
  10547. );
  10548. } else if ($abDetail ['accountType'] == 8) {
  10549. $item += array (
  10550. 'inComePrice' => - $abDetail ['receivedPrice'],
  10551. 'expensesType' => $abDetail ['expensesType']
  10552. );
  10553. } else {
  10554. $item += array (
  10555. 'inComePrice' => $abDetail ['receivedPrice'],
  10556. 'expensesType' => $abDetail ['expensesType']
  10557. );
  10558. }
  10559. }
  10560. $accountBookStatistics->setAccountBookStatistics ( $item );
  10561. // 为理财时需添加一条日常支出
  10562. if ($accountType == 7 || $accountType == 9) {
  10563. }
  10564. // 公司流水记录
  10565. Doo::loadModel ( 'wasteBook' );
  10566. $wasteBook = new wasteBook ();
  10567. // 银行
  10568. // if (empty($abDetail)){
  10569. $itemWaste += array (
  10570. 'accountPriceShow' => $receivedPrice,
  10571. 'dataID' => $id,
  10572. 'accountType' => $accountTypeWaste,
  10573. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10574. 'accountBank' => $accountBank,
  10575. 'category' => $this->staff [0] ['category'],
  10576. 'cid' => $this->staff [0] ['cid'],
  10577. 'name' => $this->staff [0] ['username'],
  10578. 'sid' => $this->staff [0] ['sid'],
  10579. 'inputDate' => date ( "Y-m-d H:i:s" )
  10580. );
  10581. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10582. // }
  10583. // 类型为理财7或者9 要添加一笔理财支出
  10584. if ($accountType == 7 || $accountType == 9) {
  10585. $accountBank = 'CGBDeposit';
  10586. $expenditureBank = '纵横广发';
  10587. $dailyExpenditureType = 4;
  10588. if ($accountType == 9) {
  10589. $accountBank = 'ICBCDeposit';
  10590. $expenditureBank = '纵横工行';
  10591. $dailyExpenditureType = 6;
  10592. }
  10593. // 添加一条支出
  10594. $accountBook = new accountBook ();
  10595. $accountBook->expenditureType = $dailyExpenditureType;
  10596. $accountBook->expenditureMsg = $accountMsg;
  10597. $accountBook->expenditurePrice = $receivedPrice;
  10598. $accountBook->expenditureBank = $expenditureBank;
  10599. $accountBook->expenditureDate = $receivedDate;
  10600. $accountBook->remarks = $remarks;
  10601. $accountBook->expensesType = 2;
  10602. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10603. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10604. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10605. $id = $accountBook->insert ();
  10606. // 添加一条收入流水
  10607. $itemWaste = array (
  10608. 'accountPriceShow' => $receivedPrice,
  10609. 'accountPrice' => $receivedPrice,
  10610. 'dataID' => $id,
  10611. 'expensesType' => 2,
  10612. 'accountType' => $accountTypeWaste,
  10613. 'dailyExpenditureType' => $dailyExpenditureType,
  10614. 'accountBank' => $accountBank,
  10615. 'category' => $this->staff [0] ['category'],
  10616. 'cid' => $this->staff [0] ['cid'],
  10617. 'name' => $this->staff [0] ['username'],
  10618. 'sid' => $this->staff [0] ['sid'],
  10619. 'inputDate' => date ( "Y-m-d H:i:s" )
  10620. );
  10621. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10622. }
  10623. }
  10624. return '/payments';
  10625. }
  10626. function paymentsExpenditureDo() {
  10627. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10628. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10629. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10630. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10631. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10632. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10633. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10634. // 理财支出特殊处理
  10635. Doo::loadModel ( "accountBook" );
  10636. Doo::loadModel ( "accountBookStatistics" );
  10637. Doo::loadModel ( 'wasteBook' );
  10638. $accountBank = '';
  10639. if ($expenditureBank == '纵横广发') {
  10640. $accountBank = 'CGBDeposit';
  10641. } elseif ($expenditureBank == '纵横工行') {
  10642. $accountBank = 'ICBCDeposit';
  10643. } elseif ($expenditureBank == '华润银行') {
  10644. $accountBank = 'HUADeposit';
  10645. } elseif ($expenditureBank == '个人广发') {
  10646. $accountBank = 'PersonalDeposit';
  10647. }
  10648. if (empty ( $accountBank ))
  10649. die ( 'illegal request' );
  10650. if ($expenditureType == 4 || $expenditureType == 6) {
  10651. if ($expenditureBank == '个人广发') {
  10652. die ( '个人广发 illegal request' );
  10653. }
  10654. // 添加一笔日常支出
  10655. $accountBook = new accountBook ();
  10656. $accountBook->expensesType = 2;
  10657. $accountBook->expenditureType = 7;
  10658. $accountBook->expenditureMsg = $expenditureMsg;
  10659. $accountBook->expenditurePrice = $expenditurePrice;
  10660. $accountBook->expenditureBank = $expenditureBank;
  10661. $accountBook->expenditureDate = $expenditureDate;
  10662. $accountBook->remarks = $remarks;
  10663. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10664. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10665. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10666. $expenditureId = $accountBook->insert ();
  10667. // 添加日常支出汇总
  10668. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  10669. $accountBookStatistics = new accountBookStatistics ();
  10670. $item = array (
  10671. 'date' => date ( "Y-m-d" ),
  10672. 'expenditureType' => $abDetail ['expenditureType'],
  10673. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10674. 'aid' => $abDetail ['aid'],
  10675. 'payPrice' => $abDetail ['expenditurePrice'],
  10676. 'expensesType' => $abDetail ['expensesType']
  10677. );
  10678. $accountBookStatistics->setAccountBookStatistics ( $item );
  10679. // 公司日常支出流水
  10680. $wasteBook = new wasteBook ();
  10681. $itemWaste = array (
  10682. 'accountPrice' => - $expenditurePrice
  10683. );
  10684. if ($expenditureBank == '个人广发') {
  10685. $itemWaste = array (
  10686. 'accountPrice' => $expenditurePrice
  10687. );
  10688. }
  10689. $itemWaste += array (
  10690. 'expensesType' => 2,
  10691. 'accountType' => 5,
  10692. 'dailyExpenditureType' => $expenditureType,
  10693. 'accountPriceShow' => $expenditurePrice,
  10694. 'accountPrice' => - $expenditurePrice,
  10695. 'dataID' => $expenditureId,
  10696. 'accountBank' => $accountBank,
  10697. 'category' => $this->staff [0] ['category'],
  10698. 'cid' => $this->staff [0] ['cid'],
  10699. 'name' => $this->staff [0] ['username'],
  10700. 'sid' => $this->staff [0] ['sid'],
  10701. 'inputDate' => date ( "Y-m-d H:i:s" )
  10702. );
  10703. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10704. // 添加一笔理财收入
  10705. $accountBank = 'CGBDeposit';
  10706. $dailyIncomeType = 7;
  10707. $receivedBank = '纵横广发';
  10708. if ($expenditureType == 6) {
  10709. $accountBank = 'ICBCDeposit';
  10710. $receivedBank = '纵横工行';
  10711. $dailyIncomeType = 9;
  10712. }
  10713. $accountBook = new accountBook ();
  10714. $accountBook->expensesType = 1;
  10715. $accountBook->accountType = $dailyIncomeType;
  10716. $accountBook->accountMsg = $expenditureMsg;
  10717. $accountBook->receivedPrice = $expenditurePrice;
  10718. $accountBook->receivedBank = $receivedBank;
  10719. $accountBook->receivedDate = $expenditureDate;
  10720. $accountBook->remarks = $remarks;
  10721. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10722. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10723. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10724. $id = $accountBook->insert ();
  10725. // 添加日常理财收入汇总
  10726. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  10727. $accountBookStatistics = new accountBookStatistics ();
  10728. $item = array (
  10729. 'date' => date ( "Y-m-d" ),
  10730. 'expenditureType' => $abDetail ['expenditureType'],
  10731. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10732. 'aid' => $abDetail ['aid'],
  10733. 'financingPrice' => $expenditurePrice,
  10734. 'expensesType' => 3
  10735. );
  10736. $accountBookStatistics->setAccountBookStatistics ( $item );
  10737. // 添加一笔收入流水
  10738. if ($expenditureMsg == '公司固定') {
  10739. $accountTypeWaste = 9;
  10740. } elseif ($expenditureMsg == '公司活期') {
  10741. $accountTypeWaste = 10;
  10742. } elseif ($expenditureMsg == '个人(GR)') {
  10743. $accountBank = 'PersonalDeposit';
  10744. }
  10745. $itemWaste = array (
  10746. 'expensesType' => 1,
  10747. 'accountType' => $accountTypeWaste,
  10748. 'accountPriceShow' => $expenditurePrice,
  10749. 'accountPrice' => $expenditurePrice,
  10750. 'dataID' => $id,
  10751. 'dailyIncomeType' => $dailyIncomeType,
  10752. 'accountBank' => $accountBank,
  10753. 'category' => $this->staff [0] ['category'],
  10754. 'cid' => $this->staff [0] ['cid'],
  10755. 'name' => $this->staff [0] ['username'],
  10756. 'sid' => $this->staff [0] ['sid'],
  10757. 'inputDate' => date ( "Y-m-d H:i:s" )
  10758. );
  10759. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10760. } else {
  10761. // 添加一笔日常支出
  10762. $accountBook = new accountBook ();
  10763. $accountBook->expensesType = 2;
  10764. $accountBook->expenditureType = $expenditureType;
  10765. $accountBook->expenditureMsg = $expenditureMsg;
  10766. $accountBook->expenditurePrice = $expenditurePrice;
  10767. $accountBook->expenditureBank = $expenditureBank;
  10768. $accountBook->expenditureDate = $expenditureDate;
  10769. $accountBook->remarks = $remarks;
  10770. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10771. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10772. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10773. $id = $accountBook->insert ();
  10774. // 添加日常支出汇总
  10775. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10776. $accountBookStatistics = new accountBookStatistics ();
  10777. $item = array (
  10778. 'date' => date ( "Y-m-d" ),
  10779. 'expenditureType' => $abDetail ['expenditureType'],
  10780. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10781. 'aid' => $abDetail ['aid'],
  10782. 'expensesType' => $abDetail ['expensesType']
  10783. );
  10784. if ($expenditureType == 5) {
  10785. $item += array (
  10786. 'payPrice' => - $abDetail ['expenditurePrice']
  10787. );
  10788. } else {
  10789. $item += array (
  10790. 'payPrice' => $abDetail ['expenditurePrice']
  10791. );
  10792. }
  10793. $accountBookStatistics->setAccountBookStatistics ( $item );
  10794. // 公司日常支出流水
  10795. $wasteBook = new wasteBook ();
  10796. $itemWaste = array (
  10797. 'accountPrice' => - $expenditurePrice
  10798. );
  10799. if ($expenditureBank == '个人广发') {
  10800. $itemWaste = array (
  10801. 'accountPrice' => $expenditurePrice
  10802. );
  10803. }
  10804. $itemWaste += array (
  10805. 'expensesType' => 2,
  10806. 'accountType' => 5,
  10807. 'accountPriceShow' => $expenditurePrice,
  10808. 'dataID' => $id,
  10809. 'dailyExpenditureType' => $expenditureType,
  10810. 'accountBank' => $accountBank,
  10811. 'category' => $this->staff [0] ['category'],
  10812. 'cid' => $this->staff [0] ['cid'],
  10813. 'name' => $this->staff [0] ['username'],
  10814. 'sid' => $this->staff [0] ['sid'],
  10815. 'inputDate' => date ( "Y-m-d H:i:s" )
  10816. );
  10817. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10818. }
  10819. }
  10820. return '/payments';
  10821. }
  10822. /**
  10823. * 添加支出
  10824. */
  10825. function paymentsExpenditureDo_() {
  10826. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10827. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10828. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10829. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10830. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10831. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10832. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10833. $dailyExpenditureType = '';
  10834. $accountTypeWaste = 5;
  10835. $accountBank = '';
  10836. if ($expenditureBank == '纵横广发') {
  10837. $accountBank = 'CGBDeposit';
  10838. } elseif ($expenditureBank == '纵横工行') {
  10839. $accountBank = 'ICBCDeposit';
  10840. } elseif ($expenditureBank == '华润银行') {
  10841. $accountBank = 'HUADeposit';
  10842. } elseif ($expenditureBank == '个人广发') {
  10843. $accountBank = 'PersonalDeposit';
  10844. }
  10845. if (empty ( $accountBank ))
  10846. die ( 'illegal request' );
  10847. $itemWaste = array (
  10848. 'accountPrice' => - $expenditurePrice
  10849. );
  10850. if ($expenditureBank == '个人广发') {
  10851. $itemWaste = array (
  10852. 'accountPrice' => $expenditurePrice
  10853. );
  10854. }
  10855. if ($expenditureType == 4 || $expenditureType == 6) {
  10856. $dailyExpenditureType = 4;
  10857. if ($expenditureMsg == '公司固定') {
  10858. $accountTypeWaste = 9;
  10859. } elseif ($expenditureMsg == '公司活期') {
  10860. $accountTypeWaste = 10;
  10861. } elseif ($expenditureMsg == '个人(GR)') {
  10862. $accountBank = 'PersonalDeposit';
  10863. }
  10864. $itemWaste = array (
  10865. 'accountPrice' => $expenditurePrice
  10866. );
  10867. } elseif ($expenditureType == 1) {
  10868. $dailyExpenditureType = 1;
  10869. } elseif ($expenditureType == 2) {
  10870. $dailyExpenditureType = 2;
  10871. } elseif ($expenditureType == 3) {
  10872. $dailyExpenditureType = 3;
  10873. } elseif ($expenditureType == 5) {
  10874. $dailyExpenditureType = 5;
  10875. }
  10876. if (empty ( $dailyExpenditureType ))
  10877. die ( 'illegal request' );
  10878. Doo::loadModel ( "accountBook" );
  10879. $accountBook = new accountBook ();
  10880. $accountBook->expenditureType = $expenditureType;
  10881. $accountBook->expenditureMsg = $expenditureMsg;
  10882. $accountBook->expenditurePrice = $expenditurePrice;
  10883. $accountBook->expenditureBank = $expenditureBank;
  10884. $accountBook->expenditureDate = $expenditureDate;
  10885. $accountBook->remarks = $remarks;
  10886. $accountBook->expensesType = 2;
  10887. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10888. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10889. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10890. $id = $accountBook->insert ();
  10891. //
  10892. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10893. Doo::loadModel ( "accountBookStatistics" );
  10894. $accountBookStatistics = new accountBookStatistics ();
  10895. $item = array (
  10896. 'date' => date ( "Y-m-d" ),
  10897. 'expenditureType' => $abDetail ['expenditureType'],
  10898. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10899. 'aid' => $abDetail ['aid']
  10900. );
  10901. if ($abDetail ['expensesType'] == 2) {
  10902. if ($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) {
  10903. $item += array (
  10904. 'financingPrice' => $expenditurePrice,
  10905. 'expensesType' => 3
  10906. );
  10907. } elseif ($abDetail ['expenditureType'] == 5) {
  10908. $item += array (
  10909. 'payPrice' => $abDetail ['expenditurePrice'],
  10910. 'expensesType' => $abDetail ['expensesType']
  10911. );
  10912. } else {
  10913. $item += array (
  10914. 'payPrice' => $abDetail ['expenditurePrice'],
  10915. 'expensesType' => $abDetail ['expensesType']
  10916. );
  10917. }
  10918. }
  10919. $accountBookStatistics->setAccountBookStatistics ( $item );
  10920. // 公司流水记录
  10921. Doo::loadModel ( 'wasteBook' );
  10922. $wasteBook = new wasteBook ();
  10923. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountTypeWaste, $id );
  10924. // 银行
  10925. if (empty ( $abDetail )) {
  10926. $itemWaste += array (
  10927. 'accountPriceShow' => $expenditurePrice,
  10928. 'dataID' => $id,
  10929. 'expensesType' => 2,
  10930. 'accountType' => $accountTypeWaste,
  10931. 'dailyExpenditureType' => $expenditureType,
  10932. 'accountBank' => $accountBank,
  10933. 'category' => $this->staff [0] ['category'],
  10934. 'cid' => $this->staff [0] ['cid'],
  10935. 'name' => $this->staff [0] ['username'],
  10936. 'sid' => $this->staff [0] ['sid'],
  10937. 'inputDate' => date ( "Y-m-d H:i:s" )
  10938. );
  10939. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10940. }
  10941. // 支出类型为4或者6 需要添加一笔收入和收入流水
  10942. if ($expenditureType == 4 || $expenditureType == 6) {
  10943. $accountBank = 'CGBDeposit';
  10944. $dailyIncomeType = 7;
  10945. $receivedBank = '纵横广发';
  10946. if ($expenditureType == 6) {
  10947. $accountBank = 'ICBCDeposit';
  10948. $receivedBank = '纵横工行';
  10949. $dailyIncomeType = 9;
  10950. }
  10951. // 添加一笔收入
  10952. $accountBook = new accountBook ();
  10953. $accountBook->accountType = $dailyIncomeType;
  10954. $accountBook->accountMsg = $expenditureMsg;
  10955. $accountBook->receivedPrice = $expenditurePrice;
  10956. $accountBook->receivedBank = $receivedBank;
  10957. $accountBook->receivedDate = $expenditureDate;
  10958. $accountBook->remarks = $remarks;
  10959. $accountBook->expensesType = 1;
  10960. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10961. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10962. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10963. $id = $accountBook->insert ();
  10964. // 添加一笔收入流水
  10965. $itemWaste = array (
  10966. 'accountPriceShow' => $expenditurePrice,
  10967. 'accountPrice' => - $expenditurePrice,
  10968. 'dataID' => $id,
  10969. 'expensesType' => 1,
  10970. 'accountType' => $accountTypeWaste,
  10971. 'dailyIncomeType' => $dailyIncomeType,
  10972. 'accountBank' => $accountBank,
  10973. 'category' => $this->staff [0] ['category'],
  10974. 'cid' => $this->staff [0] ['cid'],
  10975. 'name' => $this->staff [0] ['username'],
  10976. 'sid' => $this->staff [0] ['sid'],
  10977. 'inputDate' => date ( "Y-m-d H:i:s" )
  10978. );
  10979. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10980. }
  10981. }
  10982. return '/payments';
  10983. }
  10984. /**
  10985. * 所有收支
  10986. */
  10987. function paymentsAchieve() {
  10988. $page_size = 12;
  10989. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  10990. $expensesType = isset ( $this->params ['expensesType'] ) ? $this->params ['expensesType'] : 'ALL';
  10991. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  10992. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  10993. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10994. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10995. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10996. $submitType = $this->get_args ( 'submitType' ) ? $this->get_args ( 'submitType' ) : "";
  10997. Doo::loadModel ( "accountBookStatistics" );
  10998. $accountBookStatistics = new accountBookStatistics ();
  10999. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  11000. $data ['statisticsList'] = $statisticsList;
  11001. Doo::loadModel ( "accountBook" );
  11002. $accountBook = new accountBook ();
  11003. $con = '';
  11004. if ($expensesType == 'INCOME')
  11005. $con = ' and expensesType=1 ';
  11006. elseif ($expensesType == 'PAY')
  11007. $con = ' and expensesType=2 ';
  11008. $dateArr = explode ( ':', $date );
  11009. $D1 = $dateString = '';
  11010. $D2 = '';
  11011. if (! empty ( $date )) {
  11012. $D1 = $dateArr [0];
  11013. if (isset ( $dateArr [1] ))
  11014. $D2 = $dateArr [1];
  11015. else
  11016. $D2 = '';
  11017. $dateString = $D1 . " : " . $D2;
  11018. }
  11019. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11020. $con .= ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11021. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11022. $con .= ' and inputDate like "%' . $D1 . '%" ';
  11023. if (! empty ( $price ))
  11024. $con .= ' and (receivedPrice=' . $price . ' or expenditurePrice=' . $price . ')';
  11025. if ($submitType == 1) {
  11026. if ($accountType != '') {
  11027. $expenditureType = '';
  11028. $con .= ' and accountType=' . $accountType;
  11029. if (! empty ( $accountMsg ))
  11030. $con .= ' and (accountType=' . $accountType . ' and accountMsg like "%' . $accountMsg . '%")';
  11031. }
  11032. } elseif ($submitType == 2) {
  11033. if ($expenditureType != '') {
  11034. $accountType = $accountMsg = '';
  11035. $con .= ' and expenditureType=' . $expenditureType;
  11036. }
  11037. } else {
  11038. $accountType = $accountMsg = $expenditureType = '';
  11039. }
  11040. $sql = "" . $con;
  11041. $action = "paymentsAchieve";
  11042. $get = '/' . $expensesType; // "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  11043. $pageinfo = $this->get_page ( "CLD_accountBook", $sql, $page, $page_size, $action, $get, "" );
  11044. $limit = $pageinfo ['lower'] . ',' . $page_size;
  11045. $list = $accountBook->getAccountBookBySql ( $limit, $sql, 'desc' );
  11046. $data ['expenditureType'] = $expenditureType;
  11047. $data ['accountMsg'] = $accountMsg;
  11048. $data ['accountType'] = $accountType;
  11049. $data ['inputDate'] = $date;
  11050. $data ['price'] = $price;
  11051. $data ['expensesType'] = $expensesType;
  11052. $data ['page'] = $pageinfo;
  11053. $data ['list'] = $list;
  11054. $data ['memu'] = "receipt";
  11055. $data ['staff'] = $this->staff;
  11056. $data ['receiptMemu'] = 'payments';
  11057. $data ['verifyId'] = $this->verifyId;
  11058. $data ['executeId'] = $this->executeId;
  11059. $this->render ( "/expenses/paymentsAchieve", $data );
  11060. }
  11061. function paymentsIncomeUpdateDo() {
  11062. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11063. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11064. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11065. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  11066. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  11067. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  11068. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  11069. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11070. if (! empty ( $aidKey ) && ! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  11071. Doo::loadClass ( 'XDeode' );
  11072. $XDeode = new XDeode ( 5 );
  11073. $aid = $XDeode->decode ( $aidKey );
  11074. Doo::loadModel ( "accountBook" );
  11075. $accountBook = new accountBook ();
  11076. //
  11077. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11078. $price = $receivedPrice - $abDetail [inComePrice];
  11079. Doo::loadModel ( "accountBookStatistics" );
  11080. $accountBookStatistics = new accountBookStatistics ();
  11081. if ($abDetail ['accountType'] == 7) {
  11082. $item += array (
  11083. 'date' => date ( "Y-m-d" ),
  11084. 'financingPrice' => - $price,
  11085. 'expensesType' => 3,
  11086. 'aid' => $abDetail ['aid']
  11087. );
  11088. } elseif ($abDetail ['accountType'] == 8) {
  11089. $item += array (
  11090. 'date' => date ( "Y-m-d" ),
  11091. 'expensesType' => $abDetail ['expensesType'],
  11092. 'inComePrice' => - $price,
  11093. 'aid' => $abDetail ['aid']
  11094. );
  11095. } else {
  11096. $item = array (
  11097. 'date' => date ( "Y-m-d" ),
  11098. 'expensesType' => $abDetail ['expensesType'],
  11099. 'inComePrice' => $price,
  11100. 'aid' => $abDetail ['aid']
  11101. );
  11102. }
  11103. $accountBookStatistics->setAccountBookStatistics ( $item );
  11104. $accountBook->accountType = $accountType;
  11105. $accountBook->accountMsg = $accountMsg;
  11106. $accountBook->receivedPrice = $receivedPrice;
  11107. $accountBook->receivedMsg = $receivedMsg;
  11108. $accountBook->receivedBank = $receivedBank;
  11109. $accountBook->receivedDate = $receivedDate;
  11110. $accountBook->remarks = $remarks;
  11111. $accountBook->aid = $aid;
  11112. $accountBook->update ();
  11113. }
  11114. return '/paymentsAchieve';
  11115. }
  11116. function paymentsExpenditureEdiDo() {
  11117. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11118. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11119. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11120. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11121. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11122. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11123. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11124. if (! empty ( $aidKey ) && ! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11125. Doo::loadClass ( 'XDeode' );
  11126. $XDeode = new XDeode ( 5 );
  11127. $aid = $XDeode->decode ( $aidKey );
  11128. Doo::loadModel ( "accountBook" );
  11129. $accountBook = new accountBook ();
  11130. // 汇总信息
  11131. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11132. $price = $expenditurePrice - $abDetail [expenditurePrice];
  11133. Doo::loadModel ( "accountBookStatistics" );
  11134. $accountBookStatistics = new accountBookStatistics ();
  11135. if ($abDetail ['expenditureType'] == 4) {
  11136. $item += array (
  11137. 'date' => date ( "Y-m-d" ),
  11138. 'financingPrice' => $price,
  11139. 'expensesType' => 3,
  11140. 'aid' => $abDetail ['aid']
  11141. );
  11142. } elseif ($abDetail ['expenditureType'] == 5) {
  11143. $item += array (
  11144. 'date' => date ( "Y-m-d" ),
  11145. 'expensesType' => $abDetail ['expensesType'],
  11146. 'payPrice' => $price,
  11147. 'aid' => $abDetail ['aid']
  11148. );
  11149. } else {
  11150. $item = array (
  11151. 'date' => date ( "Y-m-d" ),
  11152. 'expensesType' => $abDetail ['expensesType'],
  11153. 'payPrice' => $price,
  11154. 'aid' => $abDetail ['aid']
  11155. );
  11156. }
  11157. $accountBookStatistics->setAccountBookStatistics ( $item );
  11158. //
  11159. $accountBook->expenditureType = $expenditureType;
  11160. $accountBook->expenditureMsg = $expenditureMsg;
  11161. $accountBook->expenditurePrice = $expenditurePrice;
  11162. $accountBook->expenditureBank = $expenditureBank;
  11163. $accountBook->remarks = $remarks;
  11164. $accountBook->expenditureDate = $expenditureDate;
  11165. $accountBook->aid = $aid;
  11166. $id = $accountBook->update ();
  11167. }
  11168. return '/paymentsAchieve';
  11169. }
  11170. function paymentsDelDo() {
  11171. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11172. if (! empty ( $aidKey )) {
  11173. Doo::loadClass ( 'XDeode' );
  11174. $XDeode = new XDeode ( 5 );
  11175. $aid = $XDeode->decode ( $aidKey );
  11176. Doo::loadModel ( "accountBook" );
  11177. $accountBook = new accountBook ();
  11178. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11179. if (empty ( $abDetail ))
  11180. die ( 'illegal request' );
  11181. // 删除收支
  11182. Doo::loadModel ( "accountBookStatistics" );
  11183. $accountBookStatistics = new accountBookStatistics ();
  11184. $item = array (
  11185. 'date' => date ( "Y-m-d" ),
  11186. 'aid' => $abDetail ['aid']
  11187. );
  11188. $accountType = '';
  11189. if ($abDetail ['expensesType'] == 1) {
  11190. $accountType = 6;
  11191. if ($abDetail ['accountType'] != 7) {
  11192. $item += array (
  11193. 'expensesType' => $abDetail ['expensesType'],
  11194. 'inComePrice' => - $abDetail ['receivedPrice']
  11195. );
  11196. } else {
  11197. $item += array (
  11198. 'financingPrice' => $abDetail ['receivedPrice'],
  11199. 'expensesType' => 3
  11200. );
  11201. }
  11202. } elseif ($abDetail ['expensesType'] == 2) {
  11203. $accountType = 5;
  11204. if ($abDetail ['accountType'] != 7) {
  11205. $item += array (
  11206. 'expensesType' => $abDetail ['expensesType'],
  11207. 'payPrice' => - $abDetail ['expenditurePrice']
  11208. );
  11209. } else {
  11210. $item += array (
  11211. 'financingPrice' => - $abDetail ['expenditurePrice'],
  11212. 'expensesType' => 3
  11213. );
  11214. }
  11215. }
  11216. if (($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) && $abDetail ['expensesType'] == 2) {
  11217. if ($abDetail ['expenditureMsg'] == '公司固定')
  11218. $accountType = 9;
  11219. elseif ($abDetail ['expenditureMsg'] == '公司活期')
  11220. $accountType = 10;
  11221. }
  11222. if (($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) && $abDetail ['expensesType'] == 1) {
  11223. if ($abDetail ['accountMsg'] == '公司固定')
  11224. $accountType = 9;
  11225. elseif ($abDetail ['accountMsg'] == '公司活期')
  11226. $accountType = 10;
  11227. }
  11228. if ($abDetail ['accountMsg'] == '活期理财收益') {
  11229. $accountType = 10;
  11230. }
  11231. $accountBookStatistics->setAccountBookStatistics ( $item );
  11232. $accountBook->delete ( array (
  11233. 'where' => 'aid=' . $aid,
  11234. 'limit' => 1
  11235. ) );
  11236. // 删除收入流水
  11237. if (! empty ( $accountType )) {
  11238. Doo::loadModel ( 'wasteBook' );
  11239. $wasteBook = new wasteBook ();
  11240. $wasteBook->delete ( array (
  11241. 'where' => 'dataID=' . $aid . ' and accountType=' . $accountType,
  11242. 'limit' => 1
  11243. ) );
  11244. }
  11245. }
  11246. return '/paymentsAchieve';
  11247. }
  11248. function paymentsCollect() {
  11249. Doo::loadModel ( "execute" );
  11250. $execute = new execute ();
  11251. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11252. die ( 'illegal request' );
  11253. }
  11254. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11255. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  11256. Doo::loadModel ( "accountBookStatistics" );
  11257. $accountBookStatistics = new accountBookStatistics ();
  11258. Doo::loadClass ( 'receipt.func' );
  11259. $statisticsIncome = $accountBookStatistics->getStatisticsByCollect ( $year );
  11260. $html = _getPaymentsCollectByYearHtml ( $statisticsIncome );
  11261. $data ['html'] = $html ['html'];
  11262. $data ['inSum'] = $html ['sum'];
  11263. $statisticsPay = $accountBookStatistics->getStatisticsByCollect ( $year, 2 );
  11264. $html = _getPaymentsCollectPayByYearHtml ( $statisticsPay );
  11265. $data ['payHtml'] = $html ['html'];
  11266. $data ['paySum'] = $html ['sum'];
  11267. // 余额统计
  11268. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1 );
  11269. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2 );
  11270. include './protected/config/wasteBook.conf.php';
  11271. Doo::loadModel ( 'wasteBook' );
  11272. $wasteBook = new wasteBook ();
  11273. $inComePay = $wasteBook->getWasteBookByStatistics ( 1, $year );
  11274. $pay = $wasteBook->getWasteBookByStatistics ( 2, $year );
  11275. // 获得年份之前所有金额
  11276. $detail = $wasteBook->getWasteBookByStatisticsYear ( $year );
  11277. // print_r($detail);
  11278. // $waste['total'];
  11279. $lastBalanceHtml = '<tr><th colspan="2">截至上月余额</th>';
  11280. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11281. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11282. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11283. $inSum = $paySum = $showInSum = $showPaySum = $balanceSum = 0;
  11284. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11285. $limitMonth = date ( 'm' ); // 限制显示月份参数
  11286. if (date ( 'Y' ) > $year) {
  11287. $limitMonth = 12;
  11288. }
  11289. for($i = 1; $i <= 12; $i ++) {
  11290. $inComeA = $payB = 0;
  11291. $falg = true;
  11292. foreach ( $inComePay as $key => $value ) {
  11293. if ($value ['month'] == $i) {
  11294. $falg = false;
  11295. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11296. $inSum += $value ['accountPrice'];
  11297. $showInSum += $value ['accountPriceShow'];
  11298. $inComeA = $value ['accountPrice'];
  11299. break;
  11300. }
  11301. }
  11302. if ($falg)
  11303. $inComeHtml .= '<td class="taR">-</td>';
  11304. $payFalg = true;
  11305. foreach ( $pay as $key => $value ) {
  11306. if ($value ['month'] == $i) {
  11307. $payFalg = false;
  11308. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11309. $paySum += $value ['accountPrice'];
  11310. $showPaySum += $value ['accountPriceShow'];
  11311. $payB = $value ['accountPrice'];
  11312. break;
  11313. }
  11314. }
  11315. if ($payFalg)
  11316. $payHtml .= '<td class="taR">-</td>';
  11317. if (empty ( $balanceC ) || $limitMonth < $i)
  11318. $lastBalanceHtml .= '<td class="taR">-</td>';
  11319. else
  11320. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11321. $balanceC = $balanceC + $inComeA + $payB;
  11322. $balanceSum += $balanceC;
  11323. if (empty ( $balanceC ) || $limitMonth < $i)
  11324. $BalanceHtml .= '<td class="taR">-</td>';
  11325. else
  11326. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11327. // 余额统计
  11328. }
  11329. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11330. $data ['inComeHtml'] = $inComeHtml;
  11331. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11332. $data ['payBalanceHtml'] = $payHtml;
  11333. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11334. $data ['BalanceHtml'] = $BalanceHtml;
  11335. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11336. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11337. $mothHtml = "";
  11338. for($i = 1; $i <= 12; $i ++) {
  11339. if ($moth == $i)
  11340. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11341. else
  11342. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11343. }
  11344. $data ['mothHtml'] = $mothHtml;
  11345. $dateHtml = "";
  11346. $now = date ( "Y" );
  11347. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11348. if ($YEARD <= $now) {
  11349. $dateHtml .= '<option ';
  11350. if ($year == $YEARD) {
  11351. $dateHtml .= 'selected ';
  11352. }
  11353. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11354. }
  11355. }
  11356. $data ['dateHtml'] = $dateHtml;
  11357. $data ['year'] = $year;
  11358. $data ['memu'] = "receipt";
  11359. $data ['staff'] = $this->staff;
  11360. $data ['receiptMemu'] = 'paymentsCollect';
  11361. $data ['verifyId'] = $this->verifyId;
  11362. $data ['executeId'] = $this->executeId;
  11363. $this->render ( "/expenses/paymentsCollect", $data );
  11364. }
  11365. function paymentsCollectDay() {
  11366. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11367. $moth = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : '';
  11368. if (empty ( $moth ))
  11369. return 'paymentsCollect';
  11370. Doo::loadModel ( "accountBookStatistics" );
  11371. $accountBookStatistics = new accountBookStatistics ();
  11372. $i = 2;
  11373. $y = 2013;
  11374. $day = date ( "t", strtotime ( "$year-$moth" ) );
  11375. Doo::loadClass ( 'receipt.func' );
  11376. $statisticsIncome = $accountBookStatistics->getStatisticsByCollectDay ( $year, 1, $moth );
  11377. $html = _getPaymentsCollectByDayHtml ( $statisticsIncome, $day );
  11378. $data ['html'] = $html ['html'];
  11379. $data ['inSum'] = $html ['sum'];
  11380. $statisticsPay = $accountBookStatistics->getStatisticsByCollectDay ( $year, 2, $moth );
  11381. $html = _getPaymentsCollectPayByDayHtml ( $statisticsPay, $day );
  11382. $data ['payHtml'] = $html ['html'];
  11383. $data ['paySum'] = $html ['sum'];
  11384. $mothHtml = "";
  11385. for($i = 1; $i <= 12; $i ++) {
  11386. if ($moth == $i)
  11387. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11388. else
  11389. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11390. }
  11391. $data ['mothHtml'] = $mothHtml;
  11392. $data ['year'] = $year;
  11393. // 余额
  11394. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1, $moth );
  11395. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2, $moth );
  11396. include './protected/config/wasteBook.conf.php';
  11397. Doo::loadModel ( 'wasteBook' );
  11398. $wasteBook = new wasteBook ();
  11399. $inComePay = $wasteBook->getStatisticsByDay ( 1, $year, $moth );
  11400. $pay = $wasteBook->getStatisticsByDay ( 2, $year, $moth );
  11401. // 获得年份之前所有金额
  11402. $detail = $wasteBook->getWasteBookByStatisticsDay ( $year, $moth );
  11403. $lastBalanceHtml = '<tr><th colspan="2">截至上日余额</th>';
  11404. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11405. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11406. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11407. $dayHtml = '<tr><th class="taC" colspan="2">余额</th>';
  11408. $inSum = $paySum = $showPaySum = $showInSum = $balanceSum = 0;
  11409. // $balanceC = 0;
  11410. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11411. $limitDay = date ( 'd' );
  11412. $monthLK = ( int ) date ( 'm' );
  11413. if (date ( 'Y' ) > $year) {
  11414. $limitDay = cal_days_in_month ( CAL_GREGORIAN, date ( 'm' ), date ( 'Y' ) );
  11415. } elseif (date ( 'Y' ) <= $year && $monthLK < $moth) {
  11416. $limitDay = 0;
  11417. }
  11418. for($i = 1; $i <= $day; $i ++) {
  11419. $dayHtml .= '<td class="taC">' . $i . '日</td>';
  11420. $inComeA = $payB = 0;
  11421. $falg = true;
  11422. foreach ( $inComePay as $key => $value ) {
  11423. if ($value ['day'] == $i) {
  11424. $falg = false;
  11425. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11426. $inSum += $value ['accountPrice'];
  11427. $showInSum += $value ['accountPriceShow'];
  11428. $inComeA = $value ['accountPrice'];
  11429. break;
  11430. }
  11431. }
  11432. if ($falg)
  11433. $inComeHtml .= '<td class="taR">-</td>';
  11434. $payFalg = true;
  11435. foreach ( $pay as $key => $value ) {
  11436. if ($value ['day'] == $i) {
  11437. $payFalg = false;
  11438. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11439. $paySum += $value ['accountPrice'];
  11440. $showPaySum += $value ['accountPriceShow'];
  11441. $payB = $value ['accountPrice'];
  11442. break;
  11443. }
  11444. }
  11445. if ($payFalg)
  11446. $payHtml .= '<td class="taR">-</td>';
  11447. if (empty ( $balanceC ) || $limitDay < $i)
  11448. $lastBalanceHtml .= '<td class="taR">-</td>';
  11449. else
  11450. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11451. $balanceC = $balanceC + $inComeA + $payB;
  11452. $balanceSum += $balanceC;
  11453. if (empty ( $balanceC ) || $limitDay < $i)
  11454. $BalanceHtml .= '<td class="taR">-</td>';
  11455. else
  11456. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11457. }
  11458. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11459. $data ['inComeHtml'] = $inComeHtml;
  11460. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11461. $data ['payBalanceHtml'] = $payHtml;
  11462. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11463. $data ['BalanceHtml'] = $BalanceHtml;
  11464. $dayHtml .= '<td class="taR ">总计</td></tr>';
  11465. $data ['dayHtml'] = $dayHtml;
  11466. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11467. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11468. $dateHtml = "";
  11469. $now = date ( "Y" );
  11470. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11471. if ($YEARD <= $now) {
  11472. $dateHtml .= '<option ';
  11473. if ($year == $YEARD) {
  11474. $dateHtml .= 'selected ';
  11475. }
  11476. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11477. }
  11478. }
  11479. $data ['dateHtml'] = $dateHtml;
  11480. $data ['memu'] = "receipt";
  11481. $data ['staff'] = $this->staff;
  11482. $data ['receiptMemu'] = 'paymentsCollect';
  11483. $data ['verifyId'] = $this->verifyId;
  11484. $data ['executeId'] = $this->executeId;
  11485. $this->render ( "/expenses/paymentsCollectDay", $data );
  11486. }
  11487. // 公司流水
  11488. function wasteBook() {
  11489. Doo::loadModel ( "execute" );
  11490. $execute = new execute ();
  11491. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11492. die ( 'illegal request' );
  11493. }
  11494. include './protected/config/wasteBook.conf.php';
  11495. Doo::loadModel ( 'wasteBook' );
  11496. $wasteBook = new wasteBook ();
  11497. $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  11498. $waste = $this->getWasteBookStatistics ( $waste, $inComeStatistics );
  11499. $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'];
  11500. // print_r($waste);
  11501. $data ['waste'] = $waste;
  11502. $data ['total'] = $total;
  11503. // 月流水数据结构
  11504. $monthStatistics = array ();
  11505. $incomeMothStatistics = array ();
  11506. $expenditureMothStatistics = array ();
  11507. for($i = 1; $i <= 12; $i ++) {
  11508. $month = date ( 'Y' ) . '-' . $i;
  11509. if ($i < 10)
  11510. $month = date ( 'Y' ) . '-0' . $i;
  11511. array_push ( $monthStatistics, $month );
  11512. }
  11513. foreach ( $monthStatistics as $value ) {
  11514. $falg = true;
  11515. foreach ( $inComeStatistics ['incomeReport'] as $k => $v ) {
  11516. if ($value == $v ['inputDate']) {
  11517. array_push ( $incomeMothStatistics, $v ['accountPrice'] );
  11518. $falg = false;
  11519. }
  11520. }
  11521. if ($falg) {
  11522. array_push ( $incomeMothStatistics, '' );
  11523. }
  11524. $falgEx = true;
  11525. foreach ( $inComeStatistics ['expenditureReport'] as $k => $v ) {
  11526. if ($value == $v ['inputDate']) {
  11527. array_push ( $expenditureMothStatistics, $v ['accountPrice'] );
  11528. $falg = false;
  11529. }
  11530. }
  11531. if ($falgEx) {
  11532. array_push ( $expenditureMothStatistics, '' );
  11533. }
  11534. }
  11535. $data ['monthStatistics'] = json_encode ( $monthStatistics );
  11536. $data ['incomeMothStatistics'] = json_encode ( $incomeMothStatistics );
  11537. $data ['expenditureMothStatistics'] = json_encode ( $expenditureMothStatistics );
  11538. $expenditureList = $wasteBook->getAccountBookByExpensesType ( 4, 2 );
  11539. $incomeList = $wasteBook->getAccountBookByExpensesType ( 4, 1 );
  11540. // print_r($incomeList);
  11541. $data ['expenditureList'] = $expenditureList;
  11542. $data ['incomeList'] = $incomeList;
  11543. $data ['memu'] = "receipt";
  11544. $data ['staff'] = $this->staff;
  11545. $data ['receiptMemu'] = 'wasteBook';
  11546. $data ['verifyId'] = $this->verifyId;
  11547. $data ['executeId'] = $this->executeId;
  11548. $this->render ( "/expenses/wasteBook", $data );
  11549. }
  11550. function wasteBookIncome() {
  11551. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11552. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11553. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  11554. $dailyIncomeType = $this->get_args ( 'dailyIncomeType' ) ? $this->get_args ( 'dailyIncomeType' ) : "ALL";
  11555. $data ['dailyIncomeType'] = $dailyIncomeType;
  11556. Doo::loadModel ( 'wasteBook' );
  11557. $wasteBook = new wasteBook ();
  11558. Doo::loadModel ( 'L_category' );
  11559. $L_category = new L_category ();
  11560. Doo::loadClass ( 'XDeode' );
  11561. $XDeode = new XDeode ( 5 );
  11562. // echo $XDeode->encode(1).'<br>';
  11563. // echo $XDeode->encode(2).'<br>';
  11564. // echo $XDeode->encode(3).'<br>';
  11565. // echo $XDeode->encode(4).'<br>';
  11566. // echo $XDeode->encode(5).'<br>';
  11567. // echo $XDeode->encode(6).'<br>';
  11568. // echo $XDeode->encode(7).'<br>';
  11569. // echo $XDeode->encode(8).'<br>';
  11570. // echo $XDeode->encode(9).'<br>';
  11571. // echo $XDeode->encode(10).'<br>';
  11572. $year=date("Y");
  11573. $theDay=date("Y-m-d");
  11574. $dateArr = explode ( ':', $date );
  11575. $D1 = '';
  11576. $D2 = '';
  11577. $con = '';
  11578. if (! empty ( $date )) {
  11579. $D1 = $dateArr [0];
  11580. $D2 = $dateArr [1];
  11581. }
  11582. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11583. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11584. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11585. $con = ' and inputDate = "' . $D1 . '"';
  11586. else{
  11587. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  11588. }
  11589. if ($cid != 'ALL') {
  11590. $cid = $XDeode->decode ( $cid );
  11591. $con .= ' and cid = "' . $cid . '"';
  11592. }
  11593. if ($accountType != 'ALL') {
  11594. if ($accountType == 'INVOICE') {
  11595. $con .= ' and (accountType = 7 or accountType = 8)';
  11596. } elseif ($accountType == 'PAYMENTS') {
  11597. $con .= ' and (accountType = 6 or accountType = 9 or accountType = 10)';
  11598. if ($dailyIncomeType != 'ALL') {
  11599. $dailyIncomeType = $XDeode->decode ( $dailyIncomeType );
  11600. $con .= ' and dailyIncomeType = ' . $dailyIncomeType;
  11601. }
  11602. }
  11603. }
  11604. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 1, $con );
  11605. $sum = 0;$thsDaySum=0;
  11606. foreach ( $incomeList as $key => $value ) {
  11607. $sum += $value ['accountPrice'];
  11608. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  11609. $thsDaySum+=$value ['accountPrice'];
  11610. }
  11611. }
  11612. // print_r($incomeList);
  11613. // 获得办事和部门
  11614. $categoryList = $L_category->getCategory ();
  11615. $data ['accountType'] = $accountType;
  11616. $data ['cid'] = $cid;
  11617. $data ['categoryList'] = $categoryList;
  11618. $data ['sum'] = $sum;
  11619. $data ['incomeList'] = $incomeList;
  11620. $data ['inputDate'] = $date;
  11621. $data['year']=$year;
  11622. $data ['thsDay'] =$theDay;
  11623. $data ['thsDaySum'] =$thsDaySum;
  11624. $data ['memu'] = "receipt";
  11625. $data ['staff'] = $this->staff;
  11626. $data ['receiptMemu'] = 'wasteBook';
  11627. $data ['verifyId'] = $this->verifyId;
  11628. $data ['executeId'] = $this->executeId;
  11629. $this->render ( "/expenses/wasteBookIncome", $data );
  11630. }
  11631. /**
  11632. * 所有支出
  11633. */
  11634. function wasteBookExpenditure() {
  11635. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11636. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11637. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  11638. $dailyExpenditureType = $this->get_args ( 'dailyExpenditureType' ) ? $this->get_args ( 'dailyExpenditureType' ) : "ALL";
  11639. $data ['dailyExpenditureType'] = $dailyExpenditureType;
  11640. $receiptType = $this->get_args ( 'receiptType' ) ? $this->get_args ( 'receiptType' ) : "ALL";
  11641. $data ['receiptType'] = $receiptType;
  11642. Doo::loadModel ( 'wasteBook' );
  11643. $wasteBook = new wasteBook ();
  11644. Doo::loadModel ( 'L_category' );
  11645. $L_category = new L_category ();
  11646. Doo::loadClass ( 'XDeode' );
  11647. $XDeode = new XDeode ( 5 );
  11648. $year=date("Y");
  11649. $theDay=date("Y-m-d");
  11650. $dateArr = explode ( ':', $date );
  11651. $D1 = '';
  11652. $D2 = '';
  11653. $con = '';
  11654. if (! empty ( $date )) {
  11655. $D1 = $dateArr [0];
  11656. $D2 = $dateArr [1];
  11657. }
  11658. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11659. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11660. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11661. $con = ' and inputDate = "' . $D1 . '"';
  11662. else{
  11663. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  11664. }
  11665. if ($cid != 'ALL') {
  11666. $cid = $XDeode->decode ( $cid );
  11667. $con .= ' and cid = "' . $cid . '"';
  11668. }
  11669. if ($accountType != 'ALL') {
  11670. if ($accountType == 'INVOICE') {
  11671. $con .= ' and accountType = 11';
  11672. } elseif ($accountType == 'PAYMENTS') {
  11673. $con .= ' and (accountType = 5 or accountType = 9 or accountType = 10)';
  11674. if ($dailyExpenditureType != 'ALL') {
  11675. $dailyExpenditureType = $XDeode->decode ( $dailyExpenditureType );
  11676. $con .= ' and dailyExpenditureType = ' . $dailyExpenditureType;
  11677. }
  11678. } elseif ($accountType == 'RECEIPT') {
  11679. if ($receiptType == 'ALL') {
  11680. $con .= ' and (accountType = 1 or accountType = 2 or accountType = 3 or accountType = 4)';
  11681. } else {
  11682. $receiptType = $XDeode->decode ( $receiptType );
  11683. echo $receiptType;
  11684. if ($receiptType == 1) {
  11685. $con .= ' and (accountType = 1 or accountType=2)';
  11686. } else {
  11687. $con .= ' and accountType = ' . $receiptType;
  11688. }
  11689. }
  11690. }
  11691. }
  11692. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 2, $con );
  11693. $sum = 0;$thsDaySum=0;
  11694. foreach ( $incomeList as $key => $value ) {
  11695. $sum += $value ['accountPriceShow'];
  11696. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  11697. $thsDaySum+=$value ['accountPriceShow'];
  11698. }
  11699. }
  11700. // print_r($incomeList);
  11701. // 获得办事和部门
  11702. $categoryList = $L_category->getCategory ();
  11703. $data ['accountType'] = $accountType;
  11704. $data ['cid'] = $cid;
  11705. $data ['categoryList'] = $categoryList;
  11706. $data ['sum'] = $sum;
  11707. $data ['incomeList'] = $incomeList;
  11708. $data ['inputDate'] = $date;
  11709. $data['year']=$year;
  11710. $data ['thsDay'] =$theDay;
  11711. $data ['thsDaySum'] =$thsDaySum;
  11712. $data ['memu'] = "receipt";
  11713. $data ['staff'] = $this->staff;
  11714. $data ['receiptMemu'] = 'wasteBook';
  11715. $data ['verifyId'] = $this->verifyId;
  11716. $data ['executeId'] = $this->executeId;
  11717. $this->render ( "/expenses/wasteBookExpenditure", $data );
  11718. }
  11719. function ajaxGetWasteinvoiceReceivables() {
  11720. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11721. Doo::loadClass ( 'XDeode' );
  11722. $XDeode = new XDeode ( 5 );
  11723. $irid = $XDeode->decode ( $serial );
  11724. Doo::loadModel ( 'invoiceReceivables' );
  11725. $invoiceReceivables = new invoiceReceivables ();
  11726. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  11727. echo json_encode ( array (
  11728. 'status' => 1,
  11729. 'detail' => $detail
  11730. ) );
  11731. }
  11732. function ajaxGetPaymentsByAid() {
  11733. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11734. Doo::loadModel ( "accountBook" );
  11735. $accountBook = new accountBook ();
  11736. $detail = $accountBook->getAccountBookByAid ( $serial );
  11737. echo json_encode ( array (
  11738. 'status' => 1,
  11739. 'detail' => $detail
  11740. ) );
  11741. }
  11742. function ajaxGetWasteInvoice() {
  11743. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11744. Doo::loadModel ( 'invoice' );
  11745. $invoice = new invoice ();
  11746. Doo::loadModel ( 'invoiceReceivables' );
  11747. $invoiceReceivables = new invoiceReceivables ();
  11748. $detail = $invoice->getInvoiceByIid ( $serial );
  11749. $detailReceivables = $invoiceReceivables->getInvoiceReceivablesByIrid ( $detail ['irid'] );
  11750. $detail ['receivablesBank'] = $detailReceivables ['receivablesBank'];
  11751. echo json_encode ( array (
  11752. 'status' => 1,
  11753. 'detail' => $detail
  11754. ) );
  11755. }
  11756. /**
  11757. */
  11758. function ajaxGetWasteReceipt() {
  11759. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11760. $accountTypeKey = $this->get_args ( 'accountTypeKey' ) ? $this->get_args ( 'accountTypeKey' ) : "";
  11761. Doo::loadModel ( 'receipt' );
  11762. $receipt = new receipt ();
  11763. Doo::loadClass ( 'XDeode' );
  11764. $XDeode = new XDeode ( 5 );
  11765. $rid = $XDeode->decode ( $serial );
  11766. $accountType= $XDeode->decode ( $accountTypeKey );
  11767. // 获得个数据
  11768. $detail = $receipt->getReceiptByRid ( $rid );
  11769. // 初始化
  11770. $detail ['reviseDetail'] = array ();
  11771. if (! empty ( $value ['reviseDetail'] ))
  11772. $detail ['reviseDetail'] = json_decode ( $detail ['reviseDetail'], true );
  11773. $detail ['accountItem'] = json_decode ( $detail ['accountItem'], true );
  11774. $detail ['loanItem'] = json_decode ( $detail ['loanItem'], true );
  11775. $detail ['loanSumCN'] = $this->num_to_rmb ( $detail ['loanSum'] );
  11776. $detail ['sumCN'] = $this->num_to_rmb ( $detail ['sum'] );
  11777. // 获得费用html
  11778. $html = $this->getWasteReceiptHtml ( $detail ,$accountType);
  11779. // 获得费用审批人数据
  11780. $detail = $this->getReceiptApproverHtml ( $detail );
  11781. // 审批执行
  11782. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  11783. <th class="taC" width="90">审批人</th>
  11784. <th class="taC">审批意见</th></tr>';
  11785. foreach ( $detail ['verifyList'] as $key => $value ) {
  11786. $html .= '<tr>
  11787. <td>' . $value [1] . '</td>
  11788. <td>' . $value ['opinion'] . '</td>
  11789. </tr>
  11790. ';
  11791. }
  11792. $html .= ' </tbody></table>';
  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 ['executeCopy'] 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. if($accountType==1){
  11805. Doo::loadModel ( 'loanReceipt' );
  11806. $loanReceipt = new loanReceipt ();
  11807. $loanList = $loanReceipt->getOne ( array (
  11808. 'where' => 'rid=' . $detail ['loanRid'],
  11809. 'desc' => 'rid',
  11810. 'asArray' => true
  11811. ) );
  11812. $html .= '<table class="table table-bordered table-condensed">
  11813. <tr class="warning">
  11814. <td class="taR"><b>汇款金额</b></td>
  11815. <td width="140" class="taR"><b style="font-size: 24px">¥'.$loanList['amount'].'</b></td>
  11816. </tr>
  11817. </table>';
  11818. }else{
  11819. $html .= '<table class="table table-bordered table-condensed">
  11820. <tr class="warning">
  11821. <td class="taR"><b>汇款金额</b></td>
  11822. <td width="140" class="taR"><b style="font-size: 24px">¥' . $detail ['amount'] . '</b></td>
  11823. </tr>
  11824. </table>';
  11825. }
  11826. // print_r($detail['verifyList']);
  11827. // header ( 'Content-Type:text/html;charset=utf-8' );
  11828. // echo $html;
  11829. echo json_encode ( array (
  11830. 'status' => 1,
  11831. 'html' => $html,
  11832. 'detail' => $detail
  11833. ) );
  11834. }
  11835. function getReceiptApproverHtml($detail = array()) {
  11836. Doo::loadModel ( 'loanReceipt' );
  11837. $loanReceipt = new loanReceipt ();
  11838. Doo::loadModel ( 'verify' );
  11839. $verify = new verify ();
  11840. Doo::loadModel ( 'staff' );
  11841. $staff = new staff ();
  11842. if (empty ( $detail ))
  11843. return array ();
  11844. $loanList = $loanReceipt->getOne ( array (
  11845. 'where' => 'rid=' . $detail ['loanRid'],
  11846. 'desc' => 'rid',
  11847. 'asArray' => true
  11848. ) );
  11849. if ($detail ['status'] == 3 || $detail ['status'] == 1 || $detail ['status'] == 8 || $detail ['status'] == 9) {
  11850. if ($detail ['status'] == 8 && $detail ['Rtype'] == 1)
  11851. $verifyList ['staff'] = $loanList ['verifyBreakup'];
  11852. else
  11853. $verifyList ['staff'] = $detail ['verifyBreakup'];
  11854. } else
  11855. $verifyList = $verify->getOne ( array (
  11856. 'where' => 'vid=' . $detail ['verify'],
  11857. 'asArray' => true
  11858. ) );
  11859. $verifyList = json_decode ( $verifyList ['staff'], true );
  11860. Doo::loadModel ( 'role' );
  11861. $role = new role ();
  11862. $roleId = 0;
  11863. $flag = true;
  11864. $roleKey = 0;
  11865. $endStaffArray = array ();
  11866. $roleArrayCopy = array ();
  11867. foreach ( $verifyList as $k => $v ) {
  11868. // init verifyStaff
  11869. if ($v [1] == 'ROLE') {
  11870. if (! empty ( $verifyStaff )) {
  11871. $endStaffArray = end ( $verifyStaff );
  11872. }
  11873. $roleVerify = json_decode ( $v [3], true );
  11874. $roleKey = $k;
  11875. $roleArray = array ();
  11876. $rolename = $role->getOne ( array (
  11877. 'where' => 'rid=' . $v [0],
  11878. 'asArray' => true
  11879. ) );
  11880. foreach ( $roleVerify as $o => $p ) {
  11881. $staffID = explode ( '_', $p );
  11882. $staffInfo = $staff->getOne ( array (
  11883. 'where' => 'sid=' . $staffID [0],
  11884. 'asArray' => true
  11885. ) );
  11886. // print_r($staffID);
  11887. $exp = array (
  11888. 0 => $staffInfo ['sid'],
  11889. 1 => $staffID [1],
  11890. 2 => $staffInfo ['avatar'],
  11891. 'date' => '',
  11892. 'date' => '',
  11893. 'opinion' => '',
  11894. 'status' => '',
  11895. 'rolename' => $rolename ['name']
  11896. );
  11897. array_push ( $roleArray, $exp );
  11898. }
  11899. $roleArrayCopy [$v [0]] = $roleArray;
  11900. // $verifyList[$k]['roleArray']=$roleArray;
  11901. }
  11902. $verifyList [$k] ['date'] = "";
  11903. $verifyList [$k] ['opinion'] = "";
  11904. $verifyList [$k] ['status'] = "";
  11905. if (empty ( $verifyStaff )) {
  11906. $verifyList [$k] ['date'] = "";
  11907. $verifyList [$k] ['opinion'] = "";
  11908. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  11909. $verifyList [$k] ['status'] = 4;
  11910. $flag = false;
  11911. }
  11912. } else {
  11913. foreach ( $verifyStaff as $m => $u ) {
  11914. if ($v [0] == $m) {
  11915. $verifyList [$k] ['date'] = $u ['date'];
  11916. $verifyList [$k] ['opinion'] = $u ['opinion'];
  11917. $verifyList [$k] ['status'] = $u ['status'];
  11918. $flag = false;
  11919. break;
  11920. }
  11921. }
  11922. $endStaffArray = end ( $verifyStaff );
  11923. }
  11924. }
  11925. $rolename ['name'] = '';
  11926. if (! empty ( $roleId )) {
  11927. Doo::loadModel ( 'role' );
  11928. $role = new role ();
  11929. $rolename = $role->getOne ( array (
  11930. 'where' => 'rid=' . $roleId,
  11931. 'asArray' => true
  11932. ) );
  11933. }
  11934. if (! empty ( $verifyStaff ))
  11935. $endStaffArray = end ( $verifyStaff );
  11936. $KOP = false;
  11937. foreach ( $roleArrayCopy as $P => $A ) {
  11938. foreach ( $A as $MKI => $AVL ) {
  11939. if (! empty ( $verifyStaff )) {
  11940. // &&$rolename['rid']==$endStaffArray['nextStaff']
  11941. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  11942. $button = 4;
  11943. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  11944. }
  11945. foreach ( $verifyStaff as $m => $u ) {
  11946. $AVLFK = $AVL [0] . '_R';
  11947. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  11948. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  11949. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  11950. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  11951. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  11952. break;
  11953. }
  11954. }
  11955. } else {
  11956. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  11957. $button = 4;
  11958. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  11959. }
  11960. }
  11961. // $roleArray[$MKI]['rolename']=$rolename['name'];
  11962. $KOP = true;
  11963. }
  11964. }
  11965. foreach ( $roleArrayCopy as $k => $v ) {
  11966. foreach ( $verifyList as $m => $n ) {
  11967. if ($n [0] == $k) {
  11968. array_splice ( $verifyList, $m, 1, $v );
  11969. }
  11970. }
  11971. }
  11972. // 费用执行人相关数据
  11973. $executeCopy = json_decode ( $detail ['executeCopy'], true );
  11974. $executeStaff = json_decode ( $detail ['executeStaff'], true );
  11975. foreach ( $executeCopy as $k => $v ) {
  11976. $executeCopy [$k] ['date'] = '';
  11977. $executeCopy [$k] ['opinion'] = '';
  11978. $executeCopy [$k] ['status'] = '';
  11979. if (! empty ( $executeStaff ))
  11980. foreach ( $executeStaff as $m => $u ) {
  11981. if ($v [0] == $m) {
  11982. $executeCopy [$k] ['date'] = $u ['date'];
  11983. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  11984. $executeCopy [$k] ['status'] = $u ['status'];
  11985. break;
  11986. }
  11987. }
  11988. }
  11989. $detail ['executeCopy'] = $executeCopy;
  11990. $detail ['verifyList'] = $verifyList;
  11991. return $detail;
  11992. }
  11993. function getWasteReceiptHtml($detail = array(),$accountType=1) {
  11994. if (empty ( $detail ))
  11995. return '';
  11996. $html = '';
  11997. if ($detail ['Rtype'] == 0) { // 报销单
  11998. $html .= '<table class="table table-bordered table-condensed">
  11999. <tbody>
  12000. <tr>
  12001. <th colspan="2" class="taC">日常相关费用</th>
  12002. </tr>';
  12003. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12004. $html .= '
  12005. <tr>
  12006. <th>' . $value ['name'] . '</th>
  12007. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12008. </tr>';
  12009. }
  12010. $html .= '
  12011. <tr>
  12012. <th class="taR">合计</th>
  12013. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12014. </tr>';
  12015. $html .= '<tr>
  12016. <th colspan="2" class="taC">差旅相关费用</th>
  12017. </tr>';
  12018. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12019. $html .= '
  12020. <tr>
  12021. <th>' . $value ['name'] . '</th>
  12022. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12023. </tr>';
  12024. }
  12025. $html .= '
  12026. <tr>
  12027. <th class="taR">合计</th>
  12028. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12029. </tr>';
  12030. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12031. $html .= '<tr>
  12032. <th colspan="2" class="taC">内部培训费用</th>
  12033. </tr>';
  12034. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12035. $html .= '
  12036. <tr>
  12037. <th>' . $value ['name'] . '</th>
  12038. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12039. </tr>';
  12040. }
  12041. $html .= '
  12042. <tr>
  12043. <th class="taR">合计</th>
  12044. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12045. </tr>';
  12046. }
  12047. $html .= '<tr>
  12048. <th colspan="2" class="taC">其他</th>
  12049. </tr>';
  12050. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12051. $html .= '
  12052. <tr>
  12053. <th>' . $value ['name'] . '</th>
  12054. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12055. </tr>';
  12056. }
  12057. $html .= '
  12058. <tr>
  12059. <th class="taR">合计</th>
  12060. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12061. </tr>';
  12062. $html .= '<tr>
  12063. <th colspan="2" class="taC">报销金额调整</th>
  12064. </tr>';
  12065. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12066. $html .= '
  12067. <tr>
  12068. <th>' . $value ['name'] . '</th>
  12069. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12070. </tr>';
  12071. }
  12072. $html .= '
  12073. <tr>
  12074. <th class="taR">合计</th>
  12075. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12076. </tr>';
  12077. $html .= '
  12078. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12079. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12080. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12081. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12082. <tr class="warning">
  12083. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12084. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12085. </tr>
  12086. </tbody>
  12087. </table>';
  12088. } elseif ($detail ['Rtype'] == 2) {//对公汇款
  12089. $html .= '
  12090. <table class="table table-bordered table-condensed">
  12091. <tbody>
  12092. <tr>
  12093. <th colspan="2" class="taC">办事处相关费用</th>
  12094. </tr>';
  12095. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12096. $html .= '
  12097. <tr>
  12098. <th>' . $value ['name'] . '</th>
  12099. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12100. </tr>';
  12101. }
  12102. $html .= '
  12103. <tr>
  12104. <th class="taR">合计</th>
  12105. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12106. </tr>';
  12107. $html .= '
  12108. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12109. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12110. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12111. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12112. <tr class="warning">
  12113. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12114. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12115. </tr>
  12116. </tbody>
  12117. </table>';
  12118. } elseif ($detail ['Rtype'] == 1) {//借款 或者借款报销
  12119. Doo::loadModel ( 'loanReceipt' );
  12120. $loanReceipt = new loanReceipt ();
  12121. $loanList = $loanReceipt->getOne ( array (
  12122. 'where' => 'rid=' . $detail ['loanRid'],
  12123. 'desc' => 'rid',
  12124. 'asArray' => true
  12125. ) );
  12126. // print_r($loanList);
  12127. $loanList ['sumCN']=$this->num_to_rmb($loanList ['sum']);
  12128. $html .= '<table class="table table-bordered table-condensed">
  12129. <tbody>
  12130. <tr>
  12131. <th colspan="2" class="taC">借款费用</th>
  12132. </tr>';
  12133. foreach ( $detail ['loanItem'] ['借款费用'] as $key => $value ) {
  12134. $html .= '<tr>
  12135. <th>' . $value ['name'] . '</th>
  12136. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12137. </tr>';
  12138. }
  12139. $html .= '<tr>
  12140. <th class="taC" colspan="2">产生费用所在办事处</th>
  12141. </tr>
  12142. <tr>
  12143. <th style="text-align: center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th>
  12144. </tr>
  12145. <tr>
  12146. <th class="taC" colspan="2">费用说明</th>
  12147. </tr>
  12148. <tr>
  12149. <td colspan="2">' . $loanList ['explanation'] . '</td>
  12150. </tr>
  12151. <tr class="warning">
  12152. <td class="taR"><b>(' . $loanList ['receiptOrder'] . ')本次费用合计</b></td>
  12153. <td class="taR"><b style="font-size: 24px">¥' . $loanList ['sum'] . '</b><br>' . $loanList ['sumCN'] . '</td>
  12154. </tr>
  12155. </tbody>
  12156. </table>
  12157. ';
  12158. if ( $accountType==2) {
  12159. $balance=$detail ['sum']-$loanList ['sum'];
  12160. $balanceCN=$this->num_to_rmb($balance);
  12161. $html .= '<table class="table table-bordered table-condensed">
  12162. <tbody>
  12163. <tr>
  12164. <th colspan="2" class="taC">日常相关费用</th>
  12165. </tr>';
  12166. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12167. $html .= '
  12168. <tr>
  12169. <th>' . $value ['name'] . '</th>
  12170. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12171. </tr>';
  12172. }
  12173. $html .= '
  12174. <tr>
  12175. <th class="taR">合计</th>
  12176. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12177. </tr>';
  12178. $html .= '<tr>
  12179. <th colspan="2" class="taC">差旅相关费用</th>
  12180. </tr>';
  12181. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12182. $html .= '
  12183. <tr>
  12184. <th>' . $value ['name'] . '</th>
  12185. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12186. </tr>';
  12187. }
  12188. $html .= '
  12189. <tr>
  12190. <th class="taR">合计</th>
  12191. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12192. </tr>';
  12193. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12194. $html .= '<tr>
  12195. <th colspan="2" class="taC">内部培训费用</th>
  12196. </tr>';
  12197. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12198. $html .= '
  12199. <tr>
  12200. <th>' . $value ['name'] . '</th>
  12201. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12202. </tr>';
  12203. }
  12204. $html .= '
  12205. <tr>
  12206. <th class="taR">合计</th>
  12207. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12208. </tr>';
  12209. }
  12210. $html .= '<tr>
  12211. <th colspan="2" class="taC">其他</th>
  12212. </tr>';
  12213. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12214. $html .= '
  12215. <tr>
  12216. <th>' . $value ['name'] . '</th>
  12217. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12218. </tr>';
  12219. }
  12220. $html .= '
  12221. <tr>
  12222. <th class="taR">合计</th>
  12223. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12224. </tr>';
  12225. $html .= '<tr>
  12226. <th colspan="2" class="taC">报销金额调整</th>
  12227. </tr>';
  12228. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12229. $html .= '
  12230. <tr>
  12231. <th>' . $value ['name'] . '</th>
  12232. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12233. </tr>';
  12234. }
  12235. $html .= '
  12236. <tr>
  12237. <th class="taR">合计</th>
  12238. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12239. </tr>';
  12240. $html .= '
  12241. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12242. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12243. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12244. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12245. <tr class="warning">
  12246. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12247. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12248. </tr>
  12249. <tr class="success">
  12250. <td class="taR"><b>借款结余</b></td>
  12251. <td class="taR"><b style="font-size:24px">¥'.$balance.'</b><br>'.$balanceCN.'</td>
  12252. </tr>
  12253. </tbody>
  12254. </table>';
  12255. }
  12256. }
  12257. return $html;
  12258. }
  12259. /**
  12260. * 计算流水
  12261. */
  12262. function getWasteBookStatistics($waste = array(), $inComeStatistics) {
  12263. $bakWaste ['bank'] = array (
  12264. 'CGBDeposit' => 0,
  12265. 'ICBCDeposit' => 0,
  12266. 'HUADeposit' => 0,
  12267. 'PersonalDeposit' => 0
  12268. );
  12269. $bakWaste ['financial'] = array (
  12270. 'current' => array (
  12271. 'CGBDeposit' => 0,
  12272. 'ICBCDeposit' => 0
  12273. ),
  12274. 'fixed' => array (
  12275. 'CGBDeposit' => 0,
  12276. 'ICBCDeposit' => 0
  12277. )
  12278. );
  12279. // 存款
  12280. foreach ( $waste ['bank'] as $key => $value ) {
  12281. // 收入
  12282. foreach ( $inComeStatistics ['incomeStatistics'] as $k => $v ) {
  12283. // 广发
  12284. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12285. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12286. }
  12287. // 工商
  12288. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12289. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12290. }
  12291. // 华润
  12292. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12293. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12294. }
  12295. // 个人
  12296. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12297. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12298. }
  12299. }
  12300. }
  12301. foreach ( $waste ['bank'] as $key => $value ) {
  12302. // 支出
  12303. foreach ( $inComeStatistics ['expenditureStatistics'] as $k => $v ) {
  12304. // 广发
  12305. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12306. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12307. }
  12308. // 工商
  12309. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12310. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12311. }
  12312. // 华润
  12313. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12314. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12315. }
  12316. // 个人
  12317. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12318. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12319. }
  12320. }
  12321. }
  12322. // 活期
  12323. foreach ( $waste ['financial'] ['current'] as $key => $value ) {
  12324. foreach ( $inComeStatistics ['currentStatistics'] as $k => $v ) {
  12325. // 广发
  12326. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12327. $waste ['financial'] ['current'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  12328. }
  12329. // 工商
  12330. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12331. $waste ['financial'] ['current'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  12332. }
  12333. // 个人
  12334. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12335. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  12336. }
  12337. }
  12338. }
  12339. // print_r($inComeStatistics ['fixedStatistics']);
  12340. // 固期
  12341. foreach ( $waste ['financial'] ['fixed'] as $key => $value ) {
  12342. foreach ( $inComeStatistics ['fixedStatistics'] as $k => $v ) {
  12343. // 广发
  12344. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12345. $waste ['financial'] ['fixed'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  12346. }
  12347. // 工商
  12348. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12349. $waste ['financial'] ['fixed'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  12350. }
  12351. // 个人
  12352. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12353. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  12354. }
  12355. }
  12356. }
  12357. return $waste;
  12358. }
  12359. function lyt() {
  12360. Doo::loadModel ( "receiptDetail" );
  12361. $receiptDetail = new receiptDetail ();
  12362. $receiptCollectList = $receiptDetail->find ( array (
  12363. 'where' => 'status=1 ',
  12364. 'asArray' => true
  12365. ) );
  12366. foreach ( $receiptCollectList as $key => $value ) {
  12367. $receiptDetail = new receiptDetail ();
  12368. $receiptDetail->pastDate = $value ['date'];
  12369. $receiptDetail->update ( array (
  12370. 'where' => "rdid= '" . $value ['rdid'] . "'"
  12371. ) );
  12372. }
  12373. }
  12374. function staffCollectMonthDetail() {
  12375. //include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  12376. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12377. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12378. if (! $year)
  12379. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12380. if (! $month)
  12381. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12382. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  12383. if (! $nature){
  12384. $nature = isset ( $this->params ['nature'] ) ? $this->params ['nature'] : 'ONJOB';
  12385. }
  12386. Doo::loadModel ( 'staff' );
  12387. $staff = new staff ();
  12388. Doo::loadModel ( "receiptDetail" );
  12389. $receiptDetail = new receiptDetail ();
  12390. Doo::loadModel ( 'accountItem' );
  12391. $accountItem = new accountItem ();
  12392. Doo::loadModel ( 'statistics' );
  12393. $statistics = new statistics ();
  12394. Doo::loadModel ( "receiptAuthorityManage" );
  12395. $receiptAuthorityManage = new receiptAuthorityManage ();
  12396. $aiList=$accountItem->getAccountItem();
  12397. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  12398. $cidList = array ();
  12399. foreach ( $imcStaff as $key => $value ) {
  12400. array_push ( $cidList, $value ['cid'] );
  12401. }
  12402. $cidString = implode ( ',', $cidList );
  12403. $naturecon='';
  12404. if ($nature=='ONJOB'){
  12405. $naturecon=' and (nature!=4 )';
  12406. }elseif($nature=='LEAVEJOB'){
  12407. $naturecon=' and (nature=4 )';
  12408. }else{
  12409. die ( 'illegal request--nature' );
  12410. }
  12411. $staffList = $staff->find ( array (
  12412. 'where' => 'username!="admin" and cid in (' . $cidString . ')'.$naturecon,
  12413. 'asArray' => true
  12414. ) );
  12415. $categoryList = $staff->find ( array (
  12416. 'select' => 'COUNT(*) as count,cid,category',
  12417. 'where' => 'username !="admin" and cid in (' . $cidString . ')'.$naturecon,
  12418. 'groupby' => 'cid',
  12419. 'asArray' => true
  12420. ) );
  12421. $list = array ();
  12422. foreach($aiList as $key=>$value){
  12423. foreach ($value as $v){
  12424. $subtotal[$key][$v['name']]=0;
  12425. }
  12426. }
  12427. foreach ( $categoryList as $vlu ) {
  12428. $s1 = 0;
  12429. $m1 = 0;
  12430. $subtotal[$this->AGENCY]['AGENCY']=$subtotal[$this->TRAVEL]['TRAVEL']=$subtotal[$this->INTTRAIN]['INTTRAIN']=$subtotal[$this->TRAIN]['TRAIN']=$subtotal[$this->OTHER]['OTHER']=0;
  12431. foreach ( $staffList as $value ) {
  12432. if ($vlu ['cid'] == $value ['cid']) {
  12433. // pastDate
  12434. $receiptCollectList = $receiptDetail->find ( array (
  12435. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12436. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12437. 'groupby' => 'item,Month(pastDate),itemCategory',
  12438. 'asArray' => true
  12439. ) );
  12440. if (! empty ( $receiptCollectList )) {
  12441. $receiptL = array (
  12442. '日常相关费用' => array (),
  12443. '差旅相关费用' => array (),
  12444. '内部培训费用' => array (),
  12445. '培训班费用' => array (),
  12446. '其他' => array ()
  12447. );
  12448. $html = "";
  12449. $psum = 0;
  12450. foreach ( $aiList[$this->AGENCY] as $va ) {
  12451. $falg = true;
  12452. foreach ( $receiptCollectList as $v ) {
  12453. if ($v ['itemCategory'] == '日常相关费用') {
  12454. if ($v ['item'] == $va['name']) {
  12455. $subtotal[$this->AGENCY][$va['name']]+=$v ['price'];
  12456. $psum += $v ['price'];
  12457. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12458. $falg = false;
  12459. break;
  12460. }
  12461. }
  12462. }
  12463. if ($falg)
  12464. $html .= '<td class="taR">-</td>';
  12465. }
  12466. $subtotal[$this->AGENCY]['AGENCY'] += $psum;
  12467. if (! empty ( $psum ))
  12468. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12469. else
  12470. $psum = '<td class="colGreen taR">-</td>';
  12471. $receiptL ['日常相关费用'] = $psum . $html;
  12472. /* ----------------------------------- */
  12473. $html = "";
  12474. $psum = 0;
  12475. foreach ( $aiList[$this->TRAVEL] as $va ) {
  12476. $falg = true;
  12477. foreach ( $receiptCollectList as $v ) {
  12478. if ($v ['itemCategory'] == '差旅相关费用') {
  12479. if ($v ['item'] == $va['name']) {
  12480. $subtotal[$this->TRAVEL][$va['name']]+=$v ['price'];
  12481. $psum += $v ['price'];
  12482. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12483. $falg = false;
  12484. break;
  12485. }
  12486. }
  12487. }
  12488. if ($falg)
  12489. $html .= '<td class="taR">-</td>';
  12490. }
  12491. $subtotal[$this->TRAVEL]['TRAVEL'] += $psum;
  12492. if (! empty ( $psum ))
  12493. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12494. else
  12495. $psum = '<td class="colGreen taR">-</td>';
  12496. $receiptL ['差旅相关费用'] = $psum . $html;
  12497. /* ------------------------------------- */
  12498. $html = "";
  12499. $psum = 0;
  12500. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  12501. $falg = true;
  12502. foreach ( $receiptCollectList as $v ) {
  12503. if ($v ['itemCategory'] == '内部培训费用') {
  12504. if ($v ['item'] == $va['name']) {
  12505. $subtotal[$this->INTTRAIN][$va['name']]+=$v ['price'];
  12506. $psum += $v ['price'];
  12507. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12508. $falg = false;
  12509. break;
  12510. }
  12511. }
  12512. }
  12513. if ($falg)
  12514. $html .= '<td class="taR">-</td>';
  12515. }
  12516. $subtotal[$this->INTTRAIN]['INTTRAIN'] += $psum;
  12517. if (! empty ( $psum ))
  12518. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12519. else
  12520. $psum = '<td class="colGreen taR">-</td>';
  12521. $receiptL ['内部培训费用'] = $psum . $html;
  12522. /* ----------------------------------- */
  12523. $html = "";
  12524. $psum = 0;
  12525. foreach ( $aiList[$this->TRAIN] as $va ) {
  12526. $falg = true;
  12527. foreach ( $receiptCollectList as $v ) {
  12528. if ($v ['itemCategory'] == '培训班费用') {
  12529. if ($v ['item'] == $va['name']) {
  12530. $subtotal[$this->TRAIN][$va['name']]+=$v ['price'];
  12531. $psum += $v ['price'];
  12532. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12533. $falg = false;
  12534. break;
  12535. }
  12536. }
  12537. }
  12538. if ($falg)
  12539. $html .= '<td class="taR">-</td>';
  12540. }
  12541. $subtotal[$this->TRAIN]['TRAIN'] += $psum;
  12542. if (! empty ( $psum ))
  12543. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12544. else
  12545. $psum = '<td class="colGreen taR">-</td>';
  12546. $receiptL ['培训班费用'] = $psum . $html;
  12547. /* ------------------------------------- */
  12548. $html = "";
  12549. $psum = 0;
  12550. foreach ( $aiList[$this->OTHER] as $va ) {
  12551. $falg = true;
  12552. foreach ( $receiptCollectList as $v ) {
  12553. if ($v ['itemCategory'] == '其他') {
  12554. if (trim ( $v ['item'] ) == $va['name']) {
  12555. $subtotal[$this->OTHER][$va['name']]+=$v ['price'];
  12556. $psum += $v ['price'];
  12557. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12558. $falg = false;
  12559. break;
  12560. }
  12561. }
  12562. }
  12563. if ($falg)
  12564. $html .= '<td class="taR">-</td>';
  12565. }
  12566. $subtotal[$this->OTHER]['OTHER'] += $psum;
  12567. if (! empty ( $psum ))
  12568. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12569. else
  12570. $psum = '<td class="colGreen taR">-</td>';
  12571. $receiptL ['其他'] = $psum . $html;
  12572. /* ------------------------------------- */
  12573. $html = "";
  12574. $psum = 0;
  12575. foreach ( $receiptCollectList as $v ) {
  12576. if ($v ['itemCategory'] == '报销金额调整') {
  12577. if (! empty ( $v ['price'] )) {
  12578. $psum += $v ['price'];
  12579. }
  12580. }
  12581. }
  12582. $s1 += $psum;
  12583. if (! empty ( $psum ))
  12584. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  12585. else
  12586. $psum = '<td class="taR colOrange">-</td>';
  12587. $receiptL ['报销金额调整'] = $psum . $html;
  12588. } else {
  12589. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  12590. foreach ( $aiList[$this->AGENCY] as $va ) {
  12591. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  12592. }
  12593. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  12594. foreach ( $aiList[$this->TRAVEL] as $va ) {
  12595. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  12596. }
  12597. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  12598. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  12599. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  12600. }
  12601. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  12602. foreach ( $aiList[$this->TRAIN] as $va ) {
  12603. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  12604. }
  12605. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  12606. foreach ( $aiList[$this->OTHER] as $va ) {
  12607. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  12608. }
  12609. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  12610. }
  12611. $monthStaffPrice = $receiptDetail->find ( array (
  12612. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12613. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12614. 'groupby' => 'Month(pastDate)',
  12615. 'asArray' => true
  12616. ) );
  12617. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  12618. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  12619. $m1 += $monthStaffPrice [0] ['price'];
  12620. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  12621. } else
  12622. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  12623. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  12624. $list [$value ['username']] = $receiptL;
  12625. }
  12626. }
  12627. $receiptL [$this->AGENCY] ='<td class="colGreen taR">'.$subtotal[$this->AGENCY]['AGENCY'].'</td>';
  12628. foreach ( $aiList[$this->AGENCY] as $va ) {
  12629. $receiptL [$this->AGENCY] .='<td class="taR">' . $subtotal[$this->AGENCY][$va['name']] . '</td>';
  12630. $subtotal[$this->AGENCY][$va['name']]=0;
  12631. }
  12632. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">'.$subtotal[$this->TRAVEL]['TRAVEL'].'</td>';
  12633. foreach ( $aiList[$this->TRAVEL] as $va ) {
  12634. $receiptL [$this->TRAVEL] .='<td class="taR">' . $subtotal[$this->TRAVEL][$va['name']] . '</td>';
  12635. $subtotal[$this->TRAVEL][$va['name']]=0;
  12636. }
  12637. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">'.$subtotal[$this->INTTRAIN]['INTTRAIN'].'</td>';
  12638. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  12639. $receiptL [$this->INTTRAIN] .='<td class="taR">' . $subtotal[$this->INTTRAIN][$va['name']] . '</td>';
  12640. $subtotal[$this->INTTRAIN][$va['name']]=0;
  12641. }
  12642. $receiptL [$this->TRAIN] ='<td class="colGreen taR">'.$subtotal[$this->TRAIN]['TRAIN'].'</td>';
  12643. foreach ( $aiList[$this->TRAIN] as $va ) {
  12644. $receiptL [$this->TRAIN] .='<td class="taR">' . $subtotal[$this->TRAIN][$va['name']] . '</td>';
  12645. $subtotal[$this->TRAIN][$va['name']]=0;
  12646. }
  12647. $receiptL [$this->OTHER] ='<td class="colGreen taR">'.$subtotal[$this->OTHER]['OTHER'].'</td>';
  12648. foreach ( $aiList[$this->OTHER] as $va ) {
  12649. $receiptL [$this->OTHER] .='<td class="taR">' . $subtotal[$this->OTHER][$va['name']] . '</td>';
  12650. $subtotal[$this->OTHER][$va['name']]=0;
  12651. }
  12652. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  12653. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  12654. $receiptL ['usernameEn'] =false;
  12655. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  12656. }
  12657. $data ['list'] = $list;
  12658. // print_r($list);
  12659. $receiptCollectList = $receiptDetail->find ( array (
  12660. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12661. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12662. 'groupby' => 'item,Month(pastDate),itemCategory',
  12663. 'asArray' => true
  12664. ) );
  12665. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  12666. // statistics html
  12667. $stList = $statistics->getOne ( array (
  12668. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  12669. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  12670. 'groupby' => 'Month(date)',
  12671. 'asArray' => true
  12672. ) );
  12673. if (empty ( $stList ))
  12674. $stList = array (
  12675. 'rePrice' => 0,
  12676. 'agPrice' => 0
  12677. );
  12678. $data ['stList'] = array (
  12679. 'rePrice' => $stList ['rePrice'],
  12680. 'agPrice' => $stList ['agPrice'],
  12681. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12682. );
  12683. $monthHtml = "";
  12684. for($i = 1; $i <= 12; $i ++) {
  12685. if ($i == $month)
  12686. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  12687. else
  12688. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  12689. }
  12690. $data ['monthHtml'] = $monthHtml;
  12691. $data ['year'] = $year;
  12692. $data ['month'] = $month;
  12693. $data ['nature'] = $nature;
  12694. $data ['aiList'] = $aiList;
  12695. $data ['memu'] = "receipt";
  12696. $data ['staff'] = $this->staff;
  12697. $data ['receiptMemu'] = 'companyCategoryCollect';
  12698. $data ['verifyId'] = $this->verifyId;
  12699. $data ['executeId'] = $this->executeId;
  12700. $this->render ( "/admin/staffCollectMonthDetail", $data );
  12701. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  12702. }
  12703. function staffCollectMonthDetail2() {
  12704. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12705. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12706. if (! $year)
  12707. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12708. if (! $month)
  12709. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12710. Doo::loadModel ( 'staff' );
  12711. $staff = new staff ();
  12712. Doo::loadModel ( "receiptDetail" );
  12713. $receiptDetail = new receiptDetail ();
  12714. Doo::loadModel ( 'accountItem' );
  12715. $accountItem = new accountItem ();
  12716. Doo::loadModel ( 'statistics' );
  12717. $statistics = new statistics ();
  12718. Doo::loadModel ( 'L_category' );
  12719. $lCategory = new L_category ();
  12720. $staffList = $staff->find ( array (
  12721. 'where' => 'username!="admin"',
  12722. 'asArray' => true
  12723. ) );
  12724. $categoryList = $staff->find ( array (
  12725. 'select' => 'COUNT(*) as count,cid,category',
  12726. 'where' => 'username !="admin"',
  12727. 'groupby' => 'cid',
  12728. 'asArray' => true
  12729. ) );
  12730. $list = array ();
  12731. foreach ( $categoryList as $vlu ) {
  12732. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  12733. $r1 = 0;
  12734. $r2 = 0;
  12735. $r3 = 0;
  12736. $r4 = 0;
  12737. $r5 = 0;
  12738. $r6 = 0;
  12739. $r7 = 0;
  12740. $r8 = 0;
  12741. $r9 = 0;
  12742. $r10 = 0;
  12743. $r11 = 0;
  12744. $r12 = 0;
  12745. $r13 = 0;
  12746. $r14 = 0;
  12747. $r15 = 0;
  12748. $c1 = 0;
  12749. $c2 = 0;
  12750. $c3 = 0;
  12751. $c4 = 0;
  12752. $c5 = 0;
  12753. $c6 = 0;
  12754. $p1 = 0;
  12755. $p2 = 0;
  12756. $p3 = 0;
  12757. $p4 = 0;
  12758. $p5 = 0;
  12759. $p6 = 0;
  12760. $p7 = 0;
  12761. $p8 = 0;
  12762. $p9 = 0;
  12763. $t1 = 0;
  12764. $t2 = 0;
  12765. $t3 = 0;
  12766. $t4 = 0;
  12767. $t5 = 0;
  12768. $s1 = 0;
  12769. $m1 = 0;
  12770. foreach ( $staffList as $value ) {
  12771. if ($vlu ['cid'] == $value ['cid']) {
  12772. $receiptCollectList = $receiptDetail->find ( array (
  12773. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  12774. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  12775. 'groupby' => 'item,Month(date),itemCategory',
  12776. 'asArray' => true
  12777. ) );
  12778. if (! empty ( $receiptCollectList )) {
  12779. $receiptL = array (
  12780. '日常相关费用' => array (),
  12781. '差旅相关费用' => array (),
  12782. '培训班费用' => array (),
  12783. '其他' => array ()
  12784. );
  12785. $html = "";
  12786. $psum = 0;
  12787. $item = array (
  12788. '市内交通费',
  12789. '市内出租费',
  12790. '办事处房租',
  12791. '电话费',
  12792. '水费',
  12793. '电费',
  12794. '办公费用',
  12795. '邮寄费',
  12796. '其他费用',
  12797. '车辆费用',
  12798. '广告费',
  12799. '团队建设费',
  12800. '物业管理费',
  12801. '宽带费'
  12802. );
  12803. foreach ( $item as $va ) {
  12804. $falg = true;
  12805. foreach ( $receiptCollectList as $v ) {
  12806. if ($v ['itemCategory'] == '日常相关费用') {
  12807. if ($v ['item'] == $va) {
  12808. if ($va == '市内交通费')
  12809. $r1 += $v ['price'];
  12810. if ($va == '市内出租费')
  12811. $r2 += $v ['price'];
  12812. if ($va == '办事处房租')
  12813. $r3 += $v ['price'];
  12814. if ($va == '电话费')
  12815. $r4 += $v ['price'];
  12816. if ($va == '水费')
  12817. $r5 += $v ['price'];
  12818. if ($va == '电费')
  12819. $r6 += $v ['price'];
  12820. if ($va == '办公费用')
  12821. $r7 += $v ['price'];
  12822. if ($va == '邮寄费')
  12823. $r8 += $v ['price'];
  12824. if ($va == '其他费用')
  12825. $r9 += $v ['price'];
  12826. if ($va == '车辆费用')
  12827. $r10 += $v ['price'];
  12828. if ($va == '广告费')
  12829. $r11 += $v ['price'];
  12830. if ($va == '团队建设费')
  12831. $r13 += $v ['price'];
  12832. if ($va == '物业管理费')
  12833. $r14 += $v ['price'];
  12834. if ($va == '宽带费')
  12835. $r15 += $v ['price'];
  12836. $psum += $v ['price'];
  12837. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12838. $falg = false;
  12839. break;
  12840. }
  12841. }
  12842. }
  12843. if ($falg)
  12844. $html .= '<td class="taR">-</td>';
  12845. }
  12846. $r12 += $psum;
  12847. if (! empty ( $psum ))
  12848. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12849. else
  12850. $psum = '<td class="colGreen taR">-</td>';
  12851. $receiptL ['日常相关费用'] = $psum . $html;
  12852. /* ----------------------------------- */
  12853. $html = "";
  12854. $psum = 0;
  12855. $item = array (
  12856. '往来交通费',
  12857. '市内交通费',
  12858. '出差住宿费',
  12859. '出差补助',
  12860. '其他费用'
  12861. );
  12862. foreach ( $item as $va ) {
  12863. $falg = true;
  12864. foreach ( $receiptCollectList as $v ) {
  12865. if ($v ['itemCategory'] == '差旅相关费用') {
  12866. if ($v ['item'] == $va) {
  12867. if ($va == '往来交通费')
  12868. $c1 += $v ['price'];
  12869. if ($va == '市内交通费')
  12870. $c2 += $v ['price'];
  12871. if ($va == '出差住宿费')
  12872. $c3 += $v ['price'];
  12873. if ($va == '出差补助')
  12874. $c4 += $v ['price'];
  12875. if ($va == '其他费用')
  12876. $c5 += $v ['price'];
  12877. $psum += $v ['price'];
  12878. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12879. $falg = false;
  12880. break;
  12881. }
  12882. }
  12883. }
  12884. if ($falg)
  12885. $html .= '<td class="taR">-</td>';
  12886. }
  12887. $c6 += $psum;
  12888. if (! empty ( $psum ))
  12889. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12890. else
  12891. $psum = '<td class="colGreen taR">-</td>';
  12892. $receiptL ['差旅相关费用'] = $psum . $html;
  12893. /* ------------------------------------- */
  12894. $html = "";
  12895. $psum = 0;
  12896. $item = array (
  12897. '场租费',
  12898. '薪酬',
  12899. '住宿费',
  12900. '交通费',
  12901. '餐饮费',
  12902. '办公费',
  12903. '公关费',
  12904. '其他'
  12905. );
  12906. foreach ( $item as $va ) {
  12907. $falg = true;
  12908. foreach ( $receiptCollectList as $v ) {
  12909. if ($v ['itemCategory'] == '培训班费用') {
  12910. if ($v ['item'] == $va) {
  12911. if ($va == '场租费')
  12912. $p1 += $v ['price'];
  12913. if ($va == '薪酬')
  12914. $p2 += $v ['price'];
  12915. if ($va == '住宿费')
  12916. $p3 += $v ['price'];
  12917. if ($va == '交通费')
  12918. $p4 += $v ['price'];
  12919. if ($va == '餐饮费')
  12920. $p5 += $v ['price'];
  12921. if ($va == '办公费')
  12922. $p6 += $v ['price'];
  12923. if ($va == '公关费')
  12924. $p7 += $v ['price'];
  12925. if ($va == '其他')
  12926. $p8 += $v ['price'];
  12927. $psum += $v ['price'];
  12928. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12929. $falg = false;
  12930. break;
  12931. }
  12932. }
  12933. }
  12934. if ($falg)
  12935. $html .= '<td class="taR">-</td>';
  12936. }
  12937. $p9 += $psum;
  12938. if (! empty ( $psum ))
  12939. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12940. else
  12941. $psum = '<td class="colGreen taR">-</td>';
  12942. $receiptL ['培训班费用'] = $psum . $html;
  12943. /* ------------------------------------- */
  12944. $html = "";
  12945. $psum = 0;
  12946. $item = array (
  12947. '公关费',
  12948. '广告费',
  12949. '借款',
  12950. '可自加费用'
  12951. );
  12952. foreach ( $item as $va ) {
  12953. $falg = true;
  12954. foreach ( $receiptCollectList as $v ) {
  12955. if ($v ['itemCategory'] == '其他') {
  12956. if ($v ['item'] == $va) {
  12957. if ($va == '公关费')
  12958. $t1 += $v ['price'];
  12959. if ($va == '广告费')
  12960. $t2 += $v ['price'];
  12961. if ($va == '借款')
  12962. $t3 += $v ['price'];
  12963. if ($va == '可自加费用')
  12964. $t4 += $v ['price'];
  12965. $psum += $v ['price'];
  12966. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12967. $falg = false;
  12968. break;
  12969. }
  12970. }
  12971. }
  12972. if ($falg)
  12973. $html .= '<td class="taR">-</td>';
  12974. }
  12975. $t5 += $psum;
  12976. if (! empty ( $psum ))
  12977. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12978. else
  12979. $psum = '<td class="colGreen taR">-</td>';
  12980. $receiptL ['其他'] = $psum . $html;
  12981. /* ------------------------------------- */
  12982. $html = "";
  12983. $psum = 0;
  12984. foreach ( $receiptCollectList as $v ) {
  12985. if ($v ['itemCategory'] == '报销金额调整') {
  12986. if (! empty ( $v ['price'] )) {
  12987. $psum += $v ['price'];
  12988. }
  12989. }
  12990. }
  12991. $s1 += $psum;
  12992. if (! empty ( $psum ))
  12993. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  12994. else
  12995. $psum = '<td class="taR colOrange">-</td>';
  12996. $receiptL ['报销金额调整'] = $psum . $html;
  12997. } else {
  12998. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  12999. <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>';
  13000. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  13001. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13002. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13003. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13004. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13005. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13006. }
  13007. $monthStaffPrice = $receiptDetail->find ( array (
  13008. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13009. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13010. 'asArray' => true
  13011. ) );
  13012. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  13013. $m1 += $monthStaffPrice [0] ['price'];
  13014. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13015. } else
  13016. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13017. $list [$value ['username']] = $receiptL;
  13018. }
  13019. }
  13020. $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>
  13021. <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>
  13022. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  13023. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  13024. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  13025. $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>
  13026. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  13027. $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>';
  13028. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  13029. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  13030. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  13031. }
  13032. $data ['list'] = $list;
  13033. $receiptCollectList = $receiptDetail->find ( array (
  13034. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13035. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13036. 'groupby' => 'item,Month(date),itemCategory',
  13037. 'asArray' => true
  13038. ) );
  13039. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  13040. // statistics html
  13041. $stList = $statistics->getOne ( array (
  13042. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13043. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13044. 'groupby' => 'Month(date)',
  13045. 'asArray' => true
  13046. ) );
  13047. if (empty ( $stList ))
  13048. $stList = array (
  13049. 'rePrice' => 0,
  13050. 'agPrice' => 0
  13051. );
  13052. $data ['stList'] = array (
  13053. 'rePrice' => $stList ['rePrice'],
  13054. 'agPrice' => $stList ['agPrice'],
  13055. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13056. );
  13057. $monthHtml = "";
  13058. for($i = 1; $i <= 12; $i ++) {
  13059. if ($i == $month)
  13060. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13061. else
  13062. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13063. }
  13064. $data ['monthHtml'] = $monthHtml;
  13065. $data ['year'] = $year;
  13066. $data ['month'] = $month;
  13067. $data ['memu'] = "receipt";
  13068. $data ['staff'] = $this->staff;
  13069. $data ['receiptMemu'] = 'companyCategoryCollect';
  13070. $data ['verifyId'] = $this->verifyId;
  13071. $data ['executeId'] = $this->executeId;
  13072. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  13073. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13074. }
  13075. /**
  13076. * 用户报销单列表
  13077. */
  13078. function receiptStatisticsStaffDetail() {
  13079. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13080. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13081. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13082. Doo::loadModel ( "receipt" );
  13083. $receipt = new receipt ();
  13084. Doo::loadModel ( "receiptDetail" );
  13085. $receiptDetail = new receiptDetail ();
  13086. Doo::loadModel ( 'staff' );
  13087. $staff = new staff ();
  13088. Doo::loadModel ( 'accountItem' );
  13089. $accountItem = new accountItem ();
  13090. Doo::loadModel ( 'statistics' );
  13091. $statistics = new statistics ();
  13092. if (! empty ( $username )) {
  13093. $username = addslashes ( urldecode ( $username ) );
  13094. $staffDetail = $staff->getStaffByName ( $username );
  13095. if (empty ( $staffDetail ))
  13096. die ( 'illegal request' );
  13097. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  13098. $itemList = $accountItem->getAccountItem ();
  13099. $itemHtml = '';
  13100. $categoryHtml = '';
  13101. $itemKeyList = array_keys ( $itemList );
  13102. $revisePrice = 0;
  13103. // 报销单内容详情
  13104. foreach ( $list as $key => $value ) {
  13105. $accountItemList = json_decode ( $value ['accountItem'], true );
  13106. $list [$key] ['accountItemList'] = $accountItemList;
  13107. $receiptItemHtml = '';
  13108. foreach ( $itemKeyList as $v ) {
  13109. if ($v == '日常相关费用')
  13110. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  13111. elseif ($v == '差旅相关费用')
  13112. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  13113. elseif ($v == '培训班费用')
  13114. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  13115. elseif ($v == '内部培训费用'){
  13116. if (isset($accountItemList ['cSum'] ['inttrainSum'])){
  13117. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['inttrainSum'] . '</td>';
  13118. }else{
  13119. $receiptItemHtml .= '<td class="colGreen taR">0</td>';
  13120. }
  13121. }elseif ($v == '其他')
  13122. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  13123. foreach ( $itemList [$v] as $ke => $va ) {
  13124. $falg = true;
  13125. if (! empty ( $accountItemList [$v] )) {
  13126. foreach ( $accountItemList [$v] as $ve ) {
  13127. if ($va ['name'] == $ve ['name']) {
  13128. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  13129. $falg = false;
  13130. break;
  13131. }
  13132. }
  13133. }
  13134. if ($falg)
  13135. $receiptItemHtml .= '<td class="taR"></td>';
  13136. }
  13137. }
  13138. // 金额调整和费用查看
  13139. $revisePrice += $value ['revisePrice'];
  13140. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  13141. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" id="sen'.$key.'" data="' . htmlspecialchars($value ['explanation']) . '" onclick=showExplanation() >查看</a></td>';
  13142. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  13143. }
  13144. // 报销单合计
  13145. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  13146. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  13147. $receiptTotalHtml = '';
  13148. // 报销单项目抬头
  13149. foreach ( $itemKeyList as $value ) {
  13150. $count = count ( $itemList [$value] ) + 1;
  13151. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  13152. $categoryHtml .= '<th class="taC">合计</th>';
  13153. $sumfalg=true;
  13154. foreach ( $rtl as $rtlValue ) {
  13155. if ($rtlValue ['itemCategory'] == $value) {
  13156. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  13157. $sumfalg=false;
  13158. break;
  13159. }
  13160. }
  13161. if ($sumfalg)
  13162. $receiptTotalHtml .= '<th></th>';
  13163. foreach ( $itemList [$value] as $k => $v ) {
  13164. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  13165. // 合计
  13166. $falg = true;
  13167. foreach ( $receiptTotalList as $ve ) {
  13168. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  13169. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  13170. $falg = false;
  13171. break;
  13172. }
  13173. }
  13174. if ($falg)
  13175. $receiptTotalHtml .= '<th></th>';
  13176. }
  13177. }
  13178. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  13179. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  13180. if (empty ( $stList ))
  13181. $stList = array (
  13182. 'rePrice' => 0,
  13183. 'agPrice' => 0
  13184. );
  13185. $data ['stList'] = array (
  13186. 'rePrice' => $stList ['rePrice'],
  13187. 'agPrice' => $stList ['agPrice'],
  13188. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13189. );
  13190. $monthHtml = "";
  13191. for($i = 1; $i <= 12; $i ++) {
  13192. if ($i == $month)
  13193. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13194. else
  13195. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13196. }
  13197. $data ['username'] = urlencode ( $username );
  13198. $data ['usernameEN'] = $username;
  13199. $data ['monthHtml'] = $monthHtml;
  13200. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  13201. $data ['list'] = $list;
  13202. $data ['categoryHtml'] = $categoryHtml;
  13203. $data ['itemHtml'] = $itemHtml;
  13204. $data ['itemList'] = $itemList;
  13205. $data ['year'] = $year;
  13206. $data ['month'] = $month;
  13207. $data ['memu'] = "receipt";
  13208. $data ['staff'] = $this->staff;
  13209. $data ['receiptMemu'] = 'companyCategoryCollect';
  13210. $data ['verifyId'] = $this->verifyId;
  13211. $data ['executeId'] = $this->executeId;
  13212. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  13213. }
  13214. die ( 'illegal request' );
  13215. }
  13216. function companyMonthCollectDetail() {
  13217. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13218. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13219. if (! $year)
  13220. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13221. if (! $month)
  13222. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13223. Doo::loadModel ( 'staff' );
  13224. $staff = new staff ();
  13225. Doo::loadModel ( "receiptDetail" );
  13226. $receiptDetail = new receiptDetail ();
  13227. Doo::loadModel ( 'accountItem' );
  13228. $accountItem = new accountItem ();
  13229. Doo::loadModel ( 'statistics' );
  13230. $statistics = new statistics ();
  13231. Doo::loadModel ( 'L_category' );
  13232. $lCategory = new L_category ();
  13233. $staffList = $staff->find ( array (
  13234. 'where' => 'username!="admin"',
  13235. 'asArray' => true
  13236. ) );
  13237. $categoryList = $lCategory->find ( array (
  13238. 'asArray' => true
  13239. ) );
  13240. $aiList=$accountItem->getAccountItem();
  13241. $list = array ();
  13242. foreach ( $categoryList as $value ) {
  13243. $receiptCollectList = $receiptDetail->find ( array (
  13244. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13245. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13246. 'groupby' => 'item,Month(pastDate),itemCategory',
  13247. 'asArray' => true
  13248. ) );
  13249. if (! empty ( $receiptCollectList )) {
  13250. $receiptL = array (
  13251. '日常相关费用' => array (),
  13252. '差旅相关费用' => array (),
  13253. '内部培训费用' => array (),
  13254. '培训班费用' => array (),
  13255. '其他' => array ()
  13256. );
  13257. $html = "";
  13258. $psum = 0;
  13259. foreach ( $aiList[$this->AGENCY] as $va ) {
  13260. $falg = true;
  13261. foreach ( $receiptCollectList as $v ) {
  13262. if ($v ['itemCategory'] == $this->AGENCY) {
  13263. if ($v ['item'] == $va['name']) {
  13264. $psum += $v ['price'];
  13265. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13266. $falg = false;
  13267. break;
  13268. }
  13269. }
  13270. }
  13271. if ($falg)
  13272. $html .= '<td class="taR">-</td>';
  13273. }
  13274. if (! empty ( $psum ))
  13275. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13276. else
  13277. $psum = '<td class="colGreen taR">-</td>';
  13278. $receiptL [$this->AGENCY] = $psum . $html;
  13279. /* ----------------------------------- */
  13280. $html = "";
  13281. $psum = 0;
  13282. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13283. $falg = true;
  13284. foreach ( $receiptCollectList as $v ) {
  13285. if ($v ['itemCategory'] == $this->TRAVEL) {
  13286. if ($v ['item'] == $va['name']) {
  13287. $psum += $v ['price'];
  13288. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13289. $falg = false;
  13290. break;
  13291. }
  13292. }
  13293. }
  13294. if ($falg)
  13295. $html .= '<td class="taR">-</td>';
  13296. }
  13297. if (! empty ( $psum ))
  13298. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13299. else
  13300. $psum = '<td class="colGreen taR">-</td>';
  13301. $receiptL [$this->TRAVEL] = $psum . $html;
  13302. /* ------------------------------------- */
  13303. $html = "";
  13304. $psum = 0;
  13305. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13306. $falg = true;
  13307. foreach ( $receiptCollectList as $v ) {
  13308. if ($v ['itemCategory'] == $this->INTTRAIN) {
  13309. if ($v ['item'] == $va['name']) {
  13310. $psum += $v ['price'];
  13311. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13312. $falg = false;
  13313. break;
  13314. }
  13315. }
  13316. }
  13317. if ($falg)
  13318. $html .= '<td class="taR">-</td>';
  13319. }
  13320. if (! empty ( $psum ))
  13321. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13322. else
  13323. $psum = '<td class="colGreen taR">-</td>';
  13324. $receiptL [$this->INTTRAIN] = $psum . $html;
  13325. /* ------------------------------------- */
  13326. $html = "";
  13327. $psum = 0;
  13328. foreach ( $aiList[$this->TRAIN] as $va ) {
  13329. $falg = true;
  13330. foreach ( $receiptCollectList as $v ) {
  13331. if ($v ['itemCategory'] == $this->TRAIN) {
  13332. if ($v ['item'] == $va['name']) {
  13333. $psum += $v ['price'];
  13334. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13335. $falg = false;
  13336. break;
  13337. }
  13338. }
  13339. }
  13340. if ($falg)
  13341. $html .= '<td class="taR">-</td>';
  13342. }
  13343. if (! empty ( $psum ))
  13344. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13345. else
  13346. $psum = '<td class="colGreen taR">-</td>';
  13347. $receiptL [$this->TRAIN] = $psum . $html;
  13348. /* ------------------------------------- */
  13349. $html = "";
  13350. $psum = 0;
  13351. foreach ( $aiList[$this->OTHER] as $va ) {
  13352. $falg = true;
  13353. foreach ( $receiptCollectList as $v ) {
  13354. if ($v ['itemCategory'] == $this->OTHER) {
  13355. if ($v ['item'] == $va['name']) {
  13356. $psum += $v ['price'];
  13357. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13358. $falg = false;
  13359. break;
  13360. }
  13361. }
  13362. }
  13363. if ($falg)
  13364. $html .= '<td class="taR">-</td>';
  13365. }
  13366. if (! empty ( $psum ))
  13367. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13368. else
  13369. $psum = '<td class="colGreen taR">-</td>';
  13370. $receiptL [$this->OTHER] = $psum . $html;
  13371. /* ------------------------------------- */
  13372. $html = "";
  13373. $psum = 0;
  13374. foreach ( $receiptCollectList as $v ) {
  13375. if ($v ['itemCategory'] == '报销金额调整') {
  13376. if (! empty ( $v ['price'] ))
  13377. $psum += $v ['price'];
  13378. }
  13379. }
  13380. if (! empty ( $psum ))
  13381. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  13382. else
  13383. $psum = '<td class="taR colOrange">-</td>';
  13384. $receiptL ['报销金额调整'] = $psum . $html;
  13385. } else {
  13386. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  13387. foreach ( $aiList[$this->AGENCY] as $va ) {
  13388. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  13389. }
  13390. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  13391. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13392. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  13393. }
  13394. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  13395. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13396. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  13397. }
  13398. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  13399. foreach ( $aiList[$this->TRAIN] as $va ) {
  13400. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  13401. }
  13402. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  13403. foreach ( $aiList[$this->OTHER] as $va ) {
  13404. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  13405. }
  13406. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13407. }
  13408. $monthStaffPrice = $receiptDetail->find ( array (
  13409. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13410. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13411. 'asArray' => true
  13412. ) );
  13413. if (! empty ( $monthStaffPrice [0] ['price'] ))
  13414. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13415. else
  13416. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13417. $list [$value ['title']] = $receiptL;
  13418. }
  13419. $data ['list'] = $list;
  13420. $receiptCollectList = $receiptDetail->find ( array (
  13421. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13422. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13423. 'groupby' => 'item,Month(pastDate),itemCategory',
  13424. 'asArray' => true
  13425. ) );
  13426. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  13427. //print_r($data['monthPriceHtml']);
  13428. // foreach ($data['monthPriceHtml'] as $value){
  13429. // echo $value;
  13430. // }
  13431. // die;
  13432. // statistics html
  13433. $stList = $statistics->getOne ( array (
  13434. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13435. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13436. 'groupby' => 'Month(date)',
  13437. 'asArray' => true
  13438. ) );
  13439. if (empty ( $stList ))
  13440. $stList = array (
  13441. 'rePrice' => 0,
  13442. 'agPrice' => 0
  13443. );
  13444. $data ['stList'] = array (
  13445. 'rePrice' => $stList ['rePrice'],
  13446. 'agPrice' => $stList ['agPrice'],
  13447. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13448. );
  13449. $monthHtml = "";
  13450. for($i = 1; $i <= 12; $i ++) {
  13451. if ($i == $month)
  13452. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13453. else
  13454. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13455. }
  13456. $data ['aiList'] = $aiList;
  13457. $dateHtml = "";
  13458. $now = date ( "Y" );
  13459. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  13460. if ($YEARD <= $now) {
  13461. $dateHtml .= '<option ';
  13462. if ($year == $YEARD) {
  13463. $dateHtml .= 'selected ';
  13464. }
  13465. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  13466. }
  13467. }
  13468. $data ['dateHtml'] = $dateHtml;
  13469. $data ['monthHtml'] = $monthHtml;
  13470. $data ['year'] = $year;
  13471. $data ['month'] = $month;
  13472. $data ['memu'] = "receipt";
  13473. $data ['staff'] = $this->staff;
  13474. $data ['receiptMemu'] = 'companyCategoryCollect';
  13475. $data ['verifyId'] = $this->verifyId;
  13476. $data ['executeId'] = $this->executeId;
  13477. $this->render ( "/admin/companyMonthCollectDetail", $data );
  13478. }
  13479. function staffCollectDetail() {
  13480. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  13481. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13482. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  13483. if (! $staffname) {
  13484. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  13485. $staffname = urldecode ( $staffname );
  13486. }
  13487. Doo::loadModel ( 'staff' );
  13488. $staff = new staff ();
  13489. Doo::loadModel ( "receiptDetail" );
  13490. $receiptDetail = new receiptDetail ();
  13491. Doo::loadModel ( 'accountItem' );
  13492. $accountItem = new accountItem ();
  13493. Doo::loadModel ( 'statistics' );
  13494. $statistics = new statistics ();
  13495. Doo::loadModel ( 'L_category' );
  13496. $lCategory = new L_category ();
  13497. Doo::loadModel ( "receiptAuthorityManage" );
  13498. $receiptAuthorityManage = new receiptAuthorityManage ();
  13499. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  13500. $cidList = array ();
  13501. foreach ( $imcStaff as $key => $value ) {
  13502. array_push ( $cidList, $value ['cid'] );
  13503. }
  13504. $cidString = implode ( ',', $cidList );
  13505. $staffList = $staff->find ( array (
  13506. 'where' => ' cid in (' . $cidString . ')',
  13507. 'asArray' => true
  13508. ) );
  13509. $stHtml = '';
  13510. $stTitle = "";
  13511. $staffId = 0;
  13512. $cid = 0;
  13513. $ocid = 0;
  13514. foreach ( $staffList as $value ) {
  13515. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  13516. $stTitle = $value ['category'] . '-' . $value ['username'];
  13517. $staffId = $value ['sid'];
  13518. $cid = $value ['cid'];
  13519. $ocid = $value ['cid'];
  13520. if (! empty ( $value ['othercid'] ))
  13521. $cid = $value ['cid'] . ',' . $value ['othercid'];
  13522. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13523. } elseif ($value ['username'] != 'admin')
  13524. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13525. }
  13526. $data ['lCategoryHtml'] = $lCategory->find ( array (
  13527. 'where' => 'cid in(' . $cid . ')',
  13528. 'asArray' => true
  13529. ) );
  13530. if (empty ( $pcid ))
  13531. $pcid = $ocid;
  13532. $data ['ocid'] = $pcid;
  13533. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  13534. $this->showCache ( $path );
  13535. //
  13536. $receiptCollectList = $receiptDetail->find ( array (
  13537. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13538. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  13539. 'groupby' => 'item,Month(pastDate),itemCategory',
  13540. 'asArray' => true
  13541. ) );
  13542. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  13543. // print_r($receiptCollectList);
  13544. $accountList = $accountItem->find ( array (
  13545. 'asArray' => true
  13546. ) );
  13547. // create CollectDetail HTML
  13548. $collectHtml = array ();
  13549. foreach ( $accountList as $key => $value ) {
  13550. $html = "";
  13551. $asum = 0;
  13552. for($i = 1; $i <= 12; $i ++) {
  13553. $falg = true;
  13554. foreach ( $receiptCollectList as $v ) {
  13555. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  13556. if ($v ['item'] == '可自加费用') {
  13557. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  13558. }
  13559. $asum += $v ['price'];
  13560. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13561. $falg = false;
  13562. break;
  13563. }
  13564. }
  13565. if ($falg)
  13566. $html .= '<td class="taR">-</td>';
  13567. }
  13568. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  13569. $collectHtml [$value ['category']] [$value ['name']] = $html;
  13570. }
  13571. $data ['collectHtml'] = $collectHtml;
  13572. // print_r($collectHtml);
  13573. // create Adjustment price html
  13574. $receiptCollectList = $receiptDetail->find ( array (
  13575. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  13576. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  13577. 'groupby' => 'itemCategory,Month(pastDate)',
  13578. 'asArray' => true
  13579. ) );
  13580. $adjustment = array ();
  13581. $collectArray = array (
  13582. '日常相关费用' => array (),
  13583. '差旅相关费用' => array (),
  13584. '培训班费用' => array (),
  13585. '内部培训费用'=>array(),
  13586. '其他' => array ()
  13587. );
  13588. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  13589. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  13590. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  13591. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  13592. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  13593. array_push ( $collectArray ['培训班费用'], $collectHtml );
  13594. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  13595. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  13596. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  13597. array_push ( $collectArray ['其他'], $collectHtml );
  13598. $data ['collectArray'] = $collectArray;
  13599. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  13600. array_push ( $adjustment, $collectHtml );
  13601. $data ['adjustment'] = $adjustment;
  13602. // total price html
  13603. $collectHtml = "";
  13604. $total = 0;
  13605. for($i = 1; $i <= 12; $i ++) {
  13606. $sumPrice = 0;
  13607. foreach ( $receiptCollectList as $key => $value ) {
  13608. if ($value ['month'] == $i) {
  13609. $sumPrice += $value ['price'];
  13610. }
  13611. }
  13612. if ($sumPrice == 0)
  13613. $collectHtml .= '<td class="taR">-</td>';
  13614. else
  13615. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  13616. $total += $sumPrice;
  13617. }
  13618. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  13619. // statistics html
  13620. $stList = $statistics->statisticsByYear ( $year, $staffId );
  13621. if (empty ( $stList ))
  13622. $stList = array (
  13623. 'rePrice' => 0,
  13624. 'agPrice' => 0
  13625. );
  13626. $data ['stList'] = array (
  13627. 'rePrice' => $stList ['rePrice'],
  13628. 'agPrice' => $stList ['agPrice'],
  13629. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13630. );
  13631. $data ['totalPrice'] = $collectHtml;
  13632. $data ['totalYear'] = $total;
  13633. $data ['stHtml'] = $stHtml;
  13634. $data ['year'] = $year;
  13635. $data ['stTitle'] = $stTitle;
  13636. $data ['staffname'] = urlencode ( $staffname );
  13637. $data ['memu'] = "receipt";
  13638. $data ['staff'] = $this->staff;
  13639. $data ['receiptMemu'] = 'companyCategoryCollect';
  13640. $data ['verifyId'] = $this->verifyId;
  13641. $data ['executeId'] = $this->executeId;
  13642. if ($year < date ( "Y" )) {
  13643. Doo::loadModel ( 'receipt' );
  13644. $receipt = new receipt ();
  13645. $receiptList = $receipt->find ( array (
  13646. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  13647. 'asArray' => true
  13648. ) );
  13649. if (empty ( $receiptList )) { // generated files
  13650. ob_start ();
  13651. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13652. $this->cacheFile ( $path );
  13653. die ();
  13654. }
  13655. }
  13656. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13657. }
  13658. function BUGFLAG() {
  13659. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  13660. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  13661. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13662. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  13663. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  13664. if (empty ( $status ))
  13665. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  13666. $page_size = 12;
  13667. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  13668. $vidList = array ();
  13669. $button = 0;
  13670. Doo::loadModel ( 'verify' );
  13671. $verify = new verify ();
  13672. Doo::loadModel ( 'receipt' );
  13673. $receipt = new receipt ();
  13674. Doo::loadModel ( 'staff' );
  13675. $staff = new staff ();
  13676. Doo::loadModel ( 'L_category' );
  13677. $Lcategory = new L_category ();
  13678. $dateCondition = " and Year(date) =" . $year;
  13679. if (! empty ( $month ))
  13680. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  13681. $categoryList = $Lcategory->find ( array (
  13682. 'asArray' => true
  13683. ) );
  13684. $staffList = $staff->find ( array (
  13685. 'where' => 'cid=' . $cid,
  13686. 'asArray' => true
  13687. ) );
  13688. $cateCondition = "";
  13689. $staffCondition = "";
  13690. $approvalCondition = "";
  13691. if (! empty ( $cid ))
  13692. $cateCondition = ' and cid=' . $cid;
  13693. if (! empty ( $sid )) {
  13694. $staffCondition = ' and staff=' . $sid;
  13695. $cateCondition = "";
  13696. }
  13697. $approvalCondition = " and status=" . $status;
  13698. if ($status == 2) {
  13699. // 查找角色审批人
  13700. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  13701. }
  13702. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  13703. $approvalCondition = ' and status=2 ';
  13704. }
  13705. if ($status == 1) {
  13706. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  13707. }
  13708. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  13709. $pageinfo ['page'] = array (
  13710. 'previous' => ''
  13711. );
  13712. if ($status == 0) {
  13713. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  13714. $receiptList = $receipt->find ( array (
  13715. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  13716. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  13717. 'desc' => 'rid',
  13718. 'asArray' => true
  13719. ) );
  13720. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  13721. } else
  13722. $receiptList = $receipt->find ( array (
  13723. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  13724. 'desc' => 'rid',
  13725. 'asArray' => true
  13726. ) );
  13727. $rLRes = $receipt->find ( array (
  13728. '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,
  13729. 'desc' => 'rid',
  13730. 'asArray' => true
  13731. ) );
  13732. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  13733. // print_r($pageinfo);
  13734. $Locate = 0;
  13735. foreach ( $receiptList as $key => $value ) {
  13736. $receiptList [$key] ['Locate'] = $Locate;
  13737. $Locate ++;
  13738. $receiptList [$key] ['reviseDetail'] = array ();
  13739. if (! empty ( $value ['reviseDetail'] ))
  13740. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  13741. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  13742. $categoryDetil = $Lcategory->getOne ( array (
  13743. 'where' => 'cid=' . $value ['cid'],
  13744. 'asArray' => true
  13745. ) );
  13746. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  13747. $verifyList = $verify->getOne ( array (
  13748. 'where' => 'vid=' . $value ['verify'],
  13749. 'asArray' => true
  13750. ) );
  13751. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  13752. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  13753. foreach ( $verifyList as $k => $v ) {
  13754. // init verifyStaff
  13755. $verifyList [$k] ['date'] = "";
  13756. $verifyList [$k] ['opinion'] = "";
  13757. $verifyList [$k] ['status'] = "";
  13758. if (empty ( $verifyStaff )) {
  13759. $verifyList [$k] ['date'] = "";
  13760. $verifyList [$k] ['opinion'] = "";
  13761. if ($v [0] == $this->staff [0] ['sid']) {
  13762. $verifyList [$k] ['status'] = 4;
  13763. $button = 4;
  13764. }
  13765. } else {
  13766. $flag = true;
  13767. foreach ( $verifyStaff as $m => $u ) {
  13768. if ($v [0] == $m) {
  13769. $verifyList [$k] ['date'] = $u ['date'];
  13770. $verifyList [$k] ['opinion'] = $u ['opinion'];
  13771. $verifyList [$k] ['status'] = $u ['status'];
  13772. $flag = false;
  13773. break;
  13774. }
  13775. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  13776. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  13777. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  13778. }
  13779. if ($flag) { // 检测可编辑
  13780. if ($v [0] == $this->staff [0] ['sid']) {
  13781. $verifyList [$k] ['status'] = 4;
  13782. $button = 4;
  13783. }
  13784. }
  13785. }
  13786. }
  13787. $receiptList [$key] ['verifyList'] = $verifyList;
  13788. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  13789. 'where' => 'sid=' . $value ['staff'],
  13790. 'asArray' => true
  13791. ) );
  13792. $receiptList [$key] ['button'] = $button;
  13793. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  13794. }
  13795. // print_r($receiptList);die;
  13796. // $data['verifyDetail']=$verifyDetail;
  13797. $mothHtml = "";
  13798. for($i = 1; $i <= 12; $i ++) {
  13799. if ($month == $i)
  13800. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  13801. else
  13802. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  13803. }
  13804. $data ['mothHtml'] = $mothHtml;
  13805. $data ['page'] = $pageinfo;
  13806. $data ['receiptList'] = $receiptList;
  13807. $data ['receiptApprovalCount'] = count ( $rLRes );
  13808. $data ['status'] = $status;
  13809. $data ['year'] = $year;
  13810. $data ['categoryList'] = $categoryList;
  13811. $data ['staffList'] = $staffList;
  13812. $data ['cid'] = $cid;
  13813. $data ['sid'] = $sid;
  13814. // print_r($receiptList);
  13815. $data ['memu'] = "receipt";
  13816. $data ['staff'] = $this->staff;
  13817. $data ['receiptMemu'] = 'approvalExpenses';
  13818. $data ['verifyId'] = $this->verifyId;
  13819. $data ['executeId'] = $this->executeId;
  13820. $this->render ( "/admin/FALG", $data );
  13821. }
  13822. function ajaxGetReceiptOrder() {
  13823. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  13824. if (! empty ( $receiptOrder )) {
  13825. Doo::loadModel ( 'receipt' );
  13826. $receipt = new receipt ();
  13827. Doo::loadModel ( 'staff' );
  13828. $staff = new staff ();
  13829. $receiptInfo = $receipt->getOne ( array (
  13830. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  13831. 'asArray' => true
  13832. ) );
  13833. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  13834. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  13835. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  13836. </tbody></table><table class="table table table-bordered"><tbody>';
  13837. foreach ( $verifyStaff as $key => $value ) {
  13838. $staffInfo = $staff->getOne ( array (
  13839. 'select' => 'username',
  13840. 'where' => ' sid="' . $key . '"',
  13841. 'asArray' => true
  13842. ) );
  13843. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  13844. }
  13845. $html .= '</tbody></table></div></div>';
  13846. echo json_encode ( array (
  13847. 'status' => 1,
  13848. 'receiptHtml' => $html
  13849. ) );
  13850. die ();
  13851. }
  13852. echo json_encode ( array (
  13853. 'status' => 2,
  13854. 'receiptHtml' => ''
  13855. ) );
  13856. die ();
  13857. }
  13858. function _getMonthCollectDetail($receiptCollectList,$aiList) {
  13859. if (! empty ( $receiptCollectList )) {
  13860. $receiptL = array (
  13861. '日常相关费用' => array (),
  13862. '差旅相关费用' => array (),
  13863. '内部培训费用'=>array(),
  13864. '培训班费用' => array (),
  13865. '其他' => array ()
  13866. );
  13867. $html = "";
  13868. $psum = 0;
  13869. foreach ( $aiList[$this->AGENCY] as $value ) {
  13870. $falg = true;
  13871. foreach ( $receiptCollectList as $v ) {
  13872. if ($v ['itemCategory'] == '日常相关费用') {
  13873. if ($v ['item'] == $value['name']) {
  13874. $psum += $v ['price'];
  13875. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13876. $falg = false;
  13877. break;
  13878. }
  13879. }
  13880. }
  13881. if ($falg)
  13882. $html .= '<td class="taR">-</td>';
  13883. }
  13884. if (! empty ( $psum ))
  13885. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13886. else
  13887. $psum = '<td class="colGreen taR">-</td>';
  13888. $receiptL ['日常相关费用'] = $psum . $html;
  13889. /* ----------------------------------- */
  13890. $html = "";
  13891. $psum = 0;
  13892. foreach ( $aiList[$this->TRAVEL] as $value ) {
  13893. $falg = true;
  13894. foreach ( $receiptCollectList as $v ) {
  13895. if ($v ['itemCategory'] == '差旅相关费用') {
  13896. if ($v ['item'] == $value['name']) {
  13897. $psum += $v ['price'];
  13898. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13899. $falg = false;
  13900. break;
  13901. }
  13902. }
  13903. }
  13904. if ($falg)
  13905. $html .= '<td class="taR">-</td>';
  13906. }
  13907. if (! empty ( $psum ))
  13908. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13909. else
  13910. $psum = '<td class="colGreen taR">-</td>';
  13911. $receiptL ['差旅相关费用'] = $psum . $html;
  13912. /* ----------------------------------- */
  13913. $html = "";
  13914. $psum = 0;
  13915. foreach ( $aiList[$this->INTTRAIN] as $value ) {
  13916. $falg = true;
  13917. foreach ( $receiptCollectList as $v ) {
  13918. if ($v ['itemCategory'] == '内部培训费用') {
  13919. if ($v ['item'] == $value['name']) {
  13920. $psum += $v ['price'];
  13921. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13922. $falg = false;
  13923. break;
  13924. }
  13925. }
  13926. }
  13927. if ($falg)
  13928. $html .= '<td class="taR">-</td>';
  13929. }
  13930. if (! empty ( $psum ))
  13931. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13932. else
  13933. $psum = '<td class="colGreen taR">-</td>';
  13934. $receiptL ['内部培训费用'] = $psum . $html;
  13935. /* ------------------------------------- */
  13936. $html = "";
  13937. $psum = 0;
  13938. foreach ( $aiList[$this->TRAIN] as $value ) {
  13939. $falg = true;
  13940. foreach ( $receiptCollectList as $v ) {
  13941. if ($v ['itemCategory'] == '培训班费用') {
  13942. if ($v ['item'] == $value['name']) {
  13943. $psum += $v ['price'];
  13944. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13945. $falg = false;
  13946. break;
  13947. }
  13948. }
  13949. }
  13950. if ($falg)
  13951. $html .= '<td class="taR">-</td>';
  13952. }
  13953. if (! empty ( $psum ))
  13954. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13955. else
  13956. $psum = '<td class="colGreen taR">-</td>';
  13957. $receiptL ['培训班费用'] = $psum . $html;
  13958. /* ------------------------------------- */
  13959. $html = "";
  13960. $psum = 0;
  13961. foreach ( $aiList[$this->OTHER] as $value ) {
  13962. $falg = true;
  13963. foreach ( $receiptCollectList as $v ) {
  13964. if ($v ['itemCategory'] == '其他') {
  13965. if ($v ['item'] == $value['name']) {
  13966. $psum += $v ['price'];
  13967. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13968. $falg = false;
  13969. break;
  13970. }
  13971. }
  13972. }
  13973. if ($falg)
  13974. $html .= '<td class="taR">-</td>';
  13975. }
  13976. if (! empty ( $psum ))
  13977. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13978. else
  13979. $psum = '<td class="colGreen taR">-</td>';
  13980. $receiptL ['其他'] = $psum . $html;
  13981. /* ------------------------------------- */
  13982. $html = "";
  13983. $psum = 0;
  13984. foreach ( $receiptCollectList as $v ) {
  13985. if ($v ['itemCategory'] == '报销金额调整') {
  13986. if (! empty ( $v ['price'] ))
  13987. $psum += $v ['price'];
  13988. }
  13989. }
  13990. if (! empty ( $psum ))
  13991. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  13992. else
  13993. $psum = '<td class="taR colOrange">-</td>';
  13994. $receiptL ['报销金额调整'] = $psum . $html;
  13995. } else {
  13996. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  13997. foreach ( $aiList[$this->AGENCY] as $va ) {
  13998. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  13999. }
  14000. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  14001. foreach ( $aiList[$this->TRAVEL] as $va ) {
  14002. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  14003. }
  14004. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  14005. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  14006. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  14007. }
  14008. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  14009. foreach ( $aiList[$this->TRAIN] as $va ) {
  14010. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  14011. }
  14012. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  14013. foreach ( $aiList[$this->OTHER] as $va ) {
  14014. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  14015. }
  14016. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  14017. }
  14018. return $receiptL;
  14019. }
  14020. function eMail() {
  14021. Doo::loadModel ( 'staff' );
  14022. $staff = new staff ();
  14023. Doo::loadModel ( 'receipt' );
  14024. $receipt = new receipt ();
  14025. Doo::loadModel ( 'L_category' );
  14026. $Lcategory = new L_category ();
  14027. Doo::loadModel ( "verify" );
  14028. $verify = new verify ();
  14029. $staffList = $staff->find ( array (
  14030. 'asArray' => true
  14031. ) );
  14032. foreach ( $staffList as $key => $value ) {
  14033. if ($value ['username'] != 'admin') {
  14034. // 提交人
  14035. $receiptList = $receipt->find ( array (
  14036. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  14037. 'asArray' => true
  14038. ) );
  14039. if (! empty ( $receiptList )) {
  14040. $html = '<br><div><style></style>
  14041. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  14042. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  14043. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14044. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  14045. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14046. <tbody><tr>
  14047. <td style="padding: 0 40px;" align="left">
  14048. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14049. </td></tr><tr>
  14050. <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>
  14051. </tr>
  14052. </tbody> </table></td> </tr> <tr><td>
  14053. <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">
  14054. <tbody> <tr><td>
  14055. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  14056. 以下报销单完成了审批,等着收款吧:</p>
  14057. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  14058. foreach ( $receiptList as $k => $v ) {
  14059. $category = $Lcategory->getOne ( array (
  14060. 'where' => 'cid=' . $v ['cid'],
  14061. 'asArray' => true
  14062. ) );
  14063. $html .= '
  14064. <tr>
  14065. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14066. <td align="left">
  14067. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  14068. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  14069. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  14070. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  14071. </tr>';
  14072. }
  14073. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  14074. <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>
  14075. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  14076. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  14077. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  14078. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14079. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14080. $receipt = new receipt ();
  14081. $receipt->notice = 1;
  14082. $receipt->update ( array (
  14083. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  14084. ) );
  14085. }
  14086. }
  14087. // 审批人
  14088. $verifyList = $verify->find ( array (
  14089. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  14090. 'asArray' => true
  14091. ) );
  14092. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  14093. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  14094. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14095. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  14096. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14097. <tbody><tr><td style="padding: 0 40px;" align="left">
  14098. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14099. </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>
  14100. </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">
  14101. <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>
  14102. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  14103. foreach ( $verifyList as $k => $v ) {
  14104. $receiptList = $receipt->find ( array (
  14105. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  14106. 'asArray' => true
  14107. ) );
  14108. foreach ( $receiptList as $r => $l ) {
  14109. $category = $Lcategory->getOne ( array (
  14110. 'where' => 'cid=' . $l ['cid'],
  14111. 'asArray' => true
  14112. ) );
  14113. $staffDetile = $staff->getOne ( array (
  14114. 'where' => 'sid=' . $l ['staff'],
  14115. 'asArray' => true
  14116. ) );
  14117. $html .= '
  14118. <tr>
  14119. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14120. <td align="left">
  14121. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  14122. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  14123. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  14124. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  14125. </tr>';
  14126. }
  14127. }
  14128. $html .= '
  14129. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  14130. <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>
  14131. </tr></tbody></table></td></tr></tbody></table></div><br>';
  14132. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  14133. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  14134. // $receipt=new receipt();
  14135. // $receipt->notice=1;
  14136. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  14137. }
  14138. }
  14139. }
  14140. }
  14141. function setWXMsg($rid, $type) {
  14142. Doo::loadModel ( "receipt" );
  14143. $receipt = new receipt ();
  14144. $receiptDetail = $receipt->getOne ( array (
  14145. 'where' => 'rid=' . $rid,
  14146. 'asArray' => true
  14147. ) );
  14148. if (! empty ( $receiptDetail )) {
  14149. Doo::loadModel ( 'staff' );
  14150. $staff = new staff ();
  14151. $staffmsg = $staff->getOne ( array (
  14152. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  14153. 'asArray' => TRUE
  14154. ) );
  14155. if (! empty ( $staffmsg ['wxid'] )) {
  14156. require_once (SITE_PATH . '/protected/class/client.php');
  14157. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  14158. $user = $staffmsg ['wxid'];
  14159. $receiptName = '';
  14160. $msg = '';
  14161. switch ($receiptDetail ['Rtype']) {
  14162. case 0 :
  14163. $receiptName = '报销';
  14164. break;
  14165. case 1 :
  14166. $receiptName = '借款';
  14167. break;
  14168. case 2 :
  14169. $receiptName = '对公汇款';
  14170. break;
  14171. }
  14172. switch ($type) {
  14173. case 1 :
  14174. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  14175. break;
  14176. case 2 :
  14177. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  14178. break;
  14179. case 3 :
  14180. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  14181. break;
  14182. }
  14183. // $result = $client->SendMsg ( $user, $msg, 'text' );
  14184. }
  14185. }
  14186. }
  14187. // Email发送函数
  14188. function SMail($toemail, $subject, $contents) {
  14189. Doo::loadClass ( 'class.phpmailer' );
  14190. $mail = new PHPMailer ();
  14191. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  14192. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  14193. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  14194. $mail->Password = "cDO1GjtY1seH"; // 密码
  14195. $mail->CharSet = "UTF8";
  14196. $mail->SMTPAuth = true;
  14197. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  14198. $mail->Mailer = "smtp";
  14199. $mail->Port = 25;
  14200. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  14201. $mail->MsgHTML ( $contents );
  14202. $mail->AddAddress ( $toemail );
  14203. $mail->CharSet = "UTF-8";
  14204. return $mail->Send ();
  14205. }
  14206. function h5Upload() {
  14207. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14208. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14209. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14210. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14211. header ( "HTTP/1.1 500 Internal Server Error" );
  14212. echo "POST exceeded maximum allowed size.";
  14213. exit ( 0 );
  14214. }
  14215. // Settings
  14216. $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)
  14217. $upload_name = "Filedata";
  14218. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14219. $extension_whitelist = array (
  14220. "doc",
  14221. "txt",
  14222. "jpg",
  14223. "gif",
  14224. "png"
  14225. ); // Allowed file extensions
  14226. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14227. // Other variables
  14228. $MAX_FILENAME_LENGTH = 260;
  14229. $file_name = "";
  14230. $file_extension = "";
  14231. $uploadErrors = array (
  14232. 0 => "文件上传成功",
  14233. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14234. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14235. 3 => "上传的文件仅为部分文件",
  14236. 4 => "没有文件上传",
  14237. 6 => "缺少临时文件夹"
  14238. );
  14239. $nk = time ();
  14240. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14241. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14242. echo "文件无法保存.";
  14243. exit ( 0 );
  14244. }
  14245. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14246. echo json_encode ( array (
  14247. 'filename' => $file_name,
  14248. 'id' => $nk
  14249. ) );
  14250. exit ( 0 );
  14251. }
  14252. function swfupload() {
  14253. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14254. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14255. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14256. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14257. header ( "HTTP/1.1 500 Internal Server Error" );
  14258. echo "POST exceeded maximum allowed size.";
  14259. exit ( 0 );
  14260. }
  14261. // Settings
  14262. $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)
  14263. $upload_name = "Filedata";
  14264. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14265. $extension_whitelist = array (
  14266. "doc",
  14267. "txt",
  14268. "jpg",
  14269. "gif",
  14270. "png"
  14271. ); // Allowed file extensions
  14272. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14273. // Other variables
  14274. $MAX_FILENAME_LENGTH = 260;
  14275. $file_name = "";
  14276. $file_extension = "";
  14277. $uploadErrors = array (
  14278. 0 => "文件上传成功",
  14279. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14280. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14281. 3 => "上传的文件仅为部分文件",
  14282. 4 => "没有文件上传",
  14283. 6 => "缺少临时文件夹"
  14284. );
  14285. $nk = time ();
  14286. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14287. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14288. echo "文件无法保存.";
  14289. exit ( 0 );
  14290. }
  14291. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14292. echo json_encode ( array (
  14293. 'filename' => $file_name,
  14294. 'id' => $nk
  14295. ) );
  14296. exit ( 0 );
  14297. }
  14298. function _GetFileEXT($filename) {
  14299. $pics = explode ( '.', $filename );
  14300. $num = count ( $pics );
  14301. return $pics [$num - 1];
  14302. }
  14303. /**
  14304. * 获取get或者POST值
  14305. * @param string $name 属性名称
  14306. * @return fixed 值
  14307. */
  14308. function get_args($name) {
  14309. if (isset ( $_GET [$name] )) {
  14310. if (is_array ( $_GET [$name] ))
  14311. return $_GET [$name];
  14312. else
  14313. return addslashes ( $_GET [$name] );
  14314. } elseif (isset ( $_POST [$name] )) {
  14315. if (is_array ( $_POST [$name] ))
  14316. return $_POST [$name];
  14317. else
  14318. return addslashes ( $_POST [$name] );
  14319. } else
  14320. return false;
  14321. }
  14322. function num_to_rmb($num) {
  14323. $c1 = "零壹贰叁肆伍陆柒捌玖";
  14324. $c2 = "分角元拾佰仟万拾佰仟亿";
  14325. // 精确到分后面就不要了,所以只留两个小数位
  14326. $num = round ( $num, 2 );
  14327. // 将数字转化为整数
  14328. $num = $num * 100;
  14329. if (strlen ( $num ) > 10) {
  14330. return "金额太大,请检查";
  14331. }
  14332. $i = 0;
  14333. $c = "";
  14334. while ( 1 ) {
  14335. if ($i == 0) {
  14336. // 获取最后一位数字
  14337. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  14338. } else {
  14339. $n = $num % 10;
  14340. }
  14341. // 每次将最后一位数字转化为中文
  14342. $p1 = substr ( $c1, 3 * $n, 3 );
  14343. $p2 = substr ( $c2, 3 * $i, 3 );
  14344. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  14345. $c = $p1 . $p2 . $c;
  14346. } else {
  14347. $c = $p1 . $c;
  14348. }
  14349. $i = $i + 1;
  14350. // 去掉数字最后一位了
  14351. $num = $num / 10;
  14352. // echo $num.'</br>';
  14353. $num = ( int ) $num;
  14354. // $num =floor($num);
  14355. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  14356. // echo $num.'</br>';
  14357. // 结束循环
  14358. if ($num == 0) {
  14359. break;
  14360. }
  14361. }
  14362. // echo $c.'</br>';
  14363. $j = 0;
  14364. $slen = strlen ( $c );
  14365. while ( $j < $slen ) {
  14366. // utf8一个汉字相当3个字符
  14367. $m = substr ( $c, $j, 6 );
  14368. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  14369. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  14370. $left = substr ( $c, 0, $j );
  14371. $right = substr ( $c, $j + 3 );
  14372. $c = $left . $right;
  14373. $j = $j - 3;
  14374. $slen = $slen - 3;
  14375. }
  14376. $j = $j + 3;
  14377. }
  14378. // 这个是为了去掉类似23.0中最后一个“零”字
  14379. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  14380. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  14381. }
  14382. // 将处理的汉字加上“整”
  14383. if (empty ( $c )) {
  14384. return "零元整";
  14385. } else {
  14386. return $c . "整";
  14387. }
  14388. }
  14389. /**
  14390. * 获得分页数据
  14391. * @param unknown_type $table
  14392. * @param unknown_type $condition
  14393. * @param unknown_type $on_page
  14394. * @param unknown_type $page_size
  14395. */
  14396. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  14397. $page_c = "";
  14398. $page ['previous'] = $this->get_previous ( $on_page );
  14399. $page ['on_page'] = $on_page;
  14400. $total_count = $this->get_table_count ( $table, $condition );
  14401. $total = intval ( $total_count / $page_size );
  14402. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  14403. $page ['total_data'] = $total_count;
  14404. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  14405. $i = 1;
  14406. $page_max = 1;
  14407. $page_width = 3;
  14408. if ($on_page >= $page_width) {
  14409. $page_max = intval ( $on_page / $page_width ) + 1;
  14410. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  14411. }
  14412. for(; $i <= $page ['total_page']; $i ++) {
  14413. if ($i == $on_page)
  14414. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  14415. else
  14416. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  14417. if ($i == ($page_width * $page_max))
  14418. break;
  14419. }
  14420. $page ['page'] = $page_c;
  14421. $page ['lower'] = (-- $on_page) * $page_size;
  14422. return $page;
  14423. }
  14424. /**
  14425. * 获取总页数
  14426. * @param unknown_type $table
  14427. * @param unknown_type $condition
  14428. */
  14429. public function get_table_count($table = "", $condition = "") {
  14430. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14431. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14432. // echo $sql;die;
  14433. $query = Doo::db ()->query ( $sql );
  14434. $result = $query->fetch ();
  14435. return $result ['count'];
  14436. }
  14437. /**
  14438. * 获取上一页
  14439. * @param unknown_type $on_page
  14440. */
  14441. function get_previous($on_page = 1) {
  14442. return $on_page != 0 ? $on_page - 1 : $on_page;
  14443. }
  14444. function _getReceiptTrainPayment($invoiceTrainId,$trainLoanRid,$rid){
  14445. // 收入合计
  14446. Doo::loadModel ( 'invoiceTraining' );
  14447. $invoiceTraining = new invoiceTraining ();
  14448. Doo::loadModel ( 'receipt' );
  14449. $receipt = new receipt ();
  14450. $invoiceTrainingDetail = array (
  14451. 'invoiceArriveAmount' => '0.00',
  14452. 'RIAmount' => '0.00',
  14453. 'invoiceTotalAmount' => '0.00',
  14454. 'invoiceCompanyAmount' => '0.00',
  14455. 'invoiceArriveAmountM'=>'0.00',
  14456. 'invoiceCompanyAmountM'=>'0.00'
  14457. );
  14458. if ($invoiceTrainId != 0) {
  14459. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $invoiceTrainId );
  14460. }
  14461. $invoiceArriveAmount = $RIAmount = 0;
  14462. if (! empty ( $invoiceTrainingDetail )) {
  14463. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  14464. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  14465. }
  14466. // 备用金
  14467. $sum = 0;
  14468. if (! empty ( $trainLoanRid )) {
  14469. $receiptLoanList = $receipt->getReceiptInRid ( $trainLoanRid );
  14470. foreach ($receiptLoanList as $key=>$value){
  14471. $sum+=$value['sum'];
  14472. }
  14473. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $trainLoanRid );
  14474. // $sum = $receiptLoanDetailBak ['sum'];
  14475. }
  14476. // 支出项金额详情
  14477. // 项目金额合计
  14478. Doo::loadModel ( 'RItem' );
  14479. $RItem = new RItem ();
  14480. Doo::loadModel ( 'accountItem' );
  14481. $accountItem = new accountItem ();
  14482. // 讲师获得
  14483. Doo::loadModel ( 'RILecturer' );
  14484. $RILecturer = new RILecturer ();
  14485. $RItemList = $RItem->getRItemByRid ($rid );
  14486. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  14487. // 支出项金额详情
  14488. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  14489. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  14490. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  14491. return $payment;
  14492. }
  14493. }
  14494. ?>