ReceiptController.php 544 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613
  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. }
  237. /**
  238. * 添加费用报销单页面
  239. */
  240. function saeaCreate() {
  241. Doo::loadModel ( 'accountItem' );
  242. Doo::loadModel ( 'verify' );
  243. Doo::loadModel ( 'receipt' );
  244. Doo::loadModel ( 'L_category' );
  245. $lCategory = new L_category ();
  246. $receipt = new receipt ();
  247. $verify = new verify ();
  248. $accountItem = new accountItem ();
  249. Doo::loadModel ( "role" );
  250. $role = new role ();
  251. $acItem = $accountItem->find ( array (
  252. 'asArray' => true
  253. ) );
  254. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  255. $data ['category'] = $lCategory->find ( array (
  256. 'asArray' => true
  257. ) );
  258. $data ['veList'] = $veList;
  259. $data ['acItem'] = $acItem;
  260. $data ['memu'] = "receipt";
  261. $data ['staff'] = $this->staff;
  262. $data ['receiptMemu'] = 'saeaBorad';
  263. $data ['verifyId'] = $this->verifyId;
  264. $data ['executeId'] = $this->executeId;
  265. $this->render ( "/admin/saea_create", $data );
  266. }
  267. function addReceipt() {
  268. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  269. $agency = $this->get_args ( 'agency' );
  270. $travel = $this->get_args ( 'travel' );
  271. $train = $this->get_args ( 'train' );
  272. $other = $this->get_args ( 'other' );
  273. $inttrain = $this->get_args ( 'inttrain' );
  274. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  275. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  276. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  277. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  278. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  279. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  280. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  281. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  282. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  283. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  284. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  285. header ( 'Content-Type:text/html;charset=utf-8' );
  286. die ( '请填写联行号' );
  287. }
  288. Doo::loadModel ( 'receipt' );
  289. Doo::loadModel ( 'receiptDetail' );
  290. Doo::loadModel ( 'accountItem' );
  291. $accountItem = new accountItem ();
  292. $receipt = new receipt ();
  293. Doo::loadModel ( 'enclosur' );
  294. Doo::loadModel ( 'execute' );
  295. $execute = new execute ();
  296. $executeDetail = $execute->getOne ( array (
  297. 'where' => 'mold="报销单执行人"',
  298. 'asArray' => true
  299. ) );
  300. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  301. // if(!empty($receiptDetail))
  302. // return "/referReceipt/".$receiptDetail['rid'];
  303. $aItem = $accountItem->find ( array (
  304. 'asArray' => true
  305. ) );
  306. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  307. $ag = $tr = $ta = $ot= $it = 0;
  308. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  309. foreach ( $aItem as $key => $value ) {
  310. if ($value ['category'] == $this->AGENCY) {
  311. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  312. array_push ( $accountJson [$this->AGENCY], array (
  313. 'aid' => $value ['aid'],
  314. 'name' => $value ['name'],
  315. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  316. ) );
  317. $sum += $agency [$ag];
  318. $agencySum += $agency [$ag];
  319. }
  320. $ag ++;
  321. }
  322. if ($value ['category'] == $this->TRAVEL) {
  323. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  324. array_push ( $accountJson [$this->TRAVEL], array (
  325. 'aid' => $value ['aid'],
  326. 'name' => $value ['name'],
  327. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  328. ) );
  329. $sum += $travel [$tr];
  330. $travelSum += $travel [$tr];
  331. }
  332. $tr ++;
  333. }
  334. if ($value ['category'] == $this->TRAIN) {
  335. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  336. array_push ( $accountJson [$this->TRAIN], array (
  337. 'aid' => $value ['aid'],
  338. 'name' => $value ['name'],
  339. 'price' => number_format ( $train [$ta], 2, '.', '' )
  340. ) );
  341. $sum += $train [$ta];
  342. $trainSum += $train [$ta];
  343. }
  344. $ta ++;
  345. }
  346. if ($value ['category'] == $this->INTTRAIN) {
  347. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  348. array_push ( $accountJson [$this->INTTRAIN], array (
  349. 'aid' => $value ['aid'],
  350. 'name' => $value ['name'],
  351. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  352. ) );
  353. $sum += $inttrain [$it];
  354. $inttrainSum += $inttrain [$it];
  355. }
  356. $it ++;
  357. }
  358. if ($value ['category'] == $this->OTHER) {
  359. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  360. array_push ( $accountJson [$this->OTHER], array (
  361. 'aid' => $value ['aid'],
  362. 'name' => $value ['name'],
  363. 'price' => number_format ( $other [$ot], 2, '.', '' )
  364. ) );
  365. $sum += $other [$ot];
  366. $otherSum += $other [$ot];
  367. }
  368. $ot ++;
  369. }
  370. }
  371. $accountJson ['cSum'] = array (
  372. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  373. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  374. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  375. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  376. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  377. );
  378. // 报销单
  379. $receipt->accountItem = json_encode ( $accountJson );
  380. $receipt->staff = $this->staff [0] ['sid'];
  381. $receipt->sum = number_format ( $sum, 2, '.', '' );
  382. $receipt->date = date ( "Y-m-d" );
  383. $receipt->cid = $cid;
  384. $receipt->status = 5;
  385. // 修改审批流程加入角色
  386. $receipt->verify = $verify;
  387. $receipt->executeCopy = $executeDetail ['staff'];
  388. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  389. $order = array (
  390. "\r\n",
  391. "\n",
  392. "\r"
  393. );
  394. $replace = '<br/>';
  395. $explanation = str_replace ( $order, $replace, $explanation );
  396. $receipt->explanation = $explanation;
  397. $receipt->remittanceName = $remittanceName;
  398. $receipt->bankName = $bankName;
  399. $receipt->bankNumber = $bankNumber;
  400. $receipt->remittanceBankType = $remittanceBankType;
  401. if ($remittanceBankType == 1)
  402. $receipt->coupletNumber = $coupletNumber;
  403. $rid = $receipt->insert ();
  404. // 附件
  405. if (! empty ( $enclosurName )) {
  406. $enclosurArray = explode ( '-', $enclosurName );
  407. foreach ( $enclosurArray as $value ) {
  408. $enclosur = new enclosur ();
  409. $enclosur->name = $value;
  410. $enclosur->rid = $rid;
  411. $enclosur->insert ();
  412. }
  413. // print_r($enclosurArray);die;
  414. }
  415. // 报销详情
  416. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  417. $receiptDetail = new receiptDetail ();
  418. $receiptDetail->staff = $this->staff [0] ['sid'];
  419. $receiptDetail->item = $value ['name'];
  420. $receiptDetail->itemCategory = $this->AGENCY;
  421. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  422. $receiptDetail->date = date ( "Y-m-d" );
  423. $receiptDetail->cid = $cid;
  424. $receiptDetail->rid = $rid;
  425. $receiptDetail->status = 4;
  426. $receiptDetail->insert ();
  427. }
  428. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  429. $receiptDetail = new receiptDetail ();
  430. $receiptDetail->staff = $this->staff [0] ['sid'];
  431. $receiptDetail->item = $value ['name'];
  432. $receiptDetail->itemCategory = $this->TRAVEL;
  433. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  434. $receiptDetail->date = date ( "Y-m-d" );
  435. $receiptDetail->cid = $cid;
  436. $receiptDetail->rid = $rid;
  437. $receiptDetail->status = 4;
  438. $receiptDetail->insert ();
  439. }
  440. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  441. $receiptDetail = new receiptDetail ();
  442. $receiptDetail->staff = $this->staff [0] ['sid'];
  443. $receiptDetail->item = $value ['name'];
  444. $receiptDetail->itemCategory = $this->TRAIN;
  445. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  446. $receiptDetail->date = date ( "Y-m-d" );
  447. $receiptDetail->cid = $cid;
  448. $receiptDetail->rid = $rid;
  449. $receiptDetail->status = 4;
  450. $receiptDetail->insert ();
  451. }
  452. //内训
  453. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  454. $receiptDetail = new receiptDetail ();
  455. $receiptDetail->staff = $this->staff [0] ['sid'];
  456. $receiptDetail->item = $value ['name'];
  457. $receiptDetail->itemCategory = $this->INTTRAIN;
  458. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  459. $receiptDetail->date = date ( "Y-m-d" );
  460. $receiptDetail->cid = $cid;
  461. $receiptDetail->rid = $rid;
  462. $receiptDetail->status = 4;
  463. $receiptDetail->insert ();
  464. }
  465. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  466. $receiptDetail = new receiptDetail ();
  467. $receiptDetail->staff = $this->staff [0] ['sid'];
  468. $receiptDetail->item = $value ['name'];
  469. $receiptDetail->itemCategory = $this->OTHER;
  470. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  471. $receiptDetail->date = date ( "Y-m-d" );
  472. $receiptDetail->cid = $cid;
  473. $receiptDetail->rid = $rid;
  474. $receiptDetail->status = 4;
  475. $receiptDetail->insert ();
  476. }
  477. return "/saeaBorad";
  478. } else
  479. die ( 'illegal request' );
  480. }
  481. function referReceipt() {
  482. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  483. Doo::loadModel ( 'receipt' );
  484. Doo::loadModel ( 'verify' );
  485. $verify = new verify ();
  486. $receipt = new receipt ();
  487. Doo::loadModel ( 'L_category' );
  488. $lCategory = new L_category ();
  489. Doo::loadModel ( "role" );
  490. $role = new role ();
  491. $receiptDetail = $receipt->find ( array (
  492. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  493. 'asArray' => true
  494. ) );
  495. if (empty ( $receiptDetail ))
  496. return "/addReceipt";
  497. foreach ( $receiptDetail as $key => $value ) {
  498. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  499. $veList = $verify->getOne ( array (
  500. 'where' => 'vid=' . $value ['verify'],
  501. 'asArray' => true
  502. ) );
  503. $v = json_decode ( $veList ['staff'] );
  504. array_push ( $v [0], $veList ['description'] );
  505. foreach ( $v as $n => $m ) {
  506. if ($m ['1'] == 'ROLE') {
  507. $roleInfo = $role->getOne ( array (
  508. 'where' => 'rid=' . $m [0],
  509. 'asArray' => true
  510. ) );
  511. $v [$n] [1] = $roleInfo ['name'];
  512. }
  513. }
  514. $receiptDetail [$key] ['staff'] = $v;
  515. $category = $lCategory->getOne ( array (
  516. 'where' => 'cid=' . $value ['cid'],
  517. 'asArray' => true
  518. ) );
  519. $receiptDetail [$key] ['category'] = $category ['title'];
  520. }
  521. // print_r($receiptDetail);
  522. $data ['receiptDetail'] = $receiptDetail;
  523. $data ['memu'] = "receipt";
  524. $data ['staff'] = $this->staff;
  525. $data ['receiptMemu'] = 'saeaCreate';
  526. $data ['verifyId'] = $this->verifyId;
  527. $data ['executeId'] = $this->executeId;
  528. $this->render ( "/admin/saea_confirm", $data );
  529. }
  530. function editReceipt() {
  531. // edit status 4
  532. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  533. Doo::loadClass ( 'XDeode' );
  534. $XDeode = new XDeode ( 7 );
  535. $rid = $XDeode->decode ( $ridKey );
  536. if (empty ( $rid ))
  537. die ( 'illegal request' );
  538. // echo $rid.'sd';
  539. Doo::loadModel ( 'accountItem' );
  540. Doo::loadModel ( 'verify' );
  541. Doo::loadModel ( 'receipt' );
  542. $receipt = new receipt ();
  543. $verify = new verify ();
  544. $accountItem = new accountItem ();
  545. Doo::loadModel ( 'L_category' );
  546. $lCategory = new L_category ();
  547. Doo::loadModel ( "role" );
  548. $role = new role ();
  549. Doo::loadModel ( 'enclosur' );
  550. $enclosur = new enclosur ();
  551. $receiptDetail = $receipt->getOne ( array (
  552. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  553. 'asArray' => true
  554. ) );
  555. if (empty ( $receiptDetail ))
  556. die ( 'illegal request' );
  557. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  558. $acItem = $accountItem->find ( array (
  559. 'asArray' => true
  560. ) );
  561. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  562. // 配置编辑信息
  563. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  564. foreach ( $acItem as $key => $value ) {
  565. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  566. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  567. $acItem [$key] ['price'] = $v ['price'];
  568. }
  569. }
  570. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  571. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  572. $acItem [$key] ['price'] = $v ['price'];
  573. }
  574. }
  575. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  576. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  577. $acItem [$key] ['price'] = $v ['price'];
  578. }
  579. }
  580. //内训
  581. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  582. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  583. $acItem [$key] ['price'] = $v ['price'];
  584. }
  585. }
  586. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  587. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  588. $acItem [$key] ['price'] = $v ['price'];
  589. }
  590. }
  591. }
  592. $data ['category'] = $lCategory->find ( array (
  593. 'asArray' => true
  594. ) );
  595. $data ['cSum'] = $accountItemList ['cSum'];
  596. $data ['sum'] = $receiptDetail ['sum'];
  597. $data ['enclosurList'] = $enclosurList;
  598. $data ['receiptDetail'] = $receiptDetail;
  599. $data ['veList'] = $veList;
  600. $data ['acItem'] = $acItem;
  601. $data ['memu'] = "receipt";
  602. $data ['staff'] = $this->staff;
  603. $data ['receiptMemu'] = 'saeaBorad';
  604. $data ['verify'] = $receiptDetail ['verify'];
  605. $data ['verifyId'] = $this->verifyId;
  606. $data ['executeId'] = $this->executeId;
  607. $data ['rid'] = $ridKey;
  608. $this->render ( "/admin/saea_edit", $data );
  609. }
  610. function updateReceipt() {
  611. $agency = $this->get_args ( 'agency' );
  612. $travel = $this->get_args ( 'travel' );
  613. $train = $this->get_args ( 'train' );
  614. $other = $this->get_args ( 'other' );
  615. $inttrain = $this->get_args ( 'inttrain' );
  616. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  617. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  618. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  619. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  620. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  621. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  622. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  623. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  624. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  625. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  626. Doo::loadClass ( 'XDeode' );
  627. $XDeode = new XDeode ( 7 );
  628. $rid = $XDeode->decode ( $ridKey );
  629. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  630. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  631. header ( 'Content-Type:text/html;charset=utf-8' );
  632. die ( '请填写联行号' );
  633. }
  634. Doo::loadModel ( 'receipt' );
  635. Doo::loadModel ( 'receiptDetail' );
  636. Doo::loadModel ( 'accountItem' );
  637. $accountItem = new accountItem ();
  638. $receipt = new receipt ();
  639. Doo::loadModel ( 'enclosur' );
  640. Doo::loadModel ( 'execute' );
  641. $execute = new execute ();
  642. $receiptDetail = $receipt->getOne ( array (
  643. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  644. 'asArray' => true
  645. ) );
  646. if (empty ( $receiptDetail ))
  647. return "/saeaBorad";
  648. if ($receiptDetail ['Rtype'] == 1)
  649. $executeDetail = $execute->getOne ( array (
  650. 'where' => 'mold="借款费用执行人"',
  651. 'asArray' => true
  652. ) );
  653. else
  654. $executeDetail = $execute->getOne ( array (
  655. 'where' => 'mold="报销单执行人"',
  656. 'asArray' => true
  657. ) );
  658. $aItem = $accountItem->find ( array (
  659. 'asArray' => true
  660. ) );
  661. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  662. $ag = $tr = $ta = $ot = $it = 0 ;
  663. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum = $otherSum = 0;
  664. foreach ( $aItem as $key => $value ) {
  665. if ($value ['category'] == $this->AGENCY) {
  666. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  667. array_push ( $accountJson [$this->AGENCY], array (
  668. 'aid' => $value ['aid'],
  669. 'name' => $value ['name'],
  670. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  671. ) );
  672. $sum += $agency [$ag];
  673. $agencySum += $agency [$ag];
  674. }
  675. $ag ++;
  676. }
  677. if ($value ['category'] == $this->TRAVEL) {
  678. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  679. array_push ( $accountJson [$this->TRAVEL], array (
  680. 'aid' => $value ['aid'],
  681. 'name' => $value ['name'],
  682. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  683. ) );
  684. $sum += $travel [$tr];
  685. $travelSum += $travel [$tr];
  686. }
  687. $tr ++;
  688. }
  689. if ($value ['category'] == $this->TRAIN) {
  690. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  691. array_push ( $accountJson [$this->TRAIN], array (
  692. 'aid' => $value ['aid'],
  693. 'name' => $value ['name'],
  694. 'price' => number_format ( $train [$ta], 2, '.', '' )
  695. ) );
  696. $sum += $train [$ta];
  697. $trainSum += $train [$ta];
  698. }
  699. $ta ++;
  700. }
  701. if ($value ['category'] == $this->INTTRAIN) {
  702. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  703. array_push ( $accountJson [$this->INTTRAIN], array (
  704. 'aid' => $value ['aid'],
  705. 'name' => $value ['name'],
  706. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  707. ) );
  708. $sum += $inttrain [$it];
  709. $inttrainSum += $inttrain [$it];
  710. }
  711. $it ++;
  712. }
  713. if ($value ['category'] == $this->OTHER) {
  714. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  715. array_push ( $accountJson [$this->OTHER], array (
  716. 'aid' => $value ['aid'],
  717. 'name' => $value ['name'],
  718. 'price' => number_format ( $other [$ot], 2, '.', '' )
  719. ) );
  720. $sum += $other [$ot];
  721. $otherSum += $other [$ot];
  722. }
  723. $ot ++;
  724. }
  725. }
  726. $accountJson ['cSum'] = array (
  727. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  728. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  729. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  730. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  731. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  732. );
  733. // 报销单
  734. $rid = $receipt->rid = $receiptDetail ['rid'];
  735. $receipt->accountItem = json_encode ( $accountJson );
  736. $receipt->staff = $this->staff [0] ['sid'];
  737. $receipt->sum = number_format ( $sum, 2, '.', '' );
  738. $receipt->date = date ( "Y-m-d" );
  739. $receipt->cid = $cid;
  740. if (($receiptDetail ['status'] != 4)) {
  741. if ($receiptDetail ['Rtype'] == 1)
  742. $receipt->status = 7;
  743. else
  744. $receipt->status = 5;
  745. }
  746. if ($receiptDetail != 4 && ! empty ( $verify ))
  747. $receipt->verify = $verify;
  748. $receipt->executeCopy = $executeDetail ['staff'];
  749. $order = array (
  750. "\r\n",
  751. "\n",
  752. "\r"
  753. );
  754. $replace = '<br/>';
  755. $explanation = str_replace ( $order, $replace, $explanation );
  756. $receipt->explanation = $explanation;
  757. $receipt->remittanceName = $remittanceName;
  758. $receipt->bankName = $bankName;
  759. $receipt->bankNumber = $bankNumber;
  760. $receipt->remittanceBankType = $remittanceBankType;
  761. if ($remittanceBankType == 1)
  762. $receipt->coupletNumber = $coupletNumber;
  763. $receipt->update ();
  764. $receiptDetail = new receiptDetail ();
  765. $receiptDetail->delete ( array (
  766. 'where' => 'rid=' . $rid
  767. ) );
  768. // 报销详情
  769. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  770. $receiptDetail = new receiptDetail ();
  771. $receiptDetail->staff = $this->staff [0] ['sid'];
  772. $receiptDetail->item = $value ['name'];
  773. $receiptDetail->itemCategory = $this->AGENCY;
  774. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  775. $receiptDetail->date = date ( "Y-m-d" );
  776. $receiptDetail->cid = $cid;
  777. $receiptDetail->rid = $rid;
  778. $receiptDetail->status = 4;
  779. $receiptDetail->insert ();
  780. }
  781. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  782. $receiptDetail = new receiptDetail ();
  783. $receiptDetail->staff = $this->staff [0] ['sid'];
  784. $receiptDetail->item = $value ['name'];
  785. $receiptDetail->itemCategory = $this->TRAVEL;
  786. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  787. $receiptDetail->date = date ( "Y-m-d" );
  788. $receiptDetail->cid = $cid;
  789. $receiptDetail->rid = $rid;
  790. $receiptDetail->status = 4;
  791. $receiptDetail->insert ();
  792. }
  793. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  794. $receiptDetail = new receiptDetail ();
  795. $receiptDetail->staff = $this->staff [0] ['sid'];
  796. $receiptDetail->item = $value ['name'];
  797. $receiptDetail->itemCategory = $this->TRAIN;
  798. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  799. $receiptDetail->date = date ( "Y-m-d" );
  800. $receiptDetail->cid = $cid;
  801. $receiptDetail->rid = $rid;
  802. $receiptDetail->status = 4;
  803. $receiptDetail->insert ();
  804. }
  805. //内训
  806. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  807. $receiptDetail = new receiptDetail ();
  808. $receiptDetail->staff = $this->staff [0] ['sid'];
  809. $receiptDetail->item = $value ['name'];
  810. $receiptDetail->itemCategory = $this->INTTRAIN;
  811. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  812. $receiptDetail->date = date ( "Y-m-d" );
  813. $receiptDetail->cid = $cid;
  814. $receiptDetail->rid = $rid;
  815. $receiptDetail->status = 4;
  816. $receiptDetail->insert ();
  817. }
  818. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  819. $receiptDetail = new receiptDetail ();
  820. $receiptDetail->staff = $this->staff [0] ['sid'];
  821. $receiptDetail->item = $value ['name'];
  822. $receiptDetail->itemCategory = $this->OTHER;
  823. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  824. $receiptDetail->date = date ( "Y-m-d" );
  825. $receiptDetail->cid = $cid;
  826. $receiptDetail->rid = $rid;
  827. $receiptDetail->status = 4;
  828. $receiptDetail->insert ();
  829. }
  830. // 附件
  831. if (! empty ( $enclosurName )) {
  832. $enclosurArray = explode ( '-', $enclosurName );
  833. foreach ( $enclosurArray as $value ) {
  834. $enclosur = new enclosur ();
  835. $enclosur->name = $value;
  836. $enclosur->rid = $rid;
  837. $enclosur->insert ();
  838. }
  839. }
  840. // return "/referReceipt/".$rid;
  841. }
  842. return "/saeaBorad";
  843. }
  844. function remitAdd() {
  845. Doo::loadModel ( 'accountItem' );
  846. Doo::loadModel ( 'verify' );
  847. Doo::loadModel ( 'receipt' );
  848. Doo::loadModel ( 'L_category' );
  849. $lCategory = new L_category ();
  850. $receipt = new receipt ();
  851. $verify = new verify ();
  852. $accountItem = new accountItem ();
  853. Doo::loadModel ( "role" );
  854. $role = new role ();
  855. $acItem = $accountItem->find ( array (
  856. 'asArray' => true
  857. ) );
  858. $veList = $verify->getVerifyBySubordinate('REMIT');
  859. $data ['category'] = $lCategory->find ( array (
  860. 'asArray' => true
  861. ) );
  862. $data ['veList'] = $veList;
  863. $data ['acItem'] = $acItem;
  864. $data ['memu'] = "receipt";
  865. $data ['staff'] = $this->staff;
  866. $data ['receiptMemu'] = 'saeaBorad';
  867. $data ['verifyId'] = $this->verifyId;
  868. $data ['executeId'] = $this->executeId;
  869. $this->render ( "/admin/remitAdd", $data );
  870. }
  871. function remitAddDo() {
  872. $agency = $this->get_args ( 'agency' );
  873. $travel = $this->get_args ( 'travel' );
  874. $train = $this->get_args ( 'train' );
  875. $other = $this->get_args ( 'other' );
  876. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  877. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  878. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  879. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  880. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  881. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  882. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  883. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  884. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  885. // print_r($agency);die;
  886. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  887. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  888. header ( 'Content-Type:text/html;charset=utf-8' );
  889. die ( '请填写联行号' );
  890. }
  891. Doo::loadModel ( 'receipt' );
  892. Doo::loadModel ( 'receiptDetail' );
  893. Doo::loadModel ( 'accountItem' );
  894. $accountItem = new accountItem ();
  895. $receipt = new receipt ();
  896. Doo::loadModel ( 'enclosur' );
  897. Doo::loadModel ( 'execute' );
  898. $execute = new execute ();
  899. $executeDetail = $execute->getOne ( array (
  900. 'where' => 'mold="对公汇款执行人"',
  901. 'asArray' => true
  902. ) );
  903. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  904. $aItem = $accountItem->find ( array (
  905. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  906. 'asArray' => true
  907. ) );
  908. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  909. $ag = $tr = $ta = $ot = 0;
  910. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  911. print_r($aItem);
  912. foreach ( $aItem as $key => $value ) {
  913. if ($value ['category'] == $this->AGENCY) {
  914. if (isset ( $agency [$ag] )) {
  915. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  916. array_push ( $accountJson [$this->AGENCY], array (
  917. 'aid' => $value ['aid'],
  918. 'name' => $value ['name'],
  919. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  920. ) );
  921. $sum += $agency [$ag];
  922. $agencySum += $agency [$ag];
  923. }
  924. }
  925. $ag ++;
  926. }
  927. }
  928. $accountJson ['cSum'] = array (
  929. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  930. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  931. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  932. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  933. );
  934. //die;
  935. // 报销单
  936. $receipt->accountItem = json_encode ( $accountJson );
  937. $receipt->staff = $this->staff [0] ['sid'];
  938. $receipt->sum = number_format ( $sum, 2, '.', '' );
  939. $receipt->date = date ( "Y-m-d" );
  940. $receipt->cid = $cid;
  941. $receipt->status = 5;
  942. $receipt->Rtype = 2;
  943. // 修改审批流程加入角色
  944. $receipt->verify = $verify;
  945. $receipt->executeCopy = $executeDetail ['staff'];
  946. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  947. $order = array (
  948. "\r\n",
  949. "\n",
  950. "\r"
  951. );
  952. $replace = '<br/>';
  953. $explanation = str_replace ( $order, $replace, $explanation );
  954. $receipt->explanation = $explanation;
  955. $receipt->remittanceName = $remittanceName;
  956. $receipt->bankName = $bankName;
  957. $receipt->bankNumber = $bankNumber;
  958. $receipt->remittanceBankType = $remittanceBankType;
  959. if ($remittanceBankType == 1)
  960. $receipt->coupletNumber = $coupletNumber;
  961. $rid = $receipt->insert ();
  962. // 附件
  963. if (! empty ( $enclosurName )) {
  964. $enclosurArray = explode ( '-', $enclosurName );
  965. foreach ( $enclosurArray as $value ) {
  966. $enclosur = new enclosur ();
  967. $enclosur->name = $value;
  968. $enclosur->rid = $rid;
  969. $enclosur->insert ();
  970. }
  971. // print_r($enclosurArray);die;
  972. }
  973. // 报销详情
  974. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  975. $receiptDetail = new receiptDetail ();
  976. $receiptDetail->staff = $this->staff [0] ['sid'];
  977. $receiptDetail->item = $value ['name'];
  978. $receiptDetail->itemCategory = $this->AGENCY;
  979. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  980. $receiptDetail->date = date ( "Y-m-d" );
  981. $receiptDetail->cid = $cid;
  982. $receiptDetail->rid = $rid;
  983. $receiptDetail->status = 4;
  984. $receiptDetail->insert ();
  985. }
  986. return "/saeaBorad";
  987. } else
  988. die ( 'illegal request' );
  989. }
  990. function remitEdit() {
  991. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  992. Doo::loadClass ( 'XDeode' );
  993. $XDeode = new XDeode ( 7 );
  994. $rid = $XDeode->decode ( $ridKey );
  995. if (! is_numeric ( $rid ))
  996. die ( 'illegal request' );
  997. Doo::loadModel ( 'accountItem' );
  998. Doo::loadModel ( 'verify' );
  999. Doo::loadModel ( 'receipt' );
  1000. $receipt = new receipt ();
  1001. $verify = new verify ();
  1002. $accountItem = new accountItem ();
  1003. Doo::loadModel ( 'L_category' );
  1004. $lCategory = new L_category ();
  1005. Doo::loadModel ( "role" );
  1006. $role = new role ();
  1007. Doo::loadModel ( 'enclosur' );
  1008. $enclosur = new enclosur ();
  1009. $receiptDetail = $receipt->getOne ( array (
  1010. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  1011. 'asArray' => true
  1012. ) );
  1013. if (empty ( $receiptDetail ))
  1014. return "/saeaCreate";
  1015. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  1016. $acItem = $accountItem->find ( array (
  1017. 'asArray' => true
  1018. ) );
  1019. $veList = $verify->getVerifyBySubordinate('REMIT');
  1020. // 配置编辑信息
  1021. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1022. foreach ( $acItem as $key => $value ) {
  1023. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1024. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1025. $acItem [$key] ['price'] = $v ['price'];
  1026. }
  1027. }
  1028. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1029. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1030. $acItem [$key] ['price'] = $v ['price'];
  1031. }
  1032. }
  1033. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1034. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1035. $acItem [$key] ['price'] = $v ['price'];
  1036. }
  1037. }
  1038. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1039. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1040. $acItem [$key] ['price'] = $v ['price'];
  1041. }
  1042. }
  1043. }
  1044. $data ['category'] = $lCategory->find ( array (
  1045. 'asArray' => true
  1046. ) );
  1047. $data ['enclosurList'] = $enclosurList;
  1048. $data ['cSum'] = $accountItemList ['cSum'];
  1049. $data ['sum'] = $receiptDetail ['sum'];
  1050. $data ['receiptDetail'] = $receiptDetail;
  1051. $data ['veList'] = $veList;
  1052. $data ['acItem'] = $acItem;
  1053. $data ['memu'] = "receipt";
  1054. $data ['staff'] = $this->staff;
  1055. $data ['receiptMemu'] = 'saeaBorad';
  1056. $data ['verify'] = $receiptDetail ['verify'];
  1057. $data ['verifyId'] = $this->verifyId;
  1058. $data ['executeId'] = $this->executeId;
  1059. $data ['rid'] = $rid;
  1060. $data ['ridKey'] = $ridKey;
  1061. $this->render ( "/admin/remitEdit", $data );
  1062. }
  1063. function remitEdiDo() {
  1064. $agency = $this->get_args ( 'agency' );
  1065. $travel = $this->get_args ( 'travel' );
  1066. $train = $this->get_args ( 'train' );
  1067. $other = $this->get_args ( 'other' );
  1068. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1069. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1070. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1071. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1072. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1073. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1074. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1075. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1076. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1077. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1078. Doo::loadClass ( 'XDeode' );
  1079. $XDeode = new XDeode ( 7 );
  1080. $rid = $XDeode->decode ( $ridKey );
  1081. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1082. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1083. header ( 'Content-Type:text/html;charset=utf-8' );
  1084. die ( '请填写联行号' );
  1085. }
  1086. Doo::loadModel ( 'receipt' );
  1087. Doo::loadModel ( 'receiptDetail' );
  1088. Doo::loadModel ( 'accountItem' );
  1089. $accountItem = new accountItem ();
  1090. $receipt = new receipt ();
  1091. Doo::loadModel ( 'enclosur' );
  1092. $enclosur = new enclosur ();
  1093. Doo::loadModel ( 'execute' );
  1094. $execute = new execute ();
  1095. $executeDetail = $execute->getOne ( array (
  1096. 'where' => 'mold="对公汇款执行人"',
  1097. 'asArray' => true
  1098. ) );
  1099. $receiptDetail = $receipt->getOne ( array (
  1100. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  1101. 'asArray' => true
  1102. ) );
  1103. if (empty ( $receiptDetail ))
  1104. return "/saeaBorad";
  1105. $aItem = $accountItem->find ( array (
  1106. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  1107. 'asArray' => true
  1108. ) );
  1109. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1110. $ag = $tr = $ta = $ot = 0;
  1111. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1112. foreach ( $aItem as $key => $value ) {
  1113. if ($value ['category'] == $this->AGENCY) {
  1114. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1115. array_push ( $accountJson [$this->AGENCY], array (
  1116. 'aid' => $value ['aid'],
  1117. 'name' => $value ['name'],
  1118. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1119. ) );
  1120. $sum += $agency [$ag];
  1121. $agencySum += $agency [$ag];
  1122. }
  1123. $ag ++;
  1124. }
  1125. }
  1126. $accountJson ['cSum'] = array (
  1127. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1128. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1129. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1130. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1131. );
  1132. // 报销单
  1133. $rid = $receipt->rid = $receiptDetail ['rid'];
  1134. $receipt->accountItem = json_encode ( $accountJson );
  1135. $receipt->staff = $this->staff [0] ['sid'];
  1136. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1137. $receipt->date = date ( "Y-m-d" );
  1138. $receipt->cid = $cid;
  1139. if ($receiptDetail ['Rtype'] == 1)
  1140. $receipt->status = 7;
  1141. else
  1142. $receipt->status = 5;
  1143. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  1144. $receipt->verify = $verify;
  1145. $receipt->executeCopy = $executeDetail ['staff'];
  1146. $order = array (
  1147. "\r\n",
  1148. "\n",
  1149. "\r"
  1150. );
  1151. $replace = '<br/>';
  1152. $explanation = str_replace ( $order, $replace, $explanation );
  1153. $receipt->explanation = $explanation;
  1154. $receipt->remittanceName = $remittanceName;
  1155. $receipt->bankName = $bankName;
  1156. $receipt->bankNumber = $bankNumber;
  1157. $receipt->remittanceBankType = $remittanceBankType;
  1158. if ($remittanceBankType == 1)
  1159. $receipt->coupletNumber = $coupletNumber;
  1160. $receipt->update ();
  1161. $receiptDetail = new receiptDetail ();
  1162. $receiptDetail->delete ( array (
  1163. 'where' => 'rid=' . $rid
  1164. ) );
  1165. // 报销详情
  1166. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1167. $receiptDetail = new receiptDetail ();
  1168. $receiptDetail->staff = $this->staff [0] ['sid'];
  1169. $receiptDetail->item = $value ['name'];
  1170. $receiptDetail->itemCategory = $this->AGENCY;
  1171. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1172. $receiptDetail->date = date ( "Y-m-d" );
  1173. $receiptDetail->cid = $cid;
  1174. $receiptDetail->rid = $rid;
  1175. $receiptDetail->status = 4;
  1176. $receiptDetail->insert ();
  1177. }
  1178. // 附件
  1179. if (! empty ( $enclosurName )) {
  1180. $enclosurArray = explode ( '-', $enclosurName );
  1181. foreach ( $enclosurArray as $value ) {
  1182. $enclosur = new enclosur ();
  1183. $enclosur->name = $value;
  1184. $enclosur->rid = $rid;
  1185. $enclosur->insert ();
  1186. }
  1187. }
  1188. }
  1189. return "/saeaBorad";
  1190. }
  1191. function remitApproval() {
  1192. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1193. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  1194. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  1195. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  1196. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  1197. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  1198. if (empty ( $status ))
  1199. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  1200. $vidList = array ();
  1201. $button = 0;
  1202. Doo::loadModel ( 'verify' );
  1203. Doo::loadModel ( 'receipt' );
  1204. Doo::loadModel ( 'staff' );
  1205. $staff = new staff ();
  1206. $receipt = new receipt ();
  1207. $verify = new verify ();
  1208. Doo::loadModel ( 'L_category' );
  1209. $Lcategory = new L_category ();
  1210. Doo::loadModel ( 'enclosur' );
  1211. $enclosur = new enclosur ();
  1212. // user verify ID
  1213. $verifyDetail = $verify->find ( array (
  1214. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  1215. 'asArray' => true
  1216. ) );
  1217. foreach ( $verifyDetail as $key => $value ) {
  1218. array_push ( $vidList, $value ['vid'] );
  1219. }
  1220. $vid = implode ( ",", $vidList );
  1221. if (empty ( $verifyDetail ))
  1222. $vid = 0;
  1223. $categoryList = $Lcategory->find ( array (
  1224. 'asArray' => true
  1225. ) );
  1226. $staffList = $staff->find ( array (
  1227. 'where' => 'cid=' . $cid,
  1228. 'asArray' => true
  1229. ) );
  1230. $ap = "";
  1231. if ($status == 4) {
  1232. $ap = 4;
  1233. $status = 2;
  1234. }
  1235. // get Receipt By verifyID status 2
  1236. $receiptList = $receipt->find ( array (
  1237. 'where' => 'rid =' . $rid . ' and status=2',
  1238. 'desc' => 'rid',
  1239. 'asArray' => true
  1240. ) );
  1241. if (empty ( $receiptList )) {
  1242. die ( 'illegal request' );
  1243. }
  1244. $Locate = 0;
  1245. $roleId = 0;
  1246. if ($ap == 4)
  1247. $status = 4;
  1248. foreach ( $receiptList as $key => $value ) {
  1249. $receiptList [$key] ['Locate'] = $Locate;
  1250. $Locate ++;
  1251. $receiptList [$key] ['reviseDetail'] = array ();
  1252. if (! empty ( $value ['reviseDetail'] ))
  1253. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1254. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1255. $categoryDetil = $Lcategory->getOne ( array (
  1256. 'where' => 'cid=' . $value ['cid'],
  1257. 'asArray' => true
  1258. ) );
  1259. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1260. // 检测编辑状态
  1261. $verifyList = $verify->getOne ( array (
  1262. 'where' => 'vid=' . $value ['verify'],
  1263. 'asArray' => true
  1264. ) );
  1265. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1266. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1267. Doo::loadModel ( 'role' );
  1268. $role = new role ();
  1269. // print_r($verifyList);
  1270. $flag = true;
  1271. $roleKey = 0;
  1272. $endStaffArray = array ();
  1273. $roleArrayCopy = array ();
  1274. foreach ( $verifyList as $k => $v ) {
  1275. // init verifyStaff
  1276. if ($v [1] == 'ROLE') {
  1277. if (! empty ( $verifyStaff )) {
  1278. $endStaffArray = end ( $verifyStaff );
  1279. if ($v [0] == $endStaffArray ['nextStaff']) {
  1280. $roleId = $v [0];
  1281. }
  1282. }
  1283. $roleVerify = json_decode ( $v [3], true );
  1284. $roleKey = $k;
  1285. $roleArray = array ();
  1286. $rolename = $role->getOne ( array (
  1287. 'where' => 'rid=' . $v [0],
  1288. 'asArray' => true
  1289. ) );
  1290. foreach ( $roleVerify as $o => $p ) {
  1291. $staffID = explode ( '_', $p );
  1292. $staffInfo = $staff->getOne ( array (
  1293. 'where' => 'sid=' . $staffID [0],
  1294. 'asArray' => true
  1295. ) );
  1296. // print_r($staffID);
  1297. $exp = array (
  1298. 0 => $staffInfo ['sid'],
  1299. 1 => $staffID [1],
  1300. 2 => $staffInfo ['avatar'],
  1301. 'date' => '',
  1302. 'date' => '',
  1303. 'opinion' => '',
  1304. 'status' => '',
  1305. 'rolename' => $rolename ['name']
  1306. );
  1307. array_push ( $roleArray, $exp );
  1308. }
  1309. $roleArrayCopy [$v [0]] = $roleArray;
  1310. // $verifyList[$k]['roleArray']=$roleArray;
  1311. }
  1312. // print_r($roleArray);
  1313. $verifyList [$k] ['date'] = "";
  1314. $verifyList [$k] ['opinion'] = "";
  1315. $verifyList [$k] ['status'] = "";
  1316. if (empty ( $verifyStaff )) {
  1317. $verifyList [$k] ['date'] = "";
  1318. $verifyList [$k] ['opinion'] = "";
  1319. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1320. $verifyList [$k] ['status'] = 4;
  1321. $button = 4;
  1322. $flag = false;
  1323. }
  1324. } else {
  1325. foreach ( $verifyStaff as $m => $u ) {
  1326. if ($v [0] == $m) {
  1327. $verifyList [$k] ['date'] = $u ['date'];
  1328. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1329. $verifyList [$k] ['status'] = $u ['status'];
  1330. $flag = false;
  1331. break;
  1332. }
  1333. }
  1334. $endStaffArray = end ( $verifyStaff );
  1335. if (isset ( $endStaffArray ['ROLE'] )) {
  1336. } else {
  1337. $endKey = key ( $verifyStaff );
  1338. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  1339. $button = 4;
  1340. $verifyList [$k] ['status'] = 4;
  1341. }
  1342. }
  1343. }
  1344. }
  1345. $rolename ['name'] = '';
  1346. if (! empty ( $roleId )) {
  1347. Doo::loadModel ( 'role' );
  1348. $role = new role ();
  1349. $rolename = $role->getOne ( array (
  1350. 'where' => 'rid=' . $roleId,
  1351. 'asArray' => true
  1352. ) );
  1353. }
  1354. if (! empty ( $verifyStaff ))
  1355. $endStaffArray = end ( $verifyStaff );
  1356. $KOP = false;
  1357. foreach ( $roleArrayCopy as $P => $A ) {
  1358. foreach ( $A as $MKI => $AVL ) {
  1359. if (! empty ( $verifyStaff )) {
  1360. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1361. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1362. $button = 4;
  1363. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1364. }
  1365. foreach ( $verifyStaff as $m => $u ) {
  1366. $AVLFK = $AVL [0] . '_R';
  1367. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1368. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1369. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1370. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1371. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1372. break;
  1373. }
  1374. }
  1375. } else {
  1376. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1377. $button = 4;
  1378. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1379. }
  1380. }
  1381. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1382. $KOP = true;
  1383. }
  1384. }
  1385. foreach ( $roleArrayCopy as $k => $v ) {
  1386. foreach ( $verifyList as $m => $n ) {
  1387. if ($n [0] == $k) {
  1388. array_splice ( $verifyList, $m, 1, $v );
  1389. }
  1390. }
  1391. }
  1392. $receiptList [$key] ['verifyList'] = $verifyList;
  1393. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1394. 'where' => 'sid=' . $value ['staff'],
  1395. 'asArray' => true
  1396. ) );
  1397. $receiptList [$key] ['button'] = $button;
  1398. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1399. }
  1400. $mothHtml = "";
  1401. for($i = 1; $i <= 12; $i ++) {
  1402. if ($month == $i)
  1403. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  1404. else
  1405. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  1406. }
  1407. // 获取审批日志
  1408. Doo::loadModel ( 'receiptLog' );
  1409. $receiptLog = new receiptLog ();
  1410. $rlList = array ();
  1411. $rlInfo = $receiptLog->getOne ( array (
  1412. 'where' => 'rid=' . $rid . ' and status=4',
  1413. 'asArray' => true
  1414. ) );
  1415. $tijdate = $receiptLog->getOne ( array (
  1416. 'where' => 'rid=' . $rid . ' and status=2',
  1417. 'asc' => 'rlid',
  1418. 'asArray' => true
  1419. ) );
  1420. if (! empty ( $rlInfo )) {
  1421. $rlList = $receiptLog->find ( array (
  1422. 'where' => 'rid=' . $rid,
  1423. 'asc' => 'rlid',
  1424. 'asArray' => true
  1425. ) );
  1426. }
  1427. $receiptList [0] ['rlList'] = $rlList;
  1428. $enclosurList = $enclosur->find ( array (
  1429. 'where' => 'rid=' . $rid,
  1430. 'asArray' => true
  1431. ) );
  1432. $enclosurHtml = '';
  1433. foreach ( $enclosurList as $value ) {
  1434. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  1435. }
  1436. // print_r($receiptList);
  1437. $data ['enclosurHtml'] = $enclosurHtml;
  1438. $data ['rolename'] = $rolename ['name'];
  1439. $data ['datetij'] = $tijdate ['date'];
  1440. $data ['mothHtml'] = $mothHtml;
  1441. $data ['rid'] = $rid;
  1442. $data ['receiptList'] = $receiptList;
  1443. $data ['receiptApprovalCount'] = count ( $receiptList );
  1444. $data ['status'] = $status;
  1445. $data ['year'] = $year;
  1446. $data ['categoryList'] = $categoryList;
  1447. $data ['staffList'] = $staffList;
  1448. $data ['cid'] = $cid;
  1449. $data ['sid'] = $sid;
  1450. $data ['ap'] = $ap;
  1451. $data ['memu'] = "receipt";
  1452. $data ['staff'] = $this->staff;
  1453. $data ['receiptMemu'] = 'approvalExpenses';
  1454. $data ['verifyId'] = $this->verifyId;
  1455. $data ['executeId'] = $this->executeId;
  1456. $this->render ( "/admin/remitApproval", $data );
  1457. }
  1458. function saeaLoanAdd() {
  1459. Doo::loadModel ( 'verify' );
  1460. $verify = new verify ();
  1461. Doo::loadModel ( "role" );
  1462. $role = new role ();
  1463. Doo::loadModel ( 'L_category' );
  1464. $lCategory = new L_category ();
  1465. $veList = $verify->getVerifyBySubordinate('LOAN');
  1466. $data ['category'] = $lCategory->find ( array (
  1467. 'asArray' => true
  1468. ) );
  1469. $data ['veList'] = $veList;
  1470. $data ['memu'] = "receipt";
  1471. $data ['staff'] = $this->staff;
  1472. $data ['receiptMemu'] = 'saeaBorad';
  1473. $data ['verifyId'] = $this->verifyId;
  1474. $data ['executeId'] = $this->executeId;
  1475. $this->render ( "/admin/saeaLoanAdd", $data );
  1476. }
  1477. function saeaLoanAddDo() {
  1478. $agency = $this->get_args ( 'agency' );
  1479. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1480. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1481. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1482. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1483. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1484. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1485. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1486. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1487. // die;
  1488. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1489. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1490. header ( 'Content-Type:text/html;charset=utf-8' );
  1491. die ( '请填写联行号' );
  1492. }
  1493. Doo::loadModel ( 'receipt' );
  1494. Doo::loadModel ( 'receiptDetail' );
  1495. Doo::loadModel ( 'accountItem' );
  1496. $accountItem = new accountItem ();
  1497. $receipt = new receipt ();
  1498. Doo::loadModel ( 'loanReceipt' );
  1499. $loanReceipt = new loanReceipt ();
  1500. Doo::loadModel ( 'execute' );
  1501. $execute = new execute ();
  1502. Doo::loadModel ( 'enclosur' );
  1503. $executeDetail = $execute->getOne ( array (
  1504. 'where' => 'mold="借款执行人"',
  1505. 'asArray' => true
  1506. ) );
  1507. $aItem = $accountItem->find ( array (
  1508. 'asArray' => true
  1509. ) );
  1510. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1511. $ag = $tr = $ta = $ot = 0;
  1512. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1513. array_push ( $accountJson ['借款费用'], array (
  1514. 'aid' => 0,
  1515. 'name' => '申请金额',
  1516. 'price' => number_format ( $agency, 2, '.', '' )
  1517. ) );
  1518. $sum += $agency;
  1519. $agencySum += $agency;
  1520. $accountJson ['cSum'] = array (
  1521. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1522. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1523. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1524. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1525. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1526. );
  1527. // 借款数据备份
  1528. $loanReceipt->loanItem = json_encode ( $accountJson );
  1529. $loanReceipt->staff = $this->staff [0] ['sid'];
  1530. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1531. $loanReceipt->date = date ( "Y-m-d" );
  1532. $loanReceipt->cid = $cid;
  1533. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1534. $loanReceipt->status = 5;
  1535. $loanReceipt->Rtype = 1;
  1536. $loanReceipt->verify = $verify;
  1537. $receipt->receiptOrder = $receipt->receiptOrder;
  1538. // 添加HTML换行符
  1539. // var_dump($explanation);
  1540. $order = array (
  1541. "\r\n",
  1542. "\n",
  1543. "\r"
  1544. );
  1545. $replace = '<br/>';
  1546. $explanation = str_replace ( $order, $replace, $explanation );
  1547. // $explanation=str_replace('\r',"<br/>",$explanation);
  1548. // $explanation=str_replace('\r\n',"<br/>",$explanation);
  1549. $loanReceipt->explanation = $explanation;
  1550. $loanRid = $loanReceipt->insert ();
  1551. // 报销单
  1552. $receipt->loanItem = json_encode ( $accountJson );
  1553. $receipt->staff = $this->staff [0] ['sid'];
  1554. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1555. $receipt->date = date ( "Y-m-d" );
  1556. $receipt->cid = $cid;
  1557. // 特殊状态
  1558. $receipt->status = 5;
  1559. $receipt->Rtype = 1;
  1560. $receipt->loanRid = $loanRid;
  1561. // 修改审批流程加入角色
  1562. $receipt->verify = $verify;
  1563. $receipt->executeCopy = $executeDetail ['staff'];
  1564. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  1565. $receipt->explanation = $explanation;
  1566. $receipt->remittanceName = $remittanceName;
  1567. $receipt->bankName = $bankName;
  1568. $receipt->bankNumber = $bankNumber;
  1569. $receipt->remittanceBankType = $remittanceBankType;
  1570. if ($remittanceBankType == 1)
  1571. $receipt->coupletNumber = $coupletNumber;
  1572. $rid = $receipt->insert ();
  1573. return "/saeaBorad";
  1574. } else
  1575. die ( 'illegal request' );
  1576. }
  1577. function saeaLoanEdi() {
  1578. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1579. Doo::loadClass ( 'XDeode' );
  1580. $XDeode = new XDeode ( 7 );
  1581. $rid = $XDeode->decode ( $ridKey );
  1582. if (! is_numeric ( $rid ))
  1583. die ( 'illegal request' );
  1584. Doo::loadModel ( 'verify' );
  1585. $verify = new verify ();
  1586. Doo::loadModel ( "role" );
  1587. $role = new role ();
  1588. Doo::loadModel ( 'L_category' );
  1589. $lCategory = new L_category ();
  1590. Doo::loadModel ( 'receipt' );
  1591. $receipt = new receipt ();
  1592. $receiptInfo = $receipt->getOne ( array (
  1593. 'where' => 'rid=' . $rid,
  1594. 'asArray' => true
  1595. ) );
  1596. $veList = $verify->find ( array (
  1597. 'where'=>'subordinate like "%LOAN%"',
  1598. 'asArray' => true
  1599. ) );
  1600. foreach ( $veList as $key => $value ) {
  1601. $v = json_decode ( $value ['staff'] );
  1602. $list = array ();
  1603. foreach ( $v as $n => $m ) {
  1604. if ($m ['1'] == 'ROLE') {
  1605. $roleInfo = $role->getOne ( array (
  1606. 'where' => 'rid=' . $m [0],
  1607. 'asArray' => true
  1608. ) );
  1609. $v [$n] [1] = $roleInfo ['name'];
  1610. array_push ( $list, $roleInfo ['name'] );
  1611. } else {
  1612. array_push ( $list, $v [$n] [1] );
  1613. }
  1614. }
  1615. $veList [$key] ['staff'] = implode ( '>', $list );
  1616. }
  1617. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  1618. // print_r($receiptInfo);
  1619. $data ['receiptInfo'] = $receiptInfo;
  1620. $data ['category'] = $lCategory->find ( array (
  1621. 'asArray' => true
  1622. ) );
  1623. $data ['veList'] = $veList;
  1624. $data ['ridKey'] = $ridKey;
  1625. $data ['memu'] = "receipt";
  1626. $data ['staff'] = $this->staff;
  1627. $data ['receiptMemu'] = 'saeaBorad';
  1628. $data ['verifyId'] = $this->verifyId;
  1629. $data ['executeId'] = $this->executeId;
  1630. $this->render ( "/admin/saeaLoanEdi", $data );
  1631. }
  1632. function saeaLoanEdiDo() {
  1633. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1634. $agency = $this->get_args ( 'agency' );
  1635. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1636. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1637. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1638. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1639. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1640. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1641. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1642. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1643. // die;
  1644. Doo::loadClass ( 'XDeode' );
  1645. $XDeode = new XDeode ( 7 );
  1646. $rid = $XDeode->decode ( $ridKey );
  1647. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1648. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1649. header ( 'Content-Type:text/html;charset=utf-8' );
  1650. die ( '请填写联行号' );
  1651. }
  1652. Doo::loadModel ( 'receipt' );
  1653. Doo::loadModel ( 'receiptDetail' );
  1654. Doo::loadModel ( 'accountItem' );
  1655. $accountItem = new accountItem ();
  1656. $receipt = new receipt ();
  1657. Doo::loadModel ( 'loanReceipt' );
  1658. $loanReceipt = new loanReceipt ();
  1659. Doo::loadModel ( 'enclosur' );
  1660. Doo::loadModel ( 'execute' );
  1661. $execute = new execute ();
  1662. $executeDetail = $execute->getOne ( array (
  1663. 'where' => 'mold="借款执行人"',
  1664. 'asArray' => true
  1665. ) );
  1666. $receiptDetail = $receipt->getOne ( array (
  1667. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  1668. 'asArray' => true
  1669. ) );
  1670. if (empty ( $receiptDetail ))
  1671. die ( '参数错误' );
  1672. $aItem = $accountItem->find ( array (
  1673. 'asArray' => true
  1674. ) );
  1675. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1676. $ag = $tr = $ta = $ot = 0;
  1677. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1678. array_push ( $accountJson ['借款费用'], array (
  1679. 'aid' => 0,
  1680. 'name' => '申请金额',
  1681. 'price' => number_format ( $agency, 2, '.', '' )
  1682. ) );
  1683. $sum += $agency;
  1684. $agencySum += $agency;
  1685. $accountJson ['cSum'] = array (
  1686. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1687. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1688. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1689. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1690. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1691. );
  1692. // 报销单
  1693. $receipt->loanItem = json_encode ( $accountJson );
  1694. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1695. $receipt->cid = $cid;
  1696. // 特殊状态
  1697. // 修改审批流程加入角色
  1698. if ($receiptDetail ['status'] != 4)
  1699. $receipt->verify = $verify;
  1700. $order = array (
  1701. "\r\n",
  1702. "\n",
  1703. "\r"
  1704. );
  1705. $replace = '<br/>';
  1706. $explanation = str_replace ( $order, $replace, $explanation );
  1707. $receipt->explanation = $explanation;
  1708. $receipt->remittanceName = $remittanceName;
  1709. $receipt->bankName = $bankName;
  1710. $receipt->bankNumber = $bankNumber;
  1711. $receipt->remittanceBankType = $remittanceBankType;
  1712. if ($remittanceBankType == 1)
  1713. $receipt->coupletNumber = $coupletNumber;
  1714. $receipt->update ( array (
  1715. 'where' => 'rid=' . $rid
  1716. ) );
  1717. // 借款数据更新
  1718. $loanReceipt->loanItem = json_encode ( $accountJson );
  1719. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1720. $loanReceipt->cid = $cid;
  1721. if ($receiptDetail ['status'] != 4)
  1722. $loanReceipt->verify = $verify;
  1723. $loanReceipt->explanation = $explanation;
  1724. $receipt->executeCopy = $executeDetail ['staff'];
  1725. $loanReceipt->update ( array (
  1726. 'where' => 'rid=' . $receiptDetail ['loanRid']
  1727. ) );
  1728. }
  1729. return "/saeaBorad";
  1730. }
  1731. function saeaLoanReceiptAdd() {
  1732. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1733. Doo::loadModel ( 'receipt' );
  1734. $receipt = new receipt ();
  1735. Doo::loadModel ( 'loanReceipt' );
  1736. $loanReceipt = new loanReceipt ();
  1737. Doo::loadModel ( 'L_category' );
  1738. $Lcategory = new L_category ();
  1739. Doo::loadModel ( 'verify' );
  1740. Doo::loadModel ( 'statistics' );
  1741. $statistics = new statistics ();
  1742. $verify = new verify ();
  1743. Doo::loadModel ( 'staff' );
  1744. $staff = new staff ();
  1745. $receiptDetail = $receipt->getOne ( array (
  1746. 'where' => 'rid=' . $rid,
  1747. 'desc' => 'rid',
  1748. 'asArray' => true
  1749. ) );
  1750. $receiptList = $loanReceipt->find ( array (
  1751. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1752. 'desc' => 'rid',
  1753. 'asArray' => true
  1754. ) );
  1755. $Locate = 0;
  1756. $roleId = 0;
  1757. $button = 0;
  1758. foreach ( $receiptList as $key => $value ) {
  1759. $receiptList [$key] ['Locate'] = $Locate;
  1760. $Locate ++;
  1761. $receiptList [$key] ['reviseDetail'] = array ();
  1762. if (! empty ( $value ['reviseDetail'] ))
  1763. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1764. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1765. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1766. $categoryDetil = $Lcategory->getOne ( array (
  1767. 'where' => 'cid=' . $value ['cid'],
  1768. 'asArray' => true
  1769. ) );
  1770. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1771. // 检测编辑状态
  1772. $verifyList = $verify->getOne ( array (
  1773. 'where' => 'vid=' . $value ['verify'],
  1774. 'asArray' => true
  1775. ) );
  1776. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1777. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1778. Doo::loadModel ( 'role' );
  1779. $role = new role ();
  1780. $flag = true;
  1781. $roleKey = 0;
  1782. $endStaffArray = array ();
  1783. $roleArrayCopy = array ();
  1784. foreach ( $verifyList as $k => $v ) {
  1785. // init verifyStaff
  1786. if ($v [1] == 'ROLE') {
  1787. if (! empty ( $verifyStaff )) {
  1788. $endStaffArray = end ( $verifyStaff );
  1789. // if ($v[0]==$endStaffArray['nextStaff']){
  1790. // $roleId=$v[0];
  1791. // }
  1792. }
  1793. $roleVerify = json_decode ( $v [3], true );
  1794. $roleKey = $k;
  1795. $roleArray = array ();
  1796. $rolename = $role->getOne ( array (
  1797. 'where' => 'rid=' . $v [0],
  1798. 'asArray' => true
  1799. ) );
  1800. foreach ( $roleVerify as $o => $p ) {
  1801. $staffID = explode ( '_', $p );
  1802. $staffInfo = $staff->getOne ( array (
  1803. 'where' => 'sid=' . $staffID [0],
  1804. 'asArray' => true
  1805. ) );
  1806. // print_r($staffID);
  1807. $exp = array (
  1808. 0 => $staffInfo ['sid'],
  1809. 1 => $staffID [1],
  1810. 2 => $staffInfo ['avatar'],
  1811. 'date' => '',
  1812. 'date' => '',
  1813. 'opinion' => '',
  1814. 'status' => '',
  1815. 'rolename' => $rolename ['name']
  1816. );
  1817. array_push ( $roleArray, $exp );
  1818. }
  1819. $roleArrayCopy [$v [0]] = $roleArray;
  1820. // $verifyList[$k]['roleArray']=$roleArray;
  1821. }
  1822. $verifyList [$k] ['date'] = "";
  1823. $verifyList [$k] ['opinion'] = "";
  1824. $verifyList [$k] ['status'] = "";
  1825. if (empty ( $verifyStaff )) {
  1826. $verifyList [$k] ['date'] = "";
  1827. $verifyList [$k] ['opinion'] = "";
  1828. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1829. $verifyList [$k] ['status'] = 4;
  1830. $flag = false;
  1831. }
  1832. } else {
  1833. foreach ( $verifyStaff as $m => $u ) {
  1834. if ($v [0] == $m) {
  1835. $verifyList [$k] ['date'] = $u ['date'];
  1836. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1837. $verifyList [$k] ['status'] = $u ['status'];
  1838. $flag = false;
  1839. break;
  1840. }
  1841. }
  1842. $endStaffArray = end ( $verifyStaff );
  1843. if (isset ( $endStaffArray ['ROLE'] )) {
  1844. } else {
  1845. // $endKey=key($verifyStaff);
  1846. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1847. // $button=4;
  1848. // $verifyList[$k]['status']=4;
  1849. // }
  1850. }
  1851. }
  1852. }
  1853. $rolename ['name'] = '';
  1854. if (! empty ( $roleId )) {
  1855. Doo::loadModel ( 'role' );
  1856. $role = new role ();
  1857. $rolename = $role->getOne ( array (
  1858. 'where' => 'rid=' . $roleId,
  1859. 'asArray' => true
  1860. ) );
  1861. }
  1862. if (! empty ( $verifyStaff ))
  1863. $endStaffArray = end ( $verifyStaff );
  1864. $KOP = false;
  1865. foreach ( $roleArrayCopy as $P => $A ) {
  1866. foreach ( $A as $MKI => $AVL ) {
  1867. if (! empty ( $verifyStaff )) {
  1868. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1869. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1870. $button = 4;
  1871. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1872. }
  1873. foreach ( $verifyStaff as $m => $u ) {
  1874. $AVLFK = $AVL [0] . '_R';
  1875. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1876. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1877. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1878. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1879. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1880. break;
  1881. }
  1882. }
  1883. } else {
  1884. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1885. $button = 4;
  1886. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1887. }
  1888. }
  1889. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1890. $KOP = true;
  1891. }
  1892. }
  1893. foreach ( $roleArrayCopy as $k => $v ) {
  1894. foreach ( $verifyList as $m => $n ) {
  1895. if ($n [0] == $k) {
  1896. array_splice ( $verifyList, $m, 1, $v );
  1897. }
  1898. }
  1899. }
  1900. $receiptList [$key] ['verifyList'] = $verifyList;
  1901. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1902. 'where' => 'sid=' . $value ['staff'],
  1903. 'asArray' => true
  1904. ) );
  1905. $receiptList [$key] ['button'] = $button;
  1906. //
  1907. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1908. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1909. }
  1910. $data ['receiptList'] = $receiptList;
  1911. $data ['receiptDetail'] = $receiptDetail;
  1912. Doo::loadModel ( 'L_category' );
  1913. $lCategory = new L_category ();
  1914. Doo::loadModel ( 'accountItem' );
  1915. $accountItem = new accountItem ();
  1916. $acItem = $accountItem->find ( array (
  1917. 'asArray' => true
  1918. ) );
  1919. $veList = $verify->getVerifyBySubordinate('RECEIPT','LOAN');
  1920. $data ['rid'] = $rid;
  1921. $data ['category'] = $lCategory->find ( array (
  1922. 'asArray' => true
  1923. ) );
  1924. $data ['veList'] = $veList;
  1925. $data ['acItem'] = $acItem;
  1926. $data ['memu'] = "receipt";
  1927. $data ['staff'] = $this->staff;
  1928. $data ['receiptMemu'] = 'saeaBorad';
  1929. $data ['verifyId'] = $this->verifyId;
  1930. $data ['executeId'] = $this->executeId;
  1931. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1932. }
  1933. function saeaLoanReceiptAddDo() {
  1934. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1935. $agency = $this->get_args ( 'agency' );
  1936. $travel = $this->get_args ( 'travel' );
  1937. $train = $this->get_args ( 'train' );
  1938. $other = $this->get_args ( 'other' );
  1939. $inttrain = $this->get_args ( 'inttrain' );
  1940. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1941. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1942. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1943. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1944. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1945. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1946. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1947. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1948. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1949. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1950. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1951. header ( 'Content-Type:text/html;charset=utf-8' );
  1952. die ( '请填写联行号' );
  1953. }
  1954. Doo::loadModel ( 'receipt' );
  1955. Doo::loadModel ( 'receiptDetail' );
  1956. Doo::loadModel ( 'accountItem' );
  1957. $accountItem = new accountItem ();
  1958. $receipt = new receipt ();
  1959. Doo::loadModel ( 'enclosur' );
  1960. Doo::loadModel ( 'execute' );
  1961. $execute = new execute ();
  1962. $executeDetail = $execute->getOne ( array (
  1963. 'where' => 'mold="借款费用执行人"',
  1964. 'asArray' => true
  1965. ) );
  1966. $receiptDet = $receipt->getOne ( array (
  1967. 'where' => 'rid=' . $rid,
  1968. 'asArray' => true
  1969. ) );
  1970. // if(!empty($receiptDetail))
  1971. // return "/referReceipt/".$receiptDetail['rid'];
  1972. $aItem = $accountItem->find ( array (
  1973. 'asArray' => true
  1974. ) );
  1975. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1976. $ag = $tr = $ta = $ot =$it = 0;
  1977. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  1978. foreach ( $aItem as $key => $value ) {
  1979. if ($value ['category'] == $this->AGENCY) {
  1980. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1981. array_push ( $accountJson [$this->AGENCY], array (
  1982. 'aid' => $value ['aid'],
  1983. 'name' => $value ['name'],
  1984. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1985. ) );
  1986. $sum += $agency [$ag];
  1987. $agencySum += $agency [$ag];
  1988. }
  1989. $ag ++;
  1990. }
  1991. if ($value ['category'] == $this->TRAVEL) {
  1992. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1993. array_push ( $accountJson [$this->TRAVEL], array (
  1994. 'aid' => $value ['aid'],
  1995. 'name' => $value ['name'],
  1996. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1997. ) );
  1998. $sum += $travel [$tr];
  1999. $travelSum += $travel [$tr];
  2000. }
  2001. $tr ++;
  2002. }
  2003. if ($value ['category'] == $this->INTTRAIN) {
  2004. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  2005. array_push ( $accountJson [$this->INTTRAIN], array (
  2006. 'aid' => $value ['aid'],
  2007. 'name' => $value ['name'],
  2008. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  2009. ) );
  2010. $sum += $inttrain [$it];
  2011. $inttrainSum += $inttrain [$it];
  2012. }
  2013. $it ++;
  2014. }
  2015. if ($value ['category'] == $this->TRAIN) {
  2016. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  2017. array_push ( $accountJson [$this->TRAIN], array (
  2018. 'aid' => $value ['aid'],
  2019. 'name' => $value ['name'],
  2020. 'price' => number_format ( $train [$ta], 2, '.', '' )
  2021. ) );
  2022. $sum += $train [$ta];
  2023. $trainSum += $train [$ta];
  2024. }
  2025. $ta ++;
  2026. }
  2027. if ($value ['category'] == $this->OTHER) {
  2028. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  2029. array_push ( $accountJson [$this->OTHER], array (
  2030. 'aid' => $value ['aid'],
  2031. 'name' => $value ['name'],
  2032. 'price' => number_format ( $other [$ot], 2, '.', '' )
  2033. ) );
  2034. $sum += $other [$ot];
  2035. $otherSum += $other [$ot];
  2036. }
  2037. $ot ++;
  2038. }
  2039. }
  2040. $accountJson ['cSum'] = array (
  2041. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  2042. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  2043. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  2044. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  2045. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  2046. );
  2047. // 报销单
  2048. $receipt->accountItem = json_encode ( $accountJson );
  2049. $receipt->staff = $this->staff [0] ['sid'];
  2050. $receipt->loanSum = $receiptDet ['sum'];
  2051. $receipt->sum = number_format ( $sum, 2, '.', '' );
  2052. $receipt->date = date ( "Y-m-d" );
  2053. $receipt->pastDate = '';
  2054. $receipt->cid = $cid;
  2055. $receipt->status = 7;
  2056. // 修改审批流程加入角色
  2057. $receipt->verify = $verify;
  2058. $receipt->verifyStaff = '';
  2059. $receipt->executeStaff = '';
  2060. $receipt->executeCopy = $executeDetail ['staff'];
  2061. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  2062. $receipt->explanation = $explanation;
  2063. $receipt->remittanceName = $remittanceName;
  2064. $receipt->bankName = $bankName;
  2065. $receipt->bankNumber = $bankNumber;
  2066. $receipt->remittanceBankType = $remittanceBankType;
  2067. if ($remittanceBankType == 1)
  2068. $receipt->coupletNumber = $coupletNumber;
  2069. $receipt->update ( array (
  2070. 'where' => 'rid=' . $rid
  2071. ) );
  2072. // 附件
  2073. if (! empty ( $enclosurName )) {
  2074. $enclosurArray = explode ( '-', $enclosurName );
  2075. foreach ( $enclosurArray as $value ) {
  2076. $enclosur = new enclosur ();
  2077. $enclosur->name = $value;
  2078. $enclosur->rid = $rid;
  2079. $enclosur->insert ();
  2080. }
  2081. // print_r($enclosurArray);die;
  2082. }
  2083. // 报销详情
  2084. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  2085. $receiptDetail = new receiptDetail ();
  2086. $receiptDetail->staff = $this->staff [0] ['sid'];
  2087. $receiptDetail->item = $value ['name'];
  2088. $receiptDetail->itemCategory = $this->AGENCY;
  2089. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2090. $receiptDetail->date = date ( "Y-m-d" );
  2091. $receiptDetail->cid = $cid;
  2092. $receiptDetail->rid = $rid;
  2093. $receiptDetail->status = 4;
  2094. $receiptDetail->insert ();
  2095. }
  2096. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  2097. $receiptDetail = new receiptDetail ();
  2098. $receiptDetail->staff = $this->staff [0] ['sid'];
  2099. $receiptDetail->item = $value ['name'];
  2100. $receiptDetail->itemCategory = $this->TRAVEL;
  2101. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2102. $receiptDetail->date = date ( "Y-m-d" );
  2103. $receiptDetail->cid = $cid;
  2104. $receiptDetail->rid = $rid;
  2105. $receiptDetail->status = 4;
  2106. $receiptDetail->insert ();
  2107. }
  2108. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  2109. $receiptDetail = new receiptDetail ();
  2110. $receiptDetail->staff = $this->staff [0] ['sid'];
  2111. $receiptDetail->item = $value ['name'];
  2112. $receiptDetail->itemCategory = $this->TRAIN;
  2113. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2114. $receiptDetail->date = date ( "Y-m-d" );
  2115. $receiptDetail->cid = $cid;
  2116. $receiptDetail->rid = $rid;
  2117. $receiptDetail->status = 4;
  2118. $receiptDetail->insert ();
  2119. }
  2120. //内训
  2121. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  2122. $receiptDetail = new receiptDetail ();
  2123. $receiptDetail->staff = $this->staff [0] ['sid'];
  2124. $receiptDetail->item = $value ['name'];
  2125. $receiptDetail->itemCategory = $this->INTTRAIN;
  2126. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2127. $receiptDetail->date = date ( "Y-m-d" );
  2128. $receiptDetail->cid = $cid;
  2129. $receiptDetail->rid = $rid;
  2130. $receiptDetail->status = 4;
  2131. $receiptDetail->insert ();
  2132. }
  2133. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  2134. $receiptDetail = new receiptDetail ();
  2135. $receiptDetail->staff = $this->staff [0] ['sid'];
  2136. $receiptDetail->item = $value ['name'];
  2137. $receiptDetail->itemCategory = $this->OTHER;
  2138. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2139. $receiptDetail->date = date ( "Y-m-d" );
  2140. $receiptDetail->cid = $cid;
  2141. $receiptDetail->rid = $rid;
  2142. $receiptDetail->status = 4;
  2143. $receiptDetail->insert ();
  2144. }
  2145. return "/saeaBorad";
  2146. }
  2147. return "/saeaLoanReceiptAdd/" . $rid;
  2148. }
  2149. function saeaLoanReceiptEdi() {
  2150. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2151. Doo::loadClass ( 'XDeode' );
  2152. $XDeode = new XDeode ( 7 );
  2153. $rid = $XDeode->decode ( $ridKey );
  2154. if (! is_numeric ( $rid ))
  2155. die ( 'illegal request' );
  2156. Doo::loadModel ( 'accountItem' );
  2157. Doo::loadModel ( 'verify' );
  2158. Doo::loadModel ( 'receipt' );
  2159. $receipt = new receipt ();
  2160. $verify = new verify ();
  2161. $accountItem = new accountItem ();
  2162. Doo::loadModel ( 'L_category' );
  2163. $Lcategory = new L_category ();
  2164. Doo::loadModel ( "role" );
  2165. $role = new role ();
  2166. Doo::loadModel ( 'loanReceipt' );
  2167. $loanReceipt = new loanReceipt ();
  2168. Doo::loadModel ( 'staff' );
  2169. $staff = new staff ();
  2170. $receiptDetail = $receipt->getOne ( array (
  2171. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  2172. 'asArray' => true
  2173. ) );
  2174. if (empty ( $receiptDetail ))
  2175. return "/saeaBorad";
  2176. $receiptList = $loanReceipt->find ( array (
  2177. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  2178. 'desc' => 'rid',
  2179. 'asArray' => true
  2180. ) );
  2181. $Locate = 0;
  2182. $roleId = 0;
  2183. $button = 0;
  2184. foreach ( $receiptList as $key => $value ) {
  2185. $receiptList [$key] ['Locate'] = $Locate;
  2186. $Locate ++;
  2187. $receiptList [$key] ['reviseDetail'] = array ();
  2188. if (! empty ( $value ['reviseDetail'] ))
  2189. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2190. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2191. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2192. $categoryDetil = $Lcategory->getOne ( array (
  2193. 'where' => 'cid=' . $value ['cid'],
  2194. 'asArray' => true
  2195. ) );
  2196. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2197. // 检测编辑状态
  2198. $verifyList = $verify->getOne ( array (
  2199. 'where' => 'vid=' . $value ['verify'],
  2200. 'asArray' => true
  2201. ) );
  2202. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2203. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2204. Doo::loadModel ( 'role' );
  2205. $role = new role ();
  2206. $flag = true;
  2207. $roleKey = 0;
  2208. $endStaffArray = array ();
  2209. $roleArrayCopy = array ();
  2210. foreach ( $verifyList as $k => $v ) {
  2211. // init verifyStaff
  2212. if ($v [1] == 'ROLE') {
  2213. if (! empty ( $verifyStaff )) {
  2214. $endStaffArray = end ( $verifyStaff );
  2215. // if ($v[0]==$endStaffArray['nextStaff']){
  2216. // $roleId=$v[0];
  2217. // }
  2218. }
  2219. $roleVerify = json_decode ( $v [3], true );
  2220. $roleKey = $k;
  2221. $roleArray = array ();
  2222. $rolename = $role->getOne ( array (
  2223. 'where' => 'rid=' . $v [0],
  2224. 'asArray' => true
  2225. ) );
  2226. foreach ( $roleVerify as $o => $p ) {
  2227. $staffID = explode ( '_', $p );
  2228. $staffInfo = $staff->getOne ( array (
  2229. 'where' => 'sid=' . $staffID [0],
  2230. 'asArray' => true
  2231. ) );
  2232. // print_r($staffID);
  2233. $exp = array (
  2234. 0 => $staffInfo ['sid'],
  2235. 1 => $staffID [1],
  2236. 2 => $staffInfo ['avatar'],
  2237. 'date' => '',
  2238. 'date' => '',
  2239. 'opinion' => '',
  2240. 'status' => '',
  2241. 'rolename' => $rolename ['name']
  2242. );
  2243. array_push ( $roleArray, $exp );
  2244. }
  2245. $roleArrayCopy [$v [0]] = $roleArray;
  2246. // $verifyList[$k]['roleArray']=$roleArray;
  2247. }
  2248. $verifyList [$k] ['date'] = "";
  2249. $verifyList [$k] ['opinion'] = "";
  2250. $verifyList [$k] ['status'] = "";
  2251. if (empty ( $verifyStaff )) {
  2252. $verifyList [$k] ['date'] = "";
  2253. $verifyList [$k] ['opinion'] = "";
  2254. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2255. $verifyList [$k] ['status'] = 4;
  2256. $flag = false;
  2257. }
  2258. } else {
  2259. foreach ( $verifyStaff as $m => $u ) {
  2260. if ($v [0] == $m) {
  2261. $verifyList [$k] ['date'] = $u ['date'];
  2262. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2263. $verifyList [$k] ['status'] = $u ['status'];
  2264. $flag = false;
  2265. break;
  2266. }
  2267. }
  2268. $endStaffArray = end ( $verifyStaff );
  2269. if (isset ( $endStaffArray ['ROLE'] )) {
  2270. } else {
  2271. // $endKey=key($verifyStaff);
  2272. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2273. // $button=4;
  2274. // $verifyList[$k]['status']=4;
  2275. // }
  2276. }
  2277. }
  2278. }
  2279. $rolename ['name'] = '';
  2280. if (! empty ( $roleId )) {
  2281. Doo::loadModel ( 'role' );
  2282. $role = new role ();
  2283. $rolename = $role->getOne ( array (
  2284. 'where' => 'rid=' . $roleId,
  2285. 'asArray' => true
  2286. ) );
  2287. }
  2288. if (! empty ( $verifyStaff ))
  2289. $endStaffArray = end ( $verifyStaff );
  2290. $KOP = false;
  2291. foreach ( $roleArrayCopy as $P => $A ) {
  2292. foreach ( $A as $MKI => $AVL ) {
  2293. if (! empty ( $verifyStaff )) {
  2294. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2295. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2296. $button = 4;
  2297. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2298. }
  2299. foreach ( $verifyStaff as $m => $u ) {
  2300. $AVLFK = $AVL [0] . '_R';
  2301. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2302. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2303. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2304. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2305. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2306. break;
  2307. }
  2308. }
  2309. } else {
  2310. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2311. $button = 4;
  2312. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2313. }
  2314. }
  2315. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2316. $KOP = true;
  2317. }
  2318. }
  2319. foreach ( $roleArrayCopy as $k => $v ) {
  2320. foreach ( $verifyList as $m => $n ) {
  2321. if ($n [0] == $k) {
  2322. array_splice ( $verifyList, $m, 1, $v );
  2323. }
  2324. }
  2325. }
  2326. $receiptList [$key] ['verifyList'] = $verifyList;
  2327. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2328. 'where' => 'sid=' . $value ['staff'],
  2329. 'asArray' => true
  2330. ) );
  2331. $receiptList [$key] ['button'] = $button;
  2332. //
  2333. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  2334. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  2335. }
  2336. $data ['receiptList'] = $receiptList;
  2337. $acItem = $accountItem->find ( array (
  2338. 'asArray' => true
  2339. ) );
  2340. $veList = $verify->find ( array (
  2341. 'asArray' => true
  2342. ) );
  2343. foreach ( $veList as $key => $value ) {
  2344. $v = json_decode ( $value ['staff'] );
  2345. $list = array ();
  2346. foreach ( $v as $n => $m ) {
  2347. if ($m ['1'] == 'ROLE') {
  2348. $roleInfo = $role->getOne ( array (
  2349. 'where' => 'rid=' . $m [0],
  2350. 'asArray' => true
  2351. ) );
  2352. $v [$n] [1] = $roleInfo ['name'];
  2353. array_push ( $list, $roleInfo ['name'] );
  2354. } else {
  2355. array_push ( $list, $v [$n] [1] );
  2356. }
  2357. }
  2358. $veList [$key] ['staff'] = implode ( '>', $list );
  2359. }
  2360. // 配置编辑信息
  2361. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  2362. foreach ( $acItem as $key => $value ) {
  2363. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  2364. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  2365. $acItem [$key] ['price'] = $v ['price'];
  2366. }
  2367. }
  2368. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  2369. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  2370. $acItem [$key] ['price'] = $v ['price'];
  2371. }
  2372. }
  2373. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  2374. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  2375. $acItem [$key] ['price'] = $v ['price'];
  2376. }
  2377. }
  2378. //内训
  2379. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  2380. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  2381. $acItem [$key] ['price'] = $v ['price'];
  2382. }
  2383. }
  2384. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  2385. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  2386. $acItem [$key] ['price'] = $v ['price'];
  2387. }
  2388. }
  2389. }
  2390. $data ['category'] = $Lcategory->find ( array (
  2391. 'asArray' => true
  2392. ) );
  2393. $data ['ridKey'] = $ridKey;
  2394. $data ['cSum'] = $accountItemList ['cSum'];
  2395. $data ['sum'] = $receiptDetail ['sum'];
  2396. $data ['receiptDetail'] = $receiptDetail;
  2397. $data ['veList'] = $veList;
  2398. $data ['acItem'] = $acItem;
  2399. $data ['memu'] = "receipt";
  2400. $data ['staff'] = $this->staff;
  2401. $data ['receiptMemu'] = 'saeaBorad';
  2402. $data ['verify'] = $receiptDetail ['verify'];
  2403. $data ['verifyId'] = $this->verifyId;
  2404. $data ['executeId'] = $this->executeId;
  2405. $data ['rid'] = $rid;
  2406. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  2407. }
  2408. /**
  2409. * 培训班结算
  2410. */
  2411. function receiptTrainAdd() {
  2412. Doo::loadModel ( 'accountItem' );
  2413. $accountItem = new accountItem ();
  2414. $acItem = $accountItem->find ( array (
  2415. 'asArray' => true
  2416. ) );
  2417. // 审批组
  2418. Doo::loadModel ( 'verify' );
  2419. $verify = new verify ();
  2420. $veList = $verify->getVerifyBySubordinate('TRAIN');
  2421. // 办事处
  2422. Doo::loadModel ( 'L_category' );
  2423. $lCategory = new L_category ();
  2424. $data ['category'] = $lCategory->getCategory ();
  2425. $data ['veList'] = $veList;
  2426. $data ['memu'] = "receipt";
  2427. $data ['staff'] = $this->staff;
  2428. $data ['acItem'] = $acItem;
  2429. $data ['receiptMemu'] = 'saeaBorad';
  2430. $data ['verifyId'] = $this->verifyId;
  2431. $data ['executeId'] = $this->executeId;
  2432. $this->render ( "/receipt/receiptTrainAdd", $data );
  2433. }
  2434. /**
  2435. * 添加培训班结算
  2436. */
  2437. function receiptTrainAddDo() {//include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  2438. // 培训班信息
  2439. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  2440. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  2441. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  2442. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  2443. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  2444. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  2445. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  2446. // 发票信息
  2447. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2448. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2449. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2450. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2451. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2452. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2453. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2454. //&&! empty ( $participants )
  2455. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  2456. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2457. header ( 'Content-Type:text/html;charset=utf-8' );
  2458. die ( '请填写联行号' );
  2459. }
  2460. Doo::loadModel ( 'execute' );
  2461. $execute = new execute ();
  2462. $executeDetail = $execute->getOne ( array (
  2463. 'where' => 'mold="培训班结算"',
  2464. 'asArray' => true
  2465. ) );
  2466. if (empty ( $executeDetail )) {
  2467. header ( 'Content-Type:text/html;charset=utf-8' );
  2468. die ( '未设置执行人' );
  2469. }
  2470. Doo::loadClass ( 'XDeode' );
  2471. $XDeode = new XDeode ( 5 );
  2472. $cid = $XDeode->decode ( $cid );
  2473. Doo::loadModel ( 'receipt' );
  2474. $receipt = new receipt ();
  2475. Doo::loadModel ( 'receiptTraining' );
  2476. $receiptTraining = new receiptTraining ();
  2477. // 创建费用培训班
  2478. $item = array (
  2479. 'cid' => $this->staff [0] ['cid'],
  2480. 'categoryName' => $this->staff [0] ['category'],
  2481. 'trainName' => $trainName,
  2482. 'trainStartDate' => $trainStartDate,
  2483. 'trainEndDate' => $trainEndDate,
  2484. 'participants' => $participants,
  2485. 'freeParticipants'=>$freeParticipants,
  2486. 'trainAddress' => $trainAddress,
  2487. 'trainRemarks' => $trainRemarks,
  2488. 'creator' => $this->staff [0] ['sid'],
  2489. 'creatorDate' => date ( "Y-m-d H:i:s" )
  2490. );
  2491. $irid = $receiptTraining->addReceiptTraining ( $item );
  2492. // 报销单
  2493. $receipt->status = 5;
  2494. $receipt->trainId = $irid;
  2495. $receipt->Rtype = 3;
  2496. $receipt->staff = $this->staff [0] ['sid'];
  2497. $receipt->cid = $cid;
  2498. $receipt->verify = $verify;
  2499. $receipt->date = date ( "Y-m-d" );
  2500. $receipt->executeCopy = $executeDetail ['staff'];
  2501. $receipt->receiptOrder = "#P" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  2502. $receipt->remittanceName = $remittanceName;
  2503. $receipt->bankName = $bankName;
  2504. $receipt->bankNumber = $bankNumber;
  2505. $receipt->remittanceBankType = $remittanceBankType;
  2506. if ($remittanceBankType == 1)
  2507. $receipt->coupletNumber = $coupletNumber;
  2508. $rid = $receipt->insert ();
  2509. $XDeode = new XDeode ( 7 );
  2510. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html";
  2511. } else
  2512. die ( 'illegal request' );
  2513. }
  2514. /**
  2515. * 培训班编辑
  2516. */
  2517. function receiptTrainEdi() {
  2518. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2519. $trainEdiType = $this->get_args ( 'trainEdiType' ) ? $this->get_args ( 'trainEdiType' ) : "INFO";
  2520. Doo::loadClass ( 'XDeode' );
  2521. $XDeode = new XDeode ( 7 );
  2522. $rid = $XDeode->decode ( $ridKey );
  2523. if (! is_numeric ( $rid ))
  2524. die ( 'illegal request' );
  2525. Doo::loadModel ( 'receipt' );
  2526. $receipt = new receipt ();
  2527. Doo::loadModel ( 'receiptTraining' );
  2528. $receiptTraining = new receiptTraining ();
  2529. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2530. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)){
  2531. die ('illegal request--status');
  2532. }
  2533. //如有已入账已收款的发票,自动取消办事处已收款
  2534. // Doo::loadModel ( 'RIExtend' );
  2535. // $RIExtend = new RIExtend ();
  2536. // $RIExtendList=$RIExtend->getRIExtendByRid($rid);
  2537. // if (!empty($RIExtendList)){
  2538. // foreach ($RIExtendList as $key=>$value){
  2539. // $RIExtend = new RIExtend ();
  2540. // $RIExtend->delete(array (
  2541. // 'where' => 'iid=' . $value['iid'],
  2542. // 'limit' => 1
  2543. // ));
  2544. // }
  2545. // }
  2546. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2547. // 汇总表合计
  2548. // 收入合计--加入开票合计
  2549. Doo::loadModel ( 'invoiceTraining' );
  2550. $invoiceTraining = new invoiceTraining ();
  2551. $invoiceTrainingDetail = array (
  2552. 'invoiceArriveAmount' => 0,
  2553. 'RIAmount' => 0,
  2554. 'invoiceTotalAmount' => 0,
  2555. 'invoiceCompanyAmount'=>0
  2556. );
  2557. if ($receiptDetail ['invoiceTrainId'] != 0) {
  2558. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  2559. }
  2560. // print_r($invoiceTrainingDetail);
  2561. $invoiceArriveAmount = $RIAmount = 0;
  2562. if (! empty ( $invoiceTrainingDetail )) {
  2563. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  2564. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  2565. }
  2566. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  2567. //print_r($invoiceTrainingDetail);
  2568. // 支出项目
  2569. Doo::loadModel ( 'accountItem' );
  2570. $accountItem = new accountItem ();
  2571. // 项目金额合计
  2572. Doo::loadModel ( 'RItem' );
  2573. $RItem = new RItem ();
  2574. // 讲师获得
  2575. Doo::loadModel ( 'RILecturer' );
  2576. $RILecturer = new RILecturer ();
  2577. $RItemList = $RItem->getRItemByRid ( $rid );
  2578. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2579. // 支出项金额详情
  2580. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  2581. // print_r($aiData);
  2582. // 利润
  2583. $profit=$invoiceArriveAmount - $aiData ['total'];
  2584. $companyProfit=$profit * 0.6;
  2585. $categoryProfit=$profit * 0.4;
  2586. $data ['profit'] = sprintf("%.2f",$profit);
  2587. $data ['companyProfit'] = sprintf("%.2f",$companyProfit);
  2588. $data ['categoryProfit'] = sprintf("%.2f",$categoryProfit);
  2589. //发票利润
  2590. $data ['invoiceProfit'] = $invoiceTrainingDetail ['invoiceTotalAmount'] - $aiData ['total'];
  2591. //发票公司利润
  2592. $invoiceCompanyProfit=$data ['invoiceProfit'] * 0.6;
  2593. $data ['invoiceCompanyProfit'] = sprintf("%.2f",$invoiceCompanyProfit);
  2594. //办事处利润
  2595. $invoiceCategoryProfit=$data ['invoiceProfit'] * 0.4;
  2596. $data ['invoiceCategoryProfit'] = sprintf("%.2f",$invoiceCategoryProfit);
  2597. // print_r($aiData['dataList']);
  2598. $categoryActualExpenditure= $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  2599. $data ['categoryActualExpenditure'] = sprintf("%.2f",$categoryActualExpenditure);
  2600. // 备用金
  2601. $sum = 0;
  2602. $data ['receiptLoanDetail'] = array (
  2603. 'sum' => '0.00'
  2604. );
  2605. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  2606. //$data ['receiptLoanDetail'] = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2607. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2608. $sum=0;
  2609. foreach ($receiptLoanList as $key=>$value){
  2610. $sum+=$value['sum'];
  2611. }
  2612. $data ['receiptLoanDetail'] = array (
  2613. 'sum' => $sum
  2614. );
  2615. //$sum = $data ['receiptLoanDetail'] ['sum'];
  2616. }
  2617. $payment=$sum + $RIAmount - $categoryActualExpenditure;
  2618. $data ['payment'] = sprintf("%.2f",$payment);
  2619. $data ['total'] = sprintf("%.2f",$aiData ['total']);
  2620. $data ['aiCount'] = count ( $aiData ['dataList'] ) + 5;
  2621. $data ['aiList'] = $aiData ['dataList'];
  2622. // 占比计算
  2623. if ($invoiceArriveAmount != 0) {
  2624. $data ['totalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceArriveAmount* 100) ;
  2625. $data ['profitProportion'] = sprintf("%.2f",$profit / $invoiceArriveAmount*100) ; //number_format ( $profit / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2626. $data ['sumProportion'] = sprintf("%.2f",$sum / $invoiceArriveAmount*100) ; //number_format ( $sum / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2627. $data ['invoiceTotalAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceArriveAmount*100) ;
  2628. $data ['RIAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceArriveAmount*100) ;
  2629. $data ['companyProfitProportion'] = sprintf("%.2f",$companyProfit / $invoiceArriveAmount*100) ;
  2630. $data ['categoryProportion'] = sprintf("%.2f",$categoryProfit / $invoiceArriveAmount*100) ;
  2631. $data ['categoryActualExpenditureProportion'] = sprintf("%.2f",$categoryActualExpenditure / $invoiceArriveAmount*100) ;
  2632. $data ['paymentProportion'] = sprintf("%.2f",$payment / $invoiceArriveAmount*100) ;
  2633. } else {
  2634. $data ['totalProportion'] = $data ['profitProportion'] = $data ['sumProportion'] = $data ['invoiceTotalAmountProportion'] = $data ['RIAmountProportion'] = $data ['companyProfitProportion'] = $data ['categoryActualExpenditureProportion'] = $data ['paymentProportion'] = $data ['categoryProportion'] = 0;
  2635. }
  2636. //发票金额占比计算
  2637. if ($invoiceTrainingDetail ['invoiceTotalAmount'] != 0) {
  2638. //支出
  2639. $data ['invoicetotalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2640. //利润
  2641. $data ['invoiceprofitProportion'] = sprintf("%.2f",$data ['invoiceProfit'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2642. //公司利润
  2643. $data ['invoicecompanyProfitProportion'] = sprintf("%.2f", $invoiceCompanyProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2644. //办事处利润
  2645. $data ['invoicecategoryProportion'] = sprintf("%.2f", $invoiceCategoryProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2646. //公司收款
  2647. $data ['invoiceTotalAmountProportionB'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2648. //备用金
  2649. $data ['invoicesumProportion'] = sprintf("%.2f", $sum / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2650. //办事处收款
  2651. $data ['invoiceRIAmountProportion'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2652. //办事处实际支出
  2653. $data ['ICAEP'] = sprintf("%.2f", $categoryActualExpenditure / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2654. //付总部款
  2655. $data ['invoicepaymentProportion'] = sprintf("%.2f", $payment / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2656. }else{
  2657. $data ['invoiceprofitProportion'] =$data ['invoiceRIAmountProportion'] =$data ['invoicetotalProportion'] =$data ['invoiceTotalAmountProportionB'] =$data ['invoicesumProportion'] =$data ['ICAEP'] =$data ['invoicepaymentProportion'] =$data ['invoicecompanyProfitProportion'] =$data ['invoicecategoryProportion'] =0;
  2658. }
  2659. //讲师人数
  2660. Doo::loadModel ( 'RILecturer' );
  2661. $RILecturer = new RILecturer ();
  2662. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2663. $data['lectureCount']=count($RILecturerList);
  2664. // 审批组
  2665. Doo::loadModel ( 'verify' );
  2666. $verify = new verify ();
  2667. $veList = $verify->getVerifyBySubordinate('TRAIN');
  2668. // 办事处
  2669. Doo::loadModel ( 'L_category' );
  2670. $lCategory = new L_category ();
  2671. $data ['category'] = $lCategory->getCategory ();
  2672. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2673. $data ['receiptDetail'] = $receiptDetail;
  2674. $data ['veList'] = $veList;
  2675. $data ['trainEdiType'] = $trainEdiType;
  2676. $data ['ridKey'] = $ridKey;
  2677. $data ['memu'] = "receipt";
  2678. $data ['staff'] = $this->staff;
  2679. $data ['receiptMemu'] = 'saeaBorad';
  2680. $data ['verifyId'] = $this->verifyId;
  2681. $data ['executeId'] = $this->executeId;
  2682. $this->render ( "/receipt/receiptTrainEdi", $data );
  2683. }
  2684. /**
  2685. * 培训班借款编辑
  2686. */
  2687. function receiptTrainLoanEdi() {
  2688. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2689. Doo::loadClass ( 'XDeode' );
  2690. $XDeode = new XDeode ( 7 );
  2691. $rid = $XDeode->decode ( $ridKey );
  2692. if (! is_numeric ( $rid ))
  2693. die ( 'illegal request' );
  2694. Doo::loadModel ( 'receipt' );
  2695. $receipt = new receipt ();
  2696. Doo::loadModel ( 'receiptTraining' );
  2697. $receiptTraining = new receiptTraining ();
  2698. Doo::loadModel ( 'verify' );
  2699. $verify = new verify ();
  2700. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2701. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  2702. die ();
  2703. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2704. // 借款详情HTML
  2705. // 获得借款信息
  2706. $receiptLoanHtml = '';
  2707. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  2708. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2709. foreach ($receiptLoanList as $key=>$value){
  2710. // 获得某费用单审批信息
  2711. $verifylist = $verify->getVerifyByRid ( $value ['rid'] );
  2712. Doo::loadClass ( 'receipt.func' );
  2713. $extendHtml = '<p><a class="button"
  2714. href="javascript:if(window.confirm(\'确认移除?\'))window.location=\'/receiptTrainLoanRemoveDo/' . $receiptDetail ['ridKey'] . '/' . $value ['ridKey'] . '.html\'" data-toggle="modal">移除借款</a></p>';
  2715. $receiptLoanHtml .= _getReceiptLoanHtml ( $value, $verifylist, $extendHtml );
  2716. }
  2717. }
  2718. $data ['receiptLoanHtml'] = $receiptLoanHtml;
  2719. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2720. $data ['receiptDetail'] = $receiptDetail;
  2721. $data ['trainEdiType'] = "LOAN";
  2722. $data ['ridKey'] = $ridKey;
  2723. $data ['memu'] = "receipt";
  2724. $data ['staff'] = $this->staff;
  2725. $data ['receiptMemu'] = 'saeaBorad';
  2726. $data ['verifyId'] = $this->verifyId;
  2727. $data ['executeId'] = $this->executeId;
  2728. $this->render ( "/receipt/receiptTrainLoanEdi", $data );
  2729. }
  2730. /**
  2731. * 更新培训班结算基本信息
  2732. */
  2733. function receiptTrainInfoEdiDo() {
  2734. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  2735. $rtid = $this->get_args ( 'rtid' ) ? $this->get_args ( 'rtid' ) : "";
  2736. // 培训班信息
  2737. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  2738. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  2739. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  2740. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  2741. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  2742. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  2743. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  2744. // 发票信息
  2745. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2746. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2747. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2748. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2749. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2750. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2751. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2752. //&& ! empty ( $participants )
  2753. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  2754. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2755. header ( 'Content-Type:text/html;charset=utf-8' );
  2756. die ( '请填写联行号' );
  2757. }
  2758. Doo::loadClass ( 'XDeode' );
  2759. $XDeode = new XDeode ( 5 );
  2760. $cid = $XDeode->decode ( $cid );
  2761. $rtid = $XDeode->decode ( $rtid );
  2762. $rid = $XDeode->decode ( $rid );
  2763. if (! is_numeric ( $rtid ) || ! is_numeric ( $rid )) {
  2764. die ( 'illegal request-IdError' );
  2765. }
  2766. Doo::loadModel ( 'receipt' );
  2767. $receipt = new receipt ();
  2768. Doo::loadModel ( 'receiptTraining' );
  2769. $receiptTraining = new receiptTraining ();
  2770. // 更新费用培训班
  2771. $item = array (
  2772. 'rtid' => $rtid,
  2773. 'trainName' => $trainName,
  2774. 'trainStartDate' => $trainStartDate,
  2775. 'trainEndDate' => $trainEndDate,
  2776. 'participants' => $participants,
  2777. 'freeParticipants'=>$freeParticipants,
  2778. 'trainAddress' => $trainAddress,
  2779. 'trainRemarks' => $trainRemarks
  2780. );
  2781. $irid = $receiptTraining->setReceiptTrainByCondition ( $item );
  2782. // 报销单
  2783. $receipt->rid = $rid;
  2784. $receipt->cid = $cid;
  2785. $receipt->verify = $verify;
  2786. $receipt->remittanceName = $remittanceName;
  2787. $receipt->bankName = $bankName;
  2788. $receipt->bankNumber = $bankNumber;
  2789. $receipt->remittanceBankType = $remittanceBankType;
  2790. if ($remittanceBankType == 1)
  2791. $receipt->coupletNumber = $coupletNumber;
  2792. $receipt->update ();
  2793. $XDeode = new XDeode ( 7 );
  2794. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html?trainEdiType=INFO";
  2795. } else
  2796. die ( 'illegal request' );
  2797. }
  2798. /**
  2799. * 编辑培训班结算---更新借款
  2800. */
  2801. function receiptTrainLoanEdiDo() {
  2802. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2803. $ridLoanKey = $this->get_args ( 'ridLoanKey' ) ? $this->get_args ( 'ridLoanKey' ) : "";
  2804. if (! empty ( $ridKey ) && ! empty ( $ridLoanKey )) {
  2805. Doo::loadModel ( 'receipt' );
  2806. $receipt = new receipt ();
  2807. Doo::loadClass ( 'XDeode' );
  2808. $XDeode = new XDeode ( 5 );
  2809. $rid = $XDeode->decode ( $ridKey );
  2810. $ridLoan = $XDeode->decode ( $ridLoanKey );
  2811. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  2812. die ( 'illegal request-ridError' );
  2813. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2814. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  2815. // 不合法的数据if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  2816. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2817. die ( 'illegal request-receiptError' );
  2818. }
  2819. if ($receiptLoanDetail ['status'] != 8 || $receiptLoanDetail ['Rtype'] != 1) {
  2820. die ( 'illegal request-receipLoantError' );
  2821. }
  2822. // 培训班结算挂钩借款
  2823. $receipt = new receipt ();
  2824. $trainLoanRid=$ridLoan;
  2825. if (!empty($receiptDetail['trainLoanRid'])){
  2826. $trainLoanRid=$receiptDetail['trainLoanRid'].','.$ridLoan;
  2827. }
  2828. $item = array (
  2829. 'rid' => $rid,
  2830. 'trainLoanRid' => $trainLoanRid
  2831. );
  2832. $receipt->setReceiptByCondition ( $item );
  2833. // 更新借款状态变成已挂钩
  2834. $receipt = new receipt ();
  2835. $item = array (
  2836. 'rid' => $ridLoan,
  2837. 'status' => 10,
  2838. 'statusTrain' => 1
  2839. );
  2840. $receipt->setReceiptByCondition ( $item );
  2841. $XDeode = new XDeode ( 7 );
  2842. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  2843. } else
  2844. die ( 'illegal request' );
  2845. }
  2846. /**
  2847. * 编辑培训班结算--移除借款
  2848. */
  2849. function receiptTrainLoanRemoveDo() {
  2850. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : 0;
  2851. $ridLoanKey = isset ( $this->params ['ridLoanKey'] ) ? $this->params ['ridLoanKey'] : 0;
  2852. if (! empty ( $ridKey ) || ! empty ( $ridLoanKey )) {
  2853. Doo::loadModel ( 'receipt' );
  2854. $receipt = new receipt ();
  2855. Doo::loadClass ( 'XDeode' );
  2856. $XDeode = new XDeode ( 5 );
  2857. $rid = $XDeode->decode ( $ridKey );
  2858. $ridLoan = $XDeode->decode ( $ridLoanKey );
  2859. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  2860. die ( 'illegal request-ridError' );
  2861. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2862. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  2863. // 不合法的数据 !($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)
  2864. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2865. die ( 'illegal request-receiptError' );
  2866. }
  2867. if ($receiptLoanDetail ['status'] != 10 || $receiptLoanDetail ['Rtype'] != 1) {
  2868. die ( 'illegal request-receipLoantError' );
  2869. }
  2870. // 培训班结算挂钩借款
  2871. $receipt = new receipt ();
  2872. $trainLoanRidArray=explode(",", $receiptDetail['trainLoanRid']);
  2873. foreach ($trainLoanRidArray as $key=>$value){
  2874. if($value==$ridLoan){
  2875. unset($trainLoanRidArray[$key]);
  2876. }
  2877. }
  2878. $trainLoanRidString=implode(",", $trainLoanRidArray);
  2879. $item = array (
  2880. 'rid' => $rid,
  2881. 'trainLoanRid' => $trainLoanRidString
  2882. );
  2883. $receipt->setReceiptByCondition ( $item );
  2884. // 更新借款状态变成已挂钩
  2885. $receipt = new receipt ();
  2886. $item = array (
  2887. 'rid' => $ridLoan,
  2888. 'status' => 8,
  2889. 'statusTrain' => 0
  2890. );
  2891. $receipt->setReceiptByCondition ( $item );
  2892. $XDeode = new XDeode ( 7 );
  2893. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  2894. } else
  2895. die ( 'illegal request' );
  2896. }
  2897. /**
  2898. * 编辑培训班结算 ---开票
  2899. */
  2900. function receiptTrainInvoiceEdi() {
  2901. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2902. Doo::loadClass ( 'XDeode' );
  2903. $XDeode = new XDeode ( 7 );
  2904. $rid = $XDeode->decode ( $ridKey );
  2905. if (! is_numeric ( $rid ))
  2906. die ( 'illegal request' );
  2907. Doo::loadModel ( 'receipt' );
  2908. $receipt = new receipt ();
  2909. Doo::loadModel ( 'receiptTraining' );
  2910. $receiptTraining = new receiptTraining ();
  2911. Doo::loadModel ( 'invoice' );
  2912. $invoice = new invoice ();
  2913. Doo::loadModel ( 'invoiceTraining' );
  2914. $invoiceTraining = new invoiceTraining ();
  2915. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2916. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  2917. die ();
  2918. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2919. $invoiceList = $invoiceTrainingDetail = array ();
  2920. if ($receiptDetail ['invoiceTrainId'] != 0) {
  2921. $invoiceList = $invoice->getInvoicePrintedByItid ( $receiptDetail ['invoiceTrainId'] );
  2922. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  2923. }
  2924. //print_r($invoiceList);
  2925. $data ['invoiceList'] = $invoiceList;
  2926. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  2927. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2928. $data ['receiptDetail'] = $receiptDetail;
  2929. $data ['trainEdiType'] = "INVOICE";
  2930. $data ['ridKey'] = $ridKey;
  2931. $data ['memu'] = "receipt";
  2932. $data ['staff'] = $this->staff;
  2933. $data ['receiptMemu'] = 'saeaBorad';
  2934. $data ['verifyId'] = $this->verifyId;
  2935. $data ['executeId'] = $this->executeId;
  2936. $this->render ( "/receipt/receiptTrainInvoiceEdi", $data );
  2937. }
  2938. /**
  2939. * 编辑培训班结算---更新开票
  2940. */
  2941. function receiptTrainInvoiceEdiDo() {
  2942. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2943. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : "";
  2944. if (! empty ( $ridKey ) && ! empty ( $itidKey )) {
  2945. Doo::loadModel ( 'receipt' );
  2946. $receipt = new receipt ();
  2947. Doo::loadModel ( 'invoiceTraining' );
  2948. $invoiceTraining = new invoiceTraining ();
  2949. Doo::loadClass ( 'XDeode' );
  2950. $XDeode = new XDeode ( 5 );
  2951. $rid = $XDeode->decode ( $ridKey );
  2952. $itid = $XDeode->decode ( $itidKey );
  2953. if (! is_numeric ( $rid ) || ! is_numeric ( $itid ))
  2954. die ( 'illegal request-idError' );
  2955. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2956. $invoiceTrainDetail = $invoiceTraining->getInvoiceTrainingByItid ( $itid );
  2957. // 不合法的数据
  2958. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2959. die ( 'illegal request-receiptError' );
  2960. }
  2961. if (empty ( $invoiceTrainDetail ) || $invoiceTrainDetail ['bindReceipt'] == 1) {
  2962. die ( 'illegal request-receipLoantError' );
  2963. }
  2964. // 培训班结算挂钩借款
  2965. $receipt = new receipt ();
  2966. $item = array (
  2967. 'rid' => $rid,
  2968. 'invoiceTrainId' => $itid
  2969. );
  2970. $receipt->setReceiptByCondition ( $item );
  2971. $invoiceTraining = new invoiceTraining ();
  2972. $item = array (
  2973. 'bindReceipt' => 1,
  2974. 'itid' => $itid
  2975. );
  2976. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  2977. $XDeode = new XDeode ( 7 );
  2978. return "/receiptTrainInvoiceEdi/" . $XDeode->encode ( $rid ) . ".html";
  2979. } else
  2980. die ( 'illegal request' );
  2981. }
  2982. /**
  2983. * 更新培训班结算 收款和取消收款
  2984. */
  2985. function receiptTrainReceivables() {
  2986. $doType = isset ( $this->params ['doType'] ) ? $this->params ['doType'] : '';
  2987. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2988. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  2989. Doo::loadClass ( 'XDeode' );
  2990. $XDeode = new XDeode ( 5 );
  2991. $rid = $XDeode->decode ( $ridKey );
  2992. $iid = $XDeode->decode ( $iidKey );
  2993. if (! is_numeric ( $rid ) || ! is_numeric ( $iid ))
  2994. die ( 'illegal request-iid' );
  2995. Doo::loadModel ( 'RIExtend' );
  2996. $RIExtend = new RIExtend ();
  2997. if ($doType == 'CONFIRM') {
  2998. $RIExtend->rid = $rid;
  2999. $RIExtend->iid = $iid;
  3000. $RIExtend->RIstatus = 1;
  3001. $RIExtend->insert ();
  3002. echo json_encode ( array (
  3003. 'status' => 1,
  3004. ) );
  3005. die ( );
  3006. } elseif ($doType == 'CANCEL') {
  3007. $RIExtend->delete ( array (
  3008. 'where' => 'rid=' . $rid . ' and iid=' . $iid,
  3009. 'limit' => 1
  3010. ) );
  3011. echo json_encode ( array (
  3012. 'status' => 1,
  3013. ) );
  3014. die ( );
  3015. } else {
  3016. echo json_encode ( array (
  3017. 'status' => 2,
  3018. ) );
  3019. die ( );
  3020. }
  3021. }
  3022. /**
  3023. * 移除挂钩的培训班发票
  3024. */
  3025. function receiptTrainReceivablesDelDo() {
  3026. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  3027. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : ""; // 发票培训班
  3028. Doo::loadModel ( 'receipt' );
  3029. $receipt = new receipt ();
  3030. Doo::loadModel ( 'RIExtend' );
  3031. $RIExtend = new RIExtend ();
  3032. Doo::loadClass ( 'XDeode' );
  3033. $XDeode = new XDeode ( 5 );
  3034. $rid = $XDeode->decode ( $ridKey );
  3035. $itid = $XDeode->decode ( $itidKey );
  3036. if (is_numeric ( $rid ) && is_numeric ( $itid )) {
  3037. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3038. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  3039. die ( 'illegal request-status' );
  3040. }
  3041. $receipt = new receipt ();
  3042. $receipt->rid = $rid;
  3043. $receipt->invoiceTrainId = 0;
  3044. $receipt->update ();
  3045. Doo::loadModel ( 'invoiceTraining' );
  3046. $invoiceTraining = new invoiceTraining ();
  3047. $item = array (
  3048. 'bindReceipt' => 0,
  3049. 'itid' => $itid
  3050. );
  3051. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  3052. $RIExtend->delete ( array (
  3053. 'where' => 'rid=' . $rid
  3054. ) );
  3055. $XDeode = new XDeode ( 7 );
  3056. return '/receiptTrainInvoiceEdi/' . $XDeode->encode ( $rid ) . '.html';
  3057. } else
  3058. die ( 'illegal request-iid' );
  3059. }
  3060. /**
  3061. * 编辑培训班结算
  3062. */
  3063. function receiptTrainItemEdi() {
  3064. //include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  3065. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3066. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : '';
  3067. Doo::loadClass ( 'XDeode' );
  3068. $XDeode = new XDeode ( 7 );
  3069. $rid = $XDeode->decode ( $ridKey );
  3070. if (! is_numeric ( $rid ))
  3071. die ( 'illegal request' );
  3072. Doo::loadModel ( 'receipt' );
  3073. $receipt = new receipt ();
  3074. Doo::loadModel ( 'receiptTraining' );
  3075. $receiptTraining = new receiptTraining ();
  3076. Doo::loadModel ( 'RItem' );
  3077. $RItem = new RItem ();
  3078. Doo::loadModel ( 'accountItem' );
  3079. $accountItem = new accountItem ();
  3080. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3081. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3082. die ();
  3083. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3084. $RItemList = $RItem->getRItemByRid ( $rid,$name );
  3085. $aiList = $accountItem->getAccountBookByCategory ( '培训班费用' );//print_r($aiList);
  3086. // foreach ($aiList as $key=>$value){//不需要添加税款,在添加收入时自动添加
  3087. // if($value['name']=='税款'){
  3088. // unset($aiList[$key]);break;
  3089. // }
  3090. // }
  3091. //print_r($RItemList);
  3092. $data ['name'] = $name;
  3093. $data ['RItemList'] = $RItemList;
  3094. $data ['aiList'] = $aiList;
  3095. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3096. $data ['receiptDetail'] = $receiptDetail;
  3097. $data ['trainEdiType'] = "ITEM";
  3098. $data ['ridKey'] = $ridKey;
  3099. $data ['memu'] = "receipt";
  3100. $data ['staff'] = $this->staff;
  3101. $data ['receiptMemu'] = 'saeaBorad';
  3102. $data ['verifyId'] = $this->verifyId;
  3103. $data ['executeId'] = $this->executeId;
  3104. $this->render ( "/receipt/receiptTrainItemEdi", $data );
  3105. }
  3106. /**
  3107. * 添加支出项 需要修改 费用金额合计
  3108. */
  3109. function receiptTrainItemAddDo() {
  3110. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3111. $rtidKey = $this->get_args ( 'rtidKey' ) ? $this->get_args ( 'rtidKey' ) : "";
  3112. // 支出项信息
  3113. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  3114. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : 0;
  3115. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  3116. $inputer = $this->get_args ( 'inputer' ) ? $this->get_args ( 'inputer' ) : "";
  3117. $describe = $this->get_args ( 'describe' ) ? $this->get_args ( 'describe' ) : "";
  3118. //$identifyingTotal = $this->get_args ( 'identifyingTotal' )&&is_numeric($this->get_args ( 'identifyingTotal' )) ? $this->get_args ( 'identifyingTotal' ) : 0;
  3119. $payType = isset ( $this->params ['payType'] ) ? $this->params ['payType'] : '';
  3120. if (! empty ( $ridKey ) && ! empty ( $item ) && is_numeric( $price ) && ! empty ( $date ) && ! empty ( $inputer )) {
  3121. Doo::loadClass ( 'XDeode' );
  3122. $XDeode = new XDeode ( 5 );
  3123. Doo::loadModel ( 'RItem' );
  3124. $RItem = new RItem ();
  3125. $rid = $XDeode->decode ( $ridKey );
  3126. $rtid= $XDeode->decode ( $rtidKey );
  3127. if (! is_numeric ( $rid )){
  3128. die ( 'illegal request' );
  3129. }
  3130. Doo::loadModel ( 'receiptDetail' );
  3131. $receiptDetail = new receiptDetail ();
  3132. Doo::loadModel ( 'receipt' );
  3133. $receipt = new receipt ();
  3134. Doo::loadModel ( 'receiptTraining' );
  3135. $receiptTraining = new receiptTraining ();
  3136. $rtDetail=$receiptTraining->getReceiptTrainingByRtid($rtid);
  3137. $identifyingTotal=$rtDetail['identifyingTotal']+1;
  3138. $order = array (
  3139. "\r\n",
  3140. "\n",
  3141. "\r"
  3142. );
  3143. $replace = '<br/>';
  3144. $describe = str_replace ( $order, $replace, $describe );
  3145. $itemData = array (
  3146. 'rid' => $rid,
  3147. 'item' => $item,
  3148. 'price' => $price,
  3149. 'date' => $date,
  3150. 'inputer' => $inputer,
  3151. 'describe' => $describe,
  3152. 'creater' => $this->staff['0']['username'],
  3153. 'createrId' => $this->staff['0']['sid'],
  3154. 'creatDate' => date ( "Y-m-d H:i:s" ),
  3155. 'identifying'=>$identifyingTotal
  3156. );
  3157. if($payType=='company'){
  3158. $itemData += array (
  3159. 'payType' => 1
  3160. );
  3161. }
  3162. $RItem->addRItem($itemData, $receipt, $receiptDetail, $rid, $item, $price, $payType);
  3163. //更新支出项标识总数
  3164. $itemData = array (
  3165. 'rtid'=>$rtid,
  3166. 'identifyingTotal'=>$identifyingTotal
  3167. );
  3168. $receiptTraining->setReceiptTrainByCondition($itemData);
  3169. $XDeode = new XDeode ( 7 );
  3170. if($payType=='company'){
  3171. return '/receiptTrainItem/approval/' . $XDeode->encode ( $rid ) . '.html';
  3172. }else{
  3173. return '/receiptTrainItemEdi/' . $XDeode->encode ( $rid ) . '.html';
  3174. }
  3175. } else
  3176. die ( 'illegal request-dataError' );
  3177. }
  3178. /**
  3179. * 培训班结算-讲师
  3180. */
  3181. function receiptTrainLecturerEdi() {
  3182. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3183. Doo::loadClass ( 'XDeode' );
  3184. $XDeode = new XDeode ( 7 );
  3185. $rid = $XDeode->decode ( $ridKey );
  3186. if (! is_numeric ( $rid ))
  3187. die ( 'illegal request' );
  3188. Doo::loadModel ( 'receipt' );
  3189. $receipt = new receipt ();
  3190. Doo::loadModel ( 'receiptTraining' );
  3191. $receiptTraining = new receiptTraining ();
  3192. Doo::loadModel ( 'RILecturer' );
  3193. $RILecturer = new RILecturer ();
  3194. Doo::loadModel ( 'lecturer' );
  3195. $lecturer = new lecturer ();
  3196. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3197. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3198. die ();
  3199. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3200. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  3201. $lecturerList = $lecturer->getLecturerAll ();
  3202. $INSIDEhtml = $OUTSIDEhtml = '';
  3203. foreach ( $lecturerList as $key => $value ) {
  3204. if ($value ['ltype'] == 'INSIDE') {
  3205. $INSIDEhtml .= '<option value="' . $value ['category'] . '-' . $value ['staff'] . '">' . $value ['category'] . '-' . $value ['staff'] . '</option>';
  3206. } elseif ($value ['ltype'] == 'OUTSIDE') {
  3207. $OUTSIDEhtml .= '<option value="' . $value ['staff'] . '">' . $value ['staff'] . '</option>';
  3208. }
  3209. }
  3210. $data ['INSIDEhtml'] = $INSIDEhtml;
  3211. $data ['OUTSIDEhtml'] = $OUTSIDEhtml;
  3212. // print_r($RItemList);
  3213. $data ['RILecturerList'] = $RILecturerList;
  3214. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3215. $data ['receiptDetail'] = $receiptDetail;
  3216. $data ['trainEdiType'] = "LECTURER";
  3217. $data ['ridKey'] = $ridKey;
  3218. $data ['memu'] = "receipt";
  3219. $data ['staff'] = $this->staff;
  3220. $data ['receiptMemu'] = 'saeaBorad';
  3221. $data ['verifyId'] = $this->verifyId;
  3222. $data ['executeId'] = $this->executeId;
  3223. $this->render ( "/receipt/receiptTrainLecturerEdi", $data );
  3224. }
  3225. /**
  3226. * 添加讲师
  3227. */
  3228. function receiptTrainLecturerAddDo() {
  3229. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3230. // 支出项信息
  3231. $ltype = $this->get_args ( 'ltype' ) ? $this->get_args ( 'ltype' ) : "";
  3232. $lecturerName = $this->get_args ( 'lecturerName' ) ? $this->get_args ( 'lecturerName' ) : "";
  3233. $schoolDay = $this->get_args ( 'schoolDay' ) ? $this->get_args ( 'schoolDay' ) : "";
  3234. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  3235. $taxation = $this->get_args ( 'taxation' ) ? $this->get_args ( 'taxation' ) : "";
  3236. $fees = $this->get_args ( 'fees' ) ? $this->get_args ( 'fees' ) : "";
  3237. if (! empty ( $ridKey ) && ! empty ( $ltype ) && ! empty ( $lecturerName ) && ! empty ( $schoolDay ) && ! empty ( $price )) {
  3238. Doo::loadClass ( 'XDeode' );
  3239. $XDeode = new XDeode ( 5 );
  3240. Doo::loadModel ( 'RILecturer' );
  3241. $RILecturer = new RILecturer ();
  3242. $rid = $XDeode->decode ( $ridKey );
  3243. if (! is_numeric ( $rid ))
  3244. die ( 'illegal request' );
  3245. if ($ltype == 'OUTSIDE' && empty ( $taxation ))
  3246. die ( 'illegal request-taxationError' );
  3247. $RILecturer->rid = $rid;
  3248. $RILecturer->ltype = $ltype;
  3249. if ($ltype == 'OUTSIDE') {
  3250. if ($taxation == 'TAXATION') {
  3251. $RILecturer->taxation = 1;
  3252. } elseif ($taxation == 'NOTAXATION') {
  3253. $RILecturer->taxation = 0;
  3254. }
  3255. }
  3256. $RILecturer->lecturerName = $lecturerName;
  3257. $RILecturer->schoolDay = $schoolDay;
  3258. $RILecturer->price = $price;
  3259. $RILecturer->fees=$fees;
  3260. $RILecturer->insert ();
  3261. // 添加公司汇总
  3262. // 报销详情
  3263. Doo::loadModel ( 'receiptDetail' );
  3264. $receiptDetail = new receiptDetail ();
  3265. Doo::loadModel ( 'receipt' );
  3266. $receipt = new receipt ();
  3267. // 金额总计
  3268. $price = $price * $schoolDay;
  3269. $rInfo = $receipt->getReceiptByRid ( $rid );
  3270. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  3271. if (empty ( $rdInfo )) {
  3272. $receiptDetail = new receiptDetail ();
  3273. $receiptDetail->staff = $rInfo ['staff'];
  3274. $receiptDetail->item = '讲课费';
  3275. $receiptDetail->itemCategory = '培训班费用';
  3276. $receiptDetail->price = number_format ( $fees, 2, '.', '' );
  3277. $receiptDetail->date = date ( "Y-m-d" );
  3278. $receiptDetail->cid = $rInfo ['cid'];
  3279. $receiptDetail->rid = $rid;
  3280. $receiptDetail->status = 4;
  3281. $receiptDetail->insert ();
  3282. } else {
  3283. $receiptDetail = new receiptDetail ();
  3284. $rdInfo ['price'] += $fees;
  3285. $receiptDetail->price = $rdInfo ['price'];
  3286. $receiptDetail->update ( array (
  3287. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  3288. ) );
  3289. }
  3290. $receipt = new receipt ();
  3291. $receipt->sum=$rInfo['sum']+$fees;
  3292. $receipt->update ( array (
  3293. 'where' => 'rid=' . $rid
  3294. ) );
  3295. $XDeode = new XDeode ( 7 );
  3296. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  3297. } else
  3298. die ( 'illegal request' );
  3299. }
  3300. /**
  3301. * 移除讲师
  3302. */
  3303. function receiptTrainLecturerDelDo() {
  3304. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  3305. $rlidKey = $this->get_args ( 'rlidKey' ) ? $this->get_args ( 'rlidKey' ) : ""; // 发票培训班
  3306. Doo::loadModel ( 'receipt' );
  3307. $receipt = new receipt ();
  3308. Doo::loadModel ( 'RILecturer' );
  3309. $RILecturer = new RILecturer ();
  3310. Doo::loadClass ( 'XDeode' );
  3311. $XDeode = new XDeode ( 5 );
  3312. $rid = $XDeode->decode ( $ridKey );
  3313. $rlid = $XDeode->decode ( $rlidKey );
  3314. if (is_numeric ( $rid ) && is_numeric ( $rlid )) {
  3315. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3316. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  3317. die ( 'illegal request-status' );
  3318. }
  3319. $detail=$RILecturer->getRILecturerByRlid($rlid);
  3320. if (empty($detail)){
  3321. die ( 'illegal request-data' );
  3322. }
  3323. $RILecturer->delete ( array (
  3324. 'where' => 'rid=' . $rid . ' and rlid=' . $rlid
  3325. ) );
  3326. //更新费用合计金额
  3327. $rInfo = $receipt->getReceiptByRid ( $rid );
  3328. $receipt = new receipt ();
  3329. $receipt->sum= $receiptDetail['sum']-$detail['price'];
  3330. $receipt->update ( array (
  3331. 'where' => 'rid=' . $rid
  3332. ) );
  3333. Doo::loadModel ( 'receiptDetail' );
  3334. $receiptDetail = new receiptDetail ();
  3335. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  3336. $receiptDetail = new receiptDetail ();
  3337. $rdInfo ['price'] -= number_format ( $detail['price'], 2, '.', '' );
  3338. $receiptDetail->price = $rdInfo ['price'];
  3339. $receiptDetail->update ( array (
  3340. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  3341. ) );
  3342. $XDeode = new XDeode ( 7 );
  3343. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  3344. } else
  3345. die ( 'illegal request-iid' );
  3346. }
  3347. /**
  3348. * 培训班提交审批
  3349. */
  3350. function receiptTrainDo() {
  3351. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3352. Doo::loadClass ( 'XDeode' );
  3353. $XDeode = new XDeode ( 7 );
  3354. $rid = $XDeode->decode ( $ridKey );
  3355. Doo::loadModel ( 'receipt' );
  3356. $receipt = new receipt ();
  3357. Doo::loadModel ( 'receiptDetail' );
  3358. $receiptDetail = new receiptDetail ();
  3359. Doo::loadModel ( 'statistics' );
  3360. $statistics = new statistics ();
  3361. Doo::loadModel ( "verify" );
  3362. $verify = new verify ();
  3363. // 审批状态的判定
  3364. $receiptDetailList = $receipt->getOne ( array (
  3365. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  3366. 'asArray' => true
  3367. ) );
  3368. if (empty ( $receiptDetailList ))
  3369. return "/saeaBorad";
  3370. $verifyDetail = $verify->getOne ( array (
  3371. 'where' => ' vid =' . $receiptDetailList ['verify'],
  3372. 'asArray' => true
  3373. ) );
  3374. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3375. if (empty ( $receiptDetailList ['nowStaff'] )) {
  3376. $nowStaff = "";
  3377. $nowStaffList = array ();
  3378. if ($verifyDetail [0] [1] == 'ROLE') {
  3379. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3380. foreach ( $vStaffString as $key => $value ) {
  3381. $staffK = explode ( "_", $value );
  3382. array_push ( $nowStaffList, $staffK [0] );
  3383. }
  3384. $nowStaff = implode ( ',', $nowStaffList );
  3385. } else {
  3386. $nowStaff = $verifyDetail [0] [0];
  3387. }
  3388. $receipt->nowStaff = $nowStaff;
  3389. }
  3390. // echo $nowStaff;
  3391. // print_r($verifyDetail);die;
  3392. $receipt->rid = $receiptDetailList ['rid'];
  3393. $receipt->date = date ( "Y-m-d" );
  3394. $receipt->status = 2;
  3395. $receipt->update ();
  3396. $receiptDetail->status = 2;
  3397. $receiptDetail->update ( array (
  3398. 'where' => 'rid=' . $receiptDetailList ['rid']
  3399. ) );
  3400. Doo::loadModel ( "receiptLog" );
  3401. $receiptLog = new receiptLog ();
  3402. Doo::loadModel ( "verify" );
  3403. $verify = new verify ();
  3404. $vr = $verify->getOne ( array (
  3405. 'where' => 'vid=' . $receiptDetailList ['verify'],
  3406. 'asArray' => true
  3407. ) );
  3408. $jd = json_decode ( $vr ['staff'] );
  3409. $roleId = 0;
  3410. foreach ( $jd as $key => $value ) {
  3411. if ($value [1] == 'ROLE') {
  3412. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  3413. if ($pos !== false) {
  3414. $roleId = $value [0];
  3415. }
  3416. }
  3417. }
  3418. // 审批日志
  3419. // echo $roleId;die;
  3420. if (! empty ( $roleId )) {
  3421. Doo::loadModel ( "role" );
  3422. $role = new role ();
  3423. $roleInfo = $role->getOne ( array (
  3424. 'where' => 'rid=' . $roleId,
  3425. 'asArray' => true
  3426. ) );
  3427. // $receiptLog->rolename = $roleInfo ['name'];
  3428. }
  3429. $receiptLog->username = $this->staff [0] ['username'];
  3430. $receiptLog->uid = $this->staff [0] ['sid'];
  3431. $receiptLog->date = date ( "Y-m-d" );
  3432. $receiptLog->opinion = '提交审批';
  3433. $receiptLog->img = $this->staff [0] ['avatar'];
  3434. $receiptLog->status = 2;
  3435. $receiptLog->rid = $rid;
  3436. $receiptLog->insert ();
  3437. // 写入列表项
  3438. Doo::loadModel ( 'accountItem' );
  3439. $accountItem = new accountItem ();
  3440. $aItem = $accountItem->getAccountBookByCategory ( '培训班费用' );
  3441. // 项目金额合计
  3442. Doo::loadModel ( 'RItem' );
  3443. $RItem = new RItem ();
  3444. // 讲师获得
  3445. Doo::loadModel ( 'RILecturer' );
  3446. $RILecturer = new RILecturer ();
  3447. $RItemList = $RItem->getRItemByRid ( $rid );
  3448. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  3449. // 支出项金额详情
  3450. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, 0 );
  3451. // print_r($aItem);
  3452. // print_r($aiData);
  3453. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  3454. $ag = $tr = $ta = $ot = 0;
  3455. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  3456. foreach ( $aItem as $key => $value ) {
  3457. if ($value ['category'] == $this->TRAIN) {
  3458. foreach ( $aiData ['dataList'] as $k => $v ) {
  3459. if ($value ['name'] == $v ['name']) {
  3460. array_push ( $accountJson [$this->TRAIN], array (
  3461. 'aid' => $value ['aid'],
  3462. 'name' => $value ['name'],
  3463. 'price' => number_format ( $v ['price'], 2, '.', '' )
  3464. ) );
  3465. $sum += $v ['price'];
  3466. $trainSum += $v ['price'];
  3467. unset ( $aiData ['dataList'] [$k] );
  3468. break;
  3469. }
  3470. }
  3471. }
  3472. }
  3473. $accountJson ['cSum'] = array (
  3474. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  3475. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  3476. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  3477. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  3478. );
  3479. // 报销单
  3480. $receipt = new receipt ();
  3481. $receipt->accountItem = json_encode ( $accountJson );
  3482. $receipt->sum = number_format ( $sum, 2, '.', '' );
  3483. $receipt->update ( array (
  3484. 'where' => 'rid=' . $rid
  3485. ) );
  3486. // print_r($accountJson);
  3487. // statistics item 统计写入
  3488. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  3489. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  3490. $accountItem = $accountJson;
  3491. $stat = $statistics->getOne ( array (
  3492. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  3493. 'asArray' => true
  3494. ) );
  3495. if (empty ( $stat )) {
  3496. $statistics->date = date ( "Y-m-d" );
  3497. $statistics->cid = $this->staff [0] ['cid'];
  3498. $statistics->staff = $this->staff [0] ['sid'];
  3499. $statistics->agPrice = 0;
  3500. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  3501. $statistics->insert ();
  3502. } else {
  3503. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  3504. $statistics->update ( array (
  3505. 'where' => 'sid=' . $stat ['sid']
  3506. ) );
  3507. }
  3508. return "/saeaBorad";
  3509. }
  3510. function confirmation() {
  3511. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3512. Doo::loadModel ( 'receipt' );
  3513. Doo::loadModel ( 'receiptDetail' );
  3514. $receipt = new receipt ();
  3515. $receiptDetail = new receiptDetail ();
  3516. Doo::loadModel ( 'statistics' );
  3517. Doo::loadModel ( 'itemStatistics' );
  3518. $statistics = new statistics ();
  3519. $itemStatistics = new itemStatistics ();
  3520. Doo::loadModel ( "verify" );
  3521. $verify = new verify ();
  3522. $receiptDetailList = $receipt->getOne ( array (
  3523. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  3524. 'asArray' => true
  3525. ) );
  3526. if (empty ( $receiptDetailList ))
  3527. return "/saeaBorad";
  3528. $verifyDetail = $verify->getOne ( array (
  3529. 'where' => ' vid =' . $receiptDetailList ['verify'],
  3530. 'asArray' => true
  3531. ) );
  3532. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3533. if (empty ( $receiptDetailList ['nowStaff'] )) {
  3534. $nowStaff = "";
  3535. $nowStaffList = array ();
  3536. if ($verifyDetail [0] [1] == 'ROLE') {
  3537. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3538. foreach ( $vStaffString as $key => $value ) {
  3539. $staffK = explode ( "_", $value );
  3540. array_push ( $nowStaffList, $staffK [0] );
  3541. }
  3542. $nowStaff = implode ( ',', $nowStaffList );
  3543. } else {
  3544. $nowStaff = $verifyDetail [0] [0];
  3545. }
  3546. $receipt->nowStaff = $nowStaff;
  3547. }
  3548. // echo $nowStaff;
  3549. // print_r($verifyDetail);die;
  3550. $receipt->rid = $receiptDetailList ['rid'];
  3551. $receipt->status = 2;
  3552. $receipt->update ();
  3553. // 操作日志
  3554. Doo::loadModel ( "receiptLog" );
  3555. $receiptLog = new receiptLog ();
  3556. $verify = new verify ();
  3557. $receiptInfo = $receipt->getOne ( array (
  3558. 'where' => 'rid=' . $rid,
  3559. 'asArray' => true
  3560. ) );
  3561. $vr = $verify->getOne ( array (
  3562. 'where' => 'vid=' . $receiptInfo ['verify'],
  3563. 'asArray' => true
  3564. ) );
  3565. $jd = json_decode ( $vr ['staff'] );
  3566. $roleId = 0;
  3567. foreach ( $jd as $key => $value ) {
  3568. if ($value [1] == 'ROLE') {
  3569. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  3570. if ($pos !== false) {
  3571. $roleId = $value [0];
  3572. }
  3573. }
  3574. }
  3575. // 审批日志
  3576. // echo $roleId;die;
  3577. if (! empty ( $roleId )) {
  3578. Doo::loadModel ( "role" );
  3579. $role = new role ();
  3580. $roleInfo = $role->getOne ( array (
  3581. 'where' => 'rid=' . $roleId,
  3582. 'asArray' => true
  3583. ) );
  3584. // $receiptLog->rolename = $roleInfo ['name'];
  3585. }
  3586. $receiptLog->username = $this->staff [0] ['username'];
  3587. $receiptLog->uid = $this->staff [0] ['sid'];
  3588. $receiptLog->date = date ( "Y-m-d" );
  3589. $receiptLog->opinion = '提交审批';
  3590. $receiptLog->img = $this->staff [0] ['avatar'];
  3591. $receiptLog->status = 2;
  3592. $receiptLog->rid = $rid;
  3593. $receiptLog->insert ();
  3594. return "/expenses";
  3595. }
  3596. function expenses() {
  3597. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  3598. if (empty ( $item ))
  3599. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  3600. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  3601. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  3602. Doo::loadClass ( 'XDeode' );
  3603. $XDeode = new XDeode ( 7 );
  3604. Doo::loadModel ( 'receipt' );
  3605. $receipt = new receipt ();
  3606. Doo::loadModel ( 'L_category' );
  3607. $Lcategory = new L_category ();
  3608. Doo::loadModel ( 'verify' );
  3609. Doo::loadModel ( 'statistics' );
  3610. $statistics = new statistics ();
  3611. $verify = new verify ();
  3612. Doo::loadModel ( 'staff' );
  3613. $staff = new staff ();
  3614. $condition = "";
  3615. if ($item == "expenses")
  3616. $condition = " and Rtype=1 ";
  3617. elseif ($item == "receipts")
  3618. $condition = " and Rtype=0 ";
  3619. elseif ($item == "remits")
  3620. $condition = " and Rtype=2 ";
  3621. elseif ($item == "train")
  3622. $condition = " and Rtype=3 ";
  3623. $dateCondition = " and Year(date) =" . $year;
  3624. if (! empty ( $moth )) {
  3625. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  3626. $stList = $statistics->getOne ( array (
  3627. 'select' => 'rePrice ,agPrice',
  3628. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  3629. 'asArray' => true
  3630. ) );
  3631. } else
  3632. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  3633. if (empty ( $stList ))
  3634. $stList = array (
  3635. 'rePrice' => 0,
  3636. 'agPrice' => 0
  3637. );
  3638. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  3639. if (! isset ( $noPassSum ['sum'] ))
  3640. $noPassSum ['sum'] = 0;
  3641. $data ['stList'] = array (
  3642. 'rePrice' => $stList ['rePrice'],
  3643. 'agPrice' => $stList ['agPrice'],
  3644. 'skPrice' => ($noPassSum ['sum'])
  3645. );
  3646. $receiptList = $receipt->find ( array (
  3647. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  3648. 'desc' => 'rid',
  3649. 'asArray' => true
  3650. ) );
  3651. $Locate = 0;
  3652. $roleId = 0;
  3653. $button = 0;
  3654. foreach ( $receiptList as $key => $value ) {
  3655. $receiptList[$key]['balance']='';
  3656. if($value['Rtype']==1){
  3657. $receiptList[$key]['balance']=$value['sum']-=$value['loanSum'];
  3658. $receiptList[$key]['balanceABS']=abs($receiptList[$key]['balance']);
  3659. }elseif($value['Rtype']==3){
  3660. $payment=$this->_getReceiptTrainPayment($value['invoiceTrainId'],$value['trainLoanRid'],$value['rid']);
  3661. $receiptList[$key]['payment']=$payment;
  3662. $receiptList[$key]['paymentABS']=abs($payment);
  3663. }
  3664. $receiptList [$key] ['Locate'] = $Locate;
  3665. $Locate ++;
  3666. $receiptList [$key] ['reviseDetail'] = array ();
  3667. if (! empty ( $value ['reviseDetail'] ))
  3668. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3669. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3670. $categoryDetil = $Lcategory->getOne ( array (
  3671. 'where' => 'cid=' . $value ['cid'],
  3672. 'asArray' => true
  3673. ) );
  3674. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3675. // 检测编辑状态
  3676. $verifyList = $verify->getOne ( array (
  3677. 'where' => 'vid=' . $value ['verify'],
  3678. 'asArray' => true
  3679. ) );
  3680. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3681. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3682. Doo::loadModel ( 'role' );
  3683. $role = new role ();
  3684. $flag = true;
  3685. $roleKey = 0;
  3686. $endStaffArray = array ();
  3687. $roleArrayCopy = array ();
  3688. foreach ( $verifyList as $k => $v ) {
  3689. // init verifyStaff
  3690. if ($v [1] == 'ROLE') {
  3691. if (! empty ( $verifyStaff )) {
  3692. $endStaffArray = end ( $verifyStaff );
  3693. // if ($v[0]==$endStaffArray['nextStaff']){
  3694. // $roleId=$v[0];
  3695. // }
  3696. }
  3697. $roleVerify = json_decode ( $v [3], true );
  3698. $roleKey = $k;
  3699. $roleArray = array ();
  3700. $rolename = $role->getOne ( array (
  3701. 'where' => 'rid=' . $v [0],
  3702. 'asArray' => true
  3703. ) );
  3704. foreach ( $roleVerify as $o => $p ) {
  3705. $staffID = explode ( '_', $p );
  3706. $staffInfo = $staff->getOne ( array (
  3707. 'where' => 'sid=' . $staffID [0],
  3708. 'asArray' => true
  3709. ) );
  3710. // print_r($staffID);
  3711. $exp = array (
  3712. 0 => $staffInfo ['sid'],
  3713. 1 => $staffID [1],
  3714. 2 => $staffInfo ['avatar'],
  3715. 'date' => '',
  3716. 'date' => '',
  3717. 'opinion' => '',
  3718. 'status' => '',
  3719. 'rolename' => $rolename ['name']
  3720. );
  3721. array_push ( $roleArray, $exp );
  3722. }
  3723. $roleArrayCopy [$v [0]] = $roleArray;
  3724. // $verifyList[$k]['roleArray']=$roleArray;
  3725. }
  3726. $verifyList [$k] ['date'] = "";
  3727. $verifyList [$k] ['opinion'] = "";
  3728. $verifyList [$k] ['status'] = "";
  3729. if (empty ( $verifyStaff )) {
  3730. $verifyList [$k] ['date'] = "";
  3731. $verifyList [$k] ['opinion'] = "";
  3732. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3733. $verifyList [$k] ['status'] = 4;
  3734. $flag = false;
  3735. }
  3736. } else {
  3737. foreach ( $verifyStaff as $m => $u ) {
  3738. if ($v [0] == $m) {
  3739. $verifyList [$k] ['date'] = $u ['date'];
  3740. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3741. $verifyList [$k] ['status'] = $u ['status'];
  3742. $flag = false;
  3743. break;
  3744. }
  3745. }
  3746. $endStaffArray = end ( $verifyStaff );
  3747. if (isset ( $endStaffArray ['ROLE'] )) {
  3748. } else {
  3749. // $endKey=key($verifyStaff);
  3750. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3751. // $button=4;
  3752. // $verifyList[$k]['status']=4;
  3753. // }
  3754. }
  3755. }
  3756. }
  3757. $rolename ['name'] = '';
  3758. if (! empty ( $roleId )) {
  3759. Doo::loadModel ( 'role' );
  3760. $role = new role ();
  3761. $rolename = $role->getOne ( array (
  3762. 'where' => 'rid=' . $roleId,
  3763. 'asArray' => true
  3764. ) );
  3765. }
  3766. if (! empty ( $verifyStaff ))
  3767. $endStaffArray = end ( $verifyStaff );
  3768. $KOP = false;
  3769. foreach ( $roleArrayCopy as $P => $A ) {
  3770. foreach ( $A as $MKI => $AVL ) {
  3771. if (! empty ( $verifyStaff )) {
  3772. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3773. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3774. $button = 4;
  3775. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3776. }
  3777. foreach ( $verifyStaff as $m => $u ) {
  3778. $AVLFK = $AVL [0] . '_R';
  3779. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3780. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3781. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3782. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3783. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3784. break;
  3785. }
  3786. }
  3787. } else {
  3788. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3789. $button = 4;
  3790. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3791. }
  3792. }
  3793. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3794. $KOP = true;
  3795. }
  3796. }
  3797. foreach ( $roleArrayCopy as $k => $v ) {
  3798. foreach ( $verifyList as $m => $n ) {
  3799. if ($n [0] == $k) {
  3800. array_splice ( $verifyList, $m, 1, $v );
  3801. }
  3802. }
  3803. }
  3804. $receiptList [$key] ['verifyList'] = $verifyList;
  3805. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3806. 'where' => 'sid=' . $value ['staff'],
  3807. 'asArray' => true
  3808. ) );
  3809. $receiptList [$key] ['button'] = $button;
  3810. $receiptList [$key] ['ridKey'] =$XDeode->encode( $value ['rid'] );
  3811. }
  3812. // print_r($receiptList);die;
  3813. $mothHtml = "";
  3814. for($i = 1; $i <= 12; $i ++) {
  3815. if ($moth == $i)
  3816. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3817. else
  3818. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3819. }
  3820. $dateHtml = "";
  3821. $now = date ( "Y" );
  3822. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  3823. if ($YEARD <= $now) {
  3824. $dateHtml .= '<option ';
  3825. if ($year == $YEARD) {
  3826. $dateHtml .= 'selected ';
  3827. }
  3828. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  3829. }
  3830. }
  3831. $data ['dateHtml'] = $dateHtml;
  3832. $data ['mothHtml'] = $mothHtml;
  3833. $data ['receiptList'] = $receiptList;
  3834. $data ['memu'] = "receipt";
  3835. $data ['staff'] = $this->staff;
  3836. $data ['receiptMemu'] = 'expenses';
  3837. $data ['verifyId'] = $this->verifyId;
  3838. $data ['executeId'] = $this->executeId;
  3839. $data ['item'] = $item;
  3840. $data ['year'] = $year;
  3841. $this->render ( "/admin/expenses", $data );
  3842. }
  3843. function expensesCollect() {
  3844. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3845. Doo::loadModel ( 'receipt' );
  3846. $receipt = new receipt ();
  3847. Doo::loadModel ( 'L_category' );
  3848. $Lcategory = new L_category ();
  3849. Doo::loadModel ( 'verify' );
  3850. Doo::loadModel ( 'statistics' );
  3851. $statistics = new statistics ();
  3852. $verify = new verify ();
  3853. Doo::loadModel ( 'staff' );
  3854. $staff = new staff ();
  3855. Doo::loadModel ( 'loanReceipt' );
  3856. $loanReceipt = new loanReceipt ();
  3857. $receiptList = $receipt->find ( array (//去掉
  3858. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  3859. 'desc' => 'rid',
  3860. 'asArray' => true
  3861. ) );
  3862. $loanList = $loanReceipt->find ( array (
  3863. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3864. 'desc' => 'rid',
  3865. 'asArray' => true
  3866. ) );
  3867. /*
  3868. * $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;
  3869. */
  3870. $data ['explanation'] = '';
  3871. if (! empty ( $loanList ))
  3872. $data ['explanation'] = $loanList [0] ['explanation'];
  3873. $Locate = 0;
  3874. $roleId = 0;
  3875. $button = 0;
  3876. foreach ( $receiptList as $key => $value ) {
  3877. $receiptList [$key] ['Locate'] = $Locate;
  3878. $Locate ++;
  3879. $receiptList [$key] ['reviseDetail'] = array ();
  3880. if (! empty ( $value ['reviseDetail'] ))
  3881. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3882. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3883. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3884. $categoryDetil = $Lcategory->getOne ( array (
  3885. 'where' => 'cid=' . $value ['cid'],
  3886. 'asArray' => true
  3887. ) );
  3888. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3889. // 检测编辑状态
  3890. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  3891. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  3892. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  3893. else
  3894. $verifyList ['staff'] = $value ['verifyBreakup'];
  3895. } else
  3896. $verifyList = $verify->getOne ( array (
  3897. 'where' => 'vid=' . $value ['verify'],
  3898. 'asArray' => true
  3899. ) );
  3900. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3901. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3902. Doo::loadModel ( 'role' );
  3903. $role = new role ();
  3904. $flag = true;
  3905. $roleKey = 0;
  3906. $endStaffArray = array ();
  3907. $roleArrayCopy = array ();
  3908. foreach ( $verifyList as $k => $v ) {
  3909. // init verifyStaff
  3910. if ($v [1] == 'ROLE') {
  3911. if (! empty ( $verifyStaff )) {
  3912. $endStaffArray = end ( $verifyStaff );
  3913. // if ($v[0]==$endStaffArray['nextStaff']){
  3914. // $roleId=$v[0];
  3915. // }
  3916. }
  3917. $roleVerify = json_decode ( $v [3], true );
  3918. $roleKey = $k;
  3919. $roleArray = array ();
  3920. $rolename = $role->getOne ( array (
  3921. 'where' => 'rid=' . $v [0],
  3922. 'asArray' => true
  3923. ) );
  3924. foreach ( $roleVerify as $o => $p ) {
  3925. $staffID = explode ( '_', $p );
  3926. $staffInfo = $staff->getOne ( array (
  3927. 'where' => 'sid=' . $staffID [0],
  3928. 'asArray' => true
  3929. ) );
  3930. // print_r($staffID);
  3931. $exp = array (
  3932. 0 => $staffInfo ['sid'],
  3933. 1 => $staffID [1],
  3934. 2 => $staffInfo ['avatar'],
  3935. 'date' => '',
  3936. 'date' => '',
  3937. 'opinion' => '',
  3938. 'status' => '',
  3939. 'rolename' => $rolename ['name']
  3940. );
  3941. array_push ( $roleArray, $exp );
  3942. }
  3943. $roleArrayCopy [$v [0]] = $roleArray;
  3944. // $verifyList[$k]['roleArray']=$roleArray;
  3945. }
  3946. $verifyList [$k] ['date'] = "";
  3947. $verifyList [$k] ['opinion'] = "";
  3948. $verifyList [$k] ['status'] = "";
  3949. if (empty ( $verifyStaff )) {
  3950. $verifyList [$k] ['date'] = "";
  3951. $verifyList [$k] ['opinion'] = "";
  3952. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3953. $verifyList [$k] ['status'] = 4;
  3954. $flag = false;
  3955. }
  3956. } else {
  3957. foreach ( $verifyStaff as $m => $u ) {
  3958. if ($v [0] == $m) {
  3959. $verifyList [$k] ['date'] = $u ['date'];
  3960. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3961. $verifyList [$k] ['status'] = $u ['status'];
  3962. $flag = false;
  3963. break;
  3964. }
  3965. }
  3966. $endStaffArray = end ( $verifyStaff );
  3967. if (isset ( $endStaffArray ['ROLE'] )) {
  3968. } else {
  3969. // $endKey=key($verifyStaff);
  3970. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3971. // $button=4;
  3972. // $verifyList[$k]['status']=4;
  3973. // }
  3974. }
  3975. }
  3976. }
  3977. $rolename ['name'] = '';
  3978. if (! empty ( $roleId )) {
  3979. Doo::loadModel ( 'role' );
  3980. $role = new role ();
  3981. $rolename = $role->getOne ( array (
  3982. 'where' => 'rid=' . $roleId,
  3983. 'asArray' => true
  3984. ) );
  3985. }
  3986. if (! empty ( $verifyStaff ))
  3987. $endStaffArray = end ( $verifyStaff );
  3988. $KOP = false;
  3989. foreach ( $roleArrayCopy as $P => $A ) {
  3990. foreach ( $A as $MKI => $AVL ) {
  3991. if (! empty ( $verifyStaff )) {
  3992. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3993. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3994. $button = 4;
  3995. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3996. }
  3997. foreach ( $verifyStaff as $m => $u ) {
  3998. $AVLFK = $AVL [0] . '_R';
  3999. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4000. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4001. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4002. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4003. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4004. break;
  4005. }
  4006. }
  4007. } else {
  4008. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4009. $button = 4;
  4010. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4011. }
  4012. }
  4013. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4014. $KOP = true;
  4015. }
  4016. }
  4017. foreach ( $roleArrayCopy as $k => $v ) {
  4018. foreach ( $verifyList as $m => $n ) {
  4019. if ($n [0] == $k) {
  4020. array_splice ( $verifyList, $m, 1, $v );
  4021. }
  4022. }
  4023. }
  4024. // 费用执行人相关数据
  4025. $executeCopy = json_decode ( $value ['executeCopy'], true );
  4026. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4027. foreach ( $executeCopy as $k => $v ) {
  4028. $executeCopy [$k] ['date'] = '';
  4029. $executeCopy [$k] ['opinion'] = '';
  4030. $executeCopy [$k] ['status'] = '';
  4031. if (! empty ( $executeStaff ))
  4032. foreach ( $executeStaff as $m => $u ) {
  4033. if ($v [0] == $m) {
  4034. $executeCopy [$k] ['date'] = $u ['date'];
  4035. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  4036. $executeCopy [$k] ['status'] = $u ['status'];
  4037. break;
  4038. }
  4039. }
  4040. }
  4041. $receiptList [$key] ['executeCopy'] = $executeCopy;
  4042. $receiptList [$key] ['verifyList'] = $verifyList;
  4043. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4044. 'where' => 'sid=' . $value ['staff'],
  4045. 'asArray' => true
  4046. ) );
  4047. $receiptList [$key] ['button'] = $button;
  4048. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4049. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4050. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4051. $receiptList [$key] ['relust'] = $relust;
  4052. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4053. }
  4054. Doo::loadModel ( 'enclosur' );
  4055. $enclosur = new enclosur ();
  4056. $enclosurList = $enclosur->find ( array (
  4057. 'where' => 'rid=' . $rid,
  4058. 'asArray' => true
  4059. ) );
  4060. $enclosurHtml = '';
  4061. foreach ( $enclosurList as $value ) {
  4062. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4063. }
  4064. $data ['enclosurHtml'] = $enclosurHtml;
  4065. //print_r($receiptList[0]['accountItem']['内部培训费用']);
  4066. $data ['receiptList'] = $receiptList;
  4067. $data ['memu'] = "receipt";
  4068. $data ['staff'] = $this->staff;
  4069. $data ['receiptMemu'] = 'expenses';
  4070. $data ['verifyId'] = $this->verifyId;
  4071. $data ['executeId'] = $this->executeId;
  4072. $this->render ( "/admin/expensesCollect", $data );
  4073. }
  4074. function approvalExpenses() {
  4075. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  4076. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4077. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4078. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4079. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4080. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  4081. // echo $rdate;
  4082. if (empty ( $status ))
  4083. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  4084. $page_size = 8;
  4085. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  4086. $vidList = array ();
  4087. $button = 0;
  4088. Doo::loadModel ( 'verify' );
  4089. $verify = new verify ();
  4090. Doo::loadModel ( 'receipt' );
  4091. $receipt = new receipt ();
  4092. Doo::loadModel ( 'staff' );
  4093. $staff = new staff ();
  4094. Doo::loadModel ( 'L_category' );
  4095. $Lcategory = new L_category ();
  4096. // user verify ID
  4097. $verifyDetail = $verify->find ( array (
  4098. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  4099. 'asArray' => true
  4100. ) );
  4101. foreach ( $verifyDetail as $key => $value ) {
  4102. array_push ( $vidList, $value ['vid'] );
  4103. }
  4104. $vid = implode ( ",", $vidList );
  4105. if (empty ( $verifyDetail ))
  4106. $vid = 0;
  4107. // if ($status==0)
  4108. // $dateCondition="";
  4109. // else
  4110. $dateCondition = " ";
  4111. // if (! empty ( $month ))
  4112. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  4113. if ($status == 'done' || $status == 'termination') {
  4114. if (! empty ( $year )) {
  4115. $dateCondition = " and Year(pastDate) =" . $year;
  4116. if (! empty ( $month ))
  4117. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  4118. }
  4119. } elseif ($status == 'finish') {
  4120. if (! empty ( $year )) {
  4121. $dateCondition = " and Year(pastDate) =" . $year;
  4122. if (! empty ( $month ))
  4123. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  4124. }
  4125. }
  4126. // date ( 'Y-m' )
  4127. // if (! empty ( $rdate ) && $status == 'done')
  4128. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  4129. // elseif (! empty ( $rdate ))
  4130. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  4131. $categoryList = $Lcategory->find ( array (
  4132. 'asArray' => true
  4133. ) );
  4134. $staffList = $staff->find ( array (
  4135. 'where' => 'cid=' . $cid,
  4136. 'asArray' => true
  4137. ) );
  4138. $cateCondition = "";
  4139. $staffCondition = "";
  4140. $approvalCondition = "";
  4141. if (! empty ( $cid )) {
  4142. $cateCondition = ' and cid=' . $cid;
  4143. }
  4144. if (! empty ( $sid )) {
  4145. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  4146. $cateCondition = "";
  4147. }
  4148. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  4149. if ($status == 'pendApproval') {
  4150. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  4151. }
  4152. if ($status == 'ongoing') {
  4153. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  4154. }
  4155. if ($status == 'done') {
  4156. $approvalCondition = ' and (status=8 or status=9 ) ';
  4157. }
  4158. if ($status == 'termination') {
  4159. $approvalCondition = " and status=3";
  4160. }
  4161. if ($status == 'finish') {
  4162. $approvalCondition = " and (status=1 or status=8 or status=9 or status=10)";
  4163. }
  4164. $pageinfo ['page'] = array (
  4165. 'previous' => ''
  4166. );
  4167. if(!empty($receiptOrder)){
  4168. $pageinfo = $this->get_page ( "CLD_receipt", ' and receiptOrder like "%' . $receiptOrder . '%"', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  4169. $receiptList = $receipt->find ( array ( // $dateCondition
  4170. 'where' => 'receiptOrder like "%' . $receiptOrder . '%"',
  4171. 'desc' => 'rid',
  4172. 'asArray' => true
  4173. ) );
  4174. }else{
  4175. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  4176. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  4177. $receiptList = $receipt->find ( array ( // $dateCondition.
  4178. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  4179. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  4180. 'desc' => 'rid',
  4181. 'asArray' => true
  4182. ) );
  4183. } else {
  4184. $receiptList = $receipt->find ( array ( // $dateCondition
  4185. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  4186. 'desc' => 'rid',
  4187. 'asArray' => true
  4188. ) );
  4189. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  4190. }
  4191. }
  4192. $rLRes = $receipt->find ( array (
  4193. '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 . ')',
  4194. 'desc' => 'rid',
  4195. 'asArray' => true
  4196. ) );
  4197. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  4198. // print_r($receiptList);
  4199. Doo::loadClass ( 'XDeode' );
  4200. $XDeode = new XDeode ( 7 );
  4201. $Locate = 0;
  4202. //
  4203. $reportList = $reportCateList = array ();
  4204. foreach ( $receiptList as $key => $value ) {
  4205. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4206. $receiptList [$key] ['Locate'] = $Locate;
  4207. $Locate ++;
  4208. $receiptList [$key] ['reviseDetail'] = array ();
  4209. if (! empty ( $value ['reviseDetail'] ))
  4210. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4211. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4212. $categoryDetil = $Lcategory->getOne ( array (
  4213. 'where' => 'cid=' . $value ['cid'],
  4214. 'asArray' => true
  4215. ) );
  4216. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4217. $verifyList = $verify->getOne ( array (
  4218. 'where' => 'vid=' . $value ['verify'],
  4219. 'asArray' => true
  4220. ) );
  4221. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4222. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4223. foreach ( $verifyList as $k => $v ) {
  4224. // init verifyStaff
  4225. $verifyList [$k] ['date'] = "";
  4226. $verifyList [$k] ['opinion'] = "";
  4227. $verifyList [$k] ['status'] = "";
  4228. if (empty ( $verifyStaff )) {
  4229. $verifyList [$k] ['date'] = "";
  4230. $verifyList [$k] ['opinion'] = "";
  4231. if ($v [0] == $this->staff [0] ['sid']) {
  4232. $verifyList [$k] ['status'] = 4;
  4233. $button = 4;
  4234. }
  4235. } else {
  4236. $flag = true;
  4237. foreach ( $verifyStaff as $m => $u ) {
  4238. if ($v [0] == $m) {
  4239. $verifyList [$k] ['date'] = $u ['date'];
  4240. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4241. $verifyList [$k] ['status'] = $u ['status'];
  4242. $flag = false;
  4243. break;
  4244. }
  4245. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  4246. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  4247. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  4248. }
  4249. if ($flag) { // 检测可编辑
  4250. if ($v [0] == $this->staff [0] ['sid']) {
  4251. $verifyList [$k] ['status'] = 4;
  4252. $button = 4;
  4253. }
  4254. }
  4255. }
  4256. }
  4257. $receiptList [$key] ['verifyList'] = $verifyList;
  4258. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4259. 'where' => 'sid=' . $value ['staff'],
  4260. 'asArray' => true
  4261. ) );
  4262. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  4263. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  4264. $receiptList [$key] ['button'] = $button;
  4265. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  4266. //获得培训班结算RID 借款费用--已经锁定
  4267. if($value['status']==10){
  4268. $trainRD=$receipt->getReceiptByTrainLoanRid($value['rid']);
  4269. $receiptList [$key]['trainRidKey7']=$trainRD['ridKey7'];
  4270. }
  4271. }
  4272. $reportList = array_unique ( $reportList );
  4273. $reportHtml = '';
  4274. foreach ( $reportList as $key => $value ) {
  4275. $v = explode ( "-", $value );
  4276. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  4277. }
  4278. // print_r($reportList)
  4279. $data ['reportHtml'] = $reportHtml;
  4280. $reportCateList = array_unique ( $reportCateList );
  4281. $reportCateHtml = '';
  4282. foreach ( $reportCateList as $key => $value ) {
  4283. $v = explode ( "-", $value );
  4284. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  4285. }
  4286. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  4287. $data ['reportCateHtml'] = $reportCateHtml;
  4288. // print_r($receiptList);die;
  4289. // $data['verifyDetail']=$verifyDetail;
  4290. $mothHtml = "";
  4291. for($i = 1; $i <= 12; $i ++) {
  4292. if ($month == $i)
  4293. $mothHtml .= '<option selected value="0' . $i . '">' . $i . '月</option>';
  4294. else
  4295. $mothHtml .= '<option value="0' . $i . '">' . $i . '月</option>';
  4296. }
  4297. $data ['mothHtml'] = $mothHtml;
  4298. $dateHtml = "";
  4299. $now = date ( "Y" );
  4300. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  4301. if ($YEARD <= $now) {
  4302. $dateHtml .= '<option ';
  4303. if ($year == $YEARD) {
  4304. $dateHtml .= 'selected ';
  4305. }
  4306. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  4307. }
  4308. }
  4309. $data ['dateHtml'] = $dateHtml;
  4310. $data ['page'] = $pageinfo;
  4311. $data ['receiptList'] = $receiptList;
  4312. $data ['receiptApprovalCount'] = count ( $rLRes );
  4313. $data ['status'] = $status;
  4314. $data ['year'] = $year;
  4315. $data ['month'] = $month;
  4316. $data ['categoryList'] = $categoryList;
  4317. $data ['staffList'] = $staffList;
  4318. $data ['cid'] = $cid;
  4319. $data ['sid'] = $sid;
  4320. // print_r($receiptList);
  4321. $data['receiptOrder']=$receiptOrder;
  4322. $data ['memu'] = "receipt";
  4323. $data ['staff'] = $this->staff;
  4324. $data ['receiptMemu'] = 'approvalExpenses';
  4325. $data ['verifyId'] = $this->verifyId;
  4326. $data ['executeId'] = $this->executeId;
  4327. $this->render ( "/admin/approvalExpenses", $data );
  4328. }
  4329. function expensesDoc() {
  4330. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  4331. Doo::loadClass ( 'XDeode' );
  4332. $XDeode = new XDeode ( 5 );
  4333. if (! empty ( $rid ) && ! is_numeric ( $rid ))
  4334. $rid = $XDeode->decode ( $rid );
  4335. if (! is_numeric ( $rid ))
  4336. die ( 'illegal request' );
  4337. Doo::loadModel ( 'receipt' );
  4338. $receipt = new receipt ();
  4339. Doo::loadModel ( 'L_category' );
  4340. $Lcategory = new L_category ();
  4341. Doo::loadModel ( 'verify' );
  4342. Doo::loadModel ( 'statistics' );
  4343. $statistics = new statistics ();
  4344. $verify = new verify ();
  4345. Doo::loadModel ( 'staff' );
  4346. $staff = new staff ();
  4347. Doo::loadModel ( 'loanReceipt' );
  4348. $loanReceipt = new loanReceipt ();
  4349. $receiptList = $receipt->find ( array (
  4350. 'where' => ' rid=' . $rid,
  4351. 'desc' => 'rid',
  4352. 'asArray' => true
  4353. ) );
  4354. $loanList = array ();
  4355. if (! empty ( $receiptList ))
  4356. $loanList = $loanReceipt->find ( array (
  4357. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4358. 'desc' => 'rid',
  4359. 'asArray' => true
  4360. ) );
  4361. $Locate = 0;
  4362. $roleId = 0;
  4363. $button = 0;
  4364. foreach ( $loanList as $key => $value ) {
  4365. $loanList [$key] ['Locate'] = $Locate;
  4366. $Locate ++;
  4367. $loanList [$key] ['reviseDetail'] = array ();
  4368. if (! empty ( $value ['reviseDetail'] ))
  4369. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4370. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4371. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4372. $categoryDetil = $Lcategory->getOne ( array (
  4373. 'where' => 'cid=' . $value ['cid'],
  4374. 'asArray' => true
  4375. ) );
  4376. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4377. // 检测编辑状态
  4378. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  4379. $verifyList ['staff'] = $value ['verifyBreakup'];
  4380. else
  4381. $verifyList = $verify->getOne ( array (
  4382. 'where' => 'vid=' . $value ['verify'],
  4383. 'asArray' => true
  4384. ) );
  4385. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4386. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4387. Doo::loadModel ( 'role' );
  4388. $role = new role ();
  4389. $flag = true;
  4390. $roleKey = 0;
  4391. $endStaffArray = array ();
  4392. $roleArrayCopy = array ();
  4393. foreach ( $verifyList as $k => $v ) {
  4394. // init verifyStaff
  4395. if ($v [1] == 'ROLE') {
  4396. if (! empty ( $verifyStaff )) {
  4397. $endStaffArray = end ( $verifyStaff );
  4398. // if ($v[0]==$endStaffArray['nextStaff']){
  4399. // $roleId=$v[0];
  4400. // }
  4401. }
  4402. $roleVerify = json_decode ( $v [3], true );
  4403. $roleKey = $k;
  4404. $roleArray = array ();
  4405. $rolename = $role->getOne ( array (
  4406. 'where' => 'rid=' . $v [0],
  4407. 'asArray' => true
  4408. ) );
  4409. foreach ( $roleVerify as $o => $p ) {
  4410. $staffID = explode ( '_', $p );
  4411. $staffInfo = $staff->getOne ( array (
  4412. 'where' => 'sid=' . $staffID [0],
  4413. 'asArray' => true
  4414. ) );
  4415. // print_r($staffID);
  4416. $exp = array (
  4417. 0 => $staffInfo ['sid'],
  4418. 1 => $staffID [1],
  4419. 2 => $staffInfo ['avatar'],
  4420. 'date' => '',
  4421. 'date' => '',
  4422. 'opinion' => '',
  4423. 'status' => '',
  4424. 'rolename' => $rolename ['name']
  4425. );
  4426. array_push ( $roleArray, $exp );
  4427. }
  4428. $roleArrayCopy [$v [0]] = $roleArray;
  4429. // $verifyList[$k]['roleArray']=$roleArray;
  4430. }
  4431. $verifyList [$k] ['date'] = "";
  4432. $verifyList [$k] ['opinion'] = "";
  4433. $verifyList [$k] ['status'] = "";
  4434. if (empty ( $verifyStaff )) {
  4435. $verifyList [$k] ['date'] = "";
  4436. $verifyList [$k] ['opinion'] = "";
  4437. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4438. $verifyList [$k] ['status'] = 4;
  4439. $flag = false;
  4440. }
  4441. } else {
  4442. foreach ( $verifyStaff as $m => $u ) {
  4443. if ($v [0] == $m) {
  4444. $verifyList [$k] ['date'] = $u ['date'];
  4445. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4446. $verifyList [$k] ['status'] = $u ['status'];
  4447. $flag = false;
  4448. break;
  4449. }
  4450. }
  4451. $endStaffArray = end ( $verifyStaff );
  4452. if (isset ( $endStaffArray ['ROLE'] )) {
  4453. } else {
  4454. // $endKey=key($verifyStaff);
  4455. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4456. // $button=4;
  4457. // $verifyList[$k]['status']=4;
  4458. // }
  4459. }
  4460. }
  4461. }
  4462. $rolename ['name'] = '';
  4463. if (! empty ( $roleId )) {
  4464. Doo::loadModel ( 'role' );
  4465. $role = new role ();
  4466. $rolename = $role->getOne ( array (
  4467. 'where' => 'rid=' . $roleId,
  4468. 'asArray' => true
  4469. ) );
  4470. }
  4471. if (! empty ( $verifyStaff ))
  4472. $endStaffArray = end ( $verifyStaff );
  4473. $KOP = false;
  4474. foreach ( $roleArrayCopy as $P => $A ) {
  4475. foreach ( $A as $MKI => $AVL ) {
  4476. if (! empty ( $verifyStaff )) {
  4477. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4478. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4479. $button = 4;
  4480. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4481. }
  4482. foreach ( $verifyStaff as $m => $u ) {
  4483. $AVLFK = $AVL [0] . '_R';
  4484. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4485. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4486. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4487. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4488. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4489. break;
  4490. }
  4491. }
  4492. } else {
  4493. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4494. $button = 4;
  4495. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4496. }
  4497. }
  4498. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4499. $KOP = true;
  4500. }
  4501. }
  4502. foreach ( $roleArrayCopy as $k => $v ) {
  4503. foreach ( $verifyList as $m => $n ) {
  4504. if ($n [0] == $k) {
  4505. array_splice ( $verifyList, $m, 1, $v );
  4506. }
  4507. }
  4508. }
  4509. $loanList [$key] ['verifyList'] = $verifyList;
  4510. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  4511. 'where' => 'sid=' . $value ['staff'],
  4512. 'asArray' => true
  4513. ) );
  4514. $loanList [$key] ['button'] = $button;
  4515. //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  4516. }
  4517. $data ['loanList'] = $loanList;
  4518. //print_r($loanList);
  4519. $Locate = 0;
  4520. $roleId = 0;
  4521. $button = 0;
  4522. foreach ( $receiptList as $key => $value ) {
  4523. $receiptList [$key] ['Locate'] = $Locate;
  4524. $Locate ++;
  4525. $receiptList [$key] ['reviseDetail'] = array ();
  4526. if (! empty ( $value ['reviseDetail'] ))
  4527. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4528. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4529. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4530. $categoryDetil = $Lcategory->getOne ( array (
  4531. 'where' => 'cid=' . $value ['cid'],
  4532. 'asArray' => true
  4533. ) );
  4534. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4535. // 检测编辑状态
  4536. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  4537. $verifyList ['staff'] = $value ['verifyBreakup'];
  4538. } else
  4539. $verifyList = $verify->getOne ( array (
  4540. 'where' => 'vid=' . $value ['verify'],
  4541. 'asArray' => true
  4542. ) );
  4543. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4544. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4545. Doo::loadModel ( 'role' );
  4546. $role = new role ();
  4547. if ($verifyList == NULL)
  4548. $verifyList = array ();
  4549. $flag = true;
  4550. $roleKey = 0;
  4551. $endStaffArray = array ();
  4552. $roleArrayCopy = array ();
  4553. foreach ( $verifyList as $k => $v ) {
  4554. // init verifyStaff
  4555. if ($v [1] == 'ROLE') {
  4556. if (! empty ( $verifyStaff )) {
  4557. $endStaffArray = end ( $verifyStaff );
  4558. // if ($v[0]==$endStaffArray['nextStaff']){
  4559. // $roleId=$v[0];
  4560. // }
  4561. }
  4562. $roleVerify = json_decode ( $v [3], true );
  4563. $roleKey = $k;
  4564. $roleArray = array ();
  4565. $rolename = $role->getOne ( array (
  4566. 'where' => 'rid=' . $v [0],
  4567. 'asArray' => true
  4568. ) );
  4569. foreach ( $roleVerify as $o => $p ) {
  4570. $staffID = explode ( '_', $p );
  4571. $staffInfo = $staff->getOne ( array (
  4572. 'where' => 'sid=' . $staffID [0],
  4573. 'asArray' => true
  4574. ) );
  4575. // print_r($staffID);
  4576. $exp = array (
  4577. 0 => $staffInfo ['sid'],
  4578. 1 => $staffID [1],
  4579. 2 => $staffInfo ['avatar'],
  4580. 'date' => '',
  4581. 'date' => '',
  4582. 'opinion' => '',
  4583. 'status' => '',
  4584. 'rolename' => $rolename ['name']
  4585. );
  4586. array_push ( $roleArray, $exp );
  4587. }
  4588. $roleArrayCopy [$v [0]] = $roleArray;
  4589. // $verifyList[$k]['roleArray']=$roleArray;
  4590. }
  4591. $verifyList [$k] ['date'] = "";
  4592. $verifyList [$k] ['opinion'] = "";
  4593. $verifyList [$k] ['status'] = "";
  4594. if (empty ( $verifyStaff )) {
  4595. $verifyList [$k] ['date'] = "";
  4596. $verifyList [$k] ['opinion'] = "";
  4597. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4598. $verifyList [$k] ['status'] = 4;
  4599. $flag = false;
  4600. }
  4601. } else {
  4602. foreach ( $verifyStaff as $m => $u ) {
  4603. if ($v [0] == $m) {
  4604. $verifyList [$k] ['date'] = $u ['date'];
  4605. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4606. $verifyList [$k] ['status'] = $u ['status'];
  4607. $flag = false;
  4608. break;
  4609. }
  4610. }
  4611. $endStaffArray = end ( $verifyStaff );
  4612. if (isset ( $endStaffArray ['ROLE'] )) {
  4613. } else {
  4614. // $endKey=key($verifyStaff);
  4615. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4616. // $button=4;
  4617. // $verifyList[$k]['status']=4;
  4618. // }
  4619. }
  4620. }
  4621. }
  4622. $FC = @$rolename ['name'];
  4623. $rolename ['name'] = '';
  4624. if (! empty ( $roleId )) {
  4625. Doo::loadModel ( 'role' );
  4626. $role = new role ();
  4627. $rolename = $role->getOne ( array (
  4628. 'where' => 'rid=' . $roleId,
  4629. 'asArray' => true
  4630. ) );
  4631. }
  4632. if (! empty ( $verifyStaff ))
  4633. $endStaffArray = end ( $verifyStaff );
  4634. $KOP = false;
  4635. foreach ( $roleArrayCopy as $P => $A ) {
  4636. foreach ( $A as $MKI => $AVL ) {
  4637. if (! empty ( $verifyStaff )) {
  4638. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4639. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4640. $button = 4;
  4641. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4642. }
  4643. foreach ( $verifyStaff as $m => $u ) {
  4644. $AVLFK = $AVL [0] . '_R';
  4645. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4646. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4647. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4648. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4649. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4650. break;
  4651. }
  4652. }
  4653. } else {
  4654. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4655. $button = 4;
  4656. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4657. }
  4658. }
  4659. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4660. $KOP = true;
  4661. }
  4662. }
  4663. foreach ( $roleArrayCopy as $k => $v ) {
  4664. foreach ( $verifyList as $m => $n ) {
  4665. if ($n [0] == $k) {
  4666. array_splice ( $verifyList, $m, 1, $v );
  4667. }
  4668. }
  4669. }
  4670. // 费用执行人相关数据
  4671. $executeCopy = json_decode ( $value ['executeCopy'], true );
  4672. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4673. foreach ( $executeCopy as $k => $v ) {
  4674. $executeCopy [$k] ['date'] = '';
  4675. $executeCopy [$k] ['opinion'] = '';
  4676. $executeCopy [$k] ['status'] = '';
  4677. if (! empty ( $executeStaff ))
  4678. foreach ( $executeStaff as $m => $u ) {
  4679. if ($v [0] == $m) {
  4680. $executeCopy [$k] ['date'] = $u ['date'];
  4681. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  4682. $executeCopy [$k] ['status'] = $u ['status'];
  4683. break;
  4684. }
  4685. }
  4686. }
  4687. $receiptList [$key] ['executeCopy'] = $executeCopy;
  4688. // print_r($verifyList);
  4689. $receiptList [$key] ['verifyList'] = $verifyList;
  4690. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4691. 'where' => 'sid=' . $value ['staff'],
  4692. 'asArray' => true
  4693. ) );
  4694. $receiptList [$key] ['button'] = $button;
  4695. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4696. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4697. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4698. $receiptList [$key] ['relust'] = $relust;
  4699. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4700. }
  4701. // print_r($receiptList);
  4702. // 获取审批日志
  4703. Doo::loadModel ( 'receiptLog' );
  4704. $receiptLog = new receiptLog ();
  4705. $rlList = array ();
  4706. $rlInfo = $receiptLog->getOne ( array (
  4707. 'where' => 'rid=' . $rid . ' and status=4',
  4708. 'asArray' => true
  4709. ) );
  4710. // $tijdate = $receiptLog->getOne ( array (
  4711. // 'where' => 'rid=' . $rid . ' and status=2',
  4712. // 'asc' => 'rlid',
  4713. // 'asArray' => true
  4714. // ) );
  4715. if (! empty ( $rlInfo )) {
  4716. $rlList = $receiptLog->find ( array (
  4717. 'where' => 'rid=' . $rid,
  4718. 'asc' => 'rlid',
  4719. 'asArray' => true
  4720. ) );
  4721. }
  4722. $RN=array();
  4723. if (!empty( $rolename ['staff'])){
  4724. $RN = @json_decode ( $rolename ['staff'] );
  4725. }
  4726. //
  4727. foreach ( $rlList as $key => $value ) {
  4728. $rlList [$key] ['rolename'] = '';
  4729. foreach ( $RN as $k => $v ) {
  4730. $id = explode ( "_", $v );
  4731. if ($id [0] == $value ['uid']) {
  4732. $rlList [$key] ['rolename'] = $FC;
  4733. break;
  4734. }
  4735. }
  4736. }
  4737. Doo::loadModel ( 'enclosur' );
  4738. $enclosur = new enclosur ();
  4739. $enclosurList = $enclosur->find ( array (
  4740. 'where' => 'rid=' . $rid,
  4741. 'asArray' => true
  4742. ) );
  4743. $enclosurHtml = '';
  4744. foreach ( $enclosurList as $value ) {
  4745. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4746. }
  4747. $data ['enclosurHtml'] = $enclosurHtml;
  4748. $receiptList [0] ['rlList'] = $rlList;
  4749. $data ['receiptList'] = $receiptList;
  4750. // print_r($receiptList);
  4751. $data ['memu'] = "receipt";
  4752. $data ['staff'] = $this->staff;
  4753. $data ['receiptMemu'] = 'approvalExpenses';
  4754. $data ['verifyId'] = $this->verifyId;
  4755. $data ['executeId'] = $this->executeId;
  4756. $this->render ( "/admin/expensesDoc", $data );
  4757. }
  4758. function expensesEdi() {
  4759. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4760. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  4761. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4762. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4763. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4764. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4765. if (empty ( $status ))
  4766. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  4767. $vidList = array ();
  4768. $button = 0;
  4769. Doo::loadModel ( 'verify' );
  4770. Doo::loadModel ( 'receipt' );
  4771. Doo::loadModel ( 'staff' );
  4772. $staff = new staff ();
  4773. $receipt = new receipt ();
  4774. $verify = new verify ();
  4775. Doo::loadModel ( 'L_category' );
  4776. $Lcategory = new L_category ();
  4777. Doo::loadModel ( 'enclosur' );
  4778. $enclosur = new enclosur ();
  4779. // user verify ID
  4780. $verifyDetail = $verify->find ( array (
  4781. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  4782. 'asArray' => true
  4783. ) );
  4784. foreach ( $verifyDetail as $key => $value ) {
  4785. array_push ( $vidList, $value ['vid'] );
  4786. }
  4787. $vid = implode ( ",", $vidList );
  4788. if (empty ( $verifyDetail ))
  4789. $vid = 0;
  4790. $categoryList = $Lcategory->find ( array (
  4791. 'asArray' => true
  4792. ) );
  4793. $staffList = $staff->find ( array (
  4794. 'where' => 'cid=' . $cid,
  4795. 'asArray' => true
  4796. ) );
  4797. $ap = "";
  4798. if ($status == 4) {
  4799. $ap = 4;
  4800. $status = 2;
  4801. }
  4802. // get Receipt By verifyID status 2
  4803. $receiptList = $receipt->find ( array (
  4804. 'where' => 'rid =' . $rid . ' and status=2',
  4805. 'desc' => 'rid',
  4806. 'asArray' => true
  4807. ) );
  4808. if (empty ( $receiptList )) {
  4809. die ( 'illegal request' );
  4810. }
  4811. $Locate = 0;
  4812. $roleId = 0;
  4813. if ($ap == 4)
  4814. $status = 4;
  4815. foreach ( $receiptList as $key => $value ) {
  4816. $receiptList [$key] ['Locate'] = $Locate;
  4817. $Locate ++;
  4818. $receiptList [$key] ['reviseDetail'] = array ();
  4819. if (! empty ( $value ['reviseDetail'] ))
  4820. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4821. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4822. $categoryDetil = $Lcategory->getOne ( array (
  4823. 'where' => 'cid=' . $value ['cid'],
  4824. 'asArray' => true
  4825. ) );
  4826. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4827. // 检测编辑状态
  4828. $verifyList = $verify->getOne ( array (
  4829. 'where' => 'vid=' . $value ['verify'],
  4830. 'asArray' => true
  4831. ) );
  4832. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4833. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4834. Doo::loadModel ( 'role' );
  4835. $role = new role ();
  4836. // print_r($verifyList);
  4837. $flag = true;
  4838. $roleKey = 0;
  4839. $endStaffArray = array ();
  4840. $roleArrayCopy = array ();
  4841. foreach ( $verifyList as $k => $v ) {
  4842. // init verifyStaff
  4843. if ($v [1] == 'ROLE') {
  4844. if (! empty ( $verifyStaff )) {
  4845. $endStaffArray = end ( $verifyStaff );
  4846. if ($v [0] == $endStaffArray ['nextStaff']) {
  4847. $roleId = $v [0];
  4848. }
  4849. }
  4850. $roleVerify = json_decode ( $v [3], true );
  4851. $roleKey = $k;
  4852. $roleArray = array ();
  4853. $rolename = $role->getOne ( array (
  4854. 'where' => 'rid=' . $v [0],
  4855. 'asArray' => true
  4856. ) );
  4857. foreach ( $roleVerify as $o => $p ) {
  4858. $staffID = explode ( '_', $p );
  4859. $staffInfo = $staff->getOne ( array (
  4860. 'where' => 'sid=' . $staffID [0],
  4861. 'asArray' => true
  4862. ) );
  4863. // print_r($staffID);
  4864. $exp = array (
  4865. 0 => $staffInfo ['sid'],
  4866. 1 => $staffID [1],
  4867. 2 => $staffInfo ['avatar'],
  4868. 'date' => '',
  4869. 'date' => '',
  4870. 'opinion' => '',
  4871. 'status' => '',
  4872. 'rolename' => $rolename ['name']
  4873. );
  4874. array_push ( $roleArray, $exp );
  4875. }
  4876. $roleArrayCopy [$v [0]] = $roleArray;
  4877. // $verifyList[$k]['roleArray']=$roleArray;
  4878. }
  4879. // print_r($roleArray);
  4880. $verifyList [$k] ['date'] = "";
  4881. $verifyList [$k] ['opinion'] = "";
  4882. $verifyList [$k] ['status'] = "";
  4883. if (empty ( $verifyStaff )) {
  4884. $verifyList [$k] ['date'] = "";
  4885. $verifyList [$k] ['opinion'] = "";
  4886. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4887. $verifyList [$k] ['status'] = 4;
  4888. $button = 4;
  4889. $flag = false;
  4890. }
  4891. } else {
  4892. foreach ( $verifyStaff as $m => $u ) {
  4893. if ($v [0] == $m) {
  4894. $verifyList [$k] ['date'] = $u ['date'];
  4895. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4896. $verifyList [$k] ['status'] = $u ['status'];
  4897. $flag = false;
  4898. break;
  4899. }
  4900. }
  4901. $endStaffArray = end ( $verifyStaff );
  4902. if (isset ( $endStaffArray ['ROLE'] )) {
  4903. } else {
  4904. $endKey = key ( $verifyStaff );
  4905. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4906. $button = 4;
  4907. $verifyList [$k] ['status'] = 4;
  4908. }
  4909. }
  4910. }
  4911. }
  4912. $rolename ['name'] = '';
  4913. if (! empty ( $roleId )) {
  4914. Doo::loadModel ( 'role' );
  4915. $role = new role ();
  4916. $rolename = $role->getOne ( array (
  4917. 'where' => 'rid=' . $roleId,
  4918. 'asArray' => true
  4919. ) );
  4920. }
  4921. if (! empty ( $verifyStaff ))
  4922. $endStaffArray = end ( $verifyStaff );
  4923. $KOP = false;
  4924. foreach ( $roleArrayCopy as $P => $A ) {
  4925. foreach ( $A as $MKI => $AVL ) {
  4926. if (! empty ( $verifyStaff )) {
  4927. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4928. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4929. $button = 4;
  4930. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4931. }
  4932. foreach ( $verifyStaff as $m => $u ) {
  4933. $AVLFK = $AVL [0] . '_R';
  4934. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4935. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4936. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4937. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4938. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4939. break;
  4940. }
  4941. }
  4942. } else {
  4943. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4944. $button = 4;
  4945. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4946. }
  4947. }
  4948. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4949. $KOP = true;
  4950. }
  4951. }
  4952. // print_r($roleArrayCopy);
  4953. // echo $roleKey;
  4954. foreach ( $roleArrayCopy as $k => $v ) {
  4955. foreach ( $verifyList as $m => $n ) {
  4956. if ($n [0] == $k) {
  4957. array_splice ( $verifyList, $m, 1, $v );
  4958. }
  4959. }
  4960. }
  4961. $receiptList [$key] ['verifyList'] = $verifyList;
  4962. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4963. 'where' => 'sid=' . $value ['staff'],
  4964. 'asArray' => true
  4965. ) );
  4966. $receiptList [$key] ['button'] = $button;
  4967. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  4968. }
  4969. // $data['verifyDetail']=$verifyDetail;
  4970. $mothHtml = "";
  4971. for($i = 1; $i <= 12; $i ++) {
  4972. if ($month == $i)
  4973. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4974. else
  4975. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4976. }
  4977. // 获取审批日志
  4978. Doo::loadModel ( 'receiptLog' );
  4979. $receiptLog = new receiptLog ();
  4980. $rlList = array ();
  4981. $rlInfo = $receiptLog->getOne ( array (
  4982. 'where' => 'rid=' . $rid . ' and status=4',
  4983. 'asArray' => true
  4984. ) );
  4985. $tijdate = $receiptLog->getOne ( array (
  4986. 'where' => 'rid=' . $rid . ' and status=2',
  4987. 'asc' => 'rlid',
  4988. 'asArray' => true
  4989. ) );
  4990. if (! empty ( $rlInfo )) {
  4991. $rlList = $receiptLog->find ( array (
  4992. 'where' => 'rid=' . $rid,
  4993. 'asc' => 'rlid',
  4994. 'asArray' => true
  4995. ) );
  4996. }
  4997. $receiptList [0] ['rlList'] = $rlList;
  4998. $enclosurList = $enclosur->find ( array (
  4999. 'where' => 'rid=' . $rid,
  5000. 'asArray' => true
  5001. ) );
  5002. $enclosurHtml = '';
  5003. foreach ( $enclosurList as $value ) {
  5004. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5005. }
  5006. // print_r($receiptList);
  5007. $data ['rid'] = $rid;
  5008. $data ['enclosurHtml'] = $enclosurHtml;
  5009. $data ['rolename'] = $rolename ['name'];
  5010. $data ['datetij'] = $tijdate ['date'];
  5011. $data ['mothHtml'] = $mothHtml;
  5012. $data ['receiptList'] = $receiptList;
  5013. $data ['receiptApprovalCount'] = count ( $receiptList );
  5014. $data ['status'] = $status;
  5015. $data ['year'] = $year;
  5016. $data ['categoryList'] = $categoryList;
  5017. $data ['staffList'] = $staffList;
  5018. $data ['cid'] = $cid;
  5019. $data ['sid'] = $sid;
  5020. $data ['ap'] = $ap;
  5021. $data ['memu'] = "receipt";
  5022. $data ['staff'] = $this->staff;
  5023. $data ['receiptMemu'] = 'approvalExpenses';
  5024. $data ['verifyId'] = $this->verifyId;
  5025. $data ['executeId'] = $this->executeId;
  5026. $this->render ( "/admin/expensesEdi", $data );
  5027. }
  5028. function expensesDefray() {
  5029. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  5030. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  5031. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5032. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  5033. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  5034. if (! empty ( $rid )) {
  5035. Doo::loadModel ( "verify" );
  5036. $verify = new verify ();
  5037. Doo::loadModel ( "receiptDetail" );
  5038. $receiptDetailObj = new receiptDetail ();
  5039. Doo::loadModel ( "itemStatistics" );
  5040. Doo::loadModel ( "statistics" );
  5041. $statistics = new statistics ();
  5042. $itemStatistics = new itemStatistics ();
  5043. Doo::loadModel ( "receipt" );
  5044. $receipt = new receipt ();
  5045. Doo::loadModel ( "loanReceipt" );
  5046. $loanReceipt = new loanReceipt ();
  5047. $receiptDetail = $receipt->getOne ( array (
  5048. 'where' => 'rid=' . $rid . ' and status=2 ',
  5049. 'asArray' => true
  5050. ) );
  5051. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  5052. $nsflag = true;
  5053. foreach ( $nslist as $value ) {
  5054. if ($value == $this->staff ['0'] ['sid']) {
  5055. $nsflag = false;
  5056. break;
  5057. }
  5058. }
  5059. // print_r($nslist);die;
  5060. if (empty ( $receiptDetail ) || $nsflag)
  5061. return "/approvalExpenses/pendApproval";
  5062. $verifyDetail = $verify->getOne ( array (
  5063. 'where' => ' vid =' . $receiptDetail ['verify'],
  5064. 'asArray' => true
  5065. ) );
  5066. $verifyString = $verifyDetail ['staff'];
  5067. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5068. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  5069. if (empty ( $opinion )) {
  5070. if ($status == 3)
  5071. $opinion = "终止";
  5072. else
  5073. $opinion = "同意支付";
  5074. }
  5075. $nowStaff = 0;
  5076. $nowStaffList = array ();
  5077. if (empty ( $verifyStaff )) {
  5078. // 还需加入是否已经进入角色审批
  5079. if ($verifyDetail [0] [1] == 'ROLE') {
  5080. // print_r($verifyDetail);echo "ddd";
  5081. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5082. foreach ( $vStaffString as $key => $value ) {
  5083. $staffK = explode ( "_", $value );
  5084. if ($staffK [0] != $this->staff [0] ['sid'])
  5085. array_push ( $nowStaffList, $staffK [0] );
  5086. }
  5087. // print_r($verifyDetail);
  5088. // die;
  5089. if (! empty ( $nowStaffList )) {
  5090. $nowStaff = implode ( ',', $nowStaffList );
  5091. $verifyStaff = array (
  5092. $this->staff [0] ['sid'] . "_R" => array (
  5093. 'date' => date ( 'Y-m-d' ),
  5094. 'opinion' => $opinion,
  5095. 'status' => $status,
  5096. 'nextStaff' => $verifyDetail [0] [0],
  5097. 'ROLE' => 1
  5098. )
  5099. );
  5100. } else {
  5101. $nowStaff = $verifyDetail [1] [0];
  5102. $verifyStaff = array (
  5103. $this->staff [0] ['sid'] . "_R" => array (
  5104. 'date' => date ( 'Y-m-d' ),
  5105. 'opinion' => $opinion,
  5106. 'status' => $status,
  5107. 'nextStaff' => $verifyDetail [1] [0]
  5108. )
  5109. );
  5110. }
  5111. } else {
  5112. if ($verifyDetail [1] [1] == 'ROLE') {
  5113. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  5114. // echo "dd";
  5115. foreach ( $vStaffString as $key => $value ) {
  5116. $staffK = explode ( "_", $value );
  5117. array_push ( $nowStaffList, $staffK [0] );
  5118. }
  5119. $nowStaff = implode ( ',', $nowStaffList );
  5120. $verifyStaff = array (
  5121. $this->staff [0] ['sid'] => array (
  5122. 'date' => date ( 'Y-m-d' ),
  5123. 'opinion' => $opinion,
  5124. 'status' => $status,
  5125. 'nextStaff' => $verifyDetail [1] [0],
  5126. 'ROLE' => 1
  5127. )
  5128. );
  5129. } else {
  5130. $nowStaff = $verifyDetail [1] [0];
  5131. $verifyStaff = array (
  5132. $this->staff [0] ['sid'] => array (
  5133. 'date' => date ( 'Y-m-d' ),
  5134. 'opinion' => $opinion,
  5135. 'status' => $status,
  5136. 'nextStaff' => $verifyDetail [1] [0]
  5137. )
  5138. );
  5139. }
  5140. }
  5141. if ($status == 3)
  5142. $verifyStaff = array (
  5143. 'final' => $status,
  5144. $this->staff [0] ['sid'] => array (
  5145. 'date' => date ( 'Y-m-d' ),
  5146. 'opinion' => $opinion,
  5147. 'status' => $status
  5148. )
  5149. );
  5150. $vStaffString = json_encode ( $verifyStaff );
  5151. $receipt->nowStaff = $nowStaff;
  5152. $receipt->verifyStaff = $vStaffString;
  5153. $loanReceipt->nowStaff = $nowStaff;
  5154. $loanReceipt->verifyStaff = $vStaffString;
  5155. } else {
  5156. $VS = end ( $verifyStaff );
  5157. // 非角色审批
  5158. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  5159. $nextStaff = 0;
  5160. $roleSTF = false;
  5161. foreach ( $verifyDetail as $key => $value ) {
  5162. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  5163. if (isset ( $verifyDetail [$key + 1] )) {
  5164. $nextStaff = $verifyDetail [$key + 1] [0];
  5165. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  5166. $roleSTF = true;
  5167. }
  5168. break;
  5169. }
  5170. }
  5171. if (! $roleSTF) {
  5172. $nowStaff = $nextStaff;
  5173. $verifyStaff [$this->staff [0] ['sid']] = array (
  5174. 'date' => date ( 'Y-m-d' ),
  5175. 'opinion' => $opinion,
  5176. 'status' => $status,
  5177. 'nextStaff' => $nextStaff
  5178. );
  5179. } else {
  5180. // 获取角色下的所有用户ID
  5181. $nowStaffList = array ();
  5182. foreach ( $verifyDetail as $vfk ) {
  5183. if ($vfk [1] == 'ROLE') {
  5184. $vStaffString = json_decode ( $vfk [3] );
  5185. foreach ( $vStaffString as $key => $value ) {
  5186. $staffK = explode ( "_", $value );
  5187. array_push ( $nowStaffList, $staffK [0] );
  5188. }
  5189. }
  5190. }
  5191. $nowStaff = implode ( ',', $nowStaffList );
  5192. $verifyStaff [$this->staff [0] ['sid']] = array (
  5193. 'date' => date ( 'Y-m-d' ),
  5194. 'opinion' => $opinion,
  5195. 'status' => $status,
  5196. 'nextStaff' => $nextStaff,
  5197. 'ROLE' => 0
  5198. );
  5199. }
  5200. if ($status == 3) {
  5201. $verifyStaff ['final'] = $status;
  5202. $verifyStaff [$this->staff [0] ['sid']] = array (
  5203. 'date' => date ( 'Y-m-d' ),
  5204. 'opinion' => $opinion,
  5205. 'status' => $status
  5206. );
  5207. }
  5208. $vStaffString = json_encode ( $verifyStaff );
  5209. $receipt->nowStaff = $nowStaff;
  5210. $receipt->verifyStaff = $vStaffString;
  5211. $loanReceipt->nowStaff = $nowStaff;
  5212. $loanReceipt->verifyStaff = $vStaffString;
  5213. }
  5214. // 角色审批
  5215. if (isset ( $VS ['ROLE'] )) {
  5216. // 找出角色人 当前审批角色组
  5217. $verifyJSStaff = array ();
  5218. $nowStaffList2 = array ();
  5219. foreach ( $verifyDetail as $key => $value ) {
  5220. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  5221. $verifyJSStaff = json_decode ( $value [3] );
  5222. foreach ( $verifyJSStaff as $m ) {
  5223. $staffK = explode ( "_", $m );
  5224. array_push ( $nowStaffList2, $staffK [0] );
  5225. }
  5226. // print_r($nowStaffList2);
  5227. }
  5228. }
  5229. $RoleVerifyStaff = array ();
  5230. foreach ( $verifyStaff as $key => $value ) {
  5231. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  5232. foreach ( $nowStaffList2 as $m ) {
  5233. if ($key == $m . "_R")
  5234. $RoleVerifyStaff [$key] = $value;
  5235. }
  5236. }
  5237. }
  5238. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  5239. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  5240. // 下一个审批人ID
  5241. $nextStaff = 0;
  5242. $falg = false;
  5243. foreach ( $verifyDetail as $key => $value ) {
  5244. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  5245. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  5246. $falg = true;
  5247. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  5248. $nowStaffList = array ();
  5249. foreach ( $vStaffString as $v ) {
  5250. $staffK = explode ( "_", $v );
  5251. array_push ( $nowStaffList, $staffK [0] );
  5252. }
  5253. $nowStaff = implode ( ',', $nowStaffList );
  5254. $nextStaff = $verifyDetail [$key + 1] [0];
  5255. } elseif (isset ( $verifyDetail [$key + 1] )) {
  5256. $nextStaff = $verifyDetail [$key + 1] [0];
  5257. $nowStaff = $nextStaff;
  5258. } else
  5259. $nowStaff = '';
  5260. break;
  5261. }
  5262. }
  5263. if ($falg)
  5264. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5265. 'date' => date ( 'Y-m-d' ),
  5266. 'opinion' => $opinion,
  5267. 'status' => $status,
  5268. 'nextStaff' => $nextStaff,
  5269. 'ROLE' => 1
  5270. );
  5271. else
  5272. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5273. 'date' => date ( 'Y-m-d' ),
  5274. 'opinion' => $opinion,
  5275. 'status' => $status,
  5276. 'nextStaff' => $nextStaff
  5277. );
  5278. // print_r($verifyStaff);
  5279. // echo $nowStaff;die;
  5280. } else { // 进入下一个角色或者审批人
  5281. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  5282. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5283. 'date' => date ( 'Y-m-d' ),
  5284. 'opinion' => $opinion,
  5285. 'status' => $status,
  5286. 'nextStaff' => $VS ['nextStaff'],
  5287. 'ROLE' => 1
  5288. );
  5289. }
  5290. if ($status == 3) {
  5291. $verifyStaff ['final'] = $status;
  5292. $verifyStaff [$this->staff [0] ['sid']] = array (
  5293. 'date' => date ( 'Y-m-d' ),
  5294. 'opinion' => $opinion,
  5295. 'status' => $status
  5296. );
  5297. }
  5298. $vStaffString = json_encode ( $verifyStaff );
  5299. $receipt->verifyStaff = $vStaffString;
  5300. $receipt->nowStaff = $nowStaff;
  5301. $loanReceipt->nowStaff = $nowStaff;
  5302. $loanReceipt->verifyStaff = $vStaffString;
  5303. }
  5304. // print_r($verifyStaff);die;
  5305. }
  5306. $roleKey = 0;
  5307. $roleId = 0;
  5308. $verifyDetailCopy = array ();
  5309. foreach ( $verifyDetail as $k => $v ) {
  5310. if ($v [1] == 'ROLE') {
  5311. $roleId = $v [0];
  5312. $roleVerify = json_decode ( $v [3], true );
  5313. $roleKey = $k;
  5314. $roleArray = array ();
  5315. foreach ( $roleVerify as $o => $p ) {
  5316. $staffID = explode ( '_', $p );
  5317. $exp = array (
  5318. 0 => $staffID [0],
  5319. 1 => $staffID [1]
  5320. );
  5321. array_push ( $roleArray, $exp );
  5322. }
  5323. $verifyDetailCopy [$v [0]] = $roleArray;
  5324. }
  5325. }
  5326. // print_r($verifyDetail);
  5327. foreach ( $verifyDetailCopy as $k => $v ) {
  5328. foreach ( $verifyDetail as $m => $n ) {
  5329. if ($n [0] == $k) {
  5330. array_splice ( $verifyDetail, $m, 1, $v );
  5331. }
  5332. }
  5333. }
  5334. // 审批日志
  5335. if (! isset ( $verifyStaff ['final'] )) {
  5336. Doo::loadModel ( "receiptLog" );
  5337. $receiptLog = new receiptLog ();
  5338. if (! empty ( $roleId )) {
  5339. Doo::loadModel ( "role" );
  5340. $role = new role ();
  5341. $roleInfo = $role->getOne ( array (
  5342. 'where' => 'rid=' . $roleId,
  5343. 'asArray' => true
  5344. ) );
  5345. $receiptLog->rolename = $roleInfo ['name'];
  5346. }
  5347. $receiptLog->username = $this->staff [0] ['username'];
  5348. $receiptLog->uid = $this->staff [0] ['sid'];
  5349. $receiptLog->date = date ( "Y-m-d" );
  5350. $receiptLog->opinion = $opinion;
  5351. $receiptLog->img = $this->staff [0] ['avatar'];
  5352. $receiptLog->status = 1;
  5353. $receiptLog->rid = $rid;
  5354. $receiptLog->insert ();
  5355. }
  5356. if (isset ( $verifyStaff ['final'] )) { // rDetail
  5357. $receipt->status = 3;
  5358. $receipt->verifyBreakup = $verifyString;
  5359. $receiptDetailObj->status = 3;
  5360. $receiptDetailObj->update ( array (
  5361. 'where' => 'rid=' . $rid
  5362. ) );
  5363. // 微信企业号通知
  5364. $this->setWXMsg ( $rid, 3 );
  5365. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  5366. $receipt->status = 6;
  5367. $receipt->pastDate = date ( "Y-m-d" );
  5368. $receipt->isBK = 1;
  5369. $loanReceipt->verifyBreakup = $verifyString;
  5370. $loanReceipt->status = 1;
  5371. $loanReceipt->pastDate = date ( "Y-m-d" );
  5372. //生成流水后 不更新汇款金额
  5373. Doo::loadModel ( 'wasteBook' );
  5374. $wasteBook = new wasteBook ();
  5375. $wbDetail = $wasteBook->getWateBookByAD ( 1, $rid );
  5376. if (empty($wbDetail)){
  5377. $loanReceipt->amount = $receiptDetail ['amount'];
  5378. }
  5379. $loanReceipt->update ( array (
  5380. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  5381. ) );
  5382. // 微信企业号通知
  5383. $this->setWXMsg ( $rid, 1 );
  5384. }
  5385. $receipt->amount = $receiptDetail['sum'];
  5386. $receipt->update ( array (
  5387. 'where' => ' rid = ' . $rid
  5388. ) );
  5389. // 进入下一条审批费用新加需求
  5390. $vidList = array ();
  5391. $verifyDetail = $verify->find ( array (
  5392. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  5393. 'asArray' => true
  5394. ) );
  5395. foreach ( $verifyDetail as $key => $value ) {
  5396. array_push ( $vidList, $value ['vid'] );
  5397. }
  5398. $vid = implode ( ",", $vidList );
  5399. if (empty ( $verifyDetail ))
  5400. $vid = 0;
  5401. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  5402. $receipt = new receipt ();
  5403. $rd = $receipt->getOne ( array (
  5404. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  5405. 'asc' => 'rid',
  5406. 'asArray' => true
  5407. ) );
  5408. if (empty ( $rd )) {
  5409. return '/approvalExpenses/pendApproval';
  5410. }
  5411. if ($rd ['Rtype'] == 1) {
  5412. if ($rd ['isBK'] == 1) {
  5413. return '/receiptburEdi/' . $rd ['rid'];
  5414. } else {
  5415. return '/expensesEdi/' . $rd ['rid'];
  5416. }
  5417. } elseif ($rd ['Rtype'] == 2) {
  5418. return '/remitApproval/' . $rd ['rid'];
  5419. } else {
  5420. return '/receiptburEdi/' . $rd ['rid'];
  5421. }
  5422. // return "/approvalExpenses/pendApproval";
  5423. }
  5424. }
  5425. function ajaxExamineExe() {
  5426. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5427. Doo::loadModel ( 'receipt' );
  5428. $receipt = new receipt ();
  5429. Doo::loadClass ( 'XDeode' );
  5430. $XDeode = new XDeode ( 5 );
  5431. if (! empty ( $rid )) {
  5432. $rLRes = $receipt->find ( array (
  5433. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  5434. 'asArray' => true
  5435. ) );
  5436. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  5437. echo json_encode ( array (
  5438. 'status' => 1,
  5439. 'receipt' => $rLRes [0]
  5440. ) );
  5441. die ();
  5442. }
  5443. echo json_encode ( array (
  5444. 'status' => 0,
  5445. 'receipt' => array ()
  5446. ) );
  5447. die ();
  5448. }
  5449. function implement() {
  5450. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5451. $Rtype = isset ( $this->params ['Rtype'] ) ? $this->params ['Rtype'] : '';
  5452. Doo::loadClass ( 'XDeode' );
  5453. $XDeode = new XDeode ( 5 );
  5454. Doo::loadModel ( 'receipt' );
  5455. $receipt = new receipt ();
  5456. Doo::loadModel ( 'L_category' );
  5457. $Lcategory = new L_category ();
  5458. Doo::loadModel ( 'verify' );
  5459. $verify = new verify ();
  5460. Doo::loadModel ( 'staff' );
  5461. $staff = new staff ();
  5462. Doo::loadModel ( "execute" );
  5463. $execute = new execute ();
  5464. $rid = $XDeode->decode ( $rid );
  5465. $receiptList = $receipt->find ( array (
  5466. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  5467. 'desc' => 'rid',
  5468. 'asArray' => true
  5469. ) );
  5470. Doo::loadModel ( 'loanReceipt' );
  5471. $loanReceipt = new loanReceipt ();
  5472. // print_r($receiptList);
  5473. $loanList = array ();
  5474. if (! isset ( $receiptList ))
  5475. $loanList = $loanReceipt->find ( array (
  5476. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  5477. 'desc' => 'rid',
  5478. 'asArray' => true
  5479. ) );
  5480. $Locate = 0;
  5481. $roleId = 0;
  5482. $button = 0;
  5483. foreach ( $loanList as $key => $value ) {
  5484. $loanList [$key] ['Locate'] = $Locate;
  5485. $Locate ++;
  5486. $loanList [$key] ['reviseDetail'] = array ();
  5487. if (! empty ( $value ['reviseDetail'] ))
  5488. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5489. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5490. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5491. $categoryDetil = $Lcategory->getOne ( array (
  5492. 'where' => 'cid=' . $value ['cid'],
  5493. 'asArray' => true
  5494. ) );
  5495. $loanList [$key] ['category'] = $categoryDetil ['title'];
  5496. // 检测编辑状态
  5497. $verifyList = $verify->getOne ( array (
  5498. 'where' => 'vid=' . $value ['verify'],
  5499. 'asArray' => true
  5500. ) );
  5501. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5502. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5503. Doo::loadModel ( 'role' );
  5504. $role = new role ();
  5505. $flag = true;
  5506. $roleKey = 0;
  5507. $endStaffArray = array ();
  5508. $roleArrayCopy = array ();
  5509. foreach ( $verifyList as $k => $v ) {
  5510. // init verifyStaff
  5511. if ($v [1] == 'ROLE') {
  5512. if (! empty ( $verifyStaff )) {
  5513. $endStaffArray = end ( $verifyStaff );
  5514. // if ($v[0]==$endStaffArray['nextStaff']){
  5515. // $roleId=$v[0];
  5516. // }
  5517. }
  5518. $roleVerify = json_decode ( $v [3], true );
  5519. $roleKey = $k;
  5520. $roleArray = array ();
  5521. $rolename = $role->getOne ( array (
  5522. 'where' => 'rid=' . $v [0],
  5523. 'asArray' => true
  5524. ) );
  5525. foreach ( $roleVerify as $o => $p ) {
  5526. $staffID = explode ( '_', $p );
  5527. $staffInfo = $staff->getOne ( array (
  5528. 'where' => 'sid=' . $staffID [0],
  5529. 'asArray' => true
  5530. ) );
  5531. // print_r($staffID);
  5532. $exp = array (
  5533. 0 => $staffInfo ['sid'],
  5534. 1 => $staffID [1],
  5535. 2 => $staffInfo ['avatar'],
  5536. 'date' => '',
  5537. 'date' => '',
  5538. 'opinion' => '',
  5539. 'status' => '',
  5540. 'rolename' => $rolename ['name']
  5541. );
  5542. array_push ( $roleArray, $exp );
  5543. }
  5544. $roleArrayCopy [$v [0]] = $roleArray;
  5545. // $verifyList[$k]['roleArray']=$roleArray;
  5546. }
  5547. $verifyList [$k] ['date'] = "";
  5548. $verifyList [$k] ['opinion'] = "";
  5549. $verifyList [$k] ['status'] = "";
  5550. if (empty ( $verifyStaff )) {
  5551. $verifyList [$k] ['date'] = "";
  5552. $verifyList [$k] ['opinion'] = "";
  5553. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5554. $verifyList [$k] ['status'] = 4;
  5555. $flag = false;
  5556. }
  5557. } else {
  5558. foreach ( $verifyStaff as $m => $u ) {
  5559. if ($v [0] == $m) {
  5560. $verifyList [$k] ['date'] = $u ['date'];
  5561. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5562. $verifyList [$k] ['status'] = $u ['status'];
  5563. $flag = false;
  5564. break;
  5565. }
  5566. }
  5567. $endStaffArray = end ( $verifyStaff );
  5568. if (isset ( $endStaffArray ['ROLE'] )) {
  5569. } else {
  5570. // $endKey=key($verifyStaff);
  5571. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5572. // $button=4;
  5573. // $verifyList[$k]['status']=4;
  5574. // }
  5575. }
  5576. }
  5577. }
  5578. $rolename ['name'] = '';
  5579. if (! empty ( $roleId )) {
  5580. Doo::loadModel ( 'role' );
  5581. $role = new role ();
  5582. $rolename = $role->getOne ( array (
  5583. 'where' => 'rid=' . $roleId,
  5584. 'asArray' => true
  5585. ) );
  5586. }
  5587. if (! empty ( $verifyStaff ))
  5588. $endStaffArray = end ( $verifyStaff );
  5589. $KOP = false;
  5590. foreach ( $roleArrayCopy as $P => $A ) {
  5591. foreach ( $A as $MKI => $AVL ) {
  5592. if (! empty ( $verifyStaff )) {
  5593. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5594. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5595. $button = 4;
  5596. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5597. }
  5598. foreach ( $verifyStaff as $m => $u ) {
  5599. $AVLFK = $AVL [0] . '_R';
  5600. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5601. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5602. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5603. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5604. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5605. break;
  5606. }
  5607. }
  5608. } else {
  5609. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5610. $button = 4;
  5611. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5612. }
  5613. }
  5614. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5615. $KOP = true;
  5616. }
  5617. }
  5618. foreach ( $roleArrayCopy as $k => $v ) {
  5619. foreach ( $verifyList as $m => $n ) {
  5620. if ($n [0] == $k) {
  5621. array_splice ( $verifyList, $m, 1, $v );
  5622. }
  5623. }
  5624. }
  5625. $loanList [$key] ['verifyList'] = $verifyList;
  5626. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  5627. 'where' => 'sid=' . $value ['staff'],
  5628. 'asArray' => true
  5629. ) );
  5630. }
  5631. $data ['loanList'] = $loanList;
  5632. $Locate = 0;
  5633. $roleId = 0;
  5634. $button = 0;
  5635. Doo::loadClass ( 'XDeode' );
  5636. $XDeode = new XDeode ( 5 );
  5637. foreach ( $receiptList as $key => $value ) {
  5638. $receiptList[$key]['ridKey']=$XDeode->encode ( $value['rid'] );
  5639. $button2 = 0;
  5640. $receiptList [$key] ['Locate'] = $Locate;
  5641. $Locate ++;
  5642. $receiptList [$key] ['reviseDetail'] = array ();
  5643. if (! empty ( $value ['reviseDetail'] ))
  5644. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5645. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5646. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5647. $categoryDetil = $Lcategory->getOne ( array (
  5648. 'where' => 'cid=' . $value ['cid'],
  5649. 'asArray' => true
  5650. ) );
  5651. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5652. $executeList = json_decode ( $value ['executeCopy'], true );
  5653. $executeStaff = array ();
  5654. if (! empty ( $value ['executeStaff'] ))
  5655. $executeStaff = json_decode ( $value ['executeStaff'], true );
  5656. if (isset ( $executeList )) {
  5657. foreach ( $executeList as $op => $lo ) {
  5658. $executeList [$op] ['date'] = "";
  5659. $executeList [$op] ['opinion'] = "";
  5660. $executeList [$op] ['status'] = "";
  5661. foreach ( $executeStaff as $m => $u ) {
  5662. if ($lo [0] == $m) {
  5663. $executeList [$op] ['date'] = $u ['date'];
  5664. $executeList [$op] ['opinion'] = $u ['opinion'];
  5665. $executeList [$op] ['status'] = $u ['status'];
  5666. break;
  5667. }
  5668. }
  5669. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  5670. $button2 = 1;
  5671. $executeList [$op] ['status'] = 4;
  5672. }
  5673. }
  5674. }
  5675. // 检测编辑状态
  5676. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  5677. $verifyList ['staff'] = $value ['verifyBreakup'];
  5678. } else
  5679. $verifyList = $verify->getOne ( array (
  5680. 'where' => 'vid=' . $value ['verify'],
  5681. 'asArray' => true
  5682. ) );
  5683. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5684. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5685. Doo::loadModel ( 'role' );
  5686. $role = new role ();
  5687. if ($verifyList == NULL)
  5688. $verifyList = array ();
  5689. $flag = true;
  5690. $roleKey = 0;
  5691. $endStaffArray = array ();
  5692. $roleArrayCopy = array ();
  5693. foreach ( $verifyList as $k => $v ) {
  5694. // init verifyStaff
  5695. if ($v [1] == 'ROLE') {
  5696. if (! empty ( $verifyStaff )) {
  5697. $endStaffArray = end ( $verifyStaff );
  5698. // if ($v[0]==$endStaffArray['nextStaff']){
  5699. // $roleId=$v[0];
  5700. // }
  5701. }
  5702. $roleVerify = json_decode ( $v [3], true );
  5703. $roleKey = $k;
  5704. $roleArray = array ();
  5705. $rolename = $role->getOne ( array (
  5706. 'where' => 'rid=' . $v [0],
  5707. 'asArray' => true
  5708. ) );
  5709. foreach ( $roleVerify as $o => $p ) {
  5710. $staffID = explode ( '_', $p );
  5711. $staffInfo = $staff->getOne ( array (
  5712. 'where' => 'sid=' . $staffID [0],
  5713. 'asArray' => true
  5714. ) );
  5715. // print_r($staffID);
  5716. $exp = array (
  5717. 0 => $staffInfo ['sid'],
  5718. 1 => $staffID [1],
  5719. 2 => $staffInfo ['avatar'],
  5720. 'date' => '',
  5721. 'date' => '',
  5722. 'opinion' => '',
  5723. 'status' => '',
  5724. 'rolename' => $rolename ['name']
  5725. );
  5726. array_push ( $roleArray, $exp );
  5727. }
  5728. $roleArrayCopy [$v [0]] = $roleArray;
  5729. // $verifyList[$k]['roleArray']=$roleArray;
  5730. }
  5731. $verifyList [$k] ['date'] = "";
  5732. $verifyList [$k] ['opinion'] = "";
  5733. $verifyList [$k] ['status'] = "";
  5734. if (empty ( $verifyStaff )) {
  5735. $verifyList [$k] ['date'] = "";
  5736. $verifyList [$k] ['opinion'] = "";
  5737. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5738. $verifyList [$k] ['status'] = 4;
  5739. $flag = false;
  5740. }
  5741. } else {
  5742. foreach ( $verifyStaff as $m => $u ) {
  5743. if ($v [0] == $m) {
  5744. $verifyList [$k] ['date'] = $u ['date'];
  5745. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5746. $verifyList [$k] ['status'] = $u ['status'];
  5747. $flag = false;
  5748. break;
  5749. }
  5750. }
  5751. $endStaffArray = end ( $verifyStaff );
  5752. if (isset ( $endStaffArray ['ROLE'] )) {
  5753. } else {
  5754. // $endKey=key($verifyStaff);
  5755. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5756. // $button=4;
  5757. // $verifyList[$k]['status']=4;
  5758. // }
  5759. }
  5760. }
  5761. }
  5762. $rolename ['name'] = '';
  5763. if (! empty ( $roleId )) {
  5764. Doo::loadModel ( 'role' );
  5765. $role = new role ();
  5766. $rolename = $role->getOne ( array (
  5767. 'where' => 'rid=' . $roleId,
  5768. 'asArray' => true
  5769. ) );
  5770. }
  5771. if (! empty ( $verifyStaff ))
  5772. $endStaffArray = end ( $verifyStaff );
  5773. $KOP = false;
  5774. foreach ( $roleArrayCopy as $P => $A ) {
  5775. foreach ( $A as $MKI => $AVL ) {
  5776. if (! empty ( $verifyStaff )) {
  5777. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5778. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5779. $button = 4;
  5780. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5781. }
  5782. foreach ( $verifyStaff as $m => $u ) {
  5783. $AVLFK = $AVL [0] . '_R';
  5784. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5785. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5786. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5787. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5788. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5789. break;
  5790. }
  5791. }
  5792. } else {
  5793. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5794. $button = 4;
  5795. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5796. }
  5797. }
  5798. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5799. $KOP = true;
  5800. }
  5801. }
  5802. foreach ( $roleArrayCopy as $k => $v ) {
  5803. foreach ( $verifyList as $m => $n ) {
  5804. if ($n [0] == $k) {
  5805. array_splice ( $verifyList, $m, 1, $v );
  5806. }
  5807. }
  5808. }
  5809. $receiptList [$key] ['verifyList'] = $verifyList;
  5810. $receiptList [$key] ['executeList'] = $executeList;
  5811. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5812. 'where' => 'sid=' . $value ['staff'],
  5813. 'asArray' => true
  5814. ) );
  5815. $receiptList [$key] ['button2'] = $button2;
  5816. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5817. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5818. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5819. $receiptList [$key] ['relust'] = $relust;
  5820. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  5821. $receiptList [$key] ['amountABS'] = abs ( $value ['amount'] );
  5822. }
  5823. //执行人是否是最后一位
  5824. $executeCopy = json_decode ( $receiptList [0] ['executeCopy'], true );
  5825. $executeStaff = json_decode ( $receiptList [0] ['executeStaff'], true );
  5826. $executePrimary=count($executeCopy)-1;
  5827. $lastOne=true;
  5828. if($executePrimary!=count($executeStaff)){
  5829. $lastOne=false;
  5830. }
  5831. $data['lastOne']=$lastOne;
  5832. // 是否写入过流水
  5833. $accountType = 0;
  5834. if ($receiptList [0] ['Rtype'] == 0) {
  5835. $accountType = 3;
  5836. } elseif ($receiptList [0] ['Rtype'] == 1) {
  5837. if (!empty($receiptList [0]['accountItem']) )
  5838. $accountType = 2;
  5839. else
  5840. $accountType = 1;
  5841. } elseif ($receiptList [0] ['Rtype'] == 2) {
  5842. $accountType = 4;
  5843. } elseif ($receiptList [0] ['Rtype'] == 3) {
  5844. $accountType = 12;
  5845. }
  5846. Doo::loadModel ( 'wasteBook' );
  5847. $wasteBook = new wasteBook ();
  5848. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $receiptList [0] ['rid'] );
  5849. $data ['wbDetail'] = $wbDetail;
  5850. $wbDetailLoan=array();
  5851. if ($accountType==2){
  5852. $wbDetailLoan = $wasteBook->getWateBookByAD ( 1, $receiptList [0] ['rid'] );
  5853. }
  5854. $data ['wbDetailLoan'] = $wbDetailLoan;
  5855. $data['inputDate']=date ( "Y-m-d H:i:s" );
  5856. //print_r($wbDetail);
  5857. $data ['receiptList'] = $receiptList;
  5858. $data ['memu'] = "receipt";
  5859. $data ['staff'] = $this->staff;
  5860. $data ['receiptMemu'] = 'implement';
  5861. $data ['verifyId'] = $this->verifyId;
  5862. $data ['executeId'] = $this->executeId;
  5863. if ($Rtype=="loan"){
  5864. $this->render ( "/receipt/receiptImplementLoan", $data );
  5865. }elseif($Rtype=="receipt"){
  5866. $this->render ( "/receipt/receiptImplement", $data );
  5867. }elseif($Rtype=="public"){
  5868. $this->render ( "/receipt/receiptImplementPublic", $data );
  5869. }else{
  5870. //$this->render ( "/admin/implement", $data );
  5871. }
  5872. }
  5873. function implementDo() {
  5874. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  5875. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  5876. // $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  5877. // $accountBank = $this->get_args ( 'accountBank' ) ? $this->get_args ( 'accountBank' ) : "";
  5878. // $ab = '';
  5879. // if ($accountBank == 'CGBDeposit')
  5880. // $ab = '纵横广发';
  5881. // elseif ($accountBank == 'ICBCDeposit')
  5882. // $ab = '纵横工行';
  5883. // elseif ($accountBank == 'HUADeposit')
  5884. // $ab = '华润银行';
  5885. // elseif ($accountBank == 'PersonalDeposit')
  5886. // $ab = '个人广发';
  5887. // if (empty ( $ab ))
  5888. // die ( 'illegal request--22' );
  5889. if (! empty ( $rid )) {
  5890. Doo::loadModel ( 'receipt' );
  5891. $receipt = new receipt ();
  5892. Doo::loadClass ( 'XDeode' );
  5893. $XDeode = new XDeode ( 5 );
  5894. $rid=$XDeode->decode($rid);
  5895. if (!is_numeric($rid)){
  5896. die;
  5897. }
  5898. // $rinfo = $receipt->getOne ( array (
  5899. // 'where' => 'rid=' . $rid,
  5900. // 'asArray' => true
  5901. // ) );
  5902. $rinfo = $receipt->getReceiptByRid ( $rid );
  5903. // $accountType = '';
  5904. // if ($rinfo ['Rtype'] == 1) {
  5905. // if ($rinfo ['loanRid'] != 0)//判断有问题
  5906. // $accountType = 2;
  5907. // else
  5908. // $accountType = 1;
  5909. // } elseif ($rinfo ['Rtype'] == 2) {
  5910. // $accountType = 4;
  5911. // } elseif ($rinfo ['Rtype'] == 0)
  5912. // $accountType = 3;
  5913. // if (empty ( $accountType ))
  5914. // die ( 'illegal request' );
  5915. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  5916. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  5917. if (empty ( $executeStaff )) {
  5918. $executeStaff = array (
  5919. $this->staff [0] ['sid'] => array (
  5920. 'date' => date ( 'Y-m-d' ),
  5921. 'opinion' => $implementOpinions,
  5922. 'status' => 1
  5923. )
  5924. );
  5925. } else {
  5926. $executeStaff [$this->staff [0] ['sid']] = array (
  5927. 'date' => date ( 'Y-m-d' ),
  5928. 'opinion' => $implementOpinions,
  5929. 'status' => 1
  5930. );
  5931. }
  5932. if (count ( $executeStaff ) == count ( $executeCopy )) {
  5933. $receipt->executeStaff = json_encode ( $executeStaff );
  5934. $receipt->status = 8;
  5935. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  5936. $receipt->status = 9;
  5937. if ($rinfo ['status'] == 6) {
  5938. $receipt->loanDate = date ( "Y-m-d" );
  5939. }
  5940. $receipt->executeDate = date ( "Y-m-d" );
  5941. } else {
  5942. $receipt->executeStaff = json_encode ( $executeStaff );
  5943. }
  5944. //$receipt->amount = $amount;
  5945. $receipt->update ( array (
  5946. 'where' => 'rid=' . $rid
  5947. ) );
  5948. // 公司流水记录
  5949. // Doo::loadModel ( 'wasteBook' );
  5950. // $wasteBook = new wasteBook ();
  5951. // $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountType, $rid );
  5952. // // 银行
  5953. // if (empty ( $abDetail ) && ! empty ( $amount )) {
  5954. // $item = array (
  5955. // 'dataID' => $rid,
  5956. // 'expensesType' => 2,
  5957. // 'accountType' => $accountType,
  5958. // 'accountPriceShow' => $amount,
  5959. // 'accountPrice' => - $amount,
  5960. // 'accountBank' => $accountBank,
  5961. // 'category' => $rinfo ['category'] [0] ['title'],
  5962. // 'cid' => $rinfo ['category'] [0] ['cid'],
  5963. // 'name' => $rinfo ['staffDetail'] ['username'],
  5964. // 'sid' => $rinfo ['staffDetail'] ['sid'],
  5965. // 'inputDate' => date ( "Y-m-d H:i:s" )
  5966. // );
  5967. // $wasteBook->setAccountBookStatistics ( $item );
  5968. // }
  5969. }
  5970. //$ridKey = $XDeode->encode ( $rid );
  5971. return "/hisImplement";
  5972. // return "/implement/" . $ridKey . ".html";
  5973. }
  5974. function receiptburEdi() {
  5975. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5976. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5977. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5978. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5979. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5980. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5981. if (empty ( $status ))
  5982. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5983. $vidList = array ();
  5984. $button = 0;
  5985. Doo::loadModel ( 'verify' );
  5986. Doo::loadModel ( 'receipt' );
  5987. Doo::loadModel ( 'staff' );
  5988. $staff = new staff ();
  5989. $receipt = new receipt ();
  5990. $verify = new verify ();
  5991. Doo::loadModel ( 'L_category' );
  5992. $Lcategory = new L_category ();
  5993. Doo::loadModel ( 'enclosur' );
  5994. $enclosur = new enclosur ();
  5995. Doo::loadModel ( 'loanReceipt' );
  5996. $loanReceipt = new loanReceipt ();
  5997. // user verify ID
  5998. $verifyDetail = $verify->find ( array (
  5999. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6000. 'asArray' => true
  6001. ) );
  6002. foreach ( $verifyDetail as $key => $value ) {
  6003. array_push ( $vidList, $value ['vid'] );
  6004. }
  6005. $vid = implode ( ",", $vidList );
  6006. if (empty ( $verifyDetail ))
  6007. $vid = 0;
  6008. $categoryList = $Lcategory->find ( array (
  6009. 'asArray' => true
  6010. ) );
  6011. $staffList = $staff->find ( array (
  6012. 'where' => 'cid=' . $cid,
  6013. 'asArray' => true
  6014. ) );
  6015. $ap = "";
  6016. if ($status == 4) {
  6017. $ap = 4;
  6018. $status = 2;
  6019. }
  6020. // get Receipt By verifyID status 2
  6021. $receiptList = $receipt->find ( array (
  6022. 'where' => 'rid =' . $rid . ' and status=2',
  6023. 'desc' => 'rid',
  6024. 'asArray' => true
  6025. ) );
  6026. if (empty ( $receiptList )) {
  6027. die ( 'illegal request' );
  6028. }
  6029. $loanList = $loanReceipt->find ( array (
  6030. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  6031. 'desc' => 'rid',
  6032. 'asArray' => true
  6033. ) );
  6034. $data ['explanation'] = '';
  6035. if (! empty ( $loanList ))
  6036. $data ['explanation'] = $loanList [0] ['explanation'];
  6037. $Locate = 0;
  6038. $roleId = 0;
  6039. $button = 0;
  6040. foreach ( $loanList as $key => $value ) {
  6041. $loanList [$key] ['Locate'] = $Locate;
  6042. $Locate ++;
  6043. $loanList [$key] ['reviseDetail'] = array ();
  6044. if (! empty ( $value ['reviseDetail'] ))
  6045. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6046. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6047. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6048. $categoryDetil = $Lcategory->getOne ( array (
  6049. 'where' => 'cid=' . $value ['cid'],
  6050. 'asArray' => true
  6051. ) );
  6052. $loanList [$key] ['category'] = $categoryDetil ['title'];
  6053. // 检测编辑状态
  6054. $verifyList = $verify->getOne ( array (
  6055. 'where' => 'vid=' . $value ['verify'],
  6056. 'asArray' => true
  6057. ) );
  6058. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6059. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6060. Doo::loadModel ( 'role' );
  6061. $role = new role ();
  6062. $flag = true;
  6063. $roleKey = 0;
  6064. $endStaffArray = array ();
  6065. $roleArrayCopy = array ();
  6066. foreach ( $verifyList as $k => $v ) {
  6067. // init verifyStaff
  6068. if ($v [1] == 'ROLE') {
  6069. if (! empty ( $verifyStaff )) {
  6070. $endStaffArray = end ( $verifyStaff );
  6071. }
  6072. $roleVerify = json_decode ( $v [3], true );
  6073. $roleKey = $k;
  6074. $roleArray = array ();
  6075. $rolename = $role->getOne ( array (
  6076. 'where' => 'rid=' . $v [0],
  6077. 'asArray' => true
  6078. ) );
  6079. foreach ( $roleVerify as $o => $p ) {
  6080. $staffID = explode ( '_', $p );
  6081. $staffInfo = $staff->getOne ( array (
  6082. 'where' => 'sid=' . $staffID [0],
  6083. 'asArray' => true
  6084. ) );
  6085. // print_r($staffID);
  6086. $exp = array (
  6087. 0 => $staffInfo ['sid'],
  6088. 1 => $staffID [1],
  6089. 2 => $staffInfo ['avatar'],
  6090. 'date' => '',
  6091. 'date' => '',
  6092. 'opinion' => '',
  6093. 'status' => '',
  6094. 'rolename' => $rolename ['name']
  6095. );
  6096. array_push ( $roleArray, $exp );
  6097. }
  6098. $roleArrayCopy [$v [0]] = $roleArray;
  6099. // $verifyList[$k]['roleArray']=$roleArray;
  6100. }
  6101. $verifyList [$k] ['date'] = "";
  6102. $verifyList [$k] ['opinion'] = "";
  6103. $verifyList [$k] ['status'] = "";
  6104. if (empty ( $verifyStaff )) {
  6105. $verifyList [$k] ['date'] = "";
  6106. $verifyList [$k] ['opinion'] = "";
  6107. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6108. $verifyList [$k] ['status'] = 4;
  6109. $flag = false;
  6110. }
  6111. } else {
  6112. foreach ( $verifyStaff as $m => $u ) {
  6113. if ($v [0] == $m) {
  6114. $verifyList [$k] ['date'] = $u ['date'];
  6115. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6116. $verifyList [$k] ['status'] = $u ['status'];
  6117. $flag = false;
  6118. break;
  6119. }
  6120. }
  6121. $endStaffArray = end ( $verifyStaff );
  6122. if (isset ( $endStaffArray ['ROLE'] )) {
  6123. } else {
  6124. }
  6125. }
  6126. }
  6127. $rolename ['name'] = '';
  6128. if (! empty ( $roleId )) {
  6129. Doo::loadModel ( 'role' );
  6130. $role = new role ();
  6131. $rolename = $role->getOne ( array (
  6132. 'where' => 'rid=' . $roleId,
  6133. 'asArray' => true
  6134. ) );
  6135. }
  6136. if (! empty ( $verifyStaff ))
  6137. $endStaffArray = end ( $verifyStaff );
  6138. $KOP = false;
  6139. foreach ( $roleArrayCopy as $P => $A ) {
  6140. foreach ( $A as $MKI => $AVL ) {
  6141. if (! empty ( $verifyStaff )) {
  6142. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6143. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6144. $button = 4;
  6145. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6146. }
  6147. foreach ( $verifyStaff as $m => $u ) {
  6148. $AVLFK = $AVL [0] . '_R';
  6149. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6150. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6151. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6152. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6153. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6154. break;
  6155. }
  6156. }
  6157. } else {
  6158. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6159. $button = 4;
  6160. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6161. }
  6162. }
  6163. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6164. $KOP = true;
  6165. }
  6166. }
  6167. foreach ( $roleArrayCopy as $k => $v ) {
  6168. foreach ( $verifyList as $m => $n ) {
  6169. if ($n [0] == $k) {
  6170. array_splice ( $verifyList, $m, 1, $v );
  6171. }
  6172. }
  6173. }
  6174. $loanList [$key] ['verifyList'] = $verifyList;
  6175. }
  6176. $htmlLoan = '';
  6177. $data ['loanReceiptDate'] = '';
  6178. if (isset ( $loanList [0] )) {
  6179. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  6180. if ($value ['status'] == 1)
  6181. $htmlLoan .= '<li class="done" >';
  6182. elseif ($value ['status'] == 3)
  6183. $htmlLoan .= '<li class="undone" >';
  6184. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  6185. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  6186. if (isset ( $value ['rolename'] ))
  6187. $htmlLoan .= $value ['rolename'];
  6188. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  6189. }
  6190. $data ['loanDate'] = $loanList [0] ['date'];
  6191. } else {
  6192. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  6193. }
  6194. $data ['htmlLoan'] = $htmlLoan;
  6195. // $data ['LoanReceipt']=$loanList[0];
  6196. // print_r($loanList);
  6197. $Locate = 0;
  6198. $roleId = 0;
  6199. $button = 0;
  6200. if ($ap == 4)
  6201. $status = 4;
  6202. Doo::loadClass ( 'XDeode' );
  6203. $XDeode = new XDeode ( 5 );
  6204. foreach ( $receiptList as $key => $value ) {
  6205. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  6206. $receiptList [$key] ['Locate'] = $Locate;
  6207. $Locate ++;
  6208. $receiptList [$key] ['reviseDetail'] = array ();
  6209. // 调整金额 代码调整
  6210. if (! empty ( $value ['reviseDetail'] )) {
  6211. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  6212. foreach ( $reviseDetail as $ry => $re ) {
  6213. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  6214. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  6215. }
  6216. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  6217. // print_r($reviseDetail);
  6218. }
  6219. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6220. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6221. $categoryDetil = $Lcategory->getOne ( array (
  6222. 'where' => 'cid=' . $value ['cid'],
  6223. 'asArray' => true
  6224. ) );
  6225. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6226. // 检测编辑状态
  6227. $verifyList = $verify->getOne ( array (
  6228. 'where' => 'vid=' . $value ['verify'],
  6229. 'asArray' => true
  6230. ) );
  6231. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6232. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6233. Doo::loadModel ( 'role' );
  6234. $role = new role ();
  6235. // print_r($verifyList);
  6236. $flag = true;
  6237. $roleKey = 0;
  6238. $endStaffArray = array ();
  6239. $roleArrayCopy = array ();
  6240. foreach ( $verifyList as $k => $v ) {
  6241. // init verifyStaff
  6242. if ($v [1] == 'ROLE') {
  6243. if (! empty ( $verifyStaff )) {
  6244. $endStaffArray = end ( $verifyStaff );
  6245. if ($v [0] == $endStaffArray ['nextStaff']) {
  6246. $roleId = $v [0];
  6247. }
  6248. }
  6249. $roleVerify = json_decode ( $v [3], true );
  6250. $roleKey = $k;
  6251. $roleArray = array ();
  6252. $rolename = $role->getOne ( array (
  6253. 'where' => 'rid=' . $v [0],
  6254. 'asArray' => true
  6255. ) );
  6256. foreach ( $roleVerify as $o => $p ) {
  6257. $staffID = explode ( '_', $p );
  6258. $staffInfo = $staff->getOne ( array (
  6259. 'where' => 'sid=' . $staffID [0],
  6260. 'asArray' => true
  6261. ) );
  6262. // print_r($staffID);
  6263. $exp = array (
  6264. 0 => $staffInfo ['sid'],
  6265. 1 => $staffID [1],
  6266. 2 => $staffInfo ['avatar'],
  6267. 'date' => '',
  6268. 'date' => '',
  6269. 'opinion' => '',
  6270. 'status' => '',
  6271. 'rolename' => $rolename ['name']
  6272. );
  6273. array_push ( $roleArray, $exp );
  6274. }
  6275. $roleArrayCopy [$v [0]] = $roleArray;
  6276. // $verifyList[$k]['roleArray']=$roleArray;
  6277. }
  6278. // print_r($roleArray);
  6279. $verifyList [$k] ['date'] = "";
  6280. $verifyList [$k] ['opinion'] = "";
  6281. $verifyList [$k] ['status'] = "";
  6282. if (empty ( $verifyStaff )) {
  6283. $verifyList [$k] ['date'] = "";
  6284. $verifyList [$k] ['opinion'] = "";
  6285. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6286. $verifyList [$k] ['status'] = 4;
  6287. $button = 4;
  6288. $flag = false;
  6289. }
  6290. } else {
  6291. foreach ( $verifyStaff as $m => $u ) {
  6292. if ($v [0] == $m) {
  6293. $verifyList [$k] ['date'] = $u ['date'];
  6294. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6295. $verifyList [$k] ['status'] = $u ['status'];
  6296. $flag = false;
  6297. break;
  6298. }
  6299. }
  6300. $endStaffArray = end ( $verifyStaff );
  6301. if (isset ( $endStaffArray ['ROLE'] )) {
  6302. } else {
  6303. $endKey = key ( $verifyStaff );
  6304. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6305. $button = 4;
  6306. $verifyList [$k] ['status'] = 4;
  6307. }
  6308. }
  6309. }
  6310. }
  6311. $rolename ['name'] = '';
  6312. if (! empty ( $roleId )) {
  6313. Doo::loadModel ( 'role' );
  6314. $role = new role ();
  6315. $rolename = $role->getOne ( array (
  6316. 'where' => 'rid=' . $roleId,
  6317. 'asArray' => true
  6318. ) );
  6319. }
  6320. if (! empty ( $verifyStaff ))
  6321. $endStaffArray = end ( $verifyStaff );
  6322. $KOP = false;
  6323. foreach ( $roleArrayCopy as $P => $A ) {
  6324. foreach ( $A as $MKI => $AVL ) {
  6325. if (! empty ( $verifyStaff )) {
  6326. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6327. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6328. $button = 4;
  6329. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6330. }
  6331. foreach ( $verifyStaff as $m => $u ) {
  6332. $AVLFK = $AVL [0] . '_R';
  6333. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6334. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6335. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6336. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6337. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6338. break;
  6339. }
  6340. }
  6341. } else {
  6342. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6343. $button = 4;
  6344. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6345. }
  6346. }
  6347. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6348. $KOP = true;
  6349. }
  6350. }
  6351. foreach ( $roleArrayCopy as $k => $v ) {
  6352. foreach ( $verifyList as $m => $n ) {
  6353. if ($n [0] == $k) {
  6354. array_splice ( $verifyList, $m, 1, $v );
  6355. }
  6356. }
  6357. }
  6358. // print_r($verifyList);
  6359. $receiptList [$key] ['verifyList'] = $verifyList;
  6360. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6361. 'where' => 'sid=' . $value ['staff'],
  6362. 'asArray' => true
  6363. ) );
  6364. $receiptList [$key] ['button'] = $button;
  6365. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  6366. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  6367. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  6368. $receiptList [$key] ['relust'] = $relust;
  6369. $receiptList [$key] ['relustABS'] = abs ( $relust );
  6370. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  6371. }
  6372. //print_r($receiptList);die;
  6373. // $data['verifyDetail']=$verifyDetail;
  6374. $mothHtml = "";
  6375. for($i = 1; $i <= 12; $i ++) {
  6376. if ($month == $i)
  6377. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6378. else
  6379. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6380. }
  6381. // 获取审批日志
  6382. Doo::loadModel ( 'receiptLog' );
  6383. $receiptLog = new receiptLog ();
  6384. $rlList = array ();
  6385. $rlInfo = $receiptLog->getOne ( array (
  6386. 'where' => 'rid=' . $rid . ' and status=4',
  6387. 'asArray' => true
  6388. ) );
  6389. $tijdate = $receiptLog->getOne ( array (
  6390. 'where' => 'rid=' . $rid . ' and status=2',
  6391. 'asc' => 'rlid',
  6392. 'asArray' => true
  6393. ) );
  6394. if (! empty ( $rlInfo )) {
  6395. $rlList = $receiptLog->find ( array (
  6396. 'where' => 'rid=' . $rid,
  6397. 'asc' => 'rlid',
  6398. 'asArray' => true
  6399. ) );
  6400. }
  6401. // echo $rid;
  6402. // print_r($receiptList);
  6403. $receiptList [0] ['rlList'] = $rlList;
  6404. // print_r($receiptList);
  6405. $enclosurList = $enclosur->find ( array (
  6406. 'where' => 'rid=' . $rid,
  6407. 'asArray' => true
  6408. ) );
  6409. $enclosurHtml = '';
  6410. foreach ( $enclosurList as $value ) {
  6411. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6412. }
  6413. $data ['enclosurHtml'] = $enclosurHtml;
  6414. $data ['rolename'] = $rolename ['name'];
  6415. $data ['mothHtml'] = $mothHtml;
  6416. // print_r($receiptList);
  6417. $data ['rid'] = $rid;
  6418. $data ['tijdate'] = $tijdate ['date'];
  6419. $data ['receiptList'] = $receiptList;
  6420. $data ['receiptApprovalCount'] = count ( $receiptList );
  6421. $data ['status'] = $status;
  6422. $data ['year'] = $year;
  6423. $data ['categoryList'] = $categoryList;
  6424. $data ['staffList'] = $staffList;
  6425. $data ['cid'] = $cid;
  6426. $data ['sid'] = $sid;
  6427. $data ['ap'] = $ap;
  6428. $data ['memu'] = "receipt";
  6429. $data ['staff'] = $this->staff;
  6430. $data ['receiptMemu'] = 'approvalExpenses';
  6431. $data ['verifyId'] = $this->verifyId;
  6432. $data ['executeId'] = $this->executeId;
  6433. $this->render ( "/admin/receiptburEdi", $data );
  6434. }
  6435. function hisImplement() {
  6436. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  6437. if (empty ( $item ))
  6438. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  6439. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  6440. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6441. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  6442. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6443. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  6444. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  6445. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  6446. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  6447. Doo::loadClass ( 'XDeode' );
  6448. $XDeode = new XDeode ( 5 );
  6449. Doo::loadModel ( 'receipt' );
  6450. $receipt = new receipt ();
  6451. Doo::loadModel ( 'L_category' );
  6452. $Lcategory = new L_category ();
  6453. Doo::loadModel ( 'verify' );
  6454. Doo::loadModel ( 'statistics' );
  6455. $statistics = new statistics ();
  6456. $verify = new verify ();
  6457. Doo::loadModel ( 'staff' );
  6458. $staff = new staff ();
  6459. Doo::loadClass ( 'XDeode' );
  6460. $XDeode = new XDeode ( 5 );
  6461. $XDeode7 = new XDeode ( 7 );
  6462. $cid = $XDeode->decode ( $cidKey );
  6463. $condition = "";
  6464. if ($item == "expenses")
  6465. $condition = " and Rtype=1 ";
  6466. elseif ($item == "receipts")
  6467. $condition = " and Rtype=0 ";
  6468. elseif ($item == "remits")
  6469. $condition = " and Rtype=2 ";
  6470. elseif($item == "train")
  6471. $condition = " and Rtype=3 ";
  6472. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  6473. $sopString = $cidString = "";
  6474. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  6475. if (empty ( $rdate ))
  6476. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  6477. else
  6478. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  6479. if ($status == 'pendImplement') {
  6480. $condition .= ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  6481. } elseif ($status == 'alerpts') {
  6482. $statusCon = '(status=8 or status=9 )';
  6483. if (empty ( $rdate ))
  6484. $dateCondition .= " and Year(date) =" . $year;
  6485. else
  6486. $dateCondition .= " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  6487. }
  6488. if ($sop != 'SOP')
  6489. $sopString = " and staff=" . $sop;
  6490. if ($cidKey != 'ALL')
  6491. $cidString = " and cid=" . $cid;
  6492. //汇款信息需要提取出来
  6493. if(!empty($receiptOrder)){
  6494. $receiptList = $receipt->find ( array (
  6495. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  6496. 'desc' => 'rid',
  6497. 'asArray' => true
  6498. ) );
  6499. // 员工筛选
  6500. $receiptList2 = $receipt->find ( array (
  6501. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  6502. 'desc' => 'rid',
  6503. 'asArray' => true
  6504. ) );
  6505. }else{
  6506. $receiptList = $receipt->find ( array (
  6507. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  6508. 'desc' => 'rid',
  6509. 'asArray' => true
  6510. ) );
  6511. // 员工筛选
  6512. $receiptList2 = $receipt->find ( array (
  6513. 'where' => $statusCon . $condition . $dateCondition,
  6514. 'desc' => 'rid',
  6515. 'asArray' => true
  6516. ) );
  6517. }
  6518. $sopStaff = array ();
  6519. foreach ( $receiptList2 as $key => $value ) {
  6520. $staffDetail = $staff->getOne ( array (
  6521. 'select' => 'username',
  6522. 'where' => 'sid=' . $value ['staff'],
  6523. 'asArray' => true
  6524. ) );
  6525. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  6526. }
  6527. // 办事处筛选
  6528. $categoryScreen = array ();
  6529. $categorList = $Lcategory->getCategory ();
  6530. foreach ( $receiptList2 as $key => $value ) {
  6531. foreach ( $categorList as $k => $v ) {
  6532. if ($value ['cid'] == $v ['cid']) {
  6533. $categoryScreen [$v ['cidKey']] = $v ['title'];
  6534. break;
  6535. }
  6536. }
  6537. }
  6538. $categoryScreenHtml = "";
  6539. foreach ( $categoryScreen as $key => $value ) {
  6540. if ($cidKey == $key)
  6541. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  6542. else
  6543. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  6544. }
  6545. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  6546. $data ['cidKey'] = $cidKey;
  6547. $Locate = 0;
  6548. $roleId = 0;
  6549. $button = 0;
  6550. $staffBatchNumber = 100001;
  6551. $remittanceList = array ();
  6552. foreach ( $receiptList as $key => $value ) {
  6553. $receiptList [$key] ['ridKey7'] = $XDeode7->encode ( $value ['rid'] );
  6554. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  6555. $receiptList [$key] ['Texe'] = 'false';
  6556. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  6557. $receiptList [$key] ['Texe'] = 'true';
  6558. }
  6559. $receiptList [$key] ['TRexe'] = 'true';
  6560. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  6561. $receiptList [$key] ['TRexe'] = 'false';
  6562. }
  6563. $receiptList [$key] ['Locate'] = $Locate;
  6564. $Locate ++;
  6565. $receiptList [$key] ['reviseDetail'] = array ();
  6566. if (! empty ( $value ['reviseDetail'] ))
  6567. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6568. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6569. $categoryDetil = $Lcategory->getOne ( array (
  6570. 'where' => 'cid=' . $value ['cid'],
  6571. 'asArray' => true
  6572. ) );
  6573. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6574. // 检测编辑状态
  6575. $verifyList = $verify->getOne ( array (
  6576. 'where' => 'vid=' . $value ['verify'],
  6577. 'asArray' => true
  6578. ) );
  6579. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6580. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6581. Doo::loadModel ( 'role' );
  6582. $role = new role ();
  6583. $flag = true;
  6584. $roleKey = 0;
  6585. $endStaffArray = array ();
  6586. $roleArrayCopy = array ();
  6587. foreach ( $verifyList as $k => $v ) {
  6588. // init verifyStaff
  6589. if ($v [1] == 'ROLE') {
  6590. if (! empty ( $verifyStaff )) {
  6591. $endStaffArray = end ( $verifyStaff );
  6592. }
  6593. $roleVerify = json_decode ( $v [3], true );
  6594. $roleKey = $k;
  6595. $roleArray = array ();
  6596. $rolename = $role->getOne ( array (
  6597. 'where' => 'rid=' . $v [0],
  6598. 'asArray' => true
  6599. ) );
  6600. foreach ( $roleVerify as $o => $p ) {
  6601. $staffID = explode ( '_', $p );
  6602. $staffInfo = $staff->getOne ( array (
  6603. 'where' => 'sid=' . $staffID [0],
  6604. 'asArray' => true
  6605. ) );
  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. }
  6620. $verifyList [$k] ['date'] = "";
  6621. $verifyList [$k] ['opinion'] = "";
  6622. $verifyList [$k] ['status'] = "";
  6623. if (empty ( $verifyStaff )) {
  6624. $verifyList [$k] ['date'] = "";
  6625. $verifyList [$k] ['opinion'] = "";
  6626. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6627. $verifyList [$k] ['status'] = 4;
  6628. $flag = false;
  6629. }
  6630. } else {
  6631. foreach ( $verifyStaff as $m => $u ) {
  6632. if ($v [0] == $m) {
  6633. $verifyList [$k] ['date'] = $u ['date'];
  6634. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6635. $verifyList [$k] ['status'] = $u ['status'];
  6636. $flag = false;
  6637. break;
  6638. }
  6639. }
  6640. $endStaffArray = end ( $verifyStaff );
  6641. }
  6642. }
  6643. $rolename ['name'] = '';
  6644. if (! empty ( $roleId )) {
  6645. Doo::loadModel ( 'role' );
  6646. $role = new role ();
  6647. $rolename = $role->getOne ( array (
  6648. 'where' => 'rid=' . $roleId,
  6649. 'asArray' => true
  6650. ) );
  6651. }
  6652. if (! empty ( $verifyStaff ))
  6653. $endStaffArray = end ( $verifyStaff );
  6654. $KOP = false;
  6655. foreach ( $roleArrayCopy as $P => $A ) {
  6656. foreach ( $A as $MKI => $AVL ) {
  6657. if (! empty ( $verifyStaff )) {
  6658. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6659. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6660. $button = 4;
  6661. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6662. }
  6663. foreach ( $verifyStaff as $m => $u ) {
  6664. $AVLFK = $AVL [0] . '_R';
  6665. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6666. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6667. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6668. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6669. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6670. break;
  6671. }
  6672. }
  6673. } else {
  6674. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6675. $button = 4;
  6676. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6677. }
  6678. }
  6679. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6680. $KOP = true;
  6681. }
  6682. }
  6683. foreach ( $roleArrayCopy as $k => $v ) {
  6684. foreach ( $verifyList as $m => $n ) {
  6685. if ($n [0] == $k) {
  6686. array_splice ( $verifyList, $m, 1, $v );
  6687. }
  6688. }
  6689. }
  6690. $receiptList [$key] ['verifyList'] = $verifyList;
  6691. $staffDetail = $staff->getOne ( array (
  6692. 'where' => 'sid=' . $value ['staff'],
  6693. 'asArray' => true
  6694. ) );
  6695. $receiptList [$key] ['staffDetail'] = $staffDetail;
  6696. $receiptList [$key] ['button'] = $button;
  6697. if ($value['Rtype']==1){
  6698. $receiptList [$key] ['relust'] = $value['sum']-$value['loanSum'];
  6699. $receiptList [$key] ['relustABS'] = abs($receiptList [$key] ['relust']);
  6700. }elseif($value['Rtype']==3){
  6701. // 收入合计
  6702. Doo::loadModel ( 'invoiceTraining' );
  6703. $invoiceTraining = new invoiceTraining ();
  6704. $invoiceTrainingDetail = array (
  6705. 'invoiceArriveAmount' => '0.00',
  6706. 'RIAmount' => '0.00',
  6707. 'invoiceTotalAmount' => '0.00',
  6708. 'invoiceCompanyAmount' => '0.00',
  6709. 'invoiceArriveAmountM'=>'0.00',
  6710. 'invoiceCompanyAmountM'=>'0.00'
  6711. );
  6712. if ($value ['invoiceTrainId'] != 0) {
  6713. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $value['invoiceTrainId'] );
  6714. }
  6715. $invoiceArriveAmount = $RIAmount = 0;
  6716. if (! empty ( $invoiceTrainingDetail )) {
  6717. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  6718. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  6719. }
  6720. // 备用金
  6721. $sum = 0;
  6722. if (! empty ( $value ['trainLoanRid'] )) {
  6723. $receiptLoanList = $receipt->getReceiptInRid ( $value ['trainLoanRid'] );
  6724. foreach ($receiptLoanList as $kll=>$vll){
  6725. $sum+=$vll['sum'];
  6726. }
  6727. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $value ['trainLoanRid'] );
  6728. // $sum = $receiptLoanDetailBak ['sum'];
  6729. }
  6730. // 支出项金额详情
  6731. // 项目金额合计
  6732. Doo::loadModel ( 'RItem' );
  6733. $RItem = new RItem ();
  6734. Doo::loadModel ( 'accountItem' );
  6735. $accountItem = new accountItem ();
  6736. // 讲师获得
  6737. Doo::loadModel ( 'RILecturer' );
  6738. $RILecturer = new RILecturer ();
  6739. $RItemList = $RItem->getRItemByRid ( $value['rid'] );
  6740. $RILecturerList = $RILecturer->getRILecturerByRid ( $value['rid'] );
  6741. // 支出项金额详情
  6742. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  6743. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  6744. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  6745. $receiptList [$key] ['payment'] =$payment;
  6746. $receiptList [$key] ['paymentABS'] =sprintf("%.2f",abs($payment));
  6747. }
  6748. // 设置导出汇款execl
  6749. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  6750. $remittanceDetail = array (
  6751. $staffBatchNumber,
  6752. $value ['remittanceName'],
  6753. $value ['bankNumber'],
  6754. $value ['bankName'],
  6755. $value ['remittanceBankType'],
  6756. $value ['coupletNumber'],
  6757. $value ['sum']
  6758. );
  6759. array_push ( $remittanceList, $remittanceDetail );
  6760. $staffBatchNumber ++;
  6761. }
  6762. }
  6763. $data ['remittanceList'] = json_encode ( $remittanceList );
  6764. // print_r($receiptList);
  6765. $mothHtml = "";
  6766. for($i = 1; $i <= 12; $i ++) {
  6767. if ($moth == $i)
  6768. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6769. else
  6770. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6771. }
  6772. $dayHtml = "";
  6773. if ($day != "DAY" || $moth != "MONTH") {
  6774. for($i = 1; $i <= 31; $i ++) {
  6775. if ($day == $i)
  6776. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6777. else
  6778. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6779. }
  6780. }
  6781. $sopHtml = "";
  6782. foreach ( $sopStaff as $key => $value ) {
  6783. if ($sop == $key)
  6784. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  6785. else
  6786. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  6787. }
  6788. $data ['status'] = $status;
  6789. $data ['rdate'] = $rdate;
  6790. $data ['sopHtml'] = $sopHtml;
  6791. $data ['dayHtml'] = $dayHtml;
  6792. $data ['mothHtml'] = $mothHtml;
  6793. $data ['receiptList'] = $receiptList;
  6794. $data ['memu'] = "receipt";
  6795. $data ['staff'] = $this->staff;
  6796. $data ['receiptMemu'] = 'implement';
  6797. $data ['verifyId'] = $this->verifyId;
  6798. $data ['executeId'] = $this->executeId;
  6799. $data ['item'] = $item;
  6800. $data ['year'] = $year;
  6801. $data ['moth'] = $moth;
  6802. $data['receiptOrder']=$receiptOrder;
  6803. $data ['day'] = $day;
  6804. $data ['sop'] = $sop;
  6805. $this->render ( "/admin/hisImplement", $data );
  6806. }
  6807. /**
  6808. * 导出汇款信息的exelc
  6809. */
  6810. function exportRemittance() {
  6811. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  6812. if (empty ( $remittanceInfo ))
  6813. die ( 'illegal request' );
  6814. $title = array (
  6815. '员工编号',
  6816. '姓名',
  6817. '员工账号',
  6818. '员工账户开户行',
  6819. '转账类型',
  6820. '联行号',
  6821. '金额'
  6822. );
  6823. $data = json_decode ( $remittanceInfo, true );
  6824. if (empty ( $data ))
  6825. die ( 'illegal request' );
  6826. Doo::loadClass ( 'receipt.func' );
  6827. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  6828. header ( 'Content-Type:text/html;charset=utf-8' );
  6829. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  6830. }
  6831. function ajaxExamine() {
  6832. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6833. Doo::loadModel ( 'receipt' );
  6834. $receipt = new receipt ();
  6835. if (! empty ( $rid )) {
  6836. $rLRes = $receipt->find ( array (
  6837. '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,
  6838. 'asArray' => true
  6839. ) );
  6840. if(!empty($rLRes)){
  6841. Doo::loadClass ( 'XDeode' );
  6842. $XDeode = new XDeode ( 7 );
  6843. $rLRes [0]['ridKey'] = $XDeode->encode( $rLRes [0]['rid'] );
  6844. echo json_encode ( array (
  6845. 'status' => 1,
  6846. 'receipt' => $rLRes [0]
  6847. ) );
  6848. die ();
  6849. }else{
  6850. echo json_encode ( array (
  6851. 'status' => 1,
  6852. 'receipt' => array ()
  6853. ) );
  6854. die ();
  6855. }
  6856. }
  6857. echo json_encode ( array (
  6858. 'status' => 0,
  6859. 'receipt' => array ()
  6860. ) );
  6861. die ();
  6862. }
  6863. /*
  6864. * 废弃
  6865. */
  6866. function myReceipt() {
  6867. // all approval past withdraw
  6868. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  6869. if (empty ( $item ))
  6870. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  6871. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6872. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  6873. Doo::loadModel ( 'receipt' );
  6874. $receipt = new receipt ();
  6875. // pre-loaded
  6876. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  6877. // have cache
  6878. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  6879. if (! empty ( $moth )) // yearPage
  6880. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  6881. $this->showCache ( $path );
  6882. }
  6883. Doo::loadModel ( 'L_category' );
  6884. $Lcategory = new L_category ();
  6885. Doo::loadModel ( 'verify' );
  6886. Doo::loadModel ( 'statistics' );
  6887. $statistics = new statistics ();
  6888. $verify = new verify ();
  6889. Doo::loadModel ( 'staff' );
  6890. $staff = new staff ();
  6891. $condition = " and status!=0 ";
  6892. if ($item == "approval")
  6893. $condition = " and status=2 ";
  6894. elseif ($item == "withdraw")
  6895. $condition = " and status=3 ";
  6896. elseif ($item == "past")
  6897. $condition = " and status=1 ";
  6898. elseif ($item == "whdw")
  6899. $condition = " and status=4 ";
  6900. $dateCondition = " and Year(date) =" . $year;
  6901. if (! empty ( $moth )) {
  6902. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  6903. $stList = $statistics->getOne ( array (
  6904. 'select' => 'rePrice ,agPrice',
  6905. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  6906. 'asArray' => true
  6907. ) );
  6908. } else
  6909. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  6910. if (empty ( $stList ))
  6911. $stList = array (
  6912. 'rePrice' => 0,
  6913. 'agPrice' => 0
  6914. );
  6915. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  6916. $data ['stList'] = array (
  6917. 'rePrice' => $stList ['rePrice'],
  6918. 'agPrice' => $stList ['agPrice'],
  6919. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  6920. );
  6921. $receiptList = $receipt->find ( array (
  6922. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  6923. 'desc' => 'rid',
  6924. 'asArray' => true
  6925. ) );
  6926. $Locate = 0;
  6927. $roleId = 0;
  6928. $button = 0;
  6929. foreach ( $receiptList as $key => $value ) {
  6930. $receiptList [$key] ['Locate'] = $Locate;
  6931. $Locate ++;
  6932. $receiptList [$key] ['reviseDetail'] = array ();
  6933. if (! empty ( $value ['reviseDetail'] ))
  6934. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6935. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6936. $categoryDetil = $Lcategory->getOne ( array (
  6937. 'where' => 'cid=' . $value ['cid'],
  6938. 'asArray' => true
  6939. ) );
  6940. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6941. // 检测编辑状态
  6942. $verifyList = $verify->getOne ( array (
  6943. 'where' => 'vid=' . $value ['verify'],
  6944. 'asArray' => true
  6945. ) );
  6946. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6947. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6948. Doo::loadModel ( 'role' );
  6949. $role = new role ();
  6950. $flag = true;
  6951. $roleKey = 0;
  6952. $endStaffArray = array ();
  6953. $roleArrayCopy = array ();
  6954. foreach ( $verifyList as $k => $v ) {
  6955. // init verifyStaff
  6956. if ($v [1] == 'ROLE') {
  6957. if (! empty ( $verifyStaff )) {
  6958. $endStaffArray = end ( $verifyStaff );
  6959. // if ($v[0]==$endStaffArray['nextStaff']){
  6960. // $roleId=$v[0];
  6961. // }
  6962. }
  6963. $roleVerify = json_decode ( $v [3], true );
  6964. $roleKey = $k;
  6965. $roleArray = array ();
  6966. $rolename = $role->getOne ( array (
  6967. 'where' => 'rid=' . $v [0],
  6968. 'asArray' => true
  6969. ) );
  6970. foreach ( $roleVerify as $o => $p ) {
  6971. $staffID = explode ( '_', $p );
  6972. $staffInfo = $staff->getOne ( array (
  6973. 'where' => 'sid=' . $staffID [0],
  6974. 'asArray' => true
  6975. ) );
  6976. // print_r($staffID);
  6977. $exp = array (
  6978. 0 => $staffInfo ['sid'],
  6979. 1 => $staffID [1],
  6980. 2 => $staffInfo ['avatar'],
  6981. 'date' => '',
  6982. 'date' => '',
  6983. 'opinion' => '',
  6984. 'status' => '',
  6985. 'rolename' => $rolename ['name']
  6986. );
  6987. array_push ( $roleArray, $exp );
  6988. }
  6989. $roleArrayCopy [$v [0]] = $roleArray;
  6990. // $verifyList[$k]['roleArray']=$roleArray;
  6991. }
  6992. $verifyList [$k] ['date'] = "";
  6993. $verifyList [$k] ['opinion'] = "";
  6994. $verifyList [$k] ['status'] = "";
  6995. if (empty ( $verifyStaff )) {
  6996. $verifyList [$k] ['date'] = "";
  6997. $verifyList [$k] ['opinion'] = "";
  6998. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6999. $verifyList [$k] ['status'] = 4;
  7000. $flag = false;
  7001. }
  7002. } else {
  7003. foreach ( $verifyStaff as $m => $u ) {
  7004. if ($v [0] == $m) {
  7005. $verifyList [$k] ['date'] = $u ['date'];
  7006. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7007. $verifyList [$k] ['status'] = $u ['status'];
  7008. $flag = false;
  7009. break;
  7010. }
  7011. }
  7012. $endStaffArray = end ( $verifyStaff );
  7013. if (isset ( $endStaffArray ['ROLE'] )) {
  7014. } else {
  7015. // $endKey=key($verifyStaff);
  7016. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  7017. // $button=4;
  7018. // $verifyList[$k]['status']=4;
  7019. // }
  7020. }
  7021. }
  7022. }
  7023. $rolename ['name'] = '';
  7024. if (! empty ( $roleId )) {
  7025. Doo::loadModel ( 'role' );
  7026. $role = new role ();
  7027. $rolename = $role->getOne ( array (
  7028. 'where' => 'rid=' . $roleId,
  7029. 'asArray' => true
  7030. ) );
  7031. }
  7032. if (! empty ( $verifyStaff ))
  7033. $endStaffArray = end ( $verifyStaff );
  7034. $KOP = false;
  7035. foreach ( $roleArrayCopy as $P => $A ) {
  7036. foreach ( $A as $MKI => $AVL ) {
  7037. if (! empty ( $verifyStaff )) {
  7038. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7039. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7040. $button = 4;
  7041. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7042. }
  7043. foreach ( $verifyStaff as $m => $u ) {
  7044. $AVLFK = $AVL [0] . '_R';
  7045. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7046. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7047. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7048. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7049. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7050. break;
  7051. }
  7052. }
  7053. } else {
  7054. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7055. $button = 4;
  7056. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7057. }
  7058. }
  7059. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7060. $KOP = true;
  7061. }
  7062. }
  7063. foreach ( $roleArrayCopy as $k => $v ) {
  7064. foreach ( $verifyList as $m => $n ) {
  7065. if ($n [0] == $k) {
  7066. array_splice ( $verifyList, $m, 1, $v );
  7067. }
  7068. }
  7069. }
  7070. $receiptList [$key] ['verifyList'] = $verifyList;
  7071. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7072. 'where' => 'sid=' . $value ['staff'],
  7073. 'asArray' => true
  7074. ) );
  7075. $receiptList [$key] ['button'] = $button;
  7076. }
  7077. // print_r($receiptList);die;
  7078. $mothHtml = "";
  7079. for($i = 1; $i <= 12; $i ++) {
  7080. if ($moth == $i)
  7081. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7082. else
  7083. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7084. }
  7085. $data ['mothHtml'] = $mothHtml;
  7086. $data ['receiptList'] = $receiptList;
  7087. $data ['memu'] = "receipt";
  7088. $data ['staff'] = $this->staff;
  7089. $data ['receiptMemu'] = 'receipt';
  7090. $data ['verifyId'] = $this->verifyId;
  7091. $data ['executeId'] = $this->executeId;
  7092. $data ['item'] = $item;
  7093. $data ['year'] = $year;
  7094. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  7095. // sufficient condition to generate cache
  7096. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  7097. $receiptList = $receipt->find ( array (
  7098. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7099. 'asArray' => true
  7100. ) );
  7101. if (empty ( $receiptList )) { // generated files
  7102. ob_start ();
  7103. $this->render ( "/admin/saea_myList", $data );
  7104. $this->cacheFile ( $path );
  7105. die ();
  7106. // $content = ob_get_contents();
  7107. // $fp = fopen($path, "w");
  7108. // fwrite($fp, $content);
  7109. // fclose($fp);
  7110. }
  7111. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  7112. $receiptList = $receipt->find ( array (
  7113. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  7114. 'asArray' => true
  7115. ) );
  7116. if (empty ( $receiptList )) { // generated files
  7117. ob_start ();
  7118. $this->render ( "/admin/saea_myList", $data );
  7119. $this->cacheFile ( $path );
  7120. die ();
  7121. }
  7122. }
  7123. }
  7124. $this->render ( "/admin/saea_myList", $data );
  7125. }
  7126. function approvedReceipt() {
  7127. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7128. Doo::loadModel ( 'receipt' );
  7129. Doo::loadModel ( 'receiptDetail' );
  7130. $receipt = new receipt ();
  7131. $receiptDetail = new receiptDetail ();
  7132. Doo::loadModel ( 'statistics' );
  7133. Doo::loadModel ( 'itemStatistics' );
  7134. $statistics = new statistics ();
  7135. $itemStatistics = new itemStatistics ();
  7136. Doo::loadModel ( "verify" );
  7137. $verify = new verify ();
  7138. // 审批状态的判定
  7139. $receiptDetailList = $receipt->getOne ( array (
  7140. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  7141. 'asArray' => true
  7142. ) );
  7143. if (empty ( $receiptDetailList ))
  7144. return "/saeaBorad";
  7145. $verifyDetail = $verify->getOne ( array (
  7146. 'where' => ' vid =' . $receiptDetailList ['verify'],
  7147. 'asArray' => true
  7148. ) );
  7149. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7150. if (empty ( $receiptDetailList ['nowStaff'] )) {
  7151. $nowStaff = "";
  7152. $nowStaffList = array ();
  7153. if ($verifyDetail [0] [1] == 'ROLE') {
  7154. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7155. foreach ( $vStaffString as $key => $value ) {
  7156. $staffK = explode ( "_", $value );
  7157. array_push ( $nowStaffList, $staffK [0] );
  7158. }
  7159. $nowStaff = implode ( ',', $nowStaffList );
  7160. } else {
  7161. $nowStaff = $verifyDetail [0] [0];
  7162. }
  7163. $receipt->nowStaff = $nowStaff;
  7164. }
  7165. // echo $nowStaff;
  7166. // print_r($verifyDetail);die;
  7167. $receipt->rid = $receiptDetailList ['rid'];
  7168. $receipt->date = date ( "Y-m-d" );
  7169. $receipt->status = 2;
  7170. $receipt->update ();
  7171. $receiptDetail->status = 2;
  7172. $receiptDetail->update ( array (
  7173. 'where' => 'rid=' . $receiptDetailList ['rid']
  7174. ) );
  7175. Doo::loadModel ( "receiptLog" );
  7176. $receiptLog = new receiptLog ();
  7177. Doo::loadModel ( "verify" );
  7178. $verify = new verify ();
  7179. $receiptInfo = $receipt->getOne ( array (
  7180. 'where' => 'rid=' . $rid,
  7181. 'asArray' => true
  7182. ) );
  7183. $vr = $verify->getOne ( array (
  7184. 'where' => 'vid=' . $receiptInfo ['verify'],
  7185. 'asArray' => true
  7186. ) );
  7187. $jd = json_decode ( $vr ['staff'] );
  7188. $roleId = 0;
  7189. foreach ( $jd as $key => $value ) {
  7190. if ($value [1] == 'ROLE') {
  7191. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7192. if ($pos !== false) {
  7193. $roleId = $value [0];
  7194. }
  7195. }
  7196. }
  7197. // 审批日志
  7198. // echo $roleId;die;
  7199. if (! empty ( $roleId )) {
  7200. Doo::loadModel ( "role" );
  7201. $role = new role ();
  7202. $roleInfo = $role->getOne ( array (
  7203. 'where' => 'rid=' . $roleId,
  7204. 'asArray' => true
  7205. ) );
  7206. // $receiptLog->rolename = $roleInfo ['name'];
  7207. }
  7208. $receiptLog->username = $this->staff [0] ['username'];
  7209. $receiptLog->uid = $this->staff [0] ['sid'];
  7210. $receiptLog->date = date ( "Y-m-d" );
  7211. $receiptLog->opinion = '提交审批';
  7212. $receiptLog->img = $this->staff [0] ['avatar'];
  7213. $receiptLog->status = 2;
  7214. $receiptLog->rid = $rid;
  7215. $receiptLog->insert ();
  7216. // statistics item
  7217. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  7218. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7219. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  7220. $stat = $statistics->getOne ( array (
  7221. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7222. 'asArray' => true
  7223. ) );
  7224. if (empty ( $stat )) {
  7225. $statistics->date = date ( "Y-m-d" );
  7226. $statistics->cid = $this->staff [0] ['cid'];
  7227. $statistics->staff = $this->staff [0] ['sid'];
  7228. $statistics->agPrice = 0;
  7229. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7230. $statistics->insert ();
  7231. } else {
  7232. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7233. $statistics->update ( array (
  7234. 'where' => 'sid=' . $stat ['sid']
  7235. ) );
  7236. }
  7237. return "/expenses";
  7238. }
  7239. function approval() {
  7240. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7241. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7242. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7243. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7244. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7245. if (empty ( $status ))
  7246. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7247. $vidList = array ();
  7248. $button = 0;
  7249. Doo::loadModel ( 'verify' );
  7250. $verify = new verify ();
  7251. Doo::loadModel ( 'receipt' );
  7252. $receipt = new receipt ();
  7253. Doo::loadModel ( 'staff' );
  7254. $staff = new staff ();
  7255. Doo::loadModel ( 'L_category' );
  7256. $Lcategory = new L_category ();
  7257. // user verify ID
  7258. $verifyDetail = $verify->find ( array (
  7259. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7260. 'asArray' => true
  7261. ) );
  7262. foreach ( $verifyDetail as $key => $value ) {
  7263. array_push ( $vidList, $value ['vid'] );
  7264. }
  7265. $vid = implode ( ",", $vidList );
  7266. if (empty ( $verifyDetail ))
  7267. $vid = 0;
  7268. /*
  7269. */
  7270. $dateCondition = " and Year(date) =" . $year;
  7271. if (! empty ( $month ))
  7272. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  7273. $categoryList = $Lcategory->find ( array (
  7274. 'asArray' => true
  7275. ) );
  7276. $staffList = $staff->find ( array (
  7277. 'where' => 'cid=' . $cid,
  7278. 'asArray' => true
  7279. ) );
  7280. $cateCondition = "";
  7281. $staffCondition = "";
  7282. $approvalCondition = "";
  7283. if (! empty ( $cid ))
  7284. $cateCondition = ' and cid=' . $cid;
  7285. if (! empty ( $sid )) {
  7286. $staffCondition = ' and staff=' . $sid;
  7287. $cateCondition = "";
  7288. }
  7289. // elseif($status==1){
  7290. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  7291. // }
  7292. if ($status == 2) {
  7293. // 查找角色审批人
  7294. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  7295. }
  7296. $ap = "";
  7297. if ($status == 4) {
  7298. $ap = 4;
  7299. $status = 2;
  7300. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  7301. }
  7302. if ($status == 5) {
  7303. $status = 4;
  7304. $ap = 5;
  7305. }
  7306. // echo $vid;
  7307. // get Receipt By verifyID status 2 .$approvalCondition
  7308. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  7309. $receiptList = $receipt->find ( array (
  7310. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  7311. 'desc' => 'rid',
  7312. 'asArray' => true
  7313. ) );
  7314. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  7315. $Locate = 0;
  7316. if ($ap == 4)
  7317. $status = 4;
  7318. elseif ($ap == 5)
  7319. $status = 5;
  7320. foreach ( $receiptList as $key => $value ) {
  7321. $receiptList [$key] ['Locate'] = $Locate;
  7322. $Locate ++;
  7323. $receiptList [$key] ['reviseDetail'] = array ();
  7324. if (! empty ( $value ['reviseDetail'] ))
  7325. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7326. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7327. $categoryDetil = $Lcategory->getOne ( array (
  7328. 'where' => 'cid=' . $value ['cid'],
  7329. 'asArray' => true
  7330. ) );
  7331. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7332. $verifyList = $verify->getOne ( array (
  7333. 'where' => 'vid=' . $value ['verify'],
  7334. 'asArray' => true
  7335. ) );
  7336. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7337. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7338. foreach ( $verifyList as $k => $v ) {
  7339. // init verifyStaff
  7340. $verifyList [$k] ['date'] = "";
  7341. $verifyList [$k] ['opinion'] = "";
  7342. $verifyList [$k] ['status'] = "";
  7343. if (empty ( $verifyStaff )) {
  7344. $verifyList [$k] ['date'] = "";
  7345. $verifyList [$k] ['opinion'] = "";
  7346. if ($v [0] == $this->staff [0] ['sid']) {
  7347. $verifyList [$k] ['status'] = 4;
  7348. $button = 4;
  7349. }
  7350. } else {
  7351. $flag = true;
  7352. foreach ( $verifyStaff as $m => $u ) {
  7353. if ($v [0] == $m) {
  7354. $verifyList [$k] ['date'] = $u ['date'];
  7355. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7356. $verifyList [$k] ['status'] = $u ['status'];
  7357. $flag = false;
  7358. break;
  7359. }
  7360. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  7361. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  7362. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  7363. }
  7364. if ($flag) { // 检测可编辑
  7365. if ($v [0] == $this->staff [0] ['sid']) {
  7366. $verifyList [$k] ['status'] = 4;
  7367. $button = 4;
  7368. }
  7369. }
  7370. }
  7371. }
  7372. $receiptList [$key] ['verifyList'] = $verifyList;
  7373. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7374. 'where' => 'sid=' . $value ['staff'],
  7375. 'asArray' => true
  7376. ) );
  7377. $receiptList [$key] ['button'] = $button;
  7378. }
  7379. // print_r($receiptList);die;
  7380. // $data['verifyDetail']=$verifyDetail;
  7381. $mothHtml = "";
  7382. for($i = 1; $i <= 12; $i ++) {
  7383. if ($month == $i)
  7384. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7385. else
  7386. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7387. }
  7388. $data ['mothHtml'] = $mothHtml;
  7389. $data ['receiptList'] = $receiptList;
  7390. $data ['receiptApprovalCount'] = count ( $receiptList );
  7391. $data ['status'] = $status;
  7392. $data ['year'] = $year;
  7393. $data ['categoryList'] = $categoryList;
  7394. $data ['staffList'] = $staffList;
  7395. $data ['cid'] = $cid;
  7396. $data ['sid'] = $sid;
  7397. $data ['ap'] = $ap;
  7398. $data ['memu'] = "receipt";
  7399. $data ['staff'] = $this->staff;
  7400. $data ['receiptMemu'] = 'approval';
  7401. $data ['verifyId'] = $this->verifyId;
  7402. $data ['executeId'] = $this->executeId;
  7403. $this->render ( "/admin/saea_reportList", $data );
  7404. }
  7405. function approvalDetails() {
  7406. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7407. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7408. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7409. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7410. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7411. Doo::loadModel ( 'verify' );
  7412. $verify = new verify ();
  7413. Doo::loadModel ( 'receipt' );
  7414. $receipt = new receipt ();
  7415. Doo::loadModel ( 'staff' );
  7416. $staff = new staff ();
  7417. Doo::loadModel ( 'L_category' );
  7418. $Lcategory = new L_category ();
  7419. Doo::loadModel ( 'enclosur' );
  7420. $enclosur = new enclosur ();
  7421. $vidList = array ();
  7422. $verifyDetail = $verify->find ( array (
  7423. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7424. 'asArray' => true
  7425. ) );
  7426. foreach ( $verifyDetail as $key => $value ) {
  7427. array_push ( $vidList, $value ['vid'] );
  7428. }
  7429. $vid = implode ( ",", $vidList );
  7430. if (empty ( $verifyDetail ))
  7431. $vid = 0;
  7432. $categoryList = $Lcategory->find ( array (
  7433. 'asArray' => true
  7434. ) );
  7435. $staffList = $staff->find ( array (
  7436. 'where' => 'cid=' . $cid,
  7437. 'asArray' => true
  7438. ) );
  7439. $ap = 0;
  7440. $receiptList = $receipt->find ( array (
  7441. 'where' => 'rid =' . $rid,
  7442. 'desc' => 'rid',
  7443. 'asArray' => true
  7444. ) );
  7445. $Locate = 0;
  7446. $roleId = 0;
  7447. $button = 0;
  7448. foreach ( $receiptList as $key => $value ) {
  7449. $receiptList [$key] ['Locate'] = $Locate;
  7450. $Locate ++;
  7451. $receiptList [$key] ['reviseDetail'] = array ();
  7452. if (! empty ( $value ['reviseDetail'] ))
  7453. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7454. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7455. $categoryDetil = $Lcategory->getOne ( array (
  7456. 'where' => 'cid=' . $value ['cid'],
  7457. 'asArray' => true
  7458. ) );
  7459. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7460. // 检测编辑状态
  7461. $verifyList = $verify->getOne ( array (
  7462. 'where' => 'vid=' . $value ['verify'],
  7463. 'asArray' => true
  7464. ) );
  7465. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7466. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7467. Doo::loadModel ( 'role' );
  7468. $role = new role ();
  7469. // print_r($verifyList);
  7470. $flag = true;
  7471. $roleKey = 0;
  7472. $endStaffArray = array ();
  7473. $roleArrayCopy = array ();
  7474. foreach ( $verifyList as $k => $v ) {
  7475. // init verifyStaff
  7476. if ($v [1] == 'ROLE') {
  7477. if (! empty ( $verifyStaff )) {
  7478. $endStaffArray = end ( $verifyStaff );
  7479. if ($v [0] == $endStaffArray ['nextStaff']) {
  7480. $roleId = $v [0];
  7481. }
  7482. }
  7483. $roleVerify = json_decode ( $v [3], true );
  7484. $roleKey = $k;
  7485. $roleArray = array ();
  7486. $rolename = $role->getOne ( array (
  7487. 'where' => 'rid=' . $v [0],
  7488. 'asArray' => true
  7489. ) );
  7490. foreach ( $roleVerify as $o => $p ) {
  7491. $staffID = explode ( '_', $p );
  7492. $staffInfo = $staff->getOne ( array (
  7493. 'where' => 'sid=' . $staffID [0],
  7494. 'asArray' => true
  7495. ) );
  7496. // print_r($staffID);
  7497. $exp = array (
  7498. 0 => $staffInfo ['sid'],
  7499. 1 => $staffID [1],
  7500. 2 => $staffInfo ['avatar'],
  7501. 'date' => '',
  7502. 'date' => '',
  7503. 'opinion' => '',
  7504. 'status' => '',
  7505. 'rolename' => $rolename ['name']
  7506. );
  7507. array_push ( $roleArray, $exp );
  7508. }
  7509. $roleArrayCopy [$v [0]] = $roleArray;
  7510. // $verifyList[$k]['roleArray']=$roleArray;
  7511. }
  7512. // print_r($roleArray);
  7513. $verifyList [$k] ['date'] = "";
  7514. $verifyList [$k] ['opinion'] = "";
  7515. $verifyList [$k] ['status'] = "";
  7516. if (empty ( $verifyStaff )) {
  7517. $verifyList [$k] ['date'] = "";
  7518. $verifyList [$k] ['opinion'] = "";
  7519. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7520. $verifyList [$k] ['status'] = 4;
  7521. $button = 4;
  7522. $flag = false;
  7523. }
  7524. } else {
  7525. foreach ( $verifyStaff as $m => $u ) {
  7526. if ($v [0] == $m) {
  7527. $verifyList [$k] ['date'] = $u ['date'];
  7528. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7529. $verifyList [$k] ['status'] = $u ['status'];
  7530. $flag = false;
  7531. break;
  7532. }
  7533. }
  7534. $endStaffArray = end ( $verifyStaff );
  7535. if (isset ( $endStaffArray ['ROLE'] )) {
  7536. } else {
  7537. $endKey = key ( $verifyStaff );
  7538. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7539. $button = 4;
  7540. $verifyList [$k] ['status'] = 4;
  7541. }
  7542. }
  7543. }
  7544. }
  7545. $rolename ['name'] = '';
  7546. if (! empty ( $roleId )) {
  7547. Doo::loadModel ( 'role' );
  7548. $role = new role ();
  7549. $rolename = $role->getOne ( array (
  7550. 'where' => 'rid=' . $roleId,
  7551. 'asArray' => true
  7552. ) );
  7553. }
  7554. if (! empty ( $verifyStaff ))
  7555. $endStaffArray = end ( $verifyStaff );
  7556. $KOP = false;
  7557. foreach ( $roleArrayCopy as $P => $A ) {
  7558. foreach ( $A as $MKI => $AVL ) {
  7559. if (! empty ( $verifyStaff )) {
  7560. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7561. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7562. $button = 4;
  7563. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7564. }
  7565. foreach ( $verifyStaff as $m => $u ) {
  7566. $AVLFK = $AVL [0] . '_R';
  7567. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7568. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7569. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7570. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7571. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7572. break;
  7573. }
  7574. }
  7575. } else {
  7576. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7577. $button = 4;
  7578. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7579. }
  7580. }
  7581. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7582. $KOP = true;
  7583. }
  7584. }
  7585. foreach ( $roleArrayCopy as $k => $v ) {
  7586. foreach ( $verifyList as $m => $n ) {
  7587. if ($n [0] == $k) {
  7588. array_splice ( $verifyList, $m, 1, $v );
  7589. }
  7590. }
  7591. }
  7592. $receiptList [$key] ['verifyList'] = $verifyList;
  7593. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7594. 'where' => 'sid=' . $value ['staff'],
  7595. 'asArray' => true
  7596. ) );
  7597. $receiptList [$key] ['button'] = $button;
  7598. }
  7599. $mothHtml = "";
  7600. for($i = 1; $i <= 12; $i ++) {
  7601. if ($month == $i)
  7602. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7603. else
  7604. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7605. }
  7606. // 获取审批日志
  7607. Doo::loadModel ( 'receiptLog' );
  7608. $receiptLog = new receiptLog ();
  7609. $rlList = array ();
  7610. $rlInfo = $receiptLog->getOne ( array (
  7611. 'where' => 'rid=' . $rid . ' and status=4',
  7612. 'asArray' => true
  7613. ) );
  7614. $tijdate = $receiptLog->getOne ( array (
  7615. 'where' => 'rid=' . $rid . ' and status=2',
  7616. 'asc' => 'rlid',
  7617. 'asArray' => true
  7618. ) );
  7619. if (! empty ( $rlInfo )) {
  7620. $rlList = $receiptLog->find ( array (
  7621. 'where' => 'rid=' . $rid,
  7622. 'asc' => 'rlid',
  7623. 'asArray' => true
  7624. ) );
  7625. }
  7626. $receiptList [0] ['rlList'] = $rlList;
  7627. $enclosurList = $enclosur->find ( array (
  7628. 'where' => 'rid=' . $rid,
  7629. 'asArray' => true
  7630. ) );
  7631. $enclosurHtml = '';
  7632. foreach ( $enclosurList as $value ) {
  7633. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  7634. }
  7635. $data ['enclosurHtml'] = $enclosurHtml;
  7636. $data ['rolename'] = $rolename ['name'];
  7637. $data ['datetij'] = $tijdate ['date'];
  7638. $data ['mothHtml'] = $mothHtml;
  7639. $data ['receiptList'] = $receiptList;
  7640. $data ['receiptApprovalCount'] = count ( $receiptList );
  7641. $data ['year'] = $year;
  7642. $data ['categoryList'] = $categoryList;
  7643. $data ['staffList'] = $staffList;
  7644. $data ['cid'] = $cid;
  7645. $data ['sid'] = $sid;
  7646. $data ['status'] = 0;
  7647. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  7648. $ap = 4;
  7649. } else
  7650. $data ['status'] = $receiptList [0] ['status'];
  7651. if ($receiptList [0] ['status'] == 4) {
  7652. $data ['status'] = 5;
  7653. $ap = 0;
  7654. }
  7655. $data ['ap'] = $ap;
  7656. $data ['memu'] = "receipt";
  7657. $data ['staff'] = $this->staff;
  7658. $data ['receiptMemu'] = 'approval';
  7659. $data ['verifyId'] = $this->verifyId;
  7660. $data ['executeId'] = $this->executeId;
  7661. $this->render ( "/admin/saeaReportListReport", $data );
  7662. }
  7663. function approvalEdi() {
  7664. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7665. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7666. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7667. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7668. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7669. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7670. if (empty ( $status ))
  7671. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7672. $vidList = array ();
  7673. $button = 0;
  7674. Doo::loadModel ( 'verify' );
  7675. Doo::loadModel ( 'receipt' );
  7676. Doo::loadModel ( 'staff' );
  7677. $staff = new staff ();
  7678. $receipt = new receipt ();
  7679. $verify = new verify ();
  7680. Doo::loadModel ( 'L_category' );
  7681. $Lcategory = new L_category ();
  7682. Doo::loadModel ( 'enclosur' );
  7683. $enclosur = new enclosur ();
  7684. // user verify ID
  7685. $verifyDetail = $verify->find ( array (
  7686. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7687. 'asArray' => true
  7688. ) );
  7689. foreach ( $verifyDetail as $key => $value ) {
  7690. array_push ( $vidList, $value ['vid'] );
  7691. }
  7692. $vid = implode ( ",", $vidList );
  7693. if (empty ( $verifyDetail ))
  7694. $vid = 0;
  7695. $categoryList = $Lcategory->find ( array (
  7696. 'asArray' => true
  7697. ) );
  7698. $staffList = $staff->find ( array (
  7699. 'where' => 'cid=' . $cid,
  7700. 'asArray' => true
  7701. ) );
  7702. $ap = "";
  7703. if ($status == 4) {
  7704. $ap = 4;
  7705. $status = 2;
  7706. }
  7707. // get Receipt By verifyID status 2
  7708. $receiptList = $receipt->find ( array (
  7709. 'where' => 'rid =' . $rid,
  7710. 'desc' => 'rid',
  7711. 'asArray' => true
  7712. ) );
  7713. $Locate = 0;
  7714. $roleId = 0;
  7715. if ($ap == 4)
  7716. $status = 4;
  7717. foreach ( $receiptList as $key => $value ) {
  7718. $receiptList [$key] ['Locate'] = $Locate;
  7719. $Locate ++;
  7720. $receiptList [$key] ['reviseDetail'] = array ();
  7721. if (! empty ( $value ['reviseDetail'] ))
  7722. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7723. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7724. $categoryDetil = $Lcategory->getOne ( array (
  7725. 'where' => 'cid=' . $value ['cid'],
  7726. 'asArray' => true
  7727. ) );
  7728. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7729. // 检测编辑状态
  7730. $verifyList = $verify->getOne ( array (
  7731. 'where' => 'vid=' . $value ['verify'],
  7732. 'asArray' => true
  7733. ) );
  7734. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7735. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7736. // print_r($verifyList);
  7737. //
  7738. // if (empty($verifyStaff)){
  7739. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  7740. // $verifyList[0]['status']=4;$button=4;
  7741. // }
  7742. //
  7743. // }else{
  7744. //
  7745. // }
  7746. // die;
  7747. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  7748. // echo array_search("green",$a);
  7749. //
  7750. Doo::loadModel ( 'role' );
  7751. $role = new role ();
  7752. // print_r($verifyList);
  7753. $flag = true;
  7754. $roleKey = 0;
  7755. $endStaffArray = array ();
  7756. $roleArrayCopy = array ();
  7757. foreach ( $verifyList as $k => $v ) {
  7758. // init verifyStaff
  7759. if ($v [1] == 'ROLE') {
  7760. if (! empty ( $verifyStaff )) {
  7761. $endStaffArray = end ( $verifyStaff );
  7762. if ($v [0] == $endStaffArray ['nextStaff']) {
  7763. $roleId = $v [0];
  7764. }
  7765. }
  7766. $roleVerify = json_decode ( $v [3], true );
  7767. $roleKey = $k;
  7768. $roleArray = array ();
  7769. $rolename = $role->getOne ( array (
  7770. 'where' => 'rid=' . $v [0],
  7771. 'asArray' => true
  7772. ) );
  7773. foreach ( $roleVerify as $o => $p ) {
  7774. $staffID = explode ( '_', $p );
  7775. $staffInfo = $staff->getOne ( array (
  7776. 'where' => 'sid=' . $staffID [0],
  7777. 'asArray' => true
  7778. ) );
  7779. // print_r($staffID);
  7780. $exp = array (
  7781. 0 => $staffInfo ['sid'],
  7782. 1 => $staffID [1],
  7783. 2 => $staffInfo ['avatar'],
  7784. 'date' => '',
  7785. 'date' => '',
  7786. 'opinion' => '',
  7787. 'status' => '',
  7788. 'rolename' => $rolename ['name']
  7789. );
  7790. array_push ( $roleArray, $exp );
  7791. }
  7792. $roleArrayCopy [$v [0]] = $roleArray;
  7793. // $verifyList[$k]['roleArray']=$roleArray;
  7794. }
  7795. // print_r($roleArray);
  7796. $verifyList [$k] ['date'] = "";
  7797. $verifyList [$k] ['opinion'] = "";
  7798. $verifyList [$k] ['status'] = "";
  7799. if (empty ( $verifyStaff )) {
  7800. $verifyList [$k] ['date'] = "";
  7801. $verifyList [$k] ['opinion'] = "";
  7802. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7803. $verifyList [$k] ['status'] = 4;
  7804. $button = 4;
  7805. $flag = false;
  7806. }
  7807. } else {
  7808. foreach ( $verifyStaff as $m => $u ) {
  7809. if ($v [0] == $m) {
  7810. $verifyList [$k] ['date'] = $u ['date'];
  7811. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7812. $verifyList [$k] ['status'] = $u ['status'];
  7813. $flag = false;
  7814. break;
  7815. }
  7816. }
  7817. $endStaffArray = end ( $verifyStaff );
  7818. if (isset ( $endStaffArray ['ROLE'] )) {
  7819. } else {
  7820. $endKey = key ( $verifyStaff );
  7821. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7822. $button = 4;
  7823. $verifyList [$k] ['status'] = 4;
  7824. }
  7825. }
  7826. // print_r($endStaffArray);die;
  7827. // if (empty($verifyStaff)){
  7828. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  7829. // $verifyList[$k]['status']=4;$button=4;
  7830. // }
  7831. //
  7832. // }else{
  7833. //
  7834. // }
  7835. // if($flag){//检测可编辑
  7836. // if($v[0]==$this->staff[0]['sid']){
  7837. // $verifyList[$k]['status']=4;$button=4;
  7838. // }
  7839. // }
  7840. }
  7841. }
  7842. $rolename ['name'] = '';
  7843. if (! empty ( $roleId )) {
  7844. Doo::loadModel ( 'role' );
  7845. $role = new role ();
  7846. $rolename = $role->getOne ( array (
  7847. 'where' => 'rid=' . $roleId,
  7848. 'asArray' => true
  7849. ) );
  7850. }
  7851. if (! empty ( $verifyStaff ))
  7852. $endStaffArray = end ( $verifyStaff );
  7853. $KOP = false;
  7854. foreach ( $roleArrayCopy as $P => $A ) {
  7855. foreach ( $A as $MKI => $AVL ) {
  7856. if (! empty ( $verifyStaff )) {
  7857. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7858. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7859. $button = 4;
  7860. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7861. }
  7862. foreach ( $verifyStaff as $m => $u ) {
  7863. $AVLFK = $AVL [0] . '_R';
  7864. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7865. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7866. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7867. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7868. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7869. break;
  7870. }
  7871. }
  7872. } else {
  7873. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7874. $button = 4;
  7875. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7876. }
  7877. }
  7878. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7879. $KOP = true;
  7880. }
  7881. }
  7882. // print_r($roleArrayCopy);
  7883. // echo $roleKey;
  7884. foreach ( $roleArrayCopy as $k => $v ) {
  7885. foreach ( $verifyList as $m => $n ) {
  7886. if ($n [0] == $k) {
  7887. array_splice ( $verifyList, $m, 1, $v );
  7888. }
  7889. }
  7890. }
  7891. // if ($KOP)
  7892. // array_splice($verifyList,$roleKey,1,$roleArray);
  7893. // print_r($verifyList);
  7894. $receiptList [$key] ['verifyList'] = $verifyList;
  7895. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7896. 'where' => 'sid=' . $value ['staff'],
  7897. 'asArray' => true
  7898. ) );
  7899. $receiptList [$key] ['button'] = $button;
  7900. }
  7901. // $data['verifyDetail']=$verifyDetail;
  7902. $mothHtml = "";
  7903. for($i = 1; $i <= 12; $i ++) {
  7904. if ($month == $i)
  7905. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7906. else
  7907. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7908. }
  7909. // 获取审批日志
  7910. Doo::loadModel ( 'receiptLog' );
  7911. $receiptLog = new receiptLog ();
  7912. $rlList = array ();
  7913. $rlInfo = $receiptLog->getOne ( array (
  7914. 'where' => 'rid=' . $rid . ' and status=4',
  7915. 'asArray' => true
  7916. ) );
  7917. $tijdate = $receiptLog->getOne ( array (
  7918. 'where' => 'rid=' . $rid . ' and status=2',
  7919. 'asc' => 'rlid',
  7920. 'asArray' => true
  7921. ) );
  7922. if (! empty ( $rlInfo )) {
  7923. $rlList = $receiptLog->find ( array (
  7924. 'where' => 'rid=' . $rid,
  7925. 'asc' => 'rlid',
  7926. 'asArray' => true
  7927. ) );
  7928. }
  7929. $receiptList [0] ['rlList'] = $rlList;
  7930. $enclosurList = $enclosur->find ( array (
  7931. 'where' => 'rid=' . $rid,
  7932. 'asArray' => true
  7933. ) );
  7934. $enclosurHtml = '';
  7935. foreach ( $enclosurList as $value ) {
  7936. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  7937. }
  7938. $data ['enclosurHtml'] = $enclosurHtml;
  7939. $data ['rolename'] = $rolename ['name'];
  7940. $data ['datetij'] = $tijdate ['date'];
  7941. $data ['mothHtml'] = $mothHtml;
  7942. $data ['receiptList'] = $receiptList;
  7943. $data ['receiptApprovalCount'] = count ( $receiptList );
  7944. $data ['status'] = $status;
  7945. $data ['year'] = $year;
  7946. $data ['categoryList'] = $categoryList;
  7947. $data ['staffList'] = $staffList;
  7948. $data ['cid'] = $cid;
  7949. $data ['sid'] = $sid;
  7950. $data ['ap'] = $ap;
  7951. $data ['memu'] = "receipt";
  7952. $data ['staff'] = $this->staff;
  7953. $data ['receiptMemu'] = 'approval';
  7954. $data ['verifyId'] = $this->verifyId;
  7955. $data ['executeId'] = $this->executeId;
  7956. $this->render ( "/admin/saeaReportListReport", $data );
  7957. }
  7958. function remittanceHky() {
  7959. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7960. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  7961. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  7962. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  7963. $page_size = 15;
  7964. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  7965. Doo::loadModel ( 'receipt' );
  7966. $receipt = new receipt ();
  7967. Doo::loadModel ( 'staff' );
  7968. $staff = new staff ();
  7969. $dateCondition = " and Year(executeDate) =" . $year;
  7970. if ($moth != 'MONTH')
  7971. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  7972. if ($day != 'DAY' && $moth != 'MONTH')
  7973. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  7974. $sql = ' (status =8 or status=9 ) and amount>0 ' . $dateCondition;
  7975. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  7976. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  7977. $limit = $pageinfo ['lower'] . ',' . $page_size;
  7978. $dayList = $receipt->find ( array (
  7979. 'select' => 'executeDate,sum(amount) as amount',
  7980. 'where' => $sql,
  7981. 'desc' => 'executeDate',
  7982. 'groupby' => 'executeDate',
  7983. 'limit' => $limit,
  7984. 'asArray' => true
  7985. ) );
  7986. // print_r($dayList);
  7987. foreach ( $dayList as $key => $value ) {
  7988. $remitString = "";
  7989. $receiptList = $receipt->find ( array (
  7990. 'select' => 'rid,executeDate,amount,staff,cid',
  7991. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  7992. 'desc' => 'executeDate',
  7993. 'asArray' => true
  7994. ) );
  7995. foreach ( $receiptList as $k => $v ) {
  7996. $sinfo = $staff->getOne ( array (
  7997. 'select' => 'username,category',
  7998. 'where' => ' sid=' . $v ['staff'],
  7999. 'asArray' => true
  8000. ) );
  8001. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  8002. }
  8003. $dayList [$key] ['staff'] = $remitString;
  8004. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  8005. }
  8006. // print_r($dayList);
  8007. $mothHtml = "";
  8008. for($i = 1; $i <= 12; $i ++) {
  8009. if ($moth == $i)
  8010. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8011. else
  8012. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8013. }
  8014. $dayHtml = "";
  8015. if ($day != "DAY" || $moth != "MONTH") {
  8016. for($i = 1; $i <= 31; $i ++) {
  8017. if ($day == $i)
  8018. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  8019. else
  8020. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  8021. }
  8022. }
  8023. $dateHtml = "";
  8024. $now = date ( "Y" );
  8025. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  8026. if ($YEARD <= $now) {
  8027. $dateHtml .= '<option ';
  8028. if ($year == $YEARD) {
  8029. $dateHtml .= 'selected ';
  8030. }
  8031. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  8032. }
  8033. }
  8034. $data ['dateHtml'] = $dateHtml;
  8035. $data ['page'] = $pageinfo;
  8036. $data ['year'] = $year;
  8037. $data ['moth'] = $moth;
  8038. $data ['day'] = $day;
  8039. $data ['get'] = $get;
  8040. $data ['dayHtml'] = $dayHtml;
  8041. $data ['mothHtml'] = $mothHtml;
  8042. $data ['receiptList'] = $dayList;
  8043. $data ['memu'] = "receipt";
  8044. $data ['staff'] = $this->staff;
  8045. $data ['receiptMemu'] = 'remittanceHky';
  8046. $data ['verifyId'] = $this->verifyId;
  8047. $data ['executeId'] = $this->executeId;
  8048. $this->render ( "/admin/remittanceHky", $data );
  8049. }
  8050. function remittancep() {
  8051. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  8052. Doo::loadModel ( 'receipt' );
  8053. $receipt = new receipt ();
  8054. Doo::loadModel ( 'staff' );
  8055. $staff = new staff ();
  8056. Doo::loadClass ( 'XDeode' );
  8057. $XDeode = new XDeode ( 5 );
  8058. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  8059. $rplist = $receipt->find ( array (
  8060. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8061. 'asArray' => true
  8062. ) );
  8063. $dayList = $receipt->find ( array (
  8064. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8065. 'desc' => 'executeDate',
  8066. 'groupby' => 'staff',
  8067. 'asArray' => true
  8068. ) );
  8069. $html = '';
  8070. foreach ( $dayList as $key => $value ) {
  8071. $sinfo = $staff->getOne ( array (
  8072. 'select' => 'username,category',
  8073. 'where' => ' sid=' . $value ['staff'],
  8074. 'asArray' => true
  8075. ) );
  8076. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  8077. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  8078. $au = 0;
  8079. foreach ( $rplist as $k => $v ) {
  8080. if ($value ['staff'] == $v ['staff']) {
  8081. $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>';
  8082. $au += $v ['amount'];
  8083. }
  8084. }
  8085. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  8086. }
  8087. $data ['html'] = $html;
  8088. $data ['memu'] = "receipt";
  8089. $data ['staff'] = $this->staff;
  8090. $data ['receiptMemu'] = 'remittanceHky';
  8091. $data ['verifyId'] = $this->verifyId;
  8092. $data ['executeId'] = $this->executeId;
  8093. $this->render ( "/admin/remittancep", $data );
  8094. }
  8095. function ajaxGetReceiptDetails() {
  8096. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  8097. Doo::loadClass ( 'XDeode' );
  8098. $XDeode = new XDeode ( 5 );
  8099. $rid = $XDeode->decode ( $rid );
  8100. if (empty ( $rid )) {
  8101. echo json_encode ( array (
  8102. 'status' => 2,
  8103. 'msg' => 'illegal request'
  8104. ) );
  8105. die ();
  8106. }
  8107. Doo::loadModel ( 'receipt' );
  8108. $receipt = new receipt ();
  8109. Doo::loadModel ( 'staff' );
  8110. $staff = new staff ();
  8111. $rinfo = $receipt->getOne ( array (
  8112. 'where' => 'rid= ' . $rid,
  8113. 'asArray' => true
  8114. ) );
  8115. $sinfo = $staff->getOne ( array (
  8116. 'select' => 'username,category',
  8117. 'where' => ' sid=' . $rinfo ['staff'],
  8118. 'asArray' => true
  8119. ) );
  8120. $rinfo ['reviseDetail'] = array ();
  8121. if (! empty ( $rinfo ['reviseDetail'] ))
  8122. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  8123. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  8124. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  8125. $rinfo ['category'] = $sinfo ['category'];
  8126. $verifyStaff = array ();
  8127. if (! empty ( $rinfo ['verifyStaff'] ))
  8128. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  8129. $relust = bcsub ( $rinfo ['sum'], $rinfo ['loanSum'], 2 );
  8130. $rinfo ['relust'] = $relust;
  8131. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  8132. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  8133. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  8134. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  8135. // 费用执行人相关数据
  8136. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  8137. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  8138. foreach ( $executeCopy as $k => $v ) {
  8139. $executeCopy [$k] ['date'] = '';
  8140. $executeCopy [$k] ['opinion'] = '';
  8141. $executeCopy [$k] ['status'] = '';
  8142. if (! empty ( $executeStaff ))
  8143. foreach ( $executeStaff as $m => $u ) {
  8144. if ($v [0] == $m) {
  8145. $executeCopy [$k] ['date'] = $u ['date'];
  8146. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  8147. $executeCopy [$k] ['status'] = $u ['status'];
  8148. break;
  8149. }
  8150. }
  8151. }
  8152. $rinfo ['executeCopy'] = $executeCopy;
  8153. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  8154. if ($rinfo ['Rtype'] == 1) { // 借款费用
  8155. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8156. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  8157. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  8158. $html .= '<tr><th>' . $value ['name'] . '</th>
  8159. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8160. }
  8161. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8162. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8163. <tr><th class="taC" colspan="2">费用说明</th>
  8164. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8165. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8166. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  8167. </tbody></table>';
  8168. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  8169. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8170. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8171. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8172. $html .= '<tr><th>' . $value ['name'] . '</th>
  8173. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8174. }
  8175. $html .= '<tr><th class="taR">合计</th>
  8176. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8177. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8178. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8179. $html .= '<tr><th>' . $value ['name'] . '</th>
  8180. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8181. }
  8182. $html .= '<tr><th class="taR">合计</th>
  8183. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8184. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8185. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8186. $html .= '<tr><th>' . $value ['name'] . '</th>
  8187. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8188. }
  8189. $html .= '<tr><th class="taR">合计</th>
  8190. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8191. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8192. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8193. $html .= '<tr><th>' . $value ['name'] . '</th>
  8194. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8195. }
  8196. $html .= '<tr><th class="taR">合计</th>
  8197. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8198. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8199. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8200. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8201. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8202. }
  8203. $html .= '<tr><th class="taR">合计</th>
  8204. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8205. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8206. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8207. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8208. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8209. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8210. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8211. <tr';
  8212. if ($rinfo ['relust'] >= 0) {
  8213. $html .= 'class="success"';
  8214. } else {
  8215. $html .= 'class="error"';
  8216. }
  8217. $html .= '><td class="taR"><b>借款结余</b></td>
  8218. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  8219. </tbody></table>
  8220. ';
  8221. }
  8222. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  8223. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8224. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  8225. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8226. $html .= '<tr><th>' . $value ['name'] . '</th>
  8227. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8228. }
  8229. $html .= '<tr><th class="taR">合计</th>
  8230. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8231. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8232. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8233. <tr><th class="taC" colspan="2">费用说明</th>
  8234. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8235. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8236. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8237. </tbody></table>';
  8238. } else {
  8239. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8240. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8241. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8242. $html .= '<tr><th>' . $value ['name'] . '</th>
  8243. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8244. }
  8245. $html .= '<tr><th class="taR">合计</th>
  8246. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8247. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8248. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8249. $html .= '<tr><th>' . $value ['name'] . '</th>
  8250. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8251. }
  8252. $html .= '<tr><th class="taR">合计</th>
  8253. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8254. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8255. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8256. $html .= '<tr><th>' . $value ['name'] . '</th>
  8257. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8258. }
  8259. $html .= '<tr><th class="taR">合计</th>
  8260. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8261. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8262. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8263. $html .= '<tr><th>' . $value ['name'] . '</th>
  8264. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8265. }
  8266. $html .= '<tr><th class="taR">合计</th>
  8267. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8268. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8269. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8270. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8271. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8272. }
  8273. $html .= '<tr><th class="taR">合计</th>
  8274. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8275. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8276. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8277. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8278. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8279. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8280. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  8281. $html .= '</tbody></table>';
  8282. /*
  8283. * <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>
  8284. */
  8285. }
  8286. // print_r($verifyStaff);die;
  8287. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  8288. foreach ( $verifyStaff as $key => $value ) {
  8289. $key = trim ( strtr ( $key, '_R', ' ' ) );
  8290. $sinfo = $staff->getOne ( array (
  8291. 'select' => 'username',
  8292. 'where' => ' sid=' . $key,
  8293. 'asArray' => true
  8294. ) );
  8295. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8296. }
  8297. $html .= '</tbody></table>';
  8298. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  8299. foreach ( $rinfo ['executeCopy'] as $value ) {
  8300. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8301. }
  8302. $html .= '</tbody></table>';
  8303. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  8304. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  8305. </tr></table>';
  8306. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  8307. echo json_encode ( array (
  8308. 'status' => 1,
  8309. 'html' => $html
  8310. ) );
  8311. die ();
  8312. }
  8313. /**
  8314. * 删除附件
  8315. */
  8316. function ajaxRemEnclousur() {
  8317. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  8318. if (empty ( $key ))
  8319. echo json_encode ( array (
  8320. 'status' => 2
  8321. ) );
  8322. Doo::loadModel ( 'enclosur' );
  8323. $enclosur = new enclosur ();
  8324. $enclosur->delEnclosurByEid ( $key );
  8325. echo json_encode ( array (
  8326. 'status' => 1
  8327. ) );
  8328. }
  8329. function remittance() {
  8330. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8331. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8332. Doo::loadModel ( 'receipt' );
  8333. $receipt = new receipt ();
  8334. Doo::loadModel ( 'staff' );
  8335. $staff = new staff ();
  8336. $dateCondition = " and Year(pastDate) =" . $year;
  8337. if (! empty ( $month ))
  8338. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  8339. // get Receipt By verifyID status 1
  8340. $receiptList = $receipt->find ( array (
  8341. 'select' => 'sum(sum) as sum,staff,pastDate',
  8342. 'where' => ' status=1' . $dateCondition,
  8343. 'desc' => 'pastDate',
  8344. 'groupby' => 'staff,pastDate',
  8345. 'asArray' => true
  8346. ) );
  8347. $dateList = $receipt->find ( array (
  8348. 'select' => 'pastDate,verifyStaff',
  8349. 'where' => ' status=1' . $dateCondition,
  8350. 'desc' => 'pastDate',
  8351. 'groupby' => 'pastDate',
  8352. 'asArray' => true
  8353. ) );
  8354. $dataList = array ();
  8355. foreach ( $dateList as $d => $a ) {
  8356. $dataList [$a ['pastDate']] = array ();
  8357. $daySum = 0;
  8358. foreach ( $receiptList as $key => $value ) {
  8359. if ($a ['pastDate'] == $value ['pastDate']) {
  8360. $oderList = $receipt->find ( array (
  8361. 'select' => 'receiptOrder',
  8362. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  8363. 'asArray' => true
  8364. ) );
  8365. $list = array ();
  8366. $html = "";
  8367. foreach ( $oderList as $v ) {
  8368. array_push ( $list, $v ['receiptOrder'] );
  8369. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  8370. }
  8371. $receiptList [$key] ['receiptOrder'] = $html;
  8372. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  8373. $sinfo = $staff->getOne ( array (
  8374. 'select' => 'username ',
  8375. 'where' => ' sid=' . $value ['staff'],
  8376. 'asArray' => true
  8377. ) );
  8378. $receiptList [$key] ['username'] = $sinfo ['username'];
  8379. $daySum += $value ['sum'];
  8380. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  8381. }
  8382. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  8383. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  8384. }
  8385. }
  8386. // print_r($dataList);
  8387. $data ['dataList'] = $dataList;
  8388. $mothHtml = "";
  8389. for($i = 1; $i <= 12; $i ++) {
  8390. if ($month == $i)
  8391. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8392. else
  8393. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8394. }
  8395. $data ['year'] = $year;
  8396. $data ['mothHtml'] = $mothHtml;
  8397. $data ['memu'] = "receipt";
  8398. $data ['staff'] = $this->staff;
  8399. $data ['receiptMemu'] = 'approval';
  8400. $data ['verifyId'] = $this->verifyId;
  8401. $data ['executeId'] = $this->executeId;
  8402. $this->render ( "/admin/saeaReportListPay", $data );
  8403. }
  8404. /**
  8405. * 金额调整,提高稳定性
  8406. * @return string
  8407. */
  8408. function revocationAdjustment() {
  8409. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  8410. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  8411. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  8412. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  8413. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  8414. Doo::loadClass ( 'XDeode' );
  8415. $XDeode = new XDeode ( 5 );
  8416. Doo::loadModel ( 'receipt' );
  8417. $receipt = new receipt ();
  8418. $sid = $XDeode->decode ( $sidKey );
  8419. $rid = $XDeode->decode ( $ridKey );
  8420. $reviseKey = $XDeode->decode ( $reviseKey );
  8421. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  8422. die ( 'illegal request' );
  8423. $receiptDetail = $receipt->getOne ( array (
  8424. 'where' => 'rid=' . $rid,
  8425. 'asArray' => true
  8426. ) );
  8427. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  8428. die ( 'illegal request' );
  8429. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8430. if (! isset ( $reviseDetail [$reviseKey] ))
  8431. die ( 'illegal request' );
  8432. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  8433. unset ( $reviseDetail [$reviseKey] );
  8434. $revisePrice = 0;
  8435. foreach ( $reviseDetail as $key => $value ) {
  8436. $revisePrice += $value ['price'];
  8437. }
  8438. $reviseDetailString = json_encode ( $reviseDetail );
  8439. $receipt->reviseDetail = $reviseDetailString;
  8440. $receipt->sum = $receiptDetail ['sum'] - $price;
  8441. $receipt->revisePrice = $revisePrice;
  8442. $receipt->update ( array (
  8443. 'where' => 'rid=' . $rid
  8444. ) );
  8445. return '/receiptburEdi/' . $rid;
  8446. } else
  8447. die ( 'illegal request2' );
  8448. }
  8449. function updateApprovalReceipt() {
  8450. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  8451. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  8452. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8453. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  8454. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  8455. if (! empty ( $rid )) {
  8456. Doo::loadModel ( "verify" );
  8457. $verify = new verify ();
  8458. Doo::loadModel ( "receiptDetail" );
  8459. $receiptDetailObj = new receiptDetail ();
  8460. Doo::loadModel ( "itemStatistics" );
  8461. Doo::loadModel ( "statistics" );
  8462. $statistics = new statistics ();
  8463. $itemStatistics = new itemStatistics ();
  8464. Doo::loadModel ( "receipt" );
  8465. $receipt = new receipt ();
  8466. $receiptDetail = $receipt->getOne ( array (
  8467. 'where' => 'rid=' . $rid . ' and status=2 ',
  8468. 'asArray' => true
  8469. ) );
  8470. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  8471. $nsflag = true;
  8472. foreach ( $nslist as $value ) {
  8473. if ($value == $this->staff ['0'] ['sid']) {
  8474. $nsflag = false;
  8475. break;
  8476. }
  8477. }
  8478. if (empty ( $receiptDetail ) || $nsflag)
  8479. return "/approvalExpenses/pendApproval";
  8480. $verifyDetail = $verify->getOne ( array (
  8481. 'where' => ' vid =' . $receiptDetail ['verify'],
  8482. 'asArray' => true
  8483. ) );
  8484. $verifyString = $verifyDetail ['staff'];
  8485. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  8486. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  8487. if (empty ( $opinion )) {
  8488. if ($status == 3)
  8489. $opinion = "终止";
  8490. else
  8491. $opinion = "同意支付";
  8492. }
  8493. $nowStaff = 0;
  8494. $nowStaffList = array ();
  8495. if (empty ( $verifyStaff )) {
  8496. // 还需加入是否已经进入角色审批
  8497. if ($verifyDetail [0] [1] == 'ROLE') {
  8498. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  8499. foreach ( $vStaffString as $key => $value ) {
  8500. $staffK = explode ( "_", $value );
  8501. if ($staffK [0] != $this->staff [0] ['sid'])
  8502. array_push ( $nowStaffList, $staffK [0] );
  8503. }
  8504. // print_r($verifyDetail);
  8505. // die;
  8506. if (! empty ( $nowStaffList )) {
  8507. $nowStaff = implode ( ',', $nowStaffList );
  8508. $verifyStaff = array (
  8509. $this->staff [0] ['sid'] . "_R" => array (
  8510. 'date' => date ( 'Y-m-d' ),
  8511. 'opinion' => $opinion,
  8512. 'status' => $status,
  8513. 'nextStaff' => $verifyDetail [0] [0],
  8514. 'ROLE' => 1
  8515. )
  8516. );
  8517. } else {
  8518. $nowStaff = $verifyDetail [1] [0];
  8519. $verifyStaff = array (
  8520. $this->staff [0] ['sid'] . "_R" => array (
  8521. 'date' => date ( 'Y-m-d' ),
  8522. 'opinion' => $opinion,
  8523. 'status' => $status,
  8524. 'nextStaff' => $verifyDetail [1] [0]
  8525. )
  8526. );
  8527. }
  8528. } else {
  8529. if ($verifyDetail [1] [1] == 'ROLE') {
  8530. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  8531. // echo "dd";
  8532. foreach ( $vStaffString as $key => $value ) {
  8533. $staffK = explode ( "_", $value );
  8534. array_push ( $nowStaffList, $staffK [0] );
  8535. }
  8536. $nowStaff = implode ( ',', $nowStaffList );
  8537. $verifyStaff = array (
  8538. $this->staff [0] ['sid'] => array (
  8539. 'date' => date ( 'Y-m-d' ),
  8540. 'opinion' => $opinion,
  8541. 'status' => $status,
  8542. 'nextStaff' => $verifyDetail [1] [0],
  8543. 'ROLE' => 1
  8544. )
  8545. );
  8546. } else {
  8547. $nowStaff = $verifyDetail [1] [0];
  8548. $verifyStaff = array (
  8549. $this->staff [0] ['sid'] => array (
  8550. 'date' => date ( 'Y-m-d' ),
  8551. 'opinion' => $opinion,
  8552. 'status' => $status,
  8553. 'nextStaff' => $verifyDetail [1] [0]
  8554. )
  8555. );
  8556. }
  8557. }
  8558. if ($status == 3)
  8559. $verifyStaff = array (
  8560. 'final' => $status,
  8561. $this->staff [0] ['sid'] => array (
  8562. 'date' => date ( 'Y-m-d' ),
  8563. 'opinion' => $opinion,
  8564. 'status' => $status
  8565. )
  8566. );
  8567. $vStaffString = json_encode ( $verifyStaff );
  8568. $receipt->nowStaff = $nowStaff;
  8569. $receipt->verifyStaff = $vStaffString;
  8570. } else {
  8571. $VS = end ( $verifyStaff );
  8572. // 非角色审批
  8573. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  8574. $nextStaff = 0;
  8575. $roleSTF = false;
  8576. foreach ( $verifyDetail as $key => $value ) {
  8577. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  8578. if (isset ( $verifyDetail [$key + 1] )) {
  8579. $nextStaff = $verifyDetail [$key + 1] [0];
  8580. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  8581. $roleSTF = true;
  8582. }
  8583. break;
  8584. }
  8585. }
  8586. if (! $roleSTF) {
  8587. $nowStaff = $nextStaff;
  8588. $verifyStaff [$this->staff [0] ['sid']] = array (
  8589. 'date' => date ( 'Y-m-d' ),
  8590. 'opinion' => $opinion,
  8591. 'status' => $status,
  8592. 'nextStaff' => $nextStaff
  8593. );
  8594. } else {
  8595. // 获取角色下的所有用户ID
  8596. $nowStaffList = array ();
  8597. foreach ( $verifyDetail as $vfk ) {
  8598. if ($vfk [1] == 'ROLE') {
  8599. $vStaffString = json_decode ( $vfk [3] );
  8600. foreach ( $vStaffString as $key => $value ) {
  8601. $staffK = explode ( "_", $value );
  8602. array_push ( $nowStaffList, $staffK [0] );
  8603. }
  8604. }
  8605. }
  8606. $nowStaff = implode ( ',', $nowStaffList );
  8607. $verifyStaff [$this->staff [0] ['sid']] = array (
  8608. 'date' => date ( 'Y-m-d' ),
  8609. 'opinion' => $opinion,
  8610. 'status' => $status,
  8611. 'nextStaff' => $nextStaff,
  8612. 'ROLE' => 0
  8613. );
  8614. }
  8615. if ($status == 3) {
  8616. $verifyStaff ['final'] = $status;
  8617. $verifyStaff [$this->staff [0] ['sid']] = array (
  8618. 'date' => date ( 'Y-m-d' ),
  8619. 'opinion' => $opinion,
  8620. 'status' => $status
  8621. );
  8622. }
  8623. $vStaffString = json_encode ( $verifyStaff );
  8624. $receipt->nowStaff = $nowStaff;
  8625. $receipt->verifyStaff = $vStaffString;
  8626. }
  8627. // 角色审批
  8628. if (isset ( $VS ['ROLE'] )) {
  8629. // 找出角色人 当前审批角色组
  8630. $verifyJSStaff = array ();
  8631. $nowStaffList2 = array ();
  8632. foreach ( $verifyDetail as $key => $value ) {
  8633. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  8634. $verifyJSStaff = json_decode ( $value [3] );
  8635. foreach ( $verifyJSStaff as $m ) {
  8636. $staffK = explode ( "_", $m );
  8637. array_push ( $nowStaffList2, $staffK [0] );
  8638. }
  8639. // print_r($nowStaffList2);
  8640. }
  8641. }
  8642. $RoleVerifyStaff = array ();
  8643. foreach ( $verifyStaff as $key => $value ) {
  8644. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  8645. foreach ( $nowStaffList2 as $m ) {
  8646. if ($key == $m . "_R")
  8647. $RoleVerifyStaff [$key] = $value;
  8648. }
  8649. }
  8650. }
  8651. // print_r($verifyStaff);
  8652. // print_r($nowStaffList2);
  8653. // print_r($RoleVerifyStaff);
  8654. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  8655. // print_r($verifyJSStaff);
  8656. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  8657. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  8658. // 下一个审批人ID
  8659. $nextStaff = 0;
  8660. $falg = false;
  8661. foreach ( $verifyDetail as $key => $value ) {
  8662. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  8663. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  8664. $falg = true;
  8665. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  8666. $nowStaffList = array ();
  8667. foreach ( $vStaffString as $v ) {
  8668. $staffK = explode ( "_", $v );
  8669. array_push ( $nowStaffList, $staffK [0] );
  8670. }
  8671. $nowStaff = implode ( ',', $nowStaffList );
  8672. $nextStaff = $verifyDetail [$key + 1] [0];
  8673. } elseif (isset ( $verifyDetail [$key + 1] )) {
  8674. $nextStaff = $verifyDetail [$key + 1] [0];
  8675. $nowStaff = $nextStaff;
  8676. } else
  8677. $nowStaff = '';
  8678. break;
  8679. }
  8680. }
  8681. if ($falg)
  8682. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8683. 'date' => date ( 'Y-m-d' ),
  8684. 'opinion' => $opinion,
  8685. 'status' => $status,
  8686. 'nextStaff' => $nextStaff,
  8687. 'ROLE' => 1
  8688. );
  8689. else
  8690. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8691. 'date' => date ( 'Y-m-d' ),
  8692. 'opinion' => $opinion,
  8693. 'status' => $status,
  8694. 'nextStaff' => $nextStaff
  8695. );
  8696. // print_r($verifyStaff);
  8697. // echo $nowStaff;die;
  8698. } else { // 进入下一个角色或者审批人
  8699. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  8700. //
  8701. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  8702. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8703. 'date' => date ( 'Y-m-d' ),
  8704. 'opinion' => $opinion,
  8705. 'status' => $status,
  8706. 'nextStaff' => $VS ['nextStaff'],
  8707. 'ROLE' => 1
  8708. );
  8709. // print_r($verifyStaff);
  8710. // die;
  8711. }
  8712. if ($status == 3) {
  8713. $verifyStaff ['final'] = $status;
  8714. $verifyStaff [$this->staff [0] ['sid']] = array (
  8715. 'date' => date ( 'Y-m-d' ),
  8716. 'opinion' => $opinion,
  8717. 'status' => $status
  8718. );
  8719. }
  8720. $vStaffString = json_encode ( $verifyStaff );
  8721. $receipt->verifyStaff = $vStaffString;
  8722. $receipt->nowStaff = $nowStaff;
  8723. // die;
  8724. // }
  8725. // print_r($verifyStaff);
  8726. // die;
  8727. }
  8728. // print_r($verifyStaff);die;
  8729. }
  8730. // print_r($verifyDetail);
  8731. $roleKey = 0;
  8732. $roleId = 0;
  8733. $verifyDetailCopy = array ();
  8734. foreach ( $verifyDetail as $k => $v ) {
  8735. if ($v [1] == 'ROLE') {
  8736. $roleId = $v [0];
  8737. $roleVerify = json_decode ( $v [3], true );
  8738. $roleKey = $k;
  8739. $roleArray = array ();
  8740. foreach ( $roleVerify as $o => $p ) {
  8741. $staffID = explode ( '_', $p );
  8742. $exp = array (
  8743. 0 => $staffID [0],
  8744. 1 => $staffID [1]
  8745. );
  8746. array_push ( $roleArray, $exp );
  8747. }
  8748. $verifyDetailCopy [$v [0]] = $roleArray;
  8749. }
  8750. }
  8751. // print_r($verifyDetail);
  8752. foreach ( $verifyDetailCopy as $k => $v ) {
  8753. foreach ( $verifyDetail as $m => $n ) {
  8754. if ($n [0] == $k) {
  8755. array_splice ( $verifyDetail, $m, 1, $v );
  8756. }
  8757. }
  8758. }
  8759. // die;
  8760. // if (!empty($roleArray))
  8761. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  8762. // echo $roleId;
  8763. // print_r($verifyStaff);
  8764. // print_r($verifyDetail);
  8765. // die;
  8766. Doo::loadModel ( "receiptLog" );
  8767. $receiptLog = new receiptLog ();
  8768. // 审批日志
  8769. if (! isset ( $verifyStaff ['final'] )) {
  8770. if (! empty ( $roleId )) {
  8771. Doo::loadModel ( "role" );
  8772. $role = new role ();
  8773. $roleInfo = $role->getOne ( array (
  8774. 'where' => 'rid=' . $roleId,
  8775. 'asArray' => true
  8776. ) );
  8777. $receiptLog->rolename = $roleInfo ['name'];
  8778. }
  8779. $receiptLog->username = $this->staff [0] ['username'];
  8780. $receiptLog->uid = $this->staff [0] ['sid'];
  8781. $receiptLog->date = date ( "Y-m-d" );
  8782. $receiptLog->opinion = $opinion;
  8783. $receiptLog->img = $this->staff [0] ['avatar'];
  8784. $receiptLog->status = 1;
  8785. $receiptLog->rid = $rid;
  8786. $receiptLog->insert ();
  8787. }
  8788. if (isset ( $verifyStaff ['final'] )) { // rDetail
  8789. $receipt->verifyBreakup = $verifyString;
  8790. $receipt->status = 3;
  8791. $receiptDetailObj->status = 3;
  8792. $receiptDetailObj->update ( array (
  8793. 'where' => 'rid=' . $rid
  8794. ) );
  8795. if (! empty ( $roleId )) {
  8796. Doo::loadModel ( "role" );
  8797. $role = new role ();
  8798. $roleInfo = $role->getOne ( array (
  8799. 'where' => 'rid=' . $roleId,
  8800. 'asArray' => true
  8801. ) );
  8802. $receiptLog->rolename = $roleInfo ['name'];
  8803. }
  8804. $receiptLog->username = $this->staff [0] ['username'];
  8805. $receiptLog->uid = $this->staff [0] ['sid'];
  8806. $receiptLog->date = date ( "Y-m-d" );
  8807. $receiptLog->opinion = $opinion;
  8808. $receiptLog->img = $this->staff [0] ['avatar'];
  8809. $receiptLog->status = 3;
  8810. $receiptLog->rid = $rid;
  8811. $receiptLog->insert ();
  8812. // 微信企业号通知
  8813. $this->setWXMsg ( $rid, 3 );
  8814. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  8815. $receipt->status = 1;
  8816. $reviseSum = 0;
  8817. $receipt->verifyBreakup = $verifyString;
  8818. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  8819. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8820. foreach ( $reviseDetail as $key => $value ) {
  8821. $receiptDetailObj = new receiptDetail ();
  8822. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8823. $receiptDetailObj->item = $value ['description'];
  8824. $receiptDetailObj->itemCategory = "报销金额调整";
  8825. $receiptDetailObj->price = $value ['price'];
  8826. $receiptDetailObj->date = $receiptDetail ['date'];
  8827. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  8828. $receiptDetailObj->rid = $rid;
  8829. $receiptDetailObj->status = 1;
  8830. $receiptDetailObj->insert ();
  8831. $reviseSum += $value ['price'];
  8832. }
  8833. $itemStatistics = new itemStatistics ();
  8834. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  8835. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8836. $itemStatistics->price = $reviseSum;
  8837. $itemStatistics->itemCategory = "报销金额调整";
  8838. $itemStatistics->date = $receiptDetail ['date'];
  8839. $itemStatistics->insert ();
  8840. }
  8841. $receiptDetailObj = new receiptDetail ();
  8842. $receiptDetailObj->status = 1;
  8843. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  8844. $receiptDetailObj->update ( array (
  8845. 'where' => 'rid=' . $rid
  8846. ) );
  8847. $dateArray = explode ( "-", $receiptDetail ['date'] );
  8848. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  8849. $stat = $statistics->getOne ( array (
  8850. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  8851. 'asArray' => true
  8852. ) );
  8853. if (empty ( $stat )) {
  8854. $statistics->date = $receiptDetail ['date'];
  8855. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  8856. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8857. $statistics->agPrice = $receiptDetail ['sum'];
  8858. $statistics->rePrice = $reviseSum;
  8859. $statistics->insert ();
  8860. } else {
  8861. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  8862. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  8863. $statistics->update ( array (
  8864. 'where' => 'sid=' . $stat ['sid']
  8865. ) );
  8866. }
  8867. $dateArray = explode ( "-", $receiptDetail ['date'] );
  8868. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  8869. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  8870. foreach ( $accountItem ['cSum'] as $key => $value ) {
  8871. if ($key == "agencySum") {
  8872. $iStatistics = $itemStatistics->getOne ( array (
  8873. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  8874. 'asArray' => true
  8875. ) );
  8876. if (empty ( $iStatistics )) {
  8877. $itemStatistics->cid = $receiptDetail ['cid'];
  8878. ;
  8879. $itemStatistics->staff = $receiptDetail ['staff'];
  8880. $itemStatistics->price = $value;
  8881. $itemStatistics->itemCategory = $this->AGENCY;
  8882. $itemStatistics->date = $receiptDetail ['date'];
  8883. $itemStatistics->insert ();
  8884. } else {
  8885. if (! empty ( $value )) {
  8886. $itemStatistics->price = $value + $iStatistics ['price'];
  8887. $itemStatistics->update ( array (
  8888. 'where' => 'sid=' . $iStatistics ['sid']
  8889. ) );
  8890. }
  8891. }
  8892. } elseif ($key == "travelSum") {
  8893. $iStatistics = $itemStatistics->getOne ( array (
  8894. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  8895. 'asArray' => true
  8896. ) );
  8897. if (empty ( $iStatistics )) {
  8898. $itemStatistics->cid = $receiptDetail ['cid'];
  8899. $itemStatistics->staff = $receiptDetail ['staff'];
  8900. $itemStatistics->price = $value;
  8901. $itemStatistics->itemCategory = $this->TRAVEL;
  8902. $itemStatistics->date = $receiptDetail ['date'];
  8903. $itemStatistics->insert ();
  8904. } else {
  8905. if (! empty ( $value )) {
  8906. $itemStatistics->price = $value + $iStatistics ['price'];
  8907. $itemStatistics->update ( array (
  8908. 'where' => 'sid=' . $iStatistics ['sid']
  8909. ) );
  8910. }
  8911. }
  8912. } elseif ($key == "trainSum") {
  8913. $iStatistics = $itemStatistics->getOne ( array (
  8914. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  8915. 'asArray' => true
  8916. ) );
  8917. if (empty ( $iStatistics )) {
  8918. $itemStatistics->cid = $receiptDetail ['cid'];
  8919. $itemStatistics->staff = $receiptDetail ['staff'];
  8920. $itemStatistics->price = $value;
  8921. $itemStatistics->itemCategory = $this->TRAIN;
  8922. $itemStatistics->date = $receiptDetail ['date'];
  8923. $itemStatistics->insert ();
  8924. } else {
  8925. if (! empty ( $value )) {
  8926. $itemStatistics->price = $value + $iStatistics ['price'];
  8927. $itemStatistics->update ( array (
  8928. 'where' => 'sid=' . $iStatistics ['sid']
  8929. ) );
  8930. }
  8931. }
  8932. } elseif ($key == "otherSum") {
  8933. $iStatistics = $itemStatistics->getOne ( array (
  8934. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  8935. 'asArray' => true
  8936. ) );
  8937. if (empty ( $iStatistics )) {
  8938. $itemStatistics->cid = $receiptDetail ['cid'];
  8939. $itemStatistics->staff = $receiptDetail ['staff'];
  8940. $itemStatistics->price = $value;
  8941. $itemStatistics->itemCategory = $this->OTHER;
  8942. $itemStatistics->date = $receiptDetail ['date'];
  8943. $itemStatistics->insert ();
  8944. } else {
  8945. if (! empty ( $value )) {
  8946. $itemStatistics->price = $value + $iStatistics ['price'];
  8947. $itemStatistics->update ( array (
  8948. 'where' => 'sid=' . $iStatistics ['sid']
  8949. ) );
  8950. }
  8951. }
  8952. }
  8953. }
  8954. $receipt->pastDate = date ( "Y-m-d" );
  8955. // 微信企业号通知
  8956. $this->setWXMsg ( $rid, 1 );
  8957. }
  8958. //是否有流水
  8959. Doo::loadModel ( 'wasteBook' );
  8960. $wasteBook = new wasteBook ();
  8961. $accountType=3;
  8962. if ($receiptDetail['Rtype']==1){
  8963. $accountType=2;
  8964. }elseif($receiptDetail['Rtype']==2){
  8965. $accountType=4;
  8966. }
  8967. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $rid );
  8968. if (empty($wbDetail)){
  8969. $rsum=$receiptDetail['sum']-$receiptDetail['loanSum'];
  8970. $receipt->amount = $rsum;//$amount;
  8971. }
  8972. $receipt->update ( array (
  8973. 'where' => ' rid = ' . $rid
  8974. ) );
  8975. // 进入下一条审批费用新加需求
  8976. $vidList = array ();
  8977. $verifyDetail = $verify->find ( array (
  8978. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  8979. 'asArray' => true
  8980. ) );
  8981. foreach ( $verifyDetail as $key => $value ) {
  8982. array_push ( $vidList, $value ['vid'] );
  8983. }
  8984. $vid = implode ( ",", $vidList );
  8985. if (empty ( $verifyDetail ))
  8986. $vid = 0;
  8987. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  8988. $receipt = new receipt ();
  8989. $rd = $receipt->getOne ( array (
  8990. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ') and Rtype!=3',
  8991. 'asc' => 'rid',
  8992. 'asArray' => true
  8993. ) );
  8994. if (empty ( $rd )) {
  8995. return '/approvalExpenses/pendApproval';
  8996. }
  8997. if ($rd ['Rtype'] == 1) {
  8998. if ($rd ['isBK'] == 1) {
  8999. return '/receiptburEdi/' . $rd ['rid'];
  9000. } else {
  9001. return '/expensesEdi/' . $rd ['rid'];
  9002. }
  9003. } elseif ($rd ['Rtype'] == 2) {
  9004. return '/remitApproval/' . $rd ['rid'];
  9005. } else {
  9006. return '/receiptburEdi/' . $rd ['rid'];
  9007. }
  9008. // return "/approvalExpenses/pendApproval";
  9009. }
  9010. }
  9011. function expensesRetreats() {
  9012. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  9013. if (! empty ( $rid )) {
  9014. // 操作记录
  9015. Doo::loadModel ( "receipt" );
  9016. $receipt = new receipt ();
  9017. Doo::loadModel ( "receiptLog" );
  9018. $receiptLog = new receiptLog ();
  9019. Doo::loadModel ( "verify" );
  9020. $verify = new verify ();
  9021. $receiptInfo = $receipt->getOne ( array (
  9022. 'where' => 'rid=' . $rid,
  9023. 'asArray' => true
  9024. ) );
  9025. $vr = $verify->getOne ( array (
  9026. 'where' => 'vid=' . $receiptInfo ['verify'],
  9027. 'asArray' => true
  9028. ) );
  9029. $jd = json_decode ( $vr ['staff'] );
  9030. $roleId = 0;
  9031. foreach ( $jd as $key => $value ) {
  9032. if ($value [1] == 'ROLE') {
  9033. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9034. if ($pos !== false) {
  9035. $roleId = $value [0];
  9036. }
  9037. }
  9038. }
  9039. // 审批日志
  9040. // echo $roleId;die;
  9041. if (! empty ( $roleId )) {
  9042. Doo::loadModel ( "role" );
  9043. $role = new role ();
  9044. $roleInfo = $role->getOne ( array (
  9045. 'where' => 'rid=' . $roleId,
  9046. 'asArray' => true
  9047. ) );
  9048. $receiptLog->rolename = $roleInfo ['name'];
  9049. }
  9050. $receiptLog->username = $this->staff [0] ['username'];
  9051. $receiptLog->uid = $this->staff [0] ['sid'];
  9052. $receiptLog->date = date ( "Y-m-d" );
  9053. $receiptLog->opinion = '撤回';
  9054. $receiptLog->img = $this->staff [0] ['avatar'];
  9055. $receiptLog->status = 4;
  9056. $receiptLog->rid = $rid;
  9057. $receiptLog->insert ();
  9058. $receipt->status = 4;
  9059. $receipt->update ( array (
  9060. 'where' => 'rid=' . $rid
  9061. ) );
  9062. // 微信企业号通知
  9063. $this->setWXMsg ( $rid, 2 );
  9064. }
  9065. // echo "ddd";
  9066. return '/approvalExpenses/pendApproval';
  9067. }
  9068. function updateCheReceipt() {
  9069. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9070. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  9071. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  9072. if (! empty ( $rid )) {
  9073. // 操作记录
  9074. Doo::loadModel ( "receipt" );
  9075. $receipt = new receipt ();
  9076. Doo::loadModel ( "receiptLog" );
  9077. $receiptLog = new receiptLog ();
  9078. Doo::loadModel ( "verify" );
  9079. $verify = new verify ();
  9080. $receiptInfo = $receipt->getOne ( array (
  9081. 'where' => 'rid=' . $rid . ' and status=2',
  9082. 'asArray' => true
  9083. ) );
  9084. if (empty ( $receiptInfo )) {
  9085. echo json_encode ( array (
  9086. 'status' => 2
  9087. ) );
  9088. die ();
  9089. }
  9090. $vr = $verify->getOne ( array (
  9091. 'where' => 'vid=' . $receiptInfo ['verify'],
  9092. 'asArray' => true
  9093. ) );
  9094. $jd = json_decode ( $vr ['staff'] );
  9095. $roleId = 0;
  9096. foreach ( $jd as $key => $value ) {
  9097. if ($value [1] == 'ROLE') {
  9098. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9099. if ($pos !== false) {
  9100. $roleId = $value [0];
  9101. }
  9102. }
  9103. }
  9104. // 审批日志
  9105. // echo $roleId;die;
  9106. if (! empty ( $roleId )) {
  9107. Doo::loadModel ( "role" );
  9108. $role = new role ();
  9109. $roleInfo = $role->getOne ( array (
  9110. 'where' => 'rid=' . $roleId,
  9111. 'asArray' => true
  9112. ) );
  9113. $receiptLog->rolename = $roleInfo ['name'];
  9114. }
  9115. $receiptLog->username = $this->staff [0] ['username'];
  9116. $receiptLog->uid = $this->staff [0] ['sid'];
  9117. $receiptLog->date = date ( "Y-m-d" );
  9118. $receiptLog->opinion = $opinion;
  9119. $receiptLog->img = $this->staff [0] ['avatar'];
  9120. $receiptLog->status = 4;
  9121. $receiptLog->rid = $rid;
  9122. $receiptLog->insert ();
  9123. $receipt->status = 4;
  9124. $receipt->update ( array (
  9125. 'where' => 'rid=' . $rid
  9126. ) );
  9127. // 微信企业号通知
  9128. $this->setWXMsg ( $rid, 2 );
  9129. echo json_encode ( array (
  9130. 'status' => 1
  9131. ) );
  9132. // Header("HTTP/1.1 303 See Other");
  9133. // Header("Location: /approvalExpenses/pendApproval");
  9134. die ();
  9135. }
  9136. echo json_encode ( array (
  9137. 'status' => 2
  9138. ) );
  9139. die ();
  9140. // echo "ddd";
  9141. // return '/saeaBorad';
  9142. }
  9143. function revisePrice() {
  9144. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  9145. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  9146. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9147. // echo $price;die;
  9148. if (! empty ( $rid )) {
  9149. Doo::loadModel ( "receipt" );
  9150. $receipt = new receipt ();
  9151. $receiptDetail = $receipt->getOne ( array (
  9152. 'where' => 'rid=' . $rid . ' and status=2 ',
  9153. 'asArray' => true
  9154. ) );
  9155. if (empty ( $receiptDetail ))
  9156. die ( 'illegal request' );
  9157. $reviseDetail = array ();
  9158. if (empty ( $receiptDetail ['reviseDetail'] )) {
  9159. array_push ( $reviseDetail, array (
  9160. 'sid' => $this->staff [0] ['sid'],
  9161. 'name' => $this->staff [0] ['username'],
  9162. 'description' => $description,
  9163. 'price' => $price
  9164. ) );
  9165. $reviseDetailString = json_encode ( $reviseDetail );
  9166. $receipt->reviseDetail = $reviseDetailString;
  9167. $receipt->revisePrice = $price;
  9168. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9169. } else {
  9170. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9171. array_push ( $reviseDetail, array (
  9172. 'sid' => $this->staff [0] ['sid'],
  9173. 'name' => $this->staff [0] ['username'],
  9174. 'description' => $description,
  9175. 'price' => $price
  9176. ) );
  9177. $reviseDetailString = json_encode ( $reviseDetail );
  9178. $receipt->reviseDetail = $reviseDetailString;
  9179. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  9180. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9181. }
  9182. $receipt->update ( array (
  9183. 'where' => 'rid=' . $rid
  9184. ) );
  9185. if ($receiptDetail ['Rtype'] == 1) {
  9186. if ($receiptDetail ['isBK'] == 1) {
  9187. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9188. }
  9189. } elseif ($receiptDetail ['Rtype'] == 2) {
  9190. } else {
  9191. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9192. }
  9193. }
  9194. die ( 'illegal request' );
  9195. }
  9196. function personalCollect() {
  9197. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9198. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  9199. $this->showCache ( $path );
  9200. Doo::loadModel ( "receiptDetail" );
  9201. Doo::loadModel ( "itemStatistics" );
  9202. Doo::loadModel ( 'statistics' );
  9203. $statistics = new statistics ();
  9204. $itemStatistics = new itemStatistics ();
  9205. $receiptDetail = new receiptDetail ();
  9206. $receiptCollectList = $receiptDetail->find ( array (
  9207. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9208. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9209. 'groupby' => 'itemCategory,Month(date)',
  9210. 'asArray' => true
  9211. ) );
  9212. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  9213. 'where' => 'staff=' . $this->staff [0] ['sid'],
  9214. 'asArray' => true
  9215. ) );
  9216. // create collect html
  9217. $collectArray = array (
  9218. '日常相关费用' => array (),
  9219. '差旅相关费用' => array (),
  9220. '培训班费用' => array (),
  9221. '其他' => array ()
  9222. );
  9223. $adjustment = array ();
  9224. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  9225. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9226. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  9227. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9228. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  9229. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9230. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  9231. array_push ( $collectArray ['其他'], $collectHtml );
  9232. $data ['collectArray'] = $collectArray;
  9233. // statistics html
  9234. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9235. if (empty ( $stList ))
  9236. $stList = array (
  9237. 'rePrice' => 0,
  9238. 'agPrice' => 0
  9239. );
  9240. $data ['stList'] = array (
  9241. 'rePrice' => $stList ['rePrice'],
  9242. 'agPrice' => $stList ['agPrice'],
  9243. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9244. );
  9245. // Adjustment price html
  9246. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9247. array_push ( $adjustment, $collectHtml );
  9248. $data ['adjustment'] = $adjustment;
  9249. // total price html
  9250. $collectHtml = "";
  9251. $total = 0;
  9252. for($i = 1; $i <= 12; $i ++) {
  9253. $sumPrice = 0;
  9254. foreach ( $receiptCollectList as $key => $value ) {
  9255. if ($value ['month'] == $i) {
  9256. $sumPrice += $value ['price'];
  9257. }
  9258. }
  9259. if ($sumPrice == 0)
  9260. $collectHtml .= '<td class="taR">-</td>';
  9261. else
  9262. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9263. $total += $sumPrice;
  9264. }
  9265. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9266. $data ['totalPrice'] = $collectHtml;
  9267. $dateHtml = "";
  9268. $now = date ( "Y" );
  9269. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9270. if ($YEARD <= $now) {
  9271. $dateHtml .= '<option ';
  9272. if ($year == $YEARD) {
  9273. $dateHtml .= 'selected ';
  9274. }
  9275. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9276. }
  9277. }
  9278. $data ['dateHtml'] = $dateHtml;
  9279. $data ['year'] = $year;
  9280. $data ['totalYear'] = $total;
  9281. $data ['memu'] = "receipt";
  9282. $data ['staff'] = $this->staff;
  9283. $data ['receiptMemu'] = 'personalCollect';
  9284. $data ['verifyId'] = $this->verifyId;
  9285. $data ['executeId'] = $this->executeId;
  9286. // year staff status 2,4
  9287. if ($year < date ( "Y" )) {
  9288. Doo::loadModel ( 'receipt' );
  9289. $receipt = new receipt ();
  9290. $receiptList = $receipt->find ( array (
  9291. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9292. 'asArray' => true
  9293. ) );
  9294. if (empty ( $receiptList )) {
  9295. ob_start ();
  9296. $this->render ( "/admin/saea_slist_collect", $data );
  9297. $this->cacheFile ( $path );
  9298. die ();
  9299. }
  9300. }
  9301. $this->render ( "/admin/saea_slist_collect", $data );
  9302. }
  9303. function personalCollectDetail() {
  9304. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9305. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  9306. $this->showCache ( $path );
  9307. Doo::loadModel ( "receiptDetail" );
  9308. Doo::loadModel ( "itemStatistics" );
  9309. Doo::loadModel ( 'statistics' );
  9310. Doo::loadModel ( 'accountItem' );
  9311. $accountItem = new accountItem ();
  9312. $statistics = new statistics ();
  9313. $itemStatistics = new itemStatistics ();
  9314. $receiptDetail = new receiptDetail ();
  9315. $receiptCollectList = $receiptDetail->find ( array (
  9316. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9317. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9318. 'groupby' => 'item,Month(date)',
  9319. 'asArray' => true
  9320. ) );
  9321. $accountList = $accountItem->find ( array (
  9322. 'asArray' => true
  9323. ) );
  9324. // create CollectDetail HTML
  9325. $collectHtml = array ();
  9326. foreach ( $accountList as $key => $value ) {
  9327. $html = "";
  9328. $asum = 0;
  9329. for($i = 1; $i <= 12; $i ++) {
  9330. $falg = true;
  9331. foreach ( $receiptCollectList as $v ) {
  9332. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9333. $asum += $v ['price'];
  9334. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9335. $falg = false;
  9336. break;
  9337. }
  9338. }
  9339. if ($falg)
  9340. $html .= '<td class="taR">-</td>';
  9341. }
  9342. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9343. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9344. }
  9345. $data ['collectHtml'] = $collectHtml;
  9346. // create Adjustment price html
  9347. $receiptCollectList = $receiptDetail->find ( array (
  9348. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9349. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9350. 'groupby' => 'itemCategory,Month(date)',
  9351. 'asArray' => true
  9352. ) );
  9353. $adjustment = array ();
  9354. $collectArray = array (
  9355. '日常相关费用' => array (),
  9356. '差旅相关费用' => array (),
  9357. '培训班费用' => array (),
  9358. '其他' => array ()
  9359. );
  9360. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9361. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9362. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9363. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9364. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9365. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9366. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9367. array_push ( $collectArray ['其他'], $collectHtml );
  9368. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9369. array_push ( $adjustment, $collectHtml );
  9370. // total price html
  9371. $collectHtml = "";
  9372. $total = 0;
  9373. for($i = 1; $i <= 12; $i ++) {
  9374. $sumPrice = 0;
  9375. foreach ( $receiptCollectList as $key => $value ) {
  9376. if ($value ['month'] == $i) {
  9377. $sumPrice += $value ['price'];
  9378. }
  9379. }
  9380. if ($sumPrice == 0)
  9381. $collectHtml .= '<td class="taR">-</td>';
  9382. else
  9383. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9384. $total += $sumPrice;
  9385. }
  9386. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9387. // statistics html
  9388. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9389. if (empty ( $stList ))
  9390. $stList = array (
  9391. 'rePrice' => 0,
  9392. 'agPrice' => 0
  9393. );
  9394. $data ['stList'] = array (
  9395. 'rePrice' => $stList ['rePrice'],
  9396. 'agPrice' => $stList ['agPrice'],
  9397. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9398. );
  9399. $data ['collectArray'] = $collectArray;
  9400. $data ['adjustment'] = $adjustment;
  9401. $data ['totalPrice'] = $collectHtml;
  9402. $data ['totalYear'] = $total;
  9403. $data ['year'] = $year;
  9404. $dateHtml = "";
  9405. $now = date ( "Y" );
  9406. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9407. if ($YEARD <= $now) {
  9408. $dateHtml .= '<option ';
  9409. if ($year == $YEARD) {
  9410. $dateHtml .= 'selected ';
  9411. }
  9412. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9413. }
  9414. }
  9415. $data ['dateHtml'] = $dateHtml;
  9416. $data ['memu'] = "receipt";
  9417. $data ['staff'] = $this->staff;
  9418. $data ['receiptMemu'] = 'personalCollect';
  9419. $data ['verifyId'] = $this->verifyId;
  9420. $data ['executeId'] = $this->executeId;
  9421. // year staff status 2,4
  9422. if ($year < date ( "Y" )) {
  9423. Doo::loadModel ( 'receipt' );
  9424. $receipt = new receipt ();
  9425. $receiptList = $receipt->find ( array (
  9426. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9427. 'asArray' => true
  9428. ) );
  9429. if (empty ( $receiptList )) {
  9430. ob_start ();
  9431. $this->render ( "/admin/saeaCollectArticles", $data );
  9432. $this->cacheFile ( $path );
  9433. die ();
  9434. }
  9435. }
  9436. $this->render ( "/admin/saeaCollectArticles", $data );
  9437. }
  9438. function companyCategoryCollect() {
  9439. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9440. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  9441. $this->showCache ( $path );
  9442. Doo::loadModel ( 'L_category' );
  9443. Doo::loadModel ( 'itemStatistics' );
  9444. Doo::loadModel ( 'statistics' );
  9445. $statistics = new statistics ();
  9446. $Lcategory = new L_category ();
  9447. $itemStatistics = new itemStatistics ();
  9448. Doo::loadModel ( "receiptAuthorityManage" );
  9449. $receiptAuthorityManage = new receiptAuthorityManage ();
  9450. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9451. $cidList = array ();
  9452. foreach ( $imcStaff as $key => $value ) {
  9453. array_push ( $cidList, $value ['cid'] );
  9454. }
  9455. $cidString = implode ( ',', $cidList );
  9456. $LcategoryList = $Lcategory->find ( array (
  9457. 'where' => ' cid in (' . $cidString . ')',
  9458. 'asArray' => true
  9459. ) ); // 'staff='.$this->staff[0]['sid']." and
  9460. $itemStatisticsList = $itemStatistics->find ( array (
  9461. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9462. 'where' => " Year(date)=" . $year,
  9463. 'groupby' => 'cid,Month(date)',
  9464. 'asArray' => true
  9465. ) );
  9466. // ceatre companyCollectHtml
  9467. foreach ( $LcategoryList as $value ) {
  9468. $html = "";
  9469. $asum = 0;
  9470. for($i = 1; $i <= 12; $i ++) {
  9471. $falg = true;
  9472. foreach ( $itemStatisticsList as $v ) {
  9473. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  9474. $asum += $v ['price'];
  9475. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9476. $falg = false;
  9477. break;
  9478. }
  9479. }
  9480. if ($falg)
  9481. $html .= '<td class="taR">-</td>';
  9482. }
  9483. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9484. $collectHtml [$value ['title']] = array (
  9485. 'html' => $html,
  9486. 'cid' => $value ['cid']
  9487. );
  9488. }
  9489. $data ['companyHtml'] = $collectHtml;
  9490. // total price html
  9491. $collectHtml = "";
  9492. $total = 0;
  9493. for($i = 1; $i <= 12; $i ++) {
  9494. $sumPrice = 0;
  9495. foreach ( $itemStatisticsList as $key => $value ) {
  9496. if ($value ['month'] == $i) {
  9497. $sumPrice += $value ['price'];
  9498. }
  9499. }
  9500. if ($sumPrice == 0)
  9501. $collectHtml .= '<td class="taR">-</td>';
  9502. else
  9503. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9504. $total += $sumPrice;
  9505. }
  9506. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9507. $data ['companyTotalHtml'] = $collectHtml;
  9508. $data ['total'] = $total;
  9509. // statistics html
  9510. // echo $cidString;
  9511. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9512. if (empty ( $stList ))
  9513. $stList = array (
  9514. 'rePrice' => 0,
  9515. 'agPrice' => 0
  9516. );
  9517. $data ['stList'] = array (
  9518. 'rePrice' => $stList ['rePrice'],
  9519. 'agPrice' => $stList ['agPrice'],
  9520. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9521. );
  9522. $data ['year'] = $year;
  9523. $data ['memu'] = "receipt";
  9524. $data ['staff'] = $this->staff;
  9525. $data ['receiptMemu'] = 'companyCategoryCollect';
  9526. $data ['verifyId'] = $this->verifyId;
  9527. $data ['executeId'] = $this->executeId;
  9528. $dateHtml = "";
  9529. $now = date ( "Y" );
  9530. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9531. if ($YEARD <= $now) {
  9532. $dateHtml .= '<option ';
  9533. if ($year == $YEARD) {
  9534. $dateHtml .= 'selected ';
  9535. }
  9536. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9537. }
  9538. }
  9539. $data ['dateHtml'] = $dateHtml;
  9540. // year staff status 2,4
  9541. if ($year < date ( "Y" )) {
  9542. Doo::loadModel ( 'receipt' );
  9543. $receipt = new receipt ();
  9544. $receiptList = $receipt->find ( array (
  9545. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  9546. 'asArray' => true
  9547. ) );
  9548. if (empty ( $receiptList )) {
  9549. ob_start ();
  9550. $this->render ( "/admin/saeaCompanyCollect", $data );
  9551. $this->cacheFile ( $path );
  9552. die ();
  9553. }
  9554. }
  9555. $this->render ( "/admin/saeaCompanyCollect", $data );
  9556. }
  9557. function categoryCollectDetail() {
  9558. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9559. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  9560. /* $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  9561. $this->showCache ( $path ); */
  9562. Doo::loadModel ( 'statistics' );
  9563. $statistics = new statistics ();
  9564. Doo::loadModel ( "receiptDetail" );
  9565. $receiptDetail = new receiptDetail ();
  9566. Doo::loadModel ( 'L_category' );
  9567. $Lcategory = new L_category ();
  9568. Doo::loadModel ( 'accountItem' );
  9569. $accountItem = new accountItem ();
  9570. Doo::loadModel ( "receiptAuthorityManage" );
  9571. $receiptAuthorityManage = new receiptAuthorityManage ();
  9572. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9573. $cidList = array ();
  9574. foreach ( $imcStaff as $key => $value ) {
  9575. array_push ( $cidList, $value ['cid'] );
  9576. }
  9577. $cidString = implode ( ',', $cidList );
  9578. $LcategoryList = $Lcategory->find ( array (
  9579. 'where' => 'cid in (' . $cidString . ')',
  9580. 'asArray' => true
  9581. ) );
  9582. if ($cid == 0) {
  9583. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9584. if ($cid == 0)
  9585. $cid = $LcategoryList [0] ['cid'];
  9586. }
  9587. $data ['LcategoryList'] = $LcategoryList;
  9588. $receiptCollectList = $receiptDetail->find ( array (
  9589. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9590. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9591. 'groupby' => 'item,Month(pastDate)',
  9592. 'asArray' => true
  9593. ) );
  9594. $accountList = $accountItem->find ( array (
  9595. 'asArray' => true
  9596. ) );
  9597. // create CollectDetail HTML
  9598. $collectHtml = array ();
  9599. foreach ( $accountList as $key => $value ) {
  9600. $html = "";
  9601. $asum = 0;
  9602. for($i = 1; $i <= 12; $i ++) {
  9603. $falg = true;
  9604. foreach ( $receiptCollectList as $v ) {
  9605. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9606. $asum += $v ['price'];
  9607. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9608. $falg = false;
  9609. break;
  9610. }
  9611. }
  9612. if ($falg)
  9613. $html .= '<td class="taR">-</td>';
  9614. }
  9615. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9616. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9617. }
  9618. $data ['collectHtml'] = $collectHtml;
  9619. // create Adjustment price html
  9620. $receiptCollectList = $receiptDetail->find ( array (
  9621. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9622. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9623. 'groupby' => 'itemCategory,Month(pastDate)',
  9624. 'asArray' => true
  9625. ) );
  9626. $adjustment = array ();
  9627. $collectArray = array (
  9628. '日常相关费用' => array (),
  9629. '差旅相关费用' => array (),
  9630. '培训班费用' => array (),
  9631. '内部培训费用'=>array(),
  9632. '其他' => array ()
  9633. );
  9634. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9635. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9636. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9637. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9638. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9639. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9640. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  9641. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  9642. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9643. array_push ( $collectArray ['其他'], $collectHtml );
  9644. $data ['collectArray'] = $collectArray;
  9645. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9646. array_push ( $adjustment, $collectHtml );
  9647. $data ['adjustment'] = $adjustment;
  9648. // total price html
  9649. $collectHtml = "";
  9650. $total = 0;
  9651. for($i = 1; $i <= 12; $i ++) {
  9652. $sumPrice = 0;
  9653. foreach ( $receiptCollectList as $key => $value ) {
  9654. if ($value ['month'] == $i) {
  9655. $sumPrice += $value ['price'];
  9656. }
  9657. }
  9658. if ($sumPrice == 0)
  9659. $collectHtml .= '<td class="taR">-</td>';
  9660. else
  9661. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9662. $total += $sumPrice;
  9663. }
  9664. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9665. // statistics html
  9666. $stList = $statistics->statisticsByCid ( $year, $cid );
  9667. if (empty ( $stList ))
  9668. $stList = array (
  9669. 'rePrice' => 0,
  9670. 'agPrice' => 0
  9671. );
  9672. $data ['stList'] = array (
  9673. 'rePrice' => $stList ['rePrice'],
  9674. 'agPrice' => $stList ['agPrice'],
  9675. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9676. );
  9677. $data ['totalYear'] = $total;
  9678. $data ['year'] = $year;
  9679. $data ['cid'] = $cid;
  9680. $data ['memu'] = "receipt";
  9681. $data ['staff'] = $this->staff;
  9682. $data ['receiptMemu'] = 'companyCategoryCollect';
  9683. $data ['verifyId'] = $this->verifyId;
  9684. $data ['executeId'] = $this->executeId;
  9685. // year staff status 2,4
  9686. /* if ($year < date ( "Y" )) {
  9687. Doo::loadModel ( 'receipt' );
  9688. $receipt = new receipt ();
  9689. $receiptList = $receipt->find ( array (
  9690. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  9691. 'asArray' => true
  9692. ) );
  9693. if (empty ( $receiptList )) {
  9694. ob_start ();
  9695. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  9696. $this->cacheFile ( $path );
  9697. die ();
  9698. }
  9699. } */
  9700. $dateHtml = "";
  9701. $now = date ( "Y" );
  9702. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9703. if ($YEARD <= $now) {
  9704. $dateHtml .= '<option ';
  9705. if ($year == $YEARD) {
  9706. $dateHtml .= 'selected ';
  9707. }
  9708. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9709. }
  9710. }
  9711. $data ['dateHtml'] = $dateHtml;
  9712. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  9713. }
  9714. function staffCollect() {
  9715. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9716. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ONJOB';//
  9717. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  9718. // $this->showCache($path);
  9719. Doo::loadModel ( 'statistics' );
  9720. $statistics = new statistics ();
  9721. Doo::loadModel ( "receiptDetail" );
  9722. $receiptDetail = new receiptDetail ();
  9723. Doo::loadModel ( 'L_category' );
  9724. $Lcategory = new L_category ();
  9725. Doo::loadModel ( 'accountItem' );
  9726. $accountItem = new accountItem ();
  9727. Doo::loadModel ( 'staff' );
  9728. $staff = new staff ();
  9729. Doo::loadModel ( 'itemStatistics' );
  9730. $itemStatistics = new itemStatistics ();
  9731. Doo::loadModel ( "receiptAuthorityManage" );
  9732. $receiptAuthorityManage = new receiptAuthorityManage ();
  9733. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9734. $cidList = array ();
  9735. foreach ( $imcStaff as $key => $value ) {
  9736. array_push ( $cidList, $value ['cid'] );
  9737. }
  9738. $cidString = implode ( ',', $cidList );
  9739. $naturecon='';
  9740. if ($nature=='ONJOB'){
  9741. $naturecon=' and (nature!=4 )';
  9742. }elseif($nature=='LEAVEJOB'){
  9743. $naturecon=' and (nature=4 )';
  9744. }else{
  9745. die ( 'illegal request--nature' );
  9746. }
  9747. // statistics html
  9748. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9749. if (empty ( $stList ))
  9750. $stList = array (
  9751. 'rePrice' => 0,
  9752. 'agPrice' => 0
  9753. );
  9754. $data ['stList'] = array (
  9755. 'rePrice' => $stList ['rePrice'],
  9756. 'agPrice' => $stList ['agPrice'],
  9757. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9758. );
  9759. // ---
  9760. $staffList = $staff->find ( array (
  9761. 'where' => 'username !="admin" '.$naturecon,
  9762. 'asArray' => true
  9763. ) );
  9764. $LcategoryList = $Lcategory->find ( array (
  9765. 'asArray' => true
  9766. ) ); // 'staff='.$this->staff[0]['sid']." and
  9767. $itemStatisticsList = $itemStatistics->find ( array (
  9768. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9769. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  9770. 'groupby' => 'staff,Month(date)',
  9771. 'asArray' => true
  9772. ) );
  9773. $categoryList = $staff->find ( array (
  9774. 'select' => 'COUNT(*) as count,cid,category',
  9775. 'where' => 'username !="admin" and cid in (' . $cidString . ') '.$naturecon,
  9776. 'groupby' => 'cid',
  9777. 'asArray' => true
  9778. ) );
  9779. // print_r($itemStatisticsList);die;
  9780. // ceatre companyCollectHtml
  9781. foreach ( $categoryList as $vlu ) {
  9782. $count = $vlu ['count'] + 1;
  9783. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  9784. $m1 = 0;
  9785. $m2 = 0;
  9786. $m3 = 0;
  9787. $m4 = 0;
  9788. $m5 = 0;
  9789. $m6 = 0;
  9790. $m7 = 0;
  9791. $m8 = 0;
  9792. $m9 = 0;
  9793. $m10 = 0;
  9794. $m11 = 0;
  9795. $m12 = 0;
  9796. $m13 = 0;
  9797. foreach ( $staffList as $value ) {
  9798. if ($vlu ['cid'] == $value ['cid']) {
  9799. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  9800. $asum = 0;
  9801. for($i = 1; $i <= 12; $i ++) {
  9802. $falg = true;
  9803. foreach ( $itemStatisticsList as $v ) {
  9804. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  9805. if ($v ['month'] == 1)
  9806. $m1 += $v ['price'];
  9807. if ($v ['month'] == 2)
  9808. $m2 += $v ['price'];
  9809. if ($v ['month'] == 3)
  9810. $m3 += $v ['price'];
  9811. if ($v ['month'] == 4)
  9812. $m4 += $v ['price'];
  9813. if ($v ['month'] == 5)
  9814. $m5 += $v ['price'];
  9815. if ($v ['month'] == 6)
  9816. $m6 += $v ['price'];
  9817. if ($v ['month'] == 7)
  9818. $m7 += $v ['price'];
  9819. if ($v ['month'] == 8)
  9820. $m8 += $v ['price'];
  9821. if ($v ['month'] == 9)
  9822. $m9 += $v ['price'];
  9823. if ($v ['month'] == 10)
  9824. $m10 += $v ['price'];
  9825. if ($v ['month'] == 11)
  9826. $m11 += $v ['price'];
  9827. if ($v ['month'] == 12)
  9828. $m12 += $v ['price'];
  9829. $asum += $v ['price'];
  9830. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9831. $falg = false;
  9832. break;
  9833. }
  9834. }
  9835. if ($falg)
  9836. $html .= '<td class="taR">-</td>';
  9837. }
  9838. $m13 += $asum;
  9839. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9840. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  9841. 'html' => $html,
  9842. 'sid' => $value ['sid']
  9843. );
  9844. $html = "";
  9845. }
  9846. }
  9847. $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>
  9848. <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>
  9849. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  9850. $collectHtml [$vlu ['cid']] = array (
  9851. 'html' => $hl,
  9852. 'sid' => ''
  9853. );
  9854. }
  9855. $data ['companyHtml'] = $collectHtml;
  9856. // total price html
  9857. $collectHtml = "";
  9858. $total = 0;
  9859. for($i = 1; $i <= 12; $i ++) {
  9860. $sumPrice = 0;
  9861. foreach ( $itemStatisticsList as $key => $value ) {
  9862. if ($value ['month'] == $i) {
  9863. $sumPrice += $value ['price'];
  9864. }
  9865. }
  9866. if ($sumPrice == 0)
  9867. $collectHtml .= '<td class="taR">-</td>';
  9868. else
  9869. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9870. $total += $sumPrice;
  9871. }
  9872. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9873. $data ['companyTotalHtml'] = $collectHtml;
  9874. $data ['total'] = $total;
  9875. $data ['nature'] =$nature;
  9876. $data ['year'] = $year;
  9877. $data ['memu'] = "receipt";
  9878. $data ['staff'] = $this->staff;
  9879. $data ['receiptMemu'] = 'companyCategoryCollect';
  9880. $data ['verifyId'] = $this->verifyId;
  9881. $data ['executeId'] = $this->executeId;
  9882. if ($year <= date ( "Y" )) {
  9883. Doo::loadModel ( 'receipt' );
  9884. $receipt = new receipt ();
  9885. $receiptList = $receipt->find ( array (
  9886. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  9887. 'asArray' => true
  9888. ) );
  9889. if (empty ( $receiptList )) { // generated files
  9890. ob_start ();
  9891. $this->render ( "/admin/saeaStaffCollectB", $data );
  9892. $this->cacheFile ( $path );
  9893. die ();
  9894. }
  9895. }
  9896. $this->render ( "/admin/saeaStaffCollectB", $data );
  9897. }
  9898. function staffCollectBak() {
  9899. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9900. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  9901. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  9902. $this->showCache ( $path );
  9903. Doo::loadModel ( 'statistics' );
  9904. $statistics = new statistics ();
  9905. Doo::loadModel ( "receiptDetail" );
  9906. $receiptDetail = new receiptDetail ();
  9907. Doo::loadModel ( 'L_category' );
  9908. $Lcategory = new L_category ();
  9909. Doo::loadModel ( 'accountItem' );
  9910. $accountItem = new accountItem ();
  9911. Doo::loadModel ( 'staff' );
  9912. $staff = new staff ();
  9913. Doo::loadModel ( 'itemStatistics' );
  9914. $itemStatistics = new itemStatistics ();
  9915. $itemStatisticsList = $itemStatistics->find ( array (
  9916. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9917. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9918. 'groupby' => 'staff,itemCategory,Month(date)',
  9919. 'asArray' => true
  9920. ) );
  9921. $itemCategoryList = $itemStatistics->find ( array (
  9922. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9923. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9924. 'groupby' => 'cid,itemCategory,Month(date)',
  9925. 'asArray' => true
  9926. ) );
  9927. $LcategoryList = $Lcategory->find ( array (
  9928. 'asArray' => true
  9929. ) );
  9930. $staffList = $staff->find ( array (
  9931. 'asArray' => true
  9932. ) );
  9933. $htmlArray = array ();
  9934. foreach ( $LcategoryList as $value ) {
  9935. $htmlArray [$value ['title']] = array ();
  9936. foreach ( $staffList as $v ) {
  9937. if ($value ['cid'] == $v ['cid']) {
  9938. $html = "";
  9939. $falg = true;
  9940. $staffSumPrice = 0;
  9941. foreach ( $itemStatisticsList as $a ) {
  9942. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  9943. if (empty ( $a ['price'] )) {
  9944. $html .= '<td class="taR">-</td>';
  9945. $falg = false;
  9946. break;
  9947. } else {
  9948. $staffSumPrice += $a ['price'];
  9949. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9950. $falg = false;
  9951. break;
  9952. }
  9953. }
  9954. }
  9955. if ($falg) {
  9956. $html .= '<td class="taR">-</td>';
  9957. $falg = true;
  9958. }
  9959. $falg = true;
  9960. foreach ( $itemStatisticsList as $a ) {
  9961. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  9962. if (empty ( $a ['price'] )) {
  9963. $html .= '<td class="taR">-</td>';
  9964. $falg = false;
  9965. break;
  9966. } else {
  9967. $staffSumPrice += $a ['price'];
  9968. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9969. $falg = false;
  9970. break;
  9971. }
  9972. }
  9973. }
  9974. if ($falg) {
  9975. $html .= '<td class="taR">-</td>';
  9976. $falg = true;
  9977. }
  9978. $falg = true;
  9979. foreach ( $itemStatisticsList as $a ) {
  9980. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  9981. if (empty ( $a ['price'] )) {
  9982. $html .= '<td class="taR">-</td>';
  9983. $falg = false;
  9984. break;
  9985. } else {
  9986. $staffSumPrice += $a ['price'];
  9987. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9988. $falg = false;
  9989. break;
  9990. }
  9991. }
  9992. }
  9993. if ($falg) {
  9994. $html .= '<td class="taR">-</td>';
  9995. $falg = true;
  9996. }
  9997. $falg = true;
  9998. foreach ( $itemStatisticsList as $a ) {
  9999. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  10000. if (! empty ( $a ['price'] )) {
  10001. $staffSumPrice += $a ['price'];
  10002. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10003. $falg = false;
  10004. break;
  10005. } else {
  10006. $html .= '<td class="taR">-</td>';
  10007. $falg = false;
  10008. break;
  10009. }
  10010. }
  10011. }
  10012. if ($falg) {
  10013. $html .= '<td class="taR">-</td>';
  10014. $falg = true;
  10015. }
  10016. $falg = true;
  10017. foreach ( $itemStatisticsList as $a ) {
  10018. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  10019. if (! empty ( $a ['price'] )) {
  10020. $staffSumPrice += $a ['price'];
  10021. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10022. $falg = false;
  10023. break;
  10024. } else {
  10025. $html .= '<td class="taR">-</td>';
  10026. $falg = false;
  10027. break;
  10028. }
  10029. }
  10030. }
  10031. if ($falg) {
  10032. $html .= '<td class="taR">-</td>';
  10033. $falg = true;
  10034. }
  10035. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  10036. $htmlArray [$value ['title']] [$v ['username']] = $html;
  10037. }
  10038. }
  10039. /* -- --- */
  10040. // 合计费用
  10041. $cateHtml = "";
  10042. $catePrice = 0;
  10043. $cateFalg = true;
  10044. foreach ( $itemCategoryList as $l ) {
  10045. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  10046. if (empty ( $l ['price'] )) {
  10047. $cateHtml .= '<td class="colGreen taR">-</td>';
  10048. $cateFalg = false;
  10049. break;
  10050. } else {
  10051. $catePrice += $l ['price'];
  10052. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10053. $cateFalg = false;
  10054. break;
  10055. }
  10056. }
  10057. }
  10058. if ($cateFalg) {
  10059. $cateHtml .= '<td class="colGreen taR">-</td>';
  10060. $cateFalg = true;
  10061. }
  10062. $cateFalg = true;
  10063. foreach ( $itemCategoryList as $l ) {
  10064. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  10065. if (empty ( $l ['price'] )) {
  10066. $cateHtml .= '<td class="colGreen taR">-</td>';
  10067. $cateFalg = false;
  10068. break;
  10069. } else {
  10070. $catePrice += $l ['price'];
  10071. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10072. $cateFalg = false;
  10073. break;
  10074. }
  10075. }
  10076. }
  10077. if ($cateFalg) {
  10078. $cateHtml .= '<td class="colGreen taR">-</td>';
  10079. $cateFalg = true;
  10080. }
  10081. $cateFalg = true;
  10082. foreach ( $itemCategoryList as $l ) {
  10083. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  10084. if (empty ( $l ['price'] )) {
  10085. $cateHtml .= '<td class="colGreen taR">-</td>';
  10086. $cateFalg = false;
  10087. break;
  10088. } else {
  10089. $catePrice += $l ['price'];
  10090. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10091. $cateFalg = false;
  10092. break;
  10093. }
  10094. }
  10095. }
  10096. if ($cateFalg) {
  10097. $cateHtml .= '<td class="colGreen taR">-</td>';
  10098. $cateFalg = true;
  10099. }
  10100. $cateFalg = true;
  10101. foreach ( $itemCategoryList as $l ) {
  10102. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  10103. if (empty ( $l ['price'] )) {
  10104. $cateHtml .= '<td class="colGreen taR">-</td>';
  10105. $cateFalg = false;
  10106. break;
  10107. } else {
  10108. $catePrice += $l ['price'];
  10109. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10110. $cateFalg = false;
  10111. break;
  10112. }
  10113. }
  10114. }
  10115. if ($cateFalg) {
  10116. $cateHtml .= '<td class="colGreen taR">-</td>';
  10117. $cateFalg = true;
  10118. }
  10119. $cateFalg = true;
  10120. foreach ( $itemCategoryList as $l ) {
  10121. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  10122. if (empty ( $l ['price'] )) {
  10123. $cateHtml .= '<td class="colGreen taR">-</td>';
  10124. $cateFalg = false;
  10125. break;
  10126. } else {
  10127. $catePrice += $l ['price'];
  10128. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10129. $cateFalg = false;
  10130. break;
  10131. }
  10132. }
  10133. }
  10134. if ($cateFalg) {
  10135. $cateHtml .= '<td class="colGreen taR">-</td>';
  10136. $cateFalg = true;
  10137. }
  10138. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  10139. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  10140. /* -- --- */
  10141. }
  10142. // print_r($htmlArray);die;
  10143. $data ['htmlArray'] = $htmlArray;
  10144. // statistics html
  10145. $stList = $statistics->getOne ( array (
  10146. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  10147. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10148. 'groupby' => 'Month(date)',
  10149. 'asArray' => true
  10150. ) );
  10151. if (empty ( $stList ))
  10152. $stList = array (
  10153. 'rePrice' => 0,
  10154. 'agPrice' => 0
  10155. );
  10156. $data ['stList'] = array (
  10157. 'rePrice' => $stList ['rePrice'],
  10158. 'agPrice' => $stList ['agPrice'],
  10159. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10160. );
  10161. $monthHtml = "";
  10162. for($i = 1; $i <= 12; $i ++) {
  10163. if ($i == $month)
  10164. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  10165. else
  10166. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  10167. }
  10168. $data ['monthHtml'] = $monthHtml;
  10169. $data ['year'] = $year;
  10170. $data ['month'] = $month;
  10171. $data ['memu'] = "receipt";
  10172. $data ['staff'] = $this->staff;
  10173. $data ['receiptMemu'] = 'companyCategoryCollect';
  10174. $data ['verifyId'] = $this->verifyId;
  10175. $data ['executeId'] = $this->executeId;
  10176. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  10177. Doo::loadModel ( 'receipt' );
  10178. $receipt = new receipt ();
  10179. $receiptList = $receipt->find ( array (
  10180. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  10181. 'asArray' => true
  10182. ) );
  10183. if (empty ( $receiptList )) { // generated files
  10184. ob_start ();
  10185. $this->render ( "/admin/saeaStaffCollect", $data );
  10186. $this->cacheFile ( $path );
  10187. die ();
  10188. }
  10189. }
  10190. $this->render ( "/admin/saeaStaffCollect", $data );
  10191. }
  10192. /**
  10193. * 日常收支
  10194. */
  10195. function payments() {
  10196. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  10197. Doo::loadModel ( "execute" );
  10198. $execute = new execute ();
  10199. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  10200. die ( 'illegal request' );
  10201. }
  10202. Doo::loadModel ( "accountBook" );
  10203. $accountBook = new accountBook ();
  10204. Doo::loadModel ( "accountBookStatistics" );
  10205. $accountBookStatistics = new accountBookStatistics ();
  10206. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  10207. $list = $accountBook->getAccountBookByLimit ( 10 );
  10208. $data ['date'] = date ( "Y-m-d" );
  10209. $data ['statisticsList'] = $statisticsList;
  10210. $data ['list'] = $list;
  10211. $data ['memu'] = "receipt";
  10212. $data ['staff'] = $this->staff;
  10213. $data ['receiptMemu'] = 'payments';
  10214. $data ['verifyId'] = $this->verifyId;
  10215. $data ['executeId'] = $this->executeId;
  10216. $this->render ( "/expenses/payments", $data );
  10217. }
  10218. function paymentsIncomeDo() {
  10219. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10220. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10221. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10222. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10223. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10224. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10225. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10226. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10227. Doo::loadClass ( 'XDeode' );
  10228. $XDeode = new XDeode ( 5 );
  10229. Doo::loadModel ( "accountBook" );
  10230. Doo::loadModel ( "accountBookStatistics" );
  10231. Doo::loadModel ( 'wasteBook' );
  10232. // 记录流水时银行的转换
  10233. $accountBank = '';
  10234. if ($receivedBank == '纵横广发') {
  10235. $accountBank = 'CGBDeposit';
  10236. } elseif ($receivedBank == '纵横工行') {
  10237. $accountBank = 'ICBCDeposit';
  10238. } elseif ($receivedBank == '华润银行') {
  10239. $accountBank = 'HUADeposit';
  10240. } elseif ($receivedBank == '个人广发') {
  10241. $accountBank = 'PersonalDeposit';
  10242. }
  10243. if (empty ( $accountBank ))
  10244. die ( 'illegal request' );
  10245. // 收入为理财时特殊处理
  10246. if ($accountType == 7 || $accountType == 9) {
  10247. if ($receivedBank == '个人广发') {
  10248. die ( '个人广发 illegal request' );
  10249. }
  10250. // 添加一条收入
  10251. $accountBook = new accountBook ();
  10252. $accountBook->accountType = 10;
  10253. $accountBook->accountMsg = $accountMsg;
  10254. $accountBook->receivedPrice = $receivedPrice;
  10255. $accountBook->receivedMsg = $receivedMsg;
  10256. $accountBook->receivedBank = $receivedBank;
  10257. $accountBook->receivedDate = $receivedDate;
  10258. $accountBook->remarks = $remarks;
  10259. $accountBook->expensesType = 1;
  10260. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10261. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10262. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10263. $inComeId = $accountBook->insert ();
  10264. // 收支汇总-添加一条收入日常汇总
  10265. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10266. $accountBookStatistics = new accountBookStatistics ();
  10267. $item = array (
  10268. 'date' => date ( "Y-m-d" ),
  10269. 'accountType' => $abDetail ['accountType'],
  10270. 'accountMsg' => $abDetail ['accountMsg'],
  10271. 'aid' => $abDetail ['aid'],
  10272. 'inComePrice' => $abDetail ['receivedPrice'],
  10273. 'expensesType' => $abDetail ['expensesType']
  10274. );
  10275. $accountBookStatistics->setAccountBookStatistics ( $item );
  10276. // 添加收入流水
  10277. $wasteBook = new wasteBook ();
  10278. $itemWaste = array (
  10279. 'accountPriceShow' => $receivedPrice,
  10280. 'accountPrice' => $receivedPrice,
  10281. 'expensesType' => 1,
  10282. 'accountType' => 6, // 流水类型
  10283. 'dataID' => $inComeId,
  10284. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10285. 'accountBank' => $accountBank,
  10286. 'category' => $this->staff [0] ['category'],
  10287. 'cid' => $this->staff [0] ['cid'],
  10288. 'name' => $this->staff [0] ['username'],
  10289. 'sid' => $this->staff [0] ['sid'],
  10290. 'inputDate' => date ( "Y-m-d H:i:s" )
  10291. );
  10292. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10293. // 添加一条理财支出
  10294. $accountBank = 'CGBDeposit';
  10295. $expenditureBank = '纵横广发';
  10296. $dailyExpenditureType = 4;
  10297. if ($accountType == 9) {
  10298. $accountBank = 'ICBCDeposit';
  10299. $expenditureBank = '纵横工行';
  10300. $dailyExpenditureType = 6;
  10301. }
  10302. $accountBook = new accountBook ();
  10303. $accountBook->expensesType = 2;
  10304. $accountBook->expenditureType = $dailyExpenditureType;
  10305. $accountBook->expenditureMsg = $accountMsg;
  10306. $accountBook->expenditurePrice = $receivedPrice;
  10307. $accountBook->expenditureBank = $expenditureBank;
  10308. $accountBook->expenditureDate = $receivedDate;
  10309. $accountBook->remarks = $remarks;
  10310. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10311. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10312. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10313. $id = $accountBook->insert ();
  10314. // 收支汇总-添加一条理财支出汇总
  10315. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10316. $accountBookStatistics = new accountBookStatistics ();
  10317. $item = array (
  10318. 'date' => date ( "Y-m-d" ),
  10319. 'accountType' => $abDetail ['accountType'],
  10320. 'accountMsg' => $abDetail ['accountMsg'],
  10321. 'aid' => $abDetail ['aid'],
  10322. 'financingPrice' => - $receivedPrice,
  10323. 'expensesType' => 3
  10324. );
  10325. $accountBookStatistics->setAccountBookStatistics ( $item );
  10326. // 添加一条支出理财流水
  10327. $accountTypeWaste = 5;
  10328. if ($accountMsg == '公司固定') {
  10329. $accountTypeWaste = 9;
  10330. } elseif ($accountMsg == '公司活期') {
  10331. $accountTypeWaste = 10;
  10332. } elseif ($accountMsg == '个人(GR)') {
  10333. $accountBank = 'PersonalDeposit';
  10334. }
  10335. $itemWaste = array (
  10336. 'expensesType' => 2,
  10337. 'accountType' => $accountTypeWaste,
  10338. 'accountPriceShow' => $receivedPrice,
  10339. 'accountPrice' => - $receivedPrice,
  10340. 'dataID' => $id,
  10341. 'dailyExpenditureType' => $dailyExpenditureType,
  10342. 'accountBank' => $accountBank,
  10343. 'category' => $this->staff [0] ['category'],
  10344. 'cid' => $this->staff [0] ['cid'],
  10345. 'name' => $this->staff [0] ['username'],
  10346. 'sid' => $this->staff [0] ['sid'],
  10347. 'inputDate' => date ( "Y-m-d H:i:s" )
  10348. );
  10349. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10350. } elseif ($accountType == 1) {
  10351. if ($receivedBank == '个人广发')
  10352. die ( 'illegal request' );
  10353. // 添加一条收入
  10354. $accountBook = new accountBook ();
  10355. $accountBook->accountType = $accountType;
  10356. $accountBook->accountMsg = $accountMsg;
  10357. $accountBook->receivedPrice = $receivedPrice;
  10358. $accountBook->receivedMsg = $receivedMsg;
  10359. $accountBook->receivedBank = $receivedBank;
  10360. $accountBook->receivedDate = $receivedDate;
  10361. $accountBook->remarks = $remarks;
  10362. $accountBook->expensesType = 1;
  10363. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10364. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10365. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10366. $id = $accountBook->insert ();
  10367. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10368. // 收支汇总-添加一条收入日常汇总
  10369. $accountBookStatistics = new accountBookStatistics ();
  10370. $item = array (
  10371. 'date' => date ( "Y-m-d" ),
  10372. 'accountType' => $abDetail ['accountType'],
  10373. 'accountMsg' => $abDetail ['accountMsg'],
  10374. 'aid' => $abDetail ['aid'],
  10375. 'expensesType' => $abDetail ['expensesType']
  10376. );
  10377. if ($abDetail ['accountType'] == 8) {
  10378. $item += array (
  10379. 'inComePrice' => $abDetail ['receivedPrice']
  10380. );
  10381. } else {
  10382. $item += array (
  10383. 'inComePrice' => $abDetail ['receivedPrice']
  10384. );
  10385. }
  10386. $accountBookStatistics->setAccountBookStatistics ( $item );
  10387. // 流水存储方向
  10388. $itemWaste = array (
  10389. 'accountType' => 6
  10390. ); // 流水类型
  10391. // if($accountMsg=='银行存款'||$accountMsg=='固定理财收益'){
  10392. // }else
  10393. if ($accountMsg == '活期理财收益') {
  10394. $itemWaste = array (
  10395. 'accountType' => 10
  10396. ); // 流水类型
  10397. }
  10398. // 添加收入流水
  10399. $wasteBook = new wasteBook ();
  10400. $itemWaste += array (
  10401. 'accountPrice' => $receivedPrice,
  10402. 'accountPriceShow' => $receivedPrice,
  10403. 'expensesType' => 1,
  10404. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10405. 'dataID' => $id,
  10406. 'accountBank' => $accountBank,
  10407. 'category' => $this->staff [0] ['category'],
  10408. 'cid' => $this->staff [0] ['cid'],
  10409. 'name' => $this->staff [0] ['username'],
  10410. 'sid' => $this->staff [0] ['sid'],
  10411. 'inputDate' => date ( "Y-m-d H:i:s" )
  10412. );
  10413. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10414. } else { // 普通日常收入处理
  10415. // 添加一条收入
  10416. $accountBook = new accountBook ();
  10417. $accountBook->accountType = $accountType;
  10418. $accountBook->accountMsg = $accountMsg;
  10419. $accountBook->receivedPrice = $receivedPrice;
  10420. $accountBook->receivedMsg = $receivedMsg;
  10421. $accountBook->receivedBank = $receivedBank;
  10422. $accountBook->receivedDate = $receivedDate;
  10423. $accountBook->remarks = $remarks;
  10424. $accountBook->expensesType = 1;
  10425. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10426. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10427. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10428. $id = $accountBook->insert ();
  10429. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10430. // 收支汇总-添加一条收入日常汇总
  10431. $accountBookStatistics = new accountBookStatistics ();
  10432. $item = array (
  10433. 'date' => date ( "Y-m-d" ),
  10434. 'accountType' => $abDetail ['accountType'],
  10435. 'accountMsg' => $abDetail ['accountMsg'],
  10436. 'aid' => $abDetail ['aid'],
  10437. 'expensesType' => $abDetail ['expensesType']
  10438. );
  10439. if ($abDetail ['accountType'] == 8) {
  10440. $item += array (
  10441. 'inComePrice' => $abDetail ['receivedPrice']
  10442. );
  10443. } else {
  10444. $item += array (
  10445. 'inComePrice' => $abDetail ['receivedPrice']
  10446. );
  10447. }
  10448. $accountBookStatistics->setAccountBookStatistics ( $item );
  10449. // 添加收入流水
  10450. $itemWaste = array (
  10451. 'accountPrice' => $receivedPrice
  10452. );
  10453. if ($receivedBank == '个人广发') {
  10454. $itemWaste = array (
  10455. 'accountPrice' => - $receivedPrice
  10456. );
  10457. }
  10458. $wasteBook = new wasteBook ();
  10459. $itemWaste += array (
  10460. 'accountPriceShow' => $receivedPrice,
  10461. 'expensesType' => 1,
  10462. 'accountType' => 6, // 流水类型
  10463. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10464. 'dataID' => $id,
  10465. 'accountBank' => $accountBank,
  10466. 'category' => $this->staff [0] ['category'],
  10467. 'cid' => $this->staff [0] ['cid'],
  10468. 'name' => $this->staff [0] ['username'],
  10469. 'sid' => $this->staff [0] ['sid'],
  10470. 'inputDate' => date ( "Y-m-d H:i:s" )
  10471. );
  10472. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10473. }
  10474. }
  10475. return '/payments';
  10476. }
  10477. /**
  10478. * 添加收入
  10479. * @return string
  10480. */
  10481. function paymentsIncomeDo_() {
  10482. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10483. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10484. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10485. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10486. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10487. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10488. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10489. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10490. Doo::loadClass ( 'XDeode' );
  10491. $XDeode = new XDeode ( 5 );
  10492. Doo::loadModel ( "accountBook" );
  10493. $accountBook = new accountBook ();
  10494. $accountBank = '';
  10495. $accountTypeWaste = 6;
  10496. if ($receivedBank == '纵横广发') {
  10497. $accountBank = 'CGBDeposit';
  10498. } elseif ($receivedBank == '纵横工行') {
  10499. $accountBank = 'ICBCDeposit';
  10500. } elseif ($receivedBank == '华润银行') {
  10501. $accountBank = 'HUADeposit';
  10502. } elseif ($receivedBank == '个人广发') {
  10503. $accountBank = 'PersonalDeposit';
  10504. }
  10505. if (empty ( $accountBank ))
  10506. die ( 'illegal request' );
  10507. $dailyIncomeType = '';
  10508. $itemWaste = array (
  10509. 'accountPrice' => $receivedPrice,
  10510. 'expensesType' => 1
  10511. );
  10512. if ($receivedBank == '个人广发') {
  10513. $itemWaste = array (
  10514. 'accountPrice' => - $receivedPrice,
  10515. 'expensesType' => 1
  10516. );
  10517. }
  10518. if ($accountType == 4) {
  10519. $dailyIncomeType = 4;
  10520. } elseif ($accountType == 1) {
  10521. $dailyIncomeType = 1;
  10522. } elseif ($accountType == 2) {
  10523. $dailyIncomeType = 2;
  10524. } elseif ($accountType == 3) {
  10525. $dailyIncomeType = 3;
  10526. } elseif ($accountType == 5) {
  10527. $dailyIncomeType = 5;
  10528. } elseif ($accountType == 6) {
  10529. $dailyIncomeType = 6;
  10530. } elseif ($accountType == 7 || $accountType == 9) {
  10531. $dailyIncomeType = 7;
  10532. if ($accountMsg == '公司固定') {
  10533. $accountTypeWaste = 9;
  10534. } elseif ($accountMsg == '公司活期') {
  10535. $accountTypeWaste = 10;
  10536. } elseif ($accountMsg == '个人(GR)') {
  10537. $accountBank = 'PersonalDeposit';
  10538. }
  10539. $itemWaste = array (
  10540. 'accountPrice' => - $receivedPrice,
  10541. 'expensesType' => 2
  10542. );
  10543. } elseif ($accountType == 8) {
  10544. $dailyIncomeType = 8;
  10545. }
  10546. if (empty ( $dailyIncomeType ))
  10547. die ( 'illegal request' );
  10548. $accountBook->accountType = $accountType;
  10549. $accountBook->accountMsg = $accountMsg;
  10550. $accountBook->receivedPrice = $receivedPrice;
  10551. $accountBook->receivedMsg = $receivedMsg;
  10552. $accountBook->receivedBank = $receivedBank;
  10553. $accountBook->receivedDate = $receivedDate;
  10554. $accountBook->remarks = $remarks;
  10555. $accountBook->expensesType = 1;
  10556. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10557. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10558. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10559. $id = $accountBook->insert ();
  10560. //
  10561. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10562. // 收支汇总
  10563. Doo::loadModel ( "accountBookStatistics" );
  10564. $accountBookStatistics = new accountBookStatistics ();
  10565. $item = array (
  10566. 'date' => date ( "Y-m-d" ),
  10567. 'accountType' => $abDetail ['accountType'],
  10568. 'accountMsg' => $abDetail ['accountMsg'],
  10569. 'aid' => $abDetail ['aid']
  10570. );
  10571. if ($abDetail ['expensesType'] == 1) {
  10572. if ($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) {
  10573. $item += array (
  10574. 'financingPrice' => - $receivedPrice,
  10575. 'expensesType' => 3
  10576. );
  10577. } else if ($abDetail ['accountType'] == 8) {
  10578. $item += array (
  10579. 'inComePrice' => - $abDetail ['receivedPrice'],
  10580. 'expensesType' => $abDetail ['expensesType']
  10581. );
  10582. } else {
  10583. $item += array (
  10584. 'inComePrice' => $abDetail ['receivedPrice'],
  10585. 'expensesType' => $abDetail ['expensesType']
  10586. );
  10587. }
  10588. }
  10589. $accountBookStatistics->setAccountBookStatistics ( $item );
  10590. // 为理财时需添加一条日常支出
  10591. if ($accountType == 7 || $accountType == 9) {
  10592. }
  10593. // 公司流水记录
  10594. Doo::loadModel ( 'wasteBook' );
  10595. $wasteBook = new wasteBook ();
  10596. // 银行
  10597. // if (empty($abDetail)){
  10598. $itemWaste += array (
  10599. 'accountPriceShow' => $receivedPrice,
  10600. 'dataID' => $id,
  10601. 'accountType' => $accountTypeWaste,
  10602. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10603. 'accountBank' => $accountBank,
  10604. 'category' => $this->staff [0] ['category'],
  10605. 'cid' => $this->staff [0] ['cid'],
  10606. 'name' => $this->staff [0] ['username'],
  10607. 'sid' => $this->staff [0] ['sid'],
  10608. 'inputDate' => date ( "Y-m-d H:i:s" )
  10609. );
  10610. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10611. // }
  10612. // 类型为理财7或者9 要添加一笔理财支出
  10613. if ($accountType == 7 || $accountType == 9) {
  10614. $accountBank = 'CGBDeposit';
  10615. $expenditureBank = '纵横广发';
  10616. $dailyExpenditureType = 4;
  10617. if ($accountType == 9) {
  10618. $accountBank = 'ICBCDeposit';
  10619. $expenditureBank = '纵横工行';
  10620. $dailyExpenditureType = 6;
  10621. }
  10622. // 添加一条支出
  10623. $accountBook = new accountBook ();
  10624. $accountBook->expenditureType = $dailyExpenditureType;
  10625. $accountBook->expenditureMsg = $accountMsg;
  10626. $accountBook->expenditurePrice = $receivedPrice;
  10627. $accountBook->expenditureBank = $expenditureBank;
  10628. $accountBook->expenditureDate = $receivedDate;
  10629. $accountBook->remarks = $remarks;
  10630. $accountBook->expensesType = 2;
  10631. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10632. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10633. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10634. $id = $accountBook->insert ();
  10635. // 添加一条收入流水
  10636. $itemWaste = array (
  10637. 'accountPriceShow' => $receivedPrice,
  10638. 'accountPrice' => $receivedPrice,
  10639. 'dataID' => $id,
  10640. 'expensesType' => 2,
  10641. 'accountType' => $accountTypeWaste,
  10642. 'dailyExpenditureType' => $dailyExpenditureType,
  10643. 'accountBank' => $accountBank,
  10644. 'category' => $this->staff [0] ['category'],
  10645. 'cid' => $this->staff [0] ['cid'],
  10646. 'name' => $this->staff [0] ['username'],
  10647. 'sid' => $this->staff [0] ['sid'],
  10648. 'inputDate' => date ( "Y-m-d H:i:s" )
  10649. );
  10650. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10651. }
  10652. }
  10653. return '/payments';
  10654. }
  10655. function paymentsExpenditureDo() {
  10656. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10657. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10658. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10659. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10660. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10661. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10662. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10663. // 理财支出特殊处理
  10664. Doo::loadModel ( "accountBook" );
  10665. Doo::loadModel ( "accountBookStatistics" );
  10666. Doo::loadModel ( 'wasteBook' );
  10667. $accountBank = '';
  10668. if ($expenditureBank == '纵横广发') {
  10669. $accountBank = 'CGBDeposit';
  10670. } elseif ($expenditureBank == '纵横工行') {
  10671. $accountBank = 'ICBCDeposit';
  10672. } elseif ($expenditureBank == '华润银行') {
  10673. $accountBank = 'HUADeposit';
  10674. } elseif ($expenditureBank == '个人广发') {
  10675. $accountBank = 'PersonalDeposit';
  10676. }
  10677. if (empty ( $accountBank ))
  10678. die ( 'illegal request' );
  10679. if ($expenditureType == 4 || $expenditureType == 6) {
  10680. if ($expenditureBank == '个人广发') {
  10681. die ( '个人广发 illegal request' );
  10682. }
  10683. // 添加一笔日常支出
  10684. $accountBook = new accountBook ();
  10685. $accountBook->expensesType = 2;
  10686. $accountBook->expenditureType = 7;
  10687. $accountBook->expenditureMsg = $expenditureMsg;
  10688. $accountBook->expenditurePrice = $expenditurePrice;
  10689. $accountBook->expenditureBank = $expenditureBank;
  10690. $accountBook->expenditureDate = $expenditureDate;
  10691. $accountBook->remarks = $remarks;
  10692. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10693. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10694. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10695. $expenditureId = $accountBook->insert ();
  10696. // 添加日常支出汇总
  10697. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  10698. $accountBookStatistics = new accountBookStatistics ();
  10699. $item = array (
  10700. 'date' => date ( "Y-m-d" ),
  10701. 'expenditureType' => $abDetail ['expenditureType'],
  10702. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10703. 'aid' => $abDetail ['aid'],
  10704. 'payPrice' => $abDetail ['expenditurePrice'],
  10705. 'expensesType' => $abDetail ['expensesType']
  10706. );
  10707. $accountBookStatistics->setAccountBookStatistics ( $item );
  10708. // 公司日常支出流水
  10709. $wasteBook = new wasteBook ();
  10710. $itemWaste = array (
  10711. 'accountPrice' => - $expenditurePrice
  10712. );
  10713. if ($expenditureBank == '个人广发') {
  10714. $itemWaste = array (
  10715. 'accountPrice' => $expenditurePrice
  10716. );
  10717. }
  10718. $itemWaste += array (
  10719. 'expensesType' => 2,
  10720. 'accountType' => 5,
  10721. 'dailyExpenditureType' => $expenditureType,
  10722. 'accountPriceShow' => $expenditurePrice,
  10723. 'accountPrice' => - $expenditurePrice,
  10724. 'dataID' => $expenditureId,
  10725. 'accountBank' => $accountBank,
  10726. 'category' => $this->staff [0] ['category'],
  10727. 'cid' => $this->staff [0] ['cid'],
  10728. 'name' => $this->staff [0] ['username'],
  10729. 'sid' => $this->staff [0] ['sid'],
  10730. 'inputDate' => date ( "Y-m-d H:i:s" )
  10731. );
  10732. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10733. // 添加一笔理财收入
  10734. $accountBank = 'CGBDeposit';
  10735. $dailyIncomeType = 7;
  10736. $receivedBank = '纵横广发';
  10737. if ($expenditureType == 6) {
  10738. $accountBank = 'ICBCDeposit';
  10739. $receivedBank = '纵横工行';
  10740. $dailyIncomeType = 9;
  10741. }
  10742. $accountBook = new accountBook ();
  10743. $accountBook->expensesType = 1;
  10744. $accountBook->accountType = $dailyIncomeType;
  10745. $accountBook->accountMsg = $expenditureMsg;
  10746. $accountBook->receivedPrice = $expenditurePrice;
  10747. $accountBook->receivedBank = $receivedBank;
  10748. $accountBook->receivedDate = $expenditureDate;
  10749. $accountBook->remarks = $remarks;
  10750. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10751. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10752. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10753. $id = $accountBook->insert ();
  10754. // 添加日常理财收入汇总
  10755. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  10756. $accountBookStatistics = new accountBookStatistics ();
  10757. $item = array (
  10758. 'date' => date ( "Y-m-d" ),
  10759. 'expenditureType' => $abDetail ['expenditureType'],
  10760. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10761. 'aid' => $abDetail ['aid'],
  10762. 'financingPrice' => $expenditurePrice,
  10763. 'expensesType' => 3
  10764. );
  10765. $accountBookStatistics->setAccountBookStatistics ( $item );
  10766. // 添加一笔收入流水
  10767. if ($expenditureMsg == '公司固定') {
  10768. $accountTypeWaste = 9;
  10769. } elseif ($expenditureMsg == '公司活期') {
  10770. $accountTypeWaste = 10;
  10771. } elseif ($expenditureMsg == '个人(GR)') {
  10772. $accountBank = 'PersonalDeposit';
  10773. }
  10774. $itemWaste = array (
  10775. 'expensesType' => 1,
  10776. 'accountType' => $accountTypeWaste,
  10777. 'accountPriceShow' => $expenditurePrice,
  10778. 'accountPrice' => $expenditurePrice,
  10779. 'dataID' => $id,
  10780. 'dailyIncomeType' => $dailyIncomeType,
  10781. 'accountBank' => $accountBank,
  10782. 'category' => $this->staff [0] ['category'],
  10783. 'cid' => $this->staff [0] ['cid'],
  10784. 'name' => $this->staff [0] ['username'],
  10785. 'sid' => $this->staff [0] ['sid'],
  10786. 'inputDate' => date ( "Y-m-d H:i:s" )
  10787. );
  10788. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10789. } else {
  10790. // 添加一笔日常支出
  10791. $accountBook = new accountBook ();
  10792. $accountBook->expensesType = 2;
  10793. $accountBook->expenditureType = $expenditureType;
  10794. $accountBook->expenditureMsg = $expenditureMsg;
  10795. $accountBook->expenditurePrice = $expenditurePrice;
  10796. $accountBook->expenditureBank = $expenditureBank;
  10797. $accountBook->expenditureDate = $expenditureDate;
  10798. $accountBook->remarks = $remarks;
  10799. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10800. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10801. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10802. $id = $accountBook->insert ();
  10803. // 添加日常支出汇总
  10804. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10805. $accountBookStatistics = new accountBookStatistics ();
  10806. $item = array (
  10807. 'date' => date ( "Y-m-d" ),
  10808. 'expenditureType' => $abDetail ['expenditureType'],
  10809. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10810. 'aid' => $abDetail ['aid'],
  10811. 'expensesType' => $abDetail ['expensesType']
  10812. );
  10813. if ($expenditureType == 5) {
  10814. $item += array (
  10815. 'payPrice' => - $abDetail ['expenditurePrice']
  10816. );
  10817. } else {
  10818. $item += array (
  10819. 'payPrice' => $abDetail ['expenditurePrice']
  10820. );
  10821. }
  10822. $accountBookStatistics->setAccountBookStatistics ( $item );
  10823. // 公司日常支出流水
  10824. $wasteBook = new wasteBook ();
  10825. $itemWaste = array (
  10826. 'accountPrice' => - $expenditurePrice
  10827. );
  10828. if ($expenditureBank == '个人广发') {
  10829. $itemWaste = array (
  10830. 'accountPrice' => $expenditurePrice
  10831. );
  10832. }
  10833. $itemWaste += array (
  10834. 'expensesType' => 2,
  10835. 'accountType' => 5,
  10836. 'accountPriceShow' => $expenditurePrice,
  10837. 'dataID' => $id,
  10838. 'dailyExpenditureType' => $expenditureType,
  10839. 'accountBank' => $accountBank,
  10840. 'category' => $this->staff [0] ['category'],
  10841. 'cid' => $this->staff [0] ['cid'],
  10842. 'name' => $this->staff [0] ['username'],
  10843. 'sid' => $this->staff [0] ['sid'],
  10844. 'inputDate' => date ( "Y-m-d H:i:s" )
  10845. );
  10846. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10847. }
  10848. }
  10849. return '/payments';
  10850. }
  10851. /**
  10852. * 添加支出
  10853. */
  10854. function paymentsExpenditureDo_() {
  10855. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10856. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10857. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10858. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10859. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10860. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10861. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10862. $dailyExpenditureType = '';
  10863. $accountTypeWaste = 5;
  10864. $accountBank = '';
  10865. if ($expenditureBank == '纵横广发') {
  10866. $accountBank = 'CGBDeposit';
  10867. } elseif ($expenditureBank == '纵横工行') {
  10868. $accountBank = 'ICBCDeposit';
  10869. } elseif ($expenditureBank == '华润银行') {
  10870. $accountBank = 'HUADeposit';
  10871. } elseif ($expenditureBank == '个人广发') {
  10872. $accountBank = 'PersonalDeposit';
  10873. }
  10874. if (empty ( $accountBank ))
  10875. die ( 'illegal request' );
  10876. $itemWaste = array (
  10877. 'accountPrice' => - $expenditurePrice
  10878. );
  10879. if ($expenditureBank == '个人广发') {
  10880. $itemWaste = array (
  10881. 'accountPrice' => $expenditurePrice
  10882. );
  10883. }
  10884. if ($expenditureType == 4 || $expenditureType == 6) {
  10885. $dailyExpenditureType = 4;
  10886. if ($expenditureMsg == '公司固定') {
  10887. $accountTypeWaste = 9;
  10888. } elseif ($expenditureMsg == '公司活期') {
  10889. $accountTypeWaste = 10;
  10890. } elseif ($expenditureMsg == '个人(GR)') {
  10891. $accountBank = 'PersonalDeposit';
  10892. }
  10893. $itemWaste = array (
  10894. 'accountPrice' => $expenditurePrice
  10895. );
  10896. } elseif ($expenditureType == 1) {
  10897. $dailyExpenditureType = 1;
  10898. } elseif ($expenditureType == 2) {
  10899. $dailyExpenditureType = 2;
  10900. } elseif ($expenditureType == 3) {
  10901. $dailyExpenditureType = 3;
  10902. } elseif ($expenditureType == 5) {
  10903. $dailyExpenditureType = 5;
  10904. }
  10905. if (empty ( $dailyExpenditureType ))
  10906. die ( 'illegal request' );
  10907. Doo::loadModel ( "accountBook" );
  10908. $accountBook = new accountBook ();
  10909. $accountBook->expenditureType = $expenditureType;
  10910. $accountBook->expenditureMsg = $expenditureMsg;
  10911. $accountBook->expenditurePrice = $expenditurePrice;
  10912. $accountBook->expenditureBank = $expenditureBank;
  10913. $accountBook->expenditureDate = $expenditureDate;
  10914. $accountBook->remarks = $remarks;
  10915. $accountBook->expensesType = 2;
  10916. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10917. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10918. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10919. $id = $accountBook->insert ();
  10920. //
  10921. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10922. Doo::loadModel ( "accountBookStatistics" );
  10923. $accountBookStatistics = new accountBookStatistics ();
  10924. $item = array (
  10925. 'date' => date ( "Y-m-d" ),
  10926. 'expenditureType' => $abDetail ['expenditureType'],
  10927. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10928. 'aid' => $abDetail ['aid']
  10929. );
  10930. if ($abDetail ['expensesType'] == 2) {
  10931. if ($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) {
  10932. $item += array (
  10933. 'financingPrice' => $expenditurePrice,
  10934. 'expensesType' => 3
  10935. );
  10936. } elseif ($abDetail ['expenditureType'] == 5) {
  10937. $item += array (
  10938. 'payPrice' => $abDetail ['expenditurePrice'],
  10939. 'expensesType' => $abDetail ['expensesType']
  10940. );
  10941. } else {
  10942. $item += array (
  10943. 'payPrice' => $abDetail ['expenditurePrice'],
  10944. 'expensesType' => $abDetail ['expensesType']
  10945. );
  10946. }
  10947. }
  10948. $accountBookStatistics->setAccountBookStatistics ( $item );
  10949. // 公司流水记录
  10950. Doo::loadModel ( 'wasteBook' );
  10951. $wasteBook = new wasteBook ();
  10952. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountTypeWaste, $id );
  10953. // 银行
  10954. if (empty ( $abDetail )) {
  10955. $itemWaste += array (
  10956. 'accountPriceShow' => $expenditurePrice,
  10957. 'dataID' => $id,
  10958. 'expensesType' => 2,
  10959. 'accountType' => $accountTypeWaste,
  10960. 'dailyExpenditureType' => $expenditureType,
  10961. 'accountBank' => $accountBank,
  10962. 'category' => $this->staff [0] ['category'],
  10963. 'cid' => $this->staff [0] ['cid'],
  10964. 'name' => $this->staff [0] ['username'],
  10965. 'sid' => $this->staff [0] ['sid'],
  10966. 'inputDate' => date ( "Y-m-d H:i:s" )
  10967. );
  10968. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10969. }
  10970. // 支出类型为4或者6 需要添加一笔收入和收入流水
  10971. if ($expenditureType == 4 || $expenditureType == 6) {
  10972. $accountBank = 'CGBDeposit';
  10973. $dailyIncomeType = 7;
  10974. $receivedBank = '纵横广发';
  10975. if ($expenditureType == 6) {
  10976. $accountBank = 'ICBCDeposit';
  10977. $receivedBank = '纵横工行';
  10978. $dailyIncomeType = 9;
  10979. }
  10980. // 添加一笔收入
  10981. $accountBook = new accountBook ();
  10982. $accountBook->accountType = $dailyIncomeType;
  10983. $accountBook->accountMsg = $expenditureMsg;
  10984. $accountBook->receivedPrice = $expenditurePrice;
  10985. $accountBook->receivedBank = $receivedBank;
  10986. $accountBook->receivedDate = $expenditureDate;
  10987. $accountBook->remarks = $remarks;
  10988. $accountBook->expensesType = 1;
  10989. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10990. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10991. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10992. $id = $accountBook->insert ();
  10993. // 添加一笔收入流水
  10994. $itemWaste = array (
  10995. 'accountPriceShow' => $expenditurePrice,
  10996. 'accountPrice' => - $expenditurePrice,
  10997. 'dataID' => $id,
  10998. 'expensesType' => 1,
  10999. 'accountType' => $accountTypeWaste,
  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. }
  11010. }
  11011. return '/payments';
  11012. }
  11013. /**
  11014. * 所有收支
  11015. */
  11016. function paymentsAchieve() {
  11017. $page_size = 12;
  11018. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  11019. $expensesType = isset ( $this->params ['expensesType'] ) ? $this->params ['expensesType'] : 'ALL';
  11020. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11021. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  11022. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11023. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11024. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11025. $submitType = $this->get_args ( 'submitType' ) ? $this->get_args ( 'submitType' ) : "";
  11026. Doo::loadModel ( "accountBookStatistics" );
  11027. $accountBookStatistics = new accountBookStatistics ();
  11028. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  11029. $data ['statisticsList'] = $statisticsList;
  11030. Doo::loadModel ( "accountBook" );
  11031. $accountBook = new accountBook ();
  11032. $con = '';
  11033. if ($expensesType == 'INCOME')
  11034. $con = ' and expensesType=1 ';
  11035. elseif ($expensesType == 'PAY')
  11036. $con = ' and expensesType=2 ';
  11037. $dateArr = explode ( ':', $date );
  11038. $D1 = $dateString = '';
  11039. $D2 = '';
  11040. if (! empty ( $date )) {
  11041. $D1 = $dateArr [0];
  11042. if (isset ( $dateArr [1] ))
  11043. $D2 = $dateArr [1];
  11044. else
  11045. $D2 = '';
  11046. $dateString = $D1 . " : " . $D2;
  11047. }
  11048. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11049. $con .= ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11050. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11051. $con .= ' and inputDate like "%' . $D1 . '%" ';
  11052. if (! empty ( $price ))
  11053. $con .= ' and (receivedPrice=' . $price . ' or expenditurePrice=' . $price . ')';
  11054. if ($submitType == 1) {
  11055. if ($accountType != '') {
  11056. $expenditureType = '';
  11057. $con .= ' and accountType=' . $accountType;
  11058. if (! empty ( $accountMsg ))
  11059. $con .= ' and (accountType=' . $accountType . ' and accountMsg like "%' . $accountMsg . '%")';
  11060. }
  11061. } elseif ($submitType == 2) {
  11062. if ($expenditureType != '') {
  11063. $accountType = $accountMsg = '';
  11064. $con .= ' and expenditureType=' . $expenditureType;
  11065. }
  11066. } else {
  11067. $accountType = $accountMsg = $expenditureType = '';
  11068. }
  11069. $sql = "" . $con;
  11070. $action = "paymentsAchieve";
  11071. $get = '/' . $expensesType; // "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  11072. $pageinfo = $this->get_page ( "CLD_accountBook", $sql, $page, $page_size, $action, $get, "" );
  11073. $limit = $pageinfo ['lower'] . ',' . $page_size;
  11074. $list = $accountBook->getAccountBookBySql ( $limit, $sql, 'desc' );
  11075. $data ['expenditureType'] = $expenditureType;
  11076. $data ['accountMsg'] = $accountMsg;
  11077. $data ['accountType'] = $accountType;
  11078. $data ['inputDate'] = $date;
  11079. $data ['price'] = $price;
  11080. $data ['expensesType'] = $expensesType;
  11081. $data ['page'] = $pageinfo;
  11082. $data ['list'] = $list;
  11083. $data ['memu'] = "receipt";
  11084. $data ['staff'] = $this->staff;
  11085. $data ['receiptMemu'] = 'payments';
  11086. $data ['verifyId'] = $this->verifyId;
  11087. $data ['executeId'] = $this->executeId;
  11088. $this->render ( "/expenses/paymentsAchieve", $data );
  11089. }
  11090. function paymentsIncomeUpdateDo() {
  11091. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11092. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11093. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11094. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  11095. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  11096. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  11097. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  11098. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11099. if (! empty ( $aidKey ) && ! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  11100. Doo::loadClass ( 'XDeode' );
  11101. $XDeode = new XDeode ( 5 );
  11102. $aid = $XDeode->decode ( $aidKey );
  11103. Doo::loadModel ( "accountBook" );
  11104. $accountBook = new accountBook ();
  11105. //
  11106. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11107. $price = $receivedPrice - $abDetail [inComePrice];
  11108. Doo::loadModel ( "accountBookStatistics" );
  11109. $accountBookStatistics = new accountBookStatistics ();
  11110. if ($abDetail ['accountType'] == 7) {
  11111. $item += array (
  11112. 'date' => date ( "Y-m-d" ),
  11113. 'financingPrice' => - $price,
  11114. 'expensesType' => 3,
  11115. 'aid' => $abDetail ['aid']
  11116. );
  11117. } elseif ($abDetail ['accountType'] == 8) {
  11118. $item += array (
  11119. 'date' => date ( "Y-m-d" ),
  11120. 'expensesType' => $abDetail ['expensesType'],
  11121. 'inComePrice' => - $price,
  11122. 'aid' => $abDetail ['aid']
  11123. );
  11124. } else {
  11125. $item = array (
  11126. 'date' => date ( "Y-m-d" ),
  11127. 'expensesType' => $abDetail ['expensesType'],
  11128. 'inComePrice' => $price,
  11129. 'aid' => $abDetail ['aid']
  11130. );
  11131. }
  11132. $accountBookStatistics->setAccountBookStatistics ( $item );
  11133. $accountBook->accountType = $accountType;
  11134. $accountBook->accountMsg = $accountMsg;
  11135. $accountBook->receivedPrice = $receivedPrice;
  11136. $accountBook->receivedMsg = $receivedMsg;
  11137. $accountBook->receivedBank = $receivedBank;
  11138. $accountBook->receivedDate = $receivedDate;
  11139. $accountBook->remarks = $remarks;
  11140. $accountBook->aid = $aid;
  11141. $accountBook->update ();
  11142. }
  11143. return '/paymentsAchieve';
  11144. }
  11145. function paymentsExpenditureEdiDo() {
  11146. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11147. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11148. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11149. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11150. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11151. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11152. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11153. if (! empty ( $aidKey ) && ! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11154. Doo::loadClass ( 'XDeode' );
  11155. $XDeode = new XDeode ( 5 );
  11156. $aid = $XDeode->decode ( $aidKey );
  11157. Doo::loadModel ( "accountBook" );
  11158. $accountBook = new accountBook ();
  11159. // 汇总信息
  11160. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11161. $price = $expenditurePrice - $abDetail [expenditurePrice];
  11162. Doo::loadModel ( "accountBookStatistics" );
  11163. $accountBookStatistics = new accountBookStatistics ();
  11164. if ($abDetail ['expenditureType'] == 4) {
  11165. $item += array (
  11166. 'date' => date ( "Y-m-d" ),
  11167. 'financingPrice' => $price,
  11168. 'expensesType' => 3,
  11169. 'aid' => $abDetail ['aid']
  11170. );
  11171. } elseif ($abDetail ['expenditureType'] == 5) {
  11172. $item += array (
  11173. 'date' => date ( "Y-m-d" ),
  11174. 'expensesType' => $abDetail ['expensesType'],
  11175. 'payPrice' => $price,
  11176. 'aid' => $abDetail ['aid']
  11177. );
  11178. } else {
  11179. $item = array (
  11180. 'date' => date ( "Y-m-d" ),
  11181. 'expensesType' => $abDetail ['expensesType'],
  11182. 'payPrice' => $price,
  11183. 'aid' => $abDetail ['aid']
  11184. );
  11185. }
  11186. $accountBookStatistics->setAccountBookStatistics ( $item );
  11187. //
  11188. $accountBook->expenditureType = $expenditureType;
  11189. $accountBook->expenditureMsg = $expenditureMsg;
  11190. $accountBook->expenditurePrice = $expenditurePrice;
  11191. $accountBook->expenditureBank = $expenditureBank;
  11192. $accountBook->remarks = $remarks;
  11193. $accountBook->expenditureDate = $expenditureDate;
  11194. $accountBook->aid = $aid;
  11195. $id = $accountBook->update ();
  11196. }
  11197. return '/paymentsAchieve';
  11198. }
  11199. function paymentsDelDo() {
  11200. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11201. if (! empty ( $aidKey )) {
  11202. Doo::loadClass ( 'XDeode' );
  11203. $XDeode = new XDeode ( 5 );
  11204. $aid = $XDeode->decode ( $aidKey );
  11205. Doo::loadModel ( "accountBook" );
  11206. $accountBook = new accountBook ();
  11207. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11208. if (empty ( $abDetail ))
  11209. die ( 'illegal request' );
  11210. // 删除收支
  11211. Doo::loadModel ( "accountBookStatistics" );
  11212. $accountBookStatistics = new accountBookStatistics ();
  11213. $item = array (
  11214. 'date' => date ( "Y-m-d" ),
  11215. 'aid' => $abDetail ['aid']
  11216. );
  11217. $accountType = '';
  11218. if ($abDetail ['expensesType'] == 1) {
  11219. $accountType = 6;
  11220. if ($abDetail ['accountType'] != 7) {
  11221. $item += array (
  11222. 'expensesType' => $abDetail ['expensesType'],
  11223. 'inComePrice' => - $abDetail ['receivedPrice']
  11224. );
  11225. } else {
  11226. $item += array (
  11227. 'financingPrice' => $abDetail ['receivedPrice'],
  11228. 'expensesType' => 3
  11229. );
  11230. }
  11231. } elseif ($abDetail ['expensesType'] == 2) {
  11232. $accountType = 5;
  11233. if ($abDetail ['accountType'] != 7) {
  11234. $item += array (
  11235. 'expensesType' => $abDetail ['expensesType'],
  11236. 'payPrice' => - $abDetail ['expenditurePrice']
  11237. );
  11238. } else {
  11239. $item += array (
  11240. 'financingPrice' => - $abDetail ['expenditurePrice'],
  11241. 'expensesType' => 3
  11242. );
  11243. }
  11244. }
  11245. if (($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) && $abDetail ['expensesType'] == 2) {
  11246. if ($abDetail ['expenditureMsg'] == '公司固定')
  11247. $accountType = 9;
  11248. elseif ($abDetail ['expenditureMsg'] == '公司活期')
  11249. $accountType = 10;
  11250. }
  11251. if (($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) && $abDetail ['expensesType'] == 1) {
  11252. if ($abDetail ['accountMsg'] == '公司固定')
  11253. $accountType = 9;
  11254. elseif ($abDetail ['accountMsg'] == '公司活期')
  11255. $accountType = 10;
  11256. }
  11257. if ($abDetail ['accountMsg'] == '活期理财收益') {
  11258. $accountType = 10;
  11259. }
  11260. $accountBookStatistics->setAccountBookStatistics ( $item );
  11261. $accountBook->delete ( array (
  11262. 'where' => 'aid=' . $aid,
  11263. 'limit' => 1
  11264. ) );
  11265. // 删除收入流水
  11266. if (! empty ( $accountType )) {
  11267. Doo::loadModel ( 'wasteBook' );
  11268. $wasteBook = new wasteBook ();
  11269. $wasteBook->delete ( array (
  11270. 'where' => 'dataID=' . $aid . ' and accountType=' . $accountType,
  11271. 'limit' => 1
  11272. ) );
  11273. }
  11274. }
  11275. return '/paymentsAchieve';
  11276. }
  11277. function paymentsCollect() {
  11278. Doo::loadModel ( "execute" );
  11279. $execute = new execute ();
  11280. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11281. die ( 'illegal request' );
  11282. }
  11283. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11284. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  11285. Doo::loadModel ( "accountBookStatistics" );
  11286. $accountBookStatistics = new accountBookStatistics ();
  11287. Doo::loadClass ( 'receipt.func' );
  11288. $statisticsIncome = $accountBookStatistics->getStatisticsByCollect ( $year );
  11289. $html = _getPaymentsCollectByYearHtml ( $statisticsIncome );
  11290. $data ['html'] = $html ['html'];
  11291. $data ['inSum'] = $html ['sum'];
  11292. $statisticsPay = $accountBookStatistics->getStatisticsByCollect ( $year, 2 );
  11293. $html = _getPaymentsCollectPayByYearHtml ( $statisticsPay );
  11294. $data ['payHtml'] = $html ['html'];
  11295. $data ['paySum'] = $html ['sum'];
  11296. // 余额统计
  11297. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1 );
  11298. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2 );
  11299. include './protected/config/wasteBook.conf.php';
  11300. Doo::loadModel ( 'wasteBook' );
  11301. $wasteBook = new wasteBook ();
  11302. $inComePay = $wasteBook->getWasteBookByStatistics ( 1, $year );
  11303. $pay = $wasteBook->getWasteBookByStatistics ( 2, $year );
  11304. // 获得年份之前所有金额
  11305. $detail = $wasteBook->getWasteBookByStatisticsYear ( $year );
  11306. // print_r($detail);
  11307. // $waste['total'];
  11308. $lastBalanceHtml = '<tr><th colspan="2">截至上月余额</th>';
  11309. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11310. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11311. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11312. $inSum = $paySum = $showInSum = $showPaySum = $balanceSum = 0;
  11313. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11314. $limitMonth = date ( 'm' ); // 限制显示月份参数
  11315. if (date ( 'Y' ) > $year) {
  11316. $limitMonth = 12;
  11317. }
  11318. for($i = 1; $i <= 12; $i ++) {
  11319. $inComeA = $payB = 0;
  11320. $falg = true;
  11321. foreach ( $inComePay as $key => $value ) {
  11322. if ($value ['month'] == $i) {
  11323. $falg = false;
  11324. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11325. $inSum += $value ['accountPrice'];
  11326. $showInSum += $value ['accountPriceShow'];
  11327. $inComeA = $value ['accountPrice'];
  11328. break;
  11329. }
  11330. }
  11331. if ($falg)
  11332. $inComeHtml .= '<td class="taR">-</td>';
  11333. $payFalg = true;
  11334. foreach ( $pay as $key => $value ) {
  11335. if ($value ['month'] == $i) {
  11336. $payFalg = false;
  11337. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11338. $paySum += $value ['accountPrice'];
  11339. $showPaySum += $value ['accountPriceShow'];
  11340. $payB = $value ['accountPrice'];
  11341. break;
  11342. }
  11343. }
  11344. if ($payFalg)
  11345. $payHtml .= '<td class="taR">-</td>';
  11346. if (empty ( $balanceC ) || $limitMonth < $i)
  11347. $lastBalanceHtml .= '<td class="taR">-</td>';
  11348. else
  11349. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11350. $balanceC = $balanceC + $inComeA + $payB;
  11351. $balanceSum += $balanceC;
  11352. if (empty ( $balanceC ) || $limitMonth < $i)
  11353. $BalanceHtml .= '<td class="taR">-</td>';
  11354. else
  11355. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11356. // 余额统计
  11357. }
  11358. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11359. $data ['inComeHtml'] = $inComeHtml;
  11360. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11361. $data ['payBalanceHtml'] = $payHtml;
  11362. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11363. $data ['BalanceHtml'] = $BalanceHtml;
  11364. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11365. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11366. $mothHtml = "";
  11367. for($i = 1; $i <= 12; $i ++) {
  11368. if ($moth == $i)
  11369. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11370. else
  11371. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11372. }
  11373. $data ['mothHtml'] = $mothHtml;
  11374. $dateHtml = "";
  11375. $now = date ( "Y" );
  11376. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11377. if ($YEARD <= $now) {
  11378. $dateHtml .= '<option ';
  11379. if ($year == $YEARD) {
  11380. $dateHtml .= 'selected ';
  11381. }
  11382. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11383. }
  11384. }
  11385. $data ['dateHtml'] = $dateHtml;
  11386. $data ['year'] = $year;
  11387. $data ['memu'] = "receipt";
  11388. $data ['staff'] = $this->staff;
  11389. $data ['receiptMemu'] = 'paymentsCollect';
  11390. $data ['verifyId'] = $this->verifyId;
  11391. $data ['executeId'] = $this->executeId;
  11392. $this->render ( "/expenses/paymentsCollect", $data );
  11393. }
  11394. function paymentsCollectDay() {
  11395. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11396. $moth = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : '';
  11397. if (empty ( $moth ))
  11398. return 'paymentsCollect';
  11399. Doo::loadModel ( "accountBookStatistics" );
  11400. $accountBookStatistics = new accountBookStatistics ();
  11401. $i = 2;
  11402. $y = 2013;
  11403. $day = date ( "t", strtotime ( "$year-$moth" ) );
  11404. Doo::loadClass ( 'receipt.func' );
  11405. $statisticsIncome = $accountBookStatistics->getStatisticsByCollectDay ( $year, 1, $moth );
  11406. $html = _getPaymentsCollectByDayHtml ( $statisticsIncome, $day );
  11407. $data ['html'] = $html ['html'];
  11408. $data ['inSum'] = $html ['sum'];
  11409. $statisticsPay = $accountBookStatistics->getStatisticsByCollectDay ( $year, 2, $moth );
  11410. $html = _getPaymentsCollectPayByDayHtml ( $statisticsPay, $day );
  11411. $data ['payHtml'] = $html ['html'];
  11412. $data ['paySum'] = $html ['sum'];
  11413. $mothHtml = "";
  11414. for($i = 1; $i <= 12; $i ++) {
  11415. if ($moth == $i)
  11416. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11417. else
  11418. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11419. }
  11420. $data ['mothHtml'] = $mothHtml;
  11421. $data ['year'] = $year;
  11422. // 余额
  11423. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1, $moth );
  11424. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2, $moth );
  11425. include './protected/config/wasteBook.conf.php';
  11426. Doo::loadModel ( 'wasteBook' );
  11427. $wasteBook = new wasteBook ();
  11428. $inComePay = $wasteBook->getStatisticsByDay ( 1, $year, $moth );
  11429. $pay = $wasteBook->getStatisticsByDay ( 2, $year, $moth );
  11430. // 获得年份之前所有金额
  11431. $detail = $wasteBook->getWasteBookByStatisticsDay ( $year, $moth );
  11432. $lastBalanceHtml = '<tr><th colspan="2">截至上日余额</th>';
  11433. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11434. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11435. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11436. $dayHtml = '<tr><th class="taC" colspan="2">余额</th>';
  11437. $inSum = $paySum = $showPaySum = $showInSum = $balanceSum = 0;
  11438. // $balanceC = 0;
  11439. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11440. $limitDay = date ( 'd' );
  11441. $monthLK = ( int ) date ( 'm' );
  11442. if (date ( 'Y' ) > $year) {
  11443. $limitDay = cal_days_in_month ( CAL_GREGORIAN, date ( 'm' ), date ( 'Y' ) );
  11444. } elseif (date ( 'Y' ) <= $year && $monthLK < $moth) {
  11445. $limitDay = 0;
  11446. }
  11447. for($i = 1; $i <= $day; $i ++) {
  11448. $dayHtml .= '<td class="taC">' . $i . '日</td>';
  11449. $inComeA = $payB = 0;
  11450. $falg = true;
  11451. foreach ( $inComePay as $key => $value ) {
  11452. if ($value ['day'] == $i) {
  11453. $falg = false;
  11454. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11455. $inSum += $value ['accountPrice'];
  11456. $showInSum += $value ['accountPriceShow'];
  11457. $inComeA = $value ['accountPrice'];
  11458. break;
  11459. }
  11460. }
  11461. if ($falg)
  11462. $inComeHtml .= '<td class="taR">-</td>';
  11463. $payFalg = true;
  11464. foreach ( $pay as $key => $value ) {
  11465. if ($value ['day'] == $i) {
  11466. $payFalg = false;
  11467. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11468. $paySum += $value ['accountPrice'];
  11469. $showPaySum += $value ['accountPriceShow'];
  11470. $payB = $value ['accountPrice'];
  11471. break;
  11472. }
  11473. }
  11474. if ($payFalg)
  11475. $payHtml .= '<td class="taR">-</td>';
  11476. if (empty ( $balanceC ) || $limitDay < $i)
  11477. $lastBalanceHtml .= '<td class="taR">-</td>';
  11478. else
  11479. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11480. $balanceC = $balanceC + $inComeA + $payB;
  11481. $balanceSum += $balanceC;
  11482. if (empty ( $balanceC ) || $limitDay < $i)
  11483. $BalanceHtml .= '<td class="taR">-</td>';
  11484. else
  11485. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11486. }
  11487. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11488. $data ['inComeHtml'] = $inComeHtml;
  11489. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11490. $data ['payBalanceHtml'] = $payHtml;
  11491. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11492. $data ['BalanceHtml'] = $BalanceHtml;
  11493. $dayHtml .= '<td class="taR ">总计</td></tr>';
  11494. $data ['dayHtml'] = $dayHtml;
  11495. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11496. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11497. $dateHtml = "";
  11498. $now = date ( "Y" );
  11499. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11500. if ($YEARD <= $now) {
  11501. $dateHtml .= '<option ';
  11502. if ($year == $YEARD) {
  11503. $dateHtml .= 'selected ';
  11504. }
  11505. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11506. }
  11507. }
  11508. $data ['dateHtml'] = $dateHtml;
  11509. $data ['memu'] = "receipt";
  11510. $data ['staff'] = $this->staff;
  11511. $data ['receiptMemu'] = 'paymentsCollect';
  11512. $data ['verifyId'] = $this->verifyId;
  11513. $data ['executeId'] = $this->executeId;
  11514. $this->render ( "/expenses/paymentsCollectDay", $data );
  11515. }
  11516. // 公司流水
  11517. function wasteBook() {
  11518. Doo::loadModel ( "execute" );
  11519. $execute = new execute ();
  11520. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11521. die ( 'illegal request' );
  11522. }
  11523. include './protected/config/wasteBook.conf.php';
  11524. Doo::loadModel ( 'wasteBook' );
  11525. $wasteBook = new wasteBook ();
  11526. $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  11527. $waste = $this->getWasteBookStatistics ( $waste, $inComeStatistics );
  11528. $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'];
  11529. // print_r($waste);
  11530. $data ['waste'] = $waste;
  11531. $data ['total'] = $total;
  11532. // 月流水数据结构
  11533. $monthStatistics = array ();
  11534. $incomeMothStatistics = array ();
  11535. $expenditureMothStatistics = array ();
  11536. for($i = 1; $i <= 12; $i ++) {
  11537. $month = date ( 'Y' ) . '-' . $i;
  11538. if ($i < 10)
  11539. $month = date ( 'Y' ) . '-0' . $i;
  11540. array_push ( $monthStatistics, $month );
  11541. }
  11542. foreach ( $monthStatistics as $value ) {
  11543. $falg = true;
  11544. foreach ( $inComeStatistics ['incomeReport'] as $k => $v ) {
  11545. if ($value == $v ['inputDate']) {
  11546. array_push ( $incomeMothStatistics, $v ['accountPrice'] );
  11547. $falg = false;
  11548. }
  11549. }
  11550. if ($falg) {
  11551. array_push ( $incomeMothStatistics, '' );
  11552. }
  11553. $falgEx = true;
  11554. foreach ( $inComeStatistics ['expenditureReport'] as $k => $v ) {
  11555. if ($value == $v ['inputDate']) {
  11556. array_push ( $expenditureMothStatistics, $v ['accountPrice'] );
  11557. $falg = false;
  11558. }
  11559. }
  11560. if ($falgEx) {
  11561. array_push ( $expenditureMothStatistics, '' );
  11562. }
  11563. }
  11564. $data ['monthStatistics'] = json_encode ( $monthStatistics );
  11565. $data ['incomeMothStatistics'] = json_encode ( $incomeMothStatistics );
  11566. $data ['expenditureMothStatistics'] = json_encode ( $expenditureMothStatistics );
  11567. $expenditureList = $wasteBook->getAccountBookByExpensesType ( 4, 2 );
  11568. $incomeList = $wasteBook->getAccountBookByExpensesType ( 4, 1 );
  11569. // print_r($incomeList);
  11570. $data ['expenditureList'] = $expenditureList;
  11571. $data ['incomeList'] = $incomeList;
  11572. $data ['memu'] = "receipt";
  11573. $data ['staff'] = $this->staff;
  11574. $data ['receiptMemu'] = 'wasteBook';
  11575. $data ['verifyId'] = $this->verifyId;
  11576. $data ['executeId'] = $this->executeId;
  11577. $this->render ( "/expenses/wasteBook", $data );
  11578. }
  11579. function wasteBookIncome() {
  11580. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11581. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11582. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  11583. $dailyIncomeType = $this->get_args ( 'dailyIncomeType' ) ? $this->get_args ( 'dailyIncomeType' ) : "ALL";
  11584. $data ['dailyIncomeType'] = $dailyIncomeType;
  11585. Doo::loadModel ( 'wasteBook' );
  11586. $wasteBook = new wasteBook ();
  11587. Doo::loadModel ( 'L_category' );
  11588. $L_category = new L_category ();
  11589. Doo::loadClass ( 'XDeode' );
  11590. $XDeode = new XDeode ( 5 );
  11591. // echo $XDeode->encode(1).'<br>';
  11592. // echo $XDeode->encode(2).'<br>';
  11593. // echo $XDeode->encode(3).'<br>';
  11594. // echo $XDeode->encode(4).'<br>';
  11595. // echo $XDeode->encode(5).'<br>';
  11596. // echo $XDeode->encode(6).'<br>';
  11597. // echo $XDeode->encode(7).'<br>';
  11598. // echo $XDeode->encode(8).'<br>';
  11599. // echo $XDeode->encode(9).'<br>';
  11600. // echo $XDeode->encode(10).'<br>';
  11601. $year=date("Y");
  11602. $theDay=date("Y-m-d");
  11603. $dateArr = explode ( ':', $date );
  11604. $D1 = '';
  11605. $D2 = '';
  11606. $con = '';
  11607. if (! empty ( $date )) {
  11608. $D1 = $dateArr [0];
  11609. $D2 = $dateArr [1];
  11610. }
  11611. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11612. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11613. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11614. $con = ' and inputDate = "' . $D1 . '"';
  11615. else{
  11616. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  11617. }
  11618. if ($cid != 'ALL') {
  11619. $cid = $XDeode->decode ( $cid );
  11620. $con .= ' and cid = "' . $cid . '"';
  11621. }
  11622. if ($accountType != 'ALL') {
  11623. if ($accountType == 'INVOICE') {
  11624. $con .= ' and (accountType = 7 or accountType = 8)';
  11625. } elseif ($accountType == 'PAYMENTS') {
  11626. $con .= ' and (accountType = 6 or accountType = 9 or accountType = 10)';
  11627. if ($dailyIncomeType != 'ALL') {
  11628. $dailyIncomeType = $XDeode->decode ( $dailyIncomeType );
  11629. $con .= ' and dailyIncomeType = ' . $dailyIncomeType;
  11630. }
  11631. }
  11632. }
  11633. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 1, $con );
  11634. $sum = 0;$thsDaySum=0;
  11635. foreach ( $incomeList as $key => $value ) {
  11636. $sum += $value ['accountPrice'];
  11637. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  11638. $thsDaySum+=$value ['accountPrice'];
  11639. }
  11640. }
  11641. // print_r($incomeList);
  11642. // 获得办事和部门
  11643. $categoryList = $L_category->getCategory ();
  11644. $data ['accountType'] = $accountType;
  11645. $data ['cid'] = $cid;
  11646. $data ['categoryList'] = $categoryList;
  11647. $data ['sum'] = $sum;
  11648. $data ['incomeList'] = $incomeList;
  11649. $data ['inputDate'] = $date;
  11650. $data['year']=$year;
  11651. $data ['thsDay'] =$theDay;
  11652. $data ['thsDaySum'] =$thsDaySum;
  11653. $data ['memu'] = "receipt";
  11654. $data ['staff'] = $this->staff;
  11655. $data ['receiptMemu'] = 'wasteBook';
  11656. $data ['verifyId'] = $this->verifyId;
  11657. $data ['executeId'] = $this->executeId;
  11658. $this->render ( "/expenses/wasteBookIncome", $data );
  11659. }
  11660. /**
  11661. * 所有支出
  11662. */
  11663. function wasteBookExpenditure() {
  11664. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11665. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11666. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  11667. $dailyExpenditureType = $this->get_args ( 'dailyExpenditureType' ) ? $this->get_args ( 'dailyExpenditureType' ) : "ALL";
  11668. $data ['dailyExpenditureType'] = $dailyExpenditureType;
  11669. $receiptType = $this->get_args ( 'receiptType' ) ? $this->get_args ( 'receiptType' ) : "ALL";
  11670. $data ['receiptType'] = $receiptType;
  11671. Doo::loadModel ( 'wasteBook' );
  11672. $wasteBook = new wasteBook ();
  11673. Doo::loadModel ( 'L_category' );
  11674. $L_category = new L_category ();
  11675. Doo::loadClass ( 'XDeode' );
  11676. $XDeode = new XDeode ( 5 );
  11677. $year=date("Y");
  11678. $theDay=date("Y-m-d");
  11679. $dateArr = explode ( ':', $date );
  11680. $D1 = '';
  11681. $D2 = '';
  11682. $con = '';
  11683. if (! empty ( $date )) {
  11684. $D1 = $dateArr [0];
  11685. $D2 = $dateArr [1];
  11686. }
  11687. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11688. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11689. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11690. $con = ' and inputDate = "' . $D1 . '"';
  11691. else{
  11692. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  11693. }
  11694. if ($cid != 'ALL') {
  11695. $cid = $XDeode->decode ( $cid );
  11696. $con .= ' and cid = "' . $cid . '"';
  11697. }
  11698. if ($accountType != 'ALL') {
  11699. if ($accountType == 'INVOICE') {
  11700. $con .= ' and accountType = 11';
  11701. } elseif ($accountType == 'PAYMENTS') {
  11702. $con .= ' and (accountType = 5 or accountType = 9 or accountType = 10)';
  11703. if ($dailyExpenditureType != 'ALL') {
  11704. $dailyExpenditureType = $XDeode->decode ( $dailyExpenditureType );
  11705. $con .= ' and dailyExpenditureType = ' . $dailyExpenditureType;
  11706. }
  11707. } elseif ($accountType == 'RECEIPT') {
  11708. if ($receiptType == 'ALL') {
  11709. $con .= ' and (accountType = 1 or accountType = 2 or accountType = 3 or accountType = 4)';
  11710. } else {
  11711. $receiptType = $XDeode->decode ( $receiptType );
  11712. echo $receiptType;
  11713. if ($receiptType == 1) {
  11714. $con .= ' and (accountType = 1 or accountType=2)';
  11715. } else {
  11716. $con .= ' and accountType = ' . $receiptType;
  11717. }
  11718. }
  11719. }
  11720. }
  11721. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 2, $con );
  11722. $sum = 0;$thsDaySum=0;
  11723. foreach ( $incomeList as $key => $value ) {
  11724. $sum += $value ['accountPriceShow'];
  11725. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  11726. $thsDaySum+=$value ['accountPriceShow'];
  11727. }
  11728. }
  11729. // print_r($incomeList);
  11730. // 获得办事和部门
  11731. $categoryList = $L_category->getCategory ();
  11732. $data ['accountType'] = $accountType;
  11733. $data ['cid'] = $cid;
  11734. $data ['categoryList'] = $categoryList;
  11735. $data ['sum'] = $sum;
  11736. $data ['incomeList'] = $incomeList;
  11737. $data ['inputDate'] = $date;
  11738. $data['year']=$year;
  11739. $data ['thsDay'] =$theDay;
  11740. $data ['thsDaySum'] =$thsDaySum;
  11741. $data ['memu'] = "receipt";
  11742. $data ['staff'] = $this->staff;
  11743. $data ['receiptMemu'] = 'wasteBook';
  11744. $data ['verifyId'] = $this->verifyId;
  11745. $data ['executeId'] = $this->executeId;
  11746. $this->render ( "/expenses/wasteBookExpenditure", $data );
  11747. }
  11748. function ajaxGetWasteinvoiceReceivables() {
  11749. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11750. Doo::loadClass ( 'XDeode' );
  11751. $XDeode = new XDeode ( 5 );
  11752. $irid = $XDeode->decode ( $serial );
  11753. Doo::loadModel ( 'invoiceReceivables' );
  11754. $invoiceReceivables = new invoiceReceivables ();
  11755. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  11756. echo json_encode ( array (
  11757. 'status' => 1,
  11758. 'detail' => $detail
  11759. ) );
  11760. }
  11761. function ajaxGetPaymentsByAid() {
  11762. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11763. Doo::loadModel ( "accountBook" );
  11764. $accountBook = new accountBook ();
  11765. $detail = $accountBook->getAccountBookByAid ( $serial );
  11766. echo json_encode ( array (
  11767. 'status' => 1,
  11768. 'detail' => $detail
  11769. ) );
  11770. }
  11771. function ajaxGetWasteInvoice() {
  11772. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11773. Doo::loadModel ( 'invoice' );
  11774. $invoice = new invoice ();
  11775. Doo::loadModel ( 'invoiceReceivables' );
  11776. $invoiceReceivables = new invoiceReceivables ();
  11777. $detail = $invoice->getInvoiceByIid ( $serial );
  11778. $detailReceivables = $invoiceReceivables->getInvoiceReceivablesByIrid ( $detail ['irid'] );
  11779. $detail ['receivablesBank'] = $detailReceivables ['receivablesBank'];
  11780. echo json_encode ( array (
  11781. 'status' => 1,
  11782. 'detail' => $detail
  11783. ) );
  11784. }
  11785. /**
  11786. */
  11787. function ajaxGetWasteReceipt() {
  11788. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11789. $accountTypeKey = $this->get_args ( 'accountTypeKey' ) ? $this->get_args ( 'accountTypeKey' ) : "";
  11790. Doo::loadModel ( 'receipt' );
  11791. $receipt = new receipt ();
  11792. Doo::loadClass ( 'XDeode' );
  11793. $XDeode = new XDeode ( 5 );
  11794. $rid = $XDeode->decode ( $serial );
  11795. $accountType= $XDeode->decode ( $accountTypeKey );
  11796. // 获得个数据
  11797. $detail = $receipt->getReceiptByRid ( $rid );
  11798. // 初始化
  11799. $detail ['reviseDetail'] = array ();
  11800. if (! empty ( $value ['reviseDetail'] ))
  11801. $detail ['reviseDetail'] = json_decode ( $detail ['reviseDetail'], true );
  11802. $detail ['accountItem'] = json_decode ( $detail ['accountItem'], true );
  11803. $detail ['loanItem'] = json_decode ( $detail ['loanItem'], true );
  11804. $detail ['loanSumCN'] = $this->num_to_rmb ( $detail ['loanSum'] );
  11805. $detail ['sumCN'] = $this->num_to_rmb ( $detail ['sum'] );
  11806. // 获得费用html
  11807. $html = $this->getWasteReceiptHtml ( $detail ,$accountType);
  11808. // 获得费用审批人数据
  11809. $detail = $this->getReceiptApproverHtml ( $detail );
  11810. // 审批执行
  11811. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  11812. <th class="taC" width="90">审批人</th>
  11813. <th class="taC">审批意见</th></tr>';
  11814. foreach ( $detail ['verifyList'] as $key => $value ) {
  11815. $html .= '<tr>
  11816. <td>' . $value [1] . '</td>
  11817. <td>' . $value ['opinion'] . '</td>
  11818. </tr>
  11819. ';
  11820. }
  11821. $html .= ' </tbody></table>';
  11822. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  11823. <th class="taC" width="90">执行人</th>
  11824. <th class="taC">执行意见</th></tr>';
  11825. foreach ( $detail ['executeCopy'] as $key => $value ) {
  11826. $html .= '<tr>
  11827. <td>' . $value [1] . '</td>
  11828. <td>' . $value ['opinion'] . '</td>
  11829. </tr>
  11830. ';
  11831. }
  11832. $html .= ' </tbody></table>';
  11833. if($accountType==1){
  11834. Doo::loadModel ( 'loanReceipt' );
  11835. $loanReceipt = new loanReceipt ();
  11836. $loanList = $loanReceipt->getOne ( array (
  11837. 'where' => 'rid=' . $detail ['loanRid'],
  11838. 'desc' => 'rid',
  11839. 'asArray' => true
  11840. ) );
  11841. $html .= '<table class="table table-bordered table-condensed">
  11842. <tr class="warning">
  11843. <td class="taR"><b>汇款金额</b></td>
  11844. <td width="140" class="taR"><b style="font-size: 24px">¥'.$loanList['amount'].'</b></td>
  11845. </tr>
  11846. </table>';
  11847. }else{
  11848. $html .= '<table class="table table-bordered table-condensed">
  11849. <tr class="warning">
  11850. <td class="taR"><b>汇款金额</b></td>
  11851. <td width="140" class="taR"><b style="font-size: 24px">¥' . $detail ['amount'] . '</b></td>
  11852. </tr>
  11853. </table>';
  11854. }
  11855. // print_r($detail['verifyList']);
  11856. // header ( 'Content-Type:text/html;charset=utf-8' );
  11857. // echo $html;
  11858. echo json_encode ( array (
  11859. 'status' => 1,
  11860. 'html' => $html,
  11861. 'detail' => $detail
  11862. ) );
  11863. }
  11864. function getReceiptApproverHtml($detail = array()) {
  11865. Doo::loadModel ( 'loanReceipt' );
  11866. $loanReceipt = new loanReceipt ();
  11867. Doo::loadModel ( 'verify' );
  11868. $verify = new verify ();
  11869. Doo::loadModel ( 'staff' );
  11870. $staff = new staff ();
  11871. if (empty ( $detail ))
  11872. return array ();
  11873. $loanList = $loanReceipt->getOne ( array (
  11874. 'where' => 'rid=' . $detail ['loanRid'],
  11875. 'desc' => 'rid',
  11876. 'asArray' => true
  11877. ) );
  11878. if ($detail ['status'] == 3 || $detail ['status'] == 1 || $detail ['status'] == 8 || $detail ['status'] == 9) {
  11879. if ($detail ['status'] == 8 && $detail ['Rtype'] == 1)
  11880. $verifyList ['staff'] = $loanList ['verifyBreakup'];
  11881. else
  11882. $verifyList ['staff'] = $detail ['verifyBreakup'];
  11883. } else
  11884. $verifyList = $verify->getOne ( array (
  11885. 'where' => 'vid=' . $detail ['verify'],
  11886. 'asArray' => true
  11887. ) );
  11888. $verifyList = json_decode ( $verifyList ['staff'], true );
  11889. Doo::loadModel ( 'role' );
  11890. $role = new role ();
  11891. $roleId = 0;
  11892. $flag = true;
  11893. $roleKey = 0;
  11894. $endStaffArray = array ();
  11895. $roleArrayCopy = array ();
  11896. foreach ( $verifyList as $k => $v ) {
  11897. // init verifyStaff
  11898. if ($v [1] == 'ROLE') {
  11899. if (! empty ( $verifyStaff )) {
  11900. $endStaffArray = end ( $verifyStaff );
  11901. }
  11902. $roleVerify = json_decode ( $v [3], true );
  11903. $roleKey = $k;
  11904. $roleArray = array ();
  11905. $rolename = $role->getOne ( array (
  11906. 'where' => 'rid=' . $v [0],
  11907. 'asArray' => true
  11908. ) );
  11909. foreach ( $roleVerify as $o => $p ) {
  11910. $staffID = explode ( '_', $p );
  11911. $staffInfo = $staff->getOne ( array (
  11912. 'where' => 'sid=' . $staffID [0],
  11913. 'asArray' => true
  11914. ) );
  11915. // print_r($staffID);
  11916. $exp = array (
  11917. 0 => $staffInfo ['sid'],
  11918. 1 => $staffID [1],
  11919. 2 => $staffInfo ['avatar'],
  11920. 'date' => '',
  11921. 'date' => '',
  11922. 'opinion' => '',
  11923. 'status' => '',
  11924. 'rolename' => $rolename ['name']
  11925. );
  11926. array_push ( $roleArray, $exp );
  11927. }
  11928. $roleArrayCopy [$v [0]] = $roleArray;
  11929. // $verifyList[$k]['roleArray']=$roleArray;
  11930. }
  11931. $verifyList [$k] ['date'] = "";
  11932. $verifyList [$k] ['opinion'] = "";
  11933. $verifyList [$k] ['status'] = "";
  11934. if (empty ( $verifyStaff )) {
  11935. $verifyList [$k] ['date'] = "";
  11936. $verifyList [$k] ['opinion'] = "";
  11937. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  11938. $verifyList [$k] ['status'] = 4;
  11939. $flag = false;
  11940. }
  11941. } else {
  11942. foreach ( $verifyStaff as $m => $u ) {
  11943. if ($v [0] == $m) {
  11944. $verifyList [$k] ['date'] = $u ['date'];
  11945. $verifyList [$k] ['opinion'] = $u ['opinion'];
  11946. $verifyList [$k] ['status'] = $u ['status'];
  11947. $flag = false;
  11948. break;
  11949. }
  11950. }
  11951. $endStaffArray = end ( $verifyStaff );
  11952. }
  11953. }
  11954. $rolename ['name'] = '';
  11955. if (! empty ( $roleId )) {
  11956. Doo::loadModel ( 'role' );
  11957. $role = new role ();
  11958. $rolename = $role->getOne ( array (
  11959. 'where' => 'rid=' . $roleId,
  11960. 'asArray' => true
  11961. ) );
  11962. }
  11963. if (! empty ( $verifyStaff ))
  11964. $endStaffArray = end ( $verifyStaff );
  11965. $KOP = false;
  11966. foreach ( $roleArrayCopy as $P => $A ) {
  11967. foreach ( $A as $MKI => $AVL ) {
  11968. if (! empty ( $verifyStaff )) {
  11969. // &&$rolename['rid']==$endStaffArray['nextStaff']
  11970. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  11971. $button = 4;
  11972. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  11973. }
  11974. foreach ( $verifyStaff as $m => $u ) {
  11975. $AVLFK = $AVL [0] . '_R';
  11976. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  11977. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  11978. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  11979. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  11980. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  11981. break;
  11982. }
  11983. }
  11984. } else {
  11985. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  11986. $button = 4;
  11987. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  11988. }
  11989. }
  11990. // $roleArray[$MKI]['rolename']=$rolename['name'];
  11991. $KOP = true;
  11992. }
  11993. }
  11994. foreach ( $roleArrayCopy as $k => $v ) {
  11995. foreach ( $verifyList as $m => $n ) {
  11996. if ($n [0] == $k) {
  11997. array_splice ( $verifyList, $m, 1, $v );
  11998. }
  11999. }
  12000. }
  12001. // 费用执行人相关数据
  12002. $executeCopy = json_decode ( $detail ['executeCopy'], true );
  12003. $executeStaff = json_decode ( $detail ['executeStaff'], true );
  12004. foreach ( $executeCopy as $k => $v ) {
  12005. $executeCopy [$k] ['date'] = '';
  12006. $executeCopy [$k] ['opinion'] = '';
  12007. $executeCopy [$k] ['status'] = '';
  12008. if (! empty ( $executeStaff ))
  12009. foreach ( $executeStaff as $m => $u ) {
  12010. if ($v [0] == $m) {
  12011. $executeCopy [$k] ['date'] = $u ['date'];
  12012. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  12013. $executeCopy [$k] ['status'] = $u ['status'];
  12014. break;
  12015. }
  12016. }
  12017. }
  12018. $detail ['executeCopy'] = $executeCopy;
  12019. $detail ['verifyList'] = $verifyList;
  12020. return $detail;
  12021. }
  12022. function getWasteReceiptHtml($detail = array(),$accountType=1) {
  12023. if (empty ( $detail ))
  12024. return '';
  12025. $html = '';
  12026. if ($detail ['Rtype'] == 0) { // 报销单
  12027. $html .= '<table class="table table-bordered table-condensed">
  12028. <tbody>
  12029. <tr>
  12030. <th colspan="2" class="taC">日常相关费用</th>
  12031. </tr>';
  12032. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12033. $html .= '
  12034. <tr>
  12035. <th>' . $value ['name'] . '</th>
  12036. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12037. </tr>';
  12038. }
  12039. $html .= '
  12040. <tr>
  12041. <th class="taR">合计</th>
  12042. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12043. </tr>';
  12044. $html .= '<tr>
  12045. <th colspan="2" class="taC">差旅相关费用</th>
  12046. </tr>';
  12047. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12048. $html .= '
  12049. <tr>
  12050. <th>' . $value ['name'] . '</th>
  12051. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12052. </tr>';
  12053. }
  12054. $html .= '
  12055. <tr>
  12056. <th class="taR">合计</th>
  12057. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12058. </tr>';
  12059. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12060. $html .= '<tr>
  12061. <th colspan="2" class="taC">内部培训费用</th>
  12062. </tr>';
  12063. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12064. $html .= '
  12065. <tr>
  12066. <th>' . $value ['name'] . '</th>
  12067. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12068. </tr>';
  12069. }
  12070. $html .= '
  12071. <tr>
  12072. <th class="taR">合计</th>
  12073. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12074. </tr>';
  12075. }
  12076. $html .= '<tr>
  12077. <th colspan="2" class="taC">其他</th>
  12078. </tr>';
  12079. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12080. $html .= '
  12081. <tr>
  12082. <th>' . $value ['name'] . '</th>
  12083. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12084. </tr>';
  12085. }
  12086. $html .= '
  12087. <tr>
  12088. <th class="taR">合计</th>
  12089. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12090. </tr>';
  12091. $html .= '<tr>
  12092. <th colspan="2" class="taC">报销金额调整</th>
  12093. </tr>';
  12094. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12095. $html .= '
  12096. <tr>
  12097. <th>' . $value ['name'] . '</th>
  12098. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12099. </tr>';
  12100. }
  12101. $html .= '
  12102. <tr>
  12103. <th class="taR">合计</th>
  12104. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12105. </tr>';
  12106. $html .= '
  12107. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12108. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12109. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12110. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12111. <tr class="warning">
  12112. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12113. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12114. </tr>
  12115. </tbody>
  12116. </table>';
  12117. } elseif ($detail ['Rtype'] == 2) {//对公汇款
  12118. $html .= '
  12119. <table class="table table-bordered table-condensed">
  12120. <tbody>
  12121. <tr>
  12122. <th colspan="2" class="taC">办事处相关费用</th>
  12123. </tr>';
  12124. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12125. $html .= '
  12126. <tr>
  12127. <th>' . $value ['name'] . '</th>
  12128. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12129. </tr>';
  12130. }
  12131. $html .= '
  12132. <tr>
  12133. <th class="taR">合计</th>
  12134. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12135. </tr>';
  12136. $html .= '
  12137. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12138. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12139. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12140. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12141. <tr class="warning">
  12142. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12143. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12144. </tr>
  12145. </tbody>
  12146. </table>';
  12147. } elseif ($detail ['Rtype'] == 1) {//借款 或者借款报销
  12148. Doo::loadModel ( 'loanReceipt' );
  12149. $loanReceipt = new loanReceipt ();
  12150. $loanList = $loanReceipt->getOne ( array (
  12151. 'where' => 'rid=' . $detail ['loanRid'],
  12152. 'desc' => 'rid',
  12153. 'asArray' => true
  12154. ) );
  12155. // print_r($loanList);
  12156. $loanList ['sumCN']=$this->num_to_rmb($loanList ['sum']);
  12157. $html .= '<table class="table table-bordered table-condensed">
  12158. <tbody>
  12159. <tr>
  12160. <th colspan="2" class="taC">借款费用</th>
  12161. </tr>';
  12162. foreach ( $detail ['loanItem'] ['借款费用'] as $key => $value ) {
  12163. $html .= '<tr>
  12164. <th>' . $value ['name'] . '</th>
  12165. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12166. </tr>';
  12167. }
  12168. $html .= '<tr>
  12169. <th class="taC" colspan="2">产生费用所在办事处</th>
  12170. </tr>
  12171. <tr>
  12172. <th style="text-align: center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th>
  12173. </tr>
  12174. <tr>
  12175. <th class="taC" colspan="2">费用说明</th>
  12176. </tr>
  12177. <tr>
  12178. <td colspan="2">' . $loanList ['explanation'] . '</td>
  12179. </tr>
  12180. <tr class="warning">
  12181. <td class="taR"><b>(' . $loanList ['receiptOrder'] . ')本次费用合计</b></td>
  12182. <td class="taR"><b style="font-size: 24px">¥' . $loanList ['sum'] . '</b><br>' . $loanList ['sumCN'] . '</td>
  12183. </tr>
  12184. </tbody>
  12185. </table>
  12186. ';
  12187. if ( $accountType==2) {
  12188. $balance=$detail ['sum']-$loanList ['sum'];
  12189. $balanceCN=$this->num_to_rmb($balance);
  12190. $html .= '<table class="table table-bordered table-condensed">
  12191. <tbody>
  12192. <tr>
  12193. <th colspan="2" class="taC">日常相关费用</th>
  12194. </tr>';
  12195. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12196. $html .= '
  12197. <tr>
  12198. <th>' . $value ['name'] . '</th>
  12199. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12200. </tr>';
  12201. }
  12202. $html .= '
  12203. <tr>
  12204. <th class="taR">合计</th>
  12205. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12206. </tr>';
  12207. $html .= '<tr>
  12208. <th colspan="2" class="taC">差旅相关费用</th>
  12209. </tr>';
  12210. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12211. $html .= '
  12212. <tr>
  12213. <th>' . $value ['name'] . '</th>
  12214. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12215. </tr>';
  12216. }
  12217. $html .= '
  12218. <tr>
  12219. <th class="taR">合计</th>
  12220. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12221. </tr>';
  12222. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12223. $html .= '<tr>
  12224. <th colspan="2" class="taC">内部培训费用</th>
  12225. </tr>';
  12226. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12227. $html .= '
  12228. <tr>
  12229. <th>' . $value ['name'] . '</th>
  12230. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12231. </tr>';
  12232. }
  12233. $html .= '
  12234. <tr>
  12235. <th class="taR">合计</th>
  12236. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12237. </tr>';
  12238. }
  12239. $html .= '<tr>
  12240. <th colspan="2" class="taC">其他</th>
  12241. </tr>';
  12242. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12243. $html .= '
  12244. <tr>
  12245. <th>' . $value ['name'] . '</th>
  12246. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12247. </tr>';
  12248. }
  12249. $html .= '
  12250. <tr>
  12251. <th class="taR">合计</th>
  12252. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12253. </tr>';
  12254. $html .= '<tr>
  12255. <th colspan="2" class="taC">报销金额调整</th>
  12256. </tr>';
  12257. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12258. $html .= '
  12259. <tr>
  12260. <th>' . $value ['name'] . '</th>
  12261. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12262. </tr>';
  12263. }
  12264. $html .= '
  12265. <tr>
  12266. <th class="taR">合计</th>
  12267. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12268. </tr>';
  12269. $html .= '
  12270. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12271. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12272. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12273. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12274. <tr class="warning">
  12275. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12276. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12277. </tr>
  12278. <tr class="success">
  12279. <td class="taR"><b>借款结余</b></td>
  12280. <td class="taR"><b style="font-size:24px">¥'.$balance.'</b><br>'.$balanceCN.'</td>
  12281. </tr>
  12282. </tbody>
  12283. </table>';
  12284. }
  12285. }
  12286. return $html;
  12287. }
  12288. /**
  12289. * 计算流水
  12290. */
  12291. function getWasteBookStatistics($waste = array(), $inComeStatistics) {
  12292. $bakWaste ['bank'] = array (
  12293. 'CGBDeposit' => 0,
  12294. 'ICBCDeposit' => 0,
  12295. 'HUADeposit' => 0,
  12296. 'PersonalDeposit' => 0
  12297. );
  12298. $bakWaste ['financial'] = array (
  12299. 'current' => array (
  12300. 'CGBDeposit' => 0,
  12301. 'ICBCDeposit' => 0
  12302. ),
  12303. 'fixed' => array (
  12304. 'CGBDeposit' => 0,
  12305. 'ICBCDeposit' => 0
  12306. )
  12307. );
  12308. // 存款
  12309. foreach ( $waste ['bank'] as $key => $value ) {
  12310. // 收入
  12311. foreach ( $inComeStatistics ['incomeStatistics'] as $k => $v ) {
  12312. // 广发
  12313. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12314. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12315. }
  12316. // 工商
  12317. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12318. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12319. }
  12320. // 华润
  12321. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12322. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12323. }
  12324. // 个人
  12325. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12326. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12327. }
  12328. }
  12329. }
  12330. foreach ( $waste ['bank'] as $key => $value ) {
  12331. // 支出
  12332. foreach ( $inComeStatistics ['expenditureStatistics'] as $k => $v ) {
  12333. // 广发
  12334. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12335. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12336. }
  12337. // 工商
  12338. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12339. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12340. }
  12341. // 华润
  12342. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12343. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12344. }
  12345. // 个人
  12346. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12347. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12348. }
  12349. }
  12350. }
  12351. // 活期
  12352. foreach ( $waste ['financial'] ['current'] as $key => $value ) {
  12353. foreach ( $inComeStatistics ['currentStatistics'] as $k => $v ) {
  12354. // 广发
  12355. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12356. $waste ['financial'] ['current'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  12357. }
  12358. // 工商
  12359. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12360. $waste ['financial'] ['current'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  12361. }
  12362. // 个人
  12363. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12364. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  12365. }
  12366. }
  12367. }
  12368. // print_r($inComeStatistics ['fixedStatistics']);
  12369. // 固期
  12370. foreach ( $waste ['financial'] ['fixed'] as $key => $value ) {
  12371. foreach ( $inComeStatistics ['fixedStatistics'] as $k => $v ) {
  12372. // 广发
  12373. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12374. $waste ['financial'] ['fixed'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  12375. }
  12376. // 工商
  12377. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12378. $waste ['financial'] ['fixed'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  12379. }
  12380. // 个人
  12381. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12382. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  12383. }
  12384. }
  12385. }
  12386. return $waste;
  12387. }
  12388. function lyt() {
  12389. Doo::loadModel ( "receiptDetail" );
  12390. $receiptDetail = new receiptDetail ();
  12391. $receiptCollectList = $receiptDetail->find ( array (
  12392. 'where' => 'status=1 ',
  12393. 'asArray' => true
  12394. ) );
  12395. foreach ( $receiptCollectList as $key => $value ) {
  12396. $receiptDetail = new receiptDetail ();
  12397. $receiptDetail->pastDate = $value ['date'];
  12398. $receiptDetail->update ( array (
  12399. 'where' => "rdid= '" . $value ['rdid'] . "'"
  12400. ) );
  12401. }
  12402. }
  12403. function staffCollectMonthDetail() {
  12404. //include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  12405. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12406. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12407. if (! $year)
  12408. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12409. if (! $month)
  12410. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12411. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  12412. if (! $nature){
  12413. $nature = isset ( $this->params ['nature'] ) ? $this->params ['nature'] : 'ONJOB';
  12414. }
  12415. Doo::loadModel ( 'staff' );
  12416. $staff = new staff ();
  12417. Doo::loadModel ( "receiptDetail" );
  12418. $receiptDetail = new receiptDetail ();
  12419. Doo::loadModel ( 'accountItem' );
  12420. $accountItem = new accountItem ();
  12421. Doo::loadModel ( 'statistics' );
  12422. $statistics = new statistics ();
  12423. Doo::loadModel ( "receiptAuthorityManage" );
  12424. $receiptAuthorityManage = new receiptAuthorityManage ();
  12425. $aiList=$accountItem->getAccountItem();
  12426. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  12427. $cidList = array ();
  12428. foreach ( $imcStaff as $key => $value ) {
  12429. array_push ( $cidList, $value ['cid'] );
  12430. }
  12431. $cidString = implode ( ',', $cidList );
  12432. $naturecon='';
  12433. if ($nature=='ONJOB'){
  12434. $naturecon=' and (nature!=4 )';
  12435. }elseif($nature=='LEAVEJOB'){
  12436. $naturecon=' and (nature=4 )';
  12437. }else{
  12438. die ( 'illegal request--nature' );
  12439. }
  12440. $staffList = $staff->find ( array (
  12441. 'where' => 'username!="admin" and cid in (' . $cidString . ')'.$naturecon,
  12442. 'asArray' => true
  12443. ) );
  12444. $categoryList = $staff->find ( array (
  12445. 'select' => 'COUNT(*) as count,cid,category',
  12446. 'where' => 'username !="admin" and cid in (' . $cidString . ')'.$naturecon,
  12447. 'groupby' => 'cid',
  12448. 'asArray' => true
  12449. ) );
  12450. $list = array ();
  12451. foreach($aiList as $key=>$value){
  12452. foreach ($value as $v){
  12453. $subtotal[$key][$v['name']]=0;
  12454. }
  12455. }
  12456. foreach ( $categoryList as $vlu ) {
  12457. $s1 = 0;
  12458. $m1 = 0;
  12459. $subtotal[$this->AGENCY]['AGENCY']=$subtotal[$this->TRAVEL]['TRAVEL']=$subtotal[$this->INTTRAIN]['INTTRAIN']=$subtotal[$this->TRAIN]['TRAIN']=$subtotal[$this->OTHER]['OTHER']=0;
  12460. foreach ( $staffList as $value ) {
  12461. if ($vlu ['cid'] == $value ['cid']) {
  12462. // pastDate
  12463. $receiptCollectList = $receiptDetail->find ( array (
  12464. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12465. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12466. 'groupby' => 'item,Month(pastDate),itemCategory',
  12467. 'asArray' => true
  12468. ) );
  12469. if (! empty ( $receiptCollectList )) {
  12470. $receiptL = array (
  12471. '日常相关费用' => array (),
  12472. '差旅相关费用' => array (),
  12473. '内部培训费用' => array (),
  12474. '培训班费用' => array (),
  12475. '其他' => array ()
  12476. );
  12477. $html = "";
  12478. $psum = 0;
  12479. foreach ( $aiList[$this->AGENCY] as $va ) {
  12480. $falg = true;
  12481. foreach ( $receiptCollectList as $v ) {
  12482. if ($v ['itemCategory'] == '日常相关费用') {
  12483. if ($v ['item'] == $va['name']) {
  12484. $subtotal[$this->AGENCY][$va['name']]+=$v ['price'];
  12485. $psum += $v ['price'];
  12486. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12487. $falg = false;
  12488. break;
  12489. }
  12490. }
  12491. }
  12492. if ($falg)
  12493. $html .= '<td class="taR">-</td>';
  12494. }
  12495. $subtotal[$this->AGENCY]['AGENCY'] += $psum;
  12496. if (! empty ( $psum ))
  12497. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12498. else
  12499. $psum = '<td class="colGreen taR">-</td>';
  12500. $receiptL ['日常相关费用'] = $psum . $html;
  12501. /* ----------------------------------- */
  12502. $html = "";
  12503. $psum = 0;
  12504. foreach ( $aiList[$this->TRAVEL] as $va ) {
  12505. $falg = true;
  12506. foreach ( $receiptCollectList as $v ) {
  12507. if ($v ['itemCategory'] == '差旅相关费用') {
  12508. if ($v ['item'] == $va['name']) {
  12509. $subtotal[$this->TRAVEL][$va['name']]+=$v ['price'];
  12510. $psum += $v ['price'];
  12511. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12512. $falg = false;
  12513. break;
  12514. }
  12515. }
  12516. }
  12517. if ($falg)
  12518. $html .= '<td class="taR">-</td>';
  12519. }
  12520. $subtotal[$this->TRAVEL]['TRAVEL'] += $psum;
  12521. if (! empty ( $psum ))
  12522. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12523. else
  12524. $psum = '<td class="colGreen taR">-</td>';
  12525. $receiptL ['差旅相关费用'] = $psum . $html;
  12526. /* ------------------------------------- */
  12527. $html = "";
  12528. $psum = 0;
  12529. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  12530. $falg = true;
  12531. foreach ( $receiptCollectList as $v ) {
  12532. if ($v ['itemCategory'] == '内部培训费用') {
  12533. if ($v ['item'] == $va['name']) {
  12534. $subtotal[$this->INTTRAIN][$va['name']]+=$v ['price'];
  12535. $psum += $v ['price'];
  12536. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12537. $falg = false;
  12538. break;
  12539. }
  12540. }
  12541. }
  12542. if ($falg)
  12543. $html .= '<td class="taR">-</td>';
  12544. }
  12545. $subtotal[$this->INTTRAIN]['INTTRAIN'] += $psum;
  12546. if (! empty ( $psum ))
  12547. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12548. else
  12549. $psum = '<td class="colGreen taR">-</td>';
  12550. $receiptL ['内部培训费用'] = $psum . $html;
  12551. /* ----------------------------------- */
  12552. $html = "";
  12553. $psum = 0;
  12554. foreach ( $aiList[$this->TRAIN] as $va ) {
  12555. $falg = true;
  12556. foreach ( $receiptCollectList as $v ) {
  12557. if ($v ['itemCategory'] == '培训班费用') {
  12558. if ($v ['item'] == $va['name']) {
  12559. $subtotal[$this->TRAIN][$va['name']]+=$v ['price'];
  12560. $psum += $v ['price'];
  12561. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12562. $falg = false;
  12563. break;
  12564. }
  12565. }
  12566. }
  12567. if ($falg)
  12568. $html .= '<td class="taR">-</td>';
  12569. }
  12570. $subtotal[$this->TRAIN]['TRAIN'] += $psum;
  12571. if (! empty ( $psum ))
  12572. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12573. else
  12574. $psum = '<td class="colGreen taR">-</td>';
  12575. $receiptL ['培训班费用'] = $psum . $html;
  12576. /* ------------------------------------- */
  12577. $html = "";
  12578. $psum = 0;
  12579. foreach ( $aiList[$this->OTHER] as $va ) {
  12580. $falg = true;
  12581. foreach ( $receiptCollectList as $v ) {
  12582. if ($v ['itemCategory'] == '其他') {
  12583. if (trim ( $v ['item'] ) == $va['name']) {
  12584. $subtotal[$this->OTHER][$va['name']]+=$v ['price'];
  12585. $psum += $v ['price'];
  12586. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12587. $falg = false;
  12588. break;
  12589. }
  12590. }
  12591. }
  12592. if ($falg)
  12593. $html .= '<td class="taR">-</td>';
  12594. }
  12595. $subtotal[$this->OTHER]['OTHER'] += $psum;
  12596. if (! empty ( $psum ))
  12597. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12598. else
  12599. $psum = '<td class="colGreen taR">-</td>';
  12600. $receiptL ['其他'] = $psum . $html;
  12601. /* ------------------------------------- */
  12602. $html = "";
  12603. $psum = 0;
  12604. foreach ( $receiptCollectList as $v ) {
  12605. if ($v ['itemCategory'] == '报销金额调整') {
  12606. if (! empty ( $v ['price'] )) {
  12607. $psum += $v ['price'];
  12608. }
  12609. }
  12610. }
  12611. $s1 += $psum;
  12612. if (! empty ( $psum ))
  12613. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  12614. else
  12615. $psum = '<td class="taR colOrange">-</td>';
  12616. $receiptL ['报销金额调整'] = $psum . $html;
  12617. } else {
  12618. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  12619. foreach ( $aiList[$this->AGENCY] as $va ) {
  12620. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  12621. }
  12622. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  12623. foreach ( $aiList[$this->TRAVEL] as $va ) {
  12624. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  12625. }
  12626. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  12627. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  12628. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  12629. }
  12630. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  12631. foreach ( $aiList[$this->TRAIN] as $va ) {
  12632. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  12633. }
  12634. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  12635. foreach ( $aiList[$this->OTHER] as $va ) {
  12636. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  12637. }
  12638. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  12639. }
  12640. $monthStaffPrice = $receiptDetail->find ( array (
  12641. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12642. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12643. 'groupby' => 'Month(pastDate)',
  12644. 'asArray' => true
  12645. ) );
  12646. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  12647. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  12648. $m1 += $monthStaffPrice [0] ['price'];
  12649. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  12650. } else
  12651. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  12652. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  12653. $list [$value ['username']] = $receiptL;
  12654. }
  12655. }
  12656. $receiptL [$this->AGENCY] ='<td class="colGreen taR">'.$subtotal[$this->AGENCY]['AGENCY'].'</td>';
  12657. foreach ( $aiList[$this->AGENCY] as $va ) {
  12658. $receiptL [$this->AGENCY] .='<td class="taR">' . $subtotal[$this->AGENCY][$va['name']] . '</td>';
  12659. $subtotal[$this->AGENCY][$va['name']]=0;
  12660. }
  12661. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">'.$subtotal[$this->TRAVEL]['TRAVEL'].'</td>';
  12662. foreach ( $aiList[$this->TRAVEL] as $va ) {
  12663. $receiptL [$this->TRAVEL] .='<td class="taR">' . $subtotal[$this->TRAVEL][$va['name']] . '</td>';
  12664. $subtotal[$this->TRAVEL][$va['name']]=0;
  12665. }
  12666. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">'.$subtotal[$this->INTTRAIN]['INTTRAIN'].'</td>';
  12667. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  12668. $receiptL [$this->INTTRAIN] .='<td class="taR">' . $subtotal[$this->INTTRAIN][$va['name']] . '</td>';
  12669. $subtotal[$this->INTTRAIN][$va['name']]=0;
  12670. }
  12671. $receiptL [$this->TRAIN] ='<td class="colGreen taR">'.$subtotal[$this->TRAIN]['TRAIN'].'</td>';
  12672. foreach ( $aiList[$this->TRAIN] as $va ) {
  12673. $receiptL [$this->TRAIN] .='<td class="taR">' . $subtotal[$this->TRAIN][$va['name']] . '</td>';
  12674. $subtotal[$this->TRAIN][$va['name']]=0;
  12675. }
  12676. $receiptL [$this->OTHER] ='<td class="colGreen taR">'.$subtotal[$this->OTHER]['OTHER'].'</td>';
  12677. foreach ( $aiList[$this->OTHER] as $va ) {
  12678. $receiptL [$this->OTHER] .='<td class="taR">' . $subtotal[$this->OTHER][$va['name']] . '</td>';
  12679. $subtotal[$this->OTHER][$va['name']]=0;
  12680. }
  12681. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  12682. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  12683. $receiptL ['usernameEn'] =false;
  12684. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  12685. }
  12686. $data ['list'] = $list;
  12687. // print_r($list);
  12688. $receiptCollectList = $receiptDetail->find ( array (
  12689. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12690. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12691. 'groupby' => 'item,Month(pastDate),itemCategory',
  12692. 'asArray' => true
  12693. ) );
  12694. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  12695. // statistics html
  12696. $stList = $statistics->getOne ( array (
  12697. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  12698. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  12699. 'groupby' => 'Month(date)',
  12700. 'asArray' => true
  12701. ) );
  12702. if (empty ( $stList ))
  12703. $stList = array (
  12704. 'rePrice' => 0,
  12705. 'agPrice' => 0
  12706. );
  12707. $data ['stList'] = array (
  12708. 'rePrice' => $stList ['rePrice'],
  12709. 'agPrice' => $stList ['agPrice'],
  12710. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12711. );
  12712. $monthHtml = "";
  12713. for($i = 1; $i <= 12; $i ++) {
  12714. if ($i == $month)
  12715. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  12716. else
  12717. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  12718. }
  12719. $data ['monthHtml'] = $monthHtml;
  12720. $data ['year'] = $year;
  12721. $data ['month'] = $month;
  12722. $data ['nature'] = $nature;
  12723. $data ['aiList'] = $aiList;
  12724. $data ['memu'] = "receipt";
  12725. $data ['staff'] = $this->staff;
  12726. $data ['receiptMemu'] = 'companyCategoryCollect';
  12727. $data ['verifyId'] = $this->verifyId;
  12728. $data ['executeId'] = $this->executeId;
  12729. $this->render ( "/admin/staffCollectMonthDetail", $data );
  12730. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  12731. }
  12732. function staffCollectMonthDetail2() {
  12733. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12734. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12735. if (! $year)
  12736. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12737. if (! $month)
  12738. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12739. Doo::loadModel ( 'staff' );
  12740. $staff = new staff ();
  12741. Doo::loadModel ( "receiptDetail" );
  12742. $receiptDetail = new receiptDetail ();
  12743. Doo::loadModel ( 'accountItem' );
  12744. $accountItem = new accountItem ();
  12745. Doo::loadModel ( 'statistics' );
  12746. $statistics = new statistics ();
  12747. Doo::loadModel ( 'L_category' );
  12748. $lCategory = new L_category ();
  12749. $staffList = $staff->find ( array (
  12750. 'where' => 'username!="admin"',
  12751. 'asArray' => true
  12752. ) );
  12753. $categoryList = $staff->find ( array (
  12754. 'select' => 'COUNT(*) as count,cid,category',
  12755. 'where' => 'username !="admin"',
  12756. 'groupby' => 'cid',
  12757. 'asArray' => true
  12758. ) );
  12759. $list = array ();
  12760. foreach ( $categoryList as $vlu ) {
  12761. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  12762. $r1 = 0;
  12763. $r2 = 0;
  12764. $r3 = 0;
  12765. $r4 = 0;
  12766. $r5 = 0;
  12767. $r6 = 0;
  12768. $r7 = 0;
  12769. $r8 = 0;
  12770. $r9 = 0;
  12771. $r10 = 0;
  12772. $r11 = 0;
  12773. $r12 = 0;
  12774. $r13 = 0;
  12775. $r14 = 0;
  12776. $r15 = 0;
  12777. $c1 = 0;
  12778. $c2 = 0;
  12779. $c3 = 0;
  12780. $c4 = 0;
  12781. $c5 = 0;
  12782. $c6 = 0;
  12783. $p1 = 0;
  12784. $p2 = 0;
  12785. $p3 = 0;
  12786. $p4 = 0;
  12787. $p5 = 0;
  12788. $p6 = 0;
  12789. $p7 = 0;
  12790. $p8 = 0;
  12791. $p9 = 0;
  12792. $t1 = 0;
  12793. $t2 = 0;
  12794. $t3 = 0;
  12795. $t4 = 0;
  12796. $t5 = 0;
  12797. $s1 = 0;
  12798. $m1 = 0;
  12799. foreach ( $staffList as $value ) {
  12800. if ($vlu ['cid'] == $value ['cid']) {
  12801. $receiptCollectList = $receiptDetail->find ( array (
  12802. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  12803. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  12804. 'groupby' => 'item,Month(date),itemCategory',
  12805. 'asArray' => true
  12806. ) );
  12807. if (! empty ( $receiptCollectList )) {
  12808. $receiptL = array (
  12809. '日常相关费用' => array (),
  12810. '差旅相关费用' => array (),
  12811. '培训班费用' => array (),
  12812. '其他' => array ()
  12813. );
  12814. $html = "";
  12815. $psum = 0;
  12816. $item = array (
  12817. '市内交通费',
  12818. '市内出租费',
  12819. '办事处房租',
  12820. '电话费',
  12821. '水费',
  12822. '电费',
  12823. '办公费用',
  12824. '邮寄费',
  12825. '其他费用',
  12826. '车辆费用',
  12827. '广告费',
  12828. '团队建设费',
  12829. '物业管理费',
  12830. '宽带费'
  12831. );
  12832. foreach ( $item as $va ) {
  12833. $falg = true;
  12834. foreach ( $receiptCollectList as $v ) {
  12835. if ($v ['itemCategory'] == '日常相关费用') {
  12836. if ($v ['item'] == $va) {
  12837. if ($va == '市内交通费')
  12838. $r1 += $v ['price'];
  12839. if ($va == '市内出租费')
  12840. $r2 += $v ['price'];
  12841. if ($va == '办事处房租')
  12842. $r3 += $v ['price'];
  12843. if ($va == '电话费')
  12844. $r4 += $v ['price'];
  12845. if ($va == '水费')
  12846. $r5 += $v ['price'];
  12847. if ($va == '电费')
  12848. $r6 += $v ['price'];
  12849. if ($va == '办公费用')
  12850. $r7 += $v ['price'];
  12851. if ($va == '邮寄费')
  12852. $r8 += $v ['price'];
  12853. if ($va == '其他费用')
  12854. $r9 += $v ['price'];
  12855. if ($va == '车辆费用')
  12856. $r10 += $v ['price'];
  12857. if ($va == '广告费')
  12858. $r11 += $v ['price'];
  12859. if ($va == '团队建设费')
  12860. $r13 += $v ['price'];
  12861. if ($va == '物业管理费')
  12862. $r14 += $v ['price'];
  12863. if ($va == '宽带费')
  12864. $r15 += $v ['price'];
  12865. $psum += $v ['price'];
  12866. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12867. $falg = false;
  12868. break;
  12869. }
  12870. }
  12871. }
  12872. if ($falg)
  12873. $html .= '<td class="taR">-</td>';
  12874. }
  12875. $r12 += $psum;
  12876. if (! empty ( $psum ))
  12877. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12878. else
  12879. $psum = '<td class="colGreen taR">-</td>';
  12880. $receiptL ['日常相关费用'] = $psum . $html;
  12881. /* ----------------------------------- */
  12882. $html = "";
  12883. $psum = 0;
  12884. $item = array (
  12885. '往来交通费',
  12886. '市内交通费',
  12887. '出差住宿费',
  12888. '出差补助',
  12889. '其他费用'
  12890. );
  12891. foreach ( $item as $va ) {
  12892. $falg = true;
  12893. foreach ( $receiptCollectList as $v ) {
  12894. if ($v ['itemCategory'] == '差旅相关费用') {
  12895. if ($v ['item'] == $va) {
  12896. if ($va == '往来交通费')
  12897. $c1 += $v ['price'];
  12898. if ($va == '市内交通费')
  12899. $c2 += $v ['price'];
  12900. if ($va == '出差住宿费')
  12901. $c3 += $v ['price'];
  12902. if ($va == '出差补助')
  12903. $c4 += $v ['price'];
  12904. if ($va == '其他费用')
  12905. $c5 += $v ['price'];
  12906. $psum += $v ['price'];
  12907. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12908. $falg = false;
  12909. break;
  12910. }
  12911. }
  12912. }
  12913. if ($falg)
  12914. $html .= '<td class="taR">-</td>';
  12915. }
  12916. $c6 += $psum;
  12917. if (! empty ( $psum ))
  12918. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12919. else
  12920. $psum = '<td class="colGreen taR">-</td>';
  12921. $receiptL ['差旅相关费用'] = $psum . $html;
  12922. /* ------------------------------------- */
  12923. $html = "";
  12924. $psum = 0;
  12925. $item = array (
  12926. '场租费',
  12927. '薪酬',
  12928. '住宿费',
  12929. '交通费',
  12930. '餐饮费',
  12931. '办公费',
  12932. '公关费',
  12933. '其他'
  12934. );
  12935. foreach ( $item as $va ) {
  12936. $falg = true;
  12937. foreach ( $receiptCollectList as $v ) {
  12938. if ($v ['itemCategory'] == '培训班费用') {
  12939. if ($v ['item'] == $va) {
  12940. if ($va == '场租费')
  12941. $p1 += $v ['price'];
  12942. if ($va == '薪酬')
  12943. $p2 += $v ['price'];
  12944. if ($va == '住宿费')
  12945. $p3 += $v ['price'];
  12946. if ($va == '交通费')
  12947. $p4 += $v ['price'];
  12948. if ($va == '餐饮费')
  12949. $p5 += $v ['price'];
  12950. if ($va == '办公费')
  12951. $p6 += $v ['price'];
  12952. if ($va == '公关费')
  12953. $p7 += $v ['price'];
  12954. if ($va == '其他')
  12955. $p8 += $v ['price'];
  12956. $psum += $v ['price'];
  12957. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12958. $falg = false;
  12959. break;
  12960. }
  12961. }
  12962. }
  12963. if ($falg)
  12964. $html .= '<td class="taR">-</td>';
  12965. }
  12966. $p9 += $psum;
  12967. if (! empty ( $psum ))
  12968. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12969. else
  12970. $psum = '<td class="colGreen taR">-</td>';
  12971. $receiptL ['培训班费用'] = $psum . $html;
  12972. /* ------------------------------------- */
  12973. $html = "";
  12974. $psum = 0;
  12975. $item = array (
  12976. '公关费',
  12977. '广告费',
  12978. '借款',
  12979. '可自加费用'
  12980. );
  12981. foreach ( $item as $va ) {
  12982. $falg = true;
  12983. foreach ( $receiptCollectList as $v ) {
  12984. if ($v ['itemCategory'] == '其他') {
  12985. if ($v ['item'] == $va) {
  12986. if ($va == '公关费')
  12987. $t1 += $v ['price'];
  12988. if ($va == '广告费')
  12989. $t2 += $v ['price'];
  12990. if ($va == '借款')
  12991. $t3 += $v ['price'];
  12992. if ($va == '可自加费用')
  12993. $t4 += $v ['price'];
  12994. $psum += $v ['price'];
  12995. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12996. $falg = false;
  12997. break;
  12998. }
  12999. }
  13000. }
  13001. if ($falg)
  13002. $html .= '<td class="taR">-</td>';
  13003. }
  13004. $t5 += $psum;
  13005. if (! empty ( $psum ))
  13006. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13007. else
  13008. $psum = '<td class="colGreen taR">-</td>';
  13009. $receiptL ['其他'] = $psum . $html;
  13010. /* ------------------------------------- */
  13011. $html = "";
  13012. $psum = 0;
  13013. foreach ( $receiptCollectList as $v ) {
  13014. if ($v ['itemCategory'] == '报销金额调整') {
  13015. if (! empty ( $v ['price'] )) {
  13016. $psum += $v ['price'];
  13017. }
  13018. }
  13019. }
  13020. $s1 += $psum;
  13021. if (! empty ( $psum ))
  13022. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  13023. else
  13024. $psum = '<td class="taR colOrange">-</td>';
  13025. $receiptL ['报销金额调整'] = $psum . $html;
  13026. } else {
  13027. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13028. <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>';
  13029. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  13030. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13031. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13032. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13033. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13034. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13035. }
  13036. $monthStaffPrice = $receiptDetail->find ( array (
  13037. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13038. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13039. 'asArray' => true
  13040. ) );
  13041. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  13042. $m1 += $monthStaffPrice [0] ['price'];
  13043. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13044. } else
  13045. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13046. $list [$value ['username']] = $receiptL;
  13047. }
  13048. }
  13049. $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>
  13050. <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>
  13051. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  13052. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  13053. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  13054. $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>
  13055. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  13056. $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>';
  13057. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  13058. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  13059. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  13060. }
  13061. $data ['list'] = $list;
  13062. $receiptCollectList = $receiptDetail->find ( array (
  13063. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13064. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13065. 'groupby' => 'item,Month(date),itemCategory',
  13066. 'asArray' => true
  13067. ) );
  13068. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  13069. // statistics html
  13070. $stList = $statistics->getOne ( array (
  13071. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13072. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13073. 'groupby' => 'Month(date)',
  13074. 'asArray' => true
  13075. ) );
  13076. if (empty ( $stList ))
  13077. $stList = array (
  13078. 'rePrice' => 0,
  13079. 'agPrice' => 0
  13080. );
  13081. $data ['stList'] = array (
  13082. 'rePrice' => $stList ['rePrice'],
  13083. 'agPrice' => $stList ['agPrice'],
  13084. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13085. );
  13086. $monthHtml = "";
  13087. for($i = 1; $i <= 12; $i ++) {
  13088. if ($i == $month)
  13089. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13090. else
  13091. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13092. }
  13093. $data ['monthHtml'] = $monthHtml;
  13094. $data ['year'] = $year;
  13095. $data ['month'] = $month;
  13096. $data ['memu'] = "receipt";
  13097. $data ['staff'] = $this->staff;
  13098. $data ['receiptMemu'] = 'companyCategoryCollect';
  13099. $data ['verifyId'] = $this->verifyId;
  13100. $data ['executeId'] = $this->executeId;
  13101. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  13102. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13103. }
  13104. /**
  13105. * 用户报销单列表
  13106. */
  13107. function receiptStatisticsStaffDetail() {
  13108. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13109. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13110. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13111. Doo::loadModel ( "receipt" );
  13112. $receipt = new receipt ();
  13113. Doo::loadModel ( "receiptDetail" );
  13114. $receiptDetail = new receiptDetail ();
  13115. Doo::loadModel ( 'staff' );
  13116. $staff = new staff ();
  13117. Doo::loadModel ( 'accountItem' );
  13118. $accountItem = new accountItem ();
  13119. Doo::loadModel ( 'statistics' );
  13120. $statistics = new statistics ();
  13121. if (! empty ( $username )) {
  13122. $username = addslashes ( urldecode ( $username ) );
  13123. $staffDetail = $staff->getStaffByName ( $username );
  13124. if (empty ( $staffDetail ))
  13125. die ( 'illegal request' );
  13126. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  13127. $itemList = $accountItem->getAccountItem ();
  13128. $itemHtml = '';
  13129. $categoryHtml = '';
  13130. $itemKeyList = array_keys ( $itemList );
  13131. $revisePrice = 0;
  13132. // 报销单内容详情
  13133. foreach ( $list as $key => $value ) {
  13134. $accountItemList = json_decode ( $value ['accountItem'], true );
  13135. $list [$key] ['accountItemList'] = $accountItemList;
  13136. $receiptItemHtml = '';
  13137. foreach ( $itemKeyList as $v ) {
  13138. if ($v == '日常相关费用')
  13139. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  13140. elseif ($v == '差旅相关费用')
  13141. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  13142. elseif ($v == '培训班费用')
  13143. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  13144. elseif ($v == '内部培训费用'){
  13145. if (isset($accountItemList ['cSum'] ['inttrainSum'])){
  13146. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['inttrainSum'] . '</td>';
  13147. }else{
  13148. $receiptItemHtml .= '<td class="colGreen taR">0</td>';
  13149. }
  13150. }elseif ($v == '其他')
  13151. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  13152. foreach ( $itemList [$v] as $ke => $va ) {
  13153. $falg = true;
  13154. if (! empty ( $accountItemList [$v] )) {
  13155. foreach ( $accountItemList [$v] as $ve ) {
  13156. if ($va ['name'] == $ve ['name']) {
  13157. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  13158. $falg = false;
  13159. break;
  13160. }
  13161. }
  13162. }
  13163. if ($falg)
  13164. $receiptItemHtml .= '<td class="taR"></td>';
  13165. }
  13166. }
  13167. // 金额调整和费用查看
  13168. $revisePrice += $value ['revisePrice'];
  13169. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  13170. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" id="sen'.$key.'" data="' . htmlspecialchars($value ['explanation']) . '" onclick=showExplanation() >查看</a></td>';
  13171. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  13172. }
  13173. // 报销单合计
  13174. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  13175. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  13176. $receiptTotalHtml = '';
  13177. // 报销单项目抬头
  13178. foreach ( $itemKeyList as $value ) {
  13179. $count = count ( $itemList [$value] ) + 1;
  13180. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  13181. $categoryHtml .= '<th class="taC">合计</th>';
  13182. $sumfalg=true;
  13183. foreach ( $rtl as $rtlValue ) {
  13184. if ($rtlValue ['itemCategory'] == $value) {
  13185. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  13186. $sumfalg=false;
  13187. break;
  13188. }
  13189. }
  13190. if ($sumfalg)
  13191. $receiptTotalHtml .= '<th></th>';
  13192. foreach ( $itemList [$value] as $k => $v ) {
  13193. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  13194. // 合计
  13195. $falg = true;
  13196. foreach ( $receiptTotalList as $ve ) {
  13197. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  13198. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  13199. $falg = false;
  13200. break;
  13201. }
  13202. }
  13203. if ($falg)
  13204. $receiptTotalHtml .= '<th></th>';
  13205. }
  13206. }
  13207. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  13208. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  13209. if (empty ( $stList ))
  13210. $stList = array (
  13211. 'rePrice' => 0,
  13212. 'agPrice' => 0
  13213. );
  13214. $data ['stList'] = array (
  13215. 'rePrice' => $stList ['rePrice'],
  13216. 'agPrice' => $stList ['agPrice'],
  13217. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13218. );
  13219. $monthHtml = "";
  13220. for($i = 1; $i <= 12; $i ++) {
  13221. if ($i == $month)
  13222. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13223. else
  13224. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13225. }
  13226. $data ['username'] = urlencode ( $username );
  13227. $data ['usernameEN'] = $username;
  13228. $data ['monthHtml'] = $monthHtml;
  13229. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  13230. $data ['list'] = $list;
  13231. $data ['categoryHtml'] = $categoryHtml;
  13232. $data ['itemHtml'] = $itemHtml;
  13233. $data ['itemList'] = $itemList;
  13234. $data ['year'] = $year;
  13235. $data ['month'] = $month;
  13236. $data ['memu'] = "receipt";
  13237. $data ['staff'] = $this->staff;
  13238. $data ['receiptMemu'] = 'companyCategoryCollect';
  13239. $data ['verifyId'] = $this->verifyId;
  13240. $data ['executeId'] = $this->executeId;
  13241. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  13242. }
  13243. die ( 'illegal request' );
  13244. }
  13245. function companyMonthCollectDetail() {
  13246. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13247. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13248. if (! $year)
  13249. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13250. if (! $month)
  13251. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13252. Doo::loadModel ( 'staff' );
  13253. $staff = new staff ();
  13254. Doo::loadModel ( "receiptDetail" );
  13255. $receiptDetail = new receiptDetail ();
  13256. Doo::loadModel ( 'accountItem' );
  13257. $accountItem = new accountItem ();
  13258. Doo::loadModel ( 'statistics' );
  13259. $statistics = new statistics ();
  13260. Doo::loadModel ( 'L_category' );
  13261. $lCategory = new L_category ();
  13262. $staffList = $staff->find ( array (
  13263. 'where' => 'username!="admin"',
  13264. 'asArray' => true
  13265. ) );
  13266. $categoryList = $lCategory->find ( array (
  13267. 'asArray' => true
  13268. ) );
  13269. $aiList=$accountItem->getAccountItem();
  13270. $list = array ();
  13271. foreach ( $categoryList as $value ) {
  13272. $receiptCollectList = $receiptDetail->find ( array (
  13273. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13274. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13275. 'groupby' => 'item,Month(pastDate),itemCategory',
  13276. 'asArray' => true
  13277. ) );
  13278. if (! empty ( $receiptCollectList )) {
  13279. $receiptL = array (
  13280. '日常相关费用' => array (),
  13281. '差旅相关费用' => array (),
  13282. '内部培训费用' => array (),
  13283. '培训班费用' => array (),
  13284. '其他' => array ()
  13285. );
  13286. $html = "";
  13287. $psum = 0;
  13288. foreach ( $aiList[$this->AGENCY] as $va ) {
  13289. $falg = true;
  13290. foreach ( $receiptCollectList as $v ) {
  13291. if ($v ['itemCategory'] == $this->AGENCY) {
  13292. if ($v ['item'] == $va['name']) {
  13293. $psum += $v ['price'];
  13294. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13295. $falg = false;
  13296. break;
  13297. }
  13298. }
  13299. }
  13300. if ($falg)
  13301. $html .= '<td class="taR">-</td>';
  13302. }
  13303. if (! empty ( $psum ))
  13304. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13305. else
  13306. $psum = '<td class="colGreen taR">-</td>';
  13307. $receiptL [$this->AGENCY] = $psum . $html;
  13308. /* ----------------------------------- */
  13309. $html = "";
  13310. $psum = 0;
  13311. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13312. $falg = true;
  13313. foreach ( $receiptCollectList as $v ) {
  13314. if ($v ['itemCategory'] == $this->TRAVEL) {
  13315. if ($v ['item'] == $va['name']) {
  13316. $psum += $v ['price'];
  13317. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13318. $falg = false;
  13319. break;
  13320. }
  13321. }
  13322. }
  13323. if ($falg)
  13324. $html .= '<td class="taR">-</td>';
  13325. }
  13326. if (! empty ( $psum ))
  13327. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13328. else
  13329. $psum = '<td class="colGreen taR">-</td>';
  13330. $receiptL [$this->TRAVEL] = $psum . $html;
  13331. /* ------------------------------------- */
  13332. $html = "";
  13333. $psum = 0;
  13334. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13335. $falg = true;
  13336. foreach ( $receiptCollectList as $v ) {
  13337. if ($v ['itemCategory'] == $this->INTTRAIN) {
  13338. if ($v ['item'] == $va['name']) {
  13339. $psum += $v ['price'];
  13340. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13341. $falg = false;
  13342. break;
  13343. }
  13344. }
  13345. }
  13346. if ($falg)
  13347. $html .= '<td class="taR">-</td>';
  13348. }
  13349. if (! empty ( $psum ))
  13350. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13351. else
  13352. $psum = '<td class="colGreen taR">-</td>';
  13353. $receiptL [$this->INTTRAIN] = $psum . $html;
  13354. /* ------------------------------------- */
  13355. $html = "";
  13356. $psum = 0;
  13357. foreach ( $aiList[$this->TRAIN] as $va ) {
  13358. $falg = true;
  13359. foreach ( $receiptCollectList as $v ) {
  13360. if ($v ['itemCategory'] == $this->TRAIN) {
  13361. if ($v ['item'] == $va['name']) {
  13362. $psum += $v ['price'];
  13363. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13364. $falg = false;
  13365. break;
  13366. }
  13367. }
  13368. }
  13369. if ($falg)
  13370. $html .= '<td class="taR">-</td>';
  13371. }
  13372. if (! empty ( $psum ))
  13373. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13374. else
  13375. $psum = '<td class="colGreen taR">-</td>';
  13376. $receiptL [$this->TRAIN] = $psum . $html;
  13377. /* ------------------------------------- */
  13378. $html = "";
  13379. $psum = 0;
  13380. foreach ( $aiList[$this->OTHER] as $va ) {
  13381. $falg = true;
  13382. foreach ( $receiptCollectList as $v ) {
  13383. if ($v ['itemCategory'] == $this->OTHER) {
  13384. if ($v ['item'] == $va['name']) {
  13385. $psum += $v ['price'];
  13386. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13387. $falg = false;
  13388. break;
  13389. }
  13390. }
  13391. }
  13392. if ($falg)
  13393. $html .= '<td class="taR">-</td>';
  13394. }
  13395. if (! empty ( $psum ))
  13396. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13397. else
  13398. $psum = '<td class="colGreen taR">-</td>';
  13399. $receiptL [$this->OTHER] = $psum . $html;
  13400. /* ------------------------------------- */
  13401. $html = "";
  13402. $psum = 0;
  13403. foreach ( $receiptCollectList as $v ) {
  13404. if ($v ['itemCategory'] == '报销金额调整') {
  13405. if (! empty ( $v ['price'] ))
  13406. $psum += $v ['price'];
  13407. }
  13408. }
  13409. if (! empty ( $psum ))
  13410. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  13411. else
  13412. $psum = '<td class="taR colOrange">-</td>';
  13413. $receiptL ['报销金额调整'] = $psum . $html;
  13414. } else {
  13415. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  13416. foreach ( $aiList[$this->AGENCY] as $va ) {
  13417. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  13418. }
  13419. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  13420. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13421. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  13422. }
  13423. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  13424. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13425. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  13426. }
  13427. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  13428. foreach ( $aiList[$this->TRAIN] as $va ) {
  13429. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  13430. }
  13431. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  13432. foreach ( $aiList[$this->OTHER] as $va ) {
  13433. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  13434. }
  13435. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13436. }
  13437. $monthStaffPrice = $receiptDetail->find ( array (
  13438. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13439. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13440. 'asArray' => true
  13441. ) );
  13442. if (! empty ( $monthStaffPrice [0] ['price'] ))
  13443. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13444. else
  13445. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13446. $list [$value ['title']] = $receiptL;
  13447. }
  13448. $data ['list'] = $list;
  13449. $receiptCollectList = $receiptDetail->find ( array (
  13450. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13451. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13452. 'groupby' => 'item,Month(pastDate),itemCategory',
  13453. 'asArray' => true
  13454. ) );
  13455. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  13456. //print_r($data['monthPriceHtml']);
  13457. // foreach ($data['monthPriceHtml'] as $value){
  13458. // echo $value;
  13459. // }
  13460. // die;
  13461. // statistics html
  13462. $stList = $statistics->getOne ( array (
  13463. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13464. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13465. 'groupby' => 'Month(date)',
  13466. 'asArray' => true
  13467. ) );
  13468. if (empty ( $stList ))
  13469. $stList = array (
  13470. 'rePrice' => 0,
  13471. 'agPrice' => 0
  13472. );
  13473. $data ['stList'] = array (
  13474. 'rePrice' => $stList ['rePrice'],
  13475. 'agPrice' => $stList ['agPrice'],
  13476. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13477. );
  13478. $monthHtml = "";
  13479. for($i = 1; $i <= 12; $i ++) {
  13480. if ($i == $month)
  13481. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13482. else
  13483. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13484. }
  13485. $data ['aiList'] = $aiList;
  13486. $dateHtml = "";
  13487. $now = date ( "Y" );
  13488. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  13489. if ($YEARD <= $now) {
  13490. $dateHtml .= '<option ';
  13491. if ($year == $YEARD) {
  13492. $dateHtml .= 'selected ';
  13493. }
  13494. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  13495. }
  13496. }
  13497. $data ['dateHtml'] = $dateHtml;
  13498. $data ['monthHtml'] = $monthHtml;
  13499. $data ['year'] = $year;
  13500. $data ['month'] = $month;
  13501. $data ['memu'] = "receipt";
  13502. $data ['staff'] = $this->staff;
  13503. $data ['receiptMemu'] = 'companyCategoryCollect';
  13504. $data ['verifyId'] = $this->verifyId;
  13505. $data ['executeId'] = $this->executeId;
  13506. $this->render ( "/admin/companyMonthCollectDetail", $data );
  13507. }
  13508. function staffCollectDetail() {
  13509. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  13510. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13511. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  13512. if (! $staffname) {
  13513. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  13514. $staffname = urldecode ( $staffname );
  13515. }
  13516. Doo::loadModel ( 'staff' );
  13517. $staff = new staff ();
  13518. Doo::loadModel ( "receiptDetail" );
  13519. $receiptDetail = new receiptDetail ();
  13520. Doo::loadModel ( 'accountItem' );
  13521. $accountItem = new accountItem ();
  13522. Doo::loadModel ( 'statistics' );
  13523. $statistics = new statistics ();
  13524. Doo::loadModel ( 'L_category' );
  13525. $lCategory = new L_category ();
  13526. Doo::loadModel ( "receiptAuthorityManage" );
  13527. $receiptAuthorityManage = new receiptAuthorityManage ();
  13528. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  13529. $cidList = array ();
  13530. foreach ( $imcStaff as $key => $value ) {
  13531. array_push ( $cidList, $value ['cid'] );
  13532. }
  13533. $cidString = implode ( ',', $cidList );
  13534. $staffList = $staff->find ( array (
  13535. 'where' => ' cid in (' . $cidString . ')',
  13536. 'asArray' => true
  13537. ) );
  13538. $stHtml = '';
  13539. $stTitle = "";
  13540. $staffId = 0;
  13541. $cid = 0;
  13542. $ocid = 0;
  13543. foreach ( $staffList as $value ) {
  13544. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  13545. $stTitle = $value ['category'] . '-' . $value ['username'];
  13546. $staffId = $value ['sid'];
  13547. $cid = $value ['cid'];
  13548. $ocid = $value ['cid'];
  13549. if (! empty ( $value ['othercid'] ))
  13550. $cid = $value ['cid'] . ',' . $value ['othercid'];
  13551. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13552. } elseif ($value ['username'] != 'admin')
  13553. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13554. }
  13555. $data ['lCategoryHtml'] = $lCategory->find ( array (
  13556. 'where' => 'cid in(' . $cid . ')',
  13557. 'asArray' => true
  13558. ) );
  13559. if (empty ( $pcid ))
  13560. $pcid = $ocid;
  13561. $data ['ocid'] = $pcid;
  13562. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  13563. $this->showCache ( $path );
  13564. //
  13565. $receiptCollectList = $receiptDetail->find ( array (
  13566. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13567. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  13568. 'groupby' => 'item,Month(pastDate),itemCategory',
  13569. 'asArray' => true
  13570. ) );
  13571. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  13572. // print_r($receiptCollectList);
  13573. $accountList = $accountItem->find ( array (
  13574. 'asArray' => true
  13575. ) );
  13576. // create CollectDetail HTML
  13577. $collectHtml = array ();
  13578. foreach ( $accountList as $key => $value ) {
  13579. $html = "";
  13580. $asum = 0;
  13581. for($i = 1; $i <= 12; $i ++) {
  13582. $falg = true;
  13583. foreach ( $receiptCollectList as $v ) {
  13584. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  13585. if ($v ['item'] == '可自加费用') {
  13586. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  13587. }
  13588. $asum += $v ['price'];
  13589. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13590. $falg = false;
  13591. break;
  13592. }
  13593. }
  13594. if ($falg)
  13595. $html .= '<td class="taR">-</td>';
  13596. }
  13597. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  13598. $collectHtml [$value ['category']] [$value ['name']] = $html;
  13599. }
  13600. $data ['collectHtml'] = $collectHtml;
  13601. // print_r($collectHtml);
  13602. // create Adjustment price html
  13603. $receiptCollectList = $receiptDetail->find ( array (
  13604. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  13605. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  13606. 'groupby' => 'itemCategory,Month(pastDate)',
  13607. 'asArray' => true
  13608. ) );
  13609. $adjustment = array ();
  13610. $collectArray = array (
  13611. '日常相关费用' => array (),
  13612. '差旅相关费用' => array (),
  13613. '培训班费用' => array (),
  13614. '内部培训费用'=>array(),
  13615. '其他' => array ()
  13616. );
  13617. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  13618. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  13619. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  13620. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  13621. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  13622. array_push ( $collectArray ['培训班费用'], $collectHtml );
  13623. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  13624. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  13625. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  13626. array_push ( $collectArray ['其他'], $collectHtml );
  13627. $data ['collectArray'] = $collectArray;
  13628. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  13629. array_push ( $adjustment, $collectHtml );
  13630. $data ['adjustment'] = $adjustment;
  13631. // total price html
  13632. $collectHtml = "";
  13633. $total = 0;
  13634. for($i = 1; $i <= 12; $i ++) {
  13635. $sumPrice = 0;
  13636. foreach ( $receiptCollectList as $key => $value ) {
  13637. if ($value ['month'] == $i) {
  13638. $sumPrice += $value ['price'];
  13639. }
  13640. }
  13641. if ($sumPrice == 0)
  13642. $collectHtml .= '<td class="taR">-</td>';
  13643. else
  13644. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  13645. $total += $sumPrice;
  13646. }
  13647. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  13648. // statistics html
  13649. $stList = $statistics->statisticsByYear ( $year, $staffId );
  13650. if (empty ( $stList ))
  13651. $stList = array (
  13652. 'rePrice' => 0,
  13653. 'agPrice' => 0
  13654. );
  13655. $data ['stList'] = array (
  13656. 'rePrice' => $stList ['rePrice'],
  13657. 'agPrice' => $stList ['agPrice'],
  13658. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13659. );
  13660. $data ['totalPrice'] = $collectHtml;
  13661. $data ['totalYear'] = $total;
  13662. $data ['stHtml'] = $stHtml;
  13663. $data ['year'] = $year;
  13664. $data ['stTitle'] = $stTitle;
  13665. $data ['staffname'] = urlencode ( $staffname );
  13666. $data ['memu'] = "receipt";
  13667. $data ['staff'] = $this->staff;
  13668. $data ['receiptMemu'] = 'companyCategoryCollect';
  13669. $data ['verifyId'] = $this->verifyId;
  13670. $data ['executeId'] = $this->executeId;
  13671. if ($year < date ( "Y" )) {
  13672. Doo::loadModel ( 'receipt' );
  13673. $receipt = new receipt ();
  13674. $receiptList = $receipt->find ( array (
  13675. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  13676. 'asArray' => true
  13677. ) );
  13678. if (empty ( $receiptList )) { // generated files
  13679. ob_start ();
  13680. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13681. $this->cacheFile ( $path );
  13682. die ();
  13683. }
  13684. }
  13685. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13686. }
  13687. function BUGFLAG() {
  13688. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  13689. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  13690. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13691. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  13692. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  13693. if (empty ( $status ))
  13694. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  13695. $page_size = 12;
  13696. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  13697. $vidList = array ();
  13698. $button = 0;
  13699. Doo::loadModel ( 'verify' );
  13700. $verify = new verify ();
  13701. Doo::loadModel ( 'receipt' );
  13702. $receipt = new receipt ();
  13703. Doo::loadModel ( 'staff' );
  13704. $staff = new staff ();
  13705. Doo::loadModel ( 'L_category' );
  13706. $Lcategory = new L_category ();
  13707. $dateCondition = " and Year(date) =" . $year;
  13708. if (! empty ( $month ))
  13709. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  13710. $categoryList = $Lcategory->find ( array (
  13711. 'asArray' => true
  13712. ) );
  13713. $staffList = $staff->find ( array (
  13714. 'where' => 'cid=' . $cid,
  13715. 'asArray' => true
  13716. ) );
  13717. $cateCondition = "";
  13718. $staffCondition = "";
  13719. $approvalCondition = "";
  13720. if (! empty ( $cid ))
  13721. $cateCondition = ' and cid=' . $cid;
  13722. if (! empty ( $sid )) {
  13723. $staffCondition = ' and staff=' . $sid;
  13724. $cateCondition = "";
  13725. }
  13726. $approvalCondition = " and status=" . $status;
  13727. if ($status == 2) {
  13728. // 查找角色审批人
  13729. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  13730. }
  13731. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  13732. $approvalCondition = ' and status=2 ';
  13733. }
  13734. if ($status == 1) {
  13735. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  13736. }
  13737. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  13738. $pageinfo ['page'] = array (
  13739. 'previous' => ''
  13740. );
  13741. if ($status == 0) {
  13742. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  13743. $receiptList = $receipt->find ( array (
  13744. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  13745. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  13746. 'desc' => 'rid',
  13747. 'asArray' => true
  13748. ) );
  13749. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  13750. } else
  13751. $receiptList = $receipt->find ( array (
  13752. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  13753. 'desc' => 'rid',
  13754. 'asArray' => true
  13755. ) );
  13756. $rLRes = $receipt->find ( array (
  13757. '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,
  13758. 'desc' => 'rid',
  13759. 'asArray' => true
  13760. ) );
  13761. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  13762. // print_r($pageinfo);
  13763. $Locate = 0;
  13764. foreach ( $receiptList as $key => $value ) {
  13765. $receiptList [$key] ['Locate'] = $Locate;
  13766. $Locate ++;
  13767. $receiptList [$key] ['reviseDetail'] = array ();
  13768. if (! empty ( $value ['reviseDetail'] ))
  13769. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  13770. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  13771. $categoryDetil = $Lcategory->getOne ( array (
  13772. 'where' => 'cid=' . $value ['cid'],
  13773. 'asArray' => true
  13774. ) );
  13775. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  13776. $verifyList = $verify->getOne ( array (
  13777. 'where' => 'vid=' . $value ['verify'],
  13778. 'asArray' => true
  13779. ) );
  13780. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  13781. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  13782. foreach ( $verifyList as $k => $v ) {
  13783. // init verifyStaff
  13784. $verifyList [$k] ['date'] = "";
  13785. $verifyList [$k] ['opinion'] = "";
  13786. $verifyList [$k] ['status'] = "";
  13787. if (empty ( $verifyStaff )) {
  13788. $verifyList [$k] ['date'] = "";
  13789. $verifyList [$k] ['opinion'] = "";
  13790. if ($v [0] == $this->staff [0] ['sid']) {
  13791. $verifyList [$k] ['status'] = 4;
  13792. $button = 4;
  13793. }
  13794. } else {
  13795. $flag = true;
  13796. foreach ( $verifyStaff as $m => $u ) {
  13797. if ($v [0] == $m) {
  13798. $verifyList [$k] ['date'] = $u ['date'];
  13799. $verifyList [$k] ['opinion'] = $u ['opinion'];
  13800. $verifyList [$k] ['status'] = $u ['status'];
  13801. $flag = false;
  13802. break;
  13803. }
  13804. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  13805. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  13806. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  13807. }
  13808. if ($flag) { // 检测可编辑
  13809. if ($v [0] == $this->staff [0] ['sid']) {
  13810. $verifyList [$k] ['status'] = 4;
  13811. $button = 4;
  13812. }
  13813. }
  13814. }
  13815. }
  13816. $receiptList [$key] ['verifyList'] = $verifyList;
  13817. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  13818. 'where' => 'sid=' . $value ['staff'],
  13819. 'asArray' => true
  13820. ) );
  13821. $receiptList [$key] ['button'] = $button;
  13822. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  13823. }
  13824. // print_r($receiptList);die;
  13825. // $data['verifyDetail']=$verifyDetail;
  13826. $mothHtml = "";
  13827. for($i = 1; $i <= 12; $i ++) {
  13828. if ($month == $i)
  13829. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  13830. else
  13831. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  13832. }
  13833. $data ['mothHtml'] = $mothHtml;
  13834. $data ['page'] = $pageinfo;
  13835. $data ['receiptList'] = $receiptList;
  13836. $data ['receiptApprovalCount'] = count ( $rLRes );
  13837. $data ['status'] = $status;
  13838. $data ['year'] = $year;
  13839. $data ['categoryList'] = $categoryList;
  13840. $data ['staffList'] = $staffList;
  13841. $data ['cid'] = $cid;
  13842. $data ['sid'] = $sid;
  13843. // print_r($receiptList);
  13844. $data ['memu'] = "receipt";
  13845. $data ['staff'] = $this->staff;
  13846. $data ['receiptMemu'] = 'approvalExpenses';
  13847. $data ['verifyId'] = $this->verifyId;
  13848. $data ['executeId'] = $this->executeId;
  13849. $this->render ( "/admin/FALG", $data );
  13850. }
  13851. function ajaxGetReceiptOrder() {
  13852. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  13853. if (! empty ( $receiptOrder )) {
  13854. Doo::loadModel ( 'receipt' );
  13855. $receipt = new receipt ();
  13856. Doo::loadModel ( 'staff' );
  13857. $staff = new staff ();
  13858. $receiptInfo = $receipt->getOne ( array (
  13859. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  13860. 'asArray' => true
  13861. ) );
  13862. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  13863. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  13864. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  13865. </tbody></table><table class="table table table-bordered"><tbody>';
  13866. foreach ( $verifyStaff as $key => $value ) {
  13867. $staffInfo = $staff->getOne ( array (
  13868. 'select' => 'username',
  13869. 'where' => ' sid="' . $key . '"',
  13870. 'asArray' => true
  13871. ) );
  13872. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  13873. }
  13874. $html .= '</tbody></table></div></div>';
  13875. echo json_encode ( array (
  13876. 'status' => 1,
  13877. 'receiptHtml' => $html
  13878. ) );
  13879. die ();
  13880. }
  13881. echo json_encode ( array (
  13882. 'status' => 2,
  13883. 'receiptHtml' => ''
  13884. ) );
  13885. die ();
  13886. }
  13887. function _getMonthCollectDetail($receiptCollectList,$aiList) {
  13888. if (! empty ( $receiptCollectList )) {
  13889. $receiptL = array (
  13890. '日常相关费用' => array (),
  13891. '差旅相关费用' => array (),
  13892. '内部培训费用'=>array(),
  13893. '培训班费用' => array (),
  13894. '其他' => array ()
  13895. );
  13896. $html = "";
  13897. $psum = 0;
  13898. foreach ( $aiList[$this->AGENCY] as $value ) {
  13899. $falg = true;
  13900. foreach ( $receiptCollectList as $v ) {
  13901. if ($v ['itemCategory'] == '日常相关费用') {
  13902. if ($v ['item'] == $value['name']) {
  13903. $psum += $v ['price'];
  13904. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13905. $falg = false;
  13906. break;
  13907. }
  13908. }
  13909. }
  13910. if ($falg)
  13911. $html .= '<td class="taR">-</td>';
  13912. }
  13913. if (! empty ( $psum ))
  13914. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13915. else
  13916. $psum = '<td class="colGreen taR">-</td>';
  13917. $receiptL ['日常相关费用'] = $psum . $html;
  13918. /* ----------------------------------- */
  13919. $html = "";
  13920. $psum = 0;
  13921. foreach ( $aiList[$this->TRAVEL] as $value ) {
  13922. $falg = true;
  13923. foreach ( $receiptCollectList as $v ) {
  13924. if ($v ['itemCategory'] == '差旅相关费用') {
  13925. if ($v ['item'] == $value['name']) {
  13926. $psum += $v ['price'];
  13927. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13928. $falg = false;
  13929. break;
  13930. }
  13931. }
  13932. }
  13933. if ($falg)
  13934. $html .= '<td class="taR">-</td>';
  13935. }
  13936. if (! empty ( $psum ))
  13937. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13938. else
  13939. $psum = '<td class="colGreen taR">-</td>';
  13940. $receiptL ['差旅相关费用'] = $psum . $html;
  13941. /* ----------------------------------- */
  13942. $html = "";
  13943. $psum = 0;
  13944. foreach ( $aiList[$this->INTTRAIN] as $value ) {
  13945. $falg = true;
  13946. foreach ( $receiptCollectList as $v ) {
  13947. if ($v ['itemCategory'] == '内部培训费用') {
  13948. if ($v ['item'] == $value['name']) {
  13949. $psum += $v ['price'];
  13950. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13951. $falg = false;
  13952. break;
  13953. }
  13954. }
  13955. }
  13956. if ($falg)
  13957. $html .= '<td class="taR">-</td>';
  13958. }
  13959. if (! empty ( $psum ))
  13960. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13961. else
  13962. $psum = '<td class="colGreen taR">-</td>';
  13963. $receiptL ['内部培训费用'] = $psum . $html;
  13964. /* ------------------------------------- */
  13965. $html = "";
  13966. $psum = 0;
  13967. foreach ( $aiList[$this->TRAIN] as $value ) {
  13968. $falg = true;
  13969. foreach ( $receiptCollectList as $v ) {
  13970. if ($v ['itemCategory'] == '培训班费用') {
  13971. if ($v ['item'] == $value['name']) {
  13972. $psum += $v ['price'];
  13973. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13974. $falg = false;
  13975. break;
  13976. }
  13977. }
  13978. }
  13979. if ($falg)
  13980. $html .= '<td class="taR">-</td>';
  13981. }
  13982. if (! empty ( $psum ))
  13983. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13984. else
  13985. $psum = '<td class="colGreen taR">-</td>';
  13986. $receiptL ['培训班费用'] = $psum . $html;
  13987. /* ------------------------------------- */
  13988. $html = "";
  13989. $psum = 0;
  13990. foreach ( $aiList[$this->OTHER] as $value ) {
  13991. $falg = true;
  13992. foreach ( $receiptCollectList as $v ) {
  13993. if ($v ['itemCategory'] == '其他') {
  13994. if ($v ['item'] == $value['name']) {
  13995. $psum += $v ['price'];
  13996. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13997. $falg = false;
  13998. break;
  13999. }
  14000. }
  14001. }
  14002. if ($falg)
  14003. $html .= '<td class="taR">-</td>';
  14004. }
  14005. if (! empty ( $psum ))
  14006. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14007. else
  14008. $psum = '<td class="colGreen taR">-</td>';
  14009. $receiptL ['其他'] = $psum . $html;
  14010. /* ------------------------------------- */
  14011. $html = "";
  14012. $psum = 0;
  14013. foreach ( $receiptCollectList as $v ) {
  14014. if ($v ['itemCategory'] == '报销金额调整') {
  14015. if (! empty ( $v ['price'] ))
  14016. $psum += $v ['price'];
  14017. }
  14018. }
  14019. if (! empty ( $psum ))
  14020. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  14021. else
  14022. $psum = '<td class="taR colOrange">-</td>';
  14023. $receiptL ['报销金额调整'] = $psum . $html;
  14024. } else {
  14025. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  14026. foreach ( $aiList[$this->AGENCY] as $va ) {
  14027. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  14028. }
  14029. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  14030. foreach ( $aiList[$this->TRAVEL] as $va ) {
  14031. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  14032. }
  14033. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  14034. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  14035. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  14036. }
  14037. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  14038. foreach ( $aiList[$this->TRAIN] as $va ) {
  14039. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  14040. }
  14041. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  14042. foreach ( $aiList[$this->OTHER] as $va ) {
  14043. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  14044. }
  14045. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  14046. }
  14047. return $receiptL;
  14048. }
  14049. function eMail() {
  14050. Doo::loadModel ( 'staff' );
  14051. $staff = new staff ();
  14052. Doo::loadModel ( 'receipt' );
  14053. $receipt = new receipt ();
  14054. Doo::loadModel ( 'L_category' );
  14055. $Lcategory = new L_category ();
  14056. Doo::loadModel ( "verify" );
  14057. $verify = new verify ();
  14058. $staffList = $staff->find ( array (
  14059. 'asArray' => true
  14060. ) );
  14061. foreach ( $staffList as $key => $value ) {
  14062. if ($value ['username'] != 'admin') {
  14063. // 提交人
  14064. $receiptList = $receipt->find ( array (
  14065. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  14066. 'asArray' => true
  14067. ) );
  14068. if (! empty ( $receiptList )) {
  14069. $html = '<br><div><style></style>
  14070. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  14071. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  14072. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14073. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  14074. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14075. <tbody><tr>
  14076. <td style="padding: 0 40px;" align="left">
  14077. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14078. </td></tr><tr>
  14079. <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>
  14080. </tr>
  14081. </tbody> </table></td> </tr> <tr><td>
  14082. <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">
  14083. <tbody> <tr><td>
  14084. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  14085. 以下报销单完成了审批,等着收款吧:</p>
  14086. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  14087. foreach ( $receiptList as $k => $v ) {
  14088. $category = $Lcategory->getOne ( array (
  14089. 'where' => 'cid=' . $v ['cid'],
  14090. 'asArray' => true
  14091. ) );
  14092. $html .= '
  14093. <tr>
  14094. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14095. <td align="left">
  14096. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  14097. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  14098. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  14099. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  14100. </tr>';
  14101. }
  14102. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  14103. <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>
  14104. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  14105. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  14106. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  14107. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14108. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14109. $receipt = new receipt ();
  14110. $receipt->notice = 1;
  14111. $receipt->update ( array (
  14112. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  14113. ) );
  14114. }
  14115. }
  14116. // 审批人
  14117. $verifyList = $verify->find ( array (
  14118. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  14119. 'asArray' => true
  14120. ) );
  14121. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  14122. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  14123. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14124. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  14125. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14126. <tbody><tr><td style="padding: 0 40px;" align="left">
  14127. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14128. </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>
  14129. </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">
  14130. <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>
  14131. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  14132. foreach ( $verifyList as $k => $v ) {
  14133. $receiptList = $receipt->find ( array (
  14134. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  14135. 'asArray' => true
  14136. ) );
  14137. foreach ( $receiptList as $r => $l ) {
  14138. $category = $Lcategory->getOne ( array (
  14139. 'where' => 'cid=' . $l ['cid'],
  14140. 'asArray' => true
  14141. ) );
  14142. $staffDetile = $staff->getOne ( array (
  14143. 'where' => 'sid=' . $l ['staff'],
  14144. 'asArray' => true
  14145. ) );
  14146. $html .= '
  14147. <tr>
  14148. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14149. <td align="left">
  14150. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  14151. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  14152. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  14153. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  14154. </tr>';
  14155. }
  14156. }
  14157. $html .= '
  14158. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  14159. <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>
  14160. </tr></tbody></table></td></tr></tbody></table></div><br>';
  14161. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  14162. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  14163. // $receipt=new receipt();
  14164. // $receipt->notice=1;
  14165. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  14166. }
  14167. }
  14168. }
  14169. }
  14170. function setWXMsg($rid, $type) {
  14171. Doo::loadModel ( "receipt" );
  14172. $receipt = new receipt ();
  14173. $receiptDetail = $receipt->getOne ( array (
  14174. 'where' => 'rid=' . $rid,
  14175. 'asArray' => true
  14176. ) );
  14177. if (! empty ( $receiptDetail )) {
  14178. Doo::loadModel ( 'staff' );
  14179. $staff = new staff ();
  14180. $staffmsg = $staff->getOne ( array (
  14181. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  14182. 'asArray' => TRUE
  14183. ) );
  14184. if (! empty ( $staffmsg ['wxid'] )) {
  14185. require_once (SITE_PATH . '/protected/class/client.php');
  14186. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  14187. $user = $staffmsg ['wxid'];
  14188. $receiptName = '';
  14189. $msg = '';
  14190. switch ($receiptDetail ['Rtype']) {
  14191. case 0 :
  14192. $receiptName = '报销';
  14193. break;
  14194. case 1 :
  14195. $receiptName = '借款';
  14196. break;
  14197. case 2 :
  14198. $receiptName = '对公汇款';
  14199. break;
  14200. }
  14201. switch ($type) {
  14202. case 1 :
  14203. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  14204. break;
  14205. case 2 :
  14206. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  14207. break;
  14208. case 3 :
  14209. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  14210. break;
  14211. }
  14212. // $result = $client->SendMsg ( $user, $msg, 'text' );
  14213. }
  14214. }
  14215. }
  14216. // Email发送函数
  14217. function SMail($toemail, $subject, $contents) {
  14218. Doo::loadClass ( 'class.phpmailer' );
  14219. $mail = new PHPMailer ();
  14220. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  14221. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  14222. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  14223. $mail->Password = "cDO1GjtY1seH"; // 密码
  14224. $mail->CharSet = "UTF8";
  14225. $mail->SMTPAuth = true;
  14226. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  14227. $mail->Mailer = "smtp";
  14228. $mail->Port = 25;
  14229. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  14230. $mail->MsgHTML ( $contents );
  14231. $mail->AddAddress ( $toemail );
  14232. $mail->CharSet = "UTF-8";
  14233. return $mail->Send ();
  14234. }
  14235. function h5Upload() {
  14236. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14237. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14238. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14239. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14240. header ( "HTTP/1.1 500 Internal Server Error" );
  14241. echo "POST exceeded maximum allowed size.";
  14242. exit ( 0 );
  14243. }
  14244. // Settings
  14245. $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)
  14246. $upload_name = "Filedata";
  14247. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14248. $extension_whitelist = array (
  14249. "doc",
  14250. "txt",
  14251. "jpg",
  14252. "gif",
  14253. "png"
  14254. ); // Allowed file extensions
  14255. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14256. // Other variables
  14257. $MAX_FILENAME_LENGTH = 260;
  14258. $file_name = "";
  14259. $file_extension = "";
  14260. $uploadErrors = array (
  14261. 0 => "文件上传成功",
  14262. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14263. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14264. 3 => "上传的文件仅为部分文件",
  14265. 4 => "没有文件上传",
  14266. 6 => "缺少临时文件夹"
  14267. );
  14268. $nk = time ();
  14269. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14270. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14271. echo "文件无法保存.";
  14272. exit ( 0 );
  14273. }
  14274. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14275. echo json_encode ( array (
  14276. 'filename' => $file_name,
  14277. 'id' => $nk
  14278. ) );
  14279. exit ( 0 );
  14280. }
  14281. function swfupload() {
  14282. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14283. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14284. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14285. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14286. header ( "HTTP/1.1 500 Internal Server Error" );
  14287. echo "POST exceeded maximum allowed size.";
  14288. exit ( 0 );
  14289. }
  14290. // Settings
  14291. $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)
  14292. $upload_name = "Filedata";
  14293. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14294. $extension_whitelist = array (
  14295. "doc",
  14296. "txt",
  14297. "jpg",
  14298. "gif",
  14299. "png"
  14300. ); // Allowed file extensions
  14301. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14302. // Other variables
  14303. $MAX_FILENAME_LENGTH = 260;
  14304. $file_name = "";
  14305. $file_extension = "";
  14306. $uploadErrors = array (
  14307. 0 => "文件上传成功",
  14308. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14309. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14310. 3 => "上传的文件仅为部分文件",
  14311. 4 => "没有文件上传",
  14312. 6 => "缺少临时文件夹"
  14313. );
  14314. $nk = time ();
  14315. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14316. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14317. echo "文件无法保存.";
  14318. exit ( 0 );
  14319. }
  14320. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14321. echo json_encode ( array (
  14322. 'filename' => $file_name,
  14323. 'id' => $nk
  14324. ) );
  14325. exit ( 0 );
  14326. }
  14327. function _GetFileEXT($filename) {
  14328. $pics = explode ( '.', $filename );
  14329. $num = count ( $pics );
  14330. return $pics [$num - 1];
  14331. }
  14332. /**
  14333. * 获取get或者POST值
  14334. * @param string $name 属性名称
  14335. * @return fixed 值
  14336. */
  14337. function get_args($name) {
  14338. if (isset ( $_GET [$name] )) {
  14339. if (is_array ( $_GET [$name] ))
  14340. return $_GET [$name];
  14341. else
  14342. return addslashes ( $_GET [$name] );
  14343. } elseif (isset ( $_POST [$name] )) {
  14344. if (is_array ( $_POST [$name] ))
  14345. return $_POST [$name];
  14346. else
  14347. return addslashes ( $_POST [$name] );
  14348. } else
  14349. return false;
  14350. }
  14351. function num_to_rmb($num) {
  14352. $c1 = "零壹贰叁肆伍陆柒捌玖";
  14353. $c2 = "分角元拾佰仟万拾佰仟亿";
  14354. // 精确到分后面就不要了,所以只留两个小数位
  14355. $num = round ( $num, 2 );
  14356. // 将数字转化为整数
  14357. $num = $num * 100;
  14358. if (strlen ( $num ) > 10) {
  14359. return "金额太大,请检查";
  14360. }
  14361. $i = 0;
  14362. $c = "";
  14363. while ( 1 ) {
  14364. if ($i == 0) {
  14365. // 获取最后一位数字
  14366. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  14367. } else {
  14368. $n = $num % 10;
  14369. }
  14370. // 每次将最后一位数字转化为中文
  14371. $p1 = substr ( $c1, 3 * $n, 3 );
  14372. $p2 = substr ( $c2, 3 * $i, 3 );
  14373. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  14374. $c = $p1 . $p2 . $c;
  14375. } else {
  14376. $c = $p1 . $c;
  14377. }
  14378. $i = $i + 1;
  14379. // 去掉数字最后一位了
  14380. $num = $num / 10;
  14381. // echo $num.'</br>';
  14382. $num = ( int ) $num;
  14383. // $num =floor($num);
  14384. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  14385. // echo $num.'</br>';
  14386. // 结束循环
  14387. if ($num == 0) {
  14388. break;
  14389. }
  14390. }
  14391. // echo $c.'</br>';
  14392. $j = 0;
  14393. $slen = strlen ( $c );
  14394. while ( $j < $slen ) {
  14395. // utf8一个汉字相当3个字符
  14396. $m = substr ( $c, $j, 6 );
  14397. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  14398. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  14399. $left = substr ( $c, 0, $j );
  14400. $right = substr ( $c, $j + 3 );
  14401. $c = $left . $right;
  14402. $j = $j - 3;
  14403. $slen = $slen - 3;
  14404. }
  14405. $j = $j + 3;
  14406. }
  14407. // 这个是为了去掉类似23.0中最后一个“零”字
  14408. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  14409. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  14410. }
  14411. // 将处理的汉字加上“整”
  14412. if (empty ( $c )) {
  14413. return "零元整";
  14414. } else {
  14415. return $c . "整";
  14416. }
  14417. }
  14418. /**
  14419. * 获得分页数据
  14420. * @param unknown_type $table
  14421. * @param unknown_type $condition
  14422. * @param unknown_type $on_page
  14423. * @param unknown_type $page_size
  14424. */
  14425. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  14426. $page_c = "";
  14427. $page ['previous'] = $this->get_previous ( $on_page );
  14428. $page ['on_page'] = $on_page;
  14429. $total_count = $this->get_table_count ( $table, $condition );
  14430. $total = intval ( $total_count / $page_size );
  14431. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  14432. $page ['total_data'] = $total_count;
  14433. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  14434. $i = 1;
  14435. $page_max = 1;
  14436. $page_width = 3;
  14437. if ($on_page >= $page_width) {
  14438. $page_max = intval ( $on_page / $page_width ) + 1;
  14439. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  14440. }
  14441. for(; $i <= $page ['total_page']; $i ++) {
  14442. if ($i == $on_page)
  14443. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  14444. else
  14445. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  14446. if ($i == ($page_width * $page_max))
  14447. break;
  14448. }
  14449. $page ['page'] = $page_c;
  14450. $page ['lower'] = (-- $on_page) * $page_size;
  14451. return $page;
  14452. }
  14453. /**
  14454. * 获取总页数
  14455. * @param unknown_type $table
  14456. * @param unknown_type $condition
  14457. */
  14458. public function get_table_count($table = "", $condition = "") {
  14459. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14460. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14461. // echo $sql;die;
  14462. $query = Doo::db ()->query ( $sql );
  14463. $result = $query->fetch ();
  14464. return $result ['count'];
  14465. }
  14466. /**
  14467. * 获取上一页
  14468. * @param unknown_type $on_page
  14469. */
  14470. function get_previous($on_page = 1) {
  14471. return $on_page != 0 ? $on_page - 1 : $on_page;
  14472. }
  14473. function _getReceiptTrainPayment($invoiceTrainId,$trainLoanRid,$rid){
  14474. // 收入合计
  14475. Doo::loadModel ( 'invoiceTraining' );
  14476. $invoiceTraining = new invoiceTraining ();
  14477. Doo::loadModel ( 'receipt' );
  14478. $receipt = new receipt ();
  14479. $invoiceTrainingDetail = array (
  14480. 'invoiceArriveAmount' => '0.00',
  14481. 'RIAmount' => '0.00',
  14482. 'invoiceTotalAmount' => '0.00',
  14483. 'invoiceCompanyAmount' => '0.00',
  14484. 'invoiceArriveAmountM'=>'0.00',
  14485. 'invoiceCompanyAmountM'=>'0.00'
  14486. );
  14487. if ($invoiceTrainId != 0) {
  14488. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $invoiceTrainId );
  14489. }
  14490. $invoiceArriveAmount = $RIAmount = 0;
  14491. if (! empty ( $invoiceTrainingDetail )) {
  14492. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  14493. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  14494. }
  14495. // 备用金
  14496. $sum = 0;
  14497. if (! empty ( $trainLoanRid )) {
  14498. $receiptLoanList = $receipt->getReceiptInRid ( $trainLoanRid );
  14499. foreach ($receiptLoanList as $key=>$value){
  14500. $sum+=$value['sum'];
  14501. }
  14502. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $trainLoanRid );
  14503. // $sum = $receiptLoanDetailBak ['sum'];
  14504. }
  14505. // 支出项金额详情
  14506. // 项目金额合计
  14507. Doo::loadModel ( 'RItem' );
  14508. $RItem = new RItem ();
  14509. Doo::loadModel ( 'accountItem' );
  14510. $accountItem = new accountItem ();
  14511. // 讲师获得
  14512. Doo::loadModel ( 'RILecturer' );
  14513. $RILecturer = new RILecturer ();
  14514. $RItemList = $RItem->getRItemByRid ($rid );
  14515. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  14516. // 支出项金额详情
  14517. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  14518. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  14519. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  14520. return $payment;
  14521. }
  14522. }
  14523. ?>