ReceiptController.php 560 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class ReceiptController extends DooController {
  6. public $staff;
  7. public $verifyId;
  8. public $executeId;
  9. // public static $NEW2 = 0;
  10. public $AGENCY = "日常相关费用";
  11. public $TRAVEL = "差旅相关费用";
  12. public $TRAIN = "培训班费用";
  13. public $OTHER = "其他";
  14. public $INTTRAIN='内部培训费用';
  15. private $MYREVEIPTCACHEPATH = "protected/cache/myReceipt/";
  16. private $PERSONALCOLLECTCACHEPATH = "protected/cache/personalCollect/";
  17. private $CATEGORYCOLLECTPATH = "protected/cache/categoryCollect/";
  18. private $STAFFCOLLECTPATH = "protected/cache/staffCollect/";
  19. private function showCache($path) {
  20. if (file_exists ( $path )) {
  21. echo "<!DOCTYPE html>";
  22. include $path;
  23. die ();
  24. }
  25. }
  26. private function cacheFile($path) {
  27. $content = ob_get_contents ();
  28. $fp = fopen ( $path, "w" );
  29. fwrite ( $fp, $content );
  30. fclose ( $fp );
  31. }
  32. private function collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {
  33. $collectHtml = "";
  34. $sumPrice = 0.00;
  35. for($i = 1; $i <= 12; $i ++) {
  36. $falg = true;
  37. foreach ( $receiptCollectList as $key => $value ) {
  38. if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {
  39. $sumPrice += $value ['price'];
  40. if ($classType == "b") {
  41. $collectHtml .= '<td class="colGreen taR">¥' . $value ['price'] . '</td>';
  42. $falg = false;
  43. break;
  44. } else {
  45. $collectHtml .= '<td class="taR">¥' . $value ['price'] . '</td>';
  46. $falg = false;
  47. break;
  48. }
  49. }
  50. }
  51. if ($falg)
  52. $collectHtml .= '<td class="taR">-</td>';
  53. }
  54. $collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';
  55. return $collectHtml;
  56. }
  57. public function beforeRun($resource, $action) {
  58. Doo::loadClass ( 'XDeode' );
  59. $XDeode = new XDeode ( 5 );
  60. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  61. // 单独判断公司汇总的访问权限
  62. if ($action == 'companyCategoryCollect') {
  63. Doo::loadModel ( "receiptAuthorityManage" );
  64. $invoiceCompanyManage = new receiptAuthorityManage ();
  65. $icm = $invoiceCompanyManage->getInvoiceCMByStaff ( $sid );
  66. if (empty ( $icm ))
  67. die ( 'illegal request-statistics' );
  68. }
  69. Doo::loadModel ( 'staff' );
  70. $staff = new staff ();
  71. $detail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  72. $accessModular = 'RECEIPTS';
  73. if (empty ( $detail ['cldAccessArray'] ))
  74. die ( 'illegal request' );
  75. else {
  76. if (in_array ( $accessModular, $detail ['cldAccessArray'] )) {
  77. if (Doo::acl ()->isAllowed ( $accessModular, $resource, $action )) {
  78. $flag = true;
  79. } else {
  80. $flag = false;
  81. }
  82. } else {
  83. die ( 'illegal request' );
  84. }
  85. }
  86. if (! $flag)
  87. die ( 'illegal request' );
  88. }
  89. function __construct() {
  90. if (isset ( $_COOKIE ["staff"] )) {
  91. if (! empty ( $_COOKIE ["staff"] )) {
  92. Doo::loadModel ( 'staff' );
  93. Doo::loadModel ( 'verify' );
  94. $verify = new verify ();
  95. $staff = new staff ();
  96. Doo::loadModel ( "execute" );
  97. $execute = new execute ();
  98. $verifyList = $verify->find ( array (
  99. 'select' => 'staff',
  100. 'asArray' => true
  101. ) );
  102. $list = array ();
  103. // 判断角色的审批权限
  104. foreach ( $verifyList as $key => $value ) {
  105. $ver = json_decode ( $value ['staff'] );
  106. foreach ( $ver as $k => $v ) {
  107. if ($v [1] == 'ROLE') {
  108. $roleList = json_decode ( $v [3] );
  109. foreach ( $roleList as $t => $g ) {
  110. $gList = explode ( "_", $g );
  111. array_push ( $list, $gList [0] );
  112. // print_r($list);
  113. }
  114. } else
  115. array_push ( $list, $v [0] );
  116. }
  117. }
  118. // 判断执行人的审批权限
  119. $executeList = $execute->find ( array (
  120. 'where'=>'mold !="日常收支"',
  121. 'select' => 'staff',
  122. 'asArray' => true
  123. ) );
  124. $list2 = array ();
  125. foreach ( $executeList as $key => $value ) {
  126. $ver = json_decode ( $value ['staff'] );
  127. foreach ( $ver as $k => $v ) {
  128. array_push ( $list2, $v [0] );
  129. }
  130. }
  131. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  132. $eidList = array_filter ( explode ( ",", $eidList ) );
  133. $this->executeId = array_merge ( $list2, $eidList );
  134. //print_r($this->executeId);
  135. $this->verifyId = $list;
  136. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  137. // 检测用户信息完成
  138. $this->data ['isStaffCompleteMsg'] = false;
  139. $detail = $staff->checkStaffInfoIsComplete ( $_COOKIE ["staff"] );
  140. if (! empty ( $detail ))
  141. $this->data ['isStaffCompleteMsg'] = true;
  142. return "/";
  143. }
  144. }
  145. Doo::loadCore ( 'uri/DooUriRouter' );
  146. $router = new DooUriRouter ();
  147. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  148. if ($routeRs ['1'] != "login") {
  149. header ( 'Content-Type:text/html;charset=utf-8' );
  150. @header ( "Location: /login" );
  151. }
  152. }
  153. /**
  154. * 费用首页
  155. */
  156. function saeaBorad() {
  157. Doo::loadModel ( 'receipt' );
  158. $receipt = new receipt ();
  159. Doo::loadModel ( 'verify' );
  160. $verify = new verify ();
  161. Doo::loadModel ( 'L_category' );
  162. $lCategory = new L_category ();
  163. Doo::loadModel ( "role" );
  164. $role = new role ();
  165. Doo::loadModel ( "receiptLog" );
  166. $receiptLog = new receiptLog ();
  167. Doo::loadModel ( 'accountItem' );
  168. $accountItem = new accountItem ();
  169. Doo::loadClass ( 'XDeode' );
  170. $XDeode = new XDeode ( 7 );
  171. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  172. $receiptDetail = $receipt->find ( array (
  173. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  174. 'desc' => 'rid',
  175. 'asArray' => true
  176. ) );
  177. foreach ( $receiptDetail as $key => $value ) {
  178. $receiptDetail [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  179. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  180. $veList = $verify->getOne ( array (
  181. 'where' => 'vid=' . $value ['verify'],
  182. 'asArray' => true
  183. ) );
  184. $v = json_decode ( $veList ['staff'] );
  185. array_push ( $v [0], $veList ['description'] );
  186. foreach ( $v as $n => $m ) {
  187. if ($m ['1'] == 'ROLE') {
  188. $roleInfo = $role->getOne ( array (
  189. 'where' => 'rid=' . $m [0],
  190. 'asArray' => true
  191. ) );
  192. $v [$n] [1] = $roleInfo ['name'];
  193. }
  194. }
  195. $receiptDetail [$key] ['staff'] = $v;
  196. $category = $lCategory->getOne ( array (
  197. 'where' => 'cid=' . $value ['cid'],
  198. 'asArray' => true
  199. ) );
  200. $receiptDetail [$key] ['category'] = $category ['title'];
  201. }
  202. // print_r($receiptLogList);
  203. Doo::loadModel ( 'RAssist' );
  204. $RAssist = new RAssist ();
  205. $receiptExtendList=$RAssist->getRAssistBySid($this->staff[0]['sid']);
  206. //费用项目
  207. $acItem = $accountItem->find ( array ('asArray' => true) );
  208. $data ['acItem'] = $acItem;
  209. $data ['receiptExtendList'] = $receiptExtendList;
  210. $data ['receiptLogList'] = $receiptLogList;
  211. $data ['receiptDetail'] = $receiptDetail;
  212. $data ['memu'] = "receipt";
  213. $data ['staff'] = $this->staff;
  214. $data ['receiptMemu'] = 'saeaBorad';
  215. $data ['verifyId'] = $this->verifyId;
  216. $data ['executeId'] = $this->executeId;
  217. $this->render ( "/receipt/receiptFee", $data );
  218. }
  219. /**
  220. * 费用报销单-导流入哪个细分类
  221. */
  222. function receiptFeeDiversion(){
  223. $feeType= $this->get_args ( 'feeType' ) ? $this->get_args ( 'feeType' ) : "";
  224. if($feeType==2){
  225. return '/receipt/feeTravel';
  226. }elseif($feeType==3){
  227. return '/receipt/feeInternalTrain';
  228. }else{
  229. return '/receipt/feeAgency';
  230. }
  231. }
  232. /**
  233. * 办事处相关费用
  234. */
  235. function feeAgency(){
  236. Doo::loadModel ( 'L_category' );
  237. $lCategory = new L_category ();
  238. Doo::loadModel ( 'verify' );
  239. $verify = new verify ();
  240. Doo::loadModel ( 'accountItem' );
  241. $accountItem = new accountItem ();
  242. Doo::loadModel ( "role" );
  243. $role = new role ();
  244. $acItem = $accountItem->find ( array (
  245. 'asArray' => true
  246. ) );
  247. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  248. $data ['category'] = $lCategory->find ( array (
  249. 'asArray' => true
  250. ) );
  251. $data ['veList'] = $veList;
  252. $data ['acItem'] = $acItem;
  253. $data ['memu'] = "receipt";
  254. $data ['staff'] = $this->staff;
  255. $data ['receiptMemu'] = 'saeaBorad';
  256. $data ['verifyId'] = $this->verifyId;
  257. $data ['executeId'] = $this->executeId;
  258. $this->render ( "/receipt/feeAgency", $data );
  259. }
  260. /**
  261. * 办事处
  262. */
  263. function feeTravel(){
  264. Doo::loadModel ( 'L_category' );
  265. $lCategory = new L_category ();
  266. Doo::loadModel ( 'verify' );
  267. $verify = new verify ();
  268. Doo::loadModel ( 'accountItem' );
  269. $accountItem = new accountItem ();
  270. Doo::loadModel ( "role" );
  271. $role = new role ();
  272. $acItem = $accountItem->find ( array (
  273. 'asArray' => true
  274. ) );
  275. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  276. $data ['category'] = $lCategory->find ( array (
  277. 'asArray' => true
  278. ) );
  279. $data ['veList'] = $veList;
  280. $data ['acItem'] = $acItem;
  281. $data ['memu'] = "receipt";
  282. $data ['staff'] = $this->staff;
  283. $data ['receiptMemu'] = 'saeaBorad';
  284. $data ['verifyId'] = $this->verifyId;
  285. $data ['executeId'] = $this->executeId;
  286. $this->render ( "/receipt/feeTravel", $data );
  287. }
  288. /**
  289. * 添加费用报销单页面
  290. */
  291. function saeaCreate() {
  292. Doo::loadModel ( 'accountItem' );
  293. Doo::loadModel ( 'verify' );
  294. Doo::loadModel ( 'receipt' );
  295. Doo::loadModel ( 'L_category' );
  296. $lCategory = new L_category ();
  297. $receipt = new receipt ();
  298. $verify = new verify ();
  299. $accountItem = new accountItem ();
  300. Doo::loadModel ( "role" );
  301. $role = new role ();
  302. $acItem = $accountItem->find ( array (
  303. 'asArray' => true
  304. ) );
  305. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  306. $data ['category'] = $lCategory->find ( array (
  307. 'asArray' => true
  308. ) );
  309. $data ['veList'] = $veList;
  310. $data ['acItem'] = $acItem;
  311. $data ['memu'] = "receipt";
  312. $data ['staff'] = $this->staff;
  313. $data ['receiptMemu'] = 'saeaBorad';
  314. $data ['verifyId'] = $this->verifyId;
  315. $data ['executeId'] = $this->executeId;
  316. $this->render ( "/admin/saea_create", $data );
  317. }
  318. private function _buildFeeData($receiptClass=1,$itinerary=''){
  319. $agency = $this->get_args ( 'agency' );
  320. $travel = $this->get_args ( 'travel' );
  321. $train = $this->get_args ( 'train' );
  322. $other = $this->get_args ( 'other' );
  323. $inttrain = $this->get_args ( 'inttrain' );
  324. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  325. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  326. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  327. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  328. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  329. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  330. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  331. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  332. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  333. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  334. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  335. header ( 'Content-Type:text/html;charset=utf-8' );
  336. die ( '请填写联行号' );
  337. }
  338. Doo::loadModel ( 'receipt' );
  339. Doo::loadModel ( 'receiptDetail' );
  340. Doo::loadModel ( 'accountItem' );
  341. $accountItem = new accountItem ();
  342. $receipt = new receipt ();
  343. Doo::loadModel ( 'enclosur' );
  344. Doo::loadModel ( 'execute' );
  345. $execute = new execute ();
  346. $executeDetail = $execute->getOne ( array (
  347. 'where' => 'mold="报销单执行人"',
  348. 'asArray' => true
  349. ) );
  350. $aItem = $accountItem->find ( array (
  351. 'asArray' => true
  352. ) );
  353. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  354. $ag = $tr = $ta = $ot= $it = 0;
  355. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  356. foreach ( $aItem as $key => $value ) {
  357. if ($value ['category'] == $this->AGENCY) {
  358. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  359. array_push ( $accountJson [$this->AGENCY], array (
  360. 'aid' => $value ['aid'],
  361. 'name' => $value ['name'],
  362. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  363. ) );
  364. $sum += $agency [$ag];
  365. $agencySum += $agency [$ag];
  366. }
  367. $ag ++;
  368. }
  369. if ($value ['category'] == $this->TRAVEL) {
  370. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  371. array_push ( $accountJson [$this->TRAVEL], array (
  372. 'aid' => $value ['aid'],
  373. 'name' => $value ['name'],
  374. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  375. ) );
  376. $sum += $travel [$tr];
  377. $travelSum += $travel [$tr];
  378. }
  379. $tr ++;
  380. }
  381. if ($value ['category'] == $this->TRAIN) {
  382. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  383. array_push ( $accountJson [$this->TRAIN], array (
  384. 'aid' => $value ['aid'],
  385. 'name' => $value ['name'],
  386. 'price' => number_format ( $train [$ta], 2, '.', '' )
  387. ) );
  388. $sum += $train [$ta];
  389. $trainSum += $train [$ta];
  390. }
  391. $ta ++;
  392. }
  393. if ($value ['category'] == $this->INTTRAIN) {
  394. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  395. array_push ( $accountJson [$this->INTTRAIN], array (
  396. 'aid' => $value ['aid'],
  397. 'name' => $value ['name'],
  398. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  399. ) );
  400. $sum += $inttrain [$it];
  401. $inttrainSum += $inttrain [$it];
  402. }
  403. $it ++;
  404. }
  405. if ($value ['category'] == $this->OTHER) {
  406. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  407. array_push ( $accountJson [$this->OTHER], array (
  408. 'aid' => $value ['aid'],
  409. 'name' => $value ['name'],
  410. 'price' => number_format ( $other [$ot], 2, '.', '' )
  411. ) );
  412. $sum += $other [$ot];
  413. $otherSum += $other [$ot];
  414. }
  415. $ot ++;
  416. }
  417. }
  418. $accountJson ['cSum'] = array (
  419. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  420. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  421. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  422. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  423. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  424. );
  425. // 报销单
  426. $receipt->accountItem = json_encode ( $accountJson );
  427. $receipt->staff = $this->staff [0] ['sid'];
  428. $receipt->sum = number_format ( $sum, 2, '.', '' );
  429. $receipt->date = date ( "Y-m-d" );
  430. $receipt->cid = $cid;
  431. $receipt->status = 5;
  432. // 修改审批流程加入角色
  433. $receipt->verify = $verify;
  434. $receipt->executeCopy = $executeDetail ['staff'];
  435. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  436. $order = array (
  437. "\r\n",
  438. "\n",
  439. "\r"
  440. );
  441. $replace = '<br/>';
  442. $explanation = str_replace ( $order, $replace, $explanation );
  443. $receipt->explanation = $explanation;
  444. $receipt->receiptClass = $receiptClass;
  445. $receipt->itinerary=$itinerary;
  446. $receipt->remittanceName = $remittanceName;
  447. $receipt->bankName = $bankName;
  448. $receipt->bankNumber = $bankNumber;
  449. $receipt->remittanceBankType = $remittanceBankType;
  450. if ($remittanceBankType == 1)
  451. $receipt->coupletNumber = $coupletNumber;
  452. $rid = $receipt->insert ();
  453. // 附件
  454. if (! empty ( $enclosurName )) {
  455. $enclosurArray = explode ( '-', $enclosurName );
  456. foreach ( $enclosurArray as $value ) {
  457. $enclosur = new enclosur ();
  458. $enclosur->name = $value;
  459. $enclosur->rid = $rid;
  460. $enclosur->insert ();
  461. }
  462. }
  463. // 报销详情
  464. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  465. $receiptDetail = new receiptDetail ();
  466. $receiptDetail->staff = $this->staff [0] ['sid'];
  467. $receiptDetail->item = $value ['name'];
  468. $receiptDetail->itemCategory = $this->AGENCY;
  469. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  470. $receiptDetail->date = date ( "Y-m-d" );
  471. $receiptDetail->cid = $cid;
  472. $receiptDetail->rid = $rid;
  473. $receiptDetail->status = 4;
  474. $receiptDetail->insert ();
  475. }
  476. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  477. $receiptDetail = new receiptDetail ();
  478. $receiptDetail->staff = $this->staff [0] ['sid'];
  479. $receiptDetail->item = $value ['name'];
  480. $receiptDetail->itemCategory = $this->TRAVEL;
  481. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  482. $receiptDetail->date = date ( "Y-m-d" );
  483. $receiptDetail->cid = $cid;
  484. $receiptDetail->rid = $rid;
  485. $receiptDetail->status = 4;
  486. $receiptDetail->insert ();
  487. }
  488. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  489. $receiptDetail = new receiptDetail ();
  490. $receiptDetail->staff = $this->staff [0] ['sid'];
  491. $receiptDetail->item = $value ['name'];
  492. $receiptDetail->itemCategory = $this->TRAIN;
  493. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  494. $receiptDetail->date = date ( "Y-m-d" );
  495. $receiptDetail->cid = $cid;
  496. $receiptDetail->rid = $rid;
  497. $receiptDetail->status = 4;
  498. $receiptDetail->insert ();
  499. }
  500. //内训
  501. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  502. $receiptDetail = new receiptDetail ();
  503. $receiptDetail->staff = $this->staff [0] ['sid'];
  504. $receiptDetail->item = $value ['name'];
  505. $receiptDetail->itemCategory = $this->INTTRAIN;
  506. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  507. $receiptDetail->date = date ( "Y-m-d" );
  508. $receiptDetail->cid = $cid;
  509. $receiptDetail->rid = $rid;
  510. $receiptDetail->status = 4;
  511. $receiptDetail->insert ();
  512. }
  513. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  514. $receiptDetail = new receiptDetail ();
  515. $receiptDetail->staff = $this->staff [0] ['sid'];
  516. $receiptDetail->item = $value ['name'];
  517. $receiptDetail->itemCategory = $this->OTHER;
  518. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  519. $receiptDetail->date = date ( "Y-m-d" );
  520. $receiptDetail->cid = $cid;
  521. $receiptDetail->rid = $rid;
  522. $receiptDetail->status = 4;
  523. $receiptDetail->insert ();
  524. }
  525. return true;
  526. } else
  527. return false;
  528. }
  529. function addReceipt() {
  530. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  531. $agency = $this->get_args ( 'agency' );
  532. $travel = $this->get_args ( 'travel' );
  533. $train = $this->get_args ( 'train' );
  534. $other = $this->get_args ( 'other' );
  535. $inttrain = $this->get_args ( 'inttrain' );
  536. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  537. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  538. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  539. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  540. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  541. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  542. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  543. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  544. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  545. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  546. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  547. header ( 'Content-Type:text/html;charset=utf-8' );
  548. die ( '请填写联行号' );
  549. }
  550. Doo::loadModel ( 'receipt' );
  551. Doo::loadModel ( 'receiptDetail' );
  552. Doo::loadModel ( 'accountItem' );
  553. $accountItem = new accountItem ();
  554. $receipt = new receipt ();
  555. Doo::loadModel ( 'enclosur' );
  556. Doo::loadModel ( 'execute' );
  557. $execute = new execute ();
  558. $executeDetail = $execute->getOne ( array (
  559. 'where' => 'mold="报销单执行人"',
  560. 'asArray' => true
  561. ) );
  562. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  563. // if(!empty($receiptDetail))
  564. // return "/referReceipt/".$receiptDetail['rid'];
  565. $aItem = $accountItem->find ( array (
  566. 'asArray' => true
  567. ) );
  568. $accountJson [$this->AGENCY]= $accountJson [$this->OTHER] = array ();
  569. $ag = $ot= 0;
  570. $sum = $agencySum = $otherSum = 0;
  571. foreach ( $aItem as $key => $value ) {
  572. if ($value ['category'] == $this->AGENCY) {
  573. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  574. array_push ( $accountJson [$this->AGENCY], array (
  575. 'aid' => $value ['aid'],
  576. 'name' => $value ['name'],
  577. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  578. ) );
  579. $sum += $agency [$ag];
  580. $agencySum += $agency [$ag];
  581. }
  582. $ag ++;
  583. }
  584. if ($value ['category'] == $this->OTHER) {
  585. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  586. array_push ( $accountJson [$this->OTHER], array (
  587. 'aid' => $value ['aid'],
  588. 'name' => $value ['name'],
  589. 'price' => number_format ( $other [$ot], 2, '.', '' )
  590. ) );
  591. $sum += $other [$ot];
  592. $otherSum += $other [$ot];
  593. }
  594. $ot ++;
  595. }
  596. }
  597. $accountJson ['cSum'] = array (
  598. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  599. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  600. );
  601. // 报销单
  602. $receipt->accountItem = json_encode ( $accountJson );
  603. $receipt->staff = $this->staff [0] ['sid'];
  604. $receipt->sum = number_format ( $sum, 2, '.', '' );
  605. $receipt->date = date ( "Y-m-d" );
  606. $receipt->cid = $cid;
  607. $receipt->status = 5;
  608. // 修改审批流程加入角色
  609. $receipt->verify = $verify;
  610. $receipt->executeCopy = $executeDetail ['staff'];
  611. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  612. $order = array (
  613. "\r\n",
  614. "\n",
  615. "\r"
  616. );
  617. $replace = '<br/>';
  618. $explanation = str_replace ( $order, $replace, $explanation );
  619. $receipt->explanation = $explanation;
  620. $receipt->receiptClass = 1;
  621. $receipt->remittanceName = $remittanceName;
  622. $receipt->bankName = $bankName;
  623. $receipt->bankNumber = $bankNumber;
  624. $receipt->remittanceBankType = $remittanceBankType;
  625. if ($remittanceBankType == 1){
  626. $receipt->coupletNumber = $coupletNumber;
  627. }
  628. $rid = $receipt->insert ();
  629. // 附件
  630. if (! empty ( $enclosurName )) {
  631. $enclosurArray = explode ( '-', $enclosurName );
  632. foreach ( $enclosurArray as $value ) {
  633. $enclosur = new enclosur ();
  634. $enclosur->name = $value;
  635. $enclosur->rid = $rid;
  636. $enclosur->insert ();
  637. }
  638. // print_r($enclosurArray);die;
  639. }
  640. // 报销详情
  641. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  642. $receiptDetail = new receiptDetail ();
  643. $receiptDetail->staff = $this->staff [0] ['sid'];
  644. $receiptDetail->item = $value ['name'];
  645. $receiptDetail->itemCategory = $this->AGENCY;
  646. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  647. $receiptDetail->date = date ( "Y-m-d" );
  648. $receiptDetail->cid = $cid;
  649. $receiptDetail->rid = $rid;
  650. $receiptDetail->status = 4;
  651. $receiptDetail->insert ();
  652. }
  653. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  654. $receiptDetail = new receiptDetail ();
  655. $receiptDetail->staff = $this->staff [0] ['sid'];
  656. $receiptDetail->item = $value ['name'];
  657. $receiptDetail->itemCategory = $this->OTHER;
  658. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  659. $receiptDetail->date = date ( "Y-m-d" );
  660. $receiptDetail->cid = $cid;
  661. $receiptDetail->rid = $rid;
  662. $receiptDetail->status = 4;
  663. $receiptDetail->insert ();
  664. }
  665. return "/saeaBorad";
  666. } else
  667. die ( 'illegal request' );
  668. }
  669. function addFeeTravel(){
  670. $travel = $this->get_args ( 'travel' );
  671. $itinerary = $this->get_args ( 'itinerary' ) ? $this->get_args ( 'itinerary' ) : "";
  672. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  673. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  674. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  675. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  676. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  677. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  678. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  679. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  680. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  681. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  682. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  683. header ( 'Content-Type:text/html;charset=utf-8' );
  684. die ( '请填写联行号' );
  685. }
  686. Doo::loadModel ( 'receipt' );
  687. Doo::loadModel ( 'receiptDetail' );
  688. Doo::loadModel ( 'accountItem' );
  689. $accountItem = new accountItem ();
  690. $receipt = new receipt ();
  691. Doo::loadModel ( 'enclosur' );
  692. Doo::loadModel ( 'execute' );
  693. $execute = new execute ();
  694. $executeDetail = $execute->getOne ( array (
  695. 'where' => 'mold="报销单执行人"',
  696. 'asArray' => true
  697. ) );
  698. $aItem = $accountItem->find ( array (
  699. 'asArray' => true
  700. ) );
  701. $accountJson [$this->TRAVEL] = array ();
  702. $tr = 0;
  703. $sum =$travelSum = 0;
  704. foreach ( $aItem as $key => $value ) {
  705. if ($value ['category'] == $this->TRAVEL) {
  706. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  707. array_push ( $accountJson [$this->TRAVEL], array (
  708. 'aid' => $value ['aid'],
  709. 'name' => $value ['name'],
  710. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  711. ) );
  712. $sum += $travel [$tr];
  713. $travelSum += $travel [$tr];
  714. }
  715. $tr ++;
  716. }
  717. }
  718. $accountJson ['cSum'] = array (
  719. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  720. );
  721. // 报销单
  722. $receipt->accountItem = json_encode ( $accountJson );
  723. $receipt->staff = $this->staff [0] ['sid'];
  724. $receipt->sum = number_format ( $sum, 2, '.', '' );
  725. $receipt->date = date ( "Y-m-d" );
  726. $receipt->cid = $cid;
  727. $receipt->status = 5;
  728. // 修改审批流程加入角色
  729. $receipt->verify = $verify;
  730. $receipt->executeCopy = $executeDetail ['staff'];
  731. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  732. $order = array (
  733. "\r\n",
  734. "\n",
  735. "\r"
  736. );
  737. $replace = '<br/>';
  738. $explanation = str_replace ( $order, $replace, $explanation );
  739. $receipt->explanation = $explanation;
  740. $receipt->remittanceName = $remittanceName;
  741. $receipt->bankName = $bankName;
  742. $receipt->bankNumber = $bankNumber;
  743. $receipt->remittanceBankType = $remittanceBankType;
  744. if ($remittanceBankType == 1)
  745. $receipt->coupletNumber = $coupletNumber;
  746. $rid = $receipt->insert ();
  747. // 附件
  748. if (! empty ( $enclosurName )) {
  749. $enclosurArray = explode ( '-', $enclosurName );
  750. foreach ( $enclosurArray as $value ) {
  751. $enclosur = new enclosur ();
  752. $enclosur->name = $value;
  753. $enclosur->rid = $rid;
  754. $enclosur->insert ();
  755. }
  756. // print_r($enclosurArray);die;
  757. }
  758. // 报销详情
  759. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  760. $receiptDetail = new receiptDetail ();
  761. $receiptDetail->staff = $this->staff [0] ['sid'];
  762. $receiptDetail->item = $value ['name'];
  763. $receiptDetail->itemCategory = $this->AGENCY;
  764. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  765. $receiptDetail->date = date ( "Y-m-d" );
  766. $receiptDetail->cid = $cid;
  767. $receiptDetail->rid = $rid;
  768. $receiptDetail->status = 4;
  769. $receiptDetail->insert ();
  770. }
  771. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  772. $receiptDetail = new receiptDetail ();
  773. $receiptDetail->staff = $this->staff [0] ['sid'];
  774. $receiptDetail->item = $value ['name'];
  775. $receiptDetail->itemCategory = $this->TRAVEL;
  776. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  777. $receiptDetail->date = date ( "Y-m-d" );
  778. $receiptDetail->cid = $cid;
  779. $receiptDetail->rid = $rid;
  780. $receiptDetail->status = 4;
  781. $receiptDetail->insert ();
  782. }
  783. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  784. $receiptDetail = new receiptDetail ();
  785. $receiptDetail->staff = $this->staff [0] ['sid'];
  786. $receiptDetail->item = $value ['name'];
  787. $receiptDetail->itemCategory = $this->TRAIN;
  788. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  789. $receiptDetail->date = date ( "Y-m-d" );
  790. $receiptDetail->cid = $cid;
  791. $receiptDetail->rid = $rid;
  792. $receiptDetail->status = 4;
  793. $receiptDetail->insert ();
  794. }
  795. //内训
  796. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  797. $receiptDetail = new receiptDetail ();
  798. $receiptDetail->staff = $this->staff [0] ['sid'];
  799. $receiptDetail->item = $value ['name'];
  800. $receiptDetail->itemCategory = $this->INTTRAIN;
  801. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  802. $receiptDetail->date = date ( "Y-m-d" );
  803. $receiptDetail->cid = $cid;
  804. $receiptDetail->rid = $rid;
  805. $receiptDetail->status = 4;
  806. $receiptDetail->insert ();
  807. }
  808. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  809. $receiptDetail = new receiptDetail ();
  810. $receiptDetail->staff = $this->staff [0] ['sid'];
  811. $receiptDetail->item = $value ['name'];
  812. $receiptDetail->itemCategory = $this->OTHER;
  813. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  814. $receiptDetail->date = date ( "Y-m-d" );
  815. $receiptDetail->cid = $cid;
  816. $receiptDetail->rid = $rid;
  817. $receiptDetail->status = 4;
  818. $receiptDetail->insert ();
  819. }
  820. return "/saeaBorad";
  821. } else
  822. die ( 'illegal request' );
  823. }
  824. function referReceipt() {
  825. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  826. Doo::loadModel ( 'receipt' );
  827. Doo::loadModel ( 'verify' );
  828. $verify = new verify ();
  829. $receipt = new receipt ();
  830. Doo::loadModel ( 'L_category' );
  831. $lCategory = new L_category ();
  832. Doo::loadModel ( "role" );
  833. $role = new role ();
  834. $receiptDetail = $receipt->find ( array (
  835. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  836. 'asArray' => true
  837. ) );
  838. if (empty ( $receiptDetail ))
  839. return "/addReceipt";
  840. foreach ( $receiptDetail as $key => $value ) {
  841. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  842. $veList = $verify->getOne ( array (
  843. 'where' => 'vid=' . $value ['verify'],
  844. 'asArray' => true
  845. ) );
  846. $v = json_decode ( $veList ['staff'] );
  847. array_push ( $v [0], $veList ['description'] );
  848. foreach ( $v as $n => $m ) {
  849. if ($m ['1'] == 'ROLE') {
  850. $roleInfo = $role->getOne ( array (
  851. 'where' => 'rid=' . $m [0],
  852. 'asArray' => true
  853. ) );
  854. $v [$n] [1] = $roleInfo ['name'];
  855. }
  856. }
  857. $receiptDetail [$key] ['staff'] = $v;
  858. $category = $lCategory->getOne ( array (
  859. 'where' => 'cid=' . $value ['cid'],
  860. 'asArray' => true
  861. ) );
  862. $receiptDetail [$key] ['category'] = $category ['title'];
  863. }
  864. // print_r($receiptDetail);
  865. $data ['receiptDetail'] = $receiptDetail;
  866. $data ['memu'] = "receipt";
  867. $data ['staff'] = $this->staff;
  868. $data ['receiptMemu'] = 'saeaCreate';
  869. $data ['verifyId'] = $this->verifyId;
  870. $data ['executeId'] = $this->executeId;
  871. $this->render ( "/admin/saea_confirm", $data );
  872. }
  873. function editReceipt() {
  874. // edit status 4
  875. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  876. Doo::loadClass ( 'XDeode' );
  877. $XDeode = new XDeode ( 7 );
  878. $rid = $XDeode->decode ( $ridKey );
  879. if (empty ( $rid ))
  880. die ( 'illegal request' );
  881. // echo $rid.'sd';
  882. Doo::loadModel ( 'accountItem' );
  883. Doo::loadModel ( 'verify' );
  884. Doo::loadModel ( 'receipt' );
  885. $receipt = new receipt ();
  886. $verify = new verify ();
  887. $accountItem = new accountItem ();
  888. Doo::loadModel ( 'L_category' );
  889. $lCategory = new L_category ();
  890. Doo::loadModel ( "role" );
  891. $role = new role ();
  892. Doo::loadModel ( 'enclosur' );
  893. $enclosur = new enclosur ();
  894. $receiptDetail = $receipt->getOne ( array (
  895. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  896. 'asArray' => true
  897. ) );
  898. if (empty ( $receiptDetail ))
  899. die ( 'illegal request' );
  900. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  901. $acItem = $accountItem->find ( array (
  902. 'asArray' => true
  903. ) );
  904. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  905. // 配置编辑信息
  906. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  907. foreach ( $acItem as $key => $value ) {
  908. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  909. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  910. $acItem [$key] ['price'] = $v ['price'];
  911. }
  912. }
  913. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  914. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  915. $acItem [$key] ['price'] = $v ['price'];
  916. }
  917. }
  918. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  919. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  920. $acItem [$key] ['price'] = $v ['price'];
  921. }
  922. }
  923. //内训
  924. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  925. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  926. $acItem [$key] ['price'] = $v ['price'];
  927. }
  928. }
  929. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  930. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  931. $acItem [$key] ['price'] = $v ['price'];
  932. }
  933. }
  934. }
  935. $data ['category'] = $lCategory->find ( array (
  936. 'asArray' => true
  937. ) );
  938. $data ['cSum'] = $accountItemList ['cSum'];
  939. $data ['sum'] = $receiptDetail ['sum'];
  940. $data ['enclosurList'] = $enclosurList;
  941. $data ['receiptDetail'] = $receiptDetail;
  942. $data ['veList'] = $veList;
  943. $data ['acItem'] = $acItem;
  944. $data ['memu'] = "receipt";
  945. $data ['staff'] = $this->staff;
  946. $data ['receiptMemu'] = 'saeaBorad';
  947. $data ['verify'] = $receiptDetail ['verify'];
  948. $data ['verifyId'] = $this->verifyId;
  949. $data ['executeId'] = $this->executeId;
  950. $data ['rid'] = $ridKey;
  951. $this->render ( "/admin/saea_edit", $data );
  952. }
  953. function updateReceipt() {
  954. $agency = $this->get_args ( 'agency' );
  955. $travel = $this->get_args ( 'travel' );
  956. $train = $this->get_args ( 'train' );
  957. $other = $this->get_args ( 'other' );
  958. $inttrain = $this->get_args ( 'inttrain' );
  959. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  960. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  961. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  962. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  963. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  964. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  965. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  966. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  967. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  968. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  969. Doo::loadClass ( 'XDeode' );
  970. $XDeode = new XDeode ( 7 );
  971. $rid = $XDeode->decode ( $ridKey );
  972. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  973. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  974. header ( 'Content-Type:text/html;charset=utf-8' );
  975. die ( '请填写联行号' );
  976. }
  977. Doo::loadModel ( 'receipt' );
  978. Doo::loadModel ( 'receiptDetail' );
  979. Doo::loadModel ( 'accountItem' );
  980. $accountItem = new accountItem ();
  981. $receipt = new receipt ();
  982. Doo::loadModel ( 'enclosur' );
  983. Doo::loadModel ( 'execute' );
  984. $execute = new execute ();
  985. $receiptDetail = $receipt->getOne ( array (
  986. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  987. 'asArray' => true
  988. ) );
  989. if (empty ( $receiptDetail ))
  990. return "/saeaBorad";
  991. if ($receiptDetail ['Rtype'] == 1)
  992. $executeDetail = $execute->getOne ( array (
  993. 'where' => 'mold="借款费用执行人"',
  994. 'asArray' => true
  995. ) );
  996. else
  997. $executeDetail = $execute->getOne ( array (
  998. 'where' => 'mold="报销单执行人"',
  999. 'asArray' => true
  1000. ) );
  1001. $aItem = $accountItem->find ( array (
  1002. 'asArray' => true
  1003. ) );
  1004. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1005. $ag = $tr = $ta = $ot = $it = 0 ;
  1006. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum = $otherSum = 0;
  1007. foreach ( $aItem as $key => $value ) {
  1008. if ($value ['category'] == $this->AGENCY) {
  1009. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1010. array_push ( $accountJson [$this->AGENCY], array (
  1011. 'aid' => $value ['aid'],
  1012. 'name' => $value ['name'],
  1013. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1014. ) );
  1015. $sum += $agency [$ag];
  1016. $agencySum += $agency [$ag];
  1017. }
  1018. $ag ++;
  1019. }
  1020. if ($value ['category'] == $this->TRAVEL) {
  1021. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1022. array_push ( $accountJson [$this->TRAVEL], array (
  1023. 'aid' => $value ['aid'],
  1024. 'name' => $value ['name'],
  1025. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1026. ) );
  1027. $sum += $travel [$tr];
  1028. $travelSum += $travel [$tr];
  1029. }
  1030. $tr ++;
  1031. }
  1032. if ($value ['category'] == $this->TRAIN) {
  1033. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1034. array_push ( $accountJson [$this->TRAIN], array (
  1035. 'aid' => $value ['aid'],
  1036. 'name' => $value ['name'],
  1037. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1038. ) );
  1039. $sum += $train [$ta];
  1040. $trainSum += $train [$ta];
  1041. }
  1042. $ta ++;
  1043. }
  1044. if ($value ['category'] == $this->INTTRAIN) {
  1045. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  1046. array_push ( $accountJson [$this->INTTRAIN], array (
  1047. 'aid' => $value ['aid'],
  1048. 'name' => $value ['name'],
  1049. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  1050. ) );
  1051. $sum += $inttrain [$it];
  1052. $inttrainSum += $inttrain [$it];
  1053. }
  1054. $it ++;
  1055. }
  1056. if ($value ['category'] == $this->OTHER) {
  1057. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1058. array_push ( $accountJson [$this->OTHER], array (
  1059. 'aid' => $value ['aid'],
  1060. 'name' => $value ['name'],
  1061. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1062. ) );
  1063. $sum += $other [$ot];
  1064. $otherSum += $other [$ot];
  1065. }
  1066. $ot ++;
  1067. }
  1068. }
  1069. $accountJson ['cSum'] = array (
  1070. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1071. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1072. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1073. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  1074. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1075. );
  1076. // 报销单
  1077. $rid = $receipt->rid = $receiptDetail ['rid'];
  1078. $receipt->accountItem = json_encode ( $accountJson );
  1079. $receipt->staff = $this->staff [0] ['sid'];
  1080. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1081. $receipt->date = date ( "Y-m-d" );
  1082. $receipt->cid = $cid;
  1083. if (($receiptDetail ['status'] != 4)) {
  1084. if ($receiptDetail ['Rtype'] == 1)
  1085. $receipt->status = 7;
  1086. else
  1087. $receipt->status = 5;
  1088. }
  1089. if ($receiptDetail != 4 && ! empty ( $verify ))
  1090. $receipt->verify = $verify;
  1091. $receipt->executeCopy = $executeDetail ['staff'];
  1092. $order = array (
  1093. "\r\n",
  1094. "\n",
  1095. "\r"
  1096. );
  1097. $replace = '<br/>';
  1098. $explanation = str_replace ( $order, $replace, $explanation );
  1099. $receipt->explanation = $explanation;
  1100. $receipt->remittanceName = $remittanceName;
  1101. $receipt->bankName = $bankName;
  1102. $receipt->bankNumber = $bankNumber;
  1103. $receipt->remittanceBankType = $remittanceBankType;
  1104. if ($remittanceBankType == 1)
  1105. $receipt->coupletNumber = $coupletNumber;
  1106. $receipt->update ();
  1107. $receiptDetail = new receiptDetail ();
  1108. $receiptDetail->delete ( array (
  1109. 'where' => 'rid=' . $rid
  1110. ) );
  1111. // 报销详情
  1112. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1113. $receiptDetail = new receiptDetail ();
  1114. $receiptDetail->staff = $this->staff [0] ['sid'];
  1115. $receiptDetail->item = $value ['name'];
  1116. $receiptDetail->itemCategory = $this->AGENCY;
  1117. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1118. $receiptDetail->date = date ( "Y-m-d" );
  1119. $receiptDetail->cid = $cid;
  1120. $receiptDetail->rid = $rid;
  1121. $receiptDetail->status = 4;
  1122. $receiptDetail->insert ();
  1123. }
  1124. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1125. $receiptDetail = new receiptDetail ();
  1126. $receiptDetail->staff = $this->staff [0] ['sid'];
  1127. $receiptDetail->item = $value ['name'];
  1128. $receiptDetail->itemCategory = $this->TRAVEL;
  1129. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1130. $receiptDetail->date = date ( "Y-m-d" );
  1131. $receiptDetail->cid = $cid;
  1132. $receiptDetail->rid = $rid;
  1133. $receiptDetail->status = 4;
  1134. $receiptDetail->insert ();
  1135. }
  1136. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1137. $receiptDetail = new receiptDetail ();
  1138. $receiptDetail->staff = $this->staff [0] ['sid'];
  1139. $receiptDetail->item = $value ['name'];
  1140. $receiptDetail->itemCategory = $this->TRAIN;
  1141. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1142. $receiptDetail->date = date ( "Y-m-d" );
  1143. $receiptDetail->cid = $cid;
  1144. $receiptDetail->rid = $rid;
  1145. $receiptDetail->status = 4;
  1146. $receiptDetail->insert ();
  1147. }
  1148. //内训
  1149. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  1150. $receiptDetail = new receiptDetail ();
  1151. $receiptDetail->staff = $this->staff [0] ['sid'];
  1152. $receiptDetail->item = $value ['name'];
  1153. $receiptDetail->itemCategory = $this->INTTRAIN;
  1154. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1155. $receiptDetail->date = date ( "Y-m-d" );
  1156. $receiptDetail->cid = $cid;
  1157. $receiptDetail->rid = $rid;
  1158. $receiptDetail->status = 4;
  1159. $receiptDetail->insert ();
  1160. }
  1161. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1162. $receiptDetail = new receiptDetail ();
  1163. $receiptDetail->staff = $this->staff [0] ['sid'];
  1164. $receiptDetail->item = $value ['name'];
  1165. $receiptDetail->itemCategory = $this->OTHER;
  1166. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1167. $receiptDetail->date = date ( "Y-m-d" );
  1168. $receiptDetail->cid = $cid;
  1169. $receiptDetail->rid = $rid;
  1170. $receiptDetail->status = 4;
  1171. $receiptDetail->insert ();
  1172. }
  1173. // 附件
  1174. if (! empty ( $enclosurName )) {
  1175. $enclosurArray = explode ( '-', $enclosurName );
  1176. foreach ( $enclosurArray as $value ) {
  1177. $enclosur = new enclosur ();
  1178. $enclosur->name = $value;
  1179. $enclosur->rid = $rid;
  1180. $enclosur->insert ();
  1181. }
  1182. }
  1183. // return "/referReceipt/".$rid;
  1184. }
  1185. return "/saeaBorad";
  1186. }
  1187. function remitAdd() {
  1188. Doo::loadModel ( 'accountItem' );
  1189. Doo::loadModel ( 'verify' );
  1190. Doo::loadModel ( 'receipt' );
  1191. Doo::loadModel ( 'L_category' );
  1192. $lCategory = new L_category ();
  1193. $receipt = new receipt ();
  1194. $verify = new verify ();
  1195. $accountItem = new accountItem ();
  1196. Doo::loadModel ( "role" );
  1197. $role = new role ();
  1198. $acItem = $accountItem->find ( array (
  1199. 'asArray' => true
  1200. ) );
  1201. $veList = $verify->getVerifyBySubordinate('REMIT');
  1202. $data ['category'] = $lCategory->find ( array (
  1203. 'asArray' => true
  1204. ) );
  1205. $data ['veList'] = $veList;
  1206. $data ['acItem'] = $acItem;
  1207. $data ['memu'] = "receipt";
  1208. $data ['staff'] = $this->staff;
  1209. $data ['receiptMemu'] = 'saeaBorad';
  1210. $data ['verifyId'] = $this->verifyId;
  1211. $data ['executeId'] = $this->executeId;
  1212. $this->render ( "/admin/remitAdd", $data );
  1213. }
  1214. function remitAddDo() {
  1215. $agency = $this->get_args ( 'agency' );
  1216. $travel = $this->get_args ( 'travel' );
  1217. $train = $this->get_args ( 'train' );
  1218. $other = $this->get_args ( 'other' );
  1219. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1220. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1221. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1222. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1223. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1224. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1225. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1226. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1227. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1228. // print_r($agency);die;
  1229. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1230. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1231. header ( 'Content-Type:text/html;charset=utf-8' );
  1232. die ( '请填写联行号' );
  1233. }
  1234. Doo::loadModel ( 'receipt' );
  1235. Doo::loadModel ( 'receiptDetail' );
  1236. Doo::loadModel ( 'accountItem' );
  1237. $accountItem = new accountItem ();
  1238. $receipt = new receipt ();
  1239. Doo::loadModel ( 'enclosur' );
  1240. Doo::loadModel ( 'execute' );
  1241. $execute = new execute ();
  1242. $executeDetail = $execute->getOne ( array (
  1243. 'where' => 'mold="对公汇款执行人"',
  1244. 'asArray' => true
  1245. ) );
  1246. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  1247. $aItem = $accountItem->find ( array (
  1248. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  1249. 'asArray' => true
  1250. ) );
  1251. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1252. $ag = $tr = $ta = $ot = 0;
  1253. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1254. print_r($aItem);
  1255. foreach ( $aItem as $key => $value ) {
  1256. if ($value ['category'] == $this->AGENCY) {
  1257. if (isset ( $agency [$ag] )) {
  1258. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1259. array_push ( $accountJson [$this->AGENCY], array (
  1260. 'aid' => $value ['aid'],
  1261. 'name' => $value ['name'],
  1262. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1263. ) );
  1264. $sum += $agency [$ag];
  1265. $agencySum += $agency [$ag];
  1266. }
  1267. }
  1268. $ag ++;
  1269. }
  1270. }
  1271. $accountJson ['cSum'] = array (
  1272. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1273. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1274. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1275. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1276. );
  1277. //die;
  1278. // 报销单
  1279. $receipt->accountItem = json_encode ( $accountJson );
  1280. $receipt->staff = $this->staff [0] ['sid'];
  1281. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1282. $receipt->date = date ( "Y-m-d" );
  1283. $receipt->cid = $cid;
  1284. $receipt->status = 5;
  1285. $receipt->Rtype = 2;
  1286. // 修改审批流程加入角色
  1287. $receipt->verify = $verify;
  1288. $receipt->executeCopy = $executeDetail ['staff'];
  1289. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1290. $order = array (
  1291. "\r\n",
  1292. "\n",
  1293. "\r"
  1294. );
  1295. $replace = '<br/>';
  1296. $explanation = str_replace ( $order, $replace, $explanation );
  1297. $receipt->explanation = $explanation;
  1298. $receipt->remittanceName = $remittanceName;
  1299. $receipt->bankName = $bankName;
  1300. $receipt->bankNumber = $bankNumber;
  1301. $receipt->remittanceBankType = $remittanceBankType;
  1302. if ($remittanceBankType == 1)
  1303. $receipt->coupletNumber = $coupletNumber;
  1304. $rid = $receipt->insert ();
  1305. // 附件
  1306. if (! empty ( $enclosurName )) {
  1307. $enclosurArray = explode ( '-', $enclosurName );
  1308. foreach ( $enclosurArray as $value ) {
  1309. $enclosur = new enclosur ();
  1310. $enclosur->name = $value;
  1311. $enclosur->rid = $rid;
  1312. $enclosur->insert ();
  1313. }
  1314. // print_r($enclosurArray);die;
  1315. }
  1316. // 报销详情
  1317. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1318. $receiptDetail = new receiptDetail ();
  1319. $receiptDetail->staff = $this->staff [0] ['sid'];
  1320. $receiptDetail->item = $value ['name'];
  1321. $receiptDetail->itemCategory = $this->AGENCY;
  1322. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1323. $receiptDetail->date = date ( "Y-m-d" );
  1324. $receiptDetail->cid = $cid;
  1325. $receiptDetail->rid = $rid;
  1326. $receiptDetail->status = 4;
  1327. $receiptDetail->insert ();
  1328. }
  1329. return "/saeaBorad";
  1330. } else
  1331. die ( 'illegal request' );
  1332. }
  1333. function remitEdit() {
  1334. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  1335. Doo::loadClass ( 'XDeode' );
  1336. $XDeode = new XDeode ( 7 );
  1337. $rid = $XDeode->decode ( $ridKey );
  1338. if (! is_numeric ( $rid ))
  1339. die ( 'illegal request' );
  1340. Doo::loadModel ( 'accountItem' );
  1341. Doo::loadModel ( 'verify' );
  1342. Doo::loadModel ( 'receipt' );
  1343. $receipt = new receipt ();
  1344. $verify = new verify ();
  1345. $accountItem = new accountItem ();
  1346. Doo::loadModel ( 'L_category' );
  1347. $lCategory = new L_category ();
  1348. Doo::loadModel ( "role" );
  1349. $role = new role ();
  1350. Doo::loadModel ( 'enclosur' );
  1351. $enclosur = new enclosur ();
  1352. $receiptDetail = $receipt->getOne ( array (
  1353. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  1354. 'asArray' => true
  1355. ) );
  1356. if (empty ( $receiptDetail ))
  1357. return "/saeaCreate";
  1358. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  1359. $acItem = $accountItem->find ( array (
  1360. 'asArray' => true
  1361. ) );
  1362. $veList = $verify->getVerifyBySubordinate('REMIT');
  1363. // 配置编辑信息
  1364. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1365. foreach ( $acItem as $key => $value ) {
  1366. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1367. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1368. $acItem [$key] ['price'] = $v ['price'];
  1369. }
  1370. }
  1371. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1372. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1373. $acItem [$key] ['price'] = $v ['price'];
  1374. }
  1375. }
  1376. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1377. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1378. $acItem [$key] ['price'] = $v ['price'];
  1379. }
  1380. }
  1381. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1382. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1383. $acItem [$key] ['price'] = $v ['price'];
  1384. }
  1385. }
  1386. }
  1387. $data ['category'] = $lCategory->find ( array (
  1388. 'asArray' => true
  1389. ) );
  1390. $data ['enclosurList'] = $enclosurList;
  1391. $data ['cSum'] = $accountItemList ['cSum'];
  1392. $data ['sum'] = $receiptDetail ['sum'];
  1393. $data ['receiptDetail'] = $receiptDetail;
  1394. $data ['veList'] = $veList;
  1395. $data ['acItem'] = $acItem;
  1396. $data ['memu'] = "receipt";
  1397. $data ['staff'] = $this->staff;
  1398. $data ['receiptMemu'] = 'saeaBorad';
  1399. $data ['verify'] = $receiptDetail ['verify'];
  1400. $data ['verifyId'] = $this->verifyId;
  1401. $data ['executeId'] = $this->executeId;
  1402. $data ['rid'] = $rid;
  1403. $data ['ridKey'] = $ridKey;
  1404. $this->render ( "/admin/remitEdit", $data );
  1405. }
  1406. function remitEdiDo() {
  1407. $agency = $this->get_args ( 'agency' );
  1408. $travel = $this->get_args ( 'travel' );
  1409. $train = $this->get_args ( 'train' );
  1410. $other = $this->get_args ( 'other' );
  1411. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1412. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1413. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1414. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1415. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1416. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1417. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1418. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1419. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1420. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1421. Doo::loadClass ( 'XDeode' );
  1422. $XDeode = new XDeode ( 7 );
  1423. $rid = $XDeode->decode ( $ridKey );
  1424. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1425. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1426. header ( 'Content-Type:text/html;charset=utf-8' );
  1427. die ( '请填写联行号' );
  1428. }
  1429. Doo::loadModel ( 'receipt' );
  1430. Doo::loadModel ( 'receiptDetail' );
  1431. Doo::loadModel ( 'accountItem' );
  1432. $accountItem = new accountItem ();
  1433. $receipt = new receipt ();
  1434. Doo::loadModel ( 'enclosur' );
  1435. $enclosur = new enclosur ();
  1436. Doo::loadModel ( 'execute' );
  1437. $execute = new execute ();
  1438. $executeDetail = $execute->getOne ( array (
  1439. 'where' => 'mold="对公汇款执行人"',
  1440. 'asArray' => true
  1441. ) );
  1442. $receiptDetail = $receipt->getOne ( array (
  1443. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  1444. 'asArray' => true
  1445. ) );
  1446. if (empty ( $receiptDetail ))
  1447. return "/saeaBorad";
  1448. $aItem = $accountItem->find ( array (
  1449. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  1450. 'asArray' => true
  1451. ) );
  1452. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1453. $ag = $tr = $ta = $ot = 0;
  1454. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1455. foreach ( $aItem as $key => $value ) {
  1456. if ($value ['category'] == $this->AGENCY) {
  1457. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1458. array_push ( $accountJson [$this->AGENCY], array (
  1459. 'aid' => $value ['aid'],
  1460. 'name' => $value ['name'],
  1461. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1462. ) );
  1463. $sum += $agency [$ag];
  1464. $agencySum += $agency [$ag];
  1465. }
  1466. $ag ++;
  1467. }
  1468. }
  1469. $accountJson ['cSum'] = array (
  1470. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1471. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1472. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1473. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1474. );
  1475. // 报销单
  1476. $rid = $receipt->rid = $receiptDetail ['rid'];
  1477. $receipt->accountItem = json_encode ( $accountJson );
  1478. $receipt->staff = $this->staff [0] ['sid'];
  1479. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1480. $receipt->date = date ( "Y-m-d" );
  1481. $receipt->cid = $cid;
  1482. if ($receiptDetail ['Rtype'] == 1)
  1483. $receipt->status = 7;
  1484. else
  1485. $receipt->status = 5;
  1486. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  1487. $receipt->verify = $verify;
  1488. $receipt->executeCopy = $executeDetail ['staff'];
  1489. $order = array (
  1490. "\r\n",
  1491. "\n",
  1492. "\r"
  1493. );
  1494. $replace = '<br/>';
  1495. $explanation = str_replace ( $order, $replace, $explanation );
  1496. $receipt->explanation = $explanation;
  1497. $receipt->remittanceName = $remittanceName;
  1498. $receipt->bankName = $bankName;
  1499. $receipt->bankNumber = $bankNumber;
  1500. $receipt->remittanceBankType = $remittanceBankType;
  1501. if ($remittanceBankType == 1)
  1502. $receipt->coupletNumber = $coupletNumber;
  1503. $receipt->update ();
  1504. $receiptDetail = new receiptDetail ();
  1505. $receiptDetail->delete ( array (
  1506. 'where' => 'rid=' . $rid
  1507. ) );
  1508. // 报销详情
  1509. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1510. $receiptDetail = new receiptDetail ();
  1511. $receiptDetail->staff = $this->staff [0] ['sid'];
  1512. $receiptDetail->item = $value ['name'];
  1513. $receiptDetail->itemCategory = $this->AGENCY;
  1514. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1515. $receiptDetail->date = date ( "Y-m-d" );
  1516. $receiptDetail->cid = $cid;
  1517. $receiptDetail->rid = $rid;
  1518. $receiptDetail->status = 4;
  1519. $receiptDetail->insert ();
  1520. }
  1521. // 附件
  1522. if (! empty ( $enclosurName )) {
  1523. $enclosurArray = explode ( '-', $enclosurName );
  1524. foreach ( $enclosurArray as $value ) {
  1525. $enclosur = new enclosur ();
  1526. $enclosur->name = $value;
  1527. $enclosur->rid = $rid;
  1528. $enclosur->insert ();
  1529. }
  1530. }
  1531. }
  1532. return "/saeaBorad";
  1533. }
  1534. function remitApproval() {
  1535. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1536. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  1537. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  1538. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  1539. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  1540. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  1541. if (empty ( $status ))
  1542. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  1543. $vidList = array ();
  1544. $button = 0;
  1545. Doo::loadModel ( 'verify' );
  1546. Doo::loadModel ( 'receipt' );
  1547. Doo::loadModel ( 'staff' );
  1548. $staff = new staff ();
  1549. $receipt = new receipt ();
  1550. $verify = new verify ();
  1551. Doo::loadModel ( 'L_category' );
  1552. $Lcategory = new L_category ();
  1553. Doo::loadModel ( 'enclosur' );
  1554. $enclosur = new enclosur ();
  1555. // user verify ID
  1556. $verifyDetail = $verify->find ( array (
  1557. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  1558. 'asArray' => true
  1559. ) );
  1560. foreach ( $verifyDetail as $key => $value ) {
  1561. array_push ( $vidList, $value ['vid'] );
  1562. }
  1563. $vid = implode ( ",", $vidList );
  1564. if (empty ( $verifyDetail ))
  1565. $vid = 0;
  1566. $categoryList = $Lcategory->find ( array (
  1567. 'asArray' => true
  1568. ) );
  1569. $staffList = $staff->find ( array (
  1570. 'where' => 'cid=' . $cid,
  1571. 'asArray' => true
  1572. ) );
  1573. $ap = "";
  1574. if ($status == 4) {
  1575. $ap = 4;
  1576. $status = 2;
  1577. }
  1578. // get Receipt By verifyID status 2
  1579. $receiptList = $receipt->find ( array (
  1580. 'where' => 'rid =' . $rid . ' and status=2',
  1581. 'desc' => 'rid',
  1582. 'asArray' => true
  1583. ) );
  1584. if (empty ( $receiptList )) {
  1585. die ( 'illegal request' );
  1586. }
  1587. $Locate = 0;
  1588. $roleId = 0;
  1589. if ($ap == 4)
  1590. $status = 4;
  1591. foreach ( $receiptList as $key => $value ) {
  1592. $receiptList [$key] ['Locate'] = $Locate;
  1593. $Locate ++;
  1594. $receiptList [$key] ['reviseDetail'] = array ();
  1595. if (! empty ( $value ['reviseDetail'] ))
  1596. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1597. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1598. $categoryDetil = $Lcategory->getOne ( array (
  1599. 'where' => 'cid=' . $value ['cid'],
  1600. 'asArray' => true
  1601. ) );
  1602. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1603. // 检测编辑状态
  1604. $verifyList = $verify->getOne ( array (
  1605. 'where' => 'vid=' . $value ['verify'],
  1606. 'asArray' => true
  1607. ) );
  1608. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1609. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1610. Doo::loadModel ( 'role' );
  1611. $role = new role ();
  1612. // print_r($verifyList);
  1613. $flag = true;
  1614. $roleKey = 0;
  1615. $endStaffArray = array ();
  1616. $roleArrayCopy = array ();
  1617. foreach ( $verifyList as $k => $v ) {
  1618. // init verifyStaff
  1619. if ($v [1] == 'ROLE') {
  1620. if (! empty ( $verifyStaff )) {
  1621. $endStaffArray = end ( $verifyStaff );
  1622. if ($v [0] == $endStaffArray ['nextStaff']) {
  1623. $roleId = $v [0];
  1624. }
  1625. }
  1626. $roleVerify = json_decode ( $v [3], true );
  1627. $roleKey = $k;
  1628. $roleArray = array ();
  1629. $rolename = $role->getOne ( array (
  1630. 'where' => 'rid=' . $v [0],
  1631. 'asArray' => true
  1632. ) );
  1633. foreach ( $roleVerify as $o => $p ) {
  1634. $staffID = explode ( '_', $p );
  1635. $staffInfo = $staff->getOne ( array (
  1636. 'where' => 'sid=' . $staffID [0],
  1637. 'asArray' => true
  1638. ) );
  1639. // print_r($staffID);
  1640. $exp = array (
  1641. 0 => $staffInfo ['sid'],
  1642. 1 => $staffID [1],
  1643. 2 => $staffInfo ['avatar'],
  1644. 'date' => '',
  1645. 'date' => '',
  1646. 'opinion' => '',
  1647. 'status' => '',
  1648. 'rolename' => $rolename ['name']
  1649. );
  1650. array_push ( $roleArray, $exp );
  1651. }
  1652. $roleArrayCopy [$v [0]] = $roleArray;
  1653. // $verifyList[$k]['roleArray']=$roleArray;
  1654. }
  1655. // print_r($roleArray);
  1656. $verifyList [$k] ['date'] = "";
  1657. $verifyList [$k] ['opinion'] = "";
  1658. $verifyList [$k] ['status'] = "";
  1659. if (empty ( $verifyStaff )) {
  1660. $verifyList [$k] ['date'] = "";
  1661. $verifyList [$k] ['opinion'] = "";
  1662. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1663. $verifyList [$k] ['status'] = 4;
  1664. $button = 4;
  1665. $flag = false;
  1666. }
  1667. } else {
  1668. foreach ( $verifyStaff as $m => $u ) {
  1669. if ($v [0] == $m) {
  1670. $verifyList [$k] ['date'] = $u ['date'];
  1671. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1672. $verifyList [$k] ['status'] = $u ['status'];
  1673. $flag = false;
  1674. break;
  1675. }
  1676. }
  1677. $endStaffArray = end ( $verifyStaff );
  1678. if (isset ( $endStaffArray ['ROLE'] )) {
  1679. } else {
  1680. $endKey = key ( $verifyStaff );
  1681. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  1682. $button = 4;
  1683. $verifyList [$k] ['status'] = 4;
  1684. }
  1685. }
  1686. }
  1687. }
  1688. $rolename ['name'] = '';
  1689. if (! empty ( $roleId )) {
  1690. Doo::loadModel ( 'role' );
  1691. $role = new role ();
  1692. $rolename = $role->getOne ( array (
  1693. 'where' => 'rid=' . $roleId,
  1694. 'asArray' => true
  1695. ) );
  1696. }
  1697. if (! empty ( $verifyStaff ))
  1698. $endStaffArray = end ( $verifyStaff );
  1699. $KOP = false;
  1700. foreach ( $roleArrayCopy as $P => $A ) {
  1701. foreach ( $A as $MKI => $AVL ) {
  1702. if (! empty ( $verifyStaff )) {
  1703. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1704. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1705. $button = 4;
  1706. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1707. }
  1708. foreach ( $verifyStaff as $m => $u ) {
  1709. $AVLFK = $AVL [0] . '_R';
  1710. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1711. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1712. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1713. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1714. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1715. break;
  1716. }
  1717. }
  1718. } else {
  1719. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1720. $button = 4;
  1721. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1722. }
  1723. }
  1724. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1725. $KOP = true;
  1726. }
  1727. }
  1728. foreach ( $roleArrayCopy as $k => $v ) {
  1729. foreach ( $verifyList as $m => $n ) {
  1730. if ($n [0] == $k) {
  1731. array_splice ( $verifyList, $m, 1, $v );
  1732. }
  1733. }
  1734. }
  1735. $receiptList [$key] ['verifyList'] = $verifyList;
  1736. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1737. 'where' => 'sid=' . $value ['staff'],
  1738. 'asArray' => true
  1739. ) );
  1740. $receiptList [$key] ['button'] = $button;
  1741. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1742. }
  1743. $mothHtml = "";
  1744. for($i = 1; $i <= 12; $i ++) {
  1745. if ($month == $i)
  1746. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  1747. else
  1748. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  1749. }
  1750. // 获取审批日志
  1751. Doo::loadModel ( 'receiptLog' );
  1752. $receiptLog = new receiptLog ();
  1753. $rlList = array ();
  1754. $rlInfo = $receiptLog->getOne ( array (
  1755. 'where' => 'rid=' . $rid . ' and status=4',
  1756. 'asArray' => true
  1757. ) );
  1758. $tijdate = $receiptLog->getOne ( array (
  1759. 'where' => 'rid=' . $rid . ' and status=2',
  1760. 'asc' => 'rlid',
  1761. 'asArray' => true
  1762. ) );
  1763. if (! empty ( $rlInfo )) {
  1764. $rlList = $receiptLog->find ( array (
  1765. 'where' => 'rid=' . $rid,
  1766. 'asc' => 'rlid',
  1767. 'asArray' => true
  1768. ) );
  1769. }
  1770. $receiptList [0] ['rlList'] = $rlList;
  1771. $enclosurList = $enclosur->find ( array (
  1772. 'where' => 'rid=' . $rid,
  1773. 'asArray' => true
  1774. ) );
  1775. $enclosurHtml = '';
  1776. foreach ( $enclosurList as $value ) {
  1777. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  1778. }
  1779. // print_r($receiptList);
  1780. $data ['enclosurHtml'] = $enclosurHtml;
  1781. $data ['rolename'] = $rolename ['name'];
  1782. $data ['datetij'] = $tijdate ['date'];
  1783. $data ['mothHtml'] = $mothHtml;
  1784. $data ['rid'] = $rid;
  1785. $data ['receiptList'] = $receiptList;
  1786. $data ['receiptApprovalCount'] = count ( $receiptList );
  1787. $data ['status'] = $status;
  1788. $data ['year'] = $year;
  1789. $data ['categoryList'] = $categoryList;
  1790. $data ['staffList'] = $staffList;
  1791. $data ['cid'] = $cid;
  1792. $data ['sid'] = $sid;
  1793. $data ['ap'] = $ap;
  1794. $data ['memu'] = "receipt";
  1795. $data ['staff'] = $this->staff;
  1796. $data ['receiptMemu'] = 'approvalExpenses';
  1797. $data ['verifyId'] = $this->verifyId;
  1798. $data ['executeId'] = $this->executeId;
  1799. $this->render ( "/admin/remitApproval", $data );
  1800. }
  1801. function saeaLoanAdd() {
  1802. Doo::loadModel ( 'verify' );
  1803. $verify = new verify ();
  1804. Doo::loadModel ( "role" );
  1805. $role = new role ();
  1806. Doo::loadModel ( 'L_category' );
  1807. $lCategory = new L_category ();
  1808. $veList = $verify->getVerifyBySubordinate('LOAN');
  1809. $data ['category'] = $lCategory->find ( array (
  1810. 'asArray' => true
  1811. ) );
  1812. $data ['veList'] = $veList;
  1813. $data ['memu'] = "receipt";
  1814. $data ['staff'] = $this->staff;
  1815. $data ['receiptMemu'] = 'saeaBorad';
  1816. $data ['verifyId'] = $this->verifyId;
  1817. $data ['executeId'] = $this->executeId;
  1818. $this->render ( "/admin/saeaLoanAdd", $data );
  1819. }
  1820. function saeaLoanAddDo() {
  1821. $agency = $this->get_args ( 'agency' );
  1822. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1823. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1824. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1825. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1826. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1827. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1828. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1829. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1830. // die;
  1831. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1832. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1833. header ( 'Content-Type:text/html;charset=utf-8' );
  1834. die ( '请填写联行号' );
  1835. }
  1836. Doo::loadModel ( 'receipt' );
  1837. Doo::loadModel ( 'receiptDetail' );
  1838. Doo::loadModel ( 'accountItem' );
  1839. $accountItem = new accountItem ();
  1840. $receipt = new receipt ();
  1841. Doo::loadModel ( 'loanReceipt' );
  1842. $loanReceipt = new loanReceipt ();
  1843. Doo::loadModel ( 'execute' );
  1844. $execute = new execute ();
  1845. Doo::loadModel ( 'enclosur' );
  1846. $executeDetail = $execute->getOne ( array (
  1847. 'where' => 'mold="借款执行人"',
  1848. 'asArray' => true
  1849. ) );
  1850. $aItem = $accountItem->find ( array (
  1851. 'asArray' => true
  1852. ) );
  1853. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1854. $ag = $tr = $ta = $ot = 0;
  1855. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1856. array_push ( $accountJson ['借款费用'], array (
  1857. 'aid' => 0,
  1858. 'name' => '申请金额',
  1859. 'price' => number_format ( $agency, 2, '.', '' )
  1860. ) );
  1861. $sum += $agency;
  1862. $agencySum += $agency;
  1863. $accountJson ['cSum'] = array (
  1864. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1865. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1866. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1867. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1868. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1869. );
  1870. // 借款数据备份
  1871. $loanReceipt->loanItem = json_encode ( $accountJson );
  1872. $loanReceipt->staff = $this->staff [0] ['sid'];
  1873. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1874. $loanReceipt->date = date ( "Y-m-d" );
  1875. $loanReceipt->cid = $cid;
  1876. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1877. $loanReceipt->status = 5;
  1878. $loanReceipt->Rtype = 1;
  1879. $loanReceipt->verify = $verify;
  1880. $receipt->receiptOrder = $receipt->receiptOrder;
  1881. // 添加HTML换行符
  1882. // var_dump($explanation);
  1883. $order = array (
  1884. "\r\n",
  1885. "\n",
  1886. "\r"
  1887. );
  1888. $replace = '<br/>';
  1889. $explanation = str_replace ( $order, $replace, $explanation );
  1890. // $explanation=str_replace('\r',"<br/>",$explanation);
  1891. // $explanation=str_replace('\r\n',"<br/>",$explanation);
  1892. $loanReceipt->explanation = $explanation;
  1893. $loanRid = $loanReceipt->insert ();
  1894. // 报销单
  1895. $receipt->loanItem = json_encode ( $accountJson );
  1896. $receipt->staff = $this->staff [0] ['sid'];
  1897. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1898. $receipt->date = date ( "Y-m-d" );
  1899. $receipt->cid = $cid;
  1900. // 特殊状态
  1901. $receipt->status = 5;
  1902. $receipt->Rtype = 1;
  1903. $receipt->loanRid = $loanRid;
  1904. // 修改审批流程加入角色
  1905. $receipt->verify = $verify;
  1906. $receipt->executeCopy = $executeDetail ['staff'];
  1907. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  1908. $receipt->explanation = $explanation;
  1909. $receipt->remittanceName = $remittanceName;
  1910. $receipt->bankName = $bankName;
  1911. $receipt->bankNumber = $bankNumber;
  1912. $receipt->remittanceBankType = $remittanceBankType;
  1913. if ($remittanceBankType == 1)
  1914. $receipt->coupletNumber = $coupletNumber;
  1915. $rid = $receipt->insert ();
  1916. return "/saeaBorad";
  1917. } else
  1918. die ( 'illegal request' );
  1919. }
  1920. function saeaLoanEdi() {
  1921. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1922. Doo::loadClass ( 'XDeode' );
  1923. $XDeode = new XDeode ( 7 );
  1924. $rid = $XDeode->decode ( $ridKey );
  1925. if (! is_numeric ( $rid ))
  1926. die ( 'illegal request' );
  1927. Doo::loadModel ( 'verify' );
  1928. $verify = new verify ();
  1929. Doo::loadModel ( "role" );
  1930. $role = new role ();
  1931. Doo::loadModel ( 'L_category' );
  1932. $lCategory = new L_category ();
  1933. Doo::loadModel ( 'receipt' );
  1934. $receipt = new receipt ();
  1935. $receiptInfo = $receipt->getOne ( array (
  1936. 'where' => 'rid=' . $rid,
  1937. 'asArray' => true
  1938. ) );
  1939. $veList = $verify->find ( array (
  1940. 'where'=>'subordinate like "%LOAN%"',
  1941. 'asArray' => true
  1942. ) );
  1943. foreach ( $veList as $key => $value ) {
  1944. $v = json_decode ( $value ['staff'] );
  1945. $list = array ();
  1946. foreach ( $v as $n => $m ) {
  1947. if ($m ['1'] == 'ROLE') {
  1948. $roleInfo = $role->getOne ( array (
  1949. 'where' => 'rid=' . $m [0],
  1950. 'asArray' => true
  1951. ) );
  1952. $v [$n] [1] = $roleInfo ['name'];
  1953. array_push ( $list, $roleInfo ['name'] );
  1954. } else {
  1955. array_push ( $list, $v [$n] [1] );
  1956. }
  1957. }
  1958. $veList [$key] ['staff'] = implode ( '>', $list );
  1959. }
  1960. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  1961. // print_r($receiptInfo);
  1962. $data ['receiptInfo'] = $receiptInfo;
  1963. $data ['category'] = $lCategory->find ( array (
  1964. 'asArray' => true
  1965. ) );
  1966. $data ['veList'] = $veList;
  1967. $data ['ridKey'] = $ridKey;
  1968. $data ['memu'] = "receipt";
  1969. $data ['staff'] = $this->staff;
  1970. $data ['receiptMemu'] = 'saeaBorad';
  1971. $data ['verifyId'] = $this->verifyId;
  1972. $data ['executeId'] = $this->executeId;
  1973. $this->render ( "/admin/saeaLoanEdi", $data );
  1974. }
  1975. function saeaLoanEdiDo() {
  1976. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1977. $agency = $this->get_args ( 'agency' );
  1978. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1979. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1980. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1981. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1982. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1983. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1984. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1985. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1986. // die;
  1987. Doo::loadClass ( 'XDeode' );
  1988. $XDeode = new XDeode ( 7 );
  1989. $rid = $XDeode->decode ( $ridKey );
  1990. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1991. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1992. header ( 'Content-Type:text/html;charset=utf-8' );
  1993. die ( '请填写联行号' );
  1994. }
  1995. Doo::loadModel ( 'receipt' );
  1996. Doo::loadModel ( 'receiptDetail' );
  1997. Doo::loadModel ( 'accountItem' );
  1998. $accountItem = new accountItem ();
  1999. $receipt = new receipt ();
  2000. Doo::loadModel ( 'loanReceipt' );
  2001. $loanReceipt = new loanReceipt ();
  2002. Doo::loadModel ( 'enclosur' );
  2003. Doo::loadModel ( 'execute' );
  2004. $execute = new execute ();
  2005. $executeDetail = $execute->getOne ( array (
  2006. 'where' => 'mold="借款执行人"',
  2007. 'asArray' => true
  2008. ) );
  2009. $receiptDetail = $receipt->getOne ( array (
  2010. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  2011. 'asArray' => true
  2012. ) );
  2013. if (empty ( $receiptDetail ))
  2014. die ( '参数错误' );
  2015. $aItem = $accountItem->find ( array (
  2016. 'asArray' => true
  2017. ) );
  2018. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  2019. $ag = $tr = $ta = $ot = 0;
  2020. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  2021. array_push ( $accountJson ['借款费用'], array (
  2022. 'aid' => 0,
  2023. 'name' => '申请金额',
  2024. 'price' => number_format ( $agency, 2, '.', '' )
  2025. ) );
  2026. $sum += $agency;
  2027. $agencySum += $agency;
  2028. $accountJson ['cSum'] = array (
  2029. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  2030. 'agencySum' => number_format ( 0, 2, '.', '' ),
  2031. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  2032. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  2033. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  2034. );
  2035. // 报销单
  2036. $receipt->loanItem = json_encode ( $accountJson );
  2037. $receipt->sum = number_format ( $sum, 2, '.', '' );
  2038. $receipt->cid = $cid;
  2039. // 特殊状态
  2040. // 修改审批流程加入角色
  2041. if ($receiptDetail ['status'] != 4)
  2042. $receipt->verify = $verify;
  2043. $order = array (
  2044. "\r\n",
  2045. "\n",
  2046. "\r"
  2047. );
  2048. $replace = '<br/>';
  2049. $explanation = str_replace ( $order, $replace, $explanation );
  2050. $receipt->explanation = $explanation;
  2051. $receipt->remittanceName = $remittanceName;
  2052. $receipt->bankName = $bankName;
  2053. $receipt->bankNumber = $bankNumber;
  2054. $receipt->remittanceBankType = $remittanceBankType;
  2055. if ($remittanceBankType == 1)
  2056. $receipt->coupletNumber = $coupletNumber;
  2057. $receipt->update ( array (
  2058. 'where' => 'rid=' . $rid
  2059. ) );
  2060. // 借款数据更新
  2061. $loanReceipt->loanItem = json_encode ( $accountJson );
  2062. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  2063. $loanReceipt->cid = $cid;
  2064. if ($receiptDetail ['status'] != 4)
  2065. $loanReceipt->verify = $verify;
  2066. $loanReceipt->explanation = $explanation;
  2067. $receipt->executeCopy = $executeDetail ['staff'];
  2068. $loanReceipt->update ( array (
  2069. 'where' => 'rid=' . $receiptDetail ['loanRid']
  2070. ) );
  2071. }
  2072. return "/saeaBorad";
  2073. }
  2074. function saeaLoanReceiptAdd() {
  2075. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2076. Doo::loadModel ( 'receipt' );
  2077. $receipt = new receipt ();
  2078. Doo::loadModel ( 'loanReceipt' );
  2079. $loanReceipt = new loanReceipt ();
  2080. Doo::loadModel ( 'L_category' );
  2081. $Lcategory = new L_category ();
  2082. Doo::loadModel ( 'verify' );
  2083. Doo::loadModel ( 'statistics' );
  2084. $statistics = new statistics ();
  2085. $verify = new verify ();
  2086. Doo::loadModel ( 'staff' );
  2087. $staff = new staff ();
  2088. $receiptDetail = $receipt->getOne ( array (
  2089. 'where' => 'rid=' . $rid,
  2090. 'desc' => 'rid',
  2091. 'asArray' => true
  2092. ) );
  2093. $receiptList = $loanReceipt->find ( array (
  2094. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  2095. 'desc' => 'rid',
  2096. 'asArray' => true
  2097. ) );
  2098. $Locate = 0;
  2099. $roleId = 0;
  2100. $button = 0;
  2101. foreach ( $receiptList as $key => $value ) {
  2102. $receiptList [$key] ['Locate'] = $Locate;
  2103. $Locate ++;
  2104. $receiptList [$key] ['reviseDetail'] = array ();
  2105. if (! empty ( $value ['reviseDetail'] ))
  2106. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2107. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2108. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2109. $categoryDetil = $Lcategory->getOne ( array (
  2110. 'where' => 'cid=' . $value ['cid'],
  2111. 'asArray' => true
  2112. ) );
  2113. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2114. // 检测编辑状态
  2115. $verifyList = $verify->getOne ( array (
  2116. 'where' => 'vid=' . $value ['verify'],
  2117. 'asArray' => true
  2118. ) );
  2119. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2120. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2121. Doo::loadModel ( 'role' );
  2122. $role = new role ();
  2123. $flag = true;
  2124. $roleKey = 0;
  2125. $endStaffArray = array ();
  2126. $roleArrayCopy = array ();
  2127. foreach ( $verifyList as $k => $v ) {
  2128. // init verifyStaff
  2129. if ($v [1] == 'ROLE') {
  2130. if (! empty ( $verifyStaff )) {
  2131. $endStaffArray = end ( $verifyStaff );
  2132. // if ($v[0]==$endStaffArray['nextStaff']){
  2133. // $roleId=$v[0];
  2134. // }
  2135. }
  2136. $roleVerify = json_decode ( $v [3], true );
  2137. $roleKey = $k;
  2138. $roleArray = array ();
  2139. $rolename = $role->getOne ( array (
  2140. 'where' => 'rid=' . $v [0],
  2141. 'asArray' => true
  2142. ) );
  2143. foreach ( $roleVerify as $o => $p ) {
  2144. $staffID = explode ( '_', $p );
  2145. $staffInfo = $staff->getOne ( array (
  2146. 'where' => 'sid=' . $staffID [0],
  2147. 'asArray' => true
  2148. ) );
  2149. // print_r($staffID);
  2150. $exp = array (
  2151. 0 => $staffInfo ['sid'],
  2152. 1 => $staffID [1],
  2153. 2 => $staffInfo ['avatar'],
  2154. 'date' => '',
  2155. 'date' => '',
  2156. 'opinion' => '',
  2157. 'status' => '',
  2158. 'rolename' => $rolename ['name']
  2159. );
  2160. array_push ( $roleArray, $exp );
  2161. }
  2162. $roleArrayCopy [$v [0]] = $roleArray;
  2163. // $verifyList[$k]['roleArray']=$roleArray;
  2164. }
  2165. $verifyList [$k] ['date'] = "";
  2166. $verifyList [$k] ['opinion'] = "";
  2167. $verifyList [$k] ['status'] = "";
  2168. if (empty ( $verifyStaff )) {
  2169. $verifyList [$k] ['date'] = "";
  2170. $verifyList [$k] ['opinion'] = "";
  2171. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2172. $verifyList [$k] ['status'] = 4;
  2173. $flag = false;
  2174. }
  2175. } else {
  2176. foreach ( $verifyStaff as $m => $u ) {
  2177. if ($v [0] == $m) {
  2178. $verifyList [$k] ['date'] = $u ['date'];
  2179. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2180. $verifyList [$k] ['status'] = $u ['status'];
  2181. $flag = false;
  2182. break;
  2183. }
  2184. }
  2185. $endStaffArray = end ( $verifyStaff );
  2186. if (isset ( $endStaffArray ['ROLE'] )) {
  2187. } else {
  2188. // $endKey=key($verifyStaff);
  2189. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2190. // $button=4;
  2191. // $verifyList[$k]['status']=4;
  2192. // }
  2193. }
  2194. }
  2195. }
  2196. $rolename ['name'] = '';
  2197. if (! empty ( $roleId )) {
  2198. Doo::loadModel ( 'role' );
  2199. $role = new role ();
  2200. $rolename = $role->getOne ( array (
  2201. 'where' => 'rid=' . $roleId,
  2202. 'asArray' => true
  2203. ) );
  2204. }
  2205. if (! empty ( $verifyStaff ))
  2206. $endStaffArray = end ( $verifyStaff );
  2207. $KOP = false;
  2208. foreach ( $roleArrayCopy as $P => $A ) {
  2209. foreach ( $A as $MKI => $AVL ) {
  2210. if (! empty ( $verifyStaff )) {
  2211. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2212. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2213. $button = 4;
  2214. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2215. }
  2216. foreach ( $verifyStaff as $m => $u ) {
  2217. $AVLFK = $AVL [0] . '_R';
  2218. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2219. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2220. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2221. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2222. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2223. break;
  2224. }
  2225. }
  2226. } else {
  2227. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2228. $button = 4;
  2229. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2230. }
  2231. }
  2232. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2233. $KOP = true;
  2234. }
  2235. }
  2236. foreach ( $roleArrayCopy as $k => $v ) {
  2237. foreach ( $verifyList as $m => $n ) {
  2238. if ($n [0] == $k) {
  2239. array_splice ( $verifyList, $m, 1, $v );
  2240. }
  2241. }
  2242. }
  2243. $receiptList [$key] ['verifyList'] = $verifyList;
  2244. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2245. 'where' => 'sid=' . $value ['staff'],
  2246. 'asArray' => true
  2247. ) );
  2248. $receiptList [$key] ['button'] = $button;
  2249. //
  2250. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  2251. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  2252. }
  2253. $data ['receiptList'] = $receiptList;
  2254. $data ['receiptDetail'] = $receiptDetail;
  2255. Doo::loadModel ( 'L_category' );
  2256. $lCategory = new L_category ();
  2257. Doo::loadModel ( 'accountItem' );
  2258. $accountItem = new accountItem ();
  2259. $acItem = $accountItem->find ( array (
  2260. 'asArray' => true
  2261. ) );
  2262. $veList = $verify->getVerifyBySubordinate('RECEIPT','LOAN');
  2263. $data ['rid'] = $rid;
  2264. $data ['category'] = $lCategory->find ( array (
  2265. 'asArray' => true
  2266. ) );
  2267. $data ['veList'] = $veList;
  2268. $data ['acItem'] = $acItem;
  2269. $data ['memu'] = "receipt";
  2270. $data ['staff'] = $this->staff;
  2271. $data ['receiptMemu'] = 'saeaBorad';
  2272. $data ['verifyId'] = $this->verifyId;
  2273. $data ['executeId'] = $this->executeId;
  2274. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  2275. }
  2276. function saeaLoanReceiptAddDo() {
  2277. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  2278. $agency = $this->get_args ( 'agency' );
  2279. $travel = $this->get_args ( 'travel' );
  2280. $train = $this->get_args ( 'train' );
  2281. $other = $this->get_args ( 'other' );
  2282. $inttrain = $this->get_args ( 'inttrain' );
  2283. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2284. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  2285. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  2286. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  2287. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2288. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2289. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2290. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2291. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2292. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  2293. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2294. header ( 'Content-Type:text/html;charset=utf-8' );
  2295. die ( '请填写联行号' );
  2296. }
  2297. Doo::loadModel ( 'receipt' );
  2298. Doo::loadModel ( 'receiptDetail' );
  2299. Doo::loadModel ( 'accountItem' );
  2300. $accountItem = new accountItem ();
  2301. $receipt = new receipt ();
  2302. Doo::loadModel ( 'enclosur' );
  2303. Doo::loadModel ( 'execute' );
  2304. $execute = new execute ();
  2305. $executeDetail = $execute->getOne ( array (
  2306. 'where' => 'mold="借款费用执行人"',
  2307. 'asArray' => true
  2308. ) );
  2309. $receiptDet = $receipt->getOne ( array (
  2310. 'where' => 'rid=' . $rid,
  2311. 'asArray' => true
  2312. ) );
  2313. // if(!empty($receiptDetail))
  2314. // return "/referReceipt/".$receiptDetail['rid'];
  2315. $aItem = $accountItem->find ( array (
  2316. 'asArray' => true
  2317. ) );
  2318. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  2319. $ag = $tr = $ta = $ot =$it = 0;
  2320. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  2321. foreach ( $aItem as $key => $value ) {
  2322. if ($value ['category'] == $this->AGENCY) {
  2323. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  2324. array_push ( $accountJson [$this->AGENCY], array (
  2325. 'aid' => $value ['aid'],
  2326. 'name' => $value ['name'],
  2327. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  2328. ) );
  2329. $sum += $agency [$ag];
  2330. $agencySum += $agency [$ag];
  2331. }
  2332. $ag ++;
  2333. }
  2334. if ($value ['category'] == $this->TRAVEL) {
  2335. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  2336. array_push ( $accountJson [$this->TRAVEL], array (
  2337. 'aid' => $value ['aid'],
  2338. 'name' => $value ['name'],
  2339. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  2340. ) );
  2341. $sum += $travel [$tr];
  2342. $travelSum += $travel [$tr];
  2343. }
  2344. $tr ++;
  2345. }
  2346. if ($value ['category'] == $this->INTTRAIN) {
  2347. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  2348. array_push ( $accountJson [$this->INTTRAIN], array (
  2349. 'aid' => $value ['aid'],
  2350. 'name' => $value ['name'],
  2351. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  2352. ) );
  2353. $sum += $inttrain [$it];
  2354. $inttrainSum += $inttrain [$it];
  2355. }
  2356. $it ++;
  2357. }
  2358. if ($value ['category'] == $this->TRAIN) {
  2359. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  2360. array_push ( $accountJson [$this->TRAIN], array (
  2361. 'aid' => $value ['aid'],
  2362. 'name' => $value ['name'],
  2363. 'price' => number_format ( $train [$ta], 2, '.', '' )
  2364. ) );
  2365. $sum += $train [$ta];
  2366. $trainSum += $train [$ta];
  2367. }
  2368. $ta ++;
  2369. }
  2370. if ($value ['category'] == $this->OTHER) {
  2371. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  2372. array_push ( $accountJson [$this->OTHER], array (
  2373. 'aid' => $value ['aid'],
  2374. 'name' => $value ['name'],
  2375. 'price' => number_format ( $other [$ot], 2, '.', '' )
  2376. ) );
  2377. $sum += $other [$ot];
  2378. $otherSum += $other [$ot];
  2379. }
  2380. $ot ++;
  2381. }
  2382. }
  2383. $accountJson ['cSum'] = array (
  2384. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  2385. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  2386. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  2387. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  2388. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  2389. );
  2390. // 报销单
  2391. $receipt->accountItem = json_encode ( $accountJson );
  2392. $receipt->staff = $this->staff [0] ['sid'];
  2393. $receipt->loanSum = $receiptDet ['sum'];
  2394. $receipt->sum = number_format ( $sum, 2, '.', '' );
  2395. $receipt->date = date ( "Y-m-d" );
  2396. $receipt->pastDate = '';
  2397. $receipt->cid = $cid;
  2398. $receipt->status = 7;
  2399. // 修改审批流程加入角色
  2400. $receipt->verify = $verify;
  2401. $receipt->verifyStaff = '';
  2402. $receipt->executeStaff = '';
  2403. $receipt->executeCopy = $executeDetail ['staff'];
  2404. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  2405. $receipt->explanation = $explanation;
  2406. $receipt->remittanceName = $remittanceName;
  2407. $receipt->bankName = $bankName;
  2408. $receipt->bankNumber = $bankNumber;
  2409. $receipt->remittanceBankType = $remittanceBankType;
  2410. if ($remittanceBankType == 1)
  2411. $receipt->coupletNumber = $coupletNumber;
  2412. $receipt->update ( array (
  2413. 'where' => 'rid=' . $rid
  2414. ) );
  2415. // 附件
  2416. if (! empty ( $enclosurName )) {
  2417. $enclosurArray = explode ( '-', $enclosurName );
  2418. foreach ( $enclosurArray as $value ) {
  2419. $enclosur = new enclosur ();
  2420. $enclosur->name = $value;
  2421. $enclosur->rid = $rid;
  2422. $enclosur->insert ();
  2423. }
  2424. // print_r($enclosurArray);die;
  2425. }
  2426. // 报销详情
  2427. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  2428. $receiptDetail = new receiptDetail ();
  2429. $receiptDetail->staff = $this->staff [0] ['sid'];
  2430. $receiptDetail->item = $value ['name'];
  2431. $receiptDetail->itemCategory = $this->AGENCY;
  2432. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2433. $receiptDetail->date = date ( "Y-m-d" );
  2434. $receiptDetail->cid = $cid;
  2435. $receiptDetail->rid = $rid;
  2436. $receiptDetail->status = 4;
  2437. $receiptDetail->insert ();
  2438. }
  2439. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  2440. $receiptDetail = new receiptDetail ();
  2441. $receiptDetail->staff = $this->staff [0] ['sid'];
  2442. $receiptDetail->item = $value ['name'];
  2443. $receiptDetail->itemCategory = $this->TRAVEL;
  2444. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2445. $receiptDetail->date = date ( "Y-m-d" );
  2446. $receiptDetail->cid = $cid;
  2447. $receiptDetail->rid = $rid;
  2448. $receiptDetail->status = 4;
  2449. $receiptDetail->insert ();
  2450. }
  2451. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  2452. $receiptDetail = new receiptDetail ();
  2453. $receiptDetail->staff = $this->staff [0] ['sid'];
  2454. $receiptDetail->item = $value ['name'];
  2455. $receiptDetail->itemCategory = $this->TRAIN;
  2456. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2457. $receiptDetail->date = date ( "Y-m-d" );
  2458. $receiptDetail->cid = $cid;
  2459. $receiptDetail->rid = $rid;
  2460. $receiptDetail->status = 4;
  2461. $receiptDetail->insert ();
  2462. }
  2463. //内训
  2464. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  2465. $receiptDetail = new receiptDetail ();
  2466. $receiptDetail->staff = $this->staff [0] ['sid'];
  2467. $receiptDetail->item = $value ['name'];
  2468. $receiptDetail->itemCategory = $this->INTTRAIN;
  2469. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2470. $receiptDetail->date = date ( "Y-m-d" );
  2471. $receiptDetail->cid = $cid;
  2472. $receiptDetail->rid = $rid;
  2473. $receiptDetail->status = 4;
  2474. $receiptDetail->insert ();
  2475. }
  2476. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  2477. $receiptDetail = new receiptDetail ();
  2478. $receiptDetail->staff = $this->staff [0] ['sid'];
  2479. $receiptDetail->item = $value ['name'];
  2480. $receiptDetail->itemCategory = $this->OTHER;
  2481. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2482. $receiptDetail->date = date ( "Y-m-d" );
  2483. $receiptDetail->cid = $cid;
  2484. $receiptDetail->rid = $rid;
  2485. $receiptDetail->status = 4;
  2486. $receiptDetail->insert ();
  2487. }
  2488. return "/saeaBorad";
  2489. }
  2490. return "/saeaLoanReceiptAdd/" . $rid;
  2491. }
  2492. function saeaLoanReceiptEdi() {
  2493. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2494. Doo::loadClass ( 'XDeode' );
  2495. $XDeode = new XDeode ( 7 );
  2496. $rid = $XDeode->decode ( $ridKey );
  2497. if (! is_numeric ( $rid ))
  2498. die ( 'illegal request' );
  2499. Doo::loadModel ( 'accountItem' );
  2500. Doo::loadModel ( 'verify' );
  2501. Doo::loadModel ( 'receipt' );
  2502. $receipt = new receipt ();
  2503. $verify = new verify ();
  2504. $accountItem = new accountItem ();
  2505. Doo::loadModel ( 'L_category' );
  2506. $Lcategory = new L_category ();
  2507. Doo::loadModel ( "role" );
  2508. $role = new role ();
  2509. Doo::loadModel ( 'loanReceipt' );
  2510. $loanReceipt = new loanReceipt ();
  2511. Doo::loadModel ( 'staff' );
  2512. $staff = new staff ();
  2513. $receiptDetail = $receipt->getOne ( array (
  2514. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  2515. 'asArray' => true
  2516. ) );
  2517. if (empty ( $receiptDetail ))
  2518. return "/saeaBorad";
  2519. $receiptList = $loanReceipt->find ( array (
  2520. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  2521. 'desc' => 'rid',
  2522. 'asArray' => true
  2523. ) );
  2524. $Locate = 0;
  2525. $roleId = 0;
  2526. $button = 0;
  2527. foreach ( $receiptList as $key => $value ) {
  2528. $receiptList [$key] ['Locate'] = $Locate;
  2529. $Locate ++;
  2530. $receiptList [$key] ['reviseDetail'] = array ();
  2531. if (! empty ( $value ['reviseDetail'] ))
  2532. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2533. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2534. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2535. $categoryDetil = $Lcategory->getOne ( array (
  2536. 'where' => 'cid=' . $value ['cid'],
  2537. 'asArray' => true
  2538. ) );
  2539. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2540. // 检测编辑状态
  2541. $verifyList = $verify->getOne ( array (
  2542. 'where' => 'vid=' . $value ['verify'],
  2543. 'asArray' => true
  2544. ) );
  2545. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2546. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2547. Doo::loadModel ( 'role' );
  2548. $role = new role ();
  2549. $flag = true;
  2550. $roleKey = 0;
  2551. $endStaffArray = array ();
  2552. $roleArrayCopy = array ();
  2553. foreach ( $verifyList as $k => $v ) {
  2554. // init verifyStaff
  2555. if ($v [1] == 'ROLE') {
  2556. if (! empty ( $verifyStaff )) {
  2557. $endStaffArray = end ( $verifyStaff );
  2558. // if ($v[0]==$endStaffArray['nextStaff']){
  2559. // $roleId=$v[0];
  2560. // }
  2561. }
  2562. $roleVerify = json_decode ( $v [3], true );
  2563. $roleKey = $k;
  2564. $roleArray = array ();
  2565. $rolename = $role->getOne ( array (
  2566. 'where' => 'rid=' . $v [0],
  2567. 'asArray' => true
  2568. ) );
  2569. foreach ( $roleVerify as $o => $p ) {
  2570. $staffID = explode ( '_', $p );
  2571. $staffInfo = $staff->getOne ( array (
  2572. 'where' => 'sid=' . $staffID [0],
  2573. 'asArray' => true
  2574. ) );
  2575. // print_r($staffID);
  2576. $exp = array (
  2577. 0 => $staffInfo ['sid'],
  2578. 1 => $staffID [1],
  2579. 2 => $staffInfo ['avatar'],
  2580. 'date' => '',
  2581. 'date' => '',
  2582. 'opinion' => '',
  2583. 'status' => '',
  2584. 'rolename' => $rolename ['name']
  2585. );
  2586. array_push ( $roleArray, $exp );
  2587. }
  2588. $roleArrayCopy [$v [0]] = $roleArray;
  2589. // $verifyList[$k]['roleArray']=$roleArray;
  2590. }
  2591. $verifyList [$k] ['date'] = "";
  2592. $verifyList [$k] ['opinion'] = "";
  2593. $verifyList [$k] ['status'] = "";
  2594. if (empty ( $verifyStaff )) {
  2595. $verifyList [$k] ['date'] = "";
  2596. $verifyList [$k] ['opinion'] = "";
  2597. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2598. $verifyList [$k] ['status'] = 4;
  2599. $flag = false;
  2600. }
  2601. } else {
  2602. foreach ( $verifyStaff as $m => $u ) {
  2603. if ($v [0] == $m) {
  2604. $verifyList [$k] ['date'] = $u ['date'];
  2605. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2606. $verifyList [$k] ['status'] = $u ['status'];
  2607. $flag = false;
  2608. break;
  2609. }
  2610. }
  2611. $endStaffArray = end ( $verifyStaff );
  2612. if (isset ( $endStaffArray ['ROLE'] )) {
  2613. } else {
  2614. // $endKey=key($verifyStaff);
  2615. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2616. // $button=4;
  2617. // $verifyList[$k]['status']=4;
  2618. // }
  2619. }
  2620. }
  2621. }
  2622. $rolename ['name'] = '';
  2623. if (! empty ( $roleId )) {
  2624. Doo::loadModel ( 'role' );
  2625. $role = new role ();
  2626. $rolename = $role->getOne ( array (
  2627. 'where' => 'rid=' . $roleId,
  2628. 'asArray' => true
  2629. ) );
  2630. }
  2631. if (! empty ( $verifyStaff ))
  2632. $endStaffArray = end ( $verifyStaff );
  2633. $KOP = false;
  2634. foreach ( $roleArrayCopy as $P => $A ) {
  2635. foreach ( $A as $MKI => $AVL ) {
  2636. if (! empty ( $verifyStaff )) {
  2637. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2638. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2639. $button = 4;
  2640. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2641. }
  2642. foreach ( $verifyStaff as $m => $u ) {
  2643. $AVLFK = $AVL [0] . '_R';
  2644. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2645. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2646. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2647. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2648. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2649. break;
  2650. }
  2651. }
  2652. } else {
  2653. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2654. $button = 4;
  2655. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2656. }
  2657. }
  2658. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2659. $KOP = true;
  2660. }
  2661. }
  2662. foreach ( $roleArrayCopy as $k => $v ) {
  2663. foreach ( $verifyList as $m => $n ) {
  2664. if ($n [0] == $k) {
  2665. array_splice ( $verifyList, $m, 1, $v );
  2666. }
  2667. }
  2668. }
  2669. $receiptList [$key] ['verifyList'] = $verifyList;
  2670. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2671. 'where' => 'sid=' . $value ['staff'],
  2672. 'asArray' => true
  2673. ) );
  2674. $receiptList [$key] ['button'] = $button;
  2675. //
  2676. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  2677. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  2678. }
  2679. $data ['receiptList'] = $receiptList;
  2680. $acItem = $accountItem->find ( array (
  2681. 'asArray' => true
  2682. ) );
  2683. $veList = $verify->find ( array (
  2684. 'asArray' => true
  2685. ) );
  2686. foreach ( $veList as $key => $value ) {
  2687. $v = json_decode ( $value ['staff'] );
  2688. $list = array ();
  2689. foreach ( $v as $n => $m ) {
  2690. if ($m ['1'] == 'ROLE') {
  2691. $roleInfo = $role->getOne ( array (
  2692. 'where' => 'rid=' . $m [0],
  2693. 'asArray' => true
  2694. ) );
  2695. $v [$n] [1] = $roleInfo ['name'];
  2696. array_push ( $list, $roleInfo ['name'] );
  2697. } else {
  2698. array_push ( $list, $v [$n] [1] );
  2699. }
  2700. }
  2701. $veList [$key] ['staff'] = implode ( '>', $list );
  2702. }
  2703. // 配置编辑信息
  2704. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  2705. foreach ( $acItem as $key => $value ) {
  2706. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  2707. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  2708. $acItem [$key] ['price'] = $v ['price'];
  2709. }
  2710. }
  2711. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  2712. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  2713. $acItem [$key] ['price'] = $v ['price'];
  2714. }
  2715. }
  2716. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  2717. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  2718. $acItem [$key] ['price'] = $v ['price'];
  2719. }
  2720. }
  2721. //内训
  2722. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  2723. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  2724. $acItem [$key] ['price'] = $v ['price'];
  2725. }
  2726. }
  2727. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  2728. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  2729. $acItem [$key] ['price'] = $v ['price'];
  2730. }
  2731. }
  2732. }
  2733. $data ['category'] = $Lcategory->find ( array (
  2734. 'asArray' => true
  2735. ) );
  2736. $data ['ridKey'] = $ridKey;
  2737. $data ['cSum'] = $accountItemList ['cSum'];
  2738. $data ['sum'] = $receiptDetail ['sum'];
  2739. $data ['receiptDetail'] = $receiptDetail;
  2740. $data ['veList'] = $veList;
  2741. $data ['acItem'] = $acItem;
  2742. $data ['memu'] = "receipt";
  2743. $data ['staff'] = $this->staff;
  2744. $data ['receiptMemu'] = 'saeaBorad';
  2745. $data ['verify'] = $receiptDetail ['verify'];
  2746. $data ['verifyId'] = $this->verifyId;
  2747. $data ['executeId'] = $this->executeId;
  2748. $data ['rid'] = $rid;
  2749. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  2750. }
  2751. /**
  2752. * 培训班结算
  2753. */
  2754. function receiptTrainAdd() {
  2755. Doo::loadModel ( 'accountItem' );
  2756. $accountItem = new accountItem ();
  2757. $acItem = $accountItem->find ( array (
  2758. 'asArray' => true
  2759. ) );
  2760. // 审批组
  2761. Doo::loadModel ( 'verify' );
  2762. $verify = new verify ();
  2763. $veList = $verify->getVerifyBySubordinate('TRAIN');
  2764. // 办事处
  2765. Doo::loadModel ( 'L_category' );
  2766. $lCategory = new L_category ();
  2767. $data ['category'] = $lCategory->getCategory ();
  2768. $data ['veList'] = $veList;
  2769. $data ['memu'] = "receipt";
  2770. $data ['staff'] = $this->staff;
  2771. $data ['acItem'] = $acItem;
  2772. $data ['receiptMemu'] = 'saeaBorad';
  2773. $data ['verifyId'] = $this->verifyId;
  2774. $data ['executeId'] = $this->executeId;
  2775. $this->render ( "/receipt/receiptTrainAdd", $data );
  2776. }
  2777. /**
  2778. * 添加培训班结算
  2779. */
  2780. function receiptTrainAddDo() {//include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  2781. // 培训班信息
  2782. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  2783. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  2784. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  2785. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  2786. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  2787. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  2788. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  2789. // 发票信息
  2790. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2791. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2792. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2793. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2794. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2795. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2796. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2797. //&&! empty ( $participants )
  2798. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  2799. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2800. header ( 'Content-Type:text/html;charset=utf-8' );
  2801. die ( '请填写联行号' );
  2802. }
  2803. Doo::loadModel ( 'execute' );
  2804. $execute = new execute ();
  2805. $executeDetail = $execute->getOne ( array (
  2806. 'where' => 'mold="培训班结算"',
  2807. 'asArray' => true
  2808. ) );
  2809. if (empty ( $executeDetail )) {
  2810. header ( 'Content-Type:text/html;charset=utf-8' );
  2811. die ( '未设置执行人' );
  2812. }
  2813. Doo::loadClass ( 'XDeode' );
  2814. $XDeode = new XDeode ( 5 );
  2815. $cid = $XDeode->decode ( $cid );
  2816. Doo::loadModel ( 'receipt' );
  2817. $receipt = new receipt ();
  2818. Doo::loadModel ( 'receiptTraining' );
  2819. $receiptTraining = new receiptTraining ();
  2820. // 创建费用培训班
  2821. $item = array (
  2822. 'cid' => $this->staff [0] ['cid'],
  2823. 'categoryName' => $this->staff [0] ['category'],
  2824. 'trainName' => $trainName,
  2825. 'trainStartDate' => $trainStartDate,
  2826. 'trainEndDate' => $trainEndDate,
  2827. 'participants' => $participants,
  2828. 'freeParticipants'=>$freeParticipants,
  2829. 'trainAddress' => $trainAddress,
  2830. 'trainRemarks' => $trainRemarks,
  2831. 'creator' => $this->staff [0] ['sid'],
  2832. 'creatorDate' => date ( "Y-m-d H:i:s" )
  2833. );
  2834. $irid = $receiptTraining->addReceiptTraining ( $item );
  2835. // 报销单
  2836. $receipt->status = 5;
  2837. $receipt->trainId = $irid;
  2838. $receipt->Rtype = 3;
  2839. $receipt->staff = $this->staff [0] ['sid'];
  2840. $receipt->cid = $cid;
  2841. $receipt->verify = $verify;
  2842. $receipt->date = date ( "Y-m-d" );
  2843. $receipt->executeCopy = $executeDetail ['staff'];
  2844. $receipt->receiptOrder = "#P" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  2845. $receipt->remittanceName = $remittanceName;
  2846. $receipt->bankName = $bankName;
  2847. $receipt->bankNumber = $bankNumber;
  2848. $receipt->remittanceBankType = $remittanceBankType;
  2849. if ($remittanceBankType == 1)
  2850. $receipt->coupletNumber = $coupletNumber;
  2851. $rid = $receipt->insert ();
  2852. $XDeode = new XDeode ( 7 );
  2853. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html";
  2854. } else
  2855. die ( 'illegal request' );
  2856. }
  2857. /**
  2858. * 培训班编辑
  2859. */
  2860. function receiptTrainEdi() {
  2861. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2862. $trainEdiType = $this->get_args ( 'trainEdiType' ) ? $this->get_args ( 'trainEdiType' ) : "INFO";
  2863. Doo::loadClass ( 'XDeode' );
  2864. $XDeode = new XDeode ( 7 );
  2865. $rid = $XDeode->decode ( $ridKey );
  2866. if (! is_numeric ( $rid ))
  2867. die ( 'illegal request' );
  2868. Doo::loadModel ( 'receipt' );
  2869. $receipt = new receipt ();
  2870. Doo::loadModel ( 'receiptTraining' );
  2871. $receiptTraining = new receiptTraining ();
  2872. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2873. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)){
  2874. die ('illegal request--status');
  2875. }
  2876. //如有已入账已收款的发票,自动取消办事处已收款
  2877. // Doo::loadModel ( 'RIExtend' );
  2878. // $RIExtend = new RIExtend ();
  2879. // $RIExtendList=$RIExtend->getRIExtendByRid($rid);
  2880. // if (!empty($RIExtendList)){
  2881. // foreach ($RIExtendList as $key=>$value){
  2882. // $RIExtend = new RIExtend ();
  2883. // $RIExtend->delete(array (
  2884. // 'where' => 'iid=' . $value['iid'],
  2885. // 'limit' => 1
  2886. // ));
  2887. // }
  2888. // }
  2889. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2890. // 汇总表合计
  2891. // 收入合计--加入开票合计
  2892. Doo::loadModel ( 'invoiceTraining' );
  2893. $invoiceTraining = new invoiceTraining ();
  2894. $invoiceTrainingDetail = array (
  2895. 'invoiceArriveAmount' => 0,
  2896. 'RIAmount' => 0,
  2897. 'invoiceTotalAmount' => 0,
  2898. 'invoiceCompanyAmount'=>0
  2899. );
  2900. if ($receiptDetail ['invoiceTrainId'] != 0) {
  2901. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  2902. }
  2903. // print_r($invoiceTrainingDetail);
  2904. $invoiceArriveAmount = $RIAmount = 0;
  2905. if (! empty ( $invoiceTrainingDetail )) {
  2906. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  2907. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  2908. }
  2909. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  2910. //print_r($invoiceTrainingDetail);
  2911. // 支出项目
  2912. Doo::loadModel ( 'accountItem' );
  2913. $accountItem = new accountItem ();
  2914. // 项目金额合计
  2915. Doo::loadModel ( 'RItem' );
  2916. $RItem = new RItem ();
  2917. // 讲师获得
  2918. Doo::loadModel ( 'RILecturer' );
  2919. $RILecturer = new RILecturer ();
  2920. $RItemList = $RItem->getRItemByRid ( $rid );
  2921. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2922. // 支出项金额详情
  2923. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  2924. // print_r($aiData);
  2925. // 利润
  2926. $profit=$invoiceArriveAmount - $aiData ['total'];
  2927. $companyProfit=$profit * 0.6;
  2928. $categoryProfit=$profit * 0.4;
  2929. $data ['profit'] = sprintf("%.2f",$profit);
  2930. $data ['companyProfit'] = sprintf("%.2f",$companyProfit);
  2931. $data ['categoryProfit'] = sprintf("%.2f",$categoryProfit);
  2932. //发票利润
  2933. $data ['invoiceProfit'] = $invoiceTrainingDetail ['invoiceTotalAmount'] - $aiData ['total'];
  2934. //发票公司利润
  2935. $invoiceCompanyProfit=$data ['invoiceProfit'] * 0.6;
  2936. $data ['invoiceCompanyProfit'] = sprintf("%.2f",$invoiceCompanyProfit);
  2937. //办事处利润
  2938. $invoiceCategoryProfit=$data ['invoiceProfit'] * 0.4;
  2939. $data ['invoiceCategoryProfit'] = sprintf("%.2f",$invoiceCategoryProfit);
  2940. // print_r($aiData['dataList']);
  2941. $categoryActualExpenditure= $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  2942. $data ['categoryActualExpenditure'] = sprintf("%.2f",$categoryActualExpenditure);
  2943. // 备用金
  2944. $sum = 0;
  2945. $data ['receiptLoanDetail'] = array (
  2946. 'sum' => '0.00'
  2947. );
  2948. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  2949. //$data ['receiptLoanDetail'] = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2950. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2951. $sum=0;
  2952. foreach ($receiptLoanList as $key=>$value){
  2953. $sum+=$value['sum'];
  2954. }
  2955. $data ['receiptLoanDetail'] = array (
  2956. 'sum' => $sum
  2957. );
  2958. //$sum = $data ['receiptLoanDetail'] ['sum'];
  2959. }
  2960. $payment=$sum + $RIAmount - $categoryActualExpenditure;
  2961. $data ['payment'] = sprintf("%.2f",$payment);
  2962. $data ['total'] = sprintf("%.2f",$aiData ['total']);
  2963. $data ['aiCount'] = count ( $aiData ['dataList'] ) + 5;
  2964. $data ['aiList'] = $aiData ['dataList'];
  2965. // 占比计算
  2966. if ($invoiceArriveAmount != 0) {
  2967. $data ['totalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceArriveAmount* 100) ;
  2968. $data ['profitProportion'] = sprintf("%.2f",$profit / $invoiceArriveAmount*100) ; //number_format ( $profit / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2969. $data ['sumProportion'] = sprintf("%.2f",$sum / $invoiceArriveAmount*100) ; //number_format ( $sum / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2970. $data ['invoiceTotalAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceArriveAmount*100) ;
  2971. $data ['RIAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceArriveAmount*100) ;
  2972. $data ['companyProfitProportion'] = sprintf("%.2f",$companyProfit / $invoiceArriveAmount*100) ;
  2973. $data ['categoryProportion'] = sprintf("%.2f",$categoryProfit / $invoiceArriveAmount*100) ;
  2974. $data ['categoryActualExpenditureProportion'] = sprintf("%.2f",$categoryActualExpenditure / $invoiceArriveAmount*100) ;
  2975. $data ['paymentProportion'] = sprintf("%.2f",$payment / $invoiceArriveAmount*100) ;
  2976. } else {
  2977. $data ['totalProportion'] = $data ['profitProportion'] = $data ['sumProportion'] = $data ['invoiceTotalAmountProportion'] = $data ['RIAmountProportion'] = $data ['companyProfitProportion'] = $data ['categoryActualExpenditureProportion'] = $data ['paymentProportion'] = $data ['categoryProportion'] = 0;
  2978. }
  2979. //发票金额占比计算
  2980. if ($invoiceTrainingDetail ['invoiceTotalAmount'] != 0) {
  2981. //支出
  2982. $data ['invoicetotalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2983. //利润
  2984. $data ['invoiceprofitProportion'] = sprintf("%.2f",$data ['invoiceProfit'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2985. //公司利润
  2986. $data ['invoicecompanyProfitProportion'] = sprintf("%.2f", $invoiceCompanyProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2987. //办事处利润
  2988. $data ['invoicecategoryProportion'] = sprintf("%.2f", $invoiceCategoryProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2989. //公司收款
  2990. $data ['invoiceTotalAmountProportionB'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2991. //备用金
  2992. $data ['invoicesumProportion'] = sprintf("%.2f", $sum / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2993. //办事处收款
  2994. $data ['invoiceRIAmountProportion'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2995. //办事处实际支出
  2996. $data ['ICAEP'] = sprintf("%.2f", $categoryActualExpenditure / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2997. //付总部款
  2998. $data ['invoicepaymentProportion'] = sprintf("%.2f", $payment / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2999. }else{
  3000. $data ['invoiceprofitProportion'] =$data ['invoiceRIAmountProportion'] =$data ['invoicetotalProportion'] =$data ['invoiceTotalAmountProportionB'] =$data ['invoicesumProportion'] =$data ['ICAEP'] =$data ['invoicepaymentProportion'] =$data ['invoicecompanyProfitProportion'] =$data ['invoicecategoryProportion'] =0;
  3001. }
  3002. //讲师人数
  3003. Doo::loadModel ( 'RILecturer' );
  3004. $RILecturer = new RILecturer ();
  3005. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  3006. $data['lectureCount']=count($RILecturerList);
  3007. // 审批组
  3008. Doo::loadModel ( 'verify' );
  3009. $verify = new verify ();
  3010. $veList = $verify->getVerifyBySubordinate('TRAIN');
  3011. // 办事处
  3012. Doo::loadModel ( 'L_category' );
  3013. $lCategory = new L_category ();
  3014. $data ['category'] = $lCategory->getCategory ();
  3015. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3016. $data ['receiptDetail'] = $receiptDetail;
  3017. $data ['veList'] = $veList;
  3018. $data ['trainEdiType'] = $trainEdiType;
  3019. $data ['ridKey'] = $ridKey;
  3020. $data ['memu'] = "receipt";
  3021. $data ['staff'] = $this->staff;
  3022. $data ['receiptMemu'] = 'saeaBorad';
  3023. $data ['verifyId'] = $this->verifyId;
  3024. $data ['executeId'] = $this->executeId;
  3025. $this->render ( "/receipt/receiptTrainEdi", $data );
  3026. }
  3027. /**
  3028. * 培训班借款编辑
  3029. */
  3030. function receiptTrainLoanEdi() {
  3031. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3032. Doo::loadClass ( 'XDeode' );
  3033. $XDeode = new XDeode ( 7 );
  3034. $rid = $XDeode->decode ( $ridKey );
  3035. if (! is_numeric ( $rid ))
  3036. die ( 'illegal request' );
  3037. Doo::loadModel ( 'receipt' );
  3038. $receipt = new receipt ();
  3039. Doo::loadModel ( 'receiptTraining' );
  3040. $receiptTraining = new receiptTraining ();
  3041. Doo::loadModel ( 'verify' );
  3042. $verify = new verify ();
  3043. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3044. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  3045. die ();
  3046. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3047. // 借款详情HTML
  3048. // 获得借款信息
  3049. $receiptLoanHtml = '';
  3050. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  3051. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  3052. foreach ($receiptLoanList as $key=>$value){
  3053. // 获得某费用单审批信息
  3054. $verifylist = $verify->getVerifyByRid ( $value ['rid'] );
  3055. Doo::loadClass ( 'receipt.func' );
  3056. $extendHtml = '<p><a class="button"
  3057. href="javascript:if(window.confirm(\'确认移除?\'))window.location=\'/receiptTrainLoanRemoveDo/' . $receiptDetail ['ridKey'] . '/' . $value ['ridKey'] . '.html\'" data-toggle="modal">移除借款</a></p>';
  3058. $receiptLoanHtml .= _getReceiptLoanHtml ( $value, $verifylist, $extendHtml );
  3059. }
  3060. }
  3061. $data ['receiptLoanHtml'] = $receiptLoanHtml;
  3062. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3063. $data ['receiptDetail'] = $receiptDetail;
  3064. $data ['trainEdiType'] = "LOAN";
  3065. $data ['ridKey'] = $ridKey;
  3066. $data ['memu'] = "receipt";
  3067. $data ['staff'] = $this->staff;
  3068. $data ['receiptMemu'] = 'saeaBorad';
  3069. $data ['verifyId'] = $this->verifyId;
  3070. $data ['executeId'] = $this->executeId;
  3071. $this->render ( "/receipt/receiptTrainLoanEdi", $data );
  3072. }
  3073. /**
  3074. * 更新培训班结算基本信息
  3075. */
  3076. function receiptTrainInfoEdiDo() {
  3077. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  3078. $rtid = $this->get_args ( 'rtid' ) ? $this->get_args ( 'rtid' ) : "";
  3079. // 培训班信息
  3080. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  3081. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  3082. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  3083. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  3084. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  3085. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  3086. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  3087. // 发票信息
  3088. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  3089. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3090. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  3091. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  3092. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  3093. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  3094. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  3095. //&& ! empty ( $participants )
  3096. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  3097. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  3098. header ( 'Content-Type:text/html;charset=utf-8' );
  3099. die ( '请填写联行号' );
  3100. }
  3101. Doo::loadClass ( 'XDeode' );
  3102. $XDeode = new XDeode ( 5 );
  3103. $cid = $XDeode->decode ( $cid );
  3104. $rtid = $XDeode->decode ( $rtid );
  3105. $rid = $XDeode->decode ( $rid );
  3106. if (! is_numeric ( $rtid ) || ! is_numeric ( $rid )) {
  3107. die ( 'illegal request-IdError' );
  3108. }
  3109. Doo::loadModel ( 'receipt' );
  3110. $receipt = new receipt ();
  3111. Doo::loadModel ( 'receiptTraining' );
  3112. $receiptTraining = new receiptTraining ();
  3113. // 更新费用培训班
  3114. $item = array (
  3115. 'rtid' => $rtid,
  3116. 'trainName' => $trainName,
  3117. 'trainStartDate' => $trainStartDate,
  3118. 'trainEndDate' => $trainEndDate,
  3119. 'participants' => $participants,
  3120. 'freeParticipants'=>$freeParticipants,
  3121. 'trainAddress' => $trainAddress,
  3122. 'trainRemarks' => $trainRemarks
  3123. );
  3124. $irid = $receiptTraining->setReceiptTrainByCondition ( $item );
  3125. // 报销单
  3126. $receipt->rid = $rid;
  3127. $receipt->cid = $cid;
  3128. $receipt->verify = $verify;
  3129. $receipt->remittanceName = $remittanceName;
  3130. $receipt->bankName = $bankName;
  3131. $receipt->bankNumber = $bankNumber;
  3132. $receipt->remittanceBankType = $remittanceBankType;
  3133. if ($remittanceBankType == 1)
  3134. $receipt->coupletNumber = $coupletNumber;
  3135. $receipt->update ();
  3136. $XDeode = new XDeode ( 7 );
  3137. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html?trainEdiType=INFO";
  3138. } else
  3139. die ( 'illegal request' );
  3140. }
  3141. /**
  3142. * 编辑培训班结算---更新借款
  3143. */
  3144. function receiptTrainLoanEdiDo() {
  3145. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3146. $ridLoanKey = $this->get_args ( 'ridLoanKey' ) ? $this->get_args ( 'ridLoanKey' ) : "";
  3147. if (! empty ( $ridKey ) && ! empty ( $ridLoanKey )) {
  3148. Doo::loadModel ( 'receipt' );
  3149. $receipt = new receipt ();
  3150. Doo::loadClass ( 'XDeode' );
  3151. $XDeode = new XDeode ( 5 );
  3152. $rid = $XDeode->decode ( $ridKey );
  3153. $ridLoan = $XDeode->decode ( $ridLoanKey );
  3154. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  3155. die ( 'illegal request-ridError' );
  3156. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3157. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  3158. // 不合法的数据if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3159. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  3160. die ( 'illegal request-receiptError' );
  3161. }
  3162. if ($receiptLoanDetail ['status'] != 8 || $receiptLoanDetail ['Rtype'] != 1) {
  3163. die ( 'illegal request-receipLoantError' );
  3164. }
  3165. // 培训班结算挂钩借款
  3166. $receipt = new receipt ();
  3167. $trainLoanRid=$ridLoan;
  3168. if (!empty($receiptDetail['trainLoanRid'])){
  3169. $trainLoanRid=$receiptDetail['trainLoanRid'].','.$ridLoan;
  3170. }
  3171. $item = array (
  3172. 'rid' => $rid,
  3173. 'trainLoanRid' => $trainLoanRid
  3174. );
  3175. $receipt->setReceiptByCondition ( $item );
  3176. // 更新借款状态变成已挂钩
  3177. $receipt = new receipt ();
  3178. $item = array (
  3179. 'rid' => $ridLoan,
  3180. 'status' => 10,
  3181. 'statusTrain' => 1
  3182. );
  3183. $receipt->setReceiptByCondition ( $item );
  3184. $XDeode = new XDeode ( 7 );
  3185. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  3186. } else
  3187. die ( 'illegal request' );
  3188. }
  3189. /**
  3190. * 编辑培训班结算--移除借款
  3191. */
  3192. function receiptTrainLoanRemoveDo() {
  3193. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : 0;
  3194. $ridLoanKey = isset ( $this->params ['ridLoanKey'] ) ? $this->params ['ridLoanKey'] : 0;
  3195. if (! empty ( $ridKey ) || ! empty ( $ridLoanKey )) {
  3196. Doo::loadModel ( 'receipt' );
  3197. $receipt = new receipt ();
  3198. Doo::loadClass ( 'XDeode' );
  3199. $XDeode = new XDeode ( 5 );
  3200. $rid = $XDeode->decode ( $ridKey );
  3201. $ridLoan = $XDeode->decode ( $ridLoanKey );
  3202. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  3203. die ( 'illegal request-ridError' );
  3204. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3205. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  3206. // 不合法的数据 !($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)
  3207. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  3208. die ( 'illegal request-receiptError' );
  3209. }
  3210. if ($receiptLoanDetail ['status'] != 10 || $receiptLoanDetail ['Rtype'] != 1) {
  3211. die ( 'illegal request-receipLoantError' );
  3212. }
  3213. // 培训班结算挂钩借款
  3214. $receipt = new receipt ();
  3215. $trainLoanRidArray=explode(",", $receiptDetail['trainLoanRid']);
  3216. foreach ($trainLoanRidArray as $key=>$value){
  3217. if($value==$ridLoan){
  3218. unset($trainLoanRidArray[$key]);
  3219. }
  3220. }
  3221. $trainLoanRidString=implode(",", $trainLoanRidArray);
  3222. $item = array (
  3223. 'rid' => $rid,
  3224. 'trainLoanRid' => $trainLoanRidString
  3225. );
  3226. $receipt->setReceiptByCondition ( $item );
  3227. // 更新借款状态变成已挂钩
  3228. $receipt = new receipt ();
  3229. $item = array (
  3230. 'rid' => $ridLoan,
  3231. 'status' => 8,
  3232. 'statusTrain' => 0
  3233. );
  3234. $receipt->setReceiptByCondition ( $item );
  3235. $XDeode = new XDeode ( 7 );
  3236. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  3237. } else
  3238. die ( 'illegal request' );
  3239. }
  3240. /**
  3241. * 编辑培训班结算 ---开票
  3242. */
  3243. function receiptTrainInvoiceEdi() {
  3244. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3245. Doo::loadClass ( 'XDeode' );
  3246. $XDeode = new XDeode ( 7 );
  3247. $rid = $XDeode->decode ( $ridKey );
  3248. if (! is_numeric ( $rid ))
  3249. die ( 'illegal request' );
  3250. Doo::loadModel ( 'receipt' );
  3251. $receipt = new receipt ();
  3252. Doo::loadModel ( 'receiptTraining' );
  3253. $receiptTraining = new receiptTraining ();
  3254. Doo::loadModel ( 'invoice' );
  3255. $invoice = new invoice ();
  3256. Doo::loadModel ( 'invoiceTraining' );
  3257. $invoiceTraining = new invoiceTraining ();
  3258. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3259. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  3260. die ();
  3261. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3262. $invoiceList = $invoiceTrainingDetail = array ();
  3263. if ($receiptDetail ['invoiceTrainId'] != 0) {
  3264. $invoiceList = $invoice->getInvoicePrintedByItid ( $receiptDetail ['invoiceTrainId'] );
  3265. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  3266. }
  3267. //print_r($invoiceList);
  3268. $data ['invoiceList'] = $invoiceList;
  3269. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  3270. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3271. $data ['receiptDetail'] = $receiptDetail;
  3272. $data ['trainEdiType'] = "INVOICE";
  3273. $data ['ridKey'] = $ridKey;
  3274. $data ['memu'] = "receipt";
  3275. $data ['staff'] = $this->staff;
  3276. $data ['receiptMemu'] = 'saeaBorad';
  3277. $data ['verifyId'] = $this->verifyId;
  3278. $data ['executeId'] = $this->executeId;
  3279. $this->render ( "/receipt/receiptTrainInvoiceEdi", $data );
  3280. }
  3281. /**
  3282. * 编辑培训班结算---更新开票
  3283. */
  3284. function receiptTrainInvoiceEdiDo() {
  3285. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3286. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : "";
  3287. if (! empty ( $ridKey ) && ! empty ( $itidKey )) {
  3288. Doo::loadModel ( 'receipt' );
  3289. $receipt = new receipt ();
  3290. Doo::loadModel ( 'invoiceTraining' );
  3291. $invoiceTraining = new invoiceTraining ();
  3292. Doo::loadClass ( 'XDeode' );
  3293. $XDeode = new XDeode ( 5 );
  3294. $rid = $XDeode->decode ( $ridKey );
  3295. $itid = $XDeode->decode ( $itidKey );
  3296. if (! is_numeric ( $rid ) || ! is_numeric ( $itid ))
  3297. die ( 'illegal request-idError' );
  3298. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3299. $invoiceTrainDetail = $invoiceTraining->getInvoiceTrainingByItid ( $itid );
  3300. // 不合法的数据
  3301. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  3302. die ( 'illegal request-receiptError' );
  3303. }
  3304. if (empty ( $invoiceTrainDetail ) || $invoiceTrainDetail ['bindReceipt'] == 1) {
  3305. die ( 'illegal request-receipLoantError' );
  3306. }
  3307. // 培训班结算挂钩借款
  3308. $receipt = new receipt ();
  3309. $item = array (
  3310. 'rid' => $rid,
  3311. 'invoiceTrainId' => $itid
  3312. );
  3313. $receipt->setReceiptByCondition ( $item );
  3314. $invoiceTraining = new invoiceTraining ();
  3315. $item = array (
  3316. 'bindReceipt' => 1,
  3317. 'itid' => $itid
  3318. );
  3319. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  3320. $XDeode = new XDeode ( 7 );
  3321. return "/receiptTrainInvoiceEdi/" . $XDeode->encode ( $rid ) . ".html";
  3322. } else
  3323. die ( 'illegal request' );
  3324. }
  3325. /**
  3326. * 更新培训班结算 收款和取消收款
  3327. */
  3328. function receiptTrainReceivables() {
  3329. $doType = isset ( $this->params ['doType'] ) ? $this->params ['doType'] : '';
  3330. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3331. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  3332. Doo::loadClass ( 'XDeode' );
  3333. $XDeode = new XDeode ( 5 );
  3334. $rid = $XDeode->decode ( $ridKey );
  3335. $iid = $XDeode->decode ( $iidKey );
  3336. if (! is_numeric ( $rid ) || ! is_numeric ( $iid ))
  3337. die ( 'illegal request-iid' );
  3338. Doo::loadModel ( 'RIExtend' );
  3339. $RIExtend = new RIExtend ();
  3340. if ($doType == 'CONFIRM') {
  3341. $RIExtend->rid = $rid;
  3342. $RIExtend->iid = $iid;
  3343. $RIExtend->RIstatus = 1;
  3344. $RIExtend->insert ();
  3345. echo json_encode ( array (
  3346. 'status' => 1,
  3347. ) );
  3348. die ( );
  3349. } elseif ($doType == 'CANCEL') {
  3350. $RIExtend->delete ( array (
  3351. 'where' => 'rid=' . $rid . ' and iid=' . $iid,
  3352. 'limit' => 1
  3353. ) );
  3354. echo json_encode ( array (
  3355. 'status' => 1,
  3356. ) );
  3357. die ( );
  3358. } else {
  3359. echo json_encode ( array (
  3360. 'status' => 2,
  3361. ) );
  3362. die ( );
  3363. }
  3364. }
  3365. /**
  3366. * 移除挂钩的培训班发票
  3367. */
  3368. function receiptTrainReceivablesDelDo() {
  3369. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  3370. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : ""; // 发票培训班
  3371. Doo::loadModel ( 'receipt' );
  3372. $receipt = new receipt ();
  3373. Doo::loadModel ( 'RIExtend' );
  3374. $RIExtend = new RIExtend ();
  3375. Doo::loadClass ( 'XDeode' );
  3376. $XDeode = new XDeode ( 5 );
  3377. $rid = $XDeode->decode ( $ridKey );
  3378. $itid = $XDeode->decode ( $itidKey );
  3379. if (is_numeric ( $rid ) && is_numeric ( $itid )) {
  3380. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3381. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  3382. die ( 'illegal request-status' );
  3383. }
  3384. $receipt = new receipt ();
  3385. $receipt->rid = $rid;
  3386. $receipt->invoiceTrainId = 0;
  3387. $receipt->update ();
  3388. Doo::loadModel ( 'invoiceTraining' );
  3389. $invoiceTraining = new invoiceTraining ();
  3390. $item = array (
  3391. 'bindReceipt' => 0,
  3392. 'itid' => $itid
  3393. );
  3394. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  3395. $RIExtend->delete ( array (
  3396. 'where' => 'rid=' . $rid
  3397. ) );
  3398. $XDeode = new XDeode ( 7 );
  3399. return '/receiptTrainInvoiceEdi/' . $XDeode->encode ( $rid ) . '.html';
  3400. } else
  3401. die ( 'illegal request-iid' );
  3402. }
  3403. /**
  3404. * 编辑培训班结算
  3405. */
  3406. function receiptTrainItemEdi() {
  3407. //include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  3408. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3409. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : '';
  3410. Doo::loadClass ( 'XDeode' );
  3411. $XDeode = new XDeode ( 7 );
  3412. $rid = $XDeode->decode ( $ridKey );
  3413. if (! is_numeric ( $rid ))
  3414. die ( 'illegal request' );
  3415. Doo::loadModel ( 'receipt' );
  3416. $receipt = new receipt ();
  3417. Doo::loadModel ( 'receiptTraining' );
  3418. $receiptTraining = new receiptTraining ();
  3419. Doo::loadModel ( 'RItem' );
  3420. $RItem = new RItem ();
  3421. Doo::loadModel ( 'accountItem' );
  3422. $accountItem = new accountItem ();
  3423. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3424. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3425. die ();
  3426. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3427. $RItemList = $RItem->getRItemByRid ( $rid,$name );
  3428. $aiList = $accountItem->getAccountBookByCategory ( '培训班费用' );//print_r($aiList);
  3429. // foreach ($aiList as $key=>$value){//不需要添加税款,在添加收入时自动添加
  3430. // if($value['name']=='税款'){
  3431. // unset($aiList[$key]);break;
  3432. // }
  3433. // }
  3434. //print_r($RItemList);
  3435. $data ['name'] = $name;
  3436. $data ['RItemList'] = $RItemList;
  3437. $data ['aiList'] = $aiList;
  3438. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3439. $data ['receiptDetail'] = $receiptDetail;
  3440. $data ['trainEdiType'] = "ITEM";
  3441. $data ['ridKey'] = $ridKey;
  3442. $data ['memu'] = "receipt";
  3443. $data ['staff'] = $this->staff;
  3444. $data ['receiptMemu'] = 'saeaBorad';
  3445. $data ['verifyId'] = $this->verifyId;
  3446. $data ['executeId'] = $this->executeId;
  3447. $this->render ( "/receipt/receiptTrainItemEdi", $data );
  3448. }
  3449. /**
  3450. * 添加支出项 需要修改 费用金额合计
  3451. */
  3452. function receiptTrainItemAddDo() {
  3453. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3454. $rtidKey = $this->get_args ( 'rtidKey' ) ? $this->get_args ( 'rtidKey' ) : "";
  3455. // 支出项信息
  3456. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  3457. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : 0;
  3458. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  3459. $inputer = $this->get_args ( 'inputer' ) ? $this->get_args ( 'inputer' ) : "";
  3460. $describe = $this->get_args ( 'describe' ) ? $this->get_args ( 'describe' ) : "";
  3461. //$identifyingTotal = $this->get_args ( 'identifyingTotal' )&&is_numeric($this->get_args ( 'identifyingTotal' )) ? $this->get_args ( 'identifyingTotal' ) : 0;
  3462. $payType = isset ( $this->params ['payType'] ) ? $this->params ['payType'] : '';
  3463. if (! empty ( $ridKey ) && ! empty ( $item ) && is_numeric( $price ) && ! empty ( $date ) && ! empty ( $inputer )) {
  3464. Doo::loadClass ( 'XDeode' );
  3465. $XDeode = new XDeode ( 5 );
  3466. Doo::loadModel ( 'RItem' );
  3467. $RItem = new RItem ();
  3468. $rid = $XDeode->decode ( $ridKey );
  3469. $rtid= $XDeode->decode ( $rtidKey );
  3470. if (! is_numeric ( $rid )){
  3471. die ( 'illegal request' );
  3472. }
  3473. Doo::loadModel ( 'receiptDetail' );
  3474. $receiptDetail = new receiptDetail ();
  3475. Doo::loadModel ( 'receipt' );
  3476. $receipt = new receipt ();
  3477. Doo::loadModel ( 'receiptTraining' );
  3478. $receiptTraining = new receiptTraining ();
  3479. $rtDetail=$receiptTraining->getReceiptTrainingByRtid($rtid);
  3480. $identifyingTotal=$rtDetail['identifyingTotal']+1;
  3481. $order = array (
  3482. "\r\n",
  3483. "\n",
  3484. "\r"
  3485. );
  3486. $replace = '<br/>';
  3487. $describe = str_replace ( $order, $replace, $describe );
  3488. $itemData = array (
  3489. 'rid' => $rid,
  3490. 'item' => $item,
  3491. 'price' => $price,
  3492. 'date' => $date,
  3493. 'inputer' => $inputer,
  3494. 'describe' => $describe,
  3495. 'creater' => $this->staff['0']['username'],
  3496. 'createrId' => $this->staff['0']['sid'],
  3497. 'creatDate' => date ( "Y-m-d H:i:s" ),
  3498. 'identifying'=>$identifyingTotal
  3499. );
  3500. if($payType=='company'){
  3501. $itemData += array (
  3502. 'payType' => 1
  3503. );
  3504. }
  3505. $RItem->addRItem($itemData, $receipt, $receiptDetail, $rid, $item, $price, $payType);
  3506. //更新支出项标识总数
  3507. $itemData = array (
  3508. 'rtid'=>$rtid,
  3509. 'identifyingTotal'=>$identifyingTotal
  3510. );
  3511. $receiptTraining->setReceiptTrainByCondition($itemData);
  3512. $XDeode = new XDeode ( 7 );
  3513. if($payType=='company'){
  3514. return '/receiptTrainItem/approval/' . $XDeode->encode ( $rid ) . '.html';
  3515. }else{
  3516. return '/receiptTrainItemEdi/' . $XDeode->encode ( $rid ) . '.html';
  3517. }
  3518. } else
  3519. die ( 'illegal request-dataError' );
  3520. }
  3521. /**
  3522. * 培训班结算-讲师
  3523. */
  3524. function receiptTrainLecturerEdi() {
  3525. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3526. Doo::loadClass ( 'XDeode' );
  3527. $XDeode = new XDeode ( 7 );
  3528. $rid = $XDeode->decode ( $ridKey );
  3529. if (! is_numeric ( $rid ))
  3530. die ( 'illegal request' );
  3531. Doo::loadModel ( 'receipt' );
  3532. $receipt = new receipt ();
  3533. Doo::loadModel ( 'receiptTraining' );
  3534. $receiptTraining = new receiptTraining ();
  3535. Doo::loadModel ( 'RILecturer' );
  3536. $RILecturer = new RILecturer ();
  3537. Doo::loadModel ( 'lecturer' );
  3538. $lecturer = new lecturer ();
  3539. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3540. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3541. die ();
  3542. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3543. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  3544. $lecturerList = $lecturer->getLecturerAll ();
  3545. $INSIDEhtml = $OUTSIDEhtml = '';
  3546. foreach ( $lecturerList as $key => $value ) {
  3547. if ($value ['ltype'] == 'INSIDE') {
  3548. $INSIDEhtml .= '<option value="' . $value ['category'] . '-' . $value ['staff'] . '">' . $value ['category'] . '-' . $value ['staff'] . '</option>';
  3549. } elseif ($value ['ltype'] == 'OUTSIDE') {
  3550. $OUTSIDEhtml .= '<option value="' . $value ['staff'] . '">' . $value ['staff'] . '</option>';
  3551. }
  3552. }
  3553. $data ['INSIDEhtml'] = $INSIDEhtml;
  3554. $data ['OUTSIDEhtml'] = $OUTSIDEhtml;
  3555. // print_r($RItemList);
  3556. $data ['RILecturerList'] = $RILecturerList;
  3557. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3558. $data ['receiptDetail'] = $receiptDetail;
  3559. $data ['trainEdiType'] = "LECTURER";
  3560. $data ['ridKey'] = $ridKey;
  3561. $data ['memu'] = "receipt";
  3562. $data ['staff'] = $this->staff;
  3563. $data ['receiptMemu'] = 'saeaBorad';
  3564. $data ['verifyId'] = $this->verifyId;
  3565. $data ['executeId'] = $this->executeId;
  3566. $this->render ( "/receipt/receiptTrainLecturerEdi", $data );
  3567. }
  3568. /**
  3569. * 添加讲师
  3570. */
  3571. function receiptTrainLecturerAddDo() {
  3572. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3573. // 支出项信息
  3574. $ltype = $this->get_args ( 'ltype' ) ? $this->get_args ( 'ltype' ) : "";
  3575. $lecturerName = $this->get_args ( 'lecturerName' ) ? $this->get_args ( 'lecturerName' ) : "";
  3576. $schoolDay = $this->get_args ( 'schoolDay' ) ? $this->get_args ( 'schoolDay' ) : "";
  3577. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  3578. $taxation = $this->get_args ( 'taxation' ) ? $this->get_args ( 'taxation' ) : "";
  3579. $fees = $this->get_args ( 'fees' ) ? $this->get_args ( 'fees' ) : "";
  3580. if (! empty ( $ridKey ) && ! empty ( $ltype ) && ! empty ( $lecturerName ) && ! empty ( $schoolDay ) && ! empty ( $price )) {
  3581. Doo::loadClass ( 'XDeode' );
  3582. $XDeode = new XDeode ( 5 );
  3583. Doo::loadModel ( 'RILecturer' );
  3584. $RILecturer = new RILecturer ();
  3585. $rid = $XDeode->decode ( $ridKey );
  3586. if (! is_numeric ( $rid ))
  3587. die ( 'illegal request' );
  3588. if ($ltype == 'OUTSIDE' && empty ( $taxation ))
  3589. die ( 'illegal request-taxationError' );
  3590. $RILecturer->rid = $rid;
  3591. $RILecturer->ltype = $ltype;
  3592. if ($ltype == 'OUTSIDE') {
  3593. if ($taxation == 'TAXATION') {
  3594. $RILecturer->taxation = 1;
  3595. } elseif ($taxation == 'NOTAXATION') {
  3596. $RILecturer->taxation = 0;
  3597. }
  3598. }
  3599. $RILecturer->lecturerName = $lecturerName;
  3600. $RILecturer->schoolDay = $schoolDay;
  3601. $RILecturer->price = $price;
  3602. $RILecturer->fees=$fees;
  3603. $RILecturer->insert ();
  3604. // 添加公司汇总
  3605. // 报销详情
  3606. Doo::loadModel ( 'receiptDetail' );
  3607. $receiptDetail = new receiptDetail ();
  3608. Doo::loadModel ( 'receipt' );
  3609. $receipt = new receipt ();
  3610. // 金额总计
  3611. $price = $price * $schoolDay;
  3612. $rInfo = $receipt->getReceiptByRid ( $rid );
  3613. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  3614. if (empty ( $rdInfo )) {
  3615. $receiptDetail = new receiptDetail ();
  3616. $receiptDetail->staff = $rInfo ['staff'];
  3617. $receiptDetail->item = '讲课费';
  3618. $receiptDetail->itemCategory = '培训班费用';
  3619. $receiptDetail->price = number_format ( $fees, 2, '.', '' );
  3620. $receiptDetail->date = date ( "Y-m-d" );
  3621. $receiptDetail->cid = $rInfo ['cid'];
  3622. $receiptDetail->rid = $rid;
  3623. $receiptDetail->status = 4;
  3624. $receiptDetail->insert ();
  3625. } else {
  3626. $receiptDetail = new receiptDetail ();
  3627. $rdInfo ['price'] += $fees;
  3628. $receiptDetail->price = $rdInfo ['price'];
  3629. $receiptDetail->update ( array (
  3630. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  3631. ) );
  3632. }
  3633. $receipt = new receipt ();
  3634. $receipt->sum=$rInfo['sum']+$fees;
  3635. $receipt->update ( array (
  3636. 'where' => 'rid=' . $rid
  3637. ) );
  3638. $XDeode = new XDeode ( 7 );
  3639. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  3640. } else
  3641. die ( 'illegal request' );
  3642. }
  3643. /**
  3644. * 移除讲师
  3645. */
  3646. function receiptTrainLecturerDelDo() {
  3647. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  3648. $rlidKey = $this->get_args ( 'rlidKey' ) ? $this->get_args ( 'rlidKey' ) : ""; // 发票培训班
  3649. Doo::loadModel ( 'receipt' );
  3650. $receipt = new receipt ();
  3651. Doo::loadModel ( 'RILecturer' );
  3652. $RILecturer = new RILecturer ();
  3653. Doo::loadClass ( 'XDeode' );
  3654. $XDeode = new XDeode ( 5 );
  3655. $rid = $XDeode->decode ( $ridKey );
  3656. $rlid = $XDeode->decode ( $rlidKey );
  3657. if (is_numeric ( $rid ) && is_numeric ( $rlid )) {
  3658. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3659. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  3660. die ( 'illegal request-status' );
  3661. }
  3662. $detail=$RILecturer->getRILecturerByRlid($rlid);
  3663. if (empty($detail)){
  3664. die ( 'illegal request-data' );
  3665. }
  3666. $RILecturer->delete ( array (
  3667. 'where' => 'rid=' . $rid . ' and rlid=' . $rlid
  3668. ) );
  3669. //更新费用合计金额
  3670. $rInfo = $receipt->getReceiptByRid ( $rid );
  3671. $receipt = new receipt ();
  3672. $receipt->sum= $receiptDetail['sum']-$detail['price'];
  3673. $receipt->update ( array (
  3674. 'where' => 'rid=' . $rid
  3675. ) );
  3676. Doo::loadModel ( 'receiptDetail' );
  3677. $receiptDetail = new receiptDetail ();
  3678. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  3679. $receiptDetail = new receiptDetail ();
  3680. $rdInfo ['price'] -= number_format ( $detail['price'], 2, '.', '' );
  3681. $receiptDetail->price = $rdInfo ['price'];
  3682. $receiptDetail->update ( array (
  3683. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  3684. ) );
  3685. $XDeode = new XDeode ( 7 );
  3686. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  3687. } else
  3688. die ( 'illegal request-iid' );
  3689. }
  3690. /**
  3691. * 培训班提交审批
  3692. */
  3693. function receiptTrainDo() {
  3694. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3695. Doo::loadClass ( 'XDeode' );
  3696. $XDeode = new XDeode ( 7 );
  3697. $rid = $XDeode->decode ( $ridKey );
  3698. Doo::loadModel ( 'receipt' );
  3699. $receipt = new receipt ();
  3700. Doo::loadModel ( 'receiptDetail' );
  3701. $receiptDetail = new receiptDetail ();
  3702. Doo::loadModel ( 'statistics' );
  3703. $statistics = new statistics ();
  3704. Doo::loadModel ( "verify" );
  3705. $verify = new verify ();
  3706. // 审批状态的判定
  3707. $receiptDetailList = $receipt->getOne ( array (
  3708. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  3709. 'asArray' => true
  3710. ) );
  3711. if (empty ( $receiptDetailList ))
  3712. return "/saeaBorad";
  3713. $verifyDetail = $verify->getOne ( array (
  3714. 'where' => ' vid =' . $receiptDetailList ['verify'],
  3715. 'asArray' => true
  3716. ) );
  3717. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3718. if (empty ( $receiptDetailList ['nowStaff'] )) {
  3719. $nowStaff = "";
  3720. $nowStaffList = array ();
  3721. if ($verifyDetail [0] [1] == 'ROLE') {
  3722. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3723. foreach ( $vStaffString as $key => $value ) {
  3724. $staffK = explode ( "_", $value );
  3725. array_push ( $nowStaffList, $staffK [0] );
  3726. }
  3727. $nowStaff = implode ( ',', $nowStaffList );
  3728. } else {
  3729. $nowStaff = $verifyDetail [0] [0];
  3730. }
  3731. $receipt->nowStaff = $nowStaff;
  3732. }
  3733. // echo $nowStaff;
  3734. // print_r($verifyDetail);die;
  3735. $receipt->rid = $receiptDetailList ['rid'];
  3736. $receipt->date = date ( "Y-m-d" );
  3737. $receipt->status = 2;
  3738. $receipt->update ();
  3739. $receiptDetail->status = 2;
  3740. $receiptDetail->update ( array (
  3741. 'where' => 'rid=' . $receiptDetailList ['rid']
  3742. ) );
  3743. Doo::loadModel ( "receiptLog" );
  3744. $receiptLog = new receiptLog ();
  3745. Doo::loadModel ( "verify" );
  3746. $verify = new verify ();
  3747. $vr = $verify->getOne ( array (
  3748. 'where' => 'vid=' . $receiptDetailList ['verify'],
  3749. 'asArray' => true
  3750. ) );
  3751. $jd = json_decode ( $vr ['staff'] );
  3752. $roleId = 0;
  3753. foreach ( $jd as $key => $value ) {
  3754. if ($value [1] == 'ROLE') {
  3755. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  3756. if ($pos !== false) {
  3757. $roleId = $value [0];
  3758. }
  3759. }
  3760. }
  3761. // 审批日志
  3762. // echo $roleId;die;
  3763. if (! empty ( $roleId )) {
  3764. Doo::loadModel ( "role" );
  3765. $role = new role ();
  3766. $roleInfo = $role->getOne ( array (
  3767. 'where' => 'rid=' . $roleId,
  3768. 'asArray' => true
  3769. ) );
  3770. // $receiptLog->rolename = $roleInfo ['name'];
  3771. }
  3772. $receiptLog->username = $this->staff [0] ['username'];
  3773. $receiptLog->uid = $this->staff [0] ['sid'];
  3774. $receiptLog->date = date ( "Y-m-d" );
  3775. $receiptLog->opinion = '提交审批';
  3776. $receiptLog->img = $this->staff [0] ['avatar'];
  3777. $receiptLog->status = 2;
  3778. $receiptLog->rid = $rid;
  3779. $receiptLog->insert ();
  3780. // 写入列表项
  3781. Doo::loadModel ( 'accountItem' );
  3782. $accountItem = new accountItem ();
  3783. $aItem = $accountItem->getAccountBookByCategory ( '培训班费用' );
  3784. // 项目金额合计
  3785. Doo::loadModel ( 'RItem' );
  3786. $RItem = new RItem ();
  3787. // 讲师获得
  3788. Doo::loadModel ( 'RILecturer' );
  3789. $RILecturer = new RILecturer ();
  3790. $RItemList = $RItem->getRItemByRid ( $rid );
  3791. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  3792. // 支出项金额详情
  3793. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, 0 );
  3794. // print_r($aItem);
  3795. // print_r($aiData);
  3796. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  3797. $ag = $tr = $ta = $ot = 0;
  3798. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  3799. foreach ( $aItem as $key => $value ) {
  3800. if ($value ['category'] == $this->TRAIN) {
  3801. foreach ( $aiData ['dataList'] as $k => $v ) {
  3802. if ($value ['name'] == $v ['name']) {
  3803. array_push ( $accountJson [$this->TRAIN], array (
  3804. 'aid' => $value ['aid'],
  3805. 'name' => $value ['name'],
  3806. 'price' => number_format ( $v ['price'], 2, '.', '' )
  3807. ) );
  3808. $sum += $v ['price'];
  3809. $trainSum += $v ['price'];
  3810. unset ( $aiData ['dataList'] [$k] );
  3811. break;
  3812. }
  3813. }
  3814. }
  3815. }
  3816. $accountJson ['cSum'] = array (
  3817. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  3818. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  3819. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  3820. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  3821. );
  3822. // 报销单
  3823. $receipt = new receipt ();
  3824. $receipt->accountItem = json_encode ( $accountJson );
  3825. $receipt->sum = number_format ( $sum, 2, '.', '' );
  3826. $receipt->update ( array (
  3827. 'where' => 'rid=' . $rid
  3828. ) );
  3829. // print_r($accountJson);
  3830. // statistics item 统计写入
  3831. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  3832. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  3833. $accountItem = $accountJson;
  3834. $stat = $statistics->getOne ( array (
  3835. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  3836. 'asArray' => true
  3837. ) );
  3838. if (empty ( $stat )) {
  3839. $statistics->date = date ( "Y-m-d" );
  3840. $statistics->cid = $this->staff [0] ['cid'];
  3841. $statistics->staff = $this->staff [0] ['sid'];
  3842. $statistics->agPrice = 0;
  3843. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  3844. $statistics->insert ();
  3845. } else {
  3846. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  3847. $statistics->update ( array (
  3848. 'where' => 'sid=' . $stat ['sid']
  3849. ) );
  3850. }
  3851. return "/saeaBorad";
  3852. }
  3853. function confirmation() {
  3854. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3855. Doo::loadModel ( 'receipt' );
  3856. Doo::loadModel ( 'receiptDetail' );
  3857. $receipt = new receipt ();
  3858. $receiptDetail = new receiptDetail ();
  3859. Doo::loadModel ( 'statistics' );
  3860. Doo::loadModel ( 'itemStatistics' );
  3861. $statistics = new statistics ();
  3862. $itemStatistics = new itemStatistics ();
  3863. Doo::loadModel ( "verify" );
  3864. $verify = new verify ();
  3865. $receiptDetailList = $receipt->getOne ( array (
  3866. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  3867. 'asArray' => true
  3868. ) );
  3869. if (empty ( $receiptDetailList ))
  3870. return "/saeaBorad";
  3871. $verifyDetail = $verify->getOne ( array (
  3872. 'where' => ' vid =' . $receiptDetailList ['verify'],
  3873. 'asArray' => true
  3874. ) );
  3875. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3876. if (empty ( $receiptDetailList ['nowStaff'] )) {
  3877. $nowStaff = "";
  3878. $nowStaffList = array ();
  3879. if ($verifyDetail [0] [1] == 'ROLE') {
  3880. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3881. foreach ( $vStaffString as $key => $value ) {
  3882. $staffK = explode ( "_", $value );
  3883. array_push ( $nowStaffList, $staffK [0] );
  3884. }
  3885. $nowStaff = implode ( ',', $nowStaffList );
  3886. } else {
  3887. $nowStaff = $verifyDetail [0] [0];
  3888. }
  3889. $receipt->nowStaff = $nowStaff;
  3890. }
  3891. // echo $nowStaff;
  3892. // print_r($verifyDetail);die;
  3893. $receipt->rid = $receiptDetailList ['rid'];
  3894. $receipt->status = 2;
  3895. $receipt->update ();
  3896. // 操作日志
  3897. Doo::loadModel ( "receiptLog" );
  3898. $receiptLog = new receiptLog ();
  3899. $verify = new verify ();
  3900. $receiptInfo = $receipt->getOne ( array (
  3901. 'where' => 'rid=' . $rid,
  3902. 'asArray' => true
  3903. ) );
  3904. $vr = $verify->getOne ( array (
  3905. 'where' => 'vid=' . $receiptInfo ['verify'],
  3906. 'asArray' => true
  3907. ) );
  3908. $jd = json_decode ( $vr ['staff'] );
  3909. $roleId = 0;
  3910. foreach ( $jd as $key => $value ) {
  3911. if ($value [1] == 'ROLE') {
  3912. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  3913. if ($pos !== false) {
  3914. $roleId = $value [0];
  3915. }
  3916. }
  3917. }
  3918. // 审批日志
  3919. // echo $roleId;die;
  3920. if (! empty ( $roleId )) {
  3921. Doo::loadModel ( "role" );
  3922. $role = new role ();
  3923. $roleInfo = $role->getOne ( array (
  3924. 'where' => 'rid=' . $roleId,
  3925. 'asArray' => true
  3926. ) );
  3927. // $receiptLog->rolename = $roleInfo ['name'];
  3928. }
  3929. $receiptLog->username = $this->staff [0] ['username'];
  3930. $receiptLog->uid = $this->staff [0] ['sid'];
  3931. $receiptLog->date = date ( "Y-m-d" );
  3932. $receiptLog->opinion = '提交审批';
  3933. $receiptLog->img = $this->staff [0] ['avatar'];
  3934. $receiptLog->status = 2;
  3935. $receiptLog->rid = $rid;
  3936. $receiptLog->insert ();
  3937. return "/expenses";
  3938. }
  3939. function expenses() {
  3940. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  3941. if (empty ( $item ))
  3942. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  3943. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  3944. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  3945. Doo::loadClass ( 'XDeode' );
  3946. $XDeode = new XDeode ( 7 );
  3947. Doo::loadModel ( 'receipt' );
  3948. $receipt = new receipt ();
  3949. Doo::loadModel ( 'L_category' );
  3950. $Lcategory = new L_category ();
  3951. Doo::loadModel ( 'verify' );
  3952. Doo::loadModel ( 'statistics' );
  3953. $statistics = new statistics ();
  3954. $verify = new verify ();
  3955. Doo::loadModel ( 'staff' );
  3956. $staff = new staff ();
  3957. $condition = "";
  3958. if ($item == "expenses")
  3959. $condition = " and Rtype=1 ";
  3960. elseif ($item == "receipts")
  3961. $condition = " and Rtype=0 ";
  3962. elseif ($item == "remits")
  3963. $condition = " and Rtype=2 ";
  3964. elseif ($item == "train")
  3965. $condition = " and Rtype=3 ";
  3966. $dateCondition = " and Year(date) =" . $year;
  3967. if (! empty ( $moth )) {
  3968. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  3969. $stList = $statistics->getOne ( array (
  3970. 'select' => 'rePrice ,agPrice',
  3971. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  3972. 'asArray' => true
  3973. ) );
  3974. } else
  3975. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  3976. if (empty ( $stList ))
  3977. $stList = array (
  3978. 'rePrice' => 0,
  3979. 'agPrice' => 0
  3980. );
  3981. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  3982. if (! isset ( $noPassSum ['sum'] ))
  3983. $noPassSum ['sum'] = 0;
  3984. $data ['stList'] = array (
  3985. 'rePrice' => $stList ['rePrice'],
  3986. 'agPrice' => $stList ['agPrice'],
  3987. 'skPrice' => ($noPassSum ['sum'])
  3988. );
  3989. $receiptList = $receipt->find ( array (
  3990. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  3991. 'desc' => 'rid',
  3992. 'asArray' => true
  3993. ) );
  3994. $Locate = 0;
  3995. $roleId = 0;
  3996. $button = 0;
  3997. foreach ( $receiptList as $key => $value ) {
  3998. $receiptList[$key]['balance']='';
  3999. if($value['Rtype']==1){
  4000. $receiptList[$key]['balance']=$value['sum']-=$value['loanSum'];
  4001. $receiptList[$key]['balanceABS']=abs($receiptList[$key]['balance']);
  4002. }elseif($value['Rtype']==3){
  4003. $payment=$this->_getReceiptTrainPayment($value['invoiceTrainId'],$value['trainLoanRid'],$value['rid']);
  4004. $receiptList[$key]['payment']=$payment;
  4005. $receiptList[$key]['paymentABS']=abs($payment);
  4006. }
  4007. $receiptList [$key] ['Locate'] = $Locate;
  4008. $Locate ++;
  4009. $receiptList [$key] ['reviseDetail'] = array ();
  4010. if (! empty ( $value ['reviseDetail'] ))
  4011. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4012. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4013. $categoryDetil = $Lcategory->getOne ( array (
  4014. 'where' => 'cid=' . $value ['cid'],
  4015. 'asArray' => true
  4016. ) );
  4017. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4018. // 检测编辑状态
  4019. $verifyList = $verify->getOne ( array (
  4020. 'where' => 'vid=' . $value ['verify'],
  4021. 'asArray' => true
  4022. ) );
  4023. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4024. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4025. Doo::loadModel ( 'role' );
  4026. $role = new role ();
  4027. $flag = true;
  4028. $roleKey = 0;
  4029. $endStaffArray = array ();
  4030. $roleArrayCopy = array ();
  4031. foreach ( $verifyList as $k => $v ) {
  4032. // init verifyStaff
  4033. if ($v [1] == 'ROLE') {
  4034. if (! empty ( $verifyStaff )) {
  4035. $endStaffArray = end ( $verifyStaff );
  4036. // if ($v[0]==$endStaffArray['nextStaff']){
  4037. // $roleId=$v[0];
  4038. // }
  4039. }
  4040. $roleVerify = json_decode ( $v [3], true );
  4041. $roleKey = $k;
  4042. $roleArray = array ();
  4043. $rolename = $role->getOne ( array (
  4044. 'where' => 'rid=' . $v [0],
  4045. 'asArray' => true
  4046. ) );
  4047. foreach ( $roleVerify as $o => $p ) {
  4048. $staffID = explode ( '_', $p );
  4049. $staffInfo = $staff->getOne ( array (
  4050. 'where' => 'sid=' . $staffID [0],
  4051. 'asArray' => true
  4052. ) );
  4053. // print_r($staffID);
  4054. $exp = array (
  4055. 0 => $staffInfo ['sid'],
  4056. 1 => $staffID [1],
  4057. 2 => $staffInfo ['avatar'],
  4058. 'date' => '',
  4059. 'date' => '',
  4060. 'opinion' => '',
  4061. 'status' => '',
  4062. 'rolename' => $rolename ['name']
  4063. );
  4064. array_push ( $roleArray, $exp );
  4065. }
  4066. $roleArrayCopy [$v [0]] = $roleArray;
  4067. // $verifyList[$k]['roleArray']=$roleArray;
  4068. }
  4069. $verifyList [$k] ['date'] = "";
  4070. $verifyList [$k] ['opinion'] = "";
  4071. $verifyList [$k] ['status'] = "";
  4072. if (empty ( $verifyStaff )) {
  4073. $verifyList [$k] ['date'] = "";
  4074. $verifyList [$k] ['opinion'] = "";
  4075. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4076. $verifyList [$k] ['status'] = 4;
  4077. $flag = false;
  4078. }
  4079. } else {
  4080. foreach ( $verifyStaff as $m => $u ) {
  4081. if ($v [0] == $m) {
  4082. $verifyList [$k] ['date'] = $u ['date'];
  4083. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4084. $verifyList [$k] ['status'] = $u ['status'];
  4085. $flag = false;
  4086. break;
  4087. }
  4088. }
  4089. $endStaffArray = end ( $verifyStaff );
  4090. if (isset ( $endStaffArray ['ROLE'] )) {
  4091. } else {
  4092. // $endKey=key($verifyStaff);
  4093. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4094. // $button=4;
  4095. // $verifyList[$k]['status']=4;
  4096. // }
  4097. }
  4098. }
  4099. }
  4100. $rolename ['name'] = '';
  4101. if (! empty ( $roleId )) {
  4102. Doo::loadModel ( 'role' );
  4103. $role = new role ();
  4104. $rolename = $role->getOne ( array (
  4105. 'where' => 'rid=' . $roleId,
  4106. 'asArray' => true
  4107. ) );
  4108. }
  4109. if (! empty ( $verifyStaff ))
  4110. $endStaffArray = end ( $verifyStaff );
  4111. $KOP = false;
  4112. foreach ( $roleArrayCopy as $P => $A ) {
  4113. foreach ( $A as $MKI => $AVL ) {
  4114. if (! empty ( $verifyStaff )) {
  4115. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4116. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4117. $button = 4;
  4118. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4119. }
  4120. foreach ( $verifyStaff as $m => $u ) {
  4121. $AVLFK = $AVL [0] . '_R';
  4122. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4123. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4124. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4125. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4126. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4127. break;
  4128. }
  4129. }
  4130. } else {
  4131. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4132. $button = 4;
  4133. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4134. }
  4135. }
  4136. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4137. $KOP = true;
  4138. }
  4139. }
  4140. foreach ( $roleArrayCopy as $k => $v ) {
  4141. foreach ( $verifyList as $m => $n ) {
  4142. if ($n [0] == $k) {
  4143. array_splice ( $verifyList, $m, 1, $v );
  4144. }
  4145. }
  4146. }
  4147. $receiptList [$key] ['verifyList'] = $verifyList;
  4148. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4149. 'where' => 'sid=' . $value ['staff'],
  4150. 'asArray' => true
  4151. ) );
  4152. $receiptList [$key] ['button'] = $button;
  4153. $receiptList [$key] ['ridKey'] =$XDeode->encode( $value ['rid'] );
  4154. }
  4155. // print_r($receiptList);die;
  4156. $mothHtml = "";
  4157. for($i = 1; $i <= 12; $i ++) {
  4158. if ($moth == $i)
  4159. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4160. else
  4161. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4162. }
  4163. $dateHtml = "";
  4164. $now = date ( "Y" );
  4165. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  4166. if ($YEARD <= $now) {
  4167. $dateHtml .= '<option ';
  4168. if ($year == $YEARD) {
  4169. $dateHtml .= 'selected ';
  4170. }
  4171. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  4172. }
  4173. }
  4174. $data ['dateHtml'] = $dateHtml;
  4175. $data ['mothHtml'] = $mothHtml;
  4176. $data ['receiptList'] = $receiptList;
  4177. $data ['memu'] = "receipt";
  4178. $data ['staff'] = $this->staff;
  4179. $data ['receiptMemu'] = 'expenses';
  4180. $data ['verifyId'] = $this->verifyId;
  4181. $data ['executeId'] = $this->executeId;
  4182. $data ['item'] = $item;
  4183. $data ['year'] = $year;
  4184. $this->render ( "/admin/expenses", $data );
  4185. }
  4186. function expensesCollect() {
  4187. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4188. Doo::loadModel ( 'receipt' );
  4189. $receipt = new receipt ();
  4190. Doo::loadModel ( 'L_category' );
  4191. $Lcategory = new L_category ();
  4192. Doo::loadModel ( 'verify' );
  4193. Doo::loadModel ( 'statistics' );
  4194. $statistics = new statistics ();
  4195. $verify = new verify ();
  4196. Doo::loadModel ( 'staff' );
  4197. $staff = new staff ();
  4198. Doo::loadModel ( 'loanReceipt' );
  4199. $loanReceipt = new loanReceipt ();
  4200. $receiptList = $receipt->find ( array (//去掉
  4201. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  4202. 'desc' => 'rid',
  4203. 'asArray' => true
  4204. ) );
  4205. $loanList = $loanReceipt->find ( array (
  4206. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4207. 'desc' => 'rid',
  4208. 'asArray' => true
  4209. ) );
  4210. /*
  4211. * $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;
  4212. */
  4213. $data ['explanation'] = '';
  4214. if (! empty ( $loanList ))
  4215. $data ['explanation'] = $loanList [0] ['explanation'];
  4216. $Locate = 0;
  4217. $roleId = 0;
  4218. $button = 0;
  4219. foreach ( $receiptList as $key => $value ) {
  4220. $receiptList [$key] ['Locate'] = $Locate;
  4221. $Locate ++;
  4222. $receiptList [$key] ['reviseDetail'] = array ();
  4223. if (! empty ( $value ['reviseDetail'] ))
  4224. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4225. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4226. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4227. $categoryDetil = $Lcategory->getOne ( array (
  4228. 'where' => 'cid=' . $value ['cid'],
  4229. 'asArray' => true
  4230. ) );
  4231. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4232. // 检测编辑状态
  4233. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  4234. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  4235. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  4236. else
  4237. $verifyList ['staff'] = $value ['verifyBreakup'];
  4238. } else
  4239. $verifyList = $verify->getOne ( array (
  4240. 'where' => 'vid=' . $value ['verify'],
  4241. 'asArray' => true
  4242. ) );
  4243. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4244. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4245. Doo::loadModel ( 'role' );
  4246. $role = new role ();
  4247. $flag = true;
  4248. $roleKey = 0;
  4249. $endStaffArray = array ();
  4250. $roleArrayCopy = array ();
  4251. foreach ( $verifyList as $k => $v ) {
  4252. // init verifyStaff
  4253. if ($v [1] == 'ROLE') {
  4254. if (! empty ( $verifyStaff )) {
  4255. $endStaffArray = end ( $verifyStaff );
  4256. // if ($v[0]==$endStaffArray['nextStaff']){
  4257. // $roleId=$v[0];
  4258. // }
  4259. }
  4260. $roleVerify = json_decode ( $v [3], true );
  4261. $roleKey = $k;
  4262. $roleArray = array ();
  4263. $rolename = $role->getOne ( array (
  4264. 'where' => 'rid=' . $v [0],
  4265. 'asArray' => true
  4266. ) );
  4267. foreach ( $roleVerify as $o => $p ) {
  4268. $staffID = explode ( '_', $p );
  4269. $staffInfo = $staff->getOne ( array (
  4270. 'where' => 'sid=' . $staffID [0],
  4271. 'asArray' => true
  4272. ) );
  4273. // print_r($staffID);
  4274. $exp = array (
  4275. 0 => $staffInfo ['sid'],
  4276. 1 => $staffID [1],
  4277. 2 => $staffInfo ['avatar'],
  4278. 'date' => '',
  4279. 'date' => '',
  4280. 'opinion' => '',
  4281. 'status' => '',
  4282. 'rolename' => $rolename ['name']
  4283. );
  4284. array_push ( $roleArray, $exp );
  4285. }
  4286. $roleArrayCopy [$v [0]] = $roleArray;
  4287. // $verifyList[$k]['roleArray']=$roleArray;
  4288. }
  4289. $verifyList [$k] ['date'] = "";
  4290. $verifyList [$k] ['opinion'] = "";
  4291. $verifyList [$k] ['status'] = "";
  4292. if (empty ( $verifyStaff )) {
  4293. $verifyList [$k] ['date'] = "";
  4294. $verifyList [$k] ['opinion'] = "";
  4295. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4296. $verifyList [$k] ['status'] = 4;
  4297. $flag = false;
  4298. }
  4299. } else {
  4300. foreach ( $verifyStaff as $m => $u ) {
  4301. if ($v [0] == $m) {
  4302. $verifyList [$k] ['date'] = $u ['date'];
  4303. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4304. $verifyList [$k] ['status'] = $u ['status'];
  4305. $flag = false;
  4306. break;
  4307. }
  4308. }
  4309. $endStaffArray = end ( $verifyStaff );
  4310. if (isset ( $endStaffArray ['ROLE'] )) {
  4311. } else {
  4312. // $endKey=key($verifyStaff);
  4313. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4314. // $button=4;
  4315. // $verifyList[$k]['status']=4;
  4316. // }
  4317. }
  4318. }
  4319. }
  4320. $rolename ['name'] = '';
  4321. if (! empty ( $roleId )) {
  4322. Doo::loadModel ( 'role' );
  4323. $role = new role ();
  4324. $rolename = $role->getOne ( array (
  4325. 'where' => 'rid=' . $roleId,
  4326. 'asArray' => true
  4327. ) );
  4328. }
  4329. if (! empty ( $verifyStaff ))
  4330. $endStaffArray = end ( $verifyStaff );
  4331. $KOP = false;
  4332. foreach ( $roleArrayCopy as $P => $A ) {
  4333. foreach ( $A as $MKI => $AVL ) {
  4334. if (! empty ( $verifyStaff )) {
  4335. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4336. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4337. $button = 4;
  4338. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4339. }
  4340. foreach ( $verifyStaff as $m => $u ) {
  4341. $AVLFK = $AVL [0] . '_R';
  4342. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4343. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4344. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4345. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4346. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4347. break;
  4348. }
  4349. }
  4350. } else {
  4351. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4352. $button = 4;
  4353. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4354. }
  4355. }
  4356. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4357. $KOP = true;
  4358. }
  4359. }
  4360. foreach ( $roleArrayCopy as $k => $v ) {
  4361. foreach ( $verifyList as $m => $n ) {
  4362. if ($n [0] == $k) {
  4363. array_splice ( $verifyList, $m, 1, $v );
  4364. }
  4365. }
  4366. }
  4367. // 费用执行人相关数据
  4368. $executeCopy = json_decode ( $value ['executeCopy'], true );
  4369. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4370. foreach ( $executeCopy as $k => $v ) {
  4371. $executeCopy [$k] ['date'] = '';
  4372. $executeCopy [$k] ['opinion'] = '';
  4373. $executeCopy [$k] ['status'] = '';
  4374. if (! empty ( $executeStaff ))
  4375. foreach ( $executeStaff as $m => $u ) {
  4376. if ($v [0] == $m) {
  4377. $executeCopy [$k] ['date'] = $u ['date'];
  4378. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  4379. $executeCopy [$k] ['status'] = $u ['status'];
  4380. break;
  4381. }
  4382. }
  4383. }
  4384. $receiptList [$key] ['executeCopy'] = $executeCopy;
  4385. $receiptList [$key] ['verifyList'] = $verifyList;
  4386. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4387. 'where' => 'sid=' . $value ['staff'],
  4388. 'asArray' => true
  4389. ) );
  4390. $receiptList [$key] ['button'] = $button;
  4391. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4392. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4393. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4394. $receiptList [$key] ['relust'] = $relust;
  4395. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4396. }
  4397. Doo::loadModel ( 'enclosur' );
  4398. $enclosur = new enclosur ();
  4399. $enclosurList = $enclosur->find ( array (
  4400. 'where' => 'rid=' . $rid,
  4401. 'asArray' => true
  4402. ) );
  4403. $enclosurHtml = '';
  4404. foreach ( $enclosurList as $value ) {
  4405. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4406. }
  4407. $data ['enclosurHtml'] = $enclosurHtml;
  4408. //print_r($receiptList[0]['accountItem']['内部培训费用']);
  4409. $data ['receiptList'] = $receiptList;
  4410. $data ['memu'] = "receipt";
  4411. $data ['staff'] = $this->staff;
  4412. $data ['receiptMemu'] = 'expenses';
  4413. $data ['verifyId'] = $this->verifyId;
  4414. $data ['executeId'] = $this->executeId;
  4415. $this->render ( "/admin/expensesCollect", $data );
  4416. }
  4417. function approvalExpenses() {
  4418. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  4419. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4420. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4421. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4422. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4423. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  4424. // echo $rdate;
  4425. if (empty ( $status ))
  4426. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  4427. $page_size = 8;
  4428. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  4429. $vidList = array ();
  4430. $button = 0;
  4431. Doo::loadModel ( 'verify' );
  4432. $verify = new verify ();
  4433. Doo::loadModel ( 'receipt' );
  4434. $receipt = new receipt ();
  4435. Doo::loadModel ( 'staff' );
  4436. $staff = new staff ();
  4437. Doo::loadModel ( 'L_category' );
  4438. $Lcategory = new L_category ();
  4439. // user verify ID
  4440. $verifyDetail = $verify->find ( array (
  4441. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  4442. 'asArray' => true
  4443. ) );
  4444. foreach ( $verifyDetail as $key => $value ) {
  4445. array_push ( $vidList, $value ['vid'] );
  4446. }
  4447. $vid = implode ( ",", $vidList );
  4448. if (empty ( $verifyDetail ))
  4449. $vid = 0;
  4450. // if ($status==0)
  4451. // $dateCondition="";
  4452. // else
  4453. $dateCondition = " ";
  4454. // if (! empty ( $month ))
  4455. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  4456. if ($status == 'done' || $status == 'termination') {
  4457. if (! empty ( $year )) {
  4458. $dateCondition = " and Year(pastDate) =" . $year;
  4459. if (! empty ( $month ))
  4460. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  4461. }
  4462. } elseif ($status == 'finish') {
  4463. if (! empty ( $year )) {
  4464. $dateCondition = " and Year(pastDate) =" . $year;
  4465. if (! empty ( $month ))
  4466. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  4467. }
  4468. }
  4469. // date ( 'Y-m' )
  4470. // if (! empty ( $rdate ) && $status == 'done')
  4471. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  4472. // elseif (! empty ( $rdate ))
  4473. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  4474. $categoryList = $Lcategory->find ( array (
  4475. 'asArray' => true
  4476. ) );
  4477. $staffList = $staff->find ( array (
  4478. 'where' => 'cid=' . $cid,
  4479. 'asArray' => true
  4480. ) );
  4481. $cateCondition = "";
  4482. $staffCondition = "";
  4483. $approvalCondition = "";
  4484. if (! empty ( $cid )) {
  4485. $cateCondition = ' and cid=' . $cid;
  4486. }
  4487. if (! empty ( $sid )) {
  4488. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  4489. $cateCondition = "";
  4490. }
  4491. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  4492. if ($status == 'pendApproval') {
  4493. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  4494. }
  4495. if ($status == 'ongoing') {
  4496. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  4497. }
  4498. if ($status == 'done') {
  4499. $approvalCondition = ' and (status=8 or status=9 ) ';
  4500. }
  4501. if ($status == 'termination') {
  4502. $approvalCondition = " and status=3";
  4503. }
  4504. if ($status == 'finish') {
  4505. $approvalCondition = " and (status=1 or status=8 or status=9 or status=10)";
  4506. }
  4507. $pageinfo ['page'] = array (
  4508. 'previous' => ''
  4509. );
  4510. if(!empty($receiptOrder)){
  4511. $pageinfo = $this->get_page ( "CLD_receipt", ' and receiptOrder like "%' . $receiptOrder . '%"', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  4512. $receiptList = $receipt->find ( array ( // $dateCondition
  4513. 'where' => 'receiptOrder like "%' . $receiptOrder . '%"',
  4514. 'desc' => 'rid',
  4515. 'asArray' => true
  4516. ) );
  4517. }else{
  4518. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  4519. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  4520. $receiptList = $receipt->find ( array ( // $dateCondition.
  4521. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  4522. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  4523. 'desc' => 'rid',
  4524. 'asArray' => true
  4525. ) );
  4526. } else {
  4527. $receiptList = $receipt->find ( array ( // $dateCondition
  4528. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  4529. 'desc' => 'rid',
  4530. 'asArray' => true
  4531. ) );
  4532. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  4533. }
  4534. }
  4535. $rLRes = $receipt->find ( array (
  4536. '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 . ')',
  4537. 'desc' => 'rid',
  4538. 'asArray' => true
  4539. ) );
  4540. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  4541. // print_r($receiptList);
  4542. Doo::loadClass ( 'XDeode' );
  4543. $XDeode = new XDeode ( 7 );
  4544. $Locate = 0;
  4545. //
  4546. $reportList = $reportCateList = array ();
  4547. foreach ( $receiptList as $key => $value ) {
  4548. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4549. $receiptList [$key] ['Locate'] = $Locate;
  4550. $Locate ++;
  4551. $receiptList [$key] ['reviseDetail'] = array ();
  4552. if (! empty ( $value ['reviseDetail'] ))
  4553. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4554. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4555. $categoryDetil = $Lcategory->getOne ( array (
  4556. 'where' => 'cid=' . $value ['cid'],
  4557. 'asArray' => true
  4558. ) );
  4559. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4560. $verifyList = $verify->getOne ( array (
  4561. 'where' => 'vid=' . $value ['verify'],
  4562. 'asArray' => true
  4563. ) );
  4564. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4565. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4566. foreach ( $verifyList as $k => $v ) {
  4567. // init verifyStaff
  4568. $verifyList [$k] ['date'] = "";
  4569. $verifyList [$k] ['opinion'] = "";
  4570. $verifyList [$k] ['status'] = "";
  4571. if (empty ( $verifyStaff )) {
  4572. $verifyList [$k] ['date'] = "";
  4573. $verifyList [$k] ['opinion'] = "";
  4574. if ($v [0] == $this->staff [0] ['sid']) {
  4575. $verifyList [$k] ['status'] = 4;
  4576. $button = 4;
  4577. }
  4578. } else {
  4579. $flag = true;
  4580. foreach ( $verifyStaff as $m => $u ) {
  4581. if ($v [0] == $m) {
  4582. $verifyList [$k] ['date'] = $u ['date'];
  4583. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4584. $verifyList [$k] ['status'] = $u ['status'];
  4585. $flag = false;
  4586. break;
  4587. }
  4588. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  4589. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  4590. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  4591. }
  4592. if ($flag) { // 检测可编辑
  4593. if ($v [0] == $this->staff [0] ['sid']) {
  4594. $verifyList [$k] ['status'] = 4;
  4595. $button = 4;
  4596. }
  4597. }
  4598. }
  4599. }
  4600. $receiptList [$key] ['verifyList'] = $verifyList;
  4601. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4602. 'where' => 'sid=' . $value ['staff'],
  4603. 'asArray' => true
  4604. ) );
  4605. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  4606. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  4607. $receiptList [$key] ['button'] = $button;
  4608. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  4609. //获得培训班结算RID 借款费用--已经锁定
  4610. if($value['status']==10){
  4611. $trainRD=$receipt->getReceiptByTrainLoanRid($value['rid']);
  4612. $receiptList [$key]['trainRidKey7']=$trainRD['ridKey7'];
  4613. }
  4614. }
  4615. $reportList = array_unique ( $reportList );
  4616. $reportHtml = '';
  4617. foreach ( $reportList as $key => $value ) {
  4618. $v = explode ( "-", $value );
  4619. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  4620. }
  4621. // print_r($reportList)
  4622. $data ['reportHtml'] = $reportHtml;
  4623. $reportCateList = array_unique ( $reportCateList );
  4624. $reportCateHtml = '';
  4625. foreach ( $reportCateList as $key => $value ) {
  4626. $v = explode ( "-", $value );
  4627. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  4628. }
  4629. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  4630. $data ['reportCateHtml'] = $reportCateHtml;
  4631. // print_r($receiptList);die;
  4632. // $data['verifyDetail']=$verifyDetail;
  4633. $mothHtml = "";
  4634. for($i = 1; $i <= 12; $i ++) {
  4635. if ($month == $i)
  4636. $mothHtml .= '<option selected value="0' . $i . '">' . $i . '月</option>';
  4637. else
  4638. $mothHtml .= '<option value="0' . $i . '">' . $i . '月</option>';
  4639. }
  4640. $data ['mothHtml'] = $mothHtml;
  4641. $dateHtml = "";
  4642. $now = date ( "Y" );
  4643. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  4644. if ($YEARD <= $now) {
  4645. $dateHtml .= '<option ';
  4646. if ($year == $YEARD) {
  4647. $dateHtml .= 'selected ';
  4648. }
  4649. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  4650. }
  4651. }
  4652. $data ['dateHtml'] = $dateHtml;
  4653. $data ['page'] = $pageinfo;
  4654. $data ['receiptList'] = $receiptList;
  4655. $data ['receiptApprovalCount'] = count ( $rLRes );
  4656. $data ['status'] = $status;
  4657. $data ['year'] = $year;
  4658. $data ['month'] = $month;
  4659. $data ['categoryList'] = $categoryList;
  4660. $data ['staffList'] = $staffList;
  4661. $data ['cid'] = $cid;
  4662. $data ['sid'] = $sid;
  4663. // print_r($receiptList);
  4664. $data['receiptOrder']=$receiptOrder;
  4665. $data ['memu'] = "receipt";
  4666. $data ['staff'] = $this->staff;
  4667. $data ['receiptMemu'] = 'approvalExpenses';
  4668. $data ['verifyId'] = $this->verifyId;
  4669. $data ['executeId'] = $this->executeId;
  4670. $this->render ( "/admin/approvalExpenses", $data );
  4671. }
  4672. function expensesDoc() {
  4673. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  4674. Doo::loadClass ( 'XDeode' );
  4675. $XDeode = new XDeode ( 5 );
  4676. if (! empty ( $rid ) && ! is_numeric ( $rid ))
  4677. $rid = $XDeode->decode ( $rid );
  4678. if (! is_numeric ( $rid ))
  4679. die ( 'illegal request' );
  4680. Doo::loadModel ( 'receipt' );
  4681. $receipt = new receipt ();
  4682. Doo::loadModel ( 'L_category' );
  4683. $Lcategory = new L_category ();
  4684. Doo::loadModel ( 'verify' );
  4685. Doo::loadModel ( 'statistics' );
  4686. $statistics = new statistics ();
  4687. $verify = new verify ();
  4688. Doo::loadModel ( 'staff' );
  4689. $staff = new staff ();
  4690. Doo::loadModel ( 'loanReceipt' );
  4691. $loanReceipt = new loanReceipt ();
  4692. $receiptList = $receipt->find ( array (
  4693. 'where' => ' rid=' . $rid,
  4694. 'desc' => 'rid',
  4695. 'asArray' => true
  4696. ) );
  4697. $loanList = array ();
  4698. if (! empty ( $receiptList ))
  4699. $loanList = $loanReceipt->find ( array (
  4700. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4701. 'desc' => 'rid',
  4702. 'asArray' => true
  4703. ) );
  4704. $Locate = 0;
  4705. $roleId = 0;
  4706. $button = 0;
  4707. foreach ( $loanList as $key => $value ) {
  4708. $loanList [$key] ['Locate'] = $Locate;
  4709. $Locate ++;
  4710. $loanList [$key] ['reviseDetail'] = array ();
  4711. if (! empty ( $value ['reviseDetail'] ))
  4712. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4713. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4714. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4715. $categoryDetil = $Lcategory->getOne ( array (
  4716. 'where' => 'cid=' . $value ['cid'],
  4717. 'asArray' => true
  4718. ) );
  4719. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4720. // 检测编辑状态
  4721. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  4722. $verifyList ['staff'] = $value ['verifyBreakup'];
  4723. else
  4724. $verifyList = $verify->getOne ( array (
  4725. 'where' => 'vid=' . $value ['verify'],
  4726. 'asArray' => true
  4727. ) );
  4728. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4729. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4730. Doo::loadModel ( 'role' );
  4731. $role = new role ();
  4732. $flag = true;
  4733. $roleKey = 0;
  4734. $endStaffArray = array ();
  4735. $roleArrayCopy = array ();
  4736. foreach ( $verifyList as $k => $v ) {
  4737. // init verifyStaff
  4738. if ($v [1] == 'ROLE') {
  4739. if (! empty ( $verifyStaff )) {
  4740. $endStaffArray = end ( $verifyStaff );
  4741. // if ($v[0]==$endStaffArray['nextStaff']){
  4742. // $roleId=$v[0];
  4743. // }
  4744. }
  4745. $roleVerify = json_decode ( $v [3], true );
  4746. $roleKey = $k;
  4747. $roleArray = array ();
  4748. $rolename = $role->getOne ( array (
  4749. 'where' => 'rid=' . $v [0],
  4750. 'asArray' => true
  4751. ) );
  4752. foreach ( $roleVerify as $o => $p ) {
  4753. $staffID = explode ( '_', $p );
  4754. $staffInfo = $staff->getOne ( array (
  4755. 'where' => 'sid=' . $staffID [0],
  4756. 'asArray' => true
  4757. ) );
  4758. // print_r($staffID);
  4759. $exp = array (
  4760. 0 => $staffInfo ['sid'],
  4761. 1 => $staffID [1],
  4762. 2 => $staffInfo ['avatar'],
  4763. 'date' => '',
  4764. 'date' => '',
  4765. 'opinion' => '',
  4766. 'status' => '',
  4767. 'rolename' => $rolename ['name']
  4768. );
  4769. array_push ( $roleArray, $exp );
  4770. }
  4771. $roleArrayCopy [$v [0]] = $roleArray;
  4772. // $verifyList[$k]['roleArray']=$roleArray;
  4773. }
  4774. $verifyList [$k] ['date'] = "";
  4775. $verifyList [$k] ['opinion'] = "";
  4776. $verifyList [$k] ['status'] = "";
  4777. if (empty ( $verifyStaff )) {
  4778. $verifyList [$k] ['date'] = "";
  4779. $verifyList [$k] ['opinion'] = "";
  4780. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4781. $verifyList [$k] ['status'] = 4;
  4782. $flag = false;
  4783. }
  4784. } else {
  4785. foreach ( $verifyStaff as $m => $u ) {
  4786. if ($v [0] == $m) {
  4787. $verifyList [$k] ['date'] = $u ['date'];
  4788. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4789. $verifyList [$k] ['status'] = $u ['status'];
  4790. $flag = false;
  4791. break;
  4792. }
  4793. }
  4794. $endStaffArray = end ( $verifyStaff );
  4795. if (isset ( $endStaffArray ['ROLE'] )) {
  4796. } else {
  4797. // $endKey=key($verifyStaff);
  4798. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4799. // $button=4;
  4800. // $verifyList[$k]['status']=4;
  4801. // }
  4802. }
  4803. }
  4804. }
  4805. $rolename ['name'] = '';
  4806. if (! empty ( $roleId )) {
  4807. Doo::loadModel ( 'role' );
  4808. $role = new role ();
  4809. $rolename = $role->getOne ( array (
  4810. 'where' => 'rid=' . $roleId,
  4811. 'asArray' => true
  4812. ) );
  4813. }
  4814. if (! empty ( $verifyStaff ))
  4815. $endStaffArray = end ( $verifyStaff );
  4816. $KOP = false;
  4817. foreach ( $roleArrayCopy as $P => $A ) {
  4818. foreach ( $A as $MKI => $AVL ) {
  4819. if (! empty ( $verifyStaff )) {
  4820. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4821. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4822. $button = 4;
  4823. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4824. }
  4825. foreach ( $verifyStaff as $m => $u ) {
  4826. $AVLFK = $AVL [0] . '_R';
  4827. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4828. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4829. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4830. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4831. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4832. break;
  4833. }
  4834. }
  4835. } else {
  4836. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4837. $button = 4;
  4838. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4839. }
  4840. }
  4841. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4842. $KOP = true;
  4843. }
  4844. }
  4845. foreach ( $roleArrayCopy as $k => $v ) {
  4846. foreach ( $verifyList as $m => $n ) {
  4847. if ($n [0] == $k) {
  4848. array_splice ( $verifyList, $m, 1, $v );
  4849. }
  4850. }
  4851. }
  4852. $loanList [$key] ['verifyList'] = $verifyList;
  4853. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  4854. 'where' => 'sid=' . $value ['staff'],
  4855. 'asArray' => true
  4856. ) );
  4857. $loanList [$key] ['button'] = $button;
  4858. //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  4859. }
  4860. $data ['loanList'] = $loanList;
  4861. //print_r($loanList);
  4862. $Locate = 0;
  4863. $roleId = 0;
  4864. $button = 0;
  4865. foreach ( $receiptList as $key => $value ) {
  4866. $receiptList [$key] ['Locate'] = $Locate;
  4867. $Locate ++;
  4868. $receiptList [$key] ['reviseDetail'] = array ();
  4869. if (! empty ( $value ['reviseDetail'] ))
  4870. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4871. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4872. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4873. $categoryDetil = $Lcategory->getOne ( array (
  4874. 'where' => 'cid=' . $value ['cid'],
  4875. 'asArray' => true
  4876. ) );
  4877. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4878. // 检测编辑状态
  4879. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  4880. $verifyList ['staff'] = $value ['verifyBreakup'];
  4881. } else
  4882. $verifyList = $verify->getOne ( array (
  4883. 'where' => 'vid=' . $value ['verify'],
  4884. 'asArray' => true
  4885. ) );
  4886. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4887. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4888. Doo::loadModel ( 'role' );
  4889. $role = new role ();
  4890. if ($verifyList == NULL)
  4891. $verifyList = array ();
  4892. $flag = true;
  4893. $roleKey = 0;
  4894. $endStaffArray = array ();
  4895. $roleArrayCopy = array ();
  4896. foreach ( $verifyList as $k => $v ) {
  4897. // init verifyStaff
  4898. if ($v [1] == 'ROLE') {
  4899. if (! empty ( $verifyStaff )) {
  4900. $endStaffArray = end ( $verifyStaff );
  4901. // if ($v[0]==$endStaffArray['nextStaff']){
  4902. // $roleId=$v[0];
  4903. // }
  4904. }
  4905. $roleVerify = json_decode ( $v [3], true );
  4906. $roleKey = $k;
  4907. $roleArray = array ();
  4908. $rolename = $role->getOne ( array (
  4909. 'where' => 'rid=' . $v [0],
  4910. 'asArray' => true
  4911. ) );
  4912. foreach ( $roleVerify as $o => $p ) {
  4913. $staffID = explode ( '_', $p );
  4914. $staffInfo = $staff->getOne ( array (
  4915. 'where' => 'sid=' . $staffID [0],
  4916. 'asArray' => true
  4917. ) );
  4918. // print_r($staffID);
  4919. $exp = array (
  4920. 0 => $staffInfo ['sid'],
  4921. 1 => $staffID [1],
  4922. 2 => $staffInfo ['avatar'],
  4923. 'date' => '',
  4924. 'date' => '',
  4925. 'opinion' => '',
  4926. 'status' => '',
  4927. 'rolename' => $rolename ['name']
  4928. );
  4929. array_push ( $roleArray, $exp );
  4930. }
  4931. $roleArrayCopy [$v [0]] = $roleArray;
  4932. // $verifyList[$k]['roleArray']=$roleArray;
  4933. }
  4934. $verifyList [$k] ['date'] = "";
  4935. $verifyList [$k] ['opinion'] = "";
  4936. $verifyList [$k] ['status'] = "";
  4937. if (empty ( $verifyStaff )) {
  4938. $verifyList [$k] ['date'] = "";
  4939. $verifyList [$k] ['opinion'] = "";
  4940. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4941. $verifyList [$k] ['status'] = 4;
  4942. $flag = false;
  4943. }
  4944. } else {
  4945. foreach ( $verifyStaff as $m => $u ) {
  4946. if ($v [0] == $m) {
  4947. $verifyList [$k] ['date'] = $u ['date'];
  4948. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4949. $verifyList [$k] ['status'] = $u ['status'];
  4950. $flag = false;
  4951. break;
  4952. }
  4953. }
  4954. $endStaffArray = end ( $verifyStaff );
  4955. if (isset ( $endStaffArray ['ROLE'] )) {
  4956. } else {
  4957. // $endKey=key($verifyStaff);
  4958. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4959. // $button=4;
  4960. // $verifyList[$k]['status']=4;
  4961. // }
  4962. }
  4963. }
  4964. }
  4965. $FC = @$rolename ['name'];
  4966. $rolename ['name'] = '';
  4967. if (! empty ( $roleId )) {
  4968. Doo::loadModel ( 'role' );
  4969. $role = new role ();
  4970. $rolename = $role->getOne ( array (
  4971. 'where' => 'rid=' . $roleId,
  4972. 'asArray' => true
  4973. ) );
  4974. }
  4975. if (! empty ( $verifyStaff ))
  4976. $endStaffArray = end ( $verifyStaff );
  4977. $KOP = false;
  4978. foreach ( $roleArrayCopy as $P => $A ) {
  4979. foreach ( $A as $MKI => $AVL ) {
  4980. if (! empty ( $verifyStaff )) {
  4981. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4982. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4983. $button = 4;
  4984. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4985. }
  4986. foreach ( $verifyStaff as $m => $u ) {
  4987. $AVLFK = $AVL [0] . '_R';
  4988. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4989. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4990. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4991. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4992. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4993. break;
  4994. }
  4995. }
  4996. } else {
  4997. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4998. $button = 4;
  4999. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5000. }
  5001. }
  5002. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5003. $KOP = true;
  5004. }
  5005. }
  5006. foreach ( $roleArrayCopy as $k => $v ) {
  5007. foreach ( $verifyList as $m => $n ) {
  5008. if ($n [0] == $k) {
  5009. array_splice ( $verifyList, $m, 1, $v );
  5010. }
  5011. }
  5012. }
  5013. // 费用执行人相关数据
  5014. $executeCopy = json_decode ( $value ['executeCopy'], true );
  5015. $executeStaff = json_decode ( $value ['executeStaff'], true );
  5016. foreach ( $executeCopy as $k => $v ) {
  5017. $executeCopy [$k] ['date'] = '';
  5018. $executeCopy [$k] ['opinion'] = '';
  5019. $executeCopy [$k] ['status'] = '';
  5020. if (! empty ( $executeStaff ))
  5021. foreach ( $executeStaff as $m => $u ) {
  5022. if ($v [0] == $m) {
  5023. $executeCopy [$k] ['date'] = $u ['date'];
  5024. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  5025. $executeCopy [$k] ['status'] = $u ['status'];
  5026. break;
  5027. }
  5028. }
  5029. }
  5030. $receiptList [$key] ['executeCopy'] = $executeCopy;
  5031. // print_r($verifyList);
  5032. $receiptList [$key] ['verifyList'] = $verifyList;
  5033. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5034. 'where' => 'sid=' . $value ['staff'],
  5035. 'asArray' => true
  5036. ) );
  5037. $receiptList [$key] ['button'] = $button;
  5038. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5039. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5040. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5041. $receiptList [$key] ['relust'] = $relust;
  5042. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  5043. }
  5044. // print_r($receiptList);
  5045. // 获取审批日志
  5046. Doo::loadModel ( 'receiptLog' );
  5047. $receiptLog = new receiptLog ();
  5048. $rlList = array ();
  5049. $rlInfo = $receiptLog->getOne ( array (
  5050. 'where' => 'rid=' . $rid . ' and status=4',
  5051. 'asArray' => true
  5052. ) );
  5053. // $tijdate = $receiptLog->getOne ( array (
  5054. // 'where' => 'rid=' . $rid . ' and status=2',
  5055. // 'asc' => 'rlid',
  5056. // 'asArray' => true
  5057. // ) );
  5058. if (! empty ( $rlInfo )) {
  5059. $rlList = $receiptLog->find ( array (
  5060. 'where' => 'rid=' . $rid,
  5061. 'asc' => 'rlid',
  5062. 'asArray' => true
  5063. ) );
  5064. }
  5065. $RN=array();
  5066. if (!empty( $rolename ['staff'])){
  5067. $RN = @json_decode ( $rolename ['staff'] );
  5068. }
  5069. //
  5070. foreach ( $rlList as $key => $value ) {
  5071. $rlList [$key] ['rolename'] = '';
  5072. foreach ( $RN as $k => $v ) {
  5073. $id = explode ( "_", $v );
  5074. if ($id [0] == $value ['uid']) {
  5075. $rlList [$key] ['rolename'] = $FC;
  5076. break;
  5077. }
  5078. }
  5079. }
  5080. Doo::loadModel ( 'enclosur' );
  5081. $enclosur = new enclosur ();
  5082. $enclosurList = $enclosur->find ( array (
  5083. 'where' => 'rid=' . $rid,
  5084. 'asArray' => true
  5085. ) );
  5086. $enclosurHtml = '';
  5087. foreach ( $enclosurList as $value ) {
  5088. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5089. }
  5090. $data ['enclosurHtml'] = $enclosurHtml;
  5091. $receiptList [0] ['rlList'] = $rlList;
  5092. $data ['receiptList'] = $receiptList;
  5093. // print_r($receiptList);
  5094. $data ['memu'] = "receipt";
  5095. $data ['staff'] = $this->staff;
  5096. $data ['receiptMemu'] = 'approvalExpenses';
  5097. $data ['verifyId'] = $this->verifyId;
  5098. $data ['executeId'] = $this->executeId;
  5099. $this->render ( "/admin/expensesDoc", $data );
  5100. }
  5101. function expensesEdi() {
  5102. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5103. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5104. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5105. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5106. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5107. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5108. if (empty ( $status ))
  5109. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5110. $vidList = array ();
  5111. $button = 0;
  5112. Doo::loadModel ( 'verify' );
  5113. Doo::loadModel ( 'receipt' );
  5114. Doo::loadModel ( 'staff' );
  5115. $staff = new staff ();
  5116. $receipt = new receipt ();
  5117. $verify = new verify ();
  5118. Doo::loadModel ( 'L_category' );
  5119. $Lcategory = new L_category ();
  5120. Doo::loadModel ( 'enclosur' );
  5121. $enclosur = new enclosur ();
  5122. // user verify ID
  5123. $verifyDetail = $verify->find ( array (
  5124. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5125. 'asArray' => true
  5126. ) );
  5127. foreach ( $verifyDetail as $key => $value ) {
  5128. array_push ( $vidList, $value ['vid'] );
  5129. }
  5130. $vid = implode ( ",", $vidList );
  5131. if (empty ( $verifyDetail ))
  5132. $vid = 0;
  5133. $categoryList = $Lcategory->find ( array (
  5134. 'asArray' => true
  5135. ) );
  5136. $staffList = $staff->find ( array (
  5137. 'where' => 'cid=' . $cid,
  5138. 'asArray' => true
  5139. ) );
  5140. $ap = "";
  5141. if ($status == 4) {
  5142. $ap = 4;
  5143. $status = 2;
  5144. }
  5145. // get Receipt By verifyID status 2
  5146. $receiptList = $receipt->find ( array (
  5147. 'where' => 'rid =' . $rid . ' and status=2',
  5148. 'desc' => 'rid',
  5149. 'asArray' => true
  5150. ) );
  5151. if (empty ( $receiptList )) {
  5152. die ( 'illegal request' );
  5153. }
  5154. $Locate = 0;
  5155. $roleId = 0;
  5156. if ($ap == 4)
  5157. $status = 4;
  5158. foreach ( $receiptList as $key => $value ) {
  5159. $receiptList [$key] ['Locate'] = $Locate;
  5160. $Locate ++;
  5161. $receiptList [$key] ['reviseDetail'] = array ();
  5162. if (! empty ( $value ['reviseDetail'] ))
  5163. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5164. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5165. $categoryDetil = $Lcategory->getOne ( array (
  5166. 'where' => 'cid=' . $value ['cid'],
  5167. 'asArray' => true
  5168. ) );
  5169. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5170. // 检测编辑状态
  5171. $verifyList = $verify->getOne ( array (
  5172. 'where' => 'vid=' . $value ['verify'],
  5173. 'asArray' => true
  5174. ) );
  5175. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5176. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5177. Doo::loadModel ( 'role' );
  5178. $role = new role ();
  5179. // print_r($verifyList);
  5180. $flag = true;
  5181. $roleKey = 0;
  5182. $endStaffArray = array ();
  5183. $roleArrayCopy = array ();
  5184. foreach ( $verifyList as $k => $v ) {
  5185. // init verifyStaff
  5186. if ($v [1] == 'ROLE') {
  5187. if (! empty ( $verifyStaff )) {
  5188. $endStaffArray = end ( $verifyStaff );
  5189. if ($v [0] == $endStaffArray ['nextStaff']) {
  5190. $roleId = $v [0];
  5191. }
  5192. }
  5193. $roleVerify = json_decode ( $v [3], true );
  5194. $roleKey = $k;
  5195. $roleArray = array ();
  5196. $rolename = $role->getOne ( array (
  5197. 'where' => 'rid=' . $v [0],
  5198. 'asArray' => true
  5199. ) );
  5200. foreach ( $roleVerify as $o => $p ) {
  5201. $staffID = explode ( '_', $p );
  5202. $staffInfo = $staff->getOne ( array (
  5203. 'where' => 'sid=' . $staffID [0],
  5204. 'asArray' => true
  5205. ) );
  5206. // print_r($staffID);
  5207. $exp = array (
  5208. 0 => $staffInfo ['sid'],
  5209. 1 => $staffID [1],
  5210. 2 => $staffInfo ['avatar'],
  5211. 'date' => '',
  5212. 'date' => '',
  5213. 'opinion' => '',
  5214. 'status' => '',
  5215. 'rolename' => $rolename ['name']
  5216. );
  5217. array_push ( $roleArray, $exp );
  5218. }
  5219. $roleArrayCopy [$v [0]] = $roleArray;
  5220. // $verifyList[$k]['roleArray']=$roleArray;
  5221. }
  5222. // print_r($roleArray);
  5223. $verifyList [$k] ['date'] = "";
  5224. $verifyList [$k] ['opinion'] = "";
  5225. $verifyList [$k] ['status'] = "";
  5226. if (empty ( $verifyStaff )) {
  5227. $verifyList [$k] ['date'] = "";
  5228. $verifyList [$k] ['opinion'] = "";
  5229. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5230. $verifyList [$k] ['status'] = 4;
  5231. $button = 4;
  5232. $flag = false;
  5233. }
  5234. } else {
  5235. foreach ( $verifyStaff as $m => $u ) {
  5236. if ($v [0] == $m) {
  5237. $verifyList [$k] ['date'] = $u ['date'];
  5238. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5239. $verifyList [$k] ['status'] = $u ['status'];
  5240. $flag = false;
  5241. break;
  5242. }
  5243. }
  5244. $endStaffArray = end ( $verifyStaff );
  5245. if (isset ( $endStaffArray ['ROLE'] )) {
  5246. } else {
  5247. $endKey = key ( $verifyStaff );
  5248. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5249. $button = 4;
  5250. $verifyList [$k] ['status'] = 4;
  5251. }
  5252. }
  5253. }
  5254. }
  5255. $rolename ['name'] = '';
  5256. if (! empty ( $roleId )) {
  5257. Doo::loadModel ( 'role' );
  5258. $role = new role ();
  5259. $rolename = $role->getOne ( array (
  5260. 'where' => 'rid=' . $roleId,
  5261. 'asArray' => true
  5262. ) );
  5263. }
  5264. if (! empty ( $verifyStaff ))
  5265. $endStaffArray = end ( $verifyStaff );
  5266. $KOP = false;
  5267. foreach ( $roleArrayCopy as $P => $A ) {
  5268. foreach ( $A as $MKI => $AVL ) {
  5269. if (! empty ( $verifyStaff )) {
  5270. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5271. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5272. $button = 4;
  5273. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5274. }
  5275. foreach ( $verifyStaff as $m => $u ) {
  5276. $AVLFK = $AVL [0] . '_R';
  5277. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5278. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5279. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5280. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5281. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5282. break;
  5283. }
  5284. }
  5285. } else {
  5286. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5287. $button = 4;
  5288. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5289. }
  5290. }
  5291. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5292. $KOP = true;
  5293. }
  5294. }
  5295. // print_r($roleArrayCopy);
  5296. // echo $roleKey;
  5297. foreach ( $roleArrayCopy as $k => $v ) {
  5298. foreach ( $verifyList as $m => $n ) {
  5299. if ($n [0] == $k) {
  5300. array_splice ( $verifyList, $m, 1, $v );
  5301. }
  5302. }
  5303. }
  5304. $receiptList [$key] ['verifyList'] = $verifyList;
  5305. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5306. 'where' => 'sid=' . $value ['staff'],
  5307. 'asArray' => true
  5308. ) );
  5309. $receiptList [$key] ['button'] = $button;
  5310. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  5311. }
  5312. // $data['verifyDetail']=$verifyDetail;
  5313. $mothHtml = "";
  5314. for($i = 1; $i <= 12; $i ++) {
  5315. if ($month == $i)
  5316. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5317. else
  5318. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5319. }
  5320. // 获取审批日志
  5321. Doo::loadModel ( 'receiptLog' );
  5322. $receiptLog = new receiptLog ();
  5323. $rlList = array ();
  5324. $rlInfo = $receiptLog->getOne ( array (
  5325. 'where' => 'rid=' . $rid . ' and status=4',
  5326. 'asArray' => true
  5327. ) );
  5328. $tijdate = $receiptLog->getOne ( array (
  5329. 'where' => 'rid=' . $rid . ' and status=2',
  5330. 'asc' => 'rlid',
  5331. 'asArray' => true
  5332. ) );
  5333. if (! empty ( $rlInfo )) {
  5334. $rlList = $receiptLog->find ( array (
  5335. 'where' => 'rid=' . $rid,
  5336. 'asc' => 'rlid',
  5337. 'asArray' => true
  5338. ) );
  5339. }
  5340. $receiptList [0] ['rlList'] = $rlList;
  5341. $enclosurList = $enclosur->find ( array (
  5342. 'where' => 'rid=' . $rid,
  5343. 'asArray' => true
  5344. ) );
  5345. $enclosurHtml = '';
  5346. foreach ( $enclosurList as $value ) {
  5347. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5348. }
  5349. // print_r($receiptList);
  5350. $data ['rid'] = $rid;
  5351. $data ['enclosurHtml'] = $enclosurHtml;
  5352. $data ['rolename'] = $rolename ['name'];
  5353. $data ['datetij'] = $tijdate ['date'];
  5354. $data ['mothHtml'] = $mothHtml;
  5355. $data ['receiptList'] = $receiptList;
  5356. $data ['receiptApprovalCount'] = count ( $receiptList );
  5357. $data ['status'] = $status;
  5358. $data ['year'] = $year;
  5359. $data ['categoryList'] = $categoryList;
  5360. $data ['staffList'] = $staffList;
  5361. $data ['cid'] = $cid;
  5362. $data ['sid'] = $sid;
  5363. $data ['ap'] = $ap;
  5364. $data ['memu'] = "receipt";
  5365. $data ['staff'] = $this->staff;
  5366. $data ['receiptMemu'] = 'approvalExpenses';
  5367. $data ['verifyId'] = $this->verifyId;
  5368. $data ['executeId'] = $this->executeId;
  5369. $this->render ( "/admin/expensesEdi", $data );
  5370. }
  5371. function expensesDefray() {
  5372. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  5373. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  5374. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5375. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  5376. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  5377. if (! empty ( $rid )) {
  5378. Doo::loadModel ( "verify" );
  5379. $verify = new verify ();
  5380. Doo::loadModel ( "receiptDetail" );
  5381. $receiptDetailObj = new receiptDetail ();
  5382. Doo::loadModel ( "itemStatistics" );
  5383. Doo::loadModel ( "statistics" );
  5384. $statistics = new statistics ();
  5385. $itemStatistics = new itemStatistics ();
  5386. Doo::loadModel ( "receipt" );
  5387. $receipt = new receipt ();
  5388. Doo::loadModel ( "loanReceipt" );
  5389. $loanReceipt = new loanReceipt ();
  5390. $receiptDetail = $receipt->getOne ( array (
  5391. 'where' => 'rid=' . $rid . ' and status=2 ',
  5392. 'asArray' => true
  5393. ) );
  5394. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  5395. $nsflag = true;
  5396. foreach ( $nslist as $value ) {
  5397. if ($value == $this->staff ['0'] ['sid']) {
  5398. $nsflag = false;
  5399. break;
  5400. }
  5401. }
  5402. // print_r($nslist);die;
  5403. if (empty ( $receiptDetail ) || $nsflag)
  5404. return "/approvalExpenses/pendApproval";
  5405. $verifyDetail = $verify->getOne ( array (
  5406. 'where' => ' vid =' . $receiptDetail ['verify'],
  5407. 'asArray' => true
  5408. ) );
  5409. $verifyString = $verifyDetail ['staff'];
  5410. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5411. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  5412. if (empty ( $opinion )) {
  5413. if ($status == 3)
  5414. $opinion = "终止";
  5415. else
  5416. $opinion = "同意支付";
  5417. }
  5418. $nowStaff = 0;
  5419. $nowStaffList = array ();
  5420. if (empty ( $verifyStaff )) {
  5421. // 还需加入是否已经进入角色审批
  5422. if ($verifyDetail [0] [1] == 'ROLE') {
  5423. // print_r($verifyDetail);echo "ddd";
  5424. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5425. foreach ( $vStaffString as $key => $value ) {
  5426. $staffK = explode ( "_", $value );
  5427. if ($staffK [0] != $this->staff [0] ['sid'])
  5428. array_push ( $nowStaffList, $staffK [0] );
  5429. }
  5430. // print_r($verifyDetail);
  5431. // die;
  5432. if (! empty ( $nowStaffList )) {
  5433. $nowStaff = implode ( ',', $nowStaffList );
  5434. $verifyStaff = array (
  5435. $this->staff [0] ['sid'] . "_R" => array (
  5436. 'date' => date ( 'Y-m-d' ),
  5437. 'opinion' => $opinion,
  5438. 'status' => $status,
  5439. 'nextStaff' => $verifyDetail [0] [0],
  5440. 'ROLE' => 1
  5441. )
  5442. );
  5443. } else {
  5444. $nowStaff = $verifyDetail [1] [0];
  5445. $verifyStaff = array (
  5446. $this->staff [0] ['sid'] . "_R" => array (
  5447. 'date' => date ( 'Y-m-d' ),
  5448. 'opinion' => $opinion,
  5449. 'status' => $status,
  5450. 'nextStaff' => $verifyDetail [1] [0]
  5451. )
  5452. );
  5453. }
  5454. } else {
  5455. if ($verifyDetail [1] [1] == 'ROLE') {
  5456. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  5457. // echo "dd";
  5458. foreach ( $vStaffString as $key => $value ) {
  5459. $staffK = explode ( "_", $value );
  5460. array_push ( $nowStaffList, $staffK [0] );
  5461. }
  5462. $nowStaff = implode ( ',', $nowStaffList );
  5463. $verifyStaff = array (
  5464. $this->staff [0] ['sid'] => array (
  5465. 'date' => date ( 'Y-m-d' ),
  5466. 'opinion' => $opinion,
  5467. 'status' => $status,
  5468. 'nextStaff' => $verifyDetail [1] [0],
  5469. 'ROLE' => 1
  5470. )
  5471. );
  5472. } else {
  5473. $nowStaff = $verifyDetail [1] [0];
  5474. $verifyStaff = array (
  5475. $this->staff [0] ['sid'] => array (
  5476. 'date' => date ( 'Y-m-d' ),
  5477. 'opinion' => $opinion,
  5478. 'status' => $status,
  5479. 'nextStaff' => $verifyDetail [1] [0]
  5480. )
  5481. );
  5482. }
  5483. }
  5484. if ($status == 3)
  5485. $verifyStaff = array (
  5486. 'final' => $status,
  5487. $this->staff [0] ['sid'] => array (
  5488. 'date' => date ( 'Y-m-d' ),
  5489. 'opinion' => $opinion,
  5490. 'status' => $status
  5491. )
  5492. );
  5493. $vStaffString = json_encode ( $verifyStaff );
  5494. $receipt->nowStaff = $nowStaff;
  5495. $receipt->verifyStaff = $vStaffString;
  5496. $loanReceipt->nowStaff = $nowStaff;
  5497. $loanReceipt->verifyStaff = $vStaffString;
  5498. } else {
  5499. $VS = end ( $verifyStaff );
  5500. // 非角色审批
  5501. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  5502. $nextStaff = 0;
  5503. $roleSTF = false;
  5504. foreach ( $verifyDetail as $key => $value ) {
  5505. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  5506. if (isset ( $verifyDetail [$key + 1] )) {
  5507. $nextStaff = $verifyDetail [$key + 1] [0];
  5508. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  5509. $roleSTF = true;
  5510. }
  5511. break;
  5512. }
  5513. }
  5514. if (! $roleSTF) {
  5515. $nowStaff = $nextStaff;
  5516. $verifyStaff [$this->staff [0] ['sid']] = array (
  5517. 'date' => date ( 'Y-m-d' ),
  5518. 'opinion' => $opinion,
  5519. 'status' => $status,
  5520. 'nextStaff' => $nextStaff
  5521. );
  5522. } else {
  5523. // 获取角色下的所有用户ID
  5524. $nowStaffList = array ();
  5525. foreach ( $verifyDetail as $vfk ) {
  5526. if ($vfk [1] == 'ROLE') {
  5527. $vStaffString = json_decode ( $vfk [3] );
  5528. foreach ( $vStaffString as $key => $value ) {
  5529. $staffK = explode ( "_", $value );
  5530. array_push ( $nowStaffList, $staffK [0] );
  5531. }
  5532. }
  5533. }
  5534. $nowStaff = implode ( ',', $nowStaffList );
  5535. $verifyStaff [$this->staff [0] ['sid']] = array (
  5536. 'date' => date ( 'Y-m-d' ),
  5537. 'opinion' => $opinion,
  5538. 'status' => $status,
  5539. 'nextStaff' => $nextStaff,
  5540. 'ROLE' => 0
  5541. );
  5542. }
  5543. if ($status == 3) {
  5544. $verifyStaff ['final'] = $status;
  5545. $verifyStaff [$this->staff [0] ['sid']] = array (
  5546. 'date' => date ( 'Y-m-d' ),
  5547. 'opinion' => $opinion,
  5548. 'status' => $status
  5549. );
  5550. }
  5551. $vStaffString = json_encode ( $verifyStaff );
  5552. $receipt->nowStaff = $nowStaff;
  5553. $receipt->verifyStaff = $vStaffString;
  5554. $loanReceipt->nowStaff = $nowStaff;
  5555. $loanReceipt->verifyStaff = $vStaffString;
  5556. }
  5557. // 角色审批
  5558. if (isset ( $VS ['ROLE'] )) {
  5559. // 找出角色人 当前审批角色组
  5560. $verifyJSStaff = array ();
  5561. $nowStaffList2 = array ();
  5562. foreach ( $verifyDetail as $key => $value ) {
  5563. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  5564. $verifyJSStaff = json_decode ( $value [3] );
  5565. foreach ( $verifyJSStaff as $m ) {
  5566. $staffK = explode ( "_", $m );
  5567. array_push ( $nowStaffList2, $staffK [0] );
  5568. }
  5569. // print_r($nowStaffList2);
  5570. }
  5571. }
  5572. $RoleVerifyStaff = array ();
  5573. foreach ( $verifyStaff as $key => $value ) {
  5574. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  5575. foreach ( $nowStaffList2 as $m ) {
  5576. if ($key == $m . "_R")
  5577. $RoleVerifyStaff [$key] = $value;
  5578. }
  5579. }
  5580. }
  5581. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  5582. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  5583. // 下一个审批人ID
  5584. $nextStaff = 0;
  5585. $falg = false;
  5586. foreach ( $verifyDetail as $key => $value ) {
  5587. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  5588. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  5589. $falg = true;
  5590. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  5591. $nowStaffList = array ();
  5592. foreach ( $vStaffString as $v ) {
  5593. $staffK = explode ( "_", $v );
  5594. array_push ( $nowStaffList, $staffK [0] );
  5595. }
  5596. $nowStaff = implode ( ',', $nowStaffList );
  5597. $nextStaff = $verifyDetail [$key + 1] [0];
  5598. } elseif (isset ( $verifyDetail [$key + 1] )) {
  5599. $nextStaff = $verifyDetail [$key + 1] [0];
  5600. $nowStaff = $nextStaff;
  5601. } else
  5602. $nowStaff = '';
  5603. break;
  5604. }
  5605. }
  5606. if ($falg)
  5607. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5608. 'date' => date ( 'Y-m-d' ),
  5609. 'opinion' => $opinion,
  5610. 'status' => $status,
  5611. 'nextStaff' => $nextStaff,
  5612. 'ROLE' => 1
  5613. );
  5614. else
  5615. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5616. 'date' => date ( 'Y-m-d' ),
  5617. 'opinion' => $opinion,
  5618. 'status' => $status,
  5619. 'nextStaff' => $nextStaff
  5620. );
  5621. // print_r($verifyStaff);
  5622. // echo $nowStaff;die;
  5623. } else { // 进入下一个角色或者审批人
  5624. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  5625. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5626. 'date' => date ( 'Y-m-d' ),
  5627. 'opinion' => $opinion,
  5628. 'status' => $status,
  5629. 'nextStaff' => $VS ['nextStaff'],
  5630. 'ROLE' => 1
  5631. );
  5632. }
  5633. if ($status == 3) {
  5634. $verifyStaff ['final'] = $status;
  5635. $verifyStaff [$this->staff [0] ['sid']] = array (
  5636. 'date' => date ( 'Y-m-d' ),
  5637. 'opinion' => $opinion,
  5638. 'status' => $status
  5639. );
  5640. }
  5641. $vStaffString = json_encode ( $verifyStaff );
  5642. $receipt->verifyStaff = $vStaffString;
  5643. $receipt->nowStaff = $nowStaff;
  5644. $loanReceipt->nowStaff = $nowStaff;
  5645. $loanReceipt->verifyStaff = $vStaffString;
  5646. }
  5647. // print_r($verifyStaff);die;
  5648. }
  5649. $roleKey = 0;
  5650. $roleId = 0;
  5651. $verifyDetailCopy = array ();
  5652. foreach ( $verifyDetail as $k => $v ) {
  5653. if ($v [1] == 'ROLE') {
  5654. $roleId = $v [0];
  5655. $roleVerify = json_decode ( $v [3], true );
  5656. $roleKey = $k;
  5657. $roleArray = array ();
  5658. foreach ( $roleVerify as $o => $p ) {
  5659. $staffID = explode ( '_', $p );
  5660. $exp = array (
  5661. 0 => $staffID [0],
  5662. 1 => $staffID [1]
  5663. );
  5664. array_push ( $roleArray, $exp );
  5665. }
  5666. $verifyDetailCopy [$v [0]] = $roleArray;
  5667. }
  5668. }
  5669. // print_r($verifyDetail);
  5670. foreach ( $verifyDetailCopy as $k => $v ) {
  5671. foreach ( $verifyDetail as $m => $n ) {
  5672. if ($n [0] == $k) {
  5673. array_splice ( $verifyDetail, $m, 1, $v );
  5674. }
  5675. }
  5676. }
  5677. // 审批日志
  5678. if (! isset ( $verifyStaff ['final'] )) {
  5679. Doo::loadModel ( "receiptLog" );
  5680. $receiptLog = new receiptLog ();
  5681. if (! empty ( $roleId )) {
  5682. Doo::loadModel ( "role" );
  5683. $role = new role ();
  5684. $roleInfo = $role->getOne ( array (
  5685. 'where' => 'rid=' . $roleId,
  5686. 'asArray' => true
  5687. ) );
  5688. $receiptLog->rolename = $roleInfo ['name'];
  5689. }
  5690. $receiptLog->username = $this->staff [0] ['username'];
  5691. $receiptLog->uid = $this->staff [0] ['sid'];
  5692. $receiptLog->date = date ( "Y-m-d" );
  5693. $receiptLog->opinion = $opinion;
  5694. $receiptLog->img = $this->staff [0] ['avatar'];
  5695. $receiptLog->status = 1;
  5696. $receiptLog->rid = $rid;
  5697. $receiptLog->insert ();
  5698. }
  5699. if (isset ( $verifyStaff ['final'] )) { // rDetail
  5700. $receipt->status = 3;
  5701. $receipt->verifyBreakup = $verifyString;
  5702. $receiptDetailObj->status = 3;
  5703. $receiptDetailObj->update ( array (
  5704. 'where' => 'rid=' . $rid
  5705. ) );
  5706. // 微信企业号通知
  5707. $this->setWXMsg ( $rid, 3 );
  5708. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  5709. $receipt->status = 6;
  5710. $receipt->pastDate = date ( "Y-m-d" );
  5711. $receipt->isBK = 1;
  5712. $loanReceipt->verifyBreakup = $verifyString;
  5713. $loanReceipt->status = 1;
  5714. $loanReceipt->pastDate = date ( "Y-m-d" );
  5715. //生成流水后 不更新汇款金额
  5716. Doo::loadModel ( 'wasteBook' );
  5717. $wasteBook = new wasteBook ();
  5718. $wbDetail = $wasteBook->getWateBookByAD ( 1, $rid );
  5719. if (empty($wbDetail)){
  5720. $loanReceipt->amount = $receiptDetail ['amount'];
  5721. }
  5722. $loanReceipt->update ( array (
  5723. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  5724. ) );
  5725. // 微信企业号通知
  5726. $this->setWXMsg ( $rid, 1 );
  5727. }
  5728. $receipt->amount = $receiptDetail['sum'];
  5729. $receipt->update ( array (
  5730. 'where' => ' rid = ' . $rid
  5731. ) );
  5732. // 进入下一条审批费用新加需求
  5733. $vidList = array ();
  5734. $verifyDetail = $verify->find ( array (
  5735. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  5736. 'asArray' => true
  5737. ) );
  5738. foreach ( $verifyDetail as $key => $value ) {
  5739. array_push ( $vidList, $value ['vid'] );
  5740. }
  5741. $vid = implode ( ",", $vidList );
  5742. if (empty ( $verifyDetail ))
  5743. $vid = 0;
  5744. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  5745. $receipt = new receipt ();
  5746. $rd = $receipt->getOne ( array (
  5747. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  5748. 'asc' => 'rid',
  5749. 'asArray' => true
  5750. ) );
  5751. if (empty ( $rd )) {
  5752. return '/approvalExpenses/pendApproval';
  5753. }
  5754. if ($rd ['Rtype'] == 1) {
  5755. if ($rd ['isBK'] == 1) {
  5756. return '/receiptburEdi/' . $rd ['rid'];
  5757. } else {
  5758. return '/expensesEdi/' . $rd ['rid'];
  5759. }
  5760. } elseif ($rd ['Rtype'] == 2) {
  5761. return '/remitApproval/' . $rd ['rid'];
  5762. } else {
  5763. return '/receiptburEdi/' . $rd ['rid'];
  5764. }
  5765. // return "/approvalExpenses/pendApproval";
  5766. }
  5767. }
  5768. function ajaxExamineExe() {
  5769. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5770. Doo::loadModel ( 'receipt' );
  5771. $receipt = new receipt ();
  5772. Doo::loadClass ( 'XDeode' );
  5773. $XDeode = new XDeode ( 5 );
  5774. if (! empty ( $rid )) {
  5775. $rLRes = $receipt->find ( array (
  5776. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  5777. 'asArray' => true
  5778. ) );
  5779. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  5780. echo json_encode ( array (
  5781. 'status' => 1,
  5782. 'receipt' => $rLRes [0]
  5783. ) );
  5784. die ();
  5785. }
  5786. echo json_encode ( array (
  5787. 'status' => 0,
  5788. 'receipt' => array ()
  5789. ) );
  5790. die ();
  5791. }
  5792. function implement() {
  5793. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5794. $Rtype = isset ( $this->params ['Rtype'] ) ? $this->params ['Rtype'] : '';
  5795. Doo::loadClass ( 'XDeode' );
  5796. $XDeode = new XDeode ( 5 );
  5797. Doo::loadModel ( 'receipt' );
  5798. $receipt = new receipt ();
  5799. Doo::loadModel ( 'L_category' );
  5800. $Lcategory = new L_category ();
  5801. Doo::loadModel ( 'verify' );
  5802. $verify = new verify ();
  5803. Doo::loadModel ( 'staff' );
  5804. $staff = new staff ();
  5805. Doo::loadModel ( "execute" );
  5806. $execute = new execute ();
  5807. $rid = $XDeode->decode ( $rid );
  5808. $receiptList = $receipt->find ( array (
  5809. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  5810. 'desc' => 'rid',
  5811. 'asArray' => true
  5812. ) );
  5813. Doo::loadModel ( 'loanReceipt' );
  5814. $loanReceipt = new loanReceipt ();
  5815. // print_r($receiptList);
  5816. $loanList = array ();
  5817. if (! isset ( $receiptList ))
  5818. $loanList = $loanReceipt->find ( array (
  5819. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  5820. 'desc' => 'rid',
  5821. 'asArray' => true
  5822. ) );
  5823. $Locate = 0;
  5824. $roleId = 0;
  5825. $button = 0;
  5826. foreach ( $loanList as $key => $value ) {
  5827. $loanList [$key] ['Locate'] = $Locate;
  5828. $Locate ++;
  5829. $loanList [$key] ['reviseDetail'] = array ();
  5830. if (! empty ( $value ['reviseDetail'] ))
  5831. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5832. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5833. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5834. $categoryDetil = $Lcategory->getOne ( array (
  5835. 'where' => 'cid=' . $value ['cid'],
  5836. 'asArray' => true
  5837. ) );
  5838. $loanList [$key] ['category'] = $categoryDetil ['title'];
  5839. // 检测编辑状态
  5840. $verifyList = $verify->getOne ( array (
  5841. 'where' => 'vid=' . $value ['verify'],
  5842. 'asArray' => true
  5843. ) );
  5844. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5845. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5846. Doo::loadModel ( 'role' );
  5847. $role = new role ();
  5848. $flag = true;
  5849. $roleKey = 0;
  5850. $endStaffArray = array ();
  5851. $roleArrayCopy = array ();
  5852. foreach ( $verifyList as $k => $v ) {
  5853. // init verifyStaff
  5854. if ($v [1] == 'ROLE') {
  5855. if (! empty ( $verifyStaff )) {
  5856. $endStaffArray = end ( $verifyStaff );
  5857. // if ($v[0]==$endStaffArray['nextStaff']){
  5858. // $roleId=$v[0];
  5859. // }
  5860. }
  5861. $roleVerify = json_decode ( $v [3], true );
  5862. $roleKey = $k;
  5863. $roleArray = array ();
  5864. $rolename = $role->getOne ( array (
  5865. 'where' => 'rid=' . $v [0],
  5866. 'asArray' => true
  5867. ) );
  5868. foreach ( $roleVerify as $o => $p ) {
  5869. $staffID = explode ( '_', $p );
  5870. $staffInfo = $staff->getOne ( array (
  5871. 'where' => 'sid=' . $staffID [0],
  5872. 'asArray' => true
  5873. ) );
  5874. // print_r($staffID);
  5875. $exp = array (
  5876. 0 => $staffInfo ['sid'],
  5877. 1 => $staffID [1],
  5878. 2 => $staffInfo ['avatar'],
  5879. 'date' => '',
  5880. 'date' => '',
  5881. 'opinion' => '',
  5882. 'status' => '',
  5883. 'rolename' => $rolename ['name']
  5884. );
  5885. array_push ( $roleArray, $exp );
  5886. }
  5887. $roleArrayCopy [$v [0]] = $roleArray;
  5888. // $verifyList[$k]['roleArray']=$roleArray;
  5889. }
  5890. $verifyList [$k] ['date'] = "";
  5891. $verifyList [$k] ['opinion'] = "";
  5892. $verifyList [$k] ['status'] = "";
  5893. if (empty ( $verifyStaff )) {
  5894. $verifyList [$k] ['date'] = "";
  5895. $verifyList [$k] ['opinion'] = "";
  5896. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5897. $verifyList [$k] ['status'] = 4;
  5898. $flag = false;
  5899. }
  5900. } else {
  5901. foreach ( $verifyStaff as $m => $u ) {
  5902. if ($v [0] == $m) {
  5903. $verifyList [$k] ['date'] = $u ['date'];
  5904. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5905. $verifyList [$k] ['status'] = $u ['status'];
  5906. $flag = false;
  5907. break;
  5908. }
  5909. }
  5910. $endStaffArray = end ( $verifyStaff );
  5911. if (isset ( $endStaffArray ['ROLE'] )) {
  5912. } else {
  5913. // $endKey=key($verifyStaff);
  5914. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5915. // $button=4;
  5916. // $verifyList[$k]['status']=4;
  5917. // }
  5918. }
  5919. }
  5920. }
  5921. $rolename ['name'] = '';
  5922. if (! empty ( $roleId )) {
  5923. Doo::loadModel ( 'role' );
  5924. $role = new role ();
  5925. $rolename = $role->getOne ( array (
  5926. 'where' => 'rid=' . $roleId,
  5927. 'asArray' => true
  5928. ) );
  5929. }
  5930. if (! empty ( $verifyStaff ))
  5931. $endStaffArray = end ( $verifyStaff );
  5932. $KOP = false;
  5933. foreach ( $roleArrayCopy as $P => $A ) {
  5934. foreach ( $A as $MKI => $AVL ) {
  5935. if (! empty ( $verifyStaff )) {
  5936. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5937. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5938. $button = 4;
  5939. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5940. }
  5941. foreach ( $verifyStaff as $m => $u ) {
  5942. $AVLFK = $AVL [0] . '_R';
  5943. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5944. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5945. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5946. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5947. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5948. break;
  5949. }
  5950. }
  5951. } else {
  5952. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5953. $button = 4;
  5954. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5955. }
  5956. }
  5957. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5958. $KOP = true;
  5959. }
  5960. }
  5961. foreach ( $roleArrayCopy as $k => $v ) {
  5962. foreach ( $verifyList as $m => $n ) {
  5963. if ($n [0] == $k) {
  5964. array_splice ( $verifyList, $m, 1, $v );
  5965. }
  5966. }
  5967. }
  5968. $loanList [$key] ['verifyList'] = $verifyList;
  5969. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  5970. 'where' => 'sid=' . $value ['staff'],
  5971. 'asArray' => true
  5972. ) );
  5973. }
  5974. $data ['loanList'] = $loanList;
  5975. $Locate = 0;
  5976. $roleId = 0;
  5977. $button = 0;
  5978. Doo::loadClass ( 'XDeode' );
  5979. $XDeode = new XDeode ( 5 );
  5980. foreach ( $receiptList as $key => $value ) {
  5981. $receiptList[$key]['ridKey']=$XDeode->encode ( $value['rid'] );
  5982. $button2 = 0;
  5983. $receiptList [$key] ['Locate'] = $Locate;
  5984. $Locate ++;
  5985. $receiptList [$key] ['reviseDetail'] = array ();
  5986. if (! empty ( $value ['reviseDetail'] ))
  5987. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5988. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5989. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5990. $categoryDetil = $Lcategory->getOne ( array (
  5991. 'where' => 'cid=' . $value ['cid'],
  5992. 'asArray' => true
  5993. ) );
  5994. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5995. $executeList = json_decode ( $value ['executeCopy'], true );
  5996. $executeStaff = array ();
  5997. if (! empty ( $value ['executeStaff'] ))
  5998. $executeStaff = json_decode ( $value ['executeStaff'], true );
  5999. if (isset ( $executeList )) {
  6000. foreach ( $executeList as $op => $lo ) {
  6001. $executeList [$op] ['date'] = "";
  6002. $executeList [$op] ['opinion'] = "";
  6003. $executeList [$op] ['status'] = "";
  6004. foreach ( $executeStaff as $m => $u ) {
  6005. if ($lo [0] == $m) {
  6006. $executeList [$op] ['date'] = $u ['date'];
  6007. $executeList [$op] ['opinion'] = $u ['opinion'];
  6008. $executeList [$op] ['status'] = $u ['status'];
  6009. break;
  6010. }
  6011. }
  6012. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  6013. $button2 = 1;
  6014. $executeList [$op] ['status'] = 4;
  6015. }
  6016. }
  6017. }
  6018. // 检测编辑状态
  6019. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  6020. $verifyList ['staff'] = $value ['verifyBreakup'];
  6021. } else
  6022. $verifyList = $verify->getOne ( array (
  6023. 'where' => 'vid=' . $value ['verify'],
  6024. 'asArray' => true
  6025. ) );
  6026. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6027. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6028. Doo::loadModel ( 'role' );
  6029. $role = new role ();
  6030. if ($verifyList == NULL)
  6031. $verifyList = array ();
  6032. $flag = true;
  6033. $roleKey = 0;
  6034. $endStaffArray = array ();
  6035. $roleArrayCopy = array ();
  6036. foreach ( $verifyList as $k => $v ) {
  6037. // init verifyStaff
  6038. if ($v [1] == 'ROLE') {
  6039. if (! empty ( $verifyStaff )) {
  6040. $endStaffArray = end ( $verifyStaff );
  6041. // if ($v[0]==$endStaffArray['nextStaff']){
  6042. // $roleId=$v[0];
  6043. // }
  6044. }
  6045. $roleVerify = json_decode ( $v [3], true );
  6046. $roleKey = $k;
  6047. $roleArray = array ();
  6048. $rolename = $role->getOne ( array (
  6049. 'where' => 'rid=' . $v [0],
  6050. 'asArray' => true
  6051. ) );
  6052. foreach ( $roleVerify as $o => $p ) {
  6053. $staffID = explode ( '_', $p );
  6054. $staffInfo = $staff->getOne ( array (
  6055. 'where' => 'sid=' . $staffID [0],
  6056. 'asArray' => true
  6057. ) );
  6058. // print_r($staffID);
  6059. $exp = array (
  6060. 0 => $staffInfo ['sid'],
  6061. 1 => $staffID [1],
  6062. 2 => $staffInfo ['avatar'],
  6063. 'date' => '',
  6064. 'date' => '',
  6065. 'opinion' => '',
  6066. 'status' => '',
  6067. 'rolename' => $rolename ['name']
  6068. );
  6069. array_push ( $roleArray, $exp );
  6070. }
  6071. $roleArrayCopy [$v [0]] = $roleArray;
  6072. // $verifyList[$k]['roleArray']=$roleArray;
  6073. }
  6074. $verifyList [$k] ['date'] = "";
  6075. $verifyList [$k] ['opinion'] = "";
  6076. $verifyList [$k] ['status'] = "";
  6077. if (empty ( $verifyStaff )) {
  6078. $verifyList [$k] ['date'] = "";
  6079. $verifyList [$k] ['opinion'] = "";
  6080. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6081. $verifyList [$k] ['status'] = 4;
  6082. $flag = false;
  6083. }
  6084. } else {
  6085. foreach ( $verifyStaff as $m => $u ) {
  6086. if ($v [0] == $m) {
  6087. $verifyList [$k] ['date'] = $u ['date'];
  6088. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6089. $verifyList [$k] ['status'] = $u ['status'];
  6090. $flag = false;
  6091. break;
  6092. }
  6093. }
  6094. $endStaffArray = end ( $verifyStaff );
  6095. if (isset ( $endStaffArray ['ROLE'] )) {
  6096. } else {
  6097. // $endKey=key($verifyStaff);
  6098. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  6099. // $button=4;
  6100. // $verifyList[$k]['status']=4;
  6101. // }
  6102. }
  6103. }
  6104. }
  6105. $rolename ['name'] = '';
  6106. if (! empty ( $roleId )) {
  6107. Doo::loadModel ( 'role' );
  6108. $role = new role ();
  6109. $rolename = $role->getOne ( array (
  6110. 'where' => 'rid=' . $roleId,
  6111. 'asArray' => true
  6112. ) );
  6113. }
  6114. if (! empty ( $verifyStaff ))
  6115. $endStaffArray = end ( $verifyStaff );
  6116. $KOP = false;
  6117. foreach ( $roleArrayCopy as $P => $A ) {
  6118. foreach ( $A as $MKI => $AVL ) {
  6119. if (! empty ( $verifyStaff )) {
  6120. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6121. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6122. $button = 4;
  6123. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6124. }
  6125. foreach ( $verifyStaff as $m => $u ) {
  6126. $AVLFK = $AVL [0] . '_R';
  6127. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6128. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6129. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6130. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6131. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6132. break;
  6133. }
  6134. }
  6135. } else {
  6136. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6137. $button = 4;
  6138. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6139. }
  6140. }
  6141. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6142. $KOP = true;
  6143. }
  6144. }
  6145. foreach ( $roleArrayCopy as $k => $v ) {
  6146. foreach ( $verifyList as $m => $n ) {
  6147. if ($n [0] == $k) {
  6148. array_splice ( $verifyList, $m, 1, $v );
  6149. }
  6150. }
  6151. }
  6152. $receiptList [$key] ['verifyList'] = $verifyList;
  6153. $receiptList [$key] ['executeList'] = $executeList;
  6154. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6155. 'where' => 'sid=' . $value ['staff'],
  6156. 'asArray' => true
  6157. ) );
  6158. $receiptList [$key] ['button2'] = $button2;
  6159. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  6160. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  6161. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  6162. $receiptList [$key] ['relust'] = $relust;
  6163. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  6164. $receiptList [$key] ['amountABS'] = abs ( $value ['amount'] );
  6165. }
  6166. //执行人是否是最后一位
  6167. $executeCopy = json_decode ( $receiptList [0] ['executeCopy'], true );
  6168. $executeStaff = json_decode ( $receiptList [0] ['executeStaff'], true );
  6169. $executePrimary=count($executeCopy)-1;
  6170. $lastOne=true;
  6171. if($executePrimary!=count($executeStaff)){
  6172. $lastOne=false;
  6173. }
  6174. $data['lastOne']=$lastOne;
  6175. // 是否写入过流水
  6176. $accountType = 0;
  6177. if ($receiptList [0] ['Rtype'] == 0) {
  6178. $accountType = 3;
  6179. } elseif ($receiptList [0] ['Rtype'] == 1) {
  6180. if (!empty($receiptList [0]['accountItem']) )
  6181. $accountType = 2;
  6182. else
  6183. $accountType = 1;
  6184. } elseif ($receiptList [0] ['Rtype'] == 2) {
  6185. $accountType = 4;
  6186. } elseif ($receiptList [0] ['Rtype'] == 3) {
  6187. $accountType = 12;
  6188. }
  6189. Doo::loadModel ( 'wasteBook' );
  6190. $wasteBook = new wasteBook ();
  6191. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $receiptList [0] ['rid'] );
  6192. $data ['wbDetail'] = $wbDetail;
  6193. $wbDetailLoan=array();
  6194. if ($accountType==2){
  6195. $wbDetailLoan = $wasteBook->getWateBookByAD ( 1, $receiptList [0] ['rid'] );
  6196. }
  6197. $data ['wbDetailLoan'] = $wbDetailLoan;
  6198. $data['inputDate']=date ( "Y-m-d H:i:s" );
  6199. //print_r($wbDetail);
  6200. $data ['receiptList'] = $receiptList;
  6201. $data ['memu'] = "receipt";
  6202. $data ['staff'] = $this->staff;
  6203. $data ['receiptMemu'] = 'implement';
  6204. $data ['verifyId'] = $this->verifyId;
  6205. $data ['executeId'] = $this->executeId;
  6206. if ($Rtype=="loan"){
  6207. $this->render ( "/receipt/receiptImplementLoan", $data );
  6208. }elseif($Rtype=="receipt"){
  6209. $this->render ( "/receipt/receiptImplement", $data );
  6210. }elseif($Rtype=="public"){
  6211. $this->render ( "/receipt/receiptImplementPublic", $data );
  6212. }else{
  6213. //$this->render ( "/admin/implement", $data );
  6214. }
  6215. }
  6216. function implementDo() {
  6217. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  6218. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6219. // $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  6220. // $accountBank = $this->get_args ( 'accountBank' ) ? $this->get_args ( 'accountBank' ) : "";
  6221. // $ab = '';
  6222. // if ($accountBank == 'CGBDeposit')
  6223. // $ab = '纵横广发';
  6224. // elseif ($accountBank == 'ICBCDeposit')
  6225. // $ab = '纵横工行';
  6226. // elseif ($accountBank == 'HUADeposit')
  6227. // $ab = '华润银行';
  6228. // elseif ($accountBank == 'PersonalDeposit')
  6229. // $ab = '个人广发';
  6230. // if (empty ( $ab ))
  6231. // die ( 'illegal request--22' );
  6232. if (! empty ( $rid )) {
  6233. Doo::loadModel ( 'receipt' );
  6234. $receipt = new receipt ();
  6235. Doo::loadClass ( 'XDeode' );
  6236. $XDeode = new XDeode ( 5 );
  6237. $rid=$XDeode->decode($rid);
  6238. if (!is_numeric($rid)){
  6239. die;
  6240. }
  6241. // $rinfo = $receipt->getOne ( array (
  6242. // 'where' => 'rid=' . $rid,
  6243. // 'asArray' => true
  6244. // ) );
  6245. $rinfo = $receipt->getReceiptByRid ( $rid );
  6246. // $accountType = '';
  6247. // if ($rinfo ['Rtype'] == 1) {
  6248. // if ($rinfo ['loanRid'] != 0)//判断有问题
  6249. // $accountType = 2;
  6250. // else
  6251. // $accountType = 1;
  6252. // } elseif ($rinfo ['Rtype'] == 2) {
  6253. // $accountType = 4;
  6254. // } elseif ($rinfo ['Rtype'] == 0)
  6255. // $accountType = 3;
  6256. // if (empty ( $accountType ))
  6257. // die ( 'illegal request' );
  6258. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6259. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6260. if (empty ( $executeStaff )) {
  6261. $executeStaff = array (
  6262. $this->staff [0] ['sid'] => array (
  6263. 'date' => date ( 'Y-m-d' ),
  6264. 'opinion' => $implementOpinions,
  6265. 'status' => 1
  6266. )
  6267. );
  6268. } else {
  6269. $executeStaff [$this->staff [0] ['sid']] = array (
  6270. 'date' => date ( 'Y-m-d' ),
  6271. 'opinion' => $implementOpinions,
  6272. 'status' => 1
  6273. );
  6274. }
  6275. if (count ( $executeStaff ) == count ( $executeCopy )) {
  6276. $receipt->executeStaff = json_encode ( $executeStaff );
  6277. $receipt->status = 8;
  6278. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  6279. $receipt->status = 9;
  6280. if ($rinfo ['status'] == 6) {
  6281. $receipt->loanDate = date ( "Y-m-d" );
  6282. }
  6283. $receipt->executeDate = date ( "Y-m-d" );
  6284. } else {
  6285. $receipt->executeStaff = json_encode ( $executeStaff );
  6286. }
  6287. //$receipt->amount = $amount;
  6288. $receipt->update ( array (
  6289. 'where' => 'rid=' . $rid
  6290. ) );
  6291. // 公司流水记录
  6292. // Doo::loadModel ( 'wasteBook' );
  6293. // $wasteBook = new wasteBook ();
  6294. // $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountType, $rid );
  6295. // // 银行
  6296. // if (empty ( $abDetail ) && ! empty ( $amount )) {
  6297. // $item = array (
  6298. // 'dataID' => $rid,
  6299. // 'expensesType' => 2,
  6300. // 'accountType' => $accountType,
  6301. // 'accountPriceShow' => $amount,
  6302. // 'accountPrice' => - $amount,
  6303. // 'accountBank' => $accountBank,
  6304. // 'category' => $rinfo ['category'] [0] ['title'],
  6305. // 'cid' => $rinfo ['category'] [0] ['cid'],
  6306. // 'name' => $rinfo ['staffDetail'] ['username'],
  6307. // 'sid' => $rinfo ['staffDetail'] ['sid'],
  6308. // 'inputDate' => date ( "Y-m-d H:i:s" )
  6309. // );
  6310. // $wasteBook->setAccountBookStatistics ( $item );
  6311. // }
  6312. }
  6313. //$ridKey = $XDeode->encode ( $rid );
  6314. return "/hisImplement";
  6315. // return "/implement/" . $ridKey . ".html";
  6316. }
  6317. function receiptburEdi() {
  6318. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6319. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  6320. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6321. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6322. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6323. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6324. if (empty ( $status ))
  6325. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  6326. $vidList = array ();
  6327. $button = 0;
  6328. Doo::loadModel ( 'verify' );
  6329. Doo::loadModel ( 'receipt' );
  6330. Doo::loadModel ( 'staff' );
  6331. $staff = new staff ();
  6332. $receipt = new receipt ();
  6333. $verify = new verify ();
  6334. Doo::loadModel ( 'L_category' );
  6335. $Lcategory = new L_category ();
  6336. Doo::loadModel ( 'enclosur' );
  6337. $enclosur = new enclosur ();
  6338. Doo::loadModel ( 'loanReceipt' );
  6339. $loanReceipt = new loanReceipt ();
  6340. // user verify ID
  6341. $verifyDetail = $verify->find ( array (
  6342. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6343. 'asArray' => true
  6344. ) );
  6345. foreach ( $verifyDetail as $key => $value ) {
  6346. array_push ( $vidList, $value ['vid'] );
  6347. }
  6348. $vid = implode ( ",", $vidList );
  6349. if (empty ( $verifyDetail ))
  6350. $vid = 0;
  6351. $categoryList = $Lcategory->find ( array (
  6352. 'asArray' => true
  6353. ) );
  6354. $staffList = $staff->find ( array (
  6355. 'where' => 'cid=' . $cid,
  6356. 'asArray' => true
  6357. ) );
  6358. $ap = "";
  6359. if ($status == 4) {
  6360. $ap = 4;
  6361. $status = 2;
  6362. }
  6363. // get Receipt By verifyID status 2
  6364. $receiptList = $receipt->find ( array (
  6365. 'where' => 'rid =' . $rid . ' and status=2',
  6366. 'desc' => 'rid',
  6367. 'asArray' => true
  6368. ) );
  6369. if (empty ( $receiptList )) {
  6370. die ( 'illegal request' );
  6371. }
  6372. $loanList = $loanReceipt->find ( array (
  6373. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  6374. 'desc' => 'rid',
  6375. 'asArray' => true
  6376. ) );
  6377. $data ['explanation'] = '';
  6378. if (! empty ( $loanList ))
  6379. $data ['explanation'] = $loanList [0] ['explanation'];
  6380. $Locate = 0;
  6381. $roleId = 0;
  6382. $button = 0;
  6383. foreach ( $loanList as $key => $value ) {
  6384. $loanList [$key] ['Locate'] = $Locate;
  6385. $Locate ++;
  6386. $loanList [$key] ['reviseDetail'] = array ();
  6387. if (! empty ( $value ['reviseDetail'] ))
  6388. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6389. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6390. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6391. $categoryDetil = $Lcategory->getOne ( array (
  6392. 'where' => 'cid=' . $value ['cid'],
  6393. 'asArray' => true
  6394. ) );
  6395. $loanList [$key] ['category'] = $categoryDetil ['title'];
  6396. // 检测编辑状态
  6397. $verifyList = $verify->getOne ( array (
  6398. 'where' => 'vid=' . $value ['verify'],
  6399. 'asArray' => true
  6400. ) );
  6401. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6402. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6403. Doo::loadModel ( 'role' );
  6404. $role = new role ();
  6405. $flag = true;
  6406. $roleKey = 0;
  6407. $endStaffArray = array ();
  6408. $roleArrayCopy = array ();
  6409. foreach ( $verifyList as $k => $v ) {
  6410. // init verifyStaff
  6411. if ($v [1] == 'ROLE') {
  6412. if (! empty ( $verifyStaff )) {
  6413. $endStaffArray = end ( $verifyStaff );
  6414. }
  6415. $roleVerify = json_decode ( $v [3], true );
  6416. $roleKey = $k;
  6417. $roleArray = array ();
  6418. $rolename = $role->getOne ( array (
  6419. 'where' => 'rid=' . $v [0],
  6420. 'asArray' => true
  6421. ) );
  6422. foreach ( $roleVerify as $o => $p ) {
  6423. $staffID = explode ( '_', $p );
  6424. $staffInfo = $staff->getOne ( array (
  6425. 'where' => 'sid=' . $staffID [0],
  6426. 'asArray' => true
  6427. ) );
  6428. // print_r($staffID);
  6429. $exp = array (
  6430. 0 => $staffInfo ['sid'],
  6431. 1 => $staffID [1],
  6432. 2 => $staffInfo ['avatar'],
  6433. 'date' => '',
  6434. 'date' => '',
  6435. 'opinion' => '',
  6436. 'status' => '',
  6437. 'rolename' => $rolename ['name']
  6438. );
  6439. array_push ( $roleArray, $exp );
  6440. }
  6441. $roleArrayCopy [$v [0]] = $roleArray;
  6442. // $verifyList[$k]['roleArray']=$roleArray;
  6443. }
  6444. $verifyList [$k] ['date'] = "";
  6445. $verifyList [$k] ['opinion'] = "";
  6446. $verifyList [$k] ['status'] = "";
  6447. if (empty ( $verifyStaff )) {
  6448. $verifyList [$k] ['date'] = "";
  6449. $verifyList [$k] ['opinion'] = "";
  6450. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6451. $verifyList [$k] ['status'] = 4;
  6452. $flag = false;
  6453. }
  6454. } else {
  6455. foreach ( $verifyStaff as $m => $u ) {
  6456. if ($v [0] == $m) {
  6457. $verifyList [$k] ['date'] = $u ['date'];
  6458. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6459. $verifyList [$k] ['status'] = $u ['status'];
  6460. $flag = false;
  6461. break;
  6462. }
  6463. }
  6464. $endStaffArray = end ( $verifyStaff );
  6465. if (isset ( $endStaffArray ['ROLE'] )) {
  6466. } else {
  6467. }
  6468. }
  6469. }
  6470. $rolename ['name'] = '';
  6471. if (! empty ( $roleId )) {
  6472. Doo::loadModel ( 'role' );
  6473. $role = new role ();
  6474. $rolename = $role->getOne ( array (
  6475. 'where' => 'rid=' . $roleId,
  6476. 'asArray' => true
  6477. ) );
  6478. }
  6479. if (! empty ( $verifyStaff ))
  6480. $endStaffArray = end ( $verifyStaff );
  6481. $KOP = false;
  6482. foreach ( $roleArrayCopy as $P => $A ) {
  6483. foreach ( $A as $MKI => $AVL ) {
  6484. if (! empty ( $verifyStaff )) {
  6485. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6486. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6487. $button = 4;
  6488. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6489. }
  6490. foreach ( $verifyStaff as $m => $u ) {
  6491. $AVLFK = $AVL [0] . '_R';
  6492. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6493. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6494. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6495. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6496. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6497. break;
  6498. }
  6499. }
  6500. } else {
  6501. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6502. $button = 4;
  6503. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6504. }
  6505. }
  6506. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6507. $KOP = true;
  6508. }
  6509. }
  6510. foreach ( $roleArrayCopy as $k => $v ) {
  6511. foreach ( $verifyList as $m => $n ) {
  6512. if ($n [0] == $k) {
  6513. array_splice ( $verifyList, $m, 1, $v );
  6514. }
  6515. }
  6516. }
  6517. $loanList [$key] ['verifyList'] = $verifyList;
  6518. }
  6519. $htmlLoan = '';
  6520. $data ['loanReceiptDate'] = '';
  6521. if (isset ( $loanList [0] )) {
  6522. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  6523. if ($value ['status'] == 1)
  6524. $htmlLoan .= '<li class="done" >';
  6525. elseif ($value ['status'] == 3)
  6526. $htmlLoan .= '<li class="undone" >';
  6527. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  6528. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  6529. if (isset ( $value ['rolename'] ))
  6530. $htmlLoan .= $value ['rolename'];
  6531. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  6532. }
  6533. $data ['loanDate'] = $loanList [0] ['date'];
  6534. } else {
  6535. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  6536. }
  6537. $data ['htmlLoan'] = $htmlLoan;
  6538. // $data ['LoanReceipt']=$loanList[0];
  6539. // print_r($loanList);
  6540. $Locate = 0;
  6541. $roleId = 0;
  6542. $button = 0;
  6543. if ($ap == 4)
  6544. $status = 4;
  6545. Doo::loadClass ( 'XDeode' );
  6546. $XDeode = new XDeode ( 5 );
  6547. foreach ( $receiptList as $key => $value ) {
  6548. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  6549. $receiptList [$key] ['Locate'] = $Locate;
  6550. $Locate ++;
  6551. $receiptList [$key] ['reviseDetail'] = array ();
  6552. // 调整金额 代码调整
  6553. if (! empty ( $value ['reviseDetail'] )) {
  6554. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  6555. foreach ( $reviseDetail as $ry => $re ) {
  6556. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  6557. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  6558. }
  6559. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  6560. // print_r($reviseDetail);
  6561. }
  6562. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6563. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6564. $categoryDetil = $Lcategory->getOne ( array (
  6565. 'where' => 'cid=' . $value ['cid'],
  6566. 'asArray' => true
  6567. ) );
  6568. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6569. // 检测编辑状态
  6570. $verifyList = $verify->getOne ( array (
  6571. 'where' => 'vid=' . $value ['verify'],
  6572. 'asArray' => true
  6573. ) );
  6574. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6575. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6576. Doo::loadModel ( 'role' );
  6577. $role = new role ();
  6578. // print_r($verifyList);
  6579. $flag = true;
  6580. $roleKey = 0;
  6581. $endStaffArray = array ();
  6582. $roleArrayCopy = array ();
  6583. foreach ( $verifyList as $k => $v ) {
  6584. // init verifyStaff
  6585. if ($v [1] == 'ROLE') {
  6586. if (! empty ( $verifyStaff )) {
  6587. $endStaffArray = end ( $verifyStaff );
  6588. if ($v [0] == $endStaffArray ['nextStaff']) {
  6589. $roleId = $v [0];
  6590. }
  6591. }
  6592. $roleVerify = json_decode ( $v [3], true );
  6593. $roleKey = $k;
  6594. $roleArray = array ();
  6595. $rolename = $role->getOne ( array (
  6596. 'where' => 'rid=' . $v [0],
  6597. 'asArray' => true
  6598. ) );
  6599. foreach ( $roleVerify as $o => $p ) {
  6600. $staffID = explode ( '_', $p );
  6601. $staffInfo = $staff->getOne ( array (
  6602. 'where' => 'sid=' . $staffID [0],
  6603. 'asArray' => true
  6604. ) );
  6605. // print_r($staffID);
  6606. $exp = array (
  6607. 0 => $staffInfo ['sid'],
  6608. 1 => $staffID [1],
  6609. 2 => $staffInfo ['avatar'],
  6610. 'date' => '',
  6611. 'date' => '',
  6612. 'opinion' => '',
  6613. 'status' => '',
  6614. 'rolename' => $rolename ['name']
  6615. );
  6616. array_push ( $roleArray, $exp );
  6617. }
  6618. $roleArrayCopy [$v [0]] = $roleArray;
  6619. // $verifyList[$k]['roleArray']=$roleArray;
  6620. }
  6621. // print_r($roleArray);
  6622. $verifyList [$k] ['date'] = "";
  6623. $verifyList [$k] ['opinion'] = "";
  6624. $verifyList [$k] ['status'] = "";
  6625. if (empty ( $verifyStaff )) {
  6626. $verifyList [$k] ['date'] = "";
  6627. $verifyList [$k] ['opinion'] = "";
  6628. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6629. $verifyList [$k] ['status'] = 4;
  6630. $button = 4;
  6631. $flag = false;
  6632. }
  6633. } else {
  6634. foreach ( $verifyStaff as $m => $u ) {
  6635. if ($v [0] == $m) {
  6636. $verifyList [$k] ['date'] = $u ['date'];
  6637. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6638. $verifyList [$k] ['status'] = $u ['status'];
  6639. $flag = false;
  6640. break;
  6641. }
  6642. }
  6643. $endStaffArray = end ( $verifyStaff );
  6644. if (isset ( $endStaffArray ['ROLE'] )) {
  6645. } else {
  6646. $endKey = key ( $verifyStaff );
  6647. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6648. $button = 4;
  6649. $verifyList [$k] ['status'] = 4;
  6650. }
  6651. }
  6652. }
  6653. }
  6654. $rolename ['name'] = '';
  6655. if (! empty ( $roleId )) {
  6656. Doo::loadModel ( 'role' );
  6657. $role = new role ();
  6658. $rolename = $role->getOne ( array (
  6659. 'where' => 'rid=' . $roleId,
  6660. 'asArray' => true
  6661. ) );
  6662. }
  6663. if (! empty ( $verifyStaff ))
  6664. $endStaffArray = end ( $verifyStaff );
  6665. $KOP = false;
  6666. foreach ( $roleArrayCopy as $P => $A ) {
  6667. foreach ( $A as $MKI => $AVL ) {
  6668. if (! empty ( $verifyStaff )) {
  6669. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6670. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6671. $button = 4;
  6672. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6673. }
  6674. foreach ( $verifyStaff as $m => $u ) {
  6675. $AVLFK = $AVL [0] . '_R';
  6676. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6677. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6678. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6679. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6680. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6681. break;
  6682. }
  6683. }
  6684. } else {
  6685. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6686. $button = 4;
  6687. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6688. }
  6689. }
  6690. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6691. $KOP = true;
  6692. }
  6693. }
  6694. foreach ( $roleArrayCopy as $k => $v ) {
  6695. foreach ( $verifyList as $m => $n ) {
  6696. if ($n [0] == $k) {
  6697. array_splice ( $verifyList, $m, 1, $v );
  6698. }
  6699. }
  6700. }
  6701. // print_r($verifyList);
  6702. $receiptList [$key] ['verifyList'] = $verifyList;
  6703. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6704. 'where' => 'sid=' . $value ['staff'],
  6705. 'asArray' => true
  6706. ) );
  6707. $receiptList [$key] ['button'] = $button;
  6708. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  6709. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  6710. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  6711. $receiptList [$key] ['relust'] = $relust;
  6712. $receiptList [$key] ['relustABS'] = abs ( $relust );
  6713. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  6714. }
  6715. //print_r($receiptList);die;
  6716. // $data['verifyDetail']=$verifyDetail;
  6717. $mothHtml = "";
  6718. for($i = 1; $i <= 12; $i ++) {
  6719. if ($month == $i)
  6720. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6721. else
  6722. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6723. }
  6724. // 获取审批日志
  6725. Doo::loadModel ( 'receiptLog' );
  6726. $receiptLog = new receiptLog ();
  6727. $rlList = array ();
  6728. $rlInfo = $receiptLog->getOne ( array (
  6729. 'where' => 'rid=' . $rid . ' and status=4',
  6730. 'asArray' => true
  6731. ) );
  6732. $tijdate = $receiptLog->getOne ( array (
  6733. 'where' => 'rid=' . $rid . ' and status=2',
  6734. 'asc' => 'rlid',
  6735. 'asArray' => true
  6736. ) );
  6737. if (! empty ( $rlInfo )) {
  6738. $rlList = $receiptLog->find ( array (
  6739. 'where' => 'rid=' . $rid,
  6740. 'asc' => 'rlid',
  6741. 'asArray' => true
  6742. ) );
  6743. }
  6744. // echo $rid;
  6745. // print_r($receiptList);
  6746. $receiptList [0] ['rlList'] = $rlList;
  6747. // print_r($receiptList);
  6748. $enclosurList = $enclosur->find ( array (
  6749. 'where' => 'rid=' . $rid,
  6750. 'asArray' => true
  6751. ) );
  6752. $enclosurHtml = '';
  6753. foreach ( $enclosurList as $value ) {
  6754. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6755. }
  6756. $data ['enclosurHtml'] = $enclosurHtml;
  6757. $data ['rolename'] = $rolename ['name'];
  6758. $data ['mothHtml'] = $mothHtml;
  6759. // print_r($receiptList);
  6760. $data ['rid'] = $rid;
  6761. $data ['tijdate'] = $tijdate ['date'];
  6762. $data ['receiptList'] = $receiptList;
  6763. $data ['receiptApprovalCount'] = count ( $receiptList );
  6764. $data ['status'] = $status;
  6765. $data ['year'] = $year;
  6766. $data ['categoryList'] = $categoryList;
  6767. $data ['staffList'] = $staffList;
  6768. $data ['cid'] = $cid;
  6769. $data ['sid'] = $sid;
  6770. $data ['ap'] = $ap;
  6771. $data ['memu'] = "receipt";
  6772. $data ['staff'] = $this->staff;
  6773. $data ['receiptMemu'] = 'approvalExpenses';
  6774. $data ['verifyId'] = $this->verifyId;
  6775. $data ['executeId'] = $this->executeId;
  6776. $this->render ( "/admin/receiptburEdi", $data );
  6777. }
  6778. function hisImplement() {
  6779. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  6780. if (empty ( $item ))
  6781. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  6782. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  6783. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6784. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  6785. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6786. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  6787. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  6788. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  6789. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  6790. Doo::loadClass ( 'XDeode' );
  6791. $XDeode = new XDeode ( 5 );
  6792. Doo::loadModel ( 'receipt' );
  6793. $receipt = new receipt ();
  6794. Doo::loadModel ( 'L_category' );
  6795. $Lcategory = new L_category ();
  6796. Doo::loadModel ( 'verify' );
  6797. Doo::loadModel ( 'statistics' );
  6798. $statistics = new statistics ();
  6799. $verify = new verify ();
  6800. Doo::loadModel ( 'staff' );
  6801. $staff = new staff ();
  6802. Doo::loadClass ( 'XDeode' );
  6803. $XDeode = new XDeode ( 5 );
  6804. $XDeode7 = new XDeode ( 7 );
  6805. $cid = $XDeode->decode ( $cidKey );
  6806. $condition = "";
  6807. if ($item == "expenses")
  6808. $condition = " and Rtype=1 ";
  6809. elseif ($item == "receipts")
  6810. $condition = " and Rtype=0 ";
  6811. elseif ($item == "remits")
  6812. $condition = " and Rtype=2 ";
  6813. elseif($item == "train")
  6814. $condition = " and Rtype=3 ";
  6815. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  6816. $sopString = $cidString = "";
  6817. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  6818. if (empty ( $rdate ))
  6819. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  6820. else
  6821. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  6822. if ($status == 'pendImplement') {
  6823. $condition .= ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  6824. } elseif ($status == 'alerpts') {
  6825. $statusCon = '(status=8 or status=9 )';
  6826. if (empty ( $rdate ))
  6827. $dateCondition .= " and Year(date) =" . $year;
  6828. else
  6829. $dateCondition .= " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  6830. }
  6831. if ($sop != 'SOP')
  6832. $sopString = " and staff=" . $sop;
  6833. if ($cidKey != 'ALL')
  6834. $cidString = " and cid=" . $cid;
  6835. //汇款信息需要提取出来
  6836. if(!empty($receiptOrder)){
  6837. $receiptList = $receipt->find ( array (
  6838. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  6839. 'desc' => 'rid',
  6840. 'asArray' => true
  6841. ) );
  6842. // 员工筛选
  6843. $receiptList2 = $receipt->find ( array (
  6844. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  6845. 'desc' => 'rid',
  6846. 'asArray' => true
  6847. ) );
  6848. }else{
  6849. $receiptList = $receipt->find ( array (
  6850. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  6851. 'desc' => 'rid',
  6852. 'asArray' => true
  6853. ) );
  6854. // 员工筛选
  6855. $receiptList2 = $receipt->find ( array (
  6856. 'where' => $statusCon . $condition . $dateCondition,
  6857. 'desc' => 'rid',
  6858. 'asArray' => true
  6859. ) );
  6860. }
  6861. $sopStaff = array ();
  6862. foreach ( $receiptList2 as $key => $value ) {
  6863. $staffDetail = $staff->getOne ( array (
  6864. 'select' => 'username',
  6865. 'where' => 'sid=' . $value ['staff'],
  6866. 'asArray' => true
  6867. ) );
  6868. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  6869. }
  6870. // 办事处筛选
  6871. $categoryScreen = array ();
  6872. $categorList = $Lcategory->getCategory ();
  6873. foreach ( $receiptList2 as $key => $value ) {
  6874. foreach ( $categorList as $k => $v ) {
  6875. if ($value ['cid'] == $v ['cid']) {
  6876. $categoryScreen [$v ['cidKey']] = $v ['title'];
  6877. break;
  6878. }
  6879. }
  6880. }
  6881. $categoryScreenHtml = "";
  6882. foreach ( $categoryScreen as $key => $value ) {
  6883. if ($cidKey == $key)
  6884. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  6885. else
  6886. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  6887. }
  6888. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  6889. $data ['cidKey'] = $cidKey;
  6890. $Locate = 0;
  6891. $roleId = 0;
  6892. $button = 0;
  6893. $staffBatchNumber = 100001;
  6894. $remittanceList = array ();
  6895. foreach ( $receiptList as $key => $value ) {
  6896. $receiptList [$key] ['ridKey7'] = $XDeode7->encode ( $value ['rid'] );
  6897. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  6898. $receiptList [$key] ['Texe'] = 'false';
  6899. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  6900. $receiptList [$key] ['Texe'] = 'true';
  6901. }
  6902. $receiptList [$key] ['TRexe'] = 'true';
  6903. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  6904. $receiptList [$key] ['TRexe'] = 'false';
  6905. }
  6906. $receiptList [$key] ['Locate'] = $Locate;
  6907. $Locate ++;
  6908. $receiptList [$key] ['reviseDetail'] = array ();
  6909. if (! empty ( $value ['reviseDetail'] ))
  6910. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6911. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6912. $categoryDetil = $Lcategory->getOne ( array (
  6913. 'where' => 'cid=' . $value ['cid'],
  6914. 'asArray' => true
  6915. ) );
  6916. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6917. // 检测编辑状态
  6918. $verifyList = $verify->getOne ( array (
  6919. 'where' => 'vid=' . $value ['verify'],
  6920. 'asArray' => true
  6921. ) );
  6922. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6923. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6924. Doo::loadModel ( 'role' );
  6925. $role = new role ();
  6926. $flag = true;
  6927. $roleKey = 0;
  6928. $endStaffArray = array ();
  6929. $roleArrayCopy = array ();
  6930. foreach ( $verifyList as $k => $v ) {
  6931. // init verifyStaff
  6932. if ($v [1] == 'ROLE') {
  6933. if (! empty ( $verifyStaff )) {
  6934. $endStaffArray = end ( $verifyStaff );
  6935. }
  6936. $roleVerify = json_decode ( $v [3], true );
  6937. $roleKey = $k;
  6938. $roleArray = array ();
  6939. $rolename = $role->getOne ( array (
  6940. 'where' => 'rid=' . $v [0],
  6941. 'asArray' => true
  6942. ) );
  6943. foreach ( $roleVerify as $o => $p ) {
  6944. $staffID = explode ( '_', $p );
  6945. $staffInfo = $staff->getOne ( array (
  6946. 'where' => 'sid=' . $staffID [0],
  6947. 'asArray' => true
  6948. ) );
  6949. $exp = array (
  6950. 0 => $staffInfo ['sid'],
  6951. 1 => $staffID [1],
  6952. 2 => $staffInfo ['avatar'],
  6953. 'date' => '',
  6954. 'date' => '',
  6955. 'opinion' => '',
  6956. 'status' => '',
  6957. 'rolename' => $rolename ['name']
  6958. );
  6959. array_push ( $roleArray, $exp );
  6960. }
  6961. $roleArrayCopy [$v [0]] = $roleArray;
  6962. }
  6963. $verifyList [$k] ['date'] = "";
  6964. $verifyList [$k] ['opinion'] = "";
  6965. $verifyList [$k] ['status'] = "";
  6966. if (empty ( $verifyStaff )) {
  6967. $verifyList [$k] ['date'] = "";
  6968. $verifyList [$k] ['opinion'] = "";
  6969. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6970. $verifyList [$k] ['status'] = 4;
  6971. $flag = false;
  6972. }
  6973. } else {
  6974. foreach ( $verifyStaff as $m => $u ) {
  6975. if ($v [0] == $m) {
  6976. $verifyList [$k] ['date'] = $u ['date'];
  6977. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6978. $verifyList [$k] ['status'] = $u ['status'];
  6979. $flag = false;
  6980. break;
  6981. }
  6982. }
  6983. $endStaffArray = end ( $verifyStaff );
  6984. }
  6985. }
  6986. $rolename ['name'] = '';
  6987. if (! empty ( $roleId )) {
  6988. Doo::loadModel ( 'role' );
  6989. $role = new role ();
  6990. $rolename = $role->getOne ( array (
  6991. 'where' => 'rid=' . $roleId,
  6992. 'asArray' => true
  6993. ) );
  6994. }
  6995. if (! empty ( $verifyStaff ))
  6996. $endStaffArray = end ( $verifyStaff );
  6997. $KOP = false;
  6998. foreach ( $roleArrayCopy as $P => $A ) {
  6999. foreach ( $A as $MKI => $AVL ) {
  7000. if (! empty ( $verifyStaff )) {
  7001. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7002. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7003. $button = 4;
  7004. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7005. }
  7006. foreach ( $verifyStaff as $m => $u ) {
  7007. $AVLFK = $AVL [0] . '_R';
  7008. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7009. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7010. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7011. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7012. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7013. break;
  7014. }
  7015. }
  7016. } else {
  7017. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7018. $button = 4;
  7019. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7020. }
  7021. }
  7022. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7023. $KOP = true;
  7024. }
  7025. }
  7026. foreach ( $roleArrayCopy as $k => $v ) {
  7027. foreach ( $verifyList as $m => $n ) {
  7028. if ($n [0] == $k) {
  7029. array_splice ( $verifyList, $m, 1, $v );
  7030. }
  7031. }
  7032. }
  7033. $receiptList [$key] ['verifyList'] = $verifyList;
  7034. $staffDetail = $staff->getOne ( array (
  7035. 'where' => 'sid=' . $value ['staff'],
  7036. 'asArray' => true
  7037. ) );
  7038. $receiptList [$key] ['staffDetail'] = $staffDetail;
  7039. $receiptList [$key] ['button'] = $button;
  7040. if ($value['Rtype']==1){
  7041. $receiptList [$key] ['relust'] = $value['sum']-$value['loanSum'];
  7042. $receiptList [$key] ['relustABS'] = abs($receiptList [$key] ['relust']);
  7043. }elseif($value['Rtype']==3){
  7044. // 收入合计
  7045. Doo::loadModel ( 'invoiceTraining' );
  7046. $invoiceTraining = new invoiceTraining ();
  7047. $invoiceTrainingDetail = array (
  7048. 'invoiceArriveAmount' => '0.00',
  7049. 'RIAmount' => '0.00',
  7050. 'invoiceTotalAmount' => '0.00',
  7051. 'invoiceCompanyAmount' => '0.00',
  7052. 'invoiceArriveAmountM'=>'0.00',
  7053. 'invoiceCompanyAmountM'=>'0.00'
  7054. );
  7055. if ($value ['invoiceTrainId'] != 0) {
  7056. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $value['invoiceTrainId'] );
  7057. }
  7058. $invoiceArriveAmount = $RIAmount = 0;
  7059. if (! empty ( $invoiceTrainingDetail )) {
  7060. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  7061. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  7062. }
  7063. // 备用金
  7064. $sum = 0;
  7065. if (! empty ( $value ['trainLoanRid'] )) {
  7066. $receiptLoanList = $receipt->getReceiptInRid ( $value ['trainLoanRid'] );
  7067. foreach ($receiptLoanList as $kll=>$vll){
  7068. $sum+=$vll['sum'];
  7069. }
  7070. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $value ['trainLoanRid'] );
  7071. // $sum = $receiptLoanDetailBak ['sum'];
  7072. }
  7073. // 支出项金额详情
  7074. // 项目金额合计
  7075. Doo::loadModel ( 'RItem' );
  7076. $RItem = new RItem ();
  7077. Doo::loadModel ( 'accountItem' );
  7078. $accountItem = new accountItem ();
  7079. // 讲师获得
  7080. Doo::loadModel ( 'RILecturer' );
  7081. $RILecturer = new RILecturer ();
  7082. $RItemList = $RItem->getRItemByRid ( $value['rid'] );
  7083. $RILecturerList = $RILecturer->getRILecturerByRid ( $value['rid'] );
  7084. // 支出项金额详情
  7085. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  7086. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  7087. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  7088. $receiptList [$key] ['payment'] =$payment;
  7089. $receiptList [$key] ['paymentABS'] =sprintf("%.2f",abs($payment));
  7090. }
  7091. // 设置导出汇款execl
  7092. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  7093. $remittanceDetail = array (
  7094. $staffBatchNumber,
  7095. $value ['remittanceName'],
  7096. $value ['bankNumber'],
  7097. $value ['bankName'],
  7098. $value ['remittanceBankType'],
  7099. $value ['coupletNumber'],
  7100. $value ['sum']
  7101. );
  7102. array_push ( $remittanceList, $remittanceDetail );
  7103. $staffBatchNumber ++;
  7104. }
  7105. }
  7106. $data ['remittanceList'] = json_encode ( $remittanceList );
  7107. // print_r($receiptList);
  7108. $mothHtml = "";
  7109. for($i = 1; $i <= 12; $i ++) {
  7110. if ($moth == $i)
  7111. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7112. else
  7113. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7114. }
  7115. $dayHtml = "";
  7116. if ($day != "DAY" || $moth != "MONTH") {
  7117. for($i = 1; $i <= 31; $i ++) {
  7118. if ($day == $i)
  7119. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  7120. else
  7121. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  7122. }
  7123. }
  7124. $sopHtml = "";
  7125. foreach ( $sopStaff as $key => $value ) {
  7126. if ($sop == $key)
  7127. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  7128. else
  7129. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  7130. }
  7131. $data ['status'] = $status;
  7132. $data ['rdate'] = $rdate;
  7133. $data ['sopHtml'] = $sopHtml;
  7134. $data ['dayHtml'] = $dayHtml;
  7135. $data ['mothHtml'] = $mothHtml;
  7136. $data ['receiptList'] = $receiptList;
  7137. $data ['memu'] = "receipt";
  7138. $data ['staff'] = $this->staff;
  7139. $data ['receiptMemu'] = 'implement';
  7140. $data ['verifyId'] = $this->verifyId;
  7141. $data ['executeId'] = $this->executeId;
  7142. $data ['item'] = $item;
  7143. $data ['year'] = $year;
  7144. $data ['moth'] = $moth;
  7145. $data['receiptOrder']=$receiptOrder;
  7146. $data ['day'] = $day;
  7147. $data ['sop'] = $sop;
  7148. $this->render ( "/admin/hisImplement", $data );
  7149. }
  7150. /**
  7151. * 导出汇款信息的exelc
  7152. */
  7153. function exportRemittance() {
  7154. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  7155. if (empty ( $remittanceInfo ))
  7156. die ( 'illegal request' );
  7157. $title = array (
  7158. '员工编号',
  7159. '姓名',
  7160. '员工账号',
  7161. '员工账户开户行',
  7162. '转账类型',
  7163. '联行号',
  7164. '金额'
  7165. );
  7166. $data = json_decode ( $remittanceInfo, true );
  7167. if (empty ( $data ))
  7168. die ( 'illegal request' );
  7169. Doo::loadClass ( 'receipt.func' );
  7170. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  7171. header ( 'Content-Type:text/html;charset=utf-8' );
  7172. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  7173. }
  7174. function ajaxExamine() {
  7175. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7176. Doo::loadModel ( 'receipt' );
  7177. $receipt = new receipt ();
  7178. if (! empty ( $rid )) {
  7179. $rLRes = $receipt->find ( array (
  7180. '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,
  7181. 'asArray' => true
  7182. ) );
  7183. if(!empty($rLRes)){
  7184. Doo::loadClass ( 'XDeode' );
  7185. $XDeode = new XDeode ( 7 );
  7186. $rLRes [0]['ridKey'] = $XDeode->encode( $rLRes [0]['rid'] );
  7187. echo json_encode ( array (
  7188. 'status' => 1,
  7189. 'receipt' => $rLRes [0]
  7190. ) );
  7191. die ();
  7192. }else{
  7193. echo json_encode ( array (
  7194. 'status' => 1,
  7195. 'receipt' => array ()
  7196. ) );
  7197. die ();
  7198. }
  7199. }
  7200. echo json_encode ( array (
  7201. 'status' => 0,
  7202. 'receipt' => array ()
  7203. ) );
  7204. die ();
  7205. }
  7206. /*
  7207. * 废弃
  7208. */
  7209. function myReceipt() {
  7210. // all approval past withdraw
  7211. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  7212. if (empty ( $item ))
  7213. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  7214. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7215. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  7216. Doo::loadModel ( 'receipt' );
  7217. $receipt = new receipt ();
  7218. // pre-loaded
  7219. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  7220. // have cache
  7221. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  7222. if (! empty ( $moth )) // yearPage
  7223. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  7224. $this->showCache ( $path );
  7225. }
  7226. Doo::loadModel ( 'L_category' );
  7227. $Lcategory = new L_category ();
  7228. Doo::loadModel ( 'verify' );
  7229. Doo::loadModel ( 'statistics' );
  7230. $statistics = new statistics ();
  7231. $verify = new verify ();
  7232. Doo::loadModel ( 'staff' );
  7233. $staff = new staff ();
  7234. $condition = " and status!=0 ";
  7235. if ($item == "approval")
  7236. $condition = " and status=2 ";
  7237. elseif ($item == "withdraw")
  7238. $condition = " and status=3 ";
  7239. elseif ($item == "past")
  7240. $condition = " and status=1 ";
  7241. elseif ($item == "whdw")
  7242. $condition = " and status=4 ";
  7243. $dateCondition = " and Year(date) =" . $year;
  7244. if (! empty ( $moth )) {
  7245. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  7246. $stList = $statistics->getOne ( array (
  7247. 'select' => 'rePrice ,agPrice',
  7248. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7249. 'asArray' => true
  7250. ) );
  7251. } else
  7252. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7253. if (empty ( $stList ))
  7254. $stList = array (
  7255. 'rePrice' => 0,
  7256. 'agPrice' => 0
  7257. );
  7258. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  7259. $data ['stList'] = array (
  7260. 'rePrice' => $stList ['rePrice'],
  7261. 'agPrice' => $stList ['agPrice'],
  7262. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  7263. );
  7264. $receiptList = $receipt->find ( array (
  7265. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  7266. 'desc' => 'rid',
  7267. 'asArray' => true
  7268. ) );
  7269. $Locate = 0;
  7270. $roleId = 0;
  7271. $button = 0;
  7272. foreach ( $receiptList as $key => $value ) {
  7273. $receiptList [$key] ['Locate'] = $Locate;
  7274. $Locate ++;
  7275. $receiptList [$key] ['reviseDetail'] = array ();
  7276. if (! empty ( $value ['reviseDetail'] ))
  7277. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7278. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7279. $categoryDetil = $Lcategory->getOne ( array (
  7280. 'where' => 'cid=' . $value ['cid'],
  7281. 'asArray' => true
  7282. ) );
  7283. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7284. // 检测编辑状态
  7285. $verifyList = $verify->getOne ( array (
  7286. 'where' => 'vid=' . $value ['verify'],
  7287. 'asArray' => true
  7288. ) );
  7289. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7290. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7291. Doo::loadModel ( 'role' );
  7292. $role = new role ();
  7293. $flag = true;
  7294. $roleKey = 0;
  7295. $endStaffArray = array ();
  7296. $roleArrayCopy = array ();
  7297. foreach ( $verifyList as $k => $v ) {
  7298. // init verifyStaff
  7299. if ($v [1] == 'ROLE') {
  7300. if (! empty ( $verifyStaff )) {
  7301. $endStaffArray = end ( $verifyStaff );
  7302. // if ($v[0]==$endStaffArray['nextStaff']){
  7303. // $roleId=$v[0];
  7304. // }
  7305. }
  7306. $roleVerify = json_decode ( $v [3], true );
  7307. $roleKey = $k;
  7308. $roleArray = array ();
  7309. $rolename = $role->getOne ( array (
  7310. 'where' => 'rid=' . $v [0],
  7311. 'asArray' => true
  7312. ) );
  7313. foreach ( $roleVerify as $o => $p ) {
  7314. $staffID = explode ( '_', $p );
  7315. $staffInfo = $staff->getOne ( array (
  7316. 'where' => 'sid=' . $staffID [0],
  7317. 'asArray' => true
  7318. ) );
  7319. // print_r($staffID);
  7320. $exp = array (
  7321. 0 => $staffInfo ['sid'],
  7322. 1 => $staffID [1],
  7323. 2 => $staffInfo ['avatar'],
  7324. 'date' => '',
  7325. 'date' => '',
  7326. 'opinion' => '',
  7327. 'status' => '',
  7328. 'rolename' => $rolename ['name']
  7329. );
  7330. array_push ( $roleArray, $exp );
  7331. }
  7332. $roleArrayCopy [$v [0]] = $roleArray;
  7333. // $verifyList[$k]['roleArray']=$roleArray;
  7334. }
  7335. $verifyList [$k] ['date'] = "";
  7336. $verifyList [$k] ['opinion'] = "";
  7337. $verifyList [$k] ['status'] = "";
  7338. if (empty ( $verifyStaff )) {
  7339. $verifyList [$k] ['date'] = "";
  7340. $verifyList [$k] ['opinion'] = "";
  7341. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7342. $verifyList [$k] ['status'] = 4;
  7343. $flag = false;
  7344. }
  7345. } else {
  7346. foreach ( $verifyStaff as $m => $u ) {
  7347. if ($v [0] == $m) {
  7348. $verifyList [$k] ['date'] = $u ['date'];
  7349. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7350. $verifyList [$k] ['status'] = $u ['status'];
  7351. $flag = false;
  7352. break;
  7353. }
  7354. }
  7355. $endStaffArray = end ( $verifyStaff );
  7356. if (isset ( $endStaffArray ['ROLE'] )) {
  7357. } else {
  7358. // $endKey=key($verifyStaff);
  7359. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  7360. // $button=4;
  7361. // $verifyList[$k]['status']=4;
  7362. // }
  7363. }
  7364. }
  7365. }
  7366. $rolename ['name'] = '';
  7367. if (! empty ( $roleId )) {
  7368. Doo::loadModel ( 'role' );
  7369. $role = new role ();
  7370. $rolename = $role->getOne ( array (
  7371. 'where' => 'rid=' . $roleId,
  7372. 'asArray' => true
  7373. ) );
  7374. }
  7375. if (! empty ( $verifyStaff ))
  7376. $endStaffArray = end ( $verifyStaff );
  7377. $KOP = false;
  7378. foreach ( $roleArrayCopy as $P => $A ) {
  7379. foreach ( $A as $MKI => $AVL ) {
  7380. if (! empty ( $verifyStaff )) {
  7381. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7382. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7383. $button = 4;
  7384. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7385. }
  7386. foreach ( $verifyStaff as $m => $u ) {
  7387. $AVLFK = $AVL [0] . '_R';
  7388. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7389. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7390. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7391. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7392. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7393. break;
  7394. }
  7395. }
  7396. } else {
  7397. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7398. $button = 4;
  7399. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7400. }
  7401. }
  7402. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7403. $KOP = true;
  7404. }
  7405. }
  7406. foreach ( $roleArrayCopy as $k => $v ) {
  7407. foreach ( $verifyList as $m => $n ) {
  7408. if ($n [0] == $k) {
  7409. array_splice ( $verifyList, $m, 1, $v );
  7410. }
  7411. }
  7412. }
  7413. $receiptList [$key] ['verifyList'] = $verifyList;
  7414. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7415. 'where' => 'sid=' . $value ['staff'],
  7416. 'asArray' => true
  7417. ) );
  7418. $receiptList [$key] ['button'] = $button;
  7419. }
  7420. // print_r($receiptList);die;
  7421. $mothHtml = "";
  7422. for($i = 1; $i <= 12; $i ++) {
  7423. if ($moth == $i)
  7424. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7425. else
  7426. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7427. }
  7428. $data ['mothHtml'] = $mothHtml;
  7429. $data ['receiptList'] = $receiptList;
  7430. $data ['memu'] = "receipt";
  7431. $data ['staff'] = $this->staff;
  7432. $data ['receiptMemu'] = 'receipt';
  7433. $data ['verifyId'] = $this->verifyId;
  7434. $data ['executeId'] = $this->executeId;
  7435. $data ['item'] = $item;
  7436. $data ['year'] = $year;
  7437. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  7438. // sufficient condition to generate cache
  7439. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  7440. $receiptList = $receipt->find ( array (
  7441. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7442. 'asArray' => true
  7443. ) );
  7444. if (empty ( $receiptList )) { // generated files
  7445. ob_start ();
  7446. $this->render ( "/admin/saea_myList", $data );
  7447. $this->cacheFile ( $path );
  7448. die ();
  7449. // $content = ob_get_contents();
  7450. // $fp = fopen($path, "w");
  7451. // fwrite($fp, $content);
  7452. // fclose($fp);
  7453. }
  7454. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  7455. $receiptList = $receipt->find ( array (
  7456. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  7457. 'asArray' => true
  7458. ) );
  7459. if (empty ( $receiptList )) { // generated files
  7460. ob_start ();
  7461. $this->render ( "/admin/saea_myList", $data );
  7462. $this->cacheFile ( $path );
  7463. die ();
  7464. }
  7465. }
  7466. }
  7467. $this->render ( "/admin/saea_myList", $data );
  7468. }
  7469. function approvedReceipt() {
  7470. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7471. Doo::loadModel ( 'receipt' );
  7472. Doo::loadModel ( 'receiptDetail' );
  7473. $receipt = new receipt ();
  7474. $receiptDetail = new receiptDetail ();
  7475. Doo::loadModel ( 'statistics' );
  7476. Doo::loadModel ( 'itemStatistics' );
  7477. $statistics = new statistics ();
  7478. $itemStatistics = new itemStatistics ();
  7479. Doo::loadModel ( "verify" );
  7480. $verify = new verify ();
  7481. // 审批状态的判定
  7482. $receiptDetailList = $receipt->getOne ( array (
  7483. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  7484. 'asArray' => true
  7485. ) );
  7486. if (empty ( $receiptDetailList ))
  7487. return "/saeaBorad";
  7488. $verifyDetail = $verify->getOne ( array (
  7489. 'where' => ' vid =' . $receiptDetailList ['verify'],
  7490. 'asArray' => true
  7491. ) );
  7492. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7493. if (empty ( $receiptDetailList ['nowStaff'] )) {
  7494. $nowStaff = "";
  7495. $nowStaffList = array ();
  7496. if ($verifyDetail [0] [1] == 'ROLE') {
  7497. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7498. foreach ( $vStaffString as $key => $value ) {
  7499. $staffK = explode ( "_", $value );
  7500. array_push ( $nowStaffList, $staffK [0] );
  7501. }
  7502. $nowStaff = implode ( ',', $nowStaffList );
  7503. } else {
  7504. $nowStaff = $verifyDetail [0] [0];
  7505. }
  7506. $receipt->nowStaff = $nowStaff;
  7507. }
  7508. // echo $nowStaff;
  7509. // print_r($verifyDetail);die;
  7510. $receipt->rid = $receiptDetailList ['rid'];
  7511. $receipt->date = date ( "Y-m-d" );
  7512. $receipt->status = 2;
  7513. $receipt->update ();
  7514. $receiptDetail->status = 2;
  7515. $receiptDetail->update ( array (
  7516. 'where' => 'rid=' . $receiptDetailList ['rid']
  7517. ) );
  7518. Doo::loadModel ( "receiptLog" );
  7519. $receiptLog = new receiptLog ();
  7520. Doo::loadModel ( "verify" );
  7521. $verify = new verify ();
  7522. $receiptInfo = $receipt->getOne ( array (
  7523. 'where' => 'rid=' . $rid,
  7524. 'asArray' => true
  7525. ) );
  7526. $vr = $verify->getOne ( array (
  7527. 'where' => 'vid=' . $receiptInfo ['verify'],
  7528. 'asArray' => true
  7529. ) );
  7530. $jd = json_decode ( $vr ['staff'] );
  7531. $roleId = 0;
  7532. foreach ( $jd as $key => $value ) {
  7533. if ($value [1] == 'ROLE') {
  7534. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7535. if ($pos !== false) {
  7536. $roleId = $value [0];
  7537. }
  7538. }
  7539. }
  7540. // 审批日志
  7541. // echo $roleId;die;
  7542. if (! empty ( $roleId )) {
  7543. Doo::loadModel ( "role" );
  7544. $role = new role ();
  7545. $roleInfo = $role->getOne ( array (
  7546. 'where' => 'rid=' . $roleId,
  7547. 'asArray' => true
  7548. ) );
  7549. // $receiptLog->rolename = $roleInfo ['name'];
  7550. }
  7551. $receiptLog->username = $this->staff [0] ['username'];
  7552. $receiptLog->uid = $this->staff [0] ['sid'];
  7553. $receiptLog->date = date ( "Y-m-d" );
  7554. $receiptLog->opinion = '提交审批';
  7555. $receiptLog->img = $this->staff [0] ['avatar'];
  7556. $receiptLog->status = 2;
  7557. $receiptLog->rid = $rid;
  7558. $receiptLog->insert ();
  7559. // statistics item
  7560. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  7561. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7562. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  7563. $stat = $statistics->getOne ( array (
  7564. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7565. 'asArray' => true
  7566. ) );
  7567. if (empty ( $stat )) {
  7568. $statistics->date = date ( "Y-m-d" );
  7569. $statistics->cid = $this->staff [0] ['cid'];
  7570. $statistics->staff = $this->staff [0] ['sid'];
  7571. $statistics->agPrice = 0;
  7572. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7573. $statistics->insert ();
  7574. } else {
  7575. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7576. $statistics->update ( array (
  7577. 'where' => 'sid=' . $stat ['sid']
  7578. ) );
  7579. }
  7580. return "/expenses";
  7581. }
  7582. function approval() {
  7583. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7584. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7585. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7586. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7587. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7588. if (empty ( $status ))
  7589. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7590. $vidList = array ();
  7591. $button = 0;
  7592. Doo::loadModel ( 'verify' );
  7593. $verify = new verify ();
  7594. Doo::loadModel ( 'receipt' );
  7595. $receipt = new receipt ();
  7596. Doo::loadModel ( 'staff' );
  7597. $staff = new staff ();
  7598. Doo::loadModel ( 'L_category' );
  7599. $Lcategory = new L_category ();
  7600. // user verify ID
  7601. $verifyDetail = $verify->find ( array (
  7602. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7603. 'asArray' => true
  7604. ) );
  7605. foreach ( $verifyDetail as $key => $value ) {
  7606. array_push ( $vidList, $value ['vid'] );
  7607. }
  7608. $vid = implode ( ",", $vidList );
  7609. if (empty ( $verifyDetail ))
  7610. $vid = 0;
  7611. /*
  7612. */
  7613. $dateCondition = " and Year(date) =" . $year;
  7614. if (! empty ( $month ))
  7615. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  7616. $categoryList = $Lcategory->find ( array (
  7617. 'asArray' => true
  7618. ) );
  7619. $staffList = $staff->find ( array (
  7620. 'where' => 'cid=' . $cid,
  7621. 'asArray' => true
  7622. ) );
  7623. $cateCondition = "";
  7624. $staffCondition = "";
  7625. $approvalCondition = "";
  7626. if (! empty ( $cid ))
  7627. $cateCondition = ' and cid=' . $cid;
  7628. if (! empty ( $sid )) {
  7629. $staffCondition = ' and staff=' . $sid;
  7630. $cateCondition = "";
  7631. }
  7632. // elseif($status==1){
  7633. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  7634. // }
  7635. if ($status == 2) {
  7636. // 查找角色审批人
  7637. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  7638. }
  7639. $ap = "";
  7640. if ($status == 4) {
  7641. $ap = 4;
  7642. $status = 2;
  7643. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  7644. }
  7645. if ($status == 5) {
  7646. $status = 4;
  7647. $ap = 5;
  7648. }
  7649. // echo $vid;
  7650. // get Receipt By verifyID status 2 .$approvalCondition
  7651. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  7652. $receiptList = $receipt->find ( array (
  7653. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  7654. 'desc' => 'rid',
  7655. 'asArray' => true
  7656. ) );
  7657. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  7658. $Locate = 0;
  7659. if ($ap == 4)
  7660. $status = 4;
  7661. elseif ($ap == 5)
  7662. $status = 5;
  7663. foreach ( $receiptList as $key => $value ) {
  7664. $receiptList [$key] ['Locate'] = $Locate;
  7665. $Locate ++;
  7666. $receiptList [$key] ['reviseDetail'] = array ();
  7667. if (! empty ( $value ['reviseDetail'] ))
  7668. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7669. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7670. $categoryDetil = $Lcategory->getOne ( array (
  7671. 'where' => 'cid=' . $value ['cid'],
  7672. 'asArray' => true
  7673. ) );
  7674. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7675. $verifyList = $verify->getOne ( array (
  7676. 'where' => 'vid=' . $value ['verify'],
  7677. 'asArray' => true
  7678. ) );
  7679. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7680. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7681. foreach ( $verifyList as $k => $v ) {
  7682. // init verifyStaff
  7683. $verifyList [$k] ['date'] = "";
  7684. $verifyList [$k] ['opinion'] = "";
  7685. $verifyList [$k] ['status'] = "";
  7686. if (empty ( $verifyStaff )) {
  7687. $verifyList [$k] ['date'] = "";
  7688. $verifyList [$k] ['opinion'] = "";
  7689. if ($v [0] == $this->staff [0] ['sid']) {
  7690. $verifyList [$k] ['status'] = 4;
  7691. $button = 4;
  7692. }
  7693. } else {
  7694. $flag = true;
  7695. foreach ( $verifyStaff as $m => $u ) {
  7696. if ($v [0] == $m) {
  7697. $verifyList [$k] ['date'] = $u ['date'];
  7698. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7699. $verifyList [$k] ['status'] = $u ['status'];
  7700. $flag = false;
  7701. break;
  7702. }
  7703. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  7704. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  7705. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  7706. }
  7707. if ($flag) { // 检测可编辑
  7708. if ($v [0] == $this->staff [0] ['sid']) {
  7709. $verifyList [$k] ['status'] = 4;
  7710. $button = 4;
  7711. }
  7712. }
  7713. }
  7714. }
  7715. $receiptList [$key] ['verifyList'] = $verifyList;
  7716. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7717. 'where' => 'sid=' . $value ['staff'],
  7718. 'asArray' => true
  7719. ) );
  7720. $receiptList [$key] ['button'] = $button;
  7721. }
  7722. // print_r($receiptList);die;
  7723. // $data['verifyDetail']=$verifyDetail;
  7724. $mothHtml = "";
  7725. for($i = 1; $i <= 12; $i ++) {
  7726. if ($month == $i)
  7727. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7728. else
  7729. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7730. }
  7731. $data ['mothHtml'] = $mothHtml;
  7732. $data ['receiptList'] = $receiptList;
  7733. $data ['receiptApprovalCount'] = count ( $receiptList );
  7734. $data ['status'] = $status;
  7735. $data ['year'] = $year;
  7736. $data ['categoryList'] = $categoryList;
  7737. $data ['staffList'] = $staffList;
  7738. $data ['cid'] = $cid;
  7739. $data ['sid'] = $sid;
  7740. $data ['ap'] = $ap;
  7741. $data ['memu'] = "receipt";
  7742. $data ['staff'] = $this->staff;
  7743. $data ['receiptMemu'] = 'approval';
  7744. $data ['verifyId'] = $this->verifyId;
  7745. $data ['executeId'] = $this->executeId;
  7746. $this->render ( "/admin/saea_reportList", $data );
  7747. }
  7748. function approvalDetails() {
  7749. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7750. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7751. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7752. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7753. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7754. Doo::loadModel ( 'verify' );
  7755. $verify = new verify ();
  7756. Doo::loadModel ( 'receipt' );
  7757. $receipt = new receipt ();
  7758. Doo::loadModel ( 'staff' );
  7759. $staff = new staff ();
  7760. Doo::loadModel ( 'L_category' );
  7761. $Lcategory = new L_category ();
  7762. Doo::loadModel ( 'enclosur' );
  7763. $enclosur = new enclosur ();
  7764. $vidList = array ();
  7765. $verifyDetail = $verify->find ( array (
  7766. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7767. 'asArray' => true
  7768. ) );
  7769. foreach ( $verifyDetail as $key => $value ) {
  7770. array_push ( $vidList, $value ['vid'] );
  7771. }
  7772. $vid = implode ( ",", $vidList );
  7773. if (empty ( $verifyDetail ))
  7774. $vid = 0;
  7775. $categoryList = $Lcategory->find ( array (
  7776. 'asArray' => true
  7777. ) );
  7778. $staffList = $staff->find ( array (
  7779. 'where' => 'cid=' . $cid,
  7780. 'asArray' => true
  7781. ) );
  7782. $ap = 0;
  7783. $receiptList = $receipt->find ( array (
  7784. 'where' => 'rid =' . $rid,
  7785. 'desc' => 'rid',
  7786. 'asArray' => true
  7787. ) );
  7788. $Locate = 0;
  7789. $roleId = 0;
  7790. $button = 0;
  7791. foreach ( $receiptList as $key => $value ) {
  7792. $receiptList [$key] ['Locate'] = $Locate;
  7793. $Locate ++;
  7794. $receiptList [$key] ['reviseDetail'] = array ();
  7795. if (! empty ( $value ['reviseDetail'] ))
  7796. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7797. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7798. $categoryDetil = $Lcategory->getOne ( array (
  7799. 'where' => 'cid=' . $value ['cid'],
  7800. 'asArray' => true
  7801. ) );
  7802. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7803. // 检测编辑状态
  7804. $verifyList = $verify->getOne ( array (
  7805. 'where' => 'vid=' . $value ['verify'],
  7806. 'asArray' => true
  7807. ) );
  7808. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7809. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7810. Doo::loadModel ( 'role' );
  7811. $role = new role ();
  7812. // print_r($verifyList);
  7813. $flag = true;
  7814. $roleKey = 0;
  7815. $endStaffArray = array ();
  7816. $roleArrayCopy = array ();
  7817. foreach ( $verifyList as $k => $v ) {
  7818. // init verifyStaff
  7819. if ($v [1] == 'ROLE') {
  7820. if (! empty ( $verifyStaff )) {
  7821. $endStaffArray = end ( $verifyStaff );
  7822. if ($v [0] == $endStaffArray ['nextStaff']) {
  7823. $roleId = $v [0];
  7824. }
  7825. }
  7826. $roleVerify = json_decode ( $v [3], true );
  7827. $roleKey = $k;
  7828. $roleArray = array ();
  7829. $rolename = $role->getOne ( array (
  7830. 'where' => 'rid=' . $v [0],
  7831. 'asArray' => true
  7832. ) );
  7833. foreach ( $roleVerify as $o => $p ) {
  7834. $staffID = explode ( '_', $p );
  7835. $staffInfo = $staff->getOne ( array (
  7836. 'where' => 'sid=' . $staffID [0],
  7837. 'asArray' => true
  7838. ) );
  7839. // print_r($staffID);
  7840. $exp = array (
  7841. 0 => $staffInfo ['sid'],
  7842. 1 => $staffID [1],
  7843. 2 => $staffInfo ['avatar'],
  7844. 'date' => '',
  7845. 'date' => '',
  7846. 'opinion' => '',
  7847. 'status' => '',
  7848. 'rolename' => $rolename ['name']
  7849. );
  7850. array_push ( $roleArray, $exp );
  7851. }
  7852. $roleArrayCopy [$v [0]] = $roleArray;
  7853. // $verifyList[$k]['roleArray']=$roleArray;
  7854. }
  7855. // print_r($roleArray);
  7856. $verifyList [$k] ['date'] = "";
  7857. $verifyList [$k] ['opinion'] = "";
  7858. $verifyList [$k] ['status'] = "";
  7859. if (empty ( $verifyStaff )) {
  7860. $verifyList [$k] ['date'] = "";
  7861. $verifyList [$k] ['opinion'] = "";
  7862. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7863. $verifyList [$k] ['status'] = 4;
  7864. $button = 4;
  7865. $flag = false;
  7866. }
  7867. } else {
  7868. foreach ( $verifyStaff as $m => $u ) {
  7869. if ($v [0] == $m) {
  7870. $verifyList [$k] ['date'] = $u ['date'];
  7871. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7872. $verifyList [$k] ['status'] = $u ['status'];
  7873. $flag = false;
  7874. break;
  7875. }
  7876. }
  7877. $endStaffArray = end ( $verifyStaff );
  7878. if (isset ( $endStaffArray ['ROLE'] )) {
  7879. } else {
  7880. $endKey = key ( $verifyStaff );
  7881. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7882. $button = 4;
  7883. $verifyList [$k] ['status'] = 4;
  7884. }
  7885. }
  7886. }
  7887. }
  7888. $rolename ['name'] = '';
  7889. if (! empty ( $roleId )) {
  7890. Doo::loadModel ( 'role' );
  7891. $role = new role ();
  7892. $rolename = $role->getOne ( array (
  7893. 'where' => 'rid=' . $roleId,
  7894. 'asArray' => true
  7895. ) );
  7896. }
  7897. if (! empty ( $verifyStaff ))
  7898. $endStaffArray = end ( $verifyStaff );
  7899. $KOP = false;
  7900. foreach ( $roleArrayCopy as $P => $A ) {
  7901. foreach ( $A as $MKI => $AVL ) {
  7902. if (! empty ( $verifyStaff )) {
  7903. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7904. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7905. $button = 4;
  7906. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7907. }
  7908. foreach ( $verifyStaff as $m => $u ) {
  7909. $AVLFK = $AVL [0] . '_R';
  7910. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7911. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7912. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7913. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7914. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7915. break;
  7916. }
  7917. }
  7918. } else {
  7919. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7920. $button = 4;
  7921. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7922. }
  7923. }
  7924. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7925. $KOP = true;
  7926. }
  7927. }
  7928. foreach ( $roleArrayCopy as $k => $v ) {
  7929. foreach ( $verifyList as $m => $n ) {
  7930. if ($n [0] == $k) {
  7931. array_splice ( $verifyList, $m, 1, $v );
  7932. }
  7933. }
  7934. }
  7935. $receiptList [$key] ['verifyList'] = $verifyList;
  7936. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7937. 'where' => 'sid=' . $value ['staff'],
  7938. 'asArray' => true
  7939. ) );
  7940. $receiptList [$key] ['button'] = $button;
  7941. }
  7942. $mothHtml = "";
  7943. for($i = 1; $i <= 12; $i ++) {
  7944. if ($month == $i)
  7945. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7946. else
  7947. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7948. }
  7949. // 获取审批日志
  7950. Doo::loadModel ( 'receiptLog' );
  7951. $receiptLog = new receiptLog ();
  7952. $rlList = array ();
  7953. $rlInfo = $receiptLog->getOne ( array (
  7954. 'where' => 'rid=' . $rid . ' and status=4',
  7955. 'asArray' => true
  7956. ) );
  7957. $tijdate = $receiptLog->getOne ( array (
  7958. 'where' => 'rid=' . $rid . ' and status=2',
  7959. 'asc' => 'rlid',
  7960. 'asArray' => true
  7961. ) );
  7962. if (! empty ( $rlInfo )) {
  7963. $rlList = $receiptLog->find ( array (
  7964. 'where' => 'rid=' . $rid,
  7965. 'asc' => 'rlid',
  7966. 'asArray' => true
  7967. ) );
  7968. }
  7969. $receiptList [0] ['rlList'] = $rlList;
  7970. $enclosurList = $enclosur->find ( array (
  7971. 'where' => 'rid=' . $rid,
  7972. 'asArray' => true
  7973. ) );
  7974. $enclosurHtml = '';
  7975. foreach ( $enclosurList as $value ) {
  7976. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  7977. }
  7978. $data ['enclosurHtml'] = $enclosurHtml;
  7979. $data ['rolename'] = $rolename ['name'];
  7980. $data ['datetij'] = $tijdate ['date'];
  7981. $data ['mothHtml'] = $mothHtml;
  7982. $data ['receiptList'] = $receiptList;
  7983. $data ['receiptApprovalCount'] = count ( $receiptList );
  7984. $data ['year'] = $year;
  7985. $data ['categoryList'] = $categoryList;
  7986. $data ['staffList'] = $staffList;
  7987. $data ['cid'] = $cid;
  7988. $data ['sid'] = $sid;
  7989. $data ['status'] = 0;
  7990. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  7991. $ap = 4;
  7992. } else
  7993. $data ['status'] = $receiptList [0] ['status'];
  7994. if ($receiptList [0] ['status'] == 4) {
  7995. $data ['status'] = 5;
  7996. $ap = 0;
  7997. }
  7998. $data ['ap'] = $ap;
  7999. $data ['memu'] = "receipt";
  8000. $data ['staff'] = $this->staff;
  8001. $data ['receiptMemu'] = 'approval';
  8002. $data ['verifyId'] = $this->verifyId;
  8003. $data ['executeId'] = $this->executeId;
  8004. $this->render ( "/admin/saeaReportListReport", $data );
  8005. }
  8006. function approvalEdi() {
  8007. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  8008. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  8009. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8010. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8011. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  8012. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  8013. if (empty ( $status ))
  8014. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  8015. $vidList = array ();
  8016. $button = 0;
  8017. Doo::loadModel ( 'verify' );
  8018. Doo::loadModel ( 'receipt' );
  8019. Doo::loadModel ( 'staff' );
  8020. $staff = new staff ();
  8021. $receipt = new receipt ();
  8022. $verify = new verify ();
  8023. Doo::loadModel ( 'L_category' );
  8024. $Lcategory = new L_category ();
  8025. Doo::loadModel ( 'enclosur' );
  8026. $enclosur = new enclosur ();
  8027. // user verify ID
  8028. $verifyDetail = $verify->find ( array (
  8029. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  8030. 'asArray' => true
  8031. ) );
  8032. foreach ( $verifyDetail as $key => $value ) {
  8033. array_push ( $vidList, $value ['vid'] );
  8034. }
  8035. $vid = implode ( ",", $vidList );
  8036. if (empty ( $verifyDetail ))
  8037. $vid = 0;
  8038. $categoryList = $Lcategory->find ( array (
  8039. 'asArray' => true
  8040. ) );
  8041. $staffList = $staff->find ( array (
  8042. 'where' => 'cid=' . $cid,
  8043. 'asArray' => true
  8044. ) );
  8045. $ap = "";
  8046. if ($status == 4) {
  8047. $ap = 4;
  8048. $status = 2;
  8049. }
  8050. // get Receipt By verifyID status 2
  8051. $receiptList = $receipt->find ( array (
  8052. 'where' => 'rid =' . $rid,
  8053. 'desc' => 'rid',
  8054. 'asArray' => true
  8055. ) );
  8056. $Locate = 0;
  8057. $roleId = 0;
  8058. if ($ap == 4)
  8059. $status = 4;
  8060. foreach ( $receiptList as $key => $value ) {
  8061. $receiptList [$key] ['Locate'] = $Locate;
  8062. $Locate ++;
  8063. $receiptList [$key] ['reviseDetail'] = array ();
  8064. if (! empty ( $value ['reviseDetail'] ))
  8065. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  8066. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  8067. $categoryDetil = $Lcategory->getOne ( array (
  8068. 'where' => 'cid=' . $value ['cid'],
  8069. 'asArray' => true
  8070. ) );
  8071. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  8072. // 检测编辑状态
  8073. $verifyList = $verify->getOne ( array (
  8074. 'where' => 'vid=' . $value ['verify'],
  8075. 'asArray' => true
  8076. ) );
  8077. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  8078. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  8079. // print_r($verifyList);
  8080. //
  8081. // if (empty($verifyStaff)){
  8082. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  8083. // $verifyList[0]['status']=4;$button=4;
  8084. // }
  8085. //
  8086. // }else{
  8087. //
  8088. // }
  8089. // die;
  8090. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  8091. // echo array_search("green",$a);
  8092. //
  8093. Doo::loadModel ( 'role' );
  8094. $role = new role ();
  8095. // print_r($verifyList);
  8096. $flag = true;
  8097. $roleKey = 0;
  8098. $endStaffArray = array ();
  8099. $roleArrayCopy = array ();
  8100. foreach ( $verifyList as $k => $v ) {
  8101. // init verifyStaff
  8102. if ($v [1] == 'ROLE') {
  8103. if (! empty ( $verifyStaff )) {
  8104. $endStaffArray = end ( $verifyStaff );
  8105. if ($v [0] == $endStaffArray ['nextStaff']) {
  8106. $roleId = $v [0];
  8107. }
  8108. }
  8109. $roleVerify = json_decode ( $v [3], true );
  8110. $roleKey = $k;
  8111. $roleArray = array ();
  8112. $rolename = $role->getOne ( array (
  8113. 'where' => 'rid=' . $v [0],
  8114. 'asArray' => true
  8115. ) );
  8116. foreach ( $roleVerify as $o => $p ) {
  8117. $staffID = explode ( '_', $p );
  8118. $staffInfo = $staff->getOne ( array (
  8119. 'where' => 'sid=' . $staffID [0],
  8120. 'asArray' => true
  8121. ) );
  8122. // print_r($staffID);
  8123. $exp = array (
  8124. 0 => $staffInfo ['sid'],
  8125. 1 => $staffID [1],
  8126. 2 => $staffInfo ['avatar'],
  8127. 'date' => '',
  8128. 'date' => '',
  8129. 'opinion' => '',
  8130. 'status' => '',
  8131. 'rolename' => $rolename ['name']
  8132. );
  8133. array_push ( $roleArray, $exp );
  8134. }
  8135. $roleArrayCopy [$v [0]] = $roleArray;
  8136. // $verifyList[$k]['roleArray']=$roleArray;
  8137. }
  8138. // print_r($roleArray);
  8139. $verifyList [$k] ['date'] = "";
  8140. $verifyList [$k] ['opinion'] = "";
  8141. $verifyList [$k] ['status'] = "";
  8142. if (empty ( $verifyStaff )) {
  8143. $verifyList [$k] ['date'] = "";
  8144. $verifyList [$k] ['opinion'] = "";
  8145. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  8146. $verifyList [$k] ['status'] = 4;
  8147. $button = 4;
  8148. $flag = false;
  8149. }
  8150. } else {
  8151. foreach ( $verifyStaff as $m => $u ) {
  8152. if ($v [0] == $m) {
  8153. $verifyList [$k] ['date'] = $u ['date'];
  8154. $verifyList [$k] ['opinion'] = $u ['opinion'];
  8155. $verifyList [$k] ['status'] = $u ['status'];
  8156. $flag = false;
  8157. break;
  8158. }
  8159. }
  8160. $endStaffArray = end ( $verifyStaff );
  8161. if (isset ( $endStaffArray ['ROLE'] )) {
  8162. } else {
  8163. $endKey = key ( $verifyStaff );
  8164. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  8165. $button = 4;
  8166. $verifyList [$k] ['status'] = 4;
  8167. }
  8168. }
  8169. // print_r($endStaffArray);die;
  8170. // if (empty($verifyStaff)){
  8171. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  8172. // $verifyList[$k]['status']=4;$button=4;
  8173. // }
  8174. //
  8175. // }else{
  8176. //
  8177. // }
  8178. // if($flag){//检测可编辑
  8179. // if($v[0]==$this->staff[0]['sid']){
  8180. // $verifyList[$k]['status']=4;$button=4;
  8181. // }
  8182. // }
  8183. }
  8184. }
  8185. $rolename ['name'] = '';
  8186. if (! empty ( $roleId )) {
  8187. Doo::loadModel ( 'role' );
  8188. $role = new role ();
  8189. $rolename = $role->getOne ( array (
  8190. 'where' => 'rid=' . $roleId,
  8191. 'asArray' => true
  8192. ) );
  8193. }
  8194. if (! empty ( $verifyStaff ))
  8195. $endStaffArray = end ( $verifyStaff );
  8196. $KOP = false;
  8197. foreach ( $roleArrayCopy as $P => $A ) {
  8198. foreach ( $A as $MKI => $AVL ) {
  8199. if (! empty ( $verifyStaff )) {
  8200. // &&$rolename['rid']==$endStaffArray['nextStaff']
  8201. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  8202. $button = 4;
  8203. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8204. }
  8205. foreach ( $verifyStaff as $m => $u ) {
  8206. $AVLFK = $AVL [0] . '_R';
  8207. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  8208. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  8209. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  8210. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  8211. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  8212. break;
  8213. }
  8214. }
  8215. } else {
  8216. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  8217. $button = 4;
  8218. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8219. }
  8220. }
  8221. // $roleArray[$MKI]['rolename']=$rolename['name'];
  8222. $KOP = true;
  8223. }
  8224. }
  8225. // print_r($roleArrayCopy);
  8226. // echo $roleKey;
  8227. foreach ( $roleArrayCopy as $k => $v ) {
  8228. foreach ( $verifyList as $m => $n ) {
  8229. if ($n [0] == $k) {
  8230. array_splice ( $verifyList, $m, 1, $v );
  8231. }
  8232. }
  8233. }
  8234. // if ($KOP)
  8235. // array_splice($verifyList,$roleKey,1,$roleArray);
  8236. // print_r($verifyList);
  8237. $receiptList [$key] ['verifyList'] = $verifyList;
  8238. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  8239. 'where' => 'sid=' . $value ['staff'],
  8240. 'asArray' => true
  8241. ) );
  8242. $receiptList [$key] ['button'] = $button;
  8243. }
  8244. // $data['verifyDetail']=$verifyDetail;
  8245. $mothHtml = "";
  8246. for($i = 1; $i <= 12; $i ++) {
  8247. if ($month == $i)
  8248. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8249. else
  8250. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8251. }
  8252. // 获取审批日志
  8253. Doo::loadModel ( 'receiptLog' );
  8254. $receiptLog = new receiptLog ();
  8255. $rlList = array ();
  8256. $rlInfo = $receiptLog->getOne ( array (
  8257. 'where' => 'rid=' . $rid . ' and status=4',
  8258. 'asArray' => true
  8259. ) );
  8260. $tijdate = $receiptLog->getOne ( array (
  8261. 'where' => 'rid=' . $rid . ' and status=2',
  8262. 'asc' => 'rlid',
  8263. 'asArray' => true
  8264. ) );
  8265. if (! empty ( $rlInfo )) {
  8266. $rlList = $receiptLog->find ( array (
  8267. 'where' => 'rid=' . $rid,
  8268. 'asc' => 'rlid',
  8269. 'asArray' => true
  8270. ) );
  8271. }
  8272. $receiptList [0] ['rlList'] = $rlList;
  8273. $enclosurList = $enclosur->find ( array (
  8274. 'where' => 'rid=' . $rid,
  8275. 'asArray' => true
  8276. ) );
  8277. $enclosurHtml = '';
  8278. foreach ( $enclosurList as $value ) {
  8279. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  8280. }
  8281. $data ['enclosurHtml'] = $enclosurHtml;
  8282. $data ['rolename'] = $rolename ['name'];
  8283. $data ['datetij'] = $tijdate ['date'];
  8284. $data ['mothHtml'] = $mothHtml;
  8285. $data ['receiptList'] = $receiptList;
  8286. $data ['receiptApprovalCount'] = count ( $receiptList );
  8287. $data ['status'] = $status;
  8288. $data ['year'] = $year;
  8289. $data ['categoryList'] = $categoryList;
  8290. $data ['staffList'] = $staffList;
  8291. $data ['cid'] = $cid;
  8292. $data ['sid'] = $sid;
  8293. $data ['ap'] = $ap;
  8294. $data ['memu'] = "receipt";
  8295. $data ['staff'] = $this->staff;
  8296. $data ['receiptMemu'] = 'approval';
  8297. $data ['verifyId'] = $this->verifyId;
  8298. $data ['executeId'] = $this->executeId;
  8299. $this->render ( "/admin/saeaReportListReport", $data );
  8300. }
  8301. function remittanceHky() {
  8302. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8303. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  8304. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  8305. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  8306. $page_size = 15;
  8307. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  8308. Doo::loadModel ( 'receipt' );
  8309. $receipt = new receipt ();
  8310. Doo::loadModel ( 'staff' );
  8311. $staff = new staff ();
  8312. $dateCondition = " and Year(executeDate) =" . $year;
  8313. if ($moth != 'MONTH')
  8314. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  8315. if ($day != 'DAY' && $moth != 'MONTH')
  8316. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  8317. $sql = ' (status =8 or status=9 ) and amount>0 ' . $dateCondition;
  8318. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  8319. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  8320. $limit = $pageinfo ['lower'] . ',' . $page_size;
  8321. $dayList = $receipt->find ( array (
  8322. 'select' => 'executeDate,sum(amount) as amount',
  8323. 'where' => $sql,
  8324. 'desc' => 'executeDate',
  8325. 'groupby' => 'executeDate',
  8326. 'limit' => $limit,
  8327. 'asArray' => true
  8328. ) );
  8329. // print_r($dayList);
  8330. foreach ( $dayList as $key => $value ) {
  8331. $remitString = "";
  8332. $receiptList = $receipt->find ( array (
  8333. 'select' => 'rid,executeDate,amount,staff,cid',
  8334. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  8335. 'desc' => 'executeDate',
  8336. 'asArray' => true
  8337. ) );
  8338. foreach ( $receiptList as $k => $v ) {
  8339. $sinfo = $staff->getOne ( array (
  8340. 'select' => 'username,category',
  8341. 'where' => ' sid=' . $v ['staff'],
  8342. 'asArray' => true
  8343. ) );
  8344. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  8345. }
  8346. $dayList [$key] ['staff'] = $remitString;
  8347. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  8348. }
  8349. // print_r($dayList);
  8350. $mothHtml = "";
  8351. for($i = 1; $i <= 12; $i ++) {
  8352. if ($moth == $i)
  8353. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8354. else
  8355. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8356. }
  8357. $dayHtml = "";
  8358. if ($day != "DAY" || $moth != "MONTH") {
  8359. for($i = 1; $i <= 31; $i ++) {
  8360. if ($day == $i)
  8361. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  8362. else
  8363. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  8364. }
  8365. }
  8366. $dateHtml = "";
  8367. $now = date ( "Y" );
  8368. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  8369. if ($YEARD <= $now) {
  8370. $dateHtml .= '<option ';
  8371. if ($year == $YEARD) {
  8372. $dateHtml .= 'selected ';
  8373. }
  8374. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  8375. }
  8376. }
  8377. $data ['dateHtml'] = $dateHtml;
  8378. $data ['page'] = $pageinfo;
  8379. $data ['year'] = $year;
  8380. $data ['moth'] = $moth;
  8381. $data ['day'] = $day;
  8382. $data ['get'] = $get;
  8383. $data ['dayHtml'] = $dayHtml;
  8384. $data ['mothHtml'] = $mothHtml;
  8385. $data ['receiptList'] = $dayList;
  8386. $data ['memu'] = "receipt";
  8387. $data ['staff'] = $this->staff;
  8388. $data ['receiptMemu'] = 'remittanceHky';
  8389. $data ['verifyId'] = $this->verifyId;
  8390. $data ['executeId'] = $this->executeId;
  8391. $this->render ( "/admin/remittanceHky", $data );
  8392. }
  8393. function remittancep() {
  8394. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  8395. Doo::loadModel ( 'receipt' );
  8396. $receipt = new receipt ();
  8397. Doo::loadModel ( 'staff' );
  8398. $staff = new staff ();
  8399. Doo::loadClass ( 'XDeode' );
  8400. $XDeode = new XDeode ( 5 );
  8401. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  8402. $rplist = $receipt->find ( array (
  8403. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8404. 'asArray' => true
  8405. ) );
  8406. $dayList = $receipt->find ( array (
  8407. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8408. 'desc' => 'executeDate',
  8409. 'groupby' => 'staff',
  8410. 'asArray' => true
  8411. ) );
  8412. $html = '';
  8413. foreach ( $dayList as $key => $value ) {
  8414. $sinfo = $staff->getOne ( array (
  8415. 'select' => 'username,category',
  8416. 'where' => ' sid=' . $value ['staff'],
  8417. 'asArray' => true
  8418. ) );
  8419. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  8420. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  8421. $au = 0;
  8422. foreach ( $rplist as $k => $v ) {
  8423. if ($value ['staff'] == $v ['staff']) {
  8424. $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>';
  8425. $au += $v ['amount'];
  8426. }
  8427. }
  8428. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  8429. }
  8430. $data ['html'] = $html;
  8431. $data ['memu'] = "receipt";
  8432. $data ['staff'] = $this->staff;
  8433. $data ['receiptMemu'] = 'remittanceHky';
  8434. $data ['verifyId'] = $this->verifyId;
  8435. $data ['executeId'] = $this->executeId;
  8436. $this->render ( "/admin/remittancep", $data );
  8437. }
  8438. function ajaxGetReceiptDetails() {
  8439. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  8440. Doo::loadClass ( 'XDeode' );
  8441. $XDeode = new XDeode ( 5 );
  8442. $rid = $XDeode->decode ( $rid );
  8443. if (empty ( $rid )) {
  8444. echo json_encode ( array (
  8445. 'status' => 2,
  8446. 'msg' => 'illegal request'
  8447. ) );
  8448. die ();
  8449. }
  8450. Doo::loadModel ( 'receipt' );
  8451. $receipt = new receipt ();
  8452. Doo::loadModel ( 'staff' );
  8453. $staff = new staff ();
  8454. $rinfo = $receipt->getOne ( array (
  8455. 'where' => 'rid= ' . $rid,
  8456. 'asArray' => true
  8457. ) );
  8458. $sinfo = $staff->getOne ( array (
  8459. 'select' => 'username,category',
  8460. 'where' => ' sid=' . $rinfo ['staff'],
  8461. 'asArray' => true
  8462. ) );
  8463. $rinfo ['reviseDetail'] = array ();
  8464. if (! empty ( $rinfo ['reviseDetail'] ))
  8465. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  8466. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  8467. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  8468. $rinfo ['category'] = $sinfo ['category'];
  8469. $verifyStaff = array ();
  8470. if (! empty ( $rinfo ['verifyStaff'] ))
  8471. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  8472. $relust = bcsub ( $rinfo ['sum'], $rinfo ['loanSum'], 2 );
  8473. $rinfo ['relust'] = $relust;
  8474. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  8475. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  8476. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  8477. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  8478. // 费用执行人相关数据
  8479. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  8480. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  8481. foreach ( $executeCopy as $k => $v ) {
  8482. $executeCopy [$k] ['date'] = '';
  8483. $executeCopy [$k] ['opinion'] = '';
  8484. $executeCopy [$k] ['status'] = '';
  8485. if (! empty ( $executeStaff ))
  8486. foreach ( $executeStaff as $m => $u ) {
  8487. if ($v [0] == $m) {
  8488. $executeCopy [$k] ['date'] = $u ['date'];
  8489. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  8490. $executeCopy [$k] ['status'] = $u ['status'];
  8491. break;
  8492. }
  8493. }
  8494. }
  8495. $rinfo ['executeCopy'] = $executeCopy;
  8496. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  8497. if ($rinfo ['Rtype'] == 1) { // 借款费用
  8498. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8499. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  8500. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  8501. $html .= '<tr><th>' . $value ['name'] . '</th>
  8502. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8503. }
  8504. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8505. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8506. <tr><th class="taC" colspan="2">费用说明</th>
  8507. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8508. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8509. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  8510. </tbody></table>';
  8511. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  8512. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8513. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8514. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8515. $html .= '<tr><th>' . $value ['name'] . '</th>
  8516. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8517. }
  8518. $html .= '<tr><th class="taR">合计</th>
  8519. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8520. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8521. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8522. $html .= '<tr><th>' . $value ['name'] . '</th>
  8523. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8524. }
  8525. $html .= '<tr><th class="taR">合计</th>
  8526. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8527. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8528. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8529. $html .= '<tr><th>' . $value ['name'] . '</th>
  8530. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8531. }
  8532. $html .= '<tr><th class="taR">合计</th>
  8533. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8534. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8535. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8536. $html .= '<tr><th>' . $value ['name'] . '</th>
  8537. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8538. }
  8539. $html .= '<tr><th class="taR">合计</th>
  8540. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8541. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8542. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8543. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8544. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8545. }
  8546. $html .= '<tr><th class="taR">合计</th>
  8547. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8548. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8549. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8550. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8551. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8552. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8553. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8554. <tr';
  8555. if ($rinfo ['relust'] >= 0) {
  8556. $html .= 'class="success"';
  8557. } else {
  8558. $html .= 'class="error"';
  8559. }
  8560. $html .= '><td class="taR"><b>借款结余</b></td>
  8561. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  8562. </tbody></table>
  8563. ';
  8564. }
  8565. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  8566. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8567. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  8568. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8569. $html .= '<tr><th>' . $value ['name'] . '</th>
  8570. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8571. }
  8572. $html .= '<tr><th class="taR">合计</th>
  8573. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8574. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8575. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8576. <tr><th class="taC" colspan="2">费用说明</th>
  8577. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8578. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8579. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8580. </tbody></table>';
  8581. } else {
  8582. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8583. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8584. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8585. $html .= '<tr><th>' . $value ['name'] . '</th>
  8586. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8587. }
  8588. $html .= '<tr><th class="taR">合计</th>
  8589. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8590. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8591. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8592. $html .= '<tr><th>' . $value ['name'] . '</th>
  8593. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8594. }
  8595. $html .= '<tr><th class="taR">合计</th>
  8596. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8597. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8598. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8599. $html .= '<tr><th>' . $value ['name'] . '</th>
  8600. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8601. }
  8602. $html .= '<tr><th class="taR">合计</th>
  8603. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8604. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8605. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8606. $html .= '<tr><th>' . $value ['name'] . '</th>
  8607. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8608. }
  8609. $html .= '<tr><th class="taR">合计</th>
  8610. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8611. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8612. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8613. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8614. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8615. }
  8616. $html .= '<tr><th class="taR">合计</th>
  8617. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8618. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8619. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8620. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8621. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8622. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8623. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  8624. $html .= '</tbody></table>';
  8625. /*
  8626. * <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>
  8627. */
  8628. }
  8629. // print_r($verifyStaff);die;
  8630. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  8631. foreach ( $verifyStaff as $key => $value ) {
  8632. $key = trim ( strtr ( $key, '_R', ' ' ) );
  8633. $sinfo = $staff->getOne ( array (
  8634. 'select' => 'username',
  8635. 'where' => ' sid=' . $key,
  8636. 'asArray' => true
  8637. ) );
  8638. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8639. }
  8640. $html .= '</tbody></table>';
  8641. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  8642. foreach ( $rinfo ['executeCopy'] as $value ) {
  8643. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8644. }
  8645. $html .= '</tbody></table>';
  8646. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  8647. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  8648. </tr></table>';
  8649. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  8650. echo json_encode ( array (
  8651. 'status' => 1,
  8652. 'html' => $html
  8653. ) );
  8654. die ();
  8655. }
  8656. /**
  8657. * 删除附件
  8658. */
  8659. function ajaxRemEnclousur() {
  8660. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  8661. if (empty ( $key ))
  8662. echo json_encode ( array (
  8663. 'status' => 2
  8664. ) );
  8665. Doo::loadModel ( 'enclosur' );
  8666. $enclosur = new enclosur ();
  8667. $enclosur->delEnclosurByEid ( $key );
  8668. echo json_encode ( array (
  8669. 'status' => 1
  8670. ) );
  8671. }
  8672. function remittance() {
  8673. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8674. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8675. Doo::loadModel ( 'receipt' );
  8676. $receipt = new receipt ();
  8677. Doo::loadModel ( 'staff' );
  8678. $staff = new staff ();
  8679. $dateCondition = " and Year(pastDate) =" . $year;
  8680. if (! empty ( $month ))
  8681. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  8682. // get Receipt By verifyID status 1
  8683. $receiptList = $receipt->find ( array (
  8684. 'select' => 'sum(sum) as sum,staff,pastDate',
  8685. 'where' => ' status=1' . $dateCondition,
  8686. 'desc' => 'pastDate',
  8687. 'groupby' => 'staff,pastDate',
  8688. 'asArray' => true
  8689. ) );
  8690. $dateList = $receipt->find ( array (
  8691. 'select' => 'pastDate,verifyStaff',
  8692. 'where' => ' status=1' . $dateCondition,
  8693. 'desc' => 'pastDate',
  8694. 'groupby' => 'pastDate',
  8695. 'asArray' => true
  8696. ) );
  8697. $dataList = array ();
  8698. foreach ( $dateList as $d => $a ) {
  8699. $dataList [$a ['pastDate']] = array ();
  8700. $daySum = 0;
  8701. foreach ( $receiptList as $key => $value ) {
  8702. if ($a ['pastDate'] == $value ['pastDate']) {
  8703. $oderList = $receipt->find ( array (
  8704. 'select' => 'receiptOrder',
  8705. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  8706. 'asArray' => true
  8707. ) );
  8708. $list = array ();
  8709. $html = "";
  8710. foreach ( $oderList as $v ) {
  8711. array_push ( $list, $v ['receiptOrder'] );
  8712. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  8713. }
  8714. $receiptList [$key] ['receiptOrder'] = $html;
  8715. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  8716. $sinfo = $staff->getOne ( array (
  8717. 'select' => 'username ',
  8718. 'where' => ' sid=' . $value ['staff'],
  8719. 'asArray' => true
  8720. ) );
  8721. $receiptList [$key] ['username'] = $sinfo ['username'];
  8722. $daySum += $value ['sum'];
  8723. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  8724. }
  8725. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  8726. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  8727. }
  8728. }
  8729. // print_r($dataList);
  8730. $data ['dataList'] = $dataList;
  8731. $mothHtml = "";
  8732. for($i = 1; $i <= 12; $i ++) {
  8733. if ($month == $i)
  8734. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8735. else
  8736. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8737. }
  8738. $data ['year'] = $year;
  8739. $data ['mothHtml'] = $mothHtml;
  8740. $data ['memu'] = "receipt";
  8741. $data ['staff'] = $this->staff;
  8742. $data ['receiptMemu'] = 'approval';
  8743. $data ['verifyId'] = $this->verifyId;
  8744. $data ['executeId'] = $this->executeId;
  8745. $this->render ( "/admin/saeaReportListPay", $data );
  8746. }
  8747. /**
  8748. * 金额调整,提高稳定性
  8749. * @return string
  8750. */
  8751. function revocationAdjustment() {
  8752. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  8753. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  8754. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  8755. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  8756. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  8757. Doo::loadClass ( 'XDeode' );
  8758. $XDeode = new XDeode ( 5 );
  8759. Doo::loadModel ( 'receipt' );
  8760. $receipt = new receipt ();
  8761. $sid = $XDeode->decode ( $sidKey );
  8762. $rid = $XDeode->decode ( $ridKey );
  8763. $reviseKey = $XDeode->decode ( $reviseKey );
  8764. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  8765. die ( 'illegal request' );
  8766. $receiptDetail = $receipt->getOne ( array (
  8767. 'where' => 'rid=' . $rid,
  8768. 'asArray' => true
  8769. ) );
  8770. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  8771. die ( 'illegal request' );
  8772. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8773. if (! isset ( $reviseDetail [$reviseKey] ))
  8774. die ( 'illegal request' );
  8775. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  8776. unset ( $reviseDetail [$reviseKey] );
  8777. $revisePrice = 0;
  8778. foreach ( $reviseDetail as $key => $value ) {
  8779. $revisePrice += $value ['price'];
  8780. }
  8781. $reviseDetailString = json_encode ( $reviseDetail );
  8782. $receipt->reviseDetail = $reviseDetailString;
  8783. $receipt->sum = $receiptDetail ['sum'] - $price;
  8784. $receipt->revisePrice = $revisePrice;
  8785. $receipt->update ( array (
  8786. 'where' => 'rid=' . $rid
  8787. ) );
  8788. return '/receiptburEdi/' . $rid;
  8789. } else
  8790. die ( 'illegal request2' );
  8791. }
  8792. function updateApprovalReceipt() {
  8793. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  8794. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  8795. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8796. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  8797. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  8798. if (! empty ( $rid )) {
  8799. Doo::loadModel ( "verify" );
  8800. $verify = new verify ();
  8801. Doo::loadModel ( "receiptDetail" );
  8802. $receiptDetailObj = new receiptDetail ();
  8803. Doo::loadModel ( "itemStatistics" );
  8804. Doo::loadModel ( "statistics" );
  8805. $statistics = new statistics ();
  8806. $itemStatistics = new itemStatistics ();
  8807. Doo::loadModel ( "receipt" );
  8808. $receipt = new receipt ();
  8809. $receiptDetail = $receipt->getOne ( array (
  8810. 'where' => 'rid=' . $rid . ' and status=2 ',
  8811. 'asArray' => true
  8812. ) );
  8813. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  8814. $nsflag = true;
  8815. foreach ( $nslist as $value ) {
  8816. if ($value == $this->staff ['0'] ['sid']) {
  8817. $nsflag = false;
  8818. break;
  8819. }
  8820. }
  8821. if (empty ( $receiptDetail ) || $nsflag)
  8822. return "/approvalExpenses/pendApproval";
  8823. $verifyDetail = $verify->getOne ( array (
  8824. 'where' => ' vid =' . $receiptDetail ['verify'],
  8825. 'asArray' => true
  8826. ) );
  8827. $verifyString = $verifyDetail ['staff'];
  8828. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  8829. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  8830. if (empty ( $opinion )) {
  8831. if ($status == 3)
  8832. $opinion = "终止";
  8833. else
  8834. $opinion = "同意支付";
  8835. }
  8836. $nowStaff = 0;
  8837. $nowStaffList = array ();
  8838. if (empty ( $verifyStaff )) {
  8839. // 还需加入是否已经进入角色审批
  8840. if ($verifyDetail [0] [1] == 'ROLE') {
  8841. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  8842. foreach ( $vStaffString as $key => $value ) {
  8843. $staffK = explode ( "_", $value );
  8844. if ($staffK [0] != $this->staff [0] ['sid'])
  8845. array_push ( $nowStaffList, $staffK [0] );
  8846. }
  8847. // print_r($verifyDetail);
  8848. // die;
  8849. if (! empty ( $nowStaffList )) {
  8850. $nowStaff = implode ( ',', $nowStaffList );
  8851. $verifyStaff = array (
  8852. $this->staff [0] ['sid'] . "_R" => array (
  8853. 'date' => date ( 'Y-m-d' ),
  8854. 'opinion' => $opinion,
  8855. 'status' => $status,
  8856. 'nextStaff' => $verifyDetail [0] [0],
  8857. 'ROLE' => 1
  8858. )
  8859. );
  8860. } else {
  8861. $nowStaff = $verifyDetail [1] [0];
  8862. $verifyStaff = array (
  8863. $this->staff [0] ['sid'] . "_R" => array (
  8864. 'date' => date ( 'Y-m-d' ),
  8865. 'opinion' => $opinion,
  8866. 'status' => $status,
  8867. 'nextStaff' => $verifyDetail [1] [0]
  8868. )
  8869. );
  8870. }
  8871. } else {
  8872. if ($verifyDetail [1] [1] == 'ROLE') {
  8873. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  8874. // echo "dd";
  8875. foreach ( $vStaffString as $key => $value ) {
  8876. $staffK = explode ( "_", $value );
  8877. array_push ( $nowStaffList, $staffK [0] );
  8878. }
  8879. $nowStaff = implode ( ',', $nowStaffList );
  8880. $verifyStaff = array (
  8881. $this->staff [0] ['sid'] => array (
  8882. 'date' => date ( 'Y-m-d' ),
  8883. 'opinion' => $opinion,
  8884. 'status' => $status,
  8885. 'nextStaff' => $verifyDetail [1] [0],
  8886. 'ROLE' => 1
  8887. )
  8888. );
  8889. } else {
  8890. $nowStaff = $verifyDetail [1] [0];
  8891. $verifyStaff = array (
  8892. $this->staff [0] ['sid'] => array (
  8893. 'date' => date ( 'Y-m-d' ),
  8894. 'opinion' => $opinion,
  8895. 'status' => $status,
  8896. 'nextStaff' => $verifyDetail [1] [0]
  8897. )
  8898. );
  8899. }
  8900. }
  8901. if ($status == 3)
  8902. $verifyStaff = array (
  8903. 'final' => $status,
  8904. $this->staff [0] ['sid'] => array (
  8905. 'date' => date ( 'Y-m-d' ),
  8906. 'opinion' => $opinion,
  8907. 'status' => $status
  8908. )
  8909. );
  8910. $vStaffString = json_encode ( $verifyStaff );
  8911. $receipt->nowStaff = $nowStaff;
  8912. $receipt->verifyStaff = $vStaffString;
  8913. } else {
  8914. $VS = end ( $verifyStaff );
  8915. // 非角色审批
  8916. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  8917. $nextStaff = 0;
  8918. $roleSTF = false;
  8919. foreach ( $verifyDetail as $key => $value ) {
  8920. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  8921. if (isset ( $verifyDetail [$key + 1] )) {
  8922. $nextStaff = $verifyDetail [$key + 1] [0];
  8923. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  8924. $roleSTF = true;
  8925. }
  8926. break;
  8927. }
  8928. }
  8929. if (! $roleSTF) {
  8930. $nowStaff = $nextStaff;
  8931. $verifyStaff [$this->staff [0] ['sid']] = array (
  8932. 'date' => date ( 'Y-m-d' ),
  8933. 'opinion' => $opinion,
  8934. 'status' => $status,
  8935. 'nextStaff' => $nextStaff
  8936. );
  8937. } else {
  8938. // 获取角色下的所有用户ID
  8939. $nowStaffList = array ();
  8940. foreach ( $verifyDetail as $vfk ) {
  8941. if ($vfk [1] == 'ROLE') {
  8942. $vStaffString = json_decode ( $vfk [3] );
  8943. foreach ( $vStaffString as $key => $value ) {
  8944. $staffK = explode ( "_", $value );
  8945. array_push ( $nowStaffList, $staffK [0] );
  8946. }
  8947. }
  8948. }
  8949. $nowStaff = implode ( ',', $nowStaffList );
  8950. $verifyStaff [$this->staff [0] ['sid']] = array (
  8951. 'date' => date ( 'Y-m-d' ),
  8952. 'opinion' => $opinion,
  8953. 'status' => $status,
  8954. 'nextStaff' => $nextStaff,
  8955. 'ROLE' => 0
  8956. );
  8957. }
  8958. if ($status == 3) {
  8959. $verifyStaff ['final'] = $status;
  8960. $verifyStaff [$this->staff [0] ['sid']] = array (
  8961. 'date' => date ( 'Y-m-d' ),
  8962. 'opinion' => $opinion,
  8963. 'status' => $status
  8964. );
  8965. }
  8966. $vStaffString = json_encode ( $verifyStaff );
  8967. $receipt->nowStaff = $nowStaff;
  8968. $receipt->verifyStaff = $vStaffString;
  8969. }
  8970. // 角色审批
  8971. if (isset ( $VS ['ROLE'] )) {
  8972. // 找出角色人 当前审批角色组
  8973. $verifyJSStaff = array ();
  8974. $nowStaffList2 = array ();
  8975. foreach ( $verifyDetail as $key => $value ) {
  8976. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  8977. $verifyJSStaff = json_decode ( $value [3] );
  8978. foreach ( $verifyJSStaff as $m ) {
  8979. $staffK = explode ( "_", $m );
  8980. array_push ( $nowStaffList2, $staffK [0] );
  8981. }
  8982. // print_r($nowStaffList2);
  8983. }
  8984. }
  8985. $RoleVerifyStaff = array ();
  8986. foreach ( $verifyStaff as $key => $value ) {
  8987. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  8988. foreach ( $nowStaffList2 as $m ) {
  8989. if ($key == $m . "_R")
  8990. $RoleVerifyStaff [$key] = $value;
  8991. }
  8992. }
  8993. }
  8994. // print_r($verifyStaff);
  8995. // print_r($nowStaffList2);
  8996. // print_r($RoleVerifyStaff);
  8997. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  8998. // print_r($verifyJSStaff);
  8999. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  9000. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  9001. // 下一个审批人ID
  9002. $nextStaff = 0;
  9003. $falg = false;
  9004. foreach ( $verifyDetail as $key => $value ) {
  9005. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  9006. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  9007. $falg = true;
  9008. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  9009. $nowStaffList = array ();
  9010. foreach ( $vStaffString as $v ) {
  9011. $staffK = explode ( "_", $v );
  9012. array_push ( $nowStaffList, $staffK [0] );
  9013. }
  9014. $nowStaff = implode ( ',', $nowStaffList );
  9015. $nextStaff = $verifyDetail [$key + 1] [0];
  9016. } elseif (isset ( $verifyDetail [$key + 1] )) {
  9017. $nextStaff = $verifyDetail [$key + 1] [0];
  9018. $nowStaff = $nextStaff;
  9019. } else
  9020. $nowStaff = '';
  9021. break;
  9022. }
  9023. }
  9024. if ($falg)
  9025. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  9026. 'date' => date ( 'Y-m-d' ),
  9027. 'opinion' => $opinion,
  9028. 'status' => $status,
  9029. 'nextStaff' => $nextStaff,
  9030. 'ROLE' => 1
  9031. );
  9032. else
  9033. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  9034. 'date' => date ( 'Y-m-d' ),
  9035. 'opinion' => $opinion,
  9036. 'status' => $status,
  9037. 'nextStaff' => $nextStaff
  9038. );
  9039. // print_r($verifyStaff);
  9040. // echo $nowStaff;die;
  9041. } else { // 进入下一个角色或者审批人
  9042. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  9043. //
  9044. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  9045. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  9046. 'date' => date ( 'Y-m-d' ),
  9047. 'opinion' => $opinion,
  9048. 'status' => $status,
  9049. 'nextStaff' => $VS ['nextStaff'],
  9050. 'ROLE' => 1
  9051. );
  9052. // print_r($verifyStaff);
  9053. // die;
  9054. }
  9055. if ($status == 3) {
  9056. $verifyStaff ['final'] = $status;
  9057. $verifyStaff [$this->staff [0] ['sid']] = array (
  9058. 'date' => date ( 'Y-m-d' ),
  9059. 'opinion' => $opinion,
  9060. 'status' => $status
  9061. );
  9062. }
  9063. $vStaffString = json_encode ( $verifyStaff );
  9064. $receipt->verifyStaff = $vStaffString;
  9065. $receipt->nowStaff = $nowStaff;
  9066. // die;
  9067. // }
  9068. // print_r($verifyStaff);
  9069. // die;
  9070. }
  9071. // print_r($verifyStaff);die;
  9072. }
  9073. // print_r($verifyDetail);
  9074. $roleKey = 0;
  9075. $roleId = 0;
  9076. $verifyDetailCopy = array ();
  9077. foreach ( $verifyDetail as $k => $v ) {
  9078. if ($v [1] == 'ROLE') {
  9079. $roleId = $v [0];
  9080. $roleVerify = json_decode ( $v [3], true );
  9081. $roleKey = $k;
  9082. $roleArray = array ();
  9083. foreach ( $roleVerify as $o => $p ) {
  9084. $staffID = explode ( '_', $p );
  9085. $exp = array (
  9086. 0 => $staffID [0],
  9087. 1 => $staffID [1]
  9088. );
  9089. array_push ( $roleArray, $exp );
  9090. }
  9091. $verifyDetailCopy [$v [0]] = $roleArray;
  9092. }
  9093. }
  9094. // print_r($verifyDetail);
  9095. foreach ( $verifyDetailCopy as $k => $v ) {
  9096. foreach ( $verifyDetail as $m => $n ) {
  9097. if ($n [0] == $k) {
  9098. array_splice ( $verifyDetail, $m, 1, $v );
  9099. }
  9100. }
  9101. }
  9102. // die;
  9103. // if (!empty($roleArray))
  9104. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  9105. // echo $roleId;
  9106. // print_r($verifyStaff);
  9107. // print_r($verifyDetail);
  9108. // die;
  9109. Doo::loadModel ( "receiptLog" );
  9110. $receiptLog = new receiptLog ();
  9111. // 审批日志
  9112. if (! isset ( $verifyStaff ['final'] )) {
  9113. if (! empty ( $roleId )) {
  9114. Doo::loadModel ( "role" );
  9115. $role = new role ();
  9116. $roleInfo = $role->getOne ( array (
  9117. 'where' => 'rid=' . $roleId,
  9118. 'asArray' => true
  9119. ) );
  9120. $receiptLog->rolename = $roleInfo ['name'];
  9121. }
  9122. $receiptLog->username = $this->staff [0] ['username'];
  9123. $receiptLog->uid = $this->staff [0] ['sid'];
  9124. $receiptLog->date = date ( "Y-m-d" );
  9125. $receiptLog->opinion = $opinion;
  9126. $receiptLog->img = $this->staff [0] ['avatar'];
  9127. $receiptLog->status = 1;
  9128. $receiptLog->rid = $rid;
  9129. $receiptLog->insert ();
  9130. }
  9131. if (isset ( $verifyStaff ['final'] )) { // rDetail
  9132. $receipt->verifyBreakup = $verifyString;
  9133. $receipt->status = 3;
  9134. $receiptDetailObj->status = 3;
  9135. $receiptDetailObj->update ( array (
  9136. 'where' => 'rid=' . $rid
  9137. ) );
  9138. if (! empty ( $roleId )) {
  9139. Doo::loadModel ( "role" );
  9140. $role = new role ();
  9141. $roleInfo = $role->getOne ( array (
  9142. 'where' => 'rid=' . $roleId,
  9143. 'asArray' => true
  9144. ) );
  9145. $receiptLog->rolename = $roleInfo ['name'];
  9146. }
  9147. $receiptLog->username = $this->staff [0] ['username'];
  9148. $receiptLog->uid = $this->staff [0] ['sid'];
  9149. $receiptLog->date = date ( "Y-m-d" );
  9150. $receiptLog->opinion = $opinion;
  9151. $receiptLog->img = $this->staff [0] ['avatar'];
  9152. $receiptLog->status = 3;
  9153. $receiptLog->rid = $rid;
  9154. $receiptLog->insert ();
  9155. // 微信企业号通知
  9156. $this->setWXMsg ( $rid, 3 );
  9157. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  9158. $receipt->status = 1;
  9159. $reviseSum = 0;
  9160. $receipt->verifyBreakup = $verifyString;
  9161. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  9162. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9163. foreach ( $reviseDetail as $key => $value ) {
  9164. $receiptDetailObj = new receiptDetail ();
  9165. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9166. $receiptDetailObj->item = $value ['description'];
  9167. $receiptDetailObj->itemCategory = "报销金额调整";
  9168. $receiptDetailObj->price = $value ['price'];
  9169. $receiptDetailObj->date = $receiptDetail ['date'];
  9170. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  9171. $receiptDetailObj->rid = $rid;
  9172. $receiptDetailObj->status = 1;
  9173. $receiptDetailObj->insert ();
  9174. $reviseSum += $value ['price'];
  9175. }
  9176. $itemStatistics = new itemStatistics ();
  9177. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  9178. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9179. $itemStatistics->price = $reviseSum;
  9180. $itemStatistics->itemCategory = "报销金额调整";
  9181. $itemStatistics->date = $receiptDetail ['date'];
  9182. $itemStatistics->insert ();
  9183. }
  9184. $receiptDetailObj = new receiptDetail ();
  9185. $receiptDetailObj->status = 1;
  9186. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  9187. $receiptDetailObj->update ( array (
  9188. 'where' => 'rid=' . $rid
  9189. ) );
  9190. $dateArray = explode ( "-", $receiptDetail ['date'] );
  9191. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  9192. $stat = $statistics->getOne ( array (
  9193. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  9194. 'asArray' => true
  9195. ) );
  9196. if (empty ( $stat )) {
  9197. $statistics->date = $receiptDetail ['date'];
  9198. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  9199. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9200. $statistics->agPrice = $receiptDetail ['sum'];
  9201. $statistics->rePrice = $reviseSum;
  9202. $statistics->insert ();
  9203. } else {
  9204. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  9205. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  9206. $statistics->update ( array (
  9207. 'where' => 'sid=' . $stat ['sid']
  9208. ) );
  9209. }
  9210. $dateArray = explode ( "-", $receiptDetail ['date'] );
  9211. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  9212. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  9213. foreach ( $accountItem ['cSum'] as $key => $value ) {
  9214. if ($key == "agencySum") {
  9215. $iStatistics = $itemStatistics->getOne ( array (
  9216. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  9217. 'asArray' => true
  9218. ) );
  9219. if (empty ( $iStatistics )) {
  9220. $itemStatistics->cid = $receiptDetail ['cid'];
  9221. ;
  9222. $itemStatistics->staff = $receiptDetail ['staff'];
  9223. $itemStatistics->price = $value;
  9224. $itemStatistics->itemCategory = $this->AGENCY;
  9225. $itemStatistics->date = $receiptDetail ['date'];
  9226. $itemStatistics->insert ();
  9227. } else {
  9228. if (! empty ( $value )) {
  9229. $itemStatistics->price = $value + $iStatistics ['price'];
  9230. $itemStatistics->update ( array (
  9231. 'where' => 'sid=' . $iStatistics ['sid']
  9232. ) );
  9233. }
  9234. }
  9235. } elseif ($key == "travelSum") {
  9236. $iStatistics = $itemStatistics->getOne ( array (
  9237. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  9238. 'asArray' => true
  9239. ) );
  9240. if (empty ( $iStatistics )) {
  9241. $itemStatistics->cid = $receiptDetail ['cid'];
  9242. $itemStatistics->staff = $receiptDetail ['staff'];
  9243. $itemStatistics->price = $value;
  9244. $itemStatistics->itemCategory = $this->TRAVEL;
  9245. $itemStatistics->date = $receiptDetail ['date'];
  9246. $itemStatistics->insert ();
  9247. } else {
  9248. if (! empty ( $value )) {
  9249. $itemStatistics->price = $value + $iStatistics ['price'];
  9250. $itemStatistics->update ( array (
  9251. 'where' => 'sid=' . $iStatistics ['sid']
  9252. ) );
  9253. }
  9254. }
  9255. } elseif ($key == "trainSum") {
  9256. $iStatistics = $itemStatistics->getOne ( array (
  9257. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  9258. 'asArray' => true
  9259. ) );
  9260. if (empty ( $iStatistics )) {
  9261. $itemStatistics->cid = $receiptDetail ['cid'];
  9262. $itemStatistics->staff = $receiptDetail ['staff'];
  9263. $itemStatistics->price = $value;
  9264. $itemStatistics->itemCategory = $this->TRAIN;
  9265. $itemStatistics->date = $receiptDetail ['date'];
  9266. $itemStatistics->insert ();
  9267. } else {
  9268. if (! empty ( $value )) {
  9269. $itemStatistics->price = $value + $iStatistics ['price'];
  9270. $itemStatistics->update ( array (
  9271. 'where' => 'sid=' . $iStatistics ['sid']
  9272. ) );
  9273. }
  9274. }
  9275. } elseif ($key == "otherSum") {
  9276. $iStatistics = $itemStatistics->getOne ( array (
  9277. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  9278. 'asArray' => true
  9279. ) );
  9280. if (empty ( $iStatistics )) {
  9281. $itemStatistics->cid = $receiptDetail ['cid'];
  9282. $itemStatistics->staff = $receiptDetail ['staff'];
  9283. $itemStatistics->price = $value;
  9284. $itemStatistics->itemCategory = $this->OTHER;
  9285. $itemStatistics->date = $receiptDetail ['date'];
  9286. $itemStatistics->insert ();
  9287. } else {
  9288. if (! empty ( $value )) {
  9289. $itemStatistics->price = $value + $iStatistics ['price'];
  9290. $itemStatistics->update ( array (
  9291. 'where' => 'sid=' . $iStatistics ['sid']
  9292. ) );
  9293. }
  9294. }
  9295. }
  9296. }
  9297. $receipt->pastDate = date ( "Y-m-d" );
  9298. // 微信企业号通知
  9299. $this->setWXMsg ( $rid, 1 );
  9300. }
  9301. //是否有流水
  9302. Doo::loadModel ( 'wasteBook' );
  9303. $wasteBook = new wasteBook ();
  9304. $accountType=3;
  9305. if ($receiptDetail['Rtype']==1){
  9306. $accountType=2;
  9307. }elseif($receiptDetail['Rtype']==2){
  9308. $accountType=4;
  9309. }
  9310. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $rid );
  9311. if (empty($wbDetail)){
  9312. $rsum=$receiptDetail['sum']-$receiptDetail['loanSum'];
  9313. $receipt->amount = $rsum;//$amount;
  9314. }
  9315. $receipt->update ( array (
  9316. 'where' => ' rid = ' . $rid
  9317. ) );
  9318. // 进入下一条审批费用新加需求
  9319. $vidList = array ();
  9320. $verifyDetail = $verify->find ( array (
  9321. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  9322. 'asArray' => true
  9323. ) );
  9324. foreach ( $verifyDetail as $key => $value ) {
  9325. array_push ( $vidList, $value ['vid'] );
  9326. }
  9327. $vid = implode ( ",", $vidList );
  9328. if (empty ( $verifyDetail ))
  9329. $vid = 0;
  9330. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9331. $receipt = new receipt ();
  9332. $rd = $receipt->getOne ( array (
  9333. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ') and Rtype!=3',
  9334. 'asc' => 'rid',
  9335. 'asArray' => true
  9336. ) );
  9337. if (empty ( $rd )) {
  9338. return '/approvalExpenses/pendApproval';
  9339. }
  9340. if ($rd ['Rtype'] == 1) {
  9341. if ($rd ['isBK'] == 1) {
  9342. return '/receiptburEdi/' . $rd ['rid'];
  9343. } else {
  9344. return '/expensesEdi/' . $rd ['rid'];
  9345. }
  9346. } elseif ($rd ['Rtype'] == 2) {
  9347. return '/remitApproval/' . $rd ['rid'];
  9348. } else {
  9349. return '/receiptburEdi/' . $rd ['rid'];
  9350. }
  9351. // return "/approvalExpenses/pendApproval";
  9352. }
  9353. }
  9354. function expensesRetreats() {
  9355. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  9356. if (! empty ( $rid )) {
  9357. // 操作记录
  9358. Doo::loadModel ( "receipt" );
  9359. $receipt = new receipt ();
  9360. Doo::loadModel ( "receiptLog" );
  9361. $receiptLog = new receiptLog ();
  9362. Doo::loadModel ( "verify" );
  9363. $verify = new verify ();
  9364. $receiptInfo = $receipt->getOne ( array (
  9365. 'where' => 'rid=' . $rid,
  9366. 'asArray' => true
  9367. ) );
  9368. $vr = $verify->getOne ( array (
  9369. 'where' => 'vid=' . $receiptInfo ['verify'],
  9370. 'asArray' => true
  9371. ) );
  9372. $jd = json_decode ( $vr ['staff'] );
  9373. $roleId = 0;
  9374. foreach ( $jd as $key => $value ) {
  9375. if ($value [1] == 'ROLE') {
  9376. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9377. if ($pos !== false) {
  9378. $roleId = $value [0];
  9379. }
  9380. }
  9381. }
  9382. // 审批日志
  9383. // echo $roleId;die;
  9384. if (! empty ( $roleId )) {
  9385. Doo::loadModel ( "role" );
  9386. $role = new role ();
  9387. $roleInfo = $role->getOne ( array (
  9388. 'where' => 'rid=' . $roleId,
  9389. 'asArray' => true
  9390. ) );
  9391. $receiptLog->rolename = $roleInfo ['name'];
  9392. }
  9393. $receiptLog->username = $this->staff [0] ['username'];
  9394. $receiptLog->uid = $this->staff [0] ['sid'];
  9395. $receiptLog->date = date ( "Y-m-d" );
  9396. $receiptLog->opinion = '撤回';
  9397. $receiptLog->img = $this->staff [0] ['avatar'];
  9398. $receiptLog->status = 4;
  9399. $receiptLog->rid = $rid;
  9400. $receiptLog->insert ();
  9401. $receipt->status = 4;
  9402. $receipt->update ( array (
  9403. 'where' => 'rid=' . $rid
  9404. ) );
  9405. // 微信企业号通知
  9406. $this->setWXMsg ( $rid, 2 );
  9407. }
  9408. // echo "ddd";
  9409. return '/approvalExpenses/pendApproval';
  9410. }
  9411. function updateCheReceipt() {
  9412. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9413. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  9414. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  9415. if (! empty ( $rid )) {
  9416. // 操作记录
  9417. Doo::loadModel ( "receipt" );
  9418. $receipt = new receipt ();
  9419. Doo::loadModel ( "receiptLog" );
  9420. $receiptLog = new receiptLog ();
  9421. Doo::loadModel ( "verify" );
  9422. $verify = new verify ();
  9423. $receiptInfo = $receipt->getOne ( array (
  9424. 'where' => 'rid=' . $rid . ' and status=2',
  9425. 'asArray' => true
  9426. ) );
  9427. if (empty ( $receiptInfo )) {
  9428. echo json_encode ( array (
  9429. 'status' => 2
  9430. ) );
  9431. die ();
  9432. }
  9433. $vr = $verify->getOne ( array (
  9434. 'where' => 'vid=' . $receiptInfo ['verify'],
  9435. 'asArray' => true
  9436. ) );
  9437. $jd = json_decode ( $vr ['staff'] );
  9438. $roleId = 0;
  9439. foreach ( $jd as $key => $value ) {
  9440. if ($value [1] == 'ROLE') {
  9441. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9442. if ($pos !== false) {
  9443. $roleId = $value [0];
  9444. }
  9445. }
  9446. }
  9447. // 审批日志
  9448. // echo $roleId;die;
  9449. if (! empty ( $roleId )) {
  9450. Doo::loadModel ( "role" );
  9451. $role = new role ();
  9452. $roleInfo = $role->getOne ( array (
  9453. 'where' => 'rid=' . $roleId,
  9454. 'asArray' => true
  9455. ) );
  9456. $receiptLog->rolename = $roleInfo ['name'];
  9457. }
  9458. $receiptLog->username = $this->staff [0] ['username'];
  9459. $receiptLog->uid = $this->staff [0] ['sid'];
  9460. $receiptLog->date = date ( "Y-m-d" );
  9461. $receiptLog->opinion = $opinion;
  9462. $receiptLog->img = $this->staff [0] ['avatar'];
  9463. $receiptLog->status = 4;
  9464. $receiptLog->rid = $rid;
  9465. $receiptLog->insert ();
  9466. $receipt->status = 4;
  9467. $receipt->update ( array (
  9468. 'where' => 'rid=' . $rid
  9469. ) );
  9470. // 微信企业号通知
  9471. $this->setWXMsg ( $rid, 2 );
  9472. echo json_encode ( array (
  9473. 'status' => 1
  9474. ) );
  9475. // Header("HTTP/1.1 303 See Other");
  9476. // Header("Location: /approvalExpenses/pendApproval");
  9477. die ();
  9478. }
  9479. echo json_encode ( array (
  9480. 'status' => 2
  9481. ) );
  9482. die ();
  9483. // echo "ddd";
  9484. // return '/saeaBorad';
  9485. }
  9486. function revisePrice() {
  9487. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  9488. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  9489. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9490. // echo $price;die;
  9491. if (! empty ( $rid )) {
  9492. Doo::loadModel ( "receipt" );
  9493. $receipt = new receipt ();
  9494. $receiptDetail = $receipt->getOne ( array (
  9495. 'where' => 'rid=' . $rid . ' and status=2 ',
  9496. 'asArray' => true
  9497. ) );
  9498. if (empty ( $receiptDetail ))
  9499. die ( 'illegal request' );
  9500. $reviseDetail = array ();
  9501. if (empty ( $receiptDetail ['reviseDetail'] )) {
  9502. array_push ( $reviseDetail, array (
  9503. 'sid' => $this->staff [0] ['sid'],
  9504. 'name' => $this->staff [0] ['username'],
  9505. 'description' => $description,
  9506. 'price' => $price
  9507. ) );
  9508. $reviseDetailString = json_encode ( $reviseDetail );
  9509. $receipt->reviseDetail = $reviseDetailString;
  9510. $receipt->revisePrice = $price;
  9511. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9512. } else {
  9513. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9514. array_push ( $reviseDetail, array (
  9515. 'sid' => $this->staff [0] ['sid'],
  9516. 'name' => $this->staff [0] ['username'],
  9517. 'description' => $description,
  9518. 'price' => $price
  9519. ) );
  9520. $reviseDetailString = json_encode ( $reviseDetail );
  9521. $receipt->reviseDetail = $reviseDetailString;
  9522. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  9523. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9524. }
  9525. $receipt->update ( array (
  9526. 'where' => 'rid=' . $rid
  9527. ) );
  9528. if ($receiptDetail ['Rtype'] == 1) {
  9529. if ($receiptDetail ['isBK'] == 1) {
  9530. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9531. }
  9532. } elseif ($receiptDetail ['Rtype'] == 2) {
  9533. } else {
  9534. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9535. }
  9536. }
  9537. die ( 'illegal request' );
  9538. }
  9539. function personalCollect() {
  9540. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9541. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  9542. $this->showCache ( $path );
  9543. Doo::loadModel ( "receiptDetail" );
  9544. Doo::loadModel ( "itemStatistics" );
  9545. Doo::loadModel ( 'statistics' );
  9546. $statistics = new statistics ();
  9547. $itemStatistics = new itemStatistics ();
  9548. $receiptDetail = new receiptDetail ();
  9549. $receiptCollectList = $receiptDetail->find ( array (
  9550. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9551. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9552. 'groupby' => 'itemCategory,Month(date)',
  9553. 'asArray' => true
  9554. ) );
  9555. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  9556. 'where' => 'staff=' . $this->staff [0] ['sid'],
  9557. 'asArray' => true
  9558. ) );
  9559. // create collect html
  9560. $collectArray = array (
  9561. '日常相关费用' => array (),
  9562. '差旅相关费用' => array (),
  9563. '培训班费用' => array (),
  9564. '其他' => array ()
  9565. );
  9566. $adjustment = array ();
  9567. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  9568. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9569. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  9570. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9571. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  9572. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9573. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  9574. array_push ( $collectArray ['其他'], $collectHtml );
  9575. $data ['collectArray'] = $collectArray;
  9576. // statistics html
  9577. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9578. if (empty ( $stList ))
  9579. $stList = array (
  9580. 'rePrice' => 0,
  9581. 'agPrice' => 0
  9582. );
  9583. $data ['stList'] = array (
  9584. 'rePrice' => $stList ['rePrice'],
  9585. 'agPrice' => $stList ['agPrice'],
  9586. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9587. );
  9588. // Adjustment price html
  9589. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9590. array_push ( $adjustment, $collectHtml );
  9591. $data ['adjustment'] = $adjustment;
  9592. // total price html
  9593. $collectHtml = "";
  9594. $total = 0;
  9595. for($i = 1; $i <= 12; $i ++) {
  9596. $sumPrice = 0;
  9597. foreach ( $receiptCollectList as $key => $value ) {
  9598. if ($value ['month'] == $i) {
  9599. $sumPrice += $value ['price'];
  9600. }
  9601. }
  9602. if ($sumPrice == 0)
  9603. $collectHtml .= '<td class="taR">-</td>';
  9604. else
  9605. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9606. $total += $sumPrice;
  9607. }
  9608. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9609. $data ['totalPrice'] = $collectHtml;
  9610. $dateHtml = "";
  9611. $now = date ( "Y" );
  9612. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9613. if ($YEARD <= $now) {
  9614. $dateHtml .= '<option ';
  9615. if ($year == $YEARD) {
  9616. $dateHtml .= 'selected ';
  9617. }
  9618. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9619. }
  9620. }
  9621. $data ['dateHtml'] = $dateHtml;
  9622. $data ['year'] = $year;
  9623. $data ['totalYear'] = $total;
  9624. $data ['memu'] = "receipt";
  9625. $data ['staff'] = $this->staff;
  9626. $data ['receiptMemu'] = 'personalCollect';
  9627. $data ['verifyId'] = $this->verifyId;
  9628. $data ['executeId'] = $this->executeId;
  9629. // year staff status 2,4
  9630. if ($year < date ( "Y" )) {
  9631. Doo::loadModel ( 'receipt' );
  9632. $receipt = new receipt ();
  9633. $receiptList = $receipt->find ( array (
  9634. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9635. 'asArray' => true
  9636. ) );
  9637. if (empty ( $receiptList )) {
  9638. ob_start ();
  9639. $this->render ( "/admin/saea_slist_collect", $data );
  9640. $this->cacheFile ( $path );
  9641. die ();
  9642. }
  9643. }
  9644. $this->render ( "/admin/saea_slist_collect", $data );
  9645. }
  9646. function personalCollectDetail() {
  9647. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9648. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  9649. $this->showCache ( $path );
  9650. Doo::loadModel ( "receiptDetail" );
  9651. Doo::loadModel ( "itemStatistics" );
  9652. Doo::loadModel ( 'statistics' );
  9653. Doo::loadModel ( 'accountItem' );
  9654. $accountItem = new accountItem ();
  9655. $statistics = new statistics ();
  9656. $itemStatistics = new itemStatistics ();
  9657. $receiptDetail = new receiptDetail ();
  9658. $receiptCollectList = $receiptDetail->find ( array (
  9659. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9660. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9661. 'groupby' => 'item,Month(date)',
  9662. 'asArray' => true
  9663. ) );
  9664. $accountList = $accountItem->find ( array (
  9665. 'asArray' => true
  9666. ) );
  9667. // create CollectDetail HTML
  9668. $collectHtml = array ();
  9669. foreach ( $accountList as $key => $value ) {
  9670. $html = "";
  9671. $asum = 0;
  9672. for($i = 1; $i <= 12; $i ++) {
  9673. $falg = true;
  9674. foreach ( $receiptCollectList as $v ) {
  9675. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9676. $asum += $v ['price'];
  9677. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9678. $falg = false;
  9679. break;
  9680. }
  9681. }
  9682. if ($falg)
  9683. $html .= '<td class="taR">-</td>';
  9684. }
  9685. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9686. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9687. }
  9688. $data ['collectHtml'] = $collectHtml;
  9689. // create Adjustment price html
  9690. $receiptCollectList = $receiptDetail->find ( array (
  9691. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9692. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9693. 'groupby' => 'itemCategory,Month(date)',
  9694. 'asArray' => true
  9695. ) );
  9696. $adjustment = array ();
  9697. $collectArray = array (
  9698. '日常相关费用' => array (),
  9699. '差旅相关费用' => array (),
  9700. '培训班费用' => array (),
  9701. '其他' => array ()
  9702. );
  9703. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9704. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9705. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9706. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9707. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9708. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9709. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9710. array_push ( $collectArray ['其他'], $collectHtml );
  9711. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9712. array_push ( $adjustment, $collectHtml );
  9713. // total price html
  9714. $collectHtml = "";
  9715. $total = 0;
  9716. for($i = 1; $i <= 12; $i ++) {
  9717. $sumPrice = 0;
  9718. foreach ( $receiptCollectList as $key => $value ) {
  9719. if ($value ['month'] == $i) {
  9720. $sumPrice += $value ['price'];
  9721. }
  9722. }
  9723. if ($sumPrice == 0)
  9724. $collectHtml .= '<td class="taR">-</td>';
  9725. else
  9726. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9727. $total += $sumPrice;
  9728. }
  9729. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9730. // statistics html
  9731. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9732. if (empty ( $stList ))
  9733. $stList = array (
  9734. 'rePrice' => 0,
  9735. 'agPrice' => 0
  9736. );
  9737. $data ['stList'] = array (
  9738. 'rePrice' => $stList ['rePrice'],
  9739. 'agPrice' => $stList ['agPrice'],
  9740. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9741. );
  9742. $data ['collectArray'] = $collectArray;
  9743. $data ['adjustment'] = $adjustment;
  9744. $data ['totalPrice'] = $collectHtml;
  9745. $data ['totalYear'] = $total;
  9746. $data ['year'] = $year;
  9747. $dateHtml = "";
  9748. $now = date ( "Y" );
  9749. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9750. if ($YEARD <= $now) {
  9751. $dateHtml .= '<option ';
  9752. if ($year == $YEARD) {
  9753. $dateHtml .= 'selected ';
  9754. }
  9755. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9756. }
  9757. }
  9758. $data ['dateHtml'] = $dateHtml;
  9759. $data ['memu'] = "receipt";
  9760. $data ['staff'] = $this->staff;
  9761. $data ['receiptMemu'] = 'personalCollect';
  9762. $data ['verifyId'] = $this->verifyId;
  9763. $data ['executeId'] = $this->executeId;
  9764. // year staff status 2,4
  9765. if ($year < date ( "Y" )) {
  9766. Doo::loadModel ( 'receipt' );
  9767. $receipt = new receipt ();
  9768. $receiptList = $receipt->find ( array (
  9769. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9770. 'asArray' => true
  9771. ) );
  9772. if (empty ( $receiptList )) {
  9773. ob_start ();
  9774. $this->render ( "/admin/saeaCollectArticles", $data );
  9775. $this->cacheFile ( $path );
  9776. die ();
  9777. }
  9778. }
  9779. $this->render ( "/admin/saeaCollectArticles", $data );
  9780. }
  9781. function companyCategoryCollect() {
  9782. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9783. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  9784. $this->showCache ( $path );
  9785. Doo::loadModel ( 'L_category' );
  9786. Doo::loadModel ( 'itemStatistics' );
  9787. Doo::loadModel ( 'statistics' );
  9788. $statistics = new statistics ();
  9789. $Lcategory = new L_category ();
  9790. $itemStatistics = new itemStatistics ();
  9791. Doo::loadModel ( "receiptAuthorityManage" );
  9792. $receiptAuthorityManage = new receiptAuthorityManage ();
  9793. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9794. $cidList = array ();
  9795. foreach ( $imcStaff as $key => $value ) {
  9796. array_push ( $cidList, $value ['cid'] );
  9797. }
  9798. $cidString = implode ( ',', $cidList );
  9799. $LcategoryList = $Lcategory->find ( array (
  9800. 'where' => ' cid in (' . $cidString . ')',
  9801. 'asArray' => true
  9802. ) ); // 'staff='.$this->staff[0]['sid']." and
  9803. $itemStatisticsList = $itemStatistics->find ( array (
  9804. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9805. 'where' => " Year(date)=" . $year,
  9806. 'groupby' => 'cid,Month(date)',
  9807. 'asArray' => true
  9808. ) );
  9809. // ceatre companyCollectHtml
  9810. foreach ( $LcategoryList as $value ) {
  9811. $html = "";
  9812. $asum = 0;
  9813. for($i = 1; $i <= 12; $i ++) {
  9814. $falg = true;
  9815. foreach ( $itemStatisticsList as $v ) {
  9816. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  9817. $asum += $v ['price'];
  9818. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9819. $falg = false;
  9820. break;
  9821. }
  9822. }
  9823. if ($falg)
  9824. $html .= '<td class="taR">-</td>';
  9825. }
  9826. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9827. $collectHtml [$value ['title']] = array (
  9828. 'html' => $html,
  9829. 'cid' => $value ['cid']
  9830. );
  9831. }
  9832. $data ['companyHtml'] = $collectHtml;
  9833. // total price html
  9834. $collectHtml = "";
  9835. $total = 0;
  9836. for($i = 1; $i <= 12; $i ++) {
  9837. $sumPrice = 0;
  9838. foreach ( $itemStatisticsList as $key => $value ) {
  9839. if ($value ['month'] == $i) {
  9840. $sumPrice += $value ['price'];
  9841. }
  9842. }
  9843. if ($sumPrice == 0)
  9844. $collectHtml .= '<td class="taR">-</td>';
  9845. else
  9846. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9847. $total += $sumPrice;
  9848. }
  9849. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9850. $data ['companyTotalHtml'] = $collectHtml;
  9851. $data ['total'] = $total;
  9852. // statistics html
  9853. // echo $cidString;
  9854. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9855. if (empty ( $stList ))
  9856. $stList = array (
  9857. 'rePrice' => 0,
  9858. 'agPrice' => 0
  9859. );
  9860. $data ['stList'] = array (
  9861. 'rePrice' => $stList ['rePrice'],
  9862. 'agPrice' => $stList ['agPrice'],
  9863. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9864. );
  9865. $data ['year'] = $year;
  9866. $data ['memu'] = "receipt";
  9867. $data ['staff'] = $this->staff;
  9868. $data ['receiptMemu'] = 'companyCategoryCollect';
  9869. $data ['verifyId'] = $this->verifyId;
  9870. $data ['executeId'] = $this->executeId;
  9871. $dateHtml = "";
  9872. $now = date ( "Y" );
  9873. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9874. if ($YEARD <= $now) {
  9875. $dateHtml .= '<option ';
  9876. if ($year == $YEARD) {
  9877. $dateHtml .= 'selected ';
  9878. }
  9879. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9880. }
  9881. }
  9882. $data ['dateHtml'] = $dateHtml;
  9883. // year staff status 2,4
  9884. if ($year < date ( "Y" )) {
  9885. Doo::loadModel ( 'receipt' );
  9886. $receipt = new receipt ();
  9887. $receiptList = $receipt->find ( array (
  9888. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  9889. 'asArray' => true
  9890. ) );
  9891. if (empty ( $receiptList )) {
  9892. ob_start ();
  9893. $this->render ( "/admin/saeaCompanyCollect", $data );
  9894. $this->cacheFile ( $path );
  9895. die ();
  9896. }
  9897. }
  9898. $this->render ( "/admin/saeaCompanyCollect", $data );
  9899. }
  9900. function categoryCollectDetail() {
  9901. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9902. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  9903. /* $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  9904. $this->showCache ( $path ); */
  9905. Doo::loadModel ( 'statistics' );
  9906. $statistics = new statistics ();
  9907. Doo::loadModel ( "receiptDetail" );
  9908. $receiptDetail = new receiptDetail ();
  9909. Doo::loadModel ( 'L_category' );
  9910. $Lcategory = new L_category ();
  9911. Doo::loadModel ( 'accountItem' );
  9912. $accountItem = new accountItem ();
  9913. Doo::loadModel ( "receiptAuthorityManage" );
  9914. $receiptAuthorityManage = new receiptAuthorityManage ();
  9915. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9916. $cidList = array ();
  9917. foreach ( $imcStaff as $key => $value ) {
  9918. array_push ( $cidList, $value ['cid'] );
  9919. }
  9920. $cidString = implode ( ',', $cidList );
  9921. $LcategoryList = $Lcategory->find ( array (
  9922. 'where' => 'cid in (' . $cidString . ')',
  9923. 'asArray' => true
  9924. ) );
  9925. if ($cid == 0) {
  9926. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9927. if ($cid == 0)
  9928. $cid = $LcategoryList [0] ['cid'];
  9929. }
  9930. $data ['LcategoryList'] = $LcategoryList;
  9931. $receiptCollectList = $receiptDetail->find ( array (
  9932. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9933. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9934. 'groupby' => 'item,Month(pastDate)',
  9935. 'asArray' => true
  9936. ) );
  9937. $accountList = $accountItem->find ( array (
  9938. 'asArray' => true
  9939. ) );
  9940. // create CollectDetail HTML
  9941. $collectHtml = array ();
  9942. foreach ( $accountList as $key => $value ) {
  9943. $html = "";
  9944. $asum = 0;
  9945. for($i = 1; $i <= 12; $i ++) {
  9946. $falg = true;
  9947. foreach ( $receiptCollectList as $v ) {
  9948. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9949. $asum += $v ['price'];
  9950. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9951. $falg = false;
  9952. break;
  9953. }
  9954. }
  9955. if ($falg)
  9956. $html .= '<td class="taR">-</td>';
  9957. }
  9958. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9959. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9960. }
  9961. $data ['collectHtml'] = $collectHtml;
  9962. // create Adjustment price html
  9963. $receiptCollectList = $receiptDetail->find ( array (
  9964. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9965. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9966. 'groupby' => 'itemCategory,Month(pastDate)',
  9967. 'asArray' => true
  9968. ) );
  9969. $adjustment = array ();
  9970. $collectArray = array (
  9971. '日常相关费用' => array (),
  9972. '差旅相关费用' => array (),
  9973. '培训班费用' => array (),
  9974. '内部培训费用'=>array(),
  9975. '其他' => array ()
  9976. );
  9977. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9978. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9979. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9980. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9981. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9982. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9983. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  9984. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  9985. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9986. array_push ( $collectArray ['其他'], $collectHtml );
  9987. $data ['collectArray'] = $collectArray;
  9988. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9989. array_push ( $adjustment, $collectHtml );
  9990. $data ['adjustment'] = $adjustment;
  9991. // total price html
  9992. $collectHtml = "";
  9993. $total = 0;
  9994. for($i = 1; $i <= 12; $i ++) {
  9995. $sumPrice = 0;
  9996. foreach ( $receiptCollectList as $key => $value ) {
  9997. if ($value ['month'] == $i) {
  9998. $sumPrice += $value ['price'];
  9999. }
  10000. }
  10001. if ($sumPrice == 0)
  10002. $collectHtml .= '<td class="taR">-</td>';
  10003. else
  10004. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10005. $total += $sumPrice;
  10006. }
  10007. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10008. // statistics html
  10009. $stList = $statistics->statisticsByCid ( $year, $cid );
  10010. if (empty ( $stList ))
  10011. $stList = array (
  10012. 'rePrice' => 0,
  10013. 'agPrice' => 0
  10014. );
  10015. $data ['stList'] = array (
  10016. 'rePrice' => $stList ['rePrice'],
  10017. 'agPrice' => $stList ['agPrice'],
  10018. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10019. );
  10020. $data ['totalYear'] = $total;
  10021. $data ['year'] = $year;
  10022. $data ['cid'] = $cid;
  10023. $data ['memu'] = "receipt";
  10024. $data ['staff'] = $this->staff;
  10025. $data ['receiptMemu'] = 'companyCategoryCollect';
  10026. $data ['verifyId'] = $this->verifyId;
  10027. $data ['executeId'] = $this->executeId;
  10028. // year staff status 2,4
  10029. /* if ($year < date ( "Y" )) {
  10030. Doo::loadModel ( 'receipt' );
  10031. $receipt = new receipt ();
  10032. $receiptList = $receipt->find ( array (
  10033. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  10034. 'asArray' => true
  10035. ) );
  10036. if (empty ( $receiptList )) {
  10037. ob_start ();
  10038. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  10039. $this->cacheFile ( $path );
  10040. die ();
  10041. }
  10042. } */
  10043. $dateHtml = "";
  10044. $now = date ( "Y" );
  10045. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  10046. if ($YEARD <= $now) {
  10047. $dateHtml .= '<option ';
  10048. if ($year == $YEARD) {
  10049. $dateHtml .= 'selected ';
  10050. }
  10051. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  10052. }
  10053. }
  10054. $data ['dateHtml'] = $dateHtml;
  10055. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  10056. }
  10057. function staffCollect() {
  10058. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10059. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ONJOB';//
  10060. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  10061. // $this->showCache($path);
  10062. Doo::loadModel ( 'statistics' );
  10063. $statistics = new statistics ();
  10064. Doo::loadModel ( "receiptDetail" );
  10065. $receiptDetail = new receiptDetail ();
  10066. Doo::loadModel ( 'L_category' );
  10067. $Lcategory = new L_category ();
  10068. Doo::loadModel ( 'accountItem' );
  10069. $accountItem = new accountItem ();
  10070. Doo::loadModel ( 'staff' );
  10071. $staff = new staff ();
  10072. Doo::loadModel ( 'itemStatistics' );
  10073. $itemStatistics = new itemStatistics ();
  10074. Doo::loadModel ( "receiptAuthorityManage" );
  10075. $receiptAuthorityManage = new receiptAuthorityManage ();
  10076. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  10077. $cidList = array ();
  10078. foreach ( $imcStaff as $key => $value ) {
  10079. array_push ( $cidList, $value ['cid'] );
  10080. }
  10081. $cidString = implode ( ',', $cidList );
  10082. $naturecon='';
  10083. if ($nature=='ONJOB'){
  10084. $naturecon=' and (nature!=4 )';
  10085. }elseif($nature=='LEAVEJOB'){
  10086. $naturecon=' and (nature=4 )';
  10087. }else{
  10088. die ( 'illegal request--nature' );
  10089. }
  10090. // statistics html
  10091. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  10092. if (empty ( $stList ))
  10093. $stList = array (
  10094. 'rePrice' => 0,
  10095. 'agPrice' => 0
  10096. );
  10097. $data ['stList'] = array (
  10098. 'rePrice' => $stList ['rePrice'],
  10099. 'agPrice' => $stList ['agPrice'],
  10100. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10101. );
  10102. // ---
  10103. $staffList = $staff->find ( array (
  10104. 'where' => 'username !="admin" '.$naturecon,
  10105. 'asArray' => true
  10106. ) );
  10107. $LcategoryList = $Lcategory->find ( array (
  10108. 'asArray' => true
  10109. ) ); // 'staff='.$this->staff[0]['sid']." and
  10110. $itemStatisticsList = $itemStatistics->find ( array (
  10111. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10112. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  10113. 'groupby' => 'staff,Month(date)',
  10114. 'asArray' => true
  10115. ) );
  10116. $categoryList = $staff->find ( array (
  10117. 'select' => 'COUNT(*) as count,cid,category',
  10118. 'where' => 'username !="admin" and cid in (' . $cidString . ') '.$naturecon,
  10119. 'groupby' => 'cid',
  10120. 'asArray' => true
  10121. ) );
  10122. // print_r($itemStatisticsList);die;
  10123. // ceatre companyCollectHtml
  10124. foreach ( $categoryList as $vlu ) {
  10125. $count = $vlu ['count'] + 1;
  10126. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  10127. $m1 = 0;
  10128. $m2 = 0;
  10129. $m3 = 0;
  10130. $m4 = 0;
  10131. $m5 = 0;
  10132. $m6 = 0;
  10133. $m7 = 0;
  10134. $m8 = 0;
  10135. $m9 = 0;
  10136. $m10 = 0;
  10137. $m11 = 0;
  10138. $m12 = 0;
  10139. $m13 = 0;
  10140. foreach ( $staffList as $value ) {
  10141. if ($vlu ['cid'] == $value ['cid']) {
  10142. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  10143. $asum = 0;
  10144. for($i = 1; $i <= 12; $i ++) {
  10145. $falg = true;
  10146. foreach ( $itemStatisticsList as $v ) {
  10147. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  10148. if ($v ['month'] == 1)
  10149. $m1 += $v ['price'];
  10150. if ($v ['month'] == 2)
  10151. $m2 += $v ['price'];
  10152. if ($v ['month'] == 3)
  10153. $m3 += $v ['price'];
  10154. if ($v ['month'] == 4)
  10155. $m4 += $v ['price'];
  10156. if ($v ['month'] == 5)
  10157. $m5 += $v ['price'];
  10158. if ($v ['month'] == 6)
  10159. $m6 += $v ['price'];
  10160. if ($v ['month'] == 7)
  10161. $m7 += $v ['price'];
  10162. if ($v ['month'] == 8)
  10163. $m8 += $v ['price'];
  10164. if ($v ['month'] == 9)
  10165. $m9 += $v ['price'];
  10166. if ($v ['month'] == 10)
  10167. $m10 += $v ['price'];
  10168. if ($v ['month'] == 11)
  10169. $m11 += $v ['price'];
  10170. if ($v ['month'] == 12)
  10171. $m12 += $v ['price'];
  10172. $asum += $v ['price'];
  10173. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  10174. $falg = false;
  10175. break;
  10176. }
  10177. }
  10178. if ($falg)
  10179. $html .= '<td class="taR">-</td>';
  10180. }
  10181. $m13 += $asum;
  10182. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  10183. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  10184. 'html' => $html,
  10185. 'sid' => $value ['sid']
  10186. );
  10187. $html = "";
  10188. }
  10189. }
  10190. $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>
  10191. <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>
  10192. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  10193. $collectHtml [$vlu ['cid']] = array (
  10194. 'html' => $hl,
  10195. 'sid' => ''
  10196. );
  10197. }
  10198. $data ['companyHtml'] = $collectHtml;
  10199. // total price html
  10200. $collectHtml = "";
  10201. $total = 0;
  10202. for($i = 1; $i <= 12; $i ++) {
  10203. $sumPrice = 0;
  10204. foreach ( $itemStatisticsList as $key => $value ) {
  10205. if ($value ['month'] == $i) {
  10206. $sumPrice += $value ['price'];
  10207. }
  10208. }
  10209. if ($sumPrice == 0)
  10210. $collectHtml .= '<td class="taR">-</td>';
  10211. else
  10212. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10213. $total += $sumPrice;
  10214. }
  10215. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10216. $data ['companyTotalHtml'] = $collectHtml;
  10217. $data ['total'] = $total;
  10218. $data ['nature'] =$nature;
  10219. $data ['year'] = $year;
  10220. $data ['memu'] = "receipt";
  10221. $data ['staff'] = $this->staff;
  10222. $data ['receiptMemu'] = 'companyCategoryCollect';
  10223. $data ['verifyId'] = $this->verifyId;
  10224. $data ['executeId'] = $this->executeId;
  10225. if ($year <= date ( "Y" )) {
  10226. Doo::loadModel ( 'receipt' );
  10227. $receipt = new receipt ();
  10228. $receiptList = $receipt->find ( array (
  10229. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  10230. 'asArray' => true
  10231. ) );
  10232. if (empty ( $receiptList )) { // generated files
  10233. ob_start ();
  10234. $this->render ( "/admin/saeaStaffCollectB", $data );
  10235. $this->cacheFile ( $path );
  10236. die ();
  10237. }
  10238. }
  10239. $this->render ( "/admin/saeaStaffCollectB", $data );
  10240. }
  10241. function staffCollectBak() {
  10242. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10243. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  10244. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  10245. $this->showCache ( $path );
  10246. Doo::loadModel ( 'statistics' );
  10247. $statistics = new statistics ();
  10248. Doo::loadModel ( "receiptDetail" );
  10249. $receiptDetail = new receiptDetail ();
  10250. Doo::loadModel ( 'L_category' );
  10251. $Lcategory = new L_category ();
  10252. Doo::loadModel ( 'accountItem' );
  10253. $accountItem = new accountItem ();
  10254. Doo::loadModel ( 'staff' );
  10255. $staff = new staff ();
  10256. Doo::loadModel ( 'itemStatistics' );
  10257. $itemStatistics = new itemStatistics ();
  10258. $itemStatisticsList = $itemStatistics->find ( array (
  10259. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10260. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10261. 'groupby' => 'staff,itemCategory,Month(date)',
  10262. 'asArray' => true
  10263. ) );
  10264. $itemCategoryList = $itemStatistics->find ( array (
  10265. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10266. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10267. 'groupby' => 'cid,itemCategory,Month(date)',
  10268. 'asArray' => true
  10269. ) );
  10270. $LcategoryList = $Lcategory->find ( array (
  10271. 'asArray' => true
  10272. ) );
  10273. $staffList = $staff->find ( array (
  10274. 'asArray' => true
  10275. ) );
  10276. $htmlArray = array ();
  10277. foreach ( $LcategoryList as $value ) {
  10278. $htmlArray [$value ['title']] = array ();
  10279. foreach ( $staffList as $v ) {
  10280. if ($value ['cid'] == $v ['cid']) {
  10281. $html = "";
  10282. $falg = true;
  10283. $staffSumPrice = 0;
  10284. foreach ( $itemStatisticsList as $a ) {
  10285. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  10286. if (empty ( $a ['price'] )) {
  10287. $html .= '<td class="taR">-</td>';
  10288. $falg = false;
  10289. break;
  10290. } else {
  10291. $staffSumPrice += $a ['price'];
  10292. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10293. $falg = false;
  10294. break;
  10295. }
  10296. }
  10297. }
  10298. if ($falg) {
  10299. $html .= '<td class="taR">-</td>';
  10300. $falg = true;
  10301. }
  10302. $falg = true;
  10303. foreach ( $itemStatisticsList as $a ) {
  10304. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  10305. if (empty ( $a ['price'] )) {
  10306. $html .= '<td class="taR">-</td>';
  10307. $falg = false;
  10308. break;
  10309. } else {
  10310. $staffSumPrice += $a ['price'];
  10311. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10312. $falg = false;
  10313. break;
  10314. }
  10315. }
  10316. }
  10317. if ($falg) {
  10318. $html .= '<td class="taR">-</td>';
  10319. $falg = true;
  10320. }
  10321. $falg = true;
  10322. foreach ( $itemStatisticsList as $a ) {
  10323. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  10324. if (empty ( $a ['price'] )) {
  10325. $html .= '<td class="taR">-</td>';
  10326. $falg = false;
  10327. break;
  10328. } else {
  10329. $staffSumPrice += $a ['price'];
  10330. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10331. $falg = false;
  10332. break;
  10333. }
  10334. }
  10335. }
  10336. if ($falg) {
  10337. $html .= '<td class="taR">-</td>';
  10338. $falg = true;
  10339. }
  10340. $falg = true;
  10341. foreach ( $itemStatisticsList as $a ) {
  10342. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  10343. if (! empty ( $a ['price'] )) {
  10344. $staffSumPrice += $a ['price'];
  10345. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10346. $falg = false;
  10347. break;
  10348. } else {
  10349. $html .= '<td class="taR">-</td>';
  10350. $falg = false;
  10351. break;
  10352. }
  10353. }
  10354. }
  10355. if ($falg) {
  10356. $html .= '<td class="taR">-</td>';
  10357. $falg = true;
  10358. }
  10359. $falg = true;
  10360. foreach ( $itemStatisticsList as $a ) {
  10361. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  10362. if (! empty ( $a ['price'] )) {
  10363. $staffSumPrice += $a ['price'];
  10364. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10365. $falg = false;
  10366. break;
  10367. } else {
  10368. $html .= '<td class="taR">-</td>';
  10369. $falg = false;
  10370. break;
  10371. }
  10372. }
  10373. }
  10374. if ($falg) {
  10375. $html .= '<td class="taR">-</td>';
  10376. $falg = true;
  10377. }
  10378. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  10379. $htmlArray [$value ['title']] [$v ['username']] = $html;
  10380. }
  10381. }
  10382. /* -- --- */
  10383. // 合计费用
  10384. $cateHtml = "";
  10385. $catePrice = 0;
  10386. $cateFalg = true;
  10387. foreach ( $itemCategoryList as $l ) {
  10388. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  10389. if (empty ( $l ['price'] )) {
  10390. $cateHtml .= '<td class="colGreen taR">-</td>';
  10391. $cateFalg = false;
  10392. break;
  10393. } else {
  10394. $catePrice += $l ['price'];
  10395. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10396. $cateFalg = false;
  10397. break;
  10398. }
  10399. }
  10400. }
  10401. if ($cateFalg) {
  10402. $cateHtml .= '<td class="colGreen taR">-</td>';
  10403. $cateFalg = true;
  10404. }
  10405. $cateFalg = true;
  10406. foreach ( $itemCategoryList as $l ) {
  10407. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  10408. if (empty ( $l ['price'] )) {
  10409. $cateHtml .= '<td class="colGreen taR">-</td>';
  10410. $cateFalg = false;
  10411. break;
  10412. } else {
  10413. $catePrice += $l ['price'];
  10414. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10415. $cateFalg = false;
  10416. break;
  10417. }
  10418. }
  10419. }
  10420. if ($cateFalg) {
  10421. $cateHtml .= '<td class="colGreen taR">-</td>';
  10422. $cateFalg = true;
  10423. }
  10424. $cateFalg = true;
  10425. foreach ( $itemCategoryList as $l ) {
  10426. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  10427. if (empty ( $l ['price'] )) {
  10428. $cateHtml .= '<td class="colGreen taR">-</td>';
  10429. $cateFalg = false;
  10430. break;
  10431. } else {
  10432. $catePrice += $l ['price'];
  10433. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10434. $cateFalg = false;
  10435. break;
  10436. }
  10437. }
  10438. }
  10439. if ($cateFalg) {
  10440. $cateHtml .= '<td class="colGreen taR">-</td>';
  10441. $cateFalg = true;
  10442. }
  10443. $cateFalg = true;
  10444. foreach ( $itemCategoryList as $l ) {
  10445. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  10446. if (empty ( $l ['price'] )) {
  10447. $cateHtml .= '<td class="colGreen taR">-</td>';
  10448. $cateFalg = false;
  10449. break;
  10450. } else {
  10451. $catePrice += $l ['price'];
  10452. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10453. $cateFalg = false;
  10454. break;
  10455. }
  10456. }
  10457. }
  10458. if ($cateFalg) {
  10459. $cateHtml .= '<td class="colGreen taR">-</td>';
  10460. $cateFalg = true;
  10461. }
  10462. $cateFalg = true;
  10463. foreach ( $itemCategoryList as $l ) {
  10464. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  10465. if (empty ( $l ['price'] )) {
  10466. $cateHtml .= '<td class="colGreen taR">-</td>';
  10467. $cateFalg = false;
  10468. break;
  10469. } else {
  10470. $catePrice += $l ['price'];
  10471. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10472. $cateFalg = false;
  10473. break;
  10474. }
  10475. }
  10476. }
  10477. if ($cateFalg) {
  10478. $cateHtml .= '<td class="colGreen taR">-</td>';
  10479. $cateFalg = true;
  10480. }
  10481. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  10482. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  10483. /* -- --- */
  10484. }
  10485. // print_r($htmlArray);die;
  10486. $data ['htmlArray'] = $htmlArray;
  10487. // statistics html
  10488. $stList = $statistics->getOne ( array (
  10489. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  10490. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10491. 'groupby' => 'Month(date)',
  10492. 'asArray' => true
  10493. ) );
  10494. if (empty ( $stList ))
  10495. $stList = array (
  10496. 'rePrice' => 0,
  10497. 'agPrice' => 0
  10498. );
  10499. $data ['stList'] = array (
  10500. 'rePrice' => $stList ['rePrice'],
  10501. 'agPrice' => $stList ['agPrice'],
  10502. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10503. );
  10504. $monthHtml = "";
  10505. for($i = 1; $i <= 12; $i ++) {
  10506. if ($i == $month)
  10507. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  10508. else
  10509. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  10510. }
  10511. $data ['monthHtml'] = $monthHtml;
  10512. $data ['year'] = $year;
  10513. $data ['month'] = $month;
  10514. $data ['memu'] = "receipt";
  10515. $data ['staff'] = $this->staff;
  10516. $data ['receiptMemu'] = 'companyCategoryCollect';
  10517. $data ['verifyId'] = $this->verifyId;
  10518. $data ['executeId'] = $this->executeId;
  10519. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  10520. Doo::loadModel ( 'receipt' );
  10521. $receipt = new receipt ();
  10522. $receiptList = $receipt->find ( array (
  10523. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  10524. 'asArray' => true
  10525. ) );
  10526. if (empty ( $receiptList )) { // generated files
  10527. ob_start ();
  10528. $this->render ( "/admin/saeaStaffCollect", $data );
  10529. $this->cacheFile ( $path );
  10530. die ();
  10531. }
  10532. }
  10533. $this->render ( "/admin/saeaStaffCollect", $data );
  10534. }
  10535. /**
  10536. * 日常收支
  10537. */
  10538. function payments() {
  10539. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  10540. Doo::loadModel ( "execute" );
  10541. $execute = new execute ();
  10542. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  10543. die ( 'illegal request' );
  10544. }
  10545. Doo::loadModel ( "accountBook" );
  10546. $accountBook = new accountBook ();
  10547. Doo::loadModel ( "accountBookStatistics" );
  10548. $accountBookStatistics = new accountBookStatistics ();
  10549. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  10550. $list = $accountBook->getAccountBookByLimit ( 10 );
  10551. $data ['date'] = date ( "Y-m-d" );
  10552. $data ['statisticsList'] = $statisticsList;
  10553. $data ['list'] = $list;
  10554. $data ['memu'] = "receipt";
  10555. $data ['staff'] = $this->staff;
  10556. $data ['receiptMemu'] = 'payments';
  10557. $data ['verifyId'] = $this->verifyId;
  10558. $data ['executeId'] = $this->executeId;
  10559. $this->render ( "/expenses/payments", $data );
  10560. }
  10561. function paymentsIncomeDo() {
  10562. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10563. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10564. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10565. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10566. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10567. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10568. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10569. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10570. Doo::loadClass ( 'XDeode' );
  10571. $XDeode = new XDeode ( 5 );
  10572. Doo::loadModel ( "accountBook" );
  10573. Doo::loadModel ( "accountBookStatistics" );
  10574. Doo::loadModel ( 'wasteBook' );
  10575. // 记录流水时银行的转换
  10576. $accountBank = '';
  10577. if ($receivedBank == '纵横广发') {
  10578. $accountBank = 'CGBDeposit';
  10579. } elseif ($receivedBank == '纵横工行') {
  10580. $accountBank = 'ICBCDeposit';
  10581. } elseif ($receivedBank == '华润银行') {
  10582. $accountBank = 'HUADeposit';
  10583. } elseif ($receivedBank == '个人广发') {
  10584. $accountBank = 'PersonalDeposit';
  10585. }
  10586. if (empty ( $accountBank ))
  10587. die ( 'illegal request' );
  10588. if($accountType == 11 || $accountType == 12){
  10589. if($accountType == 11){
  10590. $receivedBank = '纵横广发';
  10591. }elseif($accountType == 12){
  10592. $receivedBank = '纵横工行';
  10593. }
  10594. // 添加一条收入
  10595. $accountBook = new accountBook ();
  10596. $accountBook->accountType = $accountType;
  10597. $accountBook->accountMsg = $accountMsg;
  10598. $accountBook->receivedPrice = $receivedPrice;
  10599. $accountBook->receivedMsg = $receivedMsg;
  10600. $accountBook->receivedBank = $receivedBank;
  10601. $accountBook->receivedDate = $receivedDate;
  10602. $accountBook->remarks = $remarks;
  10603. $accountBook->expensesType = 1;
  10604. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10605. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10606. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10607. $inComeId = $accountBook->insert ();
  10608. // 收支汇总-添加一条收入日常汇总
  10609. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10610. $accountBookStatistics = new accountBookStatistics ();
  10611. $item = array (
  10612. 'date' => date ( "Y-m-d" ),
  10613. 'accountType' => $abDetail ['accountType'],
  10614. 'accountMsg' => $abDetail ['accountMsg'],
  10615. 'aid' => $abDetail ['aid'],
  10616. 'inComePrice' => $abDetail ['receivedPrice'],
  10617. 'expensesType' => $abDetail ['expensesType']
  10618. );
  10619. $accountBookStatistics->setAccountBookStatistics ( $item );
  10620. //流水支出
  10621. // if($accountBank=='CGBDeposit'){
  10622. // $dailyExpenditureType='8';
  10623. // }elseif($accountBank=='ICBCDeposit'){
  10624. // $dailyExpenditureType='9';
  10625. // }elseif($accountBank=='PersonalDeposit'){
  10626. // $dailyExpenditureType='10';
  10627. // }elseif($accountBank=='HUADeposit'){
  10628. // $dailyExpenditureType='11';
  10629. // }
  10630. //
  10631. // $wasteBook = new wasteBook ();
  10632. // $itemWaste = array (
  10633. // 'expensesType' => 2,
  10634. // 'accountType' => 5,
  10635. // 'accountPriceShow' => $receivedPrice,
  10636. // 'accountPrice' => - $receivedPrice,
  10637. // 'dataID' => $inComeId,
  10638. // 'dailyExpenditureType' => $dailyExpenditureType,
  10639. // 'accountBank' => $accountBank,
  10640. // 'category' => $this->staff [0] ['category'],
  10641. // 'cid' => $this->staff [0] ['cid'],
  10642. // 'name' => $this->staff [0] ['username'],
  10643. // 'sid' => $this->staff [0] ['sid'],
  10644. // 'inputDate' => date ( "Y-m-d H:i:s" )
  10645. // );
  10646. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  10647. // 添加收入流水
  10648. if($accountType == 11){
  10649. $accountBank = 'CGBDeposit';
  10650. }elseif($accountType == 12){
  10651. $accountBank = 'ICBCDeposit';
  10652. }
  10653. $wasteBook = new wasteBook ();
  10654. $itemWaste = array (
  10655. 'accountPriceShow' => $receivedPrice,
  10656. 'accountPrice' => $receivedPrice,
  10657. 'expensesType' => 1,
  10658. 'accountType' => 6, // 流水类型
  10659. 'dataID' => $inComeId,
  10660. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10661. 'accountBank' => $accountBank,
  10662. 'category' => $this->staff [0] ['category'],
  10663. 'cid' => $this->staff [0] ['cid'],
  10664. 'name' => $this->staff [0] ['username'],
  10665. 'sid' => $this->staff [0] ['sid'],
  10666. 'inputDate' => date ( "Y-m-d H:i:s" )
  10667. );
  10668. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10669. }elseif($accountType == 7 || $accountType == 9) { // 收入为理财时特殊处理
  10670. if ($receivedBank == '个人广发') {
  10671. die ( '个人广发 illegal request' );
  10672. }
  10673. // 添加一条收入
  10674. $accountBook = new accountBook ();
  10675. $accountBook->accountType = 10;
  10676. $accountBook->accountMsg = $accountMsg;
  10677. $accountBook->receivedPrice = $receivedPrice;
  10678. $accountBook->receivedMsg = $receivedMsg;
  10679. $accountBook->receivedBank = $receivedBank;
  10680. $accountBook->receivedDate = $receivedDate;
  10681. $accountBook->remarks = $remarks;
  10682. $accountBook->expensesType = 1;
  10683. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10684. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10685. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10686. $inComeId = $accountBook->insert ();
  10687. // 收支汇总-添加一条收入日常汇总
  10688. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10689. $accountBookStatistics = new accountBookStatistics ();
  10690. $item = array (
  10691. 'date' => date ( "Y-m-d" ),
  10692. 'accountType' => $abDetail ['accountType'],
  10693. 'accountMsg' => $abDetail ['accountMsg'],
  10694. 'aid' => $abDetail ['aid'],
  10695. 'inComePrice' => $abDetail ['receivedPrice'],
  10696. 'expensesType' => $abDetail ['expensesType']
  10697. );
  10698. $accountBookStatistics->setAccountBookStatistics ( $item );
  10699. // 添加收入流水
  10700. $wasteBook = new wasteBook ();
  10701. $itemWaste = array (
  10702. 'accountPriceShow' => $receivedPrice,
  10703. 'accountPrice' => $receivedPrice,
  10704. 'expensesType' => 1,
  10705. 'accountType' => 6, // 流水类型
  10706. 'dataID' => $inComeId,
  10707. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10708. 'accountBank' => $accountBank,
  10709. 'category' => $this->staff [0] ['category'],
  10710. 'cid' => $this->staff [0] ['cid'],
  10711. 'name' => $this->staff [0] ['username'],
  10712. 'sid' => $this->staff [0] ['sid'],
  10713. 'inputDate' => date ( "Y-m-d H:i:s" )
  10714. );
  10715. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10716. // 添加一条理财支出
  10717. $accountBank = 'CGBDeposit';
  10718. $expenditureBank = '纵横广发';
  10719. $dailyExpenditureType = 4;
  10720. if ($accountType == 9) {
  10721. $accountBank = 'ICBCDeposit';
  10722. $expenditureBank = '纵横工行';
  10723. $dailyExpenditureType = 6;
  10724. }
  10725. $accountBook = new accountBook ();
  10726. $accountBook->expensesType = 2;
  10727. $accountBook->expenditureType = $dailyExpenditureType;
  10728. $accountBook->expenditureMsg = $accountMsg;
  10729. $accountBook->expenditurePrice = $receivedPrice;
  10730. $accountBook->expenditureBank = $expenditureBank;
  10731. $accountBook->expenditureDate = $receivedDate;
  10732. $accountBook->remarks = $remarks;
  10733. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10734. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10735. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10736. $id = $accountBook->insert ();
  10737. // 收支汇总-添加一条理财支出汇总
  10738. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10739. $accountBookStatistics = new accountBookStatistics ();
  10740. $item = array (
  10741. 'date' => date ( "Y-m-d" ),
  10742. 'accountType' => $abDetail ['accountType'],
  10743. 'accountMsg' => $abDetail ['accountMsg'],
  10744. 'aid' => $abDetail ['aid'],
  10745. 'financingPrice' => - $receivedPrice,
  10746. 'expensesType' => 3
  10747. );
  10748. $accountBookStatistics->setAccountBookStatistics ( $item );
  10749. // 添加一条支出理财流水
  10750. $accountTypeWaste = 5;
  10751. if ($accountMsg == '公司固定') {
  10752. $accountTypeWaste = 9;
  10753. } elseif ($accountMsg == '公司活期') {
  10754. $accountTypeWaste = 10;
  10755. } elseif ($accountMsg == '个人(GR)') {
  10756. $accountBank = 'PersonalDeposit';
  10757. }
  10758. $itemWaste = array (
  10759. 'expensesType' => 2,
  10760. 'accountType' => $accountTypeWaste,
  10761. 'accountPriceShow' => $receivedPrice,
  10762. 'accountPrice' => - $receivedPrice,
  10763. 'dataID' => $id,
  10764. 'dailyExpenditureType' => $dailyExpenditureType,
  10765. 'accountBank' => $accountBank,
  10766. 'category' => $this->staff [0] ['category'],
  10767. 'cid' => $this->staff [0] ['cid'],
  10768. 'name' => $this->staff [0] ['username'],
  10769. 'sid' => $this->staff [0] ['sid'],
  10770. 'inputDate' => date ( "Y-m-d H:i:s" )
  10771. );
  10772. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10773. } elseif ($accountType == 1) {
  10774. if ($receivedBank == '个人广发')
  10775. die ( 'illegal request' );
  10776. // 添加一条收入
  10777. $accountBook = new accountBook ();
  10778. $accountBook->accountType = $accountType;
  10779. $accountBook->accountMsg = $accountMsg;
  10780. $accountBook->receivedPrice = $receivedPrice;
  10781. $accountBook->receivedMsg = $receivedMsg;
  10782. $accountBook->receivedBank = $receivedBank;
  10783. $accountBook->receivedDate = $receivedDate;
  10784. $accountBook->remarks = $remarks;
  10785. $accountBook->expensesType = 1;
  10786. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10787. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10788. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10789. $id = $accountBook->insert ();
  10790. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10791. // 收支汇总-添加一条收入日常汇总
  10792. $accountBookStatistics = new accountBookStatistics ();
  10793. $item = array (
  10794. 'date' => date ( "Y-m-d" ),
  10795. 'accountType' => $abDetail ['accountType'],
  10796. 'accountMsg' => $abDetail ['accountMsg'],
  10797. 'aid' => $abDetail ['aid'],
  10798. 'expensesType' => $abDetail ['expensesType']
  10799. );
  10800. if ($abDetail ['accountType'] == 8) {
  10801. $item += array (
  10802. 'inComePrice' => $abDetail ['receivedPrice']
  10803. );
  10804. } else {
  10805. $item += array (
  10806. 'inComePrice' => $abDetail ['receivedPrice']
  10807. );
  10808. }
  10809. $accountBookStatistics->setAccountBookStatistics ( $item );
  10810. // 流水存储方向
  10811. $itemWaste = array (
  10812. 'accountType' => 6
  10813. ); // 流水类型
  10814. // if($accountMsg=='银行存款'||$accountMsg=='固定理财收益'){
  10815. // }else
  10816. if ($accountMsg == '活期理财收益') {
  10817. $itemWaste = array (
  10818. 'accountType' => 10
  10819. ); // 流水类型
  10820. }
  10821. // 添加收入流水
  10822. $wasteBook = new wasteBook ();
  10823. $itemWaste += array (
  10824. 'accountPrice' => $receivedPrice,
  10825. 'accountPriceShow' => $receivedPrice,
  10826. 'expensesType' => 1,
  10827. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10828. 'dataID' => $id,
  10829. 'accountBank' => $accountBank,
  10830. 'category' => $this->staff [0] ['category'],
  10831. 'cid' => $this->staff [0] ['cid'],
  10832. 'name' => $this->staff [0] ['username'],
  10833. 'sid' => $this->staff [0] ['sid'],
  10834. 'inputDate' => date ( "Y-m-d H:i:s" )
  10835. );
  10836. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10837. } else { // 普通日常收入处理
  10838. // 添加一条收入
  10839. $accountBook = new accountBook ();
  10840. $accountBook->accountType = $accountType;
  10841. $accountBook->accountMsg = $accountMsg;
  10842. $accountBook->receivedPrice = $receivedPrice;
  10843. $accountBook->receivedMsg = $receivedMsg;
  10844. $accountBook->receivedBank = $receivedBank;
  10845. $accountBook->receivedDate = $receivedDate;
  10846. $accountBook->remarks = $remarks;
  10847. $accountBook->expensesType = 1;
  10848. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10849. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10850. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10851. $id = $accountBook->insert ();
  10852. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10853. // 收支汇总-添加一条收入日常汇总
  10854. $accountBookStatistics = new accountBookStatistics ();
  10855. $item = array (
  10856. 'date' => date ( "Y-m-d" ),
  10857. 'accountType' => $abDetail ['accountType'],
  10858. 'accountMsg' => $abDetail ['accountMsg'],
  10859. 'aid' => $abDetail ['aid'],
  10860. 'expensesType' => $abDetail ['expensesType']
  10861. );
  10862. if ($abDetail ['accountType'] == 8) {
  10863. $item += array (
  10864. 'inComePrice' => $abDetail ['receivedPrice']
  10865. );
  10866. } else {
  10867. $item += array (
  10868. 'inComePrice' => $abDetail ['receivedPrice']
  10869. );
  10870. }
  10871. $accountBookStatistics->setAccountBookStatistics ( $item );
  10872. // 添加收入流水
  10873. $itemWaste = array (
  10874. 'accountPrice' => $receivedPrice
  10875. );
  10876. if ($receivedBank == '个人广发') {
  10877. $itemWaste = array (
  10878. 'accountPrice' => - $receivedPrice
  10879. );
  10880. }
  10881. $wasteBook = new wasteBook ();
  10882. $itemWaste += array (
  10883. 'accountPriceShow' => $receivedPrice,
  10884. 'expensesType' => 1,
  10885. 'accountType' => 6, // 流水类型
  10886. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10887. 'dataID' => $id,
  10888. 'accountBank' => $accountBank,
  10889. 'category' => $this->staff [0] ['category'],
  10890. 'cid' => $this->staff [0] ['cid'],
  10891. 'name' => $this->staff [0] ['username'],
  10892. 'sid' => $this->staff [0] ['sid'],
  10893. 'inputDate' => date ( "Y-m-d H:i:s" )
  10894. );
  10895. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10896. }
  10897. }
  10898. return '/payments';
  10899. }
  10900. function paymentsExpenditureDo() {
  10901. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10902. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10903. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10904. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10905. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10906. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10907. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10908. // 理财支出特殊处理
  10909. Doo::loadModel ( "accountBook" );
  10910. Doo::loadModel ( "accountBookStatistics" );
  10911. Doo::loadModel ( 'wasteBook' );
  10912. $accountBank = '';
  10913. if ($expenditureBank == '纵横广发') {
  10914. $accountBank = 'CGBDeposit';
  10915. } elseif ($expenditureBank == '纵横工行') {
  10916. $accountBank = 'ICBCDeposit';
  10917. } elseif ($expenditureBank == '华润银行') {
  10918. $accountBank = 'HUADeposit';
  10919. } elseif ($expenditureBank == '个人广发') {
  10920. $accountBank = 'PersonalDeposit';
  10921. }
  10922. if (empty ( $accountBank ))
  10923. die ( 'illegal request' );
  10924. if($expenditureType == 8 || $expenditureType == 9){
  10925. if($expenditureType == 8 ){
  10926. $expenditureBank='纵横广发';
  10927. }elseif($expenditureType == 9){
  10928. $expenditureBank='纵横工行';
  10929. }
  10930. // 添加一笔日常支出
  10931. $accountBook = new accountBook ();
  10932. $accountBook->expensesType = 2;
  10933. $accountBook->expenditureType = $expenditureType;
  10934. $accountBook->expenditureMsg = $expenditureMsg;
  10935. $accountBook->expenditurePrice = $expenditurePrice;
  10936. $accountBook->expenditureBank = $expenditureBank;
  10937. $accountBook->expenditureDate = $expenditureDate;
  10938. $accountBook->remarks = $remarks;
  10939. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10940. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10941. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10942. $expenditureId = $accountBook->insert ();
  10943. // 添加日常支出汇总
  10944. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  10945. $accountBookStatistics = new accountBookStatistics ();
  10946. $item = array (
  10947. 'date' => date ( "Y-m-d" ),
  10948. 'expenditureType' => $abDetail ['expenditureType'],
  10949. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10950. 'aid' => $abDetail ['aid'],
  10951. 'payPrice' => $abDetail ['expenditurePrice'],
  10952. 'expensesType' => $abDetail ['expensesType']
  10953. );
  10954. $accountBookStatistics->setAccountBookStatistics ( $item );
  10955. // 公司日常支出流水
  10956. if($expenditureType == 8 ){
  10957. $accountBank = 'CGBDeposit';
  10958. }elseif($expenditureType == 9){
  10959. $accountBank = 'ICBCDeposit';
  10960. }
  10961. if($accountBank=='CGBDeposit'){
  10962. $dailyExpenditureType='8';
  10963. }elseif($accountBank=='ICBCDeposit'){
  10964. $dailyExpenditureType='9';
  10965. }elseif($accountBank=='PersonalDeposit'){
  10966. $dailyExpenditureType='10';
  10967. }elseif($accountBank=='HUADeposit'){
  10968. $dailyExpenditureType='11';
  10969. }
  10970. $wasteBook = new wasteBook ();
  10971. $itemWaste = array (
  10972. 'expensesType' => 2,
  10973. 'accountType' => 5,
  10974. 'dailyExpenditureType' => $dailyExpenditureType,
  10975. 'accountPriceShow' => $expenditurePrice,
  10976. 'accountPrice' => - $expenditurePrice,
  10977. 'dataID' => $expenditureId,
  10978. 'accountBank' => $accountBank,
  10979. 'category' => $this->staff [0] ['category'],
  10980. 'cid' => $this->staff [0] ['cid'],
  10981. 'name' => $this->staff [0] ['username'],
  10982. 'sid' => $this->staff [0] ['sid'],
  10983. 'inputDate' => date ( "Y-m-d H:i:s" )
  10984. );
  10985. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10986. // 添加一笔收入流水
  10987. // if($expenditureType==8){
  10988. // $dailyIncomeType='11';
  10989. // }elseif($expenditureType==9){
  10990. // $dailyIncomeType='12';
  10991. // }
  10992. // $wasteBook = new wasteBook ();
  10993. // $itemWaste = array (
  10994. // 'expensesType' => 1,
  10995. // 'accountType' => 6,
  10996. // 'accountPriceShow' => $expenditurePrice,
  10997. // 'accountPrice' => $expenditurePrice,
  10998. // 'dataID' => $expenditureId,
  10999. //
  11000. // 'dailyIncomeType' => $dailyIncomeType,
  11001. // 'accountBank' => $accountBank,
  11002. // 'category' => $this->staff [0] ['category'],
  11003. // 'cid' => $this->staff [0] ['cid'],
  11004. // 'name' => $this->staff [0] ['username'],
  11005. // 'sid' => $this->staff [0] ['sid'],
  11006. // 'inputDate' => date ( "Y-m-d H:i:s" )
  11007. // );
  11008. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  11009. }elseif ($expenditureType == 4 || $expenditureType == 6) {
  11010. if ($expenditureBank == '个人广发') {
  11011. die ( '个人广发 illegal request' );
  11012. }
  11013. // 添加一笔日常支出
  11014. $accountBook = new accountBook ();
  11015. $accountBook->expensesType = 2;
  11016. $accountBook->expenditureType = 7;
  11017. $accountBook->expenditureMsg = $expenditureMsg;
  11018. $accountBook->expenditurePrice = $expenditurePrice;
  11019. $accountBook->expenditureBank = $expenditureBank;
  11020. $accountBook->expenditureDate = $expenditureDate;
  11021. $accountBook->remarks = $remarks;
  11022. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11023. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11024. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11025. $expenditureId = $accountBook->insert ();
  11026. // 添加日常支出汇总
  11027. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11028. $accountBookStatistics = new accountBookStatistics ();
  11029. $item = array (
  11030. 'date' => date ( "Y-m-d" ),
  11031. 'expenditureType' => $abDetail ['expenditureType'],
  11032. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11033. 'aid' => $abDetail ['aid'],
  11034. 'payPrice' => $abDetail ['expenditurePrice'],
  11035. 'expensesType' => $abDetail ['expensesType']
  11036. );
  11037. $accountBookStatistics->setAccountBookStatistics ( $item );
  11038. // 公司日常支出流水
  11039. $wasteBook = new wasteBook ();
  11040. $itemWaste = array (
  11041. 'accountPrice' => - $expenditurePrice
  11042. );
  11043. if ($expenditureBank == '个人广发') {
  11044. $itemWaste = array (
  11045. 'accountPrice' => $expenditurePrice
  11046. );
  11047. }
  11048. $itemWaste += array (
  11049. 'expensesType' => 2,
  11050. 'accountType' => 5,
  11051. 'dailyExpenditureType' => $expenditureType,
  11052. 'accountPriceShow' => $expenditurePrice,
  11053. 'accountPrice' => - $expenditurePrice,
  11054. 'dataID' => $expenditureId,
  11055. 'accountBank' => $accountBank,
  11056. 'category' => $this->staff [0] ['category'],
  11057. 'cid' => $this->staff [0] ['cid'],
  11058. 'name' => $this->staff [0] ['username'],
  11059. 'sid' => $this->staff [0] ['sid'],
  11060. 'inputDate' => date ( "Y-m-d H:i:s" )
  11061. );
  11062. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11063. // 添加一笔理财收入
  11064. $accountBank = 'CGBDeposit';
  11065. $dailyIncomeType = 7;
  11066. $receivedBank = '纵横广发';
  11067. if ($expenditureType == 6) {
  11068. $accountBank = 'ICBCDeposit';
  11069. $receivedBank = '纵横工行';
  11070. $dailyIncomeType = 9;
  11071. }
  11072. $accountBook = new accountBook ();
  11073. $accountBook->expensesType = 1;
  11074. $accountBook->accountType = $dailyIncomeType;
  11075. $accountBook->accountMsg = $expenditureMsg;
  11076. $accountBook->receivedPrice = $expenditurePrice;
  11077. $accountBook->receivedBank = $receivedBank;
  11078. $accountBook->receivedDate = $expenditureDate;
  11079. $accountBook->remarks = $remarks;
  11080. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11081. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11082. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11083. $id = $accountBook->insert ();
  11084. // 添加日常理财收入汇总
  11085. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11086. $accountBookStatistics = new accountBookStatistics ();
  11087. $item = array (
  11088. 'date' => date ( "Y-m-d" ),
  11089. 'expenditureType' => $abDetail ['expenditureType'],
  11090. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11091. 'aid' => $abDetail ['aid'],
  11092. 'financingPrice' => $expenditurePrice,
  11093. 'expensesType' => 3
  11094. );
  11095. $accountBookStatistics->setAccountBookStatistics ( $item );
  11096. // 添加一笔收入流水
  11097. if ($expenditureMsg == '公司固定') {
  11098. $accountTypeWaste = 9;
  11099. } elseif ($expenditureMsg == '公司活期') {
  11100. $accountTypeWaste = 10;
  11101. } elseif ($expenditureMsg == '个人(GR)') {
  11102. $accountBank = 'PersonalDeposit';
  11103. }
  11104. $itemWaste = array (
  11105. 'expensesType' => 1,
  11106. 'accountType' => $accountTypeWaste,
  11107. 'accountPriceShow' => $expenditurePrice,
  11108. 'accountPrice' => $expenditurePrice,
  11109. 'dataID' => $id,
  11110. 'dailyIncomeType' => $dailyIncomeType,
  11111. 'accountBank' => $accountBank,
  11112. 'category' => $this->staff [0] ['category'],
  11113. 'cid' => $this->staff [0] ['cid'],
  11114. 'name' => $this->staff [0] ['username'],
  11115. 'sid' => $this->staff [0] ['sid'],
  11116. 'inputDate' => date ( "Y-m-d H:i:s" )
  11117. );
  11118. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11119. } else {
  11120. // 添加一笔日常支出
  11121. $accountBook = new accountBook ();
  11122. $accountBook->expensesType = 2;
  11123. $accountBook->expenditureType = $expenditureType;
  11124. $accountBook->expenditureMsg = $expenditureMsg;
  11125. $accountBook->expenditurePrice = $expenditurePrice;
  11126. $accountBook->expenditureBank = $expenditureBank;
  11127. $accountBook->expenditureDate = $expenditureDate;
  11128. $accountBook->remarks = $remarks;
  11129. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11130. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11131. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11132. $id = $accountBook->insert ();
  11133. // 添加日常支出汇总
  11134. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11135. $accountBookStatistics = new accountBookStatistics ();
  11136. $item = array (
  11137. 'date' => date ( "Y-m-d" ),
  11138. 'expenditureType' => $abDetail ['expenditureType'],
  11139. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11140. 'aid' => $abDetail ['aid'],
  11141. 'expensesType' => $abDetail ['expensesType']
  11142. );
  11143. if ($expenditureType == 5) {
  11144. $item += array (
  11145. 'payPrice' => - $abDetail ['expenditurePrice']
  11146. );
  11147. } else {
  11148. $item += array (
  11149. 'payPrice' => $abDetail ['expenditurePrice']
  11150. );
  11151. }
  11152. $accountBookStatistics->setAccountBookStatistics ( $item );
  11153. // 公司日常支出流水
  11154. $wasteBook = new wasteBook ();
  11155. $itemWaste = array (
  11156. 'accountPrice' => - $expenditurePrice
  11157. );
  11158. if ($expenditureBank == '个人广发') {
  11159. $itemWaste = array (
  11160. 'accountPrice' => $expenditurePrice
  11161. );
  11162. }
  11163. $itemWaste += array (
  11164. 'expensesType' => 2,
  11165. 'accountType' => 5,
  11166. 'accountPriceShow' => $expenditurePrice,
  11167. 'dataID' => $id,
  11168. 'dailyExpenditureType' => $expenditureType,
  11169. 'accountBank' => $accountBank,
  11170. 'category' => $this->staff [0] ['category'],
  11171. 'cid' => $this->staff [0] ['cid'],
  11172. 'name' => $this->staff [0] ['username'],
  11173. 'sid' => $this->staff [0] ['sid'],
  11174. 'inputDate' => date ( "Y-m-d H:i:s" )
  11175. );
  11176. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11177. }
  11178. }
  11179. return '/payments';
  11180. }
  11181. /**
  11182. * 添加支出
  11183. */
  11184. function paymentsExpenditureDo_() {
  11185. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11186. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11187. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11188. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11189. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11190. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11191. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11192. $dailyExpenditureType = '';
  11193. $accountTypeWaste = 5;
  11194. $accountBank = '';
  11195. if ($expenditureBank == '纵横广发') {
  11196. $accountBank = 'CGBDeposit';
  11197. } elseif ($expenditureBank == '纵横工行') {
  11198. $accountBank = 'ICBCDeposit';
  11199. } elseif ($expenditureBank == '华润银行') {
  11200. $accountBank = 'HUADeposit';
  11201. } elseif ($expenditureBank == '个人广发') {
  11202. $accountBank = 'PersonalDeposit';
  11203. }
  11204. if (empty ( $accountBank ))
  11205. die ( 'illegal request' );
  11206. $itemWaste = array (
  11207. 'accountPrice' => - $expenditurePrice
  11208. );
  11209. if ($expenditureBank == '个人广发') {
  11210. $itemWaste = array (
  11211. 'accountPrice' => $expenditurePrice
  11212. );
  11213. }
  11214. if ($expenditureType == 4 || $expenditureType == 6) {
  11215. $dailyExpenditureType = 4;
  11216. if ($expenditureMsg == '公司固定') {
  11217. $accountTypeWaste = 9;
  11218. } elseif ($expenditureMsg == '公司活期') {
  11219. $accountTypeWaste = 10;
  11220. } elseif ($expenditureMsg == '个人(GR)') {
  11221. $accountBank = 'PersonalDeposit';
  11222. }
  11223. $itemWaste = array (
  11224. 'accountPrice' => $expenditurePrice
  11225. );
  11226. } elseif ($expenditureType == 1) {
  11227. $dailyExpenditureType = 1;
  11228. } elseif ($expenditureType == 2) {
  11229. $dailyExpenditureType = 2;
  11230. } elseif ($expenditureType == 3) {
  11231. $dailyExpenditureType = 3;
  11232. } elseif ($expenditureType == 5) {
  11233. $dailyExpenditureType = 5;
  11234. }
  11235. if (empty ( $dailyExpenditureType ))
  11236. die ( 'illegal request' );
  11237. Doo::loadModel ( "accountBook" );
  11238. $accountBook = new accountBook ();
  11239. $accountBook->expenditureType = $expenditureType;
  11240. $accountBook->expenditureMsg = $expenditureMsg;
  11241. $accountBook->expenditurePrice = $expenditurePrice;
  11242. $accountBook->expenditureBank = $expenditureBank;
  11243. $accountBook->expenditureDate = $expenditureDate;
  11244. $accountBook->remarks = $remarks;
  11245. $accountBook->expensesType = 2;
  11246. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11247. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11248. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11249. $id = $accountBook->insert ();
  11250. //
  11251. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11252. Doo::loadModel ( "accountBookStatistics" );
  11253. $accountBookStatistics = new accountBookStatistics ();
  11254. $item = array (
  11255. 'date' => date ( "Y-m-d" ),
  11256. 'expenditureType' => $abDetail ['expenditureType'],
  11257. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11258. 'aid' => $abDetail ['aid']
  11259. );
  11260. if ($abDetail ['expensesType'] == 2) {
  11261. if ($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) {
  11262. $item += array (
  11263. 'financingPrice' => $expenditurePrice,
  11264. 'expensesType' => 3
  11265. );
  11266. } elseif ($abDetail ['expenditureType'] == 5) {
  11267. $item += array (
  11268. 'payPrice' => $abDetail ['expenditurePrice'],
  11269. 'expensesType' => $abDetail ['expensesType']
  11270. );
  11271. } else {
  11272. $item += array (
  11273. 'payPrice' => $abDetail ['expenditurePrice'],
  11274. 'expensesType' => $abDetail ['expensesType']
  11275. );
  11276. }
  11277. }
  11278. $accountBookStatistics->setAccountBookStatistics ( $item );
  11279. // 公司流水记录
  11280. Doo::loadModel ( 'wasteBook' );
  11281. $wasteBook = new wasteBook ();
  11282. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountTypeWaste, $id );
  11283. // 银行
  11284. if (empty ( $abDetail )) {
  11285. $itemWaste += array (
  11286. 'accountPriceShow' => $expenditurePrice,
  11287. 'dataID' => $id,
  11288. 'expensesType' => 2,
  11289. 'accountType' => $accountTypeWaste,
  11290. 'dailyExpenditureType' => $expenditureType,
  11291. 'accountBank' => $accountBank,
  11292. 'category' => $this->staff [0] ['category'],
  11293. 'cid' => $this->staff [0] ['cid'],
  11294. 'name' => $this->staff [0] ['username'],
  11295. 'sid' => $this->staff [0] ['sid'],
  11296. 'inputDate' => date ( "Y-m-d H:i:s" )
  11297. );
  11298. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11299. }
  11300. // 支出类型为4或者6 需要添加一笔收入和收入流水
  11301. if ($expenditureType == 4 || $expenditureType == 6) {
  11302. $accountBank = 'CGBDeposit';
  11303. $dailyIncomeType = 7;
  11304. $receivedBank = '纵横广发';
  11305. if ($expenditureType == 6) {
  11306. $accountBank = 'ICBCDeposit';
  11307. $receivedBank = '纵横工行';
  11308. $dailyIncomeType = 9;
  11309. }
  11310. // 添加一笔收入
  11311. $accountBook = new accountBook ();
  11312. $accountBook->accountType = $dailyIncomeType;
  11313. $accountBook->accountMsg = $expenditureMsg;
  11314. $accountBook->receivedPrice = $expenditurePrice;
  11315. $accountBook->receivedBank = $receivedBank;
  11316. $accountBook->receivedDate = $expenditureDate;
  11317. $accountBook->remarks = $remarks;
  11318. $accountBook->expensesType = 1;
  11319. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11320. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11321. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11322. $id = $accountBook->insert ();
  11323. // 添加一笔收入流水
  11324. $itemWaste = array (
  11325. 'accountPriceShow' => $expenditurePrice,
  11326. 'accountPrice' => - $expenditurePrice,
  11327. 'dataID' => $id,
  11328. 'expensesType' => 1,
  11329. 'accountType' => $accountTypeWaste,
  11330. 'dailyIncomeType' => $dailyIncomeType,
  11331. 'accountBank' => $accountBank,
  11332. 'category' => $this->staff [0] ['category'],
  11333. 'cid' => $this->staff [0] ['cid'],
  11334. 'name' => $this->staff [0] ['username'],
  11335. 'sid' => $this->staff [0] ['sid'],
  11336. 'inputDate' => date ( "Y-m-d H:i:s" )
  11337. );
  11338. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11339. }
  11340. }
  11341. return '/payments';
  11342. }
  11343. /**
  11344. * 所有收支
  11345. */
  11346. function paymentsAchieve() {
  11347. $page_size = 12;
  11348. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  11349. $expensesType = isset ( $this->params ['expensesType'] ) ? $this->params ['expensesType'] : 'ALL';
  11350. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11351. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  11352. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11353. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11354. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11355. $submitType = $this->get_args ( 'submitType' ) ? $this->get_args ( 'submitType' ) : "";
  11356. Doo::loadModel ( "accountBookStatistics" );
  11357. $accountBookStatistics = new accountBookStatistics ();
  11358. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  11359. $data ['statisticsList'] = $statisticsList;
  11360. Doo::loadModel ( "accountBook" );
  11361. $accountBook = new accountBook ();
  11362. $con = '';
  11363. if ($expensesType == 'INCOME')
  11364. $con = ' and expensesType=1 ';
  11365. elseif ($expensesType == 'PAY')
  11366. $con = ' and expensesType=2 ';
  11367. $dateArr = explode ( ':', $date );
  11368. $D1 = $dateString = '';
  11369. $D2 = '';
  11370. if (! empty ( $date )) {
  11371. $D1 = $dateArr [0];
  11372. if (isset ( $dateArr [1] ))
  11373. $D2 = $dateArr [1];
  11374. else
  11375. $D2 = '';
  11376. $dateString = $D1 . " : " . $D2;
  11377. }
  11378. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11379. $con .= ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11380. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11381. $con .= ' and inputDate like "%' . $D1 . '%" ';
  11382. if (! empty ( $price ))
  11383. $con .= ' and (receivedPrice=' . $price . ' or expenditurePrice=' . $price . ')';
  11384. if ($submitType == 1) {
  11385. if ($accountType != '') {
  11386. $expenditureType = '';
  11387. $con .= ' and accountType=' . $accountType;
  11388. if (! empty ( $accountMsg ))
  11389. $con .= ' and (accountType=' . $accountType . ' and accountMsg like "%' . $accountMsg . '%")';
  11390. }
  11391. } elseif ($submitType == 2) {
  11392. if ($expenditureType != '') {
  11393. $accountType = $accountMsg = '';
  11394. $con .= ' and expenditureType=' . $expenditureType;
  11395. }
  11396. } else {
  11397. $accountType = $accountMsg = $expenditureType = '';
  11398. }
  11399. $sql = "" . $con;
  11400. $action = "paymentsAchieve";
  11401. $get = '/' . $expensesType; // "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  11402. $pageinfo = $this->get_page ( "CLD_accountBook", $sql, $page, $page_size, $action, $get, "" );
  11403. $limit = $pageinfo ['lower'] . ',' . $page_size;
  11404. $list = $accountBook->getAccountBookBySql ( $limit, $sql, 'desc' );
  11405. $data ['expenditureType'] = $expenditureType;
  11406. $data ['accountMsg'] = $accountMsg;
  11407. $data ['accountType'] = $accountType;
  11408. $data ['inputDate'] = $date;
  11409. $data ['price'] = $price;
  11410. $data ['expensesType'] = $expensesType;
  11411. $data ['page'] = $pageinfo;
  11412. $data ['list'] = $list;
  11413. $data ['memu'] = "receipt";
  11414. $data ['staff'] = $this->staff;
  11415. $data ['receiptMemu'] = 'payments';
  11416. $data ['verifyId'] = $this->verifyId;
  11417. $data ['executeId'] = $this->executeId;
  11418. $this->render ( "/expenses/paymentsAchieve", $data );
  11419. }
  11420. function paymentsIncomeUpdateDo() {
  11421. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11422. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11423. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11424. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  11425. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  11426. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  11427. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  11428. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11429. if (! empty ( $aidKey ) && ! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  11430. Doo::loadClass ( 'XDeode' );
  11431. $XDeode = new XDeode ( 5 );
  11432. $aid = $XDeode->decode ( $aidKey );
  11433. Doo::loadModel ( "accountBook" );
  11434. $accountBook = new accountBook ();
  11435. //
  11436. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11437. $price = $receivedPrice - $abDetail [inComePrice];
  11438. Doo::loadModel ( "accountBookStatistics" );
  11439. $accountBookStatistics = new accountBookStatistics ();
  11440. if ($abDetail ['accountType'] == 7) {
  11441. $item += array (
  11442. 'date' => date ( "Y-m-d" ),
  11443. 'financingPrice' => - $price,
  11444. 'expensesType' => 3,
  11445. 'aid' => $abDetail ['aid']
  11446. );
  11447. } elseif ($abDetail ['accountType'] == 8) {
  11448. $item += array (
  11449. 'date' => date ( "Y-m-d" ),
  11450. 'expensesType' => $abDetail ['expensesType'],
  11451. 'inComePrice' => - $price,
  11452. 'aid' => $abDetail ['aid']
  11453. );
  11454. } else {
  11455. $item = array (
  11456. 'date' => date ( "Y-m-d" ),
  11457. 'expensesType' => $abDetail ['expensesType'],
  11458. 'inComePrice' => $price,
  11459. 'aid' => $abDetail ['aid']
  11460. );
  11461. }
  11462. $accountBookStatistics->setAccountBookStatistics ( $item );
  11463. $accountBook->accountType = $accountType;
  11464. $accountBook->accountMsg = $accountMsg;
  11465. $accountBook->receivedPrice = $receivedPrice;
  11466. $accountBook->receivedMsg = $receivedMsg;
  11467. $accountBook->receivedBank = $receivedBank;
  11468. $accountBook->receivedDate = $receivedDate;
  11469. $accountBook->remarks = $remarks;
  11470. $accountBook->aid = $aid;
  11471. $accountBook->update ();
  11472. }
  11473. return '/paymentsAchieve';
  11474. }
  11475. function paymentsExpenditureEdiDo() {
  11476. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11477. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11478. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11479. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11480. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11481. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11482. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11483. if (! empty ( $aidKey ) && ! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11484. Doo::loadClass ( 'XDeode' );
  11485. $XDeode = new XDeode ( 5 );
  11486. $aid = $XDeode->decode ( $aidKey );
  11487. Doo::loadModel ( "accountBook" );
  11488. $accountBook = new accountBook ();
  11489. // 汇总信息
  11490. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11491. $price = $expenditurePrice - $abDetail [expenditurePrice];
  11492. Doo::loadModel ( "accountBookStatistics" );
  11493. $accountBookStatistics = new accountBookStatistics ();
  11494. if ($abDetail ['expenditureType'] == 4) {
  11495. $item += array (
  11496. 'date' => date ( "Y-m-d" ),
  11497. 'financingPrice' => $price,
  11498. 'expensesType' => 3,
  11499. 'aid' => $abDetail ['aid']
  11500. );
  11501. } elseif ($abDetail ['expenditureType'] == 5) {
  11502. $item += array (
  11503. 'date' => date ( "Y-m-d" ),
  11504. 'expensesType' => $abDetail ['expensesType'],
  11505. 'payPrice' => $price,
  11506. 'aid' => $abDetail ['aid']
  11507. );
  11508. } else {
  11509. $item = array (
  11510. 'date' => date ( "Y-m-d" ),
  11511. 'expensesType' => $abDetail ['expensesType'],
  11512. 'payPrice' => $price,
  11513. 'aid' => $abDetail ['aid']
  11514. );
  11515. }
  11516. $accountBookStatistics->setAccountBookStatistics ( $item );
  11517. //
  11518. $accountBook->expenditureType = $expenditureType;
  11519. $accountBook->expenditureMsg = $expenditureMsg;
  11520. $accountBook->expenditurePrice = $expenditurePrice;
  11521. $accountBook->expenditureBank = $expenditureBank;
  11522. $accountBook->remarks = $remarks;
  11523. $accountBook->expenditureDate = $expenditureDate;
  11524. $accountBook->aid = $aid;
  11525. $id = $accountBook->update ();
  11526. }
  11527. return '/paymentsAchieve';
  11528. }
  11529. function paymentsDelDo() {
  11530. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11531. if (! empty ( $aidKey )) {
  11532. Doo::loadClass ( 'XDeode' );
  11533. $XDeode = new XDeode ( 5 );
  11534. $aid = $XDeode->decode ( $aidKey );
  11535. Doo::loadModel ( "accountBook" );
  11536. $accountBook = new accountBook ();
  11537. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11538. if (empty ( $abDetail ))
  11539. die ( 'illegal request' );
  11540. // 删除收支
  11541. Doo::loadModel ( "accountBookStatistics" );
  11542. $accountBookStatistics = new accountBookStatistics ();
  11543. $item = array (
  11544. 'date' => date ( "Y-m-d" ),
  11545. 'aid' => $abDetail ['aid']
  11546. );
  11547. $accountType = '';
  11548. if ($abDetail ['expensesType'] == 1) {
  11549. $accountType = 6;
  11550. if ($abDetail ['accountType'] != 7) {
  11551. $item += array (
  11552. 'expensesType' => $abDetail ['expensesType'],
  11553. 'inComePrice' => - $abDetail ['receivedPrice']
  11554. );
  11555. } else {
  11556. $item += array (
  11557. 'financingPrice' => $abDetail ['receivedPrice'],
  11558. 'expensesType' => 3
  11559. );
  11560. }
  11561. } elseif ($abDetail ['expensesType'] == 2) {
  11562. $accountType = 5;
  11563. if ($abDetail ['accountType'] != 7) {
  11564. $item += array (
  11565. 'expensesType' => $abDetail ['expensesType'],
  11566. 'payPrice' => - $abDetail ['expenditurePrice']
  11567. );
  11568. } else {
  11569. $item += array (
  11570. 'financingPrice' => - $abDetail ['expenditurePrice'],
  11571. 'expensesType' => 3
  11572. );
  11573. }
  11574. }
  11575. if (($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) && $abDetail ['expensesType'] == 2) {
  11576. if ($abDetail ['expenditureMsg'] == '公司固定')
  11577. $accountType = 9;
  11578. elseif ($abDetail ['expenditureMsg'] == '公司活期')
  11579. $accountType = 10;
  11580. }
  11581. if (($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) && $abDetail ['expensesType'] == 1) {
  11582. if ($abDetail ['accountMsg'] == '公司固定')
  11583. $accountType = 9;
  11584. elseif ($abDetail ['accountMsg'] == '公司活期')
  11585. $accountType = 10;
  11586. }
  11587. if ($abDetail ['accountMsg'] == '活期理财收益') {
  11588. $accountType = 10;
  11589. }
  11590. $accountBookStatistics->setAccountBookStatistics ( $item );
  11591. $accountBook->delete ( array (
  11592. 'where' => 'aid=' . $aid,
  11593. 'limit' => 1
  11594. ) );
  11595. // 删除收入流水
  11596. if (! empty ( $accountType )) {
  11597. Doo::loadModel ( 'wasteBook' );
  11598. $wasteBook = new wasteBook ();
  11599. $wasteBook->delete ( array (
  11600. 'where' => 'dataID=' . $aid . ' and accountType=' . $accountType,
  11601. 'limit' => 1
  11602. ) );
  11603. }
  11604. }
  11605. return '/paymentsAchieve';
  11606. }
  11607. function paymentsCollect() {
  11608. Doo::loadModel ( "execute" );
  11609. $execute = new execute ();
  11610. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11611. die ( 'illegal request' );
  11612. }
  11613. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11614. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  11615. Doo::loadModel ( "accountBookStatistics" );
  11616. $accountBookStatistics = new accountBookStatistics ();
  11617. Doo::loadClass ( 'receipt.func' );
  11618. $statisticsIncome = $accountBookStatistics->getStatisticsByCollect ( $year );
  11619. $html = _getPaymentsCollectByYearHtml ( $statisticsIncome );
  11620. $data ['html'] = $html ['html'];
  11621. $data ['inSum'] = $html ['sum'];
  11622. $statisticsPay = $accountBookStatistics->getStatisticsByCollect ( $year, 2 );
  11623. $html = _getPaymentsCollectPayByYearHtml ( $statisticsPay );
  11624. $data ['payHtml'] = $html ['html'];
  11625. $data ['paySum'] = $html ['sum'];
  11626. // 余额统计
  11627. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1 );
  11628. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2 );
  11629. include './protected/config/wasteBook.conf.php';
  11630. Doo::loadModel ( 'wasteBook' );
  11631. $wasteBook = new wasteBook ();
  11632. $inComePay = $wasteBook->getWasteBookByStatistics ( 1, $year );
  11633. $pay = $wasteBook->getWasteBookByStatistics ( 2, $year );
  11634. // 获得年份之前所有金额
  11635. $detail = $wasteBook->getWasteBookByStatisticsYear ( $year );
  11636. // print_r($detail);
  11637. // $waste['total'];
  11638. $lastBalanceHtml = '<tr><th colspan="2">截至上月余额</th>';
  11639. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11640. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11641. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11642. $inSum = $paySum = $showInSum = $showPaySum = $balanceSum = 0;
  11643. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11644. $limitMonth = date ( 'm' ); // 限制显示月份参数
  11645. if (date ( 'Y' ) > $year) {
  11646. $limitMonth = 12;
  11647. }
  11648. for($i = 1; $i <= 12; $i ++) {
  11649. $inComeA = $payB = 0;
  11650. $falg = true;
  11651. foreach ( $inComePay as $key => $value ) {
  11652. if ($value ['month'] == $i) {
  11653. $falg = false;
  11654. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11655. $inSum += $value ['accountPrice'];
  11656. $showInSum += $value ['accountPriceShow'];
  11657. $inComeA = $value ['accountPrice'];
  11658. break;
  11659. }
  11660. }
  11661. if ($falg)
  11662. $inComeHtml .= '<td class="taR">-</td>';
  11663. $payFalg = true;
  11664. foreach ( $pay as $key => $value ) {
  11665. if ($value ['month'] == $i) {
  11666. $payFalg = false;
  11667. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11668. $paySum += $value ['accountPrice'];
  11669. $showPaySum += $value ['accountPriceShow'];
  11670. $payB = $value ['accountPrice'];
  11671. break;
  11672. }
  11673. }
  11674. if ($payFalg)
  11675. $payHtml .= '<td class="taR">-</td>';
  11676. if (empty ( $balanceC ) || $limitMonth < $i)
  11677. $lastBalanceHtml .= '<td class="taR">-</td>';
  11678. else
  11679. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11680. $balanceC = $balanceC + $inComeA + $payB;
  11681. $balanceSum += $balanceC;
  11682. if (empty ( $balanceC ) || $limitMonth < $i)
  11683. $BalanceHtml .= '<td class="taR">-</td>';
  11684. else
  11685. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11686. // 余额统计
  11687. }
  11688. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11689. $data ['inComeHtml'] = $inComeHtml;
  11690. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11691. $data ['payBalanceHtml'] = $payHtml;
  11692. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11693. $data ['BalanceHtml'] = $BalanceHtml;
  11694. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11695. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11696. $mothHtml = "";
  11697. for($i = 1; $i <= 12; $i ++) {
  11698. if ($moth == $i)
  11699. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11700. else
  11701. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11702. }
  11703. $data ['mothHtml'] = $mothHtml;
  11704. $dateHtml = "";
  11705. $now = date ( "Y" );
  11706. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11707. if ($YEARD <= $now) {
  11708. $dateHtml .= '<option ';
  11709. if ($year == $YEARD) {
  11710. $dateHtml .= 'selected ';
  11711. }
  11712. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11713. }
  11714. }
  11715. $data ['dateHtml'] = $dateHtml;
  11716. $data ['year'] = $year;
  11717. $data ['memu'] = "receipt";
  11718. $data ['staff'] = $this->staff;
  11719. $data ['receiptMemu'] = 'paymentsCollect';
  11720. $data ['verifyId'] = $this->verifyId;
  11721. $data ['executeId'] = $this->executeId;
  11722. $this->render ( "/expenses/paymentsCollect", $data );
  11723. }
  11724. function paymentsCollectDay() {
  11725. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11726. $moth = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : '';
  11727. if (empty ( $moth ))
  11728. return 'paymentsCollect';
  11729. Doo::loadModel ( "accountBookStatistics" );
  11730. $accountBookStatistics = new accountBookStatistics ();
  11731. $i = 2;
  11732. $y = 2013;
  11733. $day = date ( "t", strtotime ( "$year-$moth" ) );
  11734. Doo::loadClass ( 'receipt.func' );
  11735. $statisticsIncome = $accountBookStatistics->getStatisticsByCollectDay ( $year, 1, $moth );
  11736. $html = _getPaymentsCollectByDayHtml ( $statisticsIncome, $day );
  11737. $data ['html'] = $html ['html'];
  11738. $data ['inSum'] = $html ['sum'];
  11739. $statisticsPay = $accountBookStatistics->getStatisticsByCollectDay ( $year, 2, $moth );
  11740. $html = _getPaymentsCollectPayByDayHtml ( $statisticsPay, $day );
  11741. $data ['payHtml'] = $html ['html'];
  11742. $data ['paySum'] = $html ['sum'];
  11743. $mothHtml = "";
  11744. for($i = 1; $i <= 12; $i ++) {
  11745. if ($moth == $i)
  11746. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11747. else
  11748. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11749. }
  11750. $data ['mothHtml'] = $mothHtml;
  11751. $data ['year'] = $year;
  11752. // 余额
  11753. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1, $moth );
  11754. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2, $moth );
  11755. include './protected/config/wasteBook.conf.php';
  11756. Doo::loadModel ( 'wasteBook' );
  11757. $wasteBook = new wasteBook ();
  11758. $inComePay = $wasteBook->getStatisticsByDay ( 1, $year, $moth );
  11759. $pay = $wasteBook->getStatisticsByDay ( 2, $year, $moth );
  11760. // 获得年份之前所有金额
  11761. $detail = $wasteBook->getWasteBookByStatisticsDay ( $year, $moth );
  11762. $lastBalanceHtml = '<tr><th colspan="2">截至上日余额</th>';
  11763. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11764. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11765. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11766. $dayHtml = '<tr><th class="taC" colspan="2">余额</th>';
  11767. $inSum = $paySum = $showPaySum = $showInSum = $balanceSum = 0;
  11768. // $balanceC = 0;
  11769. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11770. $limitDay = date ( 'd' );
  11771. $monthLK = ( int ) date ( 'm' );
  11772. if (date ( 'Y' ) > $year) {
  11773. $limitDay = cal_days_in_month ( CAL_GREGORIAN, date ( 'm' ), date ( 'Y' ) );
  11774. } elseif (date ( 'Y' ) <= $year && $monthLK < $moth) {
  11775. $limitDay = 0;
  11776. }
  11777. for($i = 1; $i <= $day; $i ++) {
  11778. $dayHtml .= '<td class="taC">' . $i . '日</td>';
  11779. $inComeA = $payB = 0;
  11780. $falg = true;
  11781. foreach ( $inComePay as $key => $value ) {
  11782. if ($value ['day'] == $i) {
  11783. $falg = false;
  11784. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11785. $inSum += $value ['accountPrice'];
  11786. $showInSum += $value ['accountPriceShow'];
  11787. $inComeA = $value ['accountPrice'];
  11788. break;
  11789. }
  11790. }
  11791. if ($falg)
  11792. $inComeHtml .= '<td class="taR">-</td>';
  11793. $payFalg = true;
  11794. foreach ( $pay as $key => $value ) {
  11795. if ($value ['day'] == $i) {
  11796. $payFalg = false;
  11797. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11798. $paySum += $value ['accountPrice'];
  11799. $showPaySum += $value ['accountPriceShow'];
  11800. $payB = $value ['accountPrice'];
  11801. break;
  11802. }
  11803. }
  11804. if ($payFalg)
  11805. $payHtml .= '<td class="taR">-</td>';
  11806. if (empty ( $balanceC ) || $limitDay < $i)
  11807. $lastBalanceHtml .= '<td class="taR">-</td>';
  11808. else
  11809. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11810. $balanceC = $balanceC + $inComeA + $payB;
  11811. $balanceSum += $balanceC;
  11812. if (empty ( $balanceC ) || $limitDay < $i)
  11813. $BalanceHtml .= '<td class="taR">-</td>';
  11814. else
  11815. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11816. }
  11817. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11818. $data ['inComeHtml'] = $inComeHtml;
  11819. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11820. $data ['payBalanceHtml'] = $payHtml;
  11821. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11822. $data ['BalanceHtml'] = $BalanceHtml;
  11823. $dayHtml .= '<td class="taR ">总计</td></tr>';
  11824. $data ['dayHtml'] = $dayHtml;
  11825. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11826. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11827. $dateHtml = "";
  11828. $now = date ( "Y" );
  11829. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11830. if ($YEARD <= $now) {
  11831. $dateHtml .= '<option ';
  11832. if ($year == $YEARD) {
  11833. $dateHtml .= 'selected ';
  11834. }
  11835. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11836. }
  11837. }
  11838. $data ['dateHtml'] = $dateHtml;
  11839. $data ['memu'] = "receipt";
  11840. $data ['staff'] = $this->staff;
  11841. $data ['receiptMemu'] = 'paymentsCollect';
  11842. $data ['verifyId'] = $this->verifyId;
  11843. $data ['executeId'] = $this->executeId;
  11844. $this->render ( "/expenses/paymentsCollectDay", $data );
  11845. }
  11846. // 公司流水
  11847. function wasteBook() {
  11848. Doo::loadModel ( "execute" );
  11849. $execute = new execute ();
  11850. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11851. die ( 'illegal request' );
  11852. }
  11853. include './protected/config/wasteBook.conf.php';
  11854. Doo::loadModel ( 'wasteBook' );
  11855. $wasteBook = new wasteBook ();
  11856. $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  11857. $waste = $this->getWasteBookStatistics ( $waste, $inComeStatistics );
  11858. //
  11859. $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'];
  11860. $CGBDeposit_total =$waste ['bank'] ['CGBDeposit']+$waste ['bank'] ['HUADeposit'];
  11861. // print_r($waste);
  11862. $data ['waste'] = $waste;
  11863. $data ['total'] = $total;
  11864. $data ['CGBDeposit_total'] = $CGBDeposit_total;
  11865. // 月流水数据结构
  11866. $monthStatistics = array ();
  11867. $incomeMothStatistics = array ();
  11868. $expenditureMothStatistics = array ();
  11869. for($i = 1; $i <= 12; $i ++) {
  11870. $month = date ( 'Y' ) . '-' . $i;
  11871. if ($i < 10)
  11872. $month = date ( 'Y' ) . '-0' . $i;
  11873. array_push ( $monthStatistics, $month );
  11874. }
  11875. foreach ( $monthStatistics as $value ) {
  11876. $falg = true;
  11877. foreach ( $inComeStatistics ['incomeReport'] as $k => $v ) {
  11878. if ($value == $v ['inputDate']) {
  11879. array_push ( $incomeMothStatistics, $v ['accountPrice'] );
  11880. $falg = false;
  11881. }
  11882. }
  11883. if ($falg) {
  11884. array_push ( $incomeMothStatistics, '' );
  11885. }
  11886. $falgEx = true;
  11887. foreach ( $inComeStatistics ['expenditureReport'] as $k => $v ) {
  11888. if ($value == $v ['inputDate']) {
  11889. array_push ( $expenditureMothStatistics, $v ['accountPrice'] );
  11890. $falg = false;
  11891. }
  11892. }
  11893. if ($falgEx) {
  11894. array_push ( $expenditureMothStatistics, '' );
  11895. }
  11896. }
  11897. $data ['monthStatistics'] = json_encode ( $monthStatistics );
  11898. $data ['incomeMothStatistics'] = json_encode ( $incomeMothStatistics );
  11899. $data ['expenditureMothStatistics'] = json_encode ( $expenditureMothStatistics );
  11900. $expenditureList = $wasteBook->getAccountBookByExpensesType ( 4, 2 );
  11901. $incomeList = $wasteBook->getAccountBookByExpensesType ( 4, 1 );
  11902. // print_r($incomeList);
  11903. $data ['expenditureList'] = $expenditureList;
  11904. $data ['incomeList'] = $incomeList;
  11905. $data ['memu'] = "receipt";
  11906. $data ['staff'] = $this->staff;
  11907. $data ['receiptMemu'] = 'wasteBook';
  11908. $data ['verifyId'] = $this->verifyId;
  11909. $data ['executeId'] = $this->executeId;
  11910. $this->render ( "/expenses/wasteBook", $data );
  11911. }
  11912. function wasteBookIncome() {
  11913. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11914. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11915. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  11916. $dailyIncomeType = $this->get_args ( 'dailyIncomeType' ) ? $this->get_args ( 'dailyIncomeType' ) : "ALL";
  11917. $data ['dailyIncomeType'] = $dailyIncomeType;
  11918. Doo::loadModel ( 'wasteBook' );
  11919. $wasteBook = new wasteBook ();
  11920. Doo::loadModel ( 'L_category' );
  11921. $L_category = new L_category ();
  11922. Doo::loadClass ( 'XDeode' );
  11923. $XDeode = new XDeode ( 5 );
  11924. // echo $XDeode->encode(1).'<br>';
  11925. // echo $XDeode->encode(2).'<br>';
  11926. // echo $XDeode->encode(3).'<br>';
  11927. // echo $XDeode->encode(4).'<br>';
  11928. // echo $XDeode->encode(5).'<br>';
  11929. // echo $XDeode->encode(6).'<br>';
  11930. // echo $XDeode->encode(7).'<br>';
  11931. // echo $XDeode->encode(8).'<br>';
  11932. // echo $XDeode->encode(9).'<br>';
  11933. // echo $XDeode->encode(10).'<br>';
  11934. $year=date("Y");
  11935. $theDay=date("Y-m-d");
  11936. $dateArr = explode ( ':', $date );
  11937. $D1 = '';
  11938. $D2 = '';
  11939. $con = '';
  11940. if (! empty ( $date )) {
  11941. $D1 = $dateArr [0];
  11942. $D2 = $dateArr [1];
  11943. }
  11944. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11945. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11946. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11947. $con = ' and inputDate = "' . $D1 . '"';
  11948. else{
  11949. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  11950. }
  11951. if ($cid != 'ALL') {
  11952. $cid = $XDeode->decode ( $cid );
  11953. $con .= ' and cid = "' . $cid . '"';
  11954. }
  11955. if ($accountType != 'ALL') {
  11956. if ($accountType == 'INVOICE') {
  11957. $con .= ' and (accountType = 7 or accountType = 8)';
  11958. } elseif ($accountType == 'PAYMENTS') {
  11959. $con .= ' and (accountType = 6 or accountType = 9 or accountType = 10)';
  11960. if ($dailyIncomeType != 'ALL') {
  11961. $dailyIncomeType = $XDeode->decode ( $dailyIncomeType );
  11962. $con .= ' and dailyIncomeType = ' . $dailyIncomeType;
  11963. }
  11964. }
  11965. }
  11966. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 1, $con );
  11967. $sum = 0;$thsDaySum=0;
  11968. foreach ( $incomeList as $key => $value ) {
  11969. $sum += $value ['accountPrice'];
  11970. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  11971. $thsDaySum+=$value ['accountPrice'];
  11972. }
  11973. }
  11974. // print_r($incomeList);
  11975. // 获得办事和部门
  11976. $categoryList = $L_category->getCategory ();
  11977. $data ['accountType'] = $accountType;
  11978. $data ['cid'] = $cid;
  11979. $data ['categoryList'] = $categoryList;
  11980. $data ['sum'] = $sum;
  11981. $data ['incomeList'] = $incomeList;
  11982. $data ['inputDate'] = $date;
  11983. $data['year']=$year;
  11984. $data ['thsDay'] =$theDay;
  11985. $data ['thsDaySum'] =$thsDaySum;
  11986. $data ['memu'] = "receipt";
  11987. $data ['staff'] = $this->staff;
  11988. $data ['receiptMemu'] = 'wasteBook';
  11989. $data ['verifyId'] = $this->verifyId;
  11990. $data ['executeId'] = $this->executeId;
  11991. $this->render ( "/expenses/wasteBookIncome", $data );
  11992. }
  11993. /**
  11994. * 所有支出
  11995. */
  11996. function wasteBookExpenditure() {
  11997. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11998. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11999. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  12000. $dailyExpenditureType = $this->get_args ( 'dailyExpenditureType' ) ? $this->get_args ( 'dailyExpenditureType' ) : "ALL";
  12001. $data ['dailyExpenditureType'] = $dailyExpenditureType;
  12002. $receiptType = $this->get_args ( 'receiptType' ) ? $this->get_args ( 'receiptType' ) : "ALL";
  12003. $data ['receiptType'] = $receiptType;
  12004. Doo::loadModel ( 'wasteBook' );
  12005. $wasteBook = new wasteBook ();
  12006. Doo::loadModel ( 'L_category' );
  12007. $L_category = new L_category ();
  12008. Doo::loadClass ( 'XDeode' );
  12009. $XDeode = new XDeode ( 5 );
  12010. $year=date("Y");
  12011. $theDay=date("Y-m-d");
  12012. $dateArr = explode ( ':', $date );
  12013. $D1 = '';
  12014. $D2 = '';
  12015. $con = '';
  12016. if (! empty ( $date )) {
  12017. $D1 = $dateArr [0];
  12018. $D2 = $dateArr [1];
  12019. }
  12020. if (! empty ( $D1 ) && ! empty ( $D2 ))
  12021. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  12022. elseif (! empty ( $D1 ) && empty ( $D2 ))
  12023. $con = ' and inputDate = "' . $D1 . '"';
  12024. else{
  12025. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  12026. }
  12027. if ($cid != 'ALL') {
  12028. $cid = $XDeode->decode ( $cid );
  12029. $con .= ' and cid = "' . $cid . '"';
  12030. }
  12031. if ($accountType != 'ALL') {
  12032. if ($accountType == 'INVOICE') {
  12033. $con .= ' and accountType = 11';
  12034. } elseif ($accountType == 'PAYMENTS') {
  12035. $con .= ' and (accountType = 5 or accountType = 9 or accountType = 10)';
  12036. if ($dailyExpenditureType != 'ALL') {
  12037. $dailyExpenditureType = $XDeode->decode ( $dailyExpenditureType );
  12038. $con .= ' and dailyExpenditureType = ' . $dailyExpenditureType;
  12039. }
  12040. } elseif ($accountType == 'RECEIPT') {
  12041. if ($receiptType == 'ALL') {
  12042. $con .= ' and (accountType = 1 or accountType = 2 or accountType = 3 or accountType = 4)';
  12043. } else {
  12044. $receiptType = $XDeode->decode ( $receiptType );
  12045. echo $receiptType;
  12046. if ($receiptType == 1) {
  12047. $con .= ' and (accountType = 1 or accountType=2)';
  12048. } else {
  12049. $con .= ' and accountType = ' . $receiptType;
  12050. }
  12051. }
  12052. }
  12053. }
  12054. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 2, $con );
  12055. $sum = 0;$thsDaySum=0;
  12056. foreach ( $incomeList as $key => $value ) {
  12057. $sum += $value ['accountPriceShow'];
  12058. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  12059. $thsDaySum+=$value ['accountPriceShow'];
  12060. }
  12061. }
  12062. // print_r($incomeList);
  12063. // 获得办事和部门
  12064. $categoryList = $L_category->getCategory ();
  12065. $data ['accountType'] = $accountType;
  12066. $data ['cid'] = $cid;
  12067. $data ['categoryList'] = $categoryList;
  12068. $data ['sum'] = $sum;
  12069. $data ['incomeList'] = $incomeList;
  12070. $data ['inputDate'] = $date;
  12071. $data['year']=$year;
  12072. $data ['thsDay'] =$theDay;
  12073. $data ['thsDaySum'] =$thsDaySum;
  12074. $data ['memu'] = "receipt";
  12075. $data ['staff'] = $this->staff;
  12076. $data ['receiptMemu'] = 'wasteBook';
  12077. $data ['verifyId'] = $this->verifyId;
  12078. $data ['executeId'] = $this->executeId;
  12079. $this->render ( "/expenses/wasteBookExpenditure", $data );
  12080. }
  12081. function ajaxGetWasteinvoiceReceivables() {
  12082. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12083. Doo::loadClass ( 'XDeode' );
  12084. $XDeode = new XDeode ( 5 );
  12085. $irid = $XDeode->decode ( $serial );
  12086. Doo::loadModel ( 'invoiceReceivables' );
  12087. $invoiceReceivables = new invoiceReceivables ();
  12088. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  12089. echo json_encode ( array (
  12090. 'status' => 1,
  12091. 'detail' => $detail
  12092. ) );
  12093. }
  12094. function ajaxGetPaymentsByAid() {
  12095. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12096. Doo::loadModel ( "accountBook" );
  12097. $accountBook = new accountBook ();
  12098. $detail = $accountBook->getAccountBookByAid ( $serial );
  12099. echo json_encode ( array (
  12100. 'status' => 1,
  12101. 'detail' => $detail
  12102. ) );
  12103. }
  12104. function ajaxGetWasteInvoice() {
  12105. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12106. Doo::loadModel ( 'invoice' );
  12107. $invoice = new invoice ();
  12108. Doo::loadModel ( 'invoiceReceivables' );
  12109. $invoiceReceivables = new invoiceReceivables ();
  12110. $detail = $invoice->getInvoiceByIid ( $serial );
  12111. $detailReceivables = $invoiceReceivables->getInvoiceReceivablesByIrid ( $detail ['irid'] );
  12112. $detail ['receivablesBank'] = $detailReceivables ['receivablesBank'];
  12113. echo json_encode ( array (
  12114. 'status' => 1,
  12115. 'detail' => $detail
  12116. ) );
  12117. }
  12118. /**
  12119. */
  12120. function ajaxGetWasteReceipt() {
  12121. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12122. $accountTypeKey = $this->get_args ( 'accountTypeKey' ) ? $this->get_args ( 'accountTypeKey' ) : "";
  12123. Doo::loadModel ( 'receipt' );
  12124. $receipt = new receipt ();
  12125. Doo::loadClass ( 'XDeode' );
  12126. $XDeode = new XDeode ( 5 );
  12127. $rid = $XDeode->decode ( $serial );
  12128. $accountType= $XDeode->decode ( $accountTypeKey );
  12129. // 获得个数据
  12130. $detail = $receipt->getReceiptByRid ( $rid );
  12131. // 初始化
  12132. $detail ['reviseDetail'] = array ();
  12133. if (! empty ( $value ['reviseDetail'] ))
  12134. $detail ['reviseDetail'] = json_decode ( $detail ['reviseDetail'], true );
  12135. $detail ['accountItem'] = json_decode ( $detail ['accountItem'], true );
  12136. $detail ['loanItem'] = json_decode ( $detail ['loanItem'], true );
  12137. $detail ['loanSumCN'] = $this->num_to_rmb ( $detail ['loanSum'] );
  12138. $detail ['sumCN'] = $this->num_to_rmb ( $detail ['sum'] );
  12139. // 获得费用html
  12140. $html = $this->getWasteReceiptHtml ( $detail ,$accountType);
  12141. // 获得费用审批人数据
  12142. $detail = $this->getReceiptApproverHtml ( $detail );
  12143. // 审批执行
  12144. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  12145. <th class="taC" width="90">审批人</th>
  12146. <th class="taC">审批意见</th></tr>';
  12147. foreach ( $detail ['verifyList'] as $key => $value ) {
  12148. $html .= '<tr>
  12149. <td>' . $value [1] . '</td>
  12150. <td>' . $value ['opinion'] . '</td>
  12151. </tr>
  12152. ';
  12153. }
  12154. $html .= ' </tbody></table>';
  12155. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  12156. <th class="taC" width="90">执行人</th>
  12157. <th class="taC">执行意见</th></tr>';
  12158. foreach ( $detail ['executeCopy'] as $key => $value ) {
  12159. $html .= '<tr>
  12160. <td>' . $value [1] . '</td>
  12161. <td>' . $value ['opinion'] . '</td>
  12162. </tr>
  12163. ';
  12164. }
  12165. $html .= ' </tbody></table>';
  12166. if($accountType==1){
  12167. Doo::loadModel ( 'loanReceipt' );
  12168. $loanReceipt = new loanReceipt ();
  12169. $loanList = $loanReceipt->getOne ( array (
  12170. 'where' => 'rid=' . $detail ['loanRid'],
  12171. 'desc' => 'rid',
  12172. 'asArray' => true
  12173. ) );
  12174. $html .= '<table class="table table-bordered table-condensed">
  12175. <tr class="warning">
  12176. <td class="taR"><b>汇款金额</b></td>
  12177. <td width="140" class="taR"><b style="font-size: 24px">¥'.$loanList['amount'].'</b></td>
  12178. </tr>
  12179. </table>';
  12180. }else{
  12181. $html .= '<table class="table table-bordered table-condensed">
  12182. <tr class="warning">
  12183. <td class="taR"><b>汇款金额</b></td>
  12184. <td width="140" class="taR"><b style="font-size: 24px">¥' . $detail ['amount'] . '</b></td>
  12185. </tr>
  12186. </table>';
  12187. }
  12188. // print_r($detail['verifyList']);
  12189. // header ( 'Content-Type:text/html;charset=utf-8' );
  12190. // echo $html;
  12191. echo json_encode ( array (
  12192. 'status' => 1,
  12193. 'html' => $html,
  12194. 'detail' => $detail
  12195. ) );
  12196. }
  12197. function getReceiptApproverHtml($detail = array()) {
  12198. Doo::loadModel ( 'loanReceipt' );
  12199. $loanReceipt = new loanReceipt ();
  12200. Doo::loadModel ( 'verify' );
  12201. $verify = new verify ();
  12202. Doo::loadModel ( 'staff' );
  12203. $staff = new staff ();
  12204. if (empty ( $detail ))
  12205. return array ();
  12206. $loanList = $loanReceipt->getOne ( array (
  12207. 'where' => 'rid=' . $detail ['loanRid'],
  12208. 'desc' => 'rid',
  12209. 'asArray' => true
  12210. ) );
  12211. if ($detail ['status'] == 3 || $detail ['status'] == 1 || $detail ['status'] == 8 || $detail ['status'] == 9) {
  12212. if ($detail ['status'] == 8 && $detail ['Rtype'] == 1)
  12213. $verifyList ['staff'] = $loanList ['verifyBreakup'];
  12214. else
  12215. $verifyList ['staff'] = $detail ['verifyBreakup'];
  12216. } else
  12217. $verifyList = $verify->getOne ( array (
  12218. 'where' => 'vid=' . $detail ['verify'],
  12219. 'asArray' => true
  12220. ) );
  12221. $verifyList = json_decode ( $verifyList ['staff'], true );
  12222. Doo::loadModel ( 'role' );
  12223. $role = new role ();
  12224. $roleId = 0;
  12225. $flag = true;
  12226. $roleKey = 0;
  12227. $endStaffArray = array ();
  12228. $roleArrayCopy = array ();
  12229. foreach ( $verifyList as $k => $v ) {
  12230. // init verifyStaff
  12231. if ($v [1] == 'ROLE') {
  12232. if (! empty ( $verifyStaff )) {
  12233. $endStaffArray = end ( $verifyStaff );
  12234. }
  12235. $roleVerify = json_decode ( $v [3], true );
  12236. $roleKey = $k;
  12237. $roleArray = array ();
  12238. $rolename = $role->getOne ( array (
  12239. 'where' => 'rid=' . $v [0],
  12240. 'asArray' => true
  12241. ) );
  12242. foreach ( $roleVerify as $o => $p ) {
  12243. $staffID = explode ( '_', $p );
  12244. $staffInfo = $staff->getOne ( array (
  12245. 'where' => 'sid=' . $staffID [0],
  12246. 'asArray' => true
  12247. ) );
  12248. // print_r($staffID);
  12249. $exp = array (
  12250. 0 => $staffInfo ['sid'],
  12251. 1 => $staffID [1],
  12252. 2 => $staffInfo ['avatar'],
  12253. 'date' => '',
  12254. 'date' => '',
  12255. 'opinion' => '',
  12256. 'status' => '',
  12257. 'rolename' => $rolename ['name']
  12258. );
  12259. array_push ( $roleArray, $exp );
  12260. }
  12261. $roleArrayCopy [$v [0]] = $roleArray;
  12262. // $verifyList[$k]['roleArray']=$roleArray;
  12263. }
  12264. $verifyList [$k] ['date'] = "";
  12265. $verifyList [$k] ['opinion'] = "";
  12266. $verifyList [$k] ['status'] = "";
  12267. if (empty ( $verifyStaff )) {
  12268. $verifyList [$k] ['date'] = "";
  12269. $verifyList [$k] ['opinion'] = "";
  12270. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  12271. $verifyList [$k] ['status'] = 4;
  12272. $flag = false;
  12273. }
  12274. } else {
  12275. foreach ( $verifyStaff as $m => $u ) {
  12276. if ($v [0] == $m) {
  12277. $verifyList [$k] ['date'] = $u ['date'];
  12278. $verifyList [$k] ['opinion'] = $u ['opinion'];
  12279. $verifyList [$k] ['status'] = $u ['status'];
  12280. $flag = false;
  12281. break;
  12282. }
  12283. }
  12284. $endStaffArray = end ( $verifyStaff );
  12285. }
  12286. }
  12287. $rolename ['name'] = '';
  12288. if (! empty ( $roleId )) {
  12289. Doo::loadModel ( 'role' );
  12290. $role = new role ();
  12291. $rolename = $role->getOne ( array (
  12292. 'where' => 'rid=' . $roleId,
  12293. 'asArray' => true
  12294. ) );
  12295. }
  12296. if (! empty ( $verifyStaff ))
  12297. $endStaffArray = end ( $verifyStaff );
  12298. $KOP = false;
  12299. foreach ( $roleArrayCopy as $P => $A ) {
  12300. foreach ( $A as $MKI => $AVL ) {
  12301. if (! empty ( $verifyStaff )) {
  12302. // &&$rolename['rid']==$endStaffArray['nextStaff']
  12303. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  12304. $button = 4;
  12305. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  12306. }
  12307. foreach ( $verifyStaff as $m => $u ) {
  12308. $AVLFK = $AVL [0] . '_R';
  12309. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  12310. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  12311. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  12312. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  12313. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  12314. break;
  12315. }
  12316. }
  12317. } else {
  12318. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  12319. $button = 4;
  12320. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  12321. }
  12322. }
  12323. // $roleArray[$MKI]['rolename']=$rolename['name'];
  12324. $KOP = true;
  12325. }
  12326. }
  12327. foreach ( $roleArrayCopy as $k => $v ) {
  12328. foreach ( $verifyList as $m => $n ) {
  12329. if ($n [0] == $k) {
  12330. array_splice ( $verifyList, $m, 1, $v );
  12331. }
  12332. }
  12333. }
  12334. // 费用执行人相关数据
  12335. $executeCopy = json_decode ( $detail ['executeCopy'], true );
  12336. $executeStaff = json_decode ( $detail ['executeStaff'], true );
  12337. foreach ( $executeCopy as $k => $v ) {
  12338. $executeCopy [$k] ['date'] = '';
  12339. $executeCopy [$k] ['opinion'] = '';
  12340. $executeCopy [$k] ['status'] = '';
  12341. if (! empty ( $executeStaff ))
  12342. foreach ( $executeStaff as $m => $u ) {
  12343. if ($v [0] == $m) {
  12344. $executeCopy [$k] ['date'] = $u ['date'];
  12345. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  12346. $executeCopy [$k] ['status'] = $u ['status'];
  12347. break;
  12348. }
  12349. }
  12350. }
  12351. $detail ['executeCopy'] = $executeCopy;
  12352. $detail ['verifyList'] = $verifyList;
  12353. return $detail;
  12354. }
  12355. function getWasteReceiptHtml($detail = array(),$accountType=1) {
  12356. if (empty ( $detail ))
  12357. return '';
  12358. $html = '';
  12359. if ($detail ['Rtype'] == 0) { // 报销单
  12360. $html .= '<table class="table table-bordered table-condensed">
  12361. <tbody>
  12362. <tr>
  12363. <th colspan="2" class="taC">日常相关费用</th>
  12364. </tr>';
  12365. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12366. $html .= '
  12367. <tr>
  12368. <th>' . $value ['name'] . '</th>
  12369. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12370. </tr>';
  12371. }
  12372. $html .= '
  12373. <tr>
  12374. <th class="taR">合计</th>
  12375. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12376. </tr>';
  12377. $html .= '<tr>
  12378. <th colspan="2" class="taC">差旅相关费用</th>
  12379. </tr>';
  12380. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12381. $html .= '
  12382. <tr>
  12383. <th>' . $value ['name'] . '</th>
  12384. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12385. </tr>';
  12386. }
  12387. $html .= '
  12388. <tr>
  12389. <th class="taR">合计</th>
  12390. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12391. </tr>';
  12392. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12393. $html .= '<tr>
  12394. <th colspan="2" class="taC">内部培训费用</th>
  12395. </tr>';
  12396. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12397. $html .= '
  12398. <tr>
  12399. <th>' . $value ['name'] . '</th>
  12400. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12401. </tr>';
  12402. }
  12403. $html .= '
  12404. <tr>
  12405. <th class="taR">合计</th>
  12406. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12407. </tr>';
  12408. }
  12409. $html .= '<tr>
  12410. <th colspan="2" class="taC">其他</th>
  12411. </tr>';
  12412. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12413. $html .= '
  12414. <tr>
  12415. <th>' . $value ['name'] . '</th>
  12416. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12417. </tr>';
  12418. }
  12419. $html .= '
  12420. <tr>
  12421. <th class="taR">合计</th>
  12422. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12423. </tr>';
  12424. $html .= '<tr>
  12425. <th colspan="2" class="taC">报销金额调整</th>
  12426. </tr>';
  12427. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12428. $html .= '
  12429. <tr>
  12430. <th>' . $value ['name'] . '</th>
  12431. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12432. </tr>';
  12433. }
  12434. $html .= '
  12435. <tr>
  12436. <th class="taR">合计</th>
  12437. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12438. </tr>';
  12439. $html .= '
  12440. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12441. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12442. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12443. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12444. <tr class="warning">
  12445. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12446. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12447. </tr>
  12448. </tbody>
  12449. </table>';
  12450. } elseif ($detail ['Rtype'] == 2) {//对公汇款
  12451. $html .= '
  12452. <table class="table table-bordered table-condensed">
  12453. <tbody>
  12454. <tr>
  12455. <th colspan="2" class="taC">办事处相关费用</th>
  12456. </tr>';
  12457. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12458. $html .= '
  12459. <tr>
  12460. <th>' . $value ['name'] . '</th>
  12461. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12462. </tr>';
  12463. }
  12464. $html .= '
  12465. <tr>
  12466. <th class="taR">合计</th>
  12467. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12468. </tr>';
  12469. $html .= '
  12470. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12471. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12472. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12473. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12474. <tr class="warning">
  12475. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12476. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12477. </tr>
  12478. </tbody>
  12479. </table>';
  12480. } elseif ($detail ['Rtype'] == 1) {//借款 或者借款报销
  12481. Doo::loadModel ( 'loanReceipt' );
  12482. $loanReceipt = new loanReceipt ();
  12483. $loanList = $loanReceipt->getOne ( array (
  12484. 'where' => 'rid=' . $detail ['loanRid'],
  12485. 'desc' => 'rid',
  12486. 'asArray' => true
  12487. ) );
  12488. // print_r($loanList);
  12489. $loanList ['sumCN']=$this->num_to_rmb($loanList ['sum']);
  12490. $html .= '<table class="table table-bordered table-condensed">
  12491. <tbody>
  12492. <tr>
  12493. <th colspan="2" class="taC">借款费用</th>
  12494. </tr>';
  12495. foreach ( $detail ['loanItem'] ['借款费用'] as $key => $value ) {
  12496. $html .= '<tr>
  12497. <th>' . $value ['name'] . '</th>
  12498. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12499. </tr>';
  12500. }
  12501. $html .= '<tr>
  12502. <th class="taC" colspan="2">产生费用所在办事处</th>
  12503. </tr>
  12504. <tr>
  12505. <th style="text-align: center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th>
  12506. </tr>
  12507. <tr>
  12508. <th class="taC" colspan="2">费用说明</th>
  12509. </tr>
  12510. <tr>
  12511. <td colspan="2">' . $loanList ['explanation'] . '</td>
  12512. </tr>
  12513. <tr class="warning">
  12514. <td class="taR"><b>(' . $loanList ['receiptOrder'] . ')本次费用合计</b></td>
  12515. <td class="taR"><b style="font-size: 24px">¥' . $loanList ['sum'] . '</b><br>' . $loanList ['sumCN'] . '</td>
  12516. </tr>
  12517. </tbody>
  12518. </table>
  12519. ';
  12520. if ( $accountType==2) {
  12521. $balance=$detail ['sum']-$loanList ['sum'];
  12522. $balanceCN=$this->num_to_rmb($balance);
  12523. $html .= '<table class="table table-bordered table-condensed">
  12524. <tbody>
  12525. <tr>
  12526. <th colspan="2" class="taC">日常相关费用</th>
  12527. </tr>';
  12528. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12529. $html .= '
  12530. <tr>
  12531. <th>' . $value ['name'] . '</th>
  12532. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12533. </tr>';
  12534. }
  12535. $html .= '
  12536. <tr>
  12537. <th class="taR">合计</th>
  12538. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12539. </tr>';
  12540. $html .= '<tr>
  12541. <th colspan="2" class="taC">差旅相关费用</th>
  12542. </tr>';
  12543. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12544. $html .= '
  12545. <tr>
  12546. <th>' . $value ['name'] . '</th>
  12547. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12548. </tr>';
  12549. }
  12550. $html .= '
  12551. <tr>
  12552. <th class="taR">合计</th>
  12553. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12554. </tr>';
  12555. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12556. $html .= '<tr>
  12557. <th colspan="2" class="taC">内部培训费用</th>
  12558. </tr>';
  12559. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12560. $html .= '
  12561. <tr>
  12562. <th>' . $value ['name'] . '</th>
  12563. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12564. </tr>';
  12565. }
  12566. $html .= '
  12567. <tr>
  12568. <th class="taR">合计</th>
  12569. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12570. </tr>';
  12571. }
  12572. $html .= '<tr>
  12573. <th colspan="2" class="taC">其他</th>
  12574. </tr>';
  12575. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12576. $html .= '
  12577. <tr>
  12578. <th>' . $value ['name'] . '</th>
  12579. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12580. </tr>';
  12581. }
  12582. $html .= '
  12583. <tr>
  12584. <th class="taR">合计</th>
  12585. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12586. </tr>';
  12587. $html .= '<tr>
  12588. <th colspan="2" class="taC">报销金额调整</th>
  12589. </tr>';
  12590. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12591. $html .= '
  12592. <tr>
  12593. <th>' . $value ['name'] . '</th>
  12594. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12595. </tr>';
  12596. }
  12597. $html .= '
  12598. <tr>
  12599. <th class="taR">合计</th>
  12600. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12601. </tr>';
  12602. $html .= '
  12603. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12604. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12605. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12606. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12607. <tr class="warning">
  12608. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12609. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12610. </tr>
  12611. <tr class="success">
  12612. <td class="taR"><b>借款结余</b></td>
  12613. <td class="taR"><b style="font-size:24px">¥'.$balance.'</b><br>'.$balanceCN.'</td>
  12614. </tr>
  12615. </tbody>
  12616. </table>';
  12617. }
  12618. }
  12619. return $html;
  12620. }
  12621. /**
  12622. * 计算流水
  12623. */
  12624. function getWasteBookStatistics($waste = array(), $inComeStatistics) {
  12625. $bakWaste ['bank'] = array (
  12626. 'CGBDeposit' => 0,
  12627. 'ICBCDeposit' => 0,
  12628. 'HUADeposit' => 0,
  12629. 'PersonalDeposit' => 0
  12630. );
  12631. $bakWaste ['financial'] = array (
  12632. 'current' => array (
  12633. 'CGBDeposit' => 0,
  12634. 'ICBCDeposit' => 0
  12635. ),
  12636. 'fixed' => array (
  12637. 'CGBDeposit' => 0,
  12638. 'ICBCDeposit' => 0
  12639. )
  12640. );
  12641. // 存款
  12642. foreach ( $waste ['bank'] as $key => $value ) {
  12643. // 收入
  12644. foreach ( $inComeStatistics ['incomeStatistics'] as $k => $v ) {
  12645. // 广发
  12646. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12647. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12648. }
  12649. // 工商
  12650. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12651. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12652. }
  12653. // 华润
  12654. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12655. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12656. }
  12657. // 个人
  12658. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12659. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12660. }
  12661. }
  12662. }
  12663. foreach ( $waste ['bank'] as $key => $value ) {
  12664. // 支出
  12665. foreach ( $inComeStatistics ['expenditureStatistics'] as $k => $v ) {
  12666. // 广发
  12667. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12668. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12669. }
  12670. // 工商
  12671. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12672. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12673. }
  12674. // 华润
  12675. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12676. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12677. }
  12678. // 个人
  12679. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12680. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12681. }
  12682. }
  12683. }
  12684. // 活期
  12685. foreach ( $waste ['financial'] ['current'] as $key => $value ) {
  12686. foreach ( $inComeStatistics ['currentStatistics'] as $k => $v ) {
  12687. // 广发
  12688. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12689. $waste ['financial'] ['current'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  12690. }
  12691. // 工商
  12692. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12693. $waste ['financial'] ['current'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  12694. }
  12695. // 个人
  12696. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12697. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  12698. }
  12699. }
  12700. }
  12701. // print_r($inComeStatistics ['fixedStatistics']);
  12702. // 固期
  12703. foreach ( $waste ['financial'] ['fixed'] as $key => $value ) {
  12704. foreach ( $inComeStatistics ['fixedStatistics'] as $k => $v ) {
  12705. // 广发
  12706. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12707. $waste ['financial'] ['fixed'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  12708. }
  12709. // 工商
  12710. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12711. $waste ['financial'] ['fixed'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  12712. }
  12713. // 个人
  12714. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12715. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  12716. }
  12717. }
  12718. }
  12719. return $waste;
  12720. }
  12721. function lyt() {
  12722. Doo::loadModel ( "receiptDetail" );
  12723. $receiptDetail = new receiptDetail ();
  12724. $receiptCollectList = $receiptDetail->find ( array (
  12725. 'where' => 'status=1 ',
  12726. 'asArray' => true
  12727. ) );
  12728. foreach ( $receiptCollectList as $key => $value ) {
  12729. $receiptDetail = new receiptDetail ();
  12730. $receiptDetail->pastDate = $value ['date'];
  12731. $receiptDetail->update ( array (
  12732. 'where' => "rdid= '" . $value ['rdid'] . "'"
  12733. ) );
  12734. }
  12735. }
  12736. function staffCollectMonthDetail() {
  12737. //include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  12738. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12739. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12740. if (! $year)
  12741. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12742. if (! $month)
  12743. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12744. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  12745. if (! $nature){
  12746. $nature = isset ( $this->params ['nature'] ) ? $this->params ['nature'] : 'ONJOB';
  12747. }
  12748. Doo::loadModel ( 'staff' );
  12749. $staff = new staff ();
  12750. Doo::loadModel ( "receiptDetail" );
  12751. $receiptDetail = new receiptDetail ();
  12752. Doo::loadModel ( 'accountItem' );
  12753. $accountItem = new accountItem ();
  12754. Doo::loadModel ( 'statistics' );
  12755. $statistics = new statistics ();
  12756. Doo::loadModel ( "receiptAuthorityManage" );
  12757. $receiptAuthorityManage = new receiptAuthorityManage ();
  12758. $aiList=$accountItem->getAccountItem();
  12759. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  12760. $cidList = array ();
  12761. foreach ( $imcStaff as $key => $value ) {
  12762. array_push ( $cidList, $value ['cid'] );
  12763. }
  12764. $cidString = implode ( ',', $cidList );
  12765. $naturecon='';
  12766. if ($nature=='ONJOB'){
  12767. $naturecon=' and (nature!=4 )';
  12768. }elseif($nature=='LEAVEJOB'){
  12769. $naturecon=' and (nature=4 )';
  12770. }else{
  12771. die ( 'illegal request--nature' );
  12772. }
  12773. $staffList = $staff->find ( array (
  12774. 'where' => 'username!="admin" and cid in (' . $cidString . ')'.$naturecon,
  12775. 'asArray' => true
  12776. ) );
  12777. $categoryList = $staff->find ( array (
  12778. 'select' => 'COUNT(*) as count,cid,category',
  12779. 'where' => 'username !="admin" and cid in (' . $cidString . ')'.$naturecon,
  12780. 'groupby' => 'cid',
  12781. 'asArray' => true
  12782. ) );
  12783. $list = array ();
  12784. foreach($aiList as $key=>$value){
  12785. foreach ($value as $v){
  12786. $subtotal[$key][$v['name']]=0;
  12787. }
  12788. }
  12789. foreach ( $categoryList as $vlu ) {
  12790. $s1 = 0;
  12791. $m1 = 0;
  12792. $subtotal[$this->AGENCY]['AGENCY']=$subtotal[$this->TRAVEL]['TRAVEL']=$subtotal[$this->INTTRAIN]['INTTRAIN']=$subtotal[$this->TRAIN]['TRAIN']=$subtotal[$this->OTHER]['OTHER']=0;
  12793. foreach ( $staffList as $value ) {
  12794. if ($vlu ['cid'] == $value ['cid']) {
  12795. // pastDate
  12796. $receiptCollectList = $receiptDetail->find ( array (
  12797. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12798. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12799. 'groupby' => 'item,Month(pastDate),itemCategory',
  12800. 'asArray' => true
  12801. ) );
  12802. if (! empty ( $receiptCollectList )) {
  12803. $receiptL = array (
  12804. '日常相关费用' => array (),
  12805. '差旅相关费用' => array (),
  12806. '内部培训费用' => array (),
  12807. '培训班费用' => array (),
  12808. '其他' => array ()
  12809. );
  12810. $html = "";
  12811. $psum = 0;
  12812. foreach ( $aiList[$this->AGENCY] as $va ) {
  12813. $falg = true;
  12814. foreach ( $receiptCollectList as $v ) {
  12815. if ($v ['itemCategory'] == '日常相关费用') {
  12816. if ($v ['item'] == $va['name']) {
  12817. $subtotal[$this->AGENCY][$va['name']]+=$v ['price'];
  12818. $psum += $v ['price'];
  12819. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12820. $falg = false;
  12821. break;
  12822. }
  12823. }
  12824. }
  12825. if ($falg)
  12826. $html .= '<td class="taR">-</td>';
  12827. }
  12828. $subtotal[$this->AGENCY]['AGENCY'] += $psum;
  12829. if (! empty ( $psum ))
  12830. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12831. else
  12832. $psum = '<td class="colGreen taR">-</td>';
  12833. $receiptL ['日常相关费用'] = $psum . $html;
  12834. /* ----------------------------------- */
  12835. $html = "";
  12836. $psum = 0;
  12837. foreach ( $aiList[$this->TRAVEL] as $va ) {
  12838. $falg = true;
  12839. foreach ( $receiptCollectList as $v ) {
  12840. if ($v ['itemCategory'] == '差旅相关费用') {
  12841. if ($v ['item'] == $va['name']) {
  12842. $subtotal[$this->TRAVEL][$va['name']]+=$v ['price'];
  12843. $psum += $v ['price'];
  12844. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12845. $falg = false;
  12846. break;
  12847. }
  12848. }
  12849. }
  12850. if ($falg)
  12851. $html .= '<td class="taR">-</td>';
  12852. }
  12853. $subtotal[$this->TRAVEL]['TRAVEL'] += $psum;
  12854. if (! empty ( $psum ))
  12855. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12856. else
  12857. $psum = '<td class="colGreen taR">-</td>';
  12858. $receiptL ['差旅相关费用'] = $psum . $html;
  12859. /* ------------------------------------- */
  12860. $html = "";
  12861. $psum = 0;
  12862. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  12863. $falg = true;
  12864. foreach ( $receiptCollectList as $v ) {
  12865. if ($v ['itemCategory'] == '内部培训费用') {
  12866. if ($v ['item'] == $va['name']) {
  12867. $subtotal[$this->INTTRAIN][$va['name']]+=$v ['price'];
  12868. $psum += $v ['price'];
  12869. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12870. $falg = false;
  12871. break;
  12872. }
  12873. }
  12874. }
  12875. if ($falg)
  12876. $html .= '<td class="taR">-</td>';
  12877. }
  12878. $subtotal[$this->INTTRAIN]['INTTRAIN'] += $psum;
  12879. if (! empty ( $psum ))
  12880. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12881. else
  12882. $psum = '<td class="colGreen taR">-</td>';
  12883. $receiptL ['内部培训费用'] = $psum . $html;
  12884. /* ----------------------------------- */
  12885. $html = "";
  12886. $psum = 0;
  12887. foreach ( $aiList[$this->TRAIN] as $va ) {
  12888. $falg = true;
  12889. foreach ( $receiptCollectList as $v ) {
  12890. if ($v ['itemCategory'] == '培训班费用') {
  12891. if ($v ['item'] == $va['name']) {
  12892. $subtotal[$this->TRAIN][$va['name']]+=$v ['price'];
  12893. $psum += $v ['price'];
  12894. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12895. $falg = false;
  12896. break;
  12897. }
  12898. }
  12899. }
  12900. if ($falg)
  12901. $html .= '<td class="taR">-</td>';
  12902. }
  12903. $subtotal[$this->TRAIN]['TRAIN'] += $psum;
  12904. if (! empty ( $psum ))
  12905. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12906. else
  12907. $psum = '<td class="colGreen taR">-</td>';
  12908. $receiptL ['培训班费用'] = $psum . $html;
  12909. /* ------------------------------------- */
  12910. $html = "";
  12911. $psum = 0;
  12912. foreach ( $aiList[$this->OTHER] as $va ) {
  12913. $falg = true;
  12914. foreach ( $receiptCollectList as $v ) {
  12915. if ($v ['itemCategory'] == '其他') {
  12916. if (trim ( $v ['item'] ) == $va['name']) {
  12917. $subtotal[$this->OTHER][$va['name']]+=$v ['price'];
  12918. $psum += $v ['price'];
  12919. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12920. $falg = false;
  12921. break;
  12922. }
  12923. }
  12924. }
  12925. if ($falg)
  12926. $html .= '<td class="taR">-</td>';
  12927. }
  12928. $subtotal[$this->OTHER]['OTHER'] += $psum;
  12929. if (! empty ( $psum ))
  12930. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12931. else
  12932. $psum = '<td class="colGreen taR">-</td>';
  12933. $receiptL ['其他'] = $psum . $html;
  12934. /* ------------------------------------- */
  12935. $html = "";
  12936. $psum = 0;
  12937. foreach ( $receiptCollectList as $v ) {
  12938. if ($v ['itemCategory'] == '报销金额调整') {
  12939. if (! empty ( $v ['price'] )) {
  12940. $psum += $v ['price'];
  12941. }
  12942. }
  12943. }
  12944. $s1 += $psum;
  12945. if (! empty ( $psum ))
  12946. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  12947. else
  12948. $psum = '<td class="taR colOrange">-</td>';
  12949. $receiptL ['报销金额调整'] = $psum . $html;
  12950. } else {
  12951. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  12952. foreach ( $aiList[$this->AGENCY] as $va ) {
  12953. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  12954. }
  12955. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  12956. foreach ( $aiList[$this->TRAVEL] as $va ) {
  12957. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  12958. }
  12959. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  12960. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  12961. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  12962. }
  12963. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  12964. foreach ( $aiList[$this->TRAIN] as $va ) {
  12965. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  12966. }
  12967. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  12968. foreach ( $aiList[$this->OTHER] as $va ) {
  12969. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  12970. }
  12971. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  12972. }
  12973. $monthStaffPrice = $receiptDetail->find ( array (
  12974. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12975. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12976. 'groupby' => 'Month(pastDate)',
  12977. 'asArray' => true
  12978. ) );
  12979. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  12980. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  12981. $m1 += $monthStaffPrice [0] ['price'];
  12982. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  12983. } else
  12984. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  12985. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  12986. $list [$value ['username']] = $receiptL;
  12987. }
  12988. }
  12989. $receiptL [$this->AGENCY] ='<td class="colGreen taR">'.$subtotal[$this->AGENCY]['AGENCY'].'</td>';
  12990. foreach ( $aiList[$this->AGENCY] as $va ) {
  12991. $receiptL [$this->AGENCY] .='<td class="taR">' . $subtotal[$this->AGENCY][$va['name']] . '</td>';
  12992. $subtotal[$this->AGENCY][$va['name']]=0;
  12993. }
  12994. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">'.$subtotal[$this->TRAVEL]['TRAVEL'].'</td>';
  12995. foreach ( $aiList[$this->TRAVEL] as $va ) {
  12996. $receiptL [$this->TRAVEL] .='<td class="taR">' . $subtotal[$this->TRAVEL][$va['name']] . '</td>';
  12997. $subtotal[$this->TRAVEL][$va['name']]=0;
  12998. }
  12999. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">'.$subtotal[$this->INTTRAIN]['INTTRAIN'].'</td>';
  13000. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13001. $receiptL [$this->INTTRAIN] .='<td class="taR">' . $subtotal[$this->INTTRAIN][$va['name']] . '</td>';
  13002. $subtotal[$this->INTTRAIN][$va['name']]=0;
  13003. }
  13004. $receiptL [$this->TRAIN] ='<td class="colGreen taR">'.$subtotal[$this->TRAIN]['TRAIN'].'</td>';
  13005. foreach ( $aiList[$this->TRAIN] as $va ) {
  13006. $receiptL [$this->TRAIN] .='<td class="taR">' . $subtotal[$this->TRAIN][$va['name']] . '</td>';
  13007. $subtotal[$this->TRAIN][$va['name']]=0;
  13008. }
  13009. $receiptL [$this->OTHER] ='<td class="colGreen taR">'.$subtotal[$this->OTHER]['OTHER'].'</td>';
  13010. foreach ( $aiList[$this->OTHER] as $va ) {
  13011. $receiptL [$this->OTHER] .='<td class="taR">' . $subtotal[$this->OTHER][$va['name']] . '</td>';
  13012. $subtotal[$this->OTHER][$va['name']]=0;
  13013. }
  13014. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  13015. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  13016. $receiptL ['usernameEn'] =false;
  13017. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  13018. }
  13019. $data ['list'] = $list;
  13020. // print_r($list);
  13021. $receiptCollectList = $receiptDetail->find ( array (
  13022. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13023. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13024. 'groupby' => 'item,Month(pastDate),itemCategory',
  13025. 'asArray' => true
  13026. ) );
  13027. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  13028. // statistics html
  13029. $stList = $statistics->getOne ( array (
  13030. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13031. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13032. 'groupby' => 'Month(date)',
  13033. 'asArray' => true
  13034. ) );
  13035. if (empty ( $stList ))
  13036. $stList = array (
  13037. 'rePrice' => 0,
  13038. 'agPrice' => 0
  13039. );
  13040. $data ['stList'] = array (
  13041. 'rePrice' => $stList ['rePrice'],
  13042. 'agPrice' => $stList ['agPrice'],
  13043. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13044. );
  13045. $monthHtml = "";
  13046. for($i = 1; $i <= 12; $i ++) {
  13047. if ($i == $month)
  13048. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13049. else
  13050. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13051. }
  13052. $data ['monthHtml'] = $monthHtml;
  13053. $data ['year'] = $year;
  13054. $data ['month'] = $month;
  13055. $data ['nature'] = $nature;
  13056. $data ['aiList'] = $aiList;
  13057. $data ['memu'] = "receipt";
  13058. $data ['staff'] = $this->staff;
  13059. $data ['receiptMemu'] = 'companyCategoryCollect';
  13060. $data ['verifyId'] = $this->verifyId;
  13061. $data ['executeId'] = $this->executeId;
  13062. $this->render ( "/admin/staffCollectMonthDetail", $data );
  13063. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13064. }
  13065. function staffCollectMonthDetail2() {
  13066. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13067. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13068. if (! $year)
  13069. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13070. if (! $month)
  13071. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13072. Doo::loadModel ( 'staff' );
  13073. $staff = new staff ();
  13074. Doo::loadModel ( "receiptDetail" );
  13075. $receiptDetail = new receiptDetail ();
  13076. Doo::loadModel ( 'accountItem' );
  13077. $accountItem = new accountItem ();
  13078. Doo::loadModel ( 'statistics' );
  13079. $statistics = new statistics ();
  13080. Doo::loadModel ( 'L_category' );
  13081. $lCategory = new L_category ();
  13082. $staffList = $staff->find ( array (
  13083. 'where' => 'username!="admin"',
  13084. 'asArray' => true
  13085. ) );
  13086. $categoryList = $staff->find ( array (
  13087. 'select' => 'COUNT(*) as count,cid,category',
  13088. 'where' => 'username !="admin"',
  13089. 'groupby' => 'cid',
  13090. 'asArray' => true
  13091. ) );
  13092. $list = array ();
  13093. foreach ( $categoryList as $vlu ) {
  13094. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  13095. $r1 = 0;
  13096. $r2 = 0;
  13097. $r3 = 0;
  13098. $r4 = 0;
  13099. $r5 = 0;
  13100. $r6 = 0;
  13101. $r7 = 0;
  13102. $r8 = 0;
  13103. $r9 = 0;
  13104. $r10 = 0;
  13105. $r11 = 0;
  13106. $r12 = 0;
  13107. $r13 = 0;
  13108. $r14 = 0;
  13109. $r15 = 0;
  13110. $c1 = 0;
  13111. $c2 = 0;
  13112. $c3 = 0;
  13113. $c4 = 0;
  13114. $c5 = 0;
  13115. $c6 = 0;
  13116. $p1 = 0;
  13117. $p2 = 0;
  13118. $p3 = 0;
  13119. $p4 = 0;
  13120. $p5 = 0;
  13121. $p6 = 0;
  13122. $p7 = 0;
  13123. $p8 = 0;
  13124. $p9 = 0;
  13125. $t1 = 0;
  13126. $t2 = 0;
  13127. $t3 = 0;
  13128. $t4 = 0;
  13129. $t5 = 0;
  13130. $s1 = 0;
  13131. $m1 = 0;
  13132. foreach ( $staffList as $value ) {
  13133. if ($vlu ['cid'] == $value ['cid']) {
  13134. $receiptCollectList = $receiptDetail->find ( array (
  13135. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13136. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13137. 'groupby' => 'item,Month(date),itemCategory',
  13138. 'asArray' => true
  13139. ) );
  13140. if (! empty ( $receiptCollectList )) {
  13141. $receiptL = array (
  13142. '日常相关费用' => array (),
  13143. '差旅相关费用' => array (),
  13144. '培训班费用' => array (),
  13145. '其他' => array ()
  13146. );
  13147. $html = "";
  13148. $psum = 0;
  13149. $item = array (
  13150. '市内交通费',
  13151. '市内出租费',
  13152. '办事处房租',
  13153. '电话费',
  13154. '水费',
  13155. '电费',
  13156. '办公费用',
  13157. '邮寄费',
  13158. '其他费用',
  13159. '车辆费用',
  13160. '广告费',
  13161. '团队建设费',
  13162. '物业管理费',
  13163. '宽带费'
  13164. );
  13165. foreach ( $item as $va ) {
  13166. $falg = true;
  13167. foreach ( $receiptCollectList as $v ) {
  13168. if ($v ['itemCategory'] == '日常相关费用') {
  13169. if ($v ['item'] == $va) {
  13170. if ($va == '市内交通费')
  13171. $r1 += $v ['price'];
  13172. if ($va == '市内出租费')
  13173. $r2 += $v ['price'];
  13174. if ($va == '办事处房租')
  13175. $r3 += $v ['price'];
  13176. if ($va == '电话费')
  13177. $r4 += $v ['price'];
  13178. if ($va == '水费')
  13179. $r5 += $v ['price'];
  13180. if ($va == '电费')
  13181. $r6 += $v ['price'];
  13182. if ($va == '办公费用')
  13183. $r7 += $v ['price'];
  13184. if ($va == '邮寄费')
  13185. $r8 += $v ['price'];
  13186. if ($va == '其他费用')
  13187. $r9 += $v ['price'];
  13188. if ($va == '车辆费用')
  13189. $r10 += $v ['price'];
  13190. if ($va == '广告费')
  13191. $r11 += $v ['price'];
  13192. if ($va == '团队建设费')
  13193. $r13 += $v ['price'];
  13194. if ($va == '物业管理费')
  13195. $r14 += $v ['price'];
  13196. if ($va == '宽带费')
  13197. $r15 += $v ['price'];
  13198. $psum += $v ['price'];
  13199. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13200. $falg = false;
  13201. break;
  13202. }
  13203. }
  13204. }
  13205. if ($falg)
  13206. $html .= '<td class="taR">-</td>';
  13207. }
  13208. $r12 += $psum;
  13209. if (! empty ( $psum ))
  13210. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13211. else
  13212. $psum = '<td class="colGreen taR">-</td>';
  13213. $receiptL ['日常相关费用'] = $psum . $html;
  13214. /* ----------------------------------- */
  13215. $html = "";
  13216. $psum = 0;
  13217. $item = array (
  13218. '往来交通费',
  13219. '市内交通费',
  13220. '出差住宿费',
  13221. '出差补助',
  13222. '其他费用'
  13223. );
  13224. foreach ( $item as $va ) {
  13225. $falg = true;
  13226. foreach ( $receiptCollectList as $v ) {
  13227. if ($v ['itemCategory'] == '差旅相关费用') {
  13228. if ($v ['item'] == $va) {
  13229. if ($va == '往来交通费')
  13230. $c1 += $v ['price'];
  13231. if ($va == '市内交通费')
  13232. $c2 += $v ['price'];
  13233. if ($va == '出差住宿费')
  13234. $c3 += $v ['price'];
  13235. if ($va == '出差补助')
  13236. $c4 += $v ['price'];
  13237. if ($va == '其他费用')
  13238. $c5 += $v ['price'];
  13239. $psum += $v ['price'];
  13240. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13241. $falg = false;
  13242. break;
  13243. }
  13244. }
  13245. }
  13246. if ($falg)
  13247. $html .= '<td class="taR">-</td>';
  13248. }
  13249. $c6 += $psum;
  13250. if (! empty ( $psum ))
  13251. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13252. else
  13253. $psum = '<td class="colGreen taR">-</td>';
  13254. $receiptL ['差旅相关费用'] = $psum . $html;
  13255. /* ------------------------------------- */
  13256. $html = "";
  13257. $psum = 0;
  13258. $item = array (
  13259. '场租费',
  13260. '薪酬',
  13261. '住宿费',
  13262. '交通费',
  13263. '餐饮费',
  13264. '办公费',
  13265. '公关费',
  13266. '其他'
  13267. );
  13268. foreach ( $item as $va ) {
  13269. $falg = true;
  13270. foreach ( $receiptCollectList as $v ) {
  13271. if ($v ['itemCategory'] == '培训班费用') {
  13272. if ($v ['item'] == $va) {
  13273. if ($va == '场租费')
  13274. $p1 += $v ['price'];
  13275. if ($va == '薪酬')
  13276. $p2 += $v ['price'];
  13277. if ($va == '住宿费')
  13278. $p3 += $v ['price'];
  13279. if ($va == '交通费')
  13280. $p4 += $v ['price'];
  13281. if ($va == '餐饮费')
  13282. $p5 += $v ['price'];
  13283. if ($va == '办公费')
  13284. $p6 += $v ['price'];
  13285. if ($va == '公关费')
  13286. $p7 += $v ['price'];
  13287. if ($va == '其他')
  13288. $p8 += $v ['price'];
  13289. $psum += $v ['price'];
  13290. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13291. $falg = false;
  13292. break;
  13293. }
  13294. }
  13295. }
  13296. if ($falg)
  13297. $html .= '<td class="taR">-</td>';
  13298. }
  13299. $p9 += $psum;
  13300. if (! empty ( $psum ))
  13301. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13302. else
  13303. $psum = '<td class="colGreen taR">-</td>';
  13304. $receiptL ['培训班费用'] = $psum . $html;
  13305. /* ------------------------------------- */
  13306. $html = "";
  13307. $psum = 0;
  13308. $item = array (
  13309. '公关费',
  13310. '广告费',
  13311. '借款',
  13312. '可自加费用'
  13313. );
  13314. foreach ( $item as $va ) {
  13315. $falg = true;
  13316. foreach ( $receiptCollectList as $v ) {
  13317. if ($v ['itemCategory'] == '其他') {
  13318. if ($v ['item'] == $va) {
  13319. if ($va == '公关费')
  13320. $t1 += $v ['price'];
  13321. if ($va == '广告费')
  13322. $t2 += $v ['price'];
  13323. if ($va == '借款')
  13324. $t3 += $v ['price'];
  13325. if ($va == '可自加费用')
  13326. $t4 += $v ['price'];
  13327. $psum += $v ['price'];
  13328. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13329. $falg = false;
  13330. break;
  13331. }
  13332. }
  13333. }
  13334. if ($falg)
  13335. $html .= '<td class="taR">-</td>';
  13336. }
  13337. $t5 += $psum;
  13338. if (! empty ( $psum ))
  13339. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13340. else
  13341. $psum = '<td class="colGreen taR">-</td>';
  13342. $receiptL ['其他'] = $psum . $html;
  13343. /* ------------------------------------- */
  13344. $html = "";
  13345. $psum = 0;
  13346. foreach ( $receiptCollectList as $v ) {
  13347. if ($v ['itemCategory'] == '报销金额调整') {
  13348. if (! empty ( $v ['price'] )) {
  13349. $psum += $v ['price'];
  13350. }
  13351. }
  13352. }
  13353. $s1 += $psum;
  13354. if (! empty ( $psum ))
  13355. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  13356. else
  13357. $psum = '<td class="taR colOrange">-</td>';
  13358. $receiptL ['报销金额调整'] = $psum . $html;
  13359. } else {
  13360. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13361. <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>';
  13362. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  13363. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13364. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13365. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13366. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13367. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13368. }
  13369. $monthStaffPrice = $receiptDetail->find ( array (
  13370. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13371. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13372. 'asArray' => true
  13373. ) );
  13374. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  13375. $m1 += $monthStaffPrice [0] ['price'];
  13376. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13377. } else
  13378. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13379. $list [$value ['username']] = $receiptL;
  13380. }
  13381. }
  13382. $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>
  13383. <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>
  13384. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  13385. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  13386. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  13387. $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>
  13388. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  13389. $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>';
  13390. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  13391. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  13392. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  13393. }
  13394. $data ['list'] = $list;
  13395. $receiptCollectList = $receiptDetail->find ( array (
  13396. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13397. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13398. 'groupby' => 'item,Month(date),itemCategory',
  13399. 'asArray' => true
  13400. ) );
  13401. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  13402. // statistics html
  13403. $stList = $statistics->getOne ( array (
  13404. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13405. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13406. 'groupby' => 'Month(date)',
  13407. 'asArray' => true
  13408. ) );
  13409. if (empty ( $stList ))
  13410. $stList = array (
  13411. 'rePrice' => 0,
  13412. 'agPrice' => 0
  13413. );
  13414. $data ['stList'] = array (
  13415. 'rePrice' => $stList ['rePrice'],
  13416. 'agPrice' => $stList ['agPrice'],
  13417. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13418. );
  13419. $monthHtml = "";
  13420. for($i = 1; $i <= 12; $i ++) {
  13421. if ($i == $month)
  13422. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13423. else
  13424. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13425. }
  13426. $data ['monthHtml'] = $monthHtml;
  13427. $data ['year'] = $year;
  13428. $data ['month'] = $month;
  13429. $data ['memu'] = "receipt";
  13430. $data ['staff'] = $this->staff;
  13431. $data ['receiptMemu'] = 'companyCategoryCollect';
  13432. $data ['verifyId'] = $this->verifyId;
  13433. $data ['executeId'] = $this->executeId;
  13434. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  13435. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13436. }
  13437. /**
  13438. * 用户报销单列表
  13439. */
  13440. function receiptStatisticsStaffDetail() {
  13441. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13442. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13443. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13444. Doo::loadModel ( "receipt" );
  13445. $receipt = new receipt ();
  13446. Doo::loadModel ( "receiptDetail" );
  13447. $receiptDetail = new receiptDetail ();
  13448. Doo::loadModel ( 'staff' );
  13449. $staff = new staff ();
  13450. Doo::loadModel ( 'accountItem' );
  13451. $accountItem = new accountItem ();
  13452. Doo::loadModel ( 'statistics' );
  13453. $statistics = new statistics ();
  13454. if (! empty ( $username )) {
  13455. $username = addslashes ( urldecode ( $username ) );
  13456. $staffDetail = $staff->getStaffByName ( $username );
  13457. if (empty ( $staffDetail ))
  13458. die ( 'illegal request' );
  13459. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  13460. $itemList = $accountItem->getAccountItem ();
  13461. $itemHtml = '';
  13462. $categoryHtml = '';
  13463. $itemKeyList = array_keys ( $itemList );
  13464. $revisePrice = 0;
  13465. // 报销单内容详情
  13466. foreach ( $list as $key => $value ) {
  13467. $accountItemList = json_decode ( $value ['accountItem'], true );
  13468. $list [$key] ['accountItemList'] = $accountItemList;
  13469. $receiptItemHtml = '';
  13470. foreach ( $itemKeyList as $v ) {
  13471. if ($v == '日常相关费用')
  13472. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  13473. elseif ($v == '差旅相关费用')
  13474. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  13475. elseif ($v == '培训班费用')
  13476. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  13477. elseif ($v == '内部培训费用'){
  13478. if (isset($accountItemList ['cSum'] ['inttrainSum'])){
  13479. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['inttrainSum'] . '</td>';
  13480. }else{
  13481. $receiptItemHtml .= '<td class="colGreen taR">0</td>';
  13482. }
  13483. }elseif ($v == '其他')
  13484. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  13485. foreach ( $itemList [$v] as $ke => $va ) {
  13486. $falg = true;
  13487. if (! empty ( $accountItemList [$v] )) {
  13488. foreach ( $accountItemList [$v] as $ve ) {
  13489. if ($va ['name'] == $ve ['name']) {
  13490. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  13491. $falg = false;
  13492. break;
  13493. }
  13494. }
  13495. }
  13496. if ($falg)
  13497. $receiptItemHtml .= '<td class="taR"></td>';
  13498. }
  13499. }
  13500. // 金额调整和费用查看
  13501. $revisePrice += $value ['revisePrice'];
  13502. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  13503. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" id="sen'.$key.'" data="' . htmlspecialchars($value ['explanation']) . '" onclick=showExplanation() >查看</a></td>';
  13504. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  13505. }
  13506. // 报销单合计
  13507. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  13508. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  13509. $receiptTotalHtml = '';
  13510. // 报销单项目抬头
  13511. foreach ( $itemKeyList as $value ) {
  13512. $count = count ( $itemList [$value] ) + 1;
  13513. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  13514. $categoryHtml .= '<th class="taC">合计</th>';
  13515. $sumfalg=true;
  13516. foreach ( $rtl as $rtlValue ) {
  13517. if ($rtlValue ['itemCategory'] == $value) {
  13518. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  13519. $sumfalg=false;
  13520. break;
  13521. }
  13522. }
  13523. if ($sumfalg)
  13524. $receiptTotalHtml .= '<th></th>';
  13525. foreach ( $itemList [$value] as $k => $v ) {
  13526. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  13527. // 合计
  13528. $falg = true;
  13529. foreach ( $receiptTotalList as $ve ) {
  13530. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  13531. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  13532. $falg = false;
  13533. break;
  13534. }
  13535. }
  13536. if ($falg)
  13537. $receiptTotalHtml .= '<th></th>';
  13538. }
  13539. }
  13540. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  13541. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  13542. if (empty ( $stList ))
  13543. $stList = array (
  13544. 'rePrice' => 0,
  13545. 'agPrice' => 0
  13546. );
  13547. $data ['stList'] = array (
  13548. 'rePrice' => $stList ['rePrice'],
  13549. 'agPrice' => $stList ['agPrice'],
  13550. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13551. );
  13552. $monthHtml = "";
  13553. for($i = 1; $i <= 12; $i ++) {
  13554. if ($i == $month)
  13555. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13556. else
  13557. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13558. }
  13559. $data ['username'] = urlencode ( $username );
  13560. $data ['usernameEN'] = $username;
  13561. $data ['monthHtml'] = $monthHtml;
  13562. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  13563. $data ['list'] = $list;
  13564. $data ['categoryHtml'] = $categoryHtml;
  13565. $data ['itemHtml'] = $itemHtml;
  13566. $data ['itemList'] = $itemList;
  13567. $data ['year'] = $year;
  13568. $data ['month'] = $month;
  13569. $data ['memu'] = "receipt";
  13570. $data ['staff'] = $this->staff;
  13571. $data ['receiptMemu'] = 'companyCategoryCollect';
  13572. $data ['verifyId'] = $this->verifyId;
  13573. $data ['executeId'] = $this->executeId;
  13574. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  13575. }
  13576. die ( 'illegal request' );
  13577. }
  13578. function companyMonthCollectDetail() {
  13579. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13580. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13581. if (! $year)
  13582. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13583. if (! $month)
  13584. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13585. Doo::loadModel ( 'staff' );
  13586. $staff = new staff ();
  13587. Doo::loadModel ( "receiptDetail" );
  13588. $receiptDetail = new receiptDetail ();
  13589. Doo::loadModel ( 'accountItem' );
  13590. $accountItem = new accountItem ();
  13591. Doo::loadModel ( 'statistics' );
  13592. $statistics = new statistics ();
  13593. Doo::loadModel ( 'L_category' );
  13594. $lCategory = new L_category ();
  13595. $staffList = $staff->find ( array (
  13596. 'where' => 'username!="admin"',
  13597. 'asArray' => true
  13598. ) );
  13599. $categoryList = $lCategory->find ( array (
  13600. 'asArray' => true
  13601. ) );
  13602. $aiList=$accountItem->getAccountItem();
  13603. $list = array ();
  13604. foreach ( $categoryList as $value ) {
  13605. $receiptCollectList = $receiptDetail->find ( array (
  13606. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13607. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13608. 'groupby' => 'item,Month(pastDate),itemCategory',
  13609. 'asArray' => true
  13610. ) );
  13611. if (! empty ( $receiptCollectList )) {
  13612. $receiptL = array (
  13613. '日常相关费用' => array (),
  13614. '差旅相关费用' => array (),
  13615. '内部培训费用' => array (),
  13616. '培训班费用' => array (),
  13617. '其他' => array ()
  13618. );
  13619. $html = "";
  13620. $psum = 0;
  13621. foreach ( $aiList[$this->AGENCY] as $va ) {
  13622. $falg = true;
  13623. foreach ( $receiptCollectList as $v ) {
  13624. if ($v ['itemCategory'] == $this->AGENCY) {
  13625. if ($v ['item'] == $va['name']) {
  13626. $psum += $v ['price'];
  13627. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13628. $falg = false;
  13629. break;
  13630. }
  13631. }
  13632. }
  13633. if ($falg)
  13634. $html .= '<td class="taR">-</td>';
  13635. }
  13636. if (! empty ( $psum ))
  13637. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13638. else
  13639. $psum = '<td class="colGreen taR">-</td>';
  13640. $receiptL [$this->AGENCY] = $psum . $html;
  13641. /* ----------------------------------- */
  13642. $html = "";
  13643. $psum = 0;
  13644. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13645. $falg = true;
  13646. foreach ( $receiptCollectList as $v ) {
  13647. if ($v ['itemCategory'] == $this->TRAVEL) {
  13648. if ($v ['item'] == $va['name']) {
  13649. $psum += $v ['price'];
  13650. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13651. $falg = false;
  13652. break;
  13653. }
  13654. }
  13655. }
  13656. if ($falg)
  13657. $html .= '<td class="taR">-</td>';
  13658. }
  13659. if (! empty ( $psum ))
  13660. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13661. else
  13662. $psum = '<td class="colGreen taR">-</td>';
  13663. $receiptL [$this->TRAVEL] = $psum . $html;
  13664. /* ------------------------------------- */
  13665. $html = "";
  13666. $psum = 0;
  13667. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13668. $falg = true;
  13669. foreach ( $receiptCollectList as $v ) {
  13670. if ($v ['itemCategory'] == $this->INTTRAIN) {
  13671. if ($v ['item'] == $va['name']) {
  13672. $psum += $v ['price'];
  13673. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13674. $falg = false;
  13675. break;
  13676. }
  13677. }
  13678. }
  13679. if ($falg)
  13680. $html .= '<td class="taR">-</td>';
  13681. }
  13682. if (! empty ( $psum ))
  13683. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13684. else
  13685. $psum = '<td class="colGreen taR">-</td>';
  13686. $receiptL [$this->INTTRAIN] = $psum . $html;
  13687. /* ------------------------------------- */
  13688. $html = "";
  13689. $psum = 0;
  13690. foreach ( $aiList[$this->TRAIN] as $va ) {
  13691. $falg = true;
  13692. foreach ( $receiptCollectList as $v ) {
  13693. if ($v ['itemCategory'] == $this->TRAIN) {
  13694. if ($v ['item'] == $va['name']) {
  13695. $psum += $v ['price'];
  13696. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13697. $falg = false;
  13698. break;
  13699. }
  13700. }
  13701. }
  13702. if ($falg)
  13703. $html .= '<td class="taR">-</td>';
  13704. }
  13705. if (! empty ( $psum ))
  13706. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13707. else
  13708. $psum = '<td class="colGreen taR">-</td>';
  13709. $receiptL [$this->TRAIN] = $psum . $html;
  13710. /* ------------------------------------- */
  13711. $html = "";
  13712. $psum = 0;
  13713. foreach ( $aiList[$this->OTHER] as $va ) {
  13714. $falg = true;
  13715. foreach ( $receiptCollectList as $v ) {
  13716. if ($v ['itemCategory'] == $this->OTHER) {
  13717. if ($v ['item'] == $va['name']) {
  13718. $psum += $v ['price'];
  13719. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13720. $falg = false;
  13721. break;
  13722. }
  13723. }
  13724. }
  13725. if ($falg)
  13726. $html .= '<td class="taR">-</td>';
  13727. }
  13728. if (! empty ( $psum ))
  13729. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13730. else
  13731. $psum = '<td class="colGreen taR">-</td>';
  13732. $receiptL [$this->OTHER] = $psum . $html;
  13733. /* ------------------------------------- */
  13734. $html = "";
  13735. $psum = 0;
  13736. foreach ( $receiptCollectList as $v ) {
  13737. if ($v ['itemCategory'] == '报销金额调整') {
  13738. if (! empty ( $v ['price'] ))
  13739. $psum += $v ['price'];
  13740. }
  13741. }
  13742. if (! empty ( $psum ))
  13743. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  13744. else
  13745. $psum = '<td class="taR colOrange">-</td>';
  13746. $receiptL ['报销金额调整'] = $psum . $html;
  13747. } else {
  13748. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  13749. foreach ( $aiList[$this->AGENCY] as $va ) {
  13750. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  13751. }
  13752. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  13753. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13754. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  13755. }
  13756. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  13757. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13758. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  13759. }
  13760. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  13761. foreach ( $aiList[$this->TRAIN] as $va ) {
  13762. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  13763. }
  13764. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  13765. foreach ( $aiList[$this->OTHER] as $va ) {
  13766. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  13767. }
  13768. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13769. }
  13770. $monthStaffPrice = $receiptDetail->find ( array (
  13771. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13772. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13773. 'asArray' => true
  13774. ) );
  13775. if (! empty ( $monthStaffPrice [0] ['price'] ))
  13776. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13777. else
  13778. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13779. $list [$value ['title']] = $receiptL;
  13780. }
  13781. $data ['list'] = $list;
  13782. $receiptCollectList = $receiptDetail->find ( array (
  13783. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13784. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13785. 'groupby' => 'item,Month(pastDate),itemCategory',
  13786. 'asArray' => true
  13787. ) );
  13788. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  13789. //print_r($data['monthPriceHtml']);
  13790. // foreach ($data['monthPriceHtml'] as $value){
  13791. // echo $value;
  13792. // }
  13793. // die;
  13794. // statistics html
  13795. $stList = $statistics->getOne ( array (
  13796. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13797. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13798. 'groupby' => 'Month(date)',
  13799. 'asArray' => true
  13800. ) );
  13801. if (empty ( $stList ))
  13802. $stList = array (
  13803. 'rePrice' => 0,
  13804. 'agPrice' => 0
  13805. );
  13806. $data ['stList'] = array (
  13807. 'rePrice' => $stList ['rePrice'],
  13808. 'agPrice' => $stList ['agPrice'],
  13809. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13810. );
  13811. $monthHtml = "";
  13812. for($i = 1; $i <= 12; $i ++) {
  13813. if ($i == $month)
  13814. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13815. else
  13816. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13817. }
  13818. $data ['aiList'] = $aiList;
  13819. $dateHtml = "";
  13820. $now = date ( "Y" );
  13821. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  13822. if ($YEARD <= $now) {
  13823. $dateHtml .= '<option ';
  13824. if ($year == $YEARD) {
  13825. $dateHtml .= 'selected ';
  13826. }
  13827. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  13828. }
  13829. }
  13830. $data ['dateHtml'] = $dateHtml;
  13831. $data ['monthHtml'] = $monthHtml;
  13832. $data ['year'] = $year;
  13833. $data ['month'] = $month;
  13834. $data ['memu'] = "receipt";
  13835. $data ['staff'] = $this->staff;
  13836. $data ['receiptMemu'] = 'companyCategoryCollect';
  13837. $data ['verifyId'] = $this->verifyId;
  13838. $data ['executeId'] = $this->executeId;
  13839. $this->render ( "/admin/companyMonthCollectDetail", $data );
  13840. }
  13841. function staffCollectDetail() {
  13842. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  13843. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13844. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  13845. if (! $staffname) {
  13846. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  13847. $staffname = urldecode ( $staffname );
  13848. }
  13849. Doo::loadModel ( 'staff' );
  13850. $staff = new staff ();
  13851. Doo::loadModel ( "receiptDetail" );
  13852. $receiptDetail = new receiptDetail ();
  13853. Doo::loadModel ( 'accountItem' );
  13854. $accountItem = new accountItem ();
  13855. Doo::loadModel ( 'statistics' );
  13856. $statistics = new statistics ();
  13857. Doo::loadModel ( 'L_category' );
  13858. $lCategory = new L_category ();
  13859. Doo::loadModel ( "receiptAuthorityManage" );
  13860. $receiptAuthorityManage = new receiptAuthorityManage ();
  13861. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  13862. $cidList = array ();
  13863. foreach ( $imcStaff as $key => $value ) {
  13864. array_push ( $cidList, $value ['cid'] );
  13865. }
  13866. $cidString = implode ( ',', $cidList );
  13867. $staffList = $staff->find ( array (
  13868. 'where' => ' cid in (' . $cidString . ')',
  13869. 'asArray' => true
  13870. ) );
  13871. $stHtml = '';
  13872. $stTitle = "";
  13873. $staffId = 0;
  13874. $cid = 0;
  13875. $ocid = 0;
  13876. foreach ( $staffList as $value ) {
  13877. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  13878. $stTitle = $value ['category'] . '-' . $value ['username'];
  13879. $staffId = $value ['sid'];
  13880. $cid = $value ['cid'];
  13881. $ocid = $value ['cid'];
  13882. if (! empty ( $value ['othercid'] ))
  13883. $cid = $value ['cid'] . ',' . $value ['othercid'];
  13884. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13885. } elseif ($value ['username'] != 'admin')
  13886. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13887. }
  13888. $data ['lCategoryHtml'] = $lCategory->find ( array (
  13889. 'where' => 'cid in(' . $cid . ')',
  13890. 'asArray' => true
  13891. ) );
  13892. if (empty ( $pcid ))
  13893. $pcid = $ocid;
  13894. $data ['ocid'] = $pcid;
  13895. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  13896. $this->showCache ( $path );
  13897. //
  13898. $receiptCollectList = $receiptDetail->find ( array (
  13899. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13900. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  13901. 'groupby' => 'item,Month(pastDate),itemCategory',
  13902. 'asArray' => true
  13903. ) );
  13904. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  13905. // print_r($receiptCollectList);
  13906. $accountList = $accountItem->find ( array (
  13907. 'asArray' => true
  13908. ) );
  13909. // create CollectDetail HTML
  13910. $collectHtml = array ();
  13911. foreach ( $accountList as $key => $value ) {
  13912. $html = "";
  13913. $asum = 0;
  13914. for($i = 1; $i <= 12; $i ++) {
  13915. $falg = true;
  13916. foreach ( $receiptCollectList as $v ) {
  13917. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  13918. if ($v ['item'] == '可自加费用') {
  13919. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  13920. }
  13921. $asum += $v ['price'];
  13922. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13923. $falg = false;
  13924. break;
  13925. }
  13926. }
  13927. if ($falg)
  13928. $html .= '<td class="taR">-</td>';
  13929. }
  13930. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  13931. $collectHtml [$value ['category']] [$value ['name']] = $html;
  13932. }
  13933. $data ['collectHtml'] = $collectHtml;
  13934. // print_r($collectHtml);
  13935. // create Adjustment price html
  13936. $receiptCollectList = $receiptDetail->find ( array (
  13937. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  13938. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  13939. 'groupby' => 'itemCategory,Month(pastDate)',
  13940. 'asArray' => true
  13941. ) );
  13942. $adjustment = array ();
  13943. $collectArray = array (
  13944. '日常相关费用' => array (),
  13945. '差旅相关费用' => array (),
  13946. '培训班费用' => array (),
  13947. '内部培训费用'=>array(),
  13948. '其他' => array ()
  13949. );
  13950. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  13951. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  13952. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  13953. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  13954. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  13955. array_push ( $collectArray ['培训班费用'], $collectHtml );
  13956. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  13957. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  13958. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  13959. array_push ( $collectArray ['其他'], $collectHtml );
  13960. $data ['collectArray'] = $collectArray;
  13961. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  13962. array_push ( $adjustment, $collectHtml );
  13963. $data ['adjustment'] = $adjustment;
  13964. // total price html
  13965. $collectHtml = "";
  13966. $total = 0;
  13967. for($i = 1; $i <= 12; $i ++) {
  13968. $sumPrice = 0;
  13969. foreach ( $receiptCollectList as $key => $value ) {
  13970. if ($value ['month'] == $i) {
  13971. $sumPrice += $value ['price'];
  13972. }
  13973. }
  13974. if ($sumPrice == 0)
  13975. $collectHtml .= '<td class="taR">-</td>';
  13976. else
  13977. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  13978. $total += $sumPrice;
  13979. }
  13980. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  13981. // statistics html
  13982. $stList = $statistics->statisticsByYear ( $year, $staffId );
  13983. if (empty ( $stList ))
  13984. $stList = array (
  13985. 'rePrice' => 0,
  13986. 'agPrice' => 0
  13987. );
  13988. $data ['stList'] = array (
  13989. 'rePrice' => $stList ['rePrice'],
  13990. 'agPrice' => $stList ['agPrice'],
  13991. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13992. );
  13993. $data ['totalPrice'] = $collectHtml;
  13994. $data ['totalYear'] = $total;
  13995. $data ['stHtml'] = $stHtml;
  13996. $data ['year'] = $year;
  13997. $data ['stTitle'] = $stTitle;
  13998. $data ['staffname'] = urlencode ( $staffname );
  13999. $data ['memu'] = "receipt";
  14000. $data ['staff'] = $this->staff;
  14001. $data ['receiptMemu'] = 'companyCategoryCollect';
  14002. $data ['verifyId'] = $this->verifyId;
  14003. $data ['executeId'] = $this->executeId;
  14004. if ($year < date ( "Y" )) {
  14005. Doo::loadModel ( 'receipt' );
  14006. $receipt = new receipt ();
  14007. $receiptList = $receipt->find ( array (
  14008. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  14009. 'asArray' => true
  14010. ) );
  14011. if (empty ( $receiptList )) { // generated files
  14012. ob_start ();
  14013. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  14014. $this->cacheFile ( $path );
  14015. die ();
  14016. }
  14017. }
  14018. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  14019. }
  14020. function BUGFLAG() {
  14021. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  14022. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  14023. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  14024. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  14025. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  14026. if (empty ( $status ))
  14027. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  14028. $page_size = 12;
  14029. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  14030. $vidList = array ();
  14031. $button = 0;
  14032. Doo::loadModel ( 'verify' );
  14033. $verify = new verify ();
  14034. Doo::loadModel ( 'receipt' );
  14035. $receipt = new receipt ();
  14036. Doo::loadModel ( 'staff' );
  14037. $staff = new staff ();
  14038. Doo::loadModel ( 'L_category' );
  14039. $Lcategory = new L_category ();
  14040. $dateCondition = " and Year(date) =" . $year;
  14041. if (! empty ( $month ))
  14042. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  14043. $categoryList = $Lcategory->find ( array (
  14044. 'asArray' => true
  14045. ) );
  14046. $staffList = $staff->find ( array (
  14047. 'where' => 'cid=' . $cid,
  14048. 'asArray' => true
  14049. ) );
  14050. $cateCondition = "";
  14051. $staffCondition = "";
  14052. $approvalCondition = "";
  14053. if (! empty ( $cid ))
  14054. $cateCondition = ' and cid=' . $cid;
  14055. if (! empty ( $sid )) {
  14056. $staffCondition = ' and staff=' . $sid;
  14057. $cateCondition = "";
  14058. }
  14059. $approvalCondition = " and status=" . $status;
  14060. if ($status == 2) {
  14061. // 查找角色审批人
  14062. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  14063. }
  14064. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  14065. $approvalCondition = ' and status=2 ';
  14066. }
  14067. if ($status == 1) {
  14068. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  14069. }
  14070. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  14071. $pageinfo ['page'] = array (
  14072. 'previous' => ''
  14073. );
  14074. if ($status == 0) {
  14075. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  14076. $receiptList = $receipt->find ( array (
  14077. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  14078. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  14079. 'desc' => 'rid',
  14080. 'asArray' => true
  14081. ) );
  14082. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  14083. } else
  14084. $receiptList = $receipt->find ( array (
  14085. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  14086. 'desc' => 'rid',
  14087. 'asArray' => true
  14088. ) );
  14089. $rLRes = $receipt->find ( array (
  14090. '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,
  14091. 'desc' => 'rid',
  14092. 'asArray' => true
  14093. ) );
  14094. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  14095. // print_r($pageinfo);
  14096. $Locate = 0;
  14097. foreach ( $receiptList as $key => $value ) {
  14098. $receiptList [$key] ['Locate'] = $Locate;
  14099. $Locate ++;
  14100. $receiptList [$key] ['reviseDetail'] = array ();
  14101. if (! empty ( $value ['reviseDetail'] ))
  14102. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  14103. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  14104. $categoryDetil = $Lcategory->getOne ( array (
  14105. 'where' => 'cid=' . $value ['cid'],
  14106. 'asArray' => true
  14107. ) );
  14108. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  14109. $verifyList = $verify->getOne ( array (
  14110. 'where' => 'vid=' . $value ['verify'],
  14111. 'asArray' => true
  14112. ) );
  14113. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  14114. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  14115. foreach ( $verifyList as $k => $v ) {
  14116. // init verifyStaff
  14117. $verifyList [$k] ['date'] = "";
  14118. $verifyList [$k] ['opinion'] = "";
  14119. $verifyList [$k] ['status'] = "";
  14120. if (empty ( $verifyStaff )) {
  14121. $verifyList [$k] ['date'] = "";
  14122. $verifyList [$k] ['opinion'] = "";
  14123. if ($v [0] == $this->staff [0] ['sid']) {
  14124. $verifyList [$k] ['status'] = 4;
  14125. $button = 4;
  14126. }
  14127. } else {
  14128. $flag = true;
  14129. foreach ( $verifyStaff as $m => $u ) {
  14130. if ($v [0] == $m) {
  14131. $verifyList [$k] ['date'] = $u ['date'];
  14132. $verifyList [$k] ['opinion'] = $u ['opinion'];
  14133. $verifyList [$k] ['status'] = $u ['status'];
  14134. $flag = false;
  14135. break;
  14136. }
  14137. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  14138. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  14139. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  14140. }
  14141. if ($flag) { // 检测可编辑
  14142. if ($v [0] == $this->staff [0] ['sid']) {
  14143. $verifyList [$k] ['status'] = 4;
  14144. $button = 4;
  14145. }
  14146. }
  14147. }
  14148. }
  14149. $receiptList [$key] ['verifyList'] = $verifyList;
  14150. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  14151. 'where' => 'sid=' . $value ['staff'],
  14152. 'asArray' => true
  14153. ) );
  14154. $receiptList [$key] ['button'] = $button;
  14155. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  14156. }
  14157. // print_r($receiptList);die;
  14158. // $data['verifyDetail']=$verifyDetail;
  14159. $mothHtml = "";
  14160. for($i = 1; $i <= 12; $i ++) {
  14161. if ($month == $i)
  14162. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  14163. else
  14164. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  14165. }
  14166. $data ['mothHtml'] = $mothHtml;
  14167. $data ['page'] = $pageinfo;
  14168. $data ['receiptList'] = $receiptList;
  14169. $data ['receiptApprovalCount'] = count ( $rLRes );
  14170. $data ['status'] = $status;
  14171. $data ['year'] = $year;
  14172. $data ['categoryList'] = $categoryList;
  14173. $data ['staffList'] = $staffList;
  14174. $data ['cid'] = $cid;
  14175. $data ['sid'] = $sid;
  14176. // print_r($receiptList);
  14177. $data ['memu'] = "receipt";
  14178. $data ['staff'] = $this->staff;
  14179. $data ['receiptMemu'] = 'approvalExpenses';
  14180. $data ['verifyId'] = $this->verifyId;
  14181. $data ['executeId'] = $this->executeId;
  14182. $this->render ( "/admin/FALG", $data );
  14183. }
  14184. function ajaxGetReceiptOrder() {
  14185. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  14186. if (! empty ( $receiptOrder )) {
  14187. Doo::loadModel ( 'receipt' );
  14188. $receipt = new receipt ();
  14189. Doo::loadModel ( 'staff' );
  14190. $staff = new staff ();
  14191. $receiptInfo = $receipt->getOne ( array (
  14192. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  14193. 'asArray' => true
  14194. ) );
  14195. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  14196. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  14197. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  14198. </tbody></table><table class="table table table-bordered"><tbody>';
  14199. foreach ( $verifyStaff as $key => $value ) {
  14200. $staffInfo = $staff->getOne ( array (
  14201. 'select' => 'username',
  14202. 'where' => ' sid="' . $key . '"',
  14203. 'asArray' => true
  14204. ) );
  14205. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  14206. }
  14207. $html .= '</tbody></table></div></div>';
  14208. echo json_encode ( array (
  14209. 'status' => 1,
  14210. 'receiptHtml' => $html
  14211. ) );
  14212. die ();
  14213. }
  14214. echo json_encode ( array (
  14215. 'status' => 2,
  14216. 'receiptHtml' => ''
  14217. ) );
  14218. die ();
  14219. }
  14220. function _getMonthCollectDetail($receiptCollectList,$aiList) {
  14221. if (! empty ( $receiptCollectList )) {
  14222. $receiptL = array (
  14223. '日常相关费用' => array (),
  14224. '差旅相关费用' => array (),
  14225. '内部培训费用'=>array(),
  14226. '培训班费用' => array (),
  14227. '其他' => array ()
  14228. );
  14229. $html = "";
  14230. $psum = 0;
  14231. foreach ( $aiList[$this->AGENCY] as $value ) {
  14232. $falg = true;
  14233. foreach ( $receiptCollectList as $v ) {
  14234. if ($v ['itemCategory'] == '日常相关费用') {
  14235. if ($v ['item'] == $value['name']) {
  14236. $psum += $v ['price'];
  14237. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14238. $falg = false;
  14239. break;
  14240. }
  14241. }
  14242. }
  14243. if ($falg)
  14244. $html .= '<td class="taR">-</td>';
  14245. }
  14246. if (! empty ( $psum ))
  14247. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14248. else
  14249. $psum = '<td class="colGreen taR">-</td>';
  14250. $receiptL ['日常相关费用'] = $psum . $html;
  14251. /* ----------------------------------- */
  14252. $html = "";
  14253. $psum = 0;
  14254. foreach ( $aiList[$this->TRAVEL] as $value ) {
  14255. $falg = true;
  14256. foreach ( $receiptCollectList as $v ) {
  14257. if ($v ['itemCategory'] == '差旅相关费用') {
  14258. if ($v ['item'] == $value['name']) {
  14259. $psum += $v ['price'];
  14260. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14261. $falg = false;
  14262. break;
  14263. }
  14264. }
  14265. }
  14266. if ($falg)
  14267. $html .= '<td class="taR">-</td>';
  14268. }
  14269. if (! empty ( $psum ))
  14270. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14271. else
  14272. $psum = '<td class="colGreen taR">-</td>';
  14273. $receiptL ['差旅相关费用'] = $psum . $html;
  14274. /* ----------------------------------- */
  14275. $html = "";
  14276. $psum = 0;
  14277. foreach ( $aiList[$this->INTTRAIN] as $value ) {
  14278. $falg = true;
  14279. foreach ( $receiptCollectList as $v ) {
  14280. if ($v ['itemCategory'] == '内部培训费用') {
  14281. if ($v ['item'] == $value['name']) {
  14282. $psum += $v ['price'];
  14283. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14284. $falg = false;
  14285. break;
  14286. }
  14287. }
  14288. }
  14289. if ($falg)
  14290. $html .= '<td class="taR">-</td>';
  14291. }
  14292. if (! empty ( $psum ))
  14293. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14294. else
  14295. $psum = '<td class="colGreen taR">-</td>';
  14296. $receiptL ['内部培训费用'] = $psum . $html;
  14297. /* ------------------------------------- */
  14298. $html = "";
  14299. $psum = 0;
  14300. foreach ( $aiList[$this->TRAIN] as $value ) {
  14301. $falg = true;
  14302. foreach ( $receiptCollectList as $v ) {
  14303. if ($v ['itemCategory'] == '培训班费用') {
  14304. if ($v ['item'] == $value['name']) {
  14305. $psum += $v ['price'];
  14306. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14307. $falg = false;
  14308. break;
  14309. }
  14310. }
  14311. }
  14312. if ($falg)
  14313. $html .= '<td class="taR">-</td>';
  14314. }
  14315. if (! empty ( $psum ))
  14316. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14317. else
  14318. $psum = '<td class="colGreen taR">-</td>';
  14319. $receiptL ['培训班费用'] = $psum . $html;
  14320. /* ------------------------------------- */
  14321. $html = "";
  14322. $psum = 0;
  14323. foreach ( $aiList[$this->OTHER] as $value ) {
  14324. $falg = true;
  14325. foreach ( $receiptCollectList as $v ) {
  14326. if ($v ['itemCategory'] == '其他') {
  14327. if ($v ['item'] == $value['name']) {
  14328. $psum += $v ['price'];
  14329. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14330. $falg = false;
  14331. break;
  14332. }
  14333. }
  14334. }
  14335. if ($falg)
  14336. $html .= '<td class="taR">-</td>';
  14337. }
  14338. if (! empty ( $psum ))
  14339. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14340. else
  14341. $psum = '<td class="colGreen taR">-</td>';
  14342. $receiptL ['其他'] = $psum . $html;
  14343. /* ------------------------------------- */
  14344. $html = "";
  14345. $psum = 0;
  14346. foreach ( $receiptCollectList as $v ) {
  14347. if ($v ['itemCategory'] == '报销金额调整') {
  14348. if (! empty ( $v ['price'] ))
  14349. $psum += $v ['price'];
  14350. }
  14351. }
  14352. if (! empty ( $psum ))
  14353. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  14354. else
  14355. $psum = '<td class="taR colOrange">-</td>';
  14356. $receiptL ['报销金额调整'] = $psum . $html;
  14357. } else {
  14358. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  14359. foreach ( $aiList[$this->AGENCY] as $va ) {
  14360. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  14361. }
  14362. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  14363. foreach ( $aiList[$this->TRAVEL] as $va ) {
  14364. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  14365. }
  14366. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  14367. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  14368. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  14369. }
  14370. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  14371. foreach ( $aiList[$this->TRAIN] as $va ) {
  14372. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  14373. }
  14374. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  14375. foreach ( $aiList[$this->OTHER] as $va ) {
  14376. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  14377. }
  14378. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  14379. }
  14380. return $receiptL;
  14381. }
  14382. function eMail() {
  14383. Doo::loadModel ( 'staff' );
  14384. $staff = new staff ();
  14385. Doo::loadModel ( 'receipt' );
  14386. $receipt = new receipt ();
  14387. Doo::loadModel ( 'L_category' );
  14388. $Lcategory = new L_category ();
  14389. Doo::loadModel ( "verify" );
  14390. $verify = new verify ();
  14391. $staffList = $staff->find ( array (
  14392. 'asArray' => true
  14393. ) );
  14394. foreach ( $staffList as $key => $value ) {
  14395. if ($value ['username'] != 'admin') {
  14396. // 提交人
  14397. $receiptList = $receipt->find ( array (
  14398. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  14399. 'asArray' => true
  14400. ) );
  14401. if (! empty ( $receiptList )) {
  14402. $html = '<br><div><style></style>
  14403. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  14404. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  14405. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14406. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  14407. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14408. <tbody><tr>
  14409. <td style="padding: 0 40px;" align="left">
  14410. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14411. </td></tr><tr>
  14412. <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>
  14413. </tr>
  14414. </tbody> </table></td> </tr> <tr><td>
  14415. <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">
  14416. <tbody> <tr><td>
  14417. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  14418. 以下报销单完成了审批,等着收款吧:</p>
  14419. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  14420. foreach ( $receiptList as $k => $v ) {
  14421. $category = $Lcategory->getOne ( array (
  14422. 'where' => 'cid=' . $v ['cid'],
  14423. 'asArray' => true
  14424. ) );
  14425. $html .= '
  14426. <tr>
  14427. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14428. <td align="left">
  14429. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  14430. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  14431. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  14432. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  14433. </tr>';
  14434. }
  14435. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  14436. <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>
  14437. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  14438. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  14439. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  14440. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14441. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14442. $receipt = new receipt ();
  14443. $receipt->notice = 1;
  14444. $receipt->update ( array (
  14445. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  14446. ) );
  14447. }
  14448. }
  14449. // 审批人
  14450. $verifyList = $verify->find ( array (
  14451. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  14452. 'asArray' => true
  14453. ) );
  14454. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  14455. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  14456. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14457. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  14458. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14459. <tbody><tr><td style="padding: 0 40px;" align="left">
  14460. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14461. </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>
  14462. </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">
  14463. <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>
  14464. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  14465. foreach ( $verifyList as $k => $v ) {
  14466. $receiptList = $receipt->find ( array (
  14467. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  14468. 'asArray' => true
  14469. ) );
  14470. foreach ( $receiptList as $r => $l ) {
  14471. $category = $Lcategory->getOne ( array (
  14472. 'where' => 'cid=' . $l ['cid'],
  14473. 'asArray' => true
  14474. ) );
  14475. $staffDetile = $staff->getOne ( array (
  14476. 'where' => 'sid=' . $l ['staff'],
  14477. 'asArray' => true
  14478. ) );
  14479. $html .= '
  14480. <tr>
  14481. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14482. <td align="left">
  14483. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  14484. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  14485. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  14486. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  14487. </tr>';
  14488. }
  14489. }
  14490. $html .= '
  14491. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  14492. <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>
  14493. </tr></tbody></table></td></tr></tbody></table></div><br>';
  14494. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  14495. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  14496. // $receipt=new receipt();
  14497. // $receipt->notice=1;
  14498. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  14499. }
  14500. }
  14501. }
  14502. }
  14503. function setWXMsg($rid, $type) {
  14504. Doo::loadModel ( "receipt" );
  14505. $receipt = new receipt ();
  14506. $receiptDetail = $receipt->getOne ( array (
  14507. 'where' => 'rid=' . $rid,
  14508. 'asArray' => true
  14509. ) );
  14510. if (! empty ( $receiptDetail )) {
  14511. Doo::loadModel ( 'staff' );
  14512. $staff = new staff ();
  14513. $staffmsg = $staff->getOne ( array (
  14514. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  14515. 'asArray' => TRUE
  14516. ) );
  14517. if (! empty ( $staffmsg ['wxid'] )) {
  14518. require_once (SITE_PATH . '/protected/class/client.php');
  14519. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  14520. $user = $staffmsg ['wxid'];
  14521. $receiptName = '';
  14522. $msg = '';
  14523. switch ($receiptDetail ['Rtype']) {
  14524. case 0 :
  14525. $receiptName = '报销';
  14526. break;
  14527. case 1 :
  14528. $receiptName = '借款';
  14529. break;
  14530. case 2 :
  14531. $receiptName = '对公汇款';
  14532. break;
  14533. }
  14534. switch ($type) {
  14535. case 1 :
  14536. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  14537. break;
  14538. case 2 :
  14539. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  14540. break;
  14541. case 3 :
  14542. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  14543. break;
  14544. }
  14545. // $result = $client->SendMsg ( $user, $msg, 'text' );
  14546. }
  14547. }
  14548. }
  14549. // Email发送函数
  14550. function SMail($toemail, $subject, $contents) {
  14551. Doo::loadClass ( 'class.phpmailer' );
  14552. $mail = new PHPMailer ();
  14553. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  14554. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  14555. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  14556. $mail->Password = "cDO1GjtY1seH"; // 密码
  14557. $mail->CharSet = "UTF8";
  14558. $mail->SMTPAuth = true;
  14559. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  14560. $mail->Mailer = "smtp";
  14561. $mail->Port = 25;
  14562. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  14563. $mail->MsgHTML ( $contents );
  14564. $mail->AddAddress ( $toemail );
  14565. $mail->CharSet = "UTF-8";
  14566. return $mail->Send ();
  14567. }
  14568. function h5Upload() {
  14569. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14570. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14571. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14572. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14573. header ( "HTTP/1.1 500 Internal Server Error" );
  14574. echo "POST exceeded maximum allowed size.";
  14575. exit ( 0 );
  14576. }
  14577. // Settings
  14578. $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)
  14579. $upload_name = "Filedata";
  14580. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14581. $extension_whitelist = array (
  14582. "doc",
  14583. "txt",
  14584. "jpg",
  14585. "gif",
  14586. "png"
  14587. ); // Allowed file extensions
  14588. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14589. // Other variables
  14590. $MAX_FILENAME_LENGTH = 260;
  14591. $file_name = "";
  14592. $file_extension = "";
  14593. $uploadErrors = array (
  14594. 0 => "文件上传成功",
  14595. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14596. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14597. 3 => "上传的文件仅为部分文件",
  14598. 4 => "没有文件上传",
  14599. 6 => "缺少临时文件夹"
  14600. );
  14601. $nk = time ();
  14602. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14603. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14604. echo "文件无法保存.";
  14605. exit ( 0 );
  14606. }
  14607. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14608. echo json_encode ( array (
  14609. 'filename' => $file_name,
  14610. 'id' => $nk
  14611. ) );
  14612. exit ( 0 );
  14613. }
  14614. function swfupload() {
  14615. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14616. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14617. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14618. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14619. header ( "HTTP/1.1 500 Internal Server Error" );
  14620. echo "POST exceeded maximum allowed size.";
  14621. exit ( 0 );
  14622. }
  14623. // Settings
  14624. $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)
  14625. $upload_name = "Filedata";
  14626. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14627. $extension_whitelist = array (
  14628. "doc",
  14629. "txt",
  14630. "jpg",
  14631. "gif",
  14632. "png"
  14633. ); // Allowed file extensions
  14634. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14635. // Other variables
  14636. $MAX_FILENAME_LENGTH = 260;
  14637. $file_name = "";
  14638. $file_extension = "";
  14639. $uploadErrors = array (
  14640. 0 => "文件上传成功",
  14641. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14642. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14643. 3 => "上传的文件仅为部分文件",
  14644. 4 => "没有文件上传",
  14645. 6 => "缺少临时文件夹"
  14646. );
  14647. $nk = time ();
  14648. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14649. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14650. echo "文件无法保存.";
  14651. exit ( 0 );
  14652. }
  14653. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14654. echo json_encode ( array (
  14655. 'filename' => $file_name,
  14656. 'id' => $nk
  14657. ) );
  14658. exit ( 0 );
  14659. }
  14660. function _GetFileEXT($filename) {
  14661. $pics = explode ( '.', $filename );
  14662. $num = count ( $pics );
  14663. return $pics [$num - 1];
  14664. }
  14665. /**
  14666. * 获取get或者POST值
  14667. * @param string $name 属性名称
  14668. * @return fixed 值
  14669. */
  14670. function get_args($name) {
  14671. if (isset ( $_GET [$name] )) {
  14672. if (is_array ( $_GET [$name] ))
  14673. return $_GET [$name];
  14674. else
  14675. return addslashes ( $_GET [$name] );
  14676. } elseif (isset ( $_POST [$name] )) {
  14677. if (is_array ( $_POST [$name] ))
  14678. return $_POST [$name];
  14679. else
  14680. return addslashes ( $_POST [$name] );
  14681. } else
  14682. return false;
  14683. }
  14684. function num_to_rmb($num) {
  14685. $c1 = "零壹贰叁肆伍陆柒捌玖";
  14686. $c2 = "分角元拾佰仟万拾佰仟亿";
  14687. // 精确到分后面就不要了,所以只留两个小数位
  14688. $num = round ( $num, 2 );
  14689. // 将数字转化为整数
  14690. $num = $num * 100;
  14691. if (strlen ( $num ) > 10) {
  14692. return "金额太大,请检查";
  14693. }
  14694. $i = 0;
  14695. $c = "";
  14696. while ( 1 ) {
  14697. if ($i == 0) {
  14698. // 获取最后一位数字
  14699. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  14700. } else {
  14701. $n = $num % 10;
  14702. }
  14703. // 每次将最后一位数字转化为中文
  14704. $p1 = substr ( $c1, 3 * $n, 3 );
  14705. $p2 = substr ( $c2, 3 * $i, 3 );
  14706. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  14707. $c = $p1 . $p2 . $c;
  14708. } else {
  14709. $c = $p1 . $c;
  14710. }
  14711. $i = $i + 1;
  14712. // 去掉数字最后一位了
  14713. $num = $num / 10;
  14714. // echo $num.'</br>';
  14715. $num = ( int ) $num;
  14716. // $num =floor($num);
  14717. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  14718. // echo $num.'</br>';
  14719. // 结束循环
  14720. if ($num == 0) {
  14721. break;
  14722. }
  14723. }
  14724. // echo $c.'</br>';
  14725. $j = 0;
  14726. $slen = strlen ( $c );
  14727. while ( $j < $slen ) {
  14728. // utf8一个汉字相当3个字符
  14729. $m = substr ( $c, $j, 6 );
  14730. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  14731. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  14732. $left = substr ( $c, 0, $j );
  14733. $right = substr ( $c, $j + 3 );
  14734. $c = $left . $right;
  14735. $j = $j - 3;
  14736. $slen = $slen - 3;
  14737. }
  14738. $j = $j + 3;
  14739. }
  14740. // 这个是为了去掉类似23.0中最后一个“零”字
  14741. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  14742. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  14743. }
  14744. // 将处理的汉字加上“整”
  14745. if (empty ( $c )) {
  14746. return "零元整";
  14747. } else {
  14748. return $c . "整";
  14749. }
  14750. }
  14751. /**
  14752. * 获得分页数据
  14753. * @param unknown_type $table
  14754. * @param unknown_type $condition
  14755. * @param unknown_type $on_page
  14756. * @param unknown_type $page_size
  14757. */
  14758. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  14759. $page_c = "";
  14760. $page ['previous'] = $this->get_previous ( $on_page );
  14761. $page ['on_page'] = $on_page;
  14762. $total_count = $this->get_table_count ( $table, $condition );
  14763. $total = intval ( $total_count / $page_size );
  14764. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  14765. $page ['total_data'] = $total_count;
  14766. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  14767. $i = 1;
  14768. $page_max = 1;
  14769. $page_width = 3;
  14770. if ($on_page >= $page_width) {
  14771. $page_max = intval ( $on_page / $page_width ) + 1;
  14772. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  14773. }
  14774. for(; $i <= $page ['total_page']; $i ++) {
  14775. if ($i == $on_page)
  14776. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  14777. else
  14778. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  14779. if ($i == ($page_width * $page_max))
  14780. break;
  14781. }
  14782. $page ['page'] = $page_c;
  14783. $page ['lower'] = (-- $on_page) * $page_size;
  14784. return $page;
  14785. }
  14786. /**
  14787. * 获取总页数
  14788. * @param unknown_type $table
  14789. * @param unknown_type $condition
  14790. */
  14791. public function get_table_count($table = "", $condition = "") {
  14792. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14793. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14794. // echo $sql;die;
  14795. $query = Doo::db ()->query ( $sql );
  14796. $result = $query->fetch ();
  14797. return $result ['count'];
  14798. }
  14799. /**
  14800. * 获取上一页
  14801. * @param unknown_type $on_page
  14802. */
  14803. function get_previous($on_page = 1) {
  14804. return $on_page != 0 ? $on_page - 1 : $on_page;
  14805. }
  14806. function _getReceiptTrainPayment($invoiceTrainId,$trainLoanRid,$rid){
  14807. // 收入合计
  14808. Doo::loadModel ( 'invoiceTraining' );
  14809. $invoiceTraining = new invoiceTraining ();
  14810. Doo::loadModel ( 'receipt' );
  14811. $receipt = new receipt ();
  14812. $invoiceTrainingDetail = array (
  14813. 'invoiceArriveAmount' => '0.00',
  14814. 'RIAmount' => '0.00',
  14815. 'invoiceTotalAmount' => '0.00',
  14816. 'invoiceCompanyAmount' => '0.00',
  14817. 'invoiceArriveAmountM'=>'0.00',
  14818. 'invoiceCompanyAmountM'=>'0.00'
  14819. );
  14820. if ($invoiceTrainId != 0) {
  14821. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $invoiceTrainId );
  14822. }
  14823. $invoiceArriveAmount = $RIAmount = 0;
  14824. if (! empty ( $invoiceTrainingDetail )) {
  14825. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  14826. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  14827. }
  14828. // 备用金
  14829. $sum = 0;
  14830. if (! empty ( $trainLoanRid )) {
  14831. $receiptLoanList = $receipt->getReceiptInRid ( $trainLoanRid );
  14832. foreach ($receiptLoanList as $key=>$value){
  14833. $sum+=$value['sum'];
  14834. }
  14835. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $trainLoanRid );
  14836. // $sum = $receiptLoanDetailBak ['sum'];
  14837. }
  14838. // 支出项金额详情
  14839. // 项目金额合计
  14840. Doo::loadModel ( 'RItem' );
  14841. $RItem = new RItem ();
  14842. Doo::loadModel ( 'accountItem' );
  14843. $accountItem = new accountItem ();
  14844. // 讲师获得
  14845. Doo::loadModel ( 'RILecturer' );
  14846. $RILecturer = new RILecturer ();
  14847. $RItemList = $RItem->getRItemByRid ($rid );
  14848. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  14849. // 支出项金额详情
  14850. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  14851. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  14852. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  14853. return $payment;
  14854. }
  14855. }
  14856. ?>