ReceiptController.php 543 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571
  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. //print_r($this->executeId);
  135. $this->verifyId = $list;
  136. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  137. // 检测用户信息完成
  138. $this->data ['isStaffCompleteMsg'] = false;
  139. $detail = $staff->checkStaffInfoIsComplete ( $_COOKIE ["staff"] );
  140. if (! empty ( $detail ))
  141. $this->data ['isStaffCompleteMsg'] = true;
  142. return "/";
  143. }
  144. }
  145. Doo::loadCore ( 'uri/DooUriRouter' );
  146. $router = new DooUriRouter ();
  147. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  148. if ($routeRs ['1'] != "login") {
  149. header ( 'Content-Type:text/html;charset=utf-8' );
  150. @header ( "Location: /login" );
  151. }
  152. }
  153. function saeaBorad() {
  154. Doo::loadModel ( 'receipt' );
  155. $receipt = new receipt ();
  156. Doo::loadModel ( 'verify' );
  157. $verify = new verify ();
  158. Doo::loadModel ( 'L_category' );
  159. $lCategory = new L_category ();
  160. Doo::loadModel ( "role" );
  161. $role = new role ();
  162. Doo::loadModel ( "receiptLog" );
  163. $receiptLog = new receiptLog ();
  164. Doo::loadClass ( 'XDeode' );
  165. $XDeode = new XDeode ( 7 );
  166. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  167. $receiptDetail = $receipt->find ( array (
  168. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  169. 'desc' => 'rid',
  170. 'asArray' => true
  171. ) );
  172. foreach ( $receiptDetail as $key => $value ) {
  173. $receiptDetail [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  174. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  175. $veList = $verify->getOne ( array (
  176. 'where' => 'vid=' . $value ['verify'],
  177. 'asArray' => true
  178. ) );
  179. $v = json_decode ( $veList ['staff'] );
  180. array_push ( $v [0], $veList ['description'] );
  181. foreach ( $v as $n => $m ) {
  182. if ($m ['1'] == 'ROLE') {
  183. $roleInfo = $role->getOne ( array (
  184. 'where' => 'rid=' . $m [0],
  185. 'asArray' => true
  186. ) );
  187. $v [$n] [1] = $roleInfo ['name'];
  188. }
  189. }
  190. $receiptDetail [$key] ['staff'] = $v;
  191. $category = $lCategory->getOne ( array (
  192. 'where' => 'cid=' . $value ['cid'],
  193. 'asArray' => true
  194. ) );
  195. $receiptDetail [$key] ['category'] = $category ['title'];
  196. }
  197. // print_r($receiptLogList);
  198. Doo::loadModel ( 'RAssist' );
  199. $RAssist = new RAssist ();
  200. $receiptExtendList=$RAssist->getRAssistBySid($this->staff[0]['sid']);
  201. $data ['receiptExtendList'] = $receiptExtendList;
  202. $data ['receiptLogList'] = $receiptLogList;
  203. $data ['receiptDetail'] = $receiptDetail;
  204. $data ['memu'] = "receipt";
  205. $data ['staff'] = $this->staff;
  206. $data ['receiptMemu'] = 'saeaBorad';
  207. $data ['verifyId'] = $this->verifyId;
  208. $data ['executeId'] = $this->executeId;
  209. $this->render ( "/admin/saeaBorad", $data );
  210. }
  211. function remitAdd() {
  212. Doo::loadModel ( 'accountItem' );
  213. Doo::loadModel ( 'verify' );
  214. Doo::loadModel ( 'receipt' );
  215. Doo::loadModel ( 'L_category' );
  216. $lCategory = new L_category ();
  217. $receipt = new receipt ();
  218. $verify = new verify ();
  219. $accountItem = new accountItem ();
  220. Doo::loadModel ( "role" );
  221. $role = new role ();
  222. $acItem = $accountItem->find ( array (
  223. 'asArray' => true
  224. ) );
  225. $veList = $verify->getVerifyBySubordinate('REMIT');
  226. $data ['category'] = $lCategory->find ( array (
  227. 'asArray' => true
  228. ) );
  229. $data ['veList'] = $veList;
  230. $data ['acItem'] = $acItem;
  231. $data ['memu'] = "receipt";
  232. $data ['staff'] = $this->staff;
  233. $data ['receiptMemu'] = 'saeaBorad';
  234. $data ['verifyId'] = $this->verifyId;
  235. $data ['executeId'] = $this->executeId;
  236. $this->render ( "/admin/remitAdd", $data );
  237. }
  238. function remitAddDo() {
  239. $agency = $this->get_args ( 'agency' );
  240. $travel = $this->get_args ( 'travel' );
  241. $train = $this->get_args ( 'train' );
  242. $other = $this->get_args ( 'other' );
  243. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  244. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  245. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  246. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  247. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  248. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  249. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  250. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  251. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  252. // print_r($agency);die;
  253. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  254. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  255. header ( 'Content-Type:text/html;charset=utf-8' );
  256. die ( '请填写联行号' );
  257. }
  258. Doo::loadModel ( 'receipt' );
  259. Doo::loadModel ( 'receiptDetail' );
  260. Doo::loadModel ( 'accountItem' );
  261. $accountItem = new accountItem ();
  262. $receipt = new receipt ();
  263. Doo::loadModel ( 'enclosur' );
  264. Doo::loadModel ( 'execute' );
  265. $execute = new execute ();
  266. $executeDetail = $execute->getOne ( array (
  267. 'where' => 'mold="对公汇款执行人"',
  268. 'asArray' => true
  269. ) );
  270. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  271. $aItem = $accountItem->find ( array (
  272. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  273. 'asArray' => true
  274. ) );
  275. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  276. $ag = $tr = $ta = $ot = 0;
  277. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  278. print_r($aItem);
  279. foreach ( $aItem as $key => $value ) {
  280. if ($value ['category'] == $this->AGENCY) {
  281. if (isset ( $agency [$ag] )) {
  282. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  283. array_push ( $accountJson [$this->AGENCY], array (
  284. 'aid' => $value ['aid'],
  285. 'name' => $value ['name'],
  286. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  287. ) );
  288. $sum += $agency [$ag];
  289. $agencySum += $agency [$ag];
  290. }
  291. }
  292. $ag ++;
  293. }
  294. }
  295. $accountJson ['cSum'] = array (
  296. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  297. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  298. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  299. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  300. );
  301. //die;
  302. // 报销单
  303. $receipt->accountItem = json_encode ( $accountJson );
  304. $receipt->staff = $this->staff [0] ['sid'];
  305. $receipt->sum = number_format ( $sum, 2, '.', '' );
  306. $receipt->date = date ( "Y-m-d" );
  307. $receipt->cid = $cid;
  308. $receipt->status = 5;
  309. $receipt->Rtype = 2;
  310. // 修改审批流程加入角色
  311. $receipt->verify = $verify;
  312. $receipt->executeCopy = $executeDetail ['staff'];
  313. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  314. $order = array (
  315. "\r\n",
  316. "\n",
  317. "\r"
  318. );
  319. $replace = '<br/>';
  320. $explanation = str_replace ( $order, $replace, $explanation );
  321. $receipt->explanation = $explanation;
  322. $receipt->remittanceName = $remittanceName;
  323. $receipt->bankName = $bankName;
  324. $receipt->bankNumber = $bankNumber;
  325. $receipt->remittanceBankType = $remittanceBankType;
  326. if ($remittanceBankType == 1)
  327. $receipt->coupletNumber = $coupletNumber;
  328. $rid = $receipt->insert ();
  329. // 附件
  330. if (! empty ( $enclosurName )) {
  331. $enclosurArray = explode ( '-', $enclosurName );
  332. foreach ( $enclosurArray as $value ) {
  333. $enclosur = new enclosur ();
  334. $enclosur->name = $value;
  335. $enclosur->rid = $rid;
  336. $enclosur->insert ();
  337. }
  338. // print_r($enclosurArray);die;
  339. }
  340. // 报销详情
  341. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  342. $receiptDetail = new receiptDetail ();
  343. $receiptDetail->staff = $this->staff [0] ['sid'];
  344. $receiptDetail->item = $value ['name'];
  345. $receiptDetail->itemCategory = $this->AGENCY;
  346. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  347. $receiptDetail->date = date ( "Y-m-d" );
  348. $receiptDetail->cid = $cid;
  349. $receiptDetail->rid = $rid;
  350. $receiptDetail->status = 4;
  351. $receiptDetail->insert ();
  352. }
  353. return "/saeaBorad";
  354. } else
  355. die ( 'illegal request' );
  356. }
  357. function remitEdit() {
  358. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  359. Doo::loadClass ( 'XDeode' );
  360. $XDeode = new XDeode ( 7 );
  361. $rid = $XDeode->decode ( $ridKey );
  362. if (! is_numeric ( $rid ))
  363. die ( 'illegal request' );
  364. Doo::loadModel ( 'accountItem' );
  365. Doo::loadModel ( 'verify' );
  366. Doo::loadModel ( 'receipt' );
  367. $receipt = new receipt ();
  368. $verify = new verify ();
  369. $accountItem = new accountItem ();
  370. Doo::loadModel ( 'L_category' );
  371. $lCategory = new L_category ();
  372. Doo::loadModel ( "role" );
  373. $role = new role ();
  374. Doo::loadModel ( 'enclosur' );
  375. $enclosur = new enclosur ();
  376. $receiptDetail = $receipt->getOne ( array (
  377. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  378. 'asArray' => true
  379. ) );
  380. if (empty ( $receiptDetail ))
  381. return "/saeaCreate";
  382. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  383. $acItem = $accountItem->find ( array (
  384. 'asArray' => true
  385. ) );
  386. $veList = $verify->getVerifyBySubordinate('REMIT');
  387. // 配置编辑信息
  388. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  389. foreach ( $acItem as $key => $value ) {
  390. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  391. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  392. $acItem [$key] ['price'] = $v ['price'];
  393. }
  394. }
  395. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  396. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  397. $acItem [$key] ['price'] = $v ['price'];
  398. }
  399. }
  400. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  401. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  402. $acItem [$key] ['price'] = $v ['price'];
  403. }
  404. }
  405. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  406. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  407. $acItem [$key] ['price'] = $v ['price'];
  408. }
  409. }
  410. }
  411. $data ['category'] = $lCategory->find ( array (
  412. 'asArray' => true
  413. ) );
  414. $data ['enclosurList'] = $enclosurList;
  415. $data ['cSum'] = $accountItemList ['cSum'];
  416. $data ['sum'] = $receiptDetail ['sum'];
  417. $data ['receiptDetail'] = $receiptDetail;
  418. $data ['veList'] = $veList;
  419. $data ['acItem'] = $acItem;
  420. $data ['memu'] = "receipt";
  421. $data ['staff'] = $this->staff;
  422. $data ['receiptMemu'] = 'saeaBorad';
  423. $data ['verify'] = $receiptDetail ['verify'];
  424. $data ['verifyId'] = $this->verifyId;
  425. $data ['executeId'] = $this->executeId;
  426. $data ['rid'] = $rid;
  427. $data ['ridKey'] = $ridKey;
  428. $this->render ( "/admin/remitEdit", $data );
  429. }
  430. function remitEdiDo() {
  431. $agency = $this->get_args ( 'agency' );
  432. $travel = $this->get_args ( 'travel' );
  433. $train = $this->get_args ( 'train' );
  434. $other = $this->get_args ( 'other' );
  435. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  436. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  437. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  438. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  439. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  440. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  441. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  442. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  443. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  444. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  445. Doo::loadClass ( 'XDeode' );
  446. $XDeode = new XDeode ( 7 );
  447. $rid = $XDeode->decode ( $ridKey );
  448. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  449. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  450. header ( 'Content-Type:text/html;charset=utf-8' );
  451. die ( '请填写联行号' );
  452. }
  453. Doo::loadModel ( 'receipt' );
  454. Doo::loadModel ( 'receiptDetail' );
  455. Doo::loadModel ( 'accountItem' );
  456. $accountItem = new accountItem ();
  457. $receipt = new receipt ();
  458. Doo::loadModel ( 'enclosur' );
  459. $enclosur = new enclosur ();
  460. Doo::loadModel ( 'execute' );
  461. $execute = new execute ();
  462. $executeDetail = $execute->getOne ( array (
  463. 'where' => 'mold="对公汇款执行人"',
  464. 'asArray' => true
  465. ) );
  466. $receiptDetail = $receipt->getOne ( array (
  467. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  468. 'asArray' => true
  469. ) );
  470. if (empty ( $receiptDetail ))
  471. return "/saeaBorad";
  472. $aItem = $accountItem->find ( array (
  473. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  474. 'asArray' => true
  475. ) );
  476. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  477. $ag = $tr = $ta = $ot = 0;
  478. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  479. foreach ( $aItem as $key => $value ) {
  480. if ($value ['category'] == $this->AGENCY) {
  481. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  482. array_push ( $accountJson [$this->AGENCY], array (
  483. 'aid' => $value ['aid'],
  484. 'name' => $value ['name'],
  485. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  486. ) );
  487. $sum += $agency [$ag];
  488. $agencySum += $agency [$ag];
  489. }
  490. $ag ++;
  491. }
  492. }
  493. $accountJson ['cSum'] = array (
  494. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  495. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  496. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  497. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  498. );
  499. // 报销单
  500. $rid = $receipt->rid = $receiptDetail ['rid'];
  501. $receipt->accountItem = json_encode ( $accountJson );
  502. $receipt->staff = $this->staff [0] ['sid'];
  503. $receipt->sum = number_format ( $sum, 2, '.', '' );
  504. $receipt->date = date ( "Y-m-d" );
  505. $receipt->cid = $cid;
  506. if ($receiptDetail ['Rtype'] == 1)
  507. $receipt->status = 7;
  508. else
  509. $receipt->status = 5;
  510. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  511. $receipt->verify = $verify;
  512. $receipt->executeCopy = $executeDetail ['staff'];
  513. $order = array (
  514. "\r\n",
  515. "\n",
  516. "\r"
  517. );
  518. $replace = '<br/>';
  519. $explanation = str_replace ( $order, $replace, $explanation );
  520. $receipt->explanation = $explanation;
  521. $receipt->remittanceName = $remittanceName;
  522. $receipt->bankName = $bankName;
  523. $receipt->bankNumber = $bankNumber;
  524. $receipt->remittanceBankType = $remittanceBankType;
  525. if ($remittanceBankType == 1)
  526. $receipt->coupletNumber = $coupletNumber;
  527. $receipt->update ();
  528. $receiptDetail = new receiptDetail ();
  529. $receiptDetail->delete ( array (
  530. 'where' => 'rid=' . $rid
  531. ) );
  532. // 报销详情
  533. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  534. $receiptDetail = new receiptDetail ();
  535. $receiptDetail->staff = $this->staff [0] ['sid'];
  536. $receiptDetail->item = $value ['name'];
  537. $receiptDetail->itemCategory = $this->AGENCY;
  538. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  539. $receiptDetail->date = date ( "Y-m-d" );
  540. $receiptDetail->cid = $cid;
  541. $receiptDetail->rid = $rid;
  542. $receiptDetail->status = 4;
  543. $receiptDetail->insert ();
  544. }
  545. // 附件
  546. if (! empty ( $enclosurName )) {
  547. $enclosurArray = explode ( '-', $enclosurName );
  548. foreach ( $enclosurArray as $value ) {
  549. $enclosur = new enclosur ();
  550. $enclosur->name = $value;
  551. $enclosur->rid = $rid;
  552. $enclosur->insert ();
  553. }
  554. }
  555. }
  556. return "/saeaBorad";
  557. }
  558. function remitApproval() {
  559. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  560. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  561. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  562. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  563. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  564. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  565. if (empty ( $status ))
  566. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  567. $vidList = array ();
  568. $button = 0;
  569. Doo::loadModel ( 'verify' );
  570. Doo::loadModel ( 'receipt' );
  571. Doo::loadModel ( 'staff' );
  572. $staff = new staff ();
  573. $receipt = new receipt ();
  574. $verify = new verify ();
  575. Doo::loadModel ( 'L_category' );
  576. $Lcategory = new L_category ();
  577. Doo::loadModel ( 'enclosur' );
  578. $enclosur = new enclosur ();
  579. // user verify ID
  580. $verifyDetail = $verify->find ( array (
  581. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  582. 'asArray' => true
  583. ) );
  584. foreach ( $verifyDetail as $key => $value ) {
  585. array_push ( $vidList, $value ['vid'] );
  586. }
  587. $vid = implode ( ",", $vidList );
  588. if (empty ( $verifyDetail ))
  589. $vid = 0;
  590. $categoryList = $Lcategory->find ( array (
  591. 'asArray' => true
  592. ) );
  593. $staffList = $staff->find ( array (
  594. 'where' => 'cid=' . $cid,
  595. 'asArray' => true
  596. ) );
  597. $ap = "";
  598. if ($status == 4) {
  599. $ap = 4;
  600. $status = 2;
  601. }
  602. // get Receipt By verifyID status 2
  603. $receiptList = $receipt->find ( array (
  604. 'where' => 'rid =' . $rid . ' and status=2',
  605. 'desc' => 'rid',
  606. 'asArray' => true
  607. ) );
  608. if (empty ( $receiptList )) {
  609. die ( 'illegal request' );
  610. }
  611. $Locate = 0;
  612. $roleId = 0;
  613. if ($ap == 4)
  614. $status = 4;
  615. foreach ( $receiptList as $key => $value ) {
  616. $receiptList [$key] ['Locate'] = $Locate;
  617. $Locate ++;
  618. $receiptList [$key] ['reviseDetail'] = array ();
  619. if (! empty ( $value ['reviseDetail'] ))
  620. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  621. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  622. $categoryDetil = $Lcategory->getOne ( array (
  623. 'where' => 'cid=' . $value ['cid'],
  624. 'asArray' => true
  625. ) );
  626. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  627. // 检测编辑状态
  628. $verifyList = $verify->getOne ( array (
  629. 'where' => 'vid=' . $value ['verify'],
  630. 'asArray' => true
  631. ) );
  632. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  633. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  634. Doo::loadModel ( 'role' );
  635. $role = new role ();
  636. // print_r($verifyList);
  637. $flag = true;
  638. $roleKey = 0;
  639. $endStaffArray = array ();
  640. $roleArrayCopy = array ();
  641. foreach ( $verifyList as $k => $v ) {
  642. // init verifyStaff
  643. if ($v [1] == 'ROLE') {
  644. if (! empty ( $verifyStaff )) {
  645. $endStaffArray = end ( $verifyStaff );
  646. if ($v [0] == $endStaffArray ['nextStaff']) {
  647. $roleId = $v [0];
  648. }
  649. }
  650. $roleVerify = json_decode ( $v [3], true );
  651. $roleKey = $k;
  652. $roleArray = array ();
  653. $rolename = $role->getOne ( array (
  654. 'where' => 'rid=' . $v [0],
  655. 'asArray' => true
  656. ) );
  657. foreach ( $roleVerify as $o => $p ) {
  658. $staffID = explode ( '_', $p );
  659. $staffInfo = $staff->getOne ( array (
  660. 'where' => 'sid=' . $staffID [0],
  661. 'asArray' => true
  662. ) );
  663. // print_r($staffID);
  664. $exp = array (
  665. 0 => $staffInfo ['sid'],
  666. 1 => $staffID [1],
  667. 2 => $staffInfo ['avatar'],
  668. 'date' => '',
  669. 'date' => '',
  670. 'opinion' => '',
  671. 'status' => '',
  672. 'rolename' => $rolename ['name']
  673. );
  674. array_push ( $roleArray, $exp );
  675. }
  676. $roleArrayCopy [$v [0]] = $roleArray;
  677. // $verifyList[$k]['roleArray']=$roleArray;
  678. }
  679. // print_r($roleArray);
  680. $verifyList [$k] ['date'] = "";
  681. $verifyList [$k] ['opinion'] = "";
  682. $verifyList [$k] ['status'] = "";
  683. if (empty ( $verifyStaff )) {
  684. $verifyList [$k] ['date'] = "";
  685. $verifyList [$k] ['opinion'] = "";
  686. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  687. $verifyList [$k] ['status'] = 4;
  688. $button = 4;
  689. $flag = false;
  690. }
  691. } else {
  692. foreach ( $verifyStaff as $m => $u ) {
  693. if ($v [0] == $m) {
  694. $verifyList [$k] ['date'] = $u ['date'];
  695. $verifyList [$k] ['opinion'] = $u ['opinion'];
  696. $verifyList [$k] ['status'] = $u ['status'];
  697. $flag = false;
  698. break;
  699. }
  700. }
  701. $endStaffArray = end ( $verifyStaff );
  702. if (isset ( $endStaffArray ['ROLE'] )) {
  703. } else {
  704. $endKey = key ( $verifyStaff );
  705. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  706. $button = 4;
  707. $verifyList [$k] ['status'] = 4;
  708. }
  709. }
  710. }
  711. }
  712. $rolename ['name'] = '';
  713. if (! empty ( $roleId )) {
  714. Doo::loadModel ( 'role' );
  715. $role = new role ();
  716. $rolename = $role->getOne ( array (
  717. 'where' => 'rid=' . $roleId,
  718. 'asArray' => true
  719. ) );
  720. }
  721. if (! empty ( $verifyStaff ))
  722. $endStaffArray = end ( $verifyStaff );
  723. $KOP = false;
  724. foreach ( $roleArrayCopy as $P => $A ) {
  725. foreach ( $A as $MKI => $AVL ) {
  726. if (! empty ( $verifyStaff )) {
  727. // &&$rolename['rid']==$endStaffArray['nextStaff']
  728. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  729. $button = 4;
  730. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  731. }
  732. foreach ( $verifyStaff as $m => $u ) {
  733. $AVLFK = $AVL [0] . '_R';
  734. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  735. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  736. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  737. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  738. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  739. break;
  740. }
  741. }
  742. } else {
  743. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  744. $button = 4;
  745. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  746. }
  747. }
  748. // $roleArray[$MKI]['rolename']=$rolename['name'];
  749. $KOP = true;
  750. }
  751. }
  752. foreach ( $roleArrayCopy as $k => $v ) {
  753. foreach ( $verifyList as $m => $n ) {
  754. if ($n [0] == $k) {
  755. array_splice ( $verifyList, $m, 1, $v );
  756. }
  757. }
  758. }
  759. $receiptList [$key] ['verifyList'] = $verifyList;
  760. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  761. 'where' => 'sid=' . $value ['staff'],
  762. 'asArray' => true
  763. ) );
  764. $receiptList [$key] ['button'] = $button;
  765. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  766. }
  767. $mothHtml = "";
  768. for($i = 1; $i <= 12; $i ++) {
  769. if ($month == $i)
  770. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  771. else
  772. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  773. }
  774. // 获取审批日志
  775. Doo::loadModel ( 'receiptLog' );
  776. $receiptLog = new receiptLog ();
  777. $rlList = array ();
  778. $rlInfo = $receiptLog->getOne ( array (
  779. 'where' => 'rid=' . $rid . ' and status=4',
  780. 'asArray' => true
  781. ) );
  782. $tijdate = $receiptLog->getOne ( array (
  783. 'where' => 'rid=' . $rid . ' and status=2',
  784. 'asc' => 'rlid',
  785. 'asArray' => true
  786. ) );
  787. if (! empty ( $rlInfo )) {
  788. $rlList = $receiptLog->find ( array (
  789. 'where' => 'rid=' . $rid,
  790. 'asc' => 'rlid',
  791. 'asArray' => true
  792. ) );
  793. }
  794. $receiptList [0] ['rlList'] = $rlList;
  795. $enclosurList = $enclosur->find ( array (
  796. 'where' => 'rid=' . $rid,
  797. 'asArray' => true
  798. ) );
  799. $enclosurHtml = '';
  800. foreach ( $enclosurList as $value ) {
  801. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  802. }
  803. // print_r($receiptList);
  804. $data ['enclosurHtml'] = $enclosurHtml;
  805. $data ['rolename'] = $rolename ['name'];
  806. $data ['datetij'] = $tijdate ['date'];
  807. $data ['mothHtml'] = $mothHtml;
  808. $data ['rid'] = $rid;
  809. $data ['receiptList'] = $receiptList;
  810. $data ['receiptApprovalCount'] = count ( $receiptList );
  811. $data ['status'] = $status;
  812. $data ['year'] = $year;
  813. $data ['categoryList'] = $categoryList;
  814. $data ['staffList'] = $staffList;
  815. $data ['cid'] = $cid;
  816. $data ['sid'] = $sid;
  817. $data ['ap'] = $ap;
  818. $data ['memu'] = "receipt";
  819. $data ['staff'] = $this->staff;
  820. $data ['receiptMemu'] = 'approvalExpenses';
  821. $data ['verifyId'] = $this->verifyId;
  822. $data ['executeId'] = $this->executeId;
  823. $this->render ( "/admin/remitApproval", $data );
  824. }
  825. function saeaLoanAdd() {
  826. Doo::loadModel ( 'verify' );
  827. $verify = new verify ();
  828. Doo::loadModel ( "role" );
  829. $role = new role ();
  830. Doo::loadModel ( 'L_category' );
  831. $lCategory = new L_category ();
  832. $veList = $verify->getVerifyBySubordinate('LOAN');
  833. $data ['category'] = $lCategory->find ( array (
  834. 'asArray' => true
  835. ) );
  836. $data ['veList'] = $veList;
  837. $data ['memu'] = "receipt";
  838. $data ['staff'] = $this->staff;
  839. $data ['receiptMemu'] = 'saeaBorad';
  840. $data ['verifyId'] = $this->verifyId;
  841. $data ['executeId'] = $this->executeId;
  842. $this->render ( "/admin/saeaLoanAdd", $data );
  843. }
  844. function saeaLoanAddDo() {
  845. $agency = $this->get_args ( 'agency' );
  846. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  847. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  848. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  849. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  850. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  851. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  852. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  853. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  854. // die;
  855. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  856. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  857. header ( 'Content-Type:text/html;charset=utf-8' );
  858. die ( '请填写联行号' );
  859. }
  860. Doo::loadModel ( 'receipt' );
  861. Doo::loadModel ( 'receiptDetail' );
  862. Doo::loadModel ( 'accountItem' );
  863. $accountItem = new accountItem ();
  864. $receipt = new receipt ();
  865. Doo::loadModel ( 'loanReceipt' );
  866. $loanReceipt = new loanReceipt ();
  867. Doo::loadModel ( 'execute' );
  868. $execute = new execute ();
  869. Doo::loadModel ( 'enclosur' );
  870. $executeDetail = $execute->getOne ( array (
  871. 'where' => 'mold="借款执行人"',
  872. 'asArray' => true
  873. ) );
  874. $aItem = $accountItem->find ( array (
  875. 'asArray' => true
  876. ) );
  877. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  878. $ag = $tr = $ta = $ot = 0;
  879. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  880. array_push ( $accountJson ['借款费用'], array (
  881. 'aid' => 0,
  882. 'name' => '申请金额',
  883. 'price' => number_format ( $agency, 2, '.', '' )
  884. ) );
  885. $sum += $agency;
  886. $agencySum += $agency;
  887. $accountJson ['cSum'] = array (
  888. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  889. 'agencySum' => number_format ( 0, 2, '.', '' ),
  890. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  891. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  892. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  893. );
  894. // 借款数据备份
  895. $loanReceipt->loanItem = json_encode ( $accountJson );
  896. $loanReceipt->staff = $this->staff [0] ['sid'];
  897. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  898. $loanReceipt->date = date ( "Y-m-d" );
  899. $loanReceipt->cid = $cid;
  900. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  901. $loanReceipt->status = 5;
  902. $loanReceipt->Rtype = 1;
  903. $loanReceipt->verify = $verify;
  904. $receipt->receiptOrder = $receipt->receiptOrder;
  905. // 添加HTML换行符
  906. // var_dump($explanation);
  907. $order = array (
  908. "\r\n",
  909. "\n",
  910. "\r"
  911. );
  912. $replace = '<br/>';
  913. $explanation = str_replace ( $order, $replace, $explanation );
  914. // $explanation=str_replace('\r',"<br/>",$explanation);
  915. // $explanation=str_replace('\r\n',"<br/>",$explanation);
  916. $loanReceipt->explanation = $explanation;
  917. $loanRid = $loanReceipt->insert ();
  918. // 报销单
  919. $receipt->loanItem = json_encode ( $accountJson );
  920. $receipt->staff = $this->staff [0] ['sid'];
  921. $receipt->sum = number_format ( $sum, 2, '.', '' );
  922. $receipt->date = date ( "Y-m-d" );
  923. $receipt->cid = $cid;
  924. // 特殊状态
  925. $receipt->status = 5;
  926. $receipt->Rtype = 1;
  927. $receipt->loanRid = $loanRid;
  928. // 修改审批流程加入角色
  929. $receipt->verify = $verify;
  930. $receipt->executeCopy = $executeDetail ['staff'];
  931. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  932. $receipt->explanation = $explanation;
  933. $receipt->remittanceName = $remittanceName;
  934. $receipt->bankName = $bankName;
  935. $receipt->bankNumber = $bankNumber;
  936. $receipt->remittanceBankType = $remittanceBankType;
  937. if ($remittanceBankType == 1)
  938. $receipt->coupletNumber = $coupletNumber;
  939. $rid = $receipt->insert ();
  940. return "/saeaBorad";
  941. } else
  942. die ( 'illegal request' );
  943. }
  944. function saeaLoanEdi() {
  945. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  946. Doo::loadClass ( 'XDeode' );
  947. $XDeode = new XDeode ( 7 );
  948. $rid = $XDeode->decode ( $ridKey );
  949. if (! is_numeric ( $rid ))
  950. die ( 'illegal request' );
  951. Doo::loadModel ( 'verify' );
  952. $verify = new verify ();
  953. Doo::loadModel ( "role" );
  954. $role = new role ();
  955. Doo::loadModel ( 'L_category' );
  956. $lCategory = new L_category ();
  957. Doo::loadModel ( 'receipt' );
  958. $receipt = new receipt ();
  959. $receiptInfo = $receipt->getOne ( array (
  960. 'where' => 'rid=' . $rid,
  961. 'asArray' => true
  962. ) );
  963. $veList = $verify->find ( array (
  964. 'where'=>'subordinate like "%LOAN%"',
  965. 'asArray' => true
  966. ) );
  967. foreach ( $veList as $key => $value ) {
  968. $v = json_decode ( $value ['staff'] );
  969. $list = array ();
  970. foreach ( $v as $n => $m ) {
  971. if ($m ['1'] == 'ROLE') {
  972. $roleInfo = $role->getOne ( array (
  973. 'where' => 'rid=' . $m [0],
  974. 'asArray' => true
  975. ) );
  976. $v [$n] [1] = $roleInfo ['name'];
  977. array_push ( $list, $roleInfo ['name'] );
  978. } else {
  979. array_push ( $list, $v [$n] [1] );
  980. }
  981. }
  982. $veList [$key] ['staff'] = implode ( '>', $list );
  983. }
  984. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  985. // print_r($receiptInfo);
  986. $data ['receiptInfo'] = $receiptInfo;
  987. $data ['category'] = $lCategory->find ( array (
  988. 'asArray' => true
  989. ) );
  990. $data ['veList'] = $veList;
  991. $data ['ridKey'] = $ridKey;
  992. $data ['memu'] = "receipt";
  993. $data ['staff'] = $this->staff;
  994. $data ['receiptMemu'] = 'saeaBorad';
  995. $data ['verifyId'] = $this->verifyId;
  996. $data ['executeId'] = $this->executeId;
  997. $this->render ( "/admin/saeaLoanEdi", $data );
  998. }
  999. function saeaLoanEdiDo() {
  1000. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1001. $agency = $this->get_args ( 'agency' );
  1002. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1003. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1004. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1005. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1006. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1007. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1008. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1009. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1010. // die;
  1011. Doo::loadClass ( 'XDeode' );
  1012. $XDeode = new XDeode ( 7 );
  1013. $rid = $XDeode->decode ( $ridKey );
  1014. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1015. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1016. header ( 'Content-Type:text/html;charset=utf-8' );
  1017. die ( '请填写联行号' );
  1018. }
  1019. Doo::loadModel ( 'receipt' );
  1020. Doo::loadModel ( 'receiptDetail' );
  1021. Doo::loadModel ( 'accountItem' );
  1022. $accountItem = new accountItem ();
  1023. $receipt = new receipt ();
  1024. Doo::loadModel ( 'loanReceipt' );
  1025. $loanReceipt = new loanReceipt ();
  1026. Doo::loadModel ( 'enclosur' );
  1027. Doo::loadModel ( 'execute' );
  1028. $execute = new execute ();
  1029. $executeDetail = $execute->getOne ( array (
  1030. 'where' => 'mold="借款执行人"',
  1031. 'asArray' => true
  1032. ) );
  1033. $receiptDetail = $receipt->getOne ( array (
  1034. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  1035. 'asArray' => true
  1036. ) );
  1037. if (empty ( $receiptDetail ))
  1038. die ( '参数错误' );
  1039. $aItem = $accountItem->find ( array (
  1040. 'asArray' => true
  1041. ) );
  1042. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1043. $ag = $tr = $ta = $ot = 0;
  1044. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1045. array_push ( $accountJson ['借款费用'], array (
  1046. 'aid' => 0,
  1047. 'name' => '申请金额',
  1048. 'price' => number_format ( $agency, 2, '.', '' )
  1049. ) );
  1050. $sum += $agency;
  1051. $agencySum += $agency;
  1052. $accountJson ['cSum'] = array (
  1053. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1054. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1055. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1056. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1057. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1058. );
  1059. // 报销单
  1060. $receipt->loanItem = json_encode ( $accountJson );
  1061. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1062. $receipt->cid = $cid;
  1063. // 特殊状态
  1064. // 修改审批流程加入角色
  1065. if ($receiptDetail ['status'] != 4)
  1066. $receipt->verify = $verify;
  1067. $order = array (
  1068. "\r\n",
  1069. "\n",
  1070. "\r"
  1071. );
  1072. $replace = '<br/>';
  1073. $explanation = str_replace ( $order, $replace, $explanation );
  1074. $receipt->explanation = $explanation;
  1075. $receipt->remittanceName = $remittanceName;
  1076. $receipt->bankName = $bankName;
  1077. $receipt->bankNumber = $bankNumber;
  1078. $receipt->remittanceBankType = $remittanceBankType;
  1079. if ($remittanceBankType == 1)
  1080. $receipt->coupletNumber = $coupletNumber;
  1081. $receipt->update ( array (
  1082. 'where' => 'rid=' . $rid
  1083. ) );
  1084. // 借款数据更新
  1085. $loanReceipt->loanItem = json_encode ( $accountJson );
  1086. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1087. $loanReceipt->cid = $cid;
  1088. if ($receiptDetail ['status'] != 4)
  1089. $loanReceipt->verify = $verify;
  1090. $loanReceipt->explanation = $explanation;
  1091. $receipt->executeCopy = $executeDetail ['staff'];
  1092. $loanReceipt->update ( array (
  1093. 'where' => 'rid=' . $receiptDetail ['loanRid']
  1094. ) );
  1095. }
  1096. return "/saeaBorad";
  1097. }
  1098. function saeaLoanReceiptAdd() {
  1099. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1100. Doo::loadModel ( 'receipt' );
  1101. $receipt = new receipt ();
  1102. Doo::loadModel ( 'loanReceipt' );
  1103. $loanReceipt = new loanReceipt ();
  1104. Doo::loadModel ( 'L_category' );
  1105. $Lcategory = new L_category ();
  1106. Doo::loadModel ( 'verify' );
  1107. Doo::loadModel ( 'statistics' );
  1108. $statistics = new statistics ();
  1109. $verify = new verify ();
  1110. Doo::loadModel ( 'staff' );
  1111. $staff = new staff ();
  1112. $receiptDetail = $receipt->getOne ( array (
  1113. 'where' => 'rid=' . $rid,
  1114. 'desc' => 'rid',
  1115. 'asArray' => true
  1116. ) );
  1117. $receiptList = $loanReceipt->find ( array (
  1118. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1119. 'desc' => 'rid',
  1120. 'asArray' => true
  1121. ) );
  1122. $Locate = 0;
  1123. $roleId = 0;
  1124. $button = 0;
  1125. foreach ( $receiptList as $key => $value ) {
  1126. $receiptList [$key] ['Locate'] = $Locate;
  1127. $Locate ++;
  1128. $receiptList [$key] ['reviseDetail'] = array ();
  1129. if (! empty ( $value ['reviseDetail'] ))
  1130. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1131. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1132. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1133. $categoryDetil = $Lcategory->getOne ( array (
  1134. 'where' => 'cid=' . $value ['cid'],
  1135. 'asArray' => true
  1136. ) );
  1137. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1138. // 检测编辑状态
  1139. $verifyList = $verify->getOne ( array (
  1140. 'where' => 'vid=' . $value ['verify'],
  1141. 'asArray' => true
  1142. ) );
  1143. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1144. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1145. Doo::loadModel ( 'role' );
  1146. $role = new role ();
  1147. $flag = true;
  1148. $roleKey = 0;
  1149. $endStaffArray = array ();
  1150. $roleArrayCopy = array ();
  1151. foreach ( $verifyList as $k => $v ) {
  1152. // init verifyStaff
  1153. if ($v [1] == 'ROLE') {
  1154. if (! empty ( $verifyStaff )) {
  1155. $endStaffArray = end ( $verifyStaff );
  1156. // if ($v[0]==$endStaffArray['nextStaff']){
  1157. // $roleId=$v[0];
  1158. // }
  1159. }
  1160. $roleVerify = json_decode ( $v [3], true );
  1161. $roleKey = $k;
  1162. $roleArray = array ();
  1163. $rolename = $role->getOne ( array (
  1164. 'where' => 'rid=' . $v [0],
  1165. 'asArray' => true
  1166. ) );
  1167. foreach ( $roleVerify as $o => $p ) {
  1168. $staffID = explode ( '_', $p );
  1169. $staffInfo = $staff->getOne ( array (
  1170. 'where' => 'sid=' . $staffID [0],
  1171. 'asArray' => true
  1172. ) );
  1173. // print_r($staffID);
  1174. $exp = array (
  1175. 0 => $staffInfo ['sid'],
  1176. 1 => $staffID [1],
  1177. 2 => $staffInfo ['avatar'],
  1178. 'date' => '',
  1179. 'date' => '',
  1180. 'opinion' => '',
  1181. 'status' => '',
  1182. 'rolename' => $rolename ['name']
  1183. );
  1184. array_push ( $roleArray, $exp );
  1185. }
  1186. $roleArrayCopy [$v [0]] = $roleArray;
  1187. // $verifyList[$k]['roleArray']=$roleArray;
  1188. }
  1189. $verifyList [$k] ['date'] = "";
  1190. $verifyList [$k] ['opinion'] = "";
  1191. $verifyList [$k] ['status'] = "";
  1192. if (empty ( $verifyStaff )) {
  1193. $verifyList [$k] ['date'] = "";
  1194. $verifyList [$k] ['opinion'] = "";
  1195. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1196. $verifyList [$k] ['status'] = 4;
  1197. $flag = false;
  1198. }
  1199. } else {
  1200. foreach ( $verifyStaff as $m => $u ) {
  1201. if ($v [0] == $m) {
  1202. $verifyList [$k] ['date'] = $u ['date'];
  1203. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1204. $verifyList [$k] ['status'] = $u ['status'];
  1205. $flag = false;
  1206. break;
  1207. }
  1208. }
  1209. $endStaffArray = end ( $verifyStaff );
  1210. if (isset ( $endStaffArray ['ROLE'] )) {
  1211. } else {
  1212. // $endKey=key($verifyStaff);
  1213. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1214. // $button=4;
  1215. // $verifyList[$k]['status']=4;
  1216. // }
  1217. }
  1218. }
  1219. }
  1220. $rolename ['name'] = '';
  1221. if (! empty ( $roleId )) {
  1222. Doo::loadModel ( 'role' );
  1223. $role = new role ();
  1224. $rolename = $role->getOne ( array (
  1225. 'where' => 'rid=' . $roleId,
  1226. 'asArray' => true
  1227. ) );
  1228. }
  1229. if (! empty ( $verifyStaff ))
  1230. $endStaffArray = end ( $verifyStaff );
  1231. $KOP = false;
  1232. foreach ( $roleArrayCopy as $P => $A ) {
  1233. foreach ( $A as $MKI => $AVL ) {
  1234. if (! empty ( $verifyStaff )) {
  1235. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1236. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1237. $button = 4;
  1238. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1239. }
  1240. foreach ( $verifyStaff as $m => $u ) {
  1241. $AVLFK = $AVL [0] . '_R';
  1242. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1243. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1244. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1245. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1246. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1247. break;
  1248. }
  1249. }
  1250. } else {
  1251. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1252. $button = 4;
  1253. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1254. }
  1255. }
  1256. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1257. $KOP = true;
  1258. }
  1259. }
  1260. foreach ( $roleArrayCopy as $k => $v ) {
  1261. foreach ( $verifyList as $m => $n ) {
  1262. if ($n [0] == $k) {
  1263. array_splice ( $verifyList, $m, 1, $v );
  1264. }
  1265. }
  1266. }
  1267. $receiptList [$key] ['verifyList'] = $verifyList;
  1268. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1269. 'where' => 'sid=' . $value ['staff'],
  1270. 'asArray' => true
  1271. ) );
  1272. $receiptList [$key] ['button'] = $button;
  1273. //
  1274. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1275. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1276. }
  1277. $data ['receiptList'] = $receiptList;
  1278. $data ['receiptDetail'] = $receiptDetail;
  1279. Doo::loadModel ( 'L_category' );
  1280. $lCategory = new L_category ();
  1281. Doo::loadModel ( 'accountItem' );
  1282. $accountItem = new accountItem ();
  1283. $acItem = $accountItem->find ( array (
  1284. 'asArray' => true
  1285. ) );
  1286. $veList = $verify->getVerifyBySubordinate('RECEIPT','LOAN');
  1287. $data ['rid'] = $rid;
  1288. $data ['category'] = $lCategory->find ( array (
  1289. 'asArray' => true
  1290. ) );
  1291. $data ['veList'] = $veList;
  1292. $data ['acItem'] = $acItem;
  1293. $data ['memu'] = "receipt";
  1294. $data ['staff'] = $this->staff;
  1295. $data ['receiptMemu'] = 'saeaBorad';
  1296. $data ['verifyId'] = $this->verifyId;
  1297. $data ['executeId'] = $this->executeId;
  1298. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1299. }
  1300. function saeaLoanReceiptAddDo() {
  1301. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1302. $agency = $this->get_args ( 'agency' );
  1303. $travel = $this->get_args ( 'travel' );
  1304. $train = $this->get_args ( 'train' );
  1305. $other = $this->get_args ( 'other' );
  1306. $inttrain = $this->get_args ( 'inttrain' );
  1307. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1308. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1309. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1310. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1311. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1312. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1313. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1314. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1315. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1316. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1317. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1318. header ( 'Content-Type:text/html;charset=utf-8' );
  1319. die ( '请填写联行号' );
  1320. }
  1321. Doo::loadModel ( 'receipt' );
  1322. Doo::loadModel ( 'receiptDetail' );
  1323. Doo::loadModel ( 'accountItem' );
  1324. $accountItem = new accountItem ();
  1325. $receipt = new receipt ();
  1326. Doo::loadModel ( 'enclosur' );
  1327. Doo::loadModel ( 'execute' );
  1328. $execute = new execute ();
  1329. $executeDetail = $execute->getOne ( array (
  1330. 'where' => 'mold="借款费用执行人"',
  1331. 'asArray' => true
  1332. ) );
  1333. $receiptDet = $receipt->getOne ( array (
  1334. 'where' => 'rid=' . $rid,
  1335. 'asArray' => true
  1336. ) );
  1337. // if(!empty($receiptDetail))
  1338. // return "/referReceipt/".$receiptDetail['rid'];
  1339. $aItem = $accountItem->find ( array (
  1340. 'asArray' => true
  1341. ) );
  1342. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1343. $ag = $tr = $ta = $ot =$it = 0;
  1344. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  1345. foreach ( $aItem as $key => $value ) {
  1346. if ($value ['category'] == $this->AGENCY) {
  1347. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1348. array_push ( $accountJson [$this->AGENCY], array (
  1349. 'aid' => $value ['aid'],
  1350. 'name' => $value ['name'],
  1351. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1352. ) );
  1353. $sum += $agency [$ag];
  1354. $agencySum += $agency [$ag];
  1355. }
  1356. $ag ++;
  1357. }
  1358. if ($value ['category'] == $this->TRAVEL) {
  1359. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1360. array_push ( $accountJson [$this->TRAVEL], array (
  1361. 'aid' => $value ['aid'],
  1362. 'name' => $value ['name'],
  1363. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1364. ) );
  1365. $sum += $travel [$tr];
  1366. $travelSum += $travel [$tr];
  1367. }
  1368. $tr ++;
  1369. }
  1370. if ($value ['category'] == $this->INTTRAIN) {
  1371. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  1372. array_push ( $accountJson [$this->INTTRAIN], array (
  1373. 'aid' => $value ['aid'],
  1374. 'name' => $value ['name'],
  1375. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  1376. ) );
  1377. $sum += $inttrain [$it];
  1378. $inttrainSum += $inttrain [$it];
  1379. }
  1380. $it ++;
  1381. }
  1382. if ($value ['category'] == $this->TRAIN) {
  1383. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1384. array_push ( $accountJson [$this->TRAIN], array (
  1385. 'aid' => $value ['aid'],
  1386. 'name' => $value ['name'],
  1387. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1388. ) );
  1389. $sum += $train [$ta];
  1390. $trainSum += $train [$ta];
  1391. }
  1392. $ta ++;
  1393. }
  1394. if ($value ['category'] == $this->OTHER) {
  1395. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1396. array_push ( $accountJson [$this->OTHER], array (
  1397. 'aid' => $value ['aid'],
  1398. 'name' => $value ['name'],
  1399. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1400. ) );
  1401. $sum += $other [$ot];
  1402. $otherSum += $other [$ot];
  1403. }
  1404. $ot ++;
  1405. }
  1406. }
  1407. $accountJson ['cSum'] = array (
  1408. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1409. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1410. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1411. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  1412. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1413. );
  1414. // 报销单
  1415. $receipt->accountItem = json_encode ( $accountJson );
  1416. $receipt->staff = $this->staff [0] ['sid'];
  1417. $receipt->loanSum = $receiptDet ['sum'];
  1418. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1419. $receipt->date = date ( "Y-m-d" );
  1420. $receipt->pastDate = '';
  1421. $receipt->cid = $cid;
  1422. $receipt->status = 7;
  1423. // 修改审批流程加入角色
  1424. $receipt->verify = $verify;
  1425. $receipt->verifyStaff = '';
  1426. $receipt->executeStaff = '';
  1427. $receipt->executeCopy = $executeDetail ['staff'];
  1428. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1429. $receipt->explanation = $explanation;
  1430. $receipt->remittanceName = $remittanceName;
  1431. $receipt->bankName = $bankName;
  1432. $receipt->bankNumber = $bankNumber;
  1433. $receipt->remittanceBankType = $remittanceBankType;
  1434. if ($remittanceBankType == 1)
  1435. $receipt->coupletNumber = $coupletNumber;
  1436. $receipt->update ( array (
  1437. 'where' => 'rid=' . $rid
  1438. ) );
  1439. // 附件
  1440. if (! empty ( $enclosurName )) {
  1441. $enclosurArray = explode ( '-', $enclosurName );
  1442. foreach ( $enclosurArray as $value ) {
  1443. $enclosur = new enclosur ();
  1444. $enclosur->name = $value;
  1445. $enclosur->rid = $rid;
  1446. $enclosur->insert ();
  1447. }
  1448. // print_r($enclosurArray);die;
  1449. }
  1450. // 报销详情
  1451. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1452. $receiptDetail = new receiptDetail ();
  1453. $receiptDetail->staff = $this->staff [0] ['sid'];
  1454. $receiptDetail->item = $value ['name'];
  1455. $receiptDetail->itemCategory = $this->AGENCY;
  1456. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1457. $receiptDetail->date = date ( "Y-m-d" );
  1458. $receiptDetail->cid = $cid;
  1459. $receiptDetail->rid = $rid;
  1460. $receiptDetail->status = 4;
  1461. $receiptDetail->insert ();
  1462. }
  1463. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1464. $receiptDetail = new receiptDetail ();
  1465. $receiptDetail->staff = $this->staff [0] ['sid'];
  1466. $receiptDetail->item = $value ['name'];
  1467. $receiptDetail->itemCategory = $this->TRAVEL;
  1468. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1469. $receiptDetail->date = date ( "Y-m-d" );
  1470. $receiptDetail->cid = $cid;
  1471. $receiptDetail->rid = $rid;
  1472. $receiptDetail->status = 4;
  1473. $receiptDetail->insert ();
  1474. }
  1475. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1476. $receiptDetail = new receiptDetail ();
  1477. $receiptDetail->staff = $this->staff [0] ['sid'];
  1478. $receiptDetail->item = $value ['name'];
  1479. $receiptDetail->itemCategory = $this->TRAIN;
  1480. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1481. $receiptDetail->date = date ( "Y-m-d" );
  1482. $receiptDetail->cid = $cid;
  1483. $receiptDetail->rid = $rid;
  1484. $receiptDetail->status = 4;
  1485. $receiptDetail->insert ();
  1486. }
  1487. //内训
  1488. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  1489. $receiptDetail = new receiptDetail ();
  1490. $receiptDetail->staff = $this->staff [0] ['sid'];
  1491. $receiptDetail->item = $value ['name'];
  1492. $receiptDetail->itemCategory = $this->INTTRAIN;
  1493. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1494. $receiptDetail->date = date ( "Y-m-d" );
  1495. $receiptDetail->cid = $cid;
  1496. $receiptDetail->rid = $rid;
  1497. $receiptDetail->status = 4;
  1498. $receiptDetail->insert ();
  1499. }
  1500. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1501. $receiptDetail = new receiptDetail ();
  1502. $receiptDetail->staff = $this->staff [0] ['sid'];
  1503. $receiptDetail->item = $value ['name'];
  1504. $receiptDetail->itemCategory = $this->OTHER;
  1505. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1506. $receiptDetail->date = date ( "Y-m-d" );
  1507. $receiptDetail->cid = $cid;
  1508. $receiptDetail->rid = $rid;
  1509. $receiptDetail->status = 4;
  1510. $receiptDetail->insert ();
  1511. }
  1512. return "/saeaBorad";
  1513. }
  1514. return "/saeaLoanReceiptAdd/" . $rid;
  1515. }
  1516. function saeaLoanReceiptEdi() {
  1517. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1518. Doo::loadClass ( 'XDeode' );
  1519. $XDeode = new XDeode ( 7 );
  1520. $rid = $XDeode->decode ( $ridKey );
  1521. if (! is_numeric ( $rid ))
  1522. die ( 'illegal request' );
  1523. Doo::loadModel ( 'accountItem' );
  1524. Doo::loadModel ( 'verify' );
  1525. Doo::loadModel ( 'receipt' );
  1526. $receipt = new receipt ();
  1527. $verify = new verify ();
  1528. $accountItem = new accountItem ();
  1529. Doo::loadModel ( 'L_category' );
  1530. $Lcategory = new L_category ();
  1531. Doo::loadModel ( "role" );
  1532. $role = new role ();
  1533. Doo::loadModel ( 'loanReceipt' );
  1534. $loanReceipt = new loanReceipt ();
  1535. Doo::loadModel ( 'staff' );
  1536. $staff = new staff ();
  1537. $receiptDetail = $receipt->getOne ( array (
  1538. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1539. 'asArray' => true
  1540. ) );
  1541. if (empty ( $receiptDetail ))
  1542. return "/saeaBorad";
  1543. $receiptList = $loanReceipt->find ( array (
  1544. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1545. 'desc' => 'rid',
  1546. 'asArray' => true
  1547. ) );
  1548. $Locate = 0;
  1549. $roleId = 0;
  1550. $button = 0;
  1551. foreach ( $receiptList as $key => $value ) {
  1552. $receiptList [$key] ['Locate'] = $Locate;
  1553. $Locate ++;
  1554. $receiptList [$key] ['reviseDetail'] = array ();
  1555. if (! empty ( $value ['reviseDetail'] ))
  1556. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1557. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1558. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1559. $categoryDetil = $Lcategory->getOne ( array (
  1560. 'where' => 'cid=' . $value ['cid'],
  1561. 'asArray' => true
  1562. ) );
  1563. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1564. // 检测编辑状态
  1565. $verifyList = $verify->getOne ( array (
  1566. 'where' => 'vid=' . $value ['verify'],
  1567. 'asArray' => true
  1568. ) );
  1569. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1570. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1571. Doo::loadModel ( 'role' );
  1572. $role = new role ();
  1573. $flag = true;
  1574. $roleKey = 0;
  1575. $endStaffArray = array ();
  1576. $roleArrayCopy = array ();
  1577. foreach ( $verifyList as $k => $v ) {
  1578. // init verifyStaff
  1579. if ($v [1] == 'ROLE') {
  1580. if (! empty ( $verifyStaff )) {
  1581. $endStaffArray = end ( $verifyStaff );
  1582. // if ($v[0]==$endStaffArray['nextStaff']){
  1583. // $roleId=$v[0];
  1584. // }
  1585. }
  1586. $roleVerify = json_decode ( $v [3], true );
  1587. $roleKey = $k;
  1588. $roleArray = array ();
  1589. $rolename = $role->getOne ( array (
  1590. 'where' => 'rid=' . $v [0],
  1591. 'asArray' => true
  1592. ) );
  1593. foreach ( $roleVerify as $o => $p ) {
  1594. $staffID = explode ( '_', $p );
  1595. $staffInfo = $staff->getOne ( array (
  1596. 'where' => 'sid=' . $staffID [0],
  1597. 'asArray' => true
  1598. ) );
  1599. // print_r($staffID);
  1600. $exp = array (
  1601. 0 => $staffInfo ['sid'],
  1602. 1 => $staffID [1],
  1603. 2 => $staffInfo ['avatar'],
  1604. 'date' => '',
  1605. 'date' => '',
  1606. 'opinion' => '',
  1607. 'status' => '',
  1608. 'rolename' => $rolename ['name']
  1609. );
  1610. array_push ( $roleArray, $exp );
  1611. }
  1612. $roleArrayCopy [$v [0]] = $roleArray;
  1613. // $verifyList[$k]['roleArray']=$roleArray;
  1614. }
  1615. $verifyList [$k] ['date'] = "";
  1616. $verifyList [$k] ['opinion'] = "";
  1617. $verifyList [$k] ['status'] = "";
  1618. if (empty ( $verifyStaff )) {
  1619. $verifyList [$k] ['date'] = "";
  1620. $verifyList [$k] ['opinion'] = "";
  1621. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1622. $verifyList [$k] ['status'] = 4;
  1623. $flag = false;
  1624. }
  1625. } else {
  1626. foreach ( $verifyStaff as $m => $u ) {
  1627. if ($v [0] == $m) {
  1628. $verifyList [$k] ['date'] = $u ['date'];
  1629. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1630. $verifyList [$k] ['status'] = $u ['status'];
  1631. $flag = false;
  1632. break;
  1633. }
  1634. }
  1635. $endStaffArray = end ( $verifyStaff );
  1636. if (isset ( $endStaffArray ['ROLE'] )) {
  1637. } else {
  1638. // $endKey=key($verifyStaff);
  1639. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1640. // $button=4;
  1641. // $verifyList[$k]['status']=4;
  1642. // }
  1643. }
  1644. }
  1645. }
  1646. $rolename ['name'] = '';
  1647. if (! empty ( $roleId )) {
  1648. Doo::loadModel ( 'role' );
  1649. $role = new role ();
  1650. $rolename = $role->getOne ( array (
  1651. 'where' => 'rid=' . $roleId,
  1652. 'asArray' => true
  1653. ) );
  1654. }
  1655. if (! empty ( $verifyStaff ))
  1656. $endStaffArray = end ( $verifyStaff );
  1657. $KOP = false;
  1658. foreach ( $roleArrayCopy as $P => $A ) {
  1659. foreach ( $A as $MKI => $AVL ) {
  1660. if (! empty ( $verifyStaff )) {
  1661. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1662. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1663. $button = 4;
  1664. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1665. }
  1666. foreach ( $verifyStaff as $m => $u ) {
  1667. $AVLFK = $AVL [0] . '_R';
  1668. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1669. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1670. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1671. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1672. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1673. break;
  1674. }
  1675. }
  1676. } else {
  1677. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1678. $button = 4;
  1679. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1680. }
  1681. }
  1682. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1683. $KOP = true;
  1684. }
  1685. }
  1686. foreach ( $roleArrayCopy as $k => $v ) {
  1687. foreach ( $verifyList as $m => $n ) {
  1688. if ($n [0] == $k) {
  1689. array_splice ( $verifyList, $m, 1, $v );
  1690. }
  1691. }
  1692. }
  1693. $receiptList [$key] ['verifyList'] = $verifyList;
  1694. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1695. 'where' => 'sid=' . $value ['staff'],
  1696. 'asArray' => true
  1697. ) );
  1698. $receiptList [$key] ['button'] = $button;
  1699. //
  1700. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1701. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1702. }
  1703. $data ['receiptList'] = $receiptList;
  1704. $acItem = $accountItem->find ( array (
  1705. 'asArray' => true
  1706. ) );
  1707. $veList = $verify->find ( array (
  1708. 'asArray' => true
  1709. ) );
  1710. foreach ( $veList as $key => $value ) {
  1711. $v = json_decode ( $value ['staff'] );
  1712. $list = array ();
  1713. foreach ( $v as $n => $m ) {
  1714. if ($m ['1'] == 'ROLE') {
  1715. $roleInfo = $role->getOne ( array (
  1716. 'where' => 'rid=' . $m [0],
  1717. 'asArray' => true
  1718. ) );
  1719. $v [$n] [1] = $roleInfo ['name'];
  1720. array_push ( $list, $roleInfo ['name'] );
  1721. } else {
  1722. array_push ( $list, $v [$n] [1] );
  1723. }
  1724. }
  1725. $veList [$key] ['staff'] = implode ( '>', $list );
  1726. }
  1727. // 配置编辑信息
  1728. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1729. foreach ( $acItem as $key => $value ) {
  1730. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1731. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1732. $acItem [$key] ['price'] = $v ['price'];
  1733. }
  1734. }
  1735. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1736. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1737. $acItem [$key] ['price'] = $v ['price'];
  1738. }
  1739. }
  1740. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1741. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1742. $acItem [$key] ['price'] = $v ['price'];
  1743. }
  1744. }
  1745. //内训
  1746. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  1747. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1748. $acItem [$key] ['price'] = $v ['price'];
  1749. }
  1750. }
  1751. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1752. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1753. $acItem [$key] ['price'] = $v ['price'];
  1754. }
  1755. }
  1756. }
  1757. $data ['category'] = $Lcategory->find ( array (
  1758. 'asArray' => true
  1759. ) );
  1760. $data ['ridKey'] = $ridKey;
  1761. $data ['cSum'] = $accountItemList ['cSum'];
  1762. $data ['sum'] = $receiptDetail ['sum'];
  1763. $data ['receiptDetail'] = $receiptDetail;
  1764. $data ['veList'] = $veList;
  1765. $data ['acItem'] = $acItem;
  1766. $data ['memu'] = "receipt";
  1767. $data ['staff'] = $this->staff;
  1768. $data ['receiptMemu'] = 'saeaBorad';
  1769. $data ['verify'] = $receiptDetail ['verify'];
  1770. $data ['verifyId'] = $this->verifyId;
  1771. $data ['executeId'] = $this->executeId;
  1772. $data ['rid'] = $rid;
  1773. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1774. }
  1775. /**
  1776. * 培训班结算
  1777. */
  1778. function receiptTrainAdd() {
  1779. Doo::loadModel ( 'accountItem' );
  1780. $accountItem = new accountItem ();
  1781. $acItem = $accountItem->find ( array (
  1782. 'asArray' => true
  1783. ) );
  1784. // 审批组
  1785. Doo::loadModel ( 'verify' );
  1786. $verify = new verify ();
  1787. $veList = $verify->getVerifyBySubordinate('TRAIN');
  1788. // 办事处
  1789. Doo::loadModel ( 'L_category' );
  1790. $lCategory = new L_category ();
  1791. $data ['category'] = $lCategory->getCategory ();
  1792. $data ['veList'] = $veList;
  1793. $data ['memu'] = "receipt";
  1794. $data ['staff'] = $this->staff;
  1795. $data ['acItem'] = $acItem;
  1796. $data ['receiptMemu'] = 'saeaBorad';
  1797. $data ['verifyId'] = $this->verifyId;
  1798. $data ['executeId'] = $this->executeId;
  1799. $this->render ( "/receipt/receiptTrainAdd", $data );
  1800. }
  1801. /**
  1802. * 添加培训班结算
  1803. */
  1804. function receiptTrainAddDo() {//include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  1805. // 培训班信息
  1806. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  1807. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  1808. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  1809. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  1810. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  1811. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  1812. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  1813. // 发票信息
  1814. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1815. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  1816. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1817. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1818. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1819. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1820. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1821. //&&! empty ( $participants )
  1822. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  1823. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1824. header ( 'Content-Type:text/html;charset=utf-8' );
  1825. die ( '请填写联行号' );
  1826. }
  1827. Doo::loadModel ( 'execute' );
  1828. $execute = new execute ();
  1829. $executeDetail = $execute->getOne ( array (
  1830. 'where' => 'mold="培训班结算"',
  1831. 'asArray' => true
  1832. ) );
  1833. if (empty ( $executeDetail )) {
  1834. header ( 'Content-Type:text/html;charset=utf-8' );
  1835. die ( '未设置执行人' );
  1836. }
  1837. Doo::loadClass ( 'XDeode' );
  1838. $XDeode = new XDeode ( 5 );
  1839. $cid = $XDeode->decode ( $cid );
  1840. Doo::loadModel ( 'receipt' );
  1841. $receipt = new receipt ();
  1842. Doo::loadModel ( 'receiptTraining' );
  1843. $receiptTraining = new receiptTraining ();
  1844. // 创建费用培训班
  1845. $item = array (
  1846. 'cid' => $this->staff [0] ['cid'],
  1847. 'categoryName' => $this->staff [0] ['category'],
  1848. 'trainName' => $trainName,
  1849. 'trainStartDate' => $trainStartDate,
  1850. 'trainEndDate' => $trainEndDate,
  1851. 'participants' => $participants,
  1852. 'freeParticipants'=>$freeParticipants,
  1853. 'trainAddress' => $trainAddress,
  1854. 'trainRemarks' => $trainRemarks,
  1855. 'creator' => $this->staff [0] ['sid'],
  1856. 'creatorDate' => date ( "Y-m-d H:i:s" )
  1857. );
  1858. $irid = $receiptTraining->addReceiptTraining ( $item );
  1859. // 报销单
  1860. $receipt->status = 5;
  1861. $receipt->trainId = $irid;
  1862. $receipt->Rtype = 3;
  1863. $receipt->staff = $this->staff [0] ['sid'];
  1864. $receipt->cid = $cid;
  1865. $receipt->verify = $verify;
  1866. $receipt->date = date ( "Y-m-d" );
  1867. $receipt->executeCopy = $executeDetail ['staff'];
  1868. $receipt->receiptOrder = "#P" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1869. $receipt->remittanceName = $remittanceName;
  1870. $receipt->bankName = $bankName;
  1871. $receipt->bankNumber = $bankNumber;
  1872. $receipt->remittanceBankType = $remittanceBankType;
  1873. if ($remittanceBankType == 1)
  1874. $receipt->coupletNumber = $coupletNumber;
  1875. $rid = $receipt->insert ();
  1876. $XDeode = new XDeode ( 7 );
  1877. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html";
  1878. } else
  1879. die ( 'illegal request' );
  1880. }
  1881. /**
  1882. * 培训班编辑
  1883. */
  1884. function receiptTrainEdi() {
  1885. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  1886. $trainEdiType = $this->get_args ( 'trainEdiType' ) ? $this->get_args ( 'trainEdiType' ) : "INFO";
  1887. Doo::loadClass ( 'XDeode' );
  1888. $XDeode = new XDeode ( 7 );
  1889. $rid = $XDeode->decode ( $ridKey );
  1890. if (! is_numeric ( $rid ))
  1891. die ( 'illegal request' );
  1892. Doo::loadModel ( 'receipt' );
  1893. $receipt = new receipt ();
  1894. Doo::loadModel ( 'receiptTraining' );
  1895. $receiptTraining = new receiptTraining ();
  1896. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  1897. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)){
  1898. die ('illegal request--status');
  1899. }
  1900. //如有已入账已收款的发票,自动取消办事处已收款
  1901. // Doo::loadModel ( 'RIExtend' );
  1902. // $RIExtend = new RIExtend ();
  1903. // $RIExtendList=$RIExtend->getRIExtendByRid($rid);
  1904. // if (!empty($RIExtendList)){
  1905. // foreach ($RIExtendList as $key=>$value){
  1906. // $RIExtend = new RIExtend ();
  1907. // $RIExtend->delete(array (
  1908. // 'where' => 'iid=' . $value['iid'],
  1909. // 'limit' => 1
  1910. // ));
  1911. // }
  1912. // }
  1913. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  1914. // 汇总表合计
  1915. // 收入合计--加入开票合计
  1916. Doo::loadModel ( 'invoiceTraining' );
  1917. $invoiceTraining = new invoiceTraining ();
  1918. $invoiceTrainingDetail = array (
  1919. 'invoiceArriveAmount' => 0,
  1920. 'RIAmount' => 0,
  1921. 'invoiceTotalAmount' => 0,
  1922. 'invoiceCompanyAmount'=>0
  1923. );
  1924. if ($receiptDetail ['invoiceTrainId'] != 0) {
  1925. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  1926. }
  1927. // print_r($invoiceTrainingDetail);
  1928. $invoiceArriveAmount = $RIAmount = 0;
  1929. if (! empty ( $invoiceTrainingDetail )) {
  1930. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  1931. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  1932. }
  1933. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  1934. //print_r($invoiceTrainingDetail);
  1935. // 支出项目
  1936. Doo::loadModel ( 'accountItem' );
  1937. $accountItem = new accountItem ();
  1938. // 项目金额合计
  1939. Doo::loadModel ( 'RItem' );
  1940. $RItem = new RItem ();
  1941. // 讲师获得
  1942. Doo::loadModel ( 'RILecturer' );
  1943. $RILecturer = new RILecturer ();
  1944. $RItemList = $RItem->getRItemByRid ( $rid );
  1945. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  1946. // 支出项金额详情
  1947. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  1948. // print_r($aiData);
  1949. // 利润
  1950. $profit=$invoiceArriveAmount - $aiData ['total'];
  1951. $companyProfit=$profit * 0.6;
  1952. $categoryProfit=$profit * 0.4;
  1953. $data ['profit'] = sprintf("%.2f",$profit);
  1954. $data ['companyProfit'] = sprintf("%.2f",$companyProfit);
  1955. $data ['categoryProfit'] = sprintf("%.2f",$categoryProfit);
  1956. //发票利润
  1957. $data ['invoiceProfit'] = $invoiceTrainingDetail ['invoiceTotalAmount'] - $aiData ['total'];
  1958. //发票公司利润
  1959. $invoiceCompanyProfit=$data ['invoiceProfit'] * 0.6;
  1960. $data ['invoiceCompanyProfit'] = sprintf("%.2f",$invoiceCompanyProfit);
  1961. //办事处利润
  1962. $invoiceCategoryProfit=$data ['invoiceProfit'] * 0.4;
  1963. $data ['invoiceCategoryProfit'] = sprintf("%.2f",$invoiceCategoryProfit);
  1964. // print_r($aiData['dataList']);
  1965. $categoryActualExpenditure= $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  1966. $data ['categoryActualExpenditure'] = sprintf("%.2f",$categoryActualExpenditure);
  1967. // 备用金
  1968. $sum = 0;
  1969. $data ['receiptLoanDetail'] = array (
  1970. 'sum' => '0.00'
  1971. );
  1972. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  1973. //$data ['receiptLoanDetail'] = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  1974. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  1975. $sum=0;
  1976. foreach ($receiptLoanList as $key=>$value){
  1977. $sum+=$value['sum'];
  1978. }
  1979. $data ['receiptLoanDetail'] = array (
  1980. 'sum' => $sum
  1981. );
  1982. //$sum = $data ['receiptLoanDetail'] ['sum'];
  1983. }
  1984. $payment=$sum + $RIAmount - $categoryActualExpenditure;
  1985. $data ['payment'] = sprintf("%.2f",$payment);
  1986. $data ['total'] = sprintf("%.2f",$aiData ['total']);
  1987. $data ['aiCount'] = count ( $aiData ['dataList'] ) + 5;
  1988. $data ['aiList'] = $aiData ['dataList'];
  1989. // 占比计算
  1990. if ($invoiceArriveAmount != 0) {
  1991. $data ['totalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceArriveAmount* 100) ;
  1992. $data ['profitProportion'] = sprintf("%.2f",$profit / $invoiceArriveAmount*100) ; //number_format ( $profit / $invoiceArriveAmount, 2, '.', '' ) * 100;
  1993. $data ['sumProportion'] = sprintf("%.2f",$sum / $invoiceArriveAmount*100) ; //number_format ( $sum / $invoiceArriveAmount, 2, '.', '' ) * 100;
  1994. $data ['invoiceTotalAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceArriveAmount*100) ;
  1995. $data ['RIAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceArriveAmount*100) ;
  1996. $data ['companyProfitProportion'] = sprintf("%.2f",$companyProfit / $invoiceArriveAmount*100) ;
  1997. $data ['categoryProportion'] = sprintf("%.2f",$categoryProfit / $invoiceArriveAmount*100) ;
  1998. $data ['categoryActualExpenditureProportion'] = sprintf("%.2f",$categoryActualExpenditure / $invoiceArriveAmount*100) ;
  1999. $data ['paymentProportion'] = sprintf("%.2f",$payment / $invoiceArriveAmount*100) ;
  2000. } else {
  2001. $data ['totalProportion'] = $data ['profitProportion'] = $data ['sumProportion'] = $data ['invoiceTotalAmountProportion'] = $data ['RIAmountProportion'] = $data ['companyProfitProportion'] = $data ['categoryActualExpenditureProportion'] = $data ['paymentProportion'] = $data ['categoryProportion'] = 0;
  2002. }
  2003. //发票金额占比计算
  2004. if ($invoiceTrainingDetail ['invoiceTotalAmount'] != 0) {
  2005. //支出
  2006. $data ['invoicetotalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2007. //利润
  2008. $data ['invoiceprofitProportion'] = sprintf("%.2f",$data ['invoiceProfit'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2009. //公司利润
  2010. $data ['invoicecompanyProfitProportion'] = sprintf("%.2f", $invoiceCompanyProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2011. //办事处利润
  2012. $data ['invoicecategoryProportion'] = sprintf("%.2f", $invoiceCategoryProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2013. //公司收款
  2014. $data ['invoiceTotalAmountProportionB'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2015. //备用金
  2016. $data ['invoicesumProportion'] = sprintf("%.2f", $sum / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2017. //办事处收款
  2018. $data ['invoiceRIAmountProportion'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2019. //办事处实际支出
  2020. $data ['ICAEP'] = sprintf("%.2f", $categoryActualExpenditure / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2021. //付总部款
  2022. $data ['invoicepaymentProportion'] = sprintf("%.2f", $payment / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2023. }else{
  2024. $data ['invoiceprofitProportion'] =$data ['invoiceRIAmountProportion'] =$data ['invoicetotalProportion'] =$data ['invoiceTotalAmountProportionB'] =$data ['invoicesumProportion'] =$data ['ICAEP'] =$data ['invoicepaymentProportion'] =$data ['invoicecompanyProfitProportion'] =$data ['invoicecategoryProportion'] =0;
  2025. }
  2026. //讲师人数
  2027. Doo::loadModel ( 'RILecturer' );
  2028. $RILecturer = new RILecturer ();
  2029. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2030. $data['lectureCount']=count($RILecturerList);
  2031. // 审批组
  2032. Doo::loadModel ( 'verify' );
  2033. $verify = new verify ();
  2034. $veList = $verify->getVerifyBySubordinate('TRAIN');
  2035. // 办事处
  2036. Doo::loadModel ( 'L_category' );
  2037. $lCategory = new L_category ();
  2038. $data ['category'] = $lCategory->getCategory ();
  2039. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2040. $data ['receiptDetail'] = $receiptDetail;
  2041. $data ['veList'] = $veList;
  2042. $data ['trainEdiType'] = $trainEdiType;
  2043. $data ['ridKey'] = $ridKey;
  2044. $data ['memu'] = "receipt";
  2045. $data ['staff'] = $this->staff;
  2046. $data ['receiptMemu'] = 'saeaBorad';
  2047. $data ['verifyId'] = $this->verifyId;
  2048. $data ['executeId'] = $this->executeId;
  2049. $this->render ( "/receipt/receiptTrainEdi", $data );
  2050. }
  2051. /**
  2052. * 培训班借款编辑
  2053. */
  2054. function receiptTrainLoanEdi() {
  2055. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2056. Doo::loadClass ( 'XDeode' );
  2057. $XDeode = new XDeode ( 7 );
  2058. $rid = $XDeode->decode ( $ridKey );
  2059. if (! is_numeric ( $rid ))
  2060. die ( 'illegal request' );
  2061. Doo::loadModel ( 'receipt' );
  2062. $receipt = new receipt ();
  2063. Doo::loadModel ( 'receiptTraining' );
  2064. $receiptTraining = new receiptTraining ();
  2065. Doo::loadModel ( 'verify' );
  2066. $verify = new verify ();
  2067. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2068. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  2069. die ();
  2070. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2071. // 借款详情HTML
  2072. // 获得借款信息
  2073. $receiptLoanHtml = '';
  2074. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  2075. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2076. foreach ($receiptLoanList as $key=>$value){
  2077. // 获得某费用单审批信息
  2078. $verifylist = $verify->getVerifyByRid ( $value ['rid'] );
  2079. Doo::loadClass ( 'receipt.func' );
  2080. $extendHtml = '<p><a class="button"
  2081. href="javascript:if(window.confirm(\'确认移除?\'))window.location=\'/receiptTrainLoanRemoveDo/' . $receiptDetail ['ridKey'] . '/' . $value ['ridKey'] . '.html\'" data-toggle="modal">移除借款</a></p>';
  2082. $receiptLoanHtml .= _getReceiptLoanHtml ( $value, $verifylist, $extendHtml );
  2083. }
  2084. }
  2085. $data ['receiptLoanHtml'] = $receiptLoanHtml;
  2086. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2087. $data ['receiptDetail'] = $receiptDetail;
  2088. $data ['trainEdiType'] = "LOAN";
  2089. $data ['ridKey'] = $ridKey;
  2090. $data ['memu'] = "receipt";
  2091. $data ['staff'] = $this->staff;
  2092. $data ['receiptMemu'] = 'saeaBorad';
  2093. $data ['verifyId'] = $this->verifyId;
  2094. $data ['executeId'] = $this->executeId;
  2095. $this->render ( "/receipt/receiptTrainLoanEdi", $data );
  2096. }
  2097. /**
  2098. * 更新培训班结算基本信息
  2099. */
  2100. function receiptTrainInfoEdiDo() {
  2101. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  2102. $rtid = $this->get_args ( 'rtid' ) ? $this->get_args ( 'rtid' ) : "";
  2103. // 培训班信息
  2104. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  2105. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  2106. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  2107. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  2108. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  2109. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  2110. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  2111. // 发票信息
  2112. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2113. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2114. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2115. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2116. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2117. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2118. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2119. //&& ! empty ( $participants )
  2120. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  2121. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2122. header ( 'Content-Type:text/html;charset=utf-8' );
  2123. die ( '请填写联行号' );
  2124. }
  2125. Doo::loadClass ( 'XDeode' );
  2126. $XDeode = new XDeode ( 5 );
  2127. $cid = $XDeode->decode ( $cid );
  2128. $rtid = $XDeode->decode ( $rtid );
  2129. $rid = $XDeode->decode ( $rid );
  2130. if (! is_numeric ( $rtid ) || ! is_numeric ( $rid )) {
  2131. die ( 'illegal request-IdError' );
  2132. }
  2133. Doo::loadModel ( 'receipt' );
  2134. $receipt = new receipt ();
  2135. Doo::loadModel ( 'receiptTraining' );
  2136. $receiptTraining = new receiptTraining ();
  2137. // 更新费用培训班
  2138. $item = array (
  2139. 'rtid' => $rtid,
  2140. 'trainName' => $trainName,
  2141. 'trainStartDate' => $trainStartDate,
  2142. 'trainEndDate' => $trainEndDate,
  2143. 'participants' => $participants,
  2144. 'freeParticipants'=>$freeParticipants,
  2145. 'trainAddress' => $trainAddress,
  2146. 'trainRemarks' => $trainRemarks
  2147. );
  2148. $irid = $receiptTraining->setReceiptTrainByCondition ( $item );
  2149. // 报销单
  2150. $receipt->rid = $rid;
  2151. $receipt->cid = $cid;
  2152. $receipt->verify = $verify;
  2153. $receipt->remittanceName = $remittanceName;
  2154. $receipt->bankName = $bankName;
  2155. $receipt->bankNumber = $bankNumber;
  2156. $receipt->remittanceBankType = $remittanceBankType;
  2157. if ($remittanceBankType == 1)
  2158. $receipt->coupletNumber = $coupletNumber;
  2159. $receipt->update ();
  2160. $XDeode = new XDeode ( 7 );
  2161. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html?trainEdiType=INFO";
  2162. } else
  2163. die ( 'illegal request' );
  2164. }
  2165. /**
  2166. * 编辑培训班结算---更新借款
  2167. */
  2168. function receiptTrainLoanEdiDo() {
  2169. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2170. $ridLoanKey = $this->get_args ( 'ridLoanKey' ) ? $this->get_args ( 'ridLoanKey' ) : "";
  2171. if (! empty ( $ridKey ) && ! empty ( $ridLoanKey )) {
  2172. Doo::loadModel ( 'receipt' );
  2173. $receipt = new receipt ();
  2174. Doo::loadClass ( 'XDeode' );
  2175. $XDeode = new XDeode ( 5 );
  2176. $rid = $XDeode->decode ( $ridKey );
  2177. $ridLoan = $XDeode->decode ( $ridLoanKey );
  2178. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  2179. die ( 'illegal request-ridError' );
  2180. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2181. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  2182. // 不合法的数据if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  2183. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2184. die ( 'illegal request-receiptError' );
  2185. }
  2186. if ($receiptLoanDetail ['status'] != 8 || $receiptLoanDetail ['Rtype'] != 1) {
  2187. die ( 'illegal request-receipLoantError' );
  2188. }
  2189. // 培训班结算挂钩借款
  2190. $receipt = new receipt ();
  2191. $trainLoanRid=$ridLoan;
  2192. if (!empty($receiptDetail['trainLoanRid'])){
  2193. $trainLoanRid=$receiptDetail['trainLoanRid'].','.$ridLoan;
  2194. }
  2195. $item = array (
  2196. 'rid' => $rid,
  2197. 'trainLoanRid' => $trainLoanRid
  2198. );
  2199. $receipt->setReceiptByCondition ( $item );
  2200. // 更新借款状态变成已挂钩
  2201. $receipt = new receipt ();
  2202. $item = array (
  2203. 'rid' => $ridLoan,
  2204. 'status' => 10,
  2205. 'statusTrain' => 1
  2206. );
  2207. $receipt->setReceiptByCondition ( $item );
  2208. $XDeode = new XDeode ( 7 );
  2209. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  2210. } else
  2211. die ( 'illegal request' );
  2212. }
  2213. /**
  2214. * 编辑培训班结算--移除借款
  2215. */
  2216. function receiptTrainLoanRemoveDo() {
  2217. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : 0;
  2218. $ridLoanKey = isset ( $this->params ['ridLoanKey'] ) ? $this->params ['ridLoanKey'] : 0;
  2219. if (! empty ( $ridKey ) || ! empty ( $ridLoanKey )) {
  2220. Doo::loadModel ( 'receipt' );
  2221. $receipt = new receipt ();
  2222. Doo::loadClass ( 'XDeode' );
  2223. $XDeode = new XDeode ( 5 );
  2224. $rid = $XDeode->decode ( $ridKey );
  2225. $ridLoan = $XDeode->decode ( $ridLoanKey );
  2226. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  2227. die ( 'illegal request-ridError' );
  2228. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2229. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  2230. // 不合法的数据 !($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)
  2231. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2232. die ( 'illegal request-receiptError' );
  2233. }
  2234. if ($receiptLoanDetail ['status'] != 10 || $receiptLoanDetail ['Rtype'] != 1) {
  2235. die ( 'illegal request-receipLoantError' );
  2236. }
  2237. // 培训班结算挂钩借款
  2238. $receipt = new receipt ();
  2239. $trainLoanRidArray=explode(",", $receiptDetail['trainLoanRid']);
  2240. foreach ($trainLoanRidArray as $key=>$value){
  2241. if($value==$ridLoan){
  2242. unset($trainLoanRidArray[$key]);
  2243. }
  2244. }
  2245. $trainLoanRidString=implode(",", $trainLoanRidArray);
  2246. $item = array (
  2247. 'rid' => $rid,
  2248. 'trainLoanRid' => $trainLoanRidString
  2249. );
  2250. $receipt->setReceiptByCondition ( $item );
  2251. // 更新借款状态变成已挂钩
  2252. $receipt = new receipt ();
  2253. $item = array (
  2254. 'rid' => $ridLoan,
  2255. 'status' => 8,
  2256. 'statusTrain' => 0
  2257. );
  2258. $receipt->setReceiptByCondition ( $item );
  2259. $XDeode = new XDeode ( 7 );
  2260. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  2261. } else
  2262. die ( 'illegal request' );
  2263. }
  2264. /**
  2265. * 编辑培训班结算 ---开票
  2266. */
  2267. function receiptTrainInvoiceEdi() {
  2268. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2269. Doo::loadClass ( 'XDeode' );
  2270. $XDeode = new XDeode ( 7 );
  2271. $rid = $XDeode->decode ( $ridKey );
  2272. if (! is_numeric ( $rid ))
  2273. die ( 'illegal request' );
  2274. Doo::loadModel ( 'receipt' );
  2275. $receipt = new receipt ();
  2276. Doo::loadModel ( 'receiptTraining' );
  2277. $receiptTraining = new receiptTraining ();
  2278. Doo::loadModel ( 'invoice' );
  2279. $invoice = new invoice ();
  2280. Doo::loadModel ( 'invoiceTraining' );
  2281. $invoiceTraining = new invoiceTraining ();
  2282. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2283. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  2284. die ();
  2285. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2286. $invoiceList = $invoiceTrainingDetail = array ();
  2287. if ($receiptDetail ['invoiceTrainId'] != 0) {
  2288. $invoiceList = $invoice->getInvoicePrintedByItid ( $receiptDetail ['invoiceTrainId'] );
  2289. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  2290. }
  2291. //print_r($invoiceList);
  2292. $data ['invoiceList'] = $invoiceList;
  2293. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  2294. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2295. $data ['receiptDetail'] = $receiptDetail;
  2296. $data ['trainEdiType'] = "INVOICE";
  2297. $data ['ridKey'] = $ridKey;
  2298. $data ['memu'] = "receipt";
  2299. $data ['staff'] = $this->staff;
  2300. $data ['receiptMemu'] = 'saeaBorad';
  2301. $data ['verifyId'] = $this->verifyId;
  2302. $data ['executeId'] = $this->executeId;
  2303. $this->render ( "/receipt/receiptTrainInvoiceEdi", $data );
  2304. }
  2305. /**
  2306. * 编辑培训班结算---更新开票
  2307. */
  2308. function receiptTrainInvoiceEdiDo() {
  2309. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2310. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : "";
  2311. if (! empty ( $ridKey ) && ! empty ( $itidKey )) {
  2312. Doo::loadModel ( 'receipt' );
  2313. $receipt = new receipt ();
  2314. Doo::loadModel ( 'invoiceTraining' );
  2315. $invoiceTraining = new invoiceTraining ();
  2316. Doo::loadClass ( 'XDeode' );
  2317. $XDeode = new XDeode ( 5 );
  2318. $rid = $XDeode->decode ( $ridKey );
  2319. $itid = $XDeode->decode ( $itidKey );
  2320. if (! is_numeric ( $rid ) || ! is_numeric ( $itid ))
  2321. die ( 'illegal request-idError' );
  2322. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2323. $invoiceTrainDetail = $invoiceTraining->getInvoiceTrainingByItid ( $itid );
  2324. // 不合法的数据
  2325. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2326. die ( 'illegal request-receiptError' );
  2327. }
  2328. if (empty ( $invoiceTrainDetail ) || $invoiceTrainDetail ['bindReceipt'] == 1) {
  2329. die ( 'illegal request-receipLoantError' );
  2330. }
  2331. // 培训班结算挂钩借款
  2332. $receipt = new receipt ();
  2333. $item = array (
  2334. 'rid' => $rid,
  2335. 'invoiceTrainId' => $itid
  2336. );
  2337. $receipt->setReceiptByCondition ( $item );
  2338. $invoiceTraining = new invoiceTraining ();
  2339. $item = array (
  2340. 'bindReceipt' => 1,
  2341. 'itid' => $itid
  2342. );
  2343. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  2344. $XDeode = new XDeode ( 7 );
  2345. return "/receiptTrainInvoiceEdi/" . $XDeode->encode ( $rid ) . ".html";
  2346. } else
  2347. die ( 'illegal request' );
  2348. }
  2349. /**
  2350. * 更新培训班结算 收款和取消收款
  2351. */
  2352. function receiptTrainReceivables() {
  2353. $doType = isset ( $this->params ['doType'] ) ? $this->params ['doType'] : '';
  2354. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2355. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  2356. Doo::loadClass ( 'XDeode' );
  2357. $XDeode = new XDeode ( 5 );
  2358. $rid = $XDeode->decode ( $ridKey );
  2359. $iid = $XDeode->decode ( $iidKey );
  2360. if (! is_numeric ( $rid ) || ! is_numeric ( $iid ))
  2361. die ( 'illegal request-iid' );
  2362. Doo::loadModel ( 'RIExtend' );
  2363. $RIExtend = new RIExtend ();
  2364. if ($doType == 'CONFIRM') {
  2365. $RIExtend->rid = $rid;
  2366. $RIExtend->iid = $iid;
  2367. $RIExtend->RIstatus = 1;
  2368. $RIExtend->insert ();
  2369. echo json_encode ( array (
  2370. 'status' => 1,
  2371. ) );
  2372. die ( );
  2373. } elseif ($doType == 'CANCEL') {
  2374. $RIExtend->delete ( array (
  2375. 'where' => 'rid=' . $rid . ' and iid=' . $iid,
  2376. 'limit' => 1
  2377. ) );
  2378. echo json_encode ( array (
  2379. 'status' => 1,
  2380. ) );
  2381. die ( );
  2382. } else {
  2383. echo json_encode ( array (
  2384. 'status' => 2,
  2385. ) );
  2386. die ( );
  2387. }
  2388. }
  2389. /**
  2390. * 移除挂钩的培训班发票
  2391. */
  2392. function receiptTrainReceivablesDelDo() {
  2393. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  2394. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : ""; // 发票培训班
  2395. Doo::loadModel ( 'receipt' );
  2396. $receipt = new receipt ();
  2397. Doo::loadModel ( 'RIExtend' );
  2398. $RIExtend = new RIExtend ();
  2399. Doo::loadClass ( 'XDeode' );
  2400. $XDeode = new XDeode ( 5 );
  2401. $rid = $XDeode->decode ( $ridKey );
  2402. $itid = $XDeode->decode ( $itidKey );
  2403. if (is_numeric ( $rid ) && is_numeric ( $itid )) {
  2404. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2405. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  2406. die ( 'illegal request-status' );
  2407. }
  2408. $receipt = new receipt ();
  2409. $receipt->rid = $rid;
  2410. $receipt->invoiceTrainId = 0;
  2411. $receipt->update ();
  2412. Doo::loadModel ( 'invoiceTraining' );
  2413. $invoiceTraining = new invoiceTraining ();
  2414. $item = array (
  2415. 'bindReceipt' => 0,
  2416. 'itid' => $itid
  2417. );
  2418. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  2419. $RIExtend->delete ( array (
  2420. 'where' => 'rid=' . $rid
  2421. ) );
  2422. $XDeode = new XDeode ( 7 );
  2423. return '/receiptTrainInvoiceEdi/' . $XDeode->encode ( $rid ) . '.html';
  2424. } else
  2425. die ( 'illegal request-iid' );
  2426. }
  2427. /**
  2428. * 编辑培训班结算
  2429. */
  2430. function receiptTrainItemEdi() {
  2431. //include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  2432. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2433. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : '';
  2434. Doo::loadClass ( 'XDeode' );
  2435. $XDeode = new XDeode ( 7 );
  2436. $rid = $XDeode->decode ( $ridKey );
  2437. if (! is_numeric ( $rid ))
  2438. die ( 'illegal request' );
  2439. Doo::loadModel ( 'receipt' );
  2440. $receipt = new receipt ();
  2441. Doo::loadModel ( 'receiptTraining' );
  2442. $receiptTraining = new receiptTraining ();
  2443. Doo::loadModel ( 'RItem' );
  2444. $RItem = new RItem ();
  2445. Doo::loadModel ( 'accountItem' );
  2446. $accountItem = new accountItem ();
  2447. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2448. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  2449. die ();
  2450. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2451. $RItemList = $RItem->getRItemByRid ( $rid,$name );
  2452. $aiList = $accountItem->getAccountBookByCategory ( '培训班费用' );//print_r($aiList);
  2453. // foreach ($aiList as $key=>$value){//不需要添加税款,在添加收入时自动添加
  2454. // if($value['name']=='税款'){
  2455. // unset($aiList[$key]);break;
  2456. // }
  2457. // }
  2458. //print_r($RItemList);
  2459. $data ['name'] = $name;
  2460. $data ['RItemList'] = $RItemList;
  2461. $data ['aiList'] = $aiList;
  2462. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2463. $data ['receiptDetail'] = $receiptDetail;
  2464. $data ['trainEdiType'] = "ITEM";
  2465. $data ['ridKey'] = $ridKey;
  2466. $data ['memu'] = "receipt";
  2467. $data ['staff'] = $this->staff;
  2468. $data ['receiptMemu'] = 'saeaBorad';
  2469. $data ['verifyId'] = $this->verifyId;
  2470. $data ['executeId'] = $this->executeId;
  2471. $this->render ( "/receipt/receiptTrainItemEdi", $data );
  2472. }
  2473. /**
  2474. * 添加支出项 需要修改 费用金额合计
  2475. */
  2476. function receiptTrainItemAddDo() {
  2477. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2478. $rtidKey = $this->get_args ( 'rtidKey' ) ? $this->get_args ( 'rtidKey' ) : "";
  2479. // 支出项信息
  2480. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  2481. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : 0;
  2482. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  2483. $inputer = $this->get_args ( 'inputer' ) ? $this->get_args ( 'inputer' ) : "";
  2484. $describe = $this->get_args ( 'describe' ) ? $this->get_args ( 'describe' ) : "";
  2485. //$identifyingTotal = $this->get_args ( 'identifyingTotal' )&&is_numeric($this->get_args ( 'identifyingTotal' )) ? $this->get_args ( 'identifyingTotal' ) : 0;
  2486. $payType = isset ( $this->params ['payType'] ) ? $this->params ['payType'] : '';
  2487. if (! empty ( $ridKey ) && ! empty ( $item ) && is_numeric( $price ) && ! empty ( $date ) && ! empty ( $inputer )) {
  2488. Doo::loadClass ( 'XDeode' );
  2489. $XDeode = new XDeode ( 5 );
  2490. Doo::loadModel ( 'RItem' );
  2491. $RItem = new RItem ();
  2492. $rid = $XDeode->decode ( $ridKey );
  2493. $rtid= $XDeode->decode ( $rtidKey );
  2494. if (! is_numeric ( $rid )){
  2495. die ( 'illegal request' );
  2496. }
  2497. Doo::loadModel ( 'receiptDetail' );
  2498. $receiptDetail = new receiptDetail ();
  2499. Doo::loadModel ( 'receipt' );
  2500. $receipt = new receipt ();
  2501. Doo::loadModel ( 'receiptTraining' );
  2502. $receiptTraining = new receiptTraining ();
  2503. $rtDetail=$receiptTraining->getReceiptTrainingByRtid($rtid);
  2504. $identifyingTotal=$rtDetail['identifyingTotal']+1;
  2505. $order = array (
  2506. "\r\n",
  2507. "\n",
  2508. "\r"
  2509. );
  2510. $replace = '<br/>';
  2511. $describe = str_replace ( $order, $replace, $describe );
  2512. $itemData = array (
  2513. 'rid' => $rid,
  2514. 'item' => $item,
  2515. 'price' => $price,
  2516. 'date' => $date,
  2517. 'inputer' => $inputer,
  2518. 'describe' => $describe,
  2519. 'creater' => $this->staff['0']['username'],
  2520. 'createrId' => $this->staff['0']['sid'],
  2521. 'creatDate' => date ( "Y-m-d H:i:s" ),
  2522. 'identifying'=>$identifyingTotal
  2523. );
  2524. if($payType=='company'){
  2525. $itemData += array (
  2526. 'payType' => 1
  2527. );
  2528. }
  2529. $RItem->addRItem($itemData, $receipt, $receiptDetail, $rid, $item, $price, $payType);
  2530. //更新支出项标识总数
  2531. $itemData = array (
  2532. 'rtid'=>$rtid,
  2533. 'identifyingTotal'=>$identifyingTotal
  2534. );
  2535. $receiptTraining->setReceiptTrainByCondition($itemData);
  2536. $XDeode = new XDeode ( 7 );
  2537. if($payType=='company'){
  2538. return '/receiptTrainItem/approval/' . $XDeode->encode ( $rid ) . '.html';
  2539. }else{
  2540. return '/receiptTrainItemEdi/' . $XDeode->encode ( $rid ) . '.html';
  2541. }
  2542. } else
  2543. die ( 'illegal request-dataError' );
  2544. }
  2545. /**
  2546. * 培训班结算-讲师
  2547. */
  2548. function receiptTrainLecturerEdi() {
  2549. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2550. Doo::loadClass ( 'XDeode' );
  2551. $XDeode = new XDeode ( 7 );
  2552. $rid = $XDeode->decode ( $ridKey );
  2553. if (! is_numeric ( $rid ))
  2554. die ( 'illegal request' );
  2555. Doo::loadModel ( 'receipt' );
  2556. $receipt = new receipt ();
  2557. Doo::loadModel ( 'receiptTraining' );
  2558. $receiptTraining = new receiptTraining ();
  2559. Doo::loadModel ( 'RILecturer' );
  2560. $RILecturer = new RILecturer ();
  2561. Doo::loadModel ( 'lecturer' );
  2562. $lecturer = new lecturer ();
  2563. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2564. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  2565. die ();
  2566. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2567. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2568. $lecturerList = $lecturer->getLecturerAll ();
  2569. $INSIDEhtml = $OUTSIDEhtml = '';
  2570. foreach ( $lecturerList as $key => $value ) {
  2571. if ($value ['ltype'] == 'INSIDE') {
  2572. $INSIDEhtml .= '<option value="' . $value ['category'] . '-' . $value ['staff'] . '">' . $value ['category'] . '-' . $value ['staff'] . '</option>';
  2573. } elseif ($value ['ltype'] == 'OUTSIDE') {
  2574. $OUTSIDEhtml .= '<option value="' . $value ['staff'] . '">' . $value ['staff'] . '</option>';
  2575. }
  2576. }
  2577. $data ['INSIDEhtml'] = $INSIDEhtml;
  2578. $data ['OUTSIDEhtml'] = $OUTSIDEhtml;
  2579. // print_r($RItemList);
  2580. $data ['RILecturerList'] = $RILecturerList;
  2581. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2582. $data ['receiptDetail'] = $receiptDetail;
  2583. $data ['trainEdiType'] = "LECTURER";
  2584. $data ['ridKey'] = $ridKey;
  2585. $data ['memu'] = "receipt";
  2586. $data ['staff'] = $this->staff;
  2587. $data ['receiptMemu'] = 'saeaBorad';
  2588. $data ['verifyId'] = $this->verifyId;
  2589. $data ['executeId'] = $this->executeId;
  2590. $this->render ( "/receipt/receiptTrainLecturerEdi", $data );
  2591. }
  2592. /**
  2593. * 添加讲师
  2594. */
  2595. function receiptTrainLecturerAddDo() {
  2596. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2597. // 支出项信息
  2598. $ltype = $this->get_args ( 'ltype' ) ? $this->get_args ( 'ltype' ) : "";
  2599. $lecturerName = $this->get_args ( 'lecturerName' ) ? $this->get_args ( 'lecturerName' ) : "";
  2600. $schoolDay = $this->get_args ( 'schoolDay' ) ? $this->get_args ( 'schoolDay' ) : "";
  2601. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  2602. $taxation = $this->get_args ( 'taxation' ) ? $this->get_args ( 'taxation' ) : "";
  2603. $fees = $this->get_args ( 'fees' ) ? $this->get_args ( 'fees' ) : "";
  2604. if (! empty ( $ridKey ) && ! empty ( $ltype ) && ! empty ( $lecturerName ) && ! empty ( $schoolDay ) && ! empty ( $price )) {
  2605. Doo::loadClass ( 'XDeode' );
  2606. $XDeode = new XDeode ( 5 );
  2607. Doo::loadModel ( 'RILecturer' );
  2608. $RILecturer = new RILecturer ();
  2609. $rid = $XDeode->decode ( $ridKey );
  2610. if (! is_numeric ( $rid ))
  2611. die ( 'illegal request' );
  2612. if ($ltype == 'OUTSIDE' && empty ( $taxation ))
  2613. die ( 'illegal request-taxationError' );
  2614. $RILecturer->rid = $rid;
  2615. $RILecturer->ltype = $ltype;
  2616. if ($ltype == 'OUTSIDE') {
  2617. if ($taxation == 'TAXATION') {
  2618. $RILecturer->taxation = 1;
  2619. } elseif ($taxation == 'NOTAXATION') {
  2620. $RILecturer->taxation = 0;
  2621. }
  2622. }
  2623. $RILecturer->lecturerName = $lecturerName;
  2624. $RILecturer->schoolDay = $schoolDay;
  2625. $RILecturer->price = $price;
  2626. $RILecturer->fees=$fees;
  2627. $RILecturer->insert ();
  2628. // 添加公司汇总
  2629. // 报销详情
  2630. Doo::loadModel ( 'receiptDetail' );
  2631. $receiptDetail = new receiptDetail ();
  2632. Doo::loadModel ( 'receipt' );
  2633. $receipt = new receipt ();
  2634. // 金额总计
  2635. $price = $price * $schoolDay;
  2636. $rInfo = $receipt->getReceiptByRid ( $rid );
  2637. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  2638. if (empty ( $rdInfo )) {
  2639. $receiptDetail = new receiptDetail ();
  2640. $receiptDetail->staff = $rInfo ['staff'];
  2641. $receiptDetail->item = '讲课费';
  2642. $receiptDetail->itemCategory = '培训班费用';
  2643. $receiptDetail->price = number_format ( $fees, 2, '.', '' );
  2644. $receiptDetail->date = date ( "Y-m-d" );
  2645. $receiptDetail->cid = $rInfo ['cid'];
  2646. $receiptDetail->rid = $rid;
  2647. $receiptDetail->status = 4;
  2648. $receiptDetail->insert ();
  2649. } else {
  2650. $receiptDetail = new receiptDetail ();
  2651. $rdInfo ['price'] += $fees;
  2652. $receiptDetail->price = $rdInfo ['price'];
  2653. $receiptDetail->update ( array (
  2654. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  2655. ) );
  2656. }
  2657. $receipt = new receipt ();
  2658. $receipt->sum=$rInfo['sum']+$fees;
  2659. $receipt->update ( array (
  2660. 'where' => 'rid=' . $rid
  2661. ) );
  2662. $XDeode = new XDeode ( 7 );
  2663. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  2664. } else
  2665. die ( 'illegal request' );
  2666. }
  2667. /**
  2668. * 移除讲师
  2669. */
  2670. function receiptTrainLecturerDelDo() {
  2671. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  2672. $rlidKey = $this->get_args ( 'rlidKey' ) ? $this->get_args ( 'rlidKey' ) : ""; // 发票培训班
  2673. Doo::loadModel ( 'receipt' );
  2674. $receipt = new receipt ();
  2675. Doo::loadModel ( 'RILecturer' );
  2676. $RILecturer = new RILecturer ();
  2677. Doo::loadClass ( 'XDeode' );
  2678. $XDeode = new XDeode ( 5 );
  2679. $rid = $XDeode->decode ( $ridKey );
  2680. $rlid = $XDeode->decode ( $rlidKey );
  2681. if (is_numeric ( $rid ) && is_numeric ( $rlid )) {
  2682. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2683. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  2684. die ( 'illegal request-status' );
  2685. }
  2686. $detail=$RILecturer->getRILecturerByRlid($rlid);
  2687. if (empty($detail)){
  2688. die ( 'illegal request-data' );
  2689. }
  2690. $RILecturer->delete ( array (
  2691. 'where' => 'rid=' . $rid . ' and rlid=' . $rlid
  2692. ) );
  2693. //更新费用合计金额
  2694. $rInfo = $receipt->getReceiptByRid ( $rid );
  2695. $receipt = new receipt ();
  2696. $receipt->sum= $receiptDetail['sum']-$detail['price'];
  2697. $receipt->update ( array (
  2698. 'where' => 'rid=' . $rid
  2699. ) );
  2700. Doo::loadModel ( 'receiptDetail' );
  2701. $receiptDetail = new receiptDetail ();
  2702. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  2703. $receiptDetail = new receiptDetail ();
  2704. $rdInfo ['price'] -= number_format ( $detail['price'], 2, '.', '' );
  2705. $receiptDetail->price = $rdInfo ['price'];
  2706. $receiptDetail->update ( array (
  2707. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  2708. ) );
  2709. $XDeode = new XDeode ( 7 );
  2710. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  2711. } else
  2712. die ( 'illegal request-iid' );
  2713. }
  2714. /**
  2715. * 培训班提交审批
  2716. */
  2717. function receiptTrainDo() {
  2718. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2719. Doo::loadClass ( 'XDeode' );
  2720. $XDeode = new XDeode ( 7 );
  2721. $rid = $XDeode->decode ( $ridKey );
  2722. Doo::loadModel ( 'receipt' );
  2723. $receipt = new receipt ();
  2724. Doo::loadModel ( 'receiptDetail' );
  2725. $receiptDetail = new receiptDetail ();
  2726. Doo::loadModel ( 'statistics' );
  2727. $statistics = new statistics ();
  2728. Doo::loadModel ( "verify" );
  2729. $verify = new verify ();
  2730. // 审批状态的判定
  2731. $receiptDetailList = $receipt->getOne ( array (
  2732. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  2733. 'asArray' => true
  2734. ) );
  2735. if (empty ( $receiptDetailList ))
  2736. return "/saeaBorad";
  2737. $verifyDetail = $verify->getOne ( array (
  2738. 'where' => ' vid =' . $receiptDetailList ['verify'],
  2739. 'asArray' => true
  2740. ) );
  2741. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  2742. if (empty ( $receiptDetailList ['nowStaff'] )) {
  2743. $nowStaff = "";
  2744. $nowStaffList = array ();
  2745. if ($verifyDetail [0] [1] == 'ROLE') {
  2746. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  2747. foreach ( $vStaffString as $key => $value ) {
  2748. $staffK = explode ( "_", $value );
  2749. array_push ( $nowStaffList, $staffK [0] );
  2750. }
  2751. $nowStaff = implode ( ',', $nowStaffList );
  2752. } else {
  2753. $nowStaff = $verifyDetail [0] [0];
  2754. }
  2755. $receipt->nowStaff = $nowStaff;
  2756. }
  2757. // echo $nowStaff;
  2758. // print_r($verifyDetail);die;
  2759. $receipt->rid = $receiptDetailList ['rid'];
  2760. $receipt->date = date ( "Y-m-d" );
  2761. $receipt->status = 2;
  2762. $receipt->update ();
  2763. $receiptDetail->status = 2;
  2764. $receiptDetail->update ( array (
  2765. 'where' => 'rid=' . $receiptDetailList ['rid']
  2766. ) );
  2767. Doo::loadModel ( "receiptLog" );
  2768. $receiptLog = new receiptLog ();
  2769. Doo::loadModel ( "verify" );
  2770. $verify = new verify ();
  2771. $vr = $verify->getOne ( array (
  2772. 'where' => 'vid=' . $receiptDetailList ['verify'],
  2773. 'asArray' => true
  2774. ) );
  2775. $jd = json_decode ( $vr ['staff'] );
  2776. $roleId = 0;
  2777. foreach ( $jd as $key => $value ) {
  2778. if ($value [1] == 'ROLE') {
  2779. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  2780. if ($pos !== false) {
  2781. $roleId = $value [0];
  2782. }
  2783. }
  2784. }
  2785. // 审批日志
  2786. // echo $roleId;die;
  2787. if (! empty ( $roleId )) {
  2788. Doo::loadModel ( "role" );
  2789. $role = new role ();
  2790. $roleInfo = $role->getOne ( array (
  2791. 'where' => 'rid=' . $roleId,
  2792. 'asArray' => true
  2793. ) );
  2794. // $receiptLog->rolename = $roleInfo ['name'];
  2795. }
  2796. $receiptLog->username = $this->staff [0] ['username'];
  2797. $receiptLog->uid = $this->staff [0] ['sid'];
  2798. $receiptLog->date = date ( "Y-m-d" );
  2799. $receiptLog->opinion = '提交审批';
  2800. $receiptLog->img = $this->staff [0] ['avatar'];
  2801. $receiptLog->status = 2;
  2802. $receiptLog->rid = $rid;
  2803. $receiptLog->insert ();
  2804. // 写入列表项
  2805. Doo::loadModel ( 'accountItem' );
  2806. $accountItem = new accountItem ();
  2807. $aItem = $accountItem->getAccountBookByCategory ( '培训班费用' );
  2808. // 项目金额合计
  2809. Doo::loadModel ( 'RItem' );
  2810. $RItem = new RItem ();
  2811. // 讲师获得
  2812. Doo::loadModel ( 'RILecturer' );
  2813. $RILecturer = new RILecturer ();
  2814. $RItemList = $RItem->getRItemByRid ( $rid );
  2815. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2816. // 支出项金额详情
  2817. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, 0 );
  2818. // print_r($aItem);
  2819. // print_r($aiData);
  2820. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  2821. $ag = $tr = $ta = $ot = 0;
  2822. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  2823. foreach ( $aItem as $key => $value ) {
  2824. if ($value ['category'] == $this->TRAIN) {
  2825. foreach ( $aiData ['dataList'] as $k => $v ) {
  2826. if ($value ['name'] == $v ['name']) {
  2827. array_push ( $accountJson [$this->TRAIN], array (
  2828. 'aid' => $value ['aid'],
  2829. 'name' => $value ['name'],
  2830. 'price' => number_format ( $v ['price'], 2, '.', '' )
  2831. ) );
  2832. $sum += $v ['price'];
  2833. $trainSum += $v ['price'];
  2834. unset ( $aiData ['dataList'] [$k] );
  2835. break;
  2836. }
  2837. }
  2838. }
  2839. }
  2840. $accountJson ['cSum'] = array (
  2841. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  2842. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  2843. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  2844. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  2845. );
  2846. // 报销单
  2847. $receipt = new receipt ();
  2848. $receipt->accountItem = json_encode ( $accountJson );
  2849. $receipt->sum = number_format ( $sum, 2, '.', '' );
  2850. $receipt->update ( array (
  2851. 'where' => 'rid=' . $rid
  2852. ) );
  2853. // print_r($accountJson);
  2854. // statistics item 统计写入
  2855. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  2856. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  2857. $accountItem = $accountJson;
  2858. $stat = $statistics->getOne ( array (
  2859. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  2860. 'asArray' => true
  2861. ) );
  2862. if (empty ( $stat )) {
  2863. $statistics->date = date ( "Y-m-d" );
  2864. $statistics->cid = $this->staff [0] ['cid'];
  2865. $statistics->staff = $this->staff [0] ['sid'];
  2866. $statistics->agPrice = 0;
  2867. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  2868. $statistics->insert ();
  2869. } else {
  2870. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  2871. $statistics->update ( array (
  2872. 'where' => 'sid=' . $stat ['sid']
  2873. ) );
  2874. }
  2875. return "/saeaBorad";
  2876. }
  2877. function confirmation() {
  2878. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2879. Doo::loadModel ( 'receipt' );
  2880. Doo::loadModel ( 'receiptDetail' );
  2881. $receipt = new receipt ();
  2882. $receiptDetail = new receiptDetail ();
  2883. Doo::loadModel ( 'statistics' );
  2884. Doo::loadModel ( 'itemStatistics' );
  2885. $statistics = new statistics ();
  2886. $itemStatistics = new itemStatistics ();
  2887. Doo::loadModel ( "verify" );
  2888. $verify = new verify ();
  2889. $receiptDetailList = $receipt->getOne ( array (
  2890. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  2891. 'asArray' => true
  2892. ) );
  2893. if (empty ( $receiptDetailList ))
  2894. return "/saeaBorad";
  2895. $verifyDetail = $verify->getOne ( array (
  2896. 'where' => ' vid =' . $receiptDetailList ['verify'],
  2897. 'asArray' => true
  2898. ) );
  2899. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  2900. if (empty ( $receiptDetailList ['nowStaff'] )) {
  2901. $nowStaff = "";
  2902. $nowStaffList = array ();
  2903. if ($verifyDetail [0] [1] == 'ROLE') {
  2904. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  2905. foreach ( $vStaffString as $key => $value ) {
  2906. $staffK = explode ( "_", $value );
  2907. array_push ( $nowStaffList, $staffK [0] );
  2908. }
  2909. $nowStaff = implode ( ',', $nowStaffList );
  2910. } else {
  2911. $nowStaff = $verifyDetail [0] [0];
  2912. }
  2913. $receipt->nowStaff = $nowStaff;
  2914. }
  2915. // echo $nowStaff;
  2916. // print_r($verifyDetail);die;
  2917. $receipt->rid = $receiptDetailList ['rid'];
  2918. $receipt->status = 2;
  2919. $receipt->update ();
  2920. // 操作日志
  2921. Doo::loadModel ( "receiptLog" );
  2922. $receiptLog = new receiptLog ();
  2923. $verify = new verify ();
  2924. $receiptInfo = $receipt->getOne ( array (
  2925. 'where' => 'rid=' . $rid,
  2926. 'asArray' => true
  2927. ) );
  2928. $vr = $verify->getOne ( array (
  2929. 'where' => 'vid=' . $receiptInfo ['verify'],
  2930. 'asArray' => true
  2931. ) );
  2932. $jd = json_decode ( $vr ['staff'] );
  2933. $roleId = 0;
  2934. foreach ( $jd as $key => $value ) {
  2935. if ($value [1] == 'ROLE') {
  2936. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  2937. if ($pos !== false) {
  2938. $roleId = $value [0];
  2939. }
  2940. }
  2941. }
  2942. // 审批日志
  2943. // echo $roleId;die;
  2944. if (! empty ( $roleId )) {
  2945. Doo::loadModel ( "role" );
  2946. $role = new role ();
  2947. $roleInfo = $role->getOne ( array (
  2948. 'where' => 'rid=' . $roleId,
  2949. 'asArray' => true
  2950. ) );
  2951. // $receiptLog->rolename = $roleInfo ['name'];
  2952. }
  2953. $receiptLog->username = $this->staff [0] ['username'];
  2954. $receiptLog->uid = $this->staff [0] ['sid'];
  2955. $receiptLog->date = date ( "Y-m-d" );
  2956. $receiptLog->opinion = '提交审批';
  2957. $receiptLog->img = $this->staff [0] ['avatar'];
  2958. $receiptLog->status = 2;
  2959. $receiptLog->rid = $rid;
  2960. $receiptLog->insert ();
  2961. return "/expenses";
  2962. }
  2963. function expenses() {
  2964. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  2965. if (empty ( $item ))
  2966. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  2967. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  2968. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  2969. Doo::loadClass ( 'XDeode' );
  2970. $XDeode = new XDeode ( 7 );
  2971. Doo::loadModel ( 'receipt' );
  2972. $receipt = new receipt ();
  2973. Doo::loadModel ( 'L_category' );
  2974. $Lcategory = new L_category ();
  2975. Doo::loadModel ( 'verify' );
  2976. Doo::loadModel ( 'statistics' );
  2977. $statistics = new statistics ();
  2978. $verify = new verify ();
  2979. Doo::loadModel ( 'staff' );
  2980. $staff = new staff ();
  2981. $condition = "";
  2982. if ($item == "expenses")
  2983. $condition = " and Rtype=1 ";
  2984. elseif ($item == "receipts")
  2985. $condition = " and Rtype=0 ";
  2986. elseif ($item == "remits")
  2987. $condition = " and Rtype=2 ";
  2988. elseif ($item == "train")
  2989. $condition = " and Rtype=3 ";
  2990. $dateCondition = " and Year(date) =" . $year;
  2991. if (! empty ( $moth )) {
  2992. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  2993. $stList = $statistics->getOne ( array (
  2994. 'select' => 'rePrice ,agPrice',
  2995. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  2996. 'asArray' => true
  2997. ) );
  2998. } else
  2999. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  3000. if (empty ( $stList ))
  3001. $stList = array (
  3002. 'rePrice' => 0,
  3003. 'agPrice' => 0
  3004. );
  3005. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  3006. if (! isset ( $noPassSum ['sum'] ))
  3007. $noPassSum ['sum'] = 0;
  3008. $data ['stList'] = array (
  3009. 'rePrice' => $stList ['rePrice'],
  3010. 'agPrice' => $stList ['agPrice'],
  3011. 'skPrice' => ($noPassSum ['sum'])
  3012. );
  3013. $receiptList = $receipt->find ( array (
  3014. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  3015. 'desc' => 'rid',
  3016. 'asArray' => true
  3017. ) );
  3018. $Locate = 0;
  3019. $roleId = 0;
  3020. $button = 0;
  3021. foreach ( $receiptList as $key => $value ) {
  3022. $receiptList[$key]['balance']='';
  3023. if($value['Rtype']==1){
  3024. $receiptList[$key]['balance']=$value['sum']-=$value['loanSum'];
  3025. $receiptList[$key]['balanceABS']=abs($receiptList[$key]['balance']);
  3026. }elseif($value['Rtype']==3){
  3027. $payment=$this->_getReceiptTrainPayment($value['invoiceTrainId'],$value['trainLoanRid'],$value['rid']);
  3028. $receiptList[$key]['payment']=$payment;
  3029. $receiptList[$key]['paymentABS']=abs($payment);
  3030. }
  3031. $receiptList [$key] ['Locate'] = $Locate;
  3032. $Locate ++;
  3033. $receiptList [$key] ['reviseDetail'] = array ();
  3034. if (! empty ( $value ['reviseDetail'] ))
  3035. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3036. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3037. $categoryDetil = $Lcategory->getOne ( array (
  3038. 'where' => 'cid=' . $value ['cid'],
  3039. 'asArray' => true
  3040. ) );
  3041. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3042. // 检测编辑状态
  3043. $verifyList = $verify->getOne ( array (
  3044. 'where' => 'vid=' . $value ['verify'],
  3045. 'asArray' => true
  3046. ) );
  3047. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3048. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3049. Doo::loadModel ( 'role' );
  3050. $role = new role ();
  3051. $flag = true;
  3052. $roleKey = 0;
  3053. $endStaffArray = array ();
  3054. $roleArrayCopy = array ();
  3055. foreach ( $verifyList as $k => $v ) {
  3056. // init verifyStaff
  3057. if ($v [1] == 'ROLE') {
  3058. if (! empty ( $verifyStaff )) {
  3059. $endStaffArray = end ( $verifyStaff );
  3060. // if ($v[0]==$endStaffArray['nextStaff']){
  3061. // $roleId=$v[0];
  3062. // }
  3063. }
  3064. $roleVerify = json_decode ( $v [3], true );
  3065. $roleKey = $k;
  3066. $roleArray = array ();
  3067. $rolename = $role->getOne ( array (
  3068. 'where' => 'rid=' . $v [0],
  3069. 'asArray' => true
  3070. ) );
  3071. foreach ( $roleVerify as $o => $p ) {
  3072. $staffID = explode ( '_', $p );
  3073. $staffInfo = $staff->getOne ( array (
  3074. 'where' => 'sid=' . $staffID [0],
  3075. 'asArray' => true
  3076. ) );
  3077. // print_r($staffID);
  3078. $exp = array (
  3079. 0 => $staffInfo ['sid'],
  3080. 1 => $staffID [1],
  3081. 2 => $staffInfo ['avatar'],
  3082. 'date' => '',
  3083. 'date' => '',
  3084. 'opinion' => '',
  3085. 'status' => '',
  3086. 'rolename' => $rolename ['name']
  3087. );
  3088. array_push ( $roleArray, $exp );
  3089. }
  3090. $roleArrayCopy [$v [0]] = $roleArray;
  3091. // $verifyList[$k]['roleArray']=$roleArray;
  3092. }
  3093. $verifyList [$k] ['date'] = "";
  3094. $verifyList [$k] ['opinion'] = "";
  3095. $verifyList [$k] ['status'] = "";
  3096. if (empty ( $verifyStaff )) {
  3097. $verifyList [$k] ['date'] = "";
  3098. $verifyList [$k] ['opinion'] = "";
  3099. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3100. $verifyList [$k] ['status'] = 4;
  3101. $flag = false;
  3102. }
  3103. } else {
  3104. foreach ( $verifyStaff as $m => $u ) {
  3105. if ($v [0] == $m) {
  3106. $verifyList [$k] ['date'] = $u ['date'];
  3107. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3108. $verifyList [$k] ['status'] = $u ['status'];
  3109. $flag = false;
  3110. break;
  3111. }
  3112. }
  3113. $endStaffArray = end ( $verifyStaff );
  3114. if (isset ( $endStaffArray ['ROLE'] )) {
  3115. } else {
  3116. // $endKey=key($verifyStaff);
  3117. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3118. // $button=4;
  3119. // $verifyList[$k]['status']=4;
  3120. // }
  3121. }
  3122. }
  3123. }
  3124. $rolename ['name'] = '';
  3125. if (! empty ( $roleId )) {
  3126. Doo::loadModel ( 'role' );
  3127. $role = new role ();
  3128. $rolename = $role->getOne ( array (
  3129. 'where' => 'rid=' . $roleId,
  3130. 'asArray' => true
  3131. ) );
  3132. }
  3133. if (! empty ( $verifyStaff ))
  3134. $endStaffArray = end ( $verifyStaff );
  3135. $KOP = false;
  3136. foreach ( $roleArrayCopy as $P => $A ) {
  3137. foreach ( $A as $MKI => $AVL ) {
  3138. if (! empty ( $verifyStaff )) {
  3139. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3140. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3141. $button = 4;
  3142. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3143. }
  3144. foreach ( $verifyStaff as $m => $u ) {
  3145. $AVLFK = $AVL [0] . '_R';
  3146. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3147. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3148. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3149. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3150. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3151. break;
  3152. }
  3153. }
  3154. } else {
  3155. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3156. $button = 4;
  3157. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3158. }
  3159. }
  3160. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3161. $KOP = true;
  3162. }
  3163. }
  3164. foreach ( $roleArrayCopy as $k => $v ) {
  3165. foreach ( $verifyList as $m => $n ) {
  3166. if ($n [0] == $k) {
  3167. array_splice ( $verifyList, $m, 1, $v );
  3168. }
  3169. }
  3170. }
  3171. $receiptList [$key] ['verifyList'] = $verifyList;
  3172. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3173. 'where' => 'sid=' . $value ['staff'],
  3174. 'asArray' => true
  3175. ) );
  3176. $receiptList [$key] ['button'] = $button;
  3177. $receiptList [$key] ['ridKey'] =$XDeode->encode( $value ['rid'] );
  3178. }
  3179. // print_r($receiptList);die;
  3180. $mothHtml = "";
  3181. for($i = 1; $i <= 12; $i ++) {
  3182. if ($moth == $i)
  3183. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3184. else
  3185. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3186. }
  3187. $dateHtml = "";
  3188. $now = date ( "Y" );
  3189. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  3190. if ($YEARD <= $now) {
  3191. $dateHtml .= '<option ';
  3192. if ($year == $YEARD) {
  3193. $dateHtml .= 'selected ';
  3194. }
  3195. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  3196. }
  3197. }
  3198. $data ['dateHtml'] = $dateHtml;
  3199. $data ['mothHtml'] = $mothHtml;
  3200. $data ['receiptList'] = $receiptList;
  3201. $data ['memu'] = "receipt";
  3202. $data ['staff'] = $this->staff;
  3203. $data ['receiptMemu'] = 'expenses';
  3204. $data ['verifyId'] = $this->verifyId;
  3205. $data ['executeId'] = $this->executeId;
  3206. $data ['item'] = $item;
  3207. $data ['year'] = $year;
  3208. $this->render ( "/admin/expenses", $data );
  3209. }
  3210. function expensesCollect() {
  3211. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3212. Doo::loadModel ( 'receipt' );
  3213. $receipt = new receipt ();
  3214. Doo::loadModel ( 'L_category' );
  3215. $Lcategory = new L_category ();
  3216. Doo::loadModel ( 'verify' );
  3217. Doo::loadModel ( 'statistics' );
  3218. $statistics = new statistics ();
  3219. $verify = new verify ();
  3220. Doo::loadModel ( 'staff' );
  3221. $staff = new staff ();
  3222. Doo::loadModel ( 'loanReceipt' );
  3223. $loanReceipt = new loanReceipt ();
  3224. $receiptList = $receipt->find ( array (//去掉
  3225. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  3226. 'desc' => 'rid',
  3227. 'asArray' => true
  3228. ) );
  3229. $loanList = $loanReceipt->find ( array (
  3230. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3231. 'desc' => 'rid',
  3232. 'asArray' => true
  3233. ) );
  3234. /*
  3235. * $Locate=0;$roleId=0;$button=0; foreach ($loanList as $key=>$value){ $loanList[$key]['Locate']=$Locate;$Locate++; $loanList[$key]['reviseDetail']=array(); if (!empty($value['reviseDetail'])) $loanList[$key]['reviseDetail']=json_decode($value['reviseDetail'],true); $loanList[$key]['accountItem']=json_decode($value['accountItem'],true); $loanList[$key]['loanItem']=json_decode($value['loanItem'],true); $categoryDetil=$Lcategory->getOne(array('where'=>'cid='.$value['cid'],'asArray'=>true)); $loanList[$key]['category']=$categoryDetil['title']; //检测编辑状态 if ($value['status']==3||$value['status']==1||$value['status']==8||$value['status']==9) $verifyList['staff']=$value['verifyBreakup']; else $verifyList=$verify->getOne(array('where'=>'vid='.$value['verify'],'asArray'=>true)); $verifyList=json_decode($verifyList['staff'],true);//status opinion $verifyStaff=json_decode($value['verifyStaff'],true); Doo::loadModel('role'); $role=new role(); $flag=true;$roleKey=0;$endStaffArray=array();$roleArrayCopy=array(); foreach ($verifyList as $k=>$v){ //init verifyStaff if ($v[1]=='ROLE'){ if (!empty($verifyStaff)){ $endStaffArray=end($verifyStaff); // if ($v[0]==$endStaffArray['nextStaff']){ // $roleId=$v[0]; // } } $roleVerify=json_decode($v[3],true); $roleKey=$k;$roleArray=array(); $rolename=$role->getOne(array('where'=>'rid='.$v[0],'asArray'=>true)); foreach ($roleVerify as $o=>$p){ $staffID=explode ('_',$p); $staffInfo=$staff->getOne(array('where'=>'sid='.$staffID[0],'asArray'=>true)); //print_r($staffID); $exp=array(0=>$staffInfo['sid'],1=>$staffID[1],2=>$staffInfo['avatar'],'date'=>'','date'=>'','opinion'=>'','status'=>'','rolename'=>$rolename['name']); array_push($roleArray, $exp); } $roleArrayCopy[$v[0]]=$roleArray; //$verifyList[$k]['roleArray']=$roleArray; } $verifyList[$k]['date']=""; $verifyList[$k]['opinion']=""; $verifyList[$k]['status']=""; if (empty($verifyStaff)){ $verifyList[$k]['date']=""; $verifyList[$k]['opinion']=""; if (($verifyList[0][0]==$this->staff[0]['sid'])&&$flag){ $verifyList[$k]['status']=4; $flag=false; } }else{ foreach ($verifyStaff as $m=>$u){ if ($v[0]==$m){ $verifyList[$k]['date']=$u['date']; $verifyList[$k]['opinion']=$u['opinion']; $verifyList[$k]['status']=$u['status']; $flag=false; break; } } $endStaffArray=end($verifyStaff); if (isset($endStaffArray['ROLE'])){ }else{ // $endKey=key($verifyStaff); // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){ // $button=4; // $verifyList[$k]['status']=4; // } } } } $rolename['name']=''; if (!empty($roleId)){ Doo::loadModel('role'); $role=new role(); $rolename=$role->getOne(array('where'=>'rid='.$roleId,'asArray'=>true)); } if (!empty($verifyStaff)) $endStaffArray=end($verifyStaff); $KOP=false; foreach ($roleArrayCopy as $P=>$A){ foreach ( $A as $MKI=>$AVL){ if (!empty($verifyStaff)){ //&&$rolename['rid']==$endStaffArray['nextStaff'] if ($this->staff[0]['sid']==$AVL[0]&&isset($endStaffArray['ROLE'])&&$rolename['rid']==$endStaffArray['nextStaff']){ $button=4; $roleArrayCopy[$P][$MKI]['status']=4; } foreach ($verifyStaff as $m=>$u){ $AVLFK=$AVL[0].'_R'; //echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>'; if (strcmp($AVLFK,$m)==0){//&&isset($u['ROLE'])&&$u['ROLE']==1 $roleArrayCopy[$P][$MKI]['date']=$u['date']; $roleArrayCopy[$P][$MKI]['opinion']=$u['opinion']; $roleArrayCopy[$P][$MKI]['status']=$u['status']; break; } } }else{ if ($this->staff[0]['sid']==$AVL[0]&&$verifyList[0][1]=='ROLE'){ $button=4; $roleArrayCopy[$P][$MKI]['status']=4; } } //$roleArray[$MKI]['rolename']=$rolename['name']; $KOP=true; } } foreach ($roleArrayCopy as $k=>$v){ foreach ($verifyList as $m=>$n){ if ($n[0]==$k){ array_splice($verifyList,$m,1,$v); } } } $loanList[$key]['verifyList']=$verifyList; $loanList[$key]['staffDetail']=$staff->getOne(array('where'=>'sid='.$value['staff'],'asArray'=>true)); $loanList[$key]['button']=$button; //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']); } $data['loanList']=$loanList;
  3236. */
  3237. $data ['explanation'] = '';
  3238. if (! empty ( $loanList ))
  3239. $data ['explanation'] = $loanList [0] ['explanation'];
  3240. $Locate = 0;
  3241. $roleId = 0;
  3242. $button = 0;
  3243. foreach ( $receiptList as $key => $value ) {
  3244. $receiptList [$key] ['Locate'] = $Locate;
  3245. $Locate ++;
  3246. $receiptList [$key] ['reviseDetail'] = array ();
  3247. if (! empty ( $value ['reviseDetail'] ))
  3248. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3249. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3250. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3251. $categoryDetil = $Lcategory->getOne ( array (
  3252. 'where' => 'cid=' . $value ['cid'],
  3253. 'asArray' => true
  3254. ) );
  3255. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3256. // 检测编辑状态
  3257. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  3258. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  3259. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  3260. else
  3261. $verifyList ['staff'] = $value ['verifyBreakup'];
  3262. } else
  3263. $verifyList = $verify->getOne ( array (
  3264. 'where' => 'vid=' . $value ['verify'],
  3265. 'asArray' => true
  3266. ) );
  3267. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3268. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3269. Doo::loadModel ( 'role' );
  3270. $role = new role ();
  3271. $flag = true;
  3272. $roleKey = 0;
  3273. $endStaffArray = array ();
  3274. $roleArrayCopy = array ();
  3275. foreach ( $verifyList as $k => $v ) {
  3276. // init verifyStaff
  3277. if ($v [1] == 'ROLE') {
  3278. if (! empty ( $verifyStaff )) {
  3279. $endStaffArray = end ( $verifyStaff );
  3280. // if ($v[0]==$endStaffArray['nextStaff']){
  3281. // $roleId=$v[0];
  3282. // }
  3283. }
  3284. $roleVerify = json_decode ( $v [3], true );
  3285. $roleKey = $k;
  3286. $roleArray = array ();
  3287. $rolename = $role->getOne ( array (
  3288. 'where' => 'rid=' . $v [0],
  3289. 'asArray' => true
  3290. ) );
  3291. foreach ( $roleVerify as $o => $p ) {
  3292. $staffID = explode ( '_', $p );
  3293. $staffInfo = $staff->getOne ( array (
  3294. 'where' => 'sid=' . $staffID [0],
  3295. 'asArray' => true
  3296. ) );
  3297. // print_r($staffID);
  3298. $exp = array (
  3299. 0 => $staffInfo ['sid'],
  3300. 1 => $staffID [1],
  3301. 2 => $staffInfo ['avatar'],
  3302. 'date' => '',
  3303. 'date' => '',
  3304. 'opinion' => '',
  3305. 'status' => '',
  3306. 'rolename' => $rolename ['name']
  3307. );
  3308. array_push ( $roleArray, $exp );
  3309. }
  3310. $roleArrayCopy [$v [0]] = $roleArray;
  3311. // $verifyList[$k]['roleArray']=$roleArray;
  3312. }
  3313. $verifyList [$k] ['date'] = "";
  3314. $verifyList [$k] ['opinion'] = "";
  3315. $verifyList [$k] ['status'] = "";
  3316. if (empty ( $verifyStaff )) {
  3317. $verifyList [$k] ['date'] = "";
  3318. $verifyList [$k] ['opinion'] = "";
  3319. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3320. $verifyList [$k] ['status'] = 4;
  3321. $flag = false;
  3322. }
  3323. } else {
  3324. foreach ( $verifyStaff as $m => $u ) {
  3325. if ($v [0] == $m) {
  3326. $verifyList [$k] ['date'] = $u ['date'];
  3327. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3328. $verifyList [$k] ['status'] = $u ['status'];
  3329. $flag = false;
  3330. break;
  3331. }
  3332. }
  3333. $endStaffArray = end ( $verifyStaff );
  3334. if (isset ( $endStaffArray ['ROLE'] )) {
  3335. } else {
  3336. // $endKey=key($verifyStaff);
  3337. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3338. // $button=4;
  3339. // $verifyList[$k]['status']=4;
  3340. // }
  3341. }
  3342. }
  3343. }
  3344. $rolename ['name'] = '';
  3345. if (! empty ( $roleId )) {
  3346. Doo::loadModel ( 'role' );
  3347. $role = new role ();
  3348. $rolename = $role->getOne ( array (
  3349. 'where' => 'rid=' . $roleId,
  3350. 'asArray' => true
  3351. ) );
  3352. }
  3353. if (! empty ( $verifyStaff ))
  3354. $endStaffArray = end ( $verifyStaff );
  3355. $KOP = false;
  3356. foreach ( $roleArrayCopy as $P => $A ) {
  3357. foreach ( $A as $MKI => $AVL ) {
  3358. if (! empty ( $verifyStaff )) {
  3359. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3360. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3361. $button = 4;
  3362. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3363. }
  3364. foreach ( $verifyStaff as $m => $u ) {
  3365. $AVLFK = $AVL [0] . '_R';
  3366. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3367. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3368. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3369. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3370. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3371. break;
  3372. }
  3373. }
  3374. } else {
  3375. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3376. $button = 4;
  3377. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3378. }
  3379. }
  3380. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3381. $KOP = true;
  3382. }
  3383. }
  3384. foreach ( $roleArrayCopy as $k => $v ) {
  3385. foreach ( $verifyList as $m => $n ) {
  3386. if ($n [0] == $k) {
  3387. array_splice ( $verifyList, $m, 1, $v );
  3388. }
  3389. }
  3390. }
  3391. // 费用执行人相关数据
  3392. $executeCopy = json_decode ( $value ['executeCopy'], true );
  3393. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3394. foreach ( $executeCopy as $k => $v ) {
  3395. $executeCopy [$k] ['date'] = '';
  3396. $executeCopy [$k] ['opinion'] = '';
  3397. $executeCopy [$k] ['status'] = '';
  3398. if (! empty ( $executeStaff ))
  3399. foreach ( $executeStaff as $m => $u ) {
  3400. if ($v [0] == $m) {
  3401. $executeCopy [$k] ['date'] = $u ['date'];
  3402. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  3403. $executeCopy [$k] ['status'] = $u ['status'];
  3404. break;
  3405. }
  3406. }
  3407. }
  3408. $receiptList [$key] ['executeCopy'] = $executeCopy;
  3409. $receiptList [$key] ['verifyList'] = $verifyList;
  3410. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3411. 'where' => 'sid=' . $value ['staff'],
  3412. 'asArray' => true
  3413. ) );
  3414. $receiptList [$key] ['button'] = $button;
  3415. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3416. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3417. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  3418. $receiptList [$key] ['relust'] = $relust;
  3419. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  3420. }
  3421. Doo::loadModel ( 'enclosur' );
  3422. $enclosur = new enclosur ();
  3423. $enclosurList = $enclosur->find ( array (
  3424. 'where' => 'rid=' . $rid,
  3425. 'asArray' => true
  3426. ) );
  3427. $enclosurHtml = '';
  3428. foreach ( $enclosurList as $value ) {
  3429. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3430. }
  3431. $data ['enclosurHtml'] = $enclosurHtml;
  3432. //print_r($receiptList[0]['accountItem']['内部培训费用']);
  3433. $data ['receiptList'] = $receiptList;
  3434. $data ['memu'] = "receipt";
  3435. $data ['staff'] = $this->staff;
  3436. $data ['receiptMemu'] = 'expenses';
  3437. $data ['verifyId'] = $this->verifyId;
  3438. $data ['executeId'] = $this->executeId;
  3439. $this->render ( "/admin/expensesCollect", $data );
  3440. }
  3441. function approvalExpenses() {
  3442. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  3443. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3444. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3445. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3446. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3447. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  3448. // echo $rdate;
  3449. if (empty ( $status ))
  3450. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3451. $page_size = 8;
  3452. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  3453. $vidList = array ();
  3454. $button = 0;
  3455. Doo::loadModel ( 'verify' );
  3456. $verify = new verify ();
  3457. Doo::loadModel ( 'receipt' );
  3458. $receipt = new receipt ();
  3459. Doo::loadModel ( 'staff' );
  3460. $staff = new staff ();
  3461. Doo::loadModel ( 'L_category' );
  3462. $Lcategory = new L_category ();
  3463. // user verify ID
  3464. $verifyDetail = $verify->find ( array (
  3465. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  3466. 'asArray' => true
  3467. ) );
  3468. foreach ( $verifyDetail as $key => $value ) {
  3469. array_push ( $vidList, $value ['vid'] );
  3470. }
  3471. $vid = implode ( ",", $vidList );
  3472. if (empty ( $verifyDetail ))
  3473. $vid = 0;
  3474. // if ($status==0)
  3475. // $dateCondition="";
  3476. // else
  3477. $dateCondition = " ";
  3478. // if (! empty ( $month ))
  3479. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  3480. if ($status == 'done' || $status == 'termination') {
  3481. if (! empty ( $year )) {
  3482. $dateCondition = " and Year(pastDate) =" . $year;
  3483. if (! empty ( $month ))
  3484. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  3485. }
  3486. } elseif ($status == 'finish') {
  3487. if (! empty ( $year )) {
  3488. $dateCondition = " and Year(pastDate) =" . $year;
  3489. if (! empty ( $month ))
  3490. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  3491. }
  3492. }
  3493. // date ( 'Y-m' )
  3494. // if (! empty ( $rdate ) && $status == 'done')
  3495. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  3496. // elseif (! empty ( $rdate ))
  3497. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  3498. $categoryList = $Lcategory->find ( array (
  3499. 'asArray' => true
  3500. ) );
  3501. $staffList = $staff->find ( array (
  3502. 'where' => 'cid=' . $cid,
  3503. 'asArray' => true
  3504. ) );
  3505. $cateCondition = "";
  3506. $staffCondition = "";
  3507. $approvalCondition = "";
  3508. if (! empty ( $cid )) {
  3509. $cateCondition = ' and cid=' . $cid;
  3510. }
  3511. if (! empty ( $sid )) {
  3512. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  3513. $cateCondition = "";
  3514. }
  3515. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  3516. if ($status == 'pendApproval') {
  3517. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  3518. }
  3519. if ($status == 'ongoing') {
  3520. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  3521. }
  3522. if ($status == 'done') {
  3523. $approvalCondition = ' and (status=8 or status=9 ) ';
  3524. }
  3525. if ($status == 'termination') {
  3526. $approvalCondition = " and status=3";
  3527. }
  3528. if ($status == 'finish') {
  3529. $approvalCondition = " and (status=1 or status=8 or status=9 or status=10)";
  3530. }
  3531. $pageinfo ['page'] = array (
  3532. 'previous' => ''
  3533. );
  3534. if(!empty($receiptOrder)){
  3535. $pageinfo = $this->get_page ( "CLD_receipt", ' and receiptOrder like "%' . $receiptOrder . '%"', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  3536. $receiptList = $receipt->find ( array ( // $dateCondition
  3537. 'where' => 'receiptOrder like "%' . $receiptOrder . '%"',
  3538. 'desc' => 'rid',
  3539. 'asArray' => true
  3540. ) );
  3541. }else{
  3542. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  3543. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  3544. $receiptList = $receipt->find ( array ( // $dateCondition.
  3545. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  3546. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  3547. 'desc' => 'rid',
  3548. 'asArray' => true
  3549. ) );
  3550. } else {
  3551. $receiptList = $receipt->find ( array ( // $dateCondition
  3552. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  3553. 'desc' => 'rid',
  3554. 'asArray' => true
  3555. ) );
  3556. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  3557. }
  3558. }
  3559. $rLRes = $receipt->find ( array (
  3560. 'where' => 'status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )' . $cateCondition . $staffCondition . ' and verify in (' . $vid . ')',
  3561. 'desc' => 'rid',
  3562. 'asArray' => true
  3563. ) );
  3564. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  3565. // print_r($receiptList);
  3566. Doo::loadClass ( 'XDeode' );
  3567. $XDeode = new XDeode ( 7 );
  3568. $Locate = 0;
  3569. //
  3570. $reportList = $reportCateList = array ();
  3571. foreach ( $receiptList as $key => $value ) {
  3572. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  3573. $receiptList [$key] ['Locate'] = $Locate;
  3574. $Locate ++;
  3575. $receiptList [$key] ['reviseDetail'] = array ();
  3576. if (! empty ( $value ['reviseDetail'] ))
  3577. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3578. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3579. $categoryDetil = $Lcategory->getOne ( array (
  3580. 'where' => 'cid=' . $value ['cid'],
  3581. 'asArray' => true
  3582. ) );
  3583. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3584. $verifyList = $verify->getOne ( array (
  3585. 'where' => 'vid=' . $value ['verify'],
  3586. 'asArray' => true
  3587. ) );
  3588. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3589. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3590. foreach ( $verifyList as $k => $v ) {
  3591. // init verifyStaff
  3592. $verifyList [$k] ['date'] = "";
  3593. $verifyList [$k] ['opinion'] = "";
  3594. $verifyList [$k] ['status'] = "";
  3595. if (empty ( $verifyStaff )) {
  3596. $verifyList [$k] ['date'] = "";
  3597. $verifyList [$k] ['opinion'] = "";
  3598. if ($v [0] == $this->staff [0] ['sid']) {
  3599. $verifyList [$k] ['status'] = 4;
  3600. $button = 4;
  3601. }
  3602. } else {
  3603. $flag = true;
  3604. foreach ( $verifyStaff as $m => $u ) {
  3605. if ($v [0] == $m) {
  3606. $verifyList [$k] ['date'] = $u ['date'];
  3607. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3608. $verifyList [$k] ['status'] = $u ['status'];
  3609. $flag = false;
  3610. break;
  3611. }
  3612. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  3613. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  3614. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  3615. }
  3616. if ($flag) { // 检测可编辑
  3617. if ($v [0] == $this->staff [0] ['sid']) {
  3618. $verifyList [$k] ['status'] = 4;
  3619. $button = 4;
  3620. }
  3621. }
  3622. }
  3623. }
  3624. $receiptList [$key] ['verifyList'] = $verifyList;
  3625. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3626. 'where' => 'sid=' . $value ['staff'],
  3627. 'asArray' => true
  3628. ) );
  3629. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  3630. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  3631. $receiptList [$key] ['button'] = $button;
  3632. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  3633. //获得培训班结算RID 借款费用--已经锁定
  3634. if($value['status']==10){
  3635. $trainRD=$receipt->getReceiptByTrainLoanRid($value['rid']);
  3636. $receiptList [$key]['trainRidKey7']=$trainRD['ridKey7'];
  3637. }
  3638. }
  3639. $reportList = array_unique ( $reportList );
  3640. $reportHtml = '';
  3641. foreach ( $reportList as $key => $value ) {
  3642. $v = explode ( "-", $value );
  3643. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  3644. }
  3645. // print_r($reportList)
  3646. $data ['reportHtml'] = $reportHtml;
  3647. $reportCateList = array_unique ( $reportCateList );
  3648. $reportCateHtml = '';
  3649. foreach ( $reportCateList as $key => $value ) {
  3650. $v = explode ( "-", $value );
  3651. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  3652. }
  3653. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  3654. $data ['reportCateHtml'] = $reportCateHtml;
  3655. // print_r($receiptList);die;
  3656. // $data['verifyDetail']=$verifyDetail;
  3657. $mothHtml = "";
  3658. for($i = 1; $i <= 12; $i ++) {
  3659. if ($month == $i)
  3660. $mothHtml .= '<option selected value="0' . $i . '">' . $i . '月</option>';
  3661. else
  3662. $mothHtml .= '<option value="0' . $i . '">' . $i . '月</option>';
  3663. }
  3664. $data ['mothHtml'] = $mothHtml;
  3665. $dateHtml = "";
  3666. $now = date ( "Y" );
  3667. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  3668. if ($YEARD <= $now) {
  3669. $dateHtml .= '<option ';
  3670. if ($year == $YEARD) {
  3671. $dateHtml .= 'selected ';
  3672. }
  3673. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  3674. }
  3675. }
  3676. $data ['dateHtml'] = $dateHtml;
  3677. $data ['page'] = $pageinfo;
  3678. $data ['receiptList'] = $receiptList;
  3679. $data ['receiptApprovalCount'] = count ( $rLRes );
  3680. $data ['status'] = $status;
  3681. $data ['year'] = $year;
  3682. $data ['month'] = $month;
  3683. $data ['categoryList'] = $categoryList;
  3684. $data ['staffList'] = $staffList;
  3685. $data ['cid'] = $cid;
  3686. $data ['sid'] = $sid;
  3687. // print_r($receiptList);
  3688. $data['receiptOrder']=$receiptOrder;
  3689. $data ['memu'] = "receipt";
  3690. $data ['staff'] = $this->staff;
  3691. $data ['receiptMemu'] = 'approvalExpenses';
  3692. $data ['verifyId'] = $this->verifyId;
  3693. $data ['executeId'] = $this->executeId;
  3694. $this->render ( "/admin/approvalExpenses", $data );
  3695. }
  3696. function expensesDoc() {
  3697. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3698. Doo::loadClass ( 'XDeode' );
  3699. $XDeode = new XDeode ( 5 );
  3700. if (! empty ( $rid ) && ! is_numeric ( $rid ))
  3701. $rid = $XDeode->decode ( $rid );
  3702. if (! is_numeric ( $rid ))
  3703. die ( 'illegal request' );
  3704. Doo::loadModel ( 'receipt' );
  3705. $receipt = new receipt ();
  3706. Doo::loadModel ( 'L_category' );
  3707. $Lcategory = new L_category ();
  3708. Doo::loadModel ( 'verify' );
  3709. Doo::loadModel ( 'statistics' );
  3710. $statistics = new statistics ();
  3711. $verify = new verify ();
  3712. Doo::loadModel ( 'staff' );
  3713. $staff = new staff ();
  3714. Doo::loadModel ( 'loanReceipt' );
  3715. $loanReceipt = new loanReceipt ();
  3716. $receiptList = $receipt->find ( array (
  3717. 'where' => ' rid=' . $rid,
  3718. 'desc' => 'rid',
  3719. 'asArray' => true
  3720. ) );
  3721. $loanList = array ();
  3722. if (! empty ( $receiptList ))
  3723. $loanList = $loanReceipt->find ( array (
  3724. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3725. 'desc' => 'rid',
  3726. 'asArray' => true
  3727. ) );
  3728. $Locate = 0;
  3729. $roleId = 0;
  3730. $button = 0;
  3731. foreach ( $loanList as $key => $value ) {
  3732. $loanList [$key] ['Locate'] = $Locate;
  3733. $Locate ++;
  3734. $loanList [$key] ['reviseDetail'] = array ();
  3735. if (! empty ( $value ['reviseDetail'] ))
  3736. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3737. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3738. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3739. $categoryDetil = $Lcategory->getOne ( array (
  3740. 'where' => 'cid=' . $value ['cid'],
  3741. 'asArray' => true
  3742. ) );
  3743. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3744. // 检测编辑状态
  3745. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  3746. $verifyList ['staff'] = $value ['verifyBreakup'];
  3747. else
  3748. $verifyList = $verify->getOne ( array (
  3749. 'where' => 'vid=' . $value ['verify'],
  3750. 'asArray' => true
  3751. ) );
  3752. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3753. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3754. Doo::loadModel ( 'role' );
  3755. $role = new role ();
  3756. $flag = true;
  3757. $roleKey = 0;
  3758. $endStaffArray = array ();
  3759. $roleArrayCopy = array ();
  3760. foreach ( $verifyList as $k => $v ) {
  3761. // init verifyStaff
  3762. if ($v [1] == 'ROLE') {
  3763. if (! empty ( $verifyStaff )) {
  3764. $endStaffArray = end ( $verifyStaff );
  3765. // if ($v[0]==$endStaffArray['nextStaff']){
  3766. // $roleId=$v[0];
  3767. // }
  3768. }
  3769. $roleVerify = json_decode ( $v [3], true );
  3770. $roleKey = $k;
  3771. $roleArray = array ();
  3772. $rolename = $role->getOne ( array (
  3773. 'where' => 'rid=' . $v [0],
  3774. 'asArray' => true
  3775. ) );
  3776. foreach ( $roleVerify as $o => $p ) {
  3777. $staffID = explode ( '_', $p );
  3778. $staffInfo = $staff->getOne ( array (
  3779. 'where' => 'sid=' . $staffID [0],
  3780. 'asArray' => true
  3781. ) );
  3782. // print_r($staffID);
  3783. $exp = array (
  3784. 0 => $staffInfo ['sid'],
  3785. 1 => $staffID [1],
  3786. 2 => $staffInfo ['avatar'],
  3787. 'date' => '',
  3788. 'date' => '',
  3789. 'opinion' => '',
  3790. 'status' => '',
  3791. 'rolename' => $rolename ['name']
  3792. );
  3793. array_push ( $roleArray, $exp );
  3794. }
  3795. $roleArrayCopy [$v [0]] = $roleArray;
  3796. // $verifyList[$k]['roleArray']=$roleArray;
  3797. }
  3798. $verifyList [$k] ['date'] = "";
  3799. $verifyList [$k] ['opinion'] = "";
  3800. $verifyList [$k] ['status'] = "";
  3801. if (empty ( $verifyStaff )) {
  3802. $verifyList [$k] ['date'] = "";
  3803. $verifyList [$k] ['opinion'] = "";
  3804. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3805. $verifyList [$k] ['status'] = 4;
  3806. $flag = false;
  3807. }
  3808. } else {
  3809. foreach ( $verifyStaff as $m => $u ) {
  3810. if ($v [0] == $m) {
  3811. $verifyList [$k] ['date'] = $u ['date'];
  3812. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3813. $verifyList [$k] ['status'] = $u ['status'];
  3814. $flag = false;
  3815. break;
  3816. }
  3817. }
  3818. $endStaffArray = end ( $verifyStaff );
  3819. if (isset ( $endStaffArray ['ROLE'] )) {
  3820. } else {
  3821. // $endKey=key($verifyStaff);
  3822. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3823. // $button=4;
  3824. // $verifyList[$k]['status']=4;
  3825. // }
  3826. }
  3827. }
  3828. }
  3829. $rolename ['name'] = '';
  3830. if (! empty ( $roleId )) {
  3831. Doo::loadModel ( 'role' );
  3832. $role = new role ();
  3833. $rolename = $role->getOne ( array (
  3834. 'where' => 'rid=' . $roleId,
  3835. 'asArray' => true
  3836. ) );
  3837. }
  3838. if (! empty ( $verifyStaff ))
  3839. $endStaffArray = end ( $verifyStaff );
  3840. $KOP = false;
  3841. foreach ( $roleArrayCopy as $P => $A ) {
  3842. foreach ( $A as $MKI => $AVL ) {
  3843. if (! empty ( $verifyStaff )) {
  3844. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3845. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3846. $button = 4;
  3847. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3848. }
  3849. foreach ( $verifyStaff as $m => $u ) {
  3850. $AVLFK = $AVL [0] . '_R';
  3851. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3852. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3853. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3854. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3855. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3856. break;
  3857. }
  3858. }
  3859. } else {
  3860. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3861. $button = 4;
  3862. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3863. }
  3864. }
  3865. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3866. $KOP = true;
  3867. }
  3868. }
  3869. foreach ( $roleArrayCopy as $k => $v ) {
  3870. foreach ( $verifyList as $m => $n ) {
  3871. if ($n [0] == $k) {
  3872. array_splice ( $verifyList, $m, 1, $v );
  3873. }
  3874. }
  3875. }
  3876. $loanList [$key] ['verifyList'] = $verifyList;
  3877. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3878. 'where' => 'sid=' . $value ['staff'],
  3879. 'asArray' => true
  3880. ) );
  3881. $loanList [$key] ['button'] = $button;
  3882. //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  3883. }
  3884. $data ['loanList'] = $loanList;
  3885. //print_r($loanList);
  3886. $Locate = 0;
  3887. $roleId = 0;
  3888. $button = 0;
  3889. foreach ( $receiptList as $key => $value ) {
  3890. $receiptList [$key] ['Locate'] = $Locate;
  3891. $Locate ++;
  3892. $receiptList [$key] ['reviseDetail'] = array ();
  3893. if (! empty ( $value ['reviseDetail'] ))
  3894. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3895. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3896. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3897. $categoryDetil = $Lcategory->getOne ( array (
  3898. 'where' => 'cid=' . $value ['cid'],
  3899. 'asArray' => true
  3900. ) );
  3901. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3902. // 检测编辑状态
  3903. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3904. $verifyList ['staff'] = $value ['verifyBreakup'];
  3905. } else
  3906. $verifyList = $verify->getOne ( array (
  3907. 'where' => 'vid=' . $value ['verify'],
  3908. 'asArray' => true
  3909. ) );
  3910. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3911. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3912. Doo::loadModel ( 'role' );
  3913. $role = new role ();
  3914. if ($verifyList == NULL)
  3915. $verifyList = array ();
  3916. $flag = true;
  3917. $roleKey = 0;
  3918. $endStaffArray = array ();
  3919. $roleArrayCopy = array ();
  3920. foreach ( $verifyList as $k => $v ) {
  3921. // init verifyStaff
  3922. if ($v [1] == 'ROLE') {
  3923. if (! empty ( $verifyStaff )) {
  3924. $endStaffArray = end ( $verifyStaff );
  3925. // if ($v[0]==$endStaffArray['nextStaff']){
  3926. // $roleId=$v[0];
  3927. // }
  3928. }
  3929. $roleVerify = json_decode ( $v [3], true );
  3930. $roleKey = $k;
  3931. $roleArray = array ();
  3932. $rolename = $role->getOne ( array (
  3933. 'where' => 'rid=' . $v [0],
  3934. 'asArray' => true
  3935. ) );
  3936. foreach ( $roleVerify as $o => $p ) {
  3937. $staffID = explode ( '_', $p );
  3938. $staffInfo = $staff->getOne ( array (
  3939. 'where' => 'sid=' . $staffID [0],
  3940. 'asArray' => true
  3941. ) );
  3942. // print_r($staffID);
  3943. $exp = array (
  3944. 0 => $staffInfo ['sid'],
  3945. 1 => $staffID [1],
  3946. 2 => $staffInfo ['avatar'],
  3947. 'date' => '',
  3948. 'date' => '',
  3949. 'opinion' => '',
  3950. 'status' => '',
  3951. 'rolename' => $rolename ['name']
  3952. );
  3953. array_push ( $roleArray, $exp );
  3954. }
  3955. $roleArrayCopy [$v [0]] = $roleArray;
  3956. // $verifyList[$k]['roleArray']=$roleArray;
  3957. }
  3958. $verifyList [$k] ['date'] = "";
  3959. $verifyList [$k] ['opinion'] = "";
  3960. $verifyList [$k] ['status'] = "";
  3961. if (empty ( $verifyStaff )) {
  3962. $verifyList [$k] ['date'] = "";
  3963. $verifyList [$k] ['opinion'] = "";
  3964. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3965. $verifyList [$k] ['status'] = 4;
  3966. $flag = false;
  3967. }
  3968. } else {
  3969. foreach ( $verifyStaff as $m => $u ) {
  3970. if ($v [0] == $m) {
  3971. $verifyList [$k] ['date'] = $u ['date'];
  3972. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3973. $verifyList [$k] ['status'] = $u ['status'];
  3974. $flag = false;
  3975. break;
  3976. }
  3977. }
  3978. $endStaffArray = end ( $verifyStaff );
  3979. if (isset ( $endStaffArray ['ROLE'] )) {
  3980. } else {
  3981. // $endKey=key($verifyStaff);
  3982. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3983. // $button=4;
  3984. // $verifyList[$k]['status']=4;
  3985. // }
  3986. }
  3987. }
  3988. }
  3989. $FC = @$rolename ['name'];
  3990. $rolename ['name'] = '';
  3991. if (! empty ( $roleId )) {
  3992. Doo::loadModel ( 'role' );
  3993. $role = new role ();
  3994. $rolename = $role->getOne ( array (
  3995. 'where' => 'rid=' . $roleId,
  3996. 'asArray' => true
  3997. ) );
  3998. }
  3999. if (! empty ( $verifyStaff ))
  4000. $endStaffArray = end ( $verifyStaff );
  4001. $KOP = false;
  4002. foreach ( $roleArrayCopy as $P => $A ) {
  4003. foreach ( $A as $MKI => $AVL ) {
  4004. if (! empty ( $verifyStaff )) {
  4005. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4006. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4007. $button = 4;
  4008. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4009. }
  4010. foreach ( $verifyStaff as $m => $u ) {
  4011. $AVLFK = $AVL [0] . '_R';
  4012. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4013. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4014. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4015. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4016. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4017. break;
  4018. }
  4019. }
  4020. } else {
  4021. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4022. $button = 4;
  4023. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4024. }
  4025. }
  4026. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4027. $KOP = true;
  4028. }
  4029. }
  4030. foreach ( $roleArrayCopy as $k => $v ) {
  4031. foreach ( $verifyList as $m => $n ) {
  4032. if ($n [0] == $k) {
  4033. array_splice ( $verifyList, $m, 1, $v );
  4034. }
  4035. }
  4036. }
  4037. // 费用执行人相关数据
  4038. $executeCopy = json_decode ( $value ['executeCopy'], true );
  4039. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4040. foreach ( $executeCopy as $k => $v ) {
  4041. $executeCopy [$k] ['date'] = '';
  4042. $executeCopy [$k] ['opinion'] = '';
  4043. $executeCopy [$k] ['status'] = '';
  4044. if (! empty ( $executeStaff ))
  4045. foreach ( $executeStaff as $m => $u ) {
  4046. if ($v [0] == $m) {
  4047. $executeCopy [$k] ['date'] = $u ['date'];
  4048. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  4049. $executeCopy [$k] ['status'] = $u ['status'];
  4050. break;
  4051. }
  4052. }
  4053. }
  4054. $receiptList [$key] ['executeCopy'] = $executeCopy;
  4055. // print_r($verifyList);
  4056. $receiptList [$key] ['verifyList'] = $verifyList;
  4057. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4058. 'where' => 'sid=' . $value ['staff'],
  4059. 'asArray' => true
  4060. ) );
  4061. $receiptList [$key] ['button'] = $button;
  4062. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4063. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4064. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4065. $receiptList [$key] ['relust'] = $relust;
  4066. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4067. }
  4068. // print_r($receiptList);
  4069. // 获取审批日志
  4070. Doo::loadModel ( 'receiptLog' );
  4071. $receiptLog = new receiptLog ();
  4072. $rlList = array ();
  4073. $rlInfo = $receiptLog->getOne ( array (
  4074. 'where' => 'rid=' . $rid . ' and status=4',
  4075. 'asArray' => true
  4076. ) );
  4077. // $tijdate = $receiptLog->getOne ( array (
  4078. // 'where' => 'rid=' . $rid . ' and status=2',
  4079. // 'asc' => 'rlid',
  4080. // 'asArray' => true
  4081. // ) );
  4082. if (! empty ( $rlInfo )) {
  4083. $rlList = $receiptLog->find ( array (
  4084. 'where' => 'rid=' . $rid,
  4085. 'asc' => 'rlid',
  4086. 'asArray' => true
  4087. ) );
  4088. }
  4089. $RN=array();
  4090. if (!empty( $rolename ['staff'])){
  4091. $RN = @json_decode ( $rolename ['staff'] );
  4092. }
  4093. //
  4094. foreach ( $rlList as $key => $value ) {
  4095. $rlList [$key] ['rolename'] = '';
  4096. foreach ( $RN as $k => $v ) {
  4097. $id = explode ( "_", $v );
  4098. if ($id [0] == $value ['uid']) {
  4099. $rlList [$key] ['rolename'] = $FC;
  4100. break;
  4101. }
  4102. }
  4103. }
  4104. Doo::loadModel ( 'enclosur' );
  4105. $enclosur = new enclosur ();
  4106. $enclosurList = $enclosur->find ( array (
  4107. 'where' => 'rid=' . $rid,
  4108. 'asArray' => true
  4109. ) );
  4110. $enclosurHtml = '';
  4111. foreach ( $enclosurList as $value ) {
  4112. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4113. }
  4114. $data ['enclosurHtml'] = $enclosurHtml;
  4115. $receiptList [0] ['rlList'] = $rlList;
  4116. $data ['receiptList'] = $receiptList;
  4117. // print_r($receiptList);
  4118. $data ['memu'] = "receipt";
  4119. $data ['staff'] = $this->staff;
  4120. $data ['receiptMemu'] = 'approvalExpenses';
  4121. $data ['verifyId'] = $this->verifyId;
  4122. $data ['executeId'] = $this->executeId;
  4123. $this->render ( "/admin/expensesDoc", $data );
  4124. }
  4125. function expensesEdi() {
  4126. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4127. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  4128. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4129. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4130. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4131. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4132. if (empty ( $status ))
  4133. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  4134. $vidList = array ();
  4135. $button = 0;
  4136. Doo::loadModel ( 'verify' );
  4137. Doo::loadModel ( 'receipt' );
  4138. Doo::loadModel ( 'staff' );
  4139. $staff = new staff ();
  4140. $receipt = new receipt ();
  4141. $verify = new verify ();
  4142. Doo::loadModel ( 'L_category' );
  4143. $Lcategory = new L_category ();
  4144. Doo::loadModel ( 'enclosur' );
  4145. $enclosur = new enclosur ();
  4146. // user verify ID
  4147. $verifyDetail = $verify->find ( array (
  4148. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  4149. 'asArray' => true
  4150. ) );
  4151. foreach ( $verifyDetail as $key => $value ) {
  4152. array_push ( $vidList, $value ['vid'] );
  4153. }
  4154. $vid = implode ( ",", $vidList );
  4155. if (empty ( $verifyDetail ))
  4156. $vid = 0;
  4157. $categoryList = $Lcategory->find ( array (
  4158. 'asArray' => true
  4159. ) );
  4160. $staffList = $staff->find ( array (
  4161. 'where' => 'cid=' . $cid,
  4162. 'asArray' => true
  4163. ) );
  4164. $ap = "";
  4165. if ($status == 4) {
  4166. $ap = 4;
  4167. $status = 2;
  4168. }
  4169. // get Receipt By verifyID status 2
  4170. $receiptList = $receipt->find ( array (
  4171. 'where' => 'rid =' . $rid . ' and status=2',
  4172. 'desc' => 'rid',
  4173. 'asArray' => true
  4174. ) );
  4175. if (empty ( $receiptList )) {
  4176. die ( 'illegal request' );
  4177. }
  4178. $Locate = 0;
  4179. $roleId = 0;
  4180. if ($ap == 4)
  4181. $status = 4;
  4182. foreach ( $receiptList as $key => $value ) {
  4183. $receiptList [$key] ['Locate'] = $Locate;
  4184. $Locate ++;
  4185. $receiptList [$key] ['reviseDetail'] = array ();
  4186. if (! empty ( $value ['reviseDetail'] ))
  4187. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4188. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4189. $categoryDetil = $Lcategory->getOne ( array (
  4190. 'where' => 'cid=' . $value ['cid'],
  4191. 'asArray' => true
  4192. ) );
  4193. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4194. // 检测编辑状态
  4195. $verifyList = $verify->getOne ( array (
  4196. 'where' => 'vid=' . $value ['verify'],
  4197. 'asArray' => true
  4198. ) );
  4199. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4200. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4201. Doo::loadModel ( 'role' );
  4202. $role = new role ();
  4203. // print_r($verifyList);
  4204. $flag = true;
  4205. $roleKey = 0;
  4206. $endStaffArray = array ();
  4207. $roleArrayCopy = array ();
  4208. foreach ( $verifyList as $k => $v ) {
  4209. // init verifyStaff
  4210. if ($v [1] == 'ROLE') {
  4211. if (! empty ( $verifyStaff )) {
  4212. $endStaffArray = end ( $verifyStaff );
  4213. if ($v [0] == $endStaffArray ['nextStaff']) {
  4214. $roleId = $v [0];
  4215. }
  4216. }
  4217. $roleVerify = json_decode ( $v [3], true );
  4218. $roleKey = $k;
  4219. $roleArray = array ();
  4220. $rolename = $role->getOne ( array (
  4221. 'where' => 'rid=' . $v [0],
  4222. 'asArray' => true
  4223. ) );
  4224. foreach ( $roleVerify as $o => $p ) {
  4225. $staffID = explode ( '_', $p );
  4226. $staffInfo = $staff->getOne ( array (
  4227. 'where' => 'sid=' . $staffID [0],
  4228. 'asArray' => true
  4229. ) );
  4230. // print_r($staffID);
  4231. $exp = array (
  4232. 0 => $staffInfo ['sid'],
  4233. 1 => $staffID [1],
  4234. 2 => $staffInfo ['avatar'],
  4235. 'date' => '',
  4236. 'date' => '',
  4237. 'opinion' => '',
  4238. 'status' => '',
  4239. 'rolename' => $rolename ['name']
  4240. );
  4241. array_push ( $roleArray, $exp );
  4242. }
  4243. $roleArrayCopy [$v [0]] = $roleArray;
  4244. // $verifyList[$k]['roleArray']=$roleArray;
  4245. }
  4246. // print_r($roleArray);
  4247. $verifyList [$k] ['date'] = "";
  4248. $verifyList [$k] ['opinion'] = "";
  4249. $verifyList [$k] ['status'] = "";
  4250. if (empty ( $verifyStaff )) {
  4251. $verifyList [$k] ['date'] = "";
  4252. $verifyList [$k] ['opinion'] = "";
  4253. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4254. $verifyList [$k] ['status'] = 4;
  4255. $button = 4;
  4256. $flag = false;
  4257. }
  4258. } else {
  4259. foreach ( $verifyStaff as $m => $u ) {
  4260. if ($v [0] == $m) {
  4261. $verifyList [$k] ['date'] = $u ['date'];
  4262. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4263. $verifyList [$k] ['status'] = $u ['status'];
  4264. $flag = false;
  4265. break;
  4266. }
  4267. }
  4268. $endStaffArray = end ( $verifyStaff );
  4269. if (isset ( $endStaffArray ['ROLE'] )) {
  4270. } else {
  4271. $endKey = key ( $verifyStaff );
  4272. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4273. $button = 4;
  4274. $verifyList [$k] ['status'] = 4;
  4275. }
  4276. }
  4277. }
  4278. }
  4279. $rolename ['name'] = '';
  4280. if (! empty ( $roleId )) {
  4281. Doo::loadModel ( 'role' );
  4282. $role = new role ();
  4283. $rolename = $role->getOne ( array (
  4284. 'where' => 'rid=' . $roleId,
  4285. 'asArray' => true
  4286. ) );
  4287. }
  4288. if (! empty ( $verifyStaff ))
  4289. $endStaffArray = end ( $verifyStaff );
  4290. $KOP = false;
  4291. foreach ( $roleArrayCopy as $P => $A ) {
  4292. foreach ( $A as $MKI => $AVL ) {
  4293. if (! empty ( $verifyStaff )) {
  4294. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4295. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4296. $button = 4;
  4297. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4298. }
  4299. foreach ( $verifyStaff as $m => $u ) {
  4300. $AVLFK = $AVL [0] . '_R';
  4301. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4302. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4303. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4304. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4305. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4306. break;
  4307. }
  4308. }
  4309. } else {
  4310. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4311. $button = 4;
  4312. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4313. }
  4314. }
  4315. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4316. $KOP = true;
  4317. }
  4318. }
  4319. // print_r($roleArrayCopy);
  4320. // echo $roleKey;
  4321. foreach ( $roleArrayCopy as $k => $v ) {
  4322. foreach ( $verifyList as $m => $n ) {
  4323. if ($n [0] == $k) {
  4324. array_splice ( $verifyList, $m, 1, $v );
  4325. }
  4326. }
  4327. }
  4328. $receiptList [$key] ['verifyList'] = $verifyList;
  4329. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4330. 'where' => 'sid=' . $value ['staff'],
  4331. 'asArray' => true
  4332. ) );
  4333. $receiptList [$key] ['button'] = $button;
  4334. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  4335. }
  4336. // $data['verifyDetail']=$verifyDetail;
  4337. $mothHtml = "";
  4338. for($i = 1; $i <= 12; $i ++) {
  4339. if ($month == $i)
  4340. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4341. else
  4342. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4343. }
  4344. // 获取审批日志
  4345. Doo::loadModel ( 'receiptLog' );
  4346. $receiptLog = new receiptLog ();
  4347. $rlList = array ();
  4348. $rlInfo = $receiptLog->getOne ( array (
  4349. 'where' => 'rid=' . $rid . ' and status=4',
  4350. 'asArray' => true
  4351. ) );
  4352. $tijdate = $receiptLog->getOne ( array (
  4353. 'where' => 'rid=' . $rid . ' and status=2',
  4354. 'asc' => 'rlid',
  4355. 'asArray' => true
  4356. ) );
  4357. if (! empty ( $rlInfo )) {
  4358. $rlList = $receiptLog->find ( array (
  4359. 'where' => 'rid=' . $rid,
  4360. 'asc' => 'rlid',
  4361. 'asArray' => true
  4362. ) );
  4363. }
  4364. $receiptList [0] ['rlList'] = $rlList;
  4365. $enclosurList = $enclosur->find ( array (
  4366. 'where' => 'rid=' . $rid,
  4367. 'asArray' => true
  4368. ) );
  4369. $enclosurHtml = '';
  4370. foreach ( $enclosurList as $value ) {
  4371. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4372. }
  4373. // print_r($receiptList);
  4374. $data ['rid'] = $rid;
  4375. $data ['enclosurHtml'] = $enclosurHtml;
  4376. $data ['rolename'] = $rolename ['name'];
  4377. $data ['datetij'] = $tijdate ['date'];
  4378. $data ['mothHtml'] = $mothHtml;
  4379. $data ['receiptList'] = $receiptList;
  4380. $data ['receiptApprovalCount'] = count ( $receiptList );
  4381. $data ['status'] = $status;
  4382. $data ['year'] = $year;
  4383. $data ['categoryList'] = $categoryList;
  4384. $data ['staffList'] = $staffList;
  4385. $data ['cid'] = $cid;
  4386. $data ['sid'] = $sid;
  4387. $data ['ap'] = $ap;
  4388. $data ['memu'] = "receipt";
  4389. $data ['staff'] = $this->staff;
  4390. $data ['receiptMemu'] = 'approvalExpenses';
  4391. $data ['verifyId'] = $this->verifyId;
  4392. $data ['executeId'] = $this->executeId;
  4393. $this->render ( "/admin/expensesEdi", $data );
  4394. }
  4395. function expensesDefray() {
  4396. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  4397. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  4398. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4399. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  4400. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  4401. if (! empty ( $rid )) {
  4402. Doo::loadModel ( "verify" );
  4403. $verify = new verify ();
  4404. Doo::loadModel ( "receiptDetail" );
  4405. $receiptDetailObj = new receiptDetail ();
  4406. Doo::loadModel ( "itemStatistics" );
  4407. Doo::loadModel ( "statistics" );
  4408. $statistics = new statistics ();
  4409. $itemStatistics = new itemStatistics ();
  4410. Doo::loadModel ( "receipt" );
  4411. $receipt = new receipt ();
  4412. Doo::loadModel ( "loanReceipt" );
  4413. $loanReceipt = new loanReceipt ();
  4414. $receiptDetail = $receipt->getOne ( array (
  4415. 'where' => 'rid=' . $rid . ' and status=2 ',
  4416. 'asArray' => true
  4417. ) );
  4418. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  4419. $nsflag = true;
  4420. foreach ( $nslist as $value ) {
  4421. if ($value == $this->staff ['0'] ['sid']) {
  4422. $nsflag = false;
  4423. break;
  4424. }
  4425. }
  4426. // print_r($nslist);die;
  4427. if (empty ( $receiptDetail ) || $nsflag)
  4428. return "/approvalExpenses/pendApproval";
  4429. $verifyDetail = $verify->getOne ( array (
  4430. 'where' => ' vid =' . $receiptDetail ['verify'],
  4431. 'asArray' => true
  4432. ) );
  4433. $verifyString = $verifyDetail ['staff'];
  4434. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  4435. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  4436. if (empty ( $opinion )) {
  4437. if ($status == 3)
  4438. $opinion = "终止";
  4439. else
  4440. $opinion = "同意支付";
  4441. }
  4442. $nowStaff = 0;
  4443. $nowStaffList = array ();
  4444. if (empty ( $verifyStaff )) {
  4445. // 还需加入是否已经进入角色审批
  4446. if ($verifyDetail [0] [1] == 'ROLE') {
  4447. // print_r($verifyDetail);echo "ddd";
  4448. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  4449. foreach ( $vStaffString as $key => $value ) {
  4450. $staffK = explode ( "_", $value );
  4451. if ($staffK [0] != $this->staff [0] ['sid'])
  4452. array_push ( $nowStaffList, $staffK [0] );
  4453. }
  4454. // print_r($verifyDetail);
  4455. // die;
  4456. if (! empty ( $nowStaffList )) {
  4457. $nowStaff = implode ( ',', $nowStaffList );
  4458. $verifyStaff = array (
  4459. $this->staff [0] ['sid'] . "_R" => array (
  4460. 'date' => date ( 'Y-m-d' ),
  4461. 'opinion' => $opinion,
  4462. 'status' => $status,
  4463. 'nextStaff' => $verifyDetail [0] [0],
  4464. 'ROLE' => 1
  4465. )
  4466. );
  4467. } else {
  4468. $nowStaff = $verifyDetail [1] [0];
  4469. $verifyStaff = array (
  4470. $this->staff [0] ['sid'] . "_R" => array (
  4471. 'date' => date ( 'Y-m-d' ),
  4472. 'opinion' => $opinion,
  4473. 'status' => $status,
  4474. 'nextStaff' => $verifyDetail [1] [0]
  4475. )
  4476. );
  4477. }
  4478. } else {
  4479. if ($verifyDetail [1] [1] == 'ROLE') {
  4480. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  4481. // echo "dd";
  4482. foreach ( $vStaffString as $key => $value ) {
  4483. $staffK = explode ( "_", $value );
  4484. array_push ( $nowStaffList, $staffK [0] );
  4485. }
  4486. $nowStaff = implode ( ',', $nowStaffList );
  4487. $verifyStaff = array (
  4488. $this->staff [0] ['sid'] => array (
  4489. 'date' => date ( 'Y-m-d' ),
  4490. 'opinion' => $opinion,
  4491. 'status' => $status,
  4492. 'nextStaff' => $verifyDetail [1] [0],
  4493. 'ROLE' => 1
  4494. )
  4495. );
  4496. } else {
  4497. $nowStaff = $verifyDetail [1] [0];
  4498. $verifyStaff = array (
  4499. $this->staff [0] ['sid'] => array (
  4500. 'date' => date ( 'Y-m-d' ),
  4501. 'opinion' => $opinion,
  4502. 'status' => $status,
  4503. 'nextStaff' => $verifyDetail [1] [0]
  4504. )
  4505. );
  4506. }
  4507. }
  4508. if ($status == 3)
  4509. $verifyStaff = array (
  4510. 'final' => $status,
  4511. $this->staff [0] ['sid'] => array (
  4512. 'date' => date ( 'Y-m-d' ),
  4513. 'opinion' => $opinion,
  4514. 'status' => $status
  4515. )
  4516. );
  4517. $vStaffString = json_encode ( $verifyStaff );
  4518. $receipt->nowStaff = $nowStaff;
  4519. $receipt->verifyStaff = $vStaffString;
  4520. $loanReceipt->nowStaff = $nowStaff;
  4521. $loanReceipt->verifyStaff = $vStaffString;
  4522. } else {
  4523. $VS = end ( $verifyStaff );
  4524. // 非角色审批
  4525. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  4526. $nextStaff = 0;
  4527. $roleSTF = false;
  4528. foreach ( $verifyDetail as $key => $value ) {
  4529. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  4530. if (isset ( $verifyDetail [$key + 1] )) {
  4531. $nextStaff = $verifyDetail [$key + 1] [0];
  4532. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  4533. $roleSTF = true;
  4534. }
  4535. break;
  4536. }
  4537. }
  4538. if (! $roleSTF) {
  4539. $nowStaff = $nextStaff;
  4540. $verifyStaff [$this->staff [0] ['sid']] = array (
  4541. 'date' => date ( 'Y-m-d' ),
  4542. 'opinion' => $opinion,
  4543. 'status' => $status,
  4544. 'nextStaff' => $nextStaff
  4545. );
  4546. } else {
  4547. // 获取角色下的所有用户ID
  4548. $nowStaffList = array ();
  4549. foreach ( $verifyDetail as $vfk ) {
  4550. if ($vfk [1] == 'ROLE') {
  4551. $vStaffString = json_decode ( $vfk [3] );
  4552. foreach ( $vStaffString as $key => $value ) {
  4553. $staffK = explode ( "_", $value );
  4554. array_push ( $nowStaffList, $staffK [0] );
  4555. }
  4556. }
  4557. }
  4558. $nowStaff = implode ( ',', $nowStaffList );
  4559. $verifyStaff [$this->staff [0] ['sid']] = array (
  4560. 'date' => date ( 'Y-m-d' ),
  4561. 'opinion' => $opinion,
  4562. 'status' => $status,
  4563. 'nextStaff' => $nextStaff,
  4564. 'ROLE' => 0
  4565. );
  4566. }
  4567. if ($status == 3) {
  4568. $verifyStaff ['final'] = $status;
  4569. $verifyStaff [$this->staff [0] ['sid']] = array (
  4570. 'date' => date ( 'Y-m-d' ),
  4571. 'opinion' => $opinion,
  4572. 'status' => $status
  4573. );
  4574. }
  4575. $vStaffString = json_encode ( $verifyStaff );
  4576. $receipt->nowStaff = $nowStaff;
  4577. $receipt->verifyStaff = $vStaffString;
  4578. $loanReceipt->nowStaff = $nowStaff;
  4579. $loanReceipt->verifyStaff = $vStaffString;
  4580. }
  4581. // 角色审批
  4582. if (isset ( $VS ['ROLE'] )) {
  4583. // 找出角色人 当前审批角色组
  4584. $verifyJSStaff = array ();
  4585. $nowStaffList2 = array ();
  4586. foreach ( $verifyDetail as $key => $value ) {
  4587. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  4588. $verifyJSStaff = json_decode ( $value [3] );
  4589. foreach ( $verifyJSStaff as $m ) {
  4590. $staffK = explode ( "_", $m );
  4591. array_push ( $nowStaffList2, $staffK [0] );
  4592. }
  4593. // print_r($nowStaffList2);
  4594. }
  4595. }
  4596. $RoleVerifyStaff = array ();
  4597. foreach ( $verifyStaff as $key => $value ) {
  4598. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  4599. foreach ( $nowStaffList2 as $m ) {
  4600. if ($key == $m . "_R")
  4601. $RoleVerifyStaff [$key] = $value;
  4602. }
  4603. }
  4604. }
  4605. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  4606. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  4607. // 下一个审批人ID
  4608. $nextStaff = 0;
  4609. $falg = false;
  4610. foreach ( $verifyDetail as $key => $value ) {
  4611. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  4612. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  4613. $falg = true;
  4614. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  4615. $nowStaffList = array ();
  4616. foreach ( $vStaffString as $v ) {
  4617. $staffK = explode ( "_", $v );
  4618. array_push ( $nowStaffList, $staffK [0] );
  4619. }
  4620. $nowStaff = implode ( ',', $nowStaffList );
  4621. $nextStaff = $verifyDetail [$key + 1] [0];
  4622. } elseif (isset ( $verifyDetail [$key + 1] )) {
  4623. $nextStaff = $verifyDetail [$key + 1] [0];
  4624. $nowStaff = $nextStaff;
  4625. } else
  4626. $nowStaff = '';
  4627. break;
  4628. }
  4629. }
  4630. if ($falg)
  4631. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  4632. 'date' => date ( 'Y-m-d' ),
  4633. 'opinion' => $opinion,
  4634. 'status' => $status,
  4635. 'nextStaff' => $nextStaff,
  4636. 'ROLE' => 1
  4637. );
  4638. else
  4639. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  4640. 'date' => date ( 'Y-m-d' ),
  4641. 'opinion' => $opinion,
  4642. 'status' => $status,
  4643. 'nextStaff' => $nextStaff
  4644. );
  4645. // print_r($verifyStaff);
  4646. // echo $nowStaff;die;
  4647. } else { // 进入下一个角色或者审批人
  4648. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  4649. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  4650. 'date' => date ( 'Y-m-d' ),
  4651. 'opinion' => $opinion,
  4652. 'status' => $status,
  4653. 'nextStaff' => $VS ['nextStaff'],
  4654. 'ROLE' => 1
  4655. );
  4656. }
  4657. if ($status == 3) {
  4658. $verifyStaff ['final'] = $status;
  4659. $verifyStaff [$this->staff [0] ['sid']] = array (
  4660. 'date' => date ( 'Y-m-d' ),
  4661. 'opinion' => $opinion,
  4662. 'status' => $status
  4663. );
  4664. }
  4665. $vStaffString = json_encode ( $verifyStaff );
  4666. $receipt->verifyStaff = $vStaffString;
  4667. $receipt->nowStaff = $nowStaff;
  4668. $loanReceipt->nowStaff = $nowStaff;
  4669. $loanReceipt->verifyStaff = $vStaffString;
  4670. }
  4671. // print_r($verifyStaff);die;
  4672. }
  4673. $roleKey = 0;
  4674. $roleId = 0;
  4675. $verifyDetailCopy = array ();
  4676. foreach ( $verifyDetail as $k => $v ) {
  4677. if ($v [1] == 'ROLE') {
  4678. $roleId = $v [0];
  4679. $roleVerify = json_decode ( $v [3], true );
  4680. $roleKey = $k;
  4681. $roleArray = array ();
  4682. foreach ( $roleVerify as $o => $p ) {
  4683. $staffID = explode ( '_', $p );
  4684. $exp = array (
  4685. 0 => $staffID [0],
  4686. 1 => $staffID [1]
  4687. );
  4688. array_push ( $roleArray, $exp );
  4689. }
  4690. $verifyDetailCopy [$v [0]] = $roleArray;
  4691. }
  4692. }
  4693. // print_r($verifyDetail);
  4694. foreach ( $verifyDetailCopy as $k => $v ) {
  4695. foreach ( $verifyDetail as $m => $n ) {
  4696. if ($n [0] == $k) {
  4697. array_splice ( $verifyDetail, $m, 1, $v );
  4698. }
  4699. }
  4700. }
  4701. // 审批日志
  4702. if (! isset ( $verifyStaff ['final'] )) {
  4703. Doo::loadModel ( "receiptLog" );
  4704. $receiptLog = new receiptLog ();
  4705. if (! empty ( $roleId )) {
  4706. Doo::loadModel ( "role" );
  4707. $role = new role ();
  4708. $roleInfo = $role->getOne ( array (
  4709. 'where' => 'rid=' . $roleId,
  4710. 'asArray' => true
  4711. ) );
  4712. $receiptLog->rolename = $roleInfo ['name'];
  4713. }
  4714. $receiptLog->username = $this->staff [0] ['username'];
  4715. $receiptLog->uid = $this->staff [0] ['sid'];
  4716. $receiptLog->date = date ( "Y-m-d" );
  4717. $receiptLog->opinion = $opinion;
  4718. $receiptLog->img = $this->staff [0] ['avatar'];
  4719. $receiptLog->status = 1;
  4720. $receiptLog->rid = $rid;
  4721. $receiptLog->insert ();
  4722. }
  4723. if (isset ( $verifyStaff ['final'] )) { // rDetail
  4724. $receipt->status = 3;
  4725. $receipt->verifyBreakup = $verifyString;
  4726. $receiptDetailObj->status = 3;
  4727. $receiptDetailObj->update ( array (
  4728. 'where' => 'rid=' . $rid
  4729. ) );
  4730. // 微信企业号通知
  4731. $this->setWXMsg ( $rid, 3 );
  4732. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  4733. $receipt->status = 6;
  4734. $receipt->pastDate = date ( "Y-m-d" );
  4735. $receipt->isBK = 1;
  4736. $loanReceipt->verifyBreakup = $verifyString;
  4737. $loanReceipt->status = 1;
  4738. $loanReceipt->pastDate = date ( "Y-m-d" );
  4739. //生成流水后 不更新汇款金额
  4740. Doo::loadModel ( 'wasteBook' );
  4741. $wasteBook = new wasteBook ();
  4742. $wbDetail = $wasteBook->getWateBookByAD ( 1, $rid );
  4743. if (empty($wbDetail)){
  4744. $loanReceipt->amount = $receiptDetail ['amount'];
  4745. }
  4746. $loanReceipt->update ( array (
  4747. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  4748. ) );
  4749. // 微信企业号通知
  4750. $this->setWXMsg ( $rid, 1 );
  4751. }
  4752. $receipt->amount = $receiptDetail['sum'];
  4753. $receipt->update ( array (
  4754. 'where' => ' rid = ' . $rid
  4755. ) );
  4756. // 进入下一条审批费用新加需求
  4757. $vidList = array ();
  4758. $verifyDetail = $verify->find ( array (
  4759. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  4760. 'asArray' => true
  4761. ) );
  4762. foreach ( $verifyDetail as $key => $value ) {
  4763. array_push ( $vidList, $value ['vid'] );
  4764. }
  4765. $vid = implode ( ",", $vidList );
  4766. if (empty ( $verifyDetail ))
  4767. $vid = 0;
  4768. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  4769. $receipt = new receipt ();
  4770. $rd = $receipt->getOne ( array (
  4771. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  4772. 'asc' => 'rid',
  4773. 'asArray' => true
  4774. ) );
  4775. if (empty ( $rd )) {
  4776. return '/approvalExpenses/pendApproval';
  4777. }
  4778. if ($rd ['Rtype'] == 1) {
  4779. if ($rd ['isBK'] == 1) {
  4780. return '/receiptburEdi/' . $rd ['rid'];
  4781. } else {
  4782. return '/expensesEdi/' . $rd ['rid'];
  4783. }
  4784. } elseif ($rd ['Rtype'] == 2) {
  4785. return '/remitApproval/' . $rd ['rid'];
  4786. } else {
  4787. return '/receiptburEdi/' . $rd ['rid'];
  4788. }
  4789. // return "/approvalExpenses/pendApproval";
  4790. }
  4791. }
  4792. function ajaxExamineExe() {
  4793. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4794. Doo::loadModel ( 'receipt' );
  4795. $receipt = new receipt ();
  4796. Doo::loadClass ( 'XDeode' );
  4797. $XDeode = new XDeode ( 5 );
  4798. if (! empty ( $rid )) {
  4799. $rLRes = $receipt->find ( array (
  4800. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  4801. 'asArray' => true
  4802. ) );
  4803. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  4804. echo json_encode ( array (
  4805. 'status' => 1,
  4806. 'receipt' => $rLRes [0]
  4807. ) );
  4808. die ();
  4809. }
  4810. echo json_encode ( array (
  4811. 'status' => 0,
  4812. 'receipt' => array ()
  4813. ) );
  4814. die ();
  4815. }
  4816. function implement() {
  4817. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4818. $Rtype = isset ( $this->params ['Rtype'] ) ? $this->params ['Rtype'] : '';
  4819. Doo::loadClass ( 'XDeode' );
  4820. $XDeode = new XDeode ( 5 );
  4821. Doo::loadModel ( 'receipt' );
  4822. $receipt = new receipt ();
  4823. Doo::loadModel ( 'L_category' );
  4824. $Lcategory = new L_category ();
  4825. Doo::loadModel ( 'verify' );
  4826. $verify = new verify ();
  4827. Doo::loadModel ( 'staff' );
  4828. $staff = new staff ();
  4829. Doo::loadModel ( "execute" );
  4830. $execute = new execute ();
  4831. $rid = $XDeode->decode ( $rid );
  4832. $receiptList = $receipt->find ( array (
  4833. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  4834. 'desc' => 'rid',
  4835. 'asArray' => true
  4836. ) );
  4837. Doo::loadModel ( 'loanReceipt' );
  4838. $loanReceipt = new loanReceipt ();
  4839. // print_r($receiptList);
  4840. $loanList = array ();
  4841. if (! isset ( $receiptList ))
  4842. $loanList = $loanReceipt->find ( array (
  4843. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4844. 'desc' => 'rid',
  4845. 'asArray' => true
  4846. ) );
  4847. $Locate = 0;
  4848. $roleId = 0;
  4849. $button = 0;
  4850. foreach ( $loanList as $key => $value ) {
  4851. $loanList [$key] ['Locate'] = $Locate;
  4852. $Locate ++;
  4853. $loanList [$key] ['reviseDetail'] = array ();
  4854. if (! empty ( $value ['reviseDetail'] ))
  4855. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4856. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4857. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4858. $categoryDetil = $Lcategory->getOne ( array (
  4859. 'where' => 'cid=' . $value ['cid'],
  4860. 'asArray' => true
  4861. ) );
  4862. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4863. // 检测编辑状态
  4864. $verifyList = $verify->getOne ( array (
  4865. 'where' => 'vid=' . $value ['verify'],
  4866. 'asArray' => true
  4867. ) );
  4868. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4869. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4870. Doo::loadModel ( 'role' );
  4871. $role = new role ();
  4872. $flag = true;
  4873. $roleKey = 0;
  4874. $endStaffArray = array ();
  4875. $roleArrayCopy = array ();
  4876. foreach ( $verifyList as $k => $v ) {
  4877. // init verifyStaff
  4878. if ($v [1] == 'ROLE') {
  4879. if (! empty ( $verifyStaff )) {
  4880. $endStaffArray = end ( $verifyStaff );
  4881. // if ($v[0]==$endStaffArray['nextStaff']){
  4882. // $roleId=$v[0];
  4883. // }
  4884. }
  4885. $roleVerify = json_decode ( $v [3], true );
  4886. $roleKey = $k;
  4887. $roleArray = array ();
  4888. $rolename = $role->getOne ( array (
  4889. 'where' => 'rid=' . $v [0],
  4890. 'asArray' => true
  4891. ) );
  4892. foreach ( $roleVerify as $o => $p ) {
  4893. $staffID = explode ( '_', $p );
  4894. $staffInfo = $staff->getOne ( array (
  4895. 'where' => 'sid=' . $staffID [0],
  4896. 'asArray' => true
  4897. ) );
  4898. // print_r($staffID);
  4899. $exp = array (
  4900. 0 => $staffInfo ['sid'],
  4901. 1 => $staffID [1],
  4902. 2 => $staffInfo ['avatar'],
  4903. 'date' => '',
  4904. 'date' => '',
  4905. 'opinion' => '',
  4906. 'status' => '',
  4907. 'rolename' => $rolename ['name']
  4908. );
  4909. array_push ( $roleArray, $exp );
  4910. }
  4911. $roleArrayCopy [$v [0]] = $roleArray;
  4912. // $verifyList[$k]['roleArray']=$roleArray;
  4913. }
  4914. $verifyList [$k] ['date'] = "";
  4915. $verifyList [$k] ['opinion'] = "";
  4916. $verifyList [$k] ['status'] = "";
  4917. if (empty ( $verifyStaff )) {
  4918. $verifyList [$k] ['date'] = "";
  4919. $verifyList [$k] ['opinion'] = "";
  4920. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4921. $verifyList [$k] ['status'] = 4;
  4922. $flag = false;
  4923. }
  4924. } else {
  4925. foreach ( $verifyStaff as $m => $u ) {
  4926. if ($v [0] == $m) {
  4927. $verifyList [$k] ['date'] = $u ['date'];
  4928. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4929. $verifyList [$k] ['status'] = $u ['status'];
  4930. $flag = false;
  4931. break;
  4932. }
  4933. }
  4934. $endStaffArray = end ( $verifyStaff );
  4935. if (isset ( $endStaffArray ['ROLE'] )) {
  4936. } else {
  4937. // $endKey=key($verifyStaff);
  4938. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4939. // $button=4;
  4940. // $verifyList[$k]['status']=4;
  4941. // }
  4942. }
  4943. }
  4944. }
  4945. $rolename ['name'] = '';
  4946. if (! empty ( $roleId )) {
  4947. Doo::loadModel ( 'role' );
  4948. $role = new role ();
  4949. $rolename = $role->getOne ( array (
  4950. 'where' => 'rid=' . $roleId,
  4951. 'asArray' => true
  4952. ) );
  4953. }
  4954. if (! empty ( $verifyStaff ))
  4955. $endStaffArray = end ( $verifyStaff );
  4956. $KOP = false;
  4957. foreach ( $roleArrayCopy as $P => $A ) {
  4958. foreach ( $A as $MKI => $AVL ) {
  4959. if (! empty ( $verifyStaff )) {
  4960. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4961. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4962. $button = 4;
  4963. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4964. }
  4965. foreach ( $verifyStaff as $m => $u ) {
  4966. $AVLFK = $AVL [0] . '_R';
  4967. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4968. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4969. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4970. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4971. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4972. break;
  4973. }
  4974. }
  4975. } else {
  4976. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4977. $button = 4;
  4978. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4979. }
  4980. }
  4981. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4982. $KOP = true;
  4983. }
  4984. }
  4985. foreach ( $roleArrayCopy as $k => $v ) {
  4986. foreach ( $verifyList as $m => $n ) {
  4987. if ($n [0] == $k) {
  4988. array_splice ( $verifyList, $m, 1, $v );
  4989. }
  4990. }
  4991. }
  4992. $loanList [$key] ['verifyList'] = $verifyList;
  4993. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  4994. 'where' => 'sid=' . $value ['staff'],
  4995. 'asArray' => true
  4996. ) );
  4997. }
  4998. $data ['loanList'] = $loanList;
  4999. $Locate = 0;
  5000. $roleId = 0;
  5001. $button = 0;
  5002. Doo::loadClass ( 'XDeode' );
  5003. $XDeode = new XDeode ( 5 );
  5004. foreach ( $receiptList as $key => $value ) {
  5005. $receiptList[$key]['ridKey']=$XDeode->encode ( $value['rid'] );
  5006. $button2 = 0;
  5007. $receiptList [$key] ['Locate'] = $Locate;
  5008. $Locate ++;
  5009. $receiptList [$key] ['reviseDetail'] = array ();
  5010. if (! empty ( $value ['reviseDetail'] ))
  5011. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5012. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5013. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5014. $categoryDetil = $Lcategory->getOne ( array (
  5015. 'where' => 'cid=' . $value ['cid'],
  5016. 'asArray' => true
  5017. ) );
  5018. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5019. $executeList = json_decode ( $value ['executeCopy'], true );
  5020. $executeStaff = array ();
  5021. if (! empty ( $value ['executeStaff'] ))
  5022. $executeStaff = json_decode ( $value ['executeStaff'], true );
  5023. if (isset ( $executeList )) {
  5024. foreach ( $executeList as $op => $lo ) {
  5025. $executeList [$op] ['date'] = "";
  5026. $executeList [$op] ['opinion'] = "";
  5027. $executeList [$op] ['status'] = "";
  5028. foreach ( $executeStaff as $m => $u ) {
  5029. if ($lo [0] == $m) {
  5030. $executeList [$op] ['date'] = $u ['date'];
  5031. $executeList [$op] ['opinion'] = $u ['opinion'];
  5032. $executeList [$op] ['status'] = $u ['status'];
  5033. break;
  5034. }
  5035. }
  5036. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  5037. $button2 = 1;
  5038. $executeList [$op] ['status'] = 4;
  5039. }
  5040. }
  5041. }
  5042. // 检测编辑状态
  5043. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  5044. $verifyList ['staff'] = $value ['verifyBreakup'];
  5045. } else
  5046. $verifyList = $verify->getOne ( array (
  5047. 'where' => 'vid=' . $value ['verify'],
  5048. 'asArray' => true
  5049. ) );
  5050. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5051. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5052. Doo::loadModel ( 'role' );
  5053. $role = new role ();
  5054. if ($verifyList == NULL)
  5055. $verifyList = array ();
  5056. $flag = true;
  5057. $roleKey = 0;
  5058. $endStaffArray = array ();
  5059. $roleArrayCopy = array ();
  5060. foreach ( $verifyList as $k => $v ) {
  5061. // init verifyStaff
  5062. if ($v [1] == 'ROLE') {
  5063. if (! empty ( $verifyStaff )) {
  5064. $endStaffArray = end ( $verifyStaff );
  5065. // if ($v[0]==$endStaffArray['nextStaff']){
  5066. // $roleId=$v[0];
  5067. // }
  5068. }
  5069. $roleVerify = json_decode ( $v [3], true );
  5070. $roleKey = $k;
  5071. $roleArray = array ();
  5072. $rolename = $role->getOne ( array (
  5073. 'where' => 'rid=' . $v [0],
  5074. 'asArray' => true
  5075. ) );
  5076. foreach ( $roleVerify as $o => $p ) {
  5077. $staffID = explode ( '_', $p );
  5078. $staffInfo = $staff->getOne ( array (
  5079. 'where' => 'sid=' . $staffID [0],
  5080. 'asArray' => true
  5081. ) );
  5082. // print_r($staffID);
  5083. $exp = array (
  5084. 0 => $staffInfo ['sid'],
  5085. 1 => $staffID [1],
  5086. 2 => $staffInfo ['avatar'],
  5087. 'date' => '',
  5088. 'date' => '',
  5089. 'opinion' => '',
  5090. 'status' => '',
  5091. 'rolename' => $rolename ['name']
  5092. );
  5093. array_push ( $roleArray, $exp );
  5094. }
  5095. $roleArrayCopy [$v [0]] = $roleArray;
  5096. // $verifyList[$k]['roleArray']=$roleArray;
  5097. }
  5098. $verifyList [$k] ['date'] = "";
  5099. $verifyList [$k] ['opinion'] = "";
  5100. $verifyList [$k] ['status'] = "";
  5101. if (empty ( $verifyStaff )) {
  5102. $verifyList [$k] ['date'] = "";
  5103. $verifyList [$k] ['opinion'] = "";
  5104. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5105. $verifyList [$k] ['status'] = 4;
  5106. $flag = false;
  5107. }
  5108. } else {
  5109. foreach ( $verifyStaff as $m => $u ) {
  5110. if ($v [0] == $m) {
  5111. $verifyList [$k] ['date'] = $u ['date'];
  5112. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5113. $verifyList [$k] ['status'] = $u ['status'];
  5114. $flag = false;
  5115. break;
  5116. }
  5117. }
  5118. $endStaffArray = end ( $verifyStaff );
  5119. if (isset ( $endStaffArray ['ROLE'] )) {
  5120. } else {
  5121. // $endKey=key($verifyStaff);
  5122. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5123. // $button=4;
  5124. // $verifyList[$k]['status']=4;
  5125. // }
  5126. }
  5127. }
  5128. }
  5129. $rolename ['name'] = '';
  5130. if (! empty ( $roleId )) {
  5131. Doo::loadModel ( 'role' );
  5132. $role = new role ();
  5133. $rolename = $role->getOne ( array (
  5134. 'where' => 'rid=' . $roleId,
  5135. 'asArray' => true
  5136. ) );
  5137. }
  5138. if (! empty ( $verifyStaff ))
  5139. $endStaffArray = end ( $verifyStaff );
  5140. $KOP = false;
  5141. foreach ( $roleArrayCopy as $P => $A ) {
  5142. foreach ( $A as $MKI => $AVL ) {
  5143. if (! empty ( $verifyStaff )) {
  5144. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5145. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5146. $button = 4;
  5147. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5148. }
  5149. foreach ( $verifyStaff as $m => $u ) {
  5150. $AVLFK = $AVL [0] . '_R';
  5151. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5152. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5153. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5154. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5155. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5156. break;
  5157. }
  5158. }
  5159. } else {
  5160. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5161. $button = 4;
  5162. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5163. }
  5164. }
  5165. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5166. $KOP = true;
  5167. }
  5168. }
  5169. foreach ( $roleArrayCopy as $k => $v ) {
  5170. foreach ( $verifyList as $m => $n ) {
  5171. if ($n [0] == $k) {
  5172. array_splice ( $verifyList, $m, 1, $v );
  5173. }
  5174. }
  5175. }
  5176. $receiptList [$key] ['verifyList'] = $verifyList;
  5177. $receiptList [$key] ['executeList'] = $executeList;
  5178. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5179. 'where' => 'sid=' . $value ['staff'],
  5180. 'asArray' => true
  5181. ) );
  5182. $receiptList [$key] ['button2'] = $button2;
  5183. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5184. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5185. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5186. $receiptList [$key] ['relust'] = $relust;
  5187. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  5188. $receiptList [$key] ['amountABS'] = abs ( $value ['amount'] );
  5189. }
  5190. //执行人是否是最后一位
  5191. $executeCopy = json_decode ( $receiptList [0] ['executeCopy'], true );
  5192. $executeStaff = json_decode ( $receiptList [0] ['executeStaff'], true );
  5193. $executePrimary=count($executeCopy)-1;
  5194. $lastOne=true;
  5195. if($executePrimary!=count($executeStaff)){
  5196. $lastOne=false;
  5197. }
  5198. $data['lastOne']=$lastOne;
  5199. // 是否写入过流水
  5200. $accountType = 0;
  5201. if ($receiptList [0] ['Rtype'] == 0) {
  5202. $accountType = 3;
  5203. } elseif ($receiptList [0] ['Rtype'] == 1) {
  5204. if (!empty($receiptList [0]['accountItem']) )
  5205. $accountType = 2;
  5206. else
  5207. $accountType = 1;
  5208. } elseif ($receiptList [0] ['Rtype'] == 2) {
  5209. $accountType = 4;
  5210. } elseif ($receiptList [0] ['Rtype'] == 3) {
  5211. $accountType = 12;
  5212. }
  5213. Doo::loadModel ( 'wasteBook' );
  5214. $wasteBook = new wasteBook ();
  5215. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $receiptList [0] ['rid'] );
  5216. $data ['wbDetail'] = $wbDetail;
  5217. $wbDetailLoan=array();
  5218. if ($accountType==2){
  5219. $wbDetailLoan = $wasteBook->getWateBookByAD ( 1, $receiptList [0] ['rid'] );
  5220. }
  5221. $data ['wbDetailLoan'] = $wbDetailLoan;
  5222. $data['inputDate']=date ( "Y-m-d H:i:s" );
  5223. //print_r($wbDetail);
  5224. $data ['receiptList'] = $receiptList;
  5225. $data ['memu'] = "receipt";
  5226. $data ['staff'] = $this->staff;
  5227. $data ['receiptMemu'] = 'implement';
  5228. $data ['verifyId'] = $this->verifyId;
  5229. $data ['executeId'] = $this->executeId;
  5230. if ($Rtype=="loan"){
  5231. $this->render ( "/receipt/receiptImplementLoan", $data );
  5232. }elseif($Rtype=="receipt"){
  5233. $this->render ( "/receipt/receiptImplement", $data );
  5234. }elseif($Rtype=="public"){
  5235. $this->render ( "/receipt/receiptImplementPublic", $data );
  5236. }else{
  5237. //$this->render ( "/admin/implement", $data );
  5238. }
  5239. }
  5240. function implementDo() {
  5241. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  5242. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  5243. // $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  5244. // $accountBank = $this->get_args ( 'accountBank' ) ? $this->get_args ( 'accountBank' ) : "";
  5245. // $ab = '';
  5246. // if ($accountBank == 'CGBDeposit')
  5247. // $ab = '纵横广发';
  5248. // elseif ($accountBank == 'ICBCDeposit')
  5249. // $ab = '纵横工行';
  5250. // elseif ($accountBank == 'HUADeposit')
  5251. // $ab = '华润银行';
  5252. // elseif ($accountBank == 'PersonalDeposit')
  5253. // $ab = '个人广发';
  5254. // if (empty ( $ab ))
  5255. // die ( 'illegal request--22' );
  5256. if (! empty ( $rid )) {
  5257. Doo::loadModel ( 'receipt' );
  5258. $receipt = new receipt ();
  5259. Doo::loadClass ( 'XDeode' );
  5260. $XDeode = new XDeode ( 5 );
  5261. $rid=$XDeode->decode($rid);
  5262. if (!is_numeric($rid)){
  5263. die;
  5264. }
  5265. // $rinfo = $receipt->getOne ( array (
  5266. // 'where' => 'rid=' . $rid,
  5267. // 'asArray' => true
  5268. // ) );
  5269. $rinfo = $receipt->getReceiptByRid ( $rid );
  5270. // $accountType = '';
  5271. // if ($rinfo ['Rtype'] == 1) {
  5272. // if ($rinfo ['loanRid'] != 0)//判断有问题
  5273. // $accountType = 2;
  5274. // else
  5275. // $accountType = 1;
  5276. // } elseif ($rinfo ['Rtype'] == 2) {
  5277. // $accountType = 4;
  5278. // } elseif ($rinfo ['Rtype'] == 0)
  5279. // $accountType = 3;
  5280. // if (empty ( $accountType ))
  5281. // die ( 'illegal request' );
  5282. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  5283. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  5284. if (empty ( $executeStaff )) {
  5285. $executeStaff = array (
  5286. $this->staff [0] ['sid'] => array (
  5287. 'date' => date ( 'Y-m-d' ),
  5288. 'opinion' => $implementOpinions,
  5289. 'status' => 1
  5290. )
  5291. );
  5292. } else {
  5293. $executeStaff [$this->staff [0] ['sid']] = array (
  5294. 'date' => date ( 'Y-m-d' ),
  5295. 'opinion' => $implementOpinions,
  5296. 'status' => 1
  5297. );
  5298. }
  5299. if (count ( $executeStaff ) == count ( $executeCopy )) {
  5300. $receipt->executeStaff = json_encode ( $executeStaff );
  5301. $receipt->status = 8;
  5302. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  5303. $receipt->status = 9;
  5304. if ($rinfo ['status'] == 6) {
  5305. $receipt->loanDate = date ( "Y-m-d" );
  5306. }
  5307. $receipt->executeDate = date ( "Y-m-d" );
  5308. } else {
  5309. $receipt->executeStaff = json_encode ( $executeStaff );
  5310. }
  5311. //$receipt->amount = $amount;
  5312. $receipt->update ( array (
  5313. 'where' => 'rid=' . $rid
  5314. ) );
  5315. // 公司流水记录
  5316. // Doo::loadModel ( 'wasteBook' );
  5317. // $wasteBook = new wasteBook ();
  5318. // $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountType, $rid );
  5319. // // 银行
  5320. // if (empty ( $abDetail ) && ! empty ( $amount )) {
  5321. // $item = array (
  5322. // 'dataID' => $rid,
  5323. // 'expensesType' => 2,
  5324. // 'accountType' => $accountType,
  5325. // 'accountPriceShow' => $amount,
  5326. // 'accountPrice' => - $amount,
  5327. // 'accountBank' => $accountBank,
  5328. // 'category' => $rinfo ['category'] [0] ['title'],
  5329. // 'cid' => $rinfo ['category'] [0] ['cid'],
  5330. // 'name' => $rinfo ['staffDetail'] ['username'],
  5331. // 'sid' => $rinfo ['staffDetail'] ['sid'],
  5332. // 'inputDate' => date ( "Y-m-d H:i:s" )
  5333. // );
  5334. // $wasteBook->setAccountBookStatistics ( $item );
  5335. // }
  5336. }
  5337. //$ridKey = $XDeode->encode ( $rid );
  5338. return "/hisImplement";
  5339. // return "/implement/" . $ridKey . ".html";
  5340. }
  5341. function receiptburEdi() {
  5342. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5343. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5344. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5345. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5346. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5347. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5348. if (empty ( $status ))
  5349. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5350. $vidList = array ();
  5351. $button = 0;
  5352. Doo::loadModel ( 'verify' );
  5353. Doo::loadModel ( 'receipt' );
  5354. Doo::loadModel ( 'staff' );
  5355. $staff = new staff ();
  5356. $receipt = new receipt ();
  5357. $verify = new verify ();
  5358. Doo::loadModel ( 'L_category' );
  5359. $Lcategory = new L_category ();
  5360. Doo::loadModel ( 'enclosur' );
  5361. $enclosur = new enclosur ();
  5362. Doo::loadModel ( 'loanReceipt' );
  5363. $loanReceipt = new loanReceipt ();
  5364. // user verify ID
  5365. $verifyDetail = $verify->find ( array (
  5366. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5367. 'asArray' => true
  5368. ) );
  5369. foreach ( $verifyDetail as $key => $value ) {
  5370. array_push ( $vidList, $value ['vid'] );
  5371. }
  5372. $vid = implode ( ",", $vidList );
  5373. if (empty ( $verifyDetail ))
  5374. $vid = 0;
  5375. $categoryList = $Lcategory->find ( array (
  5376. 'asArray' => true
  5377. ) );
  5378. $staffList = $staff->find ( array (
  5379. 'where' => 'cid=' . $cid,
  5380. 'asArray' => true
  5381. ) );
  5382. $ap = "";
  5383. if ($status == 4) {
  5384. $ap = 4;
  5385. $status = 2;
  5386. }
  5387. // get Receipt By verifyID status 2
  5388. $receiptList = $receipt->find ( array (
  5389. 'where' => 'rid =' . $rid . ' and status=2',
  5390. 'desc' => 'rid',
  5391. 'asArray' => true
  5392. ) );
  5393. if (empty ( $receiptList )) {
  5394. die ( 'illegal request' );
  5395. }
  5396. $loanList = $loanReceipt->find ( array (
  5397. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  5398. 'desc' => 'rid',
  5399. 'asArray' => true
  5400. ) );
  5401. $data ['explanation'] = '';
  5402. if (! empty ( $loanList ))
  5403. $data ['explanation'] = $loanList [0] ['explanation'];
  5404. $Locate = 0;
  5405. $roleId = 0;
  5406. $button = 0;
  5407. foreach ( $loanList as $key => $value ) {
  5408. $loanList [$key] ['Locate'] = $Locate;
  5409. $Locate ++;
  5410. $loanList [$key] ['reviseDetail'] = array ();
  5411. if (! empty ( $value ['reviseDetail'] ))
  5412. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5413. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5414. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5415. $categoryDetil = $Lcategory->getOne ( array (
  5416. 'where' => 'cid=' . $value ['cid'],
  5417. 'asArray' => true
  5418. ) );
  5419. $loanList [$key] ['category'] = $categoryDetil ['title'];
  5420. // 检测编辑状态
  5421. $verifyList = $verify->getOne ( array (
  5422. 'where' => 'vid=' . $value ['verify'],
  5423. 'asArray' => true
  5424. ) );
  5425. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5426. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5427. Doo::loadModel ( 'role' );
  5428. $role = new role ();
  5429. $flag = true;
  5430. $roleKey = 0;
  5431. $endStaffArray = array ();
  5432. $roleArrayCopy = array ();
  5433. foreach ( $verifyList as $k => $v ) {
  5434. // init verifyStaff
  5435. if ($v [1] == 'ROLE') {
  5436. if (! empty ( $verifyStaff )) {
  5437. $endStaffArray = end ( $verifyStaff );
  5438. }
  5439. $roleVerify = json_decode ( $v [3], true );
  5440. $roleKey = $k;
  5441. $roleArray = array ();
  5442. $rolename = $role->getOne ( array (
  5443. 'where' => 'rid=' . $v [0],
  5444. 'asArray' => true
  5445. ) );
  5446. foreach ( $roleVerify as $o => $p ) {
  5447. $staffID = explode ( '_', $p );
  5448. $staffInfo = $staff->getOne ( array (
  5449. 'where' => 'sid=' . $staffID [0],
  5450. 'asArray' => true
  5451. ) );
  5452. // print_r($staffID);
  5453. $exp = array (
  5454. 0 => $staffInfo ['sid'],
  5455. 1 => $staffID [1],
  5456. 2 => $staffInfo ['avatar'],
  5457. 'date' => '',
  5458. 'date' => '',
  5459. 'opinion' => '',
  5460. 'status' => '',
  5461. 'rolename' => $rolename ['name']
  5462. );
  5463. array_push ( $roleArray, $exp );
  5464. }
  5465. $roleArrayCopy [$v [0]] = $roleArray;
  5466. // $verifyList[$k]['roleArray']=$roleArray;
  5467. }
  5468. $verifyList [$k] ['date'] = "";
  5469. $verifyList [$k] ['opinion'] = "";
  5470. $verifyList [$k] ['status'] = "";
  5471. if (empty ( $verifyStaff )) {
  5472. $verifyList [$k] ['date'] = "";
  5473. $verifyList [$k] ['opinion'] = "";
  5474. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5475. $verifyList [$k] ['status'] = 4;
  5476. $flag = false;
  5477. }
  5478. } else {
  5479. foreach ( $verifyStaff as $m => $u ) {
  5480. if ($v [0] == $m) {
  5481. $verifyList [$k] ['date'] = $u ['date'];
  5482. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5483. $verifyList [$k] ['status'] = $u ['status'];
  5484. $flag = false;
  5485. break;
  5486. }
  5487. }
  5488. $endStaffArray = end ( $verifyStaff );
  5489. if (isset ( $endStaffArray ['ROLE'] )) {
  5490. } else {
  5491. }
  5492. }
  5493. }
  5494. $rolename ['name'] = '';
  5495. if (! empty ( $roleId )) {
  5496. Doo::loadModel ( 'role' );
  5497. $role = new role ();
  5498. $rolename = $role->getOne ( array (
  5499. 'where' => 'rid=' . $roleId,
  5500. 'asArray' => true
  5501. ) );
  5502. }
  5503. if (! empty ( $verifyStaff ))
  5504. $endStaffArray = end ( $verifyStaff );
  5505. $KOP = false;
  5506. foreach ( $roleArrayCopy as $P => $A ) {
  5507. foreach ( $A as $MKI => $AVL ) {
  5508. if (! empty ( $verifyStaff )) {
  5509. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5510. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5511. $button = 4;
  5512. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5513. }
  5514. foreach ( $verifyStaff as $m => $u ) {
  5515. $AVLFK = $AVL [0] . '_R';
  5516. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5517. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5518. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5519. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5520. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5521. break;
  5522. }
  5523. }
  5524. } else {
  5525. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5526. $button = 4;
  5527. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5528. }
  5529. }
  5530. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5531. $KOP = true;
  5532. }
  5533. }
  5534. foreach ( $roleArrayCopy as $k => $v ) {
  5535. foreach ( $verifyList as $m => $n ) {
  5536. if ($n [0] == $k) {
  5537. array_splice ( $verifyList, $m, 1, $v );
  5538. }
  5539. }
  5540. }
  5541. $loanList [$key] ['verifyList'] = $verifyList;
  5542. }
  5543. $htmlLoan = '';
  5544. $data ['loanReceiptDate'] = '';
  5545. if (isset ( $loanList [0] )) {
  5546. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  5547. if ($value ['status'] == 1)
  5548. $htmlLoan .= '<li class="done" >';
  5549. elseif ($value ['status'] == 3)
  5550. $htmlLoan .= '<li class="undone" >';
  5551. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  5552. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  5553. if (isset ( $value ['rolename'] ))
  5554. $htmlLoan .= $value ['rolename'];
  5555. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  5556. }
  5557. $data ['loanDate'] = $loanList [0] ['date'];
  5558. } else {
  5559. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  5560. }
  5561. $data ['htmlLoan'] = $htmlLoan;
  5562. // $data ['LoanReceipt']=$loanList[0];
  5563. // print_r($loanList);
  5564. $Locate = 0;
  5565. $roleId = 0;
  5566. $button = 0;
  5567. if ($ap == 4)
  5568. $status = 4;
  5569. Doo::loadClass ( 'XDeode' );
  5570. $XDeode = new XDeode ( 5 );
  5571. foreach ( $receiptList as $key => $value ) {
  5572. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  5573. $receiptList [$key] ['Locate'] = $Locate;
  5574. $Locate ++;
  5575. $receiptList [$key] ['reviseDetail'] = array ();
  5576. // 调整金额 代码调整
  5577. if (! empty ( $value ['reviseDetail'] )) {
  5578. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  5579. foreach ( $reviseDetail as $ry => $re ) {
  5580. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  5581. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  5582. }
  5583. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  5584. // print_r($reviseDetail);
  5585. }
  5586. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5587. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5588. $categoryDetil = $Lcategory->getOne ( array (
  5589. 'where' => 'cid=' . $value ['cid'],
  5590. 'asArray' => true
  5591. ) );
  5592. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5593. // 检测编辑状态
  5594. $verifyList = $verify->getOne ( array (
  5595. 'where' => 'vid=' . $value ['verify'],
  5596. 'asArray' => true
  5597. ) );
  5598. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5599. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5600. Doo::loadModel ( 'role' );
  5601. $role = new role ();
  5602. // print_r($verifyList);
  5603. $flag = true;
  5604. $roleKey = 0;
  5605. $endStaffArray = array ();
  5606. $roleArrayCopy = array ();
  5607. foreach ( $verifyList as $k => $v ) {
  5608. // init verifyStaff
  5609. if ($v [1] == 'ROLE') {
  5610. if (! empty ( $verifyStaff )) {
  5611. $endStaffArray = end ( $verifyStaff );
  5612. if ($v [0] == $endStaffArray ['nextStaff']) {
  5613. $roleId = $v [0];
  5614. }
  5615. }
  5616. $roleVerify = json_decode ( $v [3], true );
  5617. $roleKey = $k;
  5618. $roleArray = array ();
  5619. $rolename = $role->getOne ( array (
  5620. 'where' => 'rid=' . $v [0],
  5621. 'asArray' => true
  5622. ) );
  5623. foreach ( $roleVerify as $o => $p ) {
  5624. $staffID = explode ( '_', $p );
  5625. $staffInfo = $staff->getOne ( array (
  5626. 'where' => 'sid=' . $staffID [0],
  5627. 'asArray' => true
  5628. ) );
  5629. // print_r($staffID);
  5630. $exp = array (
  5631. 0 => $staffInfo ['sid'],
  5632. 1 => $staffID [1],
  5633. 2 => $staffInfo ['avatar'],
  5634. 'date' => '',
  5635. 'date' => '',
  5636. 'opinion' => '',
  5637. 'status' => '',
  5638. 'rolename' => $rolename ['name']
  5639. );
  5640. array_push ( $roleArray, $exp );
  5641. }
  5642. $roleArrayCopy [$v [0]] = $roleArray;
  5643. // $verifyList[$k]['roleArray']=$roleArray;
  5644. }
  5645. // print_r($roleArray);
  5646. $verifyList [$k] ['date'] = "";
  5647. $verifyList [$k] ['opinion'] = "";
  5648. $verifyList [$k] ['status'] = "";
  5649. if (empty ( $verifyStaff )) {
  5650. $verifyList [$k] ['date'] = "";
  5651. $verifyList [$k] ['opinion'] = "";
  5652. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5653. $verifyList [$k] ['status'] = 4;
  5654. $button = 4;
  5655. $flag = false;
  5656. }
  5657. } else {
  5658. foreach ( $verifyStaff as $m => $u ) {
  5659. if ($v [0] == $m) {
  5660. $verifyList [$k] ['date'] = $u ['date'];
  5661. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5662. $verifyList [$k] ['status'] = $u ['status'];
  5663. $flag = false;
  5664. break;
  5665. }
  5666. }
  5667. $endStaffArray = end ( $verifyStaff );
  5668. if (isset ( $endStaffArray ['ROLE'] )) {
  5669. } else {
  5670. $endKey = key ( $verifyStaff );
  5671. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5672. $button = 4;
  5673. $verifyList [$k] ['status'] = 4;
  5674. }
  5675. }
  5676. }
  5677. }
  5678. $rolename ['name'] = '';
  5679. if (! empty ( $roleId )) {
  5680. Doo::loadModel ( 'role' );
  5681. $role = new role ();
  5682. $rolename = $role->getOne ( array (
  5683. 'where' => 'rid=' . $roleId,
  5684. 'asArray' => true
  5685. ) );
  5686. }
  5687. if (! empty ( $verifyStaff ))
  5688. $endStaffArray = end ( $verifyStaff );
  5689. $KOP = false;
  5690. foreach ( $roleArrayCopy as $P => $A ) {
  5691. foreach ( $A as $MKI => $AVL ) {
  5692. if (! empty ( $verifyStaff )) {
  5693. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5694. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5695. $button = 4;
  5696. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5697. }
  5698. foreach ( $verifyStaff as $m => $u ) {
  5699. $AVLFK = $AVL [0] . '_R';
  5700. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5701. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5702. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5703. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5704. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5705. break;
  5706. }
  5707. }
  5708. } else {
  5709. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5710. $button = 4;
  5711. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5712. }
  5713. }
  5714. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5715. $KOP = true;
  5716. }
  5717. }
  5718. foreach ( $roleArrayCopy as $k => $v ) {
  5719. foreach ( $verifyList as $m => $n ) {
  5720. if ($n [0] == $k) {
  5721. array_splice ( $verifyList, $m, 1, $v );
  5722. }
  5723. }
  5724. }
  5725. // print_r($verifyList);
  5726. $receiptList [$key] ['verifyList'] = $verifyList;
  5727. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5728. 'where' => 'sid=' . $value ['staff'],
  5729. 'asArray' => true
  5730. ) );
  5731. $receiptList [$key] ['button'] = $button;
  5732. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5733. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5734. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5735. $receiptList [$key] ['relust'] = $relust;
  5736. $receiptList [$key] ['relustABS'] = abs ( $relust );
  5737. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  5738. }
  5739. //print_r($receiptList);die;
  5740. // $data['verifyDetail']=$verifyDetail;
  5741. $mothHtml = "";
  5742. for($i = 1; $i <= 12; $i ++) {
  5743. if ($month == $i)
  5744. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5745. else
  5746. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5747. }
  5748. // 获取审批日志
  5749. Doo::loadModel ( 'receiptLog' );
  5750. $receiptLog = new receiptLog ();
  5751. $rlList = array ();
  5752. $rlInfo = $receiptLog->getOne ( array (
  5753. 'where' => 'rid=' . $rid . ' and status=4',
  5754. 'asArray' => true
  5755. ) );
  5756. $tijdate = $receiptLog->getOne ( array (
  5757. 'where' => 'rid=' . $rid . ' and status=2',
  5758. 'asc' => 'rlid',
  5759. 'asArray' => true
  5760. ) );
  5761. if (! empty ( $rlInfo )) {
  5762. $rlList = $receiptLog->find ( array (
  5763. 'where' => 'rid=' . $rid,
  5764. 'asc' => 'rlid',
  5765. 'asArray' => true
  5766. ) );
  5767. }
  5768. // echo $rid;
  5769. // print_r($receiptList);
  5770. $receiptList [0] ['rlList'] = $rlList;
  5771. // print_r($receiptList);
  5772. $enclosurList = $enclosur->find ( array (
  5773. 'where' => 'rid=' . $rid,
  5774. 'asArray' => true
  5775. ) );
  5776. $enclosurHtml = '';
  5777. foreach ( $enclosurList as $value ) {
  5778. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5779. }
  5780. $data ['enclosurHtml'] = $enclosurHtml;
  5781. $data ['rolename'] = $rolename ['name'];
  5782. $data ['mothHtml'] = $mothHtml;
  5783. // print_r($receiptList);
  5784. $data ['rid'] = $rid;
  5785. $data ['tijdate'] = $tijdate ['date'];
  5786. $data ['receiptList'] = $receiptList;
  5787. $data ['receiptApprovalCount'] = count ( $receiptList );
  5788. $data ['status'] = $status;
  5789. $data ['year'] = $year;
  5790. $data ['categoryList'] = $categoryList;
  5791. $data ['staffList'] = $staffList;
  5792. $data ['cid'] = $cid;
  5793. $data ['sid'] = $sid;
  5794. $data ['ap'] = $ap;
  5795. $data ['memu'] = "receipt";
  5796. $data ['staff'] = $this->staff;
  5797. $data ['receiptMemu'] = 'approvalExpenses';
  5798. $data ['verifyId'] = $this->verifyId;
  5799. $data ['executeId'] = $this->executeId;
  5800. $this->render ( "/admin/receiptburEdi", $data );
  5801. }
  5802. function hisImplement() {
  5803. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  5804. if (empty ( $item ))
  5805. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  5806. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  5807. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  5808. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  5809. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  5810. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  5811. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  5812. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  5813. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  5814. Doo::loadClass ( 'XDeode' );
  5815. $XDeode = new XDeode ( 5 );
  5816. Doo::loadModel ( 'receipt' );
  5817. $receipt = new receipt ();
  5818. Doo::loadModel ( 'L_category' );
  5819. $Lcategory = new L_category ();
  5820. Doo::loadModel ( 'verify' );
  5821. Doo::loadModel ( 'statistics' );
  5822. $statistics = new statistics ();
  5823. $verify = new verify ();
  5824. Doo::loadModel ( 'staff' );
  5825. $staff = new staff ();
  5826. Doo::loadClass ( 'XDeode' );
  5827. $XDeode = new XDeode ( 5 );
  5828. $XDeode7 = new XDeode ( 7 );
  5829. $cid = $XDeode->decode ( $cidKey );
  5830. $condition = "";
  5831. if ($item == "expenses")
  5832. $condition = " and Rtype=1 ";
  5833. elseif ($item == "receipts")
  5834. $condition = " and Rtype=0 ";
  5835. elseif ($item == "remits")
  5836. $condition = " and Rtype=2 ";
  5837. elseif($item == "train")
  5838. $condition = " and Rtype=3 ";
  5839. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  5840. $sopString = $cidString = "";
  5841. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  5842. if (empty ( $rdate ))
  5843. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  5844. else
  5845. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  5846. if ($status == 'pendImplement') {
  5847. $condition .= ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  5848. } elseif ($status == 'alerpts') {
  5849. $statusCon = '(status=8 or status=9 )';
  5850. if (empty ( $rdate ))
  5851. $dateCondition .= " and Year(date) =" . $year;
  5852. else
  5853. $dateCondition .= " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  5854. }
  5855. if ($sop != 'SOP')
  5856. $sopString = " and staff=" . $sop;
  5857. if ($cidKey != 'ALL')
  5858. $cidString = " and cid=" . $cid;
  5859. //汇款信息需要提取出来
  5860. if(!empty($receiptOrder)){
  5861. $receiptList = $receipt->find ( array (
  5862. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  5863. 'desc' => 'rid',
  5864. 'asArray' => true
  5865. ) );
  5866. // 员工筛选
  5867. $receiptList2 = $receipt->find ( array (
  5868. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  5869. 'desc' => 'rid',
  5870. 'asArray' => true
  5871. ) );
  5872. }else{
  5873. $receiptList = $receipt->find ( array (
  5874. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  5875. 'desc' => 'rid',
  5876. 'asArray' => true
  5877. ) );
  5878. // 员工筛选
  5879. $receiptList2 = $receipt->find ( array (
  5880. 'where' => $statusCon . $condition . $dateCondition,
  5881. 'desc' => 'rid',
  5882. 'asArray' => true
  5883. ) );
  5884. }
  5885. $sopStaff = array ();
  5886. foreach ( $receiptList2 as $key => $value ) {
  5887. $staffDetail = $staff->getOne ( array (
  5888. 'select' => 'username',
  5889. 'where' => 'sid=' . $value ['staff'],
  5890. 'asArray' => true
  5891. ) );
  5892. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  5893. }
  5894. // 办事处筛选
  5895. $categoryScreen = array ();
  5896. $categorList = $Lcategory->getCategory ();
  5897. foreach ( $receiptList2 as $key => $value ) {
  5898. foreach ( $categorList as $k => $v ) {
  5899. if ($value ['cid'] == $v ['cid']) {
  5900. $categoryScreen [$v ['cidKey']] = $v ['title'];
  5901. break;
  5902. }
  5903. }
  5904. }
  5905. $categoryScreenHtml = "";
  5906. foreach ( $categoryScreen as $key => $value ) {
  5907. if ($cidKey == $key)
  5908. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  5909. else
  5910. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  5911. }
  5912. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  5913. $data ['cidKey'] = $cidKey;
  5914. $Locate = 0;
  5915. $roleId = 0;
  5916. $button = 0;
  5917. $staffBatchNumber = 100001;
  5918. $remittanceList = array ();
  5919. foreach ( $receiptList as $key => $value ) {
  5920. $receiptList [$key] ['ridKey7'] = $XDeode7->encode ( $value ['rid'] );
  5921. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  5922. $receiptList [$key] ['Texe'] = 'false';
  5923. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  5924. $receiptList [$key] ['Texe'] = 'true';
  5925. }
  5926. $receiptList [$key] ['TRexe'] = 'true';
  5927. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  5928. $receiptList [$key] ['TRexe'] = 'false';
  5929. }
  5930. $receiptList [$key] ['Locate'] = $Locate;
  5931. $Locate ++;
  5932. $receiptList [$key] ['reviseDetail'] = array ();
  5933. if (! empty ( $value ['reviseDetail'] ))
  5934. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5935. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5936. $categoryDetil = $Lcategory->getOne ( array (
  5937. 'where' => 'cid=' . $value ['cid'],
  5938. 'asArray' => true
  5939. ) );
  5940. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5941. // 检测编辑状态
  5942. $verifyList = $verify->getOne ( array (
  5943. 'where' => 'vid=' . $value ['verify'],
  5944. 'asArray' => true
  5945. ) );
  5946. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5947. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5948. Doo::loadModel ( 'role' );
  5949. $role = new role ();
  5950. $flag = true;
  5951. $roleKey = 0;
  5952. $endStaffArray = array ();
  5953. $roleArrayCopy = array ();
  5954. foreach ( $verifyList as $k => $v ) {
  5955. // init verifyStaff
  5956. if ($v [1] == 'ROLE') {
  5957. if (! empty ( $verifyStaff )) {
  5958. $endStaffArray = end ( $verifyStaff );
  5959. }
  5960. $roleVerify = json_decode ( $v [3], true );
  5961. $roleKey = $k;
  5962. $roleArray = array ();
  5963. $rolename = $role->getOne ( array (
  5964. 'where' => 'rid=' . $v [0],
  5965. 'asArray' => true
  5966. ) );
  5967. foreach ( $roleVerify as $o => $p ) {
  5968. $staffID = explode ( '_', $p );
  5969. $staffInfo = $staff->getOne ( array (
  5970. 'where' => 'sid=' . $staffID [0],
  5971. 'asArray' => true
  5972. ) );
  5973. $exp = array (
  5974. 0 => $staffInfo ['sid'],
  5975. 1 => $staffID [1],
  5976. 2 => $staffInfo ['avatar'],
  5977. 'date' => '',
  5978. 'date' => '',
  5979. 'opinion' => '',
  5980. 'status' => '',
  5981. 'rolename' => $rolename ['name']
  5982. );
  5983. array_push ( $roleArray, $exp );
  5984. }
  5985. $roleArrayCopy [$v [0]] = $roleArray;
  5986. }
  5987. $verifyList [$k] ['date'] = "";
  5988. $verifyList [$k] ['opinion'] = "";
  5989. $verifyList [$k] ['status'] = "";
  5990. if (empty ( $verifyStaff )) {
  5991. $verifyList [$k] ['date'] = "";
  5992. $verifyList [$k] ['opinion'] = "";
  5993. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5994. $verifyList [$k] ['status'] = 4;
  5995. $flag = false;
  5996. }
  5997. } else {
  5998. foreach ( $verifyStaff as $m => $u ) {
  5999. if ($v [0] == $m) {
  6000. $verifyList [$k] ['date'] = $u ['date'];
  6001. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6002. $verifyList [$k] ['status'] = $u ['status'];
  6003. $flag = false;
  6004. break;
  6005. }
  6006. }
  6007. $endStaffArray = end ( $verifyStaff );
  6008. }
  6009. }
  6010. $rolename ['name'] = '';
  6011. if (! empty ( $roleId )) {
  6012. Doo::loadModel ( 'role' );
  6013. $role = new role ();
  6014. $rolename = $role->getOne ( array (
  6015. 'where' => 'rid=' . $roleId,
  6016. 'asArray' => true
  6017. ) );
  6018. }
  6019. if (! empty ( $verifyStaff ))
  6020. $endStaffArray = end ( $verifyStaff );
  6021. $KOP = false;
  6022. foreach ( $roleArrayCopy as $P => $A ) {
  6023. foreach ( $A as $MKI => $AVL ) {
  6024. if (! empty ( $verifyStaff )) {
  6025. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6026. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6027. $button = 4;
  6028. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6029. }
  6030. foreach ( $verifyStaff as $m => $u ) {
  6031. $AVLFK = $AVL [0] . '_R';
  6032. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6033. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6034. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6035. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6036. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6037. break;
  6038. }
  6039. }
  6040. } else {
  6041. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6042. $button = 4;
  6043. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6044. }
  6045. }
  6046. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6047. $KOP = true;
  6048. }
  6049. }
  6050. foreach ( $roleArrayCopy as $k => $v ) {
  6051. foreach ( $verifyList as $m => $n ) {
  6052. if ($n [0] == $k) {
  6053. array_splice ( $verifyList, $m, 1, $v );
  6054. }
  6055. }
  6056. }
  6057. $receiptList [$key] ['verifyList'] = $verifyList;
  6058. $staffDetail = $staff->getOne ( array (
  6059. 'where' => 'sid=' . $value ['staff'],
  6060. 'asArray' => true
  6061. ) );
  6062. $receiptList [$key] ['staffDetail'] = $staffDetail;
  6063. $receiptList [$key] ['button'] = $button;
  6064. if ($value['Rtype']==1){
  6065. $receiptList [$key] ['relust'] = $value['sum']-$value['loanSum'];
  6066. $receiptList [$key] ['relustABS'] = abs($receiptList [$key] ['relust']);
  6067. }elseif($value['Rtype']==3){
  6068. // 收入合计
  6069. Doo::loadModel ( 'invoiceTraining' );
  6070. $invoiceTraining = new invoiceTraining ();
  6071. $invoiceTrainingDetail = array (
  6072. 'invoiceArriveAmount' => '0.00',
  6073. 'RIAmount' => '0.00',
  6074. 'invoiceTotalAmount' => '0.00',
  6075. 'invoiceCompanyAmount' => '0.00',
  6076. 'invoiceArriveAmountM'=>'0.00',
  6077. 'invoiceCompanyAmountM'=>'0.00'
  6078. );
  6079. if ($value ['invoiceTrainId'] != 0) {
  6080. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $value['invoiceTrainId'] );
  6081. }
  6082. $invoiceArriveAmount = $RIAmount = 0;
  6083. if (! empty ( $invoiceTrainingDetail )) {
  6084. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  6085. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  6086. }
  6087. // 备用金
  6088. $sum = 0;
  6089. if (! empty ( $value ['trainLoanRid'] )) {
  6090. $receiptLoanList = $receipt->getReceiptInRid ( $value ['trainLoanRid'] );
  6091. foreach ($receiptLoanList as $kll=>$vll){
  6092. $sum+=$vll['sum'];
  6093. }
  6094. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $value ['trainLoanRid'] );
  6095. // $sum = $receiptLoanDetailBak ['sum'];
  6096. }
  6097. // 支出项金额详情
  6098. // 项目金额合计
  6099. Doo::loadModel ( 'RItem' );
  6100. $RItem = new RItem ();
  6101. Doo::loadModel ( 'accountItem' );
  6102. $accountItem = new accountItem ();
  6103. // 讲师获得
  6104. Doo::loadModel ( 'RILecturer' );
  6105. $RILecturer = new RILecturer ();
  6106. $RItemList = $RItem->getRItemByRid ( $value['rid'] );
  6107. $RILecturerList = $RILecturer->getRILecturerByRid ( $value['rid'] );
  6108. // 支出项金额详情
  6109. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  6110. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  6111. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  6112. $receiptList [$key] ['payment'] =$payment;
  6113. $receiptList [$key] ['paymentABS'] =sprintf("%.2f",abs($payment));
  6114. }
  6115. // 设置导出汇款execl
  6116. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  6117. $remittanceDetail = array (
  6118. $staffBatchNumber,
  6119. $value ['remittanceName'],
  6120. $value ['bankNumber'],
  6121. $value ['bankName'],
  6122. $value ['remittanceBankType'],
  6123. $value ['coupletNumber'],
  6124. $value ['sum']
  6125. );
  6126. array_push ( $remittanceList, $remittanceDetail );
  6127. $staffBatchNumber ++;
  6128. }
  6129. }
  6130. $data ['remittanceList'] = json_encode ( $remittanceList );
  6131. // print_r($receiptList);
  6132. $mothHtml = "";
  6133. for($i = 1; $i <= 12; $i ++) {
  6134. if ($moth == $i)
  6135. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6136. else
  6137. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6138. }
  6139. $dayHtml = "";
  6140. if ($day != "DAY" || $moth != "MONTH") {
  6141. for($i = 1; $i <= 31; $i ++) {
  6142. if ($day == $i)
  6143. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6144. else
  6145. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6146. }
  6147. }
  6148. $sopHtml = "";
  6149. foreach ( $sopStaff as $key => $value ) {
  6150. if ($sop == $key)
  6151. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  6152. else
  6153. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  6154. }
  6155. $data ['status'] = $status;
  6156. $data ['rdate'] = $rdate;
  6157. $data ['sopHtml'] = $sopHtml;
  6158. $data ['dayHtml'] = $dayHtml;
  6159. $data ['mothHtml'] = $mothHtml;
  6160. $data ['receiptList'] = $receiptList;
  6161. $data ['memu'] = "receipt";
  6162. $data ['staff'] = $this->staff;
  6163. $data ['receiptMemu'] = 'implement';
  6164. $data ['verifyId'] = $this->verifyId;
  6165. $data ['executeId'] = $this->executeId;
  6166. $data ['item'] = $item;
  6167. $data ['year'] = $year;
  6168. $data ['moth'] = $moth;
  6169. $data['receiptOrder']=$receiptOrder;
  6170. $data ['day'] = $day;
  6171. $data ['sop'] = $sop;
  6172. $this->render ( "/admin/hisImplement", $data );
  6173. }
  6174. /**
  6175. * 导出汇款信息的exelc
  6176. */
  6177. function exportRemittance() {
  6178. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  6179. if (empty ( $remittanceInfo ))
  6180. die ( 'illegal request' );
  6181. $title = array (
  6182. '员工编号',
  6183. '姓名',
  6184. '员工账号',
  6185. '员工账户开户行',
  6186. '转账类型',
  6187. '联行号',
  6188. '金额'
  6189. );
  6190. $data = json_decode ( $remittanceInfo, true );
  6191. if (empty ( $data ))
  6192. die ( 'illegal request' );
  6193. Doo::loadClass ( 'receipt.func' );
  6194. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  6195. header ( 'Content-Type:text/html;charset=utf-8' );
  6196. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  6197. }
  6198. function ajaxExamine() {
  6199. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6200. Doo::loadModel ( 'receipt' );
  6201. $receipt = new receipt ();
  6202. if (! empty ( $rid )) {
  6203. $rLRes = $receipt->find ( array (
  6204. 'where' => 'status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) and rid!=' . $rid,
  6205. 'asArray' => true
  6206. ) );
  6207. if(!empty($rLRes)){
  6208. Doo::loadClass ( 'XDeode' );
  6209. $XDeode = new XDeode ( 7 );
  6210. $rLRes [0]['ridKey'] = $XDeode->encode( $rLRes [0]['rid'] );
  6211. echo json_encode ( array (
  6212. 'status' => 1,
  6213. 'receipt' => $rLRes [0]
  6214. ) );
  6215. die ();
  6216. }else{
  6217. echo json_encode ( array (
  6218. 'status' => 1,
  6219. 'receipt' => array ()
  6220. ) );
  6221. die ();
  6222. }
  6223. }
  6224. echo json_encode ( array (
  6225. 'status' => 0,
  6226. 'receipt' => array ()
  6227. ) );
  6228. die ();
  6229. }
  6230. /*
  6231. * 废弃
  6232. */
  6233. function myReceipt() {
  6234. // all approval past withdraw
  6235. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  6236. if (empty ( $item ))
  6237. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  6238. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6239. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  6240. Doo::loadModel ( 'receipt' );
  6241. $receipt = new receipt ();
  6242. // pre-loaded
  6243. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  6244. // have cache
  6245. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  6246. if (! empty ( $moth )) // yearPage
  6247. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  6248. $this->showCache ( $path );
  6249. }
  6250. Doo::loadModel ( 'L_category' );
  6251. $Lcategory = new L_category ();
  6252. Doo::loadModel ( 'verify' );
  6253. Doo::loadModel ( 'statistics' );
  6254. $statistics = new statistics ();
  6255. $verify = new verify ();
  6256. Doo::loadModel ( 'staff' );
  6257. $staff = new staff ();
  6258. $condition = " and status!=0 ";
  6259. if ($item == "approval")
  6260. $condition = " and status=2 ";
  6261. elseif ($item == "withdraw")
  6262. $condition = " and status=3 ";
  6263. elseif ($item == "past")
  6264. $condition = " and status=1 ";
  6265. elseif ($item == "whdw")
  6266. $condition = " and status=4 ";
  6267. $dateCondition = " and Year(date) =" . $year;
  6268. if (! empty ( $moth )) {
  6269. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  6270. $stList = $statistics->getOne ( array (
  6271. 'select' => 'rePrice ,agPrice',
  6272. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  6273. 'asArray' => true
  6274. ) );
  6275. } else
  6276. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  6277. if (empty ( $stList ))
  6278. $stList = array (
  6279. 'rePrice' => 0,
  6280. 'agPrice' => 0
  6281. );
  6282. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  6283. $data ['stList'] = array (
  6284. 'rePrice' => $stList ['rePrice'],
  6285. 'agPrice' => $stList ['agPrice'],
  6286. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  6287. );
  6288. $receiptList = $receipt->find ( array (
  6289. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  6290. 'desc' => 'rid',
  6291. 'asArray' => true
  6292. ) );
  6293. $Locate = 0;
  6294. $roleId = 0;
  6295. $button = 0;
  6296. foreach ( $receiptList as $key => $value ) {
  6297. $receiptList [$key] ['Locate'] = $Locate;
  6298. $Locate ++;
  6299. $receiptList [$key] ['reviseDetail'] = array ();
  6300. if (! empty ( $value ['reviseDetail'] ))
  6301. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6302. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6303. $categoryDetil = $Lcategory->getOne ( array (
  6304. 'where' => 'cid=' . $value ['cid'],
  6305. 'asArray' => true
  6306. ) );
  6307. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6308. // 检测编辑状态
  6309. $verifyList = $verify->getOne ( array (
  6310. 'where' => 'vid=' . $value ['verify'],
  6311. 'asArray' => true
  6312. ) );
  6313. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6314. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6315. Doo::loadModel ( 'role' );
  6316. $role = new role ();
  6317. $flag = true;
  6318. $roleKey = 0;
  6319. $endStaffArray = array ();
  6320. $roleArrayCopy = array ();
  6321. foreach ( $verifyList as $k => $v ) {
  6322. // init verifyStaff
  6323. if ($v [1] == 'ROLE') {
  6324. if (! empty ( $verifyStaff )) {
  6325. $endStaffArray = end ( $verifyStaff );
  6326. // if ($v[0]==$endStaffArray['nextStaff']){
  6327. // $roleId=$v[0];
  6328. // }
  6329. }
  6330. $roleVerify = json_decode ( $v [3], true );
  6331. $roleKey = $k;
  6332. $roleArray = array ();
  6333. $rolename = $role->getOne ( array (
  6334. 'where' => 'rid=' . $v [0],
  6335. 'asArray' => true
  6336. ) );
  6337. foreach ( $roleVerify as $o => $p ) {
  6338. $staffID = explode ( '_', $p );
  6339. $staffInfo = $staff->getOne ( array (
  6340. 'where' => 'sid=' . $staffID [0],
  6341. 'asArray' => true
  6342. ) );
  6343. // print_r($staffID);
  6344. $exp = array (
  6345. 0 => $staffInfo ['sid'],
  6346. 1 => $staffID [1],
  6347. 2 => $staffInfo ['avatar'],
  6348. 'date' => '',
  6349. 'date' => '',
  6350. 'opinion' => '',
  6351. 'status' => '',
  6352. 'rolename' => $rolename ['name']
  6353. );
  6354. array_push ( $roleArray, $exp );
  6355. }
  6356. $roleArrayCopy [$v [0]] = $roleArray;
  6357. // $verifyList[$k]['roleArray']=$roleArray;
  6358. }
  6359. $verifyList [$k] ['date'] = "";
  6360. $verifyList [$k] ['opinion'] = "";
  6361. $verifyList [$k] ['status'] = "";
  6362. if (empty ( $verifyStaff )) {
  6363. $verifyList [$k] ['date'] = "";
  6364. $verifyList [$k] ['opinion'] = "";
  6365. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6366. $verifyList [$k] ['status'] = 4;
  6367. $flag = false;
  6368. }
  6369. } else {
  6370. foreach ( $verifyStaff as $m => $u ) {
  6371. if ($v [0] == $m) {
  6372. $verifyList [$k] ['date'] = $u ['date'];
  6373. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6374. $verifyList [$k] ['status'] = $u ['status'];
  6375. $flag = false;
  6376. break;
  6377. }
  6378. }
  6379. $endStaffArray = end ( $verifyStaff );
  6380. if (isset ( $endStaffArray ['ROLE'] )) {
  6381. } else {
  6382. // $endKey=key($verifyStaff);
  6383. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  6384. // $button=4;
  6385. // $verifyList[$k]['status']=4;
  6386. // }
  6387. }
  6388. }
  6389. }
  6390. $rolename ['name'] = '';
  6391. if (! empty ( $roleId )) {
  6392. Doo::loadModel ( 'role' );
  6393. $role = new role ();
  6394. $rolename = $role->getOne ( array (
  6395. 'where' => 'rid=' . $roleId,
  6396. 'asArray' => true
  6397. ) );
  6398. }
  6399. if (! empty ( $verifyStaff ))
  6400. $endStaffArray = end ( $verifyStaff );
  6401. $KOP = false;
  6402. foreach ( $roleArrayCopy as $P => $A ) {
  6403. foreach ( $A as $MKI => $AVL ) {
  6404. if (! empty ( $verifyStaff )) {
  6405. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6406. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6407. $button = 4;
  6408. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6409. }
  6410. foreach ( $verifyStaff as $m => $u ) {
  6411. $AVLFK = $AVL [0] . '_R';
  6412. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6413. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6414. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6415. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6416. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6417. break;
  6418. }
  6419. }
  6420. } else {
  6421. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6422. $button = 4;
  6423. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6424. }
  6425. }
  6426. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6427. $KOP = true;
  6428. }
  6429. }
  6430. foreach ( $roleArrayCopy as $k => $v ) {
  6431. foreach ( $verifyList as $m => $n ) {
  6432. if ($n [0] == $k) {
  6433. array_splice ( $verifyList, $m, 1, $v );
  6434. }
  6435. }
  6436. }
  6437. $receiptList [$key] ['verifyList'] = $verifyList;
  6438. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6439. 'where' => 'sid=' . $value ['staff'],
  6440. 'asArray' => true
  6441. ) );
  6442. $receiptList [$key] ['button'] = $button;
  6443. }
  6444. // print_r($receiptList);die;
  6445. $mothHtml = "";
  6446. for($i = 1; $i <= 12; $i ++) {
  6447. if ($moth == $i)
  6448. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6449. else
  6450. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6451. }
  6452. $data ['mothHtml'] = $mothHtml;
  6453. $data ['receiptList'] = $receiptList;
  6454. $data ['memu'] = "receipt";
  6455. $data ['staff'] = $this->staff;
  6456. $data ['receiptMemu'] = 'receipt';
  6457. $data ['verifyId'] = $this->verifyId;
  6458. $data ['executeId'] = $this->executeId;
  6459. $data ['item'] = $item;
  6460. $data ['year'] = $year;
  6461. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  6462. // sufficient condition to generate cache
  6463. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  6464. $receiptList = $receipt->find ( array (
  6465. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  6466. 'asArray' => true
  6467. ) );
  6468. if (empty ( $receiptList )) { // generated files
  6469. ob_start ();
  6470. $this->render ( "/admin/saea_myList", $data );
  6471. $this->cacheFile ( $path );
  6472. die ();
  6473. // $content = ob_get_contents();
  6474. // $fp = fopen($path, "w");
  6475. // fwrite($fp, $content);
  6476. // fclose($fp);
  6477. }
  6478. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  6479. $receiptList = $receipt->find ( array (
  6480. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  6481. 'asArray' => true
  6482. ) );
  6483. if (empty ( $receiptList )) { // generated files
  6484. ob_start ();
  6485. $this->render ( "/admin/saea_myList", $data );
  6486. $this->cacheFile ( $path );
  6487. die ();
  6488. }
  6489. }
  6490. }
  6491. $this->render ( "/admin/saea_myList", $data );
  6492. }
  6493. function saeaCreate() {
  6494. Doo::loadModel ( 'accountItem' );
  6495. Doo::loadModel ( 'verify' );
  6496. Doo::loadModel ( 'receipt' );
  6497. Doo::loadModel ( 'L_category' );
  6498. $lCategory = new L_category ();
  6499. $receipt = new receipt ();
  6500. $verify = new verify ();
  6501. $accountItem = new accountItem ();
  6502. Doo::loadModel ( "role" );
  6503. $role = new role ();
  6504. $acItem = $accountItem->find ( array (
  6505. 'asArray' => true
  6506. ) );
  6507. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  6508. $data ['category'] = $lCategory->find ( array (
  6509. 'asArray' => true
  6510. ) );
  6511. $data ['veList'] = $veList;
  6512. $data ['acItem'] = $acItem;
  6513. $data ['memu'] = "receipt";
  6514. $data ['staff'] = $this->staff;
  6515. $data ['receiptMemu'] = 'saeaBorad';
  6516. $data ['verifyId'] = $this->verifyId;
  6517. $data ['executeId'] = $this->executeId;
  6518. $this->render ( "/admin/saea_create", $data );
  6519. }
  6520. function addReceipt() {
  6521. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  6522. $agency = $this->get_args ( 'agency' );
  6523. $travel = $this->get_args ( 'travel' );
  6524. $train = $this->get_args ( 'train' );
  6525. $other = $this->get_args ( 'other' );
  6526. $inttrain = $this->get_args ( 'inttrain' );
  6527. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  6528. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  6529. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  6530. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  6531. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  6532. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  6533. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  6534. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  6535. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  6536. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  6537. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  6538. header ( 'Content-Type:text/html;charset=utf-8' );
  6539. die ( '请填写联行号' );
  6540. }
  6541. Doo::loadModel ( 'receipt' );
  6542. Doo::loadModel ( 'receiptDetail' );
  6543. Doo::loadModel ( 'accountItem' );
  6544. $accountItem = new accountItem ();
  6545. $receipt = new receipt ();
  6546. Doo::loadModel ( 'enclosur' );
  6547. Doo::loadModel ( 'execute' );
  6548. $execute = new execute ();
  6549. $executeDetail = $execute->getOne ( array (
  6550. 'where' => 'mold="报销单执行人"',
  6551. 'asArray' => true
  6552. ) );
  6553. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  6554. // if(!empty($receiptDetail))
  6555. // return "/referReceipt/".$receiptDetail['rid'];
  6556. $aItem = $accountItem->find ( array (
  6557. 'asArray' => true
  6558. ) );
  6559. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  6560. $ag = $tr = $ta = $ot= $it = 0;
  6561. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  6562. foreach ( $aItem as $key => $value ) {
  6563. if ($value ['category'] == $this->AGENCY) {
  6564. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  6565. array_push ( $accountJson [$this->AGENCY], array (
  6566. 'aid' => $value ['aid'],
  6567. 'name' => $value ['name'],
  6568. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  6569. ) );
  6570. $sum += $agency [$ag];
  6571. $agencySum += $agency [$ag];
  6572. }
  6573. $ag ++;
  6574. }
  6575. if ($value ['category'] == $this->TRAVEL) {
  6576. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  6577. array_push ( $accountJson [$this->TRAVEL], array (
  6578. 'aid' => $value ['aid'],
  6579. 'name' => $value ['name'],
  6580. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  6581. ) );
  6582. $sum += $travel [$tr];
  6583. $travelSum += $travel [$tr];
  6584. }
  6585. $tr ++;
  6586. }
  6587. if ($value ['category'] == $this->TRAIN) {
  6588. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  6589. array_push ( $accountJson [$this->TRAIN], array (
  6590. 'aid' => $value ['aid'],
  6591. 'name' => $value ['name'],
  6592. 'price' => number_format ( $train [$ta], 2, '.', '' )
  6593. ) );
  6594. $sum += $train [$ta];
  6595. $trainSum += $train [$ta];
  6596. }
  6597. $ta ++;
  6598. }
  6599. if ($value ['category'] == $this->INTTRAIN) {
  6600. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  6601. array_push ( $accountJson [$this->INTTRAIN], array (
  6602. 'aid' => $value ['aid'],
  6603. 'name' => $value ['name'],
  6604. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  6605. ) );
  6606. $sum += $inttrain [$it];
  6607. $inttrainSum += $inttrain [$it];
  6608. }
  6609. $it ++;
  6610. }
  6611. if ($value ['category'] == $this->OTHER) {
  6612. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  6613. array_push ( $accountJson [$this->OTHER], array (
  6614. 'aid' => $value ['aid'],
  6615. 'name' => $value ['name'],
  6616. 'price' => number_format ( $other [$ot], 2, '.', '' )
  6617. ) );
  6618. $sum += $other [$ot];
  6619. $otherSum += $other [$ot];
  6620. }
  6621. $ot ++;
  6622. }
  6623. }
  6624. $accountJson ['cSum'] = array (
  6625. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  6626. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  6627. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  6628. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  6629. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  6630. );
  6631. // 报销单
  6632. $receipt->accountItem = json_encode ( $accountJson );
  6633. $receipt->staff = $this->staff [0] ['sid'];
  6634. $receipt->sum = number_format ( $sum, 2, '.', '' );
  6635. $receipt->date = date ( "Y-m-d" );
  6636. $receipt->cid = $cid;
  6637. $receipt->status = 5;
  6638. // 修改审批流程加入角色
  6639. $receipt->verify = $verify;
  6640. $receipt->executeCopy = $executeDetail ['staff'];
  6641. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  6642. $order = array (
  6643. "\r\n",
  6644. "\n",
  6645. "\r"
  6646. );
  6647. $replace = '<br/>';
  6648. $explanation = str_replace ( $order, $replace, $explanation );
  6649. $receipt->explanation = $explanation;
  6650. $receipt->remittanceName = $remittanceName;
  6651. $receipt->bankName = $bankName;
  6652. $receipt->bankNumber = $bankNumber;
  6653. $receipt->remittanceBankType = $remittanceBankType;
  6654. if ($remittanceBankType == 1)
  6655. $receipt->coupletNumber = $coupletNumber;
  6656. $rid = $receipt->insert ();
  6657. // 附件
  6658. if (! empty ( $enclosurName )) {
  6659. $enclosurArray = explode ( '-', $enclosurName );
  6660. foreach ( $enclosurArray as $value ) {
  6661. $enclosur = new enclosur ();
  6662. $enclosur->name = $value;
  6663. $enclosur->rid = $rid;
  6664. $enclosur->insert ();
  6665. }
  6666. // print_r($enclosurArray);die;
  6667. }
  6668. // 报销详情
  6669. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  6670. $receiptDetail = new receiptDetail ();
  6671. $receiptDetail->staff = $this->staff [0] ['sid'];
  6672. $receiptDetail->item = $value ['name'];
  6673. $receiptDetail->itemCategory = $this->AGENCY;
  6674. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6675. $receiptDetail->date = date ( "Y-m-d" );
  6676. $receiptDetail->cid = $cid;
  6677. $receiptDetail->rid = $rid;
  6678. $receiptDetail->status = 4;
  6679. $receiptDetail->insert ();
  6680. }
  6681. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  6682. $receiptDetail = new receiptDetail ();
  6683. $receiptDetail->staff = $this->staff [0] ['sid'];
  6684. $receiptDetail->item = $value ['name'];
  6685. $receiptDetail->itemCategory = $this->TRAVEL;
  6686. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6687. $receiptDetail->date = date ( "Y-m-d" );
  6688. $receiptDetail->cid = $cid;
  6689. $receiptDetail->rid = $rid;
  6690. $receiptDetail->status = 4;
  6691. $receiptDetail->insert ();
  6692. }
  6693. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  6694. $receiptDetail = new receiptDetail ();
  6695. $receiptDetail->staff = $this->staff [0] ['sid'];
  6696. $receiptDetail->item = $value ['name'];
  6697. $receiptDetail->itemCategory = $this->TRAIN;
  6698. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6699. $receiptDetail->date = date ( "Y-m-d" );
  6700. $receiptDetail->cid = $cid;
  6701. $receiptDetail->rid = $rid;
  6702. $receiptDetail->status = 4;
  6703. $receiptDetail->insert ();
  6704. }
  6705. //内训
  6706. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  6707. $receiptDetail = new receiptDetail ();
  6708. $receiptDetail->staff = $this->staff [0] ['sid'];
  6709. $receiptDetail->item = $value ['name'];
  6710. $receiptDetail->itemCategory = $this->INTTRAIN;
  6711. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6712. $receiptDetail->date = date ( "Y-m-d" );
  6713. $receiptDetail->cid = $cid;
  6714. $receiptDetail->rid = $rid;
  6715. $receiptDetail->status = 4;
  6716. $receiptDetail->insert ();
  6717. }
  6718. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  6719. $receiptDetail = new receiptDetail ();
  6720. $receiptDetail->staff = $this->staff [0] ['sid'];
  6721. $receiptDetail->item = $value ['name'];
  6722. $receiptDetail->itemCategory = $this->OTHER;
  6723. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6724. $receiptDetail->date = date ( "Y-m-d" );
  6725. $receiptDetail->cid = $cid;
  6726. $receiptDetail->rid = $rid;
  6727. $receiptDetail->status = 4;
  6728. $receiptDetail->insert ();
  6729. }
  6730. return "/saeaBorad";
  6731. } else
  6732. die ( 'illegal request' );
  6733. }
  6734. function referReceipt() {
  6735. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  6736. Doo::loadModel ( 'receipt' );
  6737. Doo::loadModel ( 'verify' );
  6738. $verify = new verify ();
  6739. $receipt = new receipt ();
  6740. Doo::loadModel ( 'L_category' );
  6741. $lCategory = new L_category ();
  6742. Doo::loadModel ( "role" );
  6743. $role = new role ();
  6744. $receiptDetail = $receipt->find ( array (
  6745. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  6746. 'asArray' => true
  6747. ) );
  6748. if (empty ( $receiptDetail ))
  6749. return "/addReceipt";
  6750. foreach ( $receiptDetail as $key => $value ) {
  6751. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6752. $veList = $verify->getOne ( array (
  6753. 'where' => 'vid=' . $value ['verify'],
  6754. 'asArray' => true
  6755. ) );
  6756. $v = json_decode ( $veList ['staff'] );
  6757. array_push ( $v [0], $veList ['description'] );
  6758. foreach ( $v as $n => $m ) {
  6759. if ($m ['1'] == 'ROLE') {
  6760. $roleInfo = $role->getOne ( array (
  6761. 'where' => 'rid=' . $m [0],
  6762. 'asArray' => true
  6763. ) );
  6764. $v [$n] [1] = $roleInfo ['name'];
  6765. }
  6766. }
  6767. $receiptDetail [$key] ['staff'] = $v;
  6768. $category = $lCategory->getOne ( array (
  6769. 'where' => 'cid=' . $value ['cid'],
  6770. 'asArray' => true
  6771. ) );
  6772. $receiptDetail [$key] ['category'] = $category ['title'];
  6773. }
  6774. // print_r($receiptDetail);
  6775. $data ['receiptDetail'] = $receiptDetail;
  6776. $data ['memu'] = "receipt";
  6777. $data ['staff'] = $this->staff;
  6778. $data ['receiptMemu'] = 'saeaCreate';
  6779. $data ['verifyId'] = $this->verifyId;
  6780. $data ['executeId'] = $this->executeId;
  6781. $this->render ( "/admin/saea_confirm", $data );
  6782. }
  6783. function editReceipt() {
  6784. // edit status 4
  6785. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  6786. Doo::loadClass ( 'XDeode' );
  6787. $XDeode = new XDeode ( 7 );
  6788. $rid = $XDeode->decode ( $ridKey );
  6789. if (empty ( $rid ))
  6790. die ( 'illegal request' );
  6791. // echo $rid.'sd';
  6792. Doo::loadModel ( 'accountItem' );
  6793. Doo::loadModel ( 'verify' );
  6794. Doo::loadModel ( 'receipt' );
  6795. $receipt = new receipt ();
  6796. $verify = new verify ();
  6797. $accountItem = new accountItem ();
  6798. Doo::loadModel ( 'L_category' );
  6799. $lCategory = new L_category ();
  6800. Doo::loadModel ( "role" );
  6801. $role = new role ();
  6802. Doo::loadModel ( 'enclosur' );
  6803. $enclosur = new enclosur ();
  6804. $receiptDetail = $receipt->getOne ( array (
  6805. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  6806. 'asArray' => true
  6807. ) );
  6808. if (empty ( $receiptDetail ))
  6809. die ( 'illegal request' );
  6810. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  6811. $acItem = $accountItem->find ( array (
  6812. 'asArray' => true
  6813. ) );
  6814. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  6815. // 配置编辑信息
  6816. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  6817. foreach ( $acItem as $key => $value ) {
  6818. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  6819. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  6820. $acItem [$key] ['price'] = $v ['price'];
  6821. }
  6822. }
  6823. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  6824. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  6825. $acItem [$key] ['price'] = $v ['price'];
  6826. }
  6827. }
  6828. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  6829. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  6830. $acItem [$key] ['price'] = $v ['price'];
  6831. }
  6832. }
  6833. //内训
  6834. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  6835. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  6836. $acItem [$key] ['price'] = $v ['price'];
  6837. }
  6838. }
  6839. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  6840. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  6841. $acItem [$key] ['price'] = $v ['price'];
  6842. }
  6843. }
  6844. }
  6845. $data ['category'] = $lCategory->find ( array (
  6846. 'asArray' => true
  6847. ) );
  6848. $data ['cSum'] = $accountItemList ['cSum'];
  6849. $data ['sum'] = $receiptDetail ['sum'];
  6850. $data ['enclosurList'] = $enclosurList;
  6851. $data ['receiptDetail'] = $receiptDetail;
  6852. $data ['veList'] = $veList;
  6853. $data ['acItem'] = $acItem;
  6854. $data ['memu'] = "receipt";
  6855. $data ['staff'] = $this->staff;
  6856. $data ['receiptMemu'] = 'saeaBorad';
  6857. $data ['verify'] = $receiptDetail ['verify'];
  6858. $data ['verifyId'] = $this->verifyId;
  6859. $data ['executeId'] = $this->executeId;
  6860. $data ['rid'] = $ridKey;
  6861. $this->render ( "/admin/saea_edit", $data );
  6862. }
  6863. function updateReceipt() {
  6864. $agency = $this->get_args ( 'agency' );
  6865. $travel = $this->get_args ( 'travel' );
  6866. $train = $this->get_args ( 'train' );
  6867. $other = $this->get_args ( 'other' );
  6868. $inttrain = $this->get_args ( 'inttrain' );
  6869. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  6870. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  6871. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  6872. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  6873. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  6874. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  6875. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  6876. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  6877. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  6878. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  6879. Doo::loadClass ( 'XDeode' );
  6880. $XDeode = new XDeode ( 7 );
  6881. $rid = $XDeode->decode ( $ridKey );
  6882. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  6883. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  6884. header ( 'Content-Type:text/html;charset=utf-8' );
  6885. die ( '请填写联行号' );
  6886. }
  6887. Doo::loadModel ( 'receipt' );
  6888. Doo::loadModel ( 'receiptDetail' );
  6889. Doo::loadModel ( 'accountItem' );
  6890. $accountItem = new accountItem ();
  6891. $receipt = new receipt ();
  6892. Doo::loadModel ( 'enclosur' );
  6893. Doo::loadModel ( 'execute' );
  6894. $execute = new execute ();
  6895. $receiptDetail = $receipt->getOne ( array (
  6896. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  6897. 'asArray' => true
  6898. ) );
  6899. if (empty ( $receiptDetail ))
  6900. return "/saeaBorad";
  6901. if ($receiptDetail ['Rtype'] == 1)
  6902. $executeDetail = $execute->getOne ( array (
  6903. 'where' => 'mold="借款费用执行人"',
  6904. 'asArray' => true
  6905. ) );
  6906. else
  6907. $executeDetail = $execute->getOne ( array (
  6908. 'where' => 'mold="报销单执行人"',
  6909. 'asArray' => true
  6910. ) );
  6911. $aItem = $accountItem->find ( array (
  6912. 'asArray' => true
  6913. ) );
  6914. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  6915. $ag = $tr = $ta = $ot = $it = 0 ;
  6916. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum = $otherSum = 0;
  6917. foreach ( $aItem as $key => $value ) {
  6918. if ($value ['category'] == $this->AGENCY) {
  6919. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  6920. array_push ( $accountJson [$this->AGENCY], array (
  6921. 'aid' => $value ['aid'],
  6922. 'name' => $value ['name'],
  6923. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  6924. ) );
  6925. $sum += $agency [$ag];
  6926. $agencySum += $agency [$ag];
  6927. }
  6928. $ag ++;
  6929. }
  6930. if ($value ['category'] == $this->TRAVEL) {
  6931. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  6932. array_push ( $accountJson [$this->TRAVEL], array (
  6933. 'aid' => $value ['aid'],
  6934. 'name' => $value ['name'],
  6935. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  6936. ) );
  6937. $sum += $travel [$tr];
  6938. $travelSum += $travel [$tr];
  6939. }
  6940. $tr ++;
  6941. }
  6942. if ($value ['category'] == $this->TRAIN) {
  6943. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  6944. array_push ( $accountJson [$this->TRAIN], array (
  6945. 'aid' => $value ['aid'],
  6946. 'name' => $value ['name'],
  6947. 'price' => number_format ( $train [$ta], 2, '.', '' )
  6948. ) );
  6949. $sum += $train [$ta];
  6950. $trainSum += $train [$ta];
  6951. }
  6952. $ta ++;
  6953. }
  6954. if ($value ['category'] == $this->INTTRAIN) {
  6955. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  6956. array_push ( $accountJson [$this->INTTRAIN], array (
  6957. 'aid' => $value ['aid'],
  6958. 'name' => $value ['name'],
  6959. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  6960. ) );
  6961. $sum += $inttrain [$it];
  6962. $inttrainSum += $inttrain [$it];
  6963. }
  6964. $it ++;
  6965. }
  6966. if ($value ['category'] == $this->OTHER) {
  6967. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  6968. array_push ( $accountJson [$this->OTHER], array (
  6969. 'aid' => $value ['aid'],
  6970. 'name' => $value ['name'],
  6971. 'price' => number_format ( $other [$ot], 2, '.', '' )
  6972. ) );
  6973. $sum += $other [$ot];
  6974. $otherSum += $other [$ot];
  6975. }
  6976. $ot ++;
  6977. }
  6978. }
  6979. $accountJson ['cSum'] = array (
  6980. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  6981. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  6982. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  6983. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  6984. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  6985. );
  6986. // 报销单
  6987. $rid = $receipt->rid = $receiptDetail ['rid'];
  6988. $receipt->accountItem = json_encode ( $accountJson );
  6989. $receipt->staff = $this->staff [0] ['sid'];
  6990. $receipt->sum = number_format ( $sum, 2, '.', '' );
  6991. $receipt->date = date ( "Y-m-d" );
  6992. $receipt->cid = $cid;
  6993. if (($receiptDetail ['status'] != 4)) {
  6994. if ($receiptDetail ['Rtype'] == 1)
  6995. $receipt->status = 7;
  6996. else
  6997. $receipt->status = 5;
  6998. }
  6999. if ($receiptDetail != 4 && ! empty ( $verify ))
  7000. $receipt->verify = $verify;
  7001. $receipt->executeCopy = $executeDetail ['staff'];
  7002. $order = array (
  7003. "\r\n",
  7004. "\n",
  7005. "\r"
  7006. );
  7007. $replace = '<br/>';
  7008. $explanation = str_replace ( $order, $replace, $explanation );
  7009. $receipt->explanation = $explanation;
  7010. $receipt->remittanceName = $remittanceName;
  7011. $receipt->bankName = $bankName;
  7012. $receipt->bankNumber = $bankNumber;
  7013. $receipt->remittanceBankType = $remittanceBankType;
  7014. if ($remittanceBankType == 1)
  7015. $receipt->coupletNumber = $coupletNumber;
  7016. $receipt->update ();
  7017. $receiptDetail = new receiptDetail ();
  7018. $receiptDetail->delete ( array (
  7019. 'where' => 'rid=' . $rid
  7020. ) );
  7021. // 报销详情
  7022. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  7023. $receiptDetail = new receiptDetail ();
  7024. $receiptDetail->staff = $this->staff [0] ['sid'];
  7025. $receiptDetail->item = $value ['name'];
  7026. $receiptDetail->itemCategory = $this->AGENCY;
  7027. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  7028. $receiptDetail->date = date ( "Y-m-d" );
  7029. $receiptDetail->cid = $cid;
  7030. $receiptDetail->rid = $rid;
  7031. $receiptDetail->status = 4;
  7032. $receiptDetail->insert ();
  7033. }
  7034. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  7035. $receiptDetail = new receiptDetail ();
  7036. $receiptDetail->staff = $this->staff [0] ['sid'];
  7037. $receiptDetail->item = $value ['name'];
  7038. $receiptDetail->itemCategory = $this->TRAVEL;
  7039. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  7040. $receiptDetail->date = date ( "Y-m-d" );
  7041. $receiptDetail->cid = $cid;
  7042. $receiptDetail->rid = $rid;
  7043. $receiptDetail->status = 4;
  7044. $receiptDetail->insert ();
  7045. }
  7046. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  7047. $receiptDetail = new receiptDetail ();
  7048. $receiptDetail->staff = $this->staff [0] ['sid'];
  7049. $receiptDetail->item = $value ['name'];
  7050. $receiptDetail->itemCategory = $this->TRAIN;
  7051. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  7052. $receiptDetail->date = date ( "Y-m-d" );
  7053. $receiptDetail->cid = $cid;
  7054. $receiptDetail->rid = $rid;
  7055. $receiptDetail->status = 4;
  7056. $receiptDetail->insert ();
  7057. }
  7058. //内训
  7059. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  7060. $receiptDetail = new receiptDetail ();
  7061. $receiptDetail->staff = $this->staff [0] ['sid'];
  7062. $receiptDetail->item = $value ['name'];
  7063. $receiptDetail->itemCategory = $this->INTTRAIN;
  7064. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  7065. $receiptDetail->date = date ( "Y-m-d" );
  7066. $receiptDetail->cid = $cid;
  7067. $receiptDetail->rid = $rid;
  7068. $receiptDetail->status = 4;
  7069. $receiptDetail->insert ();
  7070. }
  7071. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  7072. $receiptDetail = new receiptDetail ();
  7073. $receiptDetail->staff = $this->staff [0] ['sid'];
  7074. $receiptDetail->item = $value ['name'];
  7075. $receiptDetail->itemCategory = $this->OTHER;
  7076. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  7077. $receiptDetail->date = date ( "Y-m-d" );
  7078. $receiptDetail->cid = $cid;
  7079. $receiptDetail->rid = $rid;
  7080. $receiptDetail->status = 4;
  7081. $receiptDetail->insert ();
  7082. }
  7083. // 附件
  7084. if (! empty ( $enclosurName )) {
  7085. $enclosurArray = explode ( '-', $enclosurName );
  7086. foreach ( $enclosurArray as $value ) {
  7087. $enclosur = new enclosur ();
  7088. $enclosur->name = $value;
  7089. $enclosur->rid = $rid;
  7090. $enclosur->insert ();
  7091. }
  7092. }
  7093. // return "/referReceipt/".$rid;
  7094. }
  7095. return "/saeaBorad";
  7096. }
  7097. function approvedReceipt() {
  7098. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7099. Doo::loadModel ( 'receipt' );
  7100. Doo::loadModel ( 'receiptDetail' );
  7101. $receipt = new receipt ();
  7102. $receiptDetail = new receiptDetail ();
  7103. Doo::loadModel ( 'statistics' );
  7104. Doo::loadModel ( 'itemStatistics' );
  7105. $statistics = new statistics ();
  7106. $itemStatistics = new itemStatistics ();
  7107. Doo::loadModel ( "verify" );
  7108. $verify = new verify ();
  7109. // 审批状态的判定
  7110. $receiptDetailList = $receipt->getOne ( array (
  7111. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  7112. 'asArray' => true
  7113. ) );
  7114. if (empty ( $receiptDetailList ))
  7115. return "/saeaBorad";
  7116. $verifyDetail = $verify->getOne ( array (
  7117. 'where' => ' vid =' . $receiptDetailList ['verify'],
  7118. 'asArray' => true
  7119. ) );
  7120. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7121. if (empty ( $receiptDetailList ['nowStaff'] )) {
  7122. $nowStaff = "";
  7123. $nowStaffList = array ();
  7124. if ($verifyDetail [0] [1] == 'ROLE') {
  7125. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7126. foreach ( $vStaffString as $key => $value ) {
  7127. $staffK = explode ( "_", $value );
  7128. array_push ( $nowStaffList, $staffK [0] );
  7129. }
  7130. $nowStaff = implode ( ',', $nowStaffList );
  7131. } else {
  7132. $nowStaff = $verifyDetail [0] [0];
  7133. }
  7134. $receipt->nowStaff = $nowStaff;
  7135. }
  7136. // echo $nowStaff;
  7137. // print_r($verifyDetail);die;
  7138. $receipt->rid = $receiptDetailList ['rid'];
  7139. $receipt->date = date ( "Y-m-d" );
  7140. $receipt->status = 2;
  7141. $receipt->update ();
  7142. $receiptDetail->status = 2;
  7143. $receiptDetail->update ( array (
  7144. 'where' => 'rid=' . $receiptDetailList ['rid']
  7145. ) );
  7146. Doo::loadModel ( "receiptLog" );
  7147. $receiptLog = new receiptLog ();
  7148. Doo::loadModel ( "verify" );
  7149. $verify = new verify ();
  7150. $receiptInfo = $receipt->getOne ( array (
  7151. 'where' => 'rid=' . $rid,
  7152. 'asArray' => true
  7153. ) );
  7154. $vr = $verify->getOne ( array (
  7155. 'where' => 'vid=' . $receiptInfo ['verify'],
  7156. 'asArray' => true
  7157. ) );
  7158. $jd = json_decode ( $vr ['staff'] );
  7159. $roleId = 0;
  7160. foreach ( $jd as $key => $value ) {
  7161. if ($value [1] == 'ROLE') {
  7162. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7163. if ($pos !== false) {
  7164. $roleId = $value [0];
  7165. }
  7166. }
  7167. }
  7168. // 审批日志
  7169. // echo $roleId;die;
  7170. if (! empty ( $roleId )) {
  7171. Doo::loadModel ( "role" );
  7172. $role = new role ();
  7173. $roleInfo = $role->getOne ( array (
  7174. 'where' => 'rid=' . $roleId,
  7175. 'asArray' => true
  7176. ) );
  7177. // $receiptLog->rolename = $roleInfo ['name'];
  7178. }
  7179. $receiptLog->username = $this->staff [0] ['username'];
  7180. $receiptLog->uid = $this->staff [0] ['sid'];
  7181. $receiptLog->date = date ( "Y-m-d" );
  7182. $receiptLog->opinion = '提交审批';
  7183. $receiptLog->img = $this->staff [0] ['avatar'];
  7184. $receiptLog->status = 2;
  7185. $receiptLog->rid = $rid;
  7186. $receiptLog->insert ();
  7187. // statistics item
  7188. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  7189. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7190. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  7191. $stat = $statistics->getOne ( array (
  7192. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7193. 'asArray' => true
  7194. ) );
  7195. if (empty ( $stat )) {
  7196. $statistics->date = date ( "Y-m-d" );
  7197. $statistics->cid = $this->staff [0] ['cid'];
  7198. $statistics->staff = $this->staff [0] ['sid'];
  7199. $statistics->agPrice = 0;
  7200. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7201. $statistics->insert ();
  7202. } else {
  7203. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7204. $statistics->update ( array (
  7205. 'where' => 'sid=' . $stat ['sid']
  7206. ) );
  7207. }
  7208. return "/expenses";
  7209. }
  7210. function approval() {
  7211. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7212. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7213. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7214. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7215. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7216. if (empty ( $status ))
  7217. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7218. $vidList = array ();
  7219. $button = 0;
  7220. Doo::loadModel ( 'verify' );
  7221. $verify = new verify ();
  7222. Doo::loadModel ( 'receipt' );
  7223. $receipt = new receipt ();
  7224. Doo::loadModel ( 'staff' );
  7225. $staff = new staff ();
  7226. Doo::loadModel ( 'L_category' );
  7227. $Lcategory = new L_category ();
  7228. // user verify ID
  7229. $verifyDetail = $verify->find ( array (
  7230. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7231. 'asArray' => true
  7232. ) );
  7233. foreach ( $verifyDetail as $key => $value ) {
  7234. array_push ( $vidList, $value ['vid'] );
  7235. }
  7236. $vid = implode ( ",", $vidList );
  7237. if (empty ( $verifyDetail ))
  7238. $vid = 0;
  7239. /*
  7240. */
  7241. $dateCondition = " and Year(date) =" . $year;
  7242. if (! empty ( $month ))
  7243. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  7244. $categoryList = $Lcategory->find ( array (
  7245. 'asArray' => true
  7246. ) );
  7247. $staffList = $staff->find ( array (
  7248. 'where' => 'cid=' . $cid,
  7249. 'asArray' => true
  7250. ) );
  7251. $cateCondition = "";
  7252. $staffCondition = "";
  7253. $approvalCondition = "";
  7254. if (! empty ( $cid ))
  7255. $cateCondition = ' and cid=' . $cid;
  7256. if (! empty ( $sid )) {
  7257. $staffCondition = ' and staff=' . $sid;
  7258. $cateCondition = "";
  7259. }
  7260. // elseif($status==1){
  7261. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  7262. // }
  7263. if ($status == 2) {
  7264. // 查找角色审批人
  7265. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  7266. }
  7267. $ap = "";
  7268. if ($status == 4) {
  7269. $ap = 4;
  7270. $status = 2;
  7271. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  7272. }
  7273. if ($status == 5) {
  7274. $status = 4;
  7275. $ap = 5;
  7276. }
  7277. // echo $vid;
  7278. // get Receipt By verifyID status 2 .$approvalCondition
  7279. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  7280. $receiptList = $receipt->find ( array (
  7281. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  7282. 'desc' => 'rid',
  7283. 'asArray' => true
  7284. ) );
  7285. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  7286. $Locate = 0;
  7287. if ($ap == 4)
  7288. $status = 4;
  7289. elseif ($ap == 5)
  7290. $status = 5;
  7291. foreach ( $receiptList as $key => $value ) {
  7292. $receiptList [$key] ['Locate'] = $Locate;
  7293. $Locate ++;
  7294. $receiptList [$key] ['reviseDetail'] = array ();
  7295. if (! empty ( $value ['reviseDetail'] ))
  7296. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7297. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7298. $categoryDetil = $Lcategory->getOne ( array (
  7299. 'where' => 'cid=' . $value ['cid'],
  7300. 'asArray' => true
  7301. ) );
  7302. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7303. $verifyList = $verify->getOne ( array (
  7304. 'where' => 'vid=' . $value ['verify'],
  7305. 'asArray' => true
  7306. ) );
  7307. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7308. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7309. foreach ( $verifyList as $k => $v ) {
  7310. // init verifyStaff
  7311. $verifyList [$k] ['date'] = "";
  7312. $verifyList [$k] ['opinion'] = "";
  7313. $verifyList [$k] ['status'] = "";
  7314. if (empty ( $verifyStaff )) {
  7315. $verifyList [$k] ['date'] = "";
  7316. $verifyList [$k] ['opinion'] = "";
  7317. if ($v [0] == $this->staff [0] ['sid']) {
  7318. $verifyList [$k] ['status'] = 4;
  7319. $button = 4;
  7320. }
  7321. } else {
  7322. $flag = true;
  7323. foreach ( $verifyStaff as $m => $u ) {
  7324. if ($v [0] == $m) {
  7325. $verifyList [$k] ['date'] = $u ['date'];
  7326. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7327. $verifyList [$k] ['status'] = $u ['status'];
  7328. $flag = false;
  7329. break;
  7330. }
  7331. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  7332. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  7333. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  7334. }
  7335. if ($flag) { // 检测可编辑
  7336. if ($v [0] == $this->staff [0] ['sid']) {
  7337. $verifyList [$k] ['status'] = 4;
  7338. $button = 4;
  7339. }
  7340. }
  7341. }
  7342. }
  7343. $receiptList [$key] ['verifyList'] = $verifyList;
  7344. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7345. 'where' => 'sid=' . $value ['staff'],
  7346. 'asArray' => true
  7347. ) );
  7348. $receiptList [$key] ['button'] = $button;
  7349. }
  7350. // print_r($receiptList);die;
  7351. // $data['verifyDetail']=$verifyDetail;
  7352. $mothHtml = "";
  7353. for($i = 1; $i <= 12; $i ++) {
  7354. if ($month == $i)
  7355. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7356. else
  7357. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7358. }
  7359. $data ['mothHtml'] = $mothHtml;
  7360. $data ['receiptList'] = $receiptList;
  7361. $data ['receiptApprovalCount'] = count ( $receiptList );
  7362. $data ['status'] = $status;
  7363. $data ['year'] = $year;
  7364. $data ['categoryList'] = $categoryList;
  7365. $data ['staffList'] = $staffList;
  7366. $data ['cid'] = $cid;
  7367. $data ['sid'] = $sid;
  7368. $data ['ap'] = $ap;
  7369. $data ['memu'] = "receipt";
  7370. $data ['staff'] = $this->staff;
  7371. $data ['receiptMemu'] = 'approval';
  7372. $data ['verifyId'] = $this->verifyId;
  7373. $data ['executeId'] = $this->executeId;
  7374. $this->render ( "/admin/saea_reportList", $data );
  7375. }
  7376. function approvalDetails() {
  7377. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7378. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7379. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7380. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7381. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7382. Doo::loadModel ( 'verify' );
  7383. $verify = new verify ();
  7384. Doo::loadModel ( 'receipt' );
  7385. $receipt = new receipt ();
  7386. Doo::loadModel ( 'staff' );
  7387. $staff = new staff ();
  7388. Doo::loadModel ( 'L_category' );
  7389. $Lcategory = new L_category ();
  7390. Doo::loadModel ( 'enclosur' );
  7391. $enclosur = new enclosur ();
  7392. $vidList = array ();
  7393. $verifyDetail = $verify->find ( array (
  7394. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7395. 'asArray' => true
  7396. ) );
  7397. foreach ( $verifyDetail as $key => $value ) {
  7398. array_push ( $vidList, $value ['vid'] );
  7399. }
  7400. $vid = implode ( ",", $vidList );
  7401. if (empty ( $verifyDetail ))
  7402. $vid = 0;
  7403. $categoryList = $Lcategory->find ( array (
  7404. 'asArray' => true
  7405. ) );
  7406. $staffList = $staff->find ( array (
  7407. 'where' => 'cid=' . $cid,
  7408. 'asArray' => true
  7409. ) );
  7410. $ap = 0;
  7411. $receiptList = $receipt->find ( array (
  7412. 'where' => 'rid =' . $rid,
  7413. 'desc' => 'rid',
  7414. 'asArray' => true
  7415. ) );
  7416. $Locate = 0;
  7417. $roleId = 0;
  7418. $button = 0;
  7419. foreach ( $receiptList as $key => $value ) {
  7420. $receiptList [$key] ['Locate'] = $Locate;
  7421. $Locate ++;
  7422. $receiptList [$key] ['reviseDetail'] = array ();
  7423. if (! empty ( $value ['reviseDetail'] ))
  7424. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7425. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7426. $categoryDetil = $Lcategory->getOne ( array (
  7427. 'where' => 'cid=' . $value ['cid'],
  7428. 'asArray' => true
  7429. ) );
  7430. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7431. // 检测编辑状态
  7432. $verifyList = $verify->getOne ( array (
  7433. 'where' => 'vid=' . $value ['verify'],
  7434. 'asArray' => true
  7435. ) );
  7436. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7437. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7438. Doo::loadModel ( 'role' );
  7439. $role = new role ();
  7440. // print_r($verifyList);
  7441. $flag = true;
  7442. $roleKey = 0;
  7443. $endStaffArray = array ();
  7444. $roleArrayCopy = array ();
  7445. foreach ( $verifyList as $k => $v ) {
  7446. // init verifyStaff
  7447. if ($v [1] == 'ROLE') {
  7448. if (! empty ( $verifyStaff )) {
  7449. $endStaffArray = end ( $verifyStaff );
  7450. if ($v [0] == $endStaffArray ['nextStaff']) {
  7451. $roleId = $v [0];
  7452. }
  7453. }
  7454. $roleVerify = json_decode ( $v [3], true );
  7455. $roleKey = $k;
  7456. $roleArray = array ();
  7457. $rolename = $role->getOne ( array (
  7458. 'where' => 'rid=' . $v [0],
  7459. 'asArray' => true
  7460. ) );
  7461. foreach ( $roleVerify as $o => $p ) {
  7462. $staffID = explode ( '_', $p );
  7463. $staffInfo = $staff->getOne ( array (
  7464. 'where' => 'sid=' . $staffID [0],
  7465. 'asArray' => true
  7466. ) );
  7467. // print_r($staffID);
  7468. $exp = array (
  7469. 0 => $staffInfo ['sid'],
  7470. 1 => $staffID [1],
  7471. 2 => $staffInfo ['avatar'],
  7472. 'date' => '',
  7473. 'date' => '',
  7474. 'opinion' => '',
  7475. 'status' => '',
  7476. 'rolename' => $rolename ['name']
  7477. );
  7478. array_push ( $roleArray, $exp );
  7479. }
  7480. $roleArrayCopy [$v [0]] = $roleArray;
  7481. // $verifyList[$k]['roleArray']=$roleArray;
  7482. }
  7483. // print_r($roleArray);
  7484. $verifyList [$k] ['date'] = "";
  7485. $verifyList [$k] ['opinion'] = "";
  7486. $verifyList [$k] ['status'] = "";
  7487. if (empty ( $verifyStaff )) {
  7488. $verifyList [$k] ['date'] = "";
  7489. $verifyList [$k] ['opinion'] = "";
  7490. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7491. $verifyList [$k] ['status'] = 4;
  7492. $button = 4;
  7493. $flag = false;
  7494. }
  7495. } else {
  7496. foreach ( $verifyStaff as $m => $u ) {
  7497. if ($v [0] == $m) {
  7498. $verifyList [$k] ['date'] = $u ['date'];
  7499. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7500. $verifyList [$k] ['status'] = $u ['status'];
  7501. $flag = false;
  7502. break;
  7503. }
  7504. }
  7505. $endStaffArray = end ( $verifyStaff );
  7506. if (isset ( $endStaffArray ['ROLE'] )) {
  7507. } else {
  7508. $endKey = key ( $verifyStaff );
  7509. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7510. $button = 4;
  7511. $verifyList [$k] ['status'] = 4;
  7512. }
  7513. }
  7514. }
  7515. }
  7516. $rolename ['name'] = '';
  7517. if (! empty ( $roleId )) {
  7518. Doo::loadModel ( 'role' );
  7519. $role = new role ();
  7520. $rolename = $role->getOne ( array (
  7521. 'where' => 'rid=' . $roleId,
  7522. 'asArray' => true
  7523. ) );
  7524. }
  7525. if (! empty ( $verifyStaff ))
  7526. $endStaffArray = end ( $verifyStaff );
  7527. $KOP = false;
  7528. foreach ( $roleArrayCopy as $P => $A ) {
  7529. foreach ( $A as $MKI => $AVL ) {
  7530. if (! empty ( $verifyStaff )) {
  7531. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7532. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7533. $button = 4;
  7534. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7535. }
  7536. foreach ( $verifyStaff as $m => $u ) {
  7537. $AVLFK = $AVL [0] . '_R';
  7538. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7539. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7540. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7541. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7542. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7543. break;
  7544. }
  7545. }
  7546. } else {
  7547. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7548. $button = 4;
  7549. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7550. }
  7551. }
  7552. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7553. $KOP = true;
  7554. }
  7555. }
  7556. foreach ( $roleArrayCopy as $k => $v ) {
  7557. foreach ( $verifyList as $m => $n ) {
  7558. if ($n [0] == $k) {
  7559. array_splice ( $verifyList, $m, 1, $v );
  7560. }
  7561. }
  7562. }
  7563. $receiptList [$key] ['verifyList'] = $verifyList;
  7564. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7565. 'where' => 'sid=' . $value ['staff'],
  7566. 'asArray' => true
  7567. ) );
  7568. $receiptList [$key] ['button'] = $button;
  7569. }
  7570. $mothHtml = "";
  7571. for($i = 1; $i <= 12; $i ++) {
  7572. if ($month == $i)
  7573. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7574. else
  7575. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7576. }
  7577. // 获取审批日志
  7578. Doo::loadModel ( 'receiptLog' );
  7579. $receiptLog = new receiptLog ();
  7580. $rlList = array ();
  7581. $rlInfo = $receiptLog->getOne ( array (
  7582. 'where' => 'rid=' . $rid . ' and status=4',
  7583. 'asArray' => true
  7584. ) );
  7585. $tijdate = $receiptLog->getOne ( array (
  7586. 'where' => 'rid=' . $rid . ' and status=2',
  7587. 'asc' => 'rlid',
  7588. 'asArray' => true
  7589. ) );
  7590. if (! empty ( $rlInfo )) {
  7591. $rlList = $receiptLog->find ( array (
  7592. 'where' => 'rid=' . $rid,
  7593. 'asc' => 'rlid',
  7594. 'asArray' => true
  7595. ) );
  7596. }
  7597. $receiptList [0] ['rlList'] = $rlList;
  7598. $enclosurList = $enclosur->find ( array (
  7599. 'where' => 'rid=' . $rid,
  7600. 'asArray' => true
  7601. ) );
  7602. $enclosurHtml = '';
  7603. foreach ( $enclosurList as $value ) {
  7604. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  7605. }
  7606. $data ['enclosurHtml'] = $enclosurHtml;
  7607. $data ['rolename'] = $rolename ['name'];
  7608. $data ['datetij'] = $tijdate ['date'];
  7609. $data ['mothHtml'] = $mothHtml;
  7610. $data ['receiptList'] = $receiptList;
  7611. $data ['receiptApprovalCount'] = count ( $receiptList );
  7612. $data ['year'] = $year;
  7613. $data ['categoryList'] = $categoryList;
  7614. $data ['staffList'] = $staffList;
  7615. $data ['cid'] = $cid;
  7616. $data ['sid'] = $sid;
  7617. $data ['status'] = 0;
  7618. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  7619. $ap = 4;
  7620. } else
  7621. $data ['status'] = $receiptList [0] ['status'];
  7622. if ($receiptList [0] ['status'] == 4) {
  7623. $data ['status'] = 5;
  7624. $ap = 0;
  7625. }
  7626. $data ['ap'] = $ap;
  7627. $data ['memu'] = "receipt";
  7628. $data ['staff'] = $this->staff;
  7629. $data ['receiptMemu'] = 'approval';
  7630. $data ['verifyId'] = $this->verifyId;
  7631. $data ['executeId'] = $this->executeId;
  7632. $this->render ( "/admin/saeaReportListReport", $data );
  7633. }
  7634. function approvalEdi() {
  7635. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7636. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7637. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7638. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7639. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7640. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7641. if (empty ( $status ))
  7642. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7643. $vidList = array ();
  7644. $button = 0;
  7645. Doo::loadModel ( 'verify' );
  7646. Doo::loadModel ( 'receipt' );
  7647. Doo::loadModel ( 'staff' );
  7648. $staff = new staff ();
  7649. $receipt = new receipt ();
  7650. $verify = new verify ();
  7651. Doo::loadModel ( 'L_category' );
  7652. $Lcategory = new L_category ();
  7653. Doo::loadModel ( 'enclosur' );
  7654. $enclosur = new enclosur ();
  7655. // user verify ID
  7656. $verifyDetail = $verify->find ( array (
  7657. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7658. 'asArray' => true
  7659. ) );
  7660. foreach ( $verifyDetail as $key => $value ) {
  7661. array_push ( $vidList, $value ['vid'] );
  7662. }
  7663. $vid = implode ( ",", $vidList );
  7664. if (empty ( $verifyDetail ))
  7665. $vid = 0;
  7666. $categoryList = $Lcategory->find ( array (
  7667. 'asArray' => true
  7668. ) );
  7669. $staffList = $staff->find ( array (
  7670. 'where' => 'cid=' . $cid,
  7671. 'asArray' => true
  7672. ) );
  7673. $ap = "";
  7674. if ($status == 4) {
  7675. $ap = 4;
  7676. $status = 2;
  7677. }
  7678. // get Receipt By verifyID status 2
  7679. $receiptList = $receipt->find ( array (
  7680. 'where' => 'rid =' . $rid,
  7681. 'desc' => 'rid',
  7682. 'asArray' => true
  7683. ) );
  7684. $Locate = 0;
  7685. $roleId = 0;
  7686. if ($ap == 4)
  7687. $status = 4;
  7688. foreach ( $receiptList as $key => $value ) {
  7689. $receiptList [$key] ['Locate'] = $Locate;
  7690. $Locate ++;
  7691. $receiptList [$key] ['reviseDetail'] = array ();
  7692. if (! empty ( $value ['reviseDetail'] ))
  7693. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7694. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7695. $categoryDetil = $Lcategory->getOne ( array (
  7696. 'where' => 'cid=' . $value ['cid'],
  7697. 'asArray' => true
  7698. ) );
  7699. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7700. // 检测编辑状态
  7701. $verifyList = $verify->getOne ( array (
  7702. 'where' => 'vid=' . $value ['verify'],
  7703. 'asArray' => true
  7704. ) );
  7705. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7706. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7707. // print_r($verifyList);
  7708. //
  7709. // if (empty($verifyStaff)){
  7710. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  7711. // $verifyList[0]['status']=4;$button=4;
  7712. // }
  7713. //
  7714. // }else{
  7715. //
  7716. // }
  7717. // die;
  7718. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  7719. // echo array_search("green",$a);
  7720. //
  7721. Doo::loadModel ( 'role' );
  7722. $role = new role ();
  7723. // print_r($verifyList);
  7724. $flag = true;
  7725. $roleKey = 0;
  7726. $endStaffArray = array ();
  7727. $roleArrayCopy = array ();
  7728. foreach ( $verifyList as $k => $v ) {
  7729. // init verifyStaff
  7730. if ($v [1] == 'ROLE') {
  7731. if (! empty ( $verifyStaff )) {
  7732. $endStaffArray = end ( $verifyStaff );
  7733. if ($v [0] == $endStaffArray ['nextStaff']) {
  7734. $roleId = $v [0];
  7735. }
  7736. }
  7737. $roleVerify = json_decode ( $v [3], true );
  7738. $roleKey = $k;
  7739. $roleArray = array ();
  7740. $rolename = $role->getOne ( array (
  7741. 'where' => 'rid=' . $v [0],
  7742. 'asArray' => true
  7743. ) );
  7744. foreach ( $roleVerify as $o => $p ) {
  7745. $staffID = explode ( '_', $p );
  7746. $staffInfo = $staff->getOne ( array (
  7747. 'where' => 'sid=' . $staffID [0],
  7748. 'asArray' => true
  7749. ) );
  7750. // print_r($staffID);
  7751. $exp = array (
  7752. 0 => $staffInfo ['sid'],
  7753. 1 => $staffID [1],
  7754. 2 => $staffInfo ['avatar'],
  7755. 'date' => '',
  7756. 'date' => '',
  7757. 'opinion' => '',
  7758. 'status' => '',
  7759. 'rolename' => $rolename ['name']
  7760. );
  7761. array_push ( $roleArray, $exp );
  7762. }
  7763. $roleArrayCopy [$v [0]] = $roleArray;
  7764. // $verifyList[$k]['roleArray']=$roleArray;
  7765. }
  7766. // print_r($roleArray);
  7767. $verifyList [$k] ['date'] = "";
  7768. $verifyList [$k] ['opinion'] = "";
  7769. $verifyList [$k] ['status'] = "";
  7770. if (empty ( $verifyStaff )) {
  7771. $verifyList [$k] ['date'] = "";
  7772. $verifyList [$k] ['opinion'] = "";
  7773. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7774. $verifyList [$k] ['status'] = 4;
  7775. $button = 4;
  7776. $flag = false;
  7777. }
  7778. } else {
  7779. foreach ( $verifyStaff as $m => $u ) {
  7780. if ($v [0] == $m) {
  7781. $verifyList [$k] ['date'] = $u ['date'];
  7782. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7783. $verifyList [$k] ['status'] = $u ['status'];
  7784. $flag = false;
  7785. break;
  7786. }
  7787. }
  7788. $endStaffArray = end ( $verifyStaff );
  7789. if (isset ( $endStaffArray ['ROLE'] )) {
  7790. } else {
  7791. $endKey = key ( $verifyStaff );
  7792. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7793. $button = 4;
  7794. $verifyList [$k] ['status'] = 4;
  7795. }
  7796. }
  7797. // print_r($endStaffArray);die;
  7798. // if (empty($verifyStaff)){
  7799. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  7800. // $verifyList[$k]['status']=4;$button=4;
  7801. // }
  7802. //
  7803. // }else{
  7804. //
  7805. // }
  7806. // if($flag){//检测可编辑
  7807. // if($v[0]==$this->staff[0]['sid']){
  7808. // $verifyList[$k]['status']=4;$button=4;
  7809. // }
  7810. // }
  7811. }
  7812. }
  7813. $rolename ['name'] = '';
  7814. if (! empty ( $roleId )) {
  7815. Doo::loadModel ( 'role' );
  7816. $role = new role ();
  7817. $rolename = $role->getOne ( array (
  7818. 'where' => 'rid=' . $roleId,
  7819. 'asArray' => true
  7820. ) );
  7821. }
  7822. if (! empty ( $verifyStaff ))
  7823. $endStaffArray = end ( $verifyStaff );
  7824. $KOP = false;
  7825. foreach ( $roleArrayCopy as $P => $A ) {
  7826. foreach ( $A as $MKI => $AVL ) {
  7827. if (! empty ( $verifyStaff )) {
  7828. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7829. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7830. $button = 4;
  7831. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7832. }
  7833. foreach ( $verifyStaff as $m => $u ) {
  7834. $AVLFK = $AVL [0] . '_R';
  7835. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7836. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7837. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7838. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7839. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7840. break;
  7841. }
  7842. }
  7843. } else {
  7844. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7845. $button = 4;
  7846. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7847. }
  7848. }
  7849. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7850. $KOP = true;
  7851. }
  7852. }
  7853. // print_r($roleArrayCopy);
  7854. // echo $roleKey;
  7855. foreach ( $roleArrayCopy as $k => $v ) {
  7856. foreach ( $verifyList as $m => $n ) {
  7857. if ($n [0] == $k) {
  7858. array_splice ( $verifyList, $m, 1, $v );
  7859. }
  7860. }
  7861. }
  7862. // if ($KOP)
  7863. // array_splice($verifyList,$roleKey,1,$roleArray);
  7864. // print_r($verifyList);
  7865. $receiptList [$key] ['verifyList'] = $verifyList;
  7866. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7867. 'where' => 'sid=' . $value ['staff'],
  7868. 'asArray' => true
  7869. ) );
  7870. $receiptList [$key] ['button'] = $button;
  7871. }
  7872. // $data['verifyDetail']=$verifyDetail;
  7873. $mothHtml = "";
  7874. for($i = 1; $i <= 12; $i ++) {
  7875. if ($month == $i)
  7876. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7877. else
  7878. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7879. }
  7880. // 获取审批日志
  7881. Doo::loadModel ( 'receiptLog' );
  7882. $receiptLog = new receiptLog ();
  7883. $rlList = array ();
  7884. $rlInfo = $receiptLog->getOne ( array (
  7885. 'where' => 'rid=' . $rid . ' and status=4',
  7886. 'asArray' => true
  7887. ) );
  7888. $tijdate = $receiptLog->getOne ( array (
  7889. 'where' => 'rid=' . $rid . ' and status=2',
  7890. 'asc' => 'rlid',
  7891. 'asArray' => true
  7892. ) );
  7893. if (! empty ( $rlInfo )) {
  7894. $rlList = $receiptLog->find ( array (
  7895. 'where' => 'rid=' . $rid,
  7896. 'asc' => 'rlid',
  7897. 'asArray' => true
  7898. ) );
  7899. }
  7900. $receiptList [0] ['rlList'] = $rlList;
  7901. $enclosurList = $enclosur->find ( array (
  7902. 'where' => 'rid=' . $rid,
  7903. 'asArray' => true
  7904. ) );
  7905. $enclosurHtml = '';
  7906. foreach ( $enclosurList as $value ) {
  7907. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  7908. }
  7909. $data ['enclosurHtml'] = $enclosurHtml;
  7910. $data ['rolename'] = $rolename ['name'];
  7911. $data ['datetij'] = $tijdate ['date'];
  7912. $data ['mothHtml'] = $mothHtml;
  7913. $data ['receiptList'] = $receiptList;
  7914. $data ['receiptApprovalCount'] = count ( $receiptList );
  7915. $data ['status'] = $status;
  7916. $data ['year'] = $year;
  7917. $data ['categoryList'] = $categoryList;
  7918. $data ['staffList'] = $staffList;
  7919. $data ['cid'] = $cid;
  7920. $data ['sid'] = $sid;
  7921. $data ['ap'] = $ap;
  7922. $data ['memu'] = "receipt";
  7923. $data ['staff'] = $this->staff;
  7924. $data ['receiptMemu'] = 'approval';
  7925. $data ['verifyId'] = $this->verifyId;
  7926. $data ['executeId'] = $this->executeId;
  7927. $this->render ( "/admin/saeaReportListReport", $data );
  7928. }
  7929. function remittanceHky() {
  7930. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7931. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  7932. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  7933. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  7934. $page_size = 15;
  7935. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  7936. Doo::loadModel ( 'receipt' );
  7937. $receipt = new receipt ();
  7938. Doo::loadModel ( 'staff' );
  7939. $staff = new staff ();
  7940. $dateCondition = " and Year(executeDate) =" . $year;
  7941. if ($moth != 'MONTH')
  7942. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  7943. if ($day != 'DAY' && $moth != 'MONTH')
  7944. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  7945. $sql = ' (status =8 or status=9 ) and amount>0 ' . $dateCondition;
  7946. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  7947. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  7948. $limit = $pageinfo ['lower'] . ',' . $page_size;
  7949. $dayList = $receipt->find ( array (
  7950. 'select' => 'executeDate,sum(amount) as amount',
  7951. 'where' => $sql,
  7952. 'desc' => 'executeDate',
  7953. 'groupby' => 'executeDate',
  7954. 'limit' => $limit,
  7955. 'asArray' => true
  7956. ) );
  7957. // print_r($dayList);
  7958. foreach ( $dayList as $key => $value ) {
  7959. $remitString = "";
  7960. $receiptList = $receipt->find ( array (
  7961. 'select' => 'rid,executeDate,amount,staff,cid',
  7962. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  7963. 'desc' => 'executeDate',
  7964. 'asArray' => true
  7965. ) );
  7966. foreach ( $receiptList as $k => $v ) {
  7967. $sinfo = $staff->getOne ( array (
  7968. 'select' => 'username,category',
  7969. 'where' => ' sid=' . $v ['staff'],
  7970. 'asArray' => true
  7971. ) );
  7972. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  7973. }
  7974. $dayList [$key] ['staff'] = $remitString;
  7975. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  7976. }
  7977. // print_r($dayList);
  7978. $mothHtml = "";
  7979. for($i = 1; $i <= 12; $i ++) {
  7980. if ($moth == $i)
  7981. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7982. else
  7983. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7984. }
  7985. $dayHtml = "";
  7986. if ($day != "DAY" || $moth != "MONTH") {
  7987. for($i = 1; $i <= 31; $i ++) {
  7988. if ($day == $i)
  7989. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  7990. else
  7991. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  7992. }
  7993. }
  7994. $dateHtml = "";
  7995. $now = date ( "Y" );
  7996. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  7997. if ($YEARD <= $now) {
  7998. $dateHtml .= '<option ';
  7999. if ($year == $YEARD) {
  8000. $dateHtml .= 'selected ';
  8001. }
  8002. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  8003. }
  8004. }
  8005. $data ['dateHtml'] = $dateHtml;
  8006. $data ['page'] = $pageinfo;
  8007. $data ['year'] = $year;
  8008. $data ['moth'] = $moth;
  8009. $data ['day'] = $day;
  8010. $data ['get'] = $get;
  8011. $data ['dayHtml'] = $dayHtml;
  8012. $data ['mothHtml'] = $mothHtml;
  8013. $data ['receiptList'] = $dayList;
  8014. $data ['memu'] = "receipt";
  8015. $data ['staff'] = $this->staff;
  8016. $data ['receiptMemu'] = 'remittanceHky';
  8017. $data ['verifyId'] = $this->verifyId;
  8018. $data ['executeId'] = $this->executeId;
  8019. $this->render ( "/admin/remittanceHky", $data );
  8020. }
  8021. function remittancep() {
  8022. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  8023. Doo::loadModel ( 'receipt' );
  8024. $receipt = new receipt ();
  8025. Doo::loadModel ( 'staff' );
  8026. $staff = new staff ();
  8027. Doo::loadClass ( 'XDeode' );
  8028. $XDeode = new XDeode ( 5 );
  8029. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  8030. $rplist = $receipt->find ( array (
  8031. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8032. 'asArray' => true
  8033. ) );
  8034. $dayList = $receipt->find ( array (
  8035. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8036. 'desc' => 'executeDate',
  8037. 'groupby' => 'staff',
  8038. 'asArray' => true
  8039. ) );
  8040. $html = '';
  8041. foreach ( $dayList as $key => $value ) {
  8042. $sinfo = $staff->getOne ( array (
  8043. 'select' => 'username,category',
  8044. 'where' => ' sid=' . $value ['staff'],
  8045. 'asArray' => true
  8046. ) );
  8047. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  8048. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  8049. $au = 0;
  8050. foreach ( $rplist as $k => $v ) {
  8051. if ($value ['staff'] == $v ['staff']) {
  8052. $html .= '<tr><td><a href="#saea-detail" node-invoice="INFO" data-iskey="' . $XDeode->encode ( $v ['rid'] ) . '" data-toggle="modal">' . $v ['receiptOrder'] . '</a></td><td class="taR">¥' . $v ['amount'] . '</td></tr>';
  8053. $au += $v ['amount'];
  8054. }
  8055. }
  8056. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  8057. }
  8058. $data ['html'] = $html;
  8059. $data ['memu'] = "receipt";
  8060. $data ['staff'] = $this->staff;
  8061. $data ['receiptMemu'] = 'remittanceHky';
  8062. $data ['verifyId'] = $this->verifyId;
  8063. $data ['executeId'] = $this->executeId;
  8064. $this->render ( "/admin/remittancep", $data );
  8065. }
  8066. function ajaxGetReceiptDetails() {
  8067. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  8068. Doo::loadClass ( 'XDeode' );
  8069. $XDeode = new XDeode ( 5 );
  8070. $rid = $XDeode->decode ( $rid );
  8071. if (empty ( $rid )) {
  8072. echo json_encode ( array (
  8073. 'status' => 2,
  8074. 'msg' => 'illegal request'
  8075. ) );
  8076. die ();
  8077. }
  8078. Doo::loadModel ( 'receipt' );
  8079. $receipt = new receipt ();
  8080. Doo::loadModel ( 'staff' );
  8081. $staff = new staff ();
  8082. $rinfo = $receipt->getOne ( array (
  8083. 'where' => 'rid= ' . $rid,
  8084. 'asArray' => true
  8085. ) );
  8086. $sinfo = $staff->getOne ( array (
  8087. 'select' => 'username,category',
  8088. 'where' => ' sid=' . $rinfo ['staff'],
  8089. 'asArray' => true
  8090. ) );
  8091. $rinfo ['reviseDetail'] = array ();
  8092. if (! empty ( $rinfo ['reviseDetail'] ))
  8093. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  8094. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  8095. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  8096. $rinfo ['category'] = $sinfo ['category'];
  8097. $verifyStaff = array ();
  8098. if (! empty ( $rinfo ['verifyStaff'] ))
  8099. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  8100. $relust = bcsub ( $rinfo ['sum'], $rinfo ['loanSum'], 2 );
  8101. $rinfo ['relust'] = $relust;
  8102. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  8103. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  8104. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  8105. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  8106. // 费用执行人相关数据
  8107. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  8108. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  8109. foreach ( $executeCopy as $k => $v ) {
  8110. $executeCopy [$k] ['date'] = '';
  8111. $executeCopy [$k] ['opinion'] = '';
  8112. $executeCopy [$k] ['status'] = '';
  8113. if (! empty ( $executeStaff ))
  8114. foreach ( $executeStaff as $m => $u ) {
  8115. if ($v [0] == $m) {
  8116. $executeCopy [$k] ['date'] = $u ['date'];
  8117. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  8118. $executeCopy [$k] ['status'] = $u ['status'];
  8119. break;
  8120. }
  8121. }
  8122. }
  8123. $rinfo ['executeCopy'] = $executeCopy;
  8124. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  8125. if ($rinfo ['Rtype'] == 1) { // 借款费用
  8126. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8127. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  8128. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  8129. $html .= '<tr><th>' . $value ['name'] . '</th>
  8130. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8131. }
  8132. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8133. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8134. <tr><th class="taC" colspan="2">费用说明</th>
  8135. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8136. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8137. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  8138. </tbody></table>';
  8139. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  8140. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8141. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8142. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8143. $html .= '<tr><th>' . $value ['name'] . '</th>
  8144. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8145. }
  8146. $html .= '<tr><th class="taR">合计</th>
  8147. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8148. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8149. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8150. $html .= '<tr><th>' . $value ['name'] . '</th>
  8151. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8152. }
  8153. $html .= '<tr><th class="taR">合计</th>
  8154. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8155. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8156. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8157. $html .= '<tr><th>' . $value ['name'] . '</th>
  8158. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8159. }
  8160. $html .= '<tr><th class="taR">合计</th>
  8161. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8162. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8163. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8164. $html .= '<tr><th>' . $value ['name'] . '</th>
  8165. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8166. }
  8167. $html .= '<tr><th class="taR">合计</th>
  8168. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8169. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8170. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8171. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8172. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8173. }
  8174. $html .= '<tr><th class="taR">合计</th>
  8175. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8176. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8177. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8178. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8179. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8180. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8181. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8182. <tr';
  8183. if ($rinfo ['relust'] >= 0) {
  8184. $html .= 'class="success"';
  8185. } else {
  8186. $html .= 'class="error"';
  8187. }
  8188. $html .= '><td class="taR"><b>借款结余</b></td>
  8189. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  8190. </tbody></table>
  8191. ';
  8192. }
  8193. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  8194. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8195. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  8196. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8197. $html .= '<tr><th>' . $value ['name'] . '</th>
  8198. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8199. }
  8200. $html .= '<tr><th class="taR">合计</th>
  8201. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8202. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8203. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8204. <tr><th class="taC" colspan="2">费用说明</th>
  8205. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8206. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8207. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8208. </tbody></table>';
  8209. } else {
  8210. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8211. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8212. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8213. $html .= '<tr><th>' . $value ['name'] . '</th>
  8214. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8215. }
  8216. $html .= '<tr><th class="taR">合计</th>
  8217. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8218. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8219. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8220. $html .= '<tr><th>' . $value ['name'] . '</th>
  8221. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8222. }
  8223. $html .= '<tr><th class="taR">合计</th>
  8224. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8225. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8226. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8227. $html .= '<tr><th>' . $value ['name'] . '</th>
  8228. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8229. }
  8230. $html .= '<tr><th class="taR">合计</th>
  8231. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8232. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8233. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8234. $html .= '<tr><th>' . $value ['name'] . '</th>
  8235. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8236. }
  8237. $html .= '<tr><th class="taR">合计</th>
  8238. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8239. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8240. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8241. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8242. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8243. }
  8244. $html .= '<tr><th class="taR">合计</th>
  8245. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8246. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8247. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8248. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8249. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8250. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8251. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  8252. $html .= '</tbody></table>';
  8253. /*
  8254. * <table class="table table-bordered table-condensed table-hover"> <tbody> <tr><th colspan="2" class="taC">日常相关费用</th></tr> <!-- loop receiptList' value.accountItem.日常相关费用 --> <tr><th>{{receiptList' value' value.name}}</th><td width="140" class="taR">¥{{receiptList' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptList' value.accountItem.cSum.agencySum}}</td></tr> <tr><th colspan="2" class="taC">差旅相关费用</th></tr> <!-- loop receiptDetail' value.accountItem.差旅相关费用 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.travelSum}}</td></tr> <tr><th colspan="2" class="taC">培训班费用</th></tr> <!-- loop receiptDetail' value.accountItem.培训班费用 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.trainSum}}</td></tr> <tr><th colspan="2" class="taC">其他</th></tr> <!-- loop receiptDetail' value.accountItem.其他 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.otherSum}}</td></tr> <tr><th colspan="2" class="taC">报销金额调整</th></tr> <!-- loop receiptList' value.reviseDetail --> <tr><th><span class="interval">|</span>{{receiptList' value' value.name}}:{{receiptList' value' value.description}}</th><td class="taR">¥{{receiptList' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colOrange taR">¥{{receiptList' value.revisePrice}}</td></tr> <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr> <tr><th style="text-align:center" colspan="2">{{receiptDetail' value.category}}</th></tr> <tr><th class="taC" colspan="2">报销说明</th></tr> <tr><td colspan="2">{{receiptDetail' value.explanation}}</td></tr> <tr class="warning"><td class="taR"><b>({{receiptDetail' value.receiptOrder}})本次报销费用合计</b></td> <td class="colGreed taR"><b style="font-size:24px">¥{{receiptDetail' value.sum}}</b><br>{{receiptDetail' value.sumCN}}</td></tr> </tbody> </table>
  8255. */
  8256. }
  8257. // print_r($verifyStaff);die;
  8258. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  8259. foreach ( $verifyStaff as $key => $value ) {
  8260. $key = trim ( strtr ( $key, '_R', ' ' ) );
  8261. $sinfo = $staff->getOne ( array (
  8262. 'select' => 'username',
  8263. 'where' => ' sid=' . $key,
  8264. 'asArray' => true
  8265. ) );
  8266. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8267. }
  8268. $html .= '</tbody></table>';
  8269. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  8270. foreach ( $rinfo ['executeCopy'] as $value ) {
  8271. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8272. }
  8273. $html .= '</tbody></table>';
  8274. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  8275. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  8276. </tr></table>';
  8277. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  8278. echo json_encode ( array (
  8279. 'status' => 1,
  8280. 'html' => $html
  8281. ) );
  8282. die ();
  8283. }
  8284. /**
  8285. * 删除附件
  8286. */
  8287. function ajaxRemEnclousur() {
  8288. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  8289. if (empty ( $key ))
  8290. echo json_encode ( array (
  8291. 'status' => 2
  8292. ) );
  8293. Doo::loadModel ( 'enclosur' );
  8294. $enclosur = new enclosur ();
  8295. $enclosur->delEnclosurByEid ( $key );
  8296. echo json_encode ( array (
  8297. 'status' => 1
  8298. ) );
  8299. }
  8300. function remittance() {
  8301. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8302. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8303. Doo::loadModel ( 'receipt' );
  8304. $receipt = new receipt ();
  8305. Doo::loadModel ( 'staff' );
  8306. $staff = new staff ();
  8307. $dateCondition = " and Year(pastDate) =" . $year;
  8308. if (! empty ( $month ))
  8309. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  8310. // get Receipt By verifyID status 1
  8311. $receiptList = $receipt->find ( array (
  8312. 'select' => 'sum(sum) as sum,staff,pastDate',
  8313. 'where' => ' status=1' . $dateCondition,
  8314. 'desc' => 'pastDate',
  8315. 'groupby' => 'staff,pastDate',
  8316. 'asArray' => true
  8317. ) );
  8318. $dateList = $receipt->find ( array (
  8319. 'select' => 'pastDate,verifyStaff',
  8320. 'where' => ' status=1' . $dateCondition,
  8321. 'desc' => 'pastDate',
  8322. 'groupby' => 'pastDate',
  8323. 'asArray' => true
  8324. ) );
  8325. $dataList = array ();
  8326. foreach ( $dateList as $d => $a ) {
  8327. $dataList [$a ['pastDate']] = array ();
  8328. $daySum = 0;
  8329. foreach ( $receiptList as $key => $value ) {
  8330. if ($a ['pastDate'] == $value ['pastDate']) {
  8331. $oderList = $receipt->find ( array (
  8332. 'select' => 'receiptOrder',
  8333. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  8334. 'asArray' => true
  8335. ) );
  8336. $list = array ();
  8337. $html = "";
  8338. foreach ( $oderList as $v ) {
  8339. array_push ( $list, $v ['receiptOrder'] );
  8340. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  8341. }
  8342. $receiptList [$key] ['receiptOrder'] = $html;
  8343. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  8344. $sinfo = $staff->getOne ( array (
  8345. 'select' => 'username ',
  8346. 'where' => ' sid=' . $value ['staff'],
  8347. 'asArray' => true
  8348. ) );
  8349. $receiptList [$key] ['username'] = $sinfo ['username'];
  8350. $daySum += $value ['sum'];
  8351. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  8352. }
  8353. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  8354. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  8355. }
  8356. }
  8357. // print_r($dataList);
  8358. $data ['dataList'] = $dataList;
  8359. $mothHtml = "";
  8360. for($i = 1; $i <= 12; $i ++) {
  8361. if ($month == $i)
  8362. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8363. else
  8364. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8365. }
  8366. $data ['year'] = $year;
  8367. $data ['mothHtml'] = $mothHtml;
  8368. $data ['memu'] = "receipt";
  8369. $data ['staff'] = $this->staff;
  8370. $data ['receiptMemu'] = 'approval';
  8371. $data ['verifyId'] = $this->verifyId;
  8372. $data ['executeId'] = $this->executeId;
  8373. $this->render ( "/admin/saeaReportListPay", $data );
  8374. }
  8375. /**
  8376. * 金额调整,提高稳定性
  8377. * @return string
  8378. */
  8379. function revocationAdjustment() {
  8380. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  8381. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  8382. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  8383. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  8384. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  8385. Doo::loadClass ( 'XDeode' );
  8386. $XDeode = new XDeode ( 5 );
  8387. Doo::loadModel ( 'receipt' );
  8388. $receipt = new receipt ();
  8389. $sid = $XDeode->decode ( $sidKey );
  8390. $rid = $XDeode->decode ( $ridKey );
  8391. $reviseKey = $XDeode->decode ( $reviseKey );
  8392. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  8393. die ( 'illegal request' );
  8394. $receiptDetail = $receipt->getOne ( array (
  8395. 'where' => 'rid=' . $rid,
  8396. 'asArray' => true
  8397. ) );
  8398. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  8399. die ( 'illegal request' );
  8400. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8401. if (! isset ( $reviseDetail [$reviseKey] ))
  8402. die ( 'illegal request' );
  8403. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  8404. unset ( $reviseDetail [$reviseKey] );
  8405. $revisePrice = 0;
  8406. foreach ( $reviseDetail as $key => $value ) {
  8407. $revisePrice += $value ['price'];
  8408. }
  8409. $reviseDetailString = json_encode ( $reviseDetail );
  8410. $receipt->reviseDetail = $reviseDetailString;
  8411. $receipt->sum = $receiptDetail ['sum'] - $price;
  8412. $receipt->revisePrice = $revisePrice;
  8413. $receipt->update ( array (
  8414. 'where' => 'rid=' . $rid
  8415. ) );
  8416. return '/receiptburEdi/' . $rid;
  8417. } else
  8418. die ( 'illegal request2' );
  8419. }
  8420. function updateApprovalReceipt() {
  8421. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  8422. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  8423. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8424. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  8425. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  8426. if (! empty ( $rid )) {
  8427. Doo::loadModel ( "verify" );
  8428. $verify = new verify ();
  8429. Doo::loadModel ( "receiptDetail" );
  8430. $receiptDetailObj = new receiptDetail ();
  8431. Doo::loadModel ( "itemStatistics" );
  8432. Doo::loadModel ( "statistics" );
  8433. $statistics = new statistics ();
  8434. $itemStatistics = new itemStatistics ();
  8435. Doo::loadModel ( "receipt" );
  8436. $receipt = new receipt ();
  8437. $receiptDetail = $receipt->getOne ( array (
  8438. 'where' => 'rid=' . $rid . ' and status=2 ',
  8439. 'asArray' => true
  8440. ) );
  8441. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  8442. $nsflag = true;
  8443. foreach ( $nslist as $value ) {
  8444. if ($value == $this->staff ['0'] ['sid']) {
  8445. $nsflag = false;
  8446. break;
  8447. }
  8448. }
  8449. if (empty ( $receiptDetail ) || $nsflag)
  8450. return "/approvalExpenses/pendApproval";
  8451. $verifyDetail = $verify->getOne ( array (
  8452. 'where' => ' vid =' . $receiptDetail ['verify'],
  8453. 'asArray' => true
  8454. ) );
  8455. $verifyString = $verifyDetail ['staff'];
  8456. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  8457. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  8458. if (empty ( $opinion )) {
  8459. if ($status == 3)
  8460. $opinion = "终止";
  8461. else
  8462. $opinion = "同意支付";
  8463. }
  8464. $nowStaff = 0;
  8465. $nowStaffList = array ();
  8466. if (empty ( $verifyStaff )) {
  8467. // 还需加入是否已经进入角色审批
  8468. if ($verifyDetail [0] [1] == 'ROLE') {
  8469. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  8470. foreach ( $vStaffString as $key => $value ) {
  8471. $staffK = explode ( "_", $value );
  8472. if ($staffK [0] != $this->staff [0] ['sid'])
  8473. array_push ( $nowStaffList, $staffK [0] );
  8474. }
  8475. // print_r($verifyDetail);
  8476. // die;
  8477. if (! empty ( $nowStaffList )) {
  8478. $nowStaff = implode ( ',', $nowStaffList );
  8479. $verifyStaff = array (
  8480. $this->staff [0] ['sid'] . "_R" => array (
  8481. 'date' => date ( 'Y-m-d' ),
  8482. 'opinion' => $opinion,
  8483. 'status' => $status,
  8484. 'nextStaff' => $verifyDetail [0] [0],
  8485. 'ROLE' => 1
  8486. )
  8487. );
  8488. } else {
  8489. $nowStaff = $verifyDetail [1] [0];
  8490. $verifyStaff = array (
  8491. $this->staff [0] ['sid'] . "_R" => array (
  8492. 'date' => date ( 'Y-m-d' ),
  8493. 'opinion' => $opinion,
  8494. 'status' => $status,
  8495. 'nextStaff' => $verifyDetail [1] [0]
  8496. )
  8497. );
  8498. }
  8499. } else {
  8500. if ($verifyDetail [1] [1] == 'ROLE') {
  8501. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  8502. // echo "dd";
  8503. foreach ( $vStaffString as $key => $value ) {
  8504. $staffK = explode ( "_", $value );
  8505. array_push ( $nowStaffList, $staffK [0] );
  8506. }
  8507. $nowStaff = implode ( ',', $nowStaffList );
  8508. $verifyStaff = array (
  8509. $this->staff [0] ['sid'] => array (
  8510. 'date' => date ( 'Y-m-d' ),
  8511. 'opinion' => $opinion,
  8512. 'status' => $status,
  8513. 'nextStaff' => $verifyDetail [1] [0],
  8514. 'ROLE' => 1
  8515. )
  8516. );
  8517. } else {
  8518. $nowStaff = $verifyDetail [1] [0];
  8519. $verifyStaff = array (
  8520. $this->staff [0] ['sid'] => array (
  8521. 'date' => date ( 'Y-m-d' ),
  8522. 'opinion' => $opinion,
  8523. 'status' => $status,
  8524. 'nextStaff' => $verifyDetail [1] [0]
  8525. )
  8526. );
  8527. }
  8528. }
  8529. if ($status == 3)
  8530. $verifyStaff = array (
  8531. 'final' => $status,
  8532. $this->staff [0] ['sid'] => array (
  8533. 'date' => date ( 'Y-m-d' ),
  8534. 'opinion' => $opinion,
  8535. 'status' => $status
  8536. )
  8537. );
  8538. $vStaffString = json_encode ( $verifyStaff );
  8539. $receipt->nowStaff = $nowStaff;
  8540. $receipt->verifyStaff = $vStaffString;
  8541. } else {
  8542. $VS = end ( $verifyStaff );
  8543. // 非角色审批
  8544. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  8545. $nextStaff = 0;
  8546. $roleSTF = false;
  8547. foreach ( $verifyDetail as $key => $value ) {
  8548. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  8549. if (isset ( $verifyDetail [$key + 1] )) {
  8550. $nextStaff = $verifyDetail [$key + 1] [0];
  8551. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  8552. $roleSTF = true;
  8553. }
  8554. break;
  8555. }
  8556. }
  8557. if (! $roleSTF) {
  8558. $nowStaff = $nextStaff;
  8559. $verifyStaff [$this->staff [0] ['sid']] = array (
  8560. 'date' => date ( 'Y-m-d' ),
  8561. 'opinion' => $opinion,
  8562. 'status' => $status,
  8563. 'nextStaff' => $nextStaff
  8564. );
  8565. } else {
  8566. // 获取角色下的所有用户ID
  8567. $nowStaffList = array ();
  8568. foreach ( $verifyDetail as $vfk ) {
  8569. if ($vfk [1] == 'ROLE') {
  8570. $vStaffString = json_decode ( $vfk [3] );
  8571. foreach ( $vStaffString as $key => $value ) {
  8572. $staffK = explode ( "_", $value );
  8573. array_push ( $nowStaffList, $staffK [0] );
  8574. }
  8575. }
  8576. }
  8577. $nowStaff = implode ( ',', $nowStaffList );
  8578. $verifyStaff [$this->staff [0] ['sid']] = array (
  8579. 'date' => date ( 'Y-m-d' ),
  8580. 'opinion' => $opinion,
  8581. 'status' => $status,
  8582. 'nextStaff' => $nextStaff,
  8583. 'ROLE' => 0
  8584. );
  8585. }
  8586. if ($status == 3) {
  8587. $verifyStaff ['final'] = $status;
  8588. $verifyStaff [$this->staff [0] ['sid']] = array (
  8589. 'date' => date ( 'Y-m-d' ),
  8590. 'opinion' => $opinion,
  8591. 'status' => $status
  8592. );
  8593. }
  8594. $vStaffString = json_encode ( $verifyStaff );
  8595. $receipt->nowStaff = $nowStaff;
  8596. $receipt->verifyStaff = $vStaffString;
  8597. }
  8598. // 角色审批
  8599. if (isset ( $VS ['ROLE'] )) {
  8600. // 找出角色人 当前审批角色组
  8601. $verifyJSStaff = array ();
  8602. $nowStaffList2 = array ();
  8603. foreach ( $verifyDetail as $key => $value ) {
  8604. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  8605. $verifyJSStaff = json_decode ( $value [3] );
  8606. foreach ( $verifyJSStaff as $m ) {
  8607. $staffK = explode ( "_", $m );
  8608. array_push ( $nowStaffList2, $staffK [0] );
  8609. }
  8610. // print_r($nowStaffList2);
  8611. }
  8612. }
  8613. $RoleVerifyStaff = array ();
  8614. foreach ( $verifyStaff as $key => $value ) {
  8615. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  8616. foreach ( $nowStaffList2 as $m ) {
  8617. if ($key == $m . "_R")
  8618. $RoleVerifyStaff [$key] = $value;
  8619. }
  8620. }
  8621. }
  8622. // print_r($verifyStaff);
  8623. // print_r($nowStaffList2);
  8624. // print_r($RoleVerifyStaff);
  8625. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  8626. // print_r($verifyJSStaff);
  8627. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  8628. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  8629. // 下一个审批人ID
  8630. $nextStaff = 0;
  8631. $falg = false;
  8632. foreach ( $verifyDetail as $key => $value ) {
  8633. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  8634. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  8635. $falg = true;
  8636. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  8637. $nowStaffList = array ();
  8638. foreach ( $vStaffString as $v ) {
  8639. $staffK = explode ( "_", $v );
  8640. array_push ( $nowStaffList, $staffK [0] );
  8641. }
  8642. $nowStaff = implode ( ',', $nowStaffList );
  8643. $nextStaff = $verifyDetail [$key + 1] [0];
  8644. } elseif (isset ( $verifyDetail [$key + 1] )) {
  8645. $nextStaff = $verifyDetail [$key + 1] [0];
  8646. $nowStaff = $nextStaff;
  8647. } else
  8648. $nowStaff = '';
  8649. break;
  8650. }
  8651. }
  8652. if ($falg)
  8653. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8654. 'date' => date ( 'Y-m-d' ),
  8655. 'opinion' => $opinion,
  8656. 'status' => $status,
  8657. 'nextStaff' => $nextStaff,
  8658. 'ROLE' => 1
  8659. );
  8660. else
  8661. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8662. 'date' => date ( 'Y-m-d' ),
  8663. 'opinion' => $opinion,
  8664. 'status' => $status,
  8665. 'nextStaff' => $nextStaff
  8666. );
  8667. // print_r($verifyStaff);
  8668. // echo $nowStaff;die;
  8669. } else { // 进入下一个角色或者审批人
  8670. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  8671. //
  8672. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  8673. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8674. 'date' => date ( 'Y-m-d' ),
  8675. 'opinion' => $opinion,
  8676. 'status' => $status,
  8677. 'nextStaff' => $VS ['nextStaff'],
  8678. 'ROLE' => 1
  8679. );
  8680. // print_r($verifyStaff);
  8681. // die;
  8682. }
  8683. if ($status == 3) {
  8684. $verifyStaff ['final'] = $status;
  8685. $verifyStaff [$this->staff [0] ['sid']] = array (
  8686. 'date' => date ( 'Y-m-d' ),
  8687. 'opinion' => $opinion,
  8688. 'status' => $status
  8689. );
  8690. }
  8691. $vStaffString = json_encode ( $verifyStaff );
  8692. $receipt->verifyStaff = $vStaffString;
  8693. $receipt->nowStaff = $nowStaff;
  8694. // die;
  8695. // }
  8696. // print_r($verifyStaff);
  8697. // die;
  8698. }
  8699. // print_r($verifyStaff);die;
  8700. }
  8701. // print_r($verifyDetail);
  8702. $roleKey = 0;
  8703. $roleId = 0;
  8704. $verifyDetailCopy = array ();
  8705. foreach ( $verifyDetail as $k => $v ) {
  8706. if ($v [1] == 'ROLE') {
  8707. $roleId = $v [0];
  8708. $roleVerify = json_decode ( $v [3], true );
  8709. $roleKey = $k;
  8710. $roleArray = array ();
  8711. foreach ( $roleVerify as $o => $p ) {
  8712. $staffID = explode ( '_', $p );
  8713. $exp = array (
  8714. 0 => $staffID [0],
  8715. 1 => $staffID [1]
  8716. );
  8717. array_push ( $roleArray, $exp );
  8718. }
  8719. $verifyDetailCopy [$v [0]] = $roleArray;
  8720. }
  8721. }
  8722. // print_r($verifyDetail);
  8723. foreach ( $verifyDetailCopy as $k => $v ) {
  8724. foreach ( $verifyDetail as $m => $n ) {
  8725. if ($n [0] == $k) {
  8726. array_splice ( $verifyDetail, $m, 1, $v );
  8727. }
  8728. }
  8729. }
  8730. // die;
  8731. // if (!empty($roleArray))
  8732. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  8733. // echo $roleId;
  8734. // print_r($verifyStaff);
  8735. // print_r($verifyDetail);
  8736. // die;
  8737. Doo::loadModel ( "receiptLog" );
  8738. $receiptLog = new receiptLog ();
  8739. // 审批日志
  8740. if (! isset ( $verifyStaff ['final'] )) {
  8741. if (! empty ( $roleId )) {
  8742. Doo::loadModel ( "role" );
  8743. $role = new role ();
  8744. $roleInfo = $role->getOne ( array (
  8745. 'where' => 'rid=' . $roleId,
  8746. 'asArray' => true
  8747. ) );
  8748. $receiptLog->rolename = $roleInfo ['name'];
  8749. }
  8750. $receiptLog->username = $this->staff [0] ['username'];
  8751. $receiptLog->uid = $this->staff [0] ['sid'];
  8752. $receiptLog->date = date ( "Y-m-d" );
  8753. $receiptLog->opinion = $opinion;
  8754. $receiptLog->img = $this->staff [0] ['avatar'];
  8755. $receiptLog->status = 1;
  8756. $receiptLog->rid = $rid;
  8757. $receiptLog->insert ();
  8758. }
  8759. if (isset ( $verifyStaff ['final'] )) { // rDetail
  8760. $receipt->verifyBreakup = $verifyString;
  8761. $receipt->status = 3;
  8762. $receiptDetailObj->status = 3;
  8763. $receiptDetailObj->update ( array (
  8764. 'where' => 'rid=' . $rid
  8765. ) );
  8766. if (! empty ( $roleId )) {
  8767. Doo::loadModel ( "role" );
  8768. $role = new role ();
  8769. $roleInfo = $role->getOne ( array (
  8770. 'where' => 'rid=' . $roleId,
  8771. 'asArray' => true
  8772. ) );
  8773. $receiptLog->rolename = $roleInfo ['name'];
  8774. }
  8775. $receiptLog->username = $this->staff [0] ['username'];
  8776. $receiptLog->uid = $this->staff [0] ['sid'];
  8777. $receiptLog->date = date ( "Y-m-d" );
  8778. $receiptLog->opinion = $opinion;
  8779. $receiptLog->img = $this->staff [0] ['avatar'];
  8780. $receiptLog->status = 3;
  8781. $receiptLog->rid = $rid;
  8782. $receiptLog->insert ();
  8783. // 微信企业号通知
  8784. $this->setWXMsg ( $rid, 3 );
  8785. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  8786. $receipt->status = 1;
  8787. $reviseSum = 0;
  8788. $receipt->verifyBreakup = $verifyString;
  8789. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  8790. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8791. foreach ( $reviseDetail as $key => $value ) {
  8792. $receiptDetailObj = new receiptDetail ();
  8793. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8794. $receiptDetailObj->item = $value ['description'];
  8795. $receiptDetailObj->itemCategory = "报销金额调整";
  8796. $receiptDetailObj->price = $value ['price'];
  8797. $receiptDetailObj->date = $receiptDetail ['date'];
  8798. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  8799. $receiptDetailObj->rid = $rid;
  8800. $receiptDetailObj->status = 1;
  8801. $receiptDetailObj->insert ();
  8802. $reviseSum += $value ['price'];
  8803. }
  8804. $itemStatistics = new itemStatistics ();
  8805. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  8806. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8807. $itemStatistics->price = $reviseSum;
  8808. $itemStatistics->itemCategory = "报销金额调整";
  8809. $itemStatistics->date = $receiptDetail ['date'];
  8810. $itemStatistics->insert ();
  8811. }
  8812. $receiptDetailObj = new receiptDetail ();
  8813. $receiptDetailObj->status = 1;
  8814. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  8815. $receiptDetailObj->update ( array (
  8816. 'where' => 'rid=' . $rid
  8817. ) );
  8818. $dateArray = explode ( "-", $receiptDetail ['date'] );
  8819. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  8820. $stat = $statistics->getOne ( array (
  8821. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  8822. 'asArray' => true
  8823. ) );
  8824. if (empty ( $stat )) {
  8825. $statistics->date = $receiptDetail ['date'];
  8826. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  8827. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8828. $statistics->agPrice = $receiptDetail ['sum'];
  8829. $statistics->rePrice = $reviseSum;
  8830. $statistics->insert ();
  8831. } else {
  8832. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  8833. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  8834. $statistics->update ( array (
  8835. 'where' => 'sid=' . $stat ['sid']
  8836. ) );
  8837. }
  8838. $dateArray = explode ( "-", $receiptDetail ['date'] );
  8839. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  8840. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  8841. foreach ( $accountItem ['cSum'] as $key => $value ) {
  8842. if ($key == "agencySum") {
  8843. $iStatistics = $itemStatistics->getOne ( array (
  8844. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  8845. 'asArray' => true
  8846. ) );
  8847. if (empty ( $iStatistics )) {
  8848. $itemStatistics->cid = $receiptDetail ['cid'];
  8849. ;
  8850. $itemStatistics->staff = $receiptDetail ['staff'];
  8851. $itemStatistics->price = $value;
  8852. $itemStatistics->itemCategory = $this->AGENCY;
  8853. $itemStatistics->date = $receiptDetail ['date'];
  8854. $itemStatistics->insert ();
  8855. } else {
  8856. if (! empty ( $value )) {
  8857. $itemStatistics->price = $value + $iStatistics ['price'];
  8858. $itemStatistics->update ( array (
  8859. 'where' => 'sid=' . $iStatistics ['sid']
  8860. ) );
  8861. }
  8862. }
  8863. } elseif ($key == "travelSum") {
  8864. $iStatistics = $itemStatistics->getOne ( array (
  8865. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  8866. 'asArray' => true
  8867. ) );
  8868. if (empty ( $iStatistics )) {
  8869. $itemStatistics->cid = $receiptDetail ['cid'];
  8870. $itemStatistics->staff = $receiptDetail ['staff'];
  8871. $itemStatistics->price = $value;
  8872. $itemStatistics->itemCategory = $this->TRAVEL;
  8873. $itemStatistics->date = $receiptDetail ['date'];
  8874. $itemStatistics->insert ();
  8875. } else {
  8876. if (! empty ( $value )) {
  8877. $itemStatistics->price = $value + $iStatistics ['price'];
  8878. $itemStatistics->update ( array (
  8879. 'where' => 'sid=' . $iStatistics ['sid']
  8880. ) );
  8881. }
  8882. }
  8883. } elseif ($key == "trainSum") {
  8884. $iStatistics = $itemStatistics->getOne ( array (
  8885. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  8886. 'asArray' => true
  8887. ) );
  8888. if (empty ( $iStatistics )) {
  8889. $itemStatistics->cid = $receiptDetail ['cid'];
  8890. $itemStatistics->staff = $receiptDetail ['staff'];
  8891. $itemStatistics->price = $value;
  8892. $itemStatistics->itemCategory = $this->TRAIN;
  8893. $itemStatistics->date = $receiptDetail ['date'];
  8894. $itemStatistics->insert ();
  8895. } else {
  8896. if (! empty ( $value )) {
  8897. $itemStatistics->price = $value + $iStatistics ['price'];
  8898. $itemStatistics->update ( array (
  8899. 'where' => 'sid=' . $iStatistics ['sid']
  8900. ) );
  8901. }
  8902. }
  8903. } elseif ($key == "otherSum") {
  8904. $iStatistics = $itemStatistics->getOne ( array (
  8905. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  8906. 'asArray' => true
  8907. ) );
  8908. if (empty ( $iStatistics )) {
  8909. $itemStatistics->cid = $receiptDetail ['cid'];
  8910. $itemStatistics->staff = $receiptDetail ['staff'];
  8911. $itemStatistics->price = $value;
  8912. $itemStatistics->itemCategory = $this->OTHER;
  8913. $itemStatistics->date = $receiptDetail ['date'];
  8914. $itemStatistics->insert ();
  8915. } else {
  8916. if (! empty ( $value )) {
  8917. $itemStatistics->price = $value + $iStatistics ['price'];
  8918. $itemStatistics->update ( array (
  8919. 'where' => 'sid=' . $iStatistics ['sid']
  8920. ) );
  8921. }
  8922. }
  8923. }
  8924. }
  8925. $receipt->pastDate = date ( "Y-m-d" );
  8926. // 微信企业号通知
  8927. $this->setWXMsg ( $rid, 1 );
  8928. }
  8929. //是否有流水
  8930. Doo::loadModel ( 'wasteBook' );
  8931. $wasteBook = new wasteBook ();
  8932. $accountType=3;
  8933. if ($receiptDetail['Rtype']==1){
  8934. $accountType=2;
  8935. }elseif($receiptDetail['Rtype']==2){
  8936. $accountType=4;
  8937. }
  8938. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $rid );
  8939. if (empty($wbDetail)){
  8940. $rsum=$receiptDetail['sum']-$receiptDetail['loanSum'];
  8941. $receipt->amount = $rsum;//$amount;
  8942. }
  8943. $receipt->update ( array (
  8944. 'where' => ' rid = ' . $rid
  8945. ) );
  8946. // 进入下一条审批费用新加需求
  8947. $vidList = array ();
  8948. $verifyDetail = $verify->find ( array (
  8949. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  8950. 'asArray' => true
  8951. ) );
  8952. foreach ( $verifyDetail as $key => $value ) {
  8953. array_push ( $vidList, $value ['vid'] );
  8954. }
  8955. $vid = implode ( ",", $vidList );
  8956. if (empty ( $verifyDetail ))
  8957. $vid = 0;
  8958. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  8959. $receipt = new receipt ();
  8960. $rd = $receipt->getOne ( array (
  8961. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ') and Rtype!=3',
  8962. 'asc' => 'rid',
  8963. 'asArray' => true
  8964. ) );
  8965. if (empty ( $rd )) {
  8966. return '/approvalExpenses/pendApproval';
  8967. }
  8968. if ($rd ['Rtype'] == 1) {
  8969. if ($rd ['isBK'] == 1) {
  8970. return '/receiptburEdi/' . $rd ['rid'];
  8971. } else {
  8972. return '/expensesEdi/' . $rd ['rid'];
  8973. }
  8974. } elseif ($rd ['Rtype'] == 2) {
  8975. return '/remitApproval/' . $rd ['rid'];
  8976. } else {
  8977. return '/receiptburEdi/' . $rd ['rid'];
  8978. }
  8979. // return "/approvalExpenses/pendApproval";
  8980. }
  8981. }
  8982. function expensesRetreats() {
  8983. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  8984. if (! empty ( $rid )) {
  8985. // 操作记录
  8986. Doo::loadModel ( "receipt" );
  8987. $receipt = new receipt ();
  8988. Doo::loadModel ( "receiptLog" );
  8989. $receiptLog = new receiptLog ();
  8990. Doo::loadModel ( "verify" );
  8991. $verify = new verify ();
  8992. $receiptInfo = $receipt->getOne ( array (
  8993. 'where' => 'rid=' . $rid,
  8994. 'asArray' => true
  8995. ) );
  8996. $vr = $verify->getOne ( array (
  8997. 'where' => 'vid=' . $receiptInfo ['verify'],
  8998. 'asArray' => true
  8999. ) );
  9000. $jd = json_decode ( $vr ['staff'] );
  9001. $roleId = 0;
  9002. foreach ( $jd as $key => $value ) {
  9003. if ($value [1] == 'ROLE') {
  9004. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9005. if ($pos !== false) {
  9006. $roleId = $value [0];
  9007. }
  9008. }
  9009. }
  9010. // 审批日志
  9011. // echo $roleId;die;
  9012. if (! empty ( $roleId )) {
  9013. Doo::loadModel ( "role" );
  9014. $role = new role ();
  9015. $roleInfo = $role->getOne ( array (
  9016. 'where' => 'rid=' . $roleId,
  9017. 'asArray' => true
  9018. ) );
  9019. $receiptLog->rolename = $roleInfo ['name'];
  9020. }
  9021. $receiptLog->username = $this->staff [0] ['username'];
  9022. $receiptLog->uid = $this->staff [0] ['sid'];
  9023. $receiptLog->date = date ( "Y-m-d" );
  9024. $receiptLog->opinion = '撤回';
  9025. $receiptLog->img = $this->staff [0] ['avatar'];
  9026. $receiptLog->status = 4;
  9027. $receiptLog->rid = $rid;
  9028. $receiptLog->insert ();
  9029. $receipt->status = 4;
  9030. $receipt->update ( array (
  9031. 'where' => 'rid=' . $rid
  9032. ) );
  9033. // 微信企业号通知
  9034. $this->setWXMsg ( $rid, 2 );
  9035. }
  9036. // echo "ddd";
  9037. return '/approvalExpenses/pendApproval';
  9038. }
  9039. function updateCheReceipt() {
  9040. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9041. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  9042. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  9043. if (! empty ( $rid )) {
  9044. // 操作记录
  9045. Doo::loadModel ( "receipt" );
  9046. $receipt = new receipt ();
  9047. Doo::loadModel ( "receiptLog" );
  9048. $receiptLog = new receiptLog ();
  9049. Doo::loadModel ( "verify" );
  9050. $verify = new verify ();
  9051. $receiptInfo = $receipt->getOne ( array (
  9052. 'where' => 'rid=' . $rid . ' and status=2',
  9053. 'asArray' => true
  9054. ) );
  9055. if (empty ( $receiptInfo )) {
  9056. echo json_encode ( array (
  9057. 'status' => 2
  9058. ) );
  9059. die ();
  9060. }
  9061. $vr = $verify->getOne ( array (
  9062. 'where' => 'vid=' . $receiptInfo ['verify'],
  9063. 'asArray' => true
  9064. ) );
  9065. $jd = json_decode ( $vr ['staff'] );
  9066. $roleId = 0;
  9067. foreach ( $jd as $key => $value ) {
  9068. if ($value [1] == 'ROLE') {
  9069. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9070. if ($pos !== false) {
  9071. $roleId = $value [0];
  9072. }
  9073. }
  9074. }
  9075. // 审批日志
  9076. // echo $roleId;die;
  9077. if (! empty ( $roleId )) {
  9078. Doo::loadModel ( "role" );
  9079. $role = new role ();
  9080. $roleInfo = $role->getOne ( array (
  9081. 'where' => 'rid=' . $roleId,
  9082. 'asArray' => true
  9083. ) );
  9084. $receiptLog->rolename = $roleInfo ['name'];
  9085. }
  9086. $receiptLog->username = $this->staff [0] ['username'];
  9087. $receiptLog->uid = $this->staff [0] ['sid'];
  9088. $receiptLog->date = date ( "Y-m-d" );
  9089. $receiptLog->opinion = $opinion;
  9090. $receiptLog->img = $this->staff [0] ['avatar'];
  9091. $receiptLog->status = 4;
  9092. $receiptLog->rid = $rid;
  9093. $receiptLog->insert ();
  9094. $receipt->status = 4;
  9095. $receipt->update ( array (
  9096. 'where' => 'rid=' . $rid
  9097. ) );
  9098. // 微信企业号通知
  9099. $this->setWXMsg ( $rid, 2 );
  9100. echo json_encode ( array (
  9101. 'status' => 1
  9102. ) );
  9103. // Header("HTTP/1.1 303 See Other");
  9104. // Header("Location: /approvalExpenses/pendApproval");
  9105. die ();
  9106. }
  9107. echo json_encode ( array (
  9108. 'status' => 2
  9109. ) );
  9110. die ();
  9111. // echo "ddd";
  9112. // return '/saeaBorad';
  9113. }
  9114. function revisePrice() {
  9115. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  9116. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  9117. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9118. // echo $price;die;
  9119. if (! empty ( $rid )) {
  9120. Doo::loadModel ( "receipt" );
  9121. $receipt = new receipt ();
  9122. $receiptDetail = $receipt->getOne ( array (
  9123. 'where' => 'rid=' . $rid . ' and status=2 ',
  9124. 'asArray' => true
  9125. ) );
  9126. if (empty ( $receiptDetail ))
  9127. die ( 'illegal request' );
  9128. $reviseDetail = array ();
  9129. if (empty ( $receiptDetail ['reviseDetail'] )) {
  9130. array_push ( $reviseDetail, array (
  9131. 'sid' => $this->staff [0] ['sid'],
  9132. 'name' => $this->staff [0] ['username'],
  9133. 'description' => $description,
  9134. 'price' => $price
  9135. ) );
  9136. $reviseDetailString = json_encode ( $reviseDetail );
  9137. $receipt->reviseDetail = $reviseDetailString;
  9138. $receipt->revisePrice = $price;
  9139. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9140. } else {
  9141. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9142. array_push ( $reviseDetail, array (
  9143. 'sid' => $this->staff [0] ['sid'],
  9144. 'name' => $this->staff [0] ['username'],
  9145. 'description' => $description,
  9146. 'price' => $price
  9147. ) );
  9148. $reviseDetailString = json_encode ( $reviseDetail );
  9149. $receipt->reviseDetail = $reviseDetailString;
  9150. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  9151. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9152. }
  9153. $receipt->update ( array (
  9154. 'where' => 'rid=' . $rid
  9155. ) );
  9156. if ($receiptDetail ['Rtype'] == 1) {
  9157. if ($receiptDetail ['isBK'] == 1) {
  9158. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9159. }
  9160. } elseif ($receiptDetail ['Rtype'] == 2) {
  9161. } else {
  9162. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9163. }
  9164. }
  9165. die ( 'illegal request' );
  9166. }
  9167. function personalCollect() {
  9168. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9169. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  9170. $this->showCache ( $path );
  9171. Doo::loadModel ( "receiptDetail" );
  9172. Doo::loadModel ( "itemStatistics" );
  9173. Doo::loadModel ( 'statistics' );
  9174. $statistics = new statistics ();
  9175. $itemStatistics = new itemStatistics ();
  9176. $receiptDetail = new receiptDetail ();
  9177. $receiptCollectList = $receiptDetail->find ( array (
  9178. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9179. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9180. 'groupby' => 'itemCategory,Month(date)',
  9181. 'asArray' => true
  9182. ) );
  9183. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  9184. 'where' => 'staff=' . $this->staff [0] ['sid'],
  9185. 'asArray' => true
  9186. ) );
  9187. // create collect html
  9188. $collectArray = array (
  9189. '日常相关费用' => array (),
  9190. '差旅相关费用' => array (),
  9191. '培训班费用' => array (),
  9192. '其他' => array ()
  9193. );
  9194. $adjustment = array ();
  9195. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  9196. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9197. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  9198. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9199. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  9200. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9201. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  9202. array_push ( $collectArray ['其他'], $collectHtml );
  9203. $data ['collectArray'] = $collectArray;
  9204. // statistics html
  9205. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9206. if (empty ( $stList ))
  9207. $stList = array (
  9208. 'rePrice' => 0,
  9209. 'agPrice' => 0
  9210. );
  9211. $data ['stList'] = array (
  9212. 'rePrice' => $stList ['rePrice'],
  9213. 'agPrice' => $stList ['agPrice'],
  9214. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9215. );
  9216. // Adjustment price html
  9217. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9218. array_push ( $adjustment, $collectHtml );
  9219. $data ['adjustment'] = $adjustment;
  9220. // total price html
  9221. $collectHtml = "";
  9222. $total = 0;
  9223. for($i = 1; $i <= 12; $i ++) {
  9224. $sumPrice = 0;
  9225. foreach ( $receiptCollectList as $key => $value ) {
  9226. if ($value ['month'] == $i) {
  9227. $sumPrice += $value ['price'];
  9228. }
  9229. }
  9230. if ($sumPrice == 0)
  9231. $collectHtml .= '<td class="taR">-</td>';
  9232. else
  9233. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9234. $total += $sumPrice;
  9235. }
  9236. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9237. $data ['totalPrice'] = $collectHtml;
  9238. $dateHtml = "";
  9239. $now = date ( "Y" );
  9240. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9241. if ($YEARD <= $now) {
  9242. $dateHtml .= '<option ';
  9243. if ($year == $YEARD) {
  9244. $dateHtml .= 'selected ';
  9245. }
  9246. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9247. }
  9248. }
  9249. $data ['dateHtml'] = $dateHtml;
  9250. $data ['year'] = $year;
  9251. $data ['totalYear'] = $total;
  9252. $data ['memu'] = "receipt";
  9253. $data ['staff'] = $this->staff;
  9254. $data ['receiptMemu'] = 'personalCollect';
  9255. $data ['verifyId'] = $this->verifyId;
  9256. $data ['executeId'] = $this->executeId;
  9257. // year staff status 2,4
  9258. if ($year < date ( "Y" )) {
  9259. Doo::loadModel ( 'receipt' );
  9260. $receipt = new receipt ();
  9261. $receiptList = $receipt->find ( array (
  9262. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9263. 'asArray' => true
  9264. ) );
  9265. if (empty ( $receiptList )) {
  9266. ob_start ();
  9267. $this->render ( "/admin/saea_slist_collect", $data );
  9268. $this->cacheFile ( $path );
  9269. die ();
  9270. }
  9271. }
  9272. $this->render ( "/admin/saea_slist_collect", $data );
  9273. }
  9274. function personalCollectDetail() {
  9275. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9276. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  9277. $this->showCache ( $path );
  9278. Doo::loadModel ( "receiptDetail" );
  9279. Doo::loadModel ( "itemStatistics" );
  9280. Doo::loadModel ( 'statistics' );
  9281. Doo::loadModel ( 'accountItem' );
  9282. $accountItem = new accountItem ();
  9283. $statistics = new statistics ();
  9284. $itemStatistics = new itemStatistics ();
  9285. $receiptDetail = new receiptDetail ();
  9286. $receiptCollectList = $receiptDetail->find ( array (
  9287. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9288. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9289. 'groupby' => 'item,Month(date)',
  9290. 'asArray' => true
  9291. ) );
  9292. $accountList = $accountItem->find ( array (
  9293. 'asArray' => true
  9294. ) );
  9295. // create CollectDetail HTML
  9296. $collectHtml = array ();
  9297. foreach ( $accountList as $key => $value ) {
  9298. $html = "";
  9299. $asum = 0;
  9300. for($i = 1; $i <= 12; $i ++) {
  9301. $falg = true;
  9302. foreach ( $receiptCollectList as $v ) {
  9303. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9304. $asum += $v ['price'];
  9305. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9306. $falg = false;
  9307. break;
  9308. }
  9309. }
  9310. if ($falg)
  9311. $html .= '<td class="taR">-</td>';
  9312. }
  9313. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9314. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9315. }
  9316. $data ['collectHtml'] = $collectHtml;
  9317. // create Adjustment price html
  9318. $receiptCollectList = $receiptDetail->find ( array (
  9319. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9320. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9321. 'groupby' => 'itemCategory,Month(date)',
  9322. 'asArray' => true
  9323. ) );
  9324. $adjustment = array ();
  9325. $collectArray = array (
  9326. '日常相关费用' => array (),
  9327. '差旅相关费用' => array (),
  9328. '培训班费用' => array (),
  9329. '其他' => array ()
  9330. );
  9331. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9332. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9333. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9334. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9335. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9336. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9337. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9338. array_push ( $collectArray ['其他'], $collectHtml );
  9339. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9340. array_push ( $adjustment, $collectHtml );
  9341. // total price html
  9342. $collectHtml = "";
  9343. $total = 0;
  9344. for($i = 1; $i <= 12; $i ++) {
  9345. $sumPrice = 0;
  9346. foreach ( $receiptCollectList as $key => $value ) {
  9347. if ($value ['month'] == $i) {
  9348. $sumPrice += $value ['price'];
  9349. }
  9350. }
  9351. if ($sumPrice == 0)
  9352. $collectHtml .= '<td class="taR">-</td>';
  9353. else
  9354. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9355. $total += $sumPrice;
  9356. }
  9357. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9358. // statistics html
  9359. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9360. if (empty ( $stList ))
  9361. $stList = array (
  9362. 'rePrice' => 0,
  9363. 'agPrice' => 0
  9364. );
  9365. $data ['stList'] = array (
  9366. 'rePrice' => $stList ['rePrice'],
  9367. 'agPrice' => $stList ['agPrice'],
  9368. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9369. );
  9370. $data ['collectArray'] = $collectArray;
  9371. $data ['adjustment'] = $adjustment;
  9372. $data ['totalPrice'] = $collectHtml;
  9373. $data ['totalYear'] = $total;
  9374. $data ['year'] = $year;
  9375. $dateHtml = "";
  9376. $now = date ( "Y" );
  9377. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9378. if ($YEARD <= $now) {
  9379. $dateHtml .= '<option ';
  9380. if ($year == $YEARD) {
  9381. $dateHtml .= 'selected ';
  9382. }
  9383. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9384. }
  9385. }
  9386. $data ['dateHtml'] = $dateHtml;
  9387. $data ['memu'] = "receipt";
  9388. $data ['staff'] = $this->staff;
  9389. $data ['receiptMemu'] = 'personalCollect';
  9390. $data ['verifyId'] = $this->verifyId;
  9391. $data ['executeId'] = $this->executeId;
  9392. // year staff status 2,4
  9393. if ($year < date ( "Y" )) {
  9394. Doo::loadModel ( 'receipt' );
  9395. $receipt = new receipt ();
  9396. $receiptList = $receipt->find ( array (
  9397. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9398. 'asArray' => true
  9399. ) );
  9400. if (empty ( $receiptList )) {
  9401. ob_start ();
  9402. $this->render ( "/admin/saeaCollectArticles", $data );
  9403. $this->cacheFile ( $path );
  9404. die ();
  9405. }
  9406. }
  9407. $this->render ( "/admin/saeaCollectArticles", $data );
  9408. }
  9409. function companyCategoryCollect() {
  9410. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9411. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  9412. $this->showCache ( $path );
  9413. Doo::loadModel ( 'L_category' );
  9414. Doo::loadModel ( 'itemStatistics' );
  9415. Doo::loadModel ( 'statistics' );
  9416. $statistics = new statistics ();
  9417. $Lcategory = new L_category ();
  9418. $itemStatistics = new itemStatistics ();
  9419. Doo::loadModel ( "receiptAuthorityManage" );
  9420. $receiptAuthorityManage = new receiptAuthorityManage ();
  9421. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9422. $cidList = array ();
  9423. foreach ( $imcStaff as $key => $value ) {
  9424. array_push ( $cidList, $value ['cid'] );
  9425. }
  9426. $cidString = implode ( ',', $cidList );
  9427. $LcategoryList = $Lcategory->find ( array (
  9428. 'where' => ' cid in (' . $cidString . ')',
  9429. 'asArray' => true
  9430. ) ); // 'staff='.$this->staff[0]['sid']." and
  9431. $itemStatisticsList = $itemStatistics->find ( array (
  9432. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9433. 'where' => " Year(date)=" . $year,
  9434. 'groupby' => 'cid,Month(date)',
  9435. 'asArray' => true
  9436. ) );
  9437. // ceatre companyCollectHtml
  9438. foreach ( $LcategoryList as $value ) {
  9439. $html = "";
  9440. $asum = 0;
  9441. for($i = 1; $i <= 12; $i ++) {
  9442. $falg = true;
  9443. foreach ( $itemStatisticsList as $v ) {
  9444. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  9445. $asum += $v ['price'];
  9446. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9447. $falg = false;
  9448. break;
  9449. }
  9450. }
  9451. if ($falg)
  9452. $html .= '<td class="taR">-</td>';
  9453. }
  9454. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9455. $collectHtml [$value ['title']] = array (
  9456. 'html' => $html,
  9457. 'cid' => $value ['cid']
  9458. );
  9459. }
  9460. $data ['companyHtml'] = $collectHtml;
  9461. // total price html
  9462. $collectHtml = "";
  9463. $total = 0;
  9464. for($i = 1; $i <= 12; $i ++) {
  9465. $sumPrice = 0;
  9466. foreach ( $itemStatisticsList as $key => $value ) {
  9467. if ($value ['month'] == $i) {
  9468. $sumPrice += $value ['price'];
  9469. }
  9470. }
  9471. if ($sumPrice == 0)
  9472. $collectHtml .= '<td class="taR">-</td>';
  9473. else
  9474. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9475. $total += $sumPrice;
  9476. }
  9477. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9478. $data ['companyTotalHtml'] = $collectHtml;
  9479. $data ['total'] = $total;
  9480. // statistics html
  9481. // echo $cidString;
  9482. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9483. if (empty ( $stList ))
  9484. $stList = array (
  9485. 'rePrice' => 0,
  9486. 'agPrice' => 0
  9487. );
  9488. $data ['stList'] = array (
  9489. 'rePrice' => $stList ['rePrice'],
  9490. 'agPrice' => $stList ['agPrice'],
  9491. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9492. );
  9493. $data ['year'] = $year;
  9494. $data ['memu'] = "receipt";
  9495. $data ['staff'] = $this->staff;
  9496. $data ['receiptMemu'] = 'companyCategoryCollect';
  9497. $data ['verifyId'] = $this->verifyId;
  9498. $data ['executeId'] = $this->executeId;
  9499. $dateHtml = "";
  9500. $now = date ( "Y" );
  9501. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9502. if ($YEARD <= $now) {
  9503. $dateHtml .= '<option ';
  9504. if ($year == $YEARD) {
  9505. $dateHtml .= 'selected ';
  9506. }
  9507. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9508. }
  9509. }
  9510. $data ['dateHtml'] = $dateHtml;
  9511. // year staff status 2,4
  9512. if ($year < date ( "Y" )) {
  9513. Doo::loadModel ( 'receipt' );
  9514. $receipt = new receipt ();
  9515. $receiptList = $receipt->find ( array (
  9516. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  9517. 'asArray' => true
  9518. ) );
  9519. if (empty ( $receiptList )) {
  9520. ob_start ();
  9521. $this->render ( "/admin/saeaCompanyCollect", $data );
  9522. $this->cacheFile ( $path );
  9523. die ();
  9524. }
  9525. }
  9526. $this->render ( "/admin/saeaCompanyCollect", $data );
  9527. }
  9528. function categoryCollectDetail() {
  9529. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9530. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  9531. /* $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  9532. $this->showCache ( $path ); */
  9533. Doo::loadModel ( 'statistics' );
  9534. $statistics = new statistics ();
  9535. Doo::loadModel ( "receiptDetail" );
  9536. $receiptDetail = new receiptDetail ();
  9537. Doo::loadModel ( 'L_category' );
  9538. $Lcategory = new L_category ();
  9539. Doo::loadModel ( 'accountItem' );
  9540. $accountItem = new accountItem ();
  9541. Doo::loadModel ( "receiptAuthorityManage" );
  9542. $receiptAuthorityManage = new receiptAuthorityManage ();
  9543. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9544. $cidList = array ();
  9545. foreach ( $imcStaff as $key => $value ) {
  9546. array_push ( $cidList, $value ['cid'] );
  9547. }
  9548. $cidString = implode ( ',', $cidList );
  9549. $LcategoryList = $Lcategory->find ( array (
  9550. 'where' => 'cid in (' . $cidString . ')',
  9551. 'asArray' => true
  9552. ) );
  9553. if ($cid == 0) {
  9554. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9555. if ($cid == 0)
  9556. $cid = $LcategoryList [0] ['cid'];
  9557. }
  9558. $data ['LcategoryList'] = $LcategoryList;
  9559. $receiptCollectList = $receiptDetail->find ( array (
  9560. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9561. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9562. 'groupby' => 'item,Month(pastDate)',
  9563. 'asArray' => true
  9564. ) );
  9565. $accountList = $accountItem->find ( array (
  9566. 'asArray' => true
  9567. ) );
  9568. // create CollectDetail HTML
  9569. $collectHtml = array ();
  9570. foreach ( $accountList as $key => $value ) {
  9571. $html = "";
  9572. $asum = 0;
  9573. for($i = 1; $i <= 12; $i ++) {
  9574. $falg = true;
  9575. foreach ( $receiptCollectList as $v ) {
  9576. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9577. $asum += $v ['price'];
  9578. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9579. $falg = false;
  9580. break;
  9581. }
  9582. }
  9583. if ($falg)
  9584. $html .= '<td class="taR">-</td>';
  9585. }
  9586. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9587. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9588. }
  9589. $data ['collectHtml'] = $collectHtml;
  9590. // create Adjustment price html
  9591. $receiptCollectList = $receiptDetail->find ( array (
  9592. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9593. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9594. 'groupby' => 'itemCategory,Month(pastDate)',
  9595. 'asArray' => true
  9596. ) );
  9597. $adjustment = array ();
  9598. $collectArray = array (
  9599. '日常相关费用' => array (),
  9600. '差旅相关费用' => array (),
  9601. '培训班费用' => array (),
  9602. '内部培训费用'=>array(),
  9603. '其他' => array ()
  9604. );
  9605. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9606. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9607. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9608. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9609. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9610. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9611. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  9612. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  9613. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9614. array_push ( $collectArray ['其他'], $collectHtml );
  9615. $data ['collectArray'] = $collectArray;
  9616. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9617. array_push ( $adjustment, $collectHtml );
  9618. $data ['adjustment'] = $adjustment;
  9619. // total price html
  9620. $collectHtml = "";
  9621. $total = 0;
  9622. for($i = 1; $i <= 12; $i ++) {
  9623. $sumPrice = 0;
  9624. foreach ( $receiptCollectList as $key => $value ) {
  9625. if ($value ['month'] == $i) {
  9626. $sumPrice += $value ['price'];
  9627. }
  9628. }
  9629. if ($sumPrice == 0)
  9630. $collectHtml .= '<td class="taR">-</td>';
  9631. else
  9632. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9633. $total += $sumPrice;
  9634. }
  9635. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9636. // statistics html
  9637. $stList = $statistics->statisticsByCid ( $year, $cid );
  9638. if (empty ( $stList ))
  9639. $stList = array (
  9640. 'rePrice' => 0,
  9641. 'agPrice' => 0
  9642. );
  9643. $data ['stList'] = array (
  9644. 'rePrice' => $stList ['rePrice'],
  9645. 'agPrice' => $stList ['agPrice'],
  9646. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9647. );
  9648. $data ['totalYear'] = $total;
  9649. $data ['year'] = $year;
  9650. $data ['cid'] = $cid;
  9651. $data ['memu'] = "receipt";
  9652. $data ['staff'] = $this->staff;
  9653. $data ['receiptMemu'] = 'companyCategoryCollect';
  9654. $data ['verifyId'] = $this->verifyId;
  9655. $data ['executeId'] = $this->executeId;
  9656. // year staff status 2,4
  9657. /* if ($year < date ( "Y" )) {
  9658. Doo::loadModel ( 'receipt' );
  9659. $receipt = new receipt ();
  9660. $receiptList = $receipt->find ( array (
  9661. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  9662. 'asArray' => true
  9663. ) );
  9664. if (empty ( $receiptList )) {
  9665. ob_start ();
  9666. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  9667. $this->cacheFile ( $path );
  9668. die ();
  9669. }
  9670. } */
  9671. $dateHtml = "";
  9672. $now = date ( "Y" );
  9673. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9674. if ($YEARD <= $now) {
  9675. $dateHtml .= '<option ';
  9676. if ($year == $YEARD) {
  9677. $dateHtml .= 'selected ';
  9678. }
  9679. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9680. }
  9681. }
  9682. $data ['dateHtml'] = $dateHtml;
  9683. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  9684. }
  9685. function staffCollect() {
  9686. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9687. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ONJOB';//
  9688. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  9689. // $this->showCache($path);
  9690. Doo::loadModel ( 'statistics' );
  9691. $statistics = new statistics ();
  9692. Doo::loadModel ( "receiptDetail" );
  9693. $receiptDetail = new receiptDetail ();
  9694. Doo::loadModel ( 'L_category' );
  9695. $Lcategory = new L_category ();
  9696. Doo::loadModel ( 'accountItem' );
  9697. $accountItem = new accountItem ();
  9698. Doo::loadModel ( 'staff' );
  9699. $staff = new staff ();
  9700. Doo::loadModel ( 'itemStatistics' );
  9701. $itemStatistics = new itemStatistics ();
  9702. Doo::loadModel ( "receiptAuthorityManage" );
  9703. $receiptAuthorityManage = new receiptAuthorityManage ();
  9704. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9705. $cidList = array ();
  9706. foreach ( $imcStaff as $key => $value ) {
  9707. array_push ( $cidList, $value ['cid'] );
  9708. }
  9709. $cidString = implode ( ',', $cidList );
  9710. $naturecon='';
  9711. if ($nature=='ONJOB'){
  9712. $naturecon=' and (nature!=4 )';
  9713. }elseif($nature=='LEAVEJOB'){
  9714. $naturecon=' and (nature=4 )';
  9715. }else{
  9716. die ( 'illegal request--nature' );
  9717. }
  9718. // statistics html
  9719. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9720. if (empty ( $stList ))
  9721. $stList = array (
  9722. 'rePrice' => 0,
  9723. 'agPrice' => 0
  9724. );
  9725. $data ['stList'] = array (
  9726. 'rePrice' => $stList ['rePrice'],
  9727. 'agPrice' => $stList ['agPrice'],
  9728. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9729. );
  9730. // ---
  9731. $staffList = $staff->find ( array (
  9732. 'where' => 'username !="admin" '.$naturecon,
  9733. 'asArray' => true
  9734. ) );
  9735. $LcategoryList = $Lcategory->find ( array (
  9736. 'asArray' => true
  9737. ) ); // 'staff='.$this->staff[0]['sid']." and
  9738. $itemStatisticsList = $itemStatistics->find ( array (
  9739. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9740. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  9741. 'groupby' => 'staff,Month(date)',
  9742. 'asArray' => true
  9743. ) );
  9744. $categoryList = $staff->find ( array (
  9745. 'select' => 'COUNT(*) as count,cid,category',
  9746. 'where' => 'username !="admin" and cid in (' . $cidString . ') '.$naturecon,
  9747. 'groupby' => 'cid',
  9748. 'asArray' => true
  9749. ) );
  9750. // print_r($itemStatisticsList);die;
  9751. // ceatre companyCollectHtml
  9752. foreach ( $categoryList as $vlu ) {
  9753. $count = $vlu ['count'] + 1;
  9754. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  9755. $m1 = 0;
  9756. $m2 = 0;
  9757. $m3 = 0;
  9758. $m4 = 0;
  9759. $m5 = 0;
  9760. $m6 = 0;
  9761. $m7 = 0;
  9762. $m8 = 0;
  9763. $m9 = 0;
  9764. $m10 = 0;
  9765. $m11 = 0;
  9766. $m12 = 0;
  9767. $m13 = 0;
  9768. foreach ( $staffList as $value ) {
  9769. if ($vlu ['cid'] == $value ['cid']) {
  9770. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  9771. $asum = 0;
  9772. for($i = 1; $i <= 12; $i ++) {
  9773. $falg = true;
  9774. foreach ( $itemStatisticsList as $v ) {
  9775. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  9776. if ($v ['month'] == 1)
  9777. $m1 += $v ['price'];
  9778. if ($v ['month'] == 2)
  9779. $m2 += $v ['price'];
  9780. if ($v ['month'] == 3)
  9781. $m3 += $v ['price'];
  9782. if ($v ['month'] == 4)
  9783. $m4 += $v ['price'];
  9784. if ($v ['month'] == 5)
  9785. $m5 += $v ['price'];
  9786. if ($v ['month'] == 6)
  9787. $m6 += $v ['price'];
  9788. if ($v ['month'] == 7)
  9789. $m7 += $v ['price'];
  9790. if ($v ['month'] == 8)
  9791. $m8 += $v ['price'];
  9792. if ($v ['month'] == 9)
  9793. $m9 += $v ['price'];
  9794. if ($v ['month'] == 10)
  9795. $m10 += $v ['price'];
  9796. if ($v ['month'] == 11)
  9797. $m11 += $v ['price'];
  9798. if ($v ['month'] == 12)
  9799. $m12 += $v ['price'];
  9800. $asum += $v ['price'];
  9801. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9802. $falg = false;
  9803. break;
  9804. }
  9805. }
  9806. if ($falg)
  9807. $html .= '<td class="taR">-</td>';
  9808. }
  9809. $m13 += $asum;
  9810. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9811. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  9812. 'html' => $html,
  9813. 'sid' => $value ['sid']
  9814. );
  9815. $html = "";
  9816. }
  9817. }
  9818. $hl = '<th class="taR">小计</th><td class="taR">¥' . $m1 . '</td><td class="taR">¥' . $m2 . '</td><td class="taR">¥' . $m3 . '</td><td class="taR">¥' . $m4 . '</td><td class="taR">¥' . $m5 . '</td>
  9819. <td class="taR">¥' . $m6 . '</td><td class="taR">¥' . $m7 . '</td><td class="taR">¥' . $m8 . '</td><td class="taR">¥' . $m9 . '</td><td class="taR">¥' . $m10 . '</td><td class="taR">¥' . $m11 . '</td>
  9820. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  9821. $collectHtml [$vlu ['cid']] = array (
  9822. 'html' => $hl,
  9823. 'sid' => ''
  9824. );
  9825. }
  9826. $data ['companyHtml'] = $collectHtml;
  9827. // total price html
  9828. $collectHtml = "";
  9829. $total = 0;
  9830. for($i = 1; $i <= 12; $i ++) {
  9831. $sumPrice = 0;
  9832. foreach ( $itemStatisticsList as $key => $value ) {
  9833. if ($value ['month'] == $i) {
  9834. $sumPrice += $value ['price'];
  9835. }
  9836. }
  9837. if ($sumPrice == 0)
  9838. $collectHtml .= '<td class="taR">-</td>';
  9839. else
  9840. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9841. $total += $sumPrice;
  9842. }
  9843. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9844. $data ['companyTotalHtml'] = $collectHtml;
  9845. $data ['total'] = $total;
  9846. $data ['nature'] =$nature;
  9847. $data ['year'] = $year;
  9848. $data ['memu'] = "receipt";
  9849. $data ['staff'] = $this->staff;
  9850. $data ['receiptMemu'] = 'companyCategoryCollect';
  9851. $data ['verifyId'] = $this->verifyId;
  9852. $data ['executeId'] = $this->executeId;
  9853. if ($year <= date ( "Y" )) {
  9854. Doo::loadModel ( 'receipt' );
  9855. $receipt = new receipt ();
  9856. $receiptList = $receipt->find ( array (
  9857. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  9858. 'asArray' => true
  9859. ) );
  9860. if (empty ( $receiptList )) { // generated files
  9861. ob_start ();
  9862. $this->render ( "/admin/saeaStaffCollectB", $data );
  9863. $this->cacheFile ( $path );
  9864. die ();
  9865. }
  9866. }
  9867. $this->render ( "/admin/saeaStaffCollectB", $data );
  9868. }
  9869. function staffCollectBak() {
  9870. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9871. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  9872. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  9873. $this->showCache ( $path );
  9874. Doo::loadModel ( 'statistics' );
  9875. $statistics = new statistics ();
  9876. Doo::loadModel ( "receiptDetail" );
  9877. $receiptDetail = new receiptDetail ();
  9878. Doo::loadModel ( 'L_category' );
  9879. $Lcategory = new L_category ();
  9880. Doo::loadModel ( 'accountItem' );
  9881. $accountItem = new accountItem ();
  9882. Doo::loadModel ( 'staff' );
  9883. $staff = new staff ();
  9884. Doo::loadModel ( 'itemStatistics' );
  9885. $itemStatistics = new itemStatistics ();
  9886. $itemStatisticsList = $itemStatistics->find ( array (
  9887. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9888. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9889. 'groupby' => 'staff,itemCategory,Month(date)',
  9890. 'asArray' => true
  9891. ) );
  9892. $itemCategoryList = $itemStatistics->find ( array (
  9893. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9894. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9895. 'groupby' => 'cid,itemCategory,Month(date)',
  9896. 'asArray' => true
  9897. ) );
  9898. $LcategoryList = $Lcategory->find ( array (
  9899. 'asArray' => true
  9900. ) );
  9901. $staffList = $staff->find ( array (
  9902. 'asArray' => true
  9903. ) );
  9904. $htmlArray = array ();
  9905. foreach ( $LcategoryList as $value ) {
  9906. $htmlArray [$value ['title']] = array ();
  9907. foreach ( $staffList as $v ) {
  9908. if ($value ['cid'] == $v ['cid']) {
  9909. $html = "";
  9910. $falg = true;
  9911. $staffSumPrice = 0;
  9912. foreach ( $itemStatisticsList as $a ) {
  9913. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  9914. if (empty ( $a ['price'] )) {
  9915. $html .= '<td class="taR">-</td>';
  9916. $falg = false;
  9917. break;
  9918. } else {
  9919. $staffSumPrice += $a ['price'];
  9920. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9921. $falg = false;
  9922. break;
  9923. }
  9924. }
  9925. }
  9926. if ($falg) {
  9927. $html .= '<td class="taR">-</td>';
  9928. $falg = true;
  9929. }
  9930. $falg = true;
  9931. foreach ( $itemStatisticsList as $a ) {
  9932. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  9933. if (empty ( $a ['price'] )) {
  9934. $html .= '<td class="taR">-</td>';
  9935. $falg = false;
  9936. break;
  9937. } else {
  9938. $staffSumPrice += $a ['price'];
  9939. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9940. $falg = false;
  9941. break;
  9942. }
  9943. }
  9944. }
  9945. if ($falg) {
  9946. $html .= '<td class="taR">-</td>';
  9947. $falg = true;
  9948. }
  9949. $falg = true;
  9950. foreach ( $itemStatisticsList as $a ) {
  9951. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  9952. if (empty ( $a ['price'] )) {
  9953. $html .= '<td class="taR">-</td>';
  9954. $falg = false;
  9955. break;
  9956. } else {
  9957. $staffSumPrice += $a ['price'];
  9958. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9959. $falg = false;
  9960. break;
  9961. }
  9962. }
  9963. }
  9964. if ($falg) {
  9965. $html .= '<td class="taR">-</td>';
  9966. $falg = true;
  9967. }
  9968. $falg = true;
  9969. foreach ( $itemStatisticsList as $a ) {
  9970. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  9971. if (! empty ( $a ['price'] )) {
  9972. $staffSumPrice += $a ['price'];
  9973. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9974. $falg = false;
  9975. break;
  9976. } else {
  9977. $html .= '<td class="taR">-</td>';
  9978. $falg = false;
  9979. break;
  9980. }
  9981. }
  9982. }
  9983. if ($falg) {
  9984. $html .= '<td class="taR">-</td>';
  9985. $falg = true;
  9986. }
  9987. $falg = true;
  9988. foreach ( $itemStatisticsList as $a ) {
  9989. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  9990. if (! empty ( $a ['price'] )) {
  9991. $staffSumPrice += $a ['price'];
  9992. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9993. $falg = false;
  9994. break;
  9995. } else {
  9996. $html .= '<td class="taR">-</td>';
  9997. $falg = false;
  9998. break;
  9999. }
  10000. }
  10001. }
  10002. if ($falg) {
  10003. $html .= '<td class="taR">-</td>';
  10004. $falg = true;
  10005. }
  10006. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  10007. $htmlArray [$value ['title']] [$v ['username']] = $html;
  10008. }
  10009. }
  10010. /* -- --- */
  10011. // 合计费用
  10012. $cateHtml = "";
  10013. $catePrice = 0;
  10014. $cateFalg = true;
  10015. foreach ( $itemCategoryList as $l ) {
  10016. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  10017. if (empty ( $l ['price'] )) {
  10018. $cateHtml .= '<td class="colGreen taR">-</td>';
  10019. $cateFalg = false;
  10020. break;
  10021. } else {
  10022. $catePrice += $l ['price'];
  10023. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10024. $cateFalg = false;
  10025. break;
  10026. }
  10027. }
  10028. }
  10029. if ($cateFalg) {
  10030. $cateHtml .= '<td class="colGreen taR">-</td>';
  10031. $cateFalg = true;
  10032. }
  10033. $cateFalg = true;
  10034. foreach ( $itemCategoryList as $l ) {
  10035. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  10036. if (empty ( $l ['price'] )) {
  10037. $cateHtml .= '<td class="colGreen taR">-</td>';
  10038. $cateFalg = false;
  10039. break;
  10040. } else {
  10041. $catePrice += $l ['price'];
  10042. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10043. $cateFalg = false;
  10044. break;
  10045. }
  10046. }
  10047. }
  10048. if ($cateFalg) {
  10049. $cateHtml .= '<td class="colGreen taR">-</td>';
  10050. $cateFalg = true;
  10051. }
  10052. $cateFalg = true;
  10053. foreach ( $itemCategoryList as $l ) {
  10054. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  10055. if (empty ( $l ['price'] )) {
  10056. $cateHtml .= '<td class="colGreen taR">-</td>';
  10057. $cateFalg = false;
  10058. break;
  10059. } else {
  10060. $catePrice += $l ['price'];
  10061. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10062. $cateFalg = false;
  10063. break;
  10064. }
  10065. }
  10066. }
  10067. if ($cateFalg) {
  10068. $cateHtml .= '<td class="colGreen taR">-</td>';
  10069. $cateFalg = true;
  10070. }
  10071. $cateFalg = true;
  10072. foreach ( $itemCategoryList as $l ) {
  10073. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  10074. if (empty ( $l ['price'] )) {
  10075. $cateHtml .= '<td class="colGreen taR">-</td>';
  10076. $cateFalg = false;
  10077. break;
  10078. } else {
  10079. $catePrice += $l ['price'];
  10080. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10081. $cateFalg = false;
  10082. break;
  10083. }
  10084. }
  10085. }
  10086. if ($cateFalg) {
  10087. $cateHtml .= '<td class="colGreen taR">-</td>';
  10088. $cateFalg = true;
  10089. }
  10090. $cateFalg = true;
  10091. foreach ( $itemCategoryList as $l ) {
  10092. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  10093. if (empty ( $l ['price'] )) {
  10094. $cateHtml .= '<td class="colGreen taR">-</td>';
  10095. $cateFalg = false;
  10096. break;
  10097. } else {
  10098. $catePrice += $l ['price'];
  10099. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10100. $cateFalg = false;
  10101. break;
  10102. }
  10103. }
  10104. }
  10105. if ($cateFalg) {
  10106. $cateHtml .= '<td class="colGreen taR">-</td>';
  10107. $cateFalg = true;
  10108. }
  10109. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  10110. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  10111. /* -- --- */
  10112. }
  10113. // print_r($htmlArray);die;
  10114. $data ['htmlArray'] = $htmlArray;
  10115. // statistics html
  10116. $stList = $statistics->getOne ( array (
  10117. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  10118. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10119. 'groupby' => 'Month(date)',
  10120. 'asArray' => true
  10121. ) );
  10122. if (empty ( $stList ))
  10123. $stList = array (
  10124. 'rePrice' => 0,
  10125. 'agPrice' => 0
  10126. );
  10127. $data ['stList'] = array (
  10128. 'rePrice' => $stList ['rePrice'],
  10129. 'agPrice' => $stList ['agPrice'],
  10130. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10131. );
  10132. $monthHtml = "";
  10133. for($i = 1; $i <= 12; $i ++) {
  10134. if ($i == $month)
  10135. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  10136. else
  10137. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  10138. }
  10139. $data ['monthHtml'] = $monthHtml;
  10140. $data ['year'] = $year;
  10141. $data ['month'] = $month;
  10142. $data ['memu'] = "receipt";
  10143. $data ['staff'] = $this->staff;
  10144. $data ['receiptMemu'] = 'companyCategoryCollect';
  10145. $data ['verifyId'] = $this->verifyId;
  10146. $data ['executeId'] = $this->executeId;
  10147. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  10148. Doo::loadModel ( 'receipt' );
  10149. $receipt = new receipt ();
  10150. $receiptList = $receipt->find ( array (
  10151. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  10152. 'asArray' => true
  10153. ) );
  10154. if (empty ( $receiptList )) { // generated files
  10155. ob_start ();
  10156. $this->render ( "/admin/saeaStaffCollect", $data );
  10157. $this->cacheFile ( $path );
  10158. die ();
  10159. }
  10160. }
  10161. $this->render ( "/admin/saeaStaffCollect", $data );
  10162. }
  10163. /**
  10164. * 日常收支
  10165. */
  10166. function payments() {
  10167. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  10168. Doo::loadModel ( "execute" );
  10169. $execute = new execute ();
  10170. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  10171. die ( 'illegal request' );
  10172. }
  10173. Doo::loadModel ( "accountBook" );
  10174. $accountBook = new accountBook ();
  10175. Doo::loadModel ( "accountBookStatistics" );
  10176. $accountBookStatistics = new accountBookStatistics ();
  10177. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  10178. $list = $accountBook->getAccountBookByLimit ( 10 );
  10179. $data ['date'] = date ( "Y-m-d" );
  10180. $data ['statisticsList'] = $statisticsList;
  10181. $data ['list'] = $list;
  10182. $data ['memu'] = "receipt";
  10183. $data ['staff'] = $this->staff;
  10184. $data ['receiptMemu'] = 'payments';
  10185. $data ['verifyId'] = $this->verifyId;
  10186. $data ['executeId'] = $this->executeId;
  10187. $this->render ( "/expenses/payments", $data );
  10188. }
  10189. function paymentsIncomeDo() {
  10190. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10191. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10192. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10193. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10194. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10195. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10196. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10197. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10198. Doo::loadClass ( 'XDeode' );
  10199. $XDeode = new XDeode ( 5 );
  10200. Doo::loadModel ( "accountBook" );
  10201. Doo::loadModel ( "accountBookStatistics" );
  10202. Doo::loadModel ( 'wasteBook' );
  10203. // 记录流水时银行的转换
  10204. $accountBank = '';
  10205. if ($receivedBank == '纵横广发') {
  10206. $accountBank = 'CGBDeposit';
  10207. } elseif ($receivedBank == '纵横工行') {
  10208. $accountBank = 'ICBCDeposit';
  10209. } elseif ($receivedBank == '华润银行') {
  10210. $accountBank = 'HUADeposit';
  10211. } elseif ($receivedBank == '个人广发') {
  10212. $accountBank = 'PersonalDeposit';
  10213. }
  10214. if (empty ( $accountBank ))
  10215. die ( 'illegal request' );
  10216. // 收入为理财时特殊处理
  10217. if ($accountType == 7 || $accountType == 9) {
  10218. if ($receivedBank == '个人广发') {
  10219. die ( '个人广发 illegal request' );
  10220. }
  10221. // 添加一条收入
  10222. $accountBook = new accountBook ();
  10223. $accountBook->accountType = 10;
  10224. $accountBook->accountMsg = $accountMsg;
  10225. $accountBook->receivedPrice = $receivedPrice;
  10226. $accountBook->receivedMsg = $receivedMsg;
  10227. $accountBook->receivedBank = $receivedBank;
  10228. $accountBook->receivedDate = $receivedDate;
  10229. $accountBook->remarks = $remarks;
  10230. $accountBook->expensesType = 1;
  10231. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10232. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10233. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10234. $inComeId = $accountBook->insert ();
  10235. // 收支汇总-添加一条收入日常汇总
  10236. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10237. $accountBookStatistics = new accountBookStatistics ();
  10238. $item = array (
  10239. 'date' => date ( "Y-m-d" ),
  10240. 'accountType' => $abDetail ['accountType'],
  10241. 'accountMsg' => $abDetail ['accountMsg'],
  10242. 'aid' => $abDetail ['aid'],
  10243. 'inComePrice' => $abDetail ['receivedPrice'],
  10244. 'expensesType' => $abDetail ['expensesType']
  10245. );
  10246. $accountBookStatistics->setAccountBookStatistics ( $item );
  10247. // 添加收入流水
  10248. $wasteBook = new wasteBook ();
  10249. $itemWaste = array (
  10250. 'accountPriceShow' => $receivedPrice,
  10251. 'accountPrice' => $receivedPrice,
  10252. 'expensesType' => 1,
  10253. 'accountType' => 6, // 流水类型
  10254. 'dataID' => $inComeId,
  10255. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10256. 'accountBank' => $accountBank,
  10257. 'category' => $this->staff [0] ['category'],
  10258. 'cid' => $this->staff [0] ['cid'],
  10259. 'name' => $this->staff [0] ['username'],
  10260. 'sid' => $this->staff [0] ['sid'],
  10261. 'inputDate' => date ( "Y-m-d H:i:s" )
  10262. );
  10263. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10264. // 添加一条理财支出
  10265. $accountBank = 'CGBDeposit';
  10266. $expenditureBank = '纵横广发';
  10267. $dailyExpenditureType = 4;
  10268. if ($accountType == 9) {
  10269. $accountBank = 'ICBCDeposit';
  10270. $expenditureBank = '纵横工行';
  10271. $dailyExpenditureType = 6;
  10272. }
  10273. $accountBook = new accountBook ();
  10274. $accountBook->expensesType = 2;
  10275. $accountBook->expenditureType = $dailyExpenditureType;
  10276. $accountBook->expenditureMsg = $accountMsg;
  10277. $accountBook->expenditurePrice = $receivedPrice;
  10278. $accountBook->expenditureBank = $expenditureBank;
  10279. $accountBook->expenditureDate = $receivedDate;
  10280. $accountBook->remarks = $remarks;
  10281. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10282. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10283. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10284. $id = $accountBook->insert ();
  10285. // 收支汇总-添加一条理财支出汇总
  10286. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10287. $accountBookStatistics = new accountBookStatistics ();
  10288. $item = array (
  10289. 'date' => date ( "Y-m-d" ),
  10290. 'accountType' => $abDetail ['accountType'],
  10291. 'accountMsg' => $abDetail ['accountMsg'],
  10292. 'aid' => $abDetail ['aid'],
  10293. 'financingPrice' => - $receivedPrice,
  10294. 'expensesType' => 3
  10295. );
  10296. $accountBookStatistics->setAccountBookStatistics ( $item );
  10297. // 添加一条支出理财流水
  10298. $accountTypeWaste = 5;
  10299. if ($accountMsg == '公司固定') {
  10300. $accountTypeWaste = 9;
  10301. } elseif ($accountMsg == '公司活期') {
  10302. $accountTypeWaste = 10;
  10303. } elseif ($accountMsg == '个人(GR)') {
  10304. $accountBank = 'PersonalDeposit';
  10305. }
  10306. $itemWaste = array (
  10307. 'expensesType' => 2,
  10308. 'accountType' => $accountTypeWaste,
  10309. 'accountPriceShow' => $receivedPrice,
  10310. 'accountPrice' => - $receivedPrice,
  10311. 'dataID' => $id,
  10312. 'dailyExpenditureType' => $dailyExpenditureType,
  10313. 'accountBank' => $accountBank,
  10314. 'category' => $this->staff [0] ['category'],
  10315. 'cid' => $this->staff [0] ['cid'],
  10316. 'name' => $this->staff [0] ['username'],
  10317. 'sid' => $this->staff [0] ['sid'],
  10318. 'inputDate' => date ( "Y-m-d H:i:s" )
  10319. );
  10320. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10321. } elseif ($accountType == 1) {
  10322. if ($receivedBank == '个人广发')
  10323. die ( 'illegal request' );
  10324. // 添加一条收入
  10325. $accountBook = new accountBook ();
  10326. $accountBook->accountType = $accountType;
  10327. $accountBook->accountMsg = $accountMsg;
  10328. $accountBook->receivedPrice = $receivedPrice;
  10329. $accountBook->receivedMsg = $receivedMsg;
  10330. $accountBook->receivedBank = $receivedBank;
  10331. $accountBook->receivedDate = $receivedDate;
  10332. $accountBook->remarks = $remarks;
  10333. $accountBook->expensesType = 1;
  10334. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10335. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10336. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10337. $id = $accountBook->insert ();
  10338. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10339. // 收支汇总-添加一条收入日常汇总
  10340. $accountBookStatistics = new accountBookStatistics ();
  10341. $item = array (
  10342. 'date' => date ( "Y-m-d" ),
  10343. 'accountType' => $abDetail ['accountType'],
  10344. 'accountMsg' => $abDetail ['accountMsg'],
  10345. 'aid' => $abDetail ['aid'],
  10346. 'expensesType' => $abDetail ['expensesType']
  10347. );
  10348. if ($abDetail ['accountType'] == 8) {
  10349. $item += array (
  10350. 'inComePrice' => $abDetail ['receivedPrice']
  10351. );
  10352. } else {
  10353. $item += array (
  10354. 'inComePrice' => $abDetail ['receivedPrice']
  10355. );
  10356. }
  10357. $accountBookStatistics->setAccountBookStatistics ( $item );
  10358. // 流水存储方向
  10359. $itemWaste = array (
  10360. 'accountType' => 6
  10361. ); // 流水类型
  10362. // if($accountMsg=='银行存款'||$accountMsg=='固定理财收益'){
  10363. // }else
  10364. if ($accountMsg == '活期理财收益') {
  10365. $itemWaste = array (
  10366. 'accountType' => 10
  10367. ); // 流水类型
  10368. }
  10369. // 添加收入流水
  10370. $wasteBook = new wasteBook ();
  10371. $itemWaste += array (
  10372. 'accountPrice' => $receivedPrice,
  10373. 'accountPriceShow' => $receivedPrice,
  10374. 'expensesType' => 1,
  10375. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10376. 'dataID' => $id,
  10377. 'accountBank' => $accountBank,
  10378. 'category' => $this->staff [0] ['category'],
  10379. 'cid' => $this->staff [0] ['cid'],
  10380. 'name' => $this->staff [0] ['username'],
  10381. 'sid' => $this->staff [0] ['sid'],
  10382. 'inputDate' => date ( "Y-m-d H:i:s" )
  10383. );
  10384. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10385. } else { // 普通日常收入处理
  10386. // 添加一条收入
  10387. $accountBook = new accountBook ();
  10388. $accountBook->accountType = $accountType;
  10389. $accountBook->accountMsg = $accountMsg;
  10390. $accountBook->receivedPrice = $receivedPrice;
  10391. $accountBook->receivedMsg = $receivedMsg;
  10392. $accountBook->receivedBank = $receivedBank;
  10393. $accountBook->receivedDate = $receivedDate;
  10394. $accountBook->remarks = $remarks;
  10395. $accountBook->expensesType = 1;
  10396. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10397. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10398. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10399. $id = $accountBook->insert ();
  10400. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10401. // 收支汇总-添加一条收入日常汇总
  10402. $accountBookStatistics = new accountBookStatistics ();
  10403. $item = array (
  10404. 'date' => date ( "Y-m-d" ),
  10405. 'accountType' => $abDetail ['accountType'],
  10406. 'accountMsg' => $abDetail ['accountMsg'],
  10407. 'aid' => $abDetail ['aid'],
  10408. 'expensesType' => $abDetail ['expensesType']
  10409. );
  10410. if ($abDetail ['accountType'] == 8) {
  10411. $item += array (
  10412. 'inComePrice' => $abDetail ['receivedPrice']
  10413. );
  10414. } else {
  10415. $item += array (
  10416. 'inComePrice' => $abDetail ['receivedPrice']
  10417. );
  10418. }
  10419. $accountBookStatistics->setAccountBookStatistics ( $item );
  10420. // 添加收入流水
  10421. $itemWaste = array (
  10422. 'accountPrice' => $receivedPrice
  10423. );
  10424. if ($receivedBank == '个人广发') {
  10425. $itemWaste = array (
  10426. 'accountPrice' => - $receivedPrice
  10427. );
  10428. }
  10429. $wasteBook = new wasteBook ();
  10430. $itemWaste += array (
  10431. 'accountPriceShow' => $receivedPrice,
  10432. 'expensesType' => 1,
  10433. 'accountType' => 6, // 流水类型
  10434. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10435. 'dataID' => $id,
  10436. 'accountBank' => $accountBank,
  10437. 'category' => $this->staff [0] ['category'],
  10438. 'cid' => $this->staff [0] ['cid'],
  10439. 'name' => $this->staff [0] ['username'],
  10440. 'sid' => $this->staff [0] ['sid'],
  10441. 'inputDate' => date ( "Y-m-d H:i:s" )
  10442. );
  10443. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10444. }
  10445. }
  10446. return '/payments';
  10447. }
  10448. /**
  10449. * 添加收入
  10450. * @return string
  10451. */
  10452. function paymentsIncomeDo_() {
  10453. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10454. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10455. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10456. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10457. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10458. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10459. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10460. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10461. Doo::loadClass ( 'XDeode' );
  10462. $XDeode = new XDeode ( 5 );
  10463. Doo::loadModel ( "accountBook" );
  10464. $accountBook = new accountBook ();
  10465. $accountBank = '';
  10466. $accountTypeWaste = 6;
  10467. if ($receivedBank == '纵横广发') {
  10468. $accountBank = 'CGBDeposit';
  10469. } elseif ($receivedBank == '纵横工行') {
  10470. $accountBank = 'ICBCDeposit';
  10471. } elseif ($receivedBank == '华润银行') {
  10472. $accountBank = 'HUADeposit';
  10473. } elseif ($receivedBank == '个人广发') {
  10474. $accountBank = 'PersonalDeposit';
  10475. }
  10476. if (empty ( $accountBank ))
  10477. die ( 'illegal request' );
  10478. $dailyIncomeType = '';
  10479. $itemWaste = array (
  10480. 'accountPrice' => $receivedPrice,
  10481. 'expensesType' => 1
  10482. );
  10483. if ($receivedBank == '个人广发') {
  10484. $itemWaste = array (
  10485. 'accountPrice' => - $receivedPrice,
  10486. 'expensesType' => 1
  10487. );
  10488. }
  10489. if ($accountType == 4) {
  10490. $dailyIncomeType = 4;
  10491. } elseif ($accountType == 1) {
  10492. $dailyIncomeType = 1;
  10493. } elseif ($accountType == 2) {
  10494. $dailyIncomeType = 2;
  10495. } elseif ($accountType == 3) {
  10496. $dailyIncomeType = 3;
  10497. } elseif ($accountType == 5) {
  10498. $dailyIncomeType = 5;
  10499. } elseif ($accountType == 6) {
  10500. $dailyIncomeType = 6;
  10501. } elseif ($accountType == 7 || $accountType == 9) {
  10502. $dailyIncomeType = 7;
  10503. if ($accountMsg == '公司固定') {
  10504. $accountTypeWaste = 9;
  10505. } elseif ($accountMsg == '公司活期') {
  10506. $accountTypeWaste = 10;
  10507. } elseif ($accountMsg == '个人(GR)') {
  10508. $accountBank = 'PersonalDeposit';
  10509. }
  10510. $itemWaste = array (
  10511. 'accountPrice' => - $receivedPrice,
  10512. 'expensesType' => 2
  10513. );
  10514. } elseif ($accountType == 8) {
  10515. $dailyIncomeType = 8;
  10516. }
  10517. if (empty ( $dailyIncomeType ))
  10518. die ( 'illegal request' );
  10519. $accountBook->accountType = $accountType;
  10520. $accountBook->accountMsg = $accountMsg;
  10521. $accountBook->receivedPrice = $receivedPrice;
  10522. $accountBook->receivedMsg = $receivedMsg;
  10523. $accountBook->receivedBank = $receivedBank;
  10524. $accountBook->receivedDate = $receivedDate;
  10525. $accountBook->remarks = $remarks;
  10526. $accountBook->expensesType = 1;
  10527. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10528. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10529. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10530. $id = $accountBook->insert ();
  10531. //
  10532. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10533. // 收支汇总
  10534. Doo::loadModel ( "accountBookStatistics" );
  10535. $accountBookStatistics = new accountBookStatistics ();
  10536. $item = array (
  10537. 'date' => date ( "Y-m-d" ),
  10538. 'accountType' => $abDetail ['accountType'],
  10539. 'accountMsg' => $abDetail ['accountMsg'],
  10540. 'aid' => $abDetail ['aid']
  10541. );
  10542. if ($abDetail ['expensesType'] == 1) {
  10543. if ($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) {
  10544. $item += array (
  10545. 'financingPrice' => - $receivedPrice,
  10546. 'expensesType' => 3
  10547. );
  10548. } else if ($abDetail ['accountType'] == 8) {
  10549. $item += array (
  10550. 'inComePrice' => - $abDetail ['receivedPrice'],
  10551. 'expensesType' => $abDetail ['expensesType']
  10552. );
  10553. } else {
  10554. $item += array (
  10555. 'inComePrice' => $abDetail ['receivedPrice'],
  10556. 'expensesType' => $abDetail ['expensesType']
  10557. );
  10558. }
  10559. }
  10560. $accountBookStatistics->setAccountBookStatistics ( $item );
  10561. // 为理财时需添加一条日常支出
  10562. if ($accountType == 7 || $accountType == 9) {
  10563. }
  10564. // 公司流水记录
  10565. Doo::loadModel ( 'wasteBook' );
  10566. $wasteBook = new wasteBook ();
  10567. // 银行
  10568. // if (empty($abDetail)){
  10569. $itemWaste += array (
  10570. 'accountPriceShow' => $receivedPrice,
  10571. 'dataID' => $id,
  10572. 'accountType' => $accountTypeWaste,
  10573. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10574. 'accountBank' => $accountBank,
  10575. 'category' => $this->staff [0] ['category'],
  10576. 'cid' => $this->staff [0] ['cid'],
  10577. 'name' => $this->staff [0] ['username'],
  10578. 'sid' => $this->staff [0] ['sid'],
  10579. 'inputDate' => date ( "Y-m-d H:i:s" )
  10580. );
  10581. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10582. // }
  10583. // 类型为理财7或者9 要添加一笔理财支出
  10584. if ($accountType == 7 || $accountType == 9) {
  10585. $accountBank = 'CGBDeposit';
  10586. $expenditureBank = '纵横广发';
  10587. $dailyExpenditureType = 4;
  10588. if ($accountType == 9) {
  10589. $accountBank = 'ICBCDeposit';
  10590. $expenditureBank = '纵横工行';
  10591. $dailyExpenditureType = 6;
  10592. }
  10593. // 添加一条支出
  10594. $accountBook = new accountBook ();
  10595. $accountBook->expenditureType = $dailyExpenditureType;
  10596. $accountBook->expenditureMsg = $accountMsg;
  10597. $accountBook->expenditurePrice = $receivedPrice;
  10598. $accountBook->expenditureBank = $expenditureBank;
  10599. $accountBook->expenditureDate = $receivedDate;
  10600. $accountBook->remarks = $remarks;
  10601. $accountBook->expensesType = 2;
  10602. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10603. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10604. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10605. $id = $accountBook->insert ();
  10606. // 添加一条收入流水
  10607. $itemWaste = array (
  10608. 'accountPriceShow' => $receivedPrice,
  10609. 'accountPrice' => $receivedPrice,
  10610. 'dataID' => $id,
  10611. 'expensesType' => 2,
  10612. 'accountType' => $accountTypeWaste,
  10613. 'dailyExpenditureType' => $dailyExpenditureType,
  10614. 'accountBank' => $accountBank,
  10615. 'category' => $this->staff [0] ['category'],
  10616. 'cid' => $this->staff [0] ['cid'],
  10617. 'name' => $this->staff [0] ['username'],
  10618. 'sid' => $this->staff [0] ['sid'],
  10619. 'inputDate' => date ( "Y-m-d H:i:s" )
  10620. );
  10621. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10622. }
  10623. }
  10624. return '/payments';
  10625. }
  10626. function paymentsExpenditureDo() {
  10627. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10628. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10629. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10630. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10631. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10632. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10633. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10634. // 理财支出特殊处理
  10635. Doo::loadModel ( "accountBook" );
  10636. Doo::loadModel ( "accountBookStatistics" );
  10637. Doo::loadModel ( 'wasteBook' );
  10638. $accountBank = '';
  10639. if ($expenditureBank == '纵横广发') {
  10640. $accountBank = 'CGBDeposit';
  10641. } elseif ($expenditureBank == '纵横工行') {
  10642. $accountBank = 'ICBCDeposit';
  10643. } elseif ($expenditureBank == '华润银行') {
  10644. $accountBank = 'HUADeposit';
  10645. } elseif ($expenditureBank == '个人广发') {
  10646. $accountBank = 'PersonalDeposit';
  10647. }
  10648. if (empty ( $accountBank ))
  10649. die ( 'illegal request' );
  10650. if ($expenditureType == 4 || $expenditureType == 6) {
  10651. if ($expenditureBank == '个人广发') {
  10652. die ( '个人广发 illegal request' );
  10653. }
  10654. // 添加一笔日常支出
  10655. $accountBook = new accountBook ();
  10656. $accountBook->expensesType = 2;
  10657. $accountBook->expenditureType = 7;
  10658. $accountBook->expenditureMsg = $expenditureMsg;
  10659. $accountBook->expenditurePrice = $expenditurePrice;
  10660. $accountBook->expenditureBank = $expenditureBank;
  10661. $accountBook->expenditureDate = $expenditureDate;
  10662. $accountBook->remarks = $remarks;
  10663. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10664. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10665. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10666. $expenditureId = $accountBook->insert ();
  10667. // 添加日常支出汇总
  10668. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  10669. $accountBookStatistics = new accountBookStatistics ();
  10670. $item = array (
  10671. 'date' => date ( "Y-m-d" ),
  10672. 'expenditureType' => $abDetail ['expenditureType'],
  10673. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10674. 'aid' => $abDetail ['aid'],
  10675. 'payPrice' => $abDetail ['expenditurePrice'],
  10676. 'expensesType' => $abDetail ['expensesType']
  10677. );
  10678. $accountBookStatistics->setAccountBookStatistics ( $item );
  10679. // 公司日常支出流水
  10680. $wasteBook = new wasteBook ();
  10681. $itemWaste = array (
  10682. 'accountPrice' => - $expenditurePrice
  10683. );
  10684. if ($expenditureBank == '个人广发') {
  10685. $itemWaste = array (
  10686. 'accountPrice' => $expenditurePrice
  10687. );
  10688. }
  10689. $itemWaste += array (
  10690. 'expensesType' => 2,
  10691. 'accountType' => 5,
  10692. 'dailyExpenditureType' => $expenditureType,
  10693. 'accountPriceShow' => $expenditurePrice,
  10694. 'accountPrice' => - $expenditurePrice,
  10695. 'dataID' => $expenditureId,
  10696. 'accountBank' => $accountBank,
  10697. 'category' => $this->staff [0] ['category'],
  10698. 'cid' => $this->staff [0] ['cid'],
  10699. 'name' => $this->staff [0] ['username'],
  10700. 'sid' => $this->staff [0] ['sid'],
  10701. 'inputDate' => date ( "Y-m-d H:i:s" )
  10702. );
  10703. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10704. // 添加一笔理财收入
  10705. $accountBank = 'CGBDeposit';
  10706. $dailyIncomeType = 7;
  10707. $receivedBank = '纵横广发';
  10708. if ($expenditureType == 6) {
  10709. $accountBank = 'ICBCDeposit';
  10710. $receivedBank = '纵横工行';
  10711. $dailyIncomeType = 9;
  10712. }
  10713. $accountBook = new accountBook ();
  10714. $accountBook->expensesType = 1;
  10715. $accountBook->accountType = $dailyIncomeType;
  10716. $accountBook->accountMsg = $expenditureMsg;
  10717. $accountBook->receivedPrice = $expenditurePrice;
  10718. $accountBook->receivedBank = $receivedBank;
  10719. $accountBook->receivedDate = $expenditureDate;
  10720. $accountBook->remarks = $remarks;
  10721. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10722. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10723. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10724. $id = $accountBook->insert ();
  10725. // 添加日常理财收入汇总
  10726. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  10727. $accountBookStatistics = new accountBookStatistics ();
  10728. $item = array (
  10729. 'date' => date ( "Y-m-d" ),
  10730. 'expenditureType' => $abDetail ['expenditureType'],
  10731. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10732. 'aid' => $abDetail ['aid'],
  10733. 'financingPrice' => $expenditurePrice,
  10734. 'expensesType' => 3
  10735. );
  10736. $accountBookStatistics->setAccountBookStatistics ( $item );
  10737. // 添加一笔收入流水
  10738. if ($expenditureMsg == '公司固定') {
  10739. $accountTypeWaste = 9;
  10740. } elseif ($expenditureMsg == '公司活期') {
  10741. $accountTypeWaste = 10;
  10742. } elseif ($expenditureMsg == '个人(GR)') {
  10743. $accountBank = 'PersonalDeposit';
  10744. }
  10745. $itemWaste = array (
  10746. 'expensesType' => 1,
  10747. 'accountType' => $accountTypeWaste,
  10748. 'accountPriceShow' => $expenditurePrice,
  10749. 'accountPrice' => $expenditurePrice,
  10750. 'dataID' => $id,
  10751. 'dailyIncomeType' => $dailyIncomeType,
  10752. 'accountBank' => $accountBank,
  10753. 'category' => $this->staff [0] ['category'],
  10754. 'cid' => $this->staff [0] ['cid'],
  10755. 'name' => $this->staff [0] ['username'],
  10756. 'sid' => $this->staff [0] ['sid'],
  10757. 'inputDate' => date ( "Y-m-d H:i:s" )
  10758. );
  10759. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10760. } else {
  10761. // 添加一笔日常支出
  10762. $accountBook = new accountBook ();
  10763. $accountBook->expensesType = 2;
  10764. $accountBook->expenditureType = $expenditureType;
  10765. $accountBook->expenditureMsg = $expenditureMsg;
  10766. $accountBook->expenditurePrice = $expenditurePrice;
  10767. $accountBook->expenditureBank = $expenditureBank;
  10768. $accountBook->expenditureDate = $expenditureDate;
  10769. $accountBook->remarks = $remarks;
  10770. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10771. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10772. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10773. $id = $accountBook->insert ();
  10774. // 添加日常支出汇总
  10775. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10776. $accountBookStatistics = new accountBookStatistics ();
  10777. $item = array (
  10778. 'date' => date ( "Y-m-d" ),
  10779. 'expenditureType' => $abDetail ['expenditureType'],
  10780. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10781. 'aid' => $abDetail ['aid'],
  10782. 'expensesType' => $abDetail ['expensesType']
  10783. );
  10784. if ($expenditureType == 5) {
  10785. $item += array (
  10786. 'payPrice' => - $abDetail ['expenditurePrice']
  10787. );
  10788. } else {
  10789. $item += array (
  10790. 'payPrice' => $abDetail ['expenditurePrice']
  10791. );
  10792. }
  10793. $accountBookStatistics->setAccountBookStatistics ( $item );
  10794. // 公司日常支出流水
  10795. $wasteBook = new wasteBook ();
  10796. $itemWaste = array (
  10797. 'accountPrice' => - $expenditurePrice
  10798. );
  10799. if ($expenditureBank == '个人广发') {
  10800. $itemWaste = array (
  10801. 'accountPrice' => $expenditurePrice
  10802. );
  10803. }
  10804. $itemWaste += array (
  10805. 'expensesType' => 2,
  10806. 'accountType' => 5,
  10807. 'accountPriceShow' => $expenditurePrice,
  10808. 'dataID' => $id,
  10809. 'dailyExpenditureType' => $expenditureType,
  10810. 'accountBank' => $accountBank,
  10811. 'category' => $this->staff [0] ['category'],
  10812. 'cid' => $this->staff [0] ['cid'],
  10813. 'name' => $this->staff [0] ['username'],
  10814. 'sid' => $this->staff [0] ['sid'],
  10815. 'inputDate' => date ( "Y-m-d H:i:s" )
  10816. );
  10817. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10818. }
  10819. }
  10820. return '/payments';
  10821. }
  10822. /**
  10823. * 添加支出
  10824. */
  10825. function paymentsExpenditureDo_() {
  10826. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10827. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10828. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10829. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10830. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10831. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10832. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10833. $dailyExpenditureType = '';
  10834. $accountTypeWaste = 5;
  10835. $accountBank = '';
  10836. if ($expenditureBank == '纵横广发') {
  10837. $accountBank = 'CGBDeposit';
  10838. } elseif ($expenditureBank == '纵横工行') {
  10839. $accountBank = 'ICBCDeposit';
  10840. } elseif ($expenditureBank == '华润银行') {
  10841. $accountBank = 'HUADeposit';
  10842. } elseif ($expenditureBank == '个人广发') {
  10843. $accountBank = 'PersonalDeposit';
  10844. }
  10845. if (empty ( $accountBank ))
  10846. die ( 'illegal request' );
  10847. $itemWaste = array (
  10848. 'accountPrice' => - $expenditurePrice
  10849. );
  10850. if ($expenditureBank == '个人广发') {
  10851. $itemWaste = array (
  10852. 'accountPrice' => $expenditurePrice
  10853. );
  10854. }
  10855. if ($expenditureType == 4 || $expenditureType == 6) {
  10856. $dailyExpenditureType = 4;
  10857. if ($expenditureMsg == '公司固定') {
  10858. $accountTypeWaste = 9;
  10859. } elseif ($expenditureMsg == '公司活期') {
  10860. $accountTypeWaste = 10;
  10861. } elseif ($expenditureMsg == '个人(GR)') {
  10862. $accountBank = 'PersonalDeposit';
  10863. }
  10864. $itemWaste = array (
  10865. 'accountPrice' => $expenditurePrice
  10866. );
  10867. } elseif ($expenditureType == 1) {
  10868. $dailyExpenditureType = 1;
  10869. } elseif ($expenditureType == 2) {
  10870. $dailyExpenditureType = 2;
  10871. } elseif ($expenditureType == 3) {
  10872. $dailyExpenditureType = 3;
  10873. } elseif ($expenditureType == 5) {
  10874. $dailyExpenditureType = 5;
  10875. }
  10876. if (empty ( $dailyExpenditureType ))
  10877. die ( 'illegal request' );
  10878. Doo::loadModel ( "accountBook" );
  10879. $accountBook = new accountBook ();
  10880. $accountBook->expenditureType = $expenditureType;
  10881. $accountBook->expenditureMsg = $expenditureMsg;
  10882. $accountBook->expenditurePrice = $expenditurePrice;
  10883. $accountBook->expenditureBank = $expenditureBank;
  10884. $accountBook->expenditureDate = $expenditureDate;
  10885. $accountBook->remarks = $remarks;
  10886. $accountBook->expensesType = 2;
  10887. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10888. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10889. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10890. $id = $accountBook->insert ();
  10891. //
  10892. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10893. Doo::loadModel ( "accountBookStatistics" );
  10894. $accountBookStatistics = new accountBookStatistics ();
  10895. $item = array (
  10896. 'date' => date ( "Y-m-d" ),
  10897. 'expenditureType' => $abDetail ['expenditureType'],
  10898. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10899. 'aid' => $abDetail ['aid']
  10900. );
  10901. if ($abDetail ['expensesType'] == 2) {
  10902. if ($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) {
  10903. $item += array (
  10904. 'financingPrice' => $expenditurePrice,
  10905. 'expensesType' => 3
  10906. );
  10907. } elseif ($abDetail ['expenditureType'] == 5) {
  10908. $item += array (
  10909. 'payPrice' => $abDetail ['expenditurePrice'],
  10910. 'expensesType' => $abDetail ['expensesType']
  10911. );
  10912. } else {
  10913. $item += array (
  10914. 'payPrice' => $abDetail ['expenditurePrice'],
  10915. 'expensesType' => $abDetail ['expensesType']
  10916. );
  10917. }
  10918. }
  10919. $accountBookStatistics->setAccountBookStatistics ( $item );
  10920. // 公司流水记录
  10921. Doo::loadModel ( 'wasteBook' );
  10922. $wasteBook = new wasteBook ();
  10923. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountTypeWaste, $id );
  10924. // 银行
  10925. if (empty ( $abDetail )) {
  10926. $itemWaste += array (
  10927. 'accountPriceShow' => $expenditurePrice,
  10928. 'dataID' => $id,
  10929. 'expensesType' => 2,
  10930. 'accountType' => $accountTypeWaste,
  10931. 'dailyExpenditureType' => $expenditureType,
  10932. 'accountBank' => $accountBank,
  10933. 'category' => $this->staff [0] ['category'],
  10934. 'cid' => $this->staff [0] ['cid'],
  10935. 'name' => $this->staff [0] ['username'],
  10936. 'sid' => $this->staff [0] ['sid'],
  10937. 'inputDate' => date ( "Y-m-d H:i:s" )
  10938. );
  10939. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10940. }
  10941. // 支出类型为4或者6 需要添加一笔收入和收入流水
  10942. if ($expenditureType == 4 || $expenditureType == 6) {
  10943. $accountBank = 'CGBDeposit';
  10944. $dailyIncomeType = 7;
  10945. $receivedBank = '纵横广发';
  10946. if ($expenditureType == 6) {
  10947. $accountBank = 'ICBCDeposit';
  10948. $receivedBank = '纵横工行';
  10949. $dailyIncomeType = 9;
  10950. }
  10951. // 添加一笔收入
  10952. $accountBook = new accountBook ();
  10953. $accountBook->accountType = $dailyIncomeType;
  10954. $accountBook->accountMsg = $expenditureMsg;
  10955. $accountBook->receivedPrice = $expenditurePrice;
  10956. $accountBook->receivedBank = $receivedBank;
  10957. $accountBook->receivedDate = $expenditureDate;
  10958. $accountBook->remarks = $remarks;
  10959. $accountBook->expensesType = 1;
  10960. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10961. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10962. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10963. $id = $accountBook->insert ();
  10964. // 添加一笔收入流水
  10965. $itemWaste = array (
  10966. 'accountPriceShow' => $expenditurePrice,
  10967. 'accountPrice' => - $expenditurePrice,
  10968. 'dataID' => $id,
  10969. 'expensesType' => 1,
  10970. 'accountType' => $accountTypeWaste,
  10971. 'dailyIncomeType' => $dailyIncomeType,
  10972. 'accountBank' => $accountBank,
  10973. 'category' => $this->staff [0] ['category'],
  10974. 'cid' => $this->staff [0] ['cid'],
  10975. 'name' => $this->staff [0] ['username'],
  10976. 'sid' => $this->staff [0] ['sid'],
  10977. 'inputDate' => date ( "Y-m-d H:i:s" )
  10978. );
  10979. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10980. }
  10981. }
  10982. return '/payments';
  10983. }
  10984. /**
  10985. * 所有收支
  10986. */
  10987. function paymentsAchieve() {
  10988. $page_size = 12;
  10989. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  10990. $expensesType = isset ( $this->params ['expensesType'] ) ? $this->params ['expensesType'] : 'ALL';
  10991. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  10992. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  10993. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10994. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10995. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10996. $submitType = $this->get_args ( 'submitType' ) ? $this->get_args ( 'submitType' ) : "";
  10997. Doo::loadModel ( "accountBookStatistics" );
  10998. $accountBookStatistics = new accountBookStatistics ();
  10999. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  11000. $data ['statisticsList'] = $statisticsList;
  11001. Doo::loadModel ( "accountBook" );
  11002. $accountBook = new accountBook ();
  11003. $con = '';
  11004. if ($expensesType == 'INCOME')
  11005. $con = ' and expensesType=1 ';
  11006. elseif ($expensesType == 'PAY')
  11007. $con = ' and expensesType=2 ';
  11008. $dateArr = explode ( ':', $date );
  11009. $D1 = $dateString = '';
  11010. $D2 = '';
  11011. if (! empty ( $date )) {
  11012. $D1 = $dateArr [0];
  11013. if (isset ( $dateArr [1] ))
  11014. $D2 = $dateArr [1];
  11015. else
  11016. $D2 = '';
  11017. $dateString = $D1 . " : " . $D2;
  11018. }
  11019. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11020. $con .= ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11021. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11022. $con .= ' and inputDate like "%' . $D1 . '%" ';
  11023. if (! empty ( $price ))
  11024. $con .= ' and (receivedPrice=' . $price . ' or expenditurePrice=' . $price . ')';
  11025. if ($submitType == 1) {
  11026. if ($accountType != '') {
  11027. $expenditureType = '';
  11028. $con .= ' and accountType=' . $accountType;
  11029. if (! empty ( $accountMsg ))
  11030. $con .= ' and (accountType=' . $accountType . ' and accountMsg like "%' . $accountMsg . '%")';
  11031. }
  11032. } elseif ($submitType == 2) {
  11033. if ($expenditureType != '') {
  11034. $accountType = $accountMsg = '';
  11035. $con .= ' and expenditureType=' . $expenditureType;
  11036. }
  11037. } else {
  11038. $accountType = $accountMsg = $expenditureType = '';
  11039. }
  11040. $sql = "" . $con;
  11041. $action = "paymentsAchieve";
  11042. $get = '/' . $expensesType; // "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  11043. $pageinfo = $this->get_page ( "CLD_accountBook", $sql, $page, $page_size, $action, $get, "" );
  11044. $limit = $pageinfo ['lower'] . ',' . $page_size;
  11045. $list = $accountBook->getAccountBookBySql ( $limit, $sql, 'desc' );
  11046. $data ['expenditureType'] = $expenditureType;
  11047. $data ['accountMsg'] = $accountMsg;
  11048. $data ['accountType'] = $accountType;
  11049. $data ['inputDate'] = $date;
  11050. $data ['price'] = $price;
  11051. $data ['expensesType'] = $expensesType;
  11052. $data ['page'] = $pageinfo;
  11053. $data ['list'] = $list;
  11054. $data ['memu'] = "receipt";
  11055. $data ['staff'] = $this->staff;
  11056. $data ['receiptMemu'] = 'payments';
  11057. $data ['verifyId'] = $this->verifyId;
  11058. $data ['executeId'] = $this->executeId;
  11059. $this->render ( "/expenses/paymentsAchieve", $data );
  11060. }
  11061. function paymentsIncomeUpdateDo() {
  11062. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11063. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11064. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11065. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  11066. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  11067. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  11068. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  11069. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11070. if (! empty ( $aidKey ) && ! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  11071. Doo::loadClass ( 'XDeode' );
  11072. $XDeode = new XDeode ( 5 );
  11073. $aid = $XDeode->decode ( $aidKey );
  11074. Doo::loadModel ( "accountBook" );
  11075. $accountBook = new accountBook ();
  11076. //
  11077. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11078. $price = $receivedPrice - $abDetail [inComePrice];
  11079. Doo::loadModel ( "accountBookStatistics" );
  11080. $accountBookStatistics = new accountBookStatistics ();
  11081. if ($abDetail ['accountType'] == 7) {
  11082. $item += array (
  11083. 'date' => date ( "Y-m-d" ),
  11084. 'financingPrice' => - $price,
  11085. 'expensesType' => 3,
  11086. 'aid' => $abDetail ['aid']
  11087. );
  11088. } elseif ($abDetail ['accountType'] == 8) {
  11089. $item += array (
  11090. 'date' => date ( "Y-m-d" ),
  11091. 'expensesType' => $abDetail ['expensesType'],
  11092. 'inComePrice' => - $price,
  11093. 'aid' => $abDetail ['aid']
  11094. );
  11095. } else {
  11096. $item = array (
  11097. 'date' => date ( "Y-m-d" ),
  11098. 'expensesType' => $abDetail ['expensesType'],
  11099. 'inComePrice' => $price,
  11100. 'aid' => $abDetail ['aid']
  11101. );
  11102. }
  11103. $accountBookStatistics->setAccountBookStatistics ( $item );
  11104. $accountBook->accountType = $accountType;
  11105. $accountBook->accountMsg = $accountMsg;
  11106. $accountBook->receivedPrice = $receivedPrice;
  11107. $accountBook->receivedMsg = $receivedMsg;
  11108. $accountBook->receivedBank = $receivedBank;
  11109. $accountBook->receivedDate = $receivedDate;
  11110. $accountBook->remarks = $remarks;
  11111. $accountBook->aid = $aid;
  11112. $accountBook->update ();
  11113. }
  11114. return '/paymentsAchieve';
  11115. }
  11116. function paymentsExpenditureEdiDo() {
  11117. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11118. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11119. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11120. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11121. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11122. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11123. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11124. if (! empty ( $aidKey ) && ! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11125. Doo::loadClass ( 'XDeode' );
  11126. $XDeode = new XDeode ( 5 );
  11127. $aid = $XDeode->decode ( $aidKey );
  11128. Doo::loadModel ( "accountBook" );
  11129. $accountBook = new accountBook ();
  11130. // 汇总信息
  11131. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11132. $price = $expenditurePrice - $abDetail [expenditurePrice];
  11133. Doo::loadModel ( "accountBookStatistics" );
  11134. $accountBookStatistics = new accountBookStatistics ();
  11135. if ($abDetail ['expenditureType'] == 4) {
  11136. $item += array (
  11137. 'date' => date ( "Y-m-d" ),
  11138. 'financingPrice' => $price,
  11139. 'expensesType' => 3,
  11140. 'aid' => $abDetail ['aid']
  11141. );
  11142. } elseif ($abDetail ['expenditureType'] == 5) {
  11143. $item += array (
  11144. 'date' => date ( "Y-m-d" ),
  11145. 'expensesType' => $abDetail ['expensesType'],
  11146. 'payPrice' => $price,
  11147. 'aid' => $abDetail ['aid']
  11148. );
  11149. } else {
  11150. $item = array (
  11151. 'date' => date ( "Y-m-d" ),
  11152. 'expensesType' => $abDetail ['expensesType'],
  11153. 'payPrice' => $price,
  11154. 'aid' => $abDetail ['aid']
  11155. );
  11156. }
  11157. $accountBookStatistics->setAccountBookStatistics ( $item );
  11158. //
  11159. $accountBook->expenditureType = $expenditureType;
  11160. $accountBook->expenditureMsg = $expenditureMsg;
  11161. $accountBook->expenditurePrice = $expenditurePrice;
  11162. $accountBook->expenditureBank = $expenditureBank;
  11163. $accountBook->remarks = $remarks;
  11164. $accountBook->expenditureDate = $expenditureDate;
  11165. $accountBook->aid = $aid;
  11166. $id = $accountBook->update ();
  11167. }
  11168. return '/paymentsAchieve';
  11169. }
  11170. function paymentsDelDo() {
  11171. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11172. if (! empty ( $aidKey )) {
  11173. Doo::loadClass ( 'XDeode' );
  11174. $XDeode = new XDeode ( 5 );
  11175. $aid = $XDeode->decode ( $aidKey );
  11176. Doo::loadModel ( "accountBook" );
  11177. $accountBook = new accountBook ();
  11178. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11179. if (empty ( $abDetail ))
  11180. die ( 'illegal request' );
  11181. // 删除收支
  11182. Doo::loadModel ( "accountBookStatistics" );
  11183. $accountBookStatistics = new accountBookStatistics ();
  11184. $item = array (
  11185. 'date' => date ( "Y-m-d" ),
  11186. 'aid' => $abDetail ['aid']
  11187. );
  11188. $accountType = '';
  11189. if ($abDetail ['expensesType'] == 1) {
  11190. $accountType = 6;
  11191. if ($abDetail ['accountType'] != 7) {
  11192. $item += array (
  11193. 'expensesType' => $abDetail ['expensesType'],
  11194. 'inComePrice' => - $abDetail ['receivedPrice']
  11195. );
  11196. } else {
  11197. $item += array (
  11198. 'financingPrice' => $abDetail ['receivedPrice'],
  11199. 'expensesType' => 3
  11200. );
  11201. }
  11202. } elseif ($abDetail ['expensesType'] == 2) {
  11203. $accountType = 5;
  11204. if ($abDetail ['accountType'] != 7) {
  11205. $item += array (
  11206. 'expensesType' => $abDetail ['expensesType'],
  11207. 'payPrice' => - $abDetail ['expenditurePrice']
  11208. );
  11209. } else {
  11210. $item += array (
  11211. 'financingPrice' => - $abDetail ['expenditurePrice'],
  11212. 'expensesType' => 3
  11213. );
  11214. }
  11215. }
  11216. if (($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) && $abDetail ['expensesType'] == 2) {
  11217. if ($abDetail ['expenditureMsg'] == '公司固定')
  11218. $accountType = 9;
  11219. elseif ($abDetail ['expenditureMsg'] == '公司活期')
  11220. $accountType = 10;
  11221. }
  11222. if (($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) && $abDetail ['expensesType'] == 1) {
  11223. if ($abDetail ['accountMsg'] == '公司固定')
  11224. $accountType = 9;
  11225. elseif ($abDetail ['accountMsg'] == '公司活期')
  11226. $accountType = 10;
  11227. }
  11228. if ($abDetail ['accountMsg'] == '活期理财收益') {
  11229. $accountType = 10;
  11230. }
  11231. $accountBookStatistics->setAccountBookStatistics ( $item );
  11232. $accountBook->delete ( array (
  11233. 'where' => 'aid=' . $aid,
  11234. 'limit' => 1
  11235. ) );
  11236. // 删除收入流水
  11237. if (! empty ( $accountType )) {
  11238. Doo::loadModel ( 'wasteBook' );
  11239. $wasteBook = new wasteBook ();
  11240. $wasteBook->delete ( array (
  11241. 'where' => 'dataID=' . $aid . ' and accountType=' . $accountType,
  11242. 'limit' => 1
  11243. ) );
  11244. }
  11245. }
  11246. return '/paymentsAchieve';
  11247. }
  11248. function paymentsCollect() {
  11249. Doo::loadModel ( "execute" );
  11250. $execute = new execute ();
  11251. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11252. die ( 'illegal request' );
  11253. }
  11254. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11255. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  11256. Doo::loadModel ( "accountBookStatistics" );
  11257. $accountBookStatistics = new accountBookStatistics ();
  11258. Doo::loadClass ( 'receipt.func' );
  11259. $statisticsIncome = $accountBookStatistics->getStatisticsByCollect ( $year );
  11260. $html = _getPaymentsCollectByYearHtml ( $statisticsIncome );
  11261. $data ['html'] = $html ['html'];
  11262. $data ['inSum'] = $html ['sum'];
  11263. $statisticsPay = $accountBookStatistics->getStatisticsByCollect ( $year, 2 );
  11264. $html = _getPaymentsCollectPayByYearHtml ( $statisticsPay );
  11265. $data ['payHtml'] = $html ['html'];
  11266. $data ['paySum'] = $html ['sum'];
  11267. // 余额统计
  11268. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1 );
  11269. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2 );
  11270. include './protected/config/wasteBook.conf.php';
  11271. Doo::loadModel ( 'wasteBook' );
  11272. $wasteBook = new wasteBook ();
  11273. $inComePay = $wasteBook->getWasteBookByStatistics ( 1, $year );
  11274. $pay = $wasteBook->getWasteBookByStatistics ( 2, $year );
  11275. // 获得年份之前所有金额
  11276. $detail = $wasteBook->getWasteBookByStatisticsYear ( $year );
  11277. // print_r($detail);
  11278. // $waste['total'];
  11279. $lastBalanceHtml = '<tr><th colspan="2">截至上月余额</th>';
  11280. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11281. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11282. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11283. $inSum = $paySum = $showInSum = $showPaySum = $balanceSum = 0;
  11284. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11285. $limitMonth = date ( 'm' ); // 限制显示月份参数
  11286. if (date ( 'Y' ) > $year) {
  11287. $limitMonth = 12;
  11288. }
  11289. for($i = 1; $i <= 12; $i ++) {
  11290. $inComeA = $payB = 0;
  11291. $falg = true;
  11292. foreach ( $inComePay as $key => $value ) {
  11293. if ($value ['month'] == $i) {
  11294. $falg = false;
  11295. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11296. $inSum += $value ['accountPrice'];
  11297. $showInSum += $value ['accountPriceShow'];
  11298. $inComeA = $value ['accountPrice'];
  11299. break;
  11300. }
  11301. }
  11302. if ($falg)
  11303. $inComeHtml .= '<td class="taR">-</td>';
  11304. $payFalg = true;
  11305. foreach ( $pay as $key => $value ) {
  11306. if ($value ['month'] == $i) {
  11307. $payFalg = false;
  11308. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11309. $paySum += $value ['accountPrice'];
  11310. $showPaySum += $value ['accountPriceShow'];
  11311. $payB = $value ['accountPrice'];
  11312. break;
  11313. }
  11314. }
  11315. if ($payFalg)
  11316. $payHtml .= '<td class="taR">-</td>';
  11317. if (empty ( $balanceC ) || $limitMonth < $i)
  11318. $lastBalanceHtml .= '<td class="taR">-</td>';
  11319. else
  11320. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11321. $balanceC = $balanceC + $inComeA + $payB;
  11322. $balanceSum += $balanceC;
  11323. if (empty ( $balanceC ) || $limitMonth < $i)
  11324. $BalanceHtml .= '<td class="taR">-</td>';
  11325. else
  11326. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11327. // 余额统计
  11328. }
  11329. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11330. $data ['inComeHtml'] = $inComeHtml;
  11331. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11332. $data ['payBalanceHtml'] = $payHtml;
  11333. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11334. $data ['BalanceHtml'] = $BalanceHtml;
  11335. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11336. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11337. $mothHtml = "";
  11338. for($i = 1; $i <= 12; $i ++) {
  11339. if ($moth == $i)
  11340. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11341. else
  11342. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11343. }
  11344. $data ['mothHtml'] = $mothHtml;
  11345. $dateHtml = "";
  11346. $now = date ( "Y" );
  11347. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11348. if ($YEARD <= $now) {
  11349. $dateHtml .= '<option ';
  11350. if ($year == $YEARD) {
  11351. $dateHtml .= 'selected ';
  11352. }
  11353. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11354. }
  11355. }
  11356. $data ['dateHtml'] = $dateHtml;
  11357. $data ['year'] = $year;
  11358. $data ['memu'] = "receipt";
  11359. $data ['staff'] = $this->staff;
  11360. $data ['receiptMemu'] = 'paymentsCollect';
  11361. $data ['verifyId'] = $this->verifyId;
  11362. $data ['executeId'] = $this->executeId;
  11363. $this->render ( "/expenses/paymentsCollect", $data );
  11364. }
  11365. function paymentsCollectDay() {
  11366. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11367. $moth = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : '';
  11368. if (empty ( $moth ))
  11369. return 'paymentsCollect';
  11370. Doo::loadModel ( "accountBookStatistics" );
  11371. $accountBookStatistics = new accountBookStatistics ();
  11372. $i = 2;
  11373. $y = 2013;
  11374. $day = date ( "t", strtotime ( "$year-$moth" ) );
  11375. Doo::loadClass ( 'receipt.func' );
  11376. $statisticsIncome = $accountBookStatistics->getStatisticsByCollectDay ( $year, 1, $moth );
  11377. $html = _getPaymentsCollectByDayHtml ( $statisticsIncome, $day );
  11378. $data ['html'] = $html ['html'];
  11379. $data ['inSum'] = $html ['sum'];
  11380. $statisticsPay = $accountBookStatistics->getStatisticsByCollectDay ( $year, 2, $moth );
  11381. $html = _getPaymentsCollectPayByDayHtml ( $statisticsPay, $day );
  11382. $data ['payHtml'] = $html ['html'];
  11383. $data ['paySum'] = $html ['sum'];
  11384. $mothHtml = "";
  11385. for($i = 1; $i <= 12; $i ++) {
  11386. if ($moth == $i)
  11387. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11388. else
  11389. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11390. }
  11391. $data ['mothHtml'] = $mothHtml;
  11392. $data ['year'] = $year;
  11393. // 余额
  11394. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1, $moth );
  11395. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2, $moth );
  11396. include './protected/config/wasteBook.conf.php';
  11397. Doo::loadModel ( 'wasteBook' );
  11398. $wasteBook = new wasteBook ();
  11399. $inComePay = $wasteBook->getStatisticsByDay ( 1, $year, $moth );
  11400. $pay = $wasteBook->getStatisticsByDay ( 2, $year, $moth );
  11401. // 获得年份之前所有金额
  11402. $detail = $wasteBook->getWasteBookByStatisticsDay ( $year, $moth );
  11403. $lastBalanceHtml = '<tr><th colspan="2">截至上日余额</th>';
  11404. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11405. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11406. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11407. $dayHtml = '<tr><th class="taC" colspan="2">余额</th>';
  11408. $inSum = $paySum = $showPaySum = $showInSum = $balanceSum = 0;
  11409. // $balanceC = 0;
  11410. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11411. $limitDay = date ( 'd' );
  11412. $monthLK = ( int ) date ( 'm' );
  11413. if (date ( 'Y' ) > $year) {
  11414. $limitDay = cal_days_in_month ( CAL_GREGORIAN, date ( 'm' ), date ( 'Y' ) );
  11415. } elseif (date ( 'Y' ) <= $year && $monthLK < $moth) {
  11416. $limitDay = 0;
  11417. }
  11418. for($i = 1; $i <= $day; $i ++) {
  11419. $dayHtml .= '<td class="taC">' . $i . '日</td>';
  11420. $inComeA = $payB = 0;
  11421. $falg = true;
  11422. foreach ( $inComePay as $key => $value ) {
  11423. if ($value ['day'] == $i) {
  11424. $falg = false;
  11425. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11426. $inSum += $value ['accountPrice'];
  11427. $showInSum += $value ['accountPriceShow'];
  11428. $inComeA = $value ['accountPrice'];
  11429. break;
  11430. }
  11431. }
  11432. if ($falg)
  11433. $inComeHtml .= '<td class="taR">-</td>';
  11434. $payFalg = true;
  11435. foreach ( $pay as $key => $value ) {
  11436. if ($value ['day'] == $i) {
  11437. $payFalg = false;
  11438. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11439. $paySum += $value ['accountPrice'];
  11440. $showPaySum += $value ['accountPriceShow'];
  11441. $payB = $value ['accountPrice'];
  11442. break;
  11443. }
  11444. }
  11445. if ($payFalg)
  11446. $payHtml .= '<td class="taR">-</td>';
  11447. if (empty ( $balanceC ) || $limitDay < $i)
  11448. $lastBalanceHtml .= '<td class="taR">-</td>';
  11449. else
  11450. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11451. $balanceC = $balanceC + $inComeA + $payB;
  11452. $balanceSum += $balanceC;
  11453. if (empty ( $balanceC ) || $limitDay < $i)
  11454. $BalanceHtml .= '<td class="taR">-</td>';
  11455. else
  11456. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11457. }
  11458. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11459. $data ['inComeHtml'] = $inComeHtml;
  11460. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11461. $data ['payBalanceHtml'] = $payHtml;
  11462. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11463. $data ['BalanceHtml'] = $BalanceHtml;
  11464. $dayHtml .= '<td class="taR ">总计</td></tr>';
  11465. $data ['dayHtml'] = $dayHtml;
  11466. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11467. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11468. $dateHtml = "";
  11469. $now = date ( "Y" );
  11470. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11471. if ($YEARD <= $now) {
  11472. $dateHtml .= '<option ';
  11473. if ($year == $YEARD) {
  11474. $dateHtml .= 'selected ';
  11475. }
  11476. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11477. }
  11478. }
  11479. $data ['dateHtml'] = $dateHtml;
  11480. $data ['memu'] = "receipt";
  11481. $data ['staff'] = $this->staff;
  11482. $data ['receiptMemu'] = 'paymentsCollect';
  11483. $data ['verifyId'] = $this->verifyId;
  11484. $data ['executeId'] = $this->executeId;
  11485. $this->render ( "/expenses/paymentsCollectDay", $data );
  11486. }
  11487. // 公司流水
  11488. function wasteBook() {
  11489. Doo::loadModel ( "execute" );
  11490. $execute = new execute ();
  11491. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11492. die ( 'illegal request' );
  11493. }
  11494. include './protected/config/wasteBook.conf.php';
  11495. Doo::loadModel ( 'wasteBook' );
  11496. $wasteBook = new wasteBook ();
  11497. $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  11498. $waste = $this->getWasteBookStatistics ( $waste, $inComeStatistics );
  11499. $total = $waste ['bank'] ['CGBDeposit'] + $waste ['bank'] ['ICBCDeposit'] + $waste ['bank'] ['HUADeposit'] + $waste ['bank'] ['PersonalDeposit'] + $waste ['financial'] ['current'] ['CGBDeposit'] + $waste ['financial'] ['current'] ['ICBCDeposit'] + $waste ['financial'] ['fixed'] ['CGBDeposit'] + $waste ['financial'] ['fixed'] ['ICBCDeposit'];
  11500. // print_r($waste);
  11501. $data ['waste'] = $waste;
  11502. $data ['total'] = $total;
  11503. // 月流水数据结构
  11504. $monthStatistics = array ();
  11505. $incomeMothStatistics = array ();
  11506. $expenditureMothStatistics = array ();
  11507. for($i = 1; $i <= 12; $i ++) {
  11508. $month = date ( 'Y' ) . '-' . $i;
  11509. if ($i < 10)
  11510. $month = date ( 'Y' ) . '-0' . $i;
  11511. array_push ( $monthStatistics, $month );
  11512. }
  11513. foreach ( $monthStatistics as $value ) {
  11514. $falg = true;
  11515. foreach ( $inComeStatistics ['incomeReport'] as $k => $v ) {
  11516. if ($value == $v ['inputDate']) {
  11517. array_push ( $incomeMothStatistics, $v ['accountPrice'] );
  11518. $falg = false;
  11519. }
  11520. }
  11521. if ($falg) {
  11522. array_push ( $incomeMothStatistics, '' );
  11523. }
  11524. $falgEx = true;
  11525. foreach ( $inComeStatistics ['expenditureReport'] as $k => $v ) {
  11526. if ($value == $v ['inputDate']) {
  11527. array_push ( $expenditureMothStatistics, $v ['accountPrice'] );
  11528. $falg = false;
  11529. }
  11530. }
  11531. if ($falgEx) {
  11532. array_push ( $expenditureMothStatistics, '' );
  11533. }
  11534. }
  11535. $data ['monthStatistics'] = json_encode ( $monthStatistics );
  11536. $data ['incomeMothStatistics'] = json_encode ( $incomeMothStatistics );
  11537. $data ['expenditureMothStatistics'] = json_encode ( $expenditureMothStatistics );
  11538. $expenditureList = $wasteBook->getAccountBookByExpensesType ( 4, 2 );
  11539. $incomeList = $wasteBook->getAccountBookByExpensesType ( 4, 1 );
  11540. // print_r($incomeList);
  11541. $data ['expenditureList'] = $expenditureList;
  11542. $data ['incomeList'] = $incomeList;
  11543. $data ['memu'] = "receipt";
  11544. $data ['staff'] = $this->staff;
  11545. $data ['receiptMemu'] = 'wasteBook';
  11546. $data ['verifyId'] = $this->verifyId;
  11547. $data ['executeId'] = $this->executeId;
  11548. $this->render ( "/expenses/wasteBook", $data );
  11549. }
  11550. function wasteBookIncome() {
  11551. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11552. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11553. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  11554. $dailyIncomeType = $this->get_args ( 'dailyIncomeType' ) ? $this->get_args ( 'dailyIncomeType' ) : "ALL";
  11555. $data ['dailyIncomeType'] = $dailyIncomeType;
  11556. Doo::loadModel ( 'wasteBook' );
  11557. $wasteBook = new wasteBook ();
  11558. Doo::loadModel ( 'L_category' );
  11559. $L_category = new L_category ();
  11560. Doo::loadClass ( 'XDeode' );
  11561. $XDeode = new XDeode ( 5 );
  11562. // echo $XDeode->encode(1).'<br>';
  11563. // echo $XDeode->encode(2).'<br>';
  11564. // echo $XDeode->encode(3).'<br>';
  11565. // echo $XDeode->encode(4).'<br>';
  11566. // echo $XDeode->encode(5).'<br>';
  11567. // echo $XDeode->encode(6).'<br>';
  11568. // echo $XDeode->encode(7).'<br>';
  11569. // echo $XDeode->encode(8).'<br>';
  11570. // echo $XDeode->encode(9).'<br>';
  11571. // echo $XDeode->encode(10).'<br>';
  11572. $year=date("Y");
  11573. $theDay=date("Y-m-d");
  11574. $dateArr = explode ( ':', $date );
  11575. $D1 = '';
  11576. $D2 = '';
  11577. $con = '';
  11578. if (! empty ( $date )) {
  11579. $D1 = $dateArr [0];
  11580. $D2 = $dateArr [1];
  11581. }
  11582. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11583. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11584. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11585. $con = ' and inputDate = "' . $D1 . '"';
  11586. else{
  11587. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  11588. }
  11589. if ($cid != 'ALL') {
  11590. $cid = $XDeode->decode ( $cid );
  11591. $con .= ' and cid = "' . $cid . '"';
  11592. }
  11593. if ($accountType != 'ALL') {
  11594. if ($accountType == 'INVOICE') {
  11595. $con .= ' and (accountType = 7 or accountType = 8)';
  11596. } elseif ($accountType == 'PAYMENTS') {
  11597. $con .= ' and (accountType = 6 or accountType = 9 or accountType = 10)';
  11598. if ($dailyIncomeType != 'ALL') {
  11599. $dailyIncomeType = $XDeode->decode ( $dailyIncomeType );
  11600. $con .= ' and dailyIncomeType = ' . $dailyIncomeType;
  11601. }
  11602. }
  11603. }
  11604. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 1, $con );
  11605. $sum = 0;$thsDaySum=0;
  11606. foreach ( $incomeList as $key => $value ) {
  11607. $sum += $value ['accountPrice'];
  11608. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  11609. $thsDaySum+=$value ['accountPrice'];
  11610. }
  11611. }
  11612. // print_r($incomeList);
  11613. // 获得办事和部门
  11614. $categoryList = $L_category->getCategory ();
  11615. $data ['accountType'] = $accountType;
  11616. $data ['cid'] = $cid;
  11617. $data ['categoryList'] = $categoryList;
  11618. $data ['sum'] = $sum;
  11619. $data ['incomeList'] = $incomeList;
  11620. $data ['inputDate'] = $date;
  11621. $data['year']=$year;
  11622. $data ['thsDay'] =$theDay;
  11623. $data ['thsDaySum'] =$thsDaySum;
  11624. $data ['memu'] = "receipt";
  11625. $data ['staff'] = $this->staff;
  11626. $data ['receiptMemu'] = 'wasteBook';
  11627. $data ['verifyId'] = $this->verifyId;
  11628. $data ['executeId'] = $this->executeId;
  11629. $this->render ( "/expenses/wasteBookIncome", $data );
  11630. }
  11631. /**
  11632. * 所有支出
  11633. */
  11634. function wasteBookExpenditure() {
  11635. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11636. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11637. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  11638. $dailyExpenditureType = $this->get_args ( 'dailyExpenditureType' ) ? $this->get_args ( 'dailyExpenditureType' ) : "ALL";
  11639. $data ['dailyExpenditureType'] = $dailyExpenditureType;
  11640. $receiptType = $this->get_args ( 'receiptType' ) ? $this->get_args ( 'receiptType' ) : "ALL";
  11641. $data ['receiptType'] = $receiptType;
  11642. Doo::loadModel ( 'wasteBook' );
  11643. $wasteBook = new wasteBook ();
  11644. Doo::loadModel ( 'L_category' );
  11645. $L_category = new L_category ();
  11646. Doo::loadClass ( 'XDeode' );
  11647. $XDeode = new XDeode ( 5 );
  11648. $year=date("Y");
  11649. $theDay=date("Y-m-d");
  11650. $dateArr = explode ( ':', $date );
  11651. $D1 = '';
  11652. $D2 = '';
  11653. $con = '';
  11654. if (! empty ( $date )) {
  11655. $D1 = $dateArr [0];
  11656. $D2 = $dateArr [1];
  11657. }
  11658. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11659. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11660. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11661. $con = ' and inputDate = "' . $D1 . '"';
  11662. else{
  11663. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  11664. }
  11665. if ($cid != 'ALL') {
  11666. $cid = $XDeode->decode ( $cid );
  11667. $con .= ' and cid = "' . $cid . '"';
  11668. }
  11669. if ($accountType != 'ALL') {
  11670. if ($accountType == 'INVOICE') {
  11671. $con .= ' and accountType = 11';
  11672. } elseif ($accountType == 'PAYMENTS') {
  11673. $con .= ' and (accountType = 5 or accountType = 9 or accountType = 10)';
  11674. if ($dailyExpenditureType != 'ALL') {
  11675. $dailyExpenditureType = $XDeode->decode ( $dailyExpenditureType );
  11676. $con .= ' and dailyExpenditureType = ' . $dailyExpenditureType;
  11677. }
  11678. } elseif ($accountType == 'RECEIPT') {
  11679. if ($receiptType == 'ALL') {
  11680. $con .= ' and (accountType = 1 or accountType = 2 or accountType = 3 or accountType = 4)';
  11681. } else {
  11682. $receiptType = $XDeode->decode ( $receiptType );
  11683. echo $receiptType;
  11684. if ($receiptType == 1) {
  11685. $con .= ' and (accountType = 1 or accountType=2)';
  11686. } else {
  11687. $con .= ' and accountType = ' . $receiptType;
  11688. }
  11689. }
  11690. }
  11691. }
  11692. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 2, $con );
  11693. $sum = 0;$thsDaySum=0;
  11694. foreach ( $incomeList as $key => $value ) {
  11695. $sum += $value ['accountPriceShow'];
  11696. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  11697. $thsDaySum+=$value ['accountPriceShow'];
  11698. }
  11699. }
  11700. // print_r($incomeList);
  11701. // 获得办事和部门
  11702. $categoryList = $L_category->getCategory ();
  11703. $data ['accountType'] = $accountType;
  11704. $data ['cid'] = $cid;
  11705. $data ['categoryList'] = $categoryList;
  11706. $data ['sum'] = $sum;
  11707. $data ['incomeList'] = $incomeList;
  11708. $data ['inputDate'] = $date;
  11709. $data['year']=$year;
  11710. $data ['thsDay'] =$theDay;
  11711. $data ['thsDaySum'] =$thsDaySum;
  11712. $data ['memu'] = "receipt";
  11713. $data ['staff'] = $this->staff;
  11714. $data ['receiptMemu'] = 'wasteBook';
  11715. $data ['verifyId'] = $this->verifyId;
  11716. $data ['executeId'] = $this->executeId;
  11717. $this->render ( "/expenses/wasteBookExpenditure", $data );
  11718. }
  11719. function ajaxGetWasteinvoiceReceivables() {
  11720. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11721. Doo::loadClass ( 'XDeode' );
  11722. $XDeode = new XDeode ( 5 );
  11723. $irid = $XDeode->decode ( $serial );
  11724. Doo::loadModel ( 'invoiceReceivables' );
  11725. $invoiceReceivables = new invoiceReceivables ();
  11726. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  11727. echo json_encode ( array (
  11728. 'status' => 1,
  11729. 'detail' => $detail
  11730. ) );
  11731. }
  11732. function ajaxGetPaymentsByAid() {
  11733. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11734. Doo::loadModel ( "accountBook" );
  11735. $accountBook = new accountBook ();
  11736. $detail = $accountBook->getAccountBookByAid ( $serial );
  11737. echo json_encode ( array (
  11738. 'status' => 1,
  11739. 'detail' => $detail
  11740. ) );
  11741. }
  11742. function ajaxGetWasteInvoice() {
  11743. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11744. Doo::loadModel ( 'invoice' );
  11745. $invoice = new invoice ();
  11746. Doo::loadModel ( 'invoiceReceivables' );
  11747. $invoiceReceivables = new invoiceReceivables ();
  11748. $detail = $invoice->getInvoiceByIid ( $serial );
  11749. $detailReceivables = $invoiceReceivables->getInvoiceReceivablesByIrid ( $detail ['irid'] );
  11750. $detail ['receivablesBank'] = $detailReceivables ['receivablesBank'];
  11751. echo json_encode ( array (
  11752. 'status' => 1,
  11753. 'detail' => $detail
  11754. ) );
  11755. }
  11756. /**
  11757. */
  11758. function ajaxGetWasteReceipt() {
  11759. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11760. $accountTypeKey = $this->get_args ( 'accountTypeKey' ) ? $this->get_args ( 'accountTypeKey' ) : "";
  11761. Doo::loadModel ( 'receipt' );
  11762. $receipt = new receipt ();
  11763. Doo::loadClass ( 'XDeode' );
  11764. $XDeode = new XDeode ( 5 );
  11765. $rid = $XDeode->decode ( $serial );
  11766. $accountType= $XDeode->decode ( $accountTypeKey );
  11767. // 获得个数据
  11768. $detail = $receipt->getReceiptByRid ( $rid );
  11769. // 初始化
  11770. $detail ['reviseDetail'] = array ();
  11771. if (! empty ( $value ['reviseDetail'] ))
  11772. $detail ['reviseDetail'] = json_decode ( $detail ['reviseDetail'], true );
  11773. $detail ['accountItem'] = json_decode ( $detail ['accountItem'], true );
  11774. $detail ['loanItem'] = json_decode ( $detail ['loanItem'], true );
  11775. $detail ['loanSumCN'] = $this->num_to_rmb ( $detail ['loanSum'] );
  11776. $detail ['sumCN'] = $this->num_to_rmb ( $detail ['sum'] );
  11777. // 获得费用html
  11778. $html = $this->getWasteReceiptHtml ( $detail ,$accountType);
  11779. // 获得费用审批人数据
  11780. $detail = $this->getReceiptApproverHtml ( $detail );
  11781. // 审批执行
  11782. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  11783. <th class="taC" width="90">审批人</th>
  11784. <th class="taC">审批意见</th></tr>';
  11785. foreach ( $detail ['verifyList'] as $key => $value ) {
  11786. $html .= '<tr>
  11787. <td>' . $value [1] . '</td>
  11788. <td>' . $value ['opinion'] . '</td>
  11789. </tr>
  11790. ';
  11791. }
  11792. $html .= ' </tbody></table>';
  11793. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  11794. <th class="taC" width="90">执行人</th>
  11795. <th class="taC">执行意见</th></tr>';
  11796. foreach ( $detail ['executeCopy'] as $key => $value ) {
  11797. $html .= '<tr>
  11798. <td>' . $value [1] . '</td>
  11799. <td>' . $value ['opinion'] . '</td>
  11800. </tr>
  11801. ';
  11802. }
  11803. $html .= ' </tbody></table>';
  11804. if($accountType==1){
  11805. Doo::loadModel ( 'loanReceipt' );
  11806. $loanReceipt = new loanReceipt ();
  11807. $loanList = $loanReceipt->getOne ( array (
  11808. 'where' => 'rid=' . $detail ['loanRid'],
  11809. 'desc' => 'rid',
  11810. 'asArray' => true
  11811. ) );
  11812. $html .= '<table class="table table-bordered table-condensed">
  11813. <tr class="warning">
  11814. <td class="taR"><b>汇款金额</b></td>
  11815. <td width="140" class="taR"><b style="font-size: 24px">¥'.$loanList['amount'].'</b></td>
  11816. </tr>
  11817. </table>';
  11818. }else{
  11819. $html .= '<table class="table table-bordered table-condensed">
  11820. <tr class="warning">
  11821. <td class="taR"><b>汇款金额</b></td>
  11822. <td width="140" class="taR"><b style="font-size: 24px">¥' . $detail ['amount'] . '</b></td>
  11823. </tr>
  11824. </table>';
  11825. }
  11826. // print_r($detail['verifyList']);
  11827. // header ( 'Content-Type:text/html;charset=utf-8' );
  11828. // echo $html;
  11829. echo json_encode ( array (
  11830. 'status' => 1,
  11831. 'html' => $html,
  11832. 'detail' => $detail
  11833. ) );
  11834. }
  11835. function getReceiptApproverHtml($detail = array()) {
  11836. Doo::loadModel ( 'loanReceipt' );
  11837. $loanReceipt = new loanReceipt ();
  11838. Doo::loadModel ( 'verify' );
  11839. $verify = new verify ();
  11840. Doo::loadModel ( 'staff' );
  11841. $staff = new staff ();
  11842. if (empty ( $detail ))
  11843. return array ();
  11844. $loanList = $loanReceipt->getOne ( array (
  11845. 'where' => 'rid=' . $detail ['loanRid'],
  11846. 'desc' => 'rid',
  11847. 'asArray' => true
  11848. ) );
  11849. if ($detail ['status'] == 3 || $detail ['status'] == 1 || $detail ['status'] == 8 || $detail ['status'] == 9) {
  11850. if ($detail ['status'] == 8 && $detail ['Rtype'] == 1)
  11851. $verifyList ['staff'] = $loanList ['verifyBreakup'];
  11852. else
  11853. $verifyList ['staff'] = $detail ['verifyBreakup'];
  11854. } else
  11855. $verifyList = $verify->getOne ( array (
  11856. 'where' => 'vid=' . $detail ['verify'],
  11857. 'asArray' => true
  11858. ) );
  11859. $verifyList = json_decode ( $verifyList ['staff'], true );
  11860. Doo::loadModel ( 'role' );
  11861. $role = new role ();
  11862. $roleId = 0;
  11863. $flag = true;
  11864. $roleKey = 0;
  11865. $endStaffArray = array ();
  11866. $roleArrayCopy = array ();
  11867. foreach ( $verifyList as $k => $v ) {
  11868. // init verifyStaff
  11869. if ($v [1] == 'ROLE') {
  11870. if (! empty ( $verifyStaff )) {
  11871. $endStaffArray = end ( $verifyStaff );
  11872. }
  11873. $roleVerify = json_decode ( $v [3], true );
  11874. $roleKey = $k;
  11875. $roleArray = array ();
  11876. $rolename = $role->getOne ( array (
  11877. 'where' => 'rid=' . $v [0],
  11878. 'asArray' => true
  11879. ) );
  11880. foreach ( $roleVerify as $o => $p ) {
  11881. $staffID = explode ( '_', $p );
  11882. $staffInfo = $staff->getOne ( array (
  11883. 'where' => 'sid=' . $staffID [0],
  11884. 'asArray' => true
  11885. ) );
  11886. // print_r($staffID);
  11887. $exp = array (
  11888. 0 => $staffInfo ['sid'],
  11889. 1 => $staffID [1],
  11890. 2 => $staffInfo ['avatar'],
  11891. 'date' => '',
  11892. 'date' => '',
  11893. 'opinion' => '',
  11894. 'status' => '',
  11895. 'rolename' => $rolename ['name']
  11896. );
  11897. array_push ( $roleArray, $exp );
  11898. }
  11899. $roleArrayCopy [$v [0]] = $roleArray;
  11900. // $verifyList[$k]['roleArray']=$roleArray;
  11901. }
  11902. $verifyList [$k] ['date'] = "";
  11903. $verifyList [$k] ['opinion'] = "";
  11904. $verifyList [$k] ['status'] = "";
  11905. if (empty ( $verifyStaff )) {
  11906. $verifyList [$k] ['date'] = "";
  11907. $verifyList [$k] ['opinion'] = "";
  11908. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  11909. $verifyList [$k] ['status'] = 4;
  11910. $flag = false;
  11911. }
  11912. } else {
  11913. foreach ( $verifyStaff as $m => $u ) {
  11914. if ($v [0] == $m) {
  11915. $verifyList [$k] ['date'] = $u ['date'];
  11916. $verifyList [$k] ['opinion'] = $u ['opinion'];
  11917. $verifyList [$k] ['status'] = $u ['status'];
  11918. $flag = false;
  11919. break;
  11920. }
  11921. }
  11922. $endStaffArray = end ( $verifyStaff );
  11923. }
  11924. }
  11925. $rolename ['name'] = '';
  11926. if (! empty ( $roleId )) {
  11927. Doo::loadModel ( 'role' );
  11928. $role = new role ();
  11929. $rolename = $role->getOne ( array (
  11930. 'where' => 'rid=' . $roleId,
  11931. 'asArray' => true
  11932. ) );
  11933. }
  11934. if (! empty ( $verifyStaff ))
  11935. $endStaffArray = end ( $verifyStaff );
  11936. $KOP = false;
  11937. foreach ( $roleArrayCopy as $P => $A ) {
  11938. foreach ( $A as $MKI => $AVL ) {
  11939. if (! empty ( $verifyStaff )) {
  11940. // &&$rolename['rid']==$endStaffArray['nextStaff']
  11941. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  11942. $button = 4;
  11943. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  11944. }
  11945. foreach ( $verifyStaff as $m => $u ) {
  11946. $AVLFK = $AVL [0] . '_R';
  11947. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  11948. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  11949. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  11950. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  11951. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  11952. break;
  11953. }
  11954. }
  11955. } else {
  11956. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  11957. $button = 4;
  11958. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  11959. }
  11960. }
  11961. // $roleArray[$MKI]['rolename']=$rolename['name'];
  11962. $KOP = true;
  11963. }
  11964. }
  11965. foreach ( $roleArrayCopy as $k => $v ) {
  11966. foreach ( $verifyList as $m => $n ) {
  11967. if ($n [0] == $k) {
  11968. array_splice ( $verifyList, $m, 1, $v );
  11969. }
  11970. }
  11971. }
  11972. // 费用执行人相关数据
  11973. $executeCopy = json_decode ( $detail ['executeCopy'], true );
  11974. $executeStaff = json_decode ( $detail ['executeStaff'], true );
  11975. foreach ( $executeCopy as $k => $v ) {
  11976. $executeCopy [$k] ['date'] = '';
  11977. $executeCopy [$k] ['opinion'] = '';
  11978. $executeCopy [$k] ['status'] = '';
  11979. if (! empty ( $executeStaff ))
  11980. foreach ( $executeStaff as $m => $u ) {
  11981. if ($v [0] == $m) {
  11982. $executeCopy [$k] ['date'] = $u ['date'];
  11983. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  11984. $executeCopy [$k] ['status'] = $u ['status'];
  11985. break;
  11986. }
  11987. }
  11988. }
  11989. $detail ['executeCopy'] = $executeCopy;
  11990. $detail ['verifyList'] = $verifyList;
  11991. return $detail;
  11992. }
  11993. function getWasteReceiptHtml($detail = array(),$accountType=1) {
  11994. if (empty ( $detail ))
  11995. return '';
  11996. $html = '';
  11997. if ($detail ['Rtype'] == 0) { // 报销单
  11998. $html .= '<table class="table table-bordered table-condensed">
  11999. <tbody>
  12000. <tr>
  12001. <th colspan="2" class="taC">日常相关费用</th>
  12002. </tr>';
  12003. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12004. $html .= '
  12005. <tr>
  12006. <th>' . $value ['name'] . '</th>
  12007. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12008. </tr>';
  12009. }
  12010. $html .= '
  12011. <tr>
  12012. <th class="taR">合计</th>
  12013. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12014. </tr>';
  12015. $html .= '<tr>
  12016. <th colspan="2" class="taC">差旅相关费用</th>
  12017. </tr>';
  12018. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12019. $html .= '
  12020. <tr>
  12021. <th>' . $value ['name'] . '</th>
  12022. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12023. </tr>';
  12024. }
  12025. $html .= '
  12026. <tr>
  12027. <th class="taR">合计</th>
  12028. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12029. </tr>';
  12030. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12031. $html .= '<tr>
  12032. <th colspan="2" class="taC">内部培训费用</th>
  12033. </tr>';
  12034. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12035. $html .= '
  12036. <tr>
  12037. <th>' . $value ['name'] . '</th>
  12038. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12039. </tr>';
  12040. }
  12041. $html .= '
  12042. <tr>
  12043. <th class="taR">合计</th>
  12044. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12045. </tr>';
  12046. }
  12047. $html .= '<tr>
  12048. <th colspan="2" class="taC">其他</th>
  12049. </tr>';
  12050. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12051. $html .= '
  12052. <tr>
  12053. <th>' . $value ['name'] . '</th>
  12054. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12055. </tr>';
  12056. }
  12057. $html .= '
  12058. <tr>
  12059. <th class="taR">合计</th>
  12060. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12061. </tr>';
  12062. $html .= '<tr>
  12063. <th colspan="2" class="taC">报销金额调整</th>
  12064. </tr>';
  12065. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12066. $html .= '
  12067. <tr>
  12068. <th>' . $value ['name'] . '</th>
  12069. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12070. </tr>';
  12071. }
  12072. $html .= '
  12073. <tr>
  12074. <th class="taR">合计</th>
  12075. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12076. </tr>';
  12077. $html .= '
  12078. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12079. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12080. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12081. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12082. <tr class="warning">
  12083. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12084. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12085. </tr>
  12086. </tbody>
  12087. </table>';
  12088. } elseif ($detail ['Rtype'] == 2) {//对公汇款
  12089. $html .= '
  12090. <table class="table table-bordered table-condensed">
  12091. <tbody>
  12092. <tr>
  12093. <th colspan="2" class="taC">办事处相关费用</th>
  12094. </tr>';
  12095. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12096. $html .= '
  12097. <tr>
  12098. <th>' . $value ['name'] . '</th>
  12099. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12100. </tr>';
  12101. }
  12102. $html .= '
  12103. <tr>
  12104. <th class="taR">合计</th>
  12105. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12106. </tr>';
  12107. $html .= '
  12108. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12109. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12110. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12111. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12112. <tr class="warning">
  12113. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12114. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12115. </tr>
  12116. </tbody>
  12117. </table>';
  12118. } elseif ($detail ['Rtype'] == 1) {//借款 或者借款报销
  12119. Doo::loadModel ( 'loanReceipt' );
  12120. $loanReceipt = new loanReceipt ();
  12121. $loanList = $loanReceipt->getOne ( array (
  12122. 'where' => 'rid=' . $detail ['loanRid'],
  12123. 'desc' => 'rid',
  12124. 'asArray' => true
  12125. ) );
  12126. // print_r($loanList);
  12127. $loanList ['sumCN']=$this->num_to_rmb($loanList ['sum']);
  12128. $html .= '<table class="table table-bordered table-condensed">
  12129. <tbody>
  12130. <tr>
  12131. <th colspan="2" class="taC">借款费用</th>
  12132. </tr>';
  12133. foreach ( $detail ['loanItem'] ['借款费用'] as $key => $value ) {
  12134. $html .= '<tr>
  12135. <th>' . $value ['name'] . '</th>
  12136. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12137. </tr>';
  12138. }
  12139. $html .= '<tr>
  12140. <th class="taC" colspan="2">产生费用所在办事处</th>
  12141. </tr>
  12142. <tr>
  12143. <th style="text-align: center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th>
  12144. </tr>
  12145. <tr>
  12146. <th class="taC" colspan="2">费用说明</th>
  12147. </tr>
  12148. <tr>
  12149. <td colspan="2">' . $loanList ['explanation'] . '</td>
  12150. </tr>
  12151. <tr class="warning">
  12152. <td class="taR"><b>(' . $loanList ['receiptOrder'] . ')本次费用合计</b></td>
  12153. <td class="taR"><b style="font-size: 24px">¥' . $loanList ['sum'] . '</b><br>' . $loanList ['sumCN'] . '</td>
  12154. </tr>
  12155. </tbody>
  12156. </table>
  12157. ';
  12158. if ( $accountType==2) {
  12159. $balance=$detail ['sum']-$loanList ['sum'];
  12160. $balanceCN=$this->num_to_rmb($balance);
  12161. $html .= '<table class="table table-bordered table-condensed">
  12162. <tbody>
  12163. <tr>
  12164. <th colspan="2" class="taC">日常相关费用</th>
  12165. </tr>';
  12166. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12167. $html .= '
  12168. <tr>
  12169. <th>' . $value ['name'] . '</th>
  12170. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12171. </tr>';
  12172. }
  12173. $html .= '
  12174. <tr>
  12175. <th class="taR">合计</th>
  12176. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12177. </tr>';
  12178. $html .= '<tr>
  12179. <th colspan="2" class="taC">差旅相关费用</th>
  12180. </tr>';
  12181. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12182. $html .= '
  12183. <tr>
  12184. <th>' . $value ['name'] . '</th>
  12185. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12186. </tr>';
  12187. }
  12188. $html .= '
  12189. <tr>
  12190. <th class="taR">合计</th>
  12191. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12192. </tr>';
  12193. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12194. $html .= '<tr>
  12195. <th colspan="2" class="taC">内部培训费用</th>
  12196. </tr>';
  12197. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12198. $html .= '
  12199. <tr>
  12200. <th>' . $value ['name'] . '</th>
  12201. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12202. </tr>';
  12203. }
  12204. $html .= '
  12205. <tr>
  12206. <th class="taR">合计</th>
  12207. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12208. </tr>';
  12209. }
  12210. $html .= '<tr>
  12211. <th colspan="2" class="taC">其他</th>
  12212. </tr>';
  12213. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12214. $html .= '
  12215. <tr>
  12216. <th>' . $value ['name'] . '</th>
  12217. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12218. </tr>';
  12219. }
  12220. $html .= '
  12221. <tr>
  12222. <th class="taR">合计</th>
  12223. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12224. </tr>';
  12225. $html .= '<tr>
  12226. <th colspan="2" class="taC">报销金额调整</th>
  12227. </tr>';
  12228. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12229. $html .= '
  12230. <tr>
  12231. <th>' . $value ['name'] . '</th>
  12232. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12233. </tr>';
  12234. }
  12235. $html .= '
  12236. <tr>
  12237. <th class="taR">合计</th>
  12238. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12239. </tr>';
  12240. $html .= '
  12241. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12242. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12243. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12244. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12245. <tr class="warning">
  12246. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12247. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12248. </tr>
  12249. <tr class="success">
  12250. <td class="taR"><b>借款结余</b></td>
  12251. <td class="taR"><b style="font-size:24px">¥'.$balance.'</b><br>'.$balanceCN.'</td>
  12252. </tr>
  12253. </tbody>
  12254. </table>';
  12255. }
  12256. }
  12257. return $html;
  12258. }
  12259. /**
  12260. * 计算流水
  12261. */
  12262. function getWasteBookStatistics($waste = array(), $inComeStatistics) {
  12263. $bakWaste ['bank'] = array (
  12264. 'CGBDeposit' => 0,
  12265. 'ICBCDeposit' => 0,
  12266. 'HUADeposit' => 0,
  12267. 'PersonalDeposit' => 0
  12268. );
  12269. $bakWaste ['financial'] = array (
  12270. 'current' => array (
  12271. 'CGBDeposit' => 0,
  12272. 'ICBCDeposit' => 0
  12273. ),
  12274. 'fixed' => array (
  12275. 'CGBDeposit' => 0,
  12276. 'ICBCDeposit' => 0
  12277. )
  12278. );
  12279. // 存款
  12280. foreach ( $waste ['bank'] as $key => $value ) {
  12281. // 收入
  12282. foreach ( $inComeStatistics ['incomeStatistics'] as $k => $v ) {
  12283. // 广发
  12284. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12285. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12286. }
  12287. // 工商
  12288. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12289. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12290. }
  12291. // 华润
  12292. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12293. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12294. }
  12295. // 个人
  12296. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12297. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12298. }
  12299. }
  12300. }
  12301. foreach ( $waste ['bank'] as $key => $value ) {
  12302. // 支出
  12303. foreach ( $inComeStatistics ['expenditureStatistics'] as $k => $v ) {
  12304. // 广发
  12305. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12306. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12307. }
  12308. // 工商
  12309. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12310. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12311. }
  12312. // 华润
  12313. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12314. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12315. }
  12316. // 个人
  12317. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12318. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12319. }
  12320. }
  12321. }
  12322. // 活期
  12323. foreach ( $waste ['financial'] ['current'] as $key => $value ) {
  12324. foreach ( $inComeStatistics ['currentStatistics'] as $k => $v ) {
  12325. // 广发
  12326. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12327. $waste ['financial'] ['current'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  12328. }
  12329. // 工商
  12330. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12331. $waste ['financial'] ['current'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  12332. }
  12333. // 个人
  12334. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12335. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  12336. }
  12337. }
  12338. }
  12339. // print_r($inComeStatistics ['fixedStatistics']);
  12340. // 固期
  12341. foreach ( $waste ['financial'] ['fixed'] as $key => $value ) {
  12342. foreach ( $inComeStatistics ['fixedStatistics'] as $k => $v ) {
  12343. // 广发
  12344. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12345. $waste ['financial'] ['fixed'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  12346. }
  12347. // 工商
  12348. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12349. $waste ['financial'] ['fixed'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  12350. }
  12351. // 个人
  12352. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12353. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  12354. }
  12355. }
  12356. }
  12357. return $waste;
  12358. }
  12359. function lyt() {
  12360. Doo::loadModel ( "receiptDetail" );
  12361. $receiptDetail = new receiptDetail ();
  12362. $receiptCollectList = $receiptDetail->find ( array (
  12363. 'where' => 'status=1 ',
  12364. 'asArray' => true
  12365. ) );
  12366. foreach ( $receiptCollectList as $key => $value ) {
  12367. $receiptDetail = new receiptDetail ();
  12368. $receiptDetail->pastDate = $value ['date'];
  12369. $receiptDetail->update ( array (
  12370. 'where' => "rdid= '" . $value ['rdid'] . "'"
  12371. ) );
  12372. }
  12373. }
  12374. function staffCollectMonthDetail() {
  12375. //include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  12376. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12377. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12378. if (! $year)
  12379. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12380. if (! $month)
  12381. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12382. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  12383. if (! $nature){
  12384. $nature = isset ( $this->params ['nature'] ) ? $this->params ['nature'] : 'ONJOB';
  12385. }
  12386. Doo::loadModel ( 'staff' );
  12387. $staff = new staff ();
  12388. Doo::loadModel ( "receiptDetail" );
  12389. $receiptDetail = new receiptDetail ();
  12390. Doo::loadModel ( 'accountItem' );
  12391. $accountItem = new accountItem ();
  12392. Doo::loadModel ( 'statistics' );
  12393. $statistics = new statistics ();
  12394. Doo::loadModel ( "receiptAuthorityManage" );
  12395. $receiptAuthorityManage = new receiptAuthorityManage ();
  12396. $aiList=$accountItem->getAccountItem();
  12397. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  12398. $cidList = array ();
  12399. foreach ( $imcStaff as $key => $value ) {
  12400. array_push ( $cidList, $value ['cid'] );
  12401. }
  12402. $cidString = implode ( ',', $cidList );
  12403. $naturecon='';
  12404. if ($nature=='ONJOB'){
  12405. $naturecon=' and (nature!=4 )';
  12406. }elseif($nature=='LEAVEJOB'){
  12407. $naturecon=' and (nature=4 )';
  12408. }else{
  12409. die ( 'illegal request--nature' );
  12410. }
  12411. $staffList = $staff->find ( array (
  12412. 'where' => 'username!="admin" and cid in (' . $cidString . ')'.$naturecon,
  12413. 'asArray' => true
  12414. ) );
  12415. $categoryList = $staff->find ( array (
  12416. 'select' => 'COUNT(*) as count,cid,category',
  12417. 'where' => 'username !="admin" and cid in (' . $cidString . ')'.$naturecon,
  12418. 'groupby' => 'cid',
  12419. 'asArray' => true
  12420. ) );
  12421. $list = array ();
  12422. foreach($aiList as $key=>$value){
  12423. foreach ($value as $v){
  12424. $subtotal[$key][$v['name']]=0;
  12425. }
  12426. }
  12427. foreach ( $categoryList as $vlu ) {
  12428. $s1 = 0;
  12429. $m1 = 0;
  12430. $subtotal[$this->AGENCY]['AGENCY']=$subtotal[$this->TRAVEL]['TRAVEL']=$subtotal[$this->INTTRAIN]['INTTRAIN']=$subtotal[$this->TRAIN]['TRAIN']=$subtotal[$this->OTHER]['OTHER']=0;
  12431. foreach ( $staffList as $value ) {
  12432. if ($vlu ['cid'] == $value ['cid']) {
  12433. // pastDate
  12434. $receiptCollectList = $receiptDetail->find ( array (
  12435. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12436. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12437. 'groupby' => 'item,Month(pastDate),itemCategory',
  12438. 'asArray' => true
  12439. ) );
  12440. if (! empty ( $receiptCollectList )) {
  12441. $receiptL = array (
  12442. '日常相关费用' => array (),
  12443. '差旅相关费用' => array (),
  12444. '内部培训费用' => array (),
  12445. '培训班费用' => array (),
  12446. '其他' => array ()
  12447. );
  12448. $html = "";
  12449. $psum = 0;
  12450. foreach ( $aiList[$this->AGENCY] as $va ) {
  12451. $falg = true;
  12452. foreach ( $receiptCollectList as $v ) {
  12453. if ($v ['itemCategory'] == '日常相关费用') {
  12454. if ($v ['item'] == $va['name']) {
  12455. $subtotal[$this->AGENCY][$va['name']]+=$v ['price'];
  12456. $psum += $v ['price'];
  12457. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12458. $falg = false;
  12459. break;
  12460. }
  12461. }
  12462. }
  12463. if ($falg)
  12464. $html .= '<td class="taR">-</td>';
  12465. }
  12466. $subtotal[$this->AGENCY]['AGENCY'] += $psum;
  12467. if (! empty ( $psum ))
  12468. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12469. else
  12470. $psum = '<td class="colGreen taR">-</td>';
  12471. $receiptL ['日常相关费用'] = $psum . $html;
  12472. /* ----------------------------------- */
  12473. $html = "";
  12474. $psum = 0;
  12475. foreach ( $aiList[$this->TRAVEL] as $va ) {
  12476. $falg = true;
  12477. foreach ( $receiptCollectList as $v ) {
  12478. if ($v ['itemCategory'] == '差旅相关费用') {
  12479. if ($v ['item'] == $va['name']) {
  12480. $subtotal[$this->TRAVEL][$va['name']]+=$v ['price'];
  12481. $psum += $v ['price'];
  12482. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12483. $falg = false;
  12484. break;
  12485. }
  12486. }
  12487. }
  12488. if ($falg)
  12489. $html .= '<td class="taR">-</td>';
  12490. }
  12491. $subtotal[$this->TRAVEL]['TRAVEL'] += $psum;
  12492. if (! empty ( $psum ))
  12493. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12494. else
  12495. $psum = '<td class="colGreen taR">-</td>';
  12496. $receiptL ['差旅相关费用'] = $psum . $html;
  12497. /* ------------------------------------- */
  12498. $html = "";
  12499. $psum = 0;
  12500. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  12501. $falg = true;
  12502. foreach ( $receiptCollectList as $v ) {
  12503. if ($v ['itemCategory'] == '内部培训费用') {
  12504. if ($v ['item'] == $va['name']) {
  12505. $subtotal[$this->INTTRAIN][$va['name']]+=$v ['price'];
  12506. $psum += $v ['price'];
  12507. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12508. $falg = false;
  12509. break;
  12510. }
  12511. }
  12512. }
  12513. if ($falg)
  12514. $html .= '<td class="taR">-</td>';
  12515. }
  12516. $subtotal[$this->INTTRAIN]['INTTRAIN'] += $psum;
  12517. if (! empty ( $psum ))
  12518. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12519. else
  12520. $psum = '<td class="colGreen taR">-</td>';
  12521. $receiptL ['内部培训费用'] = $psum . $html;
  12522. /* ----------------------------------- */
  12523. $html = "";
  12524. $psum = 0;
  12525. foreach ( $aiList[$this->TRAIN] as $va ) {
  12526. $falg = true;
  12527. foreach ( $receiptCollectList as $v ) {
  12528. if ($v ['itemCategory'] == '培训班费用') {
  12529. if ($v ['item'] == $va['name']) {
  12530. $subtotal[$this->TRAIN][$va['name']]+=$v ['price'];
  12531. $psum += $v ['price'];
  12532. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12533. $falg = false;
  12534. break;
  12535. }
  12536. }
  12537. }
  12538. if ($falg)
  12539. $html .= '<td class="taR">-</td>';
  12540. }
  12541. $subtotal[$this->TRAIN]['TRAIN'] += $psum;
  12542. if (! empty ( $psum ))
  12543. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12544. else
  12545. $psum = '<td class="colGreen taR">-</td>';
  12546. $receiptL ['培训班费用'] = $psum . $html;
  12547. /* ------------------------------------- */
  12548. $html = "";
  12549. $psum = 0;
  12550. foreach ( $aiList[$this->OTHER] as $va ) {
  12551. $falg = true;
  12552. foreach ( $receiptCollectList as $v ) {
  12553. if ($v ['itemCategory'] == '其他') {
  12554. if (trim ( $v ['item'] ) == $va['name']) {
  12555. $subtotal[$this->OTHER][$va['name']]+=$v ['price'];
  12556. $psum += $v ['price'];
  12557. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12558. $falg = false;
  12559. break;
  12560. }
  12561. }
  12562. }
  12563. if ($falg)
  12564. $html .= '<td class="taR">-</td>';
  12565. }
  12566. $subtotal[$this->OTHER]['OTHER'] += $psum;
  12567. if (! empty ( $psum ))
  12568. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12569. else
  12570. $psum = '<td class="colGreen taR">-</td>';
  12571. $receiptL ['其他'] = $psum . $html;
  12572. /* ------------------------------------- */
  12573. $html = "";
  12574. $psum = 0;
  12575. foreach ( $receiptCollectList as $v ) {
  12576. if ($v ['itemCategory'] == '报销金额调整') {
  12577. if (! empty ( $v ['price'] )) {
  12578. $psum += $v ['price'];
  12579. }
  12580. }
  12581. }
  12582. $s1 += $psum;
  12583. if (! empty ( $psum ))
  12584. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  12585. else
  12586. $psum = '<td class="taR colOrange">-</td>';
  12587. $receiptL ['报销金额调整'] = $psum . $html;
  12588. } else {
  12589. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  12590. foreach ( $aiList[$this->AGENCY] as $va ) {
  12591. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  12592. }
  12593. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  12594. foreach ( $aiList[$this->TRAVEL] as $va ) {
  12595. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  12596. }
  12597. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  12598. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  12599. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  12600. }
  12601. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  12602. foreach ( $aiList[$this->TRAIN] as $va ) {
  12603. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  12604. }
  12605. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  12606. foreach ( $aiList[$this->OTHER] as $va ) {
  12607. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  12608. }
  12609. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  12610. }
  12611. $monthStaffPrice = $receiptDetail->find ( array (
  12612. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12613. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12614. 'groupby' => 'Month(pastDate)',
  12615. 'asArray' => true
  12616. ) );
  12617. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  12618. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  12619. $m1 += $monthStaffPrice [0] ['price'];
  12620. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  12621. } else
  12622. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  12623. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  12624. $list [$value ['username']] = $receiptL;
  12625. }
  12626. }
  12627. $receiptL [$this->AGENCY] ='<td class="colGreen taR">'.$subtotal[$this->AGENCY]['AGENCY'].'</td>';
  12628. foreach ( $aiList[$this->AGENCY] as $va ) {
  12629. $receiptL [$this->AGENCY] .='<td class="taR">' . $subtotal[$this->AGENCY][$va['name']] . '</td>';
  12630. $subtotal[$this->AGENCY][$va['name']]=0;
  12631. }
  12632. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">'.$subtotal[$this->TRAVEL]['TRAVEL'].'</td>';
  12633. foreach ( $aiList[$this->TRAVEL] as $va ) {
  12634. $receiptL [$this->TRAVEL] .='<td class="taR">' . $subtotal[$this->TRAVEL][$va['name']] . '</td>';
  12635. $subtotal[$this->TRAVEL][$va['name']]=0;
  12636. }
  12637. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">'.$subtotal[$this->INTTRAIN]['INTTRAIN'].'</td>';
  12638. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  12639. $receiptL [$this->INTTRAIN] .='<td class="taR">' . $subtotal[$this->INTTRAIN][$va['name']] . '</td>';
  12640. $subtotal[$this->INTTRAIN][$va['name']]=0;
  12641. }
  12642. $receiptL [$this->TRAIN] ='<td class="colGreen taR">'.$subtotal[$this->TRAIN]['TRAIN'].'</td>';
  12643. foreach ( $aiList[$this->TRAIN] as $va ) {
  12644. $receiptL [$this->TRAIN] .='<td class="taR">' . $subtotal[$this->TRAIN][$va['name']] . '</td>';
  12645. $subtotal[$this->TRAIN][$va['name']]=0;
  12646. }
  12647. $receiptL [$this->OTHER] ='<td class="colGreen taR">'.$subtotal[$this->OTHER]['OTHER'].'</td>';
  12648. foreach ( $aiList[$this->OTHER] as $va ) {
  12649. $receiptL [$this->OTHER] .='<td class="taR">' . $subtotal[$this->OTHER][$va['name']] . '</td>';
  12650. $subtotal[$this->OTHER][$va['name']]=0;
  12651. }
  12652. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  12653. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  12654. $receiptL ['usernameEn'] =false;
  12655. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  12656. }
  12657. $data ['list'] = $list;
  12658. // print_r($list);
  12659. $receiptCollectList = $receiptDetail->find ( array (
  12660. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12661. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12662. 'groupby' => 'item,Month(pastDate),itemCategory',
  12663. 'asArray' => true
  12664. ) );
  12665. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  12666. // statistics html
  12667. $stList = $statistics->getOne ( array (
  12668. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  12669. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  12670. 'groupby' => 'Month(date)',
  12671. 'asArray' => true
  12672. ) );
  12673. if (empty ( $stList ))
  12674. $stList = array (
  12675. 'rePrice' => 0,
  12676. 'agPrice' => 0
  12677. );
  12678. $data ['stList'] = array (
  12679. 'rePrice' => $stList ['rePrice'],
  12680. 'agPrice' => $stList ['agPrice'],
  12681. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12682. );
  12683. $monthHtml = "";
  12684. for($i = 1; $i <= 12; $i ++) {
  12685. if ($i == $month)
  12686. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  12687. else
  12688. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  12689. }
  12690. $data ['monthHtml'] = $monthHtml;
  12691. $data ['year'] = $year;
  12692. $data ['month'] = $month;
  12693. $data ['nature'] = $nature;
  12694. $data ['aiList'] = $aiList;
  12695. $data ['memu'] = "receipt";
  12696. $data ['staff'] = $this->staff;
  12697. $data ['receiptMemu'] = 'companyCategoryCollect';
  12698. $data ['verifyId'] = $this->verifyId;
  12699. $data ['executeId'] = $this->executeId;
  12700. $this->render ( "/admin/staffCollectMonthDetail", $data );
  12701. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  12702. }
  12703. function staffCollectMonthDetail2() {
  12704. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12705. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12706. if (! $year)
  12707. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12708. if (! $month)
  12709. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12710. Doo::loadModel ( 'staff' );
  12711. $staff = new staff ();
  12712. Doo::loadModel ( "receiptDetail" );
  12713. $receiptDetail = new receiptDetail ();
  12714. Doo::loadModel ( 'accountItem' );
  12715. $accountItem = new accountItem ();
  12716. Doo::loadModel ( 'statistics' );
  12717. $statistics = new statistics ();
  12718. Doo::loadModel ( 'L_category' );
  12719. $lCategory = new L_category ();
  12720. $staffList = $staff->find ( array (
  12721. 'where' => 'username!="admin"',
  12722. 'asArray' => true
  12723. ) );
  12724. $categoryList = $staff->find ( array (
  12725. 'select' => 'COUNT(*) as count,cid,category',
  12726. 'where' => 'username !="admin"',
  12727. 'groupby' => 'cid',
  12728. 'asArray' => true
  12729. ) );
  12730. $list = array ();
  12731. foreach ( $categoryList as $vlu ) {
  12732. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  12733. $r1 = 0;
  12734. $r2 = 0;
  12735. $r3 = 0;
  12736. $r4 = 0;
  12737. $r5 = 0;
  12738. $r6 = 0;
  12739. $r7 = 0;
  12740. $r8 = 0;
  12741. $r9 = 0;
  12742. $r10 = 0;
  12743. $r11 = 0;
  12744. $r12 = 0;
  12745. $r13 = 0;
  12746. $r14 = 0;
  12747. $r15 = 0;
  12748. $c1 = 0;
  12749. $c2 = 0;
  12750. $c3 = 0;
  12751. $c4 = 0;
  12752. $c5 = 0;
  12753. $c6 = 0;
  12754. $p1 = 0;
  12755. $p2 = 0;
  12756. $p3 = 0;
  12757. $p4 = 0;
  12758. $p5 = 0;
  12759. $p6 = 0;
  12760. $p7 = 0;
  12761. $p8 = 0;
  12762. $p9 = 0;
  12763. $t1 = 0;
  12764. $t2 = 0;
  12765. $t3 = 0;
  12766. $t4 = 0;
  12767. $t5 = 0;
  12768. $s1 = 0;
  12769. $m1 = 0;
  12770. foreach ( $staffList as $value ) {
  12771. if ($vlu ['cid'] == $value ['cid']) {
  12772. $receiptCollectList = $receiptDetail->find ( array (
  12773. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  12774. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  12775. 'groupby' => 'item,Month(date),itemCategory',
  12776. 'asArray' => true
  12777. ) );
  12778. if (! empty ( $receiptCollectList )) {
  12779. $receiptL = array (
  12780. '日常相关费用' => array (),
  12781. '差旅相关费用' => array (),
  12782. '培训班费用' => array (),
  12783. '其他' => array ()
  12784. );
  12785. $html = "";
  12786. $psum = 0;
  12787. $item = array (
  12788. '市内交通费',
  12789. '市内出租费',
  12790. '办事处房租',
  12791. '电话费',
  12792. '水费',
  12793. '电费',
  12794. '办公费用',
  12795. '邮寄费',
  12796. '其他费用',
  12797. '车辆费用',
  12798. '广告费',
  12799. '团队建设费',
  12800. '物业管理费',
  12801. '宽带费'
  12802. );
  12803. foreach ( $item as $va ) {
  12804. $falg = true;
  12805. foreach ( $receiptCollectList as $v ) {
  12806. if ($v ['itemCategory'] == '日常相关费用') {
  12807. if ($v ['item'] == $va) {
  12808. if ($va == '市内交通费')
  12809. $r1 += $v ['price'];
  12810. if ($va == '市内出租费')
  12811. $r2 += $v ['price'];
  12812. if ($va == '办事处房租')
  12813. $r3 += $v ['price'];
  12814. if ($va == '电话费')
  12815. $r4 += $v ['price'];
  12816. if ($va == '水费')
  12817. $r5 += $v ['price'];
  12818. if ($va == '电费')
  12819. $r6 += $v ['price'];
  12820. if ($va == '办公费用')
  12821. $r7 += $v ['price'];
  12822. if ($va == '邮寄费')
  12823. $r8 += $v ['price'];
  12824. if ($va == '其他费用')
  12825. $r9 += $v ['price'];
  12826. if ($va == '车辆费用')
  12827. $r10 += $v ['price'];
  12828. if ($va == '广告费')
  12829. $r11 += $v ['price'];
  12830. if ($va == '团队建设费')
  12831. $r13 += $v ['price'];
  12832. if ($va == '物业管理费')
  12833. $r14 += $v ['price'];
  12834. if ($va == '宽带费')
  12835. $r15 += $v ['price'];
  12836. $psum += $v ['price'];
  12837. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12838. $falg = false;
  12839. break;
  12840. }
  12841. }
  12842. }
  12843. if ($falg)
  12844. $html .= '<td class="taR">-</td>';
  12845. }
  12846. $r12 += $psum;
  12847. if (! empty ( $psum ))
  12848. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12849. else
  12850. $psum = '<td class="colGreen taR">-</td>';
  12851. $receiptL ['日常相关费用'] = $psum . $html;
  12852. /* ----------------------------------- */
  12853. $html = "";
  12854. $psum = 0;
  12855. $item = array (
  12856. '往来交通费',
  12857. '市内交通费',
  12858. '出差住宿费',
  12859. '出差补助',
  12860. '其他费用'
  12861. );
  12862. foreach ( $item as $va ) {
  12863. $falg = true;
  12864. foreach ( $receiptCollectList as $v ) {
  12865. if ($v ['itemCategory'] == '差旅相关费用') {
  12866. if ($v ['item'] == $va) {
  12867. if ($va == '往来交通费')
  12868. $c1 += $v ['price'];
  12869. if ($va == '市内交通费')
  12870. $c2 += $v ['price'];
  12871. if ($va == '出差住宿费')
  12872. $c3 += $v ['price'];
  12873. if ($va == '出差补助')
  12874. $c4 += $v ['price'];
  12875. if ($va == '其他费用')
  12876. $c5 += $v ['price'];
  12877. $psum += $v ['price'];
  12878. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12879. $falg = false;
  12880. break;
  12881. }
  12882. }
  12883. }
  12884. if ($falg)
  12885. $html .= '<td class="taR">-</td>';
  12886. }
  12887. $c6 += $psum;
  12888. if (! empty ( $psum ))
  12889. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12890. else
  12891. $psum = '<td class="colGreen taR">-</td>';
  12892. $receiptL ['差旅相关费用'] = $psum . $html;
  12893. /* ------------------------------------- */
  12894. $html = "";
  12895. $psum = 0;
  12896. $item = array (
  12897. '场租费',
  12898. '薪酬',
  12899. '住宿费',
  12900. '交通费',
  12901. '餐饮费',
  12902. '办公费',
  12903. '公关费',
  12904. '其他'
  12905. );
  12906. foreach ( $item as $va ) {
  12907. $falg = true;
  12908. foreach ( $receiptCollectList as $v ) {
  12909. if ($v ['itemCategory'] == '培训班费用') {
  12910. if ($v ['item'] == $va) {
  12911. if ($va == '场租费')
  12912. $p1 += $v ['price'];
  12913. if ($va == '薪酬')
  12914. $p2 += $v ['price'];
  12915. if ($va == '住宿费')
  12916. $p3 += $v ['price'];
  12917. if ($va == '交通费')
  12918. $p4 += $v ['price'];
  12919. if ($va == '餐饮费')
  12920. $p5 += $v ['price'];
  12921. if ($va == '办公费')
  12922. $p6 += $v ['price'];
  12923. if ($va == '公关费')
  12924. $p7 += $v ['price'];
  12925. if ($va == '其他')
  12926. $p8 += $v ['price'];
  12927. $psum += $v ['price'];
  12928. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12929. $falg = false;
  12930. break;
  12931. }
  12932. }
  12933. }
  12934. if ($falg)
  12935. $html .= '<td class="taR">-</td>';
  12936. }
  12937. $p9 += $psum;
  12938. if (! empty ( $psum ))
  12939. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12940. else
  12941. $psum = '<td class="colGreen taR">-</td>';
  12942. $receiptL ['培训班费用'] = $psum . $html;
  12943. /* ------------------------------------- */
  12944. $html = "";
  12945. $psum = 0;
  12946. $item = array (
  12947. '公关费',
  12948. '广告费',
  12949. '借款',
  12950. '可自加费用'
  12951. );
  12952. foreach ( $item as $va ) {
  12953. $falg = true;
  12954. foreach ( $receiptCollectList as $v ) {
  12955. if ($v ['itemCategory'] == '其他') {
  12956. if ($v ['item'] == $va) {
  12957. if ($va == '公关费')
  12958. $t1 += $v ['price'];
  12959. if ($va == '广告费')
  12960. $t2 += $v ['price'];
  12961. if ($va == '借款')
  12962. $t3 += $v ['price'];
  12963. if ($va == '可自加费用')
  12964. $t4 += $v ['price'];
  12965. $psum += $v ['price'];
  12966. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12967. $falg = false;
  12968. break;
  12969. }
  12970. }
  12971. }
  12972. if ($falg)
  12973. $html .= '<td class="taR">-</td>';
  12974. }
  12975. $t5 += $psum;
  12976. if (! empty ( $psum ))
  12977. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12978. else
  12979. $psum = '<td class="colGreen taR">-</td>';
  12980. $receiptL ['其他'] = $psum . $html;
  12981. /* ------------------------------------- */
  12982. $html = "";
  12983. $psum = 0;
  12984. foreach ( $receiptCollectList as $v ) {
  12985. if ($v ['itemCategory'] == '报销金额调整') {
  12986. if (! empty ( $v ['price'] )) {
  12987. $psum += $v ['price'];
  12988. }
  12989. }
  12990. }
  12991. $s1 += $psum;
  12992. if (! empty ( $psum ))
  12993. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  12994. else
  12995. $psum = '<td class="taR colOrange">-</td>';
  12996. $receiptL ['报销金额调整'] = $psum . $html;
  12997. } else {
  12998. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  12999. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13000. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  13001. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13002. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13003. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13004. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13005. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13006. }
  13007. $monthStaffPrice = $receiptDetail->find ( array (
  13008. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13009. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13010. 'asArray' => true
  13011. ) );
  13012. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  13013. $m1 += $monthStaffPrice [0] ['price'];
  13014. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13015. } else
  13016. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13017. $list [$value ['username']] = $receiptL;
  13018. }
  13019. }
  13020. $receiptL ['日常相关费用'] = '<td class="colGreen taR">' . $r12 . '</td><td class="taR">' . $r1 . '</td><td class="taR">' . $r2 . '</td><td class="taR">' . $r3 . '</td><td class="taR">' . $r4 . '</td><td class="taR">' . $r5 . '</td>
  13021. <td class="taR">' . $r6 . '</td><td class="taR">' . $r7 . '</td><td class="taR">' . $r8 . '</td><td class="taR">' . $r9 . '</td><td class="taR">' . $r10 . '</td><td class="taR">' . $r11 . '</td><td class="taR">' . $r13 . '</td>
  13022. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  13023. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  13024. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  13025. $receiptL ['培训班费用'] = '<td class="colGreen taR">' . $p9 . '</td><td class="taR">' . $p1 . '</td><td class="taR">' . $p2 . '</td><td class="taR">' . $p3 . '</td><td class="taR">' . $p4 . '</td>
  13026. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  13027. $receiptL ['其他'] = '<td class="colGreen taR">' . $t5 . '</td><td class="taR">' . $t1 . '</td><td class="taR">' . $t2 . '</td><td class="taR">' . $t3 . '</td><td class="taR">' . $t4 . '</td>';
  13028. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  13029. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  13030. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  13031. }
  13032. $data ['list'] = $list;
  13033. $receiptCollectList = $receiptDetail->find ( array (
  13034. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13035. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13036. 'groupby' => 'item,Month(date),itemCategory',
  13037. 'asArray' => true
  13038. ) );
  13039. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  13040. // statistics html
  13041. $stList = $statistics->getOne ( array (
  13042. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13043. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13044. 'groupby' => 'Month(date)',
  13045. 'asArray' => true
  13046. ) );
  13047. if (empty ( $stList ))
  13048. $stList = array (
  13049. 'rePrice' => 0,
  13050. 'agPrice' => 0
  13051. );
  13052. $data ['stList'] = array (
  13053. 'rePrice' => $stList ['rePrice'],
  13054. 'agPrice' => $stList ['agPrice'],
  13055. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13056. );
  13057. $monthHtml = "";
  13058. for($i = 1; $i <= 12; $i ++) {
  13059. if ($i == $month)
  13060. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13061. else
  13062. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13063. }
  13064. $data ['monthHtml'] = $monthHtml;
  13065. $data ['year'] = $year;
  13066. $data ['month'] = $month;
  13067. $data ['memu'] = "receipt";
  13068. $data ['staff'] = $this->staff;
  13069. $data ['receiptMemu'] = 'companyCategoryCollect';
  13070. $data ['verifyId'] = $this->verifyId;
  13071. $data ['executeId'] = $this->executeId;
  13072. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  13073. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13074. }
  13075. /**
  13076. * 用户报销单列表
  13077. */
  13078. function receiptStatisticsStaffDetail() {
  13079. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13080. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13081. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13082. Doo::loadModel ( "receipt" );
  13083. $receipt = new receipt ();
  13084. Doo::loadModel ( "receiptDetail" );
  13085. $receiptDetail = new receiptDetail ();
  13086. Doo::loadModel ( 'staff' );
  13087. $staff = new staff ();
  13088. Doo::loadModel ( 'accountItem' );
  13089. $accountItem = new accountItem ();
  13090. Doo::loadModel ( 'statistics' );
  13091. $statistics = new statistics ();
  13092. if (! empty ( $username )) {
  13093. $username = addslashes ( urldecode ( $username ) );
  13094. $staffDetail = $staff->getStaffByName ( $username );
  13095. if (empty ( $staffDetail ))
  13096. die ( 'illegal request' );
  13097. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  13098. $itemList = $accountItem->getAccountItem ();
  13099. $itemHtml = '';
  13100. $categoryHtml = '';
  13101. $itemKeyList = array_keys ( $itemList );
  13102. $revisePrice = 0;
  13103. // 报销单内容详情
  13104. foreach ( $list as $key => $value ) {
  13105. $accountItemList = json_decode ( $value ['accountItem'], true );
  13106. $list [$key] ['accountItemList'] = $accountItemList;
  13107. $receiptItemHtml = '';
  13108. foreach ( $itemKeyList as $v ) {
  13109. if ($v == '日常相关费用')
  13110. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  13111. elseif ($v == '差旅相关费用')
  13112. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  13113. elseif ($v == '培训班费用')
  13114. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  13115. elseif ($v == '内部培训费用'){
  13116. if (isset($accountItemList ['cSum'] ['inttrainSum'])){
  13117. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['inttrainSum'] . '</td>';
  13118. }else{
  13119. $receiptItemHtml .= '<td class="colGreen taR">0</td>';
  13120. }
  13121. }elseif ($v == '其他')
  13122. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  13123. foreach ( $itemList [$v] as $ke => $va ) {
  13124. $falg = true;
  13125. if (! empty ( $accountItemList [$v] )) {
  13126. foreach ( $accountItemList [$v] as $ve ) {
  13127. if ($va ['name'] == $ve ['name']) {
  13128. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  13129. $falg = false;
  13130. break;
  13131. }
  13132. }
  13133. }
  13134. if ($falg)
  13135. $receiptItemHtml .= '<td class="taR"></td>';
  13136. }
  13137. }
  13138. // 金额调整和费用查看
  13139. $revisePrice += $value ['revisePrice'];
  13140. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  13141. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" id="sen'.$key.'" data="' . htmlspecialchars($value ['explanation']) . '" onclick=showExplanation() >查看</a></td>';
  13142. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  13143. }
  13144. // 报销单合计
  13145. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  13146. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  13147. $receiptTotalHtml = '';
  13148. // 报销单项目抬头
  13149. foreach ( $itemKeyList as $value ) {
  13150. $count = count ( $itemList [$value] ) + 1;
  13151. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  13152. $categoryHtml .= '<th class="taC">合计</th>';
  13153. $sumfalg=true;
  13154. foreach ( $rtl as $rtlValue ) {
  13155. if ($rtlValue ['itemCategory'] == $value) {
  13156. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  13157. $sumfalg=false;
  13158. break;
  13159. }
  13160. }
  13161. if ($sumfalg)
  13162. $receiptTotalHtml .= '<th></th>';
  13163. foreach ( $itemList [$value] as $k => $v ) {
  13164. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  13165. // 合计
  13166. $falg = true;
  13167. foreach ( $receiptTotalList as $ve ) {
  13168. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  13169. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  13170. $falg = false;
  13171. break;
  13172. }
  13173. }
  13174. if ($falg)
  13175. $receiptTotalHtml .= '<th></th>';
  13176. }
  13177. }
  13178. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  13179. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  13180. if (empty ( $stList ))
  13181. $stList = array (
  13182. 'rePrice' => 0,
  13183. 'agPrice' => 0
  13184. );
  13185. $data ['stList'] = array (
  13186. 'rePrice' => $stList ['rePrice'],
  13187. 'agPrice' => $stList ['agPrice'],
  13188. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13189. );
  13190. $monthHtml = "";
  13191. for($i = 1; $i <= 12; $i ++) {
  13192. if ($i == $month)
  13193. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13194. else
  13195. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13196. }
  13197. $data ['username'] = urlencode ( $username );
  13198. $data ['usernameEN'] = $username;
  13199. $data ['monthHtml'] = $monthHtml;
  13200. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  13201. $data ['list'] = $list;
  13202. $data ['categoryHtml'] = $categoryHtml;
  13203. $data ['itemHtml'] = $itemHtml;
  13204. $data ['itemList'] = $itemList;
  13205. $data ['year'] = $year;
  13206. $data ['month'] = $month;
  13207. $data ['memu'] = "receipt";
  13208. $data ['staff'] = $this->staff;
  13209. $data ['receiptMemu'] = 'companyCategoryCollect';
  13210. $data ['verifyId'] = $this->verifyId;
  13211. $data ['executeId'] = $this->executeId;
  13212. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  13213. }
  13214. die ( 'illegal request' );
  13215. }
  13216. function companyMonthCollectDetail() {
  13217. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13218. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13219. if (! $year)
  13220. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13221. if (! $month)
  13222. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13223. Doo::loadModel ( 'staff' );
  13224. $staff = new staff ();
  13225. Doo::loadModel ( "receiptDetail" );
  13226. $receiptDetail = new receiptDetail ();
  13227. Doo::loadModel ( 'accountItem' );
  13228. $accountItem = new accountItem ();
  13229. Doo::loadModel ( 'statistics' );
  13230. $statistics = new statistics ();
  13231. Doo::loadModel ( 'L_category' );
  13232. $lCategory = new L_category ();
  13233. $staffList = $staff->find ( array (
  13234. 'where' => 'username!="admin"',
  13235. 'asArray' => true
  13236. ) );
  13237. $categoryList = $lCategory->find ( array (
  13238. 'asArray' => true
  13239. ) );
  13240. $aiList=$accountItem->getAccountItem();
  13241. $list = array ();
  13242. foreach ( $categoryList as $value ) {
  13243. $receiptCollectList = $receiptDetail->find ( array (
  13244. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13245. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13246. 'groupby' => 'item,Month(pastDate),itemCategory',
  13247. 'asArray' => true
  13248. ) );
  13249. if (! empty ( $receiptCollectList )) {
  13250. $receiptL = array (
  13251. '日常相关费用' => array (),
  13252. '差旅相关费用' => array (),
  13253. '内部培训费用' => array (),
  13254. '培训班费用' => array (),
  13255. '其他' => array ()
  13256. );
  13257. $html = "";
  13258. $psum = 0;
  13259. foreach ( $aiList[$this->AGENCY] as $va ) {
  13260. $falg = true;
  13261. foreach ( $receiptCollectList as $v ) {
  13262. if ($v ['itemCategory'] == $this->AGENCY) {
  13263. if ($v ['item'] == $va['name']) {
  13264. $psum += $v ['price'];
  13265. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13266. $falg = false;
  13267. break;
  13268. }
  13269. }
  13270. }
  13271. if ($falg)
  13272. $html .= '<td class="taR">-</td>';
  13273. }
  13274. if (! empty ( $psum ))
  13275. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13276. else
  13277. $psum = '<td class="colGreen taR">-</td>';
  13278. $receiptL [$this->AGENCY] = $psum . $html;
  13279. /* ----------------------------------- */
  13280. $html = "";
  13281. $psum = 0;
  13282. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13283. $falg = true;
  13284. foreach ( $receiptCollectList as $v ) {
  13285. if ($v ['itemCategory'] == $this->TRAVEL) {
  13286. if ($v ['item'] == $va['name']) {
  13287. $psum += $v ['price'];
  13288. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13289. $falg = false;
  13290. break;
  13291. }
  13292. }
  13293. }
  13294. if ($falg)
  13295. $html .= '<td class="taR">-</td>';
  13296. }
  13297. if (! empty ( $psum ))
  13298. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13299. else
  13300. $psum = '<td class="colGreen taR">-</td>';
  13301. $receiptL [$this->TRAVEL] = $psum . $html;
  13302. /* ------------------------------------- */
  13303. $html = "";
  13304. $psum = 0;
  13305. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13306. $falg = true;
  13307. foreach ( $receiptCollectList as $v ) {
  13308. if ($v ['itemCategory'] == $this->INTTRAIN) {
  13309. if ($v ['item'] == $va['name']) {
  13310. $psum += $v ['price'];
  13311. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13312. $falg = false;
  13313. break;
  13314. }
  13315. }
  13316. }
  13317. if ($falg)
  13318. $html .= '<td class="taR">-</td>';
  13319. }
  13320. if (! empty ( $psum ))
  13321. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13322. else
  13323. $psum = '<td class="colGreen taR">-</td>';
  13324. $receiptL [$this->INTTRAIN] = $psum . $html;
  13325. /* ------------------------------------- */
  13326. $html = "";
  13327. $psum = 0;
  13328. foreach ( $aiList[$this->TRAIN] as $va ) {
  13329. $falg = true;
  13330. foreach ( $receiptCollectList as $v ) {
  13331. if ($v ['itemCategory'] == $this->TRAIN) {
  13332. if ($v ['item'] == $va['name']) {
  13333. $psum += $v ['price'];
  13334. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13335. $falg = false;
  13336. break;
  13337. }
  13338. }
  13339. }
  13340. if ($falg)
  13341. $html .= '<td class="taR">-</td>';
  13342. }
  13343. if (! empty ( $psum ))
  13344. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13345. else
  13346. $psum = '<td class="colGreen taR">-</td>';
  13347. $receiptL [$this->TRAIN] = $psum . $html;
  13348. /* ------------------------------------- */
  13349. $html = "";
  13350. $psum = 0;
  13351. foreach ( $aiList[$this->OTHER] as $va ) {
  13352. $falg = true;
  13353. foreach ( $receiptCollectList as $v ) {
  13354. if ($v ['itemCategory'] == $this->OTHER) {
  13355. if ($v ['item'] == $va['name']) {
  13356. $psum += $v ['price'];
  13357. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13358. $falg = false;
  13359. break;
  13360. }
  13361. }
  13362. }
  13363. if ($falg)
  13364. $html .= '<td class="taR">-</td>';
  13365. }
  13366. if (! empty ( $psum ))
  13367. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13368. else
  13369. $psum = '<td class="colGreen taR">-</td>';
  13370. $receiptL [$this->OTHER] = $psum . $html;
  13371. /* ------------------------------------- */
  13372. $html = "";
  13373. $psum = 0;
  13374. foreach ( $receiptCollectList as $v ) {
  13375. if ($v ['itemCategory'] == '报销金额调整') {
  13376. if (! empty ( $v ['price'] ))
  13377. $psum += $v ['price'];
  13378. }
  13379. }
  13380. if (! empty ( $psum ))
  13381. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  13382. else
  13383. $psum = '<td class="taR colOrange">-</td>';
  13384. $receiptL ['报销金额调整'] = $psum . $html;
  13385. } else {
  13386. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  13387. foreach ( $aiList[$this->AGENCY] as $va ) {
  13388. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  13389. }
  13390. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  13391. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13392. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  13393. }
  13394. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  13395. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13396. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  13397. }
  13398. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  13399. foreach ( $aiList[$this->TRAIN] as $va ) {
  13400. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  13401. }
  13402. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  13403. foreach ( $aiList[$this->OTHER] as $va ) {
  13404. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  13405. }
  13406. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13407. }
  13408. $monthStaffPrice = $receiptDetail->find ( array (
  13409. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13410. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13411. 'asArray' => true
  13412. ) );
  13413. if (! empty ( $monthStaffPrice [0] ['price'] ))
  13414. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13415. else
  13416. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13417. $list [$value ['title']] = $receiptL;
  13418. }
  13419. $data ['list'] = $list;
  13420. $receiptCollectList = $receiptDetail->find ( array (
  13421. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13422. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13423. 'groupby' => 'item,Month(pastDate),itemCategory',
  13424. 'asArray' => true
  13425. ) );
  13426. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  13427. //print_r($data['monthPriceHtml']);
  13428. // foreach ($data['monthPriceHtml'] as $value){
  13429. // echo $value;
  13430. // }
  13431. // die;
  13432. // statistics html
  13433. $stList = $statistics->getOne ( array (
  13434. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13435. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13436. 'groupby' => 'Month(date)',
  13437. 'asArray' => true
  13438. ) );
  13439. if (empty ( $stList ))
  13440. $stList = array (
  13441. 'rePrice' => 0,
  13442. 'agPrice' => 0
  13443. );
  13444. $data ['stList'] = array (
  13445. 'rePrice' => $stList ['rePrice'],
  13446. 'agPrice' => $stList ['agPrice'],
  13447. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13448. );
  13449. $monthHtml = "";
  13450. for($i = 1; $i <= 12; $i ++) {
  13451. if ($i == $month)
  13452. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13453. else
  13454. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13455. }
  13456. $data ['aiList'] = $aiList;
  13457. $dateHtml = "";
  13458. $now = date ( "Y" );
  13459. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  13460. if ($YEARD <= $now) {
  13461. $dateHtml .= '<option ';
  13462. if ($year == $YEARD) {
  13463. $dateHtml .= 'selected ';
  13464. }
  13465. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  13466. }
  13467. }
  13468. $data ['dateHtml'] = $dateHtml;
  13469. $data ['monthHtml'] = $monthHtml;
  13470. $data ['year'] = $year;
  13471. $data ['month'] = $month;
  13472. $data ['memu'] = "receipt";
  13473. $data ['staff'] = $this->staff;
  13474. $data ['receiptMemu'] = 'companyCategoryCollect';
  13475. $data ['verifyId'] = $this->verifyId;
  13476. $data ['executeId'] = $this->executeId;
  13477. $this->render ( "/admin/companyMonthCollectDetail", $data );
  13478. }
  13479. function staffCollectDetail() {
  13480. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  13481. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13482. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  13483. if (! $staffname) {
  13484. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  13485. $staffname = urldecode ( $staffname );
  13486. }
  13487. Doo::loadModel ( 'staff' );
  13488. $staff = new staff ();
  13489. Doo::loadModel ( "receiptDetail" );
  13490. $receiptDetail = new receiptDetail ();
  13491. Doo::loadModel ( 'accountItem' );
  13492. $accountItem = new accountItem ();
  13493. Doo::loadModel ( 'statistics' );
  13494. $statistics = new statistics ();
  13495. Doo::loadModel ( 'L_category' );
  13496. $lCategory = new L_category ();
  13497. Doo::loadModel ( "receiptAuthorityManage" );
  13498. $receiptAuthorityManage = new receiptAuthorityManage ();
  13499. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  13500. $cidList = array ();
  13501. foreach ( $imcStaff as $key => $value ) {
  13502. array_push ( $cidList, $value ['cid'] );
  13503. }
  13504. $cidString = implode ( ',', $cidList );
  13505. $staffList = $staff->find ( array (
  13506. 'where' => ' cid in (' . $cidString . ')',
  13507. 'asArray' => true
  13508. ) );
  13509. $stHtml = '';
  13510. $stTitle = "";
  13511. $staffId = 0;
  13512. $cid = 0;
  13513. $ocid = 0;
  13514. foreach ( $staffList as $value ) {
  13515. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  13516. $stTitle = $value ['category'] . '-' . $value ['username'];
  13517. $staffId = $value ['sid'];
  13518. $cid = $value ['cid'];
  13519. $ocid = $value ['cid'];
  13520. if (! empty ( $value ['othercid'] ))
  13521. $cid = $value ['cid'] . ',' . $value ['othercid'];
  13522. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13523. } elseif ($value ['username'] != 'admin')
  13524. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13525. }
  13526. $data ['lCategoryHtml'] = $lCategory->find ( array (
  13527. 'where' => 'cid in(' . $cid . ')',
  13528. 'asArray' => true
  13529. ) );
  13530. if (empty ( $pcid ))
  13531. $pcid = $ocid;
  13532. $data ['ocid'] = $pcid;
  13533. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  13534. $this->showCache ( $path );
  13535. //
  13536. $receiptCollectList = $receiptDetail->find ( array (
  13537. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13538. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  13539. 'groupby' => 'item,Month(pastDate),itemCategory',
  13540. 'asArray' => true
  13541. ) );
  13542. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  13543. // print_r($receiptCollectList);
  13544. $accountList = $accountItem->find ( array (
  13545. 'asArray' => true
  13546. ) );
  13547. // create CollectDetail HTML
  13548. $collectHtml = array ();
  13549. foreach ( $accountList as $key => $value ) {
  13550. $html = "";
  13551. $asum = 0;
  13552. for($i = 1; $i <= 12; $i ++) {
  13553. $falg = true;
  13554. foreach ( $receiptCollectList as $v ) {
  13555. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  13556. if ($v ['item'] == '可自加费用') {
  13557. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  13558. }
  13559. $asum += $v ['price'];
  13560. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13561. $falg = false;
  13562. break;
  13563. }
  13564. }
  13565. if ($falg)
  13566. $html .= '<td class="taR">-</td>';
  13567. }
  13568. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  13569. $collectHtml [$value ['category']] [$value ['name']] = $html;
  13570. }
  13571. $data ['collectHtml'] = $collectHtml;
  13572. // print_r($collectHtml);
  13573. // create Adjustment price html
  13574. $receiptCollectList = $receiptDetail->find ( array (
  13575. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  13576. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  13577. 'groupby' => 'itemCategory,Month(pastDate)',
  13578. 'asArray' => true
  13579. ) );
  13580. $adjustment = array ();
  13581. $collectArray = array (
  13582. '日常相关费用' => array (),
  13583. '差旅相关费用' => array (),
  13584. '培训班费用' => array (),
  13585. '内部培训费用'=>array(),
  13586. '其他' => array ()
  13587. );
  13588. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  13589. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  13590. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  13591. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  13592. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  13593. array_push ( $collectArray ['培训班费用'], $collectHtml );
  13594. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  13595. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  13596. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  13597. array_push ( $collectArray ['其他'], $collectHtml );
  13598. $data ['collectArray'] = $collectArray;
  13599. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  13600. array_push ( $adjustment, $collectHtml );
  13601. $data ['adjustment'] = $adjustment;
  13602. // total price html
  13603. $collectHtml = "";
  13604. $total = 0;
  13605. for($i = 1; $i <= 12; $i ++) {
  13606. $sumPrice = 0;
  13607. foreach ( $receiptCollectList as $key => $value ) {
  13608. if ($value ['month'] == $i) {
  13609. $sumPrice += $value ['price'];
  13610. }
  13611. }
  13612. if ($sumPrice == 0)
  13613. $collectHtml .= '<td class="taR">-</td>';
  13614. else
  13615. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  13616. $total += $sumPrice;
  13617. }
  13618. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  13619. // statistics html
  13620. $stList = $statistics->statisticsByYear ( $year, $staffId );
  13621. if (empty ( $stList ))
  13622. $stList = array (
  13623. 'rePrice' => 0,
  13624. 'agPrice' => 0
  13625. );
  13626. $data ['stList'] = array (
  13627. 'rePrice' => $stList ['rePrice'],
  13628. 'agPrice' => $stList ['agPrice'],
  13629. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13630. );
  13631. $data ['totalPrice'] = $collectHtml;
  13632. $data ['totalYear'] = $total;
  13633. $data ['stHtml'] = $stHtml;
  13634. $data ['year'] = $year;
  13635. $data ['stTitle'] = $stTitle;
  13636. $data ['staffname'] = urlencode ( $staffname );
  13637. $data ['memu'] = "receipt";
  13638. $data ['staff'] = $this->staff;
  13639. $data ['receiptMemu'] = 'companyCategoryCollect';
  13640. $data ['verifyId'] = $this->verifyId;
  13641. $data ['executeId'] = $this->executeId;
  13642. if ($year < date ( "Y" )) {
  13643. Doo::loadModel ( 'receipt' );
  13644. $receipt = new receipt ();
  13645. $receiptList = $receipt->find ( array (
  13646. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  13647. 'asArray' => true
  13648. ) );
  13649. if (empty ( $receiptList )) { // generated files
  13650. ob_start ();
  13651. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13652. $this->cacheFile ( $path );
  13653. die ();
  13654. }
  13655. }
  13656. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13657. }
  13658. function BUGFLAG() {
  13659. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  13660. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  13661. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13662. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  13663. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  13664. if (empty ( $status ))
  13665. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  13666. $page_size = 12;
  13667. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  13668. $vidList = array ();
  13669. $button = 0;
  13670. Doo::loadModel ( 'verify' );
  13671. $verify = new verify ();
  13672. Doo::loadModel ( 'receipt' );
  13673. $receipt = new receipt ();
  13674. Doo::loadModel ( 'staff' );
  13675. $staff = new staff ();
  13676. Doo::loadModel ( 'L_category' );
  13677. $Lcategory = new L_category ();
  13678. $dateCondition = " and Year(date) =" . $year;
  13679. if (! empty ( $month ))
  13680. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  13681. $categoryList = $Lcategory->find ( array (
  13682. 'asArray' => true
  13683. ) );
  13684. $staffList = $staff->find ( array (
  13685. 'where' => 'cid=' . $cid,
  13686. 'asArray' => true
  13687. ) );
  13688. $cateCondition = "";
  13689. $staffCondition = "";
  13690. $approvalCondition = "";
  13691. if (! empty ( $cid ))
  13692. $cateCondition = ' and cid=' . $cid;
  13693. if (! empty ( $sid )) {
  13694. $staffCondition = ' and staff=' . $sid;
  13695. $cateCondition = "";
  13696. }
  13697. $approvalCondition = " and status=" . $status;
  13698. if ($status == 2) {
  13699. // 查找角色审批人
  13700. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  13701. }
  13702. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  13703. $approvalCondition = ' and status=2 ';
  13704. }
  13705. if ($status == 1) {
  13706. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  13707. }
  13708. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  13709. $pageinfo ['page'] = array (
  13710. 'previous' => ''
  13711. );
  13712. if ($status == 0) {
  13713. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  13714. $receiptList = $receipt->find ( array (
  13715. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  13716. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  13717. 'desc' => 'rid',
  13718. 'asArray' => true
  13719. ) );
  13720. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  13721. } else
  13722. $receiptList = $receipt->find ( array (
  13723. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  13724. 'desc' => 'rid',
  13725. 'asArray' => true
  13726. ) );
  13727. $rLRes = $receipt->find ( array (
  13728. 'where' => 'status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )' . $cateCondition . $staffCondition,
  13729. 'desc' => 'rid',
  13730. 'asArray' => true
  13731. ) );
  13732. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  13733. // print_r($pageinfo);
  13734. $Locate = 0;
  13735. foreach ( $receiptList as $key => $value ) {
  13736. $receiptList [$key] ['Locate'] = $Locate;
  13737. $Locate ++;
  13738. $receiptList [$key] ['reviseDetail'] = array ();
  13739. if (! empty ( $value ['reviseDetail'] ))
  13740. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  13741. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  13742. $categoryDetil = $Lcategory->getOne ( array (
  13743. 'where' => 'cid=' . $value ['cid'],
  13744. 'asArray' => true
  13745. ) );
  13746. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  13747. $verifyList = $verify->getOne ( array (
  13748. 'where' => 'vid=' . $value ['verify'],
  13749. 'asArray' => true
  13750. ) );
  13751. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  13752. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  13753. foreach ( $verifyList as $k => $v ) {
  13754. // init verifyStaff
  13755. $verifyList [$k] ['date'] = "";
  13756. $verifyList [$k] ['opinion'] = "";
  13757. $verifyList [$k] ['status'] = "";
  13758. if (empty ( $verifyStaff )) {
  13759. $verifyList [$k] ['date'] = "";
  13760. $verifyList [$k] ['opinion'] = "";
  13761. if ($v [0] == $this->staff [0] ['sid']) {
  13762. $verifyList [$k] ['status'] = 4;
  13763. $button = 4;
  13764. }
  13765. } else {
  13766. $flag = true;
  13767. foreach ( $verifyStaff as $m => $u ) {
  13768. if ($v [0] == $m) {
  13769. $verifyList [$k] ['date'] = $u ['date'];
  13770. $verifyList [$k] ['opinion'] = $u ['opinion'];
  13771. $verifyList [$k] ['status'] = $u ['status'];
  13772. $flag = false;
  13773. break;
  13774. }
  13775. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  13776. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  13777. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  13778. }
  13779. if ($flag) { // 检测可编辑
  13780. if ($v [0] == $this->staff [0] ['sid']) {
  13781. $verifyList [$k] ['status'] = 4;
  13782. $button = 4;
  13783. }
  13784. }
  13785. }
  13786. }
  13787. $receiptList [$key] ['verifyList'] = $verifyList;
  13788. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  13789. 'where' => 'sid=' . $value ['staff'],
  13790. 'asArray' => true
  13791. ) );
  13792. $receiptList [$key] ['button'] = $button;
  13793. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  13794. }
  13795. // print_r($receiptList);die;
  13796. // $data['verifyDetail']=$verifyDetail;
  13797. $mothHtml = "";
  13798. for($i = 1; $i <= 12; $i ++) {
  13799. if ($month == $i)
  13800. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  13801. else
  13802. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  13803. }
  13804. $data ['mothHtml'] = $mothHtml;
  13805. $data ['page'] = $pageinfo;
  13806. $data ['receiptList'] = $receiptList;
  13807. $data ['receiptApprovalCount'] = count ( $rLRes );
  13808. $data ['status'] = $status;
  13809. $data ['year'] = $year;
  13810. $data ['categoryList'] = $categoryList;
  13811. $data ['staffList'] = $staffList;
  13812. $data ['cid'] = $cid;
  13813. $data ['sid'] = $sid;
  13814. // print_r($receiptList);
  13815. $data ['memu'] = "receipt";
  13816. $data ['staff'] = $this->staff;
  13817. $data ['receiptMemu'] = 'approvalExpenses';
  13818. $data ['verifyId'] = $this->verifyId;
  13819. $data ['executeId'] = $this->executeId;
  13820. $this->render ( "/admin/FALG", $data );
  13821. }
  13822. function ajaxGetReceiptOrder() {
  13823. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  13824. if (! empty ( $receiptOrder )) {
  13825. Doo::loadModel ( 'receipt' );
  13826. $receipt = new receipt ();
  13827. Doo::loadModel ( 'staff' );
  13828. $staff = new staff ();
  13829. $receiptInfo = $receipt->getOne ( array (
  13830. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  13831. 'asArray' => true
  13832. ) );
  13833. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  13834. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  13835. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  13836. </tbody></table><table class="table table table-bordered"><tbody>';
  13837. foreach ( $verifyStaff as $key => $value ) {
  13838. $staffInfo = $staff->getOne ( array (
  13839. 'select' => 'username',
  13840. 'where' => ' sid="' . $key . '"',
  13841. 'asArray' => true
  13842. ) );
  13843. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  13844. }
  13845. $html .= '</tbody></table></div></div>';
  13846. echo json_encode ( array (
  13847. 'status' => 1,
  13848. 'receiptHtml' => $html
  13849. ) );
  13850. die ();
  13851. }
  13852. echo json_encode ( array (
  13853. 'status' => 2,
  13854. 'receiptHtml' => ''
  13855. ) );
  13856. die ();
  13857. }
  13858. function _getMonthCollectDetail($receiptCollectList,$aiList) {
  13859. if (! empty ( $receiptCollectList )) {
  13860. $receiptL = array (
  13861. '日常相关费用' => array (),
  13862. '差旅相关费用' => array (),
  13863. '内部培训费用'=>array(),
  13864. '培训班费用' => array (),
  13865. '其他' => array ()
  13866. );
  13867. $html = "";
  13868. $psum = 0;
  13869. foreach ( $aiList[$this->AGENCY] as $value ) {
  13870. $falg = true;
  13871. foreach ( $receiptCollectList as $v ) {
  13872. if ($v ['itemCategory'] == '日常相关费用') {
  13873. if ($v ['item'] == $value['name']) {
  13874. $psum += $v ['price'];
  13875. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13876. $falg = false;
  13877. break;
  13878. }
  13879. }
  13880. }
  13881. if ($falg)
  13882. $html .= '<td class="taR">-</td>';
  13883. }
  13884. if (! empty ( $psum ))
  13885. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13886. else
  13887. $psum = '<td class="colGreen taR">-</td>';
  13888. $receiptL ['日常相关费用'] = $psum . $html;
  13889. /* ----------------------------------- */
  13890. $html = "";
  13891. $psum = 0;
  13892. foreach ( $aiList[$this->TRAVEL] as $value ) {
  13893. $falg = true;
  13894. foreach ( $receiptCollectList as $v ) {
  13895. if ($v ['itemCategory'] == '差旅相关费用') {
  13896. if ($v ['item'] == $value['name']) {
  13897. $psum += $v ['price'];
  13898. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13899. $falg = false;
  13900. break;
  13901. }
  13902. }
  13903. }
  13904. if ($falg)
  13905. $html .= '<td class="taR">-</td>';
  13906. }
  13907. if (! empty ( $psum ))
  13908. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13909. else
  13910. $psum = '<td class="colGreen taR">-</td>';
  13911. $receiptL ['差旅相关费用'] = $psum . $html;
  13912. /* ----------------------------------- */
  13913. $html = "";
  13914. $psum = 0;
  13915. foreach ( $aiList[$this->INTTRAIN] as $value ) {
  13916. $falg = true;
  13917. foreach ( $receiptCollectList as $v ) {
  13918. if ($v ['itemCategory'] == '内部培训费用') {
  13919. if ($v ['item'] == $value['name']) {
  13920. $psum += $v ['price'];
  13921. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13922. $falg = false;
  13923. break;
  13924. }
  13925. }
  13926. }
  13927. if ($falg)
  13928. $html .= '<td class="taR">-</td>';
  13929. }
  13930. if (! empty ( $psum ))
  13931. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13932. else
  13933. $psum = '<td class="colGreen taR">-</td>';
  13934. $receiptL ['内部培训费用'] = $psum . $html;
  13935. /* ------------------------------------- */
  13936. $html = "";
  13937. $psum = 0;
  13938. foreach ( $aiList[$this->TRAIN] as $value ) {
  13939. $falg = true;
  13940. foreach ( $receiptCollectList as $v ) {
  13941. if ($v ['itemCategory'] == '培训班费用') {
  13942. if ($v ['item'] == $value['name']) {
  13943. $psum += $v ['price'];
  13944. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13945. $falg = false;
  13946. break;
  13947. }
  13948. }
  13949. }
  13950. if ($falg)
  13951. $html .= '<td class="taR">-</td>';
  13952. }
  13953. if (! empty ( $psum ))
  13954. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13955. else
  13956. $psum = '<td class="colGreen taR">-</td>';
  13957. $receiptL ['培训班费用'] = $psum . $html;
  13958. /* ------------------------------------- */
  13959. $html = "";
  13960. $psum = 0;
  13961. foreach ( $aiList[$this->OTHER] as $value ) {
  13962. $falg = true;
  13963. foreach ( $receiptCollectList as $v ) {
  13964. if ($v ['itemCategory'] == '其他') {
  13965. if ($v ['item'] == $value['name']) {
  13966. $psum += $v ['price'];
  13967. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13968. $falg = false;
  13969. break;
  13970. }
  13971. }
  13972. }
  13973. if ($falg)
  13974. $html .= '<td class="taR">-</td>';
  13975. }
  13976. if (! empty ( $psum ))
  13977. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13978. else
  13979. $psum = '<td class="colGreen taR">-</td>';
  13980. $receiptL ['其他'] = $psum . $html;
  13981. /* ------------------------------------- */
  13982. $html = "";
  13983. $psum = 0;
  13984. foreach ( $receiptCollectList as $v ) {
  13985. if ($v ['itemCategory'] == '报销金额调整') {
  13986. if (! empty ( $v ['price'] ))
  13987. $psum += $v ['price'];
  13988. }
  13989. }
  13990. if (! empty ( $psum ))
  13991. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  13992. else
  13993. $psum = '<td class="taR colOrange">-</td>';
  13994. $receiptL ['报销金额调整'] = $psum . $html;
  13995. } else {
  13996. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  13997. foreach ( $aiList[$this->AGENCY] as $va ) {
  13998. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  13999. }
  14000. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  14001. foreach ( $aiList[$this->TRAVEL] as $va ) {
  14002. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  14003. }
  14004. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  14005. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  14006. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  14007. }
  14008. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  14009. foreach ( $aiList[$this->TRAIN] as $va ) {
  14010. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  14011. }
  14012. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  14013. foreach ( $aiList[$this->OTHER] as $va ) {
  14014. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  14015. }
  14016. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  14017. }
  14018. return $receiptL;
  14019. }
  14020. function eMail() {
  14021. Doo::loadModel ( 'staff' );
  14022. $staff = new staff ();
  14023. Doo::loadModel ( 'receipt' );
  14024. $receipt = new receipt ();
  14025. Doo::loadModel ( 'L_category' );
  14026. $Lcategory = new L_category ();
  14027. Doo::loadModel ( "verify" );
  14028. $verify = new verify ();
  14029. $staffList = $staff->find ( array (
  14030. 'asArray' => true
  14031. ) );
  14032. foreach ( $staffList as $key => $value ) {
  14033. if ($value ['username'] != 'admin') {
  14034. // 提交人
  14035. $receiptList = $receipt->find ( array (
  14036. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  14037. 'asArray' => true
  14038. ) );
  14039. if (! empty ( $receiptList )) {
  14040. $html = '<br><div><style></style>
  14041. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  14042. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  14043. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14044. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  14045. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14046. <tbody><tr>
  14047. <td style="padding: 0 40px;" align="left">
  14048. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14049. </td></tr><tr>
  14050. <td style="padding: 0 40px;" align="left"><p style="margin-top:0px;margin-bottom:40px;color:#383838;font-size:20px;line-height:32px;">美好的一天从今天开始,您需要关注以下事项:</p></td>
  14051. </tr>
  14052. </tbody> </table></td> </tr> <tr><td>
  14053. <table style="background-color:#f5f6f7;width:100%;padding:0 0 20px;border-left:1px solid #ddd;border-right:1px solid #ddd;" cellpadding="0" cellspacing="0" align="left">
  14054. <tbody> <tr><td>
  14055. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  14056. 以下报销单完成了审批,等着收款吧:</p>
  14057. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  14058. foreach ( $receiptList as $k => $v ) {
  14059. $category = $Lcategory->getOne ( array (
  14060. 'where' => 'cid=' . $v ['cid'],
  14061. 'asArray' => true
  14062. ) );
  14063. $html .= '
  14064. <tr>
  14065. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14066. <td align="left">
  14067. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  14068. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  14069. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  14070. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  14071. </tr>';
  14072. }
  14073. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  14074. <tr><td style="height:150px;border:1px solid #ddd;border-top:none;background-color:#fff;" align="center"><a href="http://cld.smartcost.com.cn/approval" style="display:block;height:50px;width:260px;background-color:#0390ff;font-weight:normal;font-size:18px;color:white;line-height:50px;text-align:center;text-decoration:none;border-radius:3px;">立即登录</a></td>
  14075. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  14076. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  14077. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  14078. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14079. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14080. $receipt = new receipt ();
  14081. $receipt->notice = 1;
  14082. $receipt->update ( array (
  14083. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  14084. ) );
  14085. }
  14086. }
  14087. // 审批人
  14088. $verifyList = $verify->find ( array (
  14089. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  14090. 'asArray' => true
  14091. ) );
  14092. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  14093. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  14094. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14095. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  14096. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14097. <tbody><tr><td style="padding: 0 40px;" align="left">
  14098. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14099. </td></tr><tr><td style="padding: 0 40px;" align="left"><p style="margin-top:0px;margin-bottom:40px;color:#383838;font-size:20px;line-height:32px;">美好的一天从今天开始,您需要关注以下事项:</p></td>
  14100. </tr></tbody></table></td> </tr> <tr><td><table style="background-color:#f5f6f7;width:100%;padding:0 0 20px;border-left:1px solid #ddd;border-right:1px solid #ddd;" cellpadding="0" cellspacing="0" align="left">
  14101. <tbody><tr><td><p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">以下报销单需要您的审批:</p></td>
  14102. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  14103. foreach ( $verifyList as $k => $v ) {
  14104. $receiptList = $receipt->find ( array (
  14105. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  14106. 'asArray' => true
  14107. ) );
  14108. foreach ( $receiptList as $r => $l ) {
  14109. $category = $Lcategory->getOne ( array (
  14110. 'where' => 'cid=' . $l ['cid'],
  14111. 'asArray' => true
  14112. ) );
  14113. $staffDetile = $staff->getOne ( array (
  14114. 'where' => 'sid=' . $l ['staff'],
  14115. 'asArray' => true
  14116. ) );
  14117. $html .= '
  14118. <tr>
  14119. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14120. <td align="left">
  14121. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  14122. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  14123. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  14124. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  14125. </tr>';
  14126. }
  14127. }
  14128. $html .= '
  14129. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  14130. <td style="height:150px;border:1px solid #ddd;border-top:none;background-color:#fff;" align="center"><a href="http://cld.smartcost.com.cn/approval" style="display:block;height:50px;width:260px;background-color:#0390ff;font-weight:normal;font-size:18px;color:white;line-height:50px;text-align:center;text-decoration:none;border-radius:3px;">立即登录</a></td>
  14131. </tr></tbody></table></td></tr></tbody></table></div><br>';
  14132. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  14133. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  14134. // $receipt=new receipt();
  14135. // $receipt->notice=1;
  14136. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  14137. }
  14138. }
  14139. }
  14140. }
  14141. function setWXMsg($rid, $type) {
  14142. Doo::loadModel ( "receipt" );
  14143. $receipt = new receipt ();
  14144. $receiptDetail = $receipt->getOne ( array (
  14145. 'where' => 'rid=' . $rid,
  14146. 'asArray' => true
  14147. ) );
  14148. if (! empty ( $receiptDetail )) {
  14149. Doo::loadModel ( 'staff' );
  14150. $staff = new staff ();
  14151. $staffmsg = $staff->getOne ( array (
  14152. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  14153. 'asArray' => TRUE
  14154. ) );
  14155. if (! empty ( $staffmsg ['wxid'] )) {
  14156. require_once (SITE_PATH . '/protected/class/client.php');
  14157. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  14158. $user = $staffmsg ['wxid'];
  14159. $receiptName = '';
  14160. $msg = '';
  14161. switch ($receiptDetail ['Rtype']) {
  14162. case 0 :
  14163. $receiptName = '报销';
  14164. break;
  14165. case 1 :
  14166. $receiptName = '借款';
  14167. break;
  14168. case 2 :
  14169. $receiptName = '对公汇款';
  14170. break;
  14171. }
  14172. switch ($type) {
  14173. case 1 :
  14174. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  14175. break;
  14176. case 2 :
  14177. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  14178. break;
  14179. case 3 :
  14180. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  14181. break;
  14182. }
  14183. // $result = $client->SendMsg ( $user, $msg, 'text' );
  14184. }
  14185. }
  14186. }
  14187. // Email发送函数
  14188. function SMail($toemail, $subject, $contents) {
  14189. Doo::loadClass ( 'class.phpmailer' );
  14190. $mail = new PHPMailer ();
  14191. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  14192. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  14193. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  14194. $mail->Password = "cDO1GjtY1seH"; // 密码
  14195. $mail->CharSet = "UTF8";
  14196. $mail->SMTPAuth = true;
  14197. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  14198. $mail->Mailer = "smtp";
  14199. $mail->Port = 25;
  14200. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  14201. $mail->MsgHTML ( $contents );
  14202. $mail->AddAddress ( $toemail );
  14203. $mail->CharSet = "UTF-8";
  14204. return $mail->Send ();
  14205. }
  14206. function h5Upload() {
  14207. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14208. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14209. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14210. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14211. header ( "HTTP/1.1 500 Internal Server Error" );
  14212. echo "POST exceeded maximum allowed size.";
  14213. exit ( 0 );
  14214. }
  14215. // Settings
  14216. $save_path = DOO::conf ()->SITE_PATH . "upload/swfupload/"; // The path were we will save the file (getcwd() may not be reliable and should be tested in your environment)
  14217. $upload_name = "Filedata";
  14218. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14219. $extension_whitelist = array (
  14220. "doc",
  14221. "txt",
  14222. "jpg",
  14223. "gif",
  14224. "png"
  14225. ); // Allowed file extensions
  14226. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14227. // Other variables
  14228. $MAX_FILENAME_LENGTH = 260;
  14229. $file_name = "";
  14230. $file_extension = "";
  14231. $uploadErrors = array (
  14232. 0 => "文件上传成功",
  14233. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14234. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14235. 3 => "上传的文件仅为部分文件",
  14236. 4 => "没有文件上传",
  14237. 6 => "缺少临时文件夹"
  14238. );
  14239. $nk = time ();
  14240. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14241. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14242. echo "文件无法保存.";
  14243. exit ( 0 );
  14244. }
  14245. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14246. echo json_encode ( array (
  14247. 'filename' => $file_name,
  14248. 'id' => $nk
  14249. ) );
  14250. exit ( 0 );
  14251. }
  14252. function swfupload() {
  14253. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14254. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14255. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14256. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14257. header ( "HTTP/1.1 500 Internal Server Error" );
  14258. echo "POST exceeded maximum allowed size.";
  14259. exit ( 0 );
  14260. }
  14261. // Settings
  14262. $save_path = DOO::conf ()->SITE_PATH . "upload/swfupload/"; // The path were we will save the file (getcwd() may not be reliable and should be tested in your environment)
  14263. $upload_name = "Filedata";
  14264. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14265. $extension_whitelist = array (
  14266. "doc",
  14267. "txt",
  14268. "jpg",
  14269. "gif",
  14270. "png"
  14271. ); // Allowed file extensions
  14272. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14273. // Other variables
  14274. $MAX_FILENAME_LENGTH = 260;
  14275. $file_name = "";
  14276. $file_extension = "";
  14277. $uploadErrors = array (
  14278. 0 => "文件上传成功",
  14279. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14280. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14281. 3 => "上传的文件仅为部分文件",
  14282. 4 => "没有文件上传",
  14283. 6 => "缺少临时文件夹"
  14284. );
  14285. $nk = time ();
  14286. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14287. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14288. echo "文件无法保存.";
  14289. exit ( 0 );
  14290. }
  14291. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14292. echo json_encode ( array (
  14293. 'filename' => $file_name,
  14294. 'id' => $nk
  14295. ) );
  14296. exit ( 0 );
  14297. }
  14298. function _GetFileEXT($filename) {
  14299. $pics = explode ( '.', $filename );
  14300. $num = count ( $pics );
  14301. return $pics [$num - 1];
  14302. }
  14303. /**
  14304. * 获取get或者POST值
  14305. * @param string $name 属性名称
  14306. * @return fixed 值
  14307. */
  14308. function get_args($name) {
  14309. if (isset ( $_GET [$name] )) {
  14310. if (is_array ( $_GET [$name] ))
  14311. return $_GET [$name];
  14312. else
  14313. return addslashes ( $_GET [$name] );
  14314. } elseif (isset ( $_POST [$name] )) {
  14315. if (is_array ( $_POST [$name] ))
  14316. return $_POST [$name];
  14317. else
  14318. return addslashes ( $_POST [$name] );
  14319. } else
  14320. return false;
  14321. }
  14322. function num_to_rmb($num) {
  14323. $c1 = "零壹贰叁肆伍陆柒捌玖";
  14324. $c2 = "分角元拾佰仟万拾佰仟亿";
  14325. // 精确到分后面就不要了,所以只留两个小数位
  14326. $num = round ( $num, 2 );
  14327. // 将数字转化为整数
  14328. $num = $num * 100;
  14329. if (strlen ( $num ) > 10) {
  14330. return "金额太大,请检查";
  14331. }
  14332. $i = 0;
  14333. $c = "";
  14334. while ( 1 ) {
  14335. if ($i == 0) {
  14336. // 获取最后一位数字
  14337. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  14338. } else {
  14339. $n = $num % 10;
  14340. }
  14341. // 每次将最后一位数字转化为中文
  14342. $p1 = substr ( $c1, 3 * $n, 3 );
  14343. $p2 = substr ( $c2, 3 * $i, 3 );
  14344. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  14345. $c = $p1 . $p2 . $c;
  14346. } else {
  14347. $c = $p1 . $c;
  14348. }
  14349. $i = $i + 1;
  14350. // 去掉数字最后一位了
  14351. $num = $num / 10;
  14352. // echo $num.'</br>';
  14353. $num = ( int ) $num;
  14354. // $num =floor($num);
  14355. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  14356. // echo $num.'</br>';
  14357. // 结束循环
  14358. if ($num == 0) {
  14359. break;
  14360. }
  14361. }
  14362. // echo $c.'</br>';
  14363. $j = 0;
  14364. $slen = strlen ( $c );
  14365. while ( $j < $slen ) {
  14366. // utf8一个汉字相当3个字符
  14367. $m = substr ( $c, $j, 6 );
  14368. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  14369. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  14370. $left = substr ( $c, 0, $j );
  14371. $right = substr ( $c, $j + 3 );
  14372. $c = $left . $right;
  14373. $j = $j - 3;
  14374. $slen = $slen - 3;
  14375. }
  14376. $j = $j + 3;
  14377. }
  14378. // 这个是为了去掉类似23.0中最后一个“零”字
  14379. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  14380. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  14381. }
  14382. // 将处理的汉字加上“整”
  14383. if (empty ( $c )) {
  14384. return "零元整";
  14385. } else {
  14386. return $c . "整";
  14387. }
  14388. }
  14389. /**
  14390. * 获得分页数据
  14391. * @param unknown_type $table
  14392. * @param unknown_type $condition
  14393. * @param unknown_type $on_page
  14394. * @param unknown_type $page_size
  14395. */
  14396. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  14397. $page_c = "";
  14398. $page ['previous'] = $this->get_previous ( $on_page );
  14399. $page ['on_page'] = $on_page;
  14400. $total_count = $this->get_table_count ( $table, $condition );
  14401. $total = intval ( $total_count / $page_size );
  14402. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  14403. $page ['total_data'] = $total_count;
  14404. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  14405. $i = 1;
  14406. $page_max = 1;
  14407. $page_width = 3;
  14408. if ($on_page >= $page_width) {
  14409. $page_max = intval ( $on_page / $page_width ) + 1;
  14410. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  14411. }
  14412. for(; $i <= $page ['total_page']; $i ++) {
  14413. if ($i == $on_page)
  14414. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  14415. else
  14416. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  14417. if ($i == ($page_width * $page_max))
  14418. break;
  14419. }
  14420. $page ['page'] = $page_c;
  14421. $page ['lower'] = (-- $on_page) * $page_size;
  14422. return $page;
  14423. }
  14424. /**
  14425. * 获取总页数
  14426. * @param unknown_type $table
  14427. * @param unknown_type $condition
  14428. */
  14429. public function get_table_count($table = "", $condition = "") {
  14430. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14431. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14432. // echo $sql;die;
  14433. $query = Doo::db ()->query ( $sql );
  14434. $result = $query->fetch ();
  14435. return $result ['count'];
  14436. }
  14437. /**
  14438. * 获取上一页
  14439. * @param unknown_type $on_page
  14440. */
  14441. function get_previous($on_page = 1) {
  14442. return $on_page != 0 ? $on_page - 1 : $on_page;
  14443. }
  14444. function _getReceiptTrainPayment($invoiceTrainId,$trainLoanRid,$rid){
  14445. // 收入合计
  14446. Doo::loadModel ( 'invoiceTraining' );
  14447. $invoiceTraining = new invoiceTraining ();
  14448. Doo::loadModel ( 'receipt' );
  14449. $receipt = new receipt ();
  14450. $invoiceTrainingDetail = array (
  14451. 'invoiceArriveAmount' => '0.00',
  14452. 'RIAmount' => '0.00',
  14453. 'invoiceTotalAmount' => '0.00',
  14454. 'invoiceCompanyAmount' => '0.00',
  14455. 'invoiceArriveAmountM'=>'0.00',
  14456. 'invoiceCompanyAmountM'=>'0.00'
  14457. );
  14458. if ($invoiceTrainId != 0) {
  14459. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $invoiceTrainId );
  14460. }
  14461. $invoiceArriveAmount = $RIAmount = 0;
  14462. if (! empty ( $invoiceTrainingDetail )) {
  14463. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  14464. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  14465. }
  14466. // 备用金
  14467. $sum = 0;
  14468. if (! empty ( $trainLoanRid )) {
  14469. $receiptLoanList = $receipt->getReceiptInRid ( $trainLoanRid );
  14470. foreach ($receiptLoanList as $key=>$value){
  14471. $sum+=$value['sum'];
  14472. }
  14473. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $trainLoanRid );
  14474. // $sum = $receiptLoanDetailBak ['sum'];
  14475. }
  14476. // 支出项金额详情
  14477. // 项目金额合计
  14478. Doo::loadModel ( 'RItem' );
  14479. $RItem = new RItem ();
  14480. Doo::loadModel ( 'accountItem' );
  14481. $accountItem = new accountItem ();
  14482. // 讲师获得
  14483. Doo::loadModel ( 'RILecturer' );
  14484. $RILecturer = new RILecturer ();
  14485. $RItemList = $RItem->getRItemByRid ($rid );
  14486. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  14487. // 支出项金额详情
  14488. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  14489. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  14490. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  14491. return $payment;
  14492. }
  14493. }
  14494. ?>