ReceiptController.php 540 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class ReceiptController extends DooController {
  6. public $staff;
  7. public $verifyId;
  8. public $executeId;
  9. // public static $NEW2 = 0;
  10. public $AGENCY = "日常相关费用";
  11. public $TRAVEL = "差旅相关费用";
  12. public $TRAIN = "培训班费用";
  13. public $OTHER = "其他";
  14. public $INTTRAIN='内部培训费用';
  15. private $MYREVEIPTCACHEPATH = "protected/cache/myReceipt/";
  16. private $PERSONALCOLLECTCACHEPATH = "protected/cache/personalCollect/";
  17. private $CATEGORYCOLLECTPATH = "protected/cache/categoryCollect/";
  18. private $STAFFCOLLECTPATH = "protected/cache/staffCollect/";
  19. private function showCache($path) {
  20. if (file_exists ( $path )) {
  21. echo "<!DOCTYPE html>";
  22. include $path;
  23. die ();
  24. }
  25. }
  26. private function cacheFile($path) {
  27. $content = ob_get_contents ();
  28. $fp = fopen ( $path, "w" );
  29. fwrite ( $fp, $content );
  30. fclose ( $fp );
  31. }
  32. private function collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {
  33. $collectHtml = "";
  34. $sumPrice = 0.00;
  35. for($i = 1; $i <= 12; $i ++) {
  36. $falg = true;
  37. foreach ( $receiptCollectList as $key => $value ) {
  38. if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {
  39. $sumPrice += $value ['price'];
  40. if ($classType == "b") {
  41. $collectHtml .= '<td class="colGreen taR">¥' . $value ['price'] . '</td>';
  42. $falg = false;
  43. break;
  44. } else {
  45. $collectHtml .= '<td class="taR">¥' . $value ['price'] . '</td>';
  46. $falg = false;
  47. break;
  48. }
  49. }
  50. }
  51. if ($falg)
  52. $collectHtml .= '<td class="taR">-</td>';
  53. }
  54. $collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';
  55. return $collectHtml;
  56. }
  57. public function beforeRun($resource, $action) {
  58. Doo::loadClass ( 'XDeode' );
  59. $XDeode = new XDeode ( 5 );
  60. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  61. // 单独判断公司汇总的访问权限
  62. if ($action == 'companyCategoryCollect') {
  63. Doo::loadModel ( "receiptAuthorityManage" );
  64. $invoiceCompanyManage = new receiptAuthorityManage ();
  65. $icm = $invoiceCompanyManage->getInvoiceCMByStaff ( $sid );
  66. if (empty ( $icm ))
  67. die ( 'illegal request' );
  68. }
  69. Doo::loadModel ( 'staff' );
  70. $staff = new staff ();
  71. $detail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  72. $accessModular = 'RECEIPTS';
  73. if (empty ( $detail ['cldAccessArray'] ))
  74. die ( 'illegal request' );
  75. else {
  76. if (in_array ( $accessModular, $detail ['cldAccessArray'] )) {
  77. if (Doo::acl ()->isAllowed ( $accessModular, $resource, $action )) {
  78. $flag = true;
  79. } else {
  80. $flag = false;
  81. }
  82. } else {
  83. die ( 'illegal request' );
  84. }
  85. }
  86. if (! $flag)
  87. die ( 'illegal request' );
  88. }
  89. function __construct() {
  90. if (isset ( $_COOKIE ["staff"] )) {
  91. if (! empty ( $_COOKIE ["staff"] )) {
  92. Doo::loadModel ( 'staff' );
  93. Doo::loadModel ( 'verify' );
  94. $verify = new verify ();
  95. $staff = new staff ();
  96. Doo::loadModel ( "execute" );
  97. $execute = new execute ();
  98. $verifyList = $verify->find ( array (
  99. 'select' => 'staff',
  100. 'asArray' => true
  101. ) );
  102. $list = array ();
  103. // 判断角色的审批权限
  104. foreach ( $verifyList as $key => $value ) {
  105. $ver = json_decode ( $value ['staff'] );
  106. foreach ( $ver as $k => $v ) {
  107. if ($v [1] == 'ROLE') {
  108. $roleList = json_decode ( $v [3] );
  109. foreach ( $roleList as $t => $g ) {
  110. $gList = explode ( "_", $g );
  111. array_push ( $list, $gList [0] );
  112. // print_r($list);
  113. }
  114. } else
  115. array_push ( $list, $v [0] );
  116. }
  117. }
  118. // 判断执行人的审批权限
  119. $executeList = $execute->find ( array (
  120. 'where'=>'mold !="日常收支"',
  121. 'select' => 'staff',
  122. 'asArray' => true
  123. ) );
  124. $list2 = array ();
  125. foreach ( $executeList as $key => $value ) {
  126. $ver = json_decode ( $value ['staff'] );
  127. foreach ( $ver as $k => $v ) {
  128. array_push ( $list2, $v [0] );
  129. }
  130. }
  131. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  132. $eidList = array_filter ( explode ( ",", $eidList ) );
  133. $this->executeId = array_merge ( $list2, $eidList );
  134. $this->verifyId = $list;
  135. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  136. // 检测用户信息完成
  137. $this->data ['isStaffCompleteMsg'] = false;
  138. $detail = $staff->checkStaffInfoIsComplete ( $_COOKIE ["staff"] );
  139. if (! empty ( $detail ))
  140. $this->data ['isStaffCompleteMsg'] = true;
  141. return "/";
  142. }
  143. }
  144. Doo::loadCore ( 'uri/DooUriRouter' );
  145. $router = new DooUriRouter ();
  146. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  147. if ($routeRs ['1'] != "login") {
  148. header ( 'Content-Type:text/html;charset=utf-8' );
  149. @header ( "Location: /login" );
  150. }
  151. }
  152. function saeaBorad() {
  153. Doo::loadModel ( 'receipt' );
  154. $receipt = new receipt ();
  155. Doo::loadModel ( 'verify' );
  156. $verify = new verify ();
  157. Doo::loadModel ( 'L_category' );
  158. $lCategory = new L_category ();
  159. Doo::loadModel ( "role" );
  160. $role = new role ();
  161. Doo::loadModel ( "receiptLog" );
  162. $receiptLog = new receiptLog ();
  163. Doo::loadClass ( 'XDeode' );
  164. $XDeode = new XDeode ( 7 );
  165. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  166. $receiptDetail = $receipt->find ( array (
  167. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  168. 'desc' => 'rid',
  169. 'asArray' => true
  170. ) );
  171. foreach ( $receiptDetail as $key => $value ) {
  172. $receiptDetail [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  173. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  174. $veList = $verify->getOne ( array (
  175. 'where' => 'vid=' . $value ['verify'],
  176. 'asArray' => true
  177. ) );
  178. $v = json_decode ( $veList ['staff'] );
  179. array_push ( $v [0], $veList ['description'] );
  180. foreach ( $v as $n => $m ) {
  181. if ($m ['1'] == 'ROLE') {
  182. $roleInfo = $role->getOne ( array (
  183. 'where' => 'rid=' . $m [0],
  184. 'asArray' => true
  185. ) );
  186. $v [$n] [1] = $roleInfo ['name'];
  187. }
  188. }
  189. $receiptDetail [$key] ['staff'] = $v;
  190. $category = $lCategory->getOne ( array (
  191. 'where' => 'cid=' . $value ['cid'],
  192. 'asArray' => true
  193. ) );
  194. $receiptDetail [$key] ['category'] = $category ['title'];
  195. }
  196. // print_r($receiptLogList);
  197. Doo::loadModel ( 'RAssist' );
  198. $RAssist = new RAssist ();
  199. $receiptExtendList=$RAssist->getRAssistBySid($this->staff[0]['sid']);
  200. $data ['receiptExtendList'] = $receiptExtendList;
  201. $data ['receiptLogList'] = $receiptLogList;
  202. $data ['receiptDetail'] = $receiptDetail;
  203. $data ['memu'] = "receipt";
  204. $data ['staff'] = $this->staff;
  205. $data ['receiptMemu'] = 'saeaBorad';
  206. $data ['verifyId'] = $this->verifyId;
  207. $data ['executeId'] = $this->executeId;
  208. $this->render ( "/admin/saeaBorad", $data );
  209. }
  210. function remitAdd() {
  211. Doo::loadModel ( 'accountItem' );
  212. Doo::loadModel ( 'verify' );
  213. Doo::loadModel ( 'receipt' );
  214. Doo::loadModel ( 'L_category' );
  215. $lCategory = new L_category ();
  216. $receipt = new receipt ();
  217. $verify = new verify ();
  218. $accountItem = new accountItem ();
  219. Doo::loadModel ( "role" );
  220. $role = new role ();
  221. $acItem = $accountItem->find ( array (
  222. 'asArray' => true
  223. ) );
  224. $veList = $verify->getVerifyBySubordinate('REMIT');
  225. $data ['category'] = $lCategory->find ( array (
  226. 'asArray' => true
  227. ) );
  228. $data ['veList'] = $veList;
  229. $data ['acItem'] = $acItem;
  230. $data ['memu'] = "receipt";
  231. $data ['staff'] = $this->staff;
  232. $data ['receiptMemu'] = 'saeaBorad';
  233. $data ['verifyId'] = $this->verifyId;
  234. $data ['executeId'] = $this->executeId;
  235. $this->render ( "/admin/remitAdd", $data );
  236. }
  237. function remitAddDo() {
  238. $agency = $this->get_args ( 'agency' );
  239. $travel = $this->get_args ( 'travel' );
  240. $train = $this->get_args ( 'train' );
  241. $other = $this->get_args ( 'other' );
  242. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  243. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  244. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  245. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  246. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  247. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  248. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  249. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  250. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  251. // print_r($agency);die;
  252. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  253. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  254. header ( 'Content-Type:text/html;charset=utf-8' );
  255. die ( '请填写联行号' );
  256. }
  257. Doo::loadModel ( 'receipt' );
  258. Doo::loadModel ( 'receiptDetail' );
  259. Doo::loadModel ( 'accountItem' );
  260. $accountItem = new accountItem ();
  261. $receipt = new receipt ();
  262. Doo::loadModel ( 'enclosur' );
  263. Doo::loadModel ( 'execute' );
  264. $execute = new execute ();
  265. $executeDetail = $execute->getOne ( array (
  266. 'where' => 'mold="对公汇款执行人"',
  267. 'asArray' => true
  268. ) );
  269. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  270. $aItem = $accountItem->find ( array (
  271. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  272. 'asArray' => true
  273. ) );
  274. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  275. $ag = $tr = $ta = $ot = 0;
  276. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  277. print_r($aItem);
  278. foreach ( $aItem as $key => $value ) {
  279. if ($value ['category'] == $this->AGENCY) {
  280. if (isset ( $agency [$ag] )) {
  281. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  282. array_push ( $accountJson [$this->AGENCY], array (
  283. 'aid' => $value ['aid'],
  284. 'name' => $value ['name'],
  285. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  286. ) );
  287. $sum += $agency [$ag];
  288. $agencySum += $agency [$ag];
  289. }
  290. }
  291. $ag ++;
  292. }
  293. }
  294. $accountJson ['cSum'] = array (
  295. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  296. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  297. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  298. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  299. );
  300. //die;
  301. // 报销单
  302. $receipt->accountItem = json_encode ( $accountJson );
  303. $receipt->staff = $this->staff [0] ['sid'];
  304. $receipt->sum = number_format ( $sum, 2, '.', '' );
  305. $receipt->date = date ( "Y-m-d" );
  306. $receipt->cid = $cid;
  307. $receipt->status = 5;
  308. $receipt->Rtype = 2;
  309. // 修改审批流程加入角色
  310. $receipt->verify = $verify;
  311. $receipt->executeCopy = $executeDetail ['staff'];
  312. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  313. $order = array (
  314. "\r\n",
  315. "\n",
  316. "\r"
  317. );
  318. $replace = '<br/>';
  319. $explanation = str_replace ( $order, $replace, $explanation );
  320. $receipt->explanation = $explanation;
  321. $receipt->remittanceName = $remittanceName;
  322. $receipt->bankName = $bankName;
  323. $receipt->bankNumber = $bankNumber;
  324. $receipt->remittanceBankType = $remittanceBankType;
  325. if ($remittanceBankType == 1)
  326. $receipt->coupletNumber = $coupletNumber;
  327. $rid = $receipt->insert ();
  328. // 附件
  329. if (! empty ( $enclosurName )) {
  330. $enclosurArray = explode ( '-', $enclosurName );
  331. foreach ( $enclosurArray as $value ) {
  332. $enclosur = new enclosur ();
  333. $enclosur->name = $value;
  334. $enclosur->rid = $rid;
  335. $enclosur->insert ();
  336. }
  337. // print_r($enclosurArray);die;
  338. }
  339. // 报销详情
  340. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  341. $receiptDetail = new receiptDetail ();
  342. $receiptDetail->staff = $this->staff [0] ['sid'];
  343. $receiptDetail->item = $value ['name'];
  344. $receiptDetail->itemCategory = $this->AGENCY;
  345. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  346. $receiptDetail->date = date ( "Y-m-d" );
  347. $receiptDetail->cid = $cid;
  348. $receiptDetail->rid = $rid;
  349. $receiptDetail->status = 4;
  350. $receiptDetail->insert ();
  351. }
  352. return "/saeaBorad";
  353. } else
  354. die ( 'illegal request' );
  355. }
  356. function remitEdit() {
  357. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  358. Doo::loadClass ( 'XDeode' );
  359. $XDeode = new XDeode ( 7 );
  360. $rid = $XDeode->decode ( $ridKey );
  361. if (! is_numeric ( $rid ))
  362. die ( 'illegal request' );
  363. Doo::loadModel ( 'accountItem' );
  364. Doo::loadModel ( 'verify' );
  365. Doo::loadModel ( 'receipt' );
  366. $receipt = new receipt ();
  367. $verify = new verify ();
  368. $accountItem = new accountItem ();
  369. Doo::loadModel ( 'L_category' );
  370. $lCategory = new L_category ();
  371. Doo::loadModel ( "role" );
  372. $role = new role ();
  373. Doo::loadModel ( 'enclosur' );
  374. $enclosur = new enclosur ();
  375. $receiptDetail = $receipt->getOne ( array (
  376. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  377. 'asArray' => true
  378. ) );
  379. if (empty ( $receiptDetail ))
  380. return "/saeaCreate";
  381. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  382. $acItem = $accountItem->find ( array (
  383. 'asArray' => true
  384. ) );
  385. $veList = $verify->getVerifyBySubordinate('REMIT');
  386. // 配置编辑信息
  387. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  388. foreach ( $acItem as $key => $value ) {
  389. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  390. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  391. $acItem [$key] ['price'] = $v ['price'];
  392. }
  393. }
  394. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  395. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  396. $acItem [$key] ['price'] = $v ['price'];
  397. }
  398. }
  399. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  400. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  401. $acItem [$key] ['price'] = $v ['price'];
  402. }
  403. }
  404. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  405. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  406. $acItem [$key] ['price'] = $v ['price'];
  407. }
  408. }
  409. }
  410. $data ['category'] = $lCategory->find ( array (
  411. 'asArray' => true
  412. ) );
  413. $data ['enclosurList'] = $enclosurList;
  414. $data ['cSum'] = $accountItemList ['cSum'];
  415. $data ['sum'] = $receiptDetail ['sum'];
  416. $data ['receiptDetail'] = $receiptDetail;
  417. $data ['veList'] = $veList;
  418. $data ['acItem'] = $acItem;
  419. $data ['memu'] = "receipt";
  420. $data ['staff'] = $this->staff;
  421. $data ['receiptMemu'] = 'saeaBorad';
  422. $data ['verify'] = $receiptDetail ['verify'];
  423. $data ['verifyId'] = $this->verifyId;
  424. $data ['executeId'] = $this->executeId;
  425. $data ['rid'] = $rid;
  426. $data ['ridKey'] = $ridKey;
  427. $this->render ( "/admin/remitEdit", $data );
  428. }
  429. function remitEdiDo() {
  430. $agency = $this->get_args ( 'agency' );
  431. $travel = $this->get_args ( 'travel' );
  432. $train = $this->get_args ( 'train' );
  433. $other = $this->get_args ( 'other' );
  434. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  435. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  436. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  437. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  438. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  439. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  440. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  441. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  442. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  443. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  444. Doo::loadClass ( 'XDeode' );
  445. $XDeode = new XDeode ( 7 );
  446. $rid = $XDeode->decode ( $ridKey );
  447. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  448. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  449. header ( 'Content-Type:text/html;charset=utf-8' );
  450. die ( '请填写联行号' );
  451. }
  452. Doo::loadModel ( 'receipt' );
  453. Doo::loadModel ( 'receiptDetail' );
  454. Doo::loadModel ( 'accountItem' );
  455. $accountItem = new accountItem ();
  456. $receipt = new receipt ();
  457. Doo::loadModel ( 'enclosur' );
  458. $enclosur = new enclosur ();
  459. Doo::loadModel ( 'execute' );
  460. $execute = new execute ();
  461. $executeDetail = $execute->getOne ( array (
  462. 'where' => 'mold="对公汇款执行人"',
  463. 'asArray' => true
  464. ) );
  465. $receiptDetail = $receipt->getOne ( array (
  466. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  467. 'asArray' => true
  468. ) );
  469. if (empty ( $receiptDetail ))
  470. return "/saeaBorad";
  471. $aItem = $accountItem->find ( array (
  472. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  473. 'asArray' => true
  474. ) );
  475. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  476. $ag = $tr = $ta = $ot = 0;
  477. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  478. foreach ( $aItem as $key => $value ) {
  479. if ($value ['category'] == $this->AGENCY) {
  480. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  481. array_push ( $accountJson [$this->AGENCY], array (
  482. 'aid' => $value ['aid'],
  483. 'name' => $value ['name'],
  484. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  485. ) );
  486. $sum += $agency [$ag];
  487. $agencySum += $agency [$ag];
  488. }
  489. $ag ++;
  490. }
  491. }
  492. $accountJson ['cSum'] = array (
  493. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  494. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  495. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  496. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  497. );
  498. // 报销单
  499. $rid = $receipt->rid = $receiptDetail ['rid'];
  500. $receipt->accountItem = json_encode ( $accountJson );
  501. $receipt->staff = $this->staff [0] ['sid'];
  502. $receipt->sum = number_format ( $sum, 2, '.', '' );
  503. $receipt->date = date ( "Y-m-d" );
  504. $receipt->cid = $cid;
  505. if ($receiptDetail ['Rtype'] == 1)
  506. $receipt->status = 7;
  507. else
  508. $receipt->status = 5;
  509. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  510. $receipt->verify = $verify;
  511. $receipt->executeCopy = $executeDetail ['staff'];
  512. $order = array (
  513. "\r\n",
  514. "\n",
  515. "\r"
  516. );
  517. $replace = '<br/>';
  518. $explanation = str_replace ( $order, $replace, $explanation );
  519. $receipt->explanation = $explanation;
  520. $receipt->remittanceName = $remittanceName;
  521. $receipt->bankName = $bankName;
  522. $receipt->bankNumber = $bankNumber;
  523. $receipt->remittanceBankType = $remittanceBankType;
  524. if ($remittanceBankType == 1)
  525. $receipt->coupletNumber = $coupletNumber;
  526. $receipt->update ();
  527. $receiptDetail = new receiptDetail ();
  528. $receiptDetail->delete ( array (
  529. 'where' => 'rid=' . $rid
  530. ) );
  531. // 报销详情
  532. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  533. $receiptDetail = new receiptDetail ();
  534. $receiptDetail->staff = $this->staff [0] ['sid'];
  535. $receiptDetail->item = $value ['name'];
  536. $receiptDetail->itemCategory = $this->AGENCY;
  537. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  538. $receiptDetail->date = date ( "Y-m-d" );
  539. $receiptDetail->cid = $cid;
  540. $receiptDetail->rid = $rid;
  541. $receiptDetail->status = 4;
  542. $receiptDetail->insert ();
  543. }
  544. // 附件
  545. if (! empty ( $enclosurName )) {
  546. $enclosurArray = explode ( '-', $enclosurName );
  547. foreach ( $enclosurArray as $value ) {
  548. $enclosur = new enclosur ();
  549. $enclosur->name = $value;
  550. $enclosur->rid = $rid;
  551. $enclosur->insert ();
  552. }
  553. }
  554. }
  555. return "/saeaBorad";
  556. }
  557. function remitApproval() {
  558. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  559. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  560. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  561. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  562. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  563. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  564. if (empty ( $status ))
  565. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  566. $vidList = array ();
  567. $button = 0;
  568. Doo::loadModel ( 'verify' );
  569. Doo::loadModel ( 'receipt' );
  570. Doo::loadModel ( 'staff' );
  571. $staff = new staff ();
  572. $receipt = new receipt ();
  573. $verify = new verify ();
  574. Doo::loadModel ( 'L_category' );
  575. $Lcategory = new L_category ();
  576. Doo::loadModel ( 'enclosur' );
  577. $enclosur = new enclosur ();
  578. // user verify ID
  579. $verifyDetail = $verify->find ( array (
  580. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  581. 'asArray' => true
  582. ) );
  583. foreach ( $verifyDetail as $key => $value ) {
  584. array_push ( $vidList, $value ['vid'] );
  585. }
  586. $vid = implode ( ",", $vidList );
  587. if (empty ( $verifyDetail ))
  588. $vid = 0;
  589. $categoryList = $Lcategory->find ( array (
  590. 'asArray' => true
  591. ) );
  592. $staffList = $staff->find ( array (
  593. 'where' => 'cid=' . $cid,
  594. 'asArray' => true
  595. ) );
  596. $ap = "";
  597. if ($status == 4) {
  598. $ap = 4;
  599. $status = 2;
  600. }
  601. // get Receipt By verifyID status 2
  602. $receiptList = $receipt->find ( array (
  603. 'where' => 'rid =' . $rid . ' and status=2',
  604. 'desc' => 'rid',
  605. 'asArray' => true
  606. ) );
  607. if (empty ( $receiptList )) {
  608. die ( 'illegal request' );
  609. }
  610. $Locate = 0;
  611. $roleId = 0;
  612. if ($ap == 4)
  613. $status = 4;
  614. foreach ( $receiptList as $key => $value ) {
  615. $receiptList [$key] ['Locate'] = $Locate;
  616. $Locate ++;
  617. $receiptList [$key] ['reviseDetail'] = array ();
  618. if (! empty ( $value ['reviseDetail'] ))
  619. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  620. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  621. $categoryDetil = $Lcategory->getOne ( array (
  622. 'where' => 'cid=' . $value ['cid'],
  623. 'asArray' => true
  624. ) );
  625. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  626. // 检测编辑状态
  627. $verifyList = $verify->getOne ( array (
  628. 'where' => 'vid=' . $value ['verify'],
  629. 'asArray' => true
  630. ) );
  631. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  632. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  633. Doo::loadModel ( 'role' );
  634. $role = new role ();
  635. // print_r($verifyList);
  636. $flag = true;
  637. $roleKey = 0;
  638. $endStaffArray = array ();
  639. $roleArrayCopy = array ();
  640. foreach ( $verifyList as $k => $v ) {
  641. // init verifyStaff
  642. if ($v [1] == 'ROLE') {
  643. if (! empty ( $verifyStaff )) {
  644. $endStaffArray = end ( $verifyStaff );
  645. if ($v [0] == $endStaffArray ['nextStaff']) {
  646. $roleId = $v [0];
  647. }
  648. }
  649. $roleVerify = json_decode ( $v [3], true );
  650. $roleKey = $k;
  651. $roleArray = array ();
  652. $rolename = $role->getOne ( array (
  653. 'where' => 'rid=' . $v [0],
  654. 'asArray' => true
  655. ) );
  656. foreach ( $roleVerify as $o => $p ) {
  657. $staffID = explode ( '_', $p );
  658. $staffInfo = $staff->getOne ( array (
  659. 'where' => 'sid=' . $staffID [0],
  660. 'asArray' => true
  661. ) );
  662. // print_r($staffID);
  663. $exp = array (
  664. 0 => $staffInfo ['sid'],
  665. 1 => $staffID [1],
  666. 2 => $staffInfo ['avatar'],
  667. 'date' => '',
  668. 'date' => '',
  669. 'opinion' => '',
  670. 'status' => '',
  671. 'rolename' => $rolename ['name']
  672. );
  673. array_push ( $roleArray, $exp );
  674. }
  675. $roleArrayCopy [$v [0]] = $roleArray;
  676. // $verifyList[$k]['roleArray']=$roleArray;
  677. }
  678. // print_r($roleArray);
  679. $verifyList [$k] ['date'] = "";
  680. $verifyList [$k] ['opinion'] = "";
  681. $verifyList [$k] ['status'] = "";
  682. if (empty ( $verifyStaff )) {
  683. $verifyList [$k] ['date'] = "";
  684. $verifyList [$k] ['opinion'] = "";
  685. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  686. $verifyList [$k] ['status'] = 4;
  687. $button = 4;
  688. $flag = false;
  689. }
  690. } else {
  691. foreach ( $verifyStaff as $m => $u ) {
  692. if ($v [0] == $m) {
  693. $verifyList [$k] ['date'] = $u ['date'];
  694. $verifyList [$k] ['opinion'] = $u ['opinion'];
  695. $verifyList [$k] ['status'] = $u ['status'];
  696. $flag = false;
  697. break;
  698. }
  699. }
  700. $endStaffArray = end ( $verifyStaff );
  701. if (isset ( $endStaffArray ['ROLE'] )) {
  702. } else {
  703. $endKey = key ( $verifyStaff );
  704. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  705. $button = 4;
  706. $verifyList [$k] ['status'] = 4;
  707. }
  708. }
  709. }
  710. }
  711. $rolename ['name'] = '';
  712. if (! empty ( $roleId )) {
  713. Doo::loadModel ( 'role' );
  714. $role = new role ();
  715. $rolename = $role->getOne ( array (
  716. 'where' => 'rid=' . $roleId,
  717. 'asArray' => true
  718. ) );
  719. }
  720. if (! empty ( $verifyStaff ))
  721. $endStaffArray = end ( $verifyStaff );
  722. $KOP = false;
  723. foreach ( $roleArrayCopy as $P => $A ) {
  724. foreach ( $A as $MKI => $AVL ) {
  725. if (! empty ( $verifyStaff )) {
  726. // &&$rolename['rid']==$endStaffArray['nextStaff']
  727. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  728. $button = 4;
  729. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  730. }
  731. foreach ( $verifyStaff as $m => $u ) {
  732. $AVLFK = $AVL [0] . '_R';
  733. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  734. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  735. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  736. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  737. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  738. break;
  739. }
  740. }
  741. } else {
  742. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  743. $button = 4;
  744. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  745. }
  746. }
  747. // $roleArray[$MKI]['rolename']=$rolename['name'];
  748. $KOP = true;
  749. }
  750. }
  751. foreach ( $roleArrayCopy as $k => $v ) {
  752. foreach ( $verifyList as $m => $n ) {
  753. if ($n [0] == $k) {
  754. array_splice ( $verifyList, $m, 1, $v );
  755. }
  756. }
  757. }
  758. $receiptList [$key] ['verifyList'] = $verifyList;
  759. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  760. 'where' => 'sid=' . $value ['staff'],
  761. 'asArray' => true
  762. ) );
  763. $receiptList [$key] ['button'] = $button;
  764. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  765. }
  766. $mothHtml = "";
  767. for($i = 1; $i <= 12; $i ++) {
  768. if ($month == $i)
  769. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  770. else
  771. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  772. }
  773. // 获取审批日志
  774. Doo::loadModel ( 'receiptLog' );
  775. $receiptLog = new receiptLog ();
  776. $rlList = array ();
  777. $rlInfo = $receiptLog->getOne ( array (
  778. 'where' => 'rid=' . $rid . ' and status=4',
  779. 'asArray' => true
  780. ) );
  781. $tijdate = $receiptLog->getOne ( array (
  782. 'where' => 'rid=' . $rid . ' and status=2',
  783. 'asc' => 'rlid',
  784. 'asArray' => true
  785. ) );
  786. if (! empty ( $rlInfo )) {
  787. $rlList = $receiptLog->find ( array (
  788. 'where' => 'rid=' . $rid,
  789. 'asc' => 'rlid',
  790. 'asArray' => true
  791. ) );
  792. }
  793. $receiptList [0] ['rlList'] = $rlList;
  794. $enclosurList = $enclosur->find ( array (
  795. 'where' => 'rid=' . $rid,
  796. 'asArray' => true
  797. ) );
  798. $enclosurHtml = '';
  799. foreach ( $enclosurList as $value ) {
  800. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  801. }
  802. // print_r($receiptList);
  803. $data ['enclosurHtml'] = $enclosurHtml;
  804. $data ['rolename'] = $rolename ['name'];
  805. $data ['datetij'] = $tijdate ['date'];
  806. $data ['mothHtml'] = $mothHtml;
  807. $data ['rid'] = $rid;
  808. $data ['receiptList'] = $receiptList;
  809. $data ['receiptApprovalCount'] = count ( $receiptList );
  810. $data ['status'] = $status;
  811. $data ['year'] = $year;
  812. $data ['categoryList'] = $categoryList;
  813. $data ['staffList'] = $staffList;
  814. $data ['cid'] = $cid;
  815. $data ['sid'] = $sid;
  816. $data ['ap'] = $ap;
  817. $data ['memu'] = "receipt";
  818. $data ['staff'] = $this->staff;
  819. $data ['receiptMemu'] = 'approvalExpenses';
  820. $data ['verifyId'] = $this->verifyId;
  821. $data ['executeId'] = $this->executeId;
  822. $this->render ( "/admin/remitApproval", $data );
  823. }
  824. function saeaLoanAdd() {
  825. Doo::loadModel ( 'verify' );
  826. $verify = new verify ();
  827. Doo::loadModel ( "role" );
  828. $role = new role ();
  829. Doo::loadModel ( 'L_category' );
  830. $lCategory = new L_category ();
  831. $veList = $verify->getVerifyBySubordinate('LOAN');
  832. $data ['category'] = $lCategory->find ( array (
  833. 'asArray' => true
  834. ) );
  835. $data ['veList'] = $veList;
  836. $data ['memu'] = "receipt";
  837. $data ['staff'] = $this->staff;
  838. $data ['receiptMemu'] = 'saeaBorad';
  839. $data ['verifyId'] = $this->verifyId;
  840. $data ['executeId'] = $this->executeId;
  841. $this->render ( "/admin/saeaLoanAdd", $data );
  842. }
  843. function saeaLoanAddDo() {
  844. $agency = $this->get_args ( 'agency' );
  845. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  846. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  847. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  848. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  849. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  850. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  851. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  852. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  853. // die;
  854. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  855. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  856. header ( 'Content-Type:text/html;charset=utf-8' );
  857. die ( '请填写联行号' );
  858. }
  859. Doo::loadModel ( 'receipt' );
  860. Doo::loadModel ( 'receiptDetail' );
  861. Doo::loadModel ( 'accountItem' );
  862. $accountItem = new accountItem ();
  863. $receipt = new receipt ();
  864. Doo::loadModel ( 'loanReceipt' );
  865. $loanReceipt = new loanReceipt ();
  866. Doo::loadModel ( 'execute' );
  867. $execute = new execute ();
  868. Doo::loadModel ( 'enclosur' );
  869. $executeDetail = $execute->getOne ( array (
  870. 'where' => 'mold="借款执行人"',
  871. 'asArray' => true
  872. ) );
  873. $aItem = $accountItem->find ( array (
  874. 'asArray' => true
  875. ) );
  876. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  877. $ag = $tr = $ta = $ot = 0;
  878. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  879. array_push ( $accountJson ['借款费用'], array (
  880. 'aid' => 0,
  881. 'name' => '申请金额',
  882. 'price' => number_format ( $agency, 2, '.', '' )
  883. ) );
  884. $sum += $agency;
  885. $agencySum += $agency;
  886. $accountJson ['cSum'] = array (
  887. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  888. 'agencySum' => number_format ( 0, 2, '.', '' ),
  889. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  890. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  891. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  892. );
  893. // 借款数据备份
  894. $loanReceipt->loanItem = json_encode ( $accountJson );
  895. $loanReceipt->staff = $this->staff [0] ['sid'];
  896. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  897. $loanReceipt->date = date ( "Y-m-d" );
  898. $loanReceipt->cid = $cid;
  899. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  900. $loanReceipt->status = 5;
  901. $loanReceipt->Rtype = 1;
  902. $loanReceipt->verify = $verify;
  903. $receipt->receiptOrder = $receipt->receiptOrder;
  904. // 添加HTML换行符
  905. // var_dump($explanation);
  906. $order = array (
  907. "\r\n",
  908. "\n",
  909. "\r"
  910. );
  911. $replace = '<br/>';
  912. $explanation = str_replace ( $order, $replace, $explanation );
  913. // $explanation=str_replace('\r',"<br/>",$explanation);
  914. // $explanation=str_replace('\r\n',"<br/>",$explanation);
  915. $loanReceipt->explanation = $explanation;
  916. $loanRid = $loanReceipt->insert ();
  917. // 报销单
  918. $receipt->loanItem = json_encode ( $accountJson );
  919. $receipt->staff = $this->staff [0] ['sid'];
  920. $receipt->sum = number_format ( $sum, 2, '.', '' );
  921. $receipt->date = date ( "Y-m-d" );
  922. $receipt->cid = $cid;
  923. // 特殊状态
  924. $receipt->status = 5;
  925. $receipt->Rtype = 1;
  926. $receipt->loanRid = $loanRid;
  927. // 修改审批流程加入角色
  928. $receipt->verify = $verify;
  929. $receipt->executeCopy = $executeDetail ['staff'];
  930. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  931. $receipt->explanation = $explanation;
  932. $receipt->remittanceName = $remittanceName;
  933. $receipt->bankName = $bankName;
  934. $receipt->bankNumber = $bankNumber;
  935. $receipt->remittanceBankType = $remittanceBankType;
  936. if ($remittanceBankType == 1)
  937. $receipt->coupletNumber = $coupletNumber;
  938. $rid = $receipt->insert ();
  939. return "/saeaBorad";
  940. } else
  941. die ( 'illegal request' );
  942. }
  943. function saeaLoanEdi() {
  944. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  945. Doo::loadClass ( 'XDeode' );
  946. $XDeode = new XDeode ( 7 );
  947. $rid = $XDeode->decode ( $ridKey );
  948. if (! is_numeric ( $rid ))
  949. die ( 'illegal request' );
  950. Doo::loadModel ( 'verify' );
  951. $verify = new verify ();
  952. Doo::loadModel ( "role" );
  953. $role = new role ();
  954. Doo::loadModel ( 'L_category' );
  955. $lCategory = new L_category ();
  956. Doo::loadModel ( 'receipt' );
  957. $receipt = new receipt ();
  958. $receiptInfo = $receipt->getOne ( array (
  959. 'where' => 'rid=' . $rid,
  960. 'asArray' => true
  961. ) );
  962. $veList = $verify->find ( array (
  963. 'where'=>'subordinate like "%LOAN%"',
  964. 'asArray' => true
  965. ) );
  966. foreach ( $veList as $key => $value ) {
  967. $v = json_decode ( $value ['staff'] );
  968. $list = array ();
  969. foreach ( $v as $n => $m ) {
  970. if ($m ['1'] == 'ROLE') {
  971. $roleInfo = $role->getOne ( array (
  972. 'where' => 'rid=' . $m [0],
  973. 'asArray' => true
  974. ) );
  975. $v [$n] [1] = $roleInfo ['name'];
  976. array_push ( $list, $roleInfo ['name'] );
  977. } else {
  978. array_push ( $list, $v [$n] [1] );
  979. }
  980. }
  981. $veList [$key] ['staff'] = implode ( '>', $list );
  982. }
  983. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  984. // print_r($receiptInfo);
  985. $data ['receiptInfo'] = $receiptInfo;
  986. $data ['category'] = $lCategory->find ( array (
  987. 'asArray' => true
  988. ) );
  989. $data ['veList'] = $veList;
  990. $data ['ridKey'] = $ridKey;
  991. $data ['memu'] = "receipt";
  992. $data ['staff'] = $this->staff;
  993. $data ['receiptMemu'] = 'saeaBorad';
  994. $data ['verifyId'] = $this->verifyId;
  995. $data ['executeId'] = $this->executeId;
  996. $this->render ( "/admin/saeaLoanEdi", $data );
  997. }
  998. function saeaLoanEdiDo() {
  999. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1000. $agency = $this->get_args ( 'agency' );
  1001. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1002. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1003. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1004. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1005. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1006. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1007. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1008. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1009. // die;
  1010. Doo::loadClass ( 'XDeode' );
  1011. $XDeode = new XDeode ( 7 );
  1012. $rid = $XDeode->decode ( $ridKey );
  1013. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1014. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1015. header ( 'Content-Type:text/html;charset=utf-8' );
  1016. die ( '请填写联行号' );
  1017. }
  1018. Doo::loadModel ( 'receipt' );
  1019. Doo::loadModel ( 'receiptDetail' );
  1020. Doo::loadModel ( 'accountItem' );
  1021. $accountItem = new accountItem ();
  1022. $receipt = new receipt ();
  1023. Doo::loadModel ( 'loanReceipt' );
  1024. $loanReceipt = new loanReceipt ();
  1025. Doo::loadModel ( 'enclosur' );
  1026. Doo::loadModel ( 'execute' );
  1027. $execute = new execute ();
  1028. $executeDetail = $execute->getOne ( array (
  1029. 'where' => 'mold="借款执行人"',
  1030. 'asArray' => true
  1031. ) );
  1032. $receiptDetail = $receipt->getOne ( array (
  1033. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  1034. 'asArray' => true
  1035. ) );
  1036. if (empty ( $receiptDetail ))
  1037. die ( '参数错误' );
  1038. $aItem = $accountItem->find ( array (
  1039. 'asArray' => true
  1040. ) );
  1041. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1042. $ag = $tr = $ta = $ot = 0;
  1043. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1044. array_push ( $accountJson ['借款费用'], array (
  1045. 'aid' => 0,
  1046. 'name' => '申请金额',
  1047. 'price' => number_format ( $agency, 2, '.', '' )
  1048. ) );
  1049. $sum += $agency;
  1050. $agencySum += $agency;
  1051. $accountJson ['cSum'] = array (
  1052. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1053. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1054. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1055. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1056. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1057. );
  1058. // 报销单
  1059. $receipt->loanItem = json_encode ( $accountJson );
  1060. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1061. $receipt->cid = $cid;
  1062. // 特殊状态
  1063. // 修改审批流程加入角色
  1064. if ($receiptDetail ['status'] != 4)
  1065. $receipt->verify = $verify;
  1066. $order = array (
  1067. "\r\n",
  1068. "\n",
  1069. "\r"
  1070. );
  1071. $replace = '<br/>';
  1072. $explanation = str_replace ( $order, $replace, $explanation );
  1073. $receipt->explanation = $explanation;
  1074. $receipt->remittanceName = $remittanceName;
  1075. $receipt->bankName = $bankName;
  1076. $receipt->bankNumber = $bankNumber;
  1077. $receipt->remittanceBankType = $remittanceBankType;
  1078. if ($remittanceBankType == 1)
  1079. $receipt->coupletNumber = $coupletNumber;
  1080. $receipt->update ( array (
  1081. 'where' => 'rid=' . $rid
  1082. ) );
  1083. // 借款数据更新
  1084. $loanReceipt->loanItem = json_encode ( $accountJson );
  1085. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1086. $loanReceipt->cid = $cid;
  1087. if ($receiptDetail ['status'] != 4)
  1088. $loanReceipt->verify = $verify;
  1089. $loanReceipt->explanation = $explanation;
  1090. $receipt->executeCopy = $executeDetail ['staff'];
  1091. $loanReceipt->update ( array (
  1092. 'where' => 'rid=' . $receiptDetail ['loanRid']
  1093. ) );
  1094. }
  1095. return "/saeaBorad";
  1096. }
  1097. function saeaLoanReceiptAdd() {
  1098. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1099. Doo::loadModel ( 'receipt' );
  1100. $receipt = new receipt ();
  1101. Doo::loadModel ( 'loanReceipt' );
  1102. $loanReceipt = new loanReceipt ();
  1103. Doo::loadModel ( 'L_category' );
  1104. $Lcategory = new L_category ();
  1105. Doo::loadModel ( 'verify' );
  1106. Doo::loadModel ( 'statistics' );
  1107. $statistics = new statistics ();
  1108. $verify = new verify ();
  1109. Doo::loadModel ( 'staff' );
  1110. $staff = new staff ();
  1111. $receiptDetail = $receipt->getOne ( array (
  1112. 'where' => 'rid=' . $rid,
  1113. 'desc' => 'rid',
  1114. 'asArray' => true
  1115. ) );
  1116. $receiptList = $loanReceipt->find ( array (
  1117. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1118. 'desc' => 'rid',
  1119. 'asArray' => true
  1120. ) );
  1121. $Locate = 0;
  1122. $roleId = 0;
  1123. $button = 0;
  1124. foreach ( $receiptList as $key => $value ) {
  1125. $receiptList [$key] ['Locate'] = $Locate;
  1126. $Locate ++;
  1127. $receiptList [$key] ['reviseDetail'] = array ();
  1128. if (! empty ( $value ['reviseDetail'] ))
  1129. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1130. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1131. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1132. $categoryDetil = $Lcategory->getOne ( array (
  1133. 'where' => 'cid=' . $value ['cid'],
  1134. 'asArray' => true
  1135. ) );
  1136. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1137. // 检测编辑状态
  1138. $verifyList = $verify->getOne ( array (
  1139. 'where' => 'vid=' . $value ['verify'],
  1140. 'asArray' => true
  1141. ) );
  1142. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1143. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1144. Doo::loadModel ( 'role' );
  1145. $role = new role ();
  1146. $flag = true;
  1147. $roleKey = 0;
  1148. $endStaffArray = array ();
  1149. $roleArrayCopy = array ();
  1150. foreach ( $verifyList as $k => $v ) {
  1151. // init verifyStaff
  1152. if ($v [1] == 'ROLE') {
  1153. if (! empty ( $verifyStaff )) {
  1154. $endStaffArray = end ( $verifyStaff );
  1155. // if ($v[0]==$endStaffArray['nextStaff']){
  1156. // $roleId=$v[0];
  1157. // }
  1158. }
  1159. $roleVerify = json_decode ( $v [3], true );
  1160. $roleKey = $k;
  1161. $roleArray = array ();
  1162. $rolename = $role->getOne ( array (
  1163. 'where' => 'rid=' . $v [0],
  1164. 'asArray' => true
  1165. ) );
  1166. foreach ( $roleVerify as $o => $p ) {
  1167. $staffID = explode ( '_', $p );
  1168. $staffInfo = $staff->getOne ( array (
  1169. 'where' => 'sid=' . $staffID [0],
  1170. 'asArray' => true
  1171. ) );
  1172. // print_r($staffID);
  1173. $exp = array (
  1174. 0 => $staffInfo ['sid'],
  1175. 1 => $staffID [1],
  1176. 2 => $staffInfo ['avatar'],
  1177. 'date' => '',
  1178. 'date' => '',
  1179. 'opinion' => '',
  1180. 'status' => '',
  1181. 'rolename' => $rolename ['name']
  1182. );
  1183. array_push ( $roleArray, $exp );
  1184. }
  1185. $roleArrayCopy [$v [0]] = $roleArray;
  1186. // $verifyList[$k]['roleArray']=$roleArray;
  1187. }
  1188. $verifyList [$k] ['date'] = "";
  1189. $verifyList [$k] ['opinion'] = "";
  1190. $verifyList [$k] ['status'] = "";
  1191. if (empty ( $verifyStaff )) {
  1192. $verifyList [$k] ['date'] = "";
  1193. $verifyList [$k] ['opinion'] = "";
  1194. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1195. $verifyList [$k] ['status'] = 4;
  1196. $flag = false;
  1197. }
  1198. } else {
  1199. foreach ( $verifyStaff as $m => $u ) {
  1200. if ($v [0] == $m) {
  1201. $verifyList [$k] ['date'] = $u ['date'];
  1202. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1203. $verifyList [$k] ['status'] = $u ['status'];
  1204. $flag = false;
  1205. break;
  1206. }
  1207. }
  1208. $endStaffArray = end ( $verifyStaff );
  1209. if (isset ( $endStaffArray ['ROLE'] )) {
  1210. } else {
  1211. // $endKey=key($verifyStaff);
  1212. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1213. // $button=4;
  1214. // $verifyList[$k]['status']=4;
  1215. // }
  1216. }
  1217. }
  1218. }
  1219. $rolename ['name'] = '';
  1220. if (! empty ( $roleId )) {
  1221. Doo::loadModel ( 'role' );
  1222. $role = new role ();
  1223. $rolename = $role->getOne ( array (
  1224. 'where' => 'rid=' . $roleId,
  1225. 'asArray' => true
  1226. ) );
  1227. }
  1228. if (! empty ( $verifyStaff ))
  1229. $endStaffArray = end ( $verifyStaff );
  1230. $KOP = false;
  1231. foreach ( $roleArrayCopy as $P => $A ) {
  1232. foreach ( $A as $MKI => $AVL ) {
  1233. if (! empty ( $verifyStaff )) {
  1234. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1235. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1236. $button = 4;
  1237. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1238. }
  1239. foreach ( $verifyStaff as $m => $u ) {
  1240. $AVLFK = $AVL [0] . '_R';
  1241. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1242. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1243. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1244. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1245. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1246. break;
  1247. }
  1248. }
  1249. } else {
  1250. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1251. $button = 4;
  1252. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1253. }
  1254. }
  1255. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1256. $KOP = true;
  1257. }
  1258. }
  1259. foreach ( $roleArrayCopy as $k => $v ) {
  1260. foreach ( $verifyList as $m => $n ) {
  1261. if ($n [0] == $k) {
  1262. array_splice ( $verifyList, $m, 1, $v );
  1263. }
  1264. }
  1265. }
  1266. $receiptList [$key] ['verifyList'] = $verifyList;
  1267. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1268. 'where' => 'sid=' . $value ['staff'],
  1269. 'asArray' => true
  1270. ) );
  1271. $receiptList [$key] ['button'] = $button;
  1272. //
  1273. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1274. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1275. }
  1276. $data ['receiptList'] = $receiptList;
  1277. $data ['receiptDetail'] = $receiptDetail;
  1278. Doo::loadModel ( 'L_category' );
  1279. $lCategory = new L_category ();
  1280. Doo::loadModel ( 'accountItem' );
  1281. $accountItem = new accountItem ();
  1282. $acItem = $accountItem->find ( array (
  1283. 'asArray' => true
  1284. ) );
  1285. $veList = $verify->getVerifyBySubordinate('RECEIPT','LOAN');
  1286. $data ['rid'] = $rid;
  1287. $data ['category'] = $lCategory->find ( array (
  1288. 'asArray' => true
  1289. ) );
  1290. $data ['veList'] = $veList;
  1291. $data ['acItem'] = $acItem;
  1292. $data ['memu'] = "receipt";
  1293. $data ['staff'] = $this->staff;
  1294. $data ['receiptMemu'] = 'saeaBorad';
  1295. $data ['verifyId'] = $this->verifyId;
  1296. $data ['executeId'] = $this->executeId;
  1297. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1298. }
  1299. function saeaLoanReceiptAddDo() {
  1300. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1301. $agency = $this->get_args ( 'agency' );
  1302. $travel = $this->get_args ( 'travel' );
  1303. $train = $this->get_args ( 'train' );
  1304. $other = $this->get_args ( 'other' );
  1305. $inttrain = $this->get_args ( 'inttrain' );
  1306. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1307. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1308. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1309. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1310. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1311. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1312. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1313. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1314. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1315. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1316. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1317. header ( 'Content-Type:text/html;charset=utf-8' );
  1318. die ( '请填写联行号' );
  1319. }
  1320. Doo::loadModel ( 'receipt' );
  1321. Doo::loadModel ( 'receiptDetail' );
  1322. Doo::loadModel ( 'accountItem' );
  1323. $accountItem = new accountItem ();
  1324. $receipt = new receipt ();
  1325. Doo::loadModel ( 'enclosur' );
  1326. Doo::loadModel ( 'execute' );
  1327. $execute = new execute ();
  1328. $executeDetail = $execute->getOne ( array (
  1329. 'where' => 'mold="借款费用执行人"',
  1330. 'asArray' => true
  1331. ) );
  1332. $receiptDet = $receipt->getOne ( array (
  1333. 'where' => 'rid=' . $rid,
  1334. 'asArray' => true
  1335. ) );
  1336. // if(!empty($receiptDetail))
  1337. // return "/referReceipt/".$receiptDetail['rid'];
  1338. $aItem = $accountItem->find ( array (
  1339. 'asArray' => true
  1340. ) );
  1341. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1342. $ag = $tr = $ta = $ot =$it = 0;
  1343. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  1344. foreach ( $aItem as $key => $value ) {
  1345. if ($value ['category'] == $this->AGENCY) {
  1346. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1347. array_push ( $accountJson [$this->AGENCY], array (
  1348. 'aid' => $value ['aid'],
  1349. 'name' => $value ['name'],
  1350. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1351. ) );
  1352. $sum += $agency [$ag];
  1353. $agencySum += $agency [$ag];
  1354. }
  1355. $ag ++;
  1356. }
  1357. if ($value ['category'] == $this->TRAVEL) {
  1358. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1359. array_push ( $accountJson [$this->TRAVEL], array (
  1360. 'aid' => $value ['aid'],
  1361. 'name' => $value ['name'],
  1362. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1363. ) );
  1364. $sum += $travel [$tr];
  1365. $travelSum += $travel [$tr];
  1366. }
  1367. $tr ++;
  1368. }
  1369. if ($value ['category'] == $this->INTTRAIN) {
  1370. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  1371. array_push ( $accountJson [$this->INTTRAIN], array (
  1372. 'aid' => $value ['aid'],
  1373. 'name' => $value ['name'],
  1374. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  1375. ) );
  1376. $sum += $inttrain [$it];
  1377. $inttrainSum += $inttrain [$it];
  1378. }
  1379. $it ++;
  1380. }
  1381. if ($value ['category'] == $this->TRAIN) {
  1382. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1383. array_push ( $accountJson [$this->TRAIN], array (
  1384. 'aid' => $value ['aid'],
  1385. 'name' => $value ['name'],
  1386. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1387. ) );
  1388. $sum += $train [$ta];
  1389. $trainSum += $train [$ta];
  1390. }
  1391. $ta ++;
  1392. }
  1393. if ($value ['category'] == $this->OTHER) {
  1394. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1395. array_push ( $accountJson [$this->OTHER], array (
  1396. 'aid' => $value ['aid'],
  1397. 'name' => $value ['name'],
  1398. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1399. ) );
  1400. $sum += $other [$ot];
  1401. $otherSum += $other [$ot];
  1402. }
  1403. $ot ++;
  1404. }
  1405. }
  1406. $accountJson ['cSum'] = array (
  1407. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1408. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1409. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1410. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  1411. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1412. );
  1413. // 报销单
  1414. $receipt->accountItem = json_encode ( $accountJson );
  1415. $receipt->staff = $this->staff [0] ['sid'];
  1416. $receipt->loanSum = $receiptDet ['sum'];
  1417. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1418. $receipt->date = date ( "Y-m-d" );
  1419. $receipt->pastDate = '';
  1420. $receipt->cid = $cid;
  1421. $receipt->status = 7;
  1422. // 修改审批流程加入角色
  1423. $receipt->verify = $verify;
  1424. $receipt->verifyStaff = '';
  1425. $receipt->executeStaff = '';
  1426. $receipt->executeCopy = $executeDetail ['staff'];
  1427. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1428. $receipt->explanation = $explanation;
  1429. $receipt->remittanceName = $remittanceName;
  1430. $receipt->bankName = $bankName;
  1431. $receipt->bankNumber = $bankNumber;
  1432. $receipt->remittanceBankType = $remittanceBankType;
  1433. if ($remittanceBankType == 1)
  1434. $receipt->coupletNumber = $coupletNumber;
  1435. $receipt->update ( array (
  1436. 'where' => 'rid=' . $rid
  1437. ) );
  1438. // 附件
  1439. if (! empty ( $enclosurName )) {
  1440. $enclosurArray = explode ( '-', $enclosurName );
  1441. foreach ( $enclosurArray as $value ) {
  1442. $enclosur = new enclosur ();
  1443. $enclosur->name = $value;
  1444. $enclosur->rid = $rid;
  1445. $enclosur->insert ();
  1446. }
  1447. // print_r($enclosurArray);die;
  1448. }
  1449. // 报销详情
  1450. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1451. $receiptDetail = new receiptDetail ();
  1452. $receiptDetail->staff = $this->staff [0] ['sid'];
  1453. $receiptDetail->item = $value ['name'];
  1454. $receiptDetail->itemCategory = $this->AGENCY;
  1455. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1456. $receiptDetail->date = date ( "Y-m-d" );
  1457. $receiptDetail->cid = $cid;
  1458. $receiptDetail->rid = $rid;
  1459. $receiptDetail->status = 4;
  1460. $receiptDetail->insert ();
  1461. }
  1462. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1463. $receiptDetail = new receiptDetail ();
  1464. $receiptDetail->staff = $this->staff [0] ['sid'];
  1465. $receiptDetail->item = $value ['name'];
  1466. $receiptDetail->itemCategory = $this->TRAVEL;
  1467. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1468. $receiptDetail->date = date ( "Y-m-d" );
  1469. $receiptDetail->cid = $cid;
  1470. $receiptDetail->rid = $rid;
  1471. $receiptDetail->status = 4;
  1472. $receiptDetail->insert ();
  1473. }
  1474. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1475. $receiptDetail = new receiptDetail ();
  1476. $receiptDetail->staff = $this->staff [0] ['sid'];
  1477. $receiptDetail->item = $value ['name'];
  1478. $receiptDetail->itemCategory = $this->TRAIN;
  1479. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1480. $receiptDetail->date = date ( "Y-m-d" );
  1481. $receiptDetail->cid = $cid;
  1482. $receiptDetail->rid = $rid;
  1483. $receiptDetail->status = 4;
  1484. $receiptDetail->insert ();
  1485. }
  1486. //内训
  1487. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  1488. $receiptDetail = new receiptDetail ();
  1489. $receiptDetail->staff = $this->staff [0] ['sid'];
  1490. $receiptDetail->item = $value ['name'];
  1491. $receiptDetail->itemCategory = $this->INTTRAIN;
  1492. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1493. $receiptDetail->date = date ( "Y-m-d" );
  1494. $receiptDetail->cid = $cid;
  1495. $receiptDetail->rid = $rid;
  1496. $receiptDetail->status = 4;
  1497. $receiptDetail->insert ();
  1498. }
  1499. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1500. $receiptDetail = new receiptDetail ();
  1501. $receiptDetail->staff = $this->staff [0] ['sid'];
  1502. $receiptDetail->item = $value ['name'];
  1503. $receiptDetail->itemCategory = $this->OTHER;
  1504. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1505. $receiptDetail->date = date ( "Y-m-d" );
  1506. $receiptDetail->cid = $cid;
  1507. $receiptDetail->rid = $rid;
  1508. $receiptDetail->status = 4;
  1509. $receiptDetail->insert ();
  1510. }
  1511. return "/saeaBorad";
  1512. }
  1513. return "/saeaLoanReceiptAdd/" . $rid;
  1514. }
  1515. function saeaLoanReceiptEdi() {
  1516. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1517. Doo::loadClass ( 'XDeode' );
  1518. $XDeode = new XDeode ( 7 );
  1519. $rid = $XDeode->decode ( $ridKey );
  1520. if (! is_numeric ( $rid ))
  1521. die ( 'illegal request' );
  1522. Doo::loadModel ( 'accountItem' );
  1523. Doo::loadModel ( 'verify' );
  1524. Doo::loadModel ( 'receipt' );
  1525. $receipt = new receipt ();
  1526. $verify = new verify ();
  1527. $accountItem = new accountItem ();
  1528. Doo::loadModel ( 'L_category' );
  1529. $Lcategory = new L_category ();
  1530. Doo::loadModel ( "role" );
  1531. $role = new role ();
  1532. Doo::loadModel ( 'loanReceipt' );
  1533. $loanReceipt = new loanReceipt ();
  1534. Doo::loadModel ( 'staff' );
  1535. $staff = new staff ();
  1536. $receiptDetail = $receipt->getOne ( array (
  1537. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1538. 'asArray' => true
  1539. ) );
  1540. if (empty ( $receiptDetail ))
  1541. return "/saeaBorad";
  1542. $receiptList = $loanReceipt->find ( array (
  1543. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1544. 'desc' => 'rid',
  1545. 'asArray' => true
  1546. ) );
  1547. $Locate = 0;
  1548. $roleId = 0;
  1549. $button = 0;
  1550. foreach ( $receiptList as $key => $value ) {
  1551. $receiptList [$key] ['Locate'] = $Locate;
  1552. $Locate ++;
  1553. $receiptList [$key] ['reviseDetail'] = array ();
  1554. if (! empty ( $value ['reviseDetail'] ))
  1555. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1556. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1557. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1558. $categoryDetil = $Lcategory->getOne ( array (
  1559. 'where' => 'cid=' . $value ['cid'],
  1560. 'asArray' => true
  1561. ) );
  1562. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1563. // 检测编辑状态
  1564. $verifyList = $verify->getOne ( array (
  1565. 'where' => 'vid=' . $value ['verify'],
  1566. 'asArray' => true
  1567. ) );
  1568. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1569. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1570. Doo::loadModel ( 'role' );
  1571. $role = new role ();
  1572. $flag = true;
  1573. $roleKey = 0;
  1574. $endStaffArray = array ();
  1575. $roleArrayCopy = array ();
  1576. foreach ( $verifyList as $k => $v ) {
  1577. // init verifyStaff
  1578. if ($v [1] == 'ROLE') {
  1579. if (! empty ( $verifyStaff )) {
  1580. $endStaffArray = end ( $verifyStaff );
  1581. // if ($v[0]==$endStaffArray['nextStaff']){
  1582. // $roleId=$v[0];
  1583. // }
  1584. }
  1585. $roleVerify = json_decode ( $v [3], true );
  1586. $roleKey = $k;
  1587. $roleArray = array ();
  1588. $rolename = $role->getOne ( array (
  1589. 'where' => 'rid=' . $v [0],
  1590. 'asArray' => true
  1591. ) );
  1592. foreach ( $roleVerify as $o => $p ) {
  1593. $staffID = explode ( '_', $p );
  1594. $staffInfo = $staff->getOne ( array (
  1595. 'where' => 'sid=' . $staffID [0],
  1596. 'asArray' => true
  1597. ) );
  1598. // print_r($staffID);
  1599. $exp = array (
  1600. 0 => $staffInfo ['sid'],
  1601. 1 => $staffID [1],
  1602. 2 => $staffInfo ['avatar'],
  1603. 'date' => '',
  1604. 'date' => '',
  1605. 'opinion' => '',
  1606. 'status' => '',
  1607. 'rolename' => $rolename ['name']
  1608. );
  1609. array_push ( $roleArray, $exp );
  1610. }
  1611. $roleArrayCopy [$v [0]] = $roleArray;
  1612. // $verifyList[$k]['roleArray']=$roleArray;
  1613. }
  1614. $verifyList [$k] ['date'] = "";
  1615. $verifyList [$k] ['opinion'] = "";
  1616. $verifyList [$k] ['status'] = "";
  1617. if (empty ( $verifyStaff )) {
  1618. $verifyList [$k] ['date'] = "";
  1619. $verifyList [$k] ['opinion'] = "";
  1620. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1621. $verifyList [$k] ['status'] = 4;
  1622. $flag = false;
  1623. }
  1624. } else {
  1625. foreach ( $verifyStaff as $m => $u ) {
  1626. if ($v [0] == $m) {
  1627. $verifyList [$k] ['date'] = $u ['date'];
  1628. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1629. $verifyList [$k] ['status'] = $u ['status'];
  1630. $flag = false;
  1631. break;
  1632. }
  1633. }
  1634. $endStaffArray = end ( $verifyStaff );
  1635. if (isset ( $endStaffArray ['ROLE'] )) {
  1636. } else {
  1637. // $endKey=key($verifyStaff);
  1638. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1639. // $button=4;
  1640. // $verifyList[$k]['status']=4;
  1641. // }
  1642. }
  1643. }
  1644. }
  1645. $rolename ['name'] = '';
  1646. if (! empty ( $roleId )) {
  1647. Doo::loadModel ( 'role' );
  1648. $role = new role ();
  1649. $rolename = $role->getOne ( array (
  1650. 'where' => 'rid=' . $roleId,
  1651. 'asArray' => true
  1652. ) );
  1653. }
  1654. if (! empty ( $verifyStaff ))
  1655. $endStaffArray = end ( $verifyStaff );
  1656. $KOP = false;
  1657. foreach ( $roleArrayCopy as $P => $A ) {
  1658. foreach ( $A as $MKI => $AVL ) {
  1659. if (! empty ( $verifyStaff )) {
  1660. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1661. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1662. $button = 4;
  1663. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1664. }
  1665. foreach ( $verifyStaff as $m => $u ) {
  1666. $AVLFK = $AVL [0] . '_R';
  1667. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1668. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1669. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1670. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1671. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1672. break;
  1673. }
  1674. }
  1675. } else {
  1676. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1677. $button = 4;
  1678. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1679. }
  1680. }
  1681. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1682. $KOP = true;
  1683. }
  1684. }
  1685. foreach ( $roleArrayCopy as $k => $v ) {
  1686. foreach ( $verifyList as $m => $n ) {
  1687. if ($n [0] == $k) {
  1688. array_splice ( $verifyList, $m, 1, $v );
  1689. }
  1690. }
  1691. }
  1692. $receiptList [$key] ['verifyList'] = $verifyList;
  1693. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1694. 'where' => 'sid=' . $value ['staff'],
  1695. 'asArray' => true
  1696. ) );
  1697. $receiptList [$key] ['button'] = $button;
  1698. //
  1699. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1700. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1701. }
  1702. $data ['receiptList'] = $receiptList;
  1703. $acItem = $accountItem->find ( array (
  1704. 'asArray' => true
  1705. ) );
  1706. $veList = $verify->find ( array (
  1707. 'asArray' => true
  1708. ) );
  1709. foreach ( $veList as $key => $value ) {
  1710. $v = json_decode ( $value ['staff'] );
  1711. $list = array ();
  1712. foreach ( $v as $n => $m ) {
  1713. if ($m ['1'] == 'ROLE') {
  1714. $roleInfo = $role->getOne ( array (
  1715. 'where' => 'rid=' . $m [0],
  1716. 'asArray' => true
  1717. ) );
  1718. $v [$n] [1] = $roleInfo ['name'];
  1719. array_push ( $list, $roleInfo ['name'] );
  1720. } else {
  1721. array_push ( $list, $v [$n] [1] );
  1722. }
  1723. }
  1724. $veList [$key] ['staff'] = implode ( '>', $list );
  1725. }
  1726. // 配置编辑信息
  1727. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1728. foreach ( $acItem as $key => $value ) {
  1729. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1730. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1731. $acItem [$key] ['price'] = $v ['price'];
  1732. }
  1733. }
  1734. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1735. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1736. $acItem [$key] ['price'] = $v ['price'];
  1737. }
  1738. }
  1739. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1740. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1741. $acItem [$key] ['price'] = $v ['price'];
  1742. }
  1743. }
  1744. //内训
  1745. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  1746. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1747. $acItem [$key] ['price'] = $v ['price'];
  1748. }
  1749. }
  1750. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1751. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1752. $acItem [$key] ['price'] = $v ['price'];
  1753. }
  1754. }
  1755. }
  1756. $data ['category'] = $Lcategory->find ( array (
  1757. 'asArray' => true
  1758. ) );
  1759. $data ['ridKey'] = $ridKey;
  1760. $data ['cSum'] = $accountItemList ['cSum'];
  1761. $data ['sum'] = $receiptDetail ['sum'];
  1762. $data ['receiptDetail'] = $receiptDetail;
  1763. $data ['veList'] = $veList;
  1764. $data ['acItem'] = $acItem;
  1765. $data ['memu'] = "receipt";
  1766. $data ['staff'] = $this->staff;
  1767. $data ['receiptMemu'] = 'saeaBorad';
  1768. $data ['verify'] = $receiptDetail ['verify'];
  1769. $data ['verifyId'] = $this->verifyId;
  1770. $data ['executeId'] = $this->executeId;
  1771. $data ['rid'] = $rid;
  1772. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1773. }
  1774. /**
  1775. * 培训班结算
  1776. */
  1777. function receiptTrainAdd() {
  1778. Doo::loadModel ( 'accountItem' );
  1779. $accountItem = new accountItem ();
  1780. $acItem = $accountItem->find ( array (
  1781. 'asArray' => true
  1782. ) );
  1783. // 审批组
  1784. Doo::loadModel ( 'verify' );
  1785. $verify = new verify ();
  1786. $veList = $verify->getVerifyBySubordinate('TRAIN');
  1787. // 办事处
  1788. Doo::loadModel ( 'L_category' );
  1789. $lCategory = new L_category ();
  1790. $data ['category'] = $lCategory->getCategory ();
  1791. $data ['veList'] = $veList;
  1792. $data ['memu'] = "receipt";
  1793. $data ['staff'] = $this->staff;
  1794. $data ['acItem'] = $acItem;
  1795. $data ['receiptMemu'] = 'saeaBorad';
  1796. $data ['verifyId'] = $this->verifyId;
  1797. $data ['executeId'] = $this->executeId;
  1798. $this->render ( "/receipt/receiptTrainAdd", $data );
  1799. }
  1800. /**
  1801. * 添加培训班结算
  1802. */
  1803. function receiptTrainAddDo() {//include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  1804. // 培训班信息
  1805. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  1806. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  1807. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  1808. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  1809. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  1810. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  1811. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  1812. // 发票信息
  1813. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1814. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  1815. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1816. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1817. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1818. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1819. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1820. //&&! empty ( $participants )
  1821. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  1822. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1823. header ( 'Content-Type:text/html;charset=utf-8' );
  1824. die ( '请填写联行号' );
  1825. }
  1826. Doo::loadModel ( 'execute' );
  1827. $execute = new execute ();
  1828. $executeDetail = $execute->getOne ( array (
  1829. 'where' => 'mold="培训班结算"',
  1830. 'asArray' => true
  1831. ) );
  1832. if (empty ( $executeDetail )) {
  1833. header ( 'Content-Type:text/html;charset=utf-8' );
  1834. die ( '未设置执行人' );
  1835. }
  1836. Doo::loadClass ( 'XDeode' );
  1837. $XDeode = new XDeode ( 5 );
  1838. $cid = $XDeode->decode ( $cid );
  1839. Doo::loadModel ( 'receipt' );
  1840. $receipt = new receipt ();
  1841. Doo::loadModel ( 'receiptTraining' );
  1842. $receiptTraining = new receiptTraining ();
  1843. // 创建费用培训班
  1844. $item = array (
  1845. 'cid' => $this->staff [0] ['cid'],
  1846. 'categoryName' => $this->staff [0] ['category'],
  1847. 'trainName' => $trainName,
  1848. 'trainStartDate' => $trainStartDate,
  1849. 'trainEndDate' => $trainEndDate,
  1850. 'participants' => $participants,
  1851. 'freeParticipants'=>$freeParticipants,
  1852. 'trainAddress' => $trainAddress,
  1853. 'trainRemarks' => $trainRemarks,
  1854. 'creator' => $this->staff [0] ['sid'],
  1855. 'creatorDate' => date ( "Y-m-d H:i:s" )
  1856. );
  1857. $irid = $receiptTraining->addReceiptTraining ( $item );
  1858. // 报销单
  1859. $receipt->status = 5;
  1860. $receipt->trainId = $irid;
  1861. $receipt->Rtype = 3;
  1862. $receipt->staff = $this->staff [0] ['sid'];
  1863. $receipt->cid = $cid;
  1864. $receipt->verify = $verify;
  1865. $receipt->date = date ( "Y-m-d" );
  1866. $receipt->executeCopy = $executeDetail ['staff'];
  1867. $receipt->receiptOrder = "#P" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1868. $receipt->remittanceName = $remittanceName;
  1869. $receipt->bankName = $bankName;
  1870. $receipt->bankNumber = $bankNumber;
  1871. $receipt->remittanceBankType = $remittanceBankType;
  1872. if ($remittanceBankType == 1)
  1873. $receipt->coupletNumber = $coupletNumber;
  1874. $rid = $receipt->insert ();
  1875. $XDeode = new XDeode ( 7 );
  1876. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html";
  1877. } else
  1878. die ( 'illegal request' );
  1879. }
  1880. /**
  1881. * 培训班编辑
  1882. */
  1883. function receiptTrainEdi() {
  1884. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  1885. $trainEdiType = $this->get_args ( 'trainEdiType' ) ? $this->get_args ( 'trainEdiType' ) : "INFO";
  1886. Doo::loadClass ( 'XDeode' );
  1887. $XDeode = new XDeode ( 7 );
  1888. $rid = $XDeode->decode ( $ridKey );
  1889. if (! is_numeric ( $rid ))
  1890. die ( 'illegal request' );
  1891. Doo::loadModel ( 'receipt' );
  1892. $receipt = new receipt ();
  1893. Doo::loadModel ( 'receiptTraining' );
  1894. $receiptTraining = new receiptTraining ();
  1895. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  1896. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)){
  1897. die ('illegal request--status');
  1898. }
  1899. //如有已入账已收款的发票,自动取消办事处已收款
  1900. // Doo::loadModel ( 'RIExtend' );
  1901. // $RIExtend = new RIExtend ();
  1902. // $RIExtendList=$RIExtend->getRIExtendByRid($rid);
  1903. // if (!empty($RIExtendList)){
  1904. // foreach ($RIExtendList as $key=>$value){
  1905. // $RIExtend = new RIExtend ();
  1906. // $RIExtend->delete(array (
  1907. // 'where' => 'iid=' . $value['iid'],
  1908. // 'limit' => 1
  1909. // ));
  1910. // }
  1911. // }
  1912. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  1913. // 汇总表合计
  1914. // 收入合计--加入开票合计
  1915. Doo::loadModel ( 'invoiceTraining' );
  1916. $invoiceTraining = new invoiceTraining ();
  1917. $invoiceTrainingDetail = array (
  1918. 'invoiceArriveAmount' => 0,
  1919. 'RIAmount' => 0,
  1920. 'invoiceTotalAmount' => 0,
  1921. 'invoiceCompanyAmount'=>0
  1922. );
  1923. if ($receiptDetail ['invoiceTrainId'] != 0) {
  1924. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  1925. }
  1926. // print_r($invoiceTrainingDetail);
  1927. $invoiceArriveAmount = $RIAmount = 0;
  1928. if (! empty ( $invoiceTrainingDetail )) {
  1929. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  1930. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  1931. }
  1932. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  1933. //print_r($invoiceTrainingDetail);
  1934. // 支出项目
  1935. Doo::loadModel ( 'accountItem' );
  1936. $accountItem = new accountItem ();
  1937. // 项目金额合计
  1938. Doo::loadModel ( 'RItem' );
  1939. $RItem = new RItem ();
  1940. // 讲师获得
  1941. Doo::loadModel ( 'RILecturer' );
  1942. $RILecturer = new RILecturer ();
  1943. $RItemList = $RItem->getRItemByRid ( $rid );
  1944. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  1945. // 支出项金额详情
  1946. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  1947. // print_r($aiData);
  1948. // 利润
  1949. $profit=$invoiceArriveAmount - $aiData ['total'];
  1950. $companyProfit=$profit * 0.6;
  1951. $categoryProfit=$profit * 0.4;
  1952. $data ['profit'] = sprintf("%.2f",$profit);
  1953. $data ['companyProfit'] = sprintf("%.2f",$companyProfit);
  1954. $data ['categoryProfit'] = sprintf("%.2f",$categoryProfit);
  1955. //发票利润
  1956. $data ['invoiceProfit'] = $invoiceTrainingDetail ['invoiceTotalAmount'] - $aiData ['total'];
  1957. //发票公司利润
  1958. $invoiceCompanyProfit=$data ['invoiceProfit'] * 0.6;
  1959. $data ['invoiceCompanyProfit'] = sprintf("%.2f",$invoiceCompanyProfit);
  1960. //办事处利润
  1961. $invoiceCategoryProfit=$data ['invoiceProfit'] * 0.4;
  1962. $data ['invoiceCategoryProfit'] = sprintf("%.2f",$invoiceCategoryProfit);
  1963. // print_r($aiData['dataList']);
  1964. $categoryActualExpenditure= $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  1965. $data ['categoryActualExpenditure'] = sprintf("%.2f",$categoryActualExpenditure);
  1966. // 备用金
  1967. $sum = 0;
  1968. $data ['receiptLoanDetail'] = array (
  1969. 'sum' => '0.00'
  1970. );
  1971. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  1972. $data ['receiptLoanDetail'] = $receipt->getReceiptByRid ( $receiptDetail ['trainLoanRid'] );
  1973. $sum = $data ['receiptLoanDetail'] ['sum'];
  1974. }
  1975. $payment=$sum + $RIAmount - $categoryActualExpenditure;
  1976. $data ['payment'] = sprintf("%.2f",$payment);
  1977. $data ['total'] = sprintf("%.2f",$aiData ['total']);
  1978. $data ['aiCount'] = count ( $aiData ['dataList'] ) + 5;
  1979. $data ['aiList'] = $aiData ['dataList'];
  1980. // 占比计算
  1981. if ($invoiceArriveAmount != 0) {
  1982. $data ['totalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceArriveAmount* 100) ;
  1983. $data ['profitProportion'] = sprintf("%.2f",$profit / $invoiceArriveAmount*100) ; //number_format ( $profit / $invoiceArriveAmount, 2, '.', '' ) * 100;
  1984. $data ['sumProportion'] = sprintf("%.2f",$sum / $invoiceArriveAmount*100) ; //number_format ( $sum / $invoiceArriveAmount, 2, '.', '' ) * 100;
  1985. $data ['invoiceTotalAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceArriveAmount*100) ;
  1986. $data ['RIAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceArriveAmount*100) ;
  1987. $data ['companyProfitProportion'] = sprintf("%.2f",$companyProfit / $invoiceArriveAmount*100) ;
  1988. $data ['categoryProportion'] = sprintf("%.2f",$categoryProfit / $invoiceArriveAmount*100) ;
  1989. $data ['categoryActualExpenditureProportion'] = sprintf("%.2f",$categoryActualExpenditure / $invoiceArriveAmount*100) ;
  1990. $data ['paymentProportion'] = sprintf("%.2f",$payment / $invoiceArriveAmount*100) ;
  1991. } else {
  1992. $data ['totalProportion'] = $data ['profitProportion'] = $data ['sumProportion'] = $data ['invoiceTotalAmountProportion'] = $data ['RIAmountProportion'] = $data ['companyProfitProportion'] = $data ['categoryActualExpenditureProportion'] = $data ['paymentProportion'] = $data ['categoryProportion'] = 0;
  1993. }
  1994. //发票金额占比计算
  1995. if ($invoiceTrainingDetail ['invoiceTotalAmount'] != 0) {
  1996. //支出
  1997. $data ['invoicetotalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  1998. //利润
  1999. $data ['invoiceprofitProportion'] = sprintf("%.2f",$data ['invoiceProfit'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2000. //公司利润
  2001. $data ['invoicecompanyProfitProportion'] = sprintf("%.2f", $invoiceCompanyProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2002. //办事处利润
  2003. $data ['invoicecategoryProportion'] = sprintf("%.2f", $invoiceCategoryProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2004. //公司收款
  2005. $data ['invoiceTotalAmountProportionB'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2006. //备用金
  2007. $data ['invoicesumProportion'] = sprintf("%.2f", $sum / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2008. //办事处收款
  2009. $data ['invoiceRIAmountProportion'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2010. //办事处实际支出
  2011. $data ['ICAEP'] = sprintf("%.2f", $categoryActualExpenditure / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2012. //付总部款
  2013. $data ['invoicepaymentProportion'] = sprintf("%.2f", $payment / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2014. }else{
  2015. $data ['invoiceprofitProportion'] =$data ['invoiceRIAmountProportion'] =$data ['invoicetotalProportion'] =$data ['invoiceTotalAmountProportionB'] =$data ['invoicesumProportion'] =$data ['ICAEP'] =$data ['invoicepaymentProportion'] =$data ['invoicecompanyProfitProportion'] =$data ['invoicecategoryProportion'] =0;
  2016. }
  2017. //讲师人数
  2018. Doo::loadModel ( 'RILecturer' );
  2019. $RILecturer = new RILecturer ();
  2020. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2021. $data['lectureCount']=count($RILecturerList);
  2022. // 审批组
  2023. Doo::loadModel ( 'verify' );
  2024. $verify = new verify ();
  2025. $veList = $verify->getVerifyBySubordinate('TRAIN');
  2026. // 办事处
  2027. Doo::loadModel ( 'L_category' );
  2028. $lCategory = new L_category ();
  2029. $data ['category'] = $lCategory->getCategory ();
  2030. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2031. $data ['receiptDetail'] = $receiptDetail;
  2032. $data ['veList'] = $veList;
  2033. $data ['trainEdiType'] = $trainEdiType;
  2034. $data ['ridKey'] = $ridKey;
  2035. $data ['memu'] = "receipt";
  2036. $data ['staff'] = $this->staff;
  2037. $data ['receiptMemu'] = 'saeaBorad';
  2038. $data ['verifyId'] = $this->verifyId;
  2039. $data ['executeId'] = $this->executeId;
  2040. $this->render ( "/receipt/receiptTrainEdi", $data );
  2041. }
  2042. /**
  2043. * 培训班借款编辑
  2044. */
  2045. function receiptTrainLoanEdi() {
  2046. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2047. Doo::loadClass ( 'XDeode' );
  2048. $XDeode = new XDeode ( 7 );
  2049. $rid = $XDeode->decode ( $ridKey );
  2050. if (! is_numeric ( $rid ))
  2051. die ( 'illegal request' );
  2052. Doo::loadModel ( 'receipt' );
  2053. $receipt = new receipt ();
  2054. Doo::loadModel ( 'receiptTraining' );
  2055. $receiptTraining = new receiptTraining ();
  2056. Doo::loadModel ( 'verify' );
  2057. $verify = new verify ();
  2058. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2059. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  2060. die ();
  2061. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2062. // 借款详情HTML
  2063. // 获得借款信息
  2064. $receiptLoanHtml = '';
  2065. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  2066. $receiptLoanDetail = $receipt->getReceiptByRid ( $receiptDetail ['trainLoanRid'] );
  2067. // 获得某费用单审批信息
  2068. $verifylist = $verify->getVerifyByRid ( $receiptDetail ['trainLoanRid'] );
  2069. Doo::loadClass ( 'receipt.func' );
  2070. $extendHtml = '<p><a class="button" href="javascript:if(window.confirm(\'确认移除?\'))window.location=\'/receiptTrainLoanRemoveDo/' . $receiptDetail ['ridKey'] . '/' . $receiptDetail ['trainLoanRidKey'] . '.html\'" data-toggle="modal">移除借款</a></p>';
  2071. $receiptLoanHtml = _getReceiptLoanHtml ( $receiptLoanDetail, $verifylist, $extendHtml );
  2072. }
  2073. $data ['receiptLoanHtml'] = $receiptLoanHtml;
  2074. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2075. $data ['receiptDetail'] = $receiptDetail;
  2076. $data ['trainEdiType'] = "LOAN";
  2077. $data ['ridKey'] = $ridKey;
  2078. $data ['memu'] = "receipt";
  2079. $data ['staff'] = $this->staff;
  2080. $data ['receiptMemu'] = 'saeaBorad';
  2081. $data ['verifyId'] = $this->verifyId;
  2082. $data ['executeId'] = $this->executeId;
  2083. $this->render ( "/receipt/receiptTrainLoanEdi", $data );
  2084. }
  2085. /**
  2086. * 更新培训班结算基本信息
  2087. */
  2088. function receiptTrainInfoEdiDo() {
  2089. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  2090. $rtid = $this->get_args ( 'rtid' ) ? $this->get_args ( 'rtid' ) : "";
  2091. // 培训班信息
  2092. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  2093. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  2094. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  2095. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  2096. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  2097. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  2098. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  2099. // 发票信息
  2100. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2101. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2102. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2103. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2104. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2105. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2106. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2107. //&& ! empty ( $participants )
  2108. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  2109. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2110. header ( 'Content-Type:text/html;charset=utf-8' );
  2111. die ( '请填写联行号' );
  2112. }
  2113. Doo::loadClass ( 'XDeode' );
  2114. $XDeode = new XDeode ( 5 );
  2115. $cid = $XDeode->decode ( $cid );
  2116. $rtid = $XDeode->decode ( $rtid );
  2117. $rid = $XDeode->decode ( $rid );
  2118. if (! is_numeric ( $rtid ) || ! is_numeric ( $rid )) {
  2119. die ( 'illegal request-IdError' );
  2120. }
  2121. Doo::loadModel ( 'receipt' );
  2122. $receipt = new receipt ();
  2123. Doo::loadModel ( 'receiptTraining' );
  2124. $receiptTraining = new receiptTraining ();
  2125. // 更新费用培训班
  2126. $item = array (
  2127. 'rtid' => $rtid,
  2128. 'trainName' => $trainName,
  2129. 'trainStartDate' => $trainStartDate,
  2130. 'trainEndDate' => $trainEndDate,
  2131. 'participants' => $participants,
  2132. 'freeParticipants'=>$freeParticipants,
  2133. 'trainAddress' => $trainAddress,
  2134. 'trainRemarks' => $trainRemarks
  2135. );
  2136. $irid = $receiptTraining->setReceiptTrainByCondition ( $item );
  2137. // 报销单
  2138. $receipt->rid = $rid;
  2139. $receipt->cid = $cid;
  2140. $receipt->verify = $verify;
  2141. $receipt->remittanceName = $remittanceName;
  2142. $receipt->bankName = $bankName;
  2143. $receipt->bankNumber = $bankNumber;
  2144. $receipt->remittanceBankType = $remittanceBankType;
  2145. if ($remittanceBankType == 1)
  2146. $receipt->coupletNumber = $coupletNumber;
  2147. $receipt->update ();
  2148. $XDeode = new XDeode ( 7 );
  2149. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html?trainEdiType=INFO";
  2150. } else
  2151. die ( 'illegal request' );
  2152. }
  2153. /**
  2154. * 编辑培训班结算---更新借款
  2155. */
  2156. function receiptTrainLoanEdiDo() {
  2157. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2158. $ridLoanKey = $this->get_args ( 'ridLoanKey' ) ? $this->get_args ( 'ridLoanKey' ) : "";
  2159. if (! empty ( $ridKey ) && ! empty ( $ridLoanKey )) {
  2160. Doo::loadModel ( 'receipt' );
  2161. $receipt = new receipt ();
  2162. Doo::loadClass ( 'XDeode' );
  2163. $XDeode = new XDeode ( 5 );
  2164. $rid = $XDeode->decode ( $ridKey );
  2165. $ridLoan = $XDeode->decode ( $ridLoanKey );
  2166. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  2167. die ( 'illegal request-ridError' );
  2168. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2169. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  2170. // 不合法的数据if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  2171. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2172. die ( 'illegal request-receiptError' );
  2173. }
  2174. if ($receiptLoanDetail ['status'] != 8 || $receiptLoanDetail ['Rtype'] != 1) {
  2175. die ( 'illegal request-receipLoantError' );
  2176. }
  2177. // 培训班结算挂钩借款
  2178. $receipt = new receipt ();
  2179. $item = array (
  2180. 'rid' => $rid,
  2181. 'trainLoanRid' => $ridLoan
  2182. );
  2183. $receipt->setReceiptByCondition ( $item );
  2184. // 更新借款状态变成已挂钩
  2185. $receipt = new receipt ();
  2186. $item = array (
  2187. 'rid' => $ridLoan,
  2188. 'status' => 10,
  2189. 'statusTrain' => 1
  2190. );
  2191. $receipt->setReceiptByCondition ( $item );
  2192. $XDeode = new XDeode ( 7 );
  2193. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  2194. } else
  2195. die ( 'illegal request' );
  2196. }
  2197. /**
  2198. * 编辑培训班结算--移除借款
  2199. */
  2200. function receiptTrainLoanRemoveDo() {
  2201. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : 0;
  2202. $ridLoanKey = isset ( $this->params ['ridLoanKey'] ) ? $this->params ['ridLoanKey'] : 0;
  2203. if (! empty ( $ridKey ) || ! empty ( $ridLoanKey )) {
  2204. Doo::loadModel ( 'receipt' );
  2205. $receipt = new receipt ();
  2206. Doo::loadClass ( 'XDeode' );
  2207. $XDeode = new XDeode ( 5 );
  2208. $rid = $XDeode->decode ( $ridKey );
  2209. $ridLoan = $XDeode->decode ( $ridLoanKey );
  2210. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  2211. die ( 'illegal request-ridError' );
  2212. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2213. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  2214. // 不合法的数据 !($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)
  2215. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2216. die ( 'illegal request-receiptError' );
  2217. }
  2218. if ($receiptLoanDetail ['status'] != 10 || $receiptLoanDetail ['Rtype'] != 1) {
  2219. die ( 'illegal request-receipLoantError' );
  2220. }
  2221. // 培训班结算挂钩借款
  2222. $receipt = new receipt ();
  2223. $item = array (
  2224. 'rid' => $rid,
  2225. 'trainLoanRid' => 0
  2226. );
  2227. $receipt->setReceiptByCondition ( $item );
  2228. // 更新借款状态变成已挂钩
  2229. $receipt = new receipt ();
  2230. $item = array (
  2231. 'rid' => $ridLoan,
  2232. 'status' => 8,
  2233. 'statusTrain' => 0
  2234. );
  2235. $receipt->setReceiptByCondition ( $item );
  2236. $XDeode = new XDeode ( 7 );
  2237. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  2238. } else
  2239. die ( 'illegal request' );
  2240. }
  2241. /**
  2242. * 编辑培训班结算 ---开票
  2243. */
  2244. function receiptTrainInvoiceEdi() {
  2245. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2246. Doo::loadClass ( 'XDeode' );
  2247. $XDeode = new XDeode ( 7 );
  2248. $rid = $XDeode->decode ( $ridKey );
  2249. if (! is_numeric ( $rid ))
  2250. die ( 'illegal request' );
  2251. Doo::loadModel ( 'receipt' );
  2252. $receipt = new receipt ();
  2253. Doo::loadModel ( 'receiptTraining' );
  2254. $receiptTraining = new receiptTraining ();
  2255. Doo::loadModel ( 'invoice' );
  2256. $invoice = new invoice ();
  2257. Doo::loadModel ( 'invoiceTraining' );
  2258. $invoiceTraining = new invoiceTraining ();
  2259. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2260. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  2261. die ();
  2262. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2263. $invoiceList = $invoiceTrainingDetail = array ();
  2264. if ($receiptDetail ['invoiceTrainId'] != 0) {
  2265. $invoiceList = $invoice->getInvoicePrintedByItid ( $receiptDetail ['invoiceTrainId'] );
  2266. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  2267. }
  2268. //print_r($invoiceList);
  2269. $data ['invoiceList'] = $invoiceList;
  2270. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  2271. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2272. $data ['receiptDetail'] = $receiptDetail;
  2273. $data ['trainEdiType'] = "INVOICE";
  2274. $data ['ridKey'] = $ridKey;
  2275. $data ['memu'] = "receipt";
  2276. $data ['staff'] = $this->staff;
  2277. $data ['receiptMemu'] = 'saeaBorad';
  2278. $data ['verifyId'] = $this->verifyId;
  2279. $data ['executeId'] = $this->executeId;
  2280. $this->render ( "/receipt/receiptTrainInvoiceEdi", $data );
  2281. }
  2282. /**
  2283. * 编辑培训班结算---更新开票
  2284. */
  2285. function receiptTrainInvoiceEdiDo() {
  2286. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2287. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : "";
  2288. if (! empty ( $ridKey ) && ! empty ( $itidKey )) {
  2289. Doo::loadModel ( 'receipt' );
  2290. $receipt = new receipt ();
  2291. Doo::loadModel ( 'invoiceTraining' );
  2292. $invoiceTraining = new invoiceTraining ();
  2293. Doo::loadClass ( 'XDeode' );
  2294. $XDeode = new XDeode ( 5 );
  2295. $rid = $XDeode->decode ( $ridKey );
  2296. $itid = $XDeode->decode ( $itidKey );
  2297. if (! is_numeric ( $rid ) || ! is_numeric ( $itid ))
  2298. die ( 'illegal request-idError' );
  2299. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2300. $invoiceTrainDetail = $invoiceTraining->getInvoiceTrainingByItid ( $itid );
  2301. // 不合法的数据
  2302. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2303. die ( 'illegal request-receiptError' );
  2304. }
  2305. if (empty ( $invoiceTrainDetail ) || $invoiceTrainDetail ['bindReceipt'] == 1) {
  2306. die ( 'illegal request-receipLoantError' );
  2307. }
  2308. // 培训班结算挂钩借款
  2309. $receipt = new receipt ();
  2310. $item = array (
  2311. 'rid' => $rid,
  2312. 'invoiceTrainId' => $itid
  2313. );
  2314. $receipt->setReceiptByCondition ( $item );
  2315. $invoiceTraining = new invoiceTraining ();
  2316. $item = array (
  2317. 'bindReceipt' => 1,
  2318. 'itid' => $itid
  2319. );
  2320. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  2321. $XDeode = new XDeode ( 7 );
  2322. return "/receiptTrainInvoiceEdi/" . $XDeode->encode ( $rid ) . ".html";
  2323. } else
  2324. die ( 'illegal request' );
  2325. }
  2326. /**
  2327. * 更新培训班结算 收款和取消收款
  2328. */
  2329. function receiptTrainReceivables() {
  2330. $doType = isset ( $this->params ['doType'] ) ? $this->params ['doType'] : '';
  2331. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2332. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  2333. Doo::loadClass ( 'XDeode' );
  2334. $XDeode = new XDeode ( 5 );
  2335. $rid = $XDeode->decode ( $ridKey );
  2336. $iid = $XDeode->decode ( $iidKey );
  2337. if (! is_numeric ( $rid ) || ! is_numeric ( $iid ))
  2338. die ( 'illegal request-iid' );
  2339. Doo::loadModel ( 'RIExtend' );
  2340. $RIExtend = new RIExtend ();
  2341. if ($doType == 'CONFIRM') {
  2342. $RIExtend->rid = $rid;
  2343. $RIExtend->iid = $iid;
  2344. $RIExtend->RIstatus = 1;
  2345. $RIExtend->insert ();
  2346. echo json_encode ( array (
  2347. 'status' => 1,
  2348. ) );
  2349. die ( );
  2350. } elseif ($doType == 'CANCEL') {
  2351. $RIExtend->delete ( array (
  2352. 'where' => 'rid=' . $rid . ' and iid=' . $iid,
  2353. 'limit' => 1
  2354. ) );
  2355. echo json_encode ( array (
  2356. 'status' => 1,
  2357. ) );
  2358. die ( );
  2359. } else {
  2360. echo json_encode ( array (
  2361. 'status' => 2,
  2362. ) );
  2363. die ( );
  2364. }
  2365. }
  2366. /**
  2367. * 移除挂钩的培训班发票
  2368. */
  2369. function receiptTrainReceivablesDelDo() {
  2370. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  2371. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : ""; // 发票培训班
  2372. Doo::loadModel ( 'receipt' );
  2373. $receipt = new receipt ();
  2374. Doo::loadModel ( 'RIExtend' );
  2375. $RIExtend = new RIExtend ();
  2376. Doo::loadClass ( 'XDeode' );
  2377. $XDeode = new XDeode ( 5 );
  2378. $rid = $XDeode->decode ( $ridKey );
  2379. $itid = $XDeode->decode ( $itidKey );
  2380. if (is_numeric ( $rid ) && is_numeric ( $itid )) {
  2381. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2382. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  2383. die ( 'illegal request-status' );
  2384. }
  2385. $receipt = new receipt ();
  2386. $receipt->rid = $rid;
  2387. $receipt->invoiceTrainId = 0;
  2388. $receipt->update ();
  2389. Doo::loadModel ( 'invoiceTraining' );
  2390. $invoiceTraining = new invoiceTraining ();
  2391. $item = array (
  2392. 'bindReceipt' => 0,
  2393. 'itid' => $itid
  2394. );
  2395. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  2396. $RIExtend->delete ( array (
  2397. 'where' => 'rid=' . $rid
  2398. ) );
  2399. $XDeode = new XDeode ( 7 );
  2400. return '/receiptTrainInvoiceEdi/' . $XDeode->encode ( $rid ) . '.html';
  2401. } else
  2402. die ( 'illegal request-iid' );
  2403. }
  2404. /**
  2405. * 编辑培训班结算
  2406. */
  2407. function receiptTrainItemEdi() {
  2408. //include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  2409. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2410. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : '';
  2411. Doo::loadClass ( 'XDeode' );
  2412. $XDeode = new XDeode ( 7 );
  2413. $rid = $XDeode->decode ( $ridKey );
  2414. if (! is_numeric ( $rid ))
  2415. die ( 'illegal request' );
  2416. Doo::loadModel ( 'receipt' );
  2417. $receipt = new receipt ();
  2418. Doo::loadModel ( 'receiptTraining' );
  2419. $receiptTraining = new receiptTraining ();
  2420. Doo::loadModel ( 'RItem' );
  2421. $RItem = new RItem ();
  2422. Doo::loadModel ( 'accountItem' );
  2423. $accountItem = new accountItem ();
  2424. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2425. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  2426. die ();
  2427. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2428. $RItemList = $RItem->getRItemByRid ( $rid,$name );
  2429. $aiList = $accountItem->getAccountBookByCategory ( '培训班费用' );//print_r($aiList);
  2430. // foreach ($aiList as $key=>$value){//不需要添加税款,在添加收入时自动添加
  2431. // if($value['name']=='税款'){
  2432. // unset($aiList[$key]);break;
  2433. // }
  2434. // }
  2435. //print_r($RItemList);
  2436. $data ['name'] = $name;
  2437. $data ['RItemList'] = $RItemList;
  2438. $data ['aiList'] = $aiList;
  2439. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2440. $data ['receiptDetail'] = $receiptDetail;
  2441. $data ['trainEdiType'] = "ITEM";
  2442. $data ['ridKey'] = $ridKey;
  2443. $data ['memu'] = "receipt";
  2444. $data ['staff'] = $this->staff;
  2445. $data ['receiptMemu'] = 'saeaBorad';
  2446. $data ['verifyId'] = $this->verifyId;
  2447. $data ['executeId'] = $this->executeId;
  2448. $this->render ( "/receipt/receiptTrainItemEdi", $data );
  2449. }
  2450. /**
  2451. * 添加支出项 需要修改 费用金额合计
  2452. */
  2453. function receiptTrainItemAddDo() {
  2454. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2455. $rtidKey = $this->get_args ( 'rtidKey' ) ? $this->get_args ( 'rtidKey' ) : "";
  2456. // 支出项信息
  2457. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  2458. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : 0;
  2459. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  2460. $inputer = $this->get_args ( 'inputer' ) ? $this->get_args ( 'inputer' ) : "";
  2461. $describe = $this->get_args ( 'describe' ) ? $this->get_args ( 'describe' ) : "";
  2462. //$identifyingTotal = $this->get_args ( 'identifyingTotal' )&&is_numeric($this->get_args ( 'identifyingTotal' )) ? $this->get_args ( 'identifyingTotal' ) : 0;
  2463. $payType = isset ( $this->params ['payType'] ) ? $this->params ['payType'] : '';
  2464. if (! empty ( $ridKey ) && ! empty ( $item ) && is_numeric( $price ) && ! empty ( $date ) && ! empty ( $inputer )) {
  2465. Doo::loadClass ( 'XDeode' );
  2466. $XDeode = new XDeode ( 5 );
  2467. Doo::loadModel ( 'RItem' );
  2468. $RItem = new RItem ();
  2469. $rid = $XDeode->decode ( $ridKey );
  2470. $rtid= $XDeode->decode ( $rtidKey );
  2471. if (! is_numeric ( $rid )){
  2472. die ( 'illegal request' );
  2473. }
  2474. Doo::loadModel ( 'receiptDetail' );
  2475. $receiptDetail = new receiptDetail ();
  2476. Doo::loadModel ( 'receipt' );
  2477. $receipt = new receipt ();
  2478. Doo::loadModel ( 'receiptTraining' );
  2479. $receiptTraining = new receiptTraining ();
  2480. $rtDetail=$receiptTraining->getReceiptTrainingByRtid($rtid);
  2481. $identifyingTotal=$rtDetail['identifyingTotal']+1;
  2482. $order = array (
  2483. "\r\n",
  2484. "\n",
  2485. "\r"
  2486. );
  2487. $replace = '<br/>';
  2488. $describe = str_replace ( $order, $replace, $describe );
  2489. $itemData = array (
  2490. 'rid' => $rid,
  2491. 'item' => $item,
  2492. 'price' => $price,
  2493. 'date' => $date,
  2494. 'inputer' => $inputer,
  2495. 'describe' => $describe,
  2496. 'creater' => $this->staff['0']['username'],
  2497. 'createrId' => $this->staff['0']['sid'],
  2498. 'creatDate' => date ( "Y-m-d H:i:s" ),
  2499. 'identifying'=>$identifyingTotal
  2500. );
  2501. if($payType=='company'){
  2502. $itemData += array (
  2503. 'payType' => 1
  2504. );
  2505. }
  2506. $RItem->addRItem($itemData, $receipt, $receiptDetail, $rid, $item, $price, $payType);
  2507. //更新支出项标识总数
  2508. $itemData = array (
  2509. 'rtid'=>$rtid,
  2510. 'identifyingTotal'=>$identifyingTotal
  2511. );
  2512. $receiptTraining->setReceiptTrainByCondition($itemData);
  2513. $XDeode = new XDeode ( 7 );
  2514. if($payType=='company'){
  2515. return '/receiptTrainItem/approval/' . $XDeode->encode ( $rid ) . '.html';
  2516. }else{
  2517. return '/receiptTrainItemEdi/' . $XDeode->encode ( $rid ) . '.html';
  2518. }
  2519. } else
  2520. die ( 'illegal request-dataError' );
  2521. }
  2522. /**
  2523. * 培训班结算-讲师
  2524. */
  2525. function receiptTrainLecturerEdi() {
  2526. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2527. Doo::loadClass ( 'XDeode' );
  2528. $XDeode = new XDeode ( 7 );
  2529. $rid = $XDeode->decode ( $ridKey );
  2530. if (! is_numeric ( $rid ))
  2531. die ( 'illegal request' );
  2532. Doo::loadModel ( 'receipt' );
  2533. $receipt = new receipt ();
  2534. Doo::loadModel ( 'receiptTraining' );
  2535. $receiptTraining = new receiptTraining ();
  2536. Doo::loadModel ( 'RILecturer' );
  2537. $RILecturer = new RILecturer ();
  2538. Doo::loadModel ( 'lecturer' );
  2539. $lecturer = new lecturer ();
  2540. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2541. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  2542. die ();
  2543. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2544. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2545. $lecturerList = $lecturer->getLecturerAll ();
  2546. $INSIDEhtml = $OUTSIDEhtml = '';
  2547. foreach ( $lecturerList as $key => $value ) {
  2548. if ($value ['ltype'] == 'INSIDE') {
  2549. $INSIDEhtml .= '<option value="' . $value ['category'] . '-' . $value ['staff'] . '">' . $value ['category'] . '-' . $value ['staff'] . '</option>';
  2550. } elseif ($value ['ltype'] == 'OUTSIDE') {
  2551. $OUTSIDEhtml .= '<option value="' . $value ['staff'] . '">' . $value ['staff'] . '</option>';
  2552. }
  2553. }
  2554. $data ['INSIDEhtml'] = $INSIDEhtml;
  2555. $data ['OUTSIDEhtml'] = $OUTSIDEhtml;
  2556. // print_r($RItemList);
  2557. $data ['RILecturerList'] = $RILecturerList;
  2558. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2559. $data ['receiptDetail'] = $receiptDetail;
  2560. $data ['trainEdiType'] = "LECTURER";
  2561. $data ['ridKey'] = $ridKey;
  2562. $data ['memu'] = "receipt";
  2563. $data ['staff'] = $this->staff;
  2564. $data ['receiptMemu'] = 'saeaBorad';
  2565. $data ['verifyId'] = $this->verifyId;
  2566. $data ['executeId'] = $this->executeId;
  2567. $this->render ( "/receipt/receiptTrainLecturerEdi", $data );
  2568. }
  2569. /**
  2570. * 添加讲师
  2571. */
  2572. function receiptTrainLecturerAddDo() {
  2573. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2574. // 支出项信息
  2575. $ltype = $this->get_args ( 'ltype' ) ? $this->get_args ( 'ltype' ) : "";
  2576. $lecturerName = $this->get_args ( 'lecturerName' ) ? $this->get_args ( 'lecturerName' ) : "";
  2577. $schoolDay = $this->get_args ( 'schoolDay' ) ? $this->get_args ( 'schoolDay' ) : "";
  2578. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  2579. $taxation = $this->get_args ( 'taxation' ) ? $this->get_args ( 'taxation' ) : "";
  2580. $fees = $this->get_args ( 'fees' ) ? $this->get_args ( 'fees' ) : "";
  2581. if (! empty ( $ridKey ) && ! empty ( $ltype ) && ! empty ( $lecturerName ) && ! empty ( $schoolDay ) && ! empty ( $price )) {
  2582. Doo::loadClass ( 'XDeode' );
  2583. $XDeode = new XDeode ( 5 );
  2584. Doo::loadModel ( 'RILecturer' );
  2585. $RILecturer = new RILecturer ();
  2586. $rid = $XDeode->decode ( $ridKey );
  2587. if (! is_numeric ( $rid ))
  2588. die ( 'illegal request' );
  2589. if ($ltype == 'OUTSIDE' && empty ( $taxation ))
  2590. die ( 'illegal request-taxationError' );
  2591. $RILecturer->rid = $rid;
  2592. $RILecturer->ltype = $ltype;
  2593. if ($ltype == 'OUTSIDE') {
  2594. if ($taxation == 'TAXATION') {
  2595. $RILecturer->taxation = 1;
  2596. } elseif ($taxation == 'NOTAXATION') {
  2597. $RILecturer->taxation = 0;
  2598. }
  2599. }
  2600. $RILecturer->lecturerName = $lecturerName;
  2601. $RILecturer->schoolDay = $schoolDay;
  2602. $RILecturer->price = $price;
  2603. $RILecturer->fees=$fees;
  2604. $RILecturer->insert ();
  2605. // 添加公司汇总
  2606. // 报销详情
  2607. Doo::loadModel ( 'receiptDetail' );
  2608. $receiptDetail = new receiptDetail ();
  2609. Doo::loadModel ( 'receipt' );
  2610. $receipt = new receipt ();
  2611. // 金额总计
  2612. $price = $price * $schoolDay;
  2613. $rInfo = $receipt->getReceiptByRid ( $rid );
  2614. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  2615. if (empty ( $rdInfo )) {
  2616. $receiptDetail = new receiptDetail ();
  2617. $receiptDetail->staff = $rInfo ['staff'];
  2618. $receiptDetail->item = '讲课费';
  2619. $receiptDetail->itemCategory = '培训班费用';
  2620. $receiptDetail->price = number_format ( $fees, 2, '.', '' );
  2621. $receiptDetail->date = date ( "Y-m-d" );
  2622. $receiptDetail->cid = $rInfo ['cid'];
  2623. $receiptDetail->rid = $rid;
  2624. $receiptDetail->status = 4;
  2625. $receiptDetail->insert ();
  2626. } else {
  2627. $receiptDetail = new receiptDetail ();
  2628. $rdInfo ['price'] += $fees;
  2629. $receiptDetail->price = $rdInfo ['price'];
  2630. $receiptDetail->update ( array (
  2631. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  2632. ) );
  2633. }
  2634. $receipt = new receipt ();
  2635. $receipt->sum=$rInfo['sum']+$fees;
  2636. $receipt->update ( array (
  2637. 'where' => 'rid=' . $rid
  2638. ) );
  2639. $XDeode = new XDeode ( 7 );
  2640. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  2641. } else
  2642. die ( 'illegal request' );
  2643. }
  2644. /**
  2645. * 移除讲师
  2646. */
  2647. function receiptTrainLecturerDelDo() {
  2648. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  2649. $rlidKey = $this->get_args ( 'rlidKey' ) ? $this->get_args ( 'rlidKey' ) : ""; // 发票培训班
  2650. Doo::loadModel ( 'receipt' );
  2651. $receipt = new receipt ();
  2652. Doo::loadModel ( 'RILecturer' );
  2653. $RILecturer = new RILecturer ();
  2654. Doo::loadClass ( 'XDeode' );
  2655. $XDeode = new XDeode ( 5 );
  2656. $rid = $XDeode->decode ( $ridKey );
  2657. $rlid = $XDeode->decode ( $rlidKey );
  2658. if (is_numeric ( $rid ) && is_numeric ( $rlid )) {
  2659. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2660. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  2661. die ( 'illegal request-status' );
  2662. }
  2663. $detail=$RILecturer->getRILecturerByRlid($rlid);
  2664. if (empty($detail)){
  2665. die ( 'illegal request-data' );
  2666. }
  2667. $RILecturer->delete ( array (
  2668. 'where' => 'rid=' . $rid . ' and rlid=' . $rlid
  2669. ) );
  2670. //更新费用合计金额
  2671. $rInfo = $receipt->getReceiptByRid ( $rid );
  2672. $receipt = new receipt ();
  2673. $receipt->sum= $receiptDetail['sum']-$detail['price'];
  2674. $receipt->update ( array (
  2675. 'where' => 'rid=' . $rid
  2676. ) );
  2677. Doo::loadModel ( 'receiptDetail' );
  2678. $receiptDetail = new receiptDetail ();
  2679. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  2680. $receiptDetail = new receiptDetail ();
  2681. $rdInfo ['price'] -= number_format ( $detail['price'], 2, '.', '' );
  2682. $receiptDetail->price = $rdInfo ['price'];
  2683. $receiptDetail->update ( array (
  2684. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  2685. ) );
  2686. $XDeode = new XDeode ( 7 );
  2687. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  2688. } else
  2689. die ( 'illegal request-iid' );
  2690. }
  2691. /**
  2692. * 培训班提交审批
  2693. */
  2694. function receiptTrainDo() {
  2695. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2696. Doo::loadClass ( 'XDeode' );
  2697. $XDeode = new XDeode ( 7 );
  2698. $rid = $XDeode->decode ( $ridKey );
  2699. Doo::loadModel ( 'receipt' );
  2700. $receipt = new receipt ();
  2701. Doo::loadModel ( 'receiptDetail' );
  2702. $receiptDetail = new receiptDetail ();
  2703. Doo::loadModel ( 'statistics' );
  2704. $statistics = new statistics ();
  2705. Doo::loadModel ( "verify" );
  2706. $verify = new verify ();
  2707. // 审批状态的判定
  2708. $receiptDetailList = $receipt->getOne ( array (
  2709. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  2710. 'asArray' => true
  2711. ) );
  2712. if (empty ( $receiptDetailList ))
  2713. return "/saeaBorad";
  2714. $verifyDetail = $verify->getOne ( array (
  2715. 'where' => ' vid =' . $receiptDetailList ['verify'],
  2716. 'asArray' => true
  2717. ) );
  2718. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  2719. if (empty ( $receiptDetailList ['nowStaff'] )) {
  2720. $nowStaff = "";
  2721. $nowStaffList = array ();
  2722. if ($verifyDetail [0] [1] == 'ROLE') {
  2723. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  2724. foreach ( $vStaffString as $key => $value ) {
  2725. $staffK = explode ( "_", $value );
  2726. array_push ( $nowStaffList, $staffK [0] );
  2727. }
  2728. $nowStaff = implode ( ',', $nowStaffList );
  2729. } else {
  2730. $nowStaff = $verifyDetail [0] [0];
  2731. }
  2732. $receipt->nowStaff = $nowStaff;
  2733. }
  2734. // echo $nowStaff;
  2735. // print_r($verifyDetail);die;
  2736. $receipt->rid = $receiptDetailList ['rid'];
  2737. $receipt->date = date ( "Y-m-d" );
  2738. $receipt->status = 2;
  2739. $receipt->update ();
  2740. $receiptDetail->status = 2;
  2741. $receiptDetail->update ( array (
  2742. 'where' => 'rid=' . $receiptDetailList ['rid']
  2743. ) );
  2744. Doo::loadModel ( "receiptLog" );
  2745. $receiptLog = new receiptLog ();
  2746. Doo::loadModel ( "verify" );
  2747. $verify = new verify ();
  2748. $vr = $verify->getOne ( array (
  2749. 'where' => 'vid=' . $receiptDetailList ['verify'],
  2750. 'asArray' => true
  2751. ) );
  2752. $jd = json_decode ( $vr ['staff'] );
  2753. $roleId = 0;
  2754. foreach ( $jd as $key => $value ) {
  2755. if ($value [1] == 'ROLE') {
  2756. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  2757. if ($pos !== false) {
  2758. $roleId = $value [0];
  2759. }
  2760. }
  2761. }
  2762. // 审批日志
  2763. // echo $roleId;die;
  2764. if (! empty ( $roleId )) {
  2765. Doo::loadModel ( "role" );
  2766. $role = new role ();
  2767. $roleInfo = $role->getOne ( array (
  2768. 'where' => 'rid=' . $roleId,
  2769. 'asArray' => true
  2770. ) );
  2771. // $receiptLog->rolename = $roleInfo ['name'];
  2772. }
  2773. $receiptLog->username = $this->staff [0] ['username'];
  2774. $receiptLog->uid = $this->staff [0] ['sid'];
  2775. $receiptLog->date = date ( "Y-m-d" );
  2776. $receiptLog->opinion = '提交审批';
  2777. $receiptLog->img = $this->staff [0] ['avatar'];
  2778. $receiptLog->status = 2;
  2779. $receiptLog->rid = $rid;
  2780. $receiptLog->insert ();
  2781. // 写入列表项
  2782. Doo::loadModel ( 'accountItem' );
  2783. $accountItem = new accountItem ();
  2784. $aItem = $accountItem->getAccountBookByCategory ( '培训班费用' );
  2785. // 项目金额合计
  2786. Doo::loadModel ( 'RItem' );
  2787. $RItem = new RItem ();
  2788. // 讲师获得
  2789. Doo::loadModel ( 'RILecturer' );
  2790. $RILecturer = new RILecturer ();
  2791. $RItemList = $RItem->getRItemByRid ( $rid );
  2792. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2793. // 支出项金额详情
  2794. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, 0 );
  2795. // print_r($aItem);
  2796. // print_r($aiData);
  2797. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  2798. $ag = $tr = $ta = $ot = 0;
  2799. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  2800. foreach ( $aItem as $key => $value ) {
  2801. if ($value ['category'] == $this->TRAIN) {
  2802. foreach ( $aiData ['dataList'] as $k => $v ) {
  2803. if ($value ['name'] == $v ['name']) {
  2804. array_push ( $accountJson [$this->TRAIN], array (
  2805. 'aid' => $value ['aid'],
  2806. 'name' => $value ['name'],
  2807. 'price' => number_format ( $v ['price'], 2, '.', '' )
  2808. ) );
  2809. $sum += $v ['price'];
  2810. $trainSum += $v ['price'];
  2811. unset ( $aiData ['dataList'] [$k] );
  2812. break;
  2813. }
  2814. }
  2815. }
  2816. }
  2817. $accountJson ['cSum'] = array (
  2818. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  2819. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  2820. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  2821. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  2822. );
  2823. // 报销单
  2824. $receipt = new receipt ();
  2825. $receipt->accountItem = json_encode ( $accountJson );
  2826. $receipt->sum = number_format ( $sum, 2, '.', '' );
  2827. $receipt->update ( array (
  2828. 'where' => 'rid=' . $rid
  2829. ) );
  2830. // print_r($accountJson);
  2831. // statistics item 统计写入
  2832. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  2833. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  2834. $accountItem = $accountJson;
  2835. $stat = $statistics->getOne ( array (
  2836. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  2837. 'asArray' => true
  2838. ) );
  2839. if (empty ( $stat )) {
  2840. $statistics->date = date ( "Y-m-d" );
  2841. $statistics->cid = $this->staff [0] ['cid'];
  2842. $statistics->staff = $this->staff [0] ['sid'];
  2843. $statistics->agPrice = 0;
  2844. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  2845. $statistics->insert ();
  2846. } else {
  2847. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  2848. $statistics->update ( array (
  2849. 'where' => 'sid=' . $stat ['sid']
  2850. ) );
  2851. }
  2852. return "/saeaBorad";
  2853. }
  2854. function confirmation() {
  2855. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2856. Doo::loadModel ( 'receipt' );
  2857. Doo::loadModel ( 'receiptDetail' );
  2858. $receipt = new receipt ();
  2859. $receiptDetail = new receiptDetail ();
  2860. Doo::loadModel ( 'statistics' );
  2861. Doo::loadModel ( 'itemStatistics' );
  2862. $statistics = new statistics ();
  2863. $itemStatistics = new itemStatistics ();
  2864. Doo::loadModel ( "verify" );
  2865. $verify = new verify ();
  2866. $receiptDetailList = $receipt->getOne ( array (
  2867. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  2868. 'asArray' => true
  2869. ) );
  2870. if (empty ( $receiptDetailList ))
  2871. return "/saeaBorad";
  2872. $verifyDetail = $verify->getOne ( array (
  2873. 'where' => ' vid =' . $receiptDetailList ['verify'],
  2874. 'asArray' => true
  2875. ) );
  2876. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  2877. if (empty ( $receiptDetailList ['nowStaff'] )) {
  2878. $nowStaff = "";
  2879. $nowStaffList = array ();
  2880. if ($verifyDetail [0] [1] == 'ROLE') {
  2881. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  2882. foreach ( $vStaffString as $key => $value ) {
  2883. $staffK = explode ( "_", $value );
  2884. array_push ( $nowStaffList, $staffK [0] );
  2885. }
  2886. $nowStaff = implode ( ',', $nowStaffList );
  2887. } else {
  2888. $nowStaff = $verifyDetail [0] [0];
  2889. }
  2890. $receipt->nowStaff = $nowStaff;
  2891. }
  2892. // echo $nowStaff;
  2893. // print_r($verifyDetail);die;
  2894. $receipt->rid = $receiptDetailList ['rid'];
  2895. $receipt->status = 2;
  2896. $receipt->update ();
  2897. // 操作日志
  2898. Doo::loadModel ( "receiptLog" );
  2899. $receiptLog = new receiptLog ();
  2900. $verify = new verify ();
  2901. $receiptInfo = $receipt->getOne ( array (
  2902. 'where' => 'rid=' . $rid,
  2903. 'asArray' => true
  2904. ) );
  2905. $vr = $verify->getOne ( array (
  2906. 'where' => 'vid=' . $receiptInfo ['verify'],
  2907. 'asArray' => true
  2908. ) );
  2909. $jd = json_decode ( $vr ['staff'] );
  2910. $roleId = 0;
  2911. foreach ( $jd as $key => $value ) {
  2912. if ($value [1] == 'ROLE') {
  2913. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  2914. if ($pos !== false) {
  2915. $roleId = $value [0];
  2916. }
  2917. }
  2918. }
  2919. // 审批日志
  2920. // echo $roleId;die;
  2921. if (! empty ( $roleId )) {
  2922. Doo::loadModel ( "role" );
  2923. $role = new role ();
  2924. $roleInfo = $role->getOne ( array (
  2925. 'where' => 'rid=' . $roleId,
  2926. 'asArray' => true
  2927. ) );
  2928. // $receiptLog->rolename = $roleInfo ['name'];
  2929. }
  2930. $receiptLog->username = $this->staff [0] ['username'];
  2931. $receiptLog->uid = $this->staff [0] ['sid'];
  2932. $receiptLog->date = date ( "Y-m-d" );
  2933. $receiptLog->opinion = '提交审批';
  2934. $receiptLog->img = $this->staff [0] ['avatar'];
  2935. $receiptLog->status = 2;
  2936. $receiptLog->rid = $rid;
  2937. $receiptLog->insert ();
  2938. return "/expenses";
  2939. }
  2940. function expenses() {
  2941. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  2942. if (empty ( $item ))
  2943. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  2944. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  2945. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  2946. Doo::loadClass ( 'XDeode' );
  2947. $XDeode = new XDeode ( 7 );
  2948. Doo::loadModel ( 'receipt' );
  2949. $receipt = new receipt ();
  2950. Doo::loadModel ( 'L_category' );
  2951. $Lcategory = new L_category ();
  2952. Doo::loadModel ( 'verify' );
  2953. Doo::loadModel ( 'statistics' );
  2954. $statistics = new statistics ();
  2955. $verify = new verify ();
  2956. Doo::loadModel ( 'staff' );
  2957. $staff = new staff ();
  2958. $condition = "";
  2959. if ($item == "expenses")
  2960. $condition = " and Rtype=1 ";
  2961. elseif ($item == "receipts")
  2962. $condition = " and Rtype=0 ";
  2963. elseif ($item == "remits")
  2964. $condition = " and Rtype=2 ";
  2965. elseif ($item == "train")
  2966. $condition = " and Rtype=3 ";
  2967. $dateCondition = " and Year(date) =" . $year;
  2968. if (! empty ( $moth )) {
  2969. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  2970. $stList = $statistics->getOne ( array (
  2971. 'select' => 'rePrice ,agPrice',
  2972. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  2973. 'asArray' => true
  2974. ) );
  2975. } else
  2976. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  2977. if (empty ( $stList ))
  2978. $stList = array (
  2979. 'rePrice' => 0,
  2980. 'agPrice' => 0
  2981. );
  2982. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  2983. if (! isset ( $noPassSum ['sum'] ))
  2984. $noPassSum ['sum'] = 0;
  2985. $data ['stList'] = array (
  2986. 'rePrice' => $stList ['rePrice'],
  2987. 'agPrice' => $stList ['agPrice'],
  2988. 'skPrice' => ($noPassSum ['sum'])
  2989. );
  2990. $receiptList = $receipt->find ( array (
  2991. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  2992. 'desc' => 'rid',
  2993. 'asArray' => true
  2994. ) );
  2995. $Locate = 0;
  2996. $roleId = 0;
  2997. $button = 0;
  2998. foreach ( $receiptList as $key => $value ) {
  2999. $receiptList[$key]['balance']='';
  3000. if($value['Rtype']==1){
  3001. $receiptList[$key]['balance']=$value['sum']-=$value['loanSum'];
  3002. $receiptList[$key]['balanceABS']=abs($receiptList[$key]['balance']);
  3003. }elseif($value['Rtype']==3){
  3004. $payment=$this->_getReceiptTrainPayment($value['invoiceTrainId'],$value['trainLoanRid'],$value['rid']);
  3005. $receiptList[$key]['payment']=$payment;
  3006. $receiptList[$key]['paymentABS']=abs($payment);
  3007. }
  3008. $receiptList [$key] ['Locate'] = $Locate;
  3009. $Locate ++;
  3010. $receiptList [$key] ['reviseDetail'] = array ();
  3011. if (! empty ( $value ['reviseDetail'] ))
  3012. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3013. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3014. $categoryDetil = $Lcategory->getOne ( array (
  3015. 'where' => 'cid=' . $value ['cid'],
  3016. 'asArray' => true
  3017. ) );
  3018. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3019. // 检测编辑状态
  3020. $verifyList = $verify->getOne ( array (
  3021. 'where' => 'vid=' . $value ['verify'],
  3022. 'asArray' => true
  3023. ) );
  3024. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3025. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3026. Doo::loadModel ( 'role' );
  3027. $role = new role ();
  3028. $flag = true;
  3029. $roleKey = 0;
  3030. $endStaffArray = array ();
  3031. $roleArrayCopy = array ();
  3032. foreach ( $verifyList as $k => $v ) {
  3033. // init verifyStaff
  3034. if ($v [1] == 'ROLE') {
  3035. if (! empty ( $verifyStaff )) {
  3036. $endStaffArray = end ( $verifyStaff );
  3037. // if ($v[0]==$endStaffArray['nextStaff']){
  3038. // $roleId=$v[0];
  3039. // }
  3040. }
  3041. $roleVerify = json_decode ( $v [3], true );
  3042. $roleKey = $k;
  3043. $roleArray = array ();
  3044. $rolename = $role->getOne ( array (
  3045. 'where' => 'rid=' . $v [0],
  3046. 'asArray' => true
  3047. ) );
  3048. foreach ( $roleVerify as $o => $p ) {
  3049. $staffID = explode ( '_', $p );
  3050. $staffInfo = $staff->getOne ( array (
  3051. 'where' => 'sid=' . $staffID [0],
  3052. 'asArray' => true
  3053. ) );
  3054. // print_r($staffID);
  3055. $exp = array (
  3056. 0 => $staffInfo ['sid'],
  3057. 1 => $staffID [1],
  3058. 2 => $staffInfo ['avatar'],
  3059. 'date' => '',
  3060. 'date' => '',
  3061. 'opinion' => '',
  3062. 'status' => '',
  3063. 'rolename' => $rolename ['name']
  3064. );
  3065. array_push ( $roleArray, $exp );
  3066. }
  3067. $roleArrayCopy [$v [0]] = $roleArray;
  3068. // $verifyList[$k]['roleArray']=$roleArray;
  3069. }
  3070. $verifyList [$k] ['date'] = "";
  3071. $verifyList [$k] ['opinion'] = "";
  3072. $verifyList [$k] ['status'] = "";
  3073. if (empty ( $verifyStaff )) {
  3074. $verifyList [$k] ['date'] = "";
  3075. $verifyList [$k] ['opinion'] = "";
  3076. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3077. $verifyList [$k] ['status'] = 4;
  3078. $flag = false;
  3079. }
  3080. } else {
  3081. foreach ( $verifyStaff as $m => $u ) {
  3082. if ($v [0] == $m) {
  3083. $verifyList [$k] ['date'] = $u ['date'];
  3084. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3085. $verifyList [$k] ['status'] = $u ['status'];
  3086. $flag = false;
  3087. break;
  3088. }
  3089. }
  3090. $endStaffArray = end ( $verifyStaff );
  3091. if (isset ( $endStaffArray ['ROLE'] )) {
  3092. } else {
  3093. // $endKey=key($verifyStaff);
  3094. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3095. // $button=4;
  3096. // $verifyList[$k]['status']=4;
  3097. // }
  3098. }
  3099. }
  3100. }
  3101. $rolename ['name'] = '';
  3102. if (! empty ( $roleId )) {
  3103. Doo::loadModel ( 'role' );
  3104. $role = new role ();
  3105. $rolename = $role->getOne ( array (
  3106. 'where' => 'rid=' . $roleId,
  3107. 'asArray' => true
  3108. ) );
  3109. }
  3110. if (! empty ( $verifyStaff ))
  3111. $endStaffArray = end ( $verifyStaff );
  3112. $KOP = false;
  3113. foreach ( $roleArrayCopy as $P => $A ) {
  3114. foreach ( $A as $MKI => $AVL ) {
  3115. if (! empty ( $verifyStaff )) {
  3116. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3117. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3118. $button = 4;
  3119. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3120. }
  3121. foreach ( $verifyStaff as $m => $u ) {
  3122. $AVLFK = $AVL [0] . '_R';
  3123. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3124. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3125. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3126. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3127. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3128. break;
  3129. }
  3130. }
  3131. } else {
  3132. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3133. $button = 4;
  3134. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3135. }
  3136. }
  3137. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3138. $KOP = true;
  3139. }
  3140. }
  3141. foreach ( $roleArrayCopy as $k => $v ) {
  3142. foreach ( $verifyList as $m => $n ) {
  3143. if ($n [0] == $k) {
  3144. array_splice ( $verifyList, $m, 1, $v );
  3145. }
  3146. }
  3147. }
  3148. $receiptList [$key] ['verifyList'] = $verifyList;
  3149. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3150. 'where' => 'sid=' . $value ['staff'],
  3151. 'asArray' => true
  3152. ) );
  3153. $receiptList [$key] ['button'] = $button;
  3154. $receiptList [$key] ['ridKey'] =$XDeode->encode( $value ['rid'] );
  3155. }
  3156. // print_r($receiptList);die;
  3157. $mothHtml = "";
  3158. for($i = 1; $i <= 12; $i ++) {
  3159. if ($moth == $i)
  3160. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3161. else
  3162. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3163. }
  3164. $dateHtml = "";
  3165. $now = date ( "Y" );
  3166. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  3167. if ($YEARD <= $now) {
  3168. $dateHtml .= '<option ';
  3169. if ($year == $YEARD) {
  3170. $dateHtml .= 'selected ';
  3171. }
  3172. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  3173. }
  3174. }
  3175. $data ['dateHtml'] = $dateHtml;
  3176. $data ['mothHtml'] = $mothHtml;
  3177. $data ['receiptList'] = $receiptList;
  3178. $data ['memu'] = "receipt";
  3179. $data ['staff'] = $this->staff;
  3180. $data ['receiptMemu'] = 'expenses';
  3181. $data ['verifyId'] = $this->verifyId;
  3182. $data ['executeId'] = $this->executeId;
  3183. $data ['item'] = $item;
  3184. $data ['year'] = $year;
  3185. $this->render ( "/admin/expenses", $data );
  3186. }
  3187. function expensesCollect() {
  3188. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3189. Doo::loadModel ( 'receipt' );
  3190. $receipt = new receipt ();
  3191. Doo::loadModel ( 'L_category' );
  3192. $Lcategory = new L_category ();
  3193. Doo::loadModel ( 'verify' );
  3194. Doo::loadModel ( 'statistics' );
  3195. $statistics = new statistics ();
  3196. $verify = new verify ();
  3197. Doo::loadModel ( 'staff' );
  3198. $staff = new staff ();
  3199. Doo::loadModel ( 'loanReceipt' );
  3200. $loanReceipt = new loanReceipt ();
  3201. $receiptList = $receipt->find ( array (//去掉
  3202. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  3203. 'desc' => 'rid',
  3204. 'asArray' => true
  3205. ) );
  3206. $loanList = $loanReceipt->find ( array (
  3207. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3208. 'desc' => 'rid',
  3209. 'asArray' => true
  3210. ) );
  3211. /*
  3212. * $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;
  3213. */
  3214. $data ['explanation'] = '';
  3215. if (! empty ( $loanList ))
  3216. $data ['explanation'] = $loanList [0] ['explanation'];
  3217. $Locate = 0;
  3218. $roleId = 0;
  3219. $button = 0;
  3220. foreach ( $receiptList as $key => $value ) {
  3221. $receiptList [$key] ['Locate'] = $Locate;
  3222. $Locate ++;
  3223. $receiptList [$key] ['reviseDetail'] = array ();
  3224. if (! empty ( $value ['reviseDetail'] ))
  3225. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3226. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3227. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3228. $categoryDetil = $Lcategory->getOne ( array (
  3229. 'where' => 'cid=' . $value ['cid'],
  3230. 'asArray' => true
  3231. ) );
  3232. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3233. // 检测编辑状态
  3234. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  3235. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  3236. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  3237. else
  3238. $verifyList ['staff'] = $value ['verifyBreakup'];
  3239. } else
  3240. $verifyList = $verify->getOne ( array (
  3241. 'where' => 'vid=' . $value ['verify'],
  3242. 'asArray' => true
  3243. ) );
  3244. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3245. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3246. Doo::loadModel ( 'role' );
  3247. $role = new role ();
  3248. $flag = true;
  3249. $roleKey = 0;
  3250. $endStaffArray = array ();
  3251. $roleArrayCopy = array ();
  3252. foreach ( $verifyList as $k => $v ) {
  3253. // init verifyStaff
  3254. if ($v [1] == 'ROLE') {
  3255. if (! empty ( $verifyStaff )) {
  3256. $endStaffArray = end ( $verifyStaff );
  3257. // if ($v[0]==$endStaffArray['nextStaff']){
  3258. // $roleId=$v[0];
  3259. // }
  3260. }
  3261. $roleVerify = json_decode ( $v [3], true );
  3262. $roleKey = $k;
  3263. $roleArray = array ();
  3264. $rolename = $role->getOne ( array (
  3265. 'where' => 'rid=' . $v [0],
  3266. 'asArray' => true
  3267. ) );
  3268. foreach ( $roleVerify as $o => $p ) {
  3269. $staffID = explode ( '_', $p );
  3270. $staffInfo = $staff->getOne ( array (
  3271. 'where' => 'sid=' . $staffID [0],
  3272. 'asArray' => true
  3273. ) );
  3274. // print_r($staffID);
  3275. $exp = array (
  3276. 0 => $staffInfo ['sid'],
  3277. 1 => $staffID [1],
  3278. 2 => $staffInfo ['avatar'],
  3279. 'date' => '',
  3280. 'date' => '',
  3281. 'opinion' => '',
  3282. 'status' => '',
  3283. 'rolename' => $rolename ['name']
  3284. );
  3285. array_push ( $roleArray, $exp );
  3286. }
  3287. $roleArrayCopy [$v [0]] = $roleArray;
  3288. // $verifyList[$k]['roleArray']=$roleArray;
  3289. }
  3290. $verifyList [$k] ['date'] = "";
  3291. $verifyList [$k] ['opinion'] = "";
  3292. $verifyList [$k] ['status'] = "";
  3293. if (empty ( $verifyStaff )) {
  3294. $verifyList [$k] ['date'] = "";
  3295. $verifyList [$k] ['opinion'] = "";
  3296. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3297. $verifyList [$k] ['status'] = 4;
  3298. $flag = false;
  3299. }
  3300. } else {
  3301. foreach ( $verifyStaff as $m => $u ) {
  3302. if ($v [0] == $m) {
  3303. $verifyList [$k] ['date'] = $u ['date'];
  3304. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3305. $verifyList [$k] ['status'] = $u ['status'];
  3306. $flag = false;
  3307. break;
  3308. }
  3309. }
  3310. $endStaffArray = end ( $verifyStaff );
  3311. if (isset ( $endStaffArray ['ROLE'] )) {
  3312. } else {
  3313. // $endKey=key($verifyStaff);
  3314. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3315. // $button=4;
  3316. // $verifyList[$k]['status']=4;
  3317. // }
  3318. }
  3319. }
  3320. }
  3321. $rolename ['name'] = '';
  3322. if (! empty ( $roleId )) {
  3323. Doo::loadModel ( 'role' );
  3324. $role = new role ();
  3325. $rolename = $role->getOne ( array (
  3326. 'where' => 'rid=' . $roleId,
  3327. 'asArray' => true
  3328. ) );
  3329. }
  3330. if (! empty ( $verifyStaff ))
  3331. $endStaffArray = end ( $verifyStaff );
  3332. $KOP = false;
  3333. foreach ( $roleArrayCopy as $P => $A ) {
  3334. foreach ( $A as $MKI => $AVL ) {
  3335. if (! empty ( $verifyStaff )) {
  3336. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3337. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3338. $button = 4;
  3339. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3340. }
  3341. foreach ( $verifyStaff as $m => $u ) {
  3342. $AVLFK = $AVL [0] . '_R';
  3343. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3344. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3345. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3346. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3347. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3348. break;
  3349. }
  3350. }
  3351. } else {
  3352. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3353. $button = 4;
  3354. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3355. }
  3356. }
  3357. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3358. $KOP = true;
  3359. }
  3360. }
  3361. foreach ( $roleArrayCopy as $k => $v ) {
  3362. foreach ( $verifyList as $m => $n ) {
  3363. if ($n [0] == $k) {
  3364. array_splice ( $verifyList, $m, 1, $v );
  3365. }
  3366. }
  3367. }
  3368. // 费用执行人相关数据
  3369. $executeCopy = json_decode ( $value ['executeCopy'], true );
  3370. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3371. foreach ( $executeCopy as $k => $v ) {
  3372. $executeCopy [$k] ['date'] = '';
  3373. $executeCopy [$k] ['opinion'] = '';
  3374. $executeCopy [$k] ['status'] = '';
  3375. if (! empty ( $executeStaff ))
  3376. foreach ( $executeStaff as $m => $u ) {
  3377. if ($v [0] == $m) {
  3378. $executeCopy [$k] ['date'] = $u ['date'];
  3379. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  3380. $executeCopy [$k] ['status'] = $u ['status'];
  3381. break;
  3382. }
  3383. }
  3384. }
  3385. $receiptList [$key] ['executeCopy'] = $executeCopy;
  3386. $receiptList [$key] ['verifyList'] = $verifyList;
  3387. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3388. 'where' => 'sid=' . $value ['staff'],
  3389. 'asArray' => true
  3390. ) );
  3391. $receiptList [$key] ['button'] = $button;
  3392. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3393. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3394. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  3395. $receiptList [$key] ['relust'] = $relust;
  3396. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  3397. }
  3398. Doo::loadModel ( 'enclosur' );
  3399. $enclosur = new enclosur ();
  3400. $enclosurList = $enclosur->find ( array (
  3401. 'where' => 'rid=' . $rid,
  3402. 'asArray' => true
  3403. ) );
  3404. $enclosurHtml = '';
  3405. foreach ( $enclosurList as $value ) {
  3406. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3407. }
  3408. $data ['enclosurHtml'] = $enclosurHtml;
  3409. //print_r($receiptList[0]['accountItem']['内部培训费用']);
  3410. $data ['receiptList'] = $receiptList;
  3411. $data ['memu'] = "receipt";
  3412. $data ['staff'] = $this->staff;
  3413. $data ['receiptMemu'] = 'expenses';
  3414. $data ['verifyId'] = $this->verifyId;
  3415. $data ['executeId'] = $this->executeId;
  3416. $this->render ( "/admin/expensesCollect", $data );
  3417. }
  3418. function approvalExpenses() {
  3419. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  3420. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3421. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3422. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3423. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3424. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  3425. // echo $rdate;
  3426. if (empty ( $status ))
  3427. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3428. $page_size = 8;
  3429. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  3430. $vidList = array ();
  3431. $button = 0;
  3432. Doo::loadModel ( 'verify' );
  3433. $verify = new verify ();
  3434. Doo::loadModel ( 'receipt' );
  3435. $receipt = new receipt ();
  3436. Doo::loadModel ( 'staff' );
  3437. $staff = new staff ();
  3438. Doo::loadModel ( 'L_category' );
  3439. $Lcategory = new L_category ();
  3440. // user verify ID
  3441. $verifyDetail = $verify->find ( array (
  3442. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  3443. 'asArray' => true
  3444. ) );
  3445. foreach ( $verifyDetail as $key => $value ) {
  3446. array_push ( $vidList, $value ['vid'] );
  3447. }
  3448. $vid = implode ( ",", $vidList );
  3449. if (empty ( $verifyDetail ))
  3450. $vid = 0;
  3451. // if ($status==0)
  3452. // $dateCondition="";
  3453. // else
  3454. $dateCondition = " ";
  3455. // if (! empty ( $month ))
  3456. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  3457. if ($status == 'done' || $status == 'termination') {
  3458. if (! empty ( $year )) {
  3459. $dateCondition = " and Year(pastDate) =" . $year;
  3460. if (! empty ( $month ))
  3461. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  3462. }
  3463. } elseif ($status == 'finish') {
  3464. if (! empty ( $year )) {
  3465. $dateCondition = " and Year(pastDate) =" . $year;
  3466. if (! empty ( $month ))
  3467. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  3468. }
  3469. }
  3470. // date ( 'Y-m' )
  3471. // if (! empty ( $rdate ) && $status == 'done')
  3472. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  3473. // elseif (! empty ( $rdate ))
  3474. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  3475. $categoryList = $Lcategory->find ( array (
  3476. 'asArray' => true
  3477. ) );
  3478. $staffList = $staff->find ( array (
  3479. 'where' => 'cid=' . $cid,
  3480. 'asArray' => true
  3481. ) );
  3482. $cateCondition = "";
  3483. $staffCondition = "";
  3484. $approvalCondition = "";
  3485. if (! empty ( $cid )) {
  3486. $cateCondition = ' and cid=' . $cid;
  3487. }
  3488. if (! empty ( $sid )) {
  3489. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  3490. $cateCondition = "";
  3491. }
  3492. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  3493. if ($status == 'pendApproval') {
  3494. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  3495. }
  3496. if ($status == 'ongoing') {
  3497. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  3498. }
  3499. if ($status == 'done') {
  3500. $approvalCondition = ' and (status=8 or status=9 ) ';
  3501. }
  3502. if ($status == 'termination') {
  3503. $approvalCondition = " and status=3";
  3504. }
  3505. if ($status == 'finish') {
  3506. $approvalCondition = " and (status=1 or status=8 or status=9 or status=10)";
  3507. }
  3508. $pageinfo ['page'] = array (
  3509. 'previous' => ''
  3510. );
  3511. if(!empty($receiptOrder)){
  3512. $pageinfo = $this->get_page ( "CLD_receipt", ' and receiptOrder like "%' . $receiptOrder . '%"', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  3513. $receiptList = $receipt->find ( array ( // $dateCondition
  3514. 'where' => 'receiptOrder like "%' . $receiptOrder . '%"',
  3515. 'desc' => 'rid',
  3516. 'asArray' => true
  3517. ) );
  3518. }else{
  3519. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  3520. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  3521. $receiptList = $receipt->find ( array ( // $dateCondition.
  3522. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  3523. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  3524. 'desc' => 'rid',
  3525. 'asArray' => true
  3526. ) );
  3527. } else {
  3528. $receiptList = $receipt->find ( array ( // $dateCondition
  3529. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  3530. 'desc' => 'rid',
  3531. 'asArray' => true
  3532. ) );
  3533. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  3534. }
  3535. }
  3536. $rLRes = $receipt->find ( array (
  3537. '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 . ')',
  3538. 'desc' => 'rid',
  3539. 'asArray' => true
  3540. ) );
  3541. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  3542. // print_r($receiptList);
  3543. Doo::loadClass ( 'XDeode' );
  3544. $XDeode = new XDeode ( 7 );
  3545. $Locate = 0;
  3546. $reportList = $reportCateList = array ();
  3547. foreach ( $receiptList as $key => $value ) {
  3548. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  3549. $receiptList [$key] ['Locate'] = $Locate;
  3550. $Locate ++;
  3551. $receiptList [$key] ['reviseDetail'] = array ();
  3552. if (! empty ( $value ['reviseDetail'] ))
  3553. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3554. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3555. $categoryDetil = $Lcategory->getOne ( array (
  3556. 'where' => 'cid=' . $value ['cid'],
  3557. 'asArray' => true
  3558. ) );
  3559. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3560. $verifyList = $verify->getOne ( array (
  3561. 'where' => 'vid=' . $value ['verify'],
  3562. 'asArray' => true
  3563. ) );
  3564. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3565. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3566. foreach ( $verifyList as $k => $v ) {
  3567. // init verifyStaff
  3568. $verifyList [$k] ['date'] = "";
  3569. $verifyList [$k] ['opinion'] = "";
  3570. $verifyList [$k] ['status'] = "";
  3571. if (empty ( $verifyStaff )) {
  3572. $verifyList [$k] ['date'] = "";
  3573. $verifyList [$k] ['opinion'] = "";
  3574. if ($v [0] == $this->staff [0] ['sid']) {
  3575. $verifyList [$k] ['status'] = 4;
  3576. $button = 4;
  3577. }
  3578. } else {
  3579. $flag = true;
  3580. foreach ( $verifyStaff as $m => $u ) {
  3581. if ($v [0] == $m) {
  3582. $verifyList [$k] ['date'] = $u ['date'];
  3583. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3584. $verifyList [$k] ['status'] = $u ['status'];
  3585. $flag = false;
  3586. break;
  3587. }
  3588. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  3589. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  3590. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  3591. }
  3592. if ($flag) { // 检测可编辑
  3593. if ($v [0] == $this->staff [0] ['sid']) {
  3594. $verifyList [$k] ['status'] = 4;
  3595. $button = 4;
  3596. }
  3597. }
  3598. }
  3599. }
  3600. $receiptList [$key] ['verifyList'] = $verifyList;
  3601. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3602. 'where' => 'sid=' . $value ['staff'],
  3603. 'asArray' => true
  3604. ) );
  3605. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  3606. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  3607. $receiptList [$key] ['button'] = $button;
  3608. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  3609. //获得培训班结算RID 借款费用--已经锁定
  3610. if($value['status']==10){
  3611. $trainRD=$receipt->getReceiptByTrainLoanRid($value['rid']);
  3612. $receiptList [$key]['trainRidKey7']=$trainRD['ridKey7'];
  3613. }
  3614. }
  3615. $reportList = array_unique ( $reportList );
  3616. $reportHtml = '';
  3617. foreach ( $reportList as $key => $value ) {
  3618. $v = explode ( "-", $value );
  3619. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  3620. }
  3621. // print_r($reportList)
  3622. $data ['reportHtml'] = $reportHtml;
  3623. $reportCateList = array_unique ( $reportCateList );
  3624. $reportCateHtml = '';
  3625. foreach ( $reportCateList as $key => $value ) {
  3626. $v = explode ( "-", $value );
  3627. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  3628. }
  3629. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  3630. $data ['reportCateHtml'] = $reportCateHtml;
  3631. // print_r($receiptList);die;
  3632. // $data['verifyDetail']=$verifyDetail;
  3633. $mothHtml = "";
  3634. for($i = 1; $i <= 12; $i ++) {
  3635. if ($month == $i)
  3636. $mothHtml .= '<option selected value="0' . $i . '">' . $i . '月</option>';
  3637. else
  3638. $mothHtml .= '<option value="0' . $i . '">' . $i . '月</option>';
  3639. }
  3640. $data ['mothHtml'] = $mothHtml;
  3641. $dateHtml = "";
  3642. $now = date ( "Y" );
  3643. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  3644. if ($YEARD <= $now) {
  3645. $dateHtml .= '<option ';
  3646. if ($year == $YEARD) {
  3647. $dateHtml .= 'selected ';
  3648. }
  3649. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  3650. }
  3651. }
  3652. $data ['dateHtml'] = $dateHtml;
  3653. $data ['page'] = $pageinfo;
  3654. $data ['receiptList'] = $receiptList;
  3655. $data ['receiptApprovalCount'] = count ( $rLRes );
  3656. $data ['status'] = $status;
  3657. $data ['year'] = $year;
  3658. $data ['month'] = $month;
  3659. $data ['categoryList'] = $categoryList;
  3660. $data ['staffList'] = $staffList;
  3661. $data ['cid'] = $cid;
  3662. $data ['sid'] = $sid;
  3663. // print_r($receiptList);
  3664. $data['receiptOrder']=$receiptOrder;
  3665. $data ['memu'] = "receipt";
  3666. $data ['staff'] = $this->staff;
  3667. $data ['receiptMemu'] = 'approvalExpenses';
  3668. $data ['verifyId'] = $this->verifyId;
  3669. $data ['executeId'] = $this->executeId;
  3670. $this->render ( "/admin/approvalExpenses", $data );
  3671. }
  3672. function expensesDoc() {
  3673. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3674. Doo::loadClass ( 'XDeode' );
  3675. $XDeode = new XDeode ( 5 );
  3676. if (! empty ( $rid ) && ! is_numeric ( $rid ))
  3677. $rid = $XDeode->decode ( $rid );
  3678. if (! is_numeric ( $rid ))
  3679. die ( 'illegal request' );
  3680. Doo::loadModel ( 'receipt' );
  3681. $receipt = new receipt ();
  3682. Doo::loadModel ( 'L_category' );
  3683. $Lcategory = new L_category ();
  3684. Doo::loadModel ( 'verify' );
  3685. Doo::loadModel ( 'statistics' );
  3686. $statistics = new statistics ();
  3687. $verify = new verify ();
  3688. Doo::loadModel ( 'staff' );
  3689. $staff = new staff ();
  3690. Doo::loadModel ( 'loanReceipt' );
  3691. $loanReceipt = new loanReceipt ();
  3692. $receiptList = $receipt->find ( array (
  3693. 'where' => ' rid=' . $rid,
  3694. 'desc' => 'rid',
  3695. 'asArray' => true
  3696. ) );
  3697. $loanList = array ();
  3698. if (! empty ( $receiptList ))
  3699. $loanList = $loanReceipt->find ( array (
  3700. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3701. 'desc' => 'rid',
  3702. 'asArray' => true
  3703. ) );
  3704. $Locate = 0;
  3705. $roleId = 0;
  3706. $button = 0;
  3707. foreach ( $loanList as $key => $value ) {
  3708. $loanList [$key] ['Locate'] = $Locate;
  3709. $Locate ++;
  3710. $loanList [$key] ['reviseDetail'] = array ();
  3711. if (! empty ( $value ['reviseDetail'] ))
  3712. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3713. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3714. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3715. $categoryDetil = $Lcategory->getOne ( array (
  3716. 'where' => 'cid=' . $value ['cid'],
  3717. 'asArray' => true
  3718. ) );
  3719. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3720. // 检测编辑状态
  3721. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  3722. $verifyList ['staff'] = $value ['verifyBreakup'];
  3723. else
  3724. $verifyList = $verify->getOne ( array (
  3725. 'where' => 'vid=' . $value ['verify'],
  3726. 'asArray' => true
  3727. ) );
  3728. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3729. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3730. Doo::loadModel ( 'role' );
  3731. $role = new role ();
  3732. $flag = true;
  3733. $roleKey = 0;
  3734. $endStaffArray = array ();
  3735. $roleArrayCopy = array ();
  3736. foreach ( $verifyList as $k => $v ) {
  3737. // init verifyStaff
  3738. if ($v [1] == 'ROLE') {
  3739. if (! empty ( $verifyStaff )) {
  3740. $endStaffArray = end ( $verifyStaff );
  3741. // if ($v[0]==$endStaffArray['nextStaff']){
  3742. // $roleId=$v[0];
  3743. // }
  3744. }
  3745. $roleVerify = json_decode ( $v [3], true );
  3746. $roleKey = $k;
  3747. $roleArray = array ();
  3748. $rolename = $role->getOne ( array (
  3749. 'where' => 'rid=' . $v [0],
  3750. 'asArray' => true
  3751. ) );
  3752. foreach ( $roleVerify as $o => $p ) {
  3753. $staffID = explode ( '_', $p );
  3754. $staffInfo = $staff->getOne ( array (
  3755. 'where' => 'sid=' . $staffID [0],
  3756. 'asArray' => true
  3757. ) );
  3758. // print_r($staffID);
  3759. $exp = array (
  3760. 0 => $staffInfo ['sid'],
  3761. 1 => $staffID [1],
  3762. 2 => $staffInfo ['avatar'],
  3763. 'date' => '',
  3764. 'date' => '',
  3765. 'opinion' => '',
  3766. 'status' => '',
  3767. 'rolename' => $rolename ['name']
  3768. );
  3769. array_push ( $roleArray, $exp );
  3770. }
  3771. $roleArrayCopy [$v [0]] = $roleArray;
  3772. // $verifyList[$k]['roleArray']=$roleArray;
  3773. }
  3774. $verifyList [$k] ['date'] = "";
  3775. $verifyList [$k] ['opinion'] = "";
  3776. $verifyList [$k] ['status'] = "";
  3777. if (empty ( $verifyStaff )) {
  3778. $verifyList [$k] ['date'] = "";
  3779. $verifyList [$k] ['opinion'] = "";
  3780. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3781. $verifyList [$k] ['status'] = 4;
  3782. $flag = false;
  3783. }
  3784. } else {
  3785. foreach ( $verifyStaff as $m => $u ) {
  3786. if ($v [0] == $m) {
  3787. $verifyList [$k] ['date'] = $u ['date'];
  3788. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3789. $verifyList [$k] ['status'] = $u ['status'];
  3790. $flag = false;
  3791. break;
  3792. }
  3793. }
  3794. $endStaffArray = end ( $verifyStaff );
  3795. if (isset ( $endStaffArray ['ROLE'] )) {
  3796. } else {
  3797. // $endKey=key($verifyStaff);
  3798. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3799. // $button=4;
  3800. // $verifyList[$k]['status']=4;
  3801. // }
  3802. }
  3803. }
  3804. }
  3805. $rolename ['name'] = '';
  3806. if (! empty ( $roleId )) {
  3807. Doo::loadModel ( 'role' );
  3808. $role = new role ();
  3809. $rolename = $role->getOne ( array (
  3810. 'where' => 'rid=' . $roleId,
  3811. 'asArray' => true
  3812. ) );
  3813. }
  3814. if (! empty ( $verifyStaff ))
  3815. $endStaffArray = end ( $verifyStaff );
  3816. $KOP = false;
  3817. foreach ( $roleArrayCopy as $P => $A ) {
  3818. foreach ( $A as $MKI => $AVL ) {
  3819. if (! empty ( $verifyStaff )) {
  3820. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3821. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3822. $button = 4;
  3823. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3824. }
  3825. foreach ( $verifyStaff as $m => $u ) {
  3826. $AVLFK = $AVL [0] . '_R';
  3827. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3828. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3829. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3830. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3831. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3832. break;
  3833. }
  3834. }
  3835. } else {
  3836. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3837. $button = 4;
  3838. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3839. }
  3840. }
  3841. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3842. $KOP = true;
  3843. }
  3844. }
  3845. foreach ( $roleArrayCopy as $k => $v ) {
  3846. foreach ( $verifyList as $m => $n ) {
  3847. if ($n [0] == $k) {
  3848. array_splice ( $verifyList, $m, 1, $v );
  3849. }
  3850. }
  3851. }
  3852. $loanList [$key] ['verifyList'] = $verifyList;
  3853. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3854. 'where' => 'sid=' . $value ['staff'],
  3855. 'asArray' => true
  3856. ) );
  3857. $loanList [$key] ['button'] = $button;
  3858. //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  3859. }
  3860. $data ['loanList'] = $loanList;
  3861. //print_r($loanList);
  3862. $Locate = 0;
  3863. $roleId = 0;
  3864. $button = 0;
  3865. foreach ( $receiptList as $key => $value ) {
  3866. $receiptList [$key] ['Locate'] = $Locate;
  3867. $Locate ++;
  3868. $receiptList [$key] ['reviseDetail'] = array ();
  3869. if (! empty ( $value ['reviseDetail'] ))
  3870. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3871. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3872. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3873. $categoryDetil = $Lcategory->getOne ( array (
  3874. 'where' => 'cid=' . $value ['cid'],
  3875. 'asArray' => true
  3876. ) );
  3877. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3878. // 检测编辑状态
  3879. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3880. $verifyList ['staff'] = $value ['verifyBreakup'];
  3881. } else
  3882. $verifyList = $verify->getOne ( array (
  3883. 'where' => 'vid=' . $value ['verify'],
  3884. 'asArray' => true
  3885. ) );
  3886. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3887. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3888. Doo::loadModel ( 'role' );
  3889. $role = new role ();
  3890. if ($verifyList == NULL)
  3891. $verifyList = array ();
  3892. $flag = true;
  3893. $roleKey = 0;
  3894. $endStaffArray = array ();
  3895. $roleArrayCopy = array ();
  3896. foreach ( $verifyList as $k => $v ) {
  3897. // init verifyStaff
  3898. if ($v [1] == 'ROLE') {
  3899. if (! empty ( $verifyStaff )) {
  3900. $endStaffArray = end ( $verifyStaff );
  3901. // if ($v[0]==$endStaffArray['nextStaff']){
  3902. // $roleId=$v[0];
  3903. // }
  3904. }
  3905. $roleVerify = json_decode ( $v [3], true );
  3906. $roleKey = $k;
  3907. $roleArray = array ();
  3908. $rolename = $role->getOne ( array (
  3909. 'where' => 'rid=' . $v [0],
  3910. 'asArray' => true
  3911. ) );
  3912. foreach ( $roleVerify as $o => $p ) {
  3913. $staffID = explode ( '_', $p );
  3914. $staffInfo = $staff->getOne ( array (
  3915. 'where' => 'sid=' . $staffID [0],
  3916. 'asArray' => true
  3917. ) );
  3918. // print_r($staffID);
  3919. $exp = array (
  3920. 0 => $staffInfo ['sid'],
  3921. 1 => $staffID [1],
  3922. 2 => $staffInfo ['avatar'],
  3923. 'date' => '',
  3924. 'date' => '',
  3925. 'opinion' => '',
  3926. 'status' => '',
  3927. 'rolename' => $rolename ['name']
  3928. );
  3929. array_push ( $roleArray, $exp );
  3930. }
  3931. $roleArrayCopy [$v [0]] = $roleArray;
  3932. // $verifyList[$k]['roleArray']=$roleArray;
  3933. }
  3934. $verifyList [$k] ['date'] = "";
  3935. $verifyList [$k] ['opinion'] = "";
  3936. $verifyList [$k] ['status'] = "";
  3937. if (empty ( $verifyStaff )) {
  3938. $verifyList [$k] ['date'] = "";
  3939. $verifyList [$k] ['opinion'] = "";
  3940. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3941. $verifyList [$k] ['status'] = 4;
  3942. $flag = false;
  3943. }
  3944. } else {
  3945. foreach ( $verifyStaff as $m => $u ) {
  3946. if ($v [0] == $m) {
  3947. $verifyList [$k] ['date'] = $u ['date'];
  3948. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3949. $verifyList [$k] ['status'] = $u ['status'];
  3950. $flag = false;
  3951. break;
  3952. }
  3953. }
  3954. $endStaffArray = end ( $verifyStaff );
  3955. if (isset ( $endStaffArray ['ROLE'] )) {
  3956. } else {
  3957. // $endKey=key($verifyStaff);
  3958. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3959. // $button=4;
  3960. // $verifyList[$k]['status']=4;
  3961. // }
  3962. }
  3963. }
  3964. }
  3965. $FC = @$rolename ['name'];
  3966. $rolename ['name'] = '';
  3967. if (! empty ( $roleId )) {
  3968. Doo::loadModel ( 'role' );
  3969. $role = new role ();
  3970. $rolename = $role->getOne ( array (
  3971. 'where' => 'rid=' . $roleId,
  3972. 'asArray' => true
  3973. ) );
  3974. }
  3975. if (! empty ( $verifyStaff ))
  3976. $endStaffArray = end ( $verifyStaff );
  3977. $KOP = false;
  3978. foreach ( $roleArrayCopy as $P => $A ) {
  3979. foreach ( $A as $MKI => $AVL ) {
  3980. if (! empty ( $verifyStaff )) {
  3981. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3982. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3983. $button = 4;
  3984. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3985. }
  3986. foreach ( $verifyStaff as $m => $u ) {
  3987. $AVLFK = $AVL [0] . '_R';
  3988. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3989. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3990. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3991. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3992. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3993. break;
  3994. }
  3995. }
  3996. } else {
  3997. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3998. $button = 4;
  3999. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4000. }
  4001. }
  4002. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4003. $KOP = true;
  4004. }
  4005. }
  4006. foreach ( $roleArrayCopy as $k => $v ) {
  4007. foreach ( $verifyList as $m => $n ) {
  4008. if ($n [0] == $k) {
  4009. array_splice ( $verifyList, $m, 1, $v );
  4010. }
  4011. }
  4012. }
  4013. // 费用执行人相关数据
  4014. $executeCopy = json_decode ( $value ['executeCopy'], true );
  4015. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4016. foreach ( $executeCopy as $k => $v ) {
  4017. $executeCopy [$k] ['date'] = '';
  4018. $executeCopy [$k] ['opinion'] = '';
  4019. $executeCopy [$k] ['status'] = '';
  4020. if (! empty ( $executeStaff ))
  4021. foreach ( $executeStaff as $m => $u ) {
  4022. if ($v [0] == $m) {
  4023. $executeCopy [$k] ['date'] = $u ['date'];
  4024. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  4025. $executeCopy [$k] ['status'] = $u ['status'];
  4026. break;
  4027. }
  4028. }
  4029. }
  4030. $receiptList [$key] ['executeCopy'] = $executeCopy;
  4031. // print_r($verifyList);
  4032. $receiptList [$key] ['verifyList'] = $verifyList;
  4033. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4034. 'where' => 'sid=' . $value ['staff'],
  4035. 'asArray' => true
  4036. ) );
  4037. $receiptList [$key] ['button'] = $button;
  4038. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4039. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4040. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4041. $receiptList [$key] ['relust'] = $relust;
  4042. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4043. }
  4044. // print_r($receiptList);
  4045. // 获取审批日志
  4046. Doo::loadModel ( 'receiptLog' );
  4047. $receiptLog = new receiptLog ();
  4048. $rlList = array ();
  4049. $rlInfo = $receiptLog->getOne ( array (
  4050. 'where' => 'rid=' . $rid . ' and status=4',
  4051. 'asArray' => true
  4052. ) );
  4053. // $tijdate = $receiptLog->getOne ( array (
  4054. // 'where' => 'rid=' . $rid . ' and status=2',
  4055. // 'asc' => 'rlid',
  4056. // 'asArray' => true
  4057. // ) );
  4058. if (! empty ( $rlInfo )) {
  4059. $rlList = $receiptLog->find ( array (
  4060. 'where' => 'rid=' . $rid,
  4061. 'asc' => 'rlid',
  4062. 'asArray' => true
  4063. ) );
  4064. }
  4065. $RN=array();
  4066. if (!empty( $rolename ['staff'])){
  4067. $RN = @json_decode ( $rolename ['staff'] );
  4068. }
  4069. //
  4070. foreach ( $rlList as $key => $value ) {
  4071. $rlList [$key] ['rolename'] = '';
  4072. foreach ( $RN as $k => $v ) {
  4073. $id = explode ( "_", $v );
  4074. if ($id [0] == $value ['uid']) {
  4075. $rlList [$key] ['rolename'] = $FC;
  4076. break;
  4077. }
  4078. }
  4079. }
  4080. Doo::loadModel ( 'enclosur' );
  4081. $enclosur = new enclosur ();
  4082. $enclosurList = $enclosur->find ( array (
  4083. 'where' => 'rid=' . $rid,
  4084. 'asArray' => true
  4085. ) );
  4086. $enclosurHtml = '';
  4087. foreach ( $enclosurList as $value ) {
  4088. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4089. }
  4090. $data ['enclosurHtml'] = $enclosurHtml;
  4091. $receiptList [0] ['rlList'] = $rlList;
  4092. $data ['receiptList'] = $receiptList;
  4093. // print_r($receiptList);
  4094. $data ['memu'] = "receipt";
  4095. $data ['staff'] = $this->staff;
  4096. $data ['receiptMemu'] = 'approvalExpenses';
  4097. $data ['verifyId'] = $this->verifyId;
  4098. $data ['executeId'] = $this->executeId;
  4099. $this->render ( "/admin/expensesDoc", $data );
  4100. }
  4101. function expensesEdi() {
  4102. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4103. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  4104. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4105. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4106. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4107. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4108. if (empty ( $status ))
  4109. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  4110. $vidList = array ();
  4111. $button = 0;
  4112. Doo::loadModel ( 'verify' );
  4113. Doo::loadModel ( 'receipt' );
  4114. Doo::loadModel ( 'staff' );
  4115. $staff = new staff ();
  4116. $receipt = new receipt ();
  4117. $verify = new verify ();
  4118. Doo::loadModel ( 'L_category' );
  4119. $Lcategory = new L_category ();
  4120. Doo::loadModel ( 'enclosur' );
  4121. $enclosur = new enclosur ();
  4122. // user verify ID
  4123. $verifyDetail = $verify->find ( array (
  4124. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  4125. 'asArray' => true
  4126. ) );
  4127. foreach ( $verifyDetail as $key => $value ) {
  4128. array_push ( $vidList, $value ['vid'] );
  4129. }
  4130. $vid = implode ( ",", $vidList );
  4131. if (empty ( $verifyDetail ))
  4132. $vid = 0;
  4133. $categoryList = $Lcategory->find ( array (
  4134. 'asArray' => true
  4135. ) );
  4136. $staffList = $staff->find ( array (
  4137. 'where' => 'cid=' . $cid,
  4138. 'asArray' => true
  4139. ) );
  4140. $ap = "";
  4141. if ($status == 4) {
  4142. $ap = 4;
  4143. $status = 2;
  4144. }
  4145. // get Receipt By verifyID status 2
  4146. $receiptList = $receipt->find ( array (
  4147. 'where' => 'rid =' . $rid . ' and status=2',
  4148. 'desc' => 'rid',
  4149. 'asArray' => true
  4150. ) );
  4151. if (empty ( $receiptList )) {
  4152. die ( 'illegal request' );
  4153. }
  4154. $Locate = 0;
  4155. $roleId = 0;
  4156. if ($ap == 4)
  4157. $status = 4;
  4158. foreach ( $receiptList as $key => $value ) {
  4159. $receiptList [$key] ['Locate'] = $Locate;
  4160. $Locate ++;
  4161. $receiptList [$key] ['reviseDetail'] = array ();
  4162. if (! empty ( $value ['reviseDetail'] ))
  4163. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4164. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4165. $categoryDetil = $Lcategory->getOne ( array (
  4166. 'where' => 'cid=' . $value ['cid'],
  4167. 'asArray' => true
  4168. ) );
  4169. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4170. // 检测编辑状态
  4171. $verifyList = $verify->getOne ( array (
  4172. 'where' => 'vid=' . $value ['verify'],
  4173. 'asArray' => true
  4174. ) );
  4175. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4176. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4177. Doo::loadModel ( 'role' );
  4178. $role = new role ();
  4179. // print_r($verifyList);
  4180. $flag = true;
  4181. $roleKey = 0;
  4182. $endStaffArray = array ();
  4183. $roleArrayCopy = array ();
  4184. foreach ( $verifyList as $k => $v ) {
  4185. // init verifyStaff
  4186. if ($v [1] == 'ROLE') {
  4187. if (! empty ( $verifyStaff )) {
  4188. $endStaffArray = end ( $verifyStaff );
  4189. if ($v [0] == $endStaffArray ['nextStaff']) {
  4190. $roleId = $v [0];
  4191. }
  4192. }
  4193. $roleVerify = json_decode ( $v [3], true );
  4194. $roleKey = $k;
  4195. $roleArray = array ();
  4196. $rolename = $role->getOne ( array (
  4197. 'where' => 'rid=' . $v [0],
  4198. 'asArray' => true
  4199. ) );
  4200. foreach ( $roleVerify as $o => $p ) {
  4201. $staffID = explode ( '_', $p );
  4202. $staffInfo = $staff->getOne ( array (
  4203. 'where' => 'sid=' . $staffID [0],
  4204. 'asArray' => true
  4205. ) );
  4206. // print_r($staffID);
  4207. $exp = array (
  4208. 0 => $staffInfo ['sid'],
  4209. 1 => $staffID [1],
  4210. 2 => $staffInfo ['avatar'],
  4211. 'date' => '',
  4212. 'date' => '',
  4213. 'opinion' => '',
  4214. 'status' => '',
  4215. 'rolename' => $rolename ['name']
  4216. );
  4217. array_push ( $roleArray, $exp );
  4218. }
  4219. $roleArrayCopy [$v [0]] = $roleArray;
  4220. // $verifyList[$k]['roleArray']=$roleArray;
  4221. }
  4222. // print_r($roleArray);
  4223. $verifyList [$k] ['date'] = "";
  4224. $verifyList [$k] ['opinion'] = "";
  4225. $verifyList [$k] ['status'] = "";
  4226. if (empty ( $verifyStaff )) {
  4227. $verifyList [$k] ['date'] = "";
  4228. $verifyList [$k] ['opinion'] = "";
  4229. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4230. $verifyList [$k] ['status'] = 4;
  4231. $button = 4;
  4232. $flag = false;
  4233. }
  4234. } else {
  4235. foreach ( $verifyStaff as $m => $u ) {
  4236. if ($v [0] == $m) {
  4237. $verifyList [$k] ['date'] = $u ['date'];
  4238. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4239. $verifyList [$k] ['status'] = $u ['status'];
  4240. $flag = false;
  4241. break;
  4242. }
  4243. }
  4244. $endStaffArray = end ( $verifyStaff );
  4245. if (isset ( $endStaffArray ['ROLE'] )) {
  4246. } else {
  4247. $endKey = key ( $verifyStaff );
  4248. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4249. $button = 4;
  4250. $verifyList [$k] ['status'] = 4;
  4251. }
  4252. }
  4253. }
  4254. }
  4255. $rolename ['name'] = '';
  4256. if (! empty ( $roleId )) {
  4257. Doo::loadModel ( 'role' );
  4258. $role = new role ();
  4259. $rolename = $role->getOne ( array (
  4260. 'where' => 'rid=' . $roleId,
  4261. 'asArray' => true
  4262. ) );
  4263. }
  4264. if (! empty ( $verifyStaff ))
  4265. $endStaffArray = end ( $verifyStaff );
  4266. $KOP = false;
  4267. foreach ( $roleArrayCopy as $P => $A ) {
  4268. foreach ( $A as $MKI => $AVL ) {
  4269. if (! empty ( $verifyStaff )) {
  4270. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4271. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4272. $button = 4;
  4273. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4274. }
  4275. foreach ( $verifyStaff as $m => $u ) {
  4276. $AVLFK = $AVL [0] . '_R';
  4277. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4278. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4279. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4280. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4281. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4282. break;
  4283. }
  4284. }
  4285. } else {
  4286. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4287. $button = 4;
  4288. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4289. }
  4290. }
  4291. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4292. $KOP = true;
  4293. }
  4294. }
  4295. // print_r($roleArrayCopy);
  4296. // echo $roleKey;
  4297. foreach ( $roleArrayCopy as $k => $v ) {
  4298. foreach ( $verifyList as $m => $n ) {
  4299. if ($n [0] == $k) {
  4300. array_splice ( $verifyList, $m, 1, $v );
  4301. }
  4302. }
  4303. }
  4304. $receiptList [$key] ['verifyList'] = $verifyList;
  4305. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4306. 'where' => 'sid=' . $value ['staff'],
  4307. 'asArray' => true
  4308. ) );
  4309. $receiptList [$key] ['button'] = $button;
  4310. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  4311. }
  4312. // $data['verifyDetail']=$verifyDetail;
  4313. $mothHtml = "";
  4314. for($i = 1; $i <= 12; $i ++) {
  4315. if ($month == $i)
  4316. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4317. else
  4318. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4319. }
  4320. // 获取审批日志
  4321. Doo::loadModel ( 'receiptLog' );
  4322. $receiptLog = new receiptLog ();
  4323. $rlList = array ();
  4324. $rlInfo = $receiptLog->getOne ( array (
  4325. 'where' => 'rid=' . $rid . ' and status=4',
  4326. 'asArray' => true
  4327. ) );
  4328. $tijdate = $receiptLog->getOne ( array (
  4329. 'where' => 'rid=' . $rid . ' and status=2',
  4330. 'asc' => 'rlid',
  4331. 'asArray' => true
  4332. ) );
  4333. if (! empty ( $rlInfo )) {
  4334. $rlList = $receiptLog->find ( array (
  4335. 'where' => 'rid=' . $rid,
  4336. 'asc' => 'rlid',
  4337. 'asArray' => true
  4338. ) );
  4339. }
  4340. $receiptList [0] ['rlList'] = $rlList;
  4341. $enclosurList = $enclosur->find ( array (
  4342. 'where' => 'rid=' . $rid,
  4343. 'asArray' => true
  4344. ) );
  4345. $enclosurHtml = '';
  4346. foreach ( $enclosurList as $value ) {
  4347. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4348. }
  4349. // print_r($receiptList);
  4350. $data ['rid'] = $rid;
  4351. $data ['enclosurHtml'] = $enclosurHtml;
  4352. $data ['rolename'] = $rolename ['name'];
  4353. $data ['datetij'] = $tijdate ['date'];
  4354. $data ['mothHtml'] = $mothHtml;
  4355. $data ['receiptList'] = $receiptList;
  4356. $data ['receiptApprovalCount'] = count ( $receiptList );
  4357. $data ['status'] = $status;
  4358. $data ['year'] = $year;
  4359. $data ['categoryList'] = $categoryList;
  4360. $data ['staffList'] = $staffList;
  4361. $data ['cid'] = $cid;
  4362. $data ['sid'] = $sid;
  4363. $data ['ap'] = $ap;
  4364. $data ['memu'] = "receipt";
  4365. $data ['staff'] = $this->staff;
  4366. $data ['receiptMemu'] = 'approvalExpenses';
  4367. $data ['verifyId'] = $this->verifyId;
  4368. $data ['executeId'] = $this->executeId;
  4369. $this->render ( "/admin/expensesEdi", $data );
  4370. }
  4371. function expensesDefray() {
  4372. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  4373. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  4374. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4375. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  4376. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  4377. if (! empty ( $rid )) {
  4378. Doo::loadModel ( "verify" );
  4379. $verify = new verify ();
  4380. Doo::loadModel ( "receiptDetail" );
  4381. $receiptDetailObj = new receiptDetail ();
  4382. Doo::loadModel ( "itemStatistics" );
  4383. Doo::loadModel ( "statistics" );
  4384. $statistics = new statistics ();
  4385. $itemStatistics = new itemStatistics ();
  4386. Doo::loadModel ( "receipt" );
  4387. $receipt = new receipt ();
  4388. Doo::loadModel ( "loanReceipt" );
  4389. $loanReceipt = new loanReceipt ();
  4390. $receiptDetail = $receipt->getOne ( array (
  4391. 'where' => 'rid=' . $rid . ' and status=2 ',
  4392. 'asArray' => true
  4393. ) );
  4394. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  4395. $nsflag = true;
  4396. foreach ( $nslist as $value ) {
  4397. if ($value == $this->staff ['0'] ['sid']) {
  4398. $nsflag = false;
  4399. break;
  4400. }
  4401. }
  4402. // print_r($nslist);die;
  4403. if (empty ( $receiptDetail ) || $nsflag)
  4404. return "/approvalExpenses/pendApproval";
  4405. $verifyDetail = $verify->getOne ( array (
  4406. 'where' => ' vid =' . $receiptDetail ['verify'],
  4407. 'asArray' => true
  4408. ) );
  4409. $verifyString = $verifyDetail ['staff'];
  4410. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  4411. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  4412. if (empty ( $opinion )) {
  4413. if ($status == 3)
  4414. $opinion = "终止";
  4415. else
  4416. $opinion = "同意支付";
  4417. }
  4418. $nowStaff = 0;
  4419. $nowStaffList = array ();
  4420. if (empty ( $verifyStaff )) {
  4421. // 还需加入是否已经进入角色审批
  4422. if ($verifyDetail [0] [1] == 'ROLE') {
  4423. // print_r($verifyDetail);echo "ddd";
  4424. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  4425. foreach ( $vStaffString as $key => $value ) {
  4426. $staffK = explode ( "_", $value );
  4427. if ($staffK [0] != $this->staff [0] ['sid'])
  4428. array_push ( $nowStaffList, $staffK [0] );
  4429. }
  4430. // print_r($verifyDetail);
  4431. // die;
  4432. if (! empty ( $nowStaffList )) {
  4433. $nowStaff = implode ( ',', $nowStaffList );
  4434. $verifyStaff = array (
  4435. $this->staff [0] ['sid'] . "_R" => array (
  4436. 'date' => date ( 'Y-m-d' ),
  4437. 'opinion' => $opinion,
  4438. 'status' => $status,
  4439. 'nextStaff' => $verifyDetail [0] [0],
  4440. 'ROLE' => 1
  4441. )
  4442. );
  4443. } else {
  4444. $nowStaff = $verifyDetail [1] [0];
  4445. $verifyStaff = array (
  4446. $this->staff [0] ['sid'] . "_R" => array (
  4447. 'date' => date ( 'Y-m-d' ),
  4448. 'opinion' => $opinion,
  4449. 'status' => $status,
  4450. 'nextStaff' => $verifyDetail [1] [0]
  4451. )
  4452. );
  4453. }
  4454. } else {
  4455. if ($verifyDetail [1] [1] == 'ROLE') {
  4456. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  4457. // echo "dd";
  4458. foreach ( $vStaffString as $key => $value ) {
  4459. $staffK = explode ( "_", $value );
  4460. array_push ( $nowStaffList, $staffK [0] );
  4461. }
  4462. $nowStaff = implode ( ',', $nowStaffList );
  4463. $verifyStaff = array (
  4464. $this->staff [0] ['sid'] => array (
  4465. 'date' => date ( 'Y-m-d' ),
  4466. 'opinion' => $opinion,
  4467. 'status' => $status,
  4468. 'nextStaff' => $verifyDetail [1] [0],
  4469. 'ROLE' => 1
  4470. )
  4471. );
  4472. } else {
  4473. $nowStaff = $verifyDetail [1] [0];
  4474. $verifyStaff = array (
  4475. $this->staff [0] ['sid'] => array (
  4476. 'date' => date ( 'Y-m-d' ),
  4477. 'opinion' => $opinion,
  4478. 'status' => $status,
  4479. 'nextStaff' => $verifyDetail [1] [0]
  4480. )
  4481. );
  4482. }
  4483. }
  4484. if ($status == 3)
  4485. $verifyStaff = array (
  4486. 'final' => $status,
  4487. $this->staff [0] ['sid'] => array (
  4488. 'date' => date ( 'Y-m-d' ),
  4489. 'opinion' => $opinion,
  4490. 'status' => $status
  4491. )
  4492. );
  4493. $vStaffString = json_encode ( $verifyStaff );
  4494. $receipt->nowStaff = $nowStaff;
  4495. $receipt->verifyStaff = $vStaffString;
  4496. $loanReceipt->nowStaff = $nowStaff;
  4497. $loanReceipt->verifyStaff = $vStaffString;
  4498. } else {
  4499. $VS = end ( $verifyStaff );
  4500. // 非角色审批
  4501. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  4502. $nextStaff = 0;
  4503. $roleSTF = false;
  4504. foreach ( $verifyDetail as $key => $value ) {
  4505. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  4506. if (isset ( $verifyDetail [$key + 1] )) {
  4507. $nextStaff = $verifyDetail [$key + 1] [0];
  4508. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  4509. $roleSTF = true;
  4510. }
  4511. break;
  4512. }
  4513. }
  4514. if (! $roleSTF) {
  4515. $nowStaff = $nextStaff;
  4516. $verifyStaff [$this->staff [0] ['sid']] = array (
  4517. 'date' => date ( 'Y-m-d' ),
  4518. 'opinion' => $opinion,
  4519. 'status' => $status,
  4520. 'nextStaff' => $nextStaff
  4521. );
  4522. } else {
  4523. // 获取角色下的所有用户ID
  4524. $nowStaffList = array ();
  4525. foreach ( $verifyDetail as $vfk ) {
  4526. if ($vfk [1] == 'ROLE') {
  4527. $vStaffString = json_decode ( $vfk [3] );
  4528. foreach ( $vStaffString as $key => $value ) {
  4529. $staffK = explode ( "_", $value );
  4530. array_push ( $nowStaffList, $staffK [0] );
  4531. }
  4532. }
  4533. }
  4534. $nowStaff = implode ( ',', $nowStaffList );
  4535. $verifyStaff [$this->staff [0] ['sid']] = array (
  4536. 'date' => date ( 'Y-m-d' ),
  4537. 'opinion' => $opinion,
  4538. 'status' => $status,
  4539. 'nextStaff' => $nextStaff,
  4540. 'ROLE' => 0
  4541. );
  4542. }
  4543. if ($status == 3) {
  4544. $verifyStaff ['final'] = $status;
  4545. $verifyStaff [$this->staff [0] ['sid']] = array (
  4546. 'date' => date ( 'Y-m-d' ),
  4547. 'opinion' => $opinion,
  4548. 'status' => $status
  4549. );
  4550. }
  4551. $vStaffString = json_encode ( $verifyStaff );
  4552. $receipt->nowStaff = $nowStaff;
  4553. $receipt->verifyStaff = $vStaffString;
  4554. $loanReceipt->nowStaff = $nowStaff;
  4555. $loanReceipt->verifyStaff = $vStaffString;
  4556. }
  4557. // 角色审批
  4558. if (isset ( $VS ['ROLE'] )) {
  4559. // 找出角色人 当前审批角色组
  4560. $verifyJSStaff = array ();
  4561. $nowStaffList2 = array ();
  4562. foreach ( $verifyDetail as $key => $value ) {
  4563. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  4564. $verifyJSStaff = json_decode ( $value [3] );
  4565. foreach ( $verifyJSStaff as $m ) {
  4566. $staffK = explode ( "_", $m );
  4567. array_push ( $nowStaffList2, $staffK [0] );
  4568. }
  4569. // print_r($nowStaffList2);
  4570. }
  4571. }
  4572. $RoleVerifyStaff = array ();
  4573. foreach ( $verifyStaff as $key => $value ) {
  4574. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  4575. foreach ( $nowStaffList2 as $m ) {
  4576. if ($key == $m . "_R")
  4577. $RoleVerifyStaff [$key] = $value;
  4578. }
  4579. }
  4580. }
  4581. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  4582. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  4583. // 下一个审批人ID
  4584. $nextStaff = 0;
  4585. $falg = false;
  4586. foreach ( $verifyDetail as $key => $value ) {
  4587. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  4588. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  4589. $falg = true;
  4590. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  4591. $nowStaffList = array ();
  4592. foreach ( $vStaffString as $v ) {
  4593. $staffK = explode ( "_", $v );
  4594. array_push ( $nowStaffList, $staffK [0] );
  4595. }
  4596. $nowStaff = implode ( ',', $nowStaffList );
  4597. $nextStaff = $verifyDetail [$key + 1] [0];
  4598. } elseif (isset ( $verifyDetail [$key + 1] )) {
  4599. $nextStaff = $verifyDetail [$key + 1] [0];
  4600. $nowStaff = $nextStaff;
  4601. } else
  4602. $nowStaff = '';
  4603. break;
  4604. }
  4605. }
  4606. if ($falg)
  4607. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  4608. 'date' => date ( 'Y-m-d' ),
  4609. 'opinion' => $opinion,
  4610. 'status' => $status,
  4611. 'nextStaff' => $nextStaff,
  4612. 'ROLE' => 1
  4613. );
  4614. else
  4615. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  4616. 'date' => date ( 'Y-m-d' ),
  4617. 'opinion' => $opinion,
  4618. 'status' => $status,
  4619. 'nextStaff' => $nextStaff
  4620. );
  4621. // print_r($verifyStaff);
  4622. // echo $nowStaff;die;
  4623. } else { // 进入下一个角色或者审批人
  4624. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  4625. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  4626. 'date' => date ( 'Y-m-d' ),
  4627. 'opinion' => $opinion,
  4628. 'status' => $status,
  4629. 'nextStaff' => $VS ['nextStaff'],
  4630. 'ROLE' => 1
  4631. );
  4632. }
  4633. if ($status == 3) {
  4634. $verifyStaff ['final'] = $status;
  4635. $verifyStaff [$this->staff [0] ['sid']] = array (
  4636. 'date' => date ( 'Y-m-d' ),
  4637. 'opinion' => $opinion,
  4638. 'status' => $status
  4639. );
  4640. }
  4641. $vStaffString = json_encode ( $verifyStaff );
  4642. $receipt->verifyStaff = $vStaffString;
  4643. $receipt->nowStaff = $nowStaff;
  4644. $loanReceipt->nowStaff = $nowStaff;
  4645. $loanReceipt->verifyStaff = $vStaffString;
  4646. }
  4647. // print_r($verifyStaff);die;
  4648. }
  4649. $roleKey = 0;
  4650. $roleId = 0;
  4651. $verifyDetailCopy = array ();
  4652. foreach ( $verifyDetail as $k => $v ) {
  4653. if ($v [1] == 'ROLE') {
  4654. $roleId = $v [0];
  4655. $roleVerify = json_decode ( $v [3], true );
  4656. $roleKey = $k;
  4657. $roleArray = array ();
  4658. foreach ( $roleVerify as $o => $p ) {
  4659. $staffID = explode ( '_', $p );
  4660. $exp = array (
  4661. 0 => $staffID [0],
  4662. 1 => $staffID [1]
  4663. );
  4664. array_push ( $roleArray, $exp );
  4665. }
  4666. $verifyDetailCopy [$v [0]] = $roleArray;
  4667. }
  4668. }
  4669. // print_r($verifyDetail);
  4670. foreach ( $verifyDetailCopy as $k => $v ) {
  4671. foreach ( $verifyDetail as $m => $n ) {
  4672. if ($n [0] == $k) {
  4673. array_splice ( $verifyDetail, $m, 1, $v );
  4674. }
  4675. }
  4676. }
  4677. // 审批日志
  4678. if (! isset ( $verifyStaff ['final'] )) {
  4679. Doo::loadModel ( "receiptLog" );
  4680. $receiptLog = new receiptLog ();
  4681. if (! empty ( $roleId )) {
  4682. Doo::loadModel ( "role" );
  4683. $role = new role ();
  4684. $roleInfo = $role->getOne ( array (
  4685. 'where' => 'rid=' . $roleId,
  4686. 'asArray' => true
  4687. ) );
  4688. $receiptLog->rolename = $roleInfo ['name'];
  4689. }
  4690. $receiptLog->username = $this->staff [0] ['username'];
  4691. $receiptLog->uid = $this->staff [0] ['sid'];
  4692. $receiptLog->date = date ( "Y-m-d" );
  4693. $receiptLog->opinion = $opinion;
  4694. $receiptLog->img = $this->staff [0] ['avatar'];
  4695. $receiptLog->status = 1;
  4696. $receiptLog->rid = $rid;
  4697. $receiptLog->insert ();
  4698. }
  4699. if (isset ( $verifyStaff ['final'] )) { // rDetail
  4700. $receipt->status = 3;
  4701. $receipt->verifyBreakup = $verifyString;
  4702. $receiptDetailObj->status = 3;
  4703. $receiptDetailObj->update ( array (
  4704. 'where' => 'rid=' . $rid
  4705. ) );
  4706. // 微信企业号通知
  4707. $this->setWXMsg ( $rid, 3 );
  4708. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  4709. $receipt->status = 6;
  4710. $receipt->pastDate = date ( "Y-m-d" );
  4711. $receipt->isBK = 1;
  4712. $loanReceipt->verifyBreakup = $verifyString;
  4713. $loanReceipt->status = 1;
  4714. $loanReceipt->pastDate = date ( "Y-m-d" );
  4715. //生成流水后 不更新汇款金额
  4716. Doo::loadModel ( 'wasteBook' );
  4717. $wasteBook = new wasteBook ();
  4718. $wbDetail = $wasteBook->getWateBookByAD ( 1, $rid );
  4719. if (empty($wbDetail)){
  4720. $loanReceipt->amount = $receiptDetail ['amount'];
  4721. }
  4722. $loanReceipt->update ( array (
  4723. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  4724. ) );
  4725. // 微信企业号通知
  4726. $this->setWXMsg ( $rid, 1 );
  4727. }
  4728. $receipt->amount = $receiptDetail['sum'];
  4729. $receipt->update ( array (
  4730. 'where' => ' rid = ' . $rid
  4731. ) );
  4732. // 进入下一条审批费用新加需求
  4733. $vidList = array ();
  4734. $verifyDetail = $verify->find ( array (
  4735. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  4736. 'asArray' => true
  4737. ) );
  4738. foreach ( $verifyDetail as $key => $value ) {
  4739. array_push ( $vidList, $value ['vid'] );
  4740. }
  4741. $vid = implode ( ",", $vidList );
  4742. if (empty ( $verifyDetail ))
  4743. $vid = 0;
  4744. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  4745. $receipt = new receipt ();
  4746. $rd = $receipt->getOne ( array (
  4747. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  4748. 'asc' => 'rid',
  4749. 'asArray' => true
  4750. ) );
  4751. if (empty ( $rd )) {
  4752. return '/approvalExpenses/pendApproval';
  4753. }
  4754. if ($rd ['Rtype'] == 1) {
  4755. if ($rd ['isBK'] == 1) {
  4756. return '/receiptburEdi/' . $rd ['rid'];
  4757. } else {
  4758. return '/expensesEdi/' . $rd ['rid'];
  4759. }
  4760. } elseif ($rd ['Rtype'] == 2) {
  4761. return '/remitApproval/' . $rd ['rid'];
  4762. } else {
  4763. return '/receiptburEdi/' . $rd ['rid'];
  4764. }
  4765. // return "/approvalExpenses/pendApproval";
  4766. }
  4767. }
  4768. function ajaxExamineExe() {
  4769. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4770. Doo::loadModel ( 'receipt' );
  4771. $receipt = new receipt ();
  4772. Doo::loadClass ( 'XDeode' );
  4773. $XDeode = new XDeode ( 5 );
  4774. if (! empty ( $rid )) {
  4775. $rLRes = $receipt->find ( array (
  4776. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  4777. 'asArray' => true
  4778. ) );
  4779. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  4780. echo json_encode ( array (
  4781. 'status' => 1,
  4782. 'receipt' => $rLRes [0]
  4783. ) );
  4784. die ();
  4785. }
  4786. echo json_encode ( array (
  4787. 'status' => 0,
  4788. 'receipt' => array ()
  4789. ) );
  4790. die ();
  4791. }
  4792. function implement() {
  4793. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4794. $Rtype = isset ( $this->params ['Rtype'] ) ? $this->params ['Rtype'] : '';
  4795. Doo::loadClass ( 'XDeode' );
  4796. $XDeode = new XDeode ( 5 );
  4797. Doo::loadModel ( 'receipt' );
  4798. $receipt = new receipt ();
  4799. Doo::loadModel ( 'L_category' );
  4800. $Lcategory = new L_category ();
  4801. Doo::loadModel ( 'verify' );
  4802. $verify = new verify ();
  4803. Doo::loadModel ( 'staff' );
  4804. $staff = new staff ();
  4805. Doo::loadModel ( "execute" );
  4806. $execute = new execute ();
  4807. $rid = $XDeode->decode ( $rid );
  4808. $receiptList = $receipt->find ( array (
  4809. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  4810. 'desc' => 'rid',
  4811. 'asArray' => true
  4812. ) );
  4813. Doo::loadModel ( 'loanReceipt' );
  4814. $loanReceipt = new loanReceipt ();
  4815. // print_r($receiptList);
  4816. $loanList = array ();
  4817. if (! isset ( $receiptList ))
  4818. $loanList = $loanReceipt->find ( array (
  4819. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4820. 'desc' => 'rid',
  4821. 'asArray' => true
  4822. ) );
  4823. $Locate = 0;
  4824. $roleId = 0;
  4825. $button = 0;
  4826. foreach ( $loanList as $key => $value ) {
  4827. $loanList [$key] ['Locate'] = $Locate;
  4828. $Locate ++;
  4829. $loanList [$key] ['reviseDetail'] = array ();
  4830. if (! empty ( $value ['reviseDetail'] ))
  4831. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4832. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4833. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4834. $categoryDetil = $Lcategory->getOne ( array (
  4835. 'where' => 'cid=' . $value ['cid'],
  4836. 'asArray' => true
  4837. ) );
  4838. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4839. // 检测编辑状态
  4840. $verifyList = $verify->getOne ( array (
  4841. 'where' => 'vid=' . $value ['verify'],
  4842. 'asArray' => true
  4843. ) );
  4844. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4845. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4846. Doo::loadModel ( 'role' );
  4847. $role = new role ();
  4848. $flag = true;
  4849. $roleKey = 0;
  4850. $endStaffArray = array ();
  4851. $roleArrayCopy = array ();
  4852. foreach ( $verifyList as $k => $v ) {
  4853. // init verifyStaff
  4854. if ($v [1] == 'ROLE') {
  4855. if (! empty ( $verifyStaff )) {
  4856. $endStaffArray = end ( $verifyStaff );
  4857. // if ($v[0]==$endStaffArray['nextStaff']){
  4858. // $roleId=$v[0];
  4859. // }
  4860. }
  4861. $roleVerify = json_decode ( $v [3], true );
  4862. $roleKey = $k;
  4863. $roleArray = array ();
  4864. $rolename = $role->getOne ( array (
  4865. 'where' => 'rid=' . $v [0],
  4866. 'asArray' => true
  4867. ) );
  4868. foreach ( $roleVerify as $o => $p ) {
  4869. $staffID = explode ( '_', $p );
  4870. $staffInfo = $staff->getOne ( array (
  4871. 'where' => 'sid=' . $staffID [0],
  4872. 'asArray' => true
  4873. ) );
  4874. // print_r($staffID);
  4875. $exp = array (
  4876. 0 => $staffInfo ['sid'],
  4877. 1 => $staffID [1],
  4878. 2 => $staffInfo ['avatar'],
  4879. 'date' => '',
  4880. 'date' => '',
  4881. 'opinion' => '',
  4882. 'status' => '',
  4883. 'rolename' => $rolename ['name']
  4884. );
  4885. array_push ( $roleArray, $exp );
  4886. }
  4887. $roleArrayCopy [$v [0]] = $roleArray;
  4888. // $verifyList[$k]['roleArray']=$roleArray;
  4889. }
  4890. $verifyList [$k] ['date'] = "";
  4891. $verifyList [$k] ['opinion'] = "";
  4892. $verifyList [$k] ['status'] = "";
  4893. if (empty ( $verifyStaff )) {
  4894. $verifyList [$k] ['date'] = "";
  4895. $verifyList [$k] ['opinion'] = "";
  4896. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4897. $verifyList [$k] ['status'] = 4;
  4898. $flag = false;
  4899. }
  4900. } else {
  4901. foreach ( $verifyStaff as $m => $u ) {
  4902. if ($v [0] == $m) {
  4903. $verifyList [$k] ['date'] = $u ['date'];
  4904. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4905. $verifyList [$k] ['status'] = $u ['status'];
  4906. $flag = false;
  4907. break;
  4908. }
  4909. }
  4910. $endStaffArray = end ( $verifyStaff );
  4911. if (isset ( $endStaffArray ['ROLE'] )) {
  4912. } else {
  4913. // $endKey=key($verifyStaff);
  4914. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4915. // $button=4;
  4916. // $verifyList[$k]['status']=4;
  4917. // }
  4918. }
  4919. }
  4920. }
  4921. $rolename ['name'] = '';
  4922. if (! empty ( $roleId )) {
  4923. Doo::loadModel ( 'role' );
  4924. $role = new role ();
  4925. $rolename = $role->getOne ( array (
  4926. 'where' => 'rid=' . $roleId,
  4927. 'asArray' => true
  4928. ) );
  4929. }
  4930. if (! empty ( $verifyStaff ))
  4931. $endStaffArray = end ( $verifyStaff );
  4932. $KOP = false;
  4933. foreach ( $roleArrayCopy as $P => $A ) {
  4934. foreach ( $A as $MKI => $AVL ) {
  4935. if (! empty ( $verifyStaff )) {
  4936. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4937. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4938. $button = 4;
  4939. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4940. }
  4941. foreach ( $verifyStaff as $m => $u ) {
  4942. $AVLFK = $AVL [0] . '_R';
  4943. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4944. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4945. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4946. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4947. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4948. break;
  4949. }
  4950. }
  4951. } else {
  4952. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4953. $button = 4;
  4954. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4955. }
  4956. }
  4957. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4958. $KOP = true;
  4959. }
  4960. }
  4961. foreach ( $roleArrayCopy as $k => $v ) {
  4962. foreach ( $verifyList as $m => $n ) {
  4963. if ($n [0] == $k) {
  4964. array_splice ( $verifyList, $m, 1, $v );
  4965. }
  4966. }
  4967. }
  4968. $loanList [$key] ['verifyList'] = $verifyList;
  4969. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  4970. 'where' => 'sid=' . $value ['staff'],
  4971. 'asArray' => true
  4972. ) );
  4973. }
  4974. $data ['loanList'] = $loanList;
  4975. $Locate = 0;
  4976. $roleId = 0;
  4977. $button = 0;
  4978. Doo::loadClass ( 'XDeode' );
  4979. $XDeode = new XDeode ( 5 );
  4980. foreach ( $receiptList as $key => $value ) {
  4981. $receiptList[$key]['ridKey']=$XDeode->encode ( $value['rid'] );
  4982. $button2 = 0;
  4983. $receiptList [$key] ['Locate'] = $Locate;
  4984. $Locate ++;
  4985. $receiptList [$key] ['reviseDetail'] = array ();
  4986. if (! empty ( $value ['reviseDetail'] ))
  4987. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4988. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4989. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4990. $categoryDetil = $Lcategory->getOne ( array (
  4991. 'where' => 'cid=' . $value ['cid'],
  4992. 'asArray' => true
  4993. ) );
  4994. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4995. $executeList = json_decode ( $value ['executeCopy'], true );
  4996. $executeStaff = array ();
  4997. if (! empty ( $value ['executeStaff'] ))
  4998. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4999. if (isset ( $executeList )) {
  5000. foreach ( $executeList as $op => $lo ) {
  5001. $executeList [$op] ['date'] = "";
  5002. $executeList [$op] ['opinion'] = "";
  5003. $executeList [$op] ['status'] = "";
  5004. foreach ( $executeStaff as $m => $u ) {
  5005. if ($lo [0] == $m) {
  5006. $executeList [$op] ['date'] = $u ['date'];
  5007. $executeList [$op] ['opinion'] = $u ['opinion'];
  5008. $executeList [$op] ['status'] = $u ['status'];
  5009. break;
  5010. }
  5011. }
  5012. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  5013. $button2 = 1;
  5014. $executeList [$op] ['status'] = 4;
  5015. }
  5016. }
  5017. }
  5018. // 检测编辑状态
  5019. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  5020. $verifyList ['staff'] = $value ['verifyBreakup'];
  5021. } else
  5022. $verifyList = $verify->getOne ( array (
  5023. 'where' => 'vid=' . $value ['verify'],
  5024. 'asArray' => true
  5025. ) );
  5026. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5027. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5028. Doo::loadModel ( 'role' );
  5029. $role = new role ();
  5030. if ($verifyList == NULL)
  5031. $verifyList = array ();
  5032. $flag = true;
  5033. $roleKey = 0;
  5034. $endStaffArray = array ();
  5035. $roleArrayCopy = array ();
  5036. foreach ( $verifyList as $k => $v ) {
  5037. // init verifyStaff
  5038. if ($v [1] == 'ROLE') {
  5039. if (! empty ( $verifyStaff )) {
  5040. $endStaffArray = end ( $verifyStaff );
  5041. // if ($v[0]==$endStaffArray['nextStaff']){
  5042. // $roleId=$v[0];
  5043. // }
  5044. }
  5045. $roleVerify = json_decode ( $v [3], true );
  5046. $roleKey = $k;
  5047. $roleArray = array ();
  5048. $rolename = $role->getOne ( array (
  5049. 'where' => 'rid=' . $v [0],
  5050. 'asArray' => true
  5051. ) );
  5052. foreach ( $roleVerify as $o => $p ) {
  5053. $staffID = explode ( '_', $p );
  5054. $staffInfo = $staff->getOne ( array (
  5055. 'where' => 'sid=' . $staffID [0],
  5056. 'asArray' => true
  5057. ) );
  5058. // print_r($staffID);
  5059. $exp = array (
  5060. 0 => $staffInfo ['sid'],
  5061. 1 => $staffID [1],
  5062. 2 => $staffInfo ['avatar'],
  5063. 'date' => '',
  5064. 'date' => '',
  5065. 'opinion' => '',
  5066. 'status' => '',
  5067. 'rolename' => $rolename ['name']
  5068. );
  5069. array_push ( $roleArray, $exp );
  5070. }
  5071. $roleArrayCopy [$v [0]] = $roleArray;
  5072. // $verifyList[$k]['roleArray']=$roleArray;
  5073. }
  5074. $verifyList [$k] ['date'] = "";
  5075. $verifyList [$k] ['opinion'] = "";
  5076. $verifyList [$k] ['status'] = "";
  5077. if (empty ( $verifyStaff )) {
  5078. $verifyList [$k] ['date'] = "";
  5079. $verifyList [$k] ['opinion'] = "";
  5080. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5081. $verifyList [$k] ['status'] = 4;
  5082. $flag = false;
  5083. }
  5084. } else {
  5085. foreach ( $verifyStaff as $m => $u ) {
  5086. if ($v [0] == $m) {
  5087. $verifyList [$k] ['date'] = $u ['date'];
  5088. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5089. $verifyList [$k] ['status'] = $u ['status'];
  5090. $flag = false;
  5091. break;
  5092. }
  5093. }
  5094. $endStaffArray = end ( $verifyStaff );
  5095. if (isset ( $endStaffArray ['ROLE'] )) {
  5096. } else {
  5097. // $endKey=key($verifyStaff);
  5098. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5099. // $button=4;
  5100. // $verifyList[$k]['status']=4;
  5101. // }
  5102. }
  5103. }
  5104. }
  5105. $rolename ['name'] = '';
  5106. if (! empty ( $roleId )) {
  5107. Doo::loadModel ( 'role' );
  5108. $role = new role ();
  5109. $rolename = $role->getOne ( array (
  5110. 'where' => 'rid=' . $roleId,
  5111. 'asArray' => true
  5112. ) );
  5113. }
  5114. if (! empty ( $verifyStaff ))
  5115. $endStaffArray = end ( $verifyStaff );
  5116. $KOP = false;
  5117. foreach ( $roleArrayCopy as $P => $A ) {
  5118. foreach ( $A as $MKI => $AVL ) {
  5119. if (! empty ( $verifyStaff )) {
  5120. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5121. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5122. $button = 4;
  5123. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5124. }
  5125. foreach ( $verifyStaff as $m => $u ) {
  5126. $AVLFK = $AVL [0] . '_R';
  5127. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5128. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5129. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5130. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5131. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5132. break;
  5133. }
  5134. }
  5135. } else {
  5136. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5137. $button = 4;
  5138. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5139. }
  5140. }
  5141. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5142. $KOP = true;
  5143. }
  5144. }
  5145. foreach ( $roleArrayCopy as $k => $v ) {
  5146. foreach ( $verifyList as $m => $n ) {
  5147. if ($n [0] == $k) {
  5148. array_splice ( $verifyList, $m, 1, $v );
  5149. }
  5150. }
  5151. }
  5152. $receiptList [$key] ['verifyList'] = $verifyList;
  5153. $receiptList [$key] ['executeList'] = $executeList;
  5154. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5155. 'where' => 'sid=' . $value ['staff'],
  5156. 'asArray' => true
  5157. ) );
  5158. $receiptList [$key] ['button2'] = $button2;
  5159. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5160. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5161. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5162. $receiptList [$key] ['relust'] = $relust;
  5163. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  5164. $receiptList [$key] ['amountABS'] = abs ( $value ['amount'] );
  5165. }
  5166. //执行人是否是最后一位
  5167. $executeCopy = json_decode ( $receiptList [0] ['executeCopy'], true );
  5168. $executeStaff = json_decode ( $receiptList [0] ['executeStaff'], true );
  5169. $executePrimary=count($executeCopy)-1;
  5170. $lastOne=true;
  5171. if($executePrimary!=count($executeStaff)){
  5172. $lastOne=false;
  5173. }
  5174. $data['lastOne']=$lastOne;
  5175. // 是否写入过流水
  5176. $accountType = 0;
  5177. if ($receiptList [0] ['Rtype'] == 0) {
  5178. $accountType = 3;
  5179. } elseif ($receiptList [0] ['Rtype'] == 1) {
  5180. if (!empty($receiptList [0]['accountItem']) )
  5181. $accountType = 2;
  5182. else
  5183. $accountType = 1;
  5184. } elseif ($receiptList [0] ['Rtype'] == 2) {
  5185. $accountType = 4;
  5186. } elseif ($receiptList [0] ['Rtype'] == 3) {
  5187. $accountType = 12;
  5188. }
  5189. Doo::loadModel ( 'wasteBook' );
  5190. $wasteBook = new wasteBook ();
  5191. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $receiptList [0] ['rid'] );
  5192. $data ['wbDetail'] = $wbDetail;
  5193. $wbDetailLoan=array();
  5194. if ($accountType==2){
  5195. $wbDetailLoan = $wasteBook->getWateBookByAD ( 1, $receiptList [0] ['rid'] );
  5196. }
  5197. $data ['wbDetailLoan'] = $wbDetailLoan;
  5198. $data['inputDate']=date ( "Y-m-d H:i:s" );
  5199. //print_r($wbDetail);
  5200. $data ['receiptList'] = $receiptList;
  5201. $data ['memu'] = "receipt";
  5202. $data ['staff'] = $this->staff;
  5203. $data ['receiptMemu'] = 'implement';
  5204. $data ['verifyId'] = $this->verifyId;
  5205. $data ['executeId'] = $this->executeId;
  5206. if ($Rtype=="loan"){
  5207. $this->render ( "/receipt/receiptImplementLoan", $data );
  5208. }elseif($Rtype=="receipt"){
  5209. $this->render ( "/receipt/receiptImplement", $data );
  5210. }elseif($Rtype=="public"){
  5211. $this->render ( "/receipt/receiptImplementPublic", $data );
  5212. }else{
  5213. //$this->render ( "/admin/implement", $data );
  5214. }
  5215. }
  5216. function implementDo() {
  5217. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  5218. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  5219. // $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  5220. // $accountBank = $this->get_args ( 'accountBank' ) ? $this->get_args ( 'accountBank' ) : "";
  5221. // $ab = '';
  5222. // if ($accountBank == 'CGBDeposit')
  5223. // $ab = '纵横广发';
  5224. // elseif ($accountBank == 'ICBCDeposit')
  5225. // $ab = '纵横工行';
  5226. // elseif ($accountBank == 'HUADeposit')
  5227. // $ab = '华润银行';
  5228. // elseif ($accountBank == 'PersonalDeposit')
  5229. // $ab = '个人广发';
  5230. // if (empty ( $ab ))
  5231. // die ( 'illegal request--22' );
  5232. if (! empty ( $rid )) {
  5233. Doo::loadModel ( 'receipt' );
  5234. $receipt = new receipt ();
  5235. Doo::loadClass ( 'XDeode' );
  5236. $XDeode = new XDeode ( 5 );
  5237. $rid=$XDeode->decode($rid);
  5238. if (!is_numeric($rid)){
  5239. die;
  5240. }
  5241. // $rinfo = $receipt->getOne ( array (
  5242. // 'where' => 'rid=' . $rid,
  5243. // 'asArray' => true
  5244. // ) );
  5245. $rinfo = $receipt->getReceiptByRid ( $rid );
  5246. // $accountType = '';
  5247. // if ($rinfo ['Rtype'] == 1) {
  5248. // if ($rinfo ['loanRid'] != 0)//判断有问题
  5249. // $accountType = 2;
  5250. // else
  5251. // $accountType = 1;
  5252. // } elseif ($rinfo ['Rtype'] == 2) {
  5253. // $accountType = 4;
  5254. // } elseif ($rinfo ['Rtype'] == 0)
  5255. // $accountType = 3;
  5256. // if (empty ( $accountType ))
  5257. // die ( 'illegal request' );
  5258. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  5259. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  5260. if (empty ( $executeStaff )) {
  5261. $executeStaff = array (
  5262. $this->staff [0] ['sid'] => array (
  5263. 'date' => date ( 'Y-m-d' ),
  5264. 'opinion' => $implementOpinions,
  5265. 'status' => 1
  5266. )
  5267. );
  5268. } else {
  5269. $executeStaff [$this->staff [0] ['sid']] = array (
  5270. 'date' => date ( 'Y-m-d' ),
  5271. 'opinion' => $implementOpinions,
  5272. 'status' => 1
  5273. );
  5274. }
  5275. if (count ( $executeStaff ) == count ( $executeCopy )) {
  5276. $receipt->executeStaff = json_encode ( $executeStaff );
  5277. $receipt->status = 8;
  5278. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  5279. $receipt->status = 9;
  5280. if ($rinfo ['status'] == 6) {
  5281. $receipt->loanDate = date ( "Y-m-d" );
  5282. }
  5283. $receipt->executeDate = date ( "Y-m-d" );
  5284. } else {
  5285. $receipt->executeStaff = json_encode ( $executeStaff );
  5286. }
  5287. //$receipt->amount = $amount;
  5288. $receipt->update ( array (
  5289. 'where' => 'rid=' . $rid
  5290. ) );
  5291. // 公司流水记录
  5292. // Doo::loadModel ( 'wasteBook' );
  5293. // $wasteBook = new wasteBook ();
  5294. // $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountType, $rid );
  5295. // // 银行
  5296. // if (empty ( $abDetail ) && ! empty ( $amount )) {
  5297. // $item = array (
  5298. // 'dataID' => $rid,
  5299. // 'expensesType' => 2,
  5300. // 'accountType' => $accountType,
  5301. // 'accountPriceShow' => $amount,
  5302. // 'accountPrice' => - $amount,
  5303. // 'accountBank' => $accountBank,
  5304. // 'category' => $rinfo ['category'] [0] ['title'],
  5305. // 'cid' => $rinfo ['category'] [0] ['cid'],
  5306. // 'name' => $rinfo ['staffDetail'] ['username'],
  5307. // 'sid' => $rinfo ['staffDetail'] ['sid'],
  5308. // 'inputDate' => date ( "Y-m-d H:i:s" )
  5309. // );
  5310. // $wasteBook->setAccountBookStatistics ( $item );
  5311. // }
  5312. }
  5313. //$ridKey = $XDeode->encode ( $rid );
  5314. return "/hisImplement";
  5315. // return "/implement/" . $ridKey . ".html";
  5316. }
  5317. function receiptburEdi() {
  5318. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5319. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5320. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5321. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5322. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5323. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5324. if (empty ( $status ))
  5325. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5326. $vidList = array ();
  5327. $button = 0;
  5328. Doo::loadModel ( 'verify' );
  5329. Doo::loadModel ( 'receipt' );
  5330. Doo::loadModel ( 'staff' );
  5331. $staff = new staff ();
  5332. $receipt = new receipt ();
  5333. $verify = new verify ();
  5334. Doo::loadModel ( 'L_category' );
  5335. $Lcategory = new L_category ();
  5336. Doo::loadModel ( 'enclosur' );
  5337. $enclosur = new enclosur ();
  5338. Doo::loadModel ( 'loanReceipt' );
  5339. $loanReceipt = new loanReceipt ();
  5340. // user verify ID
  5341. $verifyDetail = $verify->find ( array (
  5342. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5343. 'asArray' => true
  5344. ) );
  5345. foreach ( $verifyDetail as $key => $value ) {
  5346. array_push ( $vidList, $value ['vid'] );
  5347. }
  5348. $vid = implode ( ",", $vidList );
  5349. if (empty ( $verifyDetail ))
  5350. $vid = 0;
  5351. $categoryList = $Lcategory->find ( array (
  5352. 'asArray' => true
  5353. ) );
  5354. $staffList = $staff->find ( array (
  5355. 'where' => 'cid=' . $cid,
  5356. 'asArray' => true
  5357. ) );
  5358. $ap = "";
  5359. if ($status == 4) {
  5360. $ap = 4;
  5361. $status = 2;
  5362. }
  5363. // get Receipt By verifyID status 2
  5364. $receiptList = $receipt->find ( array (
  5365. 'where' => 'rid =' . $rid . ' and status=2',
  5366. 'desc' => 'rid',
  5367. 'asArray' => true
  5368. ) );
  5369. if (empty ( $receiptList )) {
  5370. die ( 'illegal request' );
  5371. }
  5372. $loanList = $loanReceipt->find ( array (
  5373. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  5374. 'desc' => 'rid',
  5375. 'asArray' => true
  5376. ) );
  5377. $data ['explanation'] = '';
  5378. if (! empty ( $loanList ))
  5379. $data ['explanation'] = $loanList [0] ['explanation'];
  5380. $Locate = 0;
  5381. $roleId = 0;
  5382. $button = 0;
  5383. foreach ( $loanList as $key => $value ) {
  5384. $loanList [$key] ['Locate'] = $Locate;
  5385. $Locate ++;
  5386. $loanList [$key] ['reviseDetail'] = array ();
  5387. if (! empty ( $value ['reviseDetail'] ))
  5388. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5389. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5390. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5391. $categoryDetil = $Lcategory->getOne ( array (
  5392. 'where' => 'cid=' . $value ['cid'],
  5393. 'asArray' => true
  5394. ) );
  5395. $loanList [$key] ['category'] = $categoryDetil ['title'];
  5396. // 检测编辑状态
  5397. $verifyList = $verify->getOne ( array (
  5398. 'where' => 'vid=' . $value ['verify'],
  5399. 'asArray' => true
  5400. ) );
  5401. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5402. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5403. Doo::loadModel ( 'role' );
  5404. $role = new role ();
  5405. $flag = true;
  5406. $roleKey = 0;
  5407. $endStaffArray = array ();
  5408. $roleArrayCopy = array ();
  5409. foreach ( $verifyList as $k => $v ) {
  5410. // init verifyStaff
  5411. if ($v [1] == 'ROLE') {
  5412. if (! empty ( $verifyStaff )) {
  5413. $endStaffArray = end ( $verifyStaff );
  5414. }
  5415. $roleVerify = json_decode ( $v [3], true );
  5416. $roleKey = $k;
  5417. $roleArray = array ();
  5418. $rolename = $role->getOne ( array (
  5419. 'where' => 'rid=' . $v [0],
  5420. 'asArray' => true
  5421. ) );
  5422. foreach ( $roleVerify as $o => $p ) {
  5423. $staffID = explode ( '_', $p );
  5424. $staffInfo = $staff->getOne ( array (
  5425. 'where' => 'sid=' . $staffID [0],
  5426. 'asArray' => true
  5427. ) );
  5428. // print_r($staffID);
  5429. $exp = array (
  5430. 0 => $staffInfo ['sid'],
  5431. 1 => $staffID [1],
  5432. 2 => $staffInfo ['avatar'],
  5433. 'date' => '',
  5434. 'date' => '',
  5435. 'opinion' => '',
  5436. 'status' => '',
  5437. 'rolename' => $rolename ['name']
  5438. );
  5439. array_push ( $roleArray, $exp );
  5440. }
  5441. $roleArrayCopy [$v [0]] = $roleArray;
  5442. // $verifyList[$k]['roleArray']=$roleArray;
  5443. }
  5444. $verifyList [$k] ['date'] = "";
  5445. $verifyList [$k] ['opinion'] = "";
  5446. $verifyList [$k] ['status'] = "";
  5447. if (empty ( $verifyStaff )) {
  5448. $verifyList [$k] ['date'] = "";
  5449. $verifyList [$k] ['opinion'] = "";
  5450. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5451. $verifyList [$k] ['status'] = 4;
  5452. $flag = false;
  5453. }
  5454. } else {
  5455. foreach ( $verifyStaff as $m => $u ) {
  5456. if ($v [0] == $m) {
  5457. $verifyList [$k] ['date'] = $u ['date'];
  5458. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5459. $verifyList [$k] ['status'] = $u ['status'];
  5460. $flag = false;
  5461. break;
  5462. }
  5463. }
  5464. $endStaffArray = end ( $verifyStaff );
  5465. if (isset ( $endStaffArray ['ROLE'] )) {
  5466. } else {
  5467. }
  5468. }
  5469. }
  5470. $rolename ['name'] = '';
  5471. if (! empty ( $roleId )) {
  5472. Doo::loadModel ( 'role' );
  5473. $role = new role ();
  5474. $rolename = $role->getOne ( array (
  5475. 'where' => 'rid=' . $roleId,
  5476. 'asArray' => true
  5477. ) );
  5478. }
  5479. if (! empty ( $verifyStaff ))
  5480. $endStaffArray = end ( $verifyStaff );
  5481. $KOP = false;
  5482. foreach ( $roleArrayCopy as $P => $A ) {
  5483. foreach ( $A as $MKI => $AVL ) {
  5484. if (! empty ( $verifyStaff )) {
  5485. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5486. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5487. $button = 4;
  5488. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5489. }
  5490. foreach ( $verifyStaff as $m => $u ) {
  5491. $AVLFK = $AVL [0] . '_R';
  5492. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5493. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5494. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5495. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5496. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5497. break;
  5498. }
  5499. }
  5500. } else {
  5501. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5502. $button = 4;
  5503. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5504. }
  5505. }
  5506. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5507. $KOP = true;
  5508. }
  5509. }
  5510. foreach ( $roleArrayCopy as $k => $v ) {
  5511. foreach ( $verifyList as $m => $n ) {
  5512. if ($n [0] == $k) {
  5513. array_splice ( $verifyList, $m, 1, $v );
  5514. }
  5515. }
  5516. }
  5517. $loanList [$key] ['verifyList'] = $verifyList;
  5518. }
  5519. $htmlLoan = '';
  5520. $data ['loanReceiptDate'] = '';
  5521. if (isset ( $loanList [0] )) {
  5522. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  5523. if ($value ['status'] == 1)
  5524. $htmlLoan .= '<li class="done" >';
  5525. elseif ($value ['status'] == 3)
  5526. $htmlLoan .= '<li class="undone" >';
  5527. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  5528. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  5529. if (isset ( $value ['rolename'] ))
  5530. $htmlLoan .= $value ['rolename'];
  5531. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  5532. }
  5533. $data ['loanDate'] = $loanList [0] ['date'];
  5534. } else {
  5535. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  5536. }
  5537. $data ['htmlLoan'] = $htmlLoan;
  5538. // $data ['LoanReceipt']=$loanList[0];
  5539. // print_r($loanList);
  5540. $Locate = 0;
  5541. $roleId = 0;
  5542. $button = 0;
  5543. if ($ap == 4)
  5544. $status = 4;
  5545. Doo::loadClass ( 'XDeode' );
  5546. $XDeode = new XDeode ( 5 );
  5547. foreach ( $receiptList as $key => $value ) {
  5548. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  5549. $receiptList [$key] ['Locate'] = $Locate;
  5550. $Locate ++;
  5551. $receiptList [$key] ['reviseDetail'] = array ();
  5552. // 调整金额 代码调整
  5553. if (! empty ( $value ['reviseDetail'] )) {
  5554. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  5555. foreach ( $reviseDetail as $ry => $re ) {
  5556. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  5557. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  5558. }
  5559. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  5560. // print_r($reviseDetail);
  5561. }
  5562. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5563. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5564. $categoryDetil = $Lcategory->getOne ( array (
  5565. 'where' => 'cid=' . $value ['cid'],
  5566. 'asArray' => true
  5567. ) );
  5568. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5569. // 检测编辑状态
  5570. $verifyList = $verify->getOne ( array (
  5571. 'where' => 'vid=' . $value ['verify'],
  5572. 'asArray' => true
  5573. ) );
  5574. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5575. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5576. Doo::loadModel ( 'role' );
  5577. $role = new role ();
  5578. // print_r($verifyList);
  5579. $flag = true;
  5580. $roleKey = 0;
  5581. $endStaffArray = array ();
  5582. $roleArrayCopy = array ();
  5583. foreach ( $verifyList as $k => $v ) {
  5584. // init verifyStaff
  5585. if ($v [1] == 'ROLE') {
  5586. if (! empty ( $verifyStaff )) {
  5587. $endStaffArray = end ( $verifyStaff );
  5588. if ($v [0] == $endStaffArray ['nextStaff']) {
  5589. $roleId = $v [0];
  5590. }
  5591. }
  5592. $roleVerify = json_decode ( $v [3], true );
  5593. $roleKey = $k;
  5594. $roleArray = array ();
  5595. $rolename = $role->getOne ( array (
  5596. 'where' => 'rid=' . $v [0],
  5597. 'asArray' => true
  5598. ) );
  5599. foreach ( $roleVerify as $o => $p ) {
  5600. $staffID = explode ( '_', $p );
  5601. $staffInfo = $staff->getOne ( array (
  5602. 'where' => 'sid=' . $staffID [0],
  5603. 'asArray' => true
  5604. ) );
  5605. // print_r($staffID);
  5606. $exp = array (
  5607. 0 => $staffInfo ['sid'],
  5608. 1 => $staffID [1],
  5609. 2 => $staffInfo ['avatar'],
  5610. 'date' => '',
  5611. 'date' => '',
  5612. 'opinion' => '',
  5613. 'status' => '',
  5614. 'rolename' => $rolename ['name']
  5615. );
  5616. array_push ( $roleArray, $exp );
  5617. }
  5618. $roleArrayCopy [$v [0]] = $roleArray;
  5619. // $verifyList[$k]['roleArray']=$roleArray;
  5620. }
  5621. // print_r($roleArray);
  5622. $verifyList [$k] ['date'] = "";
  5623. $verifyList [$k] ['opinion'] = "";
  5624. $verifyList [$k] ['status'] = "";
  5625. if (empty ( $verifyStaff )) {
  5626. $verifyList [$k] ['date'] = "";
  5627. $verifyList [$k] ['opinion'] = "";
  5628. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5629. $verifyList [$k] ['status'] = 4;
  5630. $button = 4;
  5631. $flag = false;
  5632. }
  5633. } else {
  5634. foreach ( $verifyStaff as $m => $u ) {
  5635. if ($v [0] == $m) {
  5636. $verifyList [$k] ['date'] = $u ['date'];
  5637. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5638. $verifyList [$k] ['status'] = $u ['status'];
  5639. $flag = false;
  5640. break;
  5641. }
  5642. }
  5643. $endStaffArray = end ( $verifyStaff );
  5644. if (isset ( $endStaffArray ['ROLE'] )) {
  5645. } else {
  5646. $endKey = key ( $verifyStaff );
  5647. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5648. $button = 4;
  5649. $verifyList [$k] ['status'] = 4;
  5650. }
  5651. }
  5652. }
  5653. }
  5654. $rolename ['name'] = '';
  5655. if (! empty ( $roleId )) {
  5656. Doo::loadModel ( 'role' );
  5657. $role = new role ();
  5658. $rolename = $role->getOne ( array (
  5659. 'where' => 'rid=' . $roleId,
  5660. 'asArray' => true
  5661. ) );
  5662. }
  5663. if (! empty ( $verifyStaff ))
  5664. $endStaffArray = end ( $verifyStaff );
  5665. $KOP = false;
  5666. foreach ( $roleArrayCopy as $P => $A ) {
  5667. foreach ( $A as $MKI => $AVL ) {
  5668. if (! empty ( $verifyStaff )) {
  5669. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5670. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5671. $button = 4;
  5672. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5673. }
  5674. foreach ( $verifyStaff as $m => $u ) {
  5675. $AVLFK = $AVL [0] . '_R';
  5676. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5677. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5678. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5679. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5680. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5681. break;
  5682. }
  5683. }
  5684. } else {
  5685. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5686. $button = 4;
  5687. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5688. }
  5689. }
  5690. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5691. $KOP = true;
  5692. }
  5693. }
  5694. foreach ( $roleArrayCopy as $k => $v ) {
  5695. foreach ( $verifyList as $m => $n ) {
  5696. if ($n [0] == $k) {
  5697. array_splice ( $verifyList, $m, 1, $v );
  5698. }
  5699. }
  5700. }
  5701. // print_r($verifyList);
  5702. $receiptList [$key] ['verifyList'] = $verifyList;
  5703. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5704. 'where' => 'sid=' . $value ['staff'],
  5705. 'asArray' => true
  5706. ) );
  5707. $receiptList [$key] ['button'] = $button;
  5708. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5709. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5710. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5711. $receiptList [$key] ['relust'] = $relust;
  5712. $receiptList [$key] ['relustABS'] = abs ( $relust );
  5713. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  5714. }
  5715. //print_r($receiptList);die;
  5716. // $data['verifyDetail']=$verifyDetail;
  5717. $mothHtml = "";
  5718. for($i = 1; $i <= 12; $i ++) {
  5719. if ($month == $i)
  5720. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5721. else
  5722. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5723. }
  5724. // 获取审批日志
  5725. Doo::loadModel ( 'receiptLog' );
  5726. $receiptLog = new receiptLog ();
  5727. $rlList = array ();
  5728. $rlInfo = $receiptLog->getOne ( array (
  5729. 'where' => 'rid=' . $rid . ' and status=4',
  5730. 'asArray' => true
  5731. ) );
  5732. $tijdate = $receiptLog->getOne ( array (
  5733. 'where' => 'rid=' . $rid . ' and status=2',
  5734. 'asc' => 'rlid',
  5735. 'asArray' => true
  5736. ) );
  5737. if (! empty ( $rlInfo )) {
  5738. $rlList = $receiptLog->find ( array (
  5739. 'where' => 'rid=' . $rid,
  5740. 'asc' => 'rlid',
  5741. 'asArray' => true
  5742. ) );
  5743. }
  5744. // echo $rid;
  5745. // print_r($receiptList);
  5746. $receiptList [0] ['rlList'] = $rlList;
  5747. // print_r($receiptList);
  5748. $enclosurList = $enclosur->find ( array (
  5749. 'where' => 'rid=' . $rid,
  5750. 'asArray' => true
  5751. ) );
  5752. $enclosurHtml = '';
  5753. foreach ( $enclosurList as $value ) {
  5754. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5755. }
  5756. $data ['enclosurHtml'] = $enclosurHtml;
  5757. $data ['rolename'] = $rolename ['name'];
  5758. $data ['mothHtml'] = $mothHtml;
  5759. // print_r($receiptList);
  5760. $data ['rid'] = $rid;
  5761. $data ['tijdate'] = $tijdate ['date'];
  5762. $data ['receiptList'] = $receiptList;
  5763. $data ['receiptApprovalCount'] = count ( $receiptList );
  5764. $data ['status'] = $status;
  5765. $data ['year'] = $year;
  5766. $data ['categoryList'] = $categoryList;
  5767. $data ['staffList'] = $staffList;
  5768. $data ['cid'] = $cid;
  5769. $data ['sid'] = $sid;
  5770. $data ['ap'] = $ap;
  5771. $data ['memu'] = "receipt";
  5772. $data ['staff'] = $this->staff;
  5773. $data ['receiptMemu'] = 'approvalExpenses';
  5774. $data ['verifyId'] = $this->verifyId;
  5775. $data ['executeId'] = $this->executeId;
  5776. $this->render ( "/admin/receiptburEdi", $data );
  5777. }
  5778. function hisImplement() {
  5779. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  5780. if (empty ( $item ))
  5781. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  5782. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  5783. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  5784. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  5785. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  5786. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  5787. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  5788. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  5789. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  5790. Doo::loadClass ( 'XDeode' );
  5791. $XDeode = new XDeode ( 5 );
  5792. Doo::loadModel ( 'receipt' );
  5793. $receipt = new receipt ();
  5794. Doo::loadModel ( 'L_category' );
  5795. $Lcategory = new L_category ();
  5796. Doo::loadModel ( 'verify' );
  5797. Doo::loadModel ( 'statistics' );
  5798. $statistics = new statistics ();
  5799. $verify = new verify ();
  5800. Doo::loadModel ( 'staff' );
  5801. $staff = new staff ();
  5802. Doo::loadClass ( 'XDeode' );
  5803. $XDeode = new XDeode ( 5 );
  5804. $XDeode7 = new XDeode ( 7 );
  5805. $cid = $XDeode->decode ( $cidKey );
  5806. $condition = "";
  5807. if ($item == "expenses")
  5808. $condition = " and Rtype=1 ";
  5809. elseif ($item == "receipts")
  5810. $condition = " and Rtype=0 ";
  5811. elseif ($item == "remits")
  5812. $condition = " and Rtype=2 ";
  5813. elseif($item == "train")
  5814. $condition = " and Rtype=3 ";
  5815. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  5816. $sopString = $cidString = "";
  5817. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  5818. if (empty ( $rdate ))
  5819. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  5820. else
  5821. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  5822. if ($status == 'pendImplement') {
  5823. $condition .= ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  5824. } elseif ($status == 'alerpts') {
  5825. $statusCon = '(status=8 or status=9 )';
  5826. if (empty ( $rdate ))
  5827. $dateCondition .= " and Year(date) =" . $year;
  5828. else
  5829. $dateCondition .= " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  5830. }
  5831. if ($sop != 'SOP')
  5832. $sopString = " and staff=" . $sop;
  5833. if ($cidKey != 'ALL')
  5834. $cidString = " and cid=" . $cid;
  5835. //汇款信息需要提取出来
  5836. if(!empty($receiptOrder)){
  5837. $receiptList = $receipt->find ( array (
  5838. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  5839. 'desc' => 'rid',
  5840. 'asArray' => true
  5841. ) );
  5842. // 员工筛选
  5843. $receiptList2 = $receipt->find ( array (
  5844. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  5845. 'desc' => 'rid',
  5846. 'asArray' => true
  5847. ) );
  5848. }else{
  5849. $receiptList = $receipt->find ( array (
  5850. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  5851. 'desc' => 'rid',
  5852. 'asArray' => true
  5853. ) );
  5854. // 员工筛选
  5855. $receiptList2 = $receipt->find ( array (
  5856. 'where' => $statusCon . $condition . $dateCondition,
  5857. 'desc' => 'rid',
  5858. 'asArray' => true
  5859. ) );
  5860. }
  5861. $sopStaff = array ();
  5862. foreach ( $receiptList2 as $key => $value ) {
  5863. $staffDetail = $staff->getOne ( array (
  5864. 'select' => 'username',
  5865. 'where' => 'sid=' . $value ['staff'],
  5866. 'asArray' => true
  5867. ) );
  5868. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  5869. }
  5870. // 办事处筛选
  5871. $categoryScreen = array ();
  5872. $categorList = $Lcategory->getCategory ();
  5873. foreach ( $receiptList2 as $key => $value ) {
  5874. foreach ( $categorList as $k => $v ) {
  5875. if ($value ['cid'] == $v ['cid']) {
  5876. $categoryScreen [$v ['cidKey']] = $v ['title'];
  5877. break;
  5878. }
  5879. }
  5880. }
  5881. $categoryScreenHtml = "";
  5882. foreach ( $categoryScreen as $key => $value ) {
  5883. if ($cidKey == $key)
  5884. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  5885. else
  5886. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  5887. }
  5888. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  5889. $data ['cidKey'] = $cidKey;
  5890. $Locate = 0;
  5891. $roleId = 0;
  5892. $button = 0;
  5893. $staffBatchNumber = 100001;
  5894. $remittanceList = array ();
  5895. foreach ( $receiptList as $key => $value ) {
  5896. $receiptList [$key] ['ridKey7'] = $XDeode7->encode ( $value ['rid'] );
  5897. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  5898. $receiptList [$key] ['Texe'] = 'false';
  5899. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  5900. $receiptList [$key] ['Texe'] = 'true';
  5901. }
  5902. $receiptList [$key] ['TRexe'] = 'true';
  5903. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  5904. $receiptList [$key] ['TRexe'] = 'false';
  5905. }
  5906. $receiptList [$key] ['Locate'] = $Locate;
  5907. $Locate ++;
  5908. $receiptList [$key] ['reviseDetail'] = array ();
  5909. if (! empty ( $value ['reviseDetail'] ))
  5910. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5911. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5912. $categoryDetil = $Lcategory->getOne ( array (
  5913. 'where' => 'cid=' . $value ['cid'],
  5914. 'asArray' => true
  5915. ) );
  5916. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5917. // 检测编辑状态
  5918. $verifyList = $verify->getOne ( array (
  5919. 'where' => 'vid=' . $value ['verify'],
  5920. 'asArray' => true
  5921. ) );
  5922. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5923. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5924. Doo::loadModel ( 'role' );
  5925. $role = new role ();
  5926. $flag = true;
  5927. $roleKey = 0;
  5928. $endStaffArray = array ();
  5929. $roleArrayCopy = array ();
  5930. foreach ( $verifyList as $k => $v ) {
  5931. // init verifyStaff
  5932. if ($v [1] == 'ROLE') {
  5933. if (! empty ( $verifyStaff )) {
  5934. $endStaffArray = end ( $verifyStaff );
  5935. }
  5936. $roleVerify = json_decode ( $v [3], true );
  5937. $roleKey = $k;
  5938. $roleArray = array ();
  5939. $rolename = $role->getOne ( array (
  5940. 'where' => 'rid=' . $v [0],
  5941. 'asArray' => true
  5942. ) );
  5943. foreach ( $roleVerify as $o => $p ) {
  5944. $staffID = explode ( '_', $p );
  5945. $staffInfo = $staff->getOne ( array (
  5946. 'where' => 'sid=' . $staffID [0],
  5947. 'asArray' => true
  5948. ) );
  5949. $exp = array (
  5950. 0 => $staffInfo ['sid'],
  5951. 1 => $staffID [1],
  5952. 2 => $staffInfo ['avatar'],
  5953. 'date' => '',
  5954. 'date' => '',
  5955. 'opinion' => '',
  5956. 'status' => '',
  5957. 'rolename' => $rolename ['name']
  5958. );
  5959. array_push ( $roleArray, $exp );
  5960. }
  5961. $roleArrayCopy [$v [0]] = $roleArray;
  5962. }
  5963. $verifyList [$k] ['date'] = "";
  5964. $verifyList [$k] ['opinion'] = "";
  5965. $verifyList [$k] ['status'] = "";
  5966. if (empty ( $verifyStaff )) {
  5967. $verifyList [$k] ['date'] = "";
  5968. $verifyList [$k] ['opinion'] = "";
  5969. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5970. $verifyList [$k] ['status'] = 4;
  5971. $flag = false;
  5972. }
  5973. } else {
  5974. foreach ( $verifyStaff as $m => $u ) {
  5975. if ($v [0] == $m) {
  5976. $verifyList [$k] ['date'] = $u ['date'];
  5977. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5978. $verifyList [$k] ['status'] = $u ['status'];
  5979. $flag = false;
  5980. break;
  5981. }
  5982. }
  5983. $endStaffArray = end ( $verifyStaff );
  5984. }
  5985. }
  5986. $rolename ['name'] = '';
  5987. if (! empty ( $roleId )) {
  5988. Doo::loadModel ( 'role' );
  5989. $role = new role ();
  5990. $rolename = $role->getOne ( array (
  5991. 'where' => 'rid=' . $roleId,
  5992. 'asArray' => true
  5993. ) );
  5994. }
  5995. if (! empty ( $verifyStaff ))
  5996. $endStaffArray = end ( $verifyStaff );
  5997. $KOP = false;
  5998. foreach ( $roleArrayCopy as $P => $A ) {
  5999. foreach ( $A as $MKI => $AVL ) {
  6000. if (! empty ( $verifyStaff )) {
  6001. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6002. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6003. $button = 4;
  6004. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6005. }
  6006. foreach ( $verifyStaff as $m => $u ) {
  6007. $AVLFK = $AVL [0] . '_R';
  6008. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6009. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6010. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6011. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6012. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6013. break;
  6014. }
  6015. }
  6016. } else {
  6017. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6018. $button = 4;
  6019. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6020. }
  6021. }
  6022. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6023. $KOP = true;
  6024. }
  6025. }
  6026. foreach ( $roleArrayCopy as $k => $v ) {
  6027. foreach ( $verifyList as $m => $n ) {
  6028. if ($n [0] == $k) {
  6029. array_splice ( $verifyList, $m, 1, $v );
  6030. }
  6031. }
  6032. }
  6033. $receiptList [$key] ['verifyList'] = $verifyList;
  6034. $staffDetail = $staff->getOne ( array (
  6035. 'where' => 'sid=' . $value ['staff'],
  6036. 'asArray' => true
  6037. ) );
  6038. $receiptList [$key] ['staffDetail'] = $staffDetail;
  6039. $receiptList [$key] ['button'] = $button;
  6040. if ($value['Rtype']==1){
  6041. $receiptList [$key] ['relust'] = $value['sum']-$value['loanSum'];
  6042. $receiptList [$key] ['relustABS'] = abs($receiptList [$key] ['relust']);
  6043. }elseif($value['Rtype']==3){
  6044. // 收入合计
  6045. Doo::loadModel ( 'invoiceTraining' );
  6046. $invoiceTraining = new invoiceTraining ();
  6047. $invoiceTrainingDetail = array (
  6048. 'invoiceArriveAmount' => '0.00',
  6049. 'RIAmount' => '0.00',
  6050. 'invoiceTotalAmount' => '0.00',
  6051. 'invoiceCompanyAmount' => '0.00',
  6052. 'invoiceArriveAmountM'=>'0.00',
  6053. 'invoiceCompanyAmountM'=>'0.00'
  6054. );
  6055. if ($value ['invoiceTrainId'] != 0) {
  6056. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $value['invoiceTrainId'] );
  6057. }
  6058. $invoiceArriveAmount = $RIAmount = 0;
  6059. if (! empty ( $invoiceTrainingDetail )) {
  6060. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  6061. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  6062. }
  6063. // 备用金
  6064. $sum = 0;
  6065. if (! empty ( $value ['trainLoanRid'] )) {
  6066. $receiptLoanDetailBak = $receipt->getReceiptByRid ( $value ['trainLoanRid'] );
  6067. $sum = $receiptLoanDetailBak ['sum'];
  6068. }
  6069. // 支出项金额详情
  6070. // 项目金额合计
  6071. Doo::loadModel ( 'RItem' );
  6072. $RItem = new RItem ();
  6073. Doo::loadModel ( 'accountItem' );
  6074. $accountItem = new accountItem ();
  6075. // 讲师获得
  6076. Doo::loadModel ( 'RILecturer' );
  6077. $RILecturer = new RILecturer ();
  6078. $RItemList = $RItem->getRItemByRid ( $value['rid'] );
  6079. $RILecturerList = $RILecturer->getRILecturerByRid ( $value['rid'] );
  6080. // 支出项金额详情
  6081. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  6082. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  6083. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  6084. $receiptList [$key] ['payment'] =$payment;
  6085. $receiptList [$key] ['paymentABS'] =abs($payment);
  6086. }
  6087. // 设置导出汇款execl
  6088. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  6089. $remittanceDetail = array (
  6090. $staffBatchNumber,
  6091. $value ['remittanceName'],
  6092. $value ['bankNumber'],
  6093. $value ['bankName'],
  6094. $value ['remittanceBankType'],
  6095. $value ['coupletNumber'],
  6096. $value ['sum']
  6097. );
  6098. array_push ( $remittanceList, $remittanceDetail );
  6099. $staffBatchNumber ++;
  6100. }
  6101. }
  6102. $data ['remittanceList'] = json_encode ( $remittanceList );
  6103. // print_r($receiptList);
  6104. $mothHtml = "";
  6105. for($i = 1; $i <= 12; $i ++) {
  6106. if ($moth == $i)
  6107. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6108. else
  6109. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6110. }
  6111. $dayHtml = "";
  6112. if ($day != "DAY" || $moth != "MONTH") {
  6113. for($i = 1; $i <= 31; $i ++) {
  6114. if ($day == $i)
  6115. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6116. else
  6117. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6118. }
  6119. }
  6120. $sopHtml = "";
  6121. foreach ( $sopStaff as $key => $value ) {
  6122. if ($sop == $key)
  6123. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  6124. else
  6125. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  6126. }
  6127. $data ['status'] = $status;
  6128. $data ['rdate'] = $rdate;
  6129. $data ['sopHtml'] = $sopHtml;
  6130. $data ['dayHtml'] = $dayHtml;
  6131. $data ['mothHtml'] = $mothHtml;
  6132. $data ['receiptList'] = $receiptList;
  6133. $data ['memu'] = "receipt";
  6134. $data ['staff'] = $this->staff;
  6135. $data ['receiptMemu'] = 'implement';
  6136. $data ['verifyId'] = $this->verifyId;
  6137. $data ['executeId'] = $this->executeId;
  6138. $data ['item'] = $item;
  6139. $data ['year'] = $year;
  6140. $data ['moth'] = $moth;
  6141. $data['receiptOrder']=$receiptOrder;
  6142. $data ['day'] = $day;
  6143. $data ['sop'] = $sop;
  6144. $this->render ( "/admin/hisImplement", $data );
  6145. }
  6146. /**
  6147. * 导出汇款信息的exelc
  6148. */
  6149. function exportRemittance() {
  6150. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  6151. if (empty ( $remittanceInfo ))
  6152. die ( 'illegal request' );
  6153. $title = array (
  6154. '员工编号',
  6155. '姓名',
  6156. '员工账号',
  6157. '员工账户开户行',
  6158. '转账类型',
  6159. '联行号',
  6160. '金额'
  6161. );
  6162. $data = json_decode ( $remittanceInfo, true );
  6163. if (empty ( $data ))
  6164. die ( 'illegal request' );
  6165. Doo::loadClass ( 'receipt.func' );
  6166. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  6167. header ( 'Content-Type:text/html;charset=utf-8' );
  6168. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  6169. }
  6170. function ajaxExamine() {
  6171. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6172. Doo::loadModel ( 'receipt' );
  6173. $receipt = new receipt ();
  6174. if (! empty ( $rid )) {
  6175. $rLRes = $receipt->find ( array (
  6176. '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,
  6177. 'asArray' => true
  6178. ) );
  6179. echo json_encode ( array (
  6180. 'status' => 1,
  6181. 'receipt' => $rLRes [0]
  6182. ) );
  6183. die ();
  6184. }
  6185. echo json_encode ( array (
  6186. 'status' => 0,
  6187. 'receipt' => array ()
  6188. ) );
  6189. die ();
  6190. }
  6191. /*
  6192. * 废弃
  6193. */
  6194. function myReceipt() {
  6195. // all approval past withdraw
  6196. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  6197. if (empty ( $item ))
  6198. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  6199. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6200. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  6201. Doo::loadModel ( 'receipt' );
  6202. $receipt = new receipt ();
  6203. // pre-loaded
  6204. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  6205. // have cache
  6206. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  6207. if (! empty ( $moth )) // yearPage
  6208. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  6209. $this->showCache ( $path );
  6210. }
  6211. Doo::loadModel ( 'L_category' );
  6212. $Lcategory = new L_category ();
  6213. Doo::loadModel ( 'verify' );
  6214. Doo::loadModel ( 'statistics' );
  6215. $statistics = new statistics ();
  6216. $verify = new verify ();
  6217. Doo::loadModel ( 'staff' );
  6218. $staff = new staff ();
  6219. $condition = " and status!=0 ";
  6220. if ($item == "approval")
  6221. $condition = " and status=2 ";
  6222. elseif ($item == "withdraw")
  6223. $condition = " and status=3 ";
  6224. elseif ($item == "past")
  6225. $condition = " and status=1 ";
  6226. elseif ($item == "whdw")
  6227. $condition = " and status=4 ";
  6228. $dateCondition = " and Year(date) =" . $year;
  6229. if (! empty ( $moth )) {
  6230. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  6231. $stList = $statistics->getOne ( array (
  6232. 'select' => 'rePrice ,agPrice',
  6233. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  6234. 'asArray' => true
  6235. ) );
  6236. } else
  6237. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  6238. if (empty ( $stList ))
  6239. $stList = array (
  6240. 'rePrice' => 0,
  6241. 'agPrice' => 0
  6242. );
  6243. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  6244. $data ['stList'] = array (
  6245. 'rePrice' => $stList ['rePrice'],
  6246. 'agPrice' => $stList ['agPrice'],
  6247. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  6248. );
  6249. $receiptList = $receipt->find ( array (
  6250. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  6251. 'desc' => 'rid',
  6252. 'asArray' => true
  6253. ) );
  6254. $Locate = 0;
  6255. $roleId = 0;
  6256. $button = 0;
  6257. foreach ( $receiptList as $key => $value ) {
  6258. $receiptList [$key] ['Locate'] = $Locate;
  6259. $Locate ++;
  6260. $receiptList [$key] ['reviseDetail'] = array ();
  6261. if (! empty ( $value ['reviseDetail'] ))
  6262. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6263. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6264. $categoryDetil = $Lcategory->getOne ( array (
  6265. 'where' => 'cid=' . $value ['cid'],
  6266. 'asArray' => true
  6267. ) );
  6268. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6269. // 检测编辑状态
  6270. $verifyList = $verify->getOne ( array (
  6271. 'where' => 'vid=' . $value ['verify'],
  6272. 'asArray' => true
  6273. ) );
  6274. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6275. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6276. Doo::loadModel ( 'role' );
  6277. $role = new role ();
  6278. $flag = true;
  6279. $roleKey = 0;
  6280. $endStaffArray = array ();
  6281. $roleArrayCopy = array ();
  6282. foreach ( $verifyList as $k => $v ) {
  6283. // init verifyStaff
  6284. if ($v [1] == 'ROLE') {
  6285. if (! empty ( $verifyStaff )) {
  6286. $endStaffArray = end ( $verifyStaff );
  6287. // if ($v[0]==$endStaffArray['nextStaff']){
  6288. // $roleId=$v[0];
  6289. // }
  6290. }
  6291. $roleVerify = json_decode ( $v [3], true );
  6292. $roleKey = $k;
  6293. $roleArray = array ();
  6294. $rolename = $role->getOne ( array (
  6295. 'where' => 'rid=' . $v [0],
  6296. 'asArray' => true
  6297. ) );
  6298. foreach ( $roleVerify as $o => $p ) {
  6299. $staffID = explode ( '_', $p );
  6300. $staffInfo = $staff->getOne ( array (
  6301. 'where' => 'sid=' . $staffID [0],
  6302. 'asArray' => true
  6303. ) );
  6304. // print_r($staffID);
  6305. $exp = array (
  6306. 0 => $staffInfo ['sid'],
  6307. 1 => $staffID [1],
  6308. 2 => $staffInfo ['avatar'],
  6309. 'date' => '',
  6310. 'date' => '',
  6311. 'opinion' => '',
  6312. 'status' => '',
  6313. 'rolename' => $rolename ['name']
  6314. );
  6315. array_push ( $roleArray, $exp );
  6316. }
  6317. $roleArrayCopy [$v [0]] = $roleArray;
  6318. // $verifyList[$k]['roleArray']=$roleArray;
  6319. }
  6320. $verifyList [$k] ['date'] = "";
  6321. $verifyList [$k] ['opinion'] = "";
  6322. $verifyList [$k] ['status'] = "";
  6323. if (empty ( $verifyStaff )) {
  6324. $verifyList [$k] ['date'] = "";
  6325. $verifyList [$k] ['opinion'] = "";
  6326. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6327. $verifyList [$k] ['status'] = 4;
  6328. $flag = false;
  6329. }
  6330. } else {
  6331. foreach ( $verifyStaff as $m => $u ) {
  6332. if ($v [0] == $m) {
  6333. $verifyList [$k] ['date'] = $u ['date'];
  6334. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6335. $verifyList [$k] ['status'] = $u ['status'];
  6336. $flag = false;
  6337. break;
  6338. }
  6339. }
  6340. $endStaffArray = end ( $verifyStaff );
  6341. if (isset ( $endStaffArray ['ROLE'] )) {
  6342. } else {
  6343. // $endKey=key($verifyStaff);
  6344. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  6345. // $button=4;
  6346. // $verifyList[$k]['status']=4;
  6347. // }
  6348. }
  6349. }
  6350. }
  6351. $rolename ['name'] = '';
  6352. if (! empty ( $roleId )) {
  6353. Doo::loadModel ( 'role' );
  6354. $role = new role ();
  6355. $rolename = $role->getOne ( array (
  6356. 'where' => 'rid=' . $roleId,
  6357. 'asArray' => true
  6358. ) );
  6359. }
  6360. if (! empty ( $verifyStaff ))
  6361. $endStaffArray = end ( $verifyStaff );
  6362. $KOP = false;
  6363. foreach ( $roleArrayCopy as $P => $A ) {
  6364. foreach ( $A as $MKI => $AVL ) {
  6365. if (! empty ( $verifyStaff )) {
  6366. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6367. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6368. $button = 4;
  6369. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6370. }
  6371. foreach ( $verifyStaff as $m => $u ) {
  6372. $AVLFK = $AVL [0] . '_R';
  6373. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6374. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6375. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6376. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6377. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6378. break;
  6379. }
  6380. }
  6381. } else {
  6382. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6383. $button = 4;
  6384. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6385. }
  6386. }
  6387. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6388. $KOP = true;
  6389. }
  6390. }
  6391. foreach ( $roleArrayCopy as $k => $v ) {
  6392. foreach ( $verifyList as $m => $n ) {
  6393. if ($n [0] == $k) {
  6394. array_splice ( $verifyList, $m, 1, $v );
  6395. }
  6396. }
  6397. }
  6398. $receiptList [$key] ['verifyList'] = $verifyList;
  6399. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6400. 'where' => 'sid=' . $value ['staff'],
  6401. 'asArray' => true
  6402. ) );
  6403. $receiptList [$key] ['button'] = $button;
  6404. }
  6405. // print_r($receiptList);die;
  6406. $mothHtml = "";
  6407. for($i = 1; $i <= 12; $i ++) {
  6408. if ($moth == $i)
  6409. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6410. else
  6411. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6412. }
  6413. $data ['mothHtml'] = $mothHtml;
  6414. $data ['receiptList'] = $receiptList;
  6415. $data ['memu'] = "receipt";
  6416. $data ['staff'] = $this->staff;
  6417. $data ['receiptMemu'] = 'receipt';
  6418. $data ['verifyId'] = $this->verifyId;
  6419. $data ['executeId'] = $this->executeId;
  6420. $data ['item'] = $item;
  6421. $data ['year'] = $year;
  6422. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  6423. // sufficient condition to generate cache
  6424. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  6425. $receiptList = $receipt->find ( array (
  6426. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  6427. 'asArray' => true
  6428. ) );
  6429. if (empty ( $receiptList )) { // generated files
  6430. ob_start ();
  6431. $this->render ( "/admin/saea_myList", $data );
  6432. $this->cacheFile ( $path );
  6433. die ();
  6434. // $content = ob_get_contents();
  6435. // $fp = fopen($path, "w");
  6436. // fwrite($fp, $content);
  6437. // fclose($fp);
  6438. }
  6439. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  6440. $receiptList = $receipt->find ( array (
  6441. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  6442. 'asArray' => true
  6443. ) );
  6444. if (empty ( $receiptList )) { // generated files
  6445. ob_start ();
  6446. $this->render ( "/admin/saea_myList", $data );
  6447. $this->cacheFile ( $path );
  6448. die ();
  6449. }
  6450. }
  6451. }
  6452. $this->render ( "/admin/saea_myList", $data );
  6453. }
  6454. function saeaCreate() {
  6455. Doo::loadModel ( 'accountItem' );
  6456. Doo::loadModel ( 'verify' );
  6457. Doo::loadModel ( 'receipt' );
  6458. Doo::loadModel ( 'L_category' );
  6459. $lCategory = new L_category ();
  6460. $receipt = new receipt ();
  6461. $verify = new verify ();
  6462. $accountItem = new accountItem ();
  6463. Doo::loadModel ( "role" );
  6464. $role = new role ();
  6465. $acItem = $accountItem->find ( array (
  6466. 'asArray' => true
  6467. ) );
  6468. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  6469. $data ['category'] = $lCategory->find ( array (
  6470. 'asArray' => true
  6471. ) );
  6472. $data ['veList'] = $veList;
  6473. $data ['acItem'] = $acItem;
  6474. $data ['memu'] = "receipt";
  6475. $data ['staff'] = $this->staff;
  6476. $data ['receiptMemu'] = 'saeaBorad';
  6477. $data ['verifyId'] = $this->verifyId;
  6478. $data ['executeId'] = $this->executeId;
  6479. $this->render ( "/admin/saea_create", $data );
  6480. }
  6481. function addReceipt() {
  6482. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  6483. $agency = $this->get_args ( 'agency' );
  6484. $travel = $this->get_args ( 'travel' );
  6485. $train = $this->get_args ( 'train' );
  6486. $other = $this->get_args ( 'other' );
  6487. $inttrain = $this->get_args ( 'inttrain' );
  6488. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  6489. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  6490. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  6491. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  6492. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  6493. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  6494. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  6495. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  6496. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  6497. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  6498. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  6499. header ( 'Content-Type:text/html;charset=utf-8' );
  6500. die ( '请填写联行号' );
  6501. }
  6502. Doo::loadModel ( 'receipt' );
  6503. Doo::loadModel ( 'receiptDetail' );
  6504. Doo::loadModel ( 'accountItem' );
  6505. $accountItem = new accountItem ();
  6506. $receipt = new receipt ();
  6507. Doo::loadModel ( 'enclosur' );
  6508. Doo::loadModel ( 'execute' );
  6509. $execute = new execute ();
  6510. $executeDetail = $execute->getOne ( array (
  6511. 'where' => 'mold="报销单执行人"',
  6512. 'asArray' => true
  6513. ) );
  6514. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  6515. // if(!empty($receiptDetail))
  6516. // return "/referReceipt/".$receiptDetail['rid'];
  6517. $aItem = $accountItem->find ( array (
  6518. 'asArray' => true
  6519. ) );
  6520. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  6521. $ag = $tr = $ta = $ot= $it = 0;
  6522. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  6523. foreach ( $aItem as $key => $value ) {
  6524. if ($value ['category'] == $this->AGENCY) {
  6525. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  6526. array_push ( $accountJson [$this->AGENCY], array (
  6527. 'aid' => $value ['aid'],
  6528. 'name' => $value ['name'],
  6529. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  6530. ) );
  6531. $sum += $agency [$ag];
  6532. $agencySum += $agency [$ag];
  6533. }
  6534. $ag ++;
  6535. }
  6536. if ($value ['category'] == $this->TRAVEL) {
  6537. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  6538. array_push ( $accountJson [$this->TRAVEL], array (
  6539. 'aid' => $value ['aid'],
  6540. 'name' => $value ['name'],
  6541. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  6542. ) );
  6543. $sum += $travel [$tr];
  6544. $travelSum += $travel [$tr];
  6545. }
  6546. $tr ++;
  6547. }
  6548. if ($value ['category'] == $this->TRAIN) {
  6549. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  6550. array_push ( $accountJson [$this->TRAIN], array (
  6551. 'aid' => $value ['aid'],
  6552. 'name' => $value ['name'],
  6553. 'price' => number_format ( $train [$ta], 2, '.', '' )
  6554. ) );
  6555. $sum += $train [$ta];
  6556. $trainSum += $train [$ta];
  6557. }
  6558. $ta ++;
  6559. }
  6560. if ($value ['category'] == $this->INTTRAIN) {
  6561. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  6562. array_push ( $accountJson [$this->INTTRAIN], array (
  6563. 'aid' => $value ['aid'],
  6564. 'name' => $value ['name'],
  6565. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  6566. ) );
  6567. $sum += $inttrain [$it];
  6568. $inttrainSum += $inttrain [$it];
  6569. }
  6570. $it ++;
  6571. }
  6572. if ($value ['category'] == $this->OTHER) {
  6573. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  6574. array_push ( $accountJson [$this->OTHER], array (
  6575. 'aid' => $value ['aid'],
  6576. 'name' => $value ['name'],
  6577. 'price' => number_format ( $other [$ot], 2, '.', '' )
  6578. ) );
  6579. $sum += $other [$ot];
  6580. $otherSum += $other [$ot];
  6581. }
  6582. $ot ++;
  6583. }
  6584. }
  6585. $accountJson ['cSum'] = array (
  6586. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  6587. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  6588. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  6589. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  6590. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  6591. );
  6592. // 报销单
  6593. $receipt->accountItem = json_encode ( $accountJson );
  6594. $receipt->staff = $this->staff [0] ['sid'];
  6595. $receipt->sum = number_format ( $sum, 2, '.', '' );
  6596. $receipt->date = date ( "Y-m-d" );
  6597. $receipt->cid = $cid;
  6598. $receipt->status = 5;
  6599. // 修改审批流程加入角色
  6600. $receipt->verify = $verify;
  6601. $receipt->executeCopy = $executeDetail ['staff'];
  6602. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  6603. $order = array (
  6604. "\r\n",
  6605. "\n",
  6606. "\r"
  6607. );
  6608. $replace = '<br/>';
  6609. $explanation = str_replace ( $order, $replace, $explanation );
  6610. $receipt->explanation = $explanation;
  6611. $receipt->remittanceName = $remittanceName;
  6612. $receipt->bankName = $bankName;
  6613. $receipt->bankNumber = $bankNumber;
  6614. $receipt->remittanceBankType = $remittanceBankType;
  6615. if ($remittanceBankType == 1)
  6616. $receipt->coupletNumber = $coupletNumber;
  6617. $rid = $receipt->insert ();
  6618. // 附件
  6619. if (! empty ( $enclosurName )) {
  6620. $enclosurArray = explode ( '-', $enclosurName );
  6621. foreach ( $enclosurArray as $value ) {
  6622. $enclosur = new enclosur ();
  6623. $enclosur->name = $value;
  6624. $enclosur->rid = $rid;
  6625. $enclosur->insert ();
  6626. }
  6627. // print_r($enclosurArray);die;
  6628. }
  6629. // 报销详情
  6630. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  6631. $receiptDetail = new receiptDetail ();
  6632. $receiptDetail->staff = $this->staff [0] ['sid'];
  6633. $receiptDetail->item = $value ['name'];
  6634. $receiptDetail->itemCategory = $this->AGENCY;
  6635. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6636. $receiptDetail->date = date ( "Y-m-d" );
  6637. $receiptDetail->cid = $cid;
  6638. $receiptDetail->rid = $rid;
  6639. $receiptDetail->status = 4;
  6640. $receiptDetail->insert ();
  6641. }
  6642. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  6643. $receiptDetail = new receiptDetail ();
  6644. $receiptDetail->staff = $this->staff [0] ['sid'];
  6645. $receiptDetail->item = $value ['name'];
  6646. $receiptDetail->itemCategory = $this->TRAVEL;
  6647. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6648. $receiptDetail->date = date ( "Y-m-d" );
  6649. $receiptDetail->cid = $cid;
  6650. $receiptDetail->rid = $rid;
  6651. $receiptDetail->status = 4;
  6652. $receiptDetail->insert ();
  6653. }
  6654. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  6655. $receiptDetail = new receiptDetail ();
  6656. $receiptDetail->staff = $this->staff [0] ['sid'];
  6657. $receiptDetail->item = $value ['name'];
  6658. $receiptDetail->itemCategory = $this->TRAIN;
  6659. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6660. $receiptDetail->date = date ( "Y-m-d" );
  6661. $receiptDetail->cid = $cid;
  6662. $receiptDetail->rid = $rid;
  6663. $receiptDetail->status = 4;
  6664. $receiptDetail->insert ();
  6665. }
  6666. //内训
  6667. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  6668. $receiptDetail = new receiptDetail ();
  6669. $receiptDetail->staff = $this->staff [0] ['sid'];
  6670. $receiptDetail->item = $value ['name'];
  6671. $receiptDetail->itemCategory = $this->INTTRAIN;
  6672. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6673. $receiptDetail->date = date ( "Y-m-d" );
  6674. $receiptDetail->cid = $cid;
  6675. $receiptDetail->rid = $rid;
  6676. $receiptDetail->status = 4;
  6677. $receiptDetail->insert ();
  6678. }
  6679. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  6680. $receiptDetail = new receiptDetail ();
  6681. $receiptDetail->staff = $this->staff [0] ['sid'];
  6682. $receiptDetail->item = $value ['name'];
  6683. $receiptDetail->itemCategory = $this->OTHER;
  6684. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6685. $receiptDetail->date = date ( "Y-m-d" );
  6686. $receiptDetail->cid = $cid;
  6687. $receiptDetail->rid = $rid;
  6688. $receiptDetail->status = 4;
  6689. $receiptDetail->insert ();
  6690. }
  6691. return "/saeaBorad";
  6692. } else
  6693. die ( 'illegal request' );
  6694. }
  6695. function referReceipt() {
  6696. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  6697. Doo::loadModel ( 'receipt' );
  6698. Doo::loadModel ( 'verify' );
  6699. $verify = new verify ();
  6700. $receipt = new receipt ();
  6701. Doo::loadModel ( 'L_category' );
  6702. $lCategory = new L_category ();
  6703. Doo::loadModel ( "role" );
  6704. $role = new role ();
  6705. $receiptDetail = $receipt->find ( array (
  6706. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  6707. 'asArray' => true
  6708. ) );
  6709. if (empty ( $receiptDetail ))
  6710. return "/addReceipt";
  6711. foreach ( $receiptDetail as $key => $value ) {
  6712. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6713. $veList = $verify->getOne ( array (
  6714. 'where' => 'vid=' . $value ['verify'],
  6715. 'asArray' => true
  6716. ) );
  6717. $v = json_decode ( $veList ['staff'] );
  6718. array_push ( $v [0], $veList ['description'] );
  6719. foreach ( $v as $n => $m ) {
  6720. if ($m ['1'] == 'ROLE') {
  6721. $roleInfo = $role->getOne ( array (
  6722. 'where' => 'rid=' . $m [0],
  6723. 'asArray' => true
  6724. ) );
  6725. $v [$n] [1] = $roleInfo ['name'];
  6726. }
  6727. }
  6728. $receiptDetail [$key] ['staff'] = $v;
  6729. $category = $lCategory->getOne ( array (
  6730. 'where' => 'cid=' . $value ['cid'],
  6731. 'asArray' => true
  6732. ) );
  6733. $receiptDetail [$key] ['category'] = $category ['title'];
  6734. }
  6735. // print_r($receiptDetail);
  6736. $data ['receiptDetail'] = $receiptDetail;
  6737. $data ['memu'] = "receipt";
  6738. $data ['staff'] = $this->staff;
  6739. $data ['receiptMemu'] = 'saeaCreate';
  6740. $data ['verifyId'] = $this->verifyId;
  6741. $data ['executeId'] = $this->executeId;
  6742. $this->render ( "/admin/saea_confirm", $data );
  6743. }
  6744. function editReceipt() {
  6745. // edit status 4
  6746. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  6747. Doo::loadClass ( 'XDeode' );
  6748. $XDeode = new XDeode ( 7 );
  6749. $rid = $XDeode->decode ( $ridKey );
  6750. if (empty ( $rid ))
  6751. die ( 'illegal request' );
  6752. // echo $rid.'sd';
  6753. Doo::loadModel ( 'accountItem' );
  6754. Doo::loadModel ( 'verify' );
  6755. Doo::loadModel ( 'receipt' );
  6756. $receipt = new receipt ();
  6757. $verify = new verify ();
  6758. $accountItem = new accountItem ();
  6759. Doo::loadModel ( 'L_category' );
  6760. $lCategory = new L_category ();
  6761. Doo::loadModel ( "role" );
  6762. $role = new role ();
  6763. Doo::loadModel ( 'enclosur' );
  6764. $enclosur = new enclosur ();
  6765. $receiptDetail = $receipt->getOne ( array (
  6766. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  6767. 'asArray' => true
  6768. ) );
  6769. if (empty ( $receiptDetail ))
  6770. die ( 'illegal request' );
  6771. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  6772. $acItem = $accountItem->find ( array (
  6773. 'asArray' => true
  6774. ) );
  6775. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  6776. // 配置编辑信息
  6777. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  6778. foreach ( $acItem as $key => $value ) {
  6779. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  6780. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  6781. $acItem [$key] ['price'] = $v ['price'];
  6782. }
  6783. }
  6784. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  6785. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  6786. $acItem [$key] ['price'] = $v ['price'];
  6787. }
  6788. }
  6789. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  6790. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  6791. $acItem [$key] ['price'] = $v ['price'];
  6792. }
  6793. }
  6794. //内训
  6795. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  6796. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  6797. $acItem [$key] ['price'] = $v ['price'];
  6798. }
  6799. }
  6800. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  6801. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  6802. $acItem [$key] ['price'] = $v ['price'];
  6803. }
  6804. }
  6805. }
  6806. $data ['category'] = $lCategory->find ( array (
  6807. 'asArray' => true
  6808. ) );
  6809. $data ['cSum'] = $accountItemList ['cSum'];
  6810. $data ['sum'] = $receiptDetail ['sum'];
  6811. $data ['enclosurList'] = $enclosurList;
  6812. $data ['receiptDetail'] = $receiptDetail;
  6813. $data ['veList'] = $veList;
  6814. $data ['acItem'] = $acItem;
  6815. $data ['memu'] = "receipt";
  6816. $data ['staff'] = $this->staff;
  6817. $data ['receiptMemu'] = 'saeaBorad';
  6818. $data ['verify'] = $receiptDetail ['verify'];
  6819. $data ['verifyId'] = $this->verifyId;
  6820. $data ['executeId'] = $this->executeId;
  6821. $data ['rid'] = $ridKey;
  6822. $this->render ( "/admin/saea_edit", $data );
  6823. }
  6824. function updateReceipt() {
  6825. $agency = $this->get_args ( 'agency' );
  6826. $travel = $this->get_args ( 'travel' );
  6827. $train = $this->get_args ( 'train' );
  6828. $other = $this->get_args ( 'other' );
  6829. $inttrain = $this->get_args ( 'inttrain' );
  6830. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  6831. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  6832. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  6833. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  6834. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  6835. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  6836. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  6837. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  6838. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  6839. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  6840. Doo::loadClass ( 'XDeode' );
  6841. $XDeode = new XDeode ( 7 );
  6842. $rid = $XDeode->decode ( $ridKey );
  6843. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  6844. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  6845. header ( 'Content-Type:text/html;charset=utf-8' );
  6846. die ( '请填写联行号' );
  6847. }
  6848. Doo::loadModel ( 'receipt' );
  6849. Doo::loadModel ( 'receiptDetail' );
  6850. Doo::loadModel ( 'accountItem' );
  6851. $accountItem = new accountItem ();
  6852. $receipt = new receipt ();
  6853. Doo::loadModel ( 'enclosur' );
  6854. Doo::loadModel ( 'execute' );
  6855. $execute = new execute ();
  6856. $receiptDetail = $receipt->getOne ( array (
  6857. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  6858. 'asArray' => true
  6859. ) );
  6860. if (empty ( $receiptDetail ))
  6861. return "/saeaBorad";
  6862. if ($receiptDetail ['Rtype'] == 1)
  6863. $executeDetail = $execute->getOne ( array (
  6864. 'where' => 'mold="借款费用执行人"',
  6865. 'asArray' => true
  6866. ) );
  6867. else
  6868. $executeDetail = $execute->getOne ( array (
  6869. 'where' => 'mold="报销单执行人"',
  6870. 'asArray' => true
  6871. ) );
  6872. $aItem = $accountItem->find ( array (
  6873. 'asArray' => true
  6874. ) );
  6875. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  6876. $ag = $tr = $ta = $ot = $it = 0 ;
  6877. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum = $otherSum = 0;
  6878. foreach ( $aItem as $key => $value ) {
  6879. if ($value ['category'] == $this->AGENCY) {
  6880. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  6881. array_push ( $accountJson [$this->AGENCY], array (
  6882. 'aid' => $value ['aid'],
  6883. 'name' => $value ['name'],
  6884. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  6885. ) );
  6886. $sum += $agency [$ag];
  6887. $agencySum += $agency [$ag];
  6888. }
  6889. $ag ++;
  6890. }
  6891. if ($value ['category'] == $this->TRAVEL) {
  6892. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  6893. array_push ( $accountJson [$this->TRAVEL], array (
  6894. 'aid' => $value ['aid'],
  6895. 'name' => $value ['name'],
  6896. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  6897. ) );
  6898. $sum += $travel [$tr];
  6899. $travelSum += $travel [$tr];
  6900. }
  6901. $tr ++;
  6902. }
  6903. if ($value ['category'] == $this->TRAIN) {
  6904. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  6905. array_push ( $accountJson [$this->TRAIN], array (
  6906. 'aid' => $value ['aid'],
  6907. 'name' => $value ['name'],
  6908. 'price' => number_format ( $train [$ta], 2, '.', '' )
  6909. ) );
  6910. $sum += $train [$ta];
  6911. $trainSum += $train [$ta];
  6912. }
  6913. $ta ++;
  6914. }
  6915. if ($value ['category'] == $this->INTTRAIN) {
  6916. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  6917. array_push ( $accountJson [$this->INTTRAIN], array (
  6918. 'aid' => $value ['aid'],
  6919. 'name' => $value ['name'],
  6920. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  6921. ) );
  6922. $sum += $inttrain [$it];
  6923. $inttrainSum += $inttrain [$it];
  6924. }
  6925. $it ++;
  6926. }
  6927. if ($value ['category'] == $this->OTHER) {
  6928. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  6929. array_push ( $accountJson [$this->OTHER], array (
  6930. 'aid' => $value ['aid'],
  6931. 'name' => $value ['name'],
  6932. 'price' => number_format ( $other [$ot], 2, '.', '' )
  6933. ) );
  6934. $sum += $other [$ot];
  6935. $otherSum += $other [$ot];
  6936. }
  6937. $ot ++;
  6938. }
  6939. }
  6940. $accountJson ['cSum'] = array (
  6941. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  6942. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  6943. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  6944. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  6945. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  6946. );
  6947. // 报销单
  6948. $rid = $receipt->rid = $receiptDetail ['rid'];
  6949. $receipt->accountItem = json_encode ( $accountJson );
  6950. $receipt->staff = $this->staff [0] ['sid'];
  6951. $receipt->sum = number_format ( $sum, 2, '.', '' );
  6952. $receipt->date = date ( "Y-m-d" );
  6953. $receipt->cid = $cid;
  6954. if (($receiptDetail ['status'] != 4)) {
  6955. if ($receiptDetail ['Rtype'] == 1)
  6956. $receipt->status = 7;
  6957. else
  6958. $receipt->status = 5;
  6959. }
  6960. if ($receiptDetail != 4 && ! empty ( $verify ))
  6961. $receipt->verify = $verify;
  6962. $receipt->executeCopy = $executeDetail ['staff'];
  6963. $order = array (
  6964. "\r\n",
  6965. "\n",
  6966. "\r"
  6967. );
  6968. $replace = '<br/>';
  6969. $explanation = str_replace ( $order, $replace, $explanation );
  6970. $receipt->explanation = $explanation;
  6971. $receipt->remittanceName = $remittanceName;
  6972. $receipt->bankName = $bankName;
  6973. $receipt->bankNumber = $bankNumber;
  6974. $receipt->remittanceBankType = $remittanceBankType;
  6975. if ($remittanceBankType == 1)
  6976. $receipt->coupletNumber = $coupletNumber;
  6977. $receipt->update ();
  6978. $receiptDetail = new receiptDetail ();
  6979. $receiptDetail->delete ( array (
  6980. 'where' => 'rid=' . $rid
  6981. ) );
  6982. // 报销详情
  6983. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  6984. $receiptDetail = new receiptDetail ();
  6985. $receiptDetail->staff = $this->staff [0] ['sid'];
  6986. $receiptDetail->item = $value ['name'];
  6987. $receiptDetail->itemCategory = $this->AGENCY;
  6988. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6989. $receiptDetail->date = date ( "Y-m-d" );
  6990. $receiptDetail->cid = $cid;
  6991. $receiptDetail->rid = $rid;
  6992. $receiptDetail->status = 4;
  6993. $receiptDetail->insert ();
  6994. }
  6995. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  6996. $receiptDetail = new receiptDetail ();
  6997. $receiptDetail->staff = $this->staff [0] ['sid'];
  6998. $receiptDetail->item = $value ['name'];
  6999. $receiptDetail->itemCategory = $this->TRAVEL;
  7000. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  7001. $receiptDetail->date = date ( "Y-m-d" );
  7002. $receiptDetail->cid = $cid;
  7003. $receiptDetail->rid = $rid;
  7004. $receiptDetail->status = 4;
  7005. $receiptDetail->insert ();
  7006. }
  7007. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  7008. $receiptDetail = new receiptDetail ();
  7009. $receiptDetail->staff = $this->staff [0] ['sid'];
  7010. $receiptDetail->item = $value ['name'];
  7011. $receiptDetail->itemCategory = $this->TRAIN;
  7012. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  7013. $receiptDetail->date = date ( "Y-m-d" );
  7014. $receiptDetail->cid = $cid;
  7015. $receiptDetail->rid = $rid;
  7016. $receiptDetail->status = 4;
  7017. $receiptDetail->insert ();
  7018. }
  7019. //内训
  7020. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  7021. $receiptDetail = new receiptDetail ();
  7022. $receiptDetail->staff = $this->staff [0] ['sid'];
  7023. $receiptDetail->item = $value ['name'];
  7024. $receiptDetail->itemCategory = $this->INTTRAIN;
  7025. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  7026. $receiptDetail->date = date ( "Y-m-d" );
  7027. $receiptDetail->cid = $cid;
  7028. $receiptDetail->rid = $rid;
  7029. $receiptDetail->status = 4;
  7030. $receiptDetail->insert ();
  7031. }
  7032. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  7033. $receiptDetail = new receiptDetail ();
  7034. $receiptDetail->staff = $this->staff [0] ['sid'];
  7035. $receiptDetail->item = $value ['name'];
  7036. $receiptDetail->itemCategory = $this->OTHER;
  7037. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  7038. $receiptDetail->date = date ( "Y-m-d" );
  7039. $receiptDetail->cid = $cid;
  7040. $receiptDetail->rid = $rid;
  7041. $receiptDetail->status = 4;
  7042. $receiptDetail->insert ();
  7043. }
  7044. // 附件
  7045. if (! empty ( $enclosurName )) {
  7046. $enclosurArray = explode ( '-', $enclosurName );
  7047. foreach ( $enclosurArray as $value ) {
  7048. $enclosur = new enclosur ();
  7049. $enclosur->name = $value;
  7050. $enclosur->rid = $rid;
  7051. $enclosur->insert ();
  7052. }
  7053. }
  7054. // return "/referReceipt/".$rid;
  7055. }
  7056. return "/saeaBorad";
  7057. }
  7058. function approvedReceipt() {
  7059. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7060. Doo::loadModel ( 'receipt' );
  7061. Doo::loadModel ( 'receiptDetail' );
  7062. $receipt = new receipt ();
  7063. $receiptDetail = new receiptDetail ();
  7064. Doo::loadModel ( 'statistics' );
  7065. Doo::loadModel ( 'itemStatistics' );
  7066. $statistics = new statistics ();
  7067. $itemStatistics = new itemStatistics ();
  7068. Doo::loadModel ( "verify" );
  7069. $verify = new verify ();
  7070. // 审批状态的判定
  7071. $receiptDetailList = $receipt->getOne ( array (
  7072. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  7073. 'asArray' => true
  7074. ) );
  7075. if (empty ( $receiptDetailList ))
  7076. return "/saeaBorad";
  7077. $verifyDetail = $verify->getOne ( array (
  7078. 'where' => ' vid =' . $receiptDetailList ['verify'],
  7079. 'asArray' => true
  7080. ) );
  7081. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7082. if (empty ( $receiptDetailList ['nowStaff'] )) {
  7083. $nowStaff = "";
  7084. $nowStaffList = array ();
  7085. if ($verifyDetail [0] [1] == 'ROLE') {
  7086. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7087. foreach ( $vStaffString as $key => $value ) {
  7088. $staffK = explode ( "_", $value );
  7089. array_push ( $nowStaffList, $staffK [0] );
  7090. }
  7091. $nowStaff = implode ( ',', $nowStaffList );
  7092. } else {
  7093. $nowStaff = $verifyDetail [0] [0];
  7094. }
  7095. $receipt->nowStaff = $nowStaff;
  7096. }
  7097. // echo $nowStaff;
  7098. // print_r($verifyDetail);die;
  7099. $receipt->rid = $receiptDetailList ['rid'];
  7100. $receipt->date = date ( "Y-m-d" );
  7101. $receipt->status = 2;
  7102. $receipt->update ();
  7103. $receiptDetail->status = 2;
  7104. $receiptDetail->update ( array (
  7105. 'where' => 'rid=' . $receiptDetailList ['rid']
  7106. ) );
  7107. Doo::loadModel ( "receiptLog" );
  7108. $receiptLog = new receiptLog ();
  7109. Doo::loadModel ( "verify" );
  7110. $verify = new verify ();
  7111. $receiptInfo = $receipt->getOne ( array (
  7112. 'where' => 'rid=' . $rid,
  7113. 'asArray' => true
  7114. ) );
  7115. $vr = $verify->getOne ( array (
  7116. 'where' => 'vid=' . $receiptInfo ['verify'],
  7117. 'asArray' => true
  7118. ) );
  7119. $jd = json_decode ( $vr ['staff'] );
  7120. $roleId = 0;
  7121. foreach ( $jd as $key => $value ) {
  7122. if ($value [1] == 'ROLE') {
  7123. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7124. if ($pos !== false) {
  7125. $roleId = $value [0];
  7126. }
  7127. }
  7128. }
  7129. // 审批日志
  7130. // echo $roleId;die;
  7131. if (! empty ( $roleId )) {
  7132. Doo::loadModel ( "role" );
  7133. $role = new role ();
  7134. $roleInfo = $role->getOne ( array (
  7135. 'where' => 'rid=' . $roleId,
  7136. 'asArray' => true
  7137. ) );
  7138. // $receiptLog->rolename = $roleInfo ['name'];
  7139. }
  7140. $receiptLog->username = $this->staff [0] ['username'];
  7141. $receiptLog->uid = $this->staff [0] ['sid'];
  7142. $receiptLog->date = date ( "Y-m-d" );
  7143. $receiptLog->opinion = '提交审批';
  7144. $receiptLog->img = $this->staff [0] ['avatar'];
  7145. $receiptLog->status = 2;
  7146. $receiptLog->rid = $rid;
  7147. $receiptLog->insert ();
  7148. // statistics item
  7149. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  7150. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7151. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  7152. $stat = $statistics->getOne ( array (
  7153. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7154. 'asArray' => true
  7155. ) );
  7156. if (empty ( $stat )) {
  7157. $statistics->date = date ( "Y-m-d" );
  7158. $statistics->cid = $this->staff [0] ['cid'];
  7159. $statistics->staff = $this->staff [0] ['sid'];
  7160. $statistics->agPrice = 0;
  7161. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7162. $statistics->insert ();
  7163. } else {
  7164. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7165. $statistics->update ( array (
  7166. 'where' => 'sid=' . $stat ['sid']
  7167. ) );
  7168. }
  7169. return "/expenses";
  7170. }
  7171. function approval() {
  7172. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7173. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7174. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7175. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7176. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7177. if (empty ( $status ))
  7178. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7179. $vidList = array ();
  7180. $button = 0;
  7181. Doo::loadModel ( 'verify' );
  7182. $verify = new verify ();
  7183. Doo::loadModel ( 'receipt' );
  7184. $receipt = new receipt ();
  7185. Doo::loadModel ( 'staff' );
  7186. $staff = new staff ();
  7187. Doo::loadModel ( 'L_category' );
  7188. $Lcategory = new L_category ();
  7189. // user verify ID
  7190. $verifyDetail = $verify->find ( array (
  7191. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7192. 'asArray' => true
  7193. ) );
  7194. foreach ( $verifyDetail as $key => $value ) {
  7195. array_push ( $vidList, $value ['vid'] );
  7196. }
  7197. $vid = implode ( ",", $vidList );
  7198. if (empty ( $verifyDetail ))
  7199. $vid = 0;
  7200. /*
  7201. */
  7202. $dateCondition = " and Year(date) =" . $year;
  7203. if (! empty ( $month ))
  7204. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  7205. $categoryList = $Lcategory->find ( array (
  7206. 'asArray' => true
  7207. ) );
  7208. $staffList = $staff->find ( array (
  7209. 'where' => 'cid=' . $cid,
  7210. 'asArray' => true
  7211. ) );
  7212. $cateCondition = "";
  7213. $staffCondition = "";
  7214. $approvalCondition = "";
  7215. if (! empty ( $cid ))
  7216. $cateCondition = ' and cid=' . $cid;
  7217. if (! empty ( $sid )) {
  7218. $staffCondition = ' and staff=' . $sid;
  7219. $cateCondition = "";
  7220. }
  7221. // elseif($status==1){
  7222. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  7223. // }
  7224. if ($status == 2) {
  7225. // 查找角色审批人
  7226. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  7227. }
  7228. $ap = "";
  7229. if ($status == 4) {
  7230. $ap = 4;
  7231. $status = 2;
  7232. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  7233. }
  7234. if ($status == 5) {
  7235. $status = 4;
  7236. $ap = 5;
  7237. }
  7238. // echo $vid;
  7239. // get Receipt By verifyID status 2 .$approvalCondition
  7240. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  7241. $receiptList = $receipt->find ( array (
  7242. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  7243. 'desc' => 'rid',
  7244. 'asArray' => true
  7245. ) );
  7246. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  7247. $Locate = 0;
  7248. if ($ap == 4)
  7249. $status = 4;
  7250. elseif ($ap == 5)
  7251. $status = 5;
  7252. foreach ( $receiptList as $key => $value ) {
  7253. $receiptList [$key] ['Locate'] = $Locate;
  7254. $Locate ++;
  7255. $receiptList [$key] ['reviseDetail'] = array ();
  7256. if (! empty ( $value ['reviseDetail'] ))
  7257. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7258. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7259. $categoryDetil = $Lcategory->getOne ( array (
  7260. 'where' => 'cid=' . $value ['cid'],
  7261. 'asArray' => true
  7262. ) );
  7263. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7264. $verifyList = $verify->getOne ( array (
  7265. 'where' => 'vid=' . $value ['verify'],
  7266. 'asArray' => true
  7267. ) );
  7268. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7269. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7270. foreach ( $verifyList as $k => $v ) {
  7271. // init verifyStaff
  7272. $verifyList [$k] ['date'] = "";
  7273. $verifyList [$k] ['opinion'] = "";
  7274. $verifyList [$k] ['status'] = "";
  7275. if (empty ( $verifyStaff )) {
  7276. $verifyList [$k] ['date'] = "";
  7277. $verifyList [$k] ['opinion'] = "";
  7278. if ($v [0] == $this->staff [0] ['sid']) {
  7279. $verifyList [$k] ['status'] = 4;
  7280. $button = 4;
  7281. }
  7282. } else {
  7283. $flag = true;
  7284. foreach ( $verifyStaff as $m => $u ) {
  7285. if ($v [0] == $m) {
  7286. $verifyList [$k] ['date'] = $u ['date'];
  7287. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7288. $verifyList [$k] ['status'] = $u ['status'];
  7289. $flag = false;
  7290. break;
  7291. }
  7292. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  7293. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  7294. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  7295. }
  7296. if ($flag) { // 检测可编辑
  7297. if ($v [0] == $this->staff [0] ['sid']) {
  7298. $verifyList [$k] ['status'] = 4;
  7299. $button = 4;
  7300. }
  7301. }
  7302. }
  7303. }
  7304. $receiptList [$key] ['verifyList'] = $verifyList;
  7305. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7306. 'where' => 'sid=' . $value ['staff'],
  7307. 'asArray' => true
  7308. ) );
  7309. $receiptList [$key] ['button'] = $button;
  7310. }
  7311. // print_r($receiptList);die;
  7312. // $data['verifyDetail']=$verifyDetail;
  7313. $mothHtml = "";
  7314. for($i = 1; $i <= 12; $i ++) {
  7315. if ($month == $i)
  7316. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7317. else
  7318. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7319. }
  7320. $data ['mothHtml'] = $mothHtml;
  7321. $data ['receiptList'] = $receiptList;
  7322. $data ['receiptApprovalCount'] = count ( $receiptList );
  7323. $data ['status'] = $status;
  7324. $data ['year'] = $year;
  7325. $data ['categoryList'] = $categoryList;
  7326. $data ['staffList'] = $staffList;
  7327. $data ['cid'] = $cid;
  7328. $data ['sid'] = $sid;
  7329. $data ['ap'] = $ap;
  7330. $data ['memu'] = "receipt";
  7331. $data ['staff'] = $this->staff;
  7332. $data ['receiptMemu'] = 'approval';
  7333. $data ['verifyId'] = $this->verifyId;
  7334. $data ['executeId'] = $this->executeId;
  7335. $this->render ( "/admin/saea_reportList", $data );
  7336. }
  7337. function approvalDetails() {
  7338. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7339. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7340. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7341. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7342. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7343. Doo::loadModel ( 'verify' );
  7344. $verify = new verify ();
  7345. Doo::loadModel ( 'receipt' );
  7346. $receipt = new receipt ();
  7347. Doo::loadModel ( 'staff' );
  7348. $staff = new staff ();
  7349. Doo::loadModel ( 'L_category' );
  7350. $Lcategory = new L_category ();
  7351. Doo::loadModel ( 'enclosur' );
  7352. $enclosur = new enclosur ();
  7353. $vidList = array ();
  7354. $verifyDetail = $verify->find ( array (
  7355. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7356. 'asArray' => true
  7357. ) );
  7358. foreach ( $verifyDetail as $key => $value ) {
  7359. array_push ( $vidList, $value ['vid'] );
  7360. }
  7361. $vid = implode ( ",", $vidList );
  7362. if (empty ( $verifyDetail ))
  7363. $vid = 0;
  7364. $categoryList = $Lcategory->find ( array (
  7365. 'asArray' => true
  7366. ) );
  7367. $staffList = $staff->find ( array (
  7368. 'where' => 'cid=' . $cid,
  7369. 'asArray' => true
  7370. ) );
  7371. $ap = 0;
  7372. $receiptList = $receipt->find ( array (
  7373. 'where' => 'rid =' . $rid,
  7374. 'desc' => 'rid',
  7375. 'asArray' => true
  7376. ) );
  7377. $Locate = 0;
  7378. $roleId = 0;
  7379. $button = 0;
  7380. foreach ( $receiptList as $key => $value ) {
  7381. $receiptList [$key] ['Locate'] = $Locate;
  7382. $Locate ++;
  7383. $receiptList [$key] ['reviseDetail'] = array ();
  7384. if (! empty ( $value ['reviseDetail'] ))
  7385. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7386. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7387. $categoryDetil = $Lcategory->getOne ( array (
  7388. 'where' => 'cid=' . $value ['cid'],
  7389. 'asArray' => true
  7390. ) );
  7391. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7392. // 检测编辑状态
  7393. $verifyList = $verify->getOne ( array (
  7394. 'where' => 'vid=' . $value ['verify'],
  7395. 'asArray' => true
  7396. ) );
  7397. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7398. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7399. Doo::loadModel ( 'role' );
  7400. $role = new role ();
  7401. // print_r($verifyList);
  7402. $flag = true;
  7403. $roleKey = 0;
  7404. $endStaffArray = array ();
  7405. $roleArrayCopy = array ();
  7406. foreach ( $verifyList as $k => $v ) {
  7407. // init verifyStaff
  7408. if ($v [1] == 'ROLE') {
  7409. if (! empty ( $verifyStaff )) {
  7410. $endStaffArray = end ( $verifyStaff );
  7411. if ($v [0] == $endStaffArray ['nextStaff']) {
  7412. $roleId = $v [0];
  7413. }
  7414. }
  7415. $roleVerify = json_decode ( $v [3], true );
  7416. $roleKey = $k;
  7417. $roleArray = array ();
  7418. $rolename = $role->getOne ( array (
  7419. 'where' => 'rid=' . $v [0],
  7420. 'asArray' => true
  7421. ) );
  7422. foreach ( $roleVerify as $o => $p ) {
  7423. $staffID = explode ( '_', $p );
  7424. $staffInfo = $staff->getOne ( array (
  7425. 'where' => 'sid=' . $staffID [0],
  7426. 'asArray' => true
  7427. ) );
  7428. // print_r($staffID);
  7429. $exp = array (
  7430. 0 => $staffInfo ['sid'],
  7431. 1 => $staffID [1],
  7432. 2 => $staffInfo ['avatar'],
  7433. 'date' => '',
  7434. 'date' => '',
  7435. 'opinion' => '',
  7436. 'status' => '',
  7437. 'rolename' => $rolename ['name']
  7438. );
  7439. array_push ( $roleArray, $exp );
  7440. }
  7441. $roleArrayCopy [$v [0]] = $roleArray;
  7442. // $verifyList[$k]['roleArray']=$roleArray;
  7443. }
  7444. // print_r($roleArray);
  7445. $verifyList [$k] ['date'] = "";
  7446. $verifyList [$k] ['opinion'] = "";
  7447. $verifyList [$k] ['status'] = "";
  7448. if (empty ( $verifyStaff )) {
  7449. $verifyList [$k] ['date'] = "";
  7450. $verifyList [$k] ['opinion'] = "";
  7451. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7452. $verifyList [$k] ['status'] = 4;
  7453. $button = 4;
  7454. $flag = false;
  7455. }
  7456. } else {
  7457. foreach ( $verifyStaff as $m => $u ) {
  7458. if ($v [0] == $m) {
  7459. $verifyList [$k] ['date'] = $u ['date'];
  7460. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7461. $verifyList [$k] ['status'] = $u ['status'];
  7462. $flag = false;
  7463. break;
  7464. }
  7465. }
  7466. $endStaffArray = end ( $verifyStaff );
  7467. if (isset ( $endStaffArray ['ROLE'] )) {
  7468. } else {
  7469. $endKey = key ( $verifyStaff );
  7470. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7471. $button = 4;
  7472. $verifyList [$k] ['status'] = 4;
  7473. }
  7474. }
  7475. }
  7476. }
  7477. $rolename ['name'] = '';
  7478. if (! empty ( $roleId )) {
  7479. Doo::loadModel ( 'role' );
  7480. $role = new role ();
  7481. $rolename = $role->getOne ( array (
  7482. 'where' => 'rid=' . $roleId,
  7483. 'asArray' => true
  7484. ) );
  7485. }
  7486. if (! empty ( $verifyStaff ))
  7487. $endStaffArray = end ( $verifyStaff );
  7488. $KOP = false;
  7489. foreach ( $roleArrayCopy as $P => $A ) {
  7490. foreach ( $A as $MKI => $AVL ) {
  7491. if (! empty ( $verifyStaff )) {
  7492. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7493. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7494. $button = 4;
  7495. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7496. }
  7497. foreach ( $verifyStaff as $m => $u ) {
  7498. $AVLFK = $AVL [0] . '_R';
  7499. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7500. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7501. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7502. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7503. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7504. break;
  7505. }
  7506. }
  7507. } else {
  7508. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7509. $button = 4;
  7510. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7511. }
  7512. }
  7513. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7514. $KOP = true;
  7515. }
  7516. }
  7517. foreach ( $roleArrayCopy as $k => $v ) {
  7518. foreach ( $verifyList as $m => $n ) {
  7519. if ($n [0] == $k) {
  7520. array_splice ( $verifyList, $m, 1, $v );
  7521. }
  7522. }
  7523. }
  7524. $receiptList [$key] ['verifyList'] = $verifyList;
  7525. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7526. 'where' => 'sid=' . $value ['staff'],
  7527. 'asArray' => true
  7528. ) );
  7529. $receiptList [$key] ['button'] = $button;
  7530. }
  7531. $mothHtml = "";
  7532. for($i = 1; $i <= 12; $i ++) {
  7533. if ($month == $i)
  7534. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7535. else
  7536. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7537. }
  7538. // 获取审批日志
  7539. Doo::loadModel ( 'receiptLog' );
  7540. $receiptLog = new receiptLog ();
  7541. $rlList = array ();
  7542. $rlInfo = $receiptLog->getOne ( array (
  7543. 'where' => 'rid=' . $rid . ' and status=4',
  7544. 'asArray' => true
  7545. ) );
  7546. $tijdate = $receiptLog->getOne ( array (
  7547. 'where' => 'rid=' . $rid . ' and status=2',
  7548. 'asc' => 'rlid',
  7549. 'asArray' => true
  7550. ) );
  7551. if (! empty ( $rlInfo )) {
  7552. $rlList = $receiptLog->find ( array (
  7553. 'where' => 'rid=' . $rid,
  7554. 'asc' => 'rlid',
  7555. 'asArray' => true
  7556. ) );
  7557. }
  7558. $receiptList [0] ['rlList'] = $rlList;
  7559. $enclosurList = $enclosur->find ( array (
  7560. 'where' => 'rid=' . $rid,
  7561. 'asArray' => true
  7562. ) );
  7563. $enclosurHtml = '';
  7564. foreach ( $enclosurList as $value ) {
  7565. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  7566. }
  7567. $data ['enclosurHtml'] = $enclosurHtml;
  7568. $data ['rolename'] = $rolename ['name'];
  7569. $data ['datetij'] = $tijdate ['date'];
  7570. $data ['mothHtml'] = $mothHtml;
  7571. $data ['receiptList'] = $receiptList;
  7572. $data ['receiptApprovalCount'] = count ( $receiptList );
  7573. $data ['year'] = $year;
  7574. $data ['categoryList'] = $categoryList;
  7575. $data ['staffList'] = $staffList;
  7576. $data ['cid'] = $cid;
  7577. $data ['sid'] = $sid;
  7578. $data ['status'] = 0;
  7579. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  7580. $ap = 4;
  7581. } else
  7582. $data ['status'] = $receiptList [0] ['status'];
  7583. if ($receiptList [0] ['status'] == 4) {
  7584. $data ['status'] = 5;
  7585. $ap = 0;
  7586. }
  7587. $data ['ap'] = $ap;
  7588. $data ['memu'] = "receipt";
  7589. $data ['staff'] = $this->staff;
  7590. $data ['receiptMemu'] = 'approval';
  7591. $data ['verifyId'] = $this->verifyId;
  7592. $data ['executeId'] = $this->executeId;
  7593. $this->render ( "/admin/saeaReportListReport", $data );
  7594. }
  7595. function approvalEdi() {
  7596. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7597. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7598. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7599. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7600. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7601. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7602. if (empty ( $status ))
  7603. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7604. $vidList = array ();
  7605. $button = 0;
  7606. Doo::loadModel ( 'verify' );
  7607. Doo::loadModel ( 'receipt' );
  7608. Doo::loadModel ( 'staff' );
  7609. $staff = new staff ();
  7610. $receipt = new receipt ();
  7611. $verify = new verify ();
  7612. Doo::loadModel ( 'L_category' );
  7613. $Lcategory = new L_category ();
  7614. Doo::loadModel ( 'enclosur' );
  7615. $enclosur = new enclosur ();
  7616. // user verify ID
  7617. $verifyDetail = $verify->find ( array (
  7618. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7619. 'asArray' => true
  7620. ) );
  7621. foreach ( $verifyDetail as $key => $value ) {
  7622. array_push ( $vidList, $value ['vid'] );
  7623. }
  7624. $vid = implode ( ",", $vidList );
  7625. if (empty ( $verifyDetail ))
  7626. $vid = 0;
  7627. $categoryList = $Lcategory->find ( array (
  7628. 'asArray' => true
  7629. ) );
  7630. $staffList = $staff->find ( array (
  7631. 'where' => 'cid=' . $cid,
  7632. 'asArray' => true
  7633. ) );
  7634. $ap = "";
  7635. if ($status == 4) {
  7636. $ap = 4;
  7637. $status = 2;
  7638. }
  7639. // get Receipt By verifyID status 2
  7640. $receiptList = $receipt->find ( array (
  7641. 'where' => 'rid =' . $rid,
  7642. 'desc' => 'rid',
  7643. 'asArray' => true
  7644. ) );
  7645. $Locate = 0;
  7646. $roleId = 0;
  7647. if ($ap == 4)
  7648. $status = 4;
  7649. foreach ( $receiptList as $key => $value ) {
  7650. $receiptList [$key] ['Locate'] = $Locate;
  7651. $Locate ++;
  7652. $receiptList [$key] ['reviseDetail'] = array ();
  7653. if (! empty ( $value ['reviseDetail'] ))
  7654. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7655. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7656. $categoryDetil = $Lcategory->getOne ( array (
  7657. 'where' => 'cid=' . $value ['cid'],
  7658. 'asArray' => true
  7659. ) );
  7660. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7661. // 检测编辑状态
  7662. $verifyList = $verify->getOne ( array (
  7663. 'where' => 'vid=' . $value ['verify'],
  7664. 'asArray' => true
  7665. ) );
  7666. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7667. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7668. // print_r($verifyList);
  7669. //
  7670. // if (empty($verifyStaff)){
  7671. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  7672. // $verifyList[0]['status']=4;$button=4;
  7673. // }
  7674. //
  7675. // }else{
  7676. //
  7677. // }
  7678. // die;
  7679. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  7680. // echo array_search("green",$a);
  7681. //
  7682. Doo::loadModel ( 'role' );
  7683. $role = new role ();
  7684. // print_r($verifyList);
  7685. $flag = true;
  7686. $roleKey = 0;
  7687. $endStaffArray = array ();
  7688. $roleArrayCopy = array ();
  7689. foreach ( $verifyList as $k => $v ) {
  7690. // init verifyStaff
  7691. if ($v [1] == 'ROLE') {
  7692. if (! empty ( $verifyStaff )) {
  7693. $endStaffArray = end ( $verifyStaff );
  7694. if ($v [0] == $endStaffArray ['nextStaff']) {
  7695. $roleId = $v [0];
  7696. }
  7697. }
  7698. $roleVerify = json_decode ( $v [3], true );
  7699. $roleKey = $k;
  7700. $roleArray = array ();
  7701. $rolename = $role->getOne ( array (
  7702. 'where' => 'rid=' . $v [0],
  7703. 'asArray' => true
  7704. ) );
  7705. foreach ( $roleVerify as $o => $p ) {
  7706. $staffID = explode ( '_', $p );
  7707. $staffInfo = $staff->getOne ( array (
  7708. 'where' => 'sid=' . $staffID [0],
  7709. 'asArray' => true
  7710. ) );
  7711. // print_r($staffID);
  7712. $exp = array (
  7713. 0 => $staffInfo ['sid'],
  7714. 1 => $staffID [1],
  7715. 2 => $staffInfo ['avatar'],
  7716. 'date' => '',
  7717. 'date' => '',
  7718. 'opinion' => '',
  7719. 'status' => '',
  7720. 'rolename' => $rolename ['name']
  7721. );
  7722. array_push ( $roleArray, $exp );
  7723. }
  7724. $roleArrayCopy [$v [0]] = $roleArray;
  7725. // $verifyList[$k]['roleArray']=$roleArray;
  7726. }
  7727. // print_r($roleArray);
  7728. $verifyList [$k] ['date'] = "";
  7729. $verifyList [$k] ['opinion'] = "";
  7730. $verifyList [$k] ['status'] = "";
  7731. if (empty ( $verifyStaff )) {
  7732. $verifyList [$k] ['date'] = "";
  7733. $verifyList [$k] ['opinion'] = "";
  7734. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7735. $verifyList [$k] ['status'] = 4;
  7736. $button = 4;
  7737. $flag = false;
  7738. }
  7739. } else {
  7740. foreach ( $verifyStaff as $m => $u ) {
  7741. if ($v [0] == $m) {
  7742. $verifyList [$k] ['date'] = $u ['date'];
  7743. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7744. $verifyList [$k] ['status'] = $u ['status'];
  7745. $flag = false;
  7746. break;
  7747. }
  7748. }
  7749. $endStaffArray = end ( $verifyStaff );
  7750. if (isset ( $endStaffArray ['ROLE'] )) {
  7751. } else {
  7752. $endKey = key ( $verifyStaff );
  7753. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7754. $button = 4;
  7755. $verifyList [$k] ['status'] = 4;
  7756. }
  7757. }
  7758. // print_r($endStaffArray);die;
  7759. // if (empty($verifyStaff)){
  7760. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  7761. // $verifyList[$k]['status']=4;$button=4;
  7762. // }
  7763. //
  7764. // }else{
  7765. //
  7766. // }
  7767. // if($flag){//检测可编辑
  7768. // if($v[0]==$this->staff[0]['sid']){
  7769. // $verifyList[$k]['status']=4;$button=4;
  7770. // }
  7771. // }
  7772. }
  7773. }
  7774. $rolename ['name'] = '';
  7775. if (! empty ( $roleId )) {
  7776. Doo::loadModel ( 'role' );
  7777. $role = new role ();
  7778. $rolename = $role->getOne ( array (
  7779. 'where' => 'rid=' . $roleId,
  7780. 'asArray' => true
  7781. ) );
  7782. }
  7783. if (! empty ( $verifyStaff ))
  7784. $endStaffArray = end ( $verifyStaff );
  7785. $KOP = false;
  7786. foreach ( $roleArrayCopy as $P => $A ) {
  7787. foreach ( $A as $MKI => $AVL ) {
  7788. if (! empty ( $verifyStaff )) {
  7789. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7790. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7791. $button = 4;
  7792. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7793. }
  7794. foreach ( $verifyStaff as $m => $u ) {
  7795. $AVLFK = $AVL [0] . '_R';
  7796. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7797. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7798. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7799. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7800. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7801. break;
  7802. }
  7803. }
  7804. } else {
  7805. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7806. $button = 4;
  7807. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7808. }
  7809. }
  7810. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7811. $KOP = true;
  7812. }
  7813. }
  7814. // print_r($roleArrayCopy);
  7815. // echo $roleKey;
  7816. foreach ( $roleArrayCopy as $k => $v ) {
  7817. foreach ( $verifyList as $m => $n ) {
  7818. if ($n [0] == $k) {
  7819. array_splice ( $verifyList, $m, 1, $v );
  7820. }
  7821. }
  7822. }
  7823. // if ($KOP)
  7824. // array_splice($verifyList,$roleKey,1,$roleArray);
  7825. // print_r($verifyList);
  7826. $receiptList [$key] ['verifyList'] = $verifyList;
  7827. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7828. 'where' => 'sid=' . $value ['staff'],
  7829. 'asArray' => true
  7830. ) );
  7831. $receiptList [$key] ['button'] = $button;
  7832. }
  7833. // $data['verifyDetail']=$verifyDetail;
  7834. $mothHtml = "";
  7835. for($i = 1; $i <= 12; $i ++) {
  7836. if ($month == $i)
  7837. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7838. else
  7839. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7840. }
  7841. // 获取审批日志
  7842. Doo::loadModel ( 'receiptLog' );
  7843. $receiptLog = new receiptLog ();
  7844. $rlList = array ();
  7845. $rlInfo = $receiptLog->getOne ( array (
  7846. 'where' => 'rid=' . $rid . ' and status=4',
  7847. 'asArray' => true
  7848. ) );
  7849. $tijdate = $receiptLog->getOne ( array (
  7850. 'where' => 'rid=' . $rid . ' and status=2',
  7851. 'asc' => 'rlid',
  7852. 'asArray' => true
  7853. ) );
  7854. if (! empty ( $rlInfo )) {
  7855. $rlList = $receiptLog->find ( array (
  7856. 'where' => 'rid=' . $rid,
  7857. 'asc' => 'rlid',
  7858. 'asArray' => true
  7859. ) );
  7860. }
  7861. $receiptList [0] ['rlList'] = $rlList;
  7862. $enclosurList = $enclosur->find ( array (
  7863. 'where' => 'rid=' . $rid,
  7864. 'asArray' => true
  7865. ) );
  7866. $enclosurHtml = '';
  7867. foreach ( $enclosurList as $value ) {
  7868. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  7869. }
  7870. $data ['enclosurHtml'] = $enclosurHtml;
  7871. $data ['rolename'] = $rolename ['name'];
  7872. $data ['datetij'] = $tijdate ['date'];
  7873. $data ['mothHtml'] = $mothHtml;
  7874. $data ['receiptList'] = $receiptList;
  7875. $data ['receiptApprovalCount'] = count ( $receiptList );
  7876. $data ['status'] = $status;
  7877. $data ['year'] = $year;
  7878. $data ['categoryList'] = $categoryList;
  7879. $data ['staffList'] = $staffList;
  7880. $data ['cid'] = $cid;
  7881. $data ['sid'] = $sid;
  7882. $data ['ap'] = $ap;
  7883. $data ['memu'] = "receipt";
  7884. $data ['staff'] = $this->staff;
  7885. $data ['receiptMemu'] = 'approval';
  7886. $data ['verifyId'] = $this->verifyId;
  7887. $data ['executeId'] = $this->executeId;
  7888. $this->render ( "/admin/saeaReportListReport", $data );
  7889. }
  7890. function remittanceHky() {
  7891. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7892. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  7893. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  7894. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  7895. $page_size = 15;
  7896. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  7897. Doo::loadModel ( 'receipt' );
  7898. $receipt = new receipt ();
  7899. Doo::loadModel ( 'staff' );
  7900. $staff = new staff ();
  7901. $dateCondition = " and Year(executeDate) =" . $year;
  7902. if ($moth != 'MONTH')
  7903. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  7904. if ($day != 'DAY' && $moth != 'MONTH')
  7905. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  7906. $sql = ' (status =8 or status=9 ) and amount>0 ' . $dateCondition;
  7907. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  7908. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  7909. $limit = $pageinfo ['lower'] . ',' . $page_size;
  7910. $dayList = $receipt->find ( array (
  7911. 'select' => 'executeDate,sum(amount) as amount',
  7912. 'where' => $sql,
  7913. 'desc' => 'executeDate',
  7914. 'groupby' => 'executeDate',
  7915. 'limit' => $limit,
  7916. 'asArray' => true
  7917. ) );
  7918. // print_r($dayList);
  7919. foreach ( $dayList as $key => $value ) {
  7920. $remitString = "";
  7921. $receiptList = $receipt->find ( array (
  7922. 'select' => 'rid,executeDate,amount,staff,cid',
  7923. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  7924. 'desc' => 'executeDate',
  7925. 'asArray' => true
  7926. ) );
  7927. foreach ( $receiptList as $k => $v ) {
  7928. $sinfo = $staff->getOne ( array (
  7929. 'select' => 'username,category',
  7930. 'where' => ' sid=' . $v ['staff'],
  7931. 'asArray' => true
  7932. ) );
  7933. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  7934. }
  7935. $dayList [$key] ['staff'] = $remitString;
  7936. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  7937. }
  7938. // print_r($dayList);
  7939. $mothHtml = "";
  7940. for($i = 1; $i <= 12; $i ++) {
  7941. if ($moth == $i)
  7942. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7943. else
  7944. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7945. }
  7946. $dayHtml = "";
  7947. if ($day != "DAY" || $moth != "MONTH") {
  7948. for($i = 1; $i <= 31; $i ++) {
  7949. if ($day == $i)
  7950. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  7951. else
  7952. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  7953. }
  7954. }
  7955. $dateHtml = "";
  7956. $now = date ( "Y" );
  7957. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  7958. if ($YEARD <= $now) {
  7959. $dateHtml .= '<option ';
  7960. if ($year == $YEARD) {
  7961. $dateHtml .= 'selected ';
  7962. }
  7963. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  7964. }
  7965. }
  7966. $data ['dateHtml'] = $dateHtml;
  7967. $data ['page'] = $pageinfo;
  7968. $data ['year'] = $year;
  7969. $data ['moth'] = $moth;
  7970. $data ['day'] = $day;
  7971. $data ['get'] = $get;
  7972. $data ['dayHtml'] = $dayHtml;
  7973. $data ['mothHtml'] = $mothHtml;
  7974. $data ['receiptList'] = $dayList;
  7975. $data ['memu'] = "receipt";
  7976. $data ['staff'] = $this->staff;
  7977. $data ['receiptMemu'] = 'remittanceHky';
  7978. $data ['verifyId'] = $this->verifyId;
  7979. $data ['executeId'] = $this->executeId;
  7980. $this->render ( "/admin/remittanceHky", $data );
  7981. }
  7982. function remittancep() {
  7983. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  7984. Doo::loadModel ( 'receipt' );
  7985. $receipt = new receipt ();
  7986. Doo::loadModel ( 'staff' );
  7987. $staff = new staff ();
  7988. Doo::loadClass ( 'XDeode' );
  7989. $XDeode = new XDeode ( 5 );
  7990. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  7991. $rplist = $receipt->find ( array (
  7992. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  7993. 'asArray' => true
  7994. ) );
  7995. $dayList = $receipt->find ( array (
  7996. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  7997. 'desc' => 'executeDate',
  7998. 'groupby' => 'staff',
  7999. 'asArray' => true
  8000. ) );
  8001. $html = '';
  8002. foreach ( $dayList as $key => $value ) {
  8003. $sinfo = $staff->getOne ( array (
  8004. 'select' => 'username,category',
  8005. 'where' => ' sid=' . $value ['staff'],
  8006. 'asArray' => true
  8007. ) );
  8008. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  8009. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  8010. $au = 0;
  8011. foreach ( $rplist as $k => $v ) {
  8012. if ($value ['staff'] == $v ['staff']) {
  8013. $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>';
  8014. $au += $v ['amount'];
  8015. }
  8016. }
  8017. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  8018. }
  8019. $data ['html'] = $html;
  8020. $data ['memu'] = "receipt";
  8021. $data ['staff'] = $this->staff;
  8022. $data ['receiptMemu'] = 'remittanceHky';
  8023. $data ['verifyId'] = $this->verifyId;
  8024. $data ['executeId'] = $this->executeId;
  8025. $this->render ( "/admin/remittancep", $data );
  8026. }
  8027. function ajaxGetReceiptDetails() {
  8028. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  8029. Doo::loadClass ( 'XDeode' );
  8030. $XDeode = new XDeode ( 5 );
  8031. $rid = $XDeode->decode ( $rid );
  8032. if (empty ( $rid )) {
  8033. echo json_encode ( array (
  8034. 'status' => 2,
  8035. 'msg' => 'illegal request'
  8036. ) );
  8037. die ();
  8038. }
  8039. Doo::loadModel ( 'receipt' );
  8040. $receipt = new receipt ();
  8041. Doo::loadModel ( 'staff' );
  8042. $staff = new staff ();
  8043. $rinfo = $receipt->getOne ( array (
  8044. 'where' => 'rid= ' . $rid,
  8045. 'asArray' => true
  8046. ) );
  8047. $sinfo = $staff->getOne ( array (
  8048. 'select' => 'username,category',
  8049. 'where' => ' sid=' . $rinfo ['staff'],
  8050. 'asArray' => true
  8051. ) );
  8052. $rinfo ['reviseDetail'] = array ();
  8053. if (! empty ( $rinfo ['reviseDetail'] ))
  8054. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  8055. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  8056. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  8057. $rinfo ['category'] = $sinfo ['category'];
  8058. $verifyStaff = array ();
  8059. if (! empty ( $rinfo ['verifyStaff'] ))
  8060. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  8061. $relust = bcsub ( $rinfo ['sum'], $rinfo ['loanSum'], 2 );
  8062. $rinfo ['relust'] = $relust;
  8063. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  8064. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  8065. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  8066. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  8067. // 费用执行人相关数据
  8068. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  8069. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  8070. foreach ( $executeCopy as $k => $v ) {
  8071. $executeCopy [$k] ['date'] = '';
  8072. $executeCopy [$k] ['opinion'] = '';
  8073. $executeCopy [$k] ['status'] = '';
  8074. if (! empty ( $executeStaff ))
  8075. foreach ( $executeStaff as $m => $u ) {
  8076. if ($v [0] == $m) {
  8077. $executeCopy [$k] ['date'] = $u ['date'];
  8078. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  8079. $executeCopy [$k] ['status'] = $u ['status'];
  8080. break;
  8081. }
  8082. }
  8083. }
  8084. $rinfo ['executeCopy'] = $executeCopy;
  8085. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  8086. if ($rinfo ['Rtype'] == 1) { // 借款费用
  8087. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8088. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  8089. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  8090. $html .= '<tr><th>' . $value ['name'] . '</th>
  8091. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8092. }
  8093. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8094. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8095. <tr><th class="taC" colspan="2">费用说明</th>
  8096. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8097. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8098. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  8099. </tbody></table>';
  8100. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  8101. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8102. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8103. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8104. $html .= '<tr><th>' . $value ['name'] . '</th>
  8105. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8106. }
  8107. $html .= '<tr><th class="taR">合计</th>
  8108. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8109. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8110. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8111. $html .= '<tr><th>' . $value ['name'] . '</th>
  8112. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8113. }
  8114. $html .= '<tr><th class="taR">合计</th>
  8115. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8116. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8117. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8118. $html .= '<tr><th>' . $value ['name'] . '</th>
  8119. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8120. }
  8121. $html .= '<tr><th class="taR">合计</th>
  8122. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8123. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8124. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8125. $html .= '<tr><th>' . $value ['name'] . '</th>
  8126. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8127. }
  8128. $html .= '<tr><th class="taR">合计</th>
  8129. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8130. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8131. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8132. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8133. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8134. }
  8135. $html .= '<tr><th class="taR">合计</th>
  8136. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8137. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8138. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8139. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8140. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8141. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8142. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8143. <tr';
  8144. if ($rinfo ['relust'] >= 0) {
  8145. $html .= 'class="success"';
  8146. } else {
  8147. $html .= 'class="error"';
  8148. }
  8149. $html .= '><td class="taR"><b>借款结余</b></td>
  8150. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  8151. </tbody></table>
  8152. ';
  8153. }
  8154. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  8155. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8156. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  8157. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8158. $html .= '<tr><th>' . $value ['name'] . '</th>
  8159. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8160. }
  8161. $html .= '<tr><th class="taR">合计</th>
  8162. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8163. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8164. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8165. <tr><th class="taC" colspan="2">费用说明</th>
  8166. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8167. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8168. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8169. </tbody></table>';
  8170. } else {
  8171. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8172. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8173. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8174. $html .= '<tr><th>' . $value ['name'] . '</th>
  8175. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8176. }
  8177. $html .= '<tr><th class="taR">合计</th>
  8178. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8179. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8180. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8181. $html .= '<tr><th>' . $value ['name'] . '</th>
  8182. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8183. }
  8184. $html .= '<tr><th class="taR">合计</th>
  8185. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8186. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8187. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8188. $html .= '<tr><th>' . $value ['name'] . '</th>
  8189. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8190. }
  8191. $html .= '<tr><th class="taR">合计</th>
  8192. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8193. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8194. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8195. $html .= '<tr><th>' . $value ['name'] . '</th>
  8196. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8197. }
  8198. $html .= '<tr><th class="taR">合计</th>
  8199. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8200. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8201. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8202. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8203. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8204. }
  8205. $html .= '<tr><th class="taR">合计</th>
  8206. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8207. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8208. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8209. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8210. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8211. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8212. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  8213. $html .= '</tbody></table>';
  8214. /*
  8215. * <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>
  8216. */
  8217. }
  8218. // print_r($verifyStaff);die;
  8219. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  8220. foreach ( $verifyStaff as $key => $value ) {
  8221. $key = trim ( strtr ( $key, '_R', ' ' ) );
  8222. $sinfo = $staff->getOne ( array (
  8223. 'select' => 'username',
  8224. 'where' => ' sid=' . $key,
  8225. 'asArray' => true
  8226. ) );
  8227. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8228. }
  8229. $html .= '</tbody></table>';
  8230. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  8231. foreach ( $rinfo ['executeCopy'] as $value ) {
  8232. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8233. }
  8234. $html .= '</tbody></table>';
  8235. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  8236. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  8237. </tr></table>';
  8238. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  8239. echo json_encode ( array (
  8240. 'status' => 1,
  8241. 'html' => $html
  8242. ) );
  8243. die ();
  8244. }
  8245. /**
  8246. * 删除附件
  8247. */
  8248. function ajaxRemEnclousur() {
  8249. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  8250. if (empty ( $key ))
  8251. echo json_encode ( array (
  8252. 'status' => 2
  8253. ) );
  8254. Doo::loadModel ( 'enclosur' );
  8255. $enclosur = new enclosur ();
  8256. $enclosur->delEnclosurByEid ( $key );
  8257. echo json_encode ( array (
  8258. 'status' => 1
  8259. ) );
  8260. }
  8261. function remittance() {
  8262. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8263. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8264. Doo::loadModel ( 'receipt' );
  8265. $receipt = new receipt ();
  8266. Doo::loadModel ( 'staff' );
  8267. $staff = new staff ();
  8268. $dateCondition = " and Year(pastDate) =" . $year;
  8269. if (! empty ( $month ))
  8270. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  8271. // get Receipt By verifyID status 1
  8272. $receiptList = $receipt->find ( array (
  8273. 'select' => 'sum(sum) as sum,staff,pastDate',
  8274. 'where' => ' status=1' . $dateCondition,
  8275. 'desc' => 'pastDate',
  8276. 'groupby' => 'staff,pastDate',
  8277. 'asArray' => true
  8278. ) );
  8279. $dateList = $receipt->find ( array (
  8280. 'select' => 'pastDate,verifyStaff',
  8281. 'where' => ' status=1' . $dateCondition,
  8282. 'desc' => 'pastDate',
  8283. 'groupby' => 'pastDate',
  8284. 'asArray' => true
  8285. ) );
  8286. $dataList = array ();
  8287. foreach ( $dateList as $d => $a ) {
  8288. $dataList [$a ['pastDate']] = array ();
  8289. $daySum = 0;
  8290. foreach ( $receiptList as $key => $value ) {
  8291. if ($a ['pastDate'] == $value ['pastDate']) {
  8292. $oderList = $receipt->find ( array (
  8293. 'select' => 'receiptOrder',
  8294. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  8295. 'asArray' => true
  8296. ) );
  8297. $list = array ();
  8298. $html = "";
  8299. foreach ( $oderList as $v ) {
  8300. array_push ( $list, $v ['receiptOrder'] );
  8301. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  8302. }
  8303. $receiptList [$key] ['receiptOrder'] = $html;
  8304. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  8305. $sinfo = $staff->getOne ( array (
  8306. 'select' => 'username ',
  8307. 'where' => ' sid=' . $value ['staff'],
  8308. 'asArray' => true
  8309. ) );
  8310. $receiptList [$key] ['username'] = $sinfo ['username'];
  8311. $daySum += $value ['sum'];
  8312. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  8313. }
  8314. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  8315. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  8316. }
  8317. }
  8318. // print_r($dataList);
  8319. $data ['dataList'] = $dataList;
  8320. $mothHtml = "";
  8321. for($i = 1; $i <= 12; $i ++) {
  8322. if ($month == $i)
  8323. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8324. else
  8325. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8326. }
  8327. $data ['year'] = $year;
  8328. $data ['mothHtml'] = $mothHtml;
  8329. $data ['memu'] = "receipt";
  8330. $data ['staff'] = $this->staff;
  8331. $data ['receiptMemu'] = 'approval';
  8332. $data ['verifyId'] = $this->verifyId;
  8333. $data ['executeId'] = $this->executeId;
  8334. $this->render ( "/admin/saeaReportListPay", $data );
  8335. }
  8336. /**
  8337. * 金额调整,提高稳定性
  8338. * @return string
  8339. */
  8340. function revocationAdjustment() {
  8341. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  8342. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  8343. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  8344. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  8345. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  8346. Doo::loadClass ( 'XDeode' );
  8347. $XDeode = new XDeode ( 5 );
  8348. Doo::loadModel ( 'receipt' );
  8349. $receipt = new receipt ();
  8350. $sid = $XDeode->decode ( $sidKey );
  8351. $rid = $XDeode->decode ( $ridKey );
  8352. $reviseKey = $XDeode->decode ( $reviseKey );
  8353. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  8354. die ( 'illegal request' );
  8355. $receiptDetail = $receipt->getOne ( array (
  8356. 'where' => 'rid=' . $rid,
  8357. 'asArray' => true
  8358. ) );
  8359. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  8360. die ( 'illegal request' );
  8361. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8362. if (! isset ( $reviseDetail [$reviseKey] ))
  8363. die ( 'illegal request' );
  8364. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  8365. unset ( $reviseDetail [$reviseKey] );
  8366. $revisePrice = 0;
  8367. foreach ( $reviseDetail as $key => $value ) {
  8368. $revisePrice += $value ['price'];
  8369. }
  8370. $reviseDetailString = json_encode ( $reviseDetail );
  8371. $receipt->reviseDetail = $reviseDetailString;
  8372. $receipt->sum = $receiptDetail ['sum'] - $price;
  8373. $receipt->revisePrice = $revisePrice;
  8374. $receipt->update ( array (
  8375. 'where' => 'rid=' . $rid
  8376. ) );
  8377. return '/receiptburEdi/' . $rid;
  8378. } else
  8379. die ( 'illegal request2' );
  8380. }
  8381. function updateApprovalReceipt() {
  8382. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  8383. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  8384. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8385. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  8386. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  8387. if (! empty ( $rid )) {
  8388. Doo::loadModel ( "verify" );
  8389. $verify = new verify ();
  8390. Doo::loadModel ( "receiptDetail" );
  8391. $receiptDetailObj = new receiptDetail ();
  8392. Doo::loadModel ( "itemStatistics" );
  8393. Doo::loadModel ( "statistics" );
  8394. $statistics = new statistics ();
  8395. $itemStatistics = new itemStatistics ();
  8396. Doo::loadModel ( "receipt" );
  8397. $receipt = new receipt ();
  8398. $receiptDetail = $receipt->getOne ( array (
  8399. 'where' => 'rid=' . $rid . ' and status=2 ',
  8400. 'asArray' => true
  8401. ) );
  8402. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  8403. $nsflag = true;
  8404. foreach ( $nslist as $value ) {
  8405. if ($value == $this->staff ['0'] ['sid']) {
  8406. $nsflag = false;
  8407. break;
  8408. }
  8409. }
  8410. if (empty ( $receiptDetail ) || $nsflag)
  8411. return "/approvalExpenses/pendApproval";
  8412. $verifyDetail = $verify->getOne ( array (
  8413. 'where' => ' vid =' . $receiptDetail ['verify'],
  8414. 'asArray' => true
  8415. ) );
  8416. $verifyString = $verifyDetail ['staff'];
  8417. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  8418. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  8419. if (empty ( $opinion )) {
  8420. if ($status == 3)
  8421. $opinion = "终止";
  8422. else
  8423. $opinion = "同意支付";
  8424. }
  8425. $nowStaff = 0;
  8426. $nowStaffList = array ();
  8427. if (empty ( $verifyStaff )) {
  8428. // 还需加入是否已经进入角色审批
  8429. if ($verifyDetail [0] [1] == 'ROLE') {
  8430. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  8431. foreach ( $vStaffString as $key => $value ) {
  8432. $staffK = explode ( "_", $value );
  8433. if ($staffK [0] != $this->staff [0] ['sid'])
  8434. array_push ( $nowStaffList, $staffK [0] );
  8435. }
  8436. // print_r($verifyDetail);
  8437. // die;
  8438. if (! empty ( $nowStaffList )) {
  8439. $nowStaff = implode ( ',', $nowStaffList );
  8440. $verifyStaff = array (
  8441. $this->staff [0] ['sid'] . "_R" => array (
  8442. 'date' => date ( 'Y-m-d' ),
  8443. 'opinion' => $opinion,
  8444. 'status' => $status,
  8445. 'nextStaff' => $verifyDetail [0] [0],
  8446. 'ROLE' => 1
  8447. )
  8448. );
  8449. } else {
  8450. $nowStaff = $verifyDetail [1] [0];
  8451. $verifyStaff = array (
  8452. $this->staff [0] ['sid'] . "_R" => array (
  8453. 'date' => date ( 'Y-m-d' ),
  8454. 'opinion' => $opinion,
  8455. 'status' => $status,
  8456. 'nextStaff' => $verifyDetail [1] [0]
  8457. )
  8458. );
  8459. }
  8460. } else {
  8461. if ($verifyDetail [1] [1] == 'ROLE') {
  8462. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  8463. // echo "dd";
  8464. foreach ( $vStaffString as $key => $value ) {
  8465. $staffK = explode ( "_", $value );
  8466. array_push ( $nowStaffList, $staffK [0] );
  8467. }
  8468. $nowStaff = implode ( ',', $nowStaffList );
  8469. $verifyStaff = array (
  8470. $this->staff [0] ['sid'] => array (
  8471. 'date' => date ( 'Y-m-d' ),
  8472. 'opinion' => $opinion,
  8473. 'status' => $status,
  8474. 'nextStaff' => $verifyDetail [1] [0],
  8475. 'ROLE' => 1
  8476. )
  8477. );
  8478. } else {
  8479. $nowStaff = $verifyDetail [1] [0];
  8480. $verifyStaff = array (
  8481. $this->staff [0] ['sid'] => array (
  8482. 'date' => date ( 'Y-m-d' ),
  8483. 'opinion' => $opinion,
  8484. 'status' => $status,
  8485. 'nextStaff' => $verifyDetail [1] [0]
  8486. )
  8487. );
  8488. }
  8489. }
  8490. if ($status == 3)
  8491. $verifyStaff = array (
  8492. 'final' => $status,
  8493. $this->staff [0] ['sid'] => array (
  8494. 'date' => date ( 'Y-m-d' ),
  8495. 'opinion' => $opinion,
  8496. 'status' => $status
  8497. )
  8498. );
  8499. $vStaffString = json_encode ( $verifyStaff );
  8500. $receipt->nowStaff = $nowStaff;
  8501. $receipt->verifyStaff = $vStaffString;
  8502. } else {
  8503. $VS = end ( $verifyStaff );
  8504. // 非角色审批
  8505. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  8506. $nextStaff = 0;
  8507. $roleSTF = false;
  8508. foreach ( $verifyDetail as $key => $value ) {
  8509. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  8510. if (isset ( $verifyDetail [$key + 1] )) {
  8511. $nextStaff = $verifyDetail [$key + 1] [0];
  8512. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  8513. $roleSTF = true;
  8514. }
  8515. break;
  8516. }
  8517. }
  8518. if (! $roleSTF) {
  8519. $nowStaff = $nextStaff;
  8520. $verifyStaff [$this->staff [0] ['sid']] = array (
  8521. 'date' => date ( 'Y-m-d' ),
  8522. 'opinion' => $opinion,
  8523. 'status' => $status,
  8524. 'nextStaff' => $nextStaff
  8525. );
  8526. } else {
  8527. // 获取角色下的所有用户ID
  8528. $nowStaffList = array ();
  8529. foreach ( $verifyDetail as $vfk ) {
  8530. if ($vfk [1] == 'ROLE') {
  8531. $vStaffString = json_decode ( $vfk [3] );
  8532. foreach ( $vStaffString as $key => $value ) {
  8533. $staffK = explode ( "_", $value );
  8534. array_push ( $nowStaffList, $staffK [0] );
  8535. }
  8536. }
  8537. }
  8538. $nowStaff = implode ( ',', $nowStaffList );
  8539. $verifyStaff [$this->staff [0] ['sid']] = array (
  8540. 'date' => date ( 'Y-m-d' ),
  8541. 'opinion' => $opinion,
  8542. 'status' => $status,
  8543. 'nextStaff' => $nextStaff,
  8544. 'ROLE' => 0
  8545. );
  8546. }
  8547. if ($status == 3) {
  8548. $verifyStaff ['final'] = $status;
  8549. $verifyStaff [$this->staff [0] ['sid']] = array (
  8550. 'date' => date ( 'Y-m-d' ),
  8551. 'opinion' => $opinion,
  8552. 'status' => $status
  8553. );
  8554. }
  8555. $vStaffString = json_encode ( $verifyStaff );
  8556. $receipt->nowStaff = $nowStaff;
  8557. $receipt->verifyStaff = $vStaffString;
  8558. }
  8559. // 角色审批
  8560. if (isset ( $VS ['ROLE'] )) {
  8561. // 找出角色人 当前审批角色组
  8562. $verifyJSStaff = array ();
  8563. $nowStaffList2 = array ();
  8564. foreach ( $verifyDetail as $key => $value ) {
  8565. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  8566. $verifyJSStaff = json_decode ( $value [3] );
  8567. foreach ( $verifyJSStaff as $m ) {
  8568. $staffK = explode ( "_", $m );
  8569. array_push ( $nowStaffList2, $staffK [0] );
  8570. }
  8571. // print_r($nowStaffList2);
  8572. }
  8573. }
  8574. $RoleVerifyStaff = array ();
  8575. foreach ( $verifyStaff as $key => $value ) {
  8576. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  8577. foreach ( $nowStaffList2 as $m ) {
  8578. if ($key == $m . "_R")
  8579. $RoleVerifyStaff [$key] = $value;
  8580. }
  8581. }
  8582. }
  8583. // print_r($verifyStaff);
  8584. // print_r($nowStaffList2);
  8585. // print_r($RoleVerifyStaff);
  8586. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  8587. // print_r($verifyJSStaff);
  8588. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  8589. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  8590. // 下一个审批人ID
  8591. $nextStaff = 0;
  8592. $falg = false;
  8593. foreach ( $verifyDetail as $key => $value ) {
  8594. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  8595. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  8596. $falg = true;
  8597. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  8598. $nowStaffList = array ();
  8599. foreach ( $vStaffString as $v ) {
  8600. $staffK = explode ( "_", $v );
  8601. array_push ( $nowStaffList, $staffK [0] );
  8602. }
  8603. $nowStaff = implode ( ',', $nowStaffList );
  8604. $nextStaff = $verifyDetail [$key + 1] [0];
  8605. } elseif (isset ( $verifyDetail [$key + 1] )) {
  8606. $nextStaff = $verifyDetail [$key + 1] [0];
  8607. $nowStaff = $nextStaff;
  8608. } else
  8609. $nowStaff = '';
  8610. break;
  8611. }
  8612. }
  8613. if ($falg)
  8614. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8615. 'date' => date ( 'Y-m-d' ),
  8616. 'opinion' => $opinion,
  8617. 'status' => $status,
  8618. 'nextStaff' => $nextStaff,
  8619. 'ROLE' => 1
  8620. );
  8621. else
  8622. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8623. 'date' => date ( 'Y-m-d' ),
  8624. 'opinion' => $opinion,
  8625. 'status' => $status,
  8626. 'nextStaff' => $nextStaff
  8627. );
  8628. // print_r($verifyStaff);
  8629. // echo $nowStaff;die;
  8630. } else { // 进入下一个角色或者审批人
  8631. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  8632. //
  8633. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  8634. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8635. 'date' => date ( 'Y-m-d' ),
  8636. 'opinion' => $opinion,
  8637. 'status' => $status,
  8638. 'nextStaff' => $VS ['nextStaff'],
  8639. 'ROLE' => 1
  8640. );
  8641. // print_r($verifyStaff);
  8642. // die;
  8643. }
  8644. if ($status == 3) {
  8645. $verifyStaff ['final'] = $status;
  8646. $verifyStaff [$this->staff [0] ['sid']] = array (
  8647. 'date' => date ( 'Y-m-d' ),
  8648. 'opinion' => $opinion,
  8649. 'status' => $status
  8650. );
  8651. }
  8652. $vStaffString = json_encode ( $verifyStaff );
  8653. $receipt->verifyStaff = $vStaffString;
  8654. $receipt->nowStaff = $nowStaff;
  8655. // die;
  8656. // }
  8657. // print_r($verifyStaff);
  8658. // die;
  8659. }
  8660. // print_r($verifyStaff);die;
  8661. }
  8662. // print_r($verifyDetail);
  8663. $roleKey = 0;
  8664. $roleId = 0;
  8665. $verifyDetailCopy = array ();
  8666. foreach ( $verifyDetail as $k => $v ) {
  8667. if ($v [1] == 'ROLE') {
  8668. $roleId = $v [0];
  8669. $roleVerify = json_decode ( $v [3], true );
  8670. $roleKey = $k;
  8671. $roleArray = array ();
  8672. foreach ( $roleVerify as $o => $p ) {
  8673. $staffID = explode ( '_', $p );
  8674. $exp = array (
  8675. 0 => $staffID [0],
  8676. 1 => $staffID [1]
  8677. );
  8678. array_push ( $roleArray, $exp );
  8679. }
  8680. $verifyDetailCopy [$v [0]] = $roleArray;
  8681. }
  8682. }
  8683. // print_r($verifyDetail);
  8684. foreach ( $verifyDetailCopy as $k => $v ) {
  8685. foreach ( $verifyDetail as $m => $n ) {
  8686. if ($n [0] == $k) {
  8687. array_splice ( $verifyDetail, $m, 1, $v );
  8688. }
  8689. }
  8690. }
  8691. // die;
  8692. // if (!empty($roleArray))
  8693. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  8694. // echo $roleId;
  8695. // print_r($verifyStaff);
  8696. // print_r($verifyDetail);
  8697. // die;
  8698. Doo::loadModel ( "receiptLog" );
  8699. $receiptLog = new receiptLog ();
  8700. // 审批日志
  8701. if (! isset ( $verifyStaff ['final'] )) {
  8702. if (! empty ( $roleId )) {
  8703. Doo::loadModel ( "role" );
  8704. $role = new role ();
  8705. $roleInfo = $role->getOne ( array (
  8706. 'where' => 'rid=' . $roleId,
  8707. 'asArray' => true
  8708. ) );
  8709. $receiptLog->rolename = $roleInfo ['name'];
  8710. }
  8711. $receiptLog->username = $this->staff [0] ['username'];
  8712. $receiptLog->uid = $this->staff [0] ['sid'];
  8713. $receiptLog->date = date ( "Y-m-d" );
  8714. $receiptLog->opinion = $opinion;
  8715. $receiptLog->img = $this->staff [0] ['avatar'];
  8716. $receiptLog->status = 1;
  8717. $receiptLog->rid = $rid;
  8718. $receiptLog->insert ();
  8719. }
  8720. if (isset ( $verifyStaff ['final'] )) { // rDetail
  8721. $receipt->verifyBreakup = $verifyString;
  8722. $receipt->status = 3;
  8723. $receiptDetailObj->status = 3;
  8724. $receiptDetailObj->update ( array (
  8725. 'where' => 'rid=' . $rid
  8726. ) );
  8727. if (! empty ( $roleId )) {
  8728. Doo::loadModel ( "role" );
  8729. $role = new role ();
  8730. $roleInfo = $role->getOne ( array (
  8731. 'where' => 'rid=' . $roleId,
  8732. 'asArray' => true
  8733. ) );
  8734. $receiptLog->rolename = $roleInfo ['name'];
  8735. }
  8736. $receiptLog->username = $this->staff [0] ['username'];
  8737. $receiptLog->uid = $this->staff [0] ['sid'];
  8738. $receiptLog->date = date ( "Y-m-d" );
  8739. $receiptLog->opinion = $opinion;
  8740. $receiptLog->img = $this->staff [0] ['avatar'];
  8741. $receiptLog->status = 3;
  8742. $receiptLog->rid = $rid;
  8743. $receiptLog->insert ();
  8744. // 微信企业号通知
  8745. $this->setWXMsg ( $rid, 3 );
  8746. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  8747. $receipt->status = 1;
  8748. $reviseSum = 0;
  8749. $receipt->verifyBreakup = $verifyString;
  8750. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  8751. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8752. foreach ( $reviseDetail as $key => $value ) {
  8753. $receiptDetailObj = new receiptDetail ();
  8754. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8755. $receiptDetailObj->item = $value ['description'];
  8756. $receiptDetailObj->itemCategory = "报销金额调整";
  8757. $receiptDetailObj->price = $value ['price'];
  8758. $receiptDetailObj->date = $receiptDetail ['date'];
  8759. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  8760. $receiptDetailObj->rid = $rid;
  8761. $receiptDetailObj->status = 1;
  8762. $receiptDetailObj->insert ();
  8763. $reviseSum += $value ['price'];
  8764. }
  8765. $itemStatistics = new itemStatistics ();
  8766. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  8767. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8768. $itemStatistics->price = $reviseSum;
  8769. $itemStatistics->itemCategory = "报销金额调整";
  8770. $itemStatistics->date = $receiptDetail ['date'];
  8771. $itemStatistics->insert ();
  8772. }
  8773. $receiptDetailObj = new receiptDetail ();
  8774. $receiptDetailObj->status = 1;
  8775. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  8776. $receiptDetailObj->update ( array (
  8777. 'where' => 'rid=' . $rid
  8778. ) );
  8779. $dateArray = explode ( "-", $receiptDetail ['date'] );
  8780. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  8781. $stat = $statistics->getOne ( array (
  8782. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  8783. 'asArray' => true
  8784. ) );
  8785. if (empty ( $stat )) {
  8786. $statistics->date = $receiptDetail ['date'];
  8787. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  8788. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8789. $statistics->agPrice = $receiptDetail ['sum'];
  8790. $statistics->rePrice = $reviseSum;
  8791. $statistics->insert ();
  8792. } else {
  8793. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  8794. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  8795. $statistics->update ( array (
  8796. 'where' => 'sid=' . $stat ['sid']
  8797. ) );
  8798. }
  8799. $dateArray = explode ( "-", $receiptDetail ['date'] );
  8800. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  8801. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  8802. foreach ( $accountItem ['cSum'] as $key => $value ) {
  8803. if ($key == "agencySum") {
  8804. $iStatistics = $itemStatistics->getOne ( array (
  8805. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  8806. 'asArray' => true
  8807. ) );
  8808. if (empty ( $iStatistics )) {
  8809. $itemStatistics->cid = $receiptDetail ['cid'];
  8810. ;
  8811. $itemStatistics->staff = $receiptDetail ['staff'];
  8812. $itemStatistics->price = $value;
  8813. $itemStatistics->itemCategory = $this->AGENCY;
  8814. $itemStatistics->date = $receiptDetail ['date'];
  8815. $itemStatistics->insert ();
  8816. } else {
  8817. if (! empty ( $value )) {
  8818. $itemStatistics->price = $value + $iStatistics ['price'];
  8819. $itemStatistics->update ( array (
  8820. 'where' => 'sid=' . $iStatistics ['sid']
  8821. ) );
  8822. }
  8823. }
  8824. } elseif ($key == "travelSum") {
  8825. $iStatistics = $itemStatistics->getOne ( array (
  8826. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  8827. 'asArray' => true
  8828. ) );
  8829. if (empty ( $iStatistics )) {
  8830. $itemStatistics->cid = $receiptDetail ['cid'];
  8831. $itemStatistics->staff = $receiptDetail ['staff'];
  8832. $itemStatistics->price = $value;
  8833. $itemStatistics->itemCategory = $this->TRAVEL;
  8834. $itemStatistics->date = $receiptDetail ['date'];
  8835. $itemStatistics->insert ();
  8836. } else {
  8837. if (! empty ( $value )) {
  8838. $itemStatistics->price = $value + $iStatistics ['price'];
  8839. $itemStatistics->update ( array (
  8840. 'where' => 'sid=' . $iStatistics ['sid']
  8841. ) );
  8842. }
  8843. }
  8844. } elseif ($key == "trainSum") {
  8845. $iStatistics = $itemStatistics->getOne ( array (
  8846. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  8847. 'asArray' => true
  8848. ) );
  8849. if (empty ( $iStatistics )) {
  8850. $itemStatistics->cid = $receiptDetail ['cid'];
  8851. $itemStatistics->staff = $receiptDetail ['staff'];
  8852. $itemStatistics->price = $value;
  8853. $itemStatistics->itemCategory = $this->TRAIN;
  8854. $itemStatistics->date = $receiptDetail ['date'];
  8855. $itemStatistics->insert ();
  8856. } else {
  8857. if (! empty ( $value )) {
  8858. $itemStatistics->price = $value + $iStatistics ['price'];
  8859. $itemStatistics->update ( array (
  8860. 'where' => 'sid=' . $iStatistics ['sid']
  8861. ) );
  8862. }
  8863. }
  8864. } elseif ($key == "otherSum") {
  8865. $iStatistics = $itemStatistics->getOne ( array (
  8866. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  8867. 'asArray' => true
  8868. ) );
  8869. if (empty ( $iStatistics )) {
  8870. $itemStatistics->cid = $receiptDetail ['cid'];
  8871. $itemStatistics->staff = $receiptDetail ['staff'];
  8872. $itemStatistics->price = $value;
  8873. $itemStatistics->itemCategory = $this->OTHER;
  8874. $itemStatistics->date = $receiptDetail ['date'];
  8875. $itemStatistics->insert ();
  8876. } else {
  8877. if (! empty ( $value )) {
  8878. $itemStatistics->price = $value + $iStatistics ['price'];
  8879. $itemStatistics->update ( array (
  8880. 'where' => 'sid=' . $iStatistics ['sid']
  8881. ) );
  8882. }
  8883. }
  8884. }
  8885. }
  8886. $receipt->pastDate = date ( "Y-m-d" );
  8887. // 微信企业号通知
  8888. $this->setWXMsg ( $rid, 1 );
  8889. }
  8890. //是否有流水
  8891. Doo::loadModel ( 'wasteBook' );
  8892. $wasteBook = new wasteBook ();
  8893. $accountType=3;
  8894. if ($receiptDetail['Rtype']==1){
  8895. $accountType=2;
  8896. }elseif($receiptDetail['Rtype']==2){
  8897. $accountType=4;
  8898. }
  8899. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $rid );
  8900. if (empty($wbDetail)){
  8901. $rsum=$receiptDetail['sum']-$receiptDetail['loanSum'];
  8902. $receipt->amount = $rsum;//$amount;
  8903. }
  8904. $receipt->update ( array (
  8905. 'where' => ' rid = ' . $rid
  8906. ) );
  8907. // 进入下一条审批费用新加需求
  8908. $vidList = array ();
  8909. $verifyDetail = $verify->find ( array (
  8910. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  8911. 'asArray' => true
  8912. ) );
  8913. foreach ( $verifyDetail as $key => $value ) {
  8914. array_push ( $vidList, $value ['vid'] );
  8915. }
  8916. $vid = implode ( ",", $vidList );
  8917. if (empty ( $verifyDetail ))
  8918. $vid = 0;
  8919. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  8920. $receipt = new receipt ();
  8921. $rd = $receipt->getOne ( array (
  8922. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ') and Rtype!=3',
  8923. 'asc' => 'rid',
  8924. 'asArray' => true
  8925. ) );
  8926. if (empty ( $rd )) {
  8927. return '/approvalExpenses/pendApproval';
  8928. }
  8929. if ($rd ['Rtype'] == 1) {
  8930. if ($rd ['isBK'] == 1) {
  8931. return '/receiptburEdi/' . $rd ['rid'];
  8932. } else {
  8933. return '/expensesEdi/' . $rd ['rid'];
  8934. }
  8935. } elseif ($rd ['Rtype'] == 2) {
  8936. return '/remitApproval/' . $rd ['rid'];
  8937. } else {
  8938. return '/receiptburEdi/' . $rd ['rid'];
  8939. }
  8940. // return "/approvalExpenses/pendApproval";
  8941. }
  8942. }
  8943. function expensesRetreats() {
  8944. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  8945. if (! empty ( $rid )) {
  8946. // 操作记录
  8947. Doo::loadModel ( "receipt" );
  8948. $receipt = new receipt ();
  8949. Doo::loadModel ( "receiptLog" );
  8950. $receiptLog = new receiptLog ();
  8951. Doo::loadModel ( "verify" );
  8952. $verify = new verify ();
  8953. $receiptInfo = $receipt->getOne ( array (
  8954. 'where' => 'rid=' . $rid,
  8955. 'asArray' => true
  8956. ) );
  8957. $vr = $verify->getOne ( array (
  8958. 'where' => 'vid=' . $receiptInfo ['verify'],
  8959. 'asArray' => true
  8960. ) );
  8961. $jd = json_decode ( $vr ['staff'] );
  8962. $roleId = 0;
  8963. foreach ( $jd as $key => $value ) {
  8964. if ($value [1] == 'ROLE') {
  8965. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  8966. if ($pos !== false) {
  8967. $roleId = $value [0];
  8968. }
  8969. }
  8970. }
  8971. // 审批日志
  8972. // echo $roleId;die;
  8973. if (! empty ( $roleId )) {
  8974. Doo::loadModel ( "role" );
  8975. $role = new role ();
  8976. $roleInfo = $role->getOne ( array (
  8977. 'where' => 'rid=' . $roleId,
  8978. 'asArray' => true
  8979. ) );
  8980. $receiptLog->rolename = $roleInfo ['name'];
  8981. }
  8982. $receiptLog->username = $this->staff [0] ['username'];
  8983. $receiptLog->uid = $this->staff [0] ['sid'];
  8984. $receiptLog->date = date ( "Y-m-d" );
  8985. $receiptLog->opinion = '撤回';
  8986. $receiptLog->img = $this->staff [0] ['avatar'];
  8987. $receiptLog->status = 4;
  8988. $receiptLog->rid = $rid;
  8989. $receiptLog->insert ();
  8990. $receipt->status = 4;
  8991. $receipt->update ( array (
  8992. 'where' => 'rid=' . $rid
  8993. ) );
  8994. // 微信企业号通知
  8995. $this->setWXMsg ( $rid, 2 );
  8996. }
  8997. // echo "ddd";
  8998. return '/approvalExpenses/pendApproval';
  8999. }
  9000. function updateCheReceipt() {
  9001. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9002. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  9003. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  9004. if (! empty ( $rid )) {
  9005. // 操作记录
  9006. Doo::loadModel ( "receipt" );
  9007. $receipt = new receipt ();
  9008. Doo::loadModel ( "receiptLog" );
  9009. $receiptLog = new receiptLog ();
  9010. Doo::loadModel ( "verify" );
  9011. $verify = new verify ();
  9012. $receiptInfo = $receipt->getOne ( array (
  9013. 'where' => 'rid=' . $rid . ' and status=2',
  9014. 'asArray' => true
  9015. ) );
  9016. if (empty ( $receiptInfo )) {
  9017. echo json_encode ( array (
  9018. 'status' => 2
  9019. ) );
  9020. die ();
  9021. }
  9022. $vr = $verify->getOne ( array (
  9023. 'where' => 'vid=' . $receiptInfo ['verify'],
  9024. 'asArray' => true
  9025. ) );
  9026. $jd = json_decode ( $vr ['staff'] );
  9027. $roleId = 0;
  9028. foreach ( $jd as $key => $value ) {
  9029. if ($value [1] == 'ROLE') {
  9030. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9031. if ($pos !== false) {
  9032. $roleId = $value [0];
  9033. }
  9034. }
  9035. }
  9036. // 审批日志
  9037. // echo $roleId;die;
  9038. if (! empty ( $roleId )) {
  9039. Doo::loadModel ( "role" );
  9040. $role = new role ();
  9041. $roleInfo = $role->getOne ( array (
  9042. 'where' => 'rid=' . $roleId,
  9043. 'asArray' => true
  9044. ) );
  9045. $receiptLog->rolename = $roleInfo ['name'];
  9046. }
  9047. $receiptLog->username = $this->staff [0] ['username'];
  9048. $receiptLog->uid = $this->staff [0] ['sid'];
  9049. $receiptLog->date = date ( "Y-m-d" );
  9050. $receiptLog->opinion = $opinion;
  9051. $receiptLog->img = $this->staff [0] ['avatar'];
  9052. $receiptLog->status = 4;
  9053. $receiptLog->rid = $rid;
  9054. $receiptLog->insert ();
  9055. $receipt->status = 4;
  9056. $receipt->update ( array (
  9057. 'where' => 'rid=' . $rid
  9058. ) );
  9059. // 微信企业号通知
  9060. $this->setWXMsg ( $rid, 2 );
  9061. echo json_encode ( array (
  9062. 'status' => 1
  9063. ) );
  9064. // Header("HTTP/1.1 303 See Other");
  9065. // Header("Location: /approvalExpenses/pendApproval");
  9066. die ();
  9067. }
  9068. echo json_encode ( array (
  9069. 'status' => 2
  9070. ) );
  9071. die ();
  9072. // echo "ddd";
  9073. // return '/saeaBorad';
  9074. }
  9075. function revisePrice() {
  9076. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  9077. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  9078. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9079. // echo $price;die;
  9080. if (! empty ( $rid )) {
  9081. Doo::loadModel ( "receipt" );
  9082. $receipt = new receipt ();
  9083. $receiptDetail = $receipt->getOne ( array (
  9084. 'where' => 'rid=' . $rid . ' and status=2 ',
  9085. 'asArray' => true
  9086. ) );
  9087. if (empty ( $receiptDetail ))
  9088. die ( 'illegal request' );
  9089. $reviseDetail = array ();
  9090. if (empty ( $receiptDetail ['reviseDetail'] )) {
  9091. array_push ( $reviseDetail, array (
  9092. 'sid' => $this->staff [0] ['sid'],
  9093. 'name' => $this->staff [0] ['username'],
  9094. 'description' => $description,
  9095. 'price' => $price
  9096. ) );
  9097. $reviseDetailString = json_encode ( $reviseDetail );
  9098. $receipt->reviseDetail = $reviseDetailString;
  9099. $receipt->revisePrice = $price;
  9100. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9101. } else {
  9102. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9103. array_push ( $reviseDetail, array (
  9104. 'sid' => $this->staff [0] ['sid'],
  9105. 'name' => $this->staff [0] ['username'],
  9106. 'description' => $description,
  9107. 'price' => $price
  9108. ) );
  9109. $reviseDetailString = json_encode ( $reviseDetail );
  9110. $receipt->reviseDetail = $reviseDetailString;
  9111. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  9112. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9113. }
  9114. $receipt->update ( array (
  9115. 'where' => 'rid=' . $rid
  9116. ) );
  9117. if ($receiptDetail ['Rtype'] == 1) {
  9118. if ($receiptDetail ['isBK'] == 1) {
  9119. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9120. }
  9121. } elseif ($receiptDetail ['Rtype'] == 2) {
  9122. } else {
  9123. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9124. }
  9125. }
  9126. die ( 'illegal request' );
  9127. }
  9128. function personalCollect() {
  9129. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9130. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  9131. $this->showCache ( $path );
  9132. Doo::loadModel ( "receiptDetail" );
  9133. Doo::loadModel ( "itemStatistics" );
  9134. Doo::loadModel ( 'statistics' );
  9135. $statistics = new statistics ();
  9136. $itemStatistics = new itemStatistics ();
  9137. $receiptDetail = new receiptDetail ();
  9138. $receiptCollectList = $receiptDetail->find ( array (
  9139. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9140. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9141. 'groupby' => 'itemCategory,Month(date)',
  9142. 'asArray' => true
  9143. ) );
  9144. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  9145. 'where' => 'staff=' . $this->staff [0] ['sid'],
  9146. 'asArray' => true
  9147. ) );
  9148. // create collect html
  9149. $collectArray = array (
  9150. '日常相关费用' => array (),
  9151. '差旅相关费用' => array (),
  9152. '培训班费用' => array (),
  9153. '其他' => array ()
  9154. );
  9155. $adjustment = array ();
  9156. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  9157. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9158. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  9159. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9160. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  9161. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9162. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  9163. array_push ( $collectArray ['其他'], $collectHtml );
  9164. $data ['collectArray'] = $collectArray;
  9165. // statistics html
  9166. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9167. if (empty ( $stList ))
  9168. $stList = array (
  9169. 'rePrice' => 0,
  9170. 'agPrice' => 0
  9171. );
  9172. $data ['stList'] = array (
  9173. 'rePrice' => $stList ['rePrice'],
  9174. 'agPrice' => $stList ['agPrice'],
  9175. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9176. );
  9177. // Adjustment price html
  9178. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9179. array_push ( $adjustment, $collectHtml );
  9180. $data ['adjustment'] = $adjustment;
  9181. // total price html
  9182. $collectHtml = "";
  9183. $total = 0;
  9184. for($i = 1; $i <= 12; $i ++) {
  9185. $sumPrice = 0;
  9186. foreach ( $receiptCollectList as $key => $value ) {
  9187. if ($value ['month'] == $i) {
  9188. $sumPrice += $value ['price'];
  9189. }
  9190. }
  9191. if ($sumPrice == 0)
  9192. $collectHtml .= '<td class="taR">-</td>';
  9193. else
  9194. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9195. $total += $sumPrice;
  9196. }
  9197. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9198. $data ['totalPrice'] = $collectHtml;
  9199. $dateHtml = "";
  9200. $now = date ( "Y" );
  9201. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9202. if ($YEARD <= $now) {
  9203. $dateHtml .= '<option ';
  9204. if ($year == $YEARD) {
  9205. $dateHtml .= 'selected ';
  9206. }
  9207. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9208. }
  9209. }
  9210. $data ['dateHtml'] = $dateHtml;
  9211. $data ['year'] = $year;
  9212. $data ['totalYear'] = $total;
  9213. $data ['memu'] = "receipt";
  9214. $data ['staff'] = $this->staff;
  9215. $data ['receiptMemu'] = 'personalCollect';
  9216. $data ['verifyId'] = $this->verifyId;
  9217. $data ['executeId'] = $this->executeId;
  9218. // year staff status 2,4
  9219. if ($year < date ( "Y" )) {
  9220. Doo::loadModel ( 'receipt' );
  9221. $receipt = new receipt ();
  9222. $receiptList = $receipt->find ( array (
  9223. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9224. 'asArray' => true
  9225. ) );
  9226. if (empty ( $receiptList )) {
  9227. ob_start ();
  9228. $this->render ( "/admin/saea_slist_collect", $data );
  9229. $this->cacheFile ( $path );
  9230. die ();
  9231. }
  9232. }
  9233. $this->render ( "/admin/saea_slist_collect", $data );
  9234. }
  9235. function personalCollectDetail() {
  9236. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9237. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  9238. $this->showCache ( $path );
  9239. Doo::loadModel ( "receiptDetail" );
  9240. Doo::loadModel ( "itemStatistics" );
  9241. Doo::loadModel ( 'statistics' );
  9242. Doo::loadModel ( 'accountItem' );
  9243. $accountItem = new accountItem ();
  9244. $statistics = new statistics ();
  9245. $itemStatistics = new itemStatistics ();
  9246. $receiptDetail = new receiptDetail ();
  9247. $receiptCollectList = $receiptDetail->find ( array (
  9248. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9249. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9250. 'groupby' => 'item,Month(date)',
  9251. 'asArray' => true
  9252. ) );
  9253. $accountList = $accountItem->find ( array (
  9254. 'asArray' => true
  9255. ) );
  9256. // create CollectDetail HTML
  9257. $collectHtml = array ();
  9258. foreach ( $accountList as $key => $value ) {
  9259. $html = "";
  9260. $asum = 0;
  9261. for($i = 1; $i <= 12; $i ++) {
  9262. $falg = true;
  9263. foreach ( $receiptCollectList as $v ) {
  9264. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9265. $asum += $v ['price'];
  9266. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9267. $falg = false;
  9268. break;
  9269. }
  9270. }
  9271. if ($falg)
  9272. $html .= '<td class="taR">-</td>';
  9273. }
  9274. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9275. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9276. }
  9277. $data ['collectHtml'] = $collectHtml;
  9278. // create Adjustment price html
  9279. $receiptCollectList = $receiptDetail->find ( array (
  9280. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9281. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9282. 'groupby' => 'itemCategory,Month(date)',
  9283. 'asArray' => true
  9284. ) );
  9285. $adjustment = array ();
  9286. $collectArray = array (
  9287. '日常相关费用' => array (),
  9288. '差旅相关费用' => array (),
  9289. '培训班费用' => array (),
  9290. '其他' => array ()
  9291. );
  9292. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9293. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9294. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9295. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9296. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9297. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9298. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9299. array_push ( $collectArray ['其他'], $collectHtml );
  9300. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9301. array_push ( $adjustment, $collectHtml );
  9302. // total price html
  9303. $collectHtml = "";
  9304. $total = 0;
  9305. for($i = 1; $i <= 12; $i ++) {
  9306. $sumPrice = 0;
  9307. foreach ( $receiptCollectList as $key => $value ) {
  9308. if ($value ['month'] == $i) {
  9309. $sumPrice += $value ['price'];
  9310. }
  9311. }
  9312. if ($sumPrice == 0)
  9313. $collectHtml .= '<td class="taR">-</td>';
  9314. else
  9315. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9316. $total += $sumPrice;
  9317. }
  9318. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9319. // statistics html
  9320. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9321. if (empty ( $stList ))
  9322. $stList = array (
  9323. 'rePrice' => 0,
  9324. 'agPrice' => 0
  9325. );
  9326. $data ['stList'] = array (
  9327. 'rePrice' => $stList ['rePrice'],
  9328. 'agPrice' => $stList ['agPrice'],
  9329. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9330. );
  9331. $data ['collectArray'] = $collectArray;
  9332. $data ['adjustment'] = $adjustment;
  9333. $data ['totalPrice'] = $collectHtml;
  9334. $data ['totalYear'] = $total;
  9335. $data ['year'] = $year;
  9336. $dateHtml = "";
  9337. $now = date ( "Y" );
  9338. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9339. if ($YEARD <= $now) {
  9340. $dateHtml .= '<option ';
  9341. if ($year == $YEARD) {
  9342. $dateHtml .= 'selected ';
  9343. }
  9344. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9345. }
  9346. }
  9347. $data ['dateHtml'] = $dateHtml;
  9348. $data ['memu'] = "receipt";
  9349. $data ['staff'] = $this->staff;
  9350. $data ['receiptMemu'] = 'personalCollect';
  9351. $data ['verifyId'] = $this->verifyId;
  9352. $data ['executeId'] = $this->executeId;
  9353. // year staff status 2,4
  9354. if ($year < date ( "Y" )) {
  9355. Doo::loadModel ( 'receipt' );
  9356. $receipt = new receipt ();
  9357. $receiptList = $receipt->find ( array (
  9358. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9359. 'asArray' => true
  9360. ) );
  9361. if (empty ( $receiptList )) {
  9362. ob_start ();
  9363. $this->render ( "/admin/saeaCollectArticles", $data );
  9364. $this->cacheFile ( $path );
  9365. die ();
  9366. }
  9367. }
  9368. $this->render ( "/admin/saeaCollectArticles", $data );
  9369. }
  9370. function companyCategoryCollect() {
  9371. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9372. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  9373. $this->showCache ( $path );
  9374. Doo::loadModel ( 'L_category' );
  9375. Doo::loadModel ( 'itemStatistics' );
  9376. Doo::loadModel ( 'statistics' );
  9377. $statistics = new statistics ();
  9378. $Lcategory = new L_category ();
  9379. $itemStatistics = new itemStatistics ();
  9380. Doo::loadModel ( "receiptAuthorityManage" );
  9381. $receiptAuthorityManage = new receiptAuthorityManage ();
  9382. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9383. $cidList = array ();
  9384. foreach ( $imcStaff as $key => $value ) {
  9385. array_push ( $cidList, $value ['cid'] );
  9386. }
  9387. $cidString = implode ( ',', $cidList );
  9388. $LcategoryList = $Lcategory->find ( array (
  9389. 'where' => ' cid in (' . $cidString . ')',
  9390. 'asArray' => true
  9391. ) ); // 'staff='.$this->staff[0]['sid']." and
  9392. $itemStatisticsList = $itemStatistics->find ( array (
  9393. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9394. 'where' => " Year(date)=" . $year,
  9395. 'groupby' => 'cid,Month(date)',
  9396. 'asArray' => true
  9397. ) );
  9398. // ceatre companyCollectHtml
  9399. foreach ( $LcategoryList as $value ) {
  9400. $html = "";
  9401. $asum = 0;
  9402. for($i = 1; $i <= 12; $i ++) {
  9403. $falg = true;
  9404. foreach ( $itemStatisticsList as $v ) {
  9405. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  9406. $asum += $v ['price'];
  9407. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9408. $falg = false;
  9409. break;
  9410. }
  9411. }
  9412. if ($falg)
  9413. $html .= '<td class="taR">-</td>';
  9414. }
  9415. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9416. $collectHtml [$value ['title']] = array (
  9417. 'html' => $html,
  9418. 'cid' => $value ['cid']
  9419. );
  9420. }
  9421. $data ['companyHtml'] = $collectHtml;
  9422. // total price html
  9423. $collectHtml = "";
  9424. $total = 0;
  9425. for($i = 1; $i <= 12; $i ++) {
  9426. $sumPrice = 0;
  9427. foreach ( $itemStatisticsList as $key => $value ) {
  9428. if ($value ['month'] == $i) {
  9429. $sumPrice += $value ['price'];
  9430. }
  9431. }
  9432. if ($sumPrice == 0)
  9433. $collectHtml .= '<td class="taR">-</td>';
  9434. else
  9435. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9436. $total += $sumPrice;
  9437. }
  9438. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9439. $data ['companyTotalHtml'] = $collectHtml;
  9440. $data ['total'] = $total;
  9441. // statistics html
  9442. // echo $cidString;
  9443. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9444. if (empty ( $stList ))
  9445. $stList = array (
  9446. 'rePrice' => 0,
  9447. 'agPrice' => 0
  9448. );
  9449. $data ['stList'] = array (
  9450. 'rePrice' => $stList ['rePrice'],
  9451. 'agPrice' => $stList ['agPrice'],
  9452. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9453. );
  9454. $data ['year'] = $year;
  9455. $data ['memu'] = "receipt";
  9456. $data ['staff'] = $this->staff;
  9457. $data ['receiptMemu'] = 'companyCategoryCollect';
  9458. $data ['verifyId'] = $this->verifyId;
  9459. $data ['executeId'] = $this->executeId;
  9460. $dateHtml = "";
  9461. $now = date ( "Y" );
  9462. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9463. if ($YEARD <= $now) {
  9464. $dateHtml .= '<option ';
  9465. if ($year == $YEARD) {
  9466. $dateHtml .= 'selected ';
  9467. }
  9468. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9469. }
  9470. }
  9471. $data ['dateHtml'] = $dateHtml;
  9472. // year staff status 2,4
  9473. if ($year < date ( "Y" )) {
  9474. Doo::loadModel ( 'receipt' );
  9475. $receipt = new receipt ();
  9476. $receiptList = $receipt->find ( array (
  9477. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  9478. 'asArray' => true
  9479. ) );
  9480. if (empty ( $receiptList )) {
  9481. ob_start ();
  9482. $this->render ( "/admin/saeaCompanyCollect", $data );
  9483. $this->cacheFile ( $path );
  9484. die ();
  9485. }
  9486. }
  9487. $this->render ( "/admin/saeaCompanyCollect", $data );
  9488. }
  9489. function categoryCollectDetail() {
  9490. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9491. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  9492. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  9493. $this->showCache ( $path );
  9494. Doo::loadModel ( 'statistics' );
  9495. $statistics = new statistics ();
  9496. Doo::loadModel ( "receiptDetail" );
  9497. $receiptDetail = new receiptDetail ();
  9498. Doo::loadModel ( 'L_category' );
  9499. $Lcategory = new L_category ();
  9500. Doo::loadModel ( 'accountItem' );
  9501. $accountItem = new accountItem ();
  9502. Doo::loadModel ( "receiptAuthorityManage" );
  9503. $receiptAuthorityManage = new receiptAuthorityManage ();
  9504. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9505. $cidList = array ();
  9506. foreach ( $imcStaff as $key => $value ) {
  9507. array_push ( $cidList, $value ['cid'] );
  9508. }
  9509. $cidString = implode ( ',', $cidList );
  9510. $LcategoryList = $Lcategory->find ( array (
  9511. 'where' => 'cid in (' . $cidString . ')',
  9512. 'asArray' => true
  9513. ) );
  9514. if ($cid == 0) {
  9515. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9516. if ($cid == 0)
  9517. $cid = $LcategoryList [0] ['cid'];
  9518. }
  9519. $data ['LcategoryList'] = $LcategoryList;
  9520. $receiptCollectList = $receiptDetail->find ( array (
  9521. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9522. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9523. 'groupby' => 'item,Month(pastDate)',
  9524. 'asArray' => true
  9525. ) );
  9526. $accountList = $accountItem->find ( array (
  9527. 'asArray' => true
  9528. ) );
  9529. // create CollectDetail HTML
  9530. $collectHtml = array ();
  9531. foreach ( $accountList as $key => $value ) {
  9532. $html = "";
  9533. $asum = 0;
  9534. for($i = 1; $i <= 12; $i ++) {
  9535. $falg = true;
  9536. foreach ( $receiptCollectList as $v ) {
  9537. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9538. $asum += $v ['price'];
  9539. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9540. $falg = false;
  9541. break;
  9542. }
  9543. }
  9544. if ($falg)
  9545. $html .= '<td class="taR">-</td>';
  9546. }
  9547. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9548. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9549. }
  9550. $data ['collectHtml'] = $collectHtml;
  9551. // create Adjustment price html
  9552. $receiptCollectList = $receiptDetail->find ( array (
  9553. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9554. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9555. 'groupby' => 'itemCategory,Month(pastDate)',
  9556. 'asArray' => true
  9557. ) );
  9558. $adjustment = array ();
  9559. $collectArray = array (
  9560. '日常相关费用' => array (),
  9561. '差旅相关费用' => array (),
  9562. '培训班费用' => array (),
  9563. '内部培训费用'=>array(),
  9564. '其他' => array ()
  9565. );
  9566. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9567. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9568. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9569. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9570. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9571. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9572. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  9573. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  9574. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9575. array_push ( $collectArray ['其他'], $collectHtml );
  9576. $data ['collectArray'] = $collectArray;
  9577. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9578. array_push ( $adjustment, $collectHtml );
  9579. $data ['adjustment'] = $adjustment;
  9580. // total price html
  9581. $collectHtml = "";
  9582. $total = 0;
  9583. for($i = 1; $i <= 12; $i ++) {
  9584. $sumPrice = 0;
  9585. foreach ( $receiptCollectList as $key => $value ) {
  9586. if ($value ['month'] == $i) {
  9587. $sumPrice += $value ['price'];
  9588. }
  9589. }
  9590. if ($sumPrice == 0)
  9591. $collectHtml .= '<td class="taR">-</td>';
  9592. else
  9593. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9594. $total += $sumPrice;
  9595. }
  9596. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9597. // statistics html
  9598. $stList = $statistics->statisticsByCid ( $year, $cid );
  9599. if (empty ( $stList ))
  9600. $stList = array (
  9601. 'rePrice' => 0,
  9602. 'agPrice' => 0
  9603. );
  9604. $data ['stList'] = array (
  9605. 'rePrice' => $stList ['rePrice'],
  9606. 'agPrice' => $stList ['agPrice'],
  9607. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9608. );
  9609. $data ['totalYear'] = $total;
  9610. $data ['year'] = $year;
  9611. $data ['cid'] = $cid;
  9612. $data ['memu'] = "receipt";
  9613. $data ['staff'] = $this->staff;
  9614. $data ['receiptMemu'] = 'companyCategoryCollect';
  9615. $data ['verifyId'] = $this->verifyId;
  9616. $data ['executeId'] = $this->executeId;
  9617. // year staff status 2,4
  9618. if ($year < date ( "Y" )) {
  9619. Doo::loadModel ( 'receipt' );
  9620. $receipt = new receipt ();
  9621. $receiptList = $receipt->find ( array (
  9622. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  9623. 'asArray' => true
  9624. ) );
  9625. if (empty ( $receiptList )) {
  9626. ob_start ();
  9627. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  9628. $this->cacheFile ( $path );
  9629. die ();
  9630. }
  9631. }
  9632. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  9633. }
  9634. function staffCollect() {
  9635. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9636. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ONJOB';//
  9637. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  9638. // $this->showCache($path);
  9639. Doo::loadModel ( 'statistics' );
  9640. $statistics = new statistics ();
  9641. Doo::loadModel ( "receiptDetail" );
  9642. $receiptDetail = new receiptDetail ();
  9643. Doo::loadModel ( 'L_category' );
  9644. $Lcategory = new L_category ();
  9645. Doo::loadModel ( 'accountItem' );
  9646. $accountItem = new accountItem ();
  9647. Doo::loadModel ( 'staff' );
  9648. $staff = new staff ();
  9649. Doo::loadModel ( 'itemStatistics' );
  9650. $itemStatistics = new itemStatistics ();
  9651. Doo::loadModel ( "receiptAuthorityManage" );
  9652. $receiptAuthorityManage = new receiptAuthorityManage ();
  9653. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9654. $cidList = array ();
  9655. foreach ( $imcStaff as $key => $value ) {
  9656. array_push ( $cidList, $value ['cid'] );
  9657. }
  9658. $cidString = implode ( ',', $cidList );
  9659. $naturecon='';
  9660. if ($nature=='ONJOB'){
  9661. $naturecon=' and (nature!=4 )';
  9662. }elseif($nature=='LEAVEJOB'){
  9663. $naturecon=' and (nature=4 )';
  9664. }else{
  9665. die ( 'illegal request--nature' );
  9666. }
  9667. // statistics html
  9668. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9669. if (empty ( $stList ))
  9670. $stList = array (
  9671. 'rePrice' => 0,
  9672. 'agPrice' => 0
  9673. );
  9674. $data ['stList'] = array (
  9675. 'rePrice' => $stList ['rePrice'],
  9676. 'agPrice' => $stList ['agPrice'],
  9677. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9678. );
  9679. // ---
  9680. $staffList = $staff->find ( array (
  9681. 'where' => 'username !="admin" '.$naturecon,
  9682. 'asArray' => true
  9683. ) );
  9684. $LcategoryList = $Lcategory->find ( array (
  9685. 'asArray' => true
  9686. ) ); // 'staff='.$this->staff[0]['sid']." and
  9687. $itemStatisticsList = $itemStatistics->find ( array (
  9688. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9689. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  9690. 'groupby' => 'staff,Month(date)',
  9691. 'asArray' => true
  9692. ) );
  9693. $categoryList = $staff->find ( array (
  9694. 'select' => 'COUNT(*) as count,cid,category',
  9695. 'where' => 'username !="admin" and cid in (' . $cidString . ') '.$naturecon,
  9696. 'groupby' => 'cid',
  9697. 'asArray' => true
  9698. ) );
  9699. // print_r($itemStatisticsList);die;
  9700. // ceatre companyCollectHtml
  9701. foreach ( $categoryList as $vlu ) {
  9702. $count = $vlu ['count'] + 1;
  9703. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  9704. $m1 = 0;
  9705. $m2 = 0;
  9706. $m3 = 0;
  9707. $m4 = 0;
  9708. $m5 = 0;
  9709. $m6 = 0;
  9710. $m7 = 0;
  9711. $m8 = 0;
  9712. $m9 = 0;
  9713. $m10 = 0;
  9714. $m11 = 0;
  9715. $m12 = 0;
  9716. $m13 = 0;
  9717. foreach ( $staffList as $value ) {
  9718. if ($vlu ['cid'] == $value ['cid']) {
  9719. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  9720. $asum = 0;
  9721. for($i = 1; $i <= 12; $i ++) {
  9722. $falg = true;
  9723. foreach ( $itemStatisticsList as $v ) {
  9724. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  9725. if ($v ['month'] == 1)
  9726. $m1 += $v ['price'];
  9727. if ($v ['month'] == 2)
  9728. $m2 += $v ['price'];
  9729. if ($v ['month'] == 3)
  9730. $m3 += $v ['price'];
  9731. if ($v ['month'] == 4)
  9732. $m4 += $v ['price'];
  9733. if ($v ['month'] == 5)
  9734. $m5 += $v ['price'];
  9735. if ($v ['month'] == 6)
  9736. $m6 += $v ['price'];
  9737. if ($v ['month'] == 7)
  9738. $m7 += $v ['price'];
  9739. if ($v ['month'] == 8)
  9740. $m8 += $v ['price'];
  9741. if ($v ['month'] == 9)
  9742. $m9 += $v ['price'];
  9743. if ($v ['month'] == 10)
  9744. $m10 += $v ['price'];
  9745. if ($v ['month'] == 11)
  9746. $m11 += $v ['price'];
  9747. if ($v ['month'] == 12)
  9748. $m12 += $v ['price'];
  9749. $asum += $v ['price'];
  9750. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9751. $falg = false;
  9752. break;
  9753. }
  9754. }
  9755. if ($falg)
  9756. $html .= '<td class="taR">-</td>';
  9757. }
  9758. $m13 += $asum;
  9759. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9760. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  9761. 'html' => $html,
  9762. 'sid' => $value ['sid']
  9763. );
  9764. $html = "";
  9765. }
  9766. }
  9767. $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>
  9768. <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>
  9769. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  9770. $collectHtml [$vlu ['cid']] = array (
  9771. 'html' => $hl,
  9772. 'sid' => ''
  9773. );
  9774. }
  9775. $data ['companyHtml'] = $collectHtml;
  9776. // total price html
  9777. $collectHtml = "";
  9778. $total = 0;
  9779. for($i = 1; $i <= 12; $i ++) {
  9780. $sumPrice = 0;
  9781. foreach ( $itemStatisticsList as $key => $value ) {
  9782. if ($value ['month'] == $i) {
  9783. $sumPrice += $value ['price'];
  9784. }
  9785. }
  9786. if ($sumPrice == 0)
  9787. $collectHtml .= '<td class="taR">-</td>';
  9788. else
  9789. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9790. $total += $sumPrice;
  9791. }
  9792. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9793. $data ['companyTotalHtml'] = $collectHtml;
  9794. $data ['total'] = $total;
  9795. $data ['nature'] =$nature;
  9796. $data ['year'] = $year;
  9797. $data ['memu'] = "receipt";
  9798. $data ['staff'] = $this->staff;
  9799. $data ['receiptMemu'] = 'companyCategoryCollect';
  9800. $data ['verifyId'] = $this->verifyId;
  9801. $data ['executeId'] = $this->executeId;
  9802. if ($year <= date ( "Y" )) {
  9803. Doo::loadModel ( 'receipt' );
  9804. $receipt = new receipt ();
  9805. $receiptList = $receipt->find ( array (
  9806. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  9807. 'asArray' => true
  9808. ) );
  9809. if (empty ( $receiptList )) { // generated files
  9810. ob_start ();
  9811. $this->render ( "/admin/saeaStaffCollectB", $data );
  9812. $this->cacheFile ( $path );
  9813. die ();
  9814. }
  9815. }
  9816. $this->render ( "/admin/saeaStaffCollectB", $data );
  9817. }
  9818. function staffCollectBak() {
  9819. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9820. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  9821. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  9822. $this->showCache ( $path );
  9823. Doo::loadModel ( 'statistics' );
  9824. $statistics = new statistics ();
  9825. Doo::loadModel ( "receiptDetail" );
  9826. $receiptDetail = new receiptDetail ();
  9827. Doo::loadModel ( 'L_category' );
  9828. $Lcategory = new L_category ();
  9829. Doo::loadModel ( 'accountItem' );
  9830. $accountItem = new accountItem ();
  9831. Doo::loadModel ( 'staff' );
  9832. $staff = new staff ();
  9833. Doo::loadModel ( 'itemStatistics' );
  9834. $itemStatistics = new itemStatistics ();
  9835. $itemStatisticsList = $itemStatistics->find ( array (
  9836. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9837. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9838. 'groupby' => 'staff,itemCategory,Month(date)',
  9839. 'asArray' => true
  9840. ) );
  9841. $itemCategoryList = $itemStatistics->find ( array (
  9842. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9843. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9844. 'groupby' => 'cid,itemCategory,Month(date)',
  9845. 'asArray' => true
  9846. ) );
  9847. $LcategoryList = $Lcategory->find ( array (
  9848. 'asArray' => true
  9849. ) );
  9850. $staffList = $staff->find ( array (
  9851. 'asArray' => true
  9852. ) );
  9853. $htmlArray = array ();
  9854. foreach ( $LcategoryList as $value ) {
  9855. $htmlArray [$value ['title']] = array ();
  9856. foreach ( $staffList as $v ) {
  9857. if ($value ['cid'] == $v ['cid']) {
  9858. $html = "";
  9859. $falg = true;
  9860. $staffSumPrice = 0;
  9861. foreach ( $itemStatisticsList as $a ) {
  9862. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  9863. if (empty ( $a ['price'] )) {
  9864. $html .= '<td class="taR">-</td>';
  9865. $falg = false;
  9866. break;
  9867. } else {
  9868. $staffSumPrice += $a ['price'];
  9869. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9870. $falg = false;
  9871. break;
  9872. }
  9873. }
  9874. }
  9875. if ($falg) {
  9876. $html .= '<td class="taR">-</td>';
  9877. $falg = true;
  9878. }
  9879. $falg = true;
  9880. foreach ( $itemStatisticsList as $a ) {
  9881. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  9882. if (empty ( $a ['price'] )) {
  9883. $html .= '<td class="taR">-</td>';
  9884. $falg = false;
  9885. break;
  9886. } else {
  9887. $staffSumPrice += $a ['price'];
  9888. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9889. $falg = false;
  9890. break;
  9891. }
  9892. }
  9893. }
  9894. if ($falg) {
  9895. $html .= '<td class="taR">-</td>';
  9896. $falg = true;
  9897. }
  9898. $falg = true;
  9899. foreach ( $itemStatisticsList as $a ) {
  9900. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  9901. if (empty ( $a ['price'] )) {
  9902. $html .= '<td class="taR">-</td>';
  9903. $falg = false;
  9904. break;
  9905. } else {
  9906. $staffSumPrice += $a ['price'];
  9907. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9908. $falg = false;
  9909. break;
  9910. }
  9911. }
  9912. }
  9913. if ($falg) {
  9914. $html .= '<td class="taR">-</td>';
  9915. $falg = true;
  9916. }
  9917. $falg = true;
  9918. foreach ( $itemStatisticsList as $a ) {
  9919. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  9920. if (! empty ( $a ['price'] )) {
  9921. $staffSumPrice += $a ['price'];
  9922. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9923. $falg = false;
  9924. break;
  9925. } else {
  9926. $html .= '<td class="taR">-</td>';
  9927. $falg = false;
  9928. break;
  9929. }
  9930. }
  9931. }
  9932. if ($falg) {
  9933. $html .= '<td class="taR">-</td>';
  9934. $falg = true;
  9935. }
  9936. $falg = true;
  9937. foreach ( $itemStatisticsList as $a ) {
  9938. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  9939. if (! empty ( $a ['price'] )) {
  9940. $staffSumPrice += $a ['price'];
  9941. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9942. $falg = false;
  9943. break;
  9944. } else {
  9945. $html .= '<td class="taR">-</td>';
  9946. $falg = false;
  9947. break;
  9948. }
  9949. }
  9950. }
  9951. if ($falg) {
  9952. $html .= '<td class="taR">-</td>';
  9953. $falg = true;
  9954. }
  9955. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  9956. $htmlArray [$value ['title']] [$v ['username']] = $html;
  9957. }
  9958. }
  9959. /* -- --- */
  9960. // 合计费用
  9961. $cateHtml = "";
  9962. $catePrice = 0;
  9963. $cateFalg = true;
  9964. foreach ( $itemCategoryList as $l ) {
  9965. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  9966. if (empty ( $l ['price'] )) {
  9967. $cateHtml .= '<td class="colGreen taR">-</td>';
  9968. $cateFalg = false;
  9969. break;
  9970. } else {
  9971. $catePrice += $l ['price'];
  9972. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9973. $cateFalg = false;
  9974. break;
  9975. }
  9976. }
  9977. }
  9978. if ($cateFalg) {
  9979. $cateHtml .= '<td class="colGreen taR">-</td>';
  9980. $cateFalg = true;
  9981. }
  9982. $cateFalg = true;
  9983. foreach ( $itemCategoryList as $l ) {
  9984. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  9985. if (empty ( $l ['price'] )) {
  9986. $cateHtml .= '<td class="colGreen taR">-</td>';
  9987. $cateFalg = false;
  9988. break;
  9989. } else {
  9990. $catePrice += $l ['price'];
  9991. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9992. $cateFalg = false;
  9993. break;
  9994. }
  9995. }
  9996. }
  9997. if ($cateFalg) {
  9998. $cateHtml .= '<td class="colGreen taR">-</td>';
  9999. $cateFalg = true;
  10000. }
  10001. $cateFalg = true;
  10002. foreach ( $itemCategoryList as $l ) {
  10003. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  10004. if (empty ( $l ['price'] )) {
  10005. $cateHtml .= '<td class="colGreen taR">-</td>';
  10006. $cateFalg = false;
  10007. break;
  10008. } else {
  10009. $catePrice += $l ['price'];
  10010. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10011. $cateFalg = false;
  10012. break;
  10013. }
  10014. }
  10015. }
  10016. if ($cateFalg) {
  10017. $cateHtml .= '<td class="colGreen taR">-</td>';
  10018. $cateFalg = true;
  10019. }
  10020. $cateFalg = true;
  10021. foreach ( $itemCategoryList as $l ) {
  10022. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  10023. if (empty ( $l ['price'] )) {
  10024. $cateHtml .= '<td class="colGreen taR">-</td>';
  10025. $cateFalg = false;
  10026. break;
  10027. } else {
  10028. $catePrice += $l ['price'];
  10029. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10030. $cateFalg = false;
  10031. break;
  10032. }
  10033. }
  10034. }
  10035. if ($cateFalg) {
  10036. $cateHtml .= '<td class="colGreen taR">-</td>';
  10037. $cateFalg = true;
  10038. }
  10039. $cateFalg = true;
  10040. foreach ( $itemCategoryList as $l ) {
  10041. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  10042. if (empty ( $l ['price'] )) {
  10043. $cateHtml .= '<td class="colGreen taR">-</td>';
  10044. $cateFalg = false;
  10045. break;
  10046. } else {
  10047. $catePrice += $l ['price'];
  10048. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10049. $cateFalg = false;
  10050. break;
  10051. }
  10052. }
  10053. }
  10054. if ($cateFalg) {
  10055. $cateHtml .= '<td class="colGreen taR">-</td>';
  10056. $cateFalg = true;
  10057. }
  10058. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  10059. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  10060. /* -- --- */
  10061. }
  10062. // print_r($htmlArray);die;
  10063. $data ['htmlArray'] = $htmlArray;
  10064. // statistics html
  10065. $stList = $statistics->getOne ( array (
  10066. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  10067. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10068. 'groupby' => 'Month(date)',
  10069. 'asArray' => true
  10070. ) );
  10071. if (empty ( $stList ))
  10072. $stList = array (
  10073. 'rePrice' => 0,
  10074. 'agPrice' => 0
  10075. );
  10076. $data ['stList'] = array (
  10077. 'rePrice' => $stList ['rePrice'],
  10078. 'agPrice' => $stList ['agPrice'],
  10079. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10080. );
  10081. $monthHtml = "";
  10082. for($i = 1; $i <= 12; $i ++) {
  10083. if ($i == $month)
  10084. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  10085. else
  10086. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  10087. }
  10088. $data ['monthHtml'] = $monthHtml;
  10089. $data ['year'] = $year;
  10090. $data ['month'] = $month;
  10091. $data ['memu'] = "receipt";
  10092. $data ['staff'] = $this->staff;
  10093. $data ['receiptMemu'] = 'companyCategoryCollect';
  10094. $data ['verifyId'] = $this->verifyId;
  10095. $data ['executeId'] = $this->executeId;
  10096. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  10097. Doo::loadModel ( 'receipt' );
  10098. $receipt = new receipt ();
  10099. $receiptList = $receipt->find ( array (
  10100. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  10101. 'asArray' => true
  10102. ) );
  10103. if (empty ( $receiptList )) { // generated files
  10104. ob_start ();
  10105. $this->render ( "/admin/saeaStaffCollect", $data );
  10106. $this->cacheFile ( $path );
  10107. die ();
  10108. }
  10109. }
  10110. $this->render ( "/admin/saeaStaffCollect", $data );
  10111. }
  10112. /**
  10113. * 日常收支
  10114. */
  10115. function payments() {
  10116. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  10117. Doo::loadModel ( "execute" );
  10118. $execute = new execute ();
  10119. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  10120. die ( 'illegal request' );
  10121. }
  10122. Doo::loadModel ( "accountBook" );
  10123. $accountBook = new accountBook ();
  10124. Doo::loadModel ( "accountBookStatistics" );
  10125. $accountBookStatistics = new accountBookStatistics ();
  10126. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  10127. $list = $accountBook->getAccountBookByLimit ( 10 );
  10128. $data ['date'] = date ( "Y-m-d" );
  10129. $data ['statisticsList'] = $statisticsList;
  10130. $data ['list'] = $list;
  10131. $data ['memu'] = "receipt";
  10132. $data ['staff'] = $this->staff;
  10133. $data ['receiptMemu'] = 'payments';
  10134. $data ['verifyId'] = $this->verifyId;
  10135. $data ['executeId'] = $this->executeId;
  10136. $this->render ( "/expenses/payments", $data );
  10137. }
  10138. function paymentsIncomeDo() {
  10139. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10140. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10141. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10142. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10143. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10144. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10145. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10146. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10147. Doo::loadClass ( 'XDeode' );
  10148. $XDeode = new XDeode ( 5 );
  10149. Doo::loadModel ( "accountBook" );
  10150. Doo::loadModel ( "accountBookStatistics" );
  10151. Doo::loadModel ( 'wasteBook' );
  10152. // 记录流水时银行的转换
  10153. $accountBank = '';
  10154. if ($receivedBank == '纵横广发') {
  10155. $accountBank = 'CGBDeposit';
  10156. } elseif ($receivedBank == '纵横工行') {
  10157. $accountBank = 'ICBCDeposit';
  10158. } elseif ($receivedBank == '华润银行') {
  10159. $accountBank = 'HUADeposit';
  10160. } elseif ($receivedBank == '个人广发') {
  10161. $accountBank = 'PersonalDeposit';
  10162. }
  10163. if (empty ( $accountBank ))
  10164. die ( 'illegal request' );
  10165. // 收入为理财时特殊处理
  10166. if ($accountType == 7 || $accountType == 9) {
  10167. if ($receivedBank == '个人广发') {
  10168. die ( '个人广发 illegal request' );
  10169. }
  10170. // 添加一条收入
  10171. $accountBook = new accountBook ();
  10172. $accountBook->accountType = 10;
  10173. $accountBook->accountMsg = $accountMsg;
  10174. $accountBook->receivedPrice = $receivedPrice;
  10175. $accountBook->receivedMsg = $receivedMsg;
  10176. $accountBook->receivedBank = $receivedBank;
  10177. $accountBook->receivedDate = $receivedDate;
  10178. $accountBook->remarks = $remarks;
  10179. $accountBook->expensesType = 1;
  10180. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10181. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10182. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10183. $inComeId = $accountBook->insert ();
  10184. // 收支汇总-添加一条收入日常汇总
  10185. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10186. $accountBookStatistics = new accountBookStatistics ();
  10187. $item = array (
  10188. 'date' => date ( "Y-m-d" ),
  10189. 'accountType' => $abDetail ['accountType'],
  10190. 'accountMsg' => $abDetail ['accountMsg'],
  10191. 'aid' => $abDetail ['aid'],
  10192. 'inComePrice' => $abDetail ['receivedPrice'],
  10193. 'expensesType' => $abDetail ['expensesType']
  10194. );
  10195. $accountBookStatistics->setAccountBookStatistics ( $item );
  10196. // 添加收入流水
  10197. $wasteBook = new wasteBook ();
  10198. $itemWaste = array (
  10199. 'accountPriceShow' => $receivedPrice,
  10200. 'accountPrice' => $receivedPrice,
  10201. 'expensesType' => 1,
  10202. 'accountType' => 6, // 流水类型
  10203. 'dataID' => $inComeId,
  10204. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10205. 'accountBank' => $accountBank,
  10206. 'category' => $this->staff [0] ['category'],
  10207. 'cid' => $this->staff [0] ['cid'],
  10208. 'name' => $this->staff [0] ['username'],
  10209. 'sid' => $this->staff [0] ['sid'],
  10210. 'inputDate' => date ( "Y-m-d H:i:s" )
  10211. );
  10212. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10213. // 添加一条理财支出
  10214. $accountBank = 'CGBDeposit';
  10215. $expenditureBank = '纵横广发';
  10216. $dailyExpenditureType = 4;
  10217. if ($accountType == 9) {
  10218. $accountBank = 'ICBCDeposit';
  10219. $expenditureBank = '纵横工行';
  10220. $dailyExpenditureType = 6;
  10221. }
  10222. $accountBook = new accountBook ();
  10223. $accountBook->expensesType = 2;
  10224. $accountBook->expenditureType = $dailyExpenditureType;
  10225. $accountBook->expenditureMsg = $accountMsg;
  10226. $accountBook->expenditurePrice = $receivedPrice;
  10227. $accountBook->expenditureBank = $expenditureBank;
  10228. $accountBook->expenditureDate = $receivedDate;
  10229. $accountBook->remarks = $remarks;
  10230. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10231. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10232. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10233. $id = $accountBook->insert ();
  10234. // 收支汇总-添加一条理财支出汇总
  10235. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10236. $accountBookStatistics = new accountBookStatistics ();
  10237. $item = array (
  10238. 'date' => date ( "Y-m-d" ),
  10239. 'accountType' => $abDetail ['accountType'],
  10240. 'accountMsg' => $abDetail ['accountMsg'],
  10241. 'aid' => $abDetail ['aid'],
  10242. 'financingPrice' => - $receivedPrice,
  10243. 'expensesType' => 3
  10244. );
  10245. $accountBookStatistics->setAccountBookStatistics ( $item );
  10246. // 添加一条支出理财流水
  10247. $accountTypeWaste = 5;
  10248. if ($accountMsg == '公司固定') {
  10249. $accountTypeWaste = 9;
  10250. } elseif ($accountMsg == '公司活期') {
  10251. $accountTypeWaste = 10;
  10252. } elseif ($accountMsg == '个人(GR)') {
  10253. $accountBank = 'PersonalDeposit';
  10254. }
  10255. $itemWaste = array (
  10256. 'expensesType' => 2,
  10257. 'accountType' => $accountTypeWaste,
  10258. 'accountPriceShow' => $receivedPrice,
  10259. 'accountPrice' => - $receivedPrice,
  10260. 'dataID' => $id,
  10261. 'dailyExpenditureType' => $dailyExpenditureType,
  10262. 'accountBank' => $accountBank,
  10263. 'category' => $this->staff [0] ['category'],
  10264. 'cid' => $this->staff [0] ['cid'],
  10265. 'name' => $this->staff [0] ['username'],
  10266. 'sid' => $this->staff [0] ['sid'],
  10267. 'inputDate' => date ( "Y-m-d H:i:s" )
  10268. );
  10269. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10270. } elseif ($accountType == 1) {
  10271. if ($receivedBank == '个人广发')
  10272. die ( 'illegal request' );
  10273. // 添加一条收入
  10274. $accountBook = new accountBook ();
  10275. $accountBook->accountType = $accountType;
  10276. $accountBook->accountMsg = $accountMsg;
  10277. $accountBook->receivedPrice = $receivedPrice;
  10278. $accountBook->receivedMsg = $receivedMsg;
  10279. $accountBook->receivedBank = $receivedBank;
  10280. $accountBook->receivedDate = $receivedDate;
  10281. $accountBook->remarks = $remarks;
  10282. $accountBook->expensesType = 1;
  10283. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10284. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10285. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10286. $id = $accountBook->insert ();
  10287. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10288. // 收支汇总-添加一条收入日常汇总
  10289. $accountBookStatistics = new accountBookStatistics ();
  10290. $item = array (
  10291. 'date' => date ( "Y-m-d" ),
  10292. 'accountType' => $abDetail ['accountType'],
  10293. 'accountMsg' => $abDetail ['accountMsg'],
  10294. 'aid' => $abDetail ['aid'],
  10295. 'expensesType' => $abDetail ['expensesType']
  10296. );
  10297. if ($abDetail ['accountType'] == 8) {
  10298. $item += array (
  10299. 'inComePrice' => $abDetail ['receivedPrice']
  10300. );
  10301. } else {
  10302. $item += array (
  10303. 'inComePrice' => $abDetail ['receivedPrice']
  10304. );
  10305. }
  10306. $accountBookStatistics->setAccountBookStatistics ( $item );
  10307. // 流水存储方向
  10308. $itemWaste = array (
  10309. 'accountType' => 6
  10310. ); // 流水类型
  10311. // if($accountMsg=='银行存款'||$accountMsg=='固定理财收益'){
  10312. // }else
  10313. if ($accountMsg == '活期理财收益') {
  10314. $itemWaste = array (
  10315. 'accountType' => 10
  10316. ); // 流水类型
  10317. }
  10318. // 添加收入流水
  10319. $wasteBook = new wasteBook ();
  10320. $itemWaste += array (
  10321. 'accountPrice' => $receivedPrice,
  10322. 'accountPriceShow' => $receivedPrice,
  10323. 'expensesType' => 1,
  10324. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10325. 'dataID' => $id,
  10326. 'accountBank' => $accountBank,
  10327. 'category' => $this->staff [0] ['category'],
  10328. 'cid' => $this->staff [0] ['cid'],
  10329. 'name' => $this->staff [0] ['username'],
  10330. 'sid' => $this->staff [0] ['sid'],
  10331. 'inputDate' => date ( "Y-m-d H:i:s" )
  10332. );
  10333. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10334. } else { // 普通日常收入处理
  10335. // 添加一条收入
  10336. $accountBook = new accountBook ();
  10337. $accountBook->accountType = $accountType;
  10338. $accountBook->accountMsg = $accountMsg;
  10339. $accountBook->receivedPrice = $receivedPrice;
  10340. $accountBook->receivedMsg = $receivedMsg;
  10341. $accountBook->receivedBank = $receivedBank;
  10342. $accountBook->receivedDate = $receivedDate;
  10343. $accountBook->remarks = $remarks;
  10344. $accountBook->expensesType = 1;
  10345. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10346. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10347. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10348. $id = $accountBook->insert ();
  10349. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10350. // 收支汇总-添加一条收入日常汇总
  10351. $accountBookStatistics = new accountBookStatistics ();
  10352. $item = array (
  10353. 'date' => date ( "Y-m-d" ),
  10354. 'accountType' => $abDetail ['accountType'],
  10355. 'accountMsg' => $abDetail ['accountMsg'],
  10356. 'aid' => $abDetail ['aid'],
  10357. 'expensesType' => $abDetail ['expensesType']
  10358. );
  10359. if ($abDetail ['accountType'] == 8) {
  10360. $item += array (
  10361. 'inComePrice' => $abDetail ['receivedPrice']
  10362. );
  10363. } else {
  10364. $item += array (
  10365. 'inComePrice' => $abDetail ['receivedPrice']
  10366. );
  10367. }
  10368. $accountBookStatistics->setAccountBookStatistics ( $item );
  10369. // 添加收入流水
  10370. $itemWaste = array (
  10371. 'accountPrice' => $receivedPrice
  10372. );
  10373. if ($receivedBank == '个人广发') {
  10374. $itemWaste = array (
  10375. 'accountPrice' => - $receivedPrice
  10376. );
  10377. }
  10378. $wasteBook = new wasteBook ();
  10379. $itemWaste += array (
  10380. 'accountPriceShow' => $receivedPrice,
  10381. 'expensesType' => 1,
  10382. 'accountType' => 6, // 流水类型
  10383. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10384. 'dataID' => $id,
  10385. 'accountBank' => $accountBank,
  10386. 'category' => $this->staff [0] ['category'],
  10387. 'cid' => $this->staff [0] ['cid'],
  10388. 'name' => $this->staff [0] ['username'],
  10389. 'sid' => $this->staff [0] ['sid'],
  10390. 'inputDate' => date ( "Y-m-d H:i:s" )
  10391. );
  10392. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10393. }
  10394. }
  10395. return '/payments';
  10396. }
  10397. /**
  10398. * 添加收入
  10399. * @return string
  10400. */
  10401. function paymentsIncomeDo_() {
  10402. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10403. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10404. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10405. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10406. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10407. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10408. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10409. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10410. Doo::loadClass ( 'XDeode' );
  10411. $XDeode = new XDeode ( 5 );
  10412. Doo::loadModel ( "accountBook" );
  10413. $accountBook = new accountBook ();
  10414. $accountBank = '';
  10415. $accountTypeWaste = 6;
  10416. if ($receivedBank == '纵横广发') {
  10417. $accountBank = 'CGBDeposit';
  10418. } elseif ($receivedBank == '纵横工行') {
  10419. $accountBank = 'ICBCDeposit';
  10420. } elseif ($receivedBank == '华润银行') {
  10421. $accountBank = 'HUADeposit';
  10422. } elseif ($receivedBank == '个人广发') {
  10423. $accountBank = 'PersonalDeposit';
  10424. }
  10425. if (empty ( $accountBank ))
  10426. die ( 'illegal request' );
  10427. $dailyIncomeType = '';
  10428. $itemWaste = array (
  10429. 'accountPrice' => $receivedPrice,
  10430. 'expensesType' => 1
  10431. );
  10432. if ($receivedBank == '个人广发') {
  10433. $itemWaste = array (
  10434. 'accountPrice' => - $receivedPrice,
  10435. 'expensesType' => 1
  10436. );
  10437. }
  10438. if ($accountType == 4) {
  10439. $dailyIncomeType = 4;
  10440. } elseif ($accountType == 1) {
  10441. $dailyIncomeType = 1;
  10442. } elseif ($accountType == 2) {
  10443. $dailyIncomeType = 2;
  10444. } elseif ($accountType == 3) {
  10445. $dailyIncomeType = 3;
  10446. } elseif ($accountType == 5) {
  10447. $dailyIncomeType = 5;
  10448. } elseif ($accountType == 6) {
  10449. $dailyIncomeType = 6;
  10450. } elseif ($accountType == 7 || $accountType == 9) {
  10451. $dailyIncomeType = 7;
  10452. if ($accountMsg == '公司固定') {
  10453. $accountTypeWaste = 9;
  10454. } elseif ($accountMsg == '公司活期') {
  10455. $accountTypeWaste = 10;
  10456. } elseif ($accountMsg == '个人(GR)') {
  10457. $accountBank = 'PersonalDeposit';
  10458. }
  10459. $itemWaste = array (
  10460. 'accountPrice' => - $receivedPrice,
  10461. 'expensesType' => 2
  10462. );
  10463. } elseif ($accountType == 8) {
  10464. $dailyIncomeType = 8;
  10465. }
  10466. if (empty ( $dailyIncomeType ))
  10467. die ( 'illegal request' );
  10468. $accountBook->accountType = $accountType;
  10469. $accountBook->accountMsg = $accountMsg;
  10470. $accountBook->receivedPrice = $receivedPrice;
  10471. $accountBook->receivedMsg = $receivedMsg;
  10472. $accountBook->receivedBank = $receivedBank;
  10473. $accountBook->receivedDate = $receivedDate;
  10474. $accountBook->remarks = $remarks;
  10475. $accountBook->expensesType = 1;
  10476. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10477. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10478. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10479. $id = $accountBook->insert ();
  10480. //
  10481. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10482. // 收支汇总
  10483. Doo::loadModel ( "accountBookStatistics" );
  10484. $accountBookStatistics = new accountBookStatistics ();
  10485. $item = array (
  10486. 'date' => date ( "Y-m-d" ),
  10487. 'accountType' => $abDetail ['accountType'],
  10488. 'accountMsg' => $abDetail ['accountMsg'],
  10489. 'aid' => $abDetail ['aid']
  10490. );
  10491. if ($abDetail ['expensesType'] == 1) {
  10492. if ($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) {
  10493. $item += array (
  10494. 'financingPrice' => - $receivedPrice,
  10495. 'expensesType' => 3
  10496. );
  10497. } else if ($abDetail ['accountType'] == 8) {
  10498. $item += array (
  10499. 'inComePrice' => - $abDetail ['receivedPrice'],
  10500. 'expensesType' => $abDetail ['expensesType']
  10501. );
  10502. } else {
  10503. $item += array (
  10504. 'inComePrice' => $abDetail ['receivedPrice'],
  10505. 'expensesType' => $abDetail ['expensesType']
  10506. );
  10507. }
  10508. }
  10509. $accountBookStatistics->setAccountBookStatistics ( $item );
  10510. // 为理财时需添加一条日常支出
  10511. if ($accountType == 7 || $accountType == 9) {
  10512. }
  10513. // 公司流水记录
  10514. Doo::loadModel ( 'wasteBook' );
  10515. $wasteBook = new wasteBook ();
  10516. // 银行
  10517. // if (empty($abDetail)){
  10518. $itemWaste += array (
  10519. 'accountPriceShow' => $receivedPrice,
  10520. 'dataID' => $id,
  10521. 'accountType' => $accountTypeWaste,
  10522. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10523. 'accountBank' => $accountBank,
  10524. 'category' => $this->staff [0] ['category'],
  10525. 'cid' => $this->staff [0] ['cid'],
  10526. 'name' => $this->staff [0] ['username'],
  10527. 'sid' => $this->staff [0] ['sid'],
  10528. 'inputDate' => date ( "Y-m-d H:i:s" )
  10529. );
  10530. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10531. // }
  10532. // 类型为理财7或者9 要添加一笔理财支出
  10533. if ($accountType == 7 || $accountType == 9) {
  10534. $accountBank = 'CGBDeposit';
  10535. $expenditureBank = '纵横广发';
  10536. $dailyExpenditureType = 4;
  10537. if ($accountType == 9) {
  10538. $accountBank = 'ICBCDeposit';
  10539. $expenditureBank = '纵横工行';
  10540. $dailyExpenditureType = 6;
  10541. }
  10542. // 添加一条支出
  10543. $accountBook = new accountBook ();
  10544. $accountBook->expenditureType = $dailyExpenditureType;
  10545. $accountBook->expenditureMsg = $accountMsg;
  10546. $accountBook->expenditurePrice = $receivedPrice;
  10547. $accountBook->expenditureBank = $expenditureBank;
  10548. $accountBook->expenditureDate = $receivedDate;
  10549. $accountBook->remarks = $remarks;
  10550. $accountBook->expensesType = 2;
  10551. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10552. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10553. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10554. $id = $accountBook->insert ();
  10555. // 添加一条收入流水
  10556. $itemWaste = array (
  10557. 'accountPriceShow' => $receivedPrice,
  10558. 'accountPrice' => $receivedPrice,
  10559. 'dataID' => $id,
  10560. 'expensesType' => 2,
  10561. 'accountType' => $accountTypeWaste,
  10562. 'dailyExpenditureType' => $dailyExpenditureType,
  10563. 'accountBank' => $accountBank,
  10564. 'category' => $this->staff [0] ['category'],
  10565. 'cid' => $this->staff [0] ['cid'],
  10566. 'name' => $this->staff [0] ['username'],
  10567. 'sid' => $this->staff [0] ['sid'],
  10568. 'inputDate' => date ( "Y-m-d H:i:s" )
  10569. );
  10570. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10571. }
  10572. }
  10573. return '/payments';
  10574. }
  10575. function paymentsExpenditureDo() {
  10576. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10577. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10578. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10579. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10580. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10581. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10582. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10583. // 理财支出特殊处理
  10584. Doo::loadModel ( "accountBook" );
  10585. Doo::loadModel ( "accountBookStatistics" );
  10586. Doo::loadModel ( 'wasteBook' );
  10587. $accountBank = '';
  10588. if ($expenditureBank == '纵横广发') {
  10589. $accountBank = 'CGBDeposit';
  10590. } elseif ($expenditureBank == '纵横工行') {
  10591. $accountBank = 'ICBCDeposit';
  10592. } elseif ($expenditureBank == '华润银行') {
  10593. $accountBank = 'HUADeposit';
  10594. } elseif ($expenditureBank == '个人广发') {
  10595. $accountBank = 'PersonalDeposit';
  10596. }
  10597. if (empty ( $accountBank ))
  10598. die ( 'illegal request' );
  10599. if ($expenditureType == 4 || $expenditureType == 6) {
  10600. if ($expenditureBank == '个人广发') {
  10601. die ( '个人广发 illegal request' );
  10602. }
  10603. // 添加一笔日常支出
  10604. $accountBook = new accountBook ();
  10605. $accountBook->expensesType = 2;
  10606. $accountBook->expenditureType = 7;
  10607. $accountBook->expenditureMsg = $expenditureMsg;
  10608. $accountBook->expenditurePrice = $expenditurePrice;
  10609. $accountBook->expenditureBank = $expenditureBank;
  10610. $accountBook->expenditureDate = $expenditureDate;
  10611. $accountBook->remarks = $remarks;
  10612. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10613. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10614. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10615. $expenditureId = $accountBook->insert ();
  10616. // 添加日常支出汇总
  10617. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  10618. $accountBookStatistics = new accountBookStatistics ();
  10619. $item = array (
  10620. 'date' => date ( "Y-m-d" ),
  10621. 'expenditureType' => $abDetail ['expenditureType'],
  10622. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10623. 'aid' => $abDetail ['aid'],
  10624. 'payPrice' => $abDetail ['expenditurePrice'],
  10625. 'expensesType' => $abDetail ['expensesType']
  10626. );
  10627. $accountBookStatistics->setAccountBookStatistics ( $item );
  10628. // 公司日常支出流水
  10629. $wasteBook = new wasteBook ();
  10630. $itemWaste = array (
  10631. 'accountPrice' => - $expenditurePrice
  10632. );
  10633. if ($expenditureBank == '个人广发') {
  10634. $itemWaste = array (
  10635. 'accountPrice' => $expenditurePrice
  10636. );
  10637. }
  10638. $itemWaste += array (
  10639. 'expensesType' => 2,
  10640. 'accountType' => 5,
  10641. 'dailyExpenditureType' => $expenditureType,
  10642. 'accountPriceShow' => $expenditurePrice,
  10643. 'accountPrice' => - $expenditurePrice,
  10644. 'dataID' => $expenditureId,
  10645. 'accountBank' => $accountBank,
  10646. 'category' => $this->staff [0] ['category'],
  10647. 'cid' => $this->staff [0] ['cid'],
  10648. 'name' => $this->staff [0] ['username'],
  10649. 'sid' => $this->staff [0] ['sid'],
  10650. 'inputDate' => date ( "Y-m-d H:i:s" )
  10651. );
  10652. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10653. // 添加一笔理财收入
  10654. $accountBank = 'CGBDeposit';
  10655. $dailyIncomeType = 7;
  10656. $receivedBank = '纵横广发';
  10657. if ($expenditureType == 6) {
  10658. $accountBank = 'ICBCDeposit';
  10659. $receivedBank = '纵横工行';
  10660. $dailyIncomeType = 9;
  10661. }
  10662. $accountBook = new accountBook ();
  10663. $accountBook->expensesType = 1;
  10664. $accountBook->accountType = $dailyIncomeType;
  10665. $accountBook->accountMsg = $expenditureMsg;
  10666. $accountBook->receivedPrice = $expenditurePrice;
  10667. $accountBook->receivedBank = $receivedBank;
  10668. $accountBook->receivedDate = $expenditureDate;
  10669. $accountBook->remarks = $remarks;
  10670. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10671. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10672. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10673. $id = $accountBook->insert ();
  10674. // 添加日常理财收入汇总
  10675. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  10676. $accountBookStatistics = new accountBookStatistics ();
  10677. $item = array (
  10678. 'date' => date ( "Y-m-d" ),
  10679. 'expenditureType' => $abDetail ['expenditureType'],
  10680. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10681. 'aid' => $abDetail ['aid'],
  10682. 'financingPrice' => $expenditurePrice,
  10683. 'expensesType' => 3
  10684. );
  10685. $accountBookStatistics->setAccountBookStatistics ( $item );
  10686. // 添加一笔收入流水
  10687. if ($expenditureMsg == '公司固定') {
  10688. $accountTypeWaste = 9;
  10689. } elseif ($expenditureMsg == '公司活期') {
  10690. $accountTypeWaste = 10;
  10691. } elseif ($expenditureMsg == '个人(GR)') {
  10692. $accountBank = 'PersonalDeposit';
  10693. }
  10694. $itemWaste = array (
  10695. 'expensesType' => 1,
  10696. 'accountType' => $accountTypeWaste,
  10697. 'accountPriceShow' => $expenditurePrice,
  10698. 'accountPrice' => $expenditurePrice,
  10699. 'dataID' => $id,
  10700. 'dailyIncomeType' => $dailyIncomeType,
  10701. 'accountBank' => $accountBank,
  10702. 'category' => $this->staff [0] ['category'],
  10703. 'cid' => $this->staff [0] ['cid'],
  10704. 'name' => $this->staff [0] ['username'],
  10705. 'sid' => $this->staff [0] ['sid'],
  10706. 'inputDate' => date ( "Y-m-d H:i:s" )
  10707. );
  10708. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10709. } else {
  10710. // 添加一笔日常支出
  10711. $accountBook = new accountBook ();
  10712. $accountBook->expensesType = 2;
  10713. $accountBook->expenditureType = $expenditureType;
  10714. $accountBook->expenditureMsg = $expenditureMsg;
  10715. $accountBook->expenditurePrice = $expenditurePrice;
  10716. $accountBook->expenditureBank = $expenditureBank;
  10717. $accountBook->expenditureDate = $expenditureDate;
  10718. $accountBook->remarks = $remarks;
  10719. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10720. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10721. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10722. $id = $accountBook->insert ();
  10723. // 添加日常支出汇总
  10724. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10725. $accountBookStatistics = new accountBookStatistics ();
  10726. $item = array (
  10727. 'date' => date ( "Y-m-d" ),
  10728. 'expenditureType' => $abDetail ['expenditureType'],
  10729. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10730. 'aid' => $abDetail ['aid'],
  10731. 'expensesType' => $abDetail ['expensesType']
  10732. );
  10733. if ($expenditureType == 5) {
  10734. $item += array (
  10735. 'payPrice' => - $abDetail ['expenditurePrice']
  10736. );
  10737. } else {
  10738. $item += array (
  10739. 'payPrice' => $abDetail ['expenditurePrice']
  10740. );
  10741. }
  10742. $accountBookStatistics->setAccountBookStatistics ( $item );
  10743. // 公司日常支出流水
  10744. $wasteBook = new wasteBook ();
  10745. $itemWaste = array (
  10746. 'accountPrice' => - $expenditurePrice
  10747. );
  10748. if ($expenditureBank == '个人广发') {
  10749. $itemWaste = array (
  10750. 'accountPrice' => $expenditurePrice
  10751. );
  10752. }
  10753. $itemWaste += array (
  10754. 'expensesType' => 2,
  10755. 'accountType' => 5,
  10756. 'accountPriceShow' => $expenditurePrice,
  10757. 'dataID' => $id,
  10758. 'dailyExpenditureType' => $expenditureType,
  10759. 'accountBank' => $accountBank,
  10760. 'category' => $this->staff [0] ['category'],
  10761. 'cid' => $this->staff [0] ['cid'],
  10762. 'name' => $this->staff [0] ['username'],
  10763. 'sid' => $this->staff [0] ['sid'],
  10764. 'inputDate' => date ( "Y-m-d H:i:s" )
  10765. );
  10766. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10767. }
  10768. }
  10769. return '/payments';
  10770. }
  10771. /**
  10772. * 添加支出
  10773. */
  10774. function paymentsExpenditureDo_() {
  10775. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10776. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10777. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10778. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10779. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10780. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10781. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10782. $dailyExpenditureType = '';
  10783. $accountTypeWaste = 5;
  10784. $accountBank = '';
  10785. if ($expenditureBank == '纵横广发') {
  10786. $accountBank = 'CGBDeposit';
  10787. } elseif ($expenditureBank == '纵横工行') {
  10788. $accountBank = 'ICBCDeposit';
  10789. } elseif ($expenditureBank == '华润银行') {
  10790. $accountBank = 'HUADeposit';
  10791. } elseif ($expenditureBank == '个人广发') {
  10792. $accountBank = 'PersonalDeposit';
  10793. }
  10794. if (empty ( $accountBank ))
  10795. die ( 'illegal request' );
  10796. $itemWaste = array (
  10797. 'accountPrice' => - $expenditurePrice
  10798. );
  10799. if ($expenditureBank == '个人广发') {
  10800. $itemWaste = array (
  10801. 'accountPrice' => $expenditurePrice
  10802. );
  10803. }
  10804. if ($expenditureType == 4 || $expenditureType == 6) {
  10805. $dailyExpenditureType = 4;
  10806. if ($expenditureMsg == '公司固定') {
  10807. $accountTypeWaste = 9;
  10808. } elseif ($expenditureMsg == '公司活期') {
  10809. $accountTypeWaste = 10;
  10810. } elseif ($expenditureMsg == '个人(GR)') {
  10811. $accountBank = 'PersonalDeposit';
  10812. }
  10813. $itemWaste = array (
  10814. 'accountPrice' => $expenditurePrice
  10815. );
  10816. } elseif ($expenditureType == 1) {
  10817. $dailyExpenditureType = 1;
  10818. } elseif ($expenditureType == 2) {
  10819. $dailyExpenditureType = 2;
  10820. } elseif ($expenditureType == 3) {
  10821. $dailyExpenditureType = 3;
  10822. } elseif ($expenditureType == 5) {
  10823. $dailyExpenditureType = 5;
  10824. }
  10825. if (empty ( $dailyExpenditureType ))
  10826. die ( 'illegal request' );
  10827. Doo::loadModel ( "accountBook" );
  10828. $accountBook = new accountBook ();
  10829. $accountBook->expenditureType = $expenditureType;
  10830. $accountBook->expenditureMsg = $expenditureMsg;
  10831. $accountBook->expenditurePrice = $expenditurePrice;
  10832. $accountBook->expenditureBank = $expenditureBank;
  10833. $accountBook->expenditureDate = $expenditureDate;
  10834. $accountBook->remarks = $remarks;
  10835. $accountBook->expensesType = 2;
  10836. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10837. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10838. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10839. $id = $accountBook->insert ();
  10840. //
  10841. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10842. Doo::loadModel ( "accountBookStatistics" );
  10843. $accountBookStatistics = new accountBookStatistics ();
  10844. $item = array (
  10845. 'date' => date ( "Y-m-d" ),
  10846. 'expenditureType' => $abDetail ['expenditureType'],
  10847. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10848. 'aid' => $abDetail ['aid']
  10849. );
  10850. if ($abDetail ['expensesType'] == 2) {
  10851. if ($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) {
  10852. $item += array (
  10853. 'financingPrice' => $expenditurePrice,
  10854. 'expensesType' => 3
  10855. );
  10856. } elseif ($abDetail ['expenditureType'] == 5) {
  10857. $item += array (
  10858. 'payPrice' => $abDetail ['expenditurePrice'],
  10859. 'expensesType' => $abDetail ['expensesType']
  10860. );
  10861. } else {
  10862. $item += array (
  10863. 'payPrice' => $abDetail ['expenditurePrice'],
  10864. 'expensesType' => $abDetail ['expensesType']
  10865. );
  10866. }
  10867. }
  10868. $accountBookStatistics->setAccountBookStatistics ( $item );
  10869. // 公司流水记录
  10870. Doo::loadModel ( 'wasteBook' );
  10871. $wasteBook = new wasteBook ();
  10872. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountTypeWaste, $id );
  10873. // 银行
  10874. if (empty ( $abDetail )) {
  10875. $itemWaste += array (
  10876. 'accountPriceShow' => $expenditurePrice,
  10877. 'dataID' => $id,
  10878. 'expensesType' => 2,
  10879. 'accountType' => $accountTypeWaste,
  10880. 'dailyExpenditureType' => $expenditureType,
  10881. 'accountBank' => $accountBank,
  10882. 'category' => $this->staff [0] ['category'],
  10883. 'cid' => $this->staff [0] ['cid'],
  10884. 'name' => $this->staff [0] ['username'],
  10885. 'sid' => $this->staff [0] ['sid'],
  10886. 'inputDate' => date ( "Y-m-d H:i:s" )
  10887. );
  10888. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10889. }
  10890. // 支出类型为4或者6 需要添加一笔收入和收入流水
  10891. if ($expenditureType == 4 || $expenditureType == 6) {
  10892. $accountBank = 'CGBDeposit';
  10893. $dailyIncomeType = 7;
  10894. $receivedBank = '纵横广发';
  10895. if ($expenditureType == 6) {
  10896. $accountBank = 'ICBCDeposit';
  10897. $receivedBank = '纵横工行';
  10898. $dailyIncomeType = 9;
  10899. }
  10900. // 添加一笔收入
  10901. $accountBook = new accountBook ();
  10902. $accountBook->accountType = $dailyIncomeType;
  10903. $accountBook->accountMsg = $expenditureMsg;
  10904. $accountBook->receivedPrice = $expenditurePrice;
  10905. $accountBook->receivedBank = $receivedBank;
  10906. $accountBook->receivedDate = $expenditureDate;
  10907. $accountBook->remarks = $remarks;
  10908. $accountBook->expensesType = 1;
  10909. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10910. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10911. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10912. $id = $accountBook->insert ();
  10913. // 添加一笔收入流水
  10914. $itemWaste = array (
  10915. 'accountPriceShow' => $expenditurePrice,
  10916. 'accountPrice' => - $expenditurePrice,
  10917. 'dataID' => $id,
  10918. 'expensesType' => 1,
  10919. 'accountType' => $accountTypeWaste,
  10920. 'dailyIncomeType' => $dailyIncomeType,
  10921. 'accountBank' => $accountBank,
  10922. 'category' => $this->staff [0] ['category'],
  10923. 'cid' => $this->staff [0] ['cid'],
  10924. 'name' => $this->staff [0] ['username'],
  10925. 'sid' => $this->staff [0] ['sid'],
  10926. 'inputDate' => date ( "Y-m-d H:i:s" )
  10927. );
  10928. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10929. }
  10930. }
  10931. return '/payments';
  10932. }
  10933. /**
  10934. * 所有收支
  10935. */
  10936. function paymentsAchieve() {
  10937. $page_size = 12;
  10938. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  10939. $expensesType = isset ( $this->params ['expensesType'] ) ? $this->params ['expensesType'] : 'ALL';
  10940. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  10941. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  10942. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10943. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10944. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10945. $submitType = $this->get_args ( 'submitType' ) ? $this->get_args ( 'submitType' ) : "";
  10946. Doo::loadModel ( "accountBookStatistics" );
  10947. $accountBookStatistics = new accountBookStatistics ();
  10948. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  10949. $data ['statisticsList'] = $statisticsList;
  10950. Doo::loadModel ( "accountBook" );
  10951. $accountBook = new accountBook ();
  10952. $con = '';
  10953. if ($expensesType == 'INCOME')
  10954. $con = ' and expensesType=1 ';
  10955. elseif ($expensesType == 'PAY')
  10956. $con = ' and expensesType=2 ';
  10957. $dateArr = explode ( ':', $date );
  10958. $D1 = $dateString = '';
  10959. $D2 = '';
  10960. if (! empty ( $date )) {
  10961. $D1 = $dateArr [0];
  10962. if (isset ( $dateArr [1] ))
  10963. $D2 = $dateArr [1];
  10964. else
  10965. $D2 = '';
  10966. $dateString = $D1 . " : " . $D2;
  10967. }
  10968. if (! empty ( $D1 ) && ! empty ( $D2 ))
  10969. $con .= ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  10970. elseif (! empty ( $D1 ) && empty ( $D2 ))
  10971. $con .= ' and inputDate like "%' . $D1 . '%" ';
  10972. if (! empty ( $price ))
  10973. $con .= ' and (receivedPrice=' . $price . ' or expenditurePrice=' . $price . ')';
  10974. if ($submitType == 1) {
  10975. if ($accountType != '') {
  10976. $expenditureType = '';
  10977. $con .= ' and accountType=' . $accountType;
  10978. if (! empty ( $accountMsg ))
  10979. $con .= ' and (accountType=' . $accountType . ' and accountMsg like "%' . $accountMsg . '%")';
  10980. }
  10981. } elseif ($submitType == 2) {
  10982. if ($expenditureType != '') {
  10983. $accountType = $accountMsg = '';
  10984. $con .= ' and expenditureType=' . $expenditureType;
  10985. }
  10986. } else {
  10987. $accountType = $accountMsg = $expenditureType = '';
  10988. }
  10989. $sql = "" . $con;
  10990. $action = "paymentsAchieve";
  10991. $get = '/' . $expensesType; // "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  10992. $pageinfo = $this->get_page ( "CLD_accountBook", $sql, $page, $page_size, $action, $get, "" );
  10993. $limit = $pageinfo ['lower'] . ',' . $page_size;
  10994. $list = $accountBook->getAccountBookBySql ( $limit, $sql, 'desc' );
  10995. $data ['expenditureType'] = $expenditureType;
  10996. $data ['accountMsg'] = $accountMsg;
  10997. $data ['accountType'] = $accountType;
  10998. $data ['inputDate'] = $date;
  10999. $data ['price'] = $price;
  11000. $data ['expensesType'] = $expensesType;
  11001. $data ['page'] = $pageinfo;
  11002. $data ['list'] = $list;
  11003. $data ['memu'] = "receipt";
  11004. $data ['staff'] = $this->staff;
  11005. $data ['receiptMemu'] = 'payments';
  11006. $data ['verifyId'] = $this->verifyId;
  11007. $data ['executeId'] = $this->executeId;
  11008. $this->render ( "/expenses/paymentsAchieve", $data );
  11009. }
  11010. function paymentsIncomeUpdateDo() {
  11011. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11012. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11013. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11014. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  11015. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  11016. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  11017. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  11018. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11019. if (! empty ( $aidKey ) && ! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  11020. Doo::loadClass ( 'XDeode' );
  11021. $XDeode = new XDeode ( 5 );
  11022. $aid = $XDeode->decode ( $aidKey );
  11023. Doo::loadModel ( "accountBook" );
  11024. $accountBook = new accountBook ();
  11025. //
  11026. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11027. $price = $receivedPrice - $abDetail [inComePrice];
  11028. Doo::loadModel ( "accountBookStatistics" );
  11029. $accountBookStatistics = new accountBookStatistics ();
  11030. if ($abDetail ['accountType'] == 7) {
  11031. $item += array (
  11032. 'date' => date ( "Y-m-d" ),
  11033. 'financingPrice' => - $price,
  11034. 'expensesType' => 3,
  11035. 'aid' => $abDetail ['aid']
  11036. );
  11037. } elseif ($abDetail ['accountType'] == 8) {
  11038. $item += array (
  11039. 'date' => date ( "Y-m-d" ),
  11040. 'expensesType' => $abDetail ['expensesType'],
  11041. 'inComePrice' => - $price,
  11042. 'aid' => $abDetail ['aid']
  11043. );
  11044. } else {
  11045. $item = array (
  11046. 'date' => date ( "Y-m-d" ),
  11047. 'expensesType' => $abDetail ['expensesType'],
  11048. 'inComePrice' => $price,
  11049. 'aid' => $abDetail ['aid']
  11050. );
  11051. }
  11052. $accountBookStatistics->setAccountBookStatistics ( $item );
  11053. $accountBook->accountType = $accountType;
  11054. $accountBook->accountMsg = $accountMsg;
  11055. $accountBook->receivedPrice = $receivedPrice;
  11056. $accountBook->receivedMsg = $receivedMsg;
  11057. $accountBook->receivedBank = $receivedBank;
  11058. $accountBook->receivedDate = $receivedDate;
  11059. $accountBook->remarks = $remarks;
  11060. $accountBook->aid = $aid;
  11061. $accountBook->update ();
  11062. }
  11063. return '/paymentsAchieve';
  11064. }
  11065. function paymentsExpenditureEdiDo() {
  11066. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11067. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11068. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11069. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11070. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11071. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11072. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11073. if (! empty ( $aidKey ) && ! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11074. Doo::loadClass ( 'XDeode' );
  11075. $XDeode = new XDeode ( 5 );
  11076. $aid = $XDeode->decode ( $aidKey );
  11077. Doo::loadModel ( "accountBook" );
  11078. $accountBook = new accountBook ();
  11079. // 汇总信息
  11080. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11081. $price = $expenditurePrice - $abDetail [expenditurePrice];
  11082. Doo::loadModel ( "accountBookStatistics" );
  11083. $accountBookStatistics = new accountBookStatistics ();
  11084. if ($abDetail ['expenditureType'] == 4) {
  11085. $item += array (
  11086. 'date' => date ( "Y-m-d" ),
  11087. 'financingPrice' => $price,
  11088. 'expensesType' => 3,
  11089. 'aid' => $abDetail ['aid']
  11090. );
  11091. } elseif ($abDetail ['expenditureType'] == 5) {
  11092. $item += array (
  11093. 'date' => date ( "Y-m-d" ),
  11094. 'expensesType' => $abDetail ['expensesType'],
  11095. 'payPrice' => $price,
  11096. 'aid' => $abDetail ['aid']
  11097. );
  11098. } else {
  11099. $item = array (
  11100. 'date' => date ( "Y-m-d" ),
  11101. 'expensesType' => $abDetail ['expensesType'],
  11102. 'payPrice' => $price,
  11103. 'aid' => $abDetail ['aid']
  11104. );
  11105. }
  11106. $accountBookStatistics->setAccountBookStatistics ( $item );
  11107. //
  11108. $accountBook->expenditureType = $expenditureType;
  11109. $accountBook->expenditureMsg = $expenditureMsg;
  11110. $accountBook->expenditurePrice = $expenditurePrice;
  11111. $accountBook->expenditureBank = $expenditureBank;
  11112. $accountBook->remarks = $remarks;
  11113. $accountBook->expenditureDate = $expenditureDate;
  11114. $accountBook->aid = $aid;
  11115. $id = $accountBook->update ();
  11116. }
  11117. return '/paymentsAchieve';
  11118. }
  11119. function paymentsDelDo() {
  11120. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11121. if (! empty ( $aidKey )) {
  11122. Doo::loadClass ( 'XDeode' );
  11123. $XDeode = new XDeode ( 5 );
  11124. $aid = $XDeode->decode ( $aidKey );
  11125. Doo::loadModel ( "accountBook" );
  11126. $accountBook = new accountBook ();
  11127. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11128. if (empty ( $abDetail ))
  11129. die ( 'illegal request' );
  11130. // 删除收支
  11131. Doo::loadModel ( "accountBookStatistics" );
  11132. $accountBookStatistics = new accountBookStatistics ();
  11133. $item = array (
  11134. 'date' => date ( "Y-m-d" ),
  11135. 'aid' => $abDetail ['aid']
  11136. );
  11137. $accountType = '';
  11138. if ($abDetail ['expensesType'] == 1) {
  11139. $accountType = 6;
  11140. if ($abDetail ['accountType'] != 7) {
  11141. $item += array (
  11142. 'expensesType' => $abDetail ['expensesType'],
  11143. 'inComePrice' => - $abDetail ['receivedPrice']
  11144. );
  11145. } else {
  11146. $item += array (
  11147. 'financingPrice' => $abDetail ['receivedPrice'],
  11148. 'expensesType' => 3
  11149. );
  11150. }
  11151. } elseif ($abDetail ['expensesType'] == 2) {
  11152. $accountType = 5;
  11153. if ($abDetail ['accountType'] != 7) {
  11154. $item += array (
  11155. 'expensesType' => $abDetail ['expensesType'],
  11156. 'payPrice' => - $abDetail ['expenditurePrice']
  11157. );
  11158. } else {
  11159. $item += array (
  11160. 'financingPrice' => - $abDetail ['expenditurePrice'],
  11161. 'expensesType' => 3
  11162. );
  11163. }
  11164. }
  11165. if (($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) && $abDetail ['expensesType'] == 2) {
  11166. if ($abDetail ['expenditureMsg'] == '公司固定')
  11167. $accountType = 9;
  11168. elseif ($abDetail ['expenditureMsg'] == '公司活期')
  11169. $accountType = 10;
  11170. }
  11171. if (($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) && $abDetail ['expensesType'] == 1) {
  11172. if ($abDetail ['accountMsg'] == '公司固定')
  11173. $accountType = 9;
  11174. elseif ($abDetail ['accountMsg'] == '公司活期')
  11175. $accountType = 10;
  11176. }
  11177. if ($abDetail ['accountMsg'] == '活期理财收益') {
  11178. $accountType = 10;
  11179. }
  11180. $accountBookStatistics->setAccountBookStatistics ( $item );
  11181. $accountBook->delete ( array (
  11182. 'where' => 'aid=' . $aid,
  11183. 'limit' => 1
  11184. ) );
  11185. // 删除收入流水
  11186. if (! empty ( $accountType )) {
  11187. Doo::loadModel ( 'wasteBook' );
  11188. $wasteBook = new wasteBook ();
  11189. $wasteBook->delete ( array (
  11190. 'where' => 'dataID=' . $aid . ' and accountType=' . $accountType,
  11191. 'limit' => 1
  11192. ) );
  11193. }
  11194. }
  11195. return '/paymentsAchieve';
  11196. }
  11197. function paymentsCollect() {
  11198. Doo::loadModel ( "execute" );
  11199. $execute = new execute ();
  11200. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11201. die ( 'illegal request' );
  11202. }
  11203. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11204. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  11205. Doo::loadModel ( "accountBookStatistics" );
  11206. $accountBookStatistics = new accountBookStatistics ();
  11207. Doo::loadClass ( 'receipt.func' );
  11208. $statisticsIncome = $accountBookStatistics->getStatisticsByCollect ( $year );
  11209. $html = _getPaymentsCollectByYearHtml ( $statisticsIncome );
  11210. $data ['html'] = $html ['html'];
  11211. $data ['inSum'] = $html ['sum'];
  11212. $statisticsPay = $accountBookStatistics->getStatisticsByCollect ( $year, 2 );
  11213. $html = _getPaymentsCollectPayByYearHtml ( $statisticsPay );
  11214. $data ['payHtml'] = $html ['html'];
  11215. $data ['paySum'] = $html ['sum'];
  11216. // 余额统计
  11217. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1 );
  11218. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2 );
  11219. include './protected/config/wasteBook.conf.php';
  11220. Doo::loadModel ( 'wasteBook' );
  11221. $wasteBook = new wasteBook ();
  11222. $inComePay = $wasteBook->getWasteBookByStatistics ( 1, $year );
  11223. $pay = $wasteBook->getWasteBookByStatistics ( 2, $year );
  11224. // 获得年份之前所有金额
  11225. $detail = $wasteBook->getWasteBookByStatisticsYear ( $year );
  11226. // print_r($detail);
  11227. // $waste['total'];
  11228. $lastBalanceHtml = '<tr><th colspan="2">截至上月余额</th>';
  11229. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11230. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11231. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11232. $inSum = $paySum = $showInSum = $showPaySum = $balanceSum = 0;
  11233. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11234. $limitMonth = date ( 'm' ); // 限制显示月份参数
  11235. if (date ( 'Y' ) > $year) {
  11236. $limitMonth = 12;
  11237. }
  11238. for($i = 1; $i <= 12; $i ++) {
  11239. $inComeA = $payB = 0;
  11240. $falg = true;
  11241. foreach ( $inComePay as $key => $value ) {
  11242. if ($value ['month'] == $i) {
  11243. $falg = false;
  11244. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11245. $inSum += $value ['accountPrice'];
  11246. $showInSum += $value ['accountPriceShow'];
  11247. $inComeA = $value ['accountPrice'];
  11248. break;
  11249. }
  11250. }
  11251. if ($falg)
  11252. $inComeHtml .= '<td class="taR">-</td>';
  11253. $payFalg = true;
  11254. foreach ( $pay as $key => $value ) {
  11255. if ($value ['month'] == $i) {
  11256. $payFalg = false;
  11257. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11258. $paySum += $value ['accountPrice'];
  11259. $showPaySum += $value ['accountPriceShow'];
  11260. $payB = $value ['accountPrice'];
  11261. break;
  11262. }
  11263. }
  11264. if ($payFalg)
  11265. $payHtml .= '<td class="taR">-</td>';
  11266. if (empty ( $balanceC ) || $limitMonth < $i)
  11267. $lastBalanceHtml .= '<td class="taR">-</td>';
  11268. else
  11269. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11270. $balanceC = $balanceC + $inComeA + $payB;
  11271. $balanceSum += $balanceC;
  11272. if (empty ( $balanceC ) || $limitMonth < $i)
  11273. $BalanceHtml .= '<td class="taR">-</td>';
  11274. else
  11275. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11276. // 余额统计
  11277. }
  11278. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11279. $data ['inComeHtml'] = $inComeHtml;
  11280. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11281. $data ['payBalanceHtml'] = $payHtml;
  11282. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11283. $data ['BalanceHtml'] = $BalanceHtml;
  11284. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11285. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11286. $mothHtml = "";
  11287. for($i = 1; $i <= 12; $i ++) {
  11288. if ($moth == $i)
  11289. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11290. else
  11291. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11292. }
  11293. $data ['mothHtml'] = $mothHtml;
  11294. $dateHtml = "";
  11295. $now = date ( "Y" );
  11296. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11297. if ($YEARD <= $now) {
  11298. $dateHtml .= '<option ';
  11299. if ($year == $YEARD) {
  11300. $dateHtml .= 'selected ';
  11301. }
  11302. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11303. }
  11304. }
  11305. $data ['dateHtml'] = $dateHtml;
  11306. $data ['year'] = $year;
  11307. $data ['memu'] = "receipt";
  11308. $data ['staff'] = $this->staff;
  11309. $data ['receiptMemu'] = 'paymentsCollect';
  11310. $data ['verifyId'] = $this->verifyId;
  11311. $data ['executeId'] = $this->executeId;
  11312. $this->render ( "/expenses/paymentsCollect", $data );
  11313. }
  11314. function paymentsCollectDay() {
  11315. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11316. $moth = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : '';
  11317. if (empty ( $moth ))
  11318. return 'paymentsCollect';
  11319. Doo::loadModel ( "accountBookStatistics" );
  11320. $accountBookStatistics = new accountBookStatistics ();
  11321. $i = 2;
  11322. $y = 2013;
  11323. $day = date ( "t", strtotime ( "$year-$moth" ) );
  11324. Doo::loadClass ( 'receipt.func' );
  11325. $statisticsIncome = $accountBookStatistics->getStatisticsByCollectDay ( $year, 1, $moth );
  11326. $html = _getPaymentsCollectByDayHtml ( $statisticsIncome, $day );
  11327. $data ['html'] = $html ['html'];
  11328. $data ['inSum'] = $html ['sum'];
  11329. $statisticsPay = $accountBookStatistics->getStatisticsByCollectDay ( $year, 2, $moth );
  11330. $html = _getPaymentsCollectPayByDayHtml ( $statisticsPay, $day );
  11331. $data ['payHtml'] = $html ['html'];
  11332. $data ['paySum'] = $html ['sum'];
  11333. $mothHtml = "";
  11334. for($i = 1; $i <= 12; $i ++) {
  11335. if ($moth == $i)
  11336. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11337. else
  11338. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11339. }
  11340. $data ['mothHtml'] = $mothHtml;
  11341. $data ['year'] = $year;
  11342. // 余额
  11343. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1, $moth );
  11344. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2, $moth );
  11345. include './protected/config/wasteBook.conf.php';
  11346. Doo::loadModel ( 'wasteBook' );
  11347. $wasteBook = new wasteBook ();
  11348. $inComePay = $wasteBook->getStatisticsByDay ( 1, $year, $moth );
  11349. $pay = $wasteBook->getStatisticsByDay ( 2, $year, $moth );
  11350. // 获得年份之前所有金额
  11351. $detail = $wasteBook->getWasteBookByStatisticsDay ( $year, $moth );
  11352. $lastBalanceHtml = '<tr><th colspan="2">截至上日余额</th>';
  11353. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11354. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11355. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11356. $dayHtml = '<tr><th class="taC" colspan="2">余额</th>';
  11357. $inSum = $paySum = $showPaySum = $showInSum = $balanceSum = 0;
  11358. // $balanceC = 0;
  11359. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11360. $limitDay = date ( 'd' );
  11361. $monthLK = ( int ) date ( 'm' );
  11362. if (date ( 'Y' ) > $year) {
  11363. $limitDay = cal_days_in_month ( CAL_GREGORIAN, date ( 'm' ), date ( 'Y' ) );
  11364. } elseif (date ( 'Y' ) <= $year && $monthLK < $moth) {
  11365. $limitDay = 0;
  11366. }
  11367. for($i = 1; $i <= $day; $i ++) {
  11368. $dayHtml .= '<td class="taC">' . $i . '日</td>';
  11369. $inComeA = $payB = 0;
  11370. $falg = true;
  11371. foreach ( $inComePay as $key => $value ) {
  11372. if ($value ['day'] == $i) {
  11373. $falg = false;
  11374. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11375. $inSum += $value ['accountPrice'];
  11376. $showInSum += $value ['accountPriceShow'];
  11377. $inComeA = $value ['accountPrice'];
  11378. break;
  11379. }
  11380. }
  11381. if ($falg)
  11382. $inComeHtml .= '<td class="taR">-</td>';
  11383. $payFalg = true;
  11384. foreach ( $pay as $key => $value ) {
  11385. if ($value ['day'] == $i) {
  11386. $payFalg = false;
  11387. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11388. $paySum += $value ['accountPrice'];
  11389. $showPaySum += $value ['accountPriceShow'];
  11390. $payB = $value ['accountPrice'];
  11391. break;
  11392. }
  11393. }
  11394. if ($payFalg)
  11395. $payHtml .= '<td class="taR">-</td>';
  11396. if (empty ( $balanceC ) || $limitDay < $i)
  11397. $lastBalanceHtml .= '<td class="taR">-</td>';
  11398. else
  11399. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11400. $balanceC = $balanceC + $inComeA + $payB;
  11401. $balanceSum += $balanceC;
  11402. if (empty ( $balanceC ) || $limitDay < $i)
  11403. $BalanceHtml .= '<td class="taR">-</td>';
  11404. else
  11405. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11406. }
  11407. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11408. $data ['inComeHtml'] = $inComeHtml;
  11409. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11410. $data ['payBalanceHtml'] = $payHtml;
  11411. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11412. $data ['BalanceHtml'] = $BalanceHtml;
  11413. $dayHtml .= '<td class="taR ">总计</td></tr>';
  11414. $data ['dayHtml'] = $dayHtml;
  11415. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11416. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11417. $dateHtml = "";
  11418. $now = date ( "Y" );
  11419. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11420. if ($YEARD <= $now) {
  11421. $dateHtml .= '<option ';
  11422. if ($year == $YEARD) {
  11423. $dateHtml .= 'selected ';
  11424. }
  11425. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11426. }
  11427. }
  11428. $data ['dateHtml'] = $dateHtml;
  11429. $data ['memu'] = "receipt";
  11430. $data ['staff'] = $this->staff;
  11431. $data ['receiptMemu'] = 'paymentsCollect';
  11432. $data ['verifyId'] = $this->verifyId;
  11433. $data ['executeId'] = $this->executeId;
  11434. $this->render ( "/expenses/paymentsCollectDay", $data );
  11435. }
  11436. // 公司流水
  11437. function wasteBook() {
  11438. Doo::loadModel ( "execute" );
  11439. $execute = new execute ();
  11440. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11441. die ( 'illegal request' );
  11442. }
  11443. include './protected/config/wasteBook.conf.php';
  11444. Doo::loadModel ( 'wasteBook' );
  11445. $wasteBook = new wasteBook ();
  11446. $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  11447. $waste = $this->getWasteBookStatistics ( $waste, $inComeStatistics );
  11448. $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'];
  11449. // print_r($waste);
  11450. $data ['waste'] = $waste;
  11451. $data ['total'] = $total;
  11452. // 月流水数据结构
  11453. $monthStatistics = array ();
  11454. $incomeMothStatistics = array ();
  11455. $expenditureMothStatistics = array ();
  11456. for($i = 1; $i <= 12; $i ++) {
  11457. $month = date ( 'Y' ) . '-' . $i;
  11458. if ($i < 10)
  11459. $month = date ( 'Y' ) . '-0' . $i;
  11460. array_push ( $monthStatistics, $month );
  11461. }
  11462. foreach ( $monthStatistics as $value ) {
  11463. $falg = true;
  11464. foreach ( $inComeStatistics ['incomeReport'] as $k => $v ) {
  11465. if ($value == $v ['inputDate']) {
  11466. array_push ( $incomeMothStatistics, $v ['accountPrice'] );
  11467. $falg = false;
  11468. }
  11469. }
  11470. if ($falg) {
  11471. array_push ( $incomeMothStatistics, '' );
  11472. }
  11473. $falgEx = true;
  11474. foreach ( $inComeStatistics ['expenditureReport'] as $k => $v ) {
  11475. if ($value == $v ['inputDate']) {
  11476. array_push ( $expenditureMothStatistics, $v ['accountPrice'] );
  11477. $falg = false;
  11478. }
  11479. }
  11480. if ($falgEx) {
  11481. array_push ( $expenditureMothStatistics, '' );
  11482. }
  11483. }
  11484. $data ['monthStatistics'] = json_encode ( $monthStatistics );
  11485. $data ['incomeMothStatistics'] = json_encode ( $incomeMothStatistics );
  11486. $data ['expenditureMothStatistics'] = json_encode ( $expenditureMothStatistics );
  11487. $expenditureList = $wasteBook->getAccountBookByExpensesType ( 4, 2 );
  11488. $incomeList = $wasteBook->getAccountBookByExpensesType ( 4, 1 );
  11489. // print_r($incomeList);
  11490. $data ['expenditureList'] = $expenditureList;
  11491. $data ['incomeList'] = $incomeList;
  11492. $data ['memu'] = "receipt";
  11493. $data ['staff'] = $this->staff;
  11494. $data ['receiptMemu'] = 'wasteBook';
  11495. $data ['verifyId'] = $this->verifyId;
  11496. $data ['executeId'] = $this->executeId;
  11497. $this->render ( "/expenses/wasteBook", $data );
  11498. }
  11499. function wasteBookIncome() {
  11500. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11501. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11502. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  11503. $dailyIncomeType = $this->get_args ( 'dailyIncomeType' ) ? $this->get_args ( 'dailyIncomeType' ) : "ALL";
  11504. $data ['dailyIncomeType'] = $dailyIncomeType;
  11505. Doo::loadModel ( 'wasteBook' );
  11506. $wasteBook = new wasteBook ();
  11507. Doo::loadModel ( 'L_category' );
  11508. $L_category = new L_category ();
  11509. Doo::loadClass ( 'XDeode' );
  11510. $XDeode = new XDeode ( 5 );
  11511. // echo $XDeode->encode(1).'<br>';
  11512. // echo $XDeode->encode(2).'<br>';
  11513. // echo $XDeode->encode(3).'<br>';
  11514. // echo $XDeode->encode(4).'<br>';
  11515. // echo $XDeode->encode(5).'<br>';
  11516. // echo $XDeode->encode(6).'<br>';
  11517. // echo $XDeode->encode(7).'<br>';
  11518. // echo $XDeode->encode(8).'<br>';
  11519. // echo $XDeode->encode(9).'<br>';
  11520. // echo $XDeode->encode(10).'<br>';
  11521. $dateArr = explode ( ':', $date );
  11522. $D1 = '';
  11523. $D2 = '';
  11524. $con = '';
  11525. if (! empty ( $date )) {
  11526. $D1 = $dateArr [0];
  11527. $D2 = $dateArr [1];
  11528. }
  11529. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11530. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11531. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11532. $con = ' and inputDate = "' . $D1 . '"';
  11533. if ($cid != 'ALL') {
  11534. $cid = $XDeode->decode ( $cid );
  11535. $con .= ' and cid = "' . $cid . '"';
  11536. }
  11537. if ($accountType != 'ALL') {
  11538. if ($accountType == 'INVOICE') {
  11539. $con .= ' and (accountType = 7 or accountType = 8)';
  11540. } elseif ($accountType == 'PAYMENTS') {
  11541. $con .= ' and (accountType = 6 or accountType = 9 or accountType = 10)';
  11542. if ($dailyIncomeType != 'ALL') {
  11543. $dailyIncomeType = $XDeode->decode ( $dailyIncomeType );
  11544. $con .= ' and dailyIncomeType = ' . $dailyIncomeType;
  11545. }
  11546. }
  11547. }
  11548. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 1, $con );
  11549. $sum = 0;
  11550. foreach ( $incomeList as $key => $value ) {
  11551. $sum += $value ['accountPrice'];
  11552. }
  11553. // print_r($incomeList);
  11554. // 获得办事和部门
  11555. $categoryList = $L_category->getCategory ();
  11556. $data ['accountType'] = $accountType;
  11557. $data ['cid'] = $cid;
  11558. $data ['categoryList'] = $categoryList;
  11559. $data ['sum'] = $sum;
  11560. $data ['incomeList'] = $incomeList;
  11561. $data ['inputDate'] = $date;
  11562. $data ['memu'] = "receipt";
  11563. $data ['staff'] = $this->staff;
  11564. $data ['receiptMemu'] = 'wasteBook';
  11565. $data ['verifyId'] = $this->verifyId;
  11566. $data ['executeId'] = $this->executeId;
  11567. $this->render ( "/expenses/wasteBookIncome", $data );
  11568. }
  11569. /**
  11570. * 所有支出
  11571. */
  11572. function wasteBookExpenditure() {
  11573. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11574. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11575. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  11576. $dailyExpenditureType = $this->get_args ( 'dailyExpenditureType' ) ? $this->get_args ( 'dailyExpenditureType' ) : "ALL";
  11577. $data ['dailyExpenditureType'] = $dailyExpenditureType;
  11578. $receiptType = $this->get_args ( 'receiptType' ) ? $this->get_args ( 'receiptType' ) : "ALL";
  11579. $data ['receiptType'] = $receiptType;
  11580. Doo::loadModel ( 'wasteBook' );
  11581. $wasteBook = new wasteBook ();
  11582. Doo::loadModel ( 'L_category' );
  11583. $L_category = new L_category ();
  11584. Doo::loadClass ( 'XDeode' );
  11585. $XDeode = new XDeode ( 5 );
  11586. $dateArr = explode ( ':', $date );
  11587. $D1 = '';
  11588. $D2 = '';
  11589. $con = '';
  11590. if (! empty ( $date )) {
  11591. $D1 = $dateArr [0];
  11592. $D2 = $dateArr [1];
  11593. }
  11594. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11595. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11596. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11597. $con = ' and inputDate = "' . $D1 . '"';
  11598. if ($cid != 'ALL') {
  11599. $cid = $XDeode->decode ( $cid );
  11600. $con .= ' and cid = "' . $cid . '"';
  11601. }
  11602. if ($accountType != 'ALL') {
  11603. if ($accountType == 'INVOICE') {
  11604. $con .= ' and accountType = 11';
  11605. } elseif ($accountType == 'PAYMENTS') {
  11606. $con .= ' and (accountType = 5 or accountType = 9 or accountType = 10)';
  11607. if ($dailyExpenditureType != 'ALL') {
  11608. $dailyExpenditureType = $XDeode->decode ( $dailyExpenditureType );
  11609. $con .= ' and dailyExpenditureType = ' . $dailyExpenditureType;
  11610. }
  11611. } elseif ($accountType == 'RECEIPT') {
  11612. if ($receiptType == 'ALL') {
  11613. $con .= ' and (accountType = 1 or accountType = 2 or accountType = 3 or accountType = 4)';
  11614. } else {
  11615. $receiptType = $XDeode->decode ( $receiptType );
  11616. echo $receiptType;
  11617. if ($receiptType == 1) {
  11618. $con .= ' and (accountType = 1 or accountType=2)';
  11619. } else {
  11620. $con .= ' and accountType = ' . $receiptType;
  11621. }
  11622. }
  11623. }
  11624. }
  11625. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 2, $con );
  11626. $sum = 0;
  11627. foreach ( $incomeList as $key => $value ) {
  11628. $sum += $value ['accountPriceShow'];
  11629. }
  11630. // print_r($incomeList);
  11631. // 获得办事和部门
  11632. $categoryList = $L_category->getCategory ();
  11633. $data ['accountType'] = $accountType;
  11634. $data ['cid'] = $cid;
  11635. $data ['categoryList'] = $categoryList;
  11636. $data ['sum'] = $sum;
  11637. $data ['incomeList'] = $incomeList;
  11638. $data ['inputDate'] = $date;
  11639. $data ['memu'] = "receipt";
  11640. $data ['staff'] = $this->staff;
  11641. $data ['receiptMemu'] = 'wasteBook';
  11642. $data ['verifyId'] = $this->verifyId;
  11643. $data ['executeId'] = $this->executeId;
  11644. $this->render ( "/expenses/wasteBookExpenditure", $data );
  11645. }
  11646. function ajaxGetWasteinvoiceReceivables() {
  11647. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11648. Doo::loadClass ( 'XDeode' );
  11649. $XDeode = new XDeode ( 5 );
  11650. $irid = $XDeode->decode ( $serial );
  11651. Doo::loadModel ( 'invoiceReceivables' );
  11652. $invoiceReceivables = new invoiceReceivables ();
  11653. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  11654. echo json_encode ( array (
  11655. 'status' => 1,
  11656. 'detail' => $detail
  11657. ) );
  11658. }
  11659. function ajaxGetPaymentsByAid() {
  11660. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11661. Doo::loadModel ( "accountBook" );
  11662. $accountBook = new accountBook ();
  11663. $detail = $accountBook->getAccountBookByAid ( $serial );
  11664. echo json_encode ( array (
  11665. 'status' => 1,
  11666. 'detail' => $detail
  11667. ) );
  11668. }
  11669. function ajaxGetWasteInvoice() {
  11670. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11671. Doo::loadModel ( 'invoice' );
  11672. $invoice = new invoice ();
  11673. Doo::loadModel ( 'invoiceReceivables' );
  11674. $invoiceReceivables = new invoiceReceivables ();
  11675. $detail = $invoice->getInvoiceByIid ( $serial );
  11676. $detailReceivables = $invoiceReceivables->getInvoiceReceivablesByIrid ( $detail ['irid'] );
  11677. $detail ['receivablesBank'] = $detailReceivables ['receivablesBank'];
  11678. echo json_encode ( array (
  11679. 'status' => 1,
  11680. 'detail' => $detail
  11681. ) );
  11682. }
  11683. /**
  11684. */
  11685. function ajaxGetWasteReceipt() {
  11686. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11687. $accountTypeKey = $this->get_args ( 'accountTypeKey' ) ? $this->get_args ( 'accountTypeKey' ) : "";
  11688. Doo::loadModel ( 'receipt' );
  11689. $receipt = new receipt ();
  11690. Doo::loadClass ( 'XDeode' );
  11691. $XDeode = new XDeode ( 5 );
  11692. $rid = $XDeode->decode ( $serial );
  11693. $accountType= $XDeode->decode ( $accountTypeKey );
  11694. // 获得个数据
  11695. $detail = $receipt->getReceiptByRid ( $rid );
  11696. // 初始化
  11697. $detail ['reviseDetail'] = array ();
  11698. if (! empty ( $value ['reviseDetail'] ))
  11699. $detail ['reviseDetail'] = json_decode ( $detail ['reviseDetail'], true );
  11700. $detail ['accountItem'] = json_decode ( $detail ['accountItem'], true );
  11701. $detail ['loanItem'] = json_decode ( $detail ['loanItem'], true );
  11702. $detail ['loanSumCN'] = $this->num_to_rmb ( $detail ['loanSum'] );
  11703. $detail ['sumCN'] = $this->num_to_rmb ( $detail ['sum'] );
  11704. // 获得费用html
  11705. $html = $this->getWasteReceiptHtml ( $detail ,$accountType);
  11706. // 获得费用审批人数据
  11707. $detail = $this->getReceiptApproverHtml ( $detail );
  11708. // 审批执行
  11709. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  11710. <th class="taC" width="90">审批人</th>
  11711. <th class="taC">审批意见</th></tr>';
  11712. foreach ( $detail ['verifyList'] as $key => $value ) {
  11713. $html .= '<tr>
  11714. <td>' . $value [1] . '</td>
  11715. <td>' . $value ['opinion'] . '</td>
  11716. </tr>
  11717. ';
  11718. }
  11719. $html .= ' </tbody></table>';
  11720. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  11721. <th class="taC" width="90">执行人</th>
  11722. <th class="taC">执行意见</th></tr>';
  11723. foreach ( $detail ['executeCopy'] as $key => $value ) {
  11724. $html .= '<tr>
  11725. <td>' . $value [1] . '</td>
  11726. <td>' . $value ['opinion'] . '</td>
  11727. </tr>
  11728. ';
  11729. }
  11730. $html .= ' </tbody></table>';
  11731. if($accountType==1){
  11732. Doo::loadModel ( 'loanReceipt' );
  11733. $loanReceipt = new loanReceipt ();
  11734. $loanList = $loanReceipt->getOne ( array (
  11735. 'where' => 'rid=' . $detail ['loanRid'],
  11736. 'desc' => 'rid',
  11737. 'asArray' => true
  11738. ) );
  11739. $html .= '<table class="table table-bordered table-condensed">
  11740. <tr class="warning">
  11741. <td class="taR"><b>汇款金额</b></td>
  11742. <td width="140" class="taR"><b style="font-size: 24px">¥'.$loanList['amount'].'</b></td>
  11743. </tr>
  11744. </table>';
  11745. }else{
  11746. $html .= '<table class="table table-bordered table-condensed">
  11747. <tr class="warning">
  11748. <td class="taR"><b>汇款金额</b></td>
  11749. <td width="140" class="taR"><b style="font-size: 24px">¥' . $detail ['amount'] . '</b></td>
  11750. </tr>
  11751. </table>';
  11752. }
  11753. // print_r($detail['verifyList']);
  11754. // header ( 'Content-Type:text/html;charset=utf-8' );
  11755. // echo $html;
  11756. echo json_encode ( array (
  11757. 'status' => 1,
  11758. 'html' => $html,
  11759. 'detail' => $detail
  11760. ) );
  11761. }
  11762. function getReceiptApproverHtml($detail = array()) {
  11763. Doo::loadModel ( 'loanReceipt' );
  11764. $loanReceipt = new loanReceipt ();
  11765. Doo::loadModel ( 'verify' );
  11766. $verify = new verify ();
  11767. Doo::loadModel ( 'staff' );
  11768. $staff = new staff ();
  11769. if (empty ( $detail ))
  11770. return array ();
  11771. $loanList = $loanReceipt->getOne ( array (
  11772. 'where' => 'rid=' . $detail ['loanRid'],
  11773. 'desc' => 'rid',
  11774. 'asArray' => true
  11775. ) );
  11776. if ($detail ['status'] == 3 || $detail ['status'] == 1 || $detail ['status'] == 8 || $detail ['status'] == 9) {
  11777. if ($detail ['status'] == 8 && $detail ['Rtype'] == 1)
  11778. $verifyList ['staff'] = $loanList ['verifyBreakup'];
  11779. else
  11780. $verifyList ['staff'] = $detail ['verifyBreakup'];
  11781. } else
  11782. $verifyList = $verify->getOne ( array (
  11783. 'where' => 'vid=' . $detail ['verify'],
  11784. 'asArray' => true
  11785. ) );
  11786. $verifyList = json_decode ( $verifyList ['staff'], true );
  11787. Doo::loadModel ( 'role' );
  11788. $role = new role ();
  11789. $roleId = 0;
  11790. $flag = true;
  11791. $roleKey = 0;
  11792. $endStaffArray = array ();
  11793. $roleArrayCopy = array ();
  11794. foreach ( $verifyList as $k => $v ) {
  11795. // init verifyStaff
  11796. if ($v [1] == 'ROLE') {
  11797. if (! empty ( $verifyStaff )) {
  11798. $endStaffArray = end ( $verifyStaff );
  11799. }
  11800. $roleVerify = json_decode ( $v [3], true );
  11801. $roleKey = $k;
  11802. $roleArray = array ();
  11803. $rolename = $role->getOne ( array (
  11804. 'where' => 'rid=' . $v [0],
  11805. 'asArray' => true
  11806. ) );
  11807. foreach ( $roleVerify as $o => $p ) {
  11808. $staffID = explode ( '_', $p );
  11809. $staffInfo = $staff->getOne ( array (
  11810. 'where' => 'sid=' . $staffID [0],
  11811. 'asArray' => true
  11812. ) );
  11813. // print_r($staffID);
  11814. $exp = array (
  11815. 0 => $staffInfo ['sid'],
  11816. 1 => $staffID [1],
  11817. 2 => $staffInfo ['avatar'],
  11818. 'date' => '',
  11819. 'date' => '',
  11820. 'opinion' => '',
  11821. 'status' => '',
  11822. 'rolename' => $rolename ['name']
  11823. );
  11824. array_push ( $roleArray, $exp );
  11825. }
  11826. $roleArrayCopy [$v [0]] = $roleArray;
  11827. // $verifyList[$k]['roleArray']=$roleArray;
  11828. }
  11829. $verifyList [$k] ['date'] = "";
  11830. $verifyList [$k] ['opinion'] = "";
  11831. $verifyList [$k] ['status'] = "";
  11832. if (empty ( $verifyStaff )) {
  11833. $verifyList [$k] ['date'] = "";
  11834. $verifyList [$k] ['opinion'] = "";
  11835. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  11836. $verifyList [$k] ['status'] = 4;
  11837. $flag = false;
  11838. }
  11839. } else {
  11840. foreach ( $verifyStaff as $m => $u ) {
  11841. if ($v [0] == $m) {
  11842. $verifyList [$k] ['date'] = $u ['date'];
  11843. $verifyList [$k] ['opinion'] = $u ['opinion'];
  11844. $verifyList [$k] ['status'] = $u ['status'];
  11845. $flag = false;
  11846. break;
  11847. }
  11848. }
  11849. $endStaffArray = end ( $verifyStaff );
  11850. }
  11851. }
  11852. $rolename ['name'] = '';
  11853. if (! empty ( $roleId )) {
  11854. Doo::loadModel ( 'role' );
  11855. $role = new role ();
  11856. $rolename = $role->getOne ( array (
  11857. 'where' => 'rid=' . $roleId,
  11858. 'asArray' => true
  11859. ) );
  11860. }
  11861. if (! empty ( $verifyStaff ))
  11862. $endStaffArray = end ( $verifyStaff );
  11863. $KOP = false;
  11864. foreach ( $roleArrayCopy as $P => $A ) {
  11865. foreach ( $A as $MKI => $AVL ) {
  11866. if (! empty ( $verifyStaff )) {
  11867. // &&$rolename['rid']==$endStaffArray['nextStaff']
  11868. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  11869. $button = 4;
  11870. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  11871. }
  11872. foreach ( $verifyStaff as $m => $u ) {
  11873. $AVLFK = $AVL [0] . '_R';
  11874. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  11875. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  11876. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  11877. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  11878. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  11879. break;
  11880. }
  11881. }
  11882. } else {
  11883. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  11884. $button = 4;
  11885. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  11886. }
  11887. }
  11888. // $roleArray[$MKI]['rolename']=$rolename['name'];
  11889. $KOP = true;
  11890. }
  11891. }
  11892. foreach ( $roleArrayCopy as $k => $v ) {
  11893. foreach ( $verifyList as $m => $n ) {
  11894. if ($n [0] == $k) {
  11895. array_splice ( $verifyList, $m, 1, $v );
  11896. }
  11897. }
  11898. }
  11899. // 费用执行人相关数据
  11900. $executeCopy = json_decode ( $detail ['executeCopy'], true );
  11901. $executeStaff = json_decode ( $detail ['executeStaff'], true );
  11902. foreach ( $executeCopy as $k => $v ) {
  11903. $executeCopy [$k] ['date'] = '';
  11904. $executeCopy [$k] ['opinion'] = '';
  11905. $executeCopy [$k] ['status'] = '';
  11906. if (! empty ( $executeStaff ))
  11907. foreach ( $executeStaff as $m => $u ) {
  11908. if ($v [0] == $m) {
  11909. $executeCopy [$k] ['date'] = $u ['date'];
  11910. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  11911. $executeCopy [$k] ['status'] = $u ['status'];
  11912. break;
  11913. }
  11914. }
  11915. }
  11916. $detail ['executeCopy'] = $executeCopy;
  11917. $detail ['verifyList'] = $verifyList;
  11918. return $detail;
  11919. }
  11920. function getWasteReceiptHtml($detail = array(),$accountType=1) {
  11921. if (empty ( $detail ))
  11922. return '';
  11923. $html = '';
  11924. if ($detail ['Rtype'] == 0) { // 报销单
  11925. $html .= '<table class="table table-bordered table-condensed">
  11926. <tbody>
  11927. <tr>
  11928. <th colspan="2" class="taC">日常相关费用</th>
  11929. </tr>';
  11930. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  11931. $html .= '
  11932. <tr>
  11933. <th>' . $value ['name'] . '</th>
  11934. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11935. </tr>';
  11936. }
  11937. $html .= '
  11938. <tr>
  11939. <th class="taR">合计</th>
  11940. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  11941. </tr>';
  11942. $html .= '<tr>
  11943. <th colspan="2" class="taC">差旅相关费用</th>
  11944. </tr>';
  11945. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  11946. $html .= '
  11947. <tr>
  11948. <th>' . $value ['name'] . '</th>
  11949. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11950. </tr>';
  11951. }
  11952. $html .= '
  11953. <tr>
  11954. <th class="taR">合计</th>
  11955. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  11956. </tr>';
  11957. if(isset($detail ['accountItem'] ['内部培训费用'])){
  11958. $html .= '<tr>
  11959. <th colspan="2" class="taC">内部培训费用</th>
  11960. </tr>';
  11961. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  11962. $html .= '
  11963. <tr>
  11964. <th>' . $value ['name'] . '</th>
  11965. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11966. </tr>';
  11967. }
  11968. $html .= '
  11969. <tr>
  11970. <th class="taR">合计</th>
  11971. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  11972. </tr>';
  11973. }
  11974. $html .= '<tr>
  11975. <th colspan="2" class="taC">其他</th>
  11976. </tr>';
  11977. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  11978. $html .= '
  11979. <tr>
  11980. <th>' . $value ['name'] . '</th>
  11981. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11982. </tr>';
  11983. }
  11984. $html .= '
  11985. <tr>
  11986. <th class="taR">合计</th>
  11987. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  11988. </tr>';
  11989. $html .= '<tr>
  11990. <th colspan="2" class="taC">报销金额调整</th>
  11991. </tr>';
  11992. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  11993. $html .= '
  11994. <tr>
  11995. <th>' . $value ['name'] . '</th>
  11996. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11997. </tr>';
  11998. }
  11999. $html .= '
  12000. <tr>
  12001. <th class="taR">合计</th>
  12002. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12003. </tr>';
  12004. $html .= '
  12005. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12006. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12007. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12008. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12009. <tr class="warning">
  12010. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12011. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12012. </tr>
  12013. </tbody>
  12014. </table>';
  12015. } elseif ($detail ['Rtype'] == 2) {//对公汇款
  12016. $html .= '
  12017. <table class="table table-bordered table-condensed">
  12018. <tbody>
  12019. <tr>
  12020. <th colspan="2" class="taC">办事处相关费用</th>
  12021. </tr>';
  12022. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12023. $html .= '
  12024. <tr>
  12025. <th>' . $value ['name'] . '</th>
  12026. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12027. </tr>';
  12028. }
  12029. $html .= '
  12030. <tr>
  12031. <th class="taR">合计</th>
  12032. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12033. </tr>';
  12034. $html .= '
  12035. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12036. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12037. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12038. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12039. <tr class="warning">
  12040. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12041. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12042. </tr>
  12043. </tbody>
  12044. </table>';
  12045. } elseif ($detail ['Rtype'] == 1) {//借款 或者借款报销
  12046. Doo::loadModel ( 'loanReceipt' );
  12047. $loanReceipt = new loanReceipt ();
  12048. $loanList = $loanReceipt->getOne ( array (
  12049. 'where' => 'rid=' . $detail ['loanRid'],
  12050. 'desc' => 'rid',
  12051. 'asArray' => true
  12052. ) );
  12053. // print_r($loanList);
  12054. $loanList ['sumCN']=$this->num_to_rmb($loanList ['sum']);
  12055. $html .= '<table class="table table-bordered table-condensed">
  12056. <tbody>
  12057. <tr>
  12058. <th colspan="2" class="taC">借款费用</th>
  12059. </tr>';
  12060. foreach ( $detail ['loanItem'] ['借款费用'] as $key => $value ) {
  12061. $html .= '<tr>
  12062. <th>' . $value ['name'] . '</th>
  12063. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12064. </tr>';
  12065. }
  12066. $html .= '<tr>
  12067. <th class="taC" colspan="2">产生费用所在办事处</th>
  12068. </tr>
  12069. <tr>
  12070. <th style="text-align: center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th>
  12071. </tr>
  12072. <tr>
  12073. <th class="taC" colspan="2">费用说明</th>
  12074. </tr>
  12075. <tr>
  12076. <td colspan="2">' . $loanList ['explanation'] . '</td>
  12077. </tr>
  12078. <tr class="warning">
  12079. <td class="taR"><b>(' . $loanList ['receiptOrder'] . ')本次费用合计</b></td>
  12080. <td class="taR"><b style="font-size: 24px">¥' . $loanList ['sum'] . '</b><br>' . $loanList ['sumCN'] . '</td>
  12081. </tr>
  12082. </tbody>
  12083. </table>
  12084. ';
  12085. if ( $accountType==2) {
  12086. $balance=$detail ['sum']-$loanList ['sum'];
  12087. $balanceCN=$this->num_to_rmb($balance);
  12088. $html .= '<table class="table table-bordered table-condensed">
  12089. <tbody>
  12090. <tr>
  12091. <th colspan="2" class="taC">日常相关费用</th>
  12092. </tr>';
  12093. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12094. $html .= '
  12095. <tr>
  12096. <th>' . $value ['name'] . '</th>
  12097. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12098. </tr>';
  12099. }
  12100. $html .= '
  12101. <tr>
  12102. <th class="taR">合计</th>
  12103. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12104. </tr>';
  12105. $html .= '<tr>
  12106. <th colspan="2" class="taC">差旅相关费用</th>
  12107. </tr>';
  12108. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12109. $html .= '
  12110. <tr>
  12111. <th>' . $value ['name'] . '</th>
  12112. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12113. </tr>';
  12114. }
  12115. $html .= '
  12116. <tr>
  12117. <th class="taR">合计</th>
  12118. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12119. </tr>';
  12120. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12121. $html .= '<tr>
  12122. <th colspan="2" class="taC">内部培训费用</th>
  12123. </tr>';
  12124. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12125. $html .= '
  12126. <tr>
  12127. <th>' . $value ['name'] . '</th>
  12128. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12129. </tr>';
  12130. }
  12131. $html .= '
  12132. <tr>
  12133. <th class="taR">合计</th>
  12134. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12135. </tr>';
  12136. }
  12137. $html .= '<tr>
  12138. <th colspan="2" class="taC">其他</th>
  12139. </tr>';
  12140. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12141. $html .= '
  12142. <tr>
  12143. <th>' . $value ['name'] . '</th>
  12144. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12145. </tr>';
  12146. }
  12147. $html .= '
  12148. <tr>
  12149. <th class="taR">合计</th>
  12150. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12151. </tr>';
  12152. $html .= '<tr>
  12153. <th colspan="2" class="taC">报销金额调整</th>
  12154. </tr>';
  12155. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12156. $html .= '
  12157. <tr>
  12158. <th>' . $value ['name'] . '</th>
  12159. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12160. </tr>';
  12161. }
  12162. $html .= '
  12163. <tr>
  12164. <th class="taR">合计</th>
  12165. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12166. </tr>';
  12167. $html .= '
  12168. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12169. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12170. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12171. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12172. <tr class="warning">
  12173. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12174. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12175. </tr>
  12176. <tr class="success">
  12177. <td class="taR"><b>借款结余</b></td>
  12178. <td class="taR"><b style="font-size:24px">¥'.$balance.'</b><br>'.$balanceCN.'</td>
  12179. </tr>
  12180. </tbody>
  12181. </table>';
  12182. }
  12183. }
  12184. return $html;
  12185. }
  12186. /**
  12187. * 计算流水
  12188. */
  12189. function getWasteBookStatistics($waste = array(), $inComeStatistics) {
  12190. $bakWaste ['bank'] = array (
  12191. 'CGBDeposit' => 0,
  12192. 'ICBCDeposit' => 0,
  12193. 'HUADeposit' => 0,
  12194. 'PersonalDeposit' => 0
  12195. );
  12196. $bakWaste ['financial'] = array (
  12197. 'current' => array (
  12198. 'CGBDeposit' => 0,
  12199. 'ICBCDeposit' => 0
  12200. ),
  12201. 'fixed' => array (
  12202. 'CGBDeposit' => 0,
  12203. 'ICBCDeposit' => 0
  12204. )
  12205. );
  12206. // 存款
  12207. foreach ( $waste ['bank'] as $key => $value ) {
  12208. // 收入
  12209. foreach ( $inComeStatistics ['incomeStatistics'] as $k => $v ) {
  12210. // 广发
  12211. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12212. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12213. }
  12214. // 工商
  12215. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12216. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12217. }
  12218. // 华润
  12219. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12220. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12221. }
  12222. // 个人
  12223. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12224. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12225. }
  12226. }
  12227. }
  12228. foreach ( $waste ['bank'] as $key => $value ) {
  12229. // 支出
  12230. foreach ( $inComeStatistics ['expenditureStatistics'] as $k => $v ) {
  12231. // 广发
  12232. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12233. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12234. }
  12235. // 工商
  12236. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12237. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12238. }
  12239. // 华润
  12240. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12241. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12242. }
  12243. // 个人
  12244. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12245. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12246. }
  12247. }
  12248. }
  12249. // 活期
  12250. foreach ( $waste ['financial'] ['current'] as $key => $value ) {
  12251. foreach ( $inComeStatistics ['currentStatistics'] as $k => $v ) {
  12252. // 广发
  12253. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12254. $waste ['financial'] ['current'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  12255. }
  12256. // 工商
  12257. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12258. $waste ['financial'] ['current'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  12259. }
  12260. // 个人
  12261. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12262. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  12263. }
  12264. }
  12265. }
  12266. // print_r($inComeStatistics ['fixedStatistics']);
  12267. // 固期
  12268. foreach ( $waste ['financial'] ['fixed'] as $key => $value ) {
  12269. foreach ( $inComeStatistics ['fixedStatistics'] as $k => $v ) {
  12270. // 广发
  12271. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12272. $waste ['financial'] ['fixed'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  12273. }
  12274. // 工商
  12275. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12276. $waste ['financial'] ['fixed'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  12277. }
  12278. // 个人
  12279. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12280. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  12281. }
  12282. }
  12283. }
  12284. return $waste;
  12285. }
  12286. function lyt() {
  12287. Doo::loadModel ( "receiptDetail" );
  12288. $receiptDetail = new receiptDetail ();
  12289. $receiptCollectList = $receiptDetail->find ( array (
  12290. 'where' => 'status=1 ',
  12291. 'asArray' => true
  12292. ) );
  12293. foreach ( $receiptCollectList as $key => $value ) {
  12294. $receiptDetail = new receiptDetail ();
  12295. $receiptDetail->pastDate = $value ['date'];
  12296. $receiptDetail->update ( array (
  12297. 'where' => "rdid= '" . $value ['rdid'] . "'"
  12298. ) );
  12299. }
  12300. }
  12301. function staffCollectMonthDetail() {
  12302. //include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  12303. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12304. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12305. if (! $year)
  12306. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12307. if (! $month)
  12308. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12309. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  12310. if (! $nature){
  12311. $nature = isset ( $this->params ['nature'] ) ? $this->params ['nature'] : 'ONJOB';
  12312. }
  12313. Doo::loadModel ( 'staff' );
  12314. $staff = new staff ();
  12315. Doo::loadModel ( "receiptDetail" );
  12316. $receiptDetail = new receiptDetail ();
  12317. Doo::loadModel ( 'accountItem' );
  12318. $accountItem = new accountItem ();
  12319. Doo::loadModel ( 'statistics' );
  12320. $statistics = new statistics ();
  12321. Doo::loadModel ( "receiptAuthorityManage" );
  12322. $receiptAuthorityManage = new receiptAuthorityManage ();
  12323. $aiList=$accountItem->getAccountItem();
  12324. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  12325. $cidList = array ();
  12326. foreach ( $imcStaff as $key => $value ) {
  12327. array_push ( $cidList, $value ['cid'] );
  12328. }
  12329. $cidString = implode ( ',', $cidList );
  12330. $naturecon='';
  12331. if ($nature=='ONJOB'){
  12332. $naturecon=' and (nature!=4 )';
  12333. }elseif($nature=='LEAVEJOB'){
  12334. $naturecon=' and (nature=4 )';
  12335. }else{
  12336. die ( 'illegal request--nature' );
  12337. }
  12338. $staffList = $staff->find ( array (
  12339. 'where' => 'username!="admin" and cid in (' . $cidString . ')'.$naturecon,
  12340. 'asArray' => true
  12341. ) );
  12342. $categoryList = $staff->find ( array (
  12343. 'select' => 'COUNT(*) as count,cid,category',
  12344. 'where' => 'username !="admin" and cid in (' . $cidString . ')'.$naturecon,
  12345. 'groupby' => 'cid',
  12346. 'asArray' => true
  12347. ) );
  12348. $list = array ();
  12349. foreach($aiList as $key=>$value){
  12350. foreach ($value as $v){
  12351. $subtotal[$key][$v['name']]=0;
  12352. }
  12353. }
  12354. foreach ( $categoryList as $vlu ) {
  12355. $s1 = 0;
  12356. $m1 = 0;
  12357. $subtotal[$this->AGENCY]['AGENCY']=$subtotal[$this->TRAVEL]['TRAVEL']=$subtotal[$this->INTTRAIN]['INTTRAIN']=$subtotal[$this->TRAIN]['TRAIN']=$subtotal[$this->OTHER]['OTHER']=0;
  12358. foreach ( $staffList as $value ) {
  12359. if ($vlu ['cid'] == $value ['cid']) {
  12360. // pastDate
  12361. $receiptCollectList = $receiptDetail->find ( array (
  12362. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12363. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12364. 'groupby' => 'item,Month(pastDate),itemCategory',
  12365. 'asArray' => true
  12366. ) );
  12367. if (! empty ( $receiptCollectList )) {
  12368. $receiptL = array (
  12369. '日常相关费用' => array (),
  12370. '差旅相关费用' => array (),
  12371. '内部培训费用' => array (),
  12372. '培训班费用' => array (),
  12373. '其他' => array ()
  12374. );
  12375. $html = "";
  12376. $psum = 0;
  12377. foreach ( $aiList[$this->AGENCY] as $va ) {
  12378. $falg = true;
  12379. foreach ( $receiptCollectList as $v ) {
  12380. if ($v ['itemCategory'] == '日常相关费用') {
  12381. if ($v ['item'] == $va['name']) {
  12382. $subtotal[$this->AGENCY][$va['name']]+=$v ['price'];
  12383. $psum += $v ['price'];
  12384. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12385. $falg = false;
  12386. break;
  12387. }
  12388. }
  12389. }
  12390. if ($falg)
  12391. $html .= '<td class="taR">-</td>';
  12392. }
  12393. $subtotal[$this->AGENCY]['AGENCY'] += $psum;
  12394. if (! empty ( $psum ))
  12395. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12396. else
  12397. $psum = '<td class="colGreen taR">-</td>';
  12398. $receiptL ['日常相关费用'] = $psum . $html;
  12399. /* ----------------------------------- */
  12400. $html = "";
  12401. $psum = 0;
  12402. foreach ( $aiList[$this->TRAVEL] as $va ) {
  12403. $falg = true;
  12404. foreach ( $receiptCollectList as $v ) {
  12405. if ($v ['itemCategory'] == '差旅相关费用') {
  12406. if ($v ['item'] == $va['name']) {
  12407. $subtotal[$this->TRAVEL][$va['name']]+=$v ['price'];
  12408. $psum += $v ['price'];
  12409. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12410. $falg = false;
  12411. break;
  12412. }
  12413. }
  12414. }
  12415. if ($falg)
  12416. $html .= '<td class="taR">-</td>';
  12417. }
  12418. $subtotal[$this->TRAVEL]['TRAVEL'] += $psum;
  12419. if (! empty ( $psum ))
  12420. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12421. else
  12422. $psum = '<td class="colGreen taR">-</td>';
  12423. $receiptL ['差旅相关费用'] = $psum . $html;
  12424. /* ------------------------------------- */
  12425. $html = "";
  12426. $psum = 0;
  12427. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  12428. $falg = true;
  12429. foreach ( $receiptCollectList as $v ) {
  12430. if ($v ['itemCategory'] == '内部培训费用') {
  12431. if ($v ['item'] == $va['name']) {
  12432. $subtotal[$this->INTTRAIN][$va['name']]+=$v ['price'];
  12433. $psum += $v ['price'];
  12434. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12435. $falg = false;
  12436. break;
  12437. }
  12438. }
  12439. }
  12440. if ($falg)
  12441. $html .= '<td class="taR">-</td>';
  12442. }
  12443. $subtotal[$this->INTTRAIN]['INTTRAIN'] += $psum;
  12444. if (! empty ( $psum ))
  12445. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12446. else
  12447. $psum = '<td class="colGreen taR">-</td>';
  12448. $receiptL ['内部培训费用'] = $psum . $html;
  12449. /* ----------------------------------- */
  12450. $html = "";
  12451. $psum = 0;
  12452. foreach ( $aiList[$this->TRAIN] as $va ) {
  12453. $falg = true;
  12454. foreach ( $receiptCollectList as $v ) {
  12455. if ($v ['itemCategory'] == '培训班费用') {
  12456. if ($v ['item'] == $va['name']) {
  12457. $subtotal[$this->TRAIN][$va['name']]+=$v ['price'];
  12458. $psum += $v ['price'];
  12459. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12460. $falg = false;
  12461. break;
  12462. }
  12463. }
  12464. }
  12465. if ($falg)
  12466. $html .= '<td class="taR">-</td>';
  12467. }
  12468. $subtotal[$this->TRAIN]['TRAIN'] += $psum;
  12469. if (! empty ( $psum ))
  12470. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12471. else
  12472. $psum = '<td class="colGreen taR">-</td>';
  12473. $receiptL ['培训班费用'] = $psum . $html;
  12474. /* ------------------------------------- */
  12475. $html = "";
  12476. $psum = 0;
  12477. foreach ( $aiList[$this->OTHER] as $va ) {
  12478. $falg = true;
  12479. foreach ( $receiptCollectList as $v ) {
  12480. if ($v ['itemCategory'] == '其他') {
  12481. if (trim ( $v ['item'] ) == $va['name']) {
  12482. $subtotal[$this->OTHER][$va['name']]+=$v ['price'];
  12483. $psum += $v ['price'];
  12484. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12485. $falg = false;
  12486. break;
  12487. }
  12488. }
  12489. }
  12490. if ($falg)
  12491. $html .= '<td class="taR">-</td>';
  12492. }
  12493. $subtotal[$this->OTHER]['OTHER'] += $psum;
  12494. if (! empty ( $psum ))
  12495. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12496. else
  12497. $psum = '<td class="colGreen taR">-</td>';
  12498. $receiptL ['其他'] = $psum . $html;
  12499. /* ------------------------------------- */
  12500. $html = "";
  12501. $psum = 0;
  12502. foreach ( $receiptCollectList as $v ) {
  12503. if ($v ['itemCategory'] == '报销金额调整') {
  12504. if (! empty ( $v ['price'] )) {
  12505. $psum += $v ['price'];
  12506. }
  12507. }
  12508. }
  12509. $s1 += $psum;
  12510. if (! empty ( $psum ))
  12511. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  12512. else
  12513. $psum = '<td class="taR colOrange">-</td>';
  12514. $receiptL ['报销金额调整'] = $psum . $html;
  12515. } else {
  12516. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  12517. foreach ( $aiList[$this->AGENCY] as $va ) {
  12518. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  12519. }
  12520. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  12521. foreach ( $aiList[$this->TRAVEL] as $va ) {
  12522. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  12523. }
  12524. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  12525. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  12526. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  12527. }
  12528. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  12529. foreach ( $aiList[$this->TRAIN] as $va ) {
  12530. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  12531. }
  12532. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  12533. foreach ( $aiList[$this->OTHER] as $va ) {
  12534. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  12535. }
  12536. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  12537. }
  12538. $monthStaffPrice = $receiptDetail->find ( array (
  12539. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12540. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12541. 'groupby' => 'Month(pastDate)',
  12542. 'asArray' => true
  12543. ) );
  12544. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  12545. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  12546. $m1 += $monthStaffPrice [0] ['price'];
  12547. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  12548. } else
  12549. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  12550. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  12551. $list [$value ['username']] = $receiptL;
  12552. }
  12553. }
  12554. $receiptL [$this->AGENCY] ='<td class="colGreen taR">'.$subtotal[$this->AGENCY]['AGENCY'].'</td>';
  12555. foreach ( $aiList[$this->AGENCY] as $va ) {
  12556. $receiptL [$this->AGENCY] .='<td class="taR">' . $subtotal[$this->AGENCY][$va['name']] . '</td>';
  12557. $subtotal[$this->AGENCY][$va['name']]=0;
  12558. }
  12559. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">'.$subtotal[$this->TRAVEL]['TRAVEL'].'</td>';
  12560. foreach ( $aiList[$this->TRAVEL] as $va ) {
  12561. $receiptL [$this->TRAVEL] .='<td class="taR">' . $subtotal[$this->TRAVEL][$va['name']] . '</td>';
  12562. $subtotal[$this->TRAVEL][$va['name']]=0;
  12563. }
  12564. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">'.$subtotal[$this->INTTRAIN]['INTTRAIN'].'</td>';
  12565. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  12566. $receiptL [$this->INTTRAIN] .='<td class="taR">' . $subtotal[$this->INTTRAIN][$va['name']] . '</td>';
  12567. $subtotal[$this->INTTRAIN][$va['name']]=0;
  12568. }
  12569. $receiptL [$this->TRAIN] ='<td class="colGreen taR">'.$subtotal[$this->TRAIN]['TRAIN'].'</td>';
  12570. foreach ( $aiList[$this->TRAIN] as $va ) {
  12571. $receiptL [$this->TRAIN] .='<td class="taR">' . $subtotal[$this->TRAIN][$va['name']] . '</td>';
  12572. $subtotal[$this->TRAIN][$va['name']]=0;
  12573. }
  12574. $receiptL [$this->OTHER] ='<td class="colGreen taR">'.$subtotal[$this->OTHER]['OTHER'].'</td>';
  12575. foreach ( $aiList[$this->OTHER] as $va ) {
  12576. $receiptL [$this->OTHER] .='<td class="taR">' . $subtotal[$this->OTHER][$va['name']] . '</td>';
  12577. $subtotal[$this->OTHER][$va['name']]=0;
  12578. }
  12579. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  12580. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  12581. $receiptL ['usernameEn'] =false;
  12582. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  12583. }
  12584. $data ['list'] = $list;
  12585. // print_r($list);
  12586. $receiptCollectList = $receiptDetail->find ( array (
  12587. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12588. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12589. 'groupby' => 'item,Month(pastDate),itemCategory',
  12590. 'asArray' => true
  12591. ) );
  12592. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  12593. // statistics html
  12594. $stList = $statistics->getOne ( array (
  12595. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  12596. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  12597. 'groupby' => 'Month(date)',
  12598. 'asArray' => true
  12599. ) );
  12600. if (empty ( $stList ))
  12601. $stList = array (
  12602. 'rePrice' => 0,
  12603. 'agPrice' => 0
  12604. );
  12605. $data ['stList'] = array (
  12606. 'rePrice' => $stList ['rePrice'],
  12607. 'agPrice' => $stList ['agPrice'],
  12608. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12609. );
  12610. $monthHtml = "";
  12611. for($i = 1; $i <= 12; $i ++) {
  12612. if ($i == $month)
  12613. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  12614. else
  12615. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  12616. }
  12617. $data ['monthHtml'] = $monthHtml;
  12618. $data ['year'] = $year;
  12619. $data ['month'] = $month;
  12620. $data ['nature'] = $nature;
  12621. $data ['aiList'] = $aiList;
  12622. $data ['memu'] = "receipt";
  12623. $data ['staff'] = $this->staff;
  12624. $data ['receiptMemu'] = 'companyCategoryCollect';
  12625. $data ['verifyId'] = $this->verifyId;
  12626. $data ['executeId'] = $this->executeId;
  12627. $this->render ( "/admin/staffCollectMonthDetail", $data );
  12628. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  12629. }
  12630. function staffCollectMonthDetail2() {
  12631. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12632. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12633. if (! $year)
  12634. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12635. if (! $month)
  12636. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12637. Doo::loadModel ( 'staff' );
  12638. $staff = new staff ();
  12639. Doo::loadModel ( "receiptDetail" );
  12640. $receiptDetail = new receiptDetail ();
  12641. Doo::loadModel ( 'accountItem' );
  12642. $accountItem = new accountItem ();
  12643. Doo::loadModel ( 'statistics' );
  12644. $statistics = new statistics ();
  12645. Doo::loadModel ( 'L_category' );
  12646. $lCategory = new L_category ();
  12647. $staffList = $staff->find ( array (
  12648. 'where' => 'username!="admin"',
  12649. 'asArray' => true
  12650. ) );
  12651. $categoryList = $staff->find ( array (
  12652. 'select' => 'COUNT(*) as count,cid,category',
  12653. 'where' => 'username !="admin"',
  12654. 'groupby' => 'cid',
  12655. 'asArray' => true
  12656. ) );
  12657. $list = array ();
  12658. foreach ( $categoryList as $vlu ) {
  12659. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  12660. $r1 = 0;
  12661. $r2 = 0;
  12662. $r3 = 0;
  12663. $r4 = 0;
  12664. $r5 = 0;
  12665. $r6 = 0;
  12666. $r7 = 0;
  12667. $r8 = 0;
  12668. $r9 = 0;
  12669. $r10 = 0;
  12670. $r11 = 0;
  12671. $r12 = 0;
  12672. $r13 = 0;
  12673. $r14 = 0;
  12674. $r15 = 0;
  12675. $c1 = 0;
  12676. $c2 = 0;
  12677. $c3 = 0;
  12678. $c4 = 0;
  12679. $c5 = 0;
  12680. $c6 = 0;
  12681. $p1 = 0;
  12682. $p2 = 0;
  12683. $p3 = 0;
  12684. $p4 = 0;
  12685. $p5 = 0;
  12686. $p6 = 0;
  12687. $p7 = 0;
  12688. $p8 = 0;
  12689. $p9 = 0;
  12690. $t1 = 0;
  12691. $t2 = 0;
  12692. $t3 = 0;
  12693. $t4 = 0;
  12694. $t5 = 0;
  12695. $s1 = 0;
  12696. $m1 = 0;
  12697. foreach ( $staffList as $value ) {
  12698. if ($vlu ['cid'] == $value ['cid']) {
  12699. $receiptCollectList = $receiptDetail->find ( array (
  12700. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  12701. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  12702. 'groupby' => 'item,Month(date),itemCategory',
  12703. 'asArray' => true
  12704. ) );
  12705. if (! empty ( $receiptCollectList )) {
  12706. $receiptL = array (
  12707. '日常相关费用' => array (),
  12708. '差旅相关费用' => array (),
  12709. '培训班费用' => array (),
  12710. '其他' => array ()
  12711. );
  12712. $html = "";
  12713. $psum = 0;
  12714. $item = array (
  12715. '市内交通费',
  12716. '市内出租费',
  12717. '办事处房租',
  12718. '电话费',
  12719. '水费',
  12720. '电费',
  12721. '办公费用',
  12722. '邮寄费',
  12723. '其他费用',
  12724. '车辆费用',
  12725. '广告费',
  12726. '团队建设费',
  12727. '物业管理费',
  12728. '宽带费'
  12729. );
  12730. foreach ( $item as $va ) {
  12731. $falg = true;
  12732. foreach ( $receiptCollectList as $v ) {
  12733. if ($v ['itemCategory'] == '日常相关费用') {
  12734. if ($v ['item'] == $va) {
  12735. if ($va == '市内交通费')
  12736. $r1 += $v ['price'];
  12737. if ($va == '市内出租费')
  12738. $r2 += $v ['price'];
  12739. if ($va == '办事处房租')
  12740. $r3 += $v ['price'];
  12741. if ($va == '电话费')
  12742. $r4 += $v ['price'];
  12743. if ($va == '水费')
  12744. $r5 += $v ['price'];
  12745. if ($va == '电费')
  12746. $r6 += $v ['price'];
  12747. if ($va == '办公费用')
  12748. $r7 += $v ['price'];
  12749. if ($va == '邮寄费')
  12750. $r8 += $v ['price'];
  12751. if ($va == '其他费用')
  12752. $r9 += $v ['price'];
  12753. if ($va == '车辆费用')
  12754. $r10 += $v ['price'];
  12755. if ($va == '广告费')
  12756. $r11 += $v ['price'];
  12757. if ($va == '团队建设费')
  12758. $r13 += $v ['price'];
  12759. if ($va == '物业管理费')
  12760. $r14 += $v ['price'];
  12761. if ($va == '宽带费')
  12762. $r15 += $v ['price'];
  12763. $psum += $v ['price'];
  12764. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12765. $falg = false;
  12766. break;
  12767. }
  12768. }
  12769. }
  12770. if ($falg)
  12771. $html .= '<td class="taR">-</td>';
  12772. }
  12773. $r12 += $psum;
  12774. if (! empty ( $psum ))
  12775. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12776. else
  12777. $psum = '<td class="colGreen taR">-</td>';
  12778. $receiptL ['日常相关费用'] = $psum . $html;
  12779. /* ----------------------------------- */
  12780. $html = "";
  12781. $psum = 0;
  12782. $item = array (
  12783. '往来交通费',
  12784. '市内交通费',
  12785. '出差住宿费',
  12786. '出差补助',
  12787. '其他费用'
  12788. );
  12789. foreach ( $item as $va ) {
  12790. $falg = true;
  12791. foreach ( $receiptCollectList as $v ) {
  12792. if ($v ['itemCategory'] == '差旅相关费用') {
  12793. if ($v ['item'] == $va) {
  12794. if ($va == '往来交通费')
  12795. $c1 += $v ['price'];
  12796. if ($va == '市内交通费')
  12797. $c2 += $v ['price'];
  12798. if ($va == '出差住宿费')
  12799. $c3 += $v ['price'];
  12800. if ($va == '出差补助')
  12801. $c4 += $v ['price'];
  12802. if ($va == '其他费用')
  12803. $c5 += $v ['price'];
  12804. $psum += $v ['price'];
  12805. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12806. $falg = false;
  12807. break;
  12808. }
  12809. }
  12810. }
  12811. if ($falg)
  12812. $html .= '<td class="taR">-</td>';
  12813. }
  12814. $c6 += $psum;
  12815. if (! empty ( $psum ))
  12816. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12817. else
  12818. $psum = '<td class="colGreen taR">-</td>';
  12819. $receiptL ['差旅相关费用'] = $psum . $html;
  12820. /* ------------------------------------- */
  12821. $html = "";
  12822. $psum = 0;
  12823. $item = array (
  12824. '场租费',
  12825. '薪酬',
  12826. '住宿费',
  12827. '交通费',
  12828. '餐饮费',
  12829. '办公费',
  12830. '公关费',
  12831. '其他'
  12832. );
  12833. foreach ( $item as $va ) {
  12834. $falg = true;
  12835. foreach ( $receiptCollectList as $v ) {
  12836. if ($v ['itemCategory'] == '培训班费用') {
  12837. if ($v ['item'] == $va) {
  12838. if ($va == '场租费')
  12839. $p1 += $v ['price'];
  12840. if ($va == '薪酬')
  12841. $p2 += $v ['price'];
  12842. if ($va == '住宿费')
  12843. $p3 += $v ['price'];
  12844. if ($va == '交通费')
  12845. $p4 += $v ['price'];
  12846. if ($va == '餐饮费')
  12847. $p5 += $v ['price'];
  12848. if ($va == '办公费')
  12849. $p6 += $v ['price'];
  12850. if ($va == '公关费')
  12851. $p7 += $v ['price'];
  12852. if ($va == '其他')
  12853. $p8 += $v ['price'];
  12854. $psum += $v ['price'];
  12855. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12856. $falg = false;
  12857. break;
  12858. }
  12859. }
  12860. }
  12861. if ($falg)
  12862. $html .= '<td class="taR">-</td>';
  12863. }
  12864. $p9 += $psum;
  12865. if (! empty ( $psum ))
  12866. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12867. else
  12868. $psum = '<td class="colGreen taR">-</td>';
  12869. $receiptL ['培训班费用'] = $psum . $html;
  12870. /* ------------------------------------- */
  12871. $html = "";
  12872. $psum = 0;
  12873. $item = array (
  12874. '公关费',
  12875. '广告费',
  12876. '借款',
  12877. '可自加费用'
  12878. );
  12879. foreach ( $item as $va ) {
  12880. $falg = true;
  12881. foreach ( $receiptCollectList as $v ) {
  12882. if ($v ['itemCategory'] == '其他') {
  12883. if ($v ['item'] == $va) {
  12884. if ($va == '公关费')
  12885. $t1 += $v ['price'];
  12886. if ($va == '广告费')
  12887. $t2 += $v ['price'];
  12888. if ($va == '借款')
  12889. $t3 += $v ['price'];
  12890. if ($va == '可自加费用')
  12891. $t4 += $v ['price'];
  12892. $psum += $v ['price'];
  12893. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12894. $falg = false;
  12895. break;
  12896. }
  12897. }
  12898. }
  12899. if ($falg)
  12900. $html .= '<td class="taR">-</td>';
  12901. }
  12902. $t5 += $psum;
  12903. if (! empty ( $psum ))
  12904. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12905. else
  12906. $psum = '<td class="colGreen taR">-</td>';
  12907. $receiptL ['其他'] = $psum . $html;
  12908. /* ------------------------------------- */
  12909. $html = "";
  12910. $psum = 0;
  12911. foreach ( $receiptCollectList as $v ) {
  12912. if ($v ['itemCategory'] == '报销金额调整') {
  12913. if (! empty ( $v ['price'] )) {
  12914. $psum += $v ['price'];
  12915. }
  12916. }
  12917. }
  12918. $s1 += $psum;
  12919. if (! empty ( $psum ))
  12920. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  12921. else
  12922. $psum = '<td class="taR colOrange">-</td>';
  12923. $receiptL ['报销金额调整'] = $psum . $html;
  12924. } else {
  12925. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  12926. <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>';
  12927. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  12928. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12929. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  12930. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12931. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12932. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  12933. }
  12934. $monthStaffPrice = $receiptDetail->find ( array (
  12935. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  12936. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  12937. 'asArray' => true
  12938. ) );
  12939. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  12940. $m1 += $monthStaffPrice [0] ['price'];
  12941. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  12942. } else
  12943. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  12944. $list [$value ['username']] = $receiptL;
  12945. }
  12946. }
  12947. $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>
  12948. <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>
  12949. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  12950. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  12951. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  12952. $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>
  12953. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  12954. $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>';
  12955. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  12956. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  12957. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  12958. }
  12959. $data ['list'] = $list;
  12960. $receiptCollectList = $receiptDetail->find ( array (
  12961. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  12962. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  12963. 'groupby' => 'item,Month(date),itemCategory',
  12964. 'asArray' => true
  12965. ) );
  12966. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  12967. // statistics html
  12968. $stList = $statistics->getOne ( array (
  12969. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  12970. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  12971. 'groupby' => 'Month(date)',
  12972. 'asArray' => true
  12973. ) );
  12974. if (empty ( $stList ))
  12975. $stList = array (
  12976. 'rePrice' => 0,
  12977. 'agPrice' => 0
  12978. );
  12979. $data ['stList'] = array (
  12980. 'rePrice' => $stList ['rePrice'],
  12981. 'agPrice' => $stList ['agPrice'],
  12982. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12983. );
  12984. $monthHtml = "";
  12985. for($i = 1; $i <= 12; $i ++) {
  12986. if ($i == $month)
  12987. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  12988. else
  12989. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  12990. }
  12991. $data ['monthHtml'] = $monthHtml;
  12992. $data ['year'] = $year;
  12993. $data ['month'] = $month;
  12994. $data ['memu'] = "receipt";
  12995. $data ['staff'] = $this->staff;
  12996. $data ['receiptMemu'] = 'companyCategoryCollect';
  12997. $data ['verifyId'] = $this->verifyId;
  12998. $data ['executeId'] = $this->executeId;
  12999. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  13000. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13001. }
  13002. /**
  13003. * 用户报销单列表
  13004. */
  13005. function receiptStatisticsStaffDetail() {
  13006. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13007. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13008. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13009. Doo::loadModel ( "receipt" );
  13010. $receipt = new receipt ();
  13011. Doo::loadModel ( "receiptDetail" );
  13012. $receiptDetail = new receiptDetail ();
  13013. Doo::loadModel ( 'staff' );
  13014. $staff = new staff ();
  13015. Doo::loadModel ( 'accountItem' );
  13016. $accountItem = new accountItem ();
  13017. Doo::loadModel ( 'statistics' );
  13018. $statistics = new statistics ();
  13019. if (! empty ( $username )) {
  13020. $username = addslashes ( urldecode ( $username ) );
  13021. $staffDetail = $staff->getStaffByName ( $username );
  13022. if (empty ( $staffDetail ))
  13023. die ( 'illegal request' );
  13024. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  13025. $itemList = $accountItem->getAccountItem ();
  13026. $itemHtml = '';
  13027. $categoryHtml = '';
  13028. $itemKeyList = array_keys ( $itemList );
  13029. $revisePrice = 0;
  13030. // 报销单内容详情
  13031. foreach ( $list as $key => $value ) {
  13032. $accountItemList = json_decode ( $value ['accountItem'], true );
  13033. $list [$key] ['accountItemList'] = $accountItemList;
  13034. $receiptItemHtml = '';
  13035. foreach ( $itemKeyList as $v ) {
  13036. if ($v == '日常相关费用')
  13037. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  13038. elseif ($v == '差旅相关费用')
  13039. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  13040. elseif ($v == '培训班费用')
  13041. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  13042. elseif ($v == '内部培训费用'){
  13043. if (isset($accountItemList ['cSum'] ['inttrainSum'])){
  13044. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['inttrainSum'] . '</td>';
  13045. }else{
  13046. $receiptItemHtml .= '<td class="colGreen taR">0</td>';
  13047. }
  13048. }elseif ($v == '其他')
  13049. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  13050. foreach ( $itemList [$v] as $ke => $va ) {
  13051. $falg = true;
  13052. if (! empty ( $accountItemList [$v] )) {
  13053. foreach ( $accountItemList [$v] as $ve ) {
  13054. if ($va ['name'] == $ve ['name']) {
  13055. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  13056. $falg = false;
  13057. break;
  13058. }
  13059. }
  13060. }
  13061. if ($falg)
  13062. $receiptItemHtml .= '<td class="taR"></td>';
  13063. }
  13064. }
  13065. // 金额调整和费用查看
  13066. $revisePrice += $value ['revisePrice'];
  13067. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  13068. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" id="sen'.$key.'" data="' . htmlspecialchars($value ['explanation']) . '" onclick=showExplanation() >查看</a></td>';
  13069. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  13070. }
  13071. // 报销单合计
  13072. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  13073. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  13074. $receiptTotalHtml = '';
  13075. // 报销单项目抬头
  13076. foreach ( $itemKeyList as $value ) {
  13077. $count = count ( $itemList [$value] ) + 1;
  13078. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  13079. $categoryHtml .= '<th class="taC">合计</th>';
  13080. $sumfalg=true;
  13081. foreach ( $rtl as $rtlValue ) {
  13082. if ($rtlValue ['itemCategory'] == $value) {
  13083. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  13084. $sumfalg=false;
  13085. break;
  13086. }
  13087. }
  13088. if ($sumfalg)
  13089. $receiptTotalHtml .= '<th></th>';
  13090. foreach ( $itemList [$value] as $k => $v ) {
  13091. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  13092. // 合计
  13093. $falg = true;
  13094. foreach ( $receiptTotalList as $ve ) {
  13095. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  13096. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  13097. $falg = false;
  13098. break;
  13099. }
  13100. }
  13101. if ($falg)
  13102. $receiptTotalHtml .= '<th></th>';
  13103. }
  13104. }
  13105. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  13106. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  13107. if (empty ( $stList ))
  13108. $stList = array (
  13109. 'rePrice' => 0,
  13110. 'agPrice' => 0
  13111. );
  13112. $data ['stList'] = array (
  13113. 'rePrice' => $stList ['rePrice'],
  13114. 'agPrice' => $stList ['agPrice'],
  13115. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13116. );
  13117. $monthHtml = "";
  13118. for($i = 1; $i <= 12; $i ++) {
  13119. if ($i == $month)
  13120. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13121. else
  13122. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13123. }
  13124. $data ['username'] = urlencode ( $username );
  13125. $data ['usernameEN'] = $username;
  13126. $data ['monthHtml'] = $monthHtml;
  13127. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  13128. $data ['list'] = $list;
  13129. $data ['categoryHtml'] = $categoryHtml;
  13130. $data ['itemHtml'] = $itemHtml;
  13131. $data ['itemList'] = $itemList;
  13132. $data ['year'] = $year;
  13133. $data ['month'] = $month;
  13134. $data ['memu'] = "receipt";
  13135. $data ['staff'] = $this->staff;
  13136. $data ['receiptMemu'] = 'companyCategoryCollect';
  13137. $data ['verifyId'] = $this->verifyId;
  13138. $data ['executeId'] = $this->executeId;
  13139. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  13140. }
  13141. die ( 'illegal request' );
  13142. }
  13143. function companyMonthCollectDetail() {
  13144. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13145. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13146. if (! $year)
  13147. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13148. if (! $month)
  13149. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13150. Doo::loadModel ( 'staff' );
  13151. $staff = new staff ();
  13152. Doo::loadModel ( "receiptDetail" );
  13153. $receiptDetail = new receiptDetail ();
  13154. Doo::loadModel ( 'accountItem' );
  13155. $accountItem = new accountItem ();
  13156. Doo::loadModel ( 'statistics' );
  13157. $statistics = new statistics ();
  13158. Doo::loadModel ( 'L_category' );
  13159. $lCategory = new L_category ();
  13160. $staffList = $staff->find ( array (
  13161. 'where' => 'username!="admin"',
  13162. 'asArray' => true
  13163. ) );
  13164. $categoryList = $lCategory->find ( array (
  13165. 'asArray' => true
  13166. ) );
  13167. $aiList=$accountItem->getAccountItem();
  13168. $list = array ();
  13169. foreach ( $categoryList as $value ) {
  13170. $receiptCollectList = $receiptDetail->find ( array (
  13171. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13172. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13173. 'groupby' => 'item,Month(pastDate),itemCategory',
  13174. 'asArray' => true
  13175. ) );
  13176. if (! empty ( $receiptCollectList )) {
  13177. $receiptL = array (
  13178. '日常相关费用' => array (),
  13179. '差旅相关费用' => array (),
  13180. '内部培训费用' => array (),
  13181. '培训班费用' => array (),
  13182. '其他' => array ()
  13183. );
  13184. $html = "";
  13185. $psum = 0;
  13186. foreach ( $aiList[$this->AGENCY] as $va ) {
  13187. $falg = true;
  13188. foreach ( $receiptCollectList as $v ) {
  13189. if ($v ['itemCategory'] == $this->AGENCY) {
  13190. if ($v ['item'] == $va['name']) {
  13191. $psum += $v ['price'];
  13192. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13193. $falg = false;
  13194. break;
  13195. }
  13196. }
  13197. }
  13198. if ($falg)
  13199. $html .= '<td class="taR">-</td>';
  13200. }
  13201. if (! empty ( $psum ))
  13202. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13203. else
  13204. $psum = '<td class="colGreen taR">-</td>';
  13205. $receiptL [$this->AGENCY] = $psum . $html;
  13206. /* ----------------------------------- */
  13207. $html = "";
  13208. $psum = 0;
  13209. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13210. $falg = true;
  13211. foreach ( $receiptCollectList as $v ) {
  13212. if ($v ['itemCategory'] == $this->TRAVEL) {
  13213. if ($v ['item'] == $va['name']) {
  13214. $psum += $v ['price'];
  13215. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13216. $falg = false;
  13217. break;
  13218. }
  13219. }
  13220. }
  13221. if ($falg)
  13222. $html .= '<td class="taR">-</td>';
  13223. }
  13224. if (! empty ( $psum ))
  13225. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13226. else
  13227. $psum = '<td class="colGreen taR">-</td>';
  13228. $receiptL [$this->TRAVEL] = $psum . $html;
  13229. /* ------------------------------------- */
  13230. $html = "";
  13231. $psum = 0;
  13232. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13233. $falg = true;
  13234. foreach ( $receiptCollectList as $v ) {
  13235. if ($v ['itemCategory'] == $this->INTTRAIN) {
  13236. if ($v ['item'] == $va['name']) {
  13237. $psum += $v ['price'];
  13238. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13239. $falg = false;
  13240. break;
  13241. }
  13242. }
  13243. }
  13244. if ($falg)
  13245. $html .= '<td class="taR">-</td>';
  13246. }
  13247. if (! empty ( $psum ))
  13248. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13249. else
  13250. $psum = '<td class="colGreen taR">-</td>';
  13251. $receiptL [$this->INTTRAIN] = $psum . $html;
  13252. /* ------------------------------------- */
  13253. $html = "";
  13254. $psum = 0;
  13255. foreach ( $aiList[$this->TRAIN] as $va ) {
  13256. $falg = true;
  13257. foreach ( $receiptCollectList as $v ) {
  13258. if ($v ['itemCategory'] == $this->TRAIN) {
  13259. if ($v ['item'] == $va['name']) {
  13260. $psum += $v ['price'];
  13261. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13262. $falg = false;
  13263. break;
  13264. }
  13265. }
  13266. }
  13267. if ($falg)
  13268. $html .= '<td class="taR">-</td>';
  13269. }
  13270. if (! empty ( $psum ))
  13271. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13272. else
  13273. $psum = '<td class="colGreen taR">-</td>';
  13274. $receiptL [$this->TRAIN] = $psum . $html;
  13275. /* ------------------------------------- */
  13276. $html = "";
  13277. $psum = 0;
  13278. foreach ( $aiList[$this->OTHER] as $va ) {
  13279. $falg = true;
  13280. foreach ( $receiptCollectList as $v ) {
  13281. if ($v ['itemCategory'] == $this->OTHER) {
  13282. if ($v ['item'] == $va['name']) {
  13283. $psum += $v ['price'];
  13284. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13285. $falg = false;
  13286. break;
  13287. }
  13288. }
  13289. }
  13290. if ($falg)
  13291. $html .= '<td class="taR">-</td>';
  13292. }
  13293. if (! empty ( $psum ))
  13294. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13295. else
  13296. $psum = '<td class="colGreen taR">-</td>';
  13297. $receiptL [$this->OTHER] = $psum . $html;
  13298. /* ------------------------------------- */
  13299. $html = "";
  13300. $psum = 0;
  13301. foreach ( $receiptCollectList as $v ) {
  13302. if ($v ['itemCategory'] == '报销金额调整') {
  13303. if (! empty ( $v ['price'] ))
  13304. $psum += $v ['price'];
  13305. }
  13306. }
  13307. if (! empty ( $psum ))
  13308. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  13309. else
  13310. $psum = '<td class="taR colOrange">-</td>';
  13311. $receiptL ['报销金额调整'] = $psum . $html;
  13312. } else {
  13313. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  13314. foreach ( $aiList[$this->AGENCY] as $va ) {
  13315. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  13316. }
  13317. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  13318. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13319. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  13320. }
  13321. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  13322. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13323. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  13324. }
  13325. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  13326. foreach ( $aiList[$this->TRAIN] as $va ) {
  13327. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  13328. }
  13329. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  13330. foreach ( $aiList[$this->OTHER] as $va ) {
  13331. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  13332. }
  13333. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13334. }
  13335. $monthStaffPrice = $receiptDetail->find ( array (
  13336. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13337. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13338. 'asArray' => true
  13339. ) );
  13340. if (! empty ( $monthStaffPrice [0] ['price'] ))
  13341. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13342. else
  13343. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13344. $list [$value ['title']] = $receiptL;
  13345. }
  13346. $data ['list'] = $list;
  13347. $receiptCollectList = $receiptDetail->find ( array (
  13348. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13349. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13350. 'groupby' => 'item,Month(pastDate),itemCategory',
  13351. 'asArray' => true
  13352. ) );
  13353. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  13354. //print_r($data['monthPriceHtml']);
  13355. // foreach ($data['monthPriceHtml'] as $value){
  13356. // echo $value;
  13357. // }
  13358. // die;
  13359. // statistics html
  13360. $stList = $statistics->getOne ( array (
  13361. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13362. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13363. 'groupby' => 'Month(date)',
  13364. 'asArray' => true
  13365. ) );
  13366. if (empty ( $stList ))
  13367. $stList = array (
  13368. 'rePrice' => 0,
  13369. 'agPrice' => 0
  13370. );
  13371. $data ['stList'] = array (
  13372. 'rePrice' => $stList ['rePrice'],
  13373. 'agPrice' => $stList ['agPrice'],
  13374. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13375. );
  13376. $monthHtml = "";
  13377. for($i = 1; $i <= 12; $i ++) {
  13378. if ($i == $month)
  13379. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13380. else
  13381. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13382. }
  13383. $data ['aiList'] = $aiList;
  13384. $data ['monthHtml'] = $monthHtml;
  13385. $data ['year'] = $year;
  13386. $data ['month'] = $month;
  13387. $data ['memu'] = "receipt";
  13388. $data ['staff'] = $this->staff;
  13389. $data ['receiptMemu'] = 'companyCategoryCollect';
  13390. $data ['verifyId'] = $this->verifyId;
  13391. $data ['executeId'] = $this->executeId;
  13392. $this->render ( "/admin/companyMonthCollectDetail", $data );
  13393. }
  13394. function staffCollectDetail() {
  13395. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  13396. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13397. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  13398. if (! $staffname) {
  13399. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  13400. $staffname = urldecode ( $staffname );
  13401. }
  13402. Doo::loadModel ( 'staff' );
  13403. $staff = new staff ();
  13404. Doo::loadModel ( "receiptDetail" );
  13405. $receiptDetail = new receiptDetail ();
  13406. Doo::loadModel ( 'accountItem' );
  13407. $accountItem = new accountItem ();
  13408. Doo::loadModel ( 'statistics' );
  13409. $statistics = new statistics ();
  13410. Doo::loadModel ( 'L_category' );
  13411. $lCategory = new L_category ();
  13412. Doo::loadModel ( "receiptAuthorityManage" );
  13413. $receiptAuthorityManage = new receiptAuthorityManage ();
  13414. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  13415. $cidList = array ();
  13416. foreach ( $imcStaff as $key => $value ) {
  13417. array_push ( $cidList, $value ['cid'] );
  13418. }
  13419. $cidString = implode ( ',', $cidList );
  13420. $staffList = $staff->find ( array (
  13421. 'where' => ' cid in (' . $cidString . ')',
  13422. 'asArray' => true
  13423. ) );
  13424. $stHtml = '';
  13425. $stTitle = "";
  13426. $staffId = 0;
  13427. $cid = 0;
  13428. $ocid = 0;
  13429. foreach ( $staffList as $value ) {
  13430. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  13431. $stTitle = $value ['category'] . '-' . $value ['username'];
  13432. $staffId = $value ['sid'];
  13433. $cid = $value ['cid'];
  13434. $ocid = $value ['cid'];
  13435. if (! empty ( $value ['othercid'] ))
  13436. $cid = $value ['cid'] . ',' . $value ['othercid'];
  13437. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13438. } elseif ($value ['username'] != 'admin')
  13439. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13440. }
  13441. $data ['lCategoryHtml'] = $lCategory->find ( array (
  13442. 'where' => 'cid in(' . $cid . ')',
  13443. 'asArray' => true
  13444. ) );
  13445. if (empty ( $pcid ))
  13446. $pcid = $ocid;
  13447. $data ['ocid'] = $pcid;
  13448. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  13449. $this->showCache ( $path );
  13450. //
  13451. $receiptCollectList = $receiptDetail->find ( array (
  13452. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13453. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  13454. 'groupby' => 'item,Month(pastDate),itemCategory',
  13455. 'asArray' => true
  13456. ) );
  13457. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  13458. // print_r($receiptCollectList);
  13459. $accountList = $accountItem->find ( array (
  13460. 'asArray' => true
  13461. ) );
  13462. // create CollectDetail HTML
  13463. $collectHtml = array ();
  13464. foreach ( $accountList as $key => $value ) {
  13465. $html = "";
  13466. $asum = 0;
  13467. for($i = 1; $i <= 12; $i ++) {
  13468. $falg = true;
  13469. foreach ( $receiptCollectList as $v ) {
  13470. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  13471. if ($v ['item'] == '可自加费用') {
  13472. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  13473. }
  13474. $asum += $v ['price'];
  13475. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13476. $falg = false;
  13477. break;
  13478. }
  13479. }
  13480. if ($falg)
  13481. $html .= '<td class="taR">-</td>';
  13482. }
  13483. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  13484. $collectHtml [$value ['category']] [$value ['name']] = $html;
  13485. }
  13486. $data ['collectHtml'] = $collectHtml;
  13487. // print_r($collectHtml);
  13488. // create Adjustment price html
  13489. $receiptCollectList = $receiptDetail->find ( array (
  13490. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  13491. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  13492. 'groupby' => 'itemCategory,Month(pastDate)',
  13493. 'asArray' => true
  13494. ) );
  13495. $adjustment = array ();
  13496. $collectArray = array (
  13497. '日常相关费用' => array (),
  13498. '差旅相关费用' => array (),
  13499. '培训班费用' => array (),
  13500. '内部培训费用'=>array(),
  13501. '其他' => array ()
  13502. );
  13503. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  13504. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  13505. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  13506. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  13507. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  13508. array_push ( $collectArray ['培训班费用'], $collectHtml );
  13509. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  13510. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  13511. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  13512. array_push ( $collectArray ['其他'], $collectHtml );
  13513. $data ['collectArray'] = $collectArray;
  13514. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  13515. array_push ( $adjustment, $collectHtml );
  13516. $data ['adjustment'] = $adjustment;
  13517. // total price html
  13518. $collectHtml = "";
  13519. $total = 0;
  13520. for($i = 1; $i <= 12; $i ++) {
  13521. $sumPrice = 0;
  13522. foreach ( $receiptCollectList as $key => $value ) {
  13523. if ($value ['month'] == $i) {
  13524. $sumPrice += $value ['price'];
  13525. }
  13526. }
  13527. if ($sumPrice == 0)
  13528. $collectHtml .= '<td class="taR">-</td>';
  13529. else
  13530. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  13531. $total += $sumPrice;
  13532. }
  13533. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  13534. // statistics html
  13535. $stList = $statistics->statisticsByYear ( $year, $staffId );
  13536. if (empty ( $stList ))
  13537. $stList = array (
  13538. 'rePrice' => 0,
  13539. 'agPrice' => 0
  13540. );
  13541. $data ['stList'] = array (
  13542. 'rePrice' => $stList ['rePrice'],
  13543. 'agPrice' => $stList ['agPrice'],
  13544. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13545. );
  13546. $data ['totalPrice'] = $collectHtml;
  13547. $data ['totalYear'] = $total;
  13548. $data ['stHtml'] = $stHtml;
  13549. $data ['year'] = $year;
  13550. $data ['stTitle'] = $stTitle;
  13551. $data ['staffname'] = urlencode ( $staffname );
  13552. $data ['memu'] = "receipt";
  13553. $data ['staff'] = $this->staff;
  13554. $data ['receiptMemu'] = 'companyCategoryCollect';
  13555. $data ['verifyId'] = $this->verifyId;
  13556. $data ['executeId'] = $this->executeId;
  13557. if ($year < date ( "Y" )) {
  13558. Doo::loadModel ( 'receipt' );
  13559. $receipt = new receipt ();
  13560. $receiptList = $receipt->find ( array (
  13561. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  13562. 'asArray' => true
  13563. ) );
  13564. if (empty ( $receiptList )) { // generated files
  13565. ob_start ();
  13566. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13567. $this->cacheFile ( $path );
  13568. die ();
  13569. }
  13570. }
  13571. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13572. }
  13573. function BUGFLAG() {
  13574. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  13575. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  13576. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13577. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  13578. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  13579. if (empty ( $status ))
  13580. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  13581. $page_size = 12;
  13582. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  13583. $vidList = array ();
  13584. $button = 0;
  13585. Doo::loadModel ( 'verify' );
  13586. $verify = new verify ();
  13587. Doo::loadModel ( 'receipt' );
  13588. $receipt = new receipt ();
  13589. Doo::loadModel ( 'staff' );
  13590. $staff = new staff ();
  13591. Doo::loadModel ( 'L_category' );
  13592. $Lcategory = new L_category ();
  13593. $dateCondition = " and Year(date) =" . $year;
  13594. if (! empty ( $month ))
  13595. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  13596. $categoryList = $Lcategory->find ( array (
  13597. 'asArray' => true
  13598. ) );
  13599. $staffList = $staff->find ( array (
  13600. 'where' => 'cid=' . $cid,
  13601. 'asArray' => true
  13602. ) );
  13603. $cateCondition = "";
  13604. $staffCondition = "";
  13605. $approvalCondition = "";
  13606. if (! empty ( $cid ))
  13607. $cateCondition = ' and cid=' . $cid;
  13608. if (! empty ( $sid )) {
  13609. $staffCondition = ' and staff=' . $sid;
  13610. $cateCondition = "";
  13611. }
  13612. $approvalCondition = " and status=" . $status;
  13613. if ($status == 2) {
  13614. // 查找角色审批人
  13615. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  13616. }
  13617. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  13618. $approvalCondition = ' and status=2 ';
  13619. }
  13620. if ($status == 1) {
  13621. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  13622. }
  13623. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  13624. $pageinfo ['page'] = array (
  13625. 'previous' => ''
  13626. );
  13627. if ($status == 0) {
  13628. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  13629. $receiptList = $receipt->find ( array (
  13630. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  13631. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  13632. 'desc' => 'rid',
  13633. 'asArray' => true
  13634. ) );
  13635. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  13636. } else
  13637. $receiptList = $receipt->find ( array (
  13638. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  13639. 'desc' => 'rid',
  13640. 'asArray' => true
  13641. ) );
  13642. $rLRes = $receipt->find ( array (
  13643. '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,
  13644. 'desc' => 'rid',
  13645. 'asArray' => true
  13646. ) );
  13647. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  13648. // print_r($pageinfo);
  13649. $Locate = 0;
  13650. foreach ( $receiptList as $key => $value ) {
  13651. $receiptList [$key] ['Locate'] = $Locate;
  13652. $Locate ++;
  13653. $receiptList [$key] ['reviseDetail'] = array ();
  13654. if (! empty ( $value ['reviseDetail'] ))
  13655. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  13656. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  13657. $categoryDetil = $Lcategory->getOne ( array (
  13658. 'where' => 'cid=' . $value ['cid'],
  13659. 'asArray' => true
  13660. ) );
  13661. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  13662. $verifyList = $verify->getOne ( array (
  13663. 'where' => 'vid=' . $value ['verify'],
  13664. 'asArray' => true
  13665. ) );
  13666. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  13667. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  13668. foreach ( $verifyList as $k => $v ) {
  13669. // init verifyStaff
  13670. $verifyList [$k] ['date'] = "";
  13671. $verifyList [$k] ['opinion'] = "";
  13672. $verifyList [$k] ['status'] = "";
  13673. if (empty ( $verifyStaff )) {
  13674. $verifyList [$k] ['date'] = "";
  13675. $verifyList [$k] ['opinion'] = "";
  13676. if ($v [0] == $this->staff [0] ['sid']) {
  13677. $verifyList [$k] ['status'] = 4;
  13678. $button = 4;
  13679. }
  13680. } else {
  13681. $flag = true;
  13682. foreach ( $verifyStaff as $m => $u ) {
  13683. if ($v [0] == $m) {
  13684. $verifyList [$k] ['date'] = $u ['date'];
  13685. $verifyList [$k] ['opinion'] = $u ['opinion'];
  13686. $verifyList [$k] ['status'] = $u ['status'];
  13687. $flag = false;
  13688. break;
  13689. }
  13690. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  13691. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  13692. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  13693. }
  13694. if ($flag) { // 检测可编辑
  13695. if ($v [0] == $this->staff [0] ['sid']) {
  13696. $verifyList [$k] ['status'] = 4;
  13697. $button = 4;
  13698. }
  13699. }
  13700. }
  13701. }
  13702. $receiptList [$key] ['verifyList'] = $verifyList;
  13703. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  13704. 'where' => 'sid=' . $value ['staff'],
  13705. 'asArray' => true
  13706. ) );
  13707. $receiptList [$key] ['button'] = $button;
  13708. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  13709. }
  13710. // print_r($receiptList);die;
  13711. // $data['verifyDetail']=$verifyDetail;
  13712. $mothHtml = "";
  13713. for($i = 1; $i <= 12; $i ++) {
  13714. if ($month == $i)
  13715. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  13716. else
  13717. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  13718. }
  13719. $data ['mothHtml'] = $mothHtml;
  13720. $data ['page'] = $pageinfo;
  13721. $data ['receiptList'] = $receiptList;
  13722. $data ['receiptApprovalCount'] = count ( $rLRes );
  13723. $data ['status'] = $status;
  13724. $data ['year'] = $year;
  13725. $data ['categoryList'] = $categoryList;
  13726. $data ['staffList'] = $staffList;
  13727. $data ['cid'] = $cid;
  13728. $data ['sid'] = $sid;
  13729. // print_r($receiptList);
  13730. $data ['memu'] = "receipt";
  13731. $data ['staff'] = $this->staff;
  13732. $data ['receiptMemu'] = 'approvalExpenses';
  13733. $data ['verifyId'] = $this->verifyId;
  13734. $data ['executeId'] = $this->executeId;
  13735. $this->render ( "/admin/FALG", $data );
  13736. }
  13737. function ajaxGetReceiptOrder() {
  13738. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  13739. if (! empty ( $receiptOrder )) {
  13740. Doo::loadModel ( 'receipt' );
  13741. $receipt = new receipt ();
  13742. Doo::loadModel ( 'staff' );
  13743. $staff = new staff ();
  13744. $receiptInfo = $receipt->getOne ( array (
  13745. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  13746. 'asArray' => true
  13747. ) );
  13748. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  13749. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  13750. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  13751. </tbody></table><table class="table table table-bordered"><tbody>';
  13752. foreach ( $verifyStaff as $key => $value ) {
  13753. $staffInfo = $staff->getOne ( array (
  13754. 'select' => 'username',
  13755. 'where' => ' sid="' . $key . '"',
  13756. 'asArray' => true
  13757. ) );
  13758. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  13759. }
  13760. $html .= '</tbody></table></div></div>';
  13761. echo json_encode ( array (
  13762. 'status' => 1,
  13763. 'receiptHtml' => $html
  13764. ) );
  13765. die ();
  13766. }
  13767. echo json_encode ( array (
  13768. 'status' => 2,
  13769. 'receiptHtml' => ''
  13770. ) );
  13771. die ();
  13772. }
  13773. function _getMonthCollectDetail($receiptCollectList,$aiList) {
  13774. if (! empty ( $receiptCollectList )) {
  13775. $receiptL = array (
  13776. '日常相关费用' => array (),
  13777. '差旅相关费用' => array (),
  13778. '内部培训费用'=>array(),
  13779. '培训班费用' => array (),
  13780. '其他' => array ()
  13781. );
  13782. $html = "";
  13783. $psum = 0;
  13784. foreach ( $aiList[$this->AGENCY] as $value ) {
  13785. $falg = true;
  13786. foreach ( $receiptCollectList as $v ) {
  13787. if ($v ['itemCategory'] == '日常相关费用') {
  13788. if ($v ['item'] == $value['name']) {
  13789. $psum += $v ['price'];
  13790. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13791. $falg = false;
  13792. break;
  13793. }
  13794. }
  13795. }
  13796. if ($falg)
  13797. $html .= '<td class="taR">-</td>';
  13798. }
  13799. if (! empty ( $psum ))
  13800. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13801. else
  13802. $psum = '<td class="colGreen taR">-</td>';
  13803. $receiptL ['日常相关费用'] = $psum . $html;
  13804. /* ----------------------------------- */
  13805. $html = "";
  13806. $psum = 0;
  13807. foreach ( $aiList[$this->TRAVEL] as $value ) {
  13808. $falg = true;
  13809. foreach ( $receiptCollectList as $v ) {
  13810. if ($v ['itemCategory'] == '差旅相关费用') {
  13811. if ($v ['item'] == $value['name']) {
  13812. $psum += $v ['price'];
  13813. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13814. $falg = false;
  13815. break;
  13816. }
  13817. }
  13818. }
  13819. if ($falg)
  13820. $html .= '<td class="taR">-</td>';
  13821. }
  13822. if (! empty ( $psum ))
  13823. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13824. else
  13825. $psum = '<td class="colGreen taR">-</td>';
  13826. $receiptL ['差旅相关费用'] = $psum . $html;
  13827. /* ----------------------------------- */
  13828. $html = "";
  13829. $psum = 0;
  13830. foreach ( $aiList[$this->INTTRAIN] as $value ) {
  13831. $falg = true;
  13832. foreach ( $receiptCollectList as $v ) {
  13833. if ($v ['itemCategory'] == '内部培训费用') {
  13834. if ($v ['item'] == $value['name']) {
  13835. $psum += $v ['price'];
  13836. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13837. $falg = false;
  13838. break;
  13839. }
  13840. }
  13841. }
  13842. if ($falg)
  13843. $html .= '<td class="taR">-</td>';
  13844. }
  13845. if (! empty ( $psum ))
  13846. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13847. else
  13848. $psum = '<td class="colGreen taR">-</td>';
  13849. $receiptL ['内部培训费用'] = $psum . $html;
  13850. /* ------------------------------------- */
  13851. $html = "";
  13852. $psum = 0;
  13853. foreach ( $aiList[$this->TRAIN] as $value ) {
  13854. $falg = true;
  13855. foreach ( $receiptCollectList as $v ) {
  13856. if ($v ['itemCategory'] == '培训班费用') {
  13857. if ($v ['item'] == $value['name']) {
  13858. $psum += $v ['price'];
  13859. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13860. $falg = false;
  13861. break;
  13862. }
  13863. }
  13864. }
  13865. if ($falg)
  13866. $html .= '<td class="taR">-</td>';
  13867. }
  13868. if (! empty ( $psum ))
  13869. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13870. else
  13871. $psum = '<td class="colGreen taR">-</td>';
  13872. $receiptL ['培训班费用'] = $psum . $html;
  13873. /* ------------------------------------- */
  13874. $html = "";
  13875. $psum = 0;
  13876. foreach ( $aiList[$this->OTHER] as $value ) {
  13877. $falg = true;
  13878. foreach ( $receiptCollectList as $v ) {
  13879. if ($v ['itemCategory'] == '其他') {
  13880. if ($v ['item'] == $value['name']) {
  13881. $psum += $v ['price'];
  13882. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13883. $falg = false;
  13884. break;
  13885. }
  13886. }
  13887. }
  13888. if ($falg)
  13889. $html .= '<td class="taR">-</td>';
  13890. }
  13891. if (! empty ( $psum ))
  13892. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13893. else
  13894. $psum = '<td class="colGreen taR">-</td>';
  13895. $receiptL ['其他'] = $psum . $html;
  13896. /* ------------------------------------- */
  13897. $html = "";
  13898. $psum = 0;
  13899. foreach ( $receiptCollectList as $v ) {
  13900. if ($v ['itemCategory'] == '报销金额调整') {
  13901. if (! empty ( $v ['price'] ))
  13902. $psum += $v ['price'];
  13903. }
  13904. }
  13905. if (! empty ( $psum ))
  13906. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  13907. else
  13908. $psum = '<td class="taR colOrange">-</td>';
  13909. $receiptL ['报销金额调整'] = $psum . $html;
  13910. } else {
  13911. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  13912. foreach ( $aiList[$this->AGENCY] as $va ) {
  13913. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  13914. }
  13915. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  13916. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13917. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  13918. }
  13919. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  13920. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13921. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  13922. }
  13923. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  13924. foreach ( $aiList[$this->TRAIN] as $va ) {
  13925. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  13926. }
  13927. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  13928. foreach ( $aiList[$this->OTHER] as $va ) {
  13929. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  13930. }
  13931. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13932. }
  13933. return $receiptL;
  13934. }
  13935. function eMail() {
  13936. Doo::loadModel ( 'staff' );
  13937. $staff = new staff ();
  13938. Doo::loadModel ( 'receipt' );
  13939. $receipt = new receipt ();
  13940. Doo::loadModel ( 'L_category' );
  13941. $Lcategory = new L_category ();
  13942. Doo::loadModel ( "verify" );
  13943. $verify = new verify ();
  13944. $staffList = $staff->find ( array (
  13945. 'asArray' => true
  13946. ) );
  13947. foreach ( $staffList as $key => $value ) {
  13948. if ($value ['username'] != 'admin') {
  13949. // 提交人
  13950. $receiptList = $receipt->find ( array (
  13951. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  13952. 'asArray' => true
  13953. ) );
  13954. if (! empty ( $receiptList )) {
  13955. $html = '<br><div><style></style>
  13956. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  13957. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  13958. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  13959. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  13960. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  13961. <tbody><tr>
  13962. <td style="padding: 0 40px;" align="left">
  13963. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  13964. </td></tr><tr>
  13965. <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>
  13966. </tr>
  13967. </tbody> </table></td> </tr> <tr><td>
  13968. <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">
  13969. <tbody> <tr><td>
  13970. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  13971. 以下报销单完成了审批,等着收款吧:</p>
  13972. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  13973. foreach ( $receiptList as $k => $v ) {
  13974. $category = $Lcategory->getOne ( array (
  13975. 'where' => 'cid=' . $v ['cid'],
  13976. 'asArray' => true
  13977. ) );
  13978. $html .= '
  13979. <tr>
  13980. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  13981. <td align="left">
  13982. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  13983. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  13984. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  13985. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  13986. </tr>';
  13987. }
  13988. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  13989. <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>
  13990. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  13991. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  13992. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  13993. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  13994. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  13995. $receipt = new receipt ();
  13996. $receipt->notice = 1;
  13997. $receipt->update ( array (
  13998. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  13999. ) );
  14000. }
  14001. }
  14002. // 审批人
  14003. $verifyList = $verify->find ( array (
  14004. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  14005. 'asArray' => true
  14006. ) );
  14007. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  14008. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  14009. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14010. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  14011. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14012. <tbody><tr><td style="padding: 0 40px;" align="left">
  14013. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14014. </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>
  14015. </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">
  14016. <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>
  14017. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  14018. foreach ( $verifyList as $k => $v ) {
  14019. $receiptList = $receipt->find ( array (
  14020. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  14021. 'asArray' => true
  14022. ) );
  14023. foreach ( $receiptList as $r => $l ) {
  14024. $category = $Lcategory->getOne ( array (
  14025. 'where' => 'cid=' . $l ['cid'],
  14026. 'asArray' => true
  14027. ) );
  14028. $staffDetile = $staff->getOne ( array (
  14029. 'where' => 'sid=' . $l ['staff'],
  14030. 'asArray' => true
  14031. ) );
  14032. $html .= '
  14033. <tr>
  14034. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14035. <td align="left">
  14036. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  14037. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  14038. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  14039. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  14040. </tr>';
  14041. }
  14042. }
  14043. $html .= '
  14044. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  14045. <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>
  14046. </tr></tbody></table></td></tr></tbody></table></div><br>';
  14047. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  14048. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  14049. // $receipt=new receipt();
  14050. // $receipt->notice=1;
  14051. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  14052. }
  14053. }
  14054. }
  14055. }
  14056. function setWXMsg($rid, $type) {
  14057. Doo::loadModel ( "receipt" );
  14058. $receipt = new receipt ();
  14059. $receiptDetail = $receipt->getOne ( array (
  14060. 'where' => 'rid=' . $rid,
  14061. 'asArray' => true
  14062. ) );
  14063. if (! empty ( $receiptDetail )) {
  14064. Doo::loadModel ( 'staff' );
  14065. $staff = new staff ();
  14066. $staffmsg = $staff->getOne ( array (
  14067. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  14068. 'asArray' => TRUE
  14069. ) );
  14070. if (! empty ( $staffmsg ['wxid'] )) {
  14071. require_once (SITE_PATH . '/protected/class/client.php');
  14072. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  14073. $user = $staffmsg ['wxid'];
  14074. $receiptName = '';
  14075. $msg = '';
  14076. switch ($receiptDetail ['Rtype']) {
  14077. case 0 :
  14078. $receiptName = '报销';
  14079. break;
  14080. case 1 :
  14081. $receiptName = '借款';
  14082. break;
  14083. case 2 :
  14084. $receiptName = '对公汇款';
  14085. break;
  14086. }
  14087. switch ($type) {
  14088. case 1 :
  14089. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  14090. break;
  14091. case 2 :
  14092. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  14093. break;
  14094. case 3 :
  14095. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  14096. break;
  14097. }
  14098. // $result = $client->SendMsg ( $user, $msg, 'text' );
  14099. }
  14100. }
  14101. }
  14102. // Email发送函数
  14103. function SMail($toemail, $subject, $contents) {
  14104. Doo::loadClass ( 'class.phpmailer' );
  14105. $mail = new PHPMailer ();
  14106. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  14107. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  14108. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  14109. $mail->Password = "cDO1GjtY1seH"; // 密码
  14110. $mail->CharSet = "UTF8";
  14111. $mail->SMTPAuth = true;
  14112. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  14113. $mail->Mailer = "smtp";
  14114. $mail->Port = 25;
  14115. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  14116. $mail->MsgHTML ( $contents );
  14117. $mail->AddAddress ( $toemail );
  14118. $mail->CharSet = "UTF-8";
  14119. return $mail->Send ();
  14120. }
  14121. function h5Upload() {
  14122. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14123. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14124. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14125. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14126. header ( "HTTP/1.1 500 Internal Server Error" );
  14127. echo "POST exceeded maximum allowed size.";
  14128. exit ( 0 );
  14129. }
  14130. // Settings
  14131. $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)
  14132. $upload_name = "Filedata";
  14133. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14134. $extension_whitelist = array (
  14135. "doc",
  14136. "txt",
  14137. "jpg",
  14138. "gif",
  14139. "png"
  14140. ); // Allowed file extensions
  14141. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14142. // Other variables
  14143. $MAX_FILENAME_LENGTH = 260;
  14144. $file_name = "";
  14145. $file_extension = "";
  14146. $uploadErrors = array (
  14147. 0 => "文件上传成功",
  14148. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14149. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14150. 3 => "上传的文件仅为部分文件",
  14151. 4 => "没有文件上传",
  14152. 6 => "缺少临时文件夹"
  14153. );
  14154. $nk = time ();
  14155. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14156. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14157. echo "文件无法保存.";
  14158. exit ( 0 );
  14159. }
  14160. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14161. echo json_encode ( array (
  14162. 'filename' => $file_name,
  14163. 'id' => $nk
  14164. ) );
  14165. exit ( 0 );
  14166. }
  14167. function swfupload() {
  14168. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14169. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14170. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14171. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14172. header ( "HTTP/1.1 500 Internal Server Error" );
  14173. echo "POST exceeded maximum allowed size.";
  14174. exit ( 0 );
  14175. }
  14176. // Settings
  14177. $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)
  14178. $upload_name = "Filedata";
  14179. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14180. $extension_whitelist = array (
  14181. "doc",
  14182. "txt",
  14183. "jpg",
  14184. "gif",
  14185. "png"
  14186. ); // Allowed file extensions
  14187. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14188. // Other variables
  14189. $MAX_FILENAME_LENGTH = 260;
  14190. $file_name = "";
  14191. $file_extension = "";
  14192. $uploadErrors = array (
  14193. 0 => "文件上传成功",
  14194. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14195. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14196. 3 => "上传的文件仅为部分文件",
  14197. 4 => "没有文件上传",
  14198. 6 => "缺少临时文件夹"
  14199. );
  14200. $nk = time ();
  14201. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14202. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14203. echo "文件无法保存.";
  14204. exit ( 0 );
  14205. }
  14206. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14207. echo json_encode ( array (
  14208. 'filename' => $file_name,
  14209. 'id' => $nk
  14210. ) );
  14211. exit ( 0 );
  14212. }
  14213. function _GetFileEXT($filename) {
  14214. $pics = explode ( '.', $filename );
  14215. $num = count ( $pics );
  14216. return $pics [$num - 1];
  14217. }
  14218. /**
  14219. * 获取get或者POST值
  14220. * @param string $name 属性名称
  14221. * @return fixed 值
  14222. */
  14223. function get_args($name) {
  14224. if (isset ( $_GET [$name] )) {
  14225. if (is_array ( $_GET [$name] ))
  14226. return $_GET [$name];
  14227. else
  14228. return addslashes ( $_GET [$name] );
  14229. } elseif (isset ( $_POST [$name] )) {
  14230. if (is_array ( $_POST [$name] ))
  14231. return $_POST [$name];
  14232. else
  14233. return addslashes ( $_POST [$name] );
  14234. } else
  14235. return false;
  14236. }
  14237. function num_to_rmb($num) {
  14238. $c1 = "零壹贰叁肆伍陆柒捌玖";
  14239. $c2 = "分角元拾佰仟万拾佰仟亿";
  14240. // 精确到分后面就不要了,所以只留两个小数位
  14241. $num = round ( $num, 2 );
  14242. // 将数字转化为整数
  14243. $num = $num * 100;
  14244. if (strlen ( $num ) > 10) {
  14245. return "金额太大,请检查";
  14246. }
  14247. $i = 0;
  14248. $c = "";
  14249. while ( 1 ) {
  14250. if ($i == 0) {
  14251. // 获取最后一位数字
  14252. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  14253. } else {
  14254. $n = $num % 10;
  14255. }
  14256. // 每次将最后一位数字转化为中文
  14257. $p1 = substr ( $c1, 3 * $n, 3 );
  14258. $p2 = substr ( $c2, 3 * $i, 3 );
  14259. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  14260. $c = $p1 . $p2 . $c;
  14261. } else {
  14262. $c = $p1 . $c;
  14263. }
  14264. $i = $i + 1;
  14265. // 去掉数字最后一位了
  14266. $num = $num / 10;
  14267. // echo $num.'</br>';
  14268. $num = ( int ) $num;
  14269. // $num =floor($num);
  14270. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  14271. // echo $num.'</br>';
  14272. // 结束循环
  14273. if ($num == 0) {
  14274. break;
  14275. }
  14276. }
  14277. // echo $c.'</br>';
  14278. $j = 0;
  14279. $slen = strlen ( $c );
  14280. while ( $j < $slen ) {
  14281. // utf8一个汉字相当3个字符
  14282. $m = substr ( $c, $j, 6 );
  14283. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  14284. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  14285. $left = substr ( $c, 0, $j );
  14286. $right = substr ( $c, $j + 3 );
  14287. $c = $left . $right;
  14288. $j = $j - 3;
  14289. $slen = $slen - 3;
  14290. }
  14291. $j = $j + 3;
  14292. }
  14293. // 这个是为了去掉类似23.0中最后一个“零”字
  14294. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  14295. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  14296. }
  14297. // 将处理的汉字加上“整”
  14298. if (empty ( $c )) {
  14299. return "零元整";
  14300. } else {
  14301. return $c . "整";
  14302. }
  14303. }
  14304. /**
  14305. * 获得分页数据
  14306. * @param unknown_type $table
  14307. * @param unknown_type $condition
  14308. * @param unknown_type $on_page
  14309. * @param unknown_type $page_size
  14310. */
  14311. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  14312. $page_c = "";
  14313. $page ['previous'] = $this->get_previous ( $on_page );
  14314. $page ['on_page'] = $on_page;
  14315. $total_count = $this->get_table_count ( $table, $condition );
  14316. $total = intval ( $total_count / $page_size );
  14317. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  14318. $page ['total_data'] = $total_count;
  14319. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  14320. $i = 1;
  14321. $page_max = 1;
  14322. $page_width = 3;
  14323. if ($on_page >= $page_width) {
  14324. $page_max = intval ( $on_page / $page_width ) + 1;
  14325. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  14326. }
  14327. for(; $i <= $page ['total_page']; $i ++) {
  14328. if ($i == $on_page)
  14329. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  14330. else
  14331. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  14332. if ($i == ($page_width * $page_max))
  14333. break;
  14334. }
  14335. $page ['page'] = $page_c;
  14336. $page ['lower'] = (-- $on_page) * $page_size;
  14337. return $page;
  14338. }
  14339. /**
  14340. * 获取总页数
  14341. * @param unknown_type $table
  14342. * @param unknown_type $condition
  14343. */
  14344. public function get_table_count($table = "", $condition = "") {
  14345. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14346. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14347. // echo $sql;die;
  14348. $query = Doo::db ()->query ( $sql );
  14349. $result = $query->fetch ();
  14350. return $result ['count'];
  14351. }
  14352. /**
  14353. * 获取上一页
  14354. * @param unknown_type $on_page
  14355. */
  14356. function get_previous($on_page = 1) {
  14357. return $on_page != 0 ? $on_page - 1 : $on_page;
  14358. }
  14359. function _getReceiptTrainPayment($invoiceTrainId,$trainLoanRid,$rid){
  14360. // 收入合计
  14361. Doo::loadModel ( 'invoiceTraining' );
  14362. $invoiceTraining = new invoiceTraining ();
  14363. Doo::loadModel ( 'receipt' );
  14364. $receipt = new receipt ();
  14365. $invoiceTrainingDetail = array (
  14366. 'invoiceArriveAmount' => '0.00',
  14367. 'RIAmount' => '0.00',
  14368. 'invoiceTotalAmount' => '0.00',
  14369. 'invoiceCompanyAmount' => '0.00',
  14370. 'invoiceArriveAmountM'=>'0.00',
  14371. 'invoiceCompanyAmountM'=>'0.00'
  14372. );
  14373. if ($invoiceTrainId != 0) {
  14374. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $invoiceTrainId );
  14375. }
  14376. $invoiceArriveAmount = $RIAmount = 0;
  14377. if (! empty ( $invoiceTrainingDetail )) {
  14378. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  14379. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  14380. }
  14381. // 备用金
  14382. $sum = 0;
  14383. if (! empty ( $trainLoanRid )) {
  14384. $receiptLoanDetailBak = $receipt->getReceiptByRid ( $trainLoanRid );
  14385. $sum = $receiptLoanDetailBak ['sum'];
  14386. }
  14387. // 支出项金额详情
  14388. // 项目金额合计
  14389. Doo::loadModel ( 'RItem' );
  14390. $RItem = new RItem ();
  14391. Doo::loadModel ( 'accountItem' );
  14392. $accountItem = new accountItem ();
  14393. // 讲师获得
  14394. Doo::loadModel ( 'RILecturer' );
  14395. $RILecturer = new RILecturer ();
  14396. $RItemList = $RItem->getRItemByRid ($rid );
  14397. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  14398. // 支出项金额详情
  14399. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  14400. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  14401. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  14402. return $payment;
  14403. }
  14404. }
  14405. ?>