ReceiptController.php 544 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606
  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/feeAgency';
  228. }else{
  229. return '/receipt/feeInternalTrain';
  230. }
  231. }
  232. /**
  233. * 添加费用报销单页面
  234. */
  235. function saeaCreate() {
  236. Doo::loadModel ( 'accountItem' );
  237. Doo::loadModel ( 'verify' );
  238. Doo::loadModel ( 'receipt' );
  239. Doo::loadModel ( 'L_category' );
  240. $lCategory = new L_category ();
  241. $receipt = new receipt ();
  242. $verify = new verify ();
  243. $accountItem = new accountItem ();
  244. Doo::loadModel ( "role" );
  245. $role = new role ();
  246. $acItem = $accountItem->find ( array (
  247. 'asArray' => true
  248. ) );
  249. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  250. $data ['category'] = $lCategory->find ( array (
  251. 'asArray' => true
  252. ) );
  253. $data ['veList'] = $veList;
  254. $data ['acItem'] = $acItem;
  255. $data ['memu'] = "receipt";
  256. $data ['staff'] = $this->staff;
  257. $data ['receiptMemu'] = 'saeaBorad';
  258. $data ['verifyId'] = $this->verifyId;
  259. $data ['executeId'] = $this->executeId;
  260. $this->render ( "/admin/saea_create", $data );
  261. }
  262. function addReceipt() {
  263. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  264. $agency = $this->get_args ( 'agency' );
  265. $travel = $this->get_args ( 'travel' );
  266. $train = $this->get_args ( 'train' );
  267. $other = $this->get_args ( 'other' );
  268. $inttrain = $this->get_args ( 'inttrain' );
  269. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  270. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  271. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  272. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  273. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  274. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  275. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  276. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  277. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  278. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  279. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  280. header ( 'Content-Type:text/html;charset=utf-8' );
  281. die ( '请填写联行号' );
  282. }
  283. Doo::loadModel ( 'receipt' );
  284. Doo::loadModel ( 'receiptDetail' );
  285. Doo::loadModel ( 'accountItem' );
  286. $accountItem = new accountItem ();
  287. $receipt = new receipt ();
  288. Doo::loadModel ( 'enclosur' );
  289. Doo::loadModel ( 'execute' );
  290. $execute = new execute ();
  291. $executeDetail = $execute->getOne ( array (
  292. 'where' => 'mold="报销单执行人"',
  293. 'asArray' => true
  294. ) );
  295. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  296. // if(!empty($receiptDetail))
  297. // return "/referReceipt/".$receiptDetail['rid'];
  298. $aItem = $accountItem->find ( array (
  299. 'asArray' => true
  300. ) );
  301. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  302. $ag = $tr = $ta = $ot= $it = 0;
  303. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  304. foreach ( $aItem as $key => $value ) {
  305. if ($value ['category'] == $this->AGENCY) {
  306. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  307. array_push ( $accountJson [$this->AGENCY], array (
  308. 'aid' => $value ['aid'],
  309. 'name' => $value ['name'],
  310. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  311. ) );
  312. $sum += $agency [$ag];
  313. $agencySum += $agency [$ag];
  314. }
  315. $ag ++;
  316. }
  317. if ($value ['category'] == $this->TRAVEL) {
  318. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  319. array_push ( $accountJson [$this->TRAVEL], array (
  320. 'aid' => $value ['aid'],
  321. 'name' => $value ['name'],
  322. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  323. ) );
  324. $sum += $travel [$tr];
  325. $travelSum += $travel [$tr];
  326. }
  327. $tr ++;
  328. }
  329. if ($value ['category'] == $this->TRAIN) {
  330. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  331. array_push ( $accountJson [$this->TRAIN], array (
  332. 'aid' => $value ['aid'],
  333. 'name' => $value ['name'],
  334. 'price' => number_format ( $train [$ta], 2, '.', '' )
  335. ) );
  336. $sum += $train [$ta];
  337. $trainSum += $train [$ta];
  338. }
  339. $ta ++;
  340. }
  341. if ($value ['category'] == $this->INTTRAIN) {
  342. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  343. array_push ( $accountJson [$this->INTTRAIN], array (
  344. 'aid' => $value ['aid'],
  345. 'name' => $value ['name'],
  346. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  347. ) );
  348. $sum += $inttrain [$it];
  349. $inttrainSum += $inttrain [$it];
  350. }
  351. $it ++;
  352. }
  353. if ($value ['category'] == $this->OTHER) {
  354. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  355. array_push ( $accountJson [$this->OTHER], array (
  356. 'aid' => $value ['aid'],
  357. 'name' => $value ['name'],
  358. 'price' => number_format ( $other [$ot], 2, '.', '' )
  359. ) );
  360. $sum += $other [$ot];
  361. $otherSum += $other [$ot];
  362. }
  363. $ot ++;
  364. }
  365. }
  366. $accountJson ['cSum'] = array (
  367. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  368. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  369. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  370. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  371. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  372. );
  373. // 报销单
  374. $receipt->accountItem = json_encode ( $accountJson );
  375. $receipt->staff = $this->staff [0] ['sid'];
  376. $receipt->sum = number_format ( $sum, 2, '.', '' );
  377. $receipt->date = date ( "Y-m-d" );
  378. $receipt->cid = $cid;
  379. $receipt->status = 5;
  380. // 修改审批流程加入角色
  381. $receipt->verify = $verify;
  382. $receipt->executeCopy = $executeDetail ['staff'];
  383. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  384. $order = array (
  385. "\r\n",
  386. "\n",
  387. "\r"
  388. );
  389. $replace = '<br/>';
  390. $explanation = str_replace ( $order, $replace, $explanation );
  391. $receipt->explanation = $explanation;
  392. $receipt->remittanceName = $remittanceName;
  393. $receipt->bankName = $bankName;
  394. $receipt->bankNumber = $bankNumber;
  395. $receipt->remittanceBankType = $remittanceBankType;
  396. if ($remittanceBankType == 1)
  397. $receipt->coupletNumber = $coupletNumber;
  398. $rid = $receipt->insert ();
  399. // 附件
  400. if (! empty ( $enclosurName )) {
  401. $enclosurArray = explode ( '-', $enclosurName );
  402. foreach ( $enclosurArray as $value ) {
  403. $enclosur = new enclosur ();
  404. $enclosur->name = $value;
  405. $enclosur->rid = $rid;
  406. $enclosur->insert ();
  407. }
  408. // print_r($enclosurArray);die;
  409. }
  410. // 报销详情
  411. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  412. $receiptDetail = new receiptDetail ();
  413. $receiptDetail->staff = $this->staff [0] ['sid'];
  414. $receiptDetail->item = $value ['name'];
  415. $receiptDetail->itemCategory = $this->AGENCY;
  416. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  417. $receiptDetail->date = date ( "Y-m-d" );
  418. $receiptDetail->cid = $cid;
  419. $receiptDetail->rid = $rid;
  420. $receiptDetail->status = 4;
  421. $receiptDetail->insert ();
  422. }
  423. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  424. $receiptDetail = new receiptDetail ();
  425. $receiptDetail->staff = $this->staff [0] ['sid'];
  426. $receiptDetail->item = $value ['name'];
  427. $receiptDetail->itemCategory = $this->TRAVEL;
  428. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  429. $receiptDetail->date = date ( "Y-m-d" );
  430. $receiptDetail->cid = $cid;
  431. $receiptDetail->rid = $rid;
  432. $receiptDetail->status = 4;
  433. $receiptDetail->insert ();
  434. }
  435. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  436. $receiptDetail = new receiptDetail ();
  437. $receiptDetail->staff = $this->staff [0] ['sid'];
  438. $receiptDetail->item = $value ['name'];
  439. $receiptDetail->itemCategory = $this->TRAIN;
  440. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  441. $receiptDetail->date = date ( "Y-m-d" );
  442. $receiptDetail->cid = $cid;
  443. $receiptDetail->rid = $rid;
  444. $receiptDetail->status = 4;
  445. $receiptDetail->insert ();
  446. }
  447. //内训
  448. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  449. $receiptDetail = new receiptDetail ();
  450. $receiptDetail->staff = $this->staff [0] ['sid'];
  451. $receiptDetail->item = $value ['name'];
  452. $receiptDetail->itemCategory = $this->INTTRAIN;
  453. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  454. $receiptDetail->date = date ( "Y-m-d" );
  455. $receiptDetail->cid = $cid;
  456. $receiptDetail->rid = $rid;
  457. $receiptDetail->status = 4;
  458. $receiptDetail->insert ();
  459. }
  460. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  461. $receiptDetail = new receiptDetail ();
  462. $receiptDetail->staff = $this->staff [0] ['sid'];
  463. $receiptDetail->item = $value ['name'];
  464. $receiptDetail->itemCategory = $this->OTHER;
  465. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  466. $receiptDetail->date = date ( "Y-m-d" );
  467. $receiptDetail->cid = $cid;
  468. $receiptDetail->rid = $rid;
  469. $receiptDetail->status = 4;
  470. $receiptDetail->insert ();
  471. }
  472. return "/saeaBorad";
  473. } else
  474. die ( 'illegal request' );
  475. }
  476. function referReceipt() {
  477. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  478. Doo::loadModel ( 'receipt' );
  479. Doo::loadModel ( 'verify' );
  480. $verify = new verify ();
  481. $receipt = new receipt ();
  482. Doo::loadModel ( 'L_category' );
  483. $lCategory = new L_category ();
  484. Doo::loadModel ( "role" );
  485. $role = new role ();
  486. $receiptDetail = $receipt->find ( array (
  487. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  488. 'asArray' => true
  489. ) );
  490. if (empty ( $receiptDetail ))
  491. return "/addReceipt";
  492. foreach ( $receiptDetail as $key => $value ) {
  493. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  494. $veList = $verify->getOne ( array (
  495. 'where' => 'vid=' . $value ['verify'],
  496. 'asArray' => true
  497. ) );
  498. $v = json_decode ( $veList ['staff'] );
  499. array_push ( $v [0], $veList ['description'] );
  500. foreach ( $v as $n => $m ) {
  501. if ($m ['1'] == 'ROLE') {
  502. $roleInfo = $role->getOne ( array (
  503. 'where' => 'rid=' . $m [0],
  504. 'asArray' => true
  505. ) );
  506. $v [$n] [1] = $roleInfo ['name'];
  507. }
  508. }
  509. $receiptDetail [$key] ['staff'] = $v;
  510. $category = $lCategory->getOne ( array (
  511. 'where' => 'cid=' . $value ['cid'],
  512. 'asArray' => true
  513. ) );
  514. $receiptDetail [$key] ['category'] = $category ['title'];
  515. }
  516. // print_r($receiptDetail);
  517. $data ['receiptDetail'] = $receiptDetail;
  518. $data ['memu'] = "receipt";
  519. $data ['staff'] = $this->staff;
  520. $data ['receiptMemu'] = 'saeaCreate';
  521. $data ['verifyId'] = $this->verifyId;
  522. $data ['executeId'] = $this->executeId;
  523. $this->render ( "/admin/saea_confirm", $data );
  524. }
  525. function editReceipt() {
  526. // edit status 4
  527. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  528. Doo::loadClass ( 'XDeode' );
  529. $XDeode = new XDeode ( 7 );
  530. $rid = $XDeode->decode ( $ridKey );
  531. if (empty ( $rid ))
  532. die ( 'illegal request' );
  533. // echo $rid.'sd';
  534. Doo::loadModel ( 'accountItem' );
  535. Doo::loadModel ( 'verify' );
  536. Doo::loadModel ( 'receipt' );
  537. $receipt = new receipt ();
  538. $verify = new verify ();
  539. $accountItem = new accountItem ();
  540. Doo::loadModel ( 'L_category' );
  541. $lCategory = new L_category ();
  542. Doo::loadModel ( "role" );
  543. $role = new role ();
  544. Doo::loadModel ( 'enclosur' );
  545. $enclosur = new enclosur ();
  546. $receiptDetail = $receipt->getOne ( array (
  547. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  548. 'asArray' => true
  549. ) );
  550. if (empty ( $receiptDetail ))
  551. die ( 'illegal request' );
  552. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  553. $acItem = $accountItem->find ( array (
  554. 'asArray' => true
  555. ) );
  556. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  557. // 配置编辑信息
  558. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  559. foreach ( $acItem as $key => $value ) {
  560. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  561. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  562. $acItem [$key] ['price'] = $v ['price'];
  563. }
  564. }
  565. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  566. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  567. $acItem [$key] ['price'] = $v ['price'];
  568. }
  569. }
  570. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  571. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  572. $acItem [$key] ['price'] = $v ['price'];
  573. }
  574. }
  575. //内训
  576. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  577. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  578. $acItem [$key] ['price'] = $v ['price'];
  579. }
  580. }
  581. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  582. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  583. $acItem [$key] ['price'] = $v ['price'];
  584. }
  585. }
  586. }
  587. $data ['category'] = $lCategory->find ( array (
  588. 'asArray' => true
  589. ) );
  590. $data ['cSum'] = $accountItemList ['cSum'];
  591. $data ['sum'] = $receiptDetail ['sum'];
  592. $data ['enclosurList'] = $enclosurList;
  593. $data ['receiptDetail'] = $receiptDetail;
  594. $data ['veList'] = $veList;
  595. $data ['acItem'] = $acItem;
  596. $data ['memu'] = "receipt";
  597. $data ['staff'] = $this->staff;
  598. $data ['receiptMemu'] = 'saeaBorad';
  599. $data ['verify'] = $receiptDetail ['verify'];
  600. $data ['verifyId'] = $this->verifyId;
  601. $data ['executeId'] = $this->executeId;
  602. $data ['rid'] = $ridKey;
  603. $this->render ( "/admin/saea_edit", $data );
  604. }
  605. function updateReceipt() {
  606. $agency = $this->get_args ( 'agency' );
  607. $travel = $this->get_args ( 'travel' );
  608. $train = $this->get_args ( 'train' );
  609. $other = $this->get_args ( 'other' );
  610. $inttrain = $this->get_args ( 'inttrain' );
  611. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  612. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  613. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  614. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  615. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  616. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  617. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  618. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  619. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  620. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  621. Doo::loadClass ( 'XDeode' );
  622. $XDeode = new XDeode ( 7 );
  623. $rid = $XDeode->decode ( $ridKey );
  624. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  625. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  626. header ( 'Content-Type:text/html;charset=utf-8' );
  627. die ( '请填写联行号' );
  628. }
  629. Doo::loadModel ( 'receipt' );
  630. Doo::loadModel ( 'receiptDetail' );
  631. Doo::loadModel ( 'accountItem' );
  632. $accountItem = new accountItem ();
  633. $receipt = new receipt ();
  634. Doo::loadModel ( 'enclosur' );
  635. Doo::loadModel ( 'execute' );
  636. $execute = new execute ();
  637. $receiptDetail = $receipt->getOne ( array (
  638. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  639. 'asArray' => true
  640. ) );
  641. if (empty ( $receiptDetail ))
  642. return "/saeaBorad";
  643. if ($receiptDetail ['Rtype'] == 1)
  644. $executeDetail = $execute->getOne ( array (
  645. 'where' => 'mold="借款费用执行人"',
  646. 'asArray' => true
  647. ) );
  648. else
  649. $executeDetail = $execute->getOne ( array (
  650. 'where' => 'mold="报销单执行人"',
  651. 'asArray' => true
  652. ) );
  653. $aItem = $accountItem->find ( array (
  654. 'asArray' => true
  655. ) );
  656. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  657. $ag = $tr = $ta = $ot = $it = 0 ;
  658. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum = $otherSum = 0;
  659. foreach ( $aItem as $key => $value ) {
  660. if ($value ['category'] == $this->AGENCY) {
  661. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  662. array_push ( $accountJson [$this->AGENCY], array (
  663. 'aid' => $value ['aid'],
  664. 'name' => $value ['name'],
  665. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  666. ) );
  667. $sum += $agency [$ag];
  668. $agencySum += $agency [$ag];
  669. }
  670. $ag ++;
  671. }
  672. if ($value ['category'] == $this->TRAVEL) {
  673. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  674. array_push ( $accountJson [$this->TRAVEL], array (
  675. 'aid' => $value ['aid'],
  676. 'name' => $value ['name'],
  677. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  678. ) );
  679. $sum += $travel [$tr];
  680. $travelSum += $travel [$tr];
  681. }
  682. $tr ++;
  683. }
  684. if ($value ['category'] == $this->TRAIN) {
  685. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  686. array_push ( $accountJson [$this->TRAIN], array (
  687. 'aid' => $value ['aid'],
  688. 'name' => $value ['name'],
  689. 'price' => number_format ( $train [$ta], 2, '.', '' )
  690. ) );
  691. $sum += $train [$ta];
  692. $trainSum += $train [$ta];
  693. }
  694. $ta ++;
  695. }
  696. if ($value ['category'] == $this->INTTRAIN) {
  697. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  698. array_push ( $accountJson [$this->INTTRAIN], array (
  699. 'aid' => $value ['aid'],
  700. 'name' => $value ['name'],
  701. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  702. ) );
  703. $sum += $inttrain [$it];
  704. $inttrainSum += $inttrain [$it];
  705. }
  706. $it ++;
  707. }
  708. if ($value ['category'] == $this->OTHER) {
  709. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  710. array_push ( $accountJson [$this->OTHER], array (
  711. 'aid' => $value ['aid'],
  712. 'name' => $value ['name'],
  713. 'price' => number_format ( $other [$ot], 2, '.', '' )
  714. ) );
  715. $sum += $other [$ot];
  716. $otherSum += $other [$ot];
  717. }
  718. $ot ++;
  719. }
  720. }
  721. $accountJson ['cSum'] = array (
  722. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  723. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  724. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  725. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  726. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  727. );
  728. // 报销单
  729. $rid = $receipt->rid = $receiptDetail ['rid'];
  730. $receipt->accountItem = json_encode ( $accountJson );
  731. $receipt->staff = $this->staff [0] ['sid'];
  732. $receipt->sum = number_format ( $sum, 2, '.', '' );
  733. $receipt->date = date ( "Y-m-d" );
  734. $receipt->cid = $cid;
  735. if (($receiptDetail ['status'] != 4)) {
  736. if ($receiptDetail ['Rtype'] == 1)
  737. $receipt->status = 7;
  738. else
  739. $receipt->status = 5;
  740. }
  741. if ($receiptDetail != 4 && ! empty ( $verify ))
  742. $receipt->verify = $verify;
  743. $receipt->executeCopy = $executeDetail ['staff'];
  744. $order = array (
  745. "\r\n",
  746. "\n",
  747. "\r"
  748. );
  749. $replace = '<br/>';
  750. $explanation = str_replace ( $order, $replace, $explanation );
  751. $receipt->explanation = $explanation;
  752. $receipt->remittanceName = $remittanceName;
  753. $receipt->bankName = $bankName;
  754. $receipt->bankNumber = $bankNumber;
  755. $receipt->remittanceBankType = $remittanceBankType;
  756. if ($remittanceBankType == 1)
  757. $receipt->coupletNumber = $coupletNumber;
  758. $receipt->update ();
  759. $receiptDetail = new receiptDetail ();
  760. $receiptDetail->delete ( array (
  761. 'where' => 'rid=' . $rid
  762. ) );
  763. // 报销详情
  764. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  765. $receiptDetail = new receiptDetail ();
  766. $receiptDetail->staff = $this->staff [0] ['sid'];
  767. $receiptDetail->item = $value ['name'];
  768. $receiptDetail->itemCategory = $this->AGENCY;
  769. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  770. $receiptDetail->date = date ( "Y-m-d" );
  771. $receiptDetail->cid = $cid;
  772. $receiptDetail->rid = $rid;
  773. $receiptDetail->status = 4;
  774. $receiptDetail->insert ();
  775. }
  776. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  777. $receiptDetail = new receiptDetail ();
  778. $receiptDetail->staff = $this->staff [0] ['sid'];
  779. $receiptDetail->item = $value ['name'];
  780. $receiptDetail->itemCategory = $this->TRAVEL;
  781. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  782. $receiptDetail->date = date ( "Y-m-d" );
  783. $receiptDetail->cid = $cid;
  784. $receiptDetail->rid = $rid;
  785. $receiptDetail->status = 4;
  786. $receiptDetail->insert ();
  787. }
  788. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  789. $receiptDetail = new receiptDetail ();
  790. $receiptDetail->staff = $this->staff [0] ['sid'];
  791. $receiptDetail->item = $value ['name'];
  792. $receiptDetail->itemCategory = $this->TRAIN;
  793. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  794. $receiptDetail->date = date ( "Y-m-d" );
  795. $receiptDetail->cid = $cid;
  796. $receiptDetail->rid = $rid;
  797. $receiptDetail->status = 4;
  798. $receiptDetail->insert ();
  799. }
  800. //内训
  801. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  802. $receiptDetail = new receiptDetail ();
  803. $receiptDetail->staff = $this->staff [0] ['sid'];
  804. $receiptDetail->item = $value ['name'];
  805. $receiptDetail->itemCategory = $this->INTTRAIN;
  806. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  807. $receiptDetail->date = date ( "Y-m-d" );
  808. $receiptDetail->cid = $cid;
  809. $receiptDetail->rid = $rid;
  810. $receiptDetail->status = 4;
  811. $receiptDetail->insert ();
  812. }
  813. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  814. $receiptDetail = new receiptDetail ();
  815. $receiptDetail->staff = $this->staff [0] ['sid'];
  816. $receiptDetail->item = $value ['name'];
  817. $receiptDetail->itemCategory = $this->OTHER;
  818. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  819. $receiptDetail->date = date ( "Y-m-d" );
  820. $receiptDetail->cid = $cid;
  821. $receiptDetail->rid = $rid;
  822. $receiptDetail->status = 4;
  823. $receiptDetail->insert ();
  824. }
  825. // 附件
  826. if (! empty ( $enclosurName )) {
  827. $enclosurArray = explode ( '-', $enclosurName );
  828. foreach ( $enclosurArray as $value ) {
  829. $enclosur = new enclosur ();
  830. $enclosur->name = $value;
  831. $enclosur->rid = $rid;
  832. $enclosur->insert ();
  833. }
  834. }
  835. // return "/referReceipt/".$rid;
  836. }
  837. return "/saeaBorad";
  838. }
  839. function remitAdd() {
  840. Doo::loadModel ( 'accountItem' );
  841. Doo::loadModel ( 'verify' );
  842. Doo::loadModel ( 'receipt' );
  843. Doo::loadModel ( 'L_category' );
  844. $lCategory = new L_category ();
  845. $receipt = new receipt ();
  846. $verify = new verify ();
  847. $accountItem = new accountItem ();
  848. Doo::loadModel ( "role" );
  849. $role = new role ();
  850. $acItem = $accountItem->find ( array (
  851. 'asArray' => true
  852. ) );
  853. $veList = $verify->getVerifyBySubordinate('REMIT');
  854. $data ['category'] = $lCategory->find ( array (
  855. 'asArray' => true
  856. ) );
  857. $data ['veList'] = $veList;
  858. $data ['acItem'] = $acItem;
  859. $data ['memu'] = "receipt";
  860. $data ['staff'] = $this->staff;
  861. $data ['receiptMemu'] = 'saeaBorad';
  862. $data ['verifyId'] = $this->verifyId;
  863. $data ['executeId'] = $this->executeId;
  864. $this->render ( "/admin/remitAdd", $data );
  865. }
  866. function remitAddDo() {
  867. $agency = $this->get_args ( 'agency' );
  868. $travel = $this->get_args ( 'travel' );
  869. $train = $this->get_args ( 'train' );
  870. $other = $this->get_args ( 'other' );
  871. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  872. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  873. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  874. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  875. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  876. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  877. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  878. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  879. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  880. // print_r($agency);die;
  881. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  882. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  883. header ( 'Content-Type:text/html;charset=utf-8' );
  884. die ( '请填写联行号' );
  885. }
  886. Doo::loadModel ( 'receipt' );
  887. Doo::loadModel ( 'receiptDetail' );
  888. Doo::loadModel ( 'accountItem' );
  889. $accountItem = new accountItem ();
  890. $receipt = new receipt ();
  891. Doo::loadModel ( 'enclosur' );
  892. Doo::loadModel ( 'execute' );
  893. $execute = new execute ();
  894. $executeDetail = $execute->getOne ( array (
  895. 'where' => 'mold="对公汇款执行人"',
  896. 'asArray' => true
  897. ) );
  898. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  899. $aItem = $accountItem->find ( array (
  900. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  901. 'asArray' => true
  902. ) );
  903. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  904. $ag = $tr = $ta = $ot = 0;
  905. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  906. print_r($aItem);
  907. foreach ( $aItem as $key => $value ) {
  908. if ($value ['category'] == $this->AGENCY) {
  909. if (isset ( $agency [$ag] )) {
  910. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  911. array_push ( $accountJson [$this->AGENCY], array (
  912. 'aid' => $value ['aid'],
  913. 'name' => $value ['name'],
  914. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  915. ) );
  916. $sum += $agency [$ag];
  917. $agencySum += $agency [$ag];
  918. }
  919. }
  920. $ag ++;
  921. }
  922. }
  923. $accountJson ['cSum'] = array (
  924. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  925. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  926. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  927. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  928. );
  929. //die;
  930. // 报销单
  931. $receipt->accountItem = json_encode ( $accountJson );
  932. $receipt->staff = $this->staff [0] ['sid'];
  933. $receipt->sum = number_format ( $sum, 2, '.', '' );
  934. $receipt->date = date ( "Y-m-d" );
  935. $receipt->cid = $cid;
  936. $receipt->status = 5;
  937. $receipt->Rtype = 2;
  938. // 修改审批流程加入角色
  939. $receipt->verify = $verify;
  940. $receipt->executeCopy = $executeDetail ['staff'];
  941. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  942. $order = array (
  943. "\r\n",
  944. "\n",
  945. "\r"
  946. );
  947. $replace = '<br/>';
  948. $explanation = str_replace ( $order, $replace, $explanation );
  949. $receipt->explanation = $explanation;
  950. $receipt->remittanceName = $remittanceName;
  951. $receipt->bankName = $bankName;
  952. $receipt->bankNumber = $bankNumber;
  953. $receipt->remittanceBankType = $remittanceBankType;
  954. if ($remittanceBankType == 1)
  955. $receipt->coupletNumber = $coupletNumber;
  956. $rid = $receipt->insert ();
  957. // 附件
  958. if (! empty ( $enclosurName )) {
  959. $enclosurArray = explode ( '-', $enclosurName );
  960. foreach ( $enclosurArray as $value ) {
  961. $enclosur = new enclosur ();
  962. $enclosur->name = $value;
  963. $enclosur->rid = $rid;
  964. $enclosur->insert ();
  965. }
  966. // print_r($enclosurArray);die;
  967. }
  968. // 报销详情
  969. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  970. $receiptDetail = new receiptDetail ();
  971. $receiptDetail->staff = $this->staff [0] ['sid'];
  972. $receiptDetail->item = $value ['name'];
  973. $receiptDetail->itemCategory = $this->AGENCY;
  974. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  975. $receiptDetail->date = date ( "Y-m-d" );
  976. $receiptDetail->cid = $cid;
  977. $receiptDetail->rid = $rid;
  978. $receiptDetail->status = 4;
  979. $receiptDetail->insert ();
  980. }
  981. return "/saeaBorad";
  982. } else
  983. die ( 'illegal request' );
  984. }
  985. function remitEdit() {
  986. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  987. Doo::loadClass ( 'XDeode' );
  988. $XDeode = new XDeode ( 7 );
  989. $rid = $XDeode->decode ( $ridKey );
  990. if (! is_numeric ( $rid ))
  991. die ( 'illegal request' );
  992. Doo::loadModel ( 'accountItem' );
  993. Doo::loadModel ( 'verify' );
  994. Doo::loadModel ( 'receipt' );
  995. $receipt = new receipt ();
  996. $verify = new verify ();
  997. $accountItem = new accountItem ();
  998. Doo::loadModel ( 'L_category' );
  999. $lCategory = new L_category ();
  1000. Doo::loadModel ( "role" );
  1001. $role = new role ();
  1002. Doo::loadModel ( 'enclosur' );
  1003. $enclosur = new enclosur ();
  1004. $receiptDetail = $receipt->getOne ( array (
  1005. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  1006. 'asArray' => true
  1007. ) );
  1008. if (empty ( $receiptDetail ))
  1009. return "/saeaCreate";
  1010. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  1011. $acItem = $accountItem->find ( array (
  1012. 'asArray' => true
  1013. ) );
  1014. $veList = $verify->getVerifyBySubordinate('REMIT');
  1015. // 配置编辑信息
  1016. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1017. foreach ( $acItem as $key => $value ) {
  1018. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1019. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1020. $acItem [$key] ['price'] = $v ['price'];
  1021. }
  1022. }
  1023. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1024. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1025. $acItem [$key] ['price'] = $v ['price'];
  1026. }
  1027. }
  1028. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1029. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1030. $acItem [$key] ['price'] = $v ['price'];
  1031. }
  1032. }
  1033. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1034. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1035. $acItem [$key] ['price'] = $v ['price'];
  1036. }
  1037. }
  1038. }
  1039. $data ['category'] = $lCategory->find ( array (
  1040. 'asArray' => true
  1041. ) );
  1042. $data ['enclosurList'] = $enclosurList;
  1043. $data ['cSum'] = $accountItemList ['cSum'];
  1044. $data ['sum'] = $receiptDetail ['sum'];
  1045. $data ['receiptDetail'] = $receiptDetail;
  1046. $data ['veList'] = $veList;
  1047. $data ['acItem'] = $acItem;
  1048. $data ['memu'] = "receipt";
  1049. $data ['staff'] = $this->staff;
  1050. $data ['receiptMemu'] = 'saeaBorad';
  1051. $data ['verify'] = $receiptDetail ['verify'];
  1052. $data ['verifyId'] = $this->verifyId;
  1053. $data ['executeId'] = $this->executeId;
  1054. $data ['rid'] = $rid;
  1055. $data ['ridKey'] = $ridKey;
  1056. $this->render ( "/admin/remitEdit", $data );
  1057. }
  1058. function remitEdiDo() {
  1059. $agency = $this->get_args ( 'agency' );
  1060. $travel = $this->get_args ( 'travel' );
  1061. $train = $this->get_args ( 'train' );
  1062. $other = $this->get_args ( 'other' );
  1063. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1064. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1065. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1066. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1067. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1068. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1069. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1070. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1071. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1072. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1073. Doo::loadClass ( 'XDeode' );
  1074. $XDeode = new XDeode ( 7 );
  1075. $rid = $XDeode->decode ( $ridKey );
  1076. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1077. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1078. header ( 'Content-Type:text/html;charset=utf-8' );
  1079. die ( '请填写联行号' );
  1080. }
  1081. Doo::loadModel ( 'receipt' );
  1082. Doo::loadModel ( 'receiptDetail' );
  1083. Doo::loadModel ( 'accountItem' );
  1084. $accountItem = new accountItem ();
  1085. $receipt = new receipt ();
  1086. Doo::loadModel ( 'enclosur' );
  1087. $enclosur = new enclosur ();
  1088. Doo::loadModel ( 'execute' );
  1089. $execute = new execute ();
  1090. $executeDetail = $execute->getOne ( array (
  1091. 'where' => 'mold="对公汇款执行人"',
  1092. 'asArray' => true
  1093. ) );
  1094. $receiptDetail = $receipt->getOne ( array (
  1095. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  1096. 'asArray' => true
  1097. ) );
  1098. if (empty ( $receiptDetail ))
  1099. return "/saeaBorad";
  1100. $aItem = $accountItem->find ( array (
  1101. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  1102. 'asArray' => true
  1103. ) );
  1104. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1105. $ag = $tr = $ta = $ot = 0;
  1106. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1107. foreach ( $aItem as $key => $value ) {
  1108. if ($value ['category'] == $this->AGENCY) {
  1109. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1110. array_push ( $accountJson [$this->AGENCY], array (
  1111. 'aid' => $value ['aid'],
  1112. 'name' => $value ['name'],
  1113. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1114. ) );
  1115. $sum += $agency [$ag];
  1116. $agencySum += $agency [$ag];
  1117. }
  1118. $ag ++;
  1119. }
  1120. }
  1121. $accountJson ['cSum'] = array (
  1122. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1123. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1124. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1125. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1126. );
  1127. // 报销单
  1128. $rid = $receipt->rid = $receiptDetail ['rid'];
  1129. $receipt->accountItem = json_encode ( $accountJson );
  1130. $receipt->staff = $this->staff [0] ['sid'];
  1131. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1132. $receipt->date = date ( "Y-m-d" );
  1133. $receipt->cid = $cid;
  1134. if ($receiptDetail ['Rtype'] == 1)
  1135. $receipt->status = 7;
  1136. else
  1137. $receipt->status = 5;
  1138. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  1139. $receipt->verify = $verify;
  1140. $receipt->executeCopy = $executeDetail ['staff'];
  1141. $order = array (
  1142. "\r\n",
  1143. "\n",
  1144. "\r"
  1145. );
  1146. $replace = '<br/>';
  1147. $explanation = str_replace ( $order, $replace, $explanation );
  1148. $receipt->explanation = $explanation;
  1149. $receipt->remittanceName = $remittanceName;
  1150. $receipt->bankName = $bankName;
  1151. $receipt->bankNumber = $bankNumber;
  1152. $receipt->remittanceBankType = $remittanceBankType;
  1153. if ($remittanceBankType == 1)
  1154. $receipt->coupletNumber = $coupletNumber;
  1155. $receipt->update ();
  1156. $receiptDetail = new receiptDetail ();
  1157. $receiptDetail->delete ( array (
  1158. 'where' => 'rid=' . $rid
  1159. ) );
  1160. // 报销详情
  1161. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1162. $receiptDetail = new receiptDetail ();
  1163. $receiptDetail->staff = $this->staff [0] ['sid'];
  1164. $receiptDetail->item = $value ['name'];
  1165. $receiptDetail->itemCategory = $this->AGENCY;
  1166. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1167. $receiptDetail->date = date ( "Y-m-d" );
  1168. $receiptDetail->cid = $cid;
  1169. $receiptDetail->rid = $rid;
  1170. $receiptDetail->status = 4;
  1171. $receiptDetail->insert ();
  1172. }
  1173. // 附件
  1174. if (! empty ( $enclosurName )) {
  1175. $enclosurArray = explode ( '-', $enclosurName );
  1176. foreach ( $enclosurArray as $value ) {
  1177. $enclosur = new enclosur ();
  1178. $enclosur->name = $value;
  1179. $enclosur->rid = $rid;
  1180. $enclosur->insert ();
  1181. }
  1182. }
  1183. }
  1184. return "/saeaBorad";
  1185. }
  1186. function remitApproval() {
  1187. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1188. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  1189. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  1190. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  1191. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  1192. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  1193. if (empty ( $status ))
  1194. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  1195. $vidList = array ();
  1196. $button = 0;
  1197. Doo::loadModel ( 'verify' );
  1198. Doo::loadModel ( 'receipt' );
  1199. Doo::loadModel ( 'staff' );
  1200. $staff = new staff ();
  1201. $receipt = new receipt ();
  1202. $verify = new verify ();
  1203. Doo::loadModel ( 'L_category' );
  1204. $Lcategory = new L_category ();
  1205. Doo::loadModel ( 'enclosur' );
  1206. $enclosur = new enclosur ();
  1207. // user verify ID
  1208. $verifyDetail = $verify->find ( array (
  1209. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  1210. 'asArray' => true
  1211. ) );
  1212. foreach ( $verifyDetail as $key => $value ) {
  1213. array_push ( $vidList, $value ['vid'] );
  1214. }
  1215. $vid = implode ( ",", $vidList );
  1216. if (empty ( $verifyDetail ))
  1217. $vid = 0;
  1218. $categoryList = $Lcategory->find ( array (
  1219. 'asArray' => true
  1220. ) );
  1221. $staffList = $staff->find ( array (
  1222. 'where' => 'cid=' . $cid,
  1223. 'asArray' => true
  1224. ) );
  1225. $ap = "";
  1226. if ($status == 4) {
  1227. $ap = 4;
  1228. $status = 2;
  1229. }
  1230. // get Receipt By verifyID status 2
  1231. $receiptList = $receipt->find ( array (
  1232. 'where' => 'rid =' . $rid . ' and status=2',
  1233. 'desc' => 'rid',
  1234. 'asArray' => true
  1235. ) );
  1236. if (empty ( $receiptList )) {
  1237. die ( 'illegal request' );
  1238. }
  1239. $Locate = 0;
  1240. $roleId = 0;
  1241. if ($ap == 4)
  1242. $status = 4;
  1243. foreach ( $receiptList as $key => $value ) {
  1244. $receiptList [$key] ['Locate'] = $Locate;
  1245. $Locate ++;
  1246. $receiptList [$key] ['reviseDetail'] = array ();
  1247. if (! empty ( $value ['reviseDetail'] ))
  1248. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1249. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1250. $categoryDetil = $Lcategory->getOne ( array (
  1251. 'where' => 'cid=' . $value ['cid'],
  1252. 'asArray' => true
  1253. ) );
  1254. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1255. // 检测编辑状态
  1256. $verifyList = $verify->getOne ( array (
  1257. 'where' => 'vid=' . $value ['verify'],
  1258. 'asArray' => true
  1259. ) );
  1260. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1261. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1262. Doo::loadModel ( 'role' );
  1263. $role = new role ();
  1264. // print_r($verifyList);
  1265. $flag = true;
  1266. $roleKey = 0;
  1267. $endStaffArray = array ();
  1268. $roleArrayCopy = array ();
  1269. foreach ( $verifyList as $k => $v ) {
  1270. // init verifyStaff
  1271. if ($v [1] == 'ROLE') {
  1272. if (! empty ( $verifyStaff )) {
  1273. $endStaffArray = end ( $verifyStaff );
  1274. if ($v [0] == $endStaffArray ['nextStaff']) {
  1275. $roleId = $v [0];
  1276. }
  1277. }
  1278. $roleVerify = json_decode ( $v [3], true );
  1279. $roleKey = $k;
  1280. $roleArray = array ();
  1281. $rolename = $role->getOne ( array (
  1282. 'where' => 'rid=' . $v [0],
  1283. 'asArray' => true
  1284. ) );
  1285. foreach ( $roleVerify as $o => $p ) {
  1286. $staffID = explode ( '_', $p );
  1287. $staffInfo = $staff->getOne ( array (
  1288. 'where' => 'sid=' . $staffID [0],
  1289. 'asArray' => true
  1290. ) );
  1291. // print_r($staffID);
  1292. $exp = array (
  1293. 0 => $staffInfo ['sid'],
  1294. 1 => $staffID [1],
  1295. 2 => $staffInfo ['avatar'],
  1296. 'date' => '',
  1297. 'date' => '',
  1298. 'opinion' => '',
  1299. 'status' => '',
  1300. 'rolename' => $rolename ['name']
  1301. );
  1302. array_push ( $roleArray, $exp );
  1303. }
  1304. $roleArrayCopy [$v [0]] = $roleArray;
  1305. // $verifyList[$k]['roleArray']=$roleArray;
  1306. }
  1307. // print_r($roleArray);
  1308. $verifyList [$k] ['date'] = "";
  1309. $verifyList [$k] ['opinion'] = "";
  1310. $verifyList [$k] ['status'] = "";
  1311. if (empty ( $verifyStaff )) {
  1312. $verifyList [$k] ['date'] = "";
  1313. $verifyList [$k] ['opinion'] = "";
  1314. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1315. $verifyList [$k] ['status'] = 4;
  1316. $button = 4;
  1317. $flag = false;
  1318. }
  1319. } else {
  1320. foreach ( $verifyStaff as $m => $u ) {
  1321. if ($v [0] == $m) {
  1322. $verifyList [$k] ['date'] = $u ['date'];
  1323. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1324. $verifyList [$k] ['status'] = $u ['status'];
  1325. $flag = false;
  1326. break;
  1327. }
  1328. }
  1329. $endStaffArray = end ( $verifyStaff );
  1330. if (isset ( $endStaffArray ['ROLE'] )) {
  1331. } else {
  1332. $endKey = key ( $verifyStaff );
  1333. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  1334. $button = 4;
  1335. $verifyList [$k] ['status'] = 4;
  1336. }
  1337. }
  1338. }
  1339. }
  1340. $rolename ['name'] = '';
  1341. if (! empty ( $roleId )) {
  1342. Doo::loadModel ( 'role' );
  1343. $role = new role ();
  1344. $rolename = $role->getOne ( array (
  1345. 'where' => 'rid=' . $roleId,
  1346. 'asArray' => true
  1347. ) );
  1348. }
  1349. if (! empty ( $verifyStaff ))
  1350. $endStaffArray = end ( $verifyStaff );
  1351. $KOP = false;
  1352. foreach ( $roleArrayCopy as $P => $A ) {
  1353. foreach ( $A as $MKI => $AVL ) {
  1354. if (! empty ( $verifyStaff )) {
  1355. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1356. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1357. $button = 4;
  1358. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1359. }
  1360. foreach ( $verifyStaff as $m => $u ) {
  1361. $AVLFK = $AVL [0] . '_R';
  1362. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1363. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1364. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1365. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1366. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1367. break;
  1368. }
  1369. }
  1370. } else {
  1371. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1372. $button = 4;
  1373. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1374. }
  1375. }
  1376. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1377. $KOP = true;
  1378. }
  1379. }
  1380. foreach ( $roleArrayCopy as $k => $v ) {
  1381. foreach ( $verifyList as $m => $n ) {
  1382. if ($n [0] == $k) {
  1383. array_splice ( $verifyList, $m, 1, $v );
  1384. }
  1385. }
  1386. }
  1387. $receiptList [$key] ['verifyList'] = $verifyList;
  1388. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1389. 'where' => 'sid=' . $value ['staff'],
  1390. 'asArray' => true
  1391. ) );
  1392. $receiptList [$key] ['button'] = $button;
  1393. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1394. }
  1395. $mothHtml = "";
  1396. for($i = 1; $i <= 12; $i ++) {
  1397. if ($month == $i)
  1398. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  1399. else
  1400. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  1401. }
  1402. // 获取审批日志
  1403. Doo::loadModel ( 'receiptLog' );
  1404. $receiptLog = new receiptLog ();
  1405. $rlList = array ();
  1406. $rlInfo = $receiptLog->getOne ( array (
  1407. 'where' => 'rid=' . $rid . ' and status=4',
  1408. 'asArray' => true
  1409. ) );
  1410. $tijdate = $receiptLog->getOne ( array (
  1411. 'where' => 'rid=' . $rid . ' and status=2',
  1412. 'asc' => 'rlid',
  1413. 'asArray' => true
  1414. ) );
  1415. if (! empty ( $rlInfo )) {
  1416. $rlList = $receiptLog->find ( array (
  1417. 'where' => 'rid=' . $rid,
  1418. 'asc' => 'rlid',
  1419. 'asArray' => true
  1420. ) );
  1421. }
  1422. $receiptList [0] ['rlList'] = $rlList;
  1423. $enclosurList = $enclosur->find ( array (
  1424. 'where' => 'rid=' . $rid,
  1425. 'asArray' => true
  1426. ) );
  1427. $enclosurHtml = '';
  1428. foreach ( $enclosurList as $value ) {
  1429. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  1430. }
  1431. // print_r($receiptList);
  1432. $data ['enclosurHtml'] = $enclosurHtml;
  1433. $data ['rolename'] = $rolename ['name'];
  1434. $data ['datetij'] = $tijdate ['date'];
  1435. $data ['mothHtml'] = $mothHtml;
  1436. $data ['rid'] = $rid;
  1437. $data ['receiptList'] = $receiptList;
  1438. $data ['receiptApprovalCount'] = count ( $receiptList );
  1439. $data ['status'] = $status;
  1440. $data ['year'] = $year;
  1441. $data ['categoryList'] = $categoryList;
  1442. $data ['staffList'] = $staffList;
  1443. $data ['cid'] = $cid;
  1444. $data ['sid'] = $sid;
  1445. $data ['ap'] = $ap;
  1446. $data ['memu'] = "receipt";
  1447. $data ['staff'] = $this->staff;
  1448. $data ['receiptMemu'] = 'approvalExpenses';
  1449. $data ['verifyId'] = $this->verifyId;
  1450. $data ['executeId'] = $this->executeId;
  1451. $this->render ( "/admin/remitApproval", $data );
  1452. }
  1453. function saeaLoanAdd() {
  1454. Doo::loadModel ( 'verify' );
  1455. $verify = new verify ();
  1456. Doo::loadModel ( "role" );
  1457. $role = new role ();
  1458. Doo::loadModel ( 'L_category' );
  1459. $lCategory = new L_category ();
  1460. $veList = $verify->getVerifyBySubordinate('LOAN');
  1461. $data ['category'] = $lCategory->find ( array (
  1462. 'asArray' => true
  1463. ) );
  1464. $data ['veList'] = $veList;
  1465. $data ['memu'] = "receipt";
  1466. $data ['staff'] = $this->staff;
  1467. $data ['receiptMemu'] = 'saeaBorad';
  1468. $data ['verifyId'] = $this->verifyId;
  1469. $data ['executeId'] = $this->executeId;
  1470. $this->render ( "/admin/saeaLoanAdd", $data );
  1471. }
  1472. function saeaLoanAddDo() {
  1473. $agency = $this->get_args ( 'agency' );
  1474. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1475. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1476. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1477. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1478. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1479. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1480. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1481. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1482. // die;
  1483. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1484. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1485. header ( 'Content-Type:text/html;charset=utf-8' );
  1486. die ( '请填写联行号' );
  1487. }
  1488. Doo::loadModel ( 'receipt' );
  1489. Doo::loadModel ( 'receiptDetail' );
  1490. Doo::loadModel ( 'accountItem' );
  1491. $accountItem = new accountItem ();
  1492. $receipt = new receipt ();
  1493. Doo::loadModel ( 'loanReceipt' );
  1494. $loanReceipt = new loanReceipt ();
  1495. Doo::loadModel ( 'execute' );
  1496. $execute = new execute ();
  1497. Doo::loadModel ( 'enclosur' );
  1498. $executeDetail = $execute->getOne ( array (
  1499. 'where' => 'mold="借款执行人"',
  1500. 'asArray' => true
  1501. ) );
  1502. $aItem = $accountItem->find ( array (
  1503. 'asArray' => true
  1504. ) );
  1505. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1506. $ag = $tr = $ta = $ot = 0;
  1507. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1508. array_push ( $accountJson ['借款费用'], array (
  1509. 'aid' => 0,
  1510. 'name' => '申请金额',
  1511. 'price' => number_format ( $agency, 2, '.', '' )
  1512. ) );
  1513. $sum += $agency;
  1514. $agencySum += $agency;
  1515. $accountJson ['cSum'] = array (
  1516. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1517. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1518. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1519. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1520. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1521. );
  1522. // 借款数据备份
  1523. $loanReceipt->loanItem = json_encode ( $accountJson );
  1524. $loanReceipt->staff = $this->staff [0] ['sid'];
  1525. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1526. $loanReceipt->date = date ( "Y-m-d" );
  1527. $loanReceipt->cid = $cid;
  1528. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1529. $loanReceipt->status = 5;
  1530. $loanReceipt->Rtype = 1;
  1531. $loanReceipt->verify = $verify;
  1532. $receipt->receiptOrder = $receipt->receiptOrder;
  1533. // 添加HTML换行符
  1534. // var_dump($explanation);
  1535. $order = array (
  1536. "\r\n",
  1537. "\n",
  1538. "\r"
  1539. );
  1540. $replace = '<br/>';
  1541. $explanation = str_replace ( $order, $replace, $explanation );
  1542. // $explanation=str_replace('\r',"<br/>",$explanation);
  1543. // $explanation=str_replace('\r\n',"<br/>",$explanation);
  1544. $loanReceipt->explanation = $explanation;
  1545. $loanRid = $loanReceipt->insert ();
  1546. // 报销单
  1547. $receipt->loanItem = json_encode ( $accountJson );
  1548. $receipt->staff = $this->staff [0] ['sid'];
  1549. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1550. $receipt->date = date ( "Y-m-d" );
  1551. $receipt->cid = $cid;
  1552. // 特殊状态
  1553. $receipt->status = 5;
  1554. $receipt->Rtype = 1;
  1555. $receipt->loanRid = $loanRid;
  1556. // 修改审批流程加入角色
  1557. $receipt->verify = $verify;
  1558. $receipt->executeCopy = $executeDetail ['staff'];
  1559. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  1560. $receipt->explanation = $explanation;
  1561. $receipt->remittanceName = $remittanceName;
  1562. $receipt->bankName = $bankName;
  1563. $receipt->bankNumber = $bankNumber;
  1564. $receipt->remittanceBankType = $remittanceBankType;
  1565. if ($remittanceBankType == 1)
  1566. $receipt->coupletNumber = $coupletNumber;
  1567. $rid = $receipt->insert ();
  1568. return "/saeaBorad";
  1569. } else
  1570. die ( 'illegal request' );
  1571. }
  1572. function saeaLoanEdi() {
  1573. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1574. Doo::loadClass ( 'XDeode' );
  1575. $XDeode = new XDeode ( 7 );
  1576. $rid = $XDeode->decode ( $ridKey );
  1577. if (! is_numeric ( $rid ))
  1578. die ( 'illegal request' );
  1579. Doo::loadModel ( 'verify' );
  1580. $verify = new verify ();
  1581. Doo::loadModel ( "role" );
  1582. $role = new role ();
  1583. Doo::loadModel ( 'L_category' );
  1584. $lCategory = new L_category ();
  1585. Doo::loadModel ( 'receipt' );
  1586. $receipt = new receipt ();
  1587. $receiptInfo = $receipt->getOne ( array (
  1588. 'where' => 'rid=' . $rid,
  1589. 'asArray' => true
  1590. ) );
  1591. $veList = $verify->find ( array (
  1592. 'where'=>'subordinate like "%LOAN%"',
  1593. 'asArray' => true
  1594. ) );
  1595. foreach ( $veList as $key => $value ) {
  1596. $v = json_decode ( $value ['staff'] );
  1597. $list = array ();
  1598. foreach ( $v as $n => $m ) {
  1599. if ($m ['1'] == 'ROLE') {
  1600. $roleInfo = $role->getOne ( array (
  1601. 'where' => 'rid=' . $m [0],
  1602. 'asArray' => true
  1603. ) );
  1604. $v [$n] [1] = $roleInfo ['name'];
  1605. array_push ( $list, $roleInfo ['name'] );
  1606. } else {
  1607. array_push ( $list, $v [$n] [1] );
  1608. }
  1609. }
  1610. $veList [$key] ['staff'] = implode ( '>', $list );
  1611. }
  1612. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  1613. // print_r($receiptInfo);
  1614. $data ['receiptInfo'] = $receiptInfo;
  1615. $data ['category'] = $lCategory->find ( array (
  1616. 'asArray' => true
  1617. ) );
  1618. $data ['veList'] = $veList;
  1619. $data ['ridKey'] = $ridKey;
  1620. $data ['memu'] = "receipt";
  1621. $data ['staff'] = $this->staff;
  1622. $data ['receiptMemu'] = 'saeaBorad';
  1623. $data ['verifyId'] = $this->verifyId;
  1624. $data ['executeId'] = $this->executeId;
  1625. $this->render ( "/admin/saeaLoanEdi", $data );
  1626. }
  1627. function saeaLoanEdiDo() {
  1628. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1629. $agency = $this->get_args ( 'agency' );
  1630. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1631. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1632. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1633. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1634. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1635. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1636. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1637. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1638. // die;
  1639. Doo::loadClass ( 'XDeode' );
  1640. $XDeode = new XDeode ( 7 );
  1641. $rid = $XDeode->decode ( $ridKey );
  1642. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1643. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1644. header ( 'Content-Type:text/html;charset=utf-8' );
  1645. die ( '请填写联行号' );
  1646. }
  1647. Doo::loadModel ( 'receipt' );
  1648. Doo::loadModel ( 'receiptDetail' );
  1649. Doo::loadModel ( 'accountItem' );
  1650. $accountItem = new accountItem ();
  1651. $receipt = new receipt ();
  1652. Doo::loadModel ( 'loanReceipt' );
  1653. $loanReceipt = new loanReceipt ();
  1654. Doo::loadModel ( 'enclosur' );
  1655. Doo::loadModel ( 'execute' );
  1656. $execute = new execute ();
  1657. $executeDetail = $execute->getOne ( array (
  1658. 'where' => 'mold="借款执行人"',
  1659. 'asArray' => true
  1660. ) );
  1661. $receiptDetail = $receipt->getOne ( array (
  1662. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  1663. 'asArray' => true
  1664. ) );
  1665. if (empty ( $receiptDetail ))
  1666. die ( '参数错误' );
  1667. $aItem = $accountItem->find ( array (
  1668. 'asArray' => true
  1669. ) );
  1670. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1671. $ag = $tr = $ta = $ot = 0;
  1672. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1673. array_push ( $accountJson ['借款费用'], array (
  1674. 'aid' => 0,
  1675. 'name' => '申请金额',
  1676. 'price' => number_format ( $agency, 2, '.', '' )
  1677. ) );
  1678. $sum += $agency;
  1679. $agencySum += $agency;
  1680. $accountJson ['cSum'] = array (
  1681. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1682. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1683. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1684. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1685. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1686. );
  1687. // 报销单
  1688. $receipt->loanItem = json_encode ( $accountJson );
  1689. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1690. $receipt->cid = $cid;
  1691. // 特殊状态
  1692. // 修改审批流程加入角色
  1693. if ($receiptDetail ['status'] != 4)
  1694. $receipt->verify = $verify;
  1695. $order = array (
  1696. "\r\n",
  1697. "\n",
  1698. "\r"
  1699. );
  1700. $replace = '<br/>';
  1701. $explanation = str_replace ( $order, $replace, $explanation );
  1702. $receipt->explanation = $explanation;
  1703. $receipt->remittanceName = $remittanceName;
  1704. $receipt->bankName = $bankName;
  1705. $receipt->bankNumber = $bankNumber;
  1706. $receipt->remittanceBankType = $remittanceBankType;
  1707. if ($remittanceBankType == 1)
  1708. $receipt->coupletNumber = $coupletNumber;
  1709. $receipt->update ( array (
  1710. 'where' => 'rid=' . $rid
  1711. ) );
  1712. // 借款数据更新
  1713. $loanReceipt->loanItem = json_encode ( $accountJson );
  1714. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1715. $loanReceipt->cid = $cid;
  1716. if ($receiptDetail ['status'] != 4)
  1717. $loanReceipt->verify = $verify;
  1718. $loanReceipt->explanation = $explanation;
  1719. $receipt->executeCopy = $executeDetail ['staff'];
  1720. $loanReceipt->update ( array (
  1721. 'where' => 'rid=' . $receiptDetail ['loanRid']
  1722. ) );
  1723. }
  1724. return "/saeaBorad";
  1725. }
  1726. function saeaLoanReceiptAdd() {
  1727. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1728. Doo::loadModel ( 'receipt' );
  1729. $receipt = new receipt ();
  1730. Doo::loadModel ( 'loanReceipt' );
  1731. $loanReceipt = new loanReceipt ();
  1732. Doo::loadModel ( 'L_category' );
  1733. $Lcategory = new L_category ();
  1734. Doo::loadModel ( 'verify' );
  1735. Doo::loadModel ( 'statistics' );
  1736. $statistics = new statistics ();
  1737. $verify = new verify ();
  1738. Doo::loadModel ( 'staff' );
  1739. $staff = new staff ();
  1740. $receiptDetail = $receipt->getOne ( array (
  1741. 'where' => 'rid=' . $rid,
  1742. 'desc' => 'rid',
  1743. 'asArray' => true
  1744. ) );
  1745. $receiptList = $loanReceipt->find ( array (
  1746. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1747. 'desc' => 'rid',
  1748. 'asArray' => true
  1749. ) );
  1750. $Locate = 0;
  1751. $roleId = 0;
  1752. $button = 0;
  1753. foreach ( $receiptList as $key => $value ) {
  1754. $receiptList [$key] ['Locate'] = $Locate;
  1755. $Locate ++;
  1756. $receiptList [$key] ['reviseDetail'] = array ();
  1757. if (! empty ( $value ['reviseDetail'] ))
  1758. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1759. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1760. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1761. $categoryDetil = $Lcategory->getOne ( array (
  1762. 'where' => 'cid=' . $value ['cid'],
  1763. 'asArray' => true
  1764. ) );
  1765. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1766. // 检测编辑状态
  1767. $verifyList = $verify->getOne ( array (
  1768. 'where' => 'vid=' . $value ['verify'],
  1769. 'asArray' => true
  1770. ) );
  1771. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1772. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1773. Doo::loadModel ( 'role' );
  1774. $role = new role ();
  1775. $flag = true;
  1776. $roleKey = 0;
  1777. $endStaffArray = array ();
  1778. $roleArrayCopy = array ();
  1779. foreach ( $verifyList as $k => $v ) {
  1780. // init verifyStaff
  1781. if ($v [1] == 'ROLE') {
  1782. if (! empty ( $verifyStaff )) {
  1783. $endStaffArray = end ( $verifyStaff );
  1784. // if ($v[0]==$endStaffArray['nextStaff']){
  1785. // $roleId=$v[0];
  1786. // }
  1787. }
  1788. $roleVerify = json_decode ( $v [3], true );
  1789. $roleKey = $k;
  1790. $roleArray = array ();
  1791. $rolename = $role->getOne ( array (
  1792. 'where' => 'rid=' . $v [0],
  1793. 'asArray' => true
  1794. ) );
  1795. foreach ( $roleVerify as $o => $p ) {
  1796. $staffID = explode ( '_', $p );
  1797. $staffInfo = $staff->getOne ( array (
  1798. 'where' => 'sid=' . $staffID [0],
  1799. 'asArray' => true
  1800. ) );
  1801. // print_r($staffID);
  1802. $exp = array (
  1803. 0 => $staffInfo ['sid'],
  1804. 1 => $staffID [1],
  1805. 2 => $staffInfo ['avatar'],
  1806. 'date' => '',
  1807. 'date' => '',
  1808. 'opinion' => '',
  1809. 'status' => '',
  1810. 'rolename' => $rolename ['name']
  1811. );
  1812. array_push ( $roleArray, $exp );
  1813. }
  1814. $roleArrayCopy [$v [0]] = $roleArray;
  1815. // $verifyList[$k]['roleArray']=$roleArray;
  1816. }
  1817. $verifyList [$k] ['date'] = "";
  1818. $verifyList [$k] ['opinion'] = "";
  1819. $verifyList [$k] ['status'] = "";
  1820. if (empty ( $verifyStaff )) {
  1821. $verifyList [$k] ['date'] = "";
  1822. $verifyList [$k] ['opinion'] = "";
  1823. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1824. $verifyList [$k] ['status'] = 4;
  1825. $flag = false;
  1826. }
  1827. } else {
  1828. foreach ( $verifyStaff as $m => $u ) {
  1829. if ($v [0] == $m) {
  1830. $verifyList [$k] ['date'] = $u ['date'];
  1831. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1832. $verifyList [$k] ['status'] = $u ['status'];
  1833. $flag = false;
  1834. break;
  1835. }
  1836. }
  1837. $endStaffArray = end ( $verifyStaff );
  1838. if (isset ( $endStaffArray ['ROLE'] )) {
  1839. } else {
  1840. // $endKey=key($verifyStaff);
  1841. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1842. // $button=4;
  1843. // $verifyList[$k]['status']=4;
  1844. // }
  1845. }
  1846. }
  1847. }
  1848. $rolename ['name'] = '';
  1849. if (! empty ( $roleId )) {
  1850. Doo::loadModel ( 'role' );
  1851. $role = new role ();
  1852. $rolename = $role->getOne ( array (
  1853. 'where' => 'rid=' . $roleId,
  1854. 'asArray' => true
  1855. ) );
  1856. }
  1857. if (! empty ( $verifyStaff ))
  1858. $endStaffArray = end ( $verifyStaff );
  1859. $KOP = false;
  1860. foreach ( $roleArrayCopy as $P => $A ) {
  1861. foreach ( $A as $MKI => $AVL ) {
  1862. if (! empty ( $verifyStaff )) {
  1863. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1864. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1865. $button = 4;
  1866. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1867. }
  1868. foreach ( $verifyStaff as $m => $u ) {
  1869. $AVLFK = $AVL [0] . '_R';
  1870. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1871. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1872. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1873. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1874. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1875. break;
  1876. }
  1877. }
  1878. } else {
  1879. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1880. $button = 4;
  1881. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1882. }
  1883. }
  1884. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1885. $KOP = true;
  1886. }
  1887. }
  1888. foreach ( $roleArrayCopy as $k => $v ) {
  1889. foreach ( $verifyList as $m => $n ) {
  1890. if ($n [0] == $k) {
  1891. array_splice ( $verifyList, $m, 1, $v );
  1892. }
  1893. }
  1894. }
  1895. $receiptList [$key] ['verifyList'] = $verifyList;
  1896. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1897. 'where' => 'sid=' . $value ['staff'],
  1898. 'asArray' => true
  1899. ) );
  1900. $receiptList [$key] ['button'] = $button;
  1901. //
  1902. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1903. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1904. }
  1905. $data ['receiptList'] = $receiptList;
  1906. $data ['receiptDetail'] = $receiptDetail;
  1907. Doo::loadModel ( 'L_category' );
  1908. $lCategory = new L_category ();
  1909. Doo::loadModel ( 'accountItem' );
  1910. $accountItem = new accountItem ();
  1911. $acItem = $accountItem->find ( array (
  1912. 'asArray' => true
  1913. ) );
  1914. $veList = $verify->getVerifyBySubordinate('RECEIPT','LOAN');
  1915. $data ['rid'] = $rid;
  1916. $data ['category'] = $lCategory->find ( array (
  1917. 'asArray' => true
  1918. ) );
  1919. $data ['veList'] = $veList;
  1920. $data ['acItem'] = $acItem;
  1921. $data ['memu'] = "receipt";
  1922. $data ['staff'] = $this->staff;
  1923. $data ['receiptMemu'] = 'saeaBorad';
  1924. $data ['verifyId'] = $this->verifyId;
  1925. $data ['executeId'] = $this->executeId;
  1926. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1927. }
  1928. function saeaLoanReceiptAddDo() {
  1929. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1930. $agency = $this->get_args ( 'agency' );
  1931. $travel = $this->get_args ( 'travel' );
  1932. $train = $this->get_args ( 'train' );
  1933. $other = $this->get_args ( 'other' );
  1934. $inttrain = $this->get_args ( 'inttrain' );
  1935. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1936. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1937. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1938. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1939. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1940. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1941. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1942. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1943. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1944. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1945. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1946. header ( 'Content-Type:text/html;charset=utf-8' );
  1947. die ( '请填写联行号' );
  1948. }
  1949. Doo::loadModel ( 'receipt' );
  1950. Doo::loadModel ( 'receiptDetail' );
  1951. Doo::loadModel ( 'accountItem' );
  1952. $accountItem = new accountItem ();
  1953. $receipt = new receipt ();
  1954. Doo::loadModel ( 'enclosur' );
  1955. Doo::loadModel ( 'execute' );
  1956. $execute = new execute ();
  1957. $executeDetail = $execute->getOne ( array (
  1958. 'where' => 'mold="借款费用执行人"',
  1959. 'asArray' => true
  1960. ) );
  1961. $receiptDet = $receipt->getOne ( array (
  1962. 'where' => 'rid=' . $rid,
  1963. 'asArray' => true
  1964. ) );
  1965. // if(!empty($receiptDetail))
  1966. // return "/referReceipt/".$receiptDetail['rid'];
  1967. $aItem = $accountItem->find ( array (
  1968. 'asArray' => true
  1969. ) );
  1970. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1971. $ag = $tr = $ta = $ot =$it = 0;
  1972. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  1973. foreach ( $aItem as $key => $value ) {
  1974. if ($value ['category'] == $this->AGENCY) {
  1975. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1976. array_push ( $accountJson [$this->AGENCY], array (
  1977. 'aid' => $value ['aid'],
  1978. 'name' => $value ['name'],
  1979. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1980. ) );
  1981. $sum += $agency [$ag];
  1982. $agencySum += $agency [$ag];
  1983. }
  1984. $ag ++;
  1985. }
  1986. if ($value ['category'] == $this->TRAVEL) {
  1987. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1988. array_push ( $accountJson [$this->TRAVEL], array (
  1989. 'aid' => $value ['aid'],
  1990. 'name' => $value ['name'],
  1991. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1992. ) );
  1993. $sum += $travel [$tr];
  1994. $travelSum += $travel [$tr];
  1995. }
  1996. $tr ++;
  1997. }
  1998. if ($value ['category'] == $this->INTTRAIN) {
  1999. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  2000. array_push ( $accountJson [$this->INTTRAIN], array (
  2001. 'aid' => $value ['aid'],
  2002. 'name' => $value ['name'],
  2003. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  2004. ) );
  2005. $sum += $inttrain [$it];
  2006. $inttrainSum += $inttrain [$it];
  2007. }
  2008. $it ++;
  2009. }
  2010. if ($value ['category'] == $this->TRAIN) {
  2011. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  2012. array_push ( $accountJson [$this->TRAIN], array (
  2013. 'aid' => $value ['aid'],
  2014. 'name' => $value ['name'],
  2015. 'price' => number_format ( $train [$ta], 2, '.', '' )
  2016. ) );
  2017. $sum += $train [$ta];
  2018. $trainSum += $train [$ta];
  2019. }
  2020. $ta ++;
  2021. }
  2022. if ($value ['category'] == $this->OTHER) {
  2023. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  2024. array_push ( $accountJson [$this->OTHER], array (
  2025. 'aid' => $value ['aid'],
  2026. 'name' => $value ['name'],
  2027. 'price' => number_format ( $other [$ot], 2, '.', '' )
  2028. ) );
  2029. $sum += $other [$ot];
  2030. $otherSum += $other [$ot];
  2031. }
  2032. $ot ++;
  2033. }
  2034. }
  2035. $accountJson ['cSum'] = array (
  2036. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  2037. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  2038. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  2039. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  2040. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  2041. );
  2042. // 报销单
  2043. $receipt->accountItem = json_encode ( $accountJson );
  2044. $receipt->staff = $this->staff [0] ['sid'];
  2045. $receipt->loanSum = $receiptDet ['sum'];
  2046. $receipt->sum = number_format ( $sum, 2, '.', '' );
  2047. $receipt->date = date ( "Y-m-d" );
  2048. $receipt->pastDate = '';
  2049. $receipt->cid = $cid;
  2050. $receipt->status = 7;
  2051. // 修改审批流程加入角色
  2052. $receipt->verify = $verify;
  2053. $receipt->verifyStaff = '';
  2054. $receipt->executeStaff = '';
  2055. $receipt->executeCopy = $executeDetail ['staff'];
  2056. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  2057. $receipt->explanation = $explanation;
  2058. $receipt->remittanceName = $remittanceName;
  2059. $receipt->bankName = $bankName;
  2060. $receipt->bankNumber = $bankNumber;
  2061. $receipt->remittanceBankType = $remittanceBankType;
  2062. if ($remittanceBankType == 1)
  2063. $receipt->coupletNumber = $coupletNumber;
  2064. $receipt->update ( array (
  2065. 'where' => 'rid=' . $rid
  2066. ) );
  2067. // 附件
  2068. if (! empty ( $enclosurName )) {
  2069. $enclosurArray = explode ( '-', $enclosurName );
  2070. foreach ( $enclosurArray as $value ) {
  2071. $enclosur = new enclosur ();
  2072. $enclosur->name = $value;
  2073. $enclosur->rid = $rid;
  2074. $enclosur->insert ();
  2075. }
  2076. // print_r($enclosurArray);die;
  2077. }
  2078. // 报销详情
  2079. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  2080. $receiptDetail = new receiptDetail ();
  2081. $receiptDetail->staff = $this->staff [0] ['sid'];
  2082. $receiptDetail->item = $value ['name'];
  2083. $receiptDetail->itemCategory = $this->AGENCY;
  2084. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2085. $receiptDetail->date = date ( "Y-m-d" );
  2086. $receiptDetail->cid = $cid;
  2087. $receiptDetail->rid = $rid;
  2088. $receiptDetail->status = 4;
  2089. $receiptDetail->insert ();
  2090. }
  2091. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  2092. $receiptDetail = new receiptDetail ();
  2093. $receiptDetail->staff = $this->staff [0] ['sid'];
  2094. $receiptDetail->item = $value ['name'];
  2095. $receiptDetail->itemCategory = $this->TRAVEL;
  2096. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2097. $receiptDetail->date = date ( "Y-m-d" );
  2098. $receiptDetail->cid = $cid;
  2099. $receiptDetail->rid = $rid;
  2100. $receiptDetail->status = 4;
  2101. $receiptDetail->insert ();
  2102. }
  2103. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  2104. $receiptDetail = new receiptDetail ();
  2105. $receiptDetail->staff = $this->staff [0] ['sid'];
  2106. $receiptDetail->item = $value ['name'];
  2107. $receiptDetail->itemCategory = $this->TRAIN;
  2108. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2109. $receiptDetail->date = date ( "Y-m-d" );
  2110. $receiptDetail->cid = $cid;
  2111. $receiptDetail->rid = $rid;
  2112. $receiptDetail->status = 4;
  2113. $receiptDetail->insert ();
  2114. }
  2115. //内训
  2116. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  2117. $receiptDetail = new receiptDetail ();
  2118. $receiptDetail->staff = $this->staff [0] ['sid'];
  2119. $receiptDetail->item = $value ['name'];
  2120. $receiptDetail->itemCategory = $this->INTTRAIN;
  2121. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2122. $receiptDetail->date = date ( "Y-m-d" );
  2123. $receiptDetail->cid = $cid;
  2124. $receiptDetail->rid = $rid;
  2125. $receiptDetail->status = 4;
  2126. $receiptDetail->insert ();
  2127. }
  2128. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  2129. $receiptDetail = new receiptDetail ();
  2130. $receiptDetail->staff = $this->staff [0] ['sid'];
  2131. $receiptDetail->item = $value ['name'];
  2132. $receiptDetail->itemCategory = $this->OTHER;
  2133. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2134. $receiptDetail->date = date ( "Y-m-d" );
  2135. $receiptDetail->cid = $cid;
  2136. $receiptDetail->rid = $rid;
  2137. $receiptDetail->status = 4;
  2138. $receiptDetail->insert ();
  2139. }
  2140. return "/saeaBorad";
  2141. }
  2142. return "/saeaLoanReceiptAdd/" . $rid;
  2143. }
  2144. function saeaLoanReceiptEdi() {
  2145. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2146. Doo::loadClass ( 'XDeode' );
  2147. $XDeode = new XDeode ( 7 );
  2148. $rid = $XDeode->decode ( $ridKey );
  2149. if (! is_numeric ( $rid ))
  2150. die ( 'illegal request' );
  2151. Doo::loadModel ( 'accountItem' );
  2152. Doo::loadModel ( 'verify' );
  2153. Doo::loadModel ( 'receipt' );
  2154. $receipt = new receipt ();
  2155. $verify = new verify ();
  2156. $accountItem = new accountItem ();
  2157. Doo::loadModel ( 'L_category' );
  2158. $Lcategory = new L_category ();
  2159. Doo::loadModel ( "role" );
  2160. $role = new role ();
  2161. Doo::loadModel ( 'loanReceipt' );
  2162. $loanReceipt = new loanReceipt ();
  2163. Doo::loadModel ( 'staff' );
  2164. $staff = new staff ();
  2165. $receiptDetail = $receipt->getOne ( array (
  2166. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  2167. 'asArray' => true
  2168. ) );
  2169. if (empty ( $receiptDetail ))
  2170. return "/saeaBorad";
  2171. $receiptList = $loanReceipt->find ( array (
  2172. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  2173. 'desc' => 'rid',
  2174. 'asArray' => true
  2175. ) );
  2176. $Locate = 0;
  2177. $roleId = 0;
  2178. $button = 0;
  2179. foreach ( $receiptList as $key => $value ) {
  2180. $receiptList [$key] ['Locate'] = $Locate;
  2181. $Locate ++;
  2182. $receiptList [$key] ['reviseDetail'] = array ();
  2183. if (! empty ( $value ['reviseDetail'] ))
  2184. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2185. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2186. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2187. $categoryDetil = $Lcategory->getOne ( array (
  2188. 'where' => 'cid=' . $value ['cid'],
  2189. 'asArray' => true
  2190. ) );
  2191. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2192. // 检测编辑状态
  2193. $verifyList = $verify->getOne ( array (
  2194. 'where' => 'vid=' . $value ['verify'],
  2195. 'asArray' => true
  2196. ) );
  2197. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2198. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2199. Doo::loadModel ( 'role' );
  2200. $role = new role ();
  2201. $flag = true;
  2202. $roleKey = 0;
  2203. $endStaffArray = array ();
  2204. $roleArrayCopy = array ();
  2205. foreach ( $verifyList as $k => $v ) {
  2206. // init verifyStaff
  2207. if ($v [1] == 'ROLE') {
  2208. if (! empty ( $verifyStaff )) {
  2209. $endStaffArray = end ( $verifyStaff );
  2210. // if ($v[0]==$endStaffArray['nextStaff']){
  2211. // $roleId=$v[0];
  2212. // }
  2213. }
  2214. $roleVerify = json_decode ( $v [3], true );
  2215. $roleKey = $k;
  2216. $roleArray = array ();
  2217. $rolename = $role->getOne ( array (
  2218. 'where' => 'rid=' . $v [0],
  2219. 'asArray' => true
  2220. ) );
  2221. foreach ( $roleVerify as $o => $p ) {
  2222. $staffID = explode ( '_', $p );
  2223. $staffInfo = $staff->getOne ( array (
  2224. 'where' => 'sid=' . $staffID [0],
  2225. 'asArray' => true
  2226. ) );
  2227. // print_r($staffID);
  2228. $exp = array (
  2229. 0 => $staffInfo ['sid'],
  2230. 1 => $staffID [1],
  2231. 2 => $staffInfo ['avatar'],
  2232. 'date' => '',
  2233. 'date' => '',
  2234. 'opinion' => '',
  2235. 'status' => '',
  2236. 'rolename' => $rolename ['name']
  2237. );
  2238. array_push ( $roleArray, $exp );
  2239. }
  2240. $roleArrayCopy [$v [0]] = $roleArray;
  2241. // $verifyList[$k]['roleArray']=$roleArray;
  2242. }
  2243. $verifyList [$k] ['date'] = "";
  2244. $verifyList [$k] ['opinion'] = "";
  2245. $verifyList [$k] ['status'] = "";
  2246. if (empty ( $verifyStaff )) {
  2247. $verifyList [$k] ['date'] = "";
  2248. $verifyList [$k] ['opinion'] = "";
  2249. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2250. $verifyList [$k] ['status'] = 4;
  2251. $flag = false;
  2252. }
  2253. } else {
  2254. foreach ( $verifyStaff as $m => $u ) {
  2255. if ($v [0] == $m) {
  2256. $verifyList [$k] ['date'] = $u ['date'];
  2257. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2258. $verifyList [$k] ['status'] = $u ['status'];
  2259. $flag = false;
  2260. break;
  2261. }
  2262. }
  2263. $endStaffArray = end ( $verifyStaff );
  2264. if (isset ( $endStaffArray ['ROLE'] )) {
  2265. } else {
  2266. // $endKey=key($verifyStaff);
  2267. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2268. // $button=4;
  2269. // $verifyList[$k]['status']=4;
  2270. // }
  2271. }
  2272. }
  2273. }
  2274. $rolename ['name'] = '';
  2275. if (! empty ( $roleId )) {
  2276. Doo::loadModel ( 'role' );
  2277. $role = new role ();
  2278. $rolename = $role->getOne ( array (
  2279. 'where' => 'rid=' . $roleId,
  2280. 'asArray' => true
  2281. ) );
  2282. }
  2283. if (! empty ( $verifyStaff ))
  2284. $endStaffArray = end ( $verifyStaff );
  2285. $KOP = false;
  2286. foreach ( $roleArrayCopy as $P => $A ) {
  2287. foreach ( $A as $MKI => $AVL ) {
  2288. if (! empty ( $verifyStaff )) {
  2289. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2290. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2291. $button = 4;
  2292. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2293. }
  2294. foreach ( $verifyStaff as $m => $u ) {
  2295. $AVLFK = $AVL [0] . '_R';
  2296. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2297. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2298. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2299. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2300. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2301. break;
  2302. }
  2303. }
  2304. } else {
  2305. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2306. $button = 4;
  2307. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2308. }
  2309. }
  2310. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2311. $KOP = true;
  2312. }
  2313. }
  2314. foreach ( $roleArrayCopy as $k => $v ) {
  2315. foreach ( $verifyList as $m => $n ) {
  2316. if ($n [0] == $k) {
  2317. array_splice ( $verifyList, $m, 1, $v );
  2318. }
  2319. }
  2320. }
  2321. $receiptList [$key] ['verifyList'] = $verifyList;
  2322. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2323. 'where' => 'sid=' . $value ['staff'],
  2324. 'asArray' => true
  2325. ) );
  2326. $receiptList [$key] ['button'] = $button;
  2327. //
  2328. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  2329. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  2330. }
  2331. $data ['receiptList'] = $receiptList;
  2332. $acItem = $accountItem->find ( array (
  2333. 'asArray' => true
  2334. ) );
  2335. $veList = $verify->find ( array (
  2336. 'asArray' => true
  2337. ) );
  2338. foreach ( $veList as $key => $value ) {
  2339. $v = json_decode ( $value ['staff'] );
  2340. $list = array ();
  2341. foreach ( $v as $n => $m ) {
  2342. if ($m ['1'] == 'ROLE') {
  2343. $roleInfo = $role->getOne ( array (
  2344. 'where' => 'rid=' . $m [0],
  2345. 'asArray' => true
  2346. ) );
  2347. $v [$n] [1] = $roleInfo ['name'];
  2348. array_push ( $list, $roleInfo ['name'] );
  2349. } else {
  2350. array_push ( $list, $v [$n] [1] );
  2351. }
  2352. }
  2353. $veList [$key] ['staff'] = implode ( '>', $list );
  2354. }
  2355. // 配置编辑信息
  2356. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  2357. foreach ( $acItem as $key => $value ) {
  2358. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  2359. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  2360. $acItem [$key] ['price'] = $v ['price'];
  2361. }
  2362. }
  2363. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  2364. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  2365. $acItem [$key] ['price'] = $v ['price'];
  2366. }
  2367. }
  2368. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  2369. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  2370. $acItem [$key] ['price'] = $v ['price'];
  2371. }
  2372. }
  2373. //内训
  2374. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  2375. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  2376. $acItem [$key] ['price'] = $v ['price'];
  2377. }
  2378. }
  2379. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  2380. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  2381. $acItem [$key] ['price'] = $v ['price'];
  2382. }
  2383. }
  2384. }
  2385. $data ['category'] = $Lcategory->find ( array (
  2386. 'asArray' => true
  2387. ) );
  2388. $data ['ridKey'] = $ridKey;
  2389. $data ['cSum'] = $accountItemList ['cSum'];
  2390. $data ['sum'] = $receiptDetail ['sum'];
  2391. $data ['receiptDetail'] = $receiptDetail;
  2392. $data ['veList'] = $veList;
  2393. $data ['acItem'] = $acItem;
  2394. $data ['memu'] = "receipt";
  2395. $data ['staff'] = $this->staff;
  2396. $data ['receiptMemu'] = 'saeaBorad';
  2397. $data ['verify'] = $receiptDetail ['verify'];
  2398. $data ['verifyId'] = $this->verifyId;
  2399. $data ['executeId'] = $this->executeId;
  2400. $data ['rid'] = $rid;
  2401. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  2402. }
  2403. /**
  2404. * 培训班结算
  2405. */
  2406. function receiptTrainAdd() {
  2407. Doo::loadModel ( 'accountItem' );
  2408. $accountItem = new accountItem ();
  2409. $acItem = $accountItem->find ( array (
  2410. 'asArray' => true
  2411. ) );
  2412. // 审批组
  2413. Doo::loadModel ( 'verify' );
  2414. $verify = new verify ();
  2415. $veList = $verify->getVerifyBySubordinate('TRAIN');
  2416. // 办事处
  2417. Doo::loadModel ( 'L_category' );
  2418. $lCategory = new L_category ();
  2419. $data ['category'] = $lCategory->getCategory ();
  2420. $data ['veList'] = $veList;
  2421. $data ['memu'] = "receipt";
  2422. $data ['staff'] = $this->staff;
  2423. $data ['acItem'] = $acItem;
  2424. $data ['receiptMemu'] = 'saeaBorad';
  2425. $data ['verifyId'] = $this->verifyId;
  2426. $data ['executeId'] = $this->executeId;
  2427. $this->render ( "/receipt/receiptTrainAdd", $data );
  2428. }
  2429. /**
  2430. * 添加培训班结算
  2431. */
  2432. function receiptTrainAddDo() {//include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  2433. // 培训班信息
  2434. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  2435. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  2436. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  2437. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  2438. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  2439. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  2440. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  2441. // 发票信息
  2442. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2443. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2444. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2445. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2446. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2447. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2448. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2449. //&&! empty ( $participants )
  2450. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  2451. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2452. header ( 'Content-Type:text/html;charset=utf-8' );
  2453. die ( '请填写联行号' );
  2454. }
  2455. Doo::loadModel ( 'execute' );
  2456. $execute = new execute ();
  2457. $executeDetail = $execute->getOne ( array (
  2458. 'where' => 'mold="培训班结算"',
  2459. 'asArray' => true
  2460. ) );
  2461. if (empty ( $executeDetail )) {
  2462. header ( 'Content-Type:text/html;charset=utf-8' );
  2463. die ( '未设置执行人' );
  2464. }
  2465. Doo::loadClass ( 'XDeode' );
  2466. $XDeode = new XDeode ( 5 );
  2467. $cid = $XDeode->decode ( $cid );
  2468. Doo::loadModel ( 'receipt' );
  2469. $receipt = new receipt ();
  2470. Doo::loadModel ( 'receiptTraining' );
  2471. $receiptTraining = new receiptTraining ();
  2472. // 创建费用培训班
  2473. $item = array (
  2474. 'cid' => $this->staff [0] ['cid'],
  2475. 'categoryName' => $this->staff [0] ['category'],
  2476. 'trainName' => $trainName,
  2477. 'trainStartDate' => $trainStartDate,
  2478. 'trainEndDate' => $trainEndDate,
  2479. 'participants' => $participants,
  2480. 'freeParticipants'=>$freeParticipants,
  2481. 'trainAddress' => $trainAddress,
  2482. 'trainRemarks' => $trainRemarks,
  2483. 'creator' => $this->staff [0] ['sid'],
  2484. 'creatorDate' => date ( "Y-m-d H:i:s" )
  2485. );
  2486. $irid = $receiptTraining->addReceiptTraining ( $item );
  2487. // 报销单
  2488. $receipt->status = 5;
  2489. $receipt->trainId = $irid;
  2490. $receipt->Rtype = 3;
  2491. $receipt->staff = $this->staff [0] ['sid'];
  2492. $receipt->cid = $cid;
  2493. $receipt->verify = $verify;
  2494. $receipt->date = date ( "Y-m-d" );
  2495. $receipt->executeCopy = $executeDetail ['staff'];
  2496. $receipt->receiptOrder = "#P" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  2497. $receipt->remittanceName = $remittanceName;
  2498. $receipt->bankName = $bankName;
  2499. $receipt->bankNumber = $bankNumber;
  2500. $receipt->remittanceBankType = $remittanceBankType;
  2501. if ($remittanceBankType == 1)
  2502. $receipt->coupletNumber = $coupletNumber;
  2503. $rid = $receipt->insert ();
  2504. $XDeode = new XDeode ( 7 );
  2505. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html";
  2506. } else
  2507. die ( 'illegal request' );
  2508. }
  2509. /**
  2510. * 培训班编辑
  2511. */
  2512. function receiptTrainEdi() {
  2513. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2514. $trainEdiType = $this->get_args ( 'trainEdiType' ) ? $this->get_args ( 'trainEdiType' ) : "INFO";
  2515. Doo::loadClass ( 'XDeode' );
  2516. $XDeode = new XDeode ( 7 );
  2517. $rid = $XDeode->decode ( $ridKey );
  2518. if (! is_numeric ( $rid ))
  2519. die ( 'illegal request' );
  2520. Doo::loadModel ( 'receipt' );
  2521. $receipt = new receipt ();
  2522. Doo::loadModel ( 'receiptTraining' );
  2523. $receiptTraining = new receiptTraining ();
  2524. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2525. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)){
  2526. die ('illegal request--status');
  2527. }
  2528. //如有已入账已收款的发票,自动取消办事处已收款
  2529. // Doo::loadModel ( 'RIExtend' );
  2530. // $RIExtend = new RIExtend ();
  2531. // $RIExtendList=$RIExtend->getRIExtendByRid($rid);
  2532. // if (!empty($RIExtendList)){
  2533. // foreach ($RIExtendList as $key=>$value){
  2534. // $RIExtend = new RIExtend ();
  2535. // $RIExtend->delete(array (
  2536. // 'where' => 'iid=' . $value['iid'],
  2537. // 'limit' => 1
  2538. // ));
  2539. // }
  2540. // }
  2541. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2542. // 汇总表合计
  2543. // 收入合计--加入开票合计
  2544. Doo::loadModel ( 'invoiceTraining' );
  2545. $invoiceTraining = new invoiceTraining ();
  2546. $invoiceTrainingDetail = array (
  2547. 'invoiceArriveAmount' => 0,
  2548. 'RIAmount' => 0,
  2549. 'invoiceTotalAmount' => 0,
  2550. 'invoiceCompanyAmount'=>0
  2551. );
  2552. if ($receiptDetail ['invoiceTrainId'] != 0) {
  2553. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  2554. }
  2555. // print_r($invoiceTrainingDetail);
  2556. $invoiceArriveAmount = $RIAmount = 0;
  2557. if (! empty ( $invoiceTrainingDetail )) {
  2558. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  2559. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  2560. }
  2561. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  2562. //print_r($invoiceTrainingDetail);
  2563. // 支出项目
  2564. Doo::loadModel ( 'accountItem' );
  2565. $accountItem = new accountItem ();
  2566. // 项目金额合计
  2567. Doo::loadModel ( 'RItem' );
  2568. $RItem = new RItem ();
  2569. // 讲师获得
  2570. Doo::loadModel ( 'RILecturer' );
  2571. $RILecturer = new RILecturer ();
  2572. $RItemList = $RItem->getRItemByRid ( $rid );
  2573. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2574. // 支出项金额详情
  2575. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  2576. // print_r($aiData);
  2577. // 利润
  2578. $profit=$invoiceArriveAmount - $aiData ['total'];
  2579. $companyProfit=$profit * 0.6;
  2580. $categoryProfit=$profit * 0.4;
  2581. $data ['profit'] = sprintf("%.2f",$profit);
  2582. $data ['companyProfit'] = sprintf("%.2f",$companyProfit);
  2583. $data ['categoryProfit'] = sprintf("%.2f",$categoryProfit);
  2584. //发票利润
  2585. $data ['invoiceProfit'] = $invoiceTrainingDetail ['invoiceTotalAmount'] - $aiData ['total'];
  2586. //发票公司利润
  2587. $invoiceCompanyProfit=$data ['invoiceProfit'] * 0.6;
  2588. $data ['invoiceCompanyProfit'] = sprintf("%.2f",$invoiceCompanyProfit);
  2589. //办事处利润
  2590. $invoiceCategoryProfit=$data ['invoiceProfit'] * 0.4;
  2591. $data ['invoiceCategoryProfit'] = sprintf("%.2f",$invoiceCategoryProfit);
  2592. // print_r($aiData['dataList']);
  2593. $categoryActualExpenditure= $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  2594. $data ['categoryActualExpenditure'] = sprintf("%.2f",$categoryActualExpenditure);
  2595. // 备用金
  2596. $sum = 0;
  2597. $data ['receiptLoanDetail'] = array (
  2598. 'sum' => '0.00'
  2599. );
  2600. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  2601. //$data ['receiptLoanDetail'] = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2602. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2603. $sum=0;
  2604. foreach ($receiptLoanList as $key=>$value){
  2605. $sum+=$value['sum'];
  2606. }
  2607. $data ['receiptLoanDetail'] = array (
  2608. 'sum' => $sum
  2609. );
  2610. //$sum = $data ['receiptLoanDetail'] ['sum'];
  2611. }
  2612. $payment=$sum + $RIAmount - $categoryActualExpenditure;
  2613. $data ['payment'] = sprintf("%.2f",$payment);
  2614. $data ['total'] = sprintf("%.2f",$aiData ['total']);
  2615. $data ['aiCount'] = count ( $aiData ['dataList'] ) + 5;
  2616. $data ['aiList'] = $aiData ['dataList'];
  2617. // 占比计算
  2618. if ($invoiceArriveAmount != 0) {
  2619. $data ['totalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceArriveAmount* 100) ;
  2620. $data ['profitProportion'] = sprintf("%.2f",$profit / $invoiceArriveAmount*100) ; //number_format ( $profit / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2621. $data ['sumProportion'] = sprintf("%.2f",$sum / $invoiceArriveAmount*100) ; //number_format ( $sum / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2622. $data ['invoiceTotalAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceArriveAmount*100) ;
  2623. $data ['RIAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceArriveAmount*100) ;
  2624. $data ['companyProfitProportion'] = sprintf("%.2f",$companyProfit / $invoiceArriveAmount*100) ;
  2625. $data ['categoryProportion'] = sprintf("%.2f",$categoryProfit / $invoiceArriveAmount*100) ;
  2626. $data ['categoryActualExpenditureProportion'] = sprintf("%.2f",$categoryActualExpenditure / $invoiceArriveAmount*100) ;
  2627. $data ['paymentProportion'] = sprintf("%.2f",$payment / $invoiceArriveAmount*100) ;
  2628. } else {
  2629. $data ['totalProportion'] = $data ['profitProportion'] = $data ['sumProportion'] = $data ['invoiceTotalAmountProportion'] = $data ['RIAmountProportion'] = $data ['companyProfitProportion'] = $data ['categoryActualExpenditureProportion'] = $data ['paymentProportion'] = $data ['categoryProportion'] = 0;
  2630. }
  2631. //发票金额占比计算
  2632. if ($invoiceTrainingDetail ['invoiceTotalAmount'] != 0) {
  2633. //支出
  2634. $data ['invoicetotalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2635. //利润
  2636. $data ['invoiceprofitProportion'] = sprintf("%.2f",$data ['invoiceProfit'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2637. //公司利润
  2638. $data ['invoicecompanyProfitProportion'] = sprintf("%.2f", $invoiceCompanyProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2639. //办事处利润
  2640. $data ['invoicecategoryProportion'] = sprintf("%.2f", $invoiceCategoryProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2641. //公司收款
  2642. $data ['invoiceTotalAmountProportionB'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2643. //备用金
  2644. $data ['invoicesumProportion'] = sprintf("%.2f", $sum / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2645. //办事处收款
  2646. $data ['invoiceRIAmountProportion'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2647. //办事处实际支出
  2648. $data ['ICAEP'] = sprintf("%.2f", $categoryActualExpenditure / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2649. //付总部款
  2650. $data ['invoicepaymentProportion'] = sprintf("%.2f", $payment / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2651. }else{
  2652. $data ['invoiceprofitProportion'] =$data ['invoiceRIAmountProportion'] =$data ['invoicetotalProportion'] =$data ['invoiceTotalAmountProportionB'] =$data ['invoicesumProportion'] =$data ['ICAEP'] =$data ['invoicepaymentProportion'] =$data ['invoicecompanyProfitProportion'] =$data ['invoicecategoryProportion'] =0;
  2653. }
  2654. //讲师人数
  2655. Doo::loadModel ( 'RILecturer' );
  2656. $RILecturer = new RILecturer ();
  2657. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2658. $data['lectureCount']=count($RILecturerList);
  2659. // 审批组
  2660. Doo::loadModel ( 'verify' );
  2661. $verify = new verify ();
  2662. $veList = $verify->getVerifyBySubordinate('TRAIN');
  2663. // 办事处
  2664. Doo::loadModel ( 'L_category' );
  2665. $lCategory = new L_category ();
  2666. $data ['category'] = $lCategory->getCategory ();
  2667. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2668. $data ['receiptDetail'] = $receiptDetail;
  2669. $data ['veList'] = $veList;
  2670. $data ['trainEdiType'] = $trainEdiType;
  2671. $data ['ridKey'] = $ridKey;
  2672. $data ['memu'] = "receipt";
  2673. $data ['staff'] = $this->staff;
  2674. $data ['receiptMemu'] = 'saeaBorad';
  2675. $data ['verifyId'] = $this->verifyId;
  2676. $data ['executeId'] = $this->executeId;
  2677. $this->render ( "/receipt/receiptTrainEdi", $data );
  2678. }
  2679. /**
  2680. * 培训班借款编辑
  2681. */
  2682. function receiptTrainLoanEdi() {
  2683. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2684. Doo::loadClass ( 'XDeode' );
  2685. $XDeode = new XDeode ( 7 );
  2686. $rid = $XDeode->decode ( $ridKey );
  2687. if (! is_numeric ( $rid ))
  2688. die ( 'illegal request' );
  2689. Doo::loadModel ( 'receipt' );
  2690. $receipt = new receipt ();
  2691. Doo::loadModel ( 'receiptTraining' );
  2692. $receiptTraining = new receiptTraining ();
  2693. Doo::loadModel ( 'verify' );
  2694. $verify = new verify ();
  2695. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2696. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  2697. die ();
  2698. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2699. // 借款详情HTML
  2700. // 获得借款信息
  2701. $receiptLoanHtml = '';
  2702. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  2703. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2704. foreach ($receiptLoanList as $key=>$value){
  2705. // 获得某费用单审批信息
  2706. $verifylist = $verify->getVerifyByRid ( $value ['rid'] );
  2707. Doo::loadClass ( 'receipt.func' );
  2708. $extendHtml = '<p><a class="button"
  2709. href="javascript:if(window.confirm(\'确认移除?\'))window.location=\'/receiptTrainLoanRemoveDo/' . $receiptDetail ['ridKey'] . '/' . $value ['ridKey'] . '.html\'" data-toggle="modal">移除借款</a></p>';
  2710. $receiptLoanHtml .= _getReceiptLoanHtml ( $value, $verifylist, $extendHtml );
  2711. }
  2712. }
  2713. $data ['receiptLoanHtml'] = $receiptLoanHtml;
  2714. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2715. $data ['receiptDetail'] = $receiptDetail;
  2716. $data ['trainEdiType'] = "LOAN";
  2717. $data ['ridKey'] = $ridKey;
  2718. $data ['memu'] = "receipt";
  2719. $data ['staff'] = $this->staff;
  2720. $data ['receiptMemu'] = 'saeaBorad';
  2721. $data ['verifyId'] = $this->verifyId;
  2722. $data ['executeId'] = $this->executeId;
  2723. $this->render ( "/receipt/receiptTrainLoanEdi", $data );
  2724. }
  2725. /**
  2726. * 更新培训班结算基本信息
  2727. */
  2728. function receiptTrainInfoEdiDo() {
  2729. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  2730. $rtid = $this->get_args ( 'rtid' ) ? $this->get_args ( 'rtid' ) : "";
  2731. // 培训班信息
  2732. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  2733. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  2734. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  2735. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  2736. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  2737. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  2738. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  2739. // 发票信息
  2740. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2741. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2742. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2743. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2744. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2745. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2746. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2747. //&& ! empty ( $participants )
  2748. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  2749. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2750. header ( 'Content-Type:text/html;charset=utf-8' );
  2751. die ( '请填写联行号' );
  2752. }
  2753. Doo::loadClass ( 'XDeode' );
  2754. $XDeode = new XDeode ( 5 );
  2755. $cid = $XDeode->decode ( $cid );
  2756. $rtid = $XDeode->decode ( $rtid );
  2757. $rid = $XDeode->decode ( $rid );
  2758. if (! is_numeric ( $rtid ) || ! is_numeric ( $rid )) {
  2759. die ( 'illegal request-IdError' );
  2760. }
  2761. Doo::loadModel ( 'receipt' );
  2762. $receipt = new receipt ();
  2763. Doo::loadModel ( 'receiptTraining' );
  2764. $receiptTraining = new receiptTraining ();
  2765. // 更新费用培训班
  2766. $item = array (
  2767. 'rtid' => $rtid,
  2768. 'trainName' => $trainName,
  2769. 'trainStartDate' => $trainStartDate,
  2770. 'trainEndDate' => $trainEndDate,
  2771. 'participants' => $participants,
  2772. 'freeParticipants'=>$freeParticipants,
  2773. 'trainAddress' => $trainAddress,
  2774. 'trainRemarks' => $trainRemarks
  2775. );
  2776. $irid = $receiptTraining->setReceiptTrainByCondition ( $item );
  2777. // 报销单
  2778. $receipt->rid = $rid;
  2779. $receipt->cid = $cid;
  2780. $receipt->verify = $verify;
  2781. $receipt->remittanceName = $remittanceName;
  2782. $receipt->bankName = $bankName;
  2783. $receipt->bankNumber = $bankNumber;
  2784. $receipt->remittanceBankType = $remittanceBankType;
  2785. if ($remittanceBankType == 1)
  2786. $receipt->coupletNumber = $coupletNumber;
  2787. $receipt->update ();
  2788. $XDeode = new XDeode ( 7 );
  2789. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html?trainEdiType=INFO";
  2790. } else
  2791. die ( 'illegal request' );
  2792. }
  2793. /**
  2794. * 编辑培训班结算---更新借款
  2795. */
  2796. function receiptTrainLoanEdiDo() {
  2797. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2798. $ridLoanKey = $this->get_args ( 'ridLoanKey' ) ? $this->get_args ( 'ridLoanKey' ) : "";
  2799. if (! empty ( $ridKey ) && ! empty ( $ridLoanKey )) {
  2800. Doo::loadModel ( 'receipt' );
  2801. $receipt = new receipt ();
  2802. Doo::loadClass ( 'XDeode' );
  2803. $XDeode = new XDeode ( 5 );
  2804. $rid = $XDeode->decode ( $ridKey );
  2805. $ridLoan = $XDeode->decode ( $ridLoanKey );
  2806. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  2807. die ( 'illegal request-ridError' );
  2808. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2809. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  2810. // 不合法的数据if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  2811. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2812. die ( 'illegal request-receiptError' );
  2813. }
  2814. if ($receiptLoanDetail ['status'] != 8 || $receiptLoanDetail ['Rtype'] != 1) {
  2815. die ( 'illegal request-receipLoantError' );
  2816. }
  2817. // 培训班结算挂钩借款
  2818. $receipt = new receipt ();
  2819. $trainLoanRid=$ridLoan;
  2820. if (!empty($receiptDetail['trainLoanRid'])){
  2821. $trainLoanRid=$receiptDetail['trainLoanRid'].','.$ridLoan;
  2822. }
  2823. $item = array (
  2824. 'rid' => $rid,
  2825. 'trainLoanRid' => $trainLoanRid
  2826. );
  2827. $receipt->setReceiptByCondition ( $item );
  2828. // 更新借款状态变成已挂钩
  2829. $receipt = new receipt ();
  2830. $item = array (
  2831. 'rid' => $ridLoan,
  2832. 'status' => 10,
  2833. 'statusTrain' => 1
  2834. );
  2835. $receipt->setReceiptByCondition ( $item );
  2836. $XDeode = new XDeode ( 7 );
  2837. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  2838. } else
  2839. die ( 'illegal request' );
  2840. }
  2841. /**
  2842. * 编辑培训班结算--移除借款
  2843. */
  2844. function receiptTrainLoanRemoveDo() {
  2845. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : 0;
  2846. $ridLoanKey = isset ( $this->params ['ridLoanKey'] ) ? $this->params ['ridLoanKey'] : 0;
  2847. if (! empty ( $ridKey ) || ! empty ( $ridLoanKey )) {
  2848. Doo::loadModel ( 'receipt' );
  2849. $receipt = new receipt ();
  2850. Doo::loadClass ( 'XDeode' );
  2851. $XDeode = new XDeode ( 5 );
  2852. $rid = $XDeode->decode ( $ridKey );
  2853. $ridLoan = $XDeode->decode ( $ridLoanKey );
  2854. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  2855. die ( 'illegal request-ridError' );
  2856. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2857. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  2858. // 不合法的数据 !($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)
  2859. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2860. die ( 'illegal request-receiptError' );
  2861. }
  2862. if ($receiptLoanDetail ['status'] != 10 || $receiptLoanDetail ['Rtype'] != 1) {
  2863. die ( 'illegal request-receipLoantError' );
  2864. }
  2865. // 培训班结算挂钩借款
  2866. $receipt = new receipt ();
  2867. $trainLoanRidArray=explode(",", $receiptDetail['trainLoanRid']);
  2868. foreach ($trainLoanRidArray as $key=>$value){
  2869. if($value==$ridLoan){
  2870. unset($trainLoanRidArray[$key]);
  2871. }
  2872. }
  2873. $trainLoanRidString=implode(",", $trainLoanRidArray);
  2874. $item = array (
  2875. 'rid' => $rid,
  2876. 'trainLoanRid' => $trainLoanRidString
  2877. );
  2878. $receipt->setReceiptByCondition ( $item );
  2879. // 更新借款状态变成已挂钩
  2880. $receipt = new receipt ();
  2881. $item = array (
  2882. 'rid' => $ridLoan,
  2883. 'status' => 8,
  2884. 'statusTrain' => 0
  2885. );
  2886. $receipt->setReceiptByCondition ( $item );
  2887. $XDeode = new XDeode ( 7 );
  2888. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  2889. } else
  2890. die ( 'illegal request' );
  2891. }
  2892. /**
  2893. * 编辑培训班结算 ---开票
  2894. */
  2895. function receiptTrainInvoiceEdi() {
  2896. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2897. Doo::loadClass ( 'XDeode' );
  2898. $XDeode = new XDeode ( 7 );
  2899. $rid = $XDeode->decode ( $ridKey );
  2900. if (! is_numeric ( $rid ))
  2901. die ( 'illegal request' );
  2902. Doo::loadModel ( 'receipt' );
  2903. $receipt = new receipt ();
  2904. Doo::loadModel ( 'receiptTraining' );
  2905. $receiptTraining = new receiptTraining ();
  2906. Doo::loadModel ( 'invoice' );
  2907. $invoice = new invoice ();
  2908. Doo::loadModel ( 'invoiceTraining' );
  2909. $invoiceTraining = new invoiceTraining ();
  2910. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2911. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  2912. die ();
  2913. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2914. $invoiceList = $invoiceTrainingDetail = array ();
  2915. if ($receiptDetail ['invoiceTrainId'] != 0) {
  2916. $invoiceList = $invoice->getInvoicePrintedByItid ( $receiptDetail ['invoiceTrainId'] );
  2917. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  2918. }
  2919. //print_r($invoiceList);
  2920. $data ['invoiceList'] = $invoiceList;
  2921. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  2922. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2923. $data ['receiptDetail'] = $receiptDetail;
  2924. $data ['trainEdiType'] = "INVOICE";
  2925. $data ['ridKey'] = $ridKey;
  2926. $data ['memu'] = "receipt";
  2927. $data ['staff'] = $this->staff;
  2928. $data ['receiptMemu'] = 'saeaBorad';
  2929. $data ['verifyId'] = $this->verifyId;
  2930. $data ['executeId'] = $this->executeId;
  2931. $this->render ( "/receipt/receiptTrainInvoiceEdi", $data );
  2932. }
  2933. /**
  2934. * 编辑培训班结算---更新开票
  2935. */
  2936. function receiptTrainInvoiceEdiDo() {
  2937. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2938. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : "";
  2939. if (! empty ( $ridKey ) && ! empty ( $itidKey )) {
  2940. Doo::loadModel ( 'receipt' );
  2941. $receipt = new receipt ();
  2942. Doo::loadModel ( 'invoiceTraining' );
  2943. $invoiceTraining = new invoiceTraining ();
  2944. Doo::loadClass ( 'XDeode' );
  2945. $XDeode = new XDeode ( 5 );
  2946. $rid = $XDeode->decode ( $ridKey );
  2947. $itid = $XDeode->decode ( $itidKey );
  2948. if (! is_numeric ( $rid ) || ! is_numeric ( $itid ))
  2949. die ( 'illegal request-idError' );
  2950. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2951. $invoiceTrainDetail = $invoiceTraining->getInvoiceTrainingByItid ( $itid );
  2952. // 不合法的数据
  2953. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2954. die ( 'illegal request-receiptError' );
  2955. }
  2956. if (empty ( $invoiceTrainDetail ) || $invoiceTrainDetail ['bindReceipt'] == 1) {
  2957. die ( 'illegal request-receipLoantError' );
  2958. }
  2959. // 培训班结算挂钩借款
  2960. $receipt = new receipt ();
  2961. $item = array (
  2962. 'rid' => $rid,
  2963. 'invoiceTrainId' => $itid
  2964. );
  2965. $receipt->setReceiptByCondition ( $item );
  2966. $invoiceTraining = new invoiceTraining ();
  2967. $item = array (
  2968. 'bindReceipt' => 1,
  2969. 'itid' => $itid
  2970. );
  2971. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  2972. $XDeode = new XDeode ( 7 );
  2973. return "/receiptTrainInvoiceEdi/" . $XDeode->encode ( $rid ) . ".html";
  2974. } else
  2975. die ( 'illegal request' );
  2976. }
  2977. /**
  2978. * 更新培训班结算 收款和取消收款
  2979. */
  2980. function receiptTrainReceivables() {
  2981. $doType = isset ( $this->params ['doType'] ) ? $this->params ['doType'] : '';
  2982. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2983. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  2984. Doo::loadClass ( 'XDeode' );
  2985. $XDeode = new XDeode ( 5 );
  2986. $rid = $XDeode->decode ( $ridKey );
  2987. $iid = $XDeode->decode ( $iidKey );
  2988. if (! is_numeric ( $rid ) || ! is_numeric ( $iid ))
  2989. die ( 'illegal request-iid' );
  2990. Doo::loadModel ( 'RIExtend' );
  2991. $RIExtend = new RIExtend ();
  2992. if ($doType == 'CONFIRM') {
  2993. $RIExtend->rid = $rid;
  2994. $RIExtend->iid = $iid;
  2995. $RIExtend->RIstatus = 1;
  2996. $RIExtend->insert ();
  2997. echo json_encode ( array (
  2998. 'status' => 1,
  2999. ) );
  3000. die ( );
  3001. } elseif ($doType == 'CANCEL') {
  3002. $RIExtend->delete ( array (
  3003. 'where' => 'rid=' . $rid . ' and iid=' . $iid,
  3004. 'limit' => 1
  3005. ) );
  3006. echo json_encode ( array (
  3007. 'status' => 1,
  3008. ) );
  3009. die ( );
  3010. } else {
  3011. echo json_encode ( array (
  3012. 'status' => 2,
  3013. ) );
  3014. die ( );
  3015. }
  3016. }
  3017. /**
  3018. * 移除挂钩的培训班发票
  3019. */
  3020. function receiptTrainReceivablesDelDo() {
  3021. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  3022. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : ""; // 发票培训班
  3023. Doo::loadModel ( 'receipt' );
  3024. $receipt = new receipt ();
  3025. Doo::loadModel ( 'RIExtend' );
  3026. $RIExtend = new RIExtend ();
  3027. Doo::loadClass ( 'XDeode' );
  3028. $XDeode = new XDeode ( 5 );
  3029. $rid = $XDeode->decode ( $ridKey );
  3030. $itid = $XDeode->decode ( $itidKey );
  3031. if (is_numeric ( $rid ) && is_numeric ( $itid )) {
  3032. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3033. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  3034. die ( 'illegal request-status' );
  3035. }
  3036. $receipt = new receipt ();
  3037. $receipt->rid = $rid;
  3038. $receipt->invoiceTrainId = 0;
  3039. $receipt->update ();
  3040. Doo::loadModel ( 'invoiceTraining' );
  3041. $invoiceTraining = new invoiceTraining ();
  3042. $item = array (
  3043. 'bindReceipt' => 0,
  3044. 'itid' => $itid
  3045. );
  3046. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  3047. $RIExtend->delete ( array (
  3048. 'where' => 'rid=' . $rid
  3049. ) );
  3050. $XDeode = new XDeode ( 7 );
  3051. return '/receiptTrainInvoiceEdi/' . $XDeode->encode ( $rid ) . '.html';
  3052. } else
  3053. die ( 'illegal request-iid' );
  3054. }
  3055. /**
  3056. * 编辑培训班结算
  3057. */
  3058. function receiptTrainItemEdi() {
  3059. //include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  3060. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3061. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : '';
  3062. Doo::loadClass ( 'XDeode' );
  3063. $XDeode = new XDeode ( 7 );
  3064. $rid = $XDeode->decode ( $ridKey );
  3065. if (! is_numeric ( $rid ))
  3066. die ( 'illegal request' );
  3067. Doo::loadModel ( 'receipt' );
  3068. $receipt = new receipt ();
  3069. Doo::loadModel ( 'receiptTraining' );
  3070. $receiptTraining = new receiptTraining ();
  3071. Doo::loadModel ( 'RItem' );
  3072. $RItem = new RItem ();
  3073. Doo::loadModel ( 'accountItem' );
  3074. $accountItem = new accountItem ();
  3075. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3076. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3077. die ();
  3078. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3079. $RItemList = $RItem->getRItemByRid ( $rid,$name );
  3080. $aiList = $accountItem->getAccountBookByCategory ( '培训班费用' );//print_r($aiList);
  3081. // foreach ($aiList as $key=>$value){//不需要添加税款,在添加收入时自动添加
  3082. // if($value['name']=='税款'){
  3083. // unset($aiList[$key]);break;
  3084. // }
  3085. // }
  3086. //print_r($RItemList);
  3087. $data ['name'] = $name;
  3088. $data ['RItemList'] = $RItemList;
  3089. $data ['aiList'] = $aiList;
  3090. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3091. $data ['receiptDetail'] = $receiptDetail;
  3092. $data ['trainEdiType'] = "ITEM";
  3093. $data ['ridKey'] = $ridKey;
  3094. $data ['memu'] = "receipt";
  3095. $data ['staff'] = $this->staff;
  3096. $data ['receiptMemu'] = 'saeaBorad';
  3097. $data ['verifyId'] = $this->verifyId;
  3098. $data ['executeId'] = $this->executeId;
  3099. $this->render ( "/receipt/receiptTrainItemEdi", $data );
  3100. }
  3101. /**
  3102. * 添加支出项 需要修改 费用金额合计
  3103. */
  3104. function receiptTrainItemAddDo() {
  3105. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3106. $rtidKey = $this->get_args ( 'rtidKey' ) ? $this->get_args ( 'rtidKey' ) : "";
  3107. // 支出项信息
  3108. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  3109. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : 0;
  3110. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  3111. $inputer = $this->get_args ( 'inputer' ) ? $this->get_args ( 'inputer' ) : "";
  3112. $describe = $this->get_args ( 'describe' ) ? $this->get_args ( 'describe' ) : "";
  3113. //$identifyingTotal = $this->get_args ( 'identifyingTotal' )&&is_numeric($this->get_args ( 'identifyingTotal' )) ? $this->get_args ( 'identifyingTotal' ) : 0;
  3114. $payType = isset ( $this->params ['payType'] ) ? $this->params ['payType'] : '';
  3115. if (! empty ( $ridKey ) && ! empty ( $item ) && is_numeric( $price ) && ! empty ( $date ) && ! empty ( $inputer )) {
  3116. Doo::loadClass ( 'XDeode' );
  3117. $XDeode = new XDeode ( 5 );
  3118. Doo::loadModel ( 'RItem' );
  3119. $RItem = new RItem ();
  3120. $rid = $XDeode->decode ( $ridKey );
  3121. $rtid= $XDeode->decode ( $rtidKey );
  3122. if (! is_numeric ( $rid )){
  3123. die ( 'illegal request' );
  3124. }
  3125. Doo::loadModel ( 'receiptDetail' );
  3126. $receiptDetail = new receiptDetail ();
  3127. Doo::loadModel ( 'receipt' );
  3128. $receipt = new receipt ();
  3129. Doo::loadModel ( 'receiptTraining' );
  3130. $receiptTraining = new receiptTraining ();
  3131. $rtDetail=$receiptTraining->getReceiptTrainingByRtid($rtid);
  3132. $identifyingTotal=$rtDetail['identifyingTotal']+1;
  3133. $order = array (
  3134. "\r\n",
  3135. "\n",
  3136. "\r"
  3137. );
  3138. $replace = '<br/>';
  3139. $describe = str_replace ( $order, $replace, $describe );
  3140. $itemData = array (
  3141. 'rid' => $rid,
  3142. 'item' => $item,
  3143. 'price' => $price,
  3144. 'date' => $date,
  3145. 'inputer' => $inputer,
  3146. 'describe' => $describe,
  3147. 'creater' => $this->staff['0']['username'],
  3148. 'createrId' => $this->staff['0']['sid'],
  3149. 'creatDate' => date ( "Y-m-d H:i:s" ),
  3150. 'identifying'=>$identifyingTotal
  3151. );
  3152. if($payType=='company'){
  3153. $itemData += array (
  3154. 'payType' => 1
  3155. );
  3156. }
  3157. $RItem->addRItem($itemData, $receipt, $receiptDetail, $rid, $item, $price, $payType);
  3158. //更新支出项标识总数
  3159. $itemData = array (
  3160. 'rtid'=>$rtid,
  3161. 'identifyingTotal'=>$identifyingTotal
  3162. );
  3163. $receiptTraining->setReceiptTrainByCondition($itemData);
  3164. $XDeode = new XDeode ( 7 );
  3165. if($payType=='company'){
  3166. return '/receiptTrainItem/approval/' . $XDeode->encode ( $rid ) . '.html';
  3167. }else{
  3168. return '/receiptTrainItemEdi/' . $XDeode->encode ( $rid ) . '.html';
  3169. }
  3170. } else
  3171. die ( 'illegal request-dataError' );
  3172. }
  3173. /**
  3174. * 培训班结算-讲师
  3175. */
  3176. function receiptTrainLecturerEdi() {
  3177. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3178. Doo::loadClass ( 'XDeode' );
  3179. $XDeode = new XDeode ( 7 );
  3180. $rid = $XDeode->decode ( $ridKey );
  3181. if (! is_numeric ( $rid ))
  3182. die ( 'illegal request' );
  3183. Doo::loadModel ( 'receipt' );
  3184. $receipt = new receipt ();
  3185. Doo::loadModel ( 'receiptTraining' );
  3186. $receiptTraining = new receiptTraining ();
  3187. Doo::loadModel ( 'RILecturer' );
  3188. $RILecturer = new RILecturer ();
  3189. Doo::loadModel ( 'lecturer' );
  3190. $lecturer = new lecturer ();
  3191. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3192. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3193. die ();
  3194. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3195. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  3196. $lecturerList = $lecturer->getLecturerAll ();
  3197. $INSIDEhtml = $OUTSIDEhtml = '';
  3198. foreach ( $lecturerList as $key => $value ) {
  3199. if ($value ['ltype'] == 'INSIDE') {
  3200. $INSIDEhtml .= '<option value="' . $value ['category'] . '-' . $value ['staff'] . '">' . $value ['category'] . '-' . $value ['staff'] . '</option>';
  3201. } elseif ($value ['ltype'] == 'OUTSIDE') {
  3202. $OUTSIDEhtml .= '<option value="' . $value ['staff'] . '">' . $value ['staff'] . '</option>';
  3203. }
  3204. }
  3205. $data ['INSIDEhtml'] = $INSIDEhtml;
  3206. $data ['OUTSIDEhtml'] = $OUTSIDEhtml;
  3207. // print_r($RItemList);
  3208. $data ['RILecturerList'] = $RILecturerList;
  3209. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3210. $data ['receiptDetail'] = $receiptDetail;
  3211. $data ['trainEdiType'] = "LECTURER";
  3212. $data ['ridKey'] = $ridKey;
  3213. $data ['memu'] = "receipt";
  3214. $data ['staff'] = $this->staff;
  3215. $data ['receiptMemu'] = 'saeaBorad';
  3216. $data ['verifyId'] = $this->verifyId;
  3217. $data ['executeId'] = $this->executeId;
  3218. $this->render ( "/receipt/receiptTrainLecturerEdi", $data );
  3219. }
  3220. /**
  3221. * 添加讲师
  3222. */
  3223. function receiptTrainLecturerAddDo() {
  3224. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3225. // 支出项信息
  3226. $ltype = $this->get_args ( 'ltype' ) ? $this->get_args ( 'ltype' ) : "";
  3227. $lecturerName = $this->get_args ( 'lecturerName' ) ? $this->get_args ( 'lecturerName' ) : "";
  3228. $schoolDay = $this->get_args ( 'schoolDay' ) ? $this->get_args ( 'schoolDay' ) : "";
  3229. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  3230. $taxation = $this->get_args ( 'taxation' ) ? $this->get_args ( 'taxation' ) : "";
  3231. $fees = $this->get_args ( 'fees' ) ? $this->get_args ( 'fees' ) : "";
  3232. if (! empty ( $ridKey ) && ! empty ( $ltype ) && ! empty ( $lecturerName ) && ! empty ( $schoolDay ) && ! empty ( $price )) {
  3233. Doo::loadClass ( 'XDeode' );
  3234. $XDeode = new XDeode ( 5 );
  3235. Doo::loadModel ( 'RILecturer' );
  3236. $RILecturer = new RILecturer ();
  3237. $rid = $XDeode->decode ( $ridKey );
  3238. if (! is_numeric ( $rid ))
  3239. die ( 'illegal request' );
  3240. if ($ltype == 'OUTSIDE' && empty ( $taxation ))
  3241. die ( 'illegal request-taxationError' );
  3242. $RILecturer->rid = $rid;
  3243. $RILecturer->ltype = $ltype;
  3244. if ($ltype == 'OUTSIDE') {
  3245. if ($taxation == 'TAXATION') {
  3246. $RILecturer->taxation = 1;
  3247. } elseif ($taxation == 'NOTAXATION') {
  3248. $RILecturer->taxation = 0;
  3249. }
  3250. }
  3251. $RILecturer->lecturerName = $lecturerName;
  3252. $RILecturer->schoolDay = $schoolDay;
  3253. $RILecturer->price = $price;
  3254. $RILecturer->fees=$fees;
  3255. $RILecturer->insert ();
  3256. // 添加公司汇总
  3257. // 报销详情
  3258. Doo::loadModel ( 'receiptDetail' );
  3259. $receiptDetail = new receiptDetail ();
  3260. Doo::loadModel ( 'receipt' );
  3261. $receipt = new receipt ();
  3262. // 金额总计
  3263. $price = $price * $schoolDay;
  3264. $rInfo = $receipt->getReceiptByRid ( $rid );
  3265. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  3266. if (empty ( $rdInfo )) {
  3267. $receiptDetail = new receiptDetail ();
  3268. $receiptDetail->staff = $rInfo ['staff'];
  3269. $receiptDetail->item = '讲课费';
  3270. $receiptDetail->itemCategory = '培训班费用';
  3271. $receiptDetail->price = number_format ( $fees, 2, '.', '' );
  3272. $receiptDetail->date = date ( "Y-m-d" );
  3273. $receiptDetail->cid = $rInfo ['cid'];
  3274. $receiptDetail->rid = $rid;
  3275. $receiptDetail->status = 4;
  3276. $receiptDetail->insert ();
  3277. } else {
  3278. $receiptDetail = new receiptDetail ();
  3279. $rdInfo ['price'] += $fees;
  3280. $receiptDetail->price = $rdInfo ['price'];
  3281. $receiptDetail->update ( array (
  3282. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  3283. ) );
  3284. }
  3285. $receipt = new receipt ();
  3286. $receipt->sum=$rInfo['sum']+$fees;
  3287. $receipt->update ( array (
  3288. 'where' => 'rid=' . $rid
  3289. ) );
  3290. $XDeode = new XDeode ( 7 );
  3291. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  3292. } else
  3293. die ( 'illegal request' );
  3294. }
  3295. /**
  3296. * 移除讲师
  3297. */
  3298. function receiptTrainLecturerDelDo() {
  3299. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  3300. $rlidKey = $this->get_args ( 'rlidKey' ) ? $this->get_args ( 'rlidKey' ) : ""; // 发票培训班
  3301. Doo::loadModel ( 'receipt' );
  3302. $receipt = new receipt ();
  3303. Doo::loadModel ( 'RILecturer' );
  3304. $RILecturer = new RILecturer ();
  3305. Doo::loadClass ( 'XDeode' );
  3306. $XDeode = new XDeode ( 5 );
  3307. $rid = $XDeode->decode ( $ridKey );
  3308. $rlid = $XDeode->decode ( $rlidKey );
  3309. if (is_numeric ( $rid ) && is_numeric ( $rlid )) {
  3310. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3311. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  3312. die ( 'illegal request-status' );
  3313. }
  3314. $detail=$RILecturer->getRILecturerByRlid($rlid);
  3315. if (empty($detail)){
  3316. die ( 'illegal request-data' );
  3317. }
  3318. $RILecturer->delete ( array (
  3319. 'where' => 'rid=' . $rid . ' and rlid=' . $rlid
  3320. ) );
  3321. //更新费用合计金额
  3322. $rInfo = $receipt->getReceiptByRid ( $rid );
  3323. $receipt = new receipt ();
  3324. $receipt->sum= $receiptDetail['sum']-$detail['price'];
  3325. $receipt->update ( array (
  3326. 'where' => 'rid=' . $rid
  3327. ) );
  3328. Doo::loadModel ( 'receiptDetail' );
  3329. $receiptDetail = new receiptDetail ();
  3330. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  3331. $receiptDetail = new receiptDetail ();
  3332. $rdInfo ['price'] -= number_format ( $detail['price'], 2, '.', '' );
  3333. $receiptDetail->price = $rdInfo ['price'];
  3334. $receiptDetail->update ( array (
  3335. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  3336. ) );
  3337. $XDeode = new XDeode ( 7 );
  3338. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  3339. } else
  3340. die ( 'illegal request-iid' );
  3341. }
  3342. /**
  3343. * 培训班提交审批
  3344. */
  3345. function receiptTrainDo() {
  3346. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3347. Doo::loadClass ( 'XDeode' );
  3348. $XDeode = new XDeode ( 7 );
  3349. $rid = $XDeode->decode ( $ridKey );
  3350. Doo::loadModel ( 'receipt' );
  3351. $receipt = new receipt ();
  3352. Doo::loadModel ( 'receiptDetail' );
  3353. $receiptDetail = new receiptDetail ();
  3354. Doo::loadModel ( 'statistics' );
  3355. $statistics = new statistics ();
  3356. Doo::loadModel ( "verify" );
  3357. $verify = new verify ();
  3358. // 审批状态的判定
  3359. $receiptDetailList = $receipt->getOne ( array (
  3360. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  3361. 'asArray' => true
  3362. ) );
  3363. if (empty ( $receiptDetailList ))
  3364. return "/saeaBorad";
  3365. $verifyDetail = $verify->getOne ( array (
  3366. 'where' => ' vid =' . $receiptDetailList ['verify'],
  3367. 'asArray' => true
  3368. ) );
  3369. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3370. if (empty ( $receiptDetailList ['nowStaff'] )) {
  3371. $nowStaff = "";
  3372. $nowStaffList = array ();
  3373. if ($verifyDetail [0] [1] == 'ROLE') {
  3374. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3375. foreach ( $vStaffString as $key => $value ) {
  3376. $staffK = explode ( "_", $value );
  3377. array_push ( $nowStaffList, $staffK [0] );
  3378. }
  3379. $nowStaff = implode ( ',', $nowStaffList );
  3380. } else {
  3381. $nowStaff = $verifyDetail [0] [0];
  3382. }
  3383. $receipt->nowStaff = $nowStaff;
  3384. }
  3385. // echo $nowStaff;
  3386. // print_r($verifyDetail);die;
  3387. $receipt->rid = $receiptDetailList ['rid'];
  3388. $receipt->date = date ( "Y-m-d" );
  3389. $receipt->status = 2;
  3390. $receipt->update ();
  3391. $receiptDetail->status = 2;
  3392. $receiptDetail->update ( array (
  3393. 'where' => 'rid=' . $receiptDetailList ['rid']
  3394. ) );
  3395. Doo::loadModel ( "receiptLog" );
  3396. $receiptLog = new receiptLog ();
  3397. Doo::loadModel ( "verify" );
  3398. $verify = new verify ();
  3399. $vr = $verify->getOne ( array (
  3400. 'where' => 'vid=' . $receiptDetailList ['verify'],
  3401. 'asArray' => true
  3402. ) );
  3403. $jd = json_decode ( $vr ['staff'] );
  3404. $roleId = 0;
  3405. foreach ( $jd as $key => $value ) {
  3406. if ($value [1] == 'ROLE') {
  3407. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  3408. if ($pos !== false) {
  3409. $roleId = $value [0];
  3410. }
  3411. }
  3412. }
  3413. // 审批日志
  3414. // echo $roleId;die;
  3415. if (! empty ( $roleId )) {
  3416. Doo::loadModel ( "role" );
  3417. $role = new role ();
  3418. $roleInfo = $role->getOne ( array (
  3419. 'where' => 'rid=' . $roleId,
  3420. 'asArray' => true
  3421. ) );
  3422. // $receiptLog->rolename = $roleInfo ['name'];
  3423. }
  3424. $receiptLog->username = $this->staff [0] ['username'];
  3425. $receiptLog->uid = $this->staff [0] ['sid'];
  3426. $receiptLog->date = date ( "Y-m-d" );
  3427. $receiptLog->opinion = '提交审批';
  3428. $receiptLog->img = $this->staff [0] ['avatar'];
  3429. $receiptLog->status = 2;
  3430. $receiptLog->rid = $rid;
  3431. $receiptLog->insert ();
  3432. // 写入列表项
  3433. Doo::loadModel ( 'accountItem' );
  3434. $accountItem = new accountItem ();
  3435. $aItem = $accountItem->getAccountBookByCategory ( '培训班费用' );
  3436. // 项目金额合计
  3437. Doo::loadModel ( 'RItem' );
  3438. $RItem = new RItem ();
  3439. // 讲师获得
  3440. Doo::loadModel ( 'RILecturer' );
  3441. $RILecturer = new RILecturer ();
  3442. $RItemList = $RItem->getRItemByRid ( $rid );
  3443. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  3444. // 支出项金额详情
  3445. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, 0 );
  3446. // print_r($aItem);
  3447. // print_r($aiData);
  3448. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  3449. $ag = $tr = $ta = $ot = 0;
  3450. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  3451. foreach ( $aItem as $key => $value ) {
  3452. if ($value ['category'] == $this->TRAIN) {
  3453. foreach ( $aiData ['dataList'] as $k => $v ) {
  3454. if ($value ['name'] == $v ['name']) {
  3455. array_push ( $accountJson [$this->TRAIN], array (
  3456. 'aid' => $value ['aid'],
  3457. 'name' => $value ['name'],
  3458. 'price' => number_format ( $v ['price'], 2, '.', '' )
  3459. ) );
  3460. $sum += $v ['price'];
  3461. $trainSum += $v ['price'];
  3462. unset ( $aiData ['dataList'] [$k] );
  3463. break;
  3464. }
  3465. }
  3466. }
  3467. }
  3468. $accountJson ['cSum'] = array (
  3469. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  3470. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  3471. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  3472. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  3473. );
  3474. // 报销单
  3475. $receipt = new receipt ();
  3476. $receipt->accountItem = json_encode ( $accountJson );
  3477. $receipt->sum = number_format ( $sum, 2, '.', '' );
  3478. $receipt->update ( array (
  3479. 'where' => 'rid=' . $rid
  3480. ) );
  3481. // print_r($accountJson);
  3482. // statistics item 统计写入
  3483. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  3484. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  3485. $accountItem = $accountJson;
  3486. $stat = $statistics->getOne ( array (
  3487. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  3488. 'asArray' => true
  3489. ) );
  3490. if (empty ( $stat )) {
  3491. $statistics->date = date ( "Y-m-d" );
  3492. $statistics->cid = $this->staff [0] ['cid'];
  3493. $statistics->staff = $this->staff [0] ['sid'];
  3494. $statistics->agPrice = 0;
  3495. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  3496. $statistics->insert ();
  3497. } else {
  3498. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  3499. $statistics->update ( array (
  3500. 'where' => 'sid=' . $stat ['sid']
  3501. ) );
  3502. }
  3503. return "/saeaBorad";
  3504. }
  3505. function confirmation() {
  3506. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3507. Doo::loadModel ( 'receipt' );
  3508. Doo::loadModel ( 'receiptDetail' );
  3509. $receipt = new receipt ();
  3510. $receiptDetail = new receiptDetail ();
  3511. Doo::loadModel ( 'statistics' );
  3512. Doo::loadModel ( 'itemStatistics' );
  3513. $statistics = new statistics ();
  3514. $itemStatistics = new itemStatistics ();
  3515. Doo::loadModel ( "verify" );
  3516. $verify = new verify ();
  3517. $receiptDetailList = $receipt->getOne ( array (
  3518. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  3519. 'asArray' => true
  3520. ) );
  3521. if (empty ( $receiptDetailList ))
  3522. return "/saeaBorad";
  3523. $verifyDetail = $verify->getOne ( array (
  3524. 'where' => ' vid =' . $receiptDetailList ['verify'],
  3525. 'asArray' => true
  3526. ) );
  3527. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3528. if (empty ( $receiptDetailList ['nowStaff'] )) {
  3529. $nowStaff = "";
  3530. $nowStaffList = array ();
  3531. if ($verifyDetail [0] [1] == 'ROLE') {
  3532. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3533. foreach ( $vStaffString as $key => $value ) {
  3534. $staffK = explode ( "_", $value );
  3535. array_push ( $nowStaffList, $staffK [0] );
  3536. }
  3537. $nowStaff = implode ( ',', $nowStaffList );
  3538. } else {
  3539. $nowStaff = $verifyDetail [0] [0];
  3540. }
  3541. $receipt->nowStaff = $nowStaff;
  3542. }
  3543. // echo $nowStaff;
  3544. // print_r($verifyDetail);die;
  3545. $receipt->rid = $receiptDetailList ['rid'];
  3546. $receipt->status = 2;
  3547. $receipt->update ();
  3548. // 操作日志
  3549. Doo::loadModel ( "receiptLog" );
  3550. $receiptLog = new receiptLog ();
  3551. $verify = new verify ();
  3552. $receiptInfo = $receipt->getOne ( array (
  3553. 'where' => 'rid=' . $rid,
  3554. 'asArray' => true
  3555. ) );
  3556. $vr = $verify->getOne ( array (
  3557. 'where' => 'vid=' . $receiptInfo ['verify'],
  3558. 'asArray' => true
  3559. ) );
  3560. $jd = json_decode ( $vr ['staff'] );
  3561. $roleId = 0;
  3562. foreach ( $jd as $key => $value ) {
  3563. if ($value [1] == 'ROLE') {
  3564. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  3565. if ($pos !== false) {
  3566. $roleId = $value [0];
  3567. }
  3568. }
  3569. }
  3570. // 审批日志
  3571. // echo $roleId;die;
  3572. if (! empty ( $roleId )) {
  3573. Doo::loadModel ( "role" );
  3574. $role = new role ();
  3575. $roleInfo = $role->getOne ( array (
  3576. 'where' => 'rid=' . $roleId,
  3577. 'asArray' => true
  3578. ) );
  3579. // $receiptLog->rolename = $roleInfo ['name'];
  3580. }
  3581. $receiptLog->username = $this->staff [0] ['username'];
  3582. $receiptLog->uid = $this->staff [0] ['sid'];
  3583. $receiptLog->date = date ( "Y-m-d" );
  3584. $receiptLog->opinion = '提交审批';
  3585. $receiptLog->img = $this->staff [0] ['avatar'];
  3586. $receiptLog->status = 2;
  3587. $receiptLog->rid = $rid;
  3588. $receiptLog->insert ();
  3589. return "/expenses";
  3590. }
  3591. function expenses() {
  3592. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  3593. if (empty ( $item ))
  3594. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  3595. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  3596. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  3597. Doo::loadClass ( 'XDeode' );
  3598. $XDeode = new XDeode ( 7 );
  3599. Doo::loadModel ( 'receipt' );
  3600. $receipt = new receipt ();
  3601. Doo::loadModel ( 'L_category' );
  3602. $Lcategory = new L_category ();
  3603. Doo::loadModel ( 'verify' );
  3604. Doo::loadModel ( 'statistics' );
  3605. $statistics = new statistics ();
  3606. $verify = new verify ();
  3607. Doo::loadModel ( 'staff' );
  3608. $staff = new staff ();
  3609. $condition = "";
  3610. if ($item == "expenses")
  3611. $condition = " and Rtype=1 ";
  3612. elseif ($item == "receipts")
  3613. $condition = " and Rtype=0 ";
  3614. elseif ($item == "remits")
  3615. $condition = " and Rtype=2 ";
  3616. elseif ($item == "train")
  3617. $condition = " and Rtype=3 ";
  3618. $dateCondition = " and Year(date) =" . $year;
  3619. if (! empty ( $moth )) {
  3620. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  3621. $stList = $statistics->getOne ( array (
  3622. 'select' => 'rePrice ,agPrice',
  3623. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  3624. 'asArray' => true
  3625. ) );
  3626. } else
  3627. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  3628. if (empty ( $stList ))
  3629. $stList = array (
  3630. 'rePrice' => 0,
  3631. 'agPrice' => 0
  3632. );
  3633. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  3634. if (! isset ( $noPassSum ['sum'] ))
  3635. $noPassSum ['sum'] = 0;
  3636. $data ['stList'] = array (
  3637. 'rePrice' => $stList ['rePrice'],
  3638. 'agPrice' => $stList ['agPrice'],
  3639. 'skPrice' => ($noPassSum ['sum'])
  3640. );
  3641. $receiptList = $receipt->find ( array (
  3642. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  3643. 'desc' => 'rid',
  3644. 'asArray' => true
  3645. ) );
  3646. $Locate = 0;
  3647. $roleId = 0;
  3648. $button = 0;
  3649. foreach ( $receiptList as $key => $value ) {
  3650. $receiptList[$key]['balance']='';
  3651. if($value['Rtype']==1){
  3652. $receiptList[$key]['balance']=$value['sum']-=$value['loanSum'];
  3653. $receiptList[$key]['balanceABS']=abs($receiptList[$key]['balance']);
  3654. }elseif($value['Rtype']==3){
  3655. $payment=$this->_getReceiptTrainPayment($value['invoiceTrainId'],$value['trainLoanRid'],$value['rid']);
  3656. $receiptList[$key]['payment']=$payment;
  3657. $receiptList[$key]['paymentABS']=abs($payment);
  3658. }
  3659. $receiptList [$key] ['Locate'] = $Locate;
  3660. $Locate ++;
  3661. $receiptList [$key] ['reviseDetail'] = array ();
  3662. if (! empty ( $value ['reviseDetail'] ))
  3663. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3664. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3665. $categoryDetil = $Lcategory->getOne ( array (
  3666. 'where' => 'cid=' . $value ['cid'],
  3667. 'asArray' => true
  3668. ) );
  3669. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3670. // 检测编辑状态
  3671. $verifyList = $verify->getOne ( array (
  3672. 'where' => 'vid=' . $value ['verify'],
  3673. 'asArray' => true
  3674. ) );
  3675. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3676. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3677. Doo::loadModel ( 'role' );
  3678. $role = new role ();
  3679. $flag = true;
  3680. $roleKey = 0;
  3681. $endStaffArray = array ();
  3682. $roleArrayCopy = array ();
  3683. foreach ( $verifyList as $k => $v ) {
  3684. // init verifyStaff
  3685. if ($v [1] == 'ROLE') {
  3686. if (! empty ( $verifyStaff )) {
  3687. $endStaffArray = end ( $verifyStaff );
  3688. // if ($v[0]==$endStaffArray['nextStaff']){
  3689. // $roleId=$v[0];
  3690. // }
  3691. }
  3692. $roleVerify = json_decode ( $v [3], true );
  3693. $roleKey = $k;
  3694. $roleArray = array ();
  3695. $rolename = $role->getOne ( array (
  3696. 'where' => 'rid=' . $v [0],
  3697. 'asArray' => true
  3698. ) );
  3699. foreach ( $roleVerify as $o => $p ) {
  3700. $staffID = explode ( '_', $p );
  3701. $staffInfo = $staff->getOne ( array (
  3702. 'where' => 'sid=' . $staffID [0],
  3703. 'asArray' => true
  3704. ) );
  3705. // print_r($staffID);
  3706. $exp = array (
  3707. 0 => $staffInfo ['sid'],
  3708. 1 => $staffID [1],
  3709. 2 => $staffInfo ['avatar'],
  3710. 'date' => '',
  3711. 'date' => '',
  3712. 'opinion' => '',
  3713. 'status' => '',
  3714. 'rolename' => $rolename ['name']
  3715. );
  3716. array_push ( $roleArray, $exp );
  3717. }
  3718. $roleArrayCopy [$v [0]] = $roleArray;
  3719. // $verifyList[$k]['roleArray']=$roleArray;
  3720. }
  3721. $verifyList [$k] ['date'] = "";
  3722. $verifyList [$k] ['opinion'] = "";
  3723. $verifyList [$k] ['status'] = "";
  3724. if (empty ( $verifyStaff )) {
  3725. $verifyList [$k] ['date'] = "";
  3726. $verifyList [$k] ['opinion'] = "";
  3727. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3728. $verifyList [$k] ['status'] = 4;
  3729. $flag = false;
  3730. }
  3731. } else {
  3732. foreach ( $verifyStaff as $m => $u ) {
  3733. if ($v [0] == $m) {
  3734. $verifyList [$k] ['date'] = $u ['date'];
  3735. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3736. $verifyList [$k] ['status'] = $u ['status'];
  3737. $flag = false;
  3738. break;
  3739. }
  3740. }
  3741. $endStaffArray = end ( $verifyStaff );
  3742. if (isset ( $endStaffArray ['ROLE'] )) {
  3743. } else {
  3744. // $endKey=key($verifyStaff);
  3745. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3746. // $button=4;
  3747. // $verifyList[$k]['status']=4;
  3748. // }
  3749. }
  3750. }
  3751. }
  3752. $rolename ['name'] = '';
  3753. if (! empty ( $roleId )) {
  3754. Doo::loadModel ( 'role' );
  3755. $role = new role ();
  3756. $rolename = $role->getOne ( array (
  3757. 'where' => 'rid=' . $roleId,
  3758. 'asArray' => true
  3759. ) );
  3760. }
  3761. if (! empty ( $verifyStaff ))
  3762. $endStaffArray = end ( $verifyStaff );
  3763. $KOP = false;
  3764. foreach ( $roleArrayCopy as $P => $A ) {
  3765. foreach ( $A as $MKI => $AVL ) {
  3766. if (! empty ( $verifyStaff )) {
  3767. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3768. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3769. $button = 4;
  3770. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3771. }
  3772. foreach ( $verifyStaff as $m => $u ) {
  3773. $AVLFK = $AVL [0] . '_R';
  3774. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3775. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3776. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3777. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3778. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3779. break;
  3780. }
  3781. }
  3782. } else {
  3783. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3784. $button = 4;
  3785. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3786. }
  3787. }
  3788. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3789. $KOP = true;
  3790. }
  3791. }
  3792. foreach ( $roleArrayCopy as $k => $v ) {
  3793. foreach ( $verifyList as $m => $n ) {
  3794. if ($n [0] == $k) {
  3795. array_splice ( $verifyList, $m, 1, $v );
  3796. }
  3797. }
  3798. }
  3799. $receiptList [$key] ['verifyList'] = $verifyList;
  3800. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3801. 'where' => 'sid=' . $value ['staff'],
  3802. 'asArray' => true
  3803. ) );
  3804. $receiptList [$key] ['button'] = $button;
  3805. $receiptList [$key] ['ridKey'] =$XDeode->encode( $value ['rid'] );
  3806. }
  3807. // print_r($receiptList);die;
  3808. $mothHtml = "";
  3809. for($i = 1; $i <= 12; $i ++) {
  3810. if ($moth == $i)
  3811. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3812. else
  3813. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3814. }
  3815. $dateHtml = "";
  3816. $now = date ( "Y" );
  3817. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  3818. if ($YEARD <= $now) {
  3819. $dateHtml .= '<option ';
  3820. if ($year == $YEARD) {
  3821. $dateHtml .= 'selected ';
  3822. }
  3823. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  3824. }
  3825. }
  3826. $data ['dateHtml'] = $dateHtml;
  3827. $data ['mothHtml'] = $mothHtml;
  3828. $data ['receiptList'] = $receiptList;
  3829. $data ['memu'] = "receipt";
  3830. $data ['staff'] = $this->staff;
  3831. $data ['receiptMemu'] = 'expenses';
  3832. $data ['verifyId'] = $this->verifyId;
  3833. $data ['executeId'] = $this->executeId;
  3834. $data ['item'] = $item;
  3835. $data ['year'] = $year;
  3836. $this->render ( "/admin/expenses", $data );
  3837. }
  3838. function expensesCollect() {
  3839. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3840. Doo::loadModel ( 'receipt' );
  3841. $receipt = new receipt ();
  3842. Doo::loadModel ( 'L_category' );
  3843. $Lcategory = new L_category ();
  3844. Doo::loadModel ( 'verify' );
  3845. Doo::loadModel ( 'statistics' );
  3846. $statistics = new statistics ();
  3847. $verify = new verify ();
  3848. Doo::loadModel ( 'staff' );
  3849. $staff = new staff ();
  3850. Doo::loadModel ( 'loanReceipt' );
  3851. $loanReceipt = new loanReceipt ();
  3852. $receiptList = $receipt->find ( array (//去掉
  3853. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  3854. 'desc' => 'rid',
  3855. 'asArray' => true
  3856. ) );
  3857. $loanList = $loanReceipt->find ( array (
  3858. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3859. 'desc' => 'rid',
  3860. 'asArray' => true
  3861. ) );
  3862. /*
  3863. * $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;
  3864. */
  3865. $data ['explanation'] = '';
  3866. if (! empty ( $loanList ))
  3867. $data ['explanation'] = $loanList [0] ['explanation'];
  3868. $Locate = 0;
  3869. $roleId = 0;
  3870. $button = 0;
  3871. foreach ( $receiptList as $key => $value ) {
  3872. $receiptList [$key] ['Locate'] = $Locate;
  3873. $Locate ++;
  3874. $receiptList [$key] ['reviseDetail'] = array ();
  3875. if (! empty ( $value ['reviseDetail'] ))
  3876. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3877. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3878. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3879. $categoryDetil = $Lcategory->getOne ( array (
  3880. 'where' => 'cid=' . $value ['cid'],
  3881. 'asArray' => true
  3882. ) );
  3883. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3884. // 检测编辑状态
  3885. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  3886. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  3887. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  3888. else
  3889. $verifyList ['staff'] = $value ['verifyBreakup'];
  3890. } else
  3891. $verifyList = $verify->getOne ( array (
  3892. 'where' => 'vid=' . $value ['verify'],
  3893. 'asArray' => true
  3894. ) );
  3895. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3896. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3897. Doo::loadModel ( 'role' );
  3898. $role = new role ();
  3899. $flag = true;
  3900. $roleKey = 0;
  3901. $endStaffArray = array ();
  3902. $roleArrayCopy = array ();
  3903. foreach ( $verifyList as $k => $v ) {
  3904. // init verifyStaff
  3905. if ($v [1] == 'ROLE') {
  3906. if (! empty ( $verifyStaff )) {
  3907. $endStaffArray = end ( $verifyStaff );
  3908. // if ($v[0]==$endStaffArray['nextStaff']){
  3909. // $roleId=$v[0];
  3910. // }
  3911. }
  3912. $roleVerify = json_decode ( $v [3], true );
  3913. $roleKey = $k;
  3914. $roleArray = array ();
  3915. $rolename = $role->getOne ( array (
  3916. 'where' => 'rid=' . $v [0],
  3917. 'asArray' => true
  3918. ) );
  3919. foreach ( $roleVerify as $o => $p ) {
  3920. $staffID = explode ( '_', $p );
  3921. $staffInfo = $staff->getOne ( array (
  3922. 'where' => 'sid=' . $staffID [0],
  3923. 'asArray' => true
  3924. ) );
  3925. // print_r($staffID);
  3926. $exp = array (
  3927. 0 => $staffInfo ['sid'],
  3928. 1 => $staffID [1],
  3929. 2 => $staffInfo ['avatar'],
  3930. 'date' => '',
  3931. 'date' => '',
  3932. 'opinion' => '',
  3933. 'status' => '',
  3934. 'rolename' => $rolename ['name']
  3935. );
  3936. array_push ( $roleArray, $exp );
  3937. }
  3938. $roleArrayCopy [$v [0]] = $roleArray;
  3939. // $verifyList[$k]['roleArray']=$roleArray;
  3940. }
  3941. $verifyList [$k] ['date'] = "";
  3942. $verifyList [$k] ['opinion'] = "";
  3943. $verifyList [$k] ['status'] = "";
  3944. if (empty ( $verifyStaff )) {
  3945. $verifyList [$k] ['date'] = "";
  3946. $verifyList [$k] ['opinion'] = "";
  3947. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3948. $verifyList [$k] ['status'] = 4;
  3949. $flag = false;
  3950. }
  3951. } else {
  3952. foreach ( $verifyStaff as $m => $u ) {
  3953. if ($v [0] == $m) {
  3954. $verifyList [$k] ['date'] = $u ['date'];
  3955. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3956. $verifyList [$k] ['status'] = $u ['status'];
  3957. $flag = false;
  3958. break;
  3959. }
  3960. }
  3961. $endStaffArray = end ( $verifyStaff );
  3962. if (isset ( $endStaffArray ['ROLE'] )) {
  3963. } else {
  3964. // $endKey=key($verifyStaff);
  3965. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3966. // $button=4;
  3967. // $verifyList[$k]['status']=4;
  3968. // }
  3969. }
  3970. }
  3971. }
  3972. $rolename ['name'] = '';
  3973. if (! empty ( $roleId )) {
  3974. Doo::loadModel ( 'role' );
  3975. $role = new role ();
  3976. $rolename = $role->getOne ( array (
  3977. 'where' => 'rid=' . $roleId,
  3978. 'asArray' => true
  3979. ) );
  3980. }
  3981. if (! empty ( $verifyStaff ))
  3982. $endStaffArray = end ( $verifyStaff );
  3983. $KOP = false;
  3984. foreach ( $roleArrayCopy as $P => $A ) {
  3985. foreach ( $A as $MKI => $AVL ) {
  3986. if (! empty ( $verifyStaff )) {
  3987. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3988. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3989. $button = 4;
  3990. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3991. }
  3992. foreach ( $verifyStaff as $m => $u ) {
  3993. $AVLFK = $AVL [0] . '_R';
  3994. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3995. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3996. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3997. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3998. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3999. break;
  4000. }
  4001. }
  4002. } else {
  4003. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4004. $button = 4;
  4005. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4006. }
  4007. }
  4008. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4009. $KOP = true;
  4010. }
  4011. }
  4012. foreach ( $roleArrayCopy as $k => $v ) {
  4013. foreach ( $verifyList as $m => $n ) {
  4014. if ($n [0] == $k) {
  4015. array_splice ( $verifyList, $m, 1, $v );
  4016. }
  4017. }
  4018. }
  4019. // 费用执行人相关数据
  4020. $executeCopy = json_decode ( $value ['executeCopy'], true );
  4021. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4022. foreach ( $executeCopy as $k => $v ) {
  4023. $executeCopy [$k] ['date'] = '';
  4024. $executeCopy [$k] ['opinion'] = '';
  4025. $executeCopy [$k] ['status'] = '';
  4026. if (! empty ( $executeStaff ))
  4027. foreach ( $executeStaff as $m => $u ) {
  4028. if ($v [0] == $m) {
  4029. $executeCopy [$k] ['date'] = $u ['date'];
  4030. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  4031. $executeCopy [$k] ['status'] = $u ['status'];
  4032. break;
  4033. }
  4034. }
  4035. }
  4036. $receiptList [$key] ['executeCopy'] = $executeCopy;
  4037. $receiptList [$key] ['verifyList'] = $verifyList;
  4038. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4039. 'where' => 'sid=' . $value ['staff'],
  4040. 'asArray' => true
  4041. ) );
  4042. $receiptList [$key] ['button'] = $button;
  4043. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4044. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4045. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4046. $receiptList [$key] ['relust'] = $relust;
  4047. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4048. }
  4049. Doo::loadModel ( 'enclosur' );
  4050. $enclosur = new enclosur ();
  4051. $enclosurList = $enclosur->find ( array (
  4052. 'where' => 'rid=' . $rid,
  4053. 'asArray' => true
  4054. ) );
  4055. $enclosurHtml = '';
  4056. foreach ( $enclosurList as $value ) {
  4057. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4058. }
  4059. $data ['enclosurHtml'] = $enclosurHtml;
  4060. //print_r($receiptList[0]['accountItem']['内部培训费用']);
  4061. $data ['receiptList'] = $receiptList;
  4062. $data ['memu'] = "receipt";
  4063. $data ['staff'] = $this->staff;
  4064. $data ['receiptMemu'] = 'expenses';
  4065. $data ['verifyId'] = $this->verifyId;
  4066. $data ['executeId'] = $this->executeId;
  4067. $this->render ( "/admin/expensesCollect", $data );
  4068. }
  4069. function approvalExpenses() {
  4070. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  4071. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4072. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4073. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4074. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4075. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  4076. // echo $rdate;
  4077. if (empty ( $status ))
  4078. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  4079. $page_size = 8;
  4080. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  4081. $vidList = array ();
  4082. $button = 0;
  4083. Doo::loadModel ( 'verify' );
  4084. $verify = new verify ();
  4085. Doo::loadModel ( 'receipt' );
  4086. $receipt = new receipt ();
  4087. Doo::loadModel ( 'staff' );
  4088. $staff = new staff ();
  4089. Doo::loadModel ( 'L_category' );
  4090. $Lcategory = new L_category ();
  4091. // user verify ID
  4092. $verifyDetail = $verify->find ( array (
  4093. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  4094. 'asArray' => true
  4095. ) );
  4096. foreach ( $verifyDetail as $key => $value ) {
  4097. array_push ( $vidList, $value ['vid'] );
  4098. }
  4099. $vid = implode ( ",", $vidList );
  4100. if (empty ( $verifyDetail ))
  4101. $vid = 0;
  4102. // if ($status==0)
  4103. // $dateCondition="";
  4104. // else
  4105. $dateCondition = " ";
  4106. // if (! empty ( $month ))
  4107. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  4108. if ($status == 'done' || $status == 'termination') {
  4109. if (! empty ( $year )) {
  4110. $dateCondition = " and Year(pastDate) =" . $year;
  4111. if (! empty ( $month ))
  4112. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  4113. }
  4114. } elseif ($status == 'finish') {
  4115. if (! empty ( $year )) {
  4116. $dateCondition = " and Year(pastDate) =" . $year;
  4117. if (! empty ( $month ))
  4118. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  4119. }
  4120. }
  4121. // date ( 'Y-m' )
  4122. // if (! empty ( $rdate ) && $status == 'done')
  4123. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  4124. // elseif (! empty ( $rdate ))
  4125. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  4126. $categoryList = $Lcategory->find ( array (
  4127. 'asArray' => true
  4128. ) );
  4129. $staffList = $staff->find ( array (
  4130. 'where' => 'cid=' . $cid,
  4131. 'asArray' => true
  4132. ) );
  4133. $cateCondition = "";
  4134. $staffCondition = "";
  4135. $approvalCondition = "";
  4136. if (! empty ( $cid )) {
  4137. $cateCondition = ' and cid=' . $cid;
  4138. }
  4139. if (! empty ( $sid )) {
  4140. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  4141. $cateCondition = "";
  4142. }
  4143. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  4144. if ($status == 'pendApproval') {
  4145. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  4146. }
  4147. if ($status == 'ongoing') {
  4148. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  4149. }
  4150. if ($status == 'done') {
  4151. $approvalCondition = ' and (status=8 or status=9 ) ';
  4152. }
  4153. if ($status == 'termination') {
  4154. $approvalCondition = " and status=3";
  4155. }
  4156. if ($status == 'finish') {
  4157. $approvalCondition = " and (status=1 or status=8 or status=9 or status=10)";
  4158. }
  4159. $pageinfo ['page'] = array (
  4160. 'previous' => ''
  4161. );
  4162. if(!empty($receiptOrder)){
  4163. $pageinfo = $this->get_page ( "CLD_receipt", ' and receiptOrder like "%' . $receiptOrder . '%"', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  4164. $receiptList = $receipt->find ( array ( // $dateCondition
  4165. 'where' => 'receiptOrder like "%' . $receiptOrder . '%"',
  4166. 'desc' => 'rid',
  4167. 'asArray' => true
  4168. ) );
  4169. }else{
  4170. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  4171. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  4172. $receiptList = $receipt->find ( array ( // $dateCondition.
  4173. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  4174. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  4175. 'desc' => 'rid',
  4176. 'asArray' => true
  4177. ) );
  4178. } else {
  4179. $receiptList = $receipt->find ( array ( // $dateCondition
  4180. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  4181. 'desc' => 'rid',
  4182. 'asArray' => true
  4183. ) );
  4184. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  4185. }
  4186. }
  4187. $rLRes = $receipt->find ( array (
  4188. '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 . ')',
  4189. 'desc' => 'rid',
  4190. 'asArray' => true
  4191. ) );
  4192. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  4193. // print_r($receiptList);
  4194. Doo::loadClass ( 'XDeode' );
  4195. $XDeode = new XDeode ( 7 );
  4196. $Locate = 0;
  4197. //
  4198. $reportList = $reportCateList = array ();
  4199. foreach ( $receiptList as $key => $value ) {
  4200. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4201. $receiptList [$key] ['Locate'] = $Locate;
  4202. $Locate ++;
  4203. $receiptList [$key] ['reviseDetail'] = array ();
  4204. if (! empty ( $value ['reviseDetail'] ))
  4205. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4206. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4207. $categoryDetil = $Lcategory->getOne ( array (
  4208. 'where' => 'cid=' . $value ['cid'],
  4209. 'asArray' => true
  4210. ) );
  4211. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4212. $verifyList = $verify->getOne ( array (
  4213. 'where' => 'vid=' . $value ['verify'],
  4214. 'asArray' => true
  4215. ) );
  4216. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4217. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4218. foreach ( $verifyList as $k => $v ) {
  4219. // init verifyStaff
  4220. $verifyList [$k] ['date'] = "";
  4221. $verifyList [$k] ['opinion'] = "";
  4222. $verifyList [$k] ['status'] = "";
  4223. if (empty ( $verifyStaff )) {
  4224. $verifyList [$k] ['date'] = "";
  4225. $verifyList [$k] ['opinion'] = "";
  4226. if ($v [0] == $this->staff [0] ['sid']) {
  4227. $verifyList [$k] ['status'] = 4;
  4228. $button = 4;
  4229. }
  4230. } else {
  4231. $flag = true;
  4232. foreach ( $verifyStaff as $m => $u ) {
  4233. if ($v [0] == $m) {
  4234. $verifyList [$k] ['date'] = $u ['date'];
  4235. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4236. $verifyList [$k] ['status'] = $u ['status'];
  4237. $flag = false;
  4238. break;
  4239. }
  4240. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  4241. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  4242. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  4243. }
  4244. if ($flag) { // 检测可编辑
  4245. if ($v [0] == $this->staff [0] ['sid']) {
  4246. $verifyList [$k] ['status'] = 4;
  4247. $button = 4;
  4248. }
  4249. }
  4250. }
  4251. }
  4252. $receiptList [$key] ['verifyList'] = $verifyList;
  4253. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4254. 'where' => 'sid=' . $value ['staff'],
  4255. 'asArray' => true
  4256. ) );
  4257. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  4258. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  4259. $receiptList [$key] ['button'] = $button;
  4260. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  4261. //获得培训班结算RID 借款费用--已经锁定
  4262. if($value['status']==10){
  4263. $trainRD=$receipt->getReceiptByTrainLoanRid($value['rid']);
  4264. $receiptList [$key]['trainRidKey7']=$trainRD['ridKey7'];
  4265. }
  4266. }
  4267. $reportList = array_unique ( $reportList );
  4268. $reportHtml = '';
  4269. foreach ( $reportList as $key => $value ) {
  4270. $v = explode ( "-", $value );
  4271. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  4272. }
  4273. // print_r($reportList)
  4274. $data ['reportHtml'] = $reportHtml;
  4275. $reportCateList = array_unique ( $reportCateList );
  4276. $reportCateHtml = '';
  4277. foreach ( $reportCateList as $key => $value ) {
  4278. $v = explode ( "-", $value );
  4279. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  4280. }
  4281. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  4282. $data ['reportCateHtml'] = $reportCateHtml;
  4283. // print_r($receiptList);die;
  4284. // $data['verifyDetail']=$verifyDetail;
  4285. $mothHtml = "";
  4286. for($i = 1; $i <= 12; $i ++) {
  4287. if ($month == $i)
  4288. $mothHtml .= '<option selected value="0' . $i . '">' . $i . '月</option>';
  4289. else
  4290. $mothHtml .= '<option value="0' . $i . '">' . $i . '月</option>';
  4291. }
  4292. $data ['mothHtml'] = $mothHtml;
  4293. $dateHtml = "";
  4294. $now = date ( "Y" );
  4295. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  4296. if ($YEARD <= $now) {
  4297. $dateHtml .= '<option ';
  4298. if ($year == $YEARD) {
  4299. $dateHtml .= 'selected ';
  4300. }
  4301. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  4302. }
  4303. }
  4304. $data ['dateHtml'] = $dateHtml;
  4305. $data ['page'] = $pageinfo;
  4306. $data ['receiptList'] = $receiptList;
  4307. $data ['receiptApprovalCount'] = count ( $rLRes );
  4308. $data ['status'] = $status;
  4309. $data ['year'] = $year;
  4310. $data ['month'] = $month;
  4311. $data ['categoryList'] = $categoryList;
  4312. $data ['staffList'] = $staffList;
  4313. $data ['cid'] = $cid;
  4314. $data ['sid'] = $sid;
  4315. // print_r($receiptList);
  4316. $data['receiptOrder']=$receiptOrder;
  4317. $data ['memu'] = "receipt";
  4318. $data ['staff'] = $this->staff;
  4319. $data ['receiptMemu'] = 'approvalExpenses';
  4320. $data ['verifyId'] = $this->verifyId;
  4321. $data ['executeId'] = $this->executeId;
  4322. $this->render ( "/admin/approvalExpenses", $data );
  4323. }
  4324. function expensesDoc() {
  4325. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  4326. Doo::loadClass ( 'XDeode' );
  4327. $XDeode = new XDeode ( 5 );
  4328. if (! empty ( $rid ) && ! is_numeric ( $rid ))
  4329. $rid = $XDeode->decode ( $rid );
  4330. if (! is_numeric ( $rid ))
  4331. die ( 'illegal request' );
  4332. Doo::loadModel ( 'receipt' );
  4333. $receipt = new receipt ();
  4334. Doo::loadModel ( 'L_category' );
  4335. $Lcategory = new L_category ();
  4336. Doo::loadModel ( 'verify' );
  4337. Doo::loadModel ( 'statistics' );
  4338. $statistics = new statistics ();
  4339. $verify = new verify ();
  4340. Doo::loadModel ( 'staff' );
  4341. $staff = new staff ();
  4342. Doo::loadModel ( 'loanReceipt' );
  4343. $loanReceipt = new loanReceipt ();
  4344. $receiptList = $receipt->find ( array (
  4345. 'where' => ' rid=' . $rid,
  4346. 'desc' => 'rid',
  4347. 'asArray' => true
  4348. ) );
  4349. $loanList = array ();
  4350. if (! empty ( $receiptList ))
  4351. $loanList = $loanReceipt->find ( array (
  4352. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4353. 'desc' => 'rid',
  4354. 'asArray' => true
  4355. ) );
  4356. $Locate = 0;
  4357. $roleId = 0;
  4358. $button = 0;
  4359. foreach ( $loanList as $key => $value ) {
  4360. $loanList [$key] ['Locate'] = $Locate;
  4361. $Locate ++;
  4362. $loanList [$key] ['reviseDetail'] = array ();
  4363. if (! empty ( $value ['reviseDetail'] ))
  4364. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4365. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4366. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4367. $categoryDetil = $Lcategory->getOne ( array (
  4368. 'where' => 'cid=' . $value ['cid'],
  4369. 'asArray' => true
  4370. ) );
  4371. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4372. // 检测编辑状态
  4373. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  4374. $verifyList ['staff'] = $value ['verifyBreakup'];
  4375. else
  4376. $verifyList = $verify->getOne ( array (
  4377. 'where' => 'vid=' . $value ['verify'],
  4378. 'asArray' => true
  4379. ) );
  4380. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4381. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4382. Doo::loadModel ( 'role' );
  4383. $role = new role ();
  4384. $flag = true;
  4385. $roleKey = 0;
  4386. $endStaffArray = array ();
  4387. $roleArrayCopy = array ();
  4388. foreach ( $verifyList as $k => $v ) {
  4389. // init verifyStaff
  4390. if ($v [1] == 'ROLE') {
  4391. if (! empty ( $verifyStaff )) {
  4392. $endStaffArray = end ( $verifyStaff );
  4393. // if ($v[0]==$endStaffArray['nextStaff']){
  4394. // $roleId=$v[0];
  4395. // }
  4396. }
  4397. $roleVerify = json_decode ( $v [3], true );
  4398. $roleKey = $k;
  4399. $roleArray = array ();
  4400. $rolename = $role->getOne ( array (
  4401. 'where' => 'rid=' . $v [0],
  4402. 'asArray' => true
  4403. ) );
  4404. foreach ( $roleVerify as $o => $p ) {
  4405. $staffID = explode ( '_', $p );
  4406. $staffInfo = $staff->getOne ( array (
  4407. 'where' => 'sid=' . $staffID [0],
  4408. 'asArray' => true
  4409. ) );
  4410. // print_r($staffID);
  4411. $exp = array (
  4412. 0 => $staffInfo ['sid'],
  4413. 1 => $staffID [1],
  4414. 2 => $staffInfo ['avatar'],
  4415. 'date' => '',
  4416. 'date' => '',
  4417. 'opinion' => '',
  4418. 'status' => '',
  4419. 'rolename' => $rolename ['name']
  4420. );
  4421. array_push ( $roleArray, $exp );
  4422. }
  4423. $roleArrayCopy [$v [0]] = $roleArray;
  4424. // $verifyList[$k]['roleArray']=$roleArray;
  4425. }
  4426. $verifyList [$k] ['date'] = "";
  4427. $verifyList [$k] ['opinion'] = "";
  4428. $verifyList [$k] ['status'] = "";
  4429. if (empty ( $verifyStaff )) {
  4430. $verifyList [$k] ['date'] = "";
  4431. $verifyList [$k] ['opinion'] = "";
  4432. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4433. $verifyList [$k] ['status'] = 4;
  4434. $flag = false;
  4435. }
  4436. } else {
  4437. foreach ( $verifyStaff as $m => $u ) {
  4438. if ($v [0] == $m) {
  4439. $verifyList [$k] ['date'] = $u ['date'];
  4440. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4441. $verifyList [$k] ['status'] = $u ['status'];
  4442. $flag = false;
  4443. break;
  4444. }
  4445. }
  4446. $endStaffArray = end ( $verifyStaff );
  4447. if (isset ( $endStaffArray ['ROLE'] )) {
  4448. } else {
  4449. // $endKey=key($verifyStaff);
  4450. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4451. // $button=4;
  4452. // $verifyList[$k]['status']=4;
  4453. // }
  4454. }
  4455. }
  4456. }
  4457. $rolename ['name'] = '';
  4458. if (! empty ( $roleId )) {
  4459. Doo::loadModel ( 'role' );
  4460. $role = new role ();
  4461. $rolename = $role->getOne ( array (
  4462. 'where' => 'rid=' . $roleId,
  4463. 'asArray' => true
  4464. ) );
  4465. }
  4466. if (! empty ( $verifyStaff ))
  4467. $endStaffArray = end ( $verifyStaff );
  4468. $KOP = false;
  4469. foreach ( $roleArrayCopy as $P => $A ) {
  4470. foreach ( $A as $MKI => $AVL ) {
  4471. if (! empty ( $verifyStaff )) {
  4472. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4473. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4474. $button = 4;
  4475. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4476. }
  4477. foreach ( $verifyStaff as $m => $u ) {
  4478. $AVLFK = $AVL [0] . '_R';
  4479. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4480. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4481. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4482. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4483. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4484. break;
  4485. }
  4486. }
  4487. } else {
  4488. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4489. $button = 4;
  4490. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4491. }
  4492. }
  4493. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4494. $KOP = true;
  4495. }
  4496. }
  4497. foreach ( $roleArrayCopy as $k => $v ) {
  4498. foreach ( $verifyList as $m => $n ) {
  4499. if ($n [0] == $k) {
  4500. array_splice ( $verifyList, $m, 1, $v );
  4501. }
  4502. }
  4503. }
  4504. $loanList [$key] ['verifyList'] = $verifyList;
  4505. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  4506. 'where' => 'sid=' . $value ['staff'],
  4507. 'asArray' => true
  4508. ) );
  4509. $loanList [$key] ['button'] = $button;
  4510. //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  4511. }
  4512. $data ['loanList'] = $loanList;
  4513. //print_r($loanList);
  4514. $Locate = 0;
  4515. $roleId = 0;
  4516. $button = 0;
  4517. foreach ( $receiptList as $key => $value ) {
  4518. $receiptList [$key] ['Locate'] = $Locate;
  4519. $Locate ++;
  4520. $receiptList [$key] ['reviseDetail'] = array ();
  4521. if (! empty ( $value ['reviseDetail'] ))
  4522. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4523. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4524. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4525. $categoryDetil = $Lcategory->getOne ( array (
  4526. 'where' => 'cid=' . $value ['cid'],
  4527. 'asArray' => true
  4528. ) );
  4529. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4530. // 检测编辑状态
  4531. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  4532. $verifyList ['staff'] = $value ['verifyBreakup'];
  4533. } else
  4534. $verifyList = $verify->getOne ( array (
  4535. 'where' => 'vid=' . $value ['verify'],
  4536. 'asArray' => true
  4537. ) );
  4538. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4539. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4540. Doo::loadModel ( 'role' );
  4541. $role = new role ();
  4542. if ($verifyList == NULL)
  4543. $verifyList = array ();
  4544. $flag = true;
  4545. $roleKey = 0;
  4546. $endStaffArray = array ();
  4547. $roleArrayCopy = array ();
  4548. foreach ( $verifyList as $k => $v ) {
  4549. // init verifyStaff
  4550. if ($v [1] == 'ROLE') {
  4551. if (! empty ( $verifyStaff )) {
  4552. $endStaffArray = end ( $verifyStaff );
  4553. // if ($v[0]==$endStaffArray['nextStaff']){
  4554. // $roleId=$v[0];
  4555. // }
  4556. }
  4557. $roleVerify = json_decode ( $v [3], true );
  4558. $roleKey = $k;
  4559. $roleArray = array ();
  4560. $rolename = $role->getOne ( array (
  4561. 'where' => 'rid=' . $v [0],
  4562. 'asArray' => true
  4563. ) );
  4564. foreach ( $roleVerify as $o => $p ) {
  4565. $staffID = explode ( '_', $p );
  4566. $staffInfo = $staff->getOne ( array (
  4567. 'where' => 'sid=' . $staffID [0],
  4568. 'asArray' => true
  4569. ) );
  4570. // print_r($staffID);
  4571. $exp = array (
  4572. 0 => $staffInfo ['sid'],
  4573. 1 => $staffID [1],
  4574. 2 => $staffInfo ['avatar'],
  4575. 'date' => '',
  4576. 'date' => '',
  4577. 'opinion' => '',
  4578. 'status' => '',
  4579. 'rolename' => $rolename ['name']
  4580. );
  4581. array_push ( $roleArray, $exp );
  4582. }
  4583. $roleArrayCopy [$v [0]] = $roleArray;
  4584. // $verifyList[$k]['roleArray']=$roleArray;
  4585. }
  4586. $verifyList [$k] ['date'] = "";
  4587. $verifyList [$k] ['opinion'] = "";
  4588. $verifyList [$k] ['status'] = "";
  4589. if (empty ( $verifyStaff )) {
  4590. $verifyList [$k] ['date'] = "";
  4591. $verifyList [$k] ['opinion'] = "";
  4592. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4593. $verifyList [$k] ['status'] = 4;
  4594. $flag = false;
  4595. }
  4596. } else {
  4597. foreach ( $verifyStaff as $m => $u ) {
  4598. if ($v [0] == $m) {
  4599. $verifyList [$k] ['date'] = $u ['date'];
  4600. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4601. $verifyList [$k] ['status'] = $u ['status'];
  4602. $flag = false;
  4603. break;
  4604. }
  4605. }
  4606. $endStaffArray = end ( $verifyStaff );
  4607. if (isset ( $endStaffArray ['ROLE'] )) {
  4608. } else {
  4609. // $endKey=key($verifyStaff);
  4610. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4611. // $button=4;
  4612. // $verifyList[$k]['status']=4;
  4613. // }
  4614. }
  4615. }
  4616. }
  4617. $FC = @$rolename ['name'];
  4618. $rolename ['name'] = '';
  4619. if (! empty ( $roleId )) {
  4620. Doo::loadModel ( 'role' );
  4621. $role = new role ();
  4622. $rolename = $role->getOne ( array (
  4623. 'where' => 'rid=' . $roleId,
  4624. 'asArray' => true
  4625. ) );
  4626. }
  4627. if (! empty ( $verifyStaff ))
  4628. $endStaffArray = end ( $verifyStaff );
  4629. $KOP = false;
  4630. foreach ( $roleArrayCopy as $P => $A ) {
  4631. foreach ( $A as $MKI => $AVL ) {
  4632. if (! empty ( $verifyStaff )) {
  4633. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4634. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4635. $button = 4;
  4636. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4637. }
  4638. foreach ( $verifyStaff as $m => $u ) {
  4639. $AVLFK = $AVL [0] . '_R';
  4640. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4641. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4642. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4643. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4644. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4645. break;
  4646. }
  4647. }
  4648. } else {
  4649. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4650. $button = 4;
  4651. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4652. }
  4653. }
  4654. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4655. $KOP = true;
  4656. }
  4657. }
  4658. foreach ( $roleArrayCopy as $k => $v ) {
  4659. foreach ( $verifyList as $m => $n ) {
  4660. if ($n [0] == $k) {
  4661. array_splice ( $verifyList, $m, 1, $v );
  4662. }
  4663. }
  4664. }
  4665. // 费用执行人相关数据
  4666. $executeCopy = json_decode ( $value ['executeCopy'], true );
  4667. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4668. foreach ( $executeCopy as $k => $v ) {
  4669. $executeCopy [$k] ['date'] = '';
  4670. $executeCopy [$k] ['opinion'] = '';
  4671. $executeCopy [$k] ['status'] = '';
  4672. if (! empty ( $executeStaff ))
  4673. foreach ( $executeStaff as $m => $u ) {
  4674. if ($v [0] == $m) {
  4675. $executeCopy [$k] ['date'] = $u ['date'];
  4676. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  4677. $executeCopy [$k] ['status'] = $u ['status'];
  4678. break;
  4679. }
  4680. }
  4681. }
  4682. $receiptList [$key] ['executeCopy'] = $executeCopy;
  4683. // print_r($verifyList);
  4684. $receiptList [$key] ['verifyList'] = $verifyList;
  4685. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4686. 'where' => 'sid=' . $value ['staff'],
  4687. 'asArray' => true
  4688. ) );
  4689. $receiptList [$key] ['button'] = $button;
  4690. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4691. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4692. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4693. $receiptList [$key] ['relust'] = $relust;
  4694. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4695. }
  4696. // print_r($receiptList);
  4697. // 获取审批日志
  4698. Doo::loadModel ( 'receiptLog' );
  4699. $receiptLog = new receiptLog ();
  4700. $rlList = array ();
  4701. $rlInfo = $receiptLog->getOne ( array (
  4702. 'where' => 'rid=' . $rid . ' and status=4',
  4703. 'asArray' => true
  4704. ) );
  4705. // $tijdate = $receiptLog->getOne ( array (
  4706. // 'where' => 'rid=' . $rid . ' and status=2',
  4707. // 'asc' => 'rlid',
  4708. // 'asArray' => true
  4709. // ) );
  4710. if (! empty ( $rlInfo )) {
  4711. $rlList = $receiptLog->find ( array (
  4712. 'where' => 'rid=' . $rid,
  4713. 'asc' => 'rlid',
  4714. 'asArray' => true
  4715. ) );
  4716. }
  4717. $RN=array();
  4718. if (!empty( $rolename ['staff'])){
  4719. $RN = @json_decode ( $rolename ['staff'] );
  4720. }
  4721. //
  4722. foreach ( $rlList as $key => $value ) {
  4723. $rlList [$key] ['rolename'] = '';
  4724. foreach ( $RN as $k => $v ) {
  4725. $id = explode ( "_", $v );
  4726. if ($id [0] == $value ['uid']) {
  4727. $rlList [$key] ['rolename'] = $FC;
  4728. break;
  4729. }
  4730. }
  4731. }
  4732. Doo::loadModel ( 'enclosur' );
  4733. $enclosur = new enclosur ();
  4734. $enclosurList = $enclosur->find ( array (
  4735. 'where' => 'rid=' . $rid,
  4736. 'asArray' => true
  4737. ) );
  4738. $enclosurHtml = '';
  4739. foreach ( $enclosurList as $value ) {
  4740. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4741. }
  4742. $data ['enclosurHtml'] = $enclosurHtml;
  4743. $receiptList [0] ['rlList'] = $rlList;
  4744. $data ['receiptList'] = $receiptList;
  4745. // print_r($receiptList);
  4746. $data ['memu'] = "receipt";
  4747. $data ['staff'] = $this->staff;
  4748. $data ['receiptMemu'] = 'approvalExpenses';
  4749. $data ['verifyId'] = $this->verifyId;
  4750. $data ['executeId'] = $this->executeId;
  4751. $this->render ( "/admin/expensesDoc", $data );
  4752. }
  4753. function expensesEdi() {
  4754. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4755. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  4756. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4757. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4758. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4759. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4760. if (empty ( $status ))
  4761. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  4762. $vidList = array ();
  4763. $button = 0;
  4764. Doo::loadModel ( 'verify' );
  4765. Doo::loadModel ( 'receipt' );
  4766. Doo::loadModel ( 'staff' );
  4767. $staff = new staff ();
  4768. $receipt = new receipt ();
  4769. $verify = new verify ();
  4770. Doo::loadModel ( 'L_category' );
  4771. $Lcategory = new L_category ();
  4772. Doo::loadModel ( 'enclosur' );
  4773. $enclosur = new enclosur ();
  4774. // user verify ID
  4775. $verifyDetail = $verify->find ( array (
  4776. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  4777. 'asArray' => true
  4778. ) );
  4779. foreach ( $verifyDetail as $key => $value ) {
  4780. array_push ( $vidList, $value ['vid'] );
  4781. }
  4782. $vid = implode ( ",", $vidList );
  4783. if (empty ( $verifyDetail ))
  4784. $vid = 0;
  4785. $categoryList = $Lcategory->find ( array (
  4786. 'asArray' => true
  4787. ) );
  4788. $staffList = $staff->find ( array (
  4789. 'where' => 'cid=' . $cid,
  4790. 'asArray' => true
  4791. ) );
  4792. $ap = "";
  4793. if ($status == 4) {
  4794. $ap = 4;
  4795. $status = 2;
  4796. }
  4797. // get Receipt By verifyID status 2
  4798. $receiptList = $receipt->find ( array (
  4799. 'where' => 'rid =' . $rid . ' and status=2',
  4800. 'desc' => 'rid',
  4801. 'asArray' => true
  4802. ) );
  4803. if (empty ( $receiptList )) {
  4804. die ( 'illegal request' );
  4805. }
  4806. $Locate = 0;
  4807. $roleId = 0;
  4808. if ($ap == 4)
  4809. $status = 4;
  4810. foreach ( $receiptList as $key => $value ) {
  4811. $receiptList [$key] ['Locate'] = $Locate;
  4812. $Locate ++;
  4813. $receiptList [$key] ['reviseDetail'] = array ();
  4814. if (! empty ( $value ['reviseDetail'] ))
  4815. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4816. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4817. $categoryDetil = $Lcategory->getOne ( array (
  4818. 'where' => 'cid=' . $value ['cid'],
  4819. 'asArray' => true
  4820. ) );
  4821. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4822. // 检测编辑状态
  4823. $verifyList = $verify->getOne ( array (
  4824. 'where' => 'vid=' . $value ['verify'],
  4825. 'asArray' => true
  4826. ) );
  4827. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4828. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4829. Doo::loadModel ( 'role' );
  4830. $role = new role ();
  4831. // print_r($verifyList);
  4832. $flag = true;
  4833. $roleKey = 0;
  4834. $endStaffArray = array ();
  4835. $roleArrayCopy = array ();
  4836. foreach ( $verifyList as $k => $v ) {
  4837. // init verifyStaff
  4838. if ($v [1] == 'ROLE') {
  4839. if (! empty ( $verifyStaff )) {
  4840. $endStaffArray = end ( $verifyStaff );
  4841. if ($v [0] == $endStaffArray ['nextStaff']) {
  4842. $roleId = $v [0];
  4843. }
  4844. }
  4845. $roleVerify = json_decode ( $v [3], true );
  4846. $roleKey = $k;
  4847. $roleArray = array ();
  4848. $rolename = $role->getOne ( array (
  4849. 'where' => 'rid=' . $v [0],
  4850. 'asArray' => true
  4851. ) );
  4852. foreach ( $roleVerify as $o => $p ) {
  4853. $staffID = explode ( '_', $p );
  4854. $staffInfo = $staff->getOne ( array (
  4855. 'where' => 'sid=' . $staffID [0],
  4856. 'asArray' => true
  4857. ) );
  4858. // print_r($staffID);
  4859. $exp = array (
  4860. 0 => $staffInfo ['sid'],
  4861. 1 => $staffID [1],
  4862. 2 => $staffInfo ['avatar'],
  4863. 'date' => '',
  4864. 'date' => '',
  4865. 'opinion' => '',
  4866. 'status' => '',
  4867. 'rolename' => $rolename ['name']
  4868. );
  4869. array_push ( $roleArray, $exp );
  4870. }
  4871. $roleArrayCopy [$v [0]] = $roleArray;
  4872. // $verifyList[$k]['roleArray']=$roleArray;
  4873. }
  4874. // print_r($roleArray);
  4875. $verifyList [$k] ['date'] = "";
  4876. $verifyList [$k] ['opinion'] = "";
  4877. $verifyList [$k] ['status'] = "";
  4878. if (empty ( $verifyStaff )) {
  4879. $verifyList [$k] ['date'] = "";
  4880. $verifyList [$k] ['opinion'] = "";
  4881. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4882. $verifyList [$k] ['status'] = 4;
  4883. $button = 4;
  4884. $flag = false;
  4885. }
  4886. } else {
  4887. foreach ( $verifyStaff as $m => $u ) {
  4888. if ($v [0] == $m) {
  4889. $verifyList [$k] ['date'] = $u ['date'];
  4890. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4891. $verifyList [$k] ['status'] = $u ['status'];
  4892. $flag = false;
  4893. break;
  4894. }
  4895. }
  4896. $endStaffArray = end ( $verifyStaff );
  4897. if (isset ( $endStaffArray ['ROLE'] )) {
  4898. } else {
  4899. $endKey = key ( $verifyStaff );
  4900. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4901. $button = 4;
  4902. $verifyList [$k] ['status'] = 4;
  4903. }
  4904. }
  4905. }
  4906. }
  4907. $rolename ['name'] = '';
  4908. if (! empty ( $roleId )) {
  4909. Doo::loadModel ( 'role' );
  4910. $role = new role ();
  4911. $rolename = $role->getOne ( array (
  4912. 'where' => 'rid=' . $roleId,
  4913. 'asArray' => true
  4914. ) );
  4915. }
  4916. if (! empty ( $verifyStaff ))
  4917. $endStaffArray = end ( $verifyStaff );
  4918. $KOP = false;
  4919. foreach ( $roleArrayCopy as $P => $A ) {
  4920. foreach ( $A as $MKI => $AVL ) {
  4921. if (! empty ( $verifyStaff )) {
  4922. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4923. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4924. $button = 4;
  4925. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4926. }
  4927. foreach ( $verifyStaff as $m => $u ) {
  4928. $AVLFK = $AVL [0] . '_R';
  4929. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4930. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4931. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4932. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4933. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4934. break;
  4935. }
  4936. }
  4937. } else {
  4938. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4939. $button = 4;
  4940. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4941. }
  4942. }
  4943. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4944. $KOP = true;
  4945. }
  4946. }
  4947. // print_r($roleArrayCopy);
  4948. // echo $roleKey;
  4949. foreach ( $roleArrayCopy as $k => $v ) {
  4950. foreach ( $verifyList as $m => $n ) {
  4951. if ($n [0] == $k) {
  4952. array_splice ( $verifyList, $m, 1, $v );
  4953. }
  4954. }
  4955. }
  4956. $receiptList [$key] ['verifyList'] = $verifyList;
  4957. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4958. 'where' => 'sid=' . $value ['staff'],
  4959. 'asArray' => true
  4960. ) );
  4961. $receiptList [$key] ['button'] = $button;
  4962. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  4963. }
  4964. // $data['verifyDetail']=$verifyDetail;
  4965. $mothHtml = "";
  4966. for($i = 1; $i <= 12; $i ++) {
  4967. if ($month == $i)
  4968. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4969. else
  4970. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4971. }
  4972. // 获取审批日志
  4973. Doo::loadModel ( 'receiptLog' );
  4974. $receiptLog = new receiptLog ();
  4975. $rlList = array ();
  4976. $rlInfo = $receiptLog->getOne ( array (
  4977. 'where' => 'rid=' . $rid . ' and status=4',
  4978. 'asArray' => true
  4979. ) );
  4980. $tijdate = $receiptLog->getOne ( array (
  4981. 'where' => 'rid=' . $rid . ' and status=2',
  4982. 'asc' => 'rlid',
  4983. 'asArray' => true
  4984. ) );
  4985. if (! empty ( $rlInfo )) {
  4986. $rlList = $receiptLog->find ( array (
  4987. 'where' => 'rid=' . $rid,
  4988. 'asc' => 'rlid',
  4989. 'asArray' => true
  4990. ) );
  4991. }
  4992. $receiptList [0] ['rlList'] = $rlList;
  4993. $enclosurList = $enclosur->find ( array (
  4994. 'where' => 'rid=' . $rid,
  4995. 'asArray' => true
  4996. ) );
  4997. $enclosurHtml = '';
  4998. foreach ( $enclosurList as $value ) {
  4999. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5000. }
  5001. // print_r($receiptList);
  5002. $data ['rid'] = $rid;
  5003. $data ['enclosurHtml'] = $enclosurHtml;
  5004. $data ['rolename'] = $rolename ['name'];
  5005. $data ['datetij'] = $tijdate ['date'];
  5006. $data ['mothHtml'] = $mothHtml;
  5007. $data ['receiptList'] = $receiptList;
  5008. $data ['receiptApprovalCount'] = count ( $receiptList );
  5009. $data ['status'] = $status;
  5010. $data ['year'] = $year;
  5011. $data ['categoryList'] = $categoryList;
  5012. $data ['staffList'] = $staffList;
  5013. $data ['cid'] = $cid;
  5014. $data ['sid'] = $sid;
  5015. $data ['ap'] = $ap;
  5016. $data ['memu'] = "receipt";
  5017. $data ['staff'] = $this->staff;
  5018. $data ['receiptMemu'] = 'approvalExpenses';
  5019. $data ['verifyId'] = $this->verifyId;
  5020. $data ['executeId'] = $this->executeId;
  5021. $this->render ( "/admin/expensesEdi", $data );
  5022. }
  5023. function expensesDefray() {
  5024. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  5025. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  5026. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5027. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  5028. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  5029. if (! empty ( $rid )) {
  5030. Doo::loadModel ( "verify" );
  5031. $verify = new verify ();
  5032. Doo::loadModel ( "receiptDetail" );
  5033. $receiptDetailObj = new receiptDetail ();
  5034. Doo::loadModel ( "itemStatistics" );
  5035. Doo::loadModel ( "statistics" );
  5036. $statistics = new statistics ();
  5037. $itemStatistics = new itemStatistics ();
  5038. Doo::loadModel ( "receipt" );
  5039. $receipt = new receipt ();
  5040. Doo::loadModel ( "loanReceipt" );
  5041. $loanReceipt = new loanReceipt ();
  5042. $receiptDetail = $receipt->getOne ( array (
  5043. 'where' => 'rid=' . $rid . ' and status=2 ',
  5044. 'asArray' => true
  5045. ) );
  5046. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  5047. $nsflag = true;
  5048. foreach ( $nslist as $value ) {
  5049. if ($value == $this->staff ['0'] ['sid']) {
  5050. $nsflag = false;
  5051. break;
  5052. }
  5053. }
  5054. // print_r($nslist);die;
  5055. if (empty ( $receiptDetail ) || $nsflag)
  5056. return "/approvalExpenses/pendApproval";
  5057. $verifyDetail = $verify->getOne ( array (
  5058. 'where' => ' vid =' . $receiptDetail ['verify'],
  5059. 'asArray' => true
  5060. ) );
  5061. $verifyString = $verifyDetail ['staff'];
  5062. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5063. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  5064. if (empty ( $opinion )) {
  5065. if ($status == 3)
  5066. $opinion = "终止";
  5067. else
  5068. $opinion = "同意支付";
  5069. }
  5070. $nowStaff = 0;
  5071. $nowStaffList = array ();
  5072. if (empty ( $verifyStaff )) {
  5073. // 还需加入是否已经进入角色审批
  5074. if ($verifyDetail [0] [1] == 'ROLE') {
  5075. // print_r($verifyDetail);echo "ddd";
  5076. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5077. foreach ( $vStaffString as $key => $value ) {
  5078. $staffK = explode ( "_", $value );
  5079. if ($staffK [0] != $this->staff [0] ['sid'])
  5080. array_push ( $nowStaffList, $staffK [0] );
  5081. }
  5082. // print_r($verifyDetail);
  5083. // die;
  5084. if (! empty ( $nowStaffList )) {
  5085. $nowStaff = implode ( ',', $nowStaffList );
  5086. $verifyStaff = array (
  5087. $this->staff [0] ['sid'] . "_R" => array (
  5088. 'date' => date ( 'Y-m-d' ),
  5089. 'opinion' => $opinion,
  5090. 'status' => $status,
  5091. 'nextStaff' => $verifyDetail [0] [0],
  5092. 'ROLE' => 1
  5093. )
  5094. );
  5095. } else {
  5096. $nowStaff = $verifyDetail [1] [0];
  5097. $verifyStaff = array (
  5098. $this->staff [0] ['sid'] . "_R" => array (
  5099. 'date' => date ( 'Y-m-d' ),
  5100. 'opinion' => $opinion,
  5101. 'status' => $status,
  5102. 'nextStaff' => $verifyDetail [1] [0]
  5103. )
  5104. );
  5105. }
  5106. } else {
  5107. if ($verifyDetail [1] [1] == 'ROLE') {
  5108. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  5109. // echo "dd";
  5110. foreach ( $vStaffString as $key => $value ) {
  5111. $staffK = explode ( "_", $value );
  5112. array_push ( $nowStaffList, $staffK [0] );
  5113. }
  5114. $nowStaff = implode ( ',', $nowStaffList );
  5115. $verifyStaff = array (
  5116. $this->staff [0] ['sid'] => array (
  5117. 'date' => date ( 'Y-m-d' ),
  5118. 'opinion' => $opinion,
  5119. 'status' => $status,
  5120. 'nextStaff' => $verifyDetail [1] [0],
  5121. 'ROLE' => 1
  5122. )
  5123. );
  5124. } else {
  5125. $nowStaff = $verifyDetail [1] [0];
  5126. $verifyStaff = array (
  5127. $this->staff [0] ['sid'] => array (
  5128. 'date' => date ( 'Y-m-d' ),
  5129. 'opinion' => $opinion,
  5130. 'status' => $status,
  5131. 'nextStaff' => $verifyDetail [1] [0]
  5132. )
  5133. );
  5134. }
  5135. }
  5136. if ($status == 3)
  5137. $verifyStaff = array (
  5138. 'final' => $status,
  5139. $this->staff [0] ['sid'] => array (
  5140. 'date' => date ( 'Y-m-d' ),
  5141. 'opinion' => $opinion,
  5142. 'status' => $status
  5143. )
  5144. );
  5145. $vStaffString = json_encode ( $verifyStaff );
  5146. $receipt->nowStaff = $nowStaff;
  5147. $receipt->verifyStaff = $vStaffString;
  5148. $loanReceipt->nowStaff = $nowStaff;
  5149. $loanReceipt->verifyStaff = $vStaffString;
  5150. } else {
  5151. $VS = end ( $verifyStaff );
  5152. // 非角色审批
  5153. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  5154. $nextStaff = 0;
  5155. $roleSTF = false;
  5156. foreach ( $verifyDetail as $key => $value ) {
  5157. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  5158. if (isset ( $verifyDetail [$key + 1] )) {
  5159. $nextStaff = $verifyDetail [$key + 1] [0];
  5160. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  5161. $roleSTF = true;
  5162. }
  5163. break;
  5164. }
  5165. }
  5166. if (! $roleSTF) {
  5167. $nowStaff = $nextStaff;
  5168. $verifyStaff [$this->staff [0] ['sid']] = array (
  5169. 'date' => date ( 'Y-m-d' ),
  5170. 'opinion' => $opinion,
  5171. 'status' => $status,
  5172. 'nextStaff' => $nextStaff
  5173. );
  5174. } else {
  5175. // 获取角色下的所有用户ID
  5176. $nowStaffList = array ();
  5177. foreach ( $verifyDetail as $vfk ) {
  5178. if ($vfk [1] == 'ROLE') {
  5179. $vStaffString = json_decode ( $vfk [3] );
  5180. foreach ( $vStaffString as $key => $value ) {
  5181. $staffK = explode ( "_", $value );
  5182. array_push ( $nowStaffList, $staffK [0] );
  5183. }
  5184. }
  5185. }
  5186. $nowStaff = implode ( ',', $nowStaffList );
  5187. $verifyStaff [$this->staff [0] ['sid']] = array (
  5188. 'date' => date ( 'Y-m-d' ),
  5189. 'opinion' => $opinion,
  5190. 'status' => $status,
  5191. 'nextStaff' => $nextStaff,
  5192. 'ROLE' => 0
  5193. );
  5194. }
  5195. if ($status == 3) {
  5196. $verifyStaff ['final'] = $status;
  5197. $verifyStaff [$this->staff [0] ['sid']] = array (
  5198. 'date' => date ( 'Y-m-d' ),
  5199. 'opinion' => $opinion,
  5200. 'status' => $status
  5201. );
  5202. }
  5203. $vStaffString = json_encode ( $verifyStaff );
  5204. $receipt->nowStaff = $nowStaff;
  5205. $receipt->verifyStaff = $vStaffString;
  5206. $loanReceipt->nowStaff = $nowStaff;
  5207. $loanReceipt->verifyStaff = $vStaffString;
  5208. }
  5209. // 角色审批
  5210. if (isset ( $VS ['ROLE'] )) {
  5211. // 找出角色人 当前审批角色组
  5212. $verifyJSStaff = array ();
  5213. $nowStaffList2 = array ();
  5214. foreach ( $verifyDetail as $key => $value ) {
  5215. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  5216. $verifyJSStaff = json_decode ( $value [3] );
  5217. foreach ( $verifyJSStaff as $m ) {
  5218. $staffK = explode ( "_", $m );
  5219. array_push ( $nowStaffList2, $staffK [0] );
  5220. }
  5221. // print_r($nowStaffList2);
  5222. }
  5223. }
  5224. $RoleVerifyStaff = array ();
  5225. foreach ( $verifyStaff as $key => $value ) {
  5226. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  5227. foreach ( $nowStaffList2 as $m ) {
  5228. if ($key == $m . "_R")
  5229. $RoleVerifyStaff [$key] = $value;
  5230. }
  5231. }
  5232. }
  5233. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  5234. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  5235. // 下一个审批人ID
  5236. $nextStaff = 0;
  5237. $falg = false;
  5238. foreach ( $verifyDetail as $key => $value ) {
  5239. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  5240. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  5241. $falg = true;
  5242. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  5243. $nowStaffList = array ();
  5244. foreach ( $vStaffString as $v ) {
  5245. $staffK = explode ( "_", $v );
  5246. array_push ( $nowStaffList, $staffK [0] );
  5247. }
  5248. $nowStaff = implode ( ',', $nowStaffList );
  5249. $nextStaff = $verifyDetail [$key + 1] [0];
  5250. } elseif (isset ( $verifyDetail [$key + 1] )) {
  5251. $nextStaff = $verifyDetail [$key + 1] [0];
  5252. $nowStaff = $nextStaff;
  5253. } else
  5254. $nowStaff = '';
  5255. break;
  5256. }
  5257. }
  5258. if ($falg)
  5259. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5260. 'date' => date ( 'Y-m-d' ),
  5261. 'opinion' => $opinion,
  5262. 'status' => $status,
  5263. 'nextStaff' => $nextStaff,
  5264. 'ROLE' => 1
  5265. );
  5266. else
  5267. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5268. 'date' => date ( 'Y-m-d' ),
  5269. 'opinion' => $opinion,
  5270. 'status' => $status,
  5271. 'nextStaff' => $nextStaff
  5272. );
  5273. // print_r($verifyStaff);
  5274. // echo $nowStaff;die;
  5275. } else { // 进入下一个角色或者审批人
  5276. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  5277. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5278. 'date' => date ( 'Y-m-d' ),
  5279. 'opinion' => $opinion,
  5280. 'status' => $status,
  5281. 'nextStaff' => $VS ['nextStaff'],
  5282. 'ROLE' => 1
  5283. );
  5284. }
  5285. if ($status == 3) {
  5286. $verifyStaff ['final'] = $status;
  5287. $verifyStaff [$this->staff [0] ['sid']] = array (
  5288. 'date' => date ( 'Y-m-d' ),
  5289. 'opinion' => $opinion,
  5290. 'status' => $status
  5291. );
  5292. }
  5293. $vStaffString = json_encode ( $verifyStaff );
  5294. $receipt->verifyStaff = $vStaffString;
  5295. $receipt->nowStaff = $nowStaff;
  5296. $loanReceipt->nowStaff = $nowStaff;
  5297. $loanReceipt->verifyStaff = $vStaffString;
  5298. }
  5299. // print_r($verifyStaff);die;
  5300. }
  5301. $roleKey = 0;
  5302. $roleId = 0;
  5303. $verifyDetailCopy = array ();
  5304. foreach ( $verifyDetail as $k => $v ) {
  5305. if ($v [1] == 'ROLE') {
  5306. $roleId = $v [0];
  5307. $roleVerify = json_decode ( $v [3], true );
  5308. $roleKey = $k;
  5309. $roleArray = array ();
  5310. foreach ( $roleVerify as $o => $p ) {
  5311. $staffID = explode ( '_', $p );
  5312. $exp = array (
  5313. 0 => $staffID [0],
  5314. 1 => $staffID [1]
  5315. );
  5316. array_push ( $roleArray, $exp );
  5317. }
  5318. $verifyDetailCopy [$v [0]] = $roleArray;
  5319. }
  5320. }
  5321. // print_r($verifyDetail);
  5322. foreach ( $verifyDetailCopy as $k => $v ) {
  5323. foreach ( $verifyDetail as $m => $n ) {
  5324. if ($n [0] == $k) {
  5325. array_splice ( $verifyDetail, $m, 1, $v );
  5326. }
  5327. }
  5328. }
  5329. // 审批日志
  5330. if (! isset ( $verifyStaff ['final'] )) {
  5331. Doo::loadModel ( "receiptLog" );
  5332. $receiptLog = new receiptLog ();
  5333. if (! empty ( $roleId )) {
  5334. Doo::loadModel ( "role" );
  5335. $role = new role ();
  5336. $roleInfo = $role->getOne ( array (
  5337. 'where' => 'rid=' . $roleId,
  5338. 'asArray' => true
  5339. ) );
  5340. $receiptLog->rolename = $roleInfo ['name'];
  5341. }
  5342. $receiptLog->username = $this->staff [0] ['username'];
  5343. $receiptLog->uid = $this->staff [0] ['sid'];
  5344. $receiptLog->date = date ( "Y-m-d" );
  5345. $receiptLog->opinion = $opinion;
  5346. $receiptLog->img = $this->staff [0] ['avatar'];
  5347. $receiptLog->status = 1;
  5348. $receiptLog->rid = $rid;
  5349. $receiptLog->insert ();
  5350. }
  5351. if (isset ( $verifyStaff ['final'] )) { // rDetail
  5352. $receipt->status = 3;
  5353. $receipt->verifyBreakup = $verifyString;
  5354. $receiptDetailObj->status = 3;
  5355. $receiptDetailObj->update ( array (
  5356. 'where' => 'rid=' . $rid
  5357. ) );
  5358. // 微信企业号通知
  5359. $this->setWXMsg ( $rid, 3 );
  5360. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  5361. $receipt->status = 6;
  5362. $receipt->pastDate = date ( "Y-m-d" );
  5363. $receipt->isBK = 1;
  5364. $loanReceipt->verifyBreakup = $verifyString;
  5365. $loanReceipt->status = 1;
  5366. $loanReceipt->pastDate = date ( "Y-m-d" );
  5367. //生成流水后 不更新汇款金额
  5368. Doo::loadModel ( 'wasteBook' );
  5369. $wasteBook = new wasteBook ();
  5370. $wbDetail = $wasteBook->getWateBookByAD ( 1, $rid );
  5371. if (empty($wbDetail)){
  5372. $loanReceipt->amount = $receiptDetail ['amount'];
  5373. }
  5374. $loanReceipt->update ( array (
  5375. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  5376. ) );
  5377. // 微信企业号通知
  5378. $this->setWXMsg ( $rid, 1 );
  5379. }
  5380. $receipt->amount = $receiptDetail['sum'];
  5381. $receipt->update ( array (
  5382. 'where' => ' rid = ' . $rid
  5383. ) );
  5384. // 进入下一条审批费用新加需求
  5385. $vidList = array ();
  5386. $verifyDetail = $verify->find ( array (
  5387. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  5388. 'asArray' => true
  5389. ) );
  5390. foreach ( $verifyDetail as $key => $value ) {
  5391. array_push ( $vidList, $value ['vid'] );
  5392. }
  5393. $vid = implode ( ",", $vidList );
  5394. if (empty ( $verifyDetail ))
  5395. $vid = 0;
  5396. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  5397. $receipt = new receipt ();
  5398. $rd = $receipt->getOne ( array (
  5399. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  5400. 'asc' => 'rid',
  5401. 'asArray' => true
  5402. ) );
  5403. if (empty ( $rd )) {
  5404. return '/approvalExpenses/pendApproval';
  5405. }
  5406. if ($rd ['Rtype'] == 1) {
  5407. if ($rd ['isBK'] == 1) {
  5408. return '/receiptburEdi/' . $rd ['rid'];
  5409. } else {
  5410. return '/expensesEdi/' . $rd ['rid'];
  5411. }
  5412. } elseif ($rd ['Rtype'] == 2) {
  5413. return '/remitApproval/' . $rd ['rid'];
  5414. } else {
  5415. return '/receiptburEdi/' . $rd ['rid'];
  5416. }
  5417. // return "/approvalExpenses/pendApproval";
  5418. }
  5419. }
  5420. function ajaxExamineExe() {
  5421. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5422. Doo::loadModel ( 'receipt' );
  5423. $receipt = new receipt ();
  5424. Doo::loadClass ( 'XDeode' );
  5425. $XDeode = new XDeode ( 5 );
  5426. if (! empty ( $rid )) {
  5427. $rLRes = $receipt->find ( array (
  5428. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  5429. 'asArray' => true
  5430. ) );
  5431. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  5432. echo json_encode ( array (
  5433. 'status' => 1,
  5434. 'receipt' => $rLRes [0]
  5435. ) );
  5436. die ();
  5437. }
  5438. echo json_encode ( array (
  5439. 'status' => 0,
  5440. 'receipt' => array ()
  5441. ) );
  5442. die ();
  5443. }
  5444. function implement() {
  5445. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5446. $Rtype = isset ( $this->params ['Rtype'] ) ? $this->params ['Rtype'] : '';
  5447. Doo::loadClass ( 'XDeode' );
  5448. $XDeode = new XDeode ( 5 );
  5449. Doo::loadModel ( 'receipt' );
  5450. $receipt = new receipt ();
  5451. Doo::loadModel ( 'L_category' );
  5452. $Lcategory = new L_category ();
  5453. Doo::loadModel ( 'verify' );
  5454. $verify = new verify ();
  5455. Doo::loadModel ( 'staff' );
  5456. $staff = new staff ();
  5457. Doo::loadModel ( "execute" );
  5458. $execute = new execute ();
  5459. $rid = $XDeode->decode ( $rid );
  5460. $receiptList = $receipt->find ( array (
  5461. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  5462. 'desc' => 'rid',
  5463. 'asArray' => true
  5464. ) );
  5465. Doo::loadModel ( 'loanReceipt' );
  5466. $loanReceipt = new loanReceipt ();
  5467. // print_r($receiptList);
  5468. $loanList = array ();
  5469. if (! isset ( $receiptList ))
  5470. $loanList = $loanReceipt->find ( array (
  5471. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  5472. 'desc' => 'rid',
  5473. 'asArray' => true
  5474. ) );
  5475. $Locate = 0;
  5476. $roleId = 0;
  5477. $button = 0;
  5478. foreach ( $loanList as $key => $value ) {
  5479. $loanList [$key] ['Locate'] = $Locate;
  5480. $Locate ++;
  5481. $loanList [$key] ['reviseDetail'] = array ();
  5482. if (! empty ( $value ['reviseDetail'] ))
  5483. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5484. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5485. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5486. $categoryDetil = $Lcategory->getOne ( array (
  5487. 'where' => 'cid=' . $value ['cid'],
  5488. 'asArray' => true
  5489. ) );
  5490. $loanList [$key] ['category'] = $categoryDetil ['title'];
  5491. // 检测编辑状态
  5492. $verifyList = $verify->getOne ( array (
  5493. 'where' => 'vid=' . $value ['verify'],
  5494. 'asArray' => true
  5495. ) );
  5496. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5497. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5498. Doo::loadModel ( 'role' );
  5499. $role = new role ();
  5500. $flag = true;
  5501. $roleKey = 0;
  5502. $endStaffArray = array ();
  5503. $roleArrayCopy = array ();
  5504. foreach ( $verifyList as $k => $v ) {
  5505. // init verifyStaff
  5506. if ($v [1] == 'ROLE') {
  5507. if (! empty ( $verifyStaff )) {
  5508. $endStaffArray = end ( $verifyStaff );
  5509. // if ($v[0]==$endStaffArray['nextStaff']){
  5510. // $roleId=$v[0];
  5511. // }
  5512. }
  5513. $roleVerify = json_decode ( $v [3], true );
  5514. $roleKey = $k;
  5515. $roleArray = array ();
  5516. $rolename = $role->getOne ( array (
  5517. 'where' => 'rid=' . $v [0],
  5518. 'asArray' => true
  5519. ) );
  5520. foreach ( $roleVerify as $o => $p ) {
  5521. $staffID = explode ( '_', $p );
  5522. $staffInfo = $staff->getOne ( array (
  5523. 'where' => 'sid=' . $staffID [0],
  5524. 'asArray' => true
  5525. ) );
  5526. // print_r($staffID);
  5527. $exp = array (
  5528. 0 => $staffInfo ['sid'],
  5529. 1 => $staffID [1],
  5530. 2 => $staffInfo ['avatar'],
  5531. 'date' => '',
  5532. 'date' => '',
  5533. 'opinion' => '',
  5534. 'status' => '',
  5535. 'rolename' => $rolename ['name']
  5536. );
  5537. array_push ( $roleArray, $exp );
  5538. }
  5539. $roleArrayCopy [$v [0]] = $roleArray;
  5540. // $verifyList[$k]['roleArray']=$roleArray;
  5541. }
  5542. $verifyList [$k] ['date'] = "";
  5543. $verifyList [$k] ['opinion'] = "";
  5544. $verifyList [$k] ['status'] = "";
  5545. if (empty ( $verifyStaff )) {
  5546. $verifyList [$k] ['date'] = "";
  5547. $verifyList [$k] ['opinion'] = "";
  5548. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5549. $verifyList [$k] ['status'] = 4;
  5550. $flag = false;
  5551. }
  5552. } else {
  5553. foreach ( $verifyStaff as $m => $u ) {
  5554. if ($v [0] == $m) {
  5555. $verifyList [$k] ['date'] = $u ['date'];
  5556. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5557. $verifyList [$k] ['status'] = $u ['status'];
  5558. $flag = false;
  5559. break;
  5560. }
  5561. }
  5562. $endStaffArray = end ( $verifyStaff );
  5563. if (isset ( $endStaffArray ['ROLE'] )) {
  5564. } else {
  5565. // $endKey=key($verifyStaff);
  5566. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5567. // $button=4;
  5568. // $verifyList[$k]['status']=4;
  5569. // }
  5570. }
  5571. }
  5572. }
  5573. $rolename ['name'] = '';
  5574. if (! empty ( $roleId )) {
  5575. Doo::loadModel ( 'role' );
  5576. $role = new role ();
  5577. $rolename = $role->getOne ( array (
  5578. 'where' => 'rid=' . $roleId,
  5579. 'asArray' => true
  5580. ) );
  5581. }
  5582. if (! empty ( $verifyStaff ))
  5583. $endStaffArray = end ( $verifyStaff );
  5584. $KOP = false;
  5585. foreach ( $roleArrayCopy as $P => $A ) {
  5586. foreach ( $A as $MKI => $AVL ) {
  5587. if (! empty ( $verifyStaff )) {
  5588. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5589. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5590. $button = 4;
  5591. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5592. }
  5593. foreach ( $verifyStaff as $m => $u ) {
  5594. $AVLFK = $AVL [0] . '_R';
  5595. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5596. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5597. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5598. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5599. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5600. break;
  5601. }
  5602. }
  5603. } else {
  5604. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5605. $button = 4;
  5606. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5607. }
  5608. }
  5609. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5610. $KOP = true;
  5611. }
  5612. }
  5613. foreach ( $roleArrayCopy as $k => $v ) {
  5614. foreach ( $verifyList as $m => $n ) {
  5615. if ($n [0] == $k) {
  5616. array_splice ( $verifyList, $m, 1, $v );
  5617. }
  5618. }
  5619. }
  5620. $loanList [$key] ['verifyList'] = $verifyList;
  5621. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  5622. 'where' => 'sid=' . $value ['staff'],
  5623. 'asArray' => true
  5624. ) );
  5625. }
  5626. $data ['loanList'] = $loanList;
  5627. $Locate = 0;
  5628. $roleId = 0;
  5629. $button = 0;
  5630. Doo::loadClass ( 'XDeode' );
  5631. $XDeode = new XDeode ( 5 );
  5632. foreach ( $receiptList as $key => $value ) {
  5633. $receiptList[$key]['ridKey']=$XDeode->encode ( $value['rid'] );
  5634. $button2 = 0;
  5635. $receiptList [$key] ['Locate'] = $Locate;
  5636. $Locate ++;
  5637. $receiptList [$key] ['reviseDetail'] = array ();
  5638. if (! empty ( $value ['reviseDetail'] ))
  5639. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5640. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5641. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5642. $categoryDetil = $Lcategory->getOne ( array (
  5643. 'where' => 'cid=' . $value ['cid'],
  5644. 'asArray' => true
  5645. ) );
  5646. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5647. $executeList = json_decode ( $value ['executeCopy'], true );
  5648. $executeStaff = array ();
  5649. if (! empty ( $value ['executeStaff'] ))
  5650. $executeStaff = json_decode ( $value ['executeStaff'], true );
  5651. if (isset ( $executeList )) {
  5652. foreach ( $executeList as $op => $lo ) {
  5653. $executeList [$op] ['date'] = "";
  5654. $executeList [$op] ['opinion'] = "";
  5655. $executeList [$op] ['status'] = "";
  5656. foreach ( $executeStaff as $m => $u ) {
  5657. if ($lo [0] == $m) {
  5658. $executeList [$op] ['date'] = $u ['date'];
  5659. $executeList [$op] ['opinion'] = $u ['opinion'];
  5660. $executeList [$op] ['status'] = $u ['status'];
  5661. break;
  5662. }
  5663. }
  5664. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  5665. $button2 = 1;
  5666. $executeList [$op] ['status'] = 4;
  5667. }
  5668. }
  5669. }
  5670. // 检测编辑状态
  5671. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  5672. $verifyList ['staff'] = $value ['verifyBreakup'];
  5673. } else
  5674. $verifyList = $verify->getOne ( array (
  5675. 'where' => 'vid=' . $value ['verify'],
  5676. 'asArray' => true
  5677. ) );
  5678. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5679. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5680. Doo::loadModel ( 'role' );
  5681. $role = new role ();
  5682. if ($verifyList == NULL)
  5683. $verifyList = array ();
  5684. $flag = true;
  5685. $roleKey = 0;
  5686. $endStaffArray = array ();
  5687. $roleArrayCopy = array ();
  5688. foreach ( $verifyList as $k => $v ) {
  5689. // init verifyStaff
  5690. if ($v [1] == 'ROLE') {
  5691. if (! empty ( $verifyStaff )) {
  5692. $endStaffArray = end ( $verifyStaff );
  5693. // if ($v[0]==$endStaffArray['nextStaff']){
  5694. // $roleId=$v[0];
  5695. // }
  5696. }
  5697. $roleVerify = json_decode ( $v [3], true );
  5698. $roleKey = $k;
  5699. $roleArray = array ();
  5700. $rolename = $role->getOne ( array (
  5701. 'where' => 'rid=' . $v [0],
  5702. 'asArray' => true
  5703. ) );
  5704. foreach ( $roleVerify as $o => $p ) {
  5705. $staffID = explode ( '_', $p );
  5706. $staffInfo = $staff->getOne ( array (
  5707. 'where' => 'sid=' . $staffID [0],
  5708. 'asArray' => true
  5709. ) );
  5710. // print_r($staffID);
  5711. $exp = array (
  5712. 0 => $staffInfo ['sid'],
  5713. 1 => $staffID [1],
  5714. 2 => $staffInfo ['avatar'],
  5715. 'date' => '',
  5716. 'date' => '',
  5717. 'opinion' => '',
  5718. 'status' => '',
  5719. 'rolename' => $rolename ['name']
  5720. );
  5721. array_push ( $roleArray, $exp );
  5722. }
  5723. $roleArrayCopy [$v [0]] = $roleArray;
  5724. // $verifyList[$k]['roleArray']=$roleArray;
  5725. }
  5726. $verifyList [$k] ['date'] = "";
  5727. $verifyList [$k] ['opinion'] = "";
  5728. $verifyList [$k] ['status'] = "";
  5729. if (empty ( $verifyStaff )) {
  5730. $verifyList [$k] ['date'] = "";
  5731. $verifyList [$k] ['opinion'] = "";
  5732. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5733. $verifyList [$k] ['status'] = 4;
  5734. $flag = false;
  5735. }
  5736. } else {
  5737. foreach ( $verifyStaff as $m => $u ) {
  5738. if ($v [0] == $m) {
  5739. $verifyList [$k] ['date'] = $u ['date'];
  5740. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5741. $verifyList [$k] ['status'] = $u ['status'];
  5742. $flag = false;
  5743. break;
  5744. }
  5745. }
  5746. $endStaffArray = end ( $verifyStaff );
  5747. if (isset ( $endStaffArray ['ROLE'] )) {
  5748. } else {
  5749. // $endKey=key($verifyStaff);
  5750. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5751. // $button=4;
  5752. // $verifyList[$k]['status']=4;
  5753. // }
  5754. }
  5755. }
  5756. }
  5757. $rolename ['name'] = '';
  5758. if (! empty ( $roleId )) {
  5759. Doo::loadModel ( 'role' );
  5760. $role = new role ();
  5761. $rolename = $role->getOne ( array (
  5762. 'where' => 'rid=' . $roleId,
  5763. 'asArray' => true
  5764. ) );
  5765. }
  5766. if (! empty ( $verifyStaff ))
  5767. $endStaffArray = end ( $verifyStaff );
  5768. $KOP = false;
  5769. foreach ( $roleArrayCopy as $P => $A ) {
  5770. foreach ( $A as $MKI => $AVL ) {
  5771. if (! empty ( $verifyStaff )) {
  5772. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5773. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5774. $button = 4;
  5775. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5776. }
  5777. foreach ( $verifyStaff as $m => $u ) {
  5778. $AVLFK = $AVL [0] . '_R';
  5779. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5780. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5781. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5782. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5783. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5784. break;
  5785. }
  5786. }
  5787. } else {
  5788. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5789. $button = 4;
  5790. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5791. }
  5792. }
  5793. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5794. $KOP = true;
  5795. }
  5796. }
  5797. foreach ( $roleArrayCopy as $k => $v ) {
  5798. foreach ( $verifyList as $m => $n ) {
  5799. if ($n [0] == $k) {
  5800. array_splice ( $verifyList, $m, 1, $v );
  5801. }
  5802. }
  5803. }
  5804. $receiptList [$key] ['verifyList'] = $verifyList;
  5805. $receiptList [$key] ['executeList'] = $executeList;
  5806. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5807. 'where' => 'sid=' . $value ['staff'],
  5808. 'asArray' => true
  5809. ) );
  5810. $receiptList [$key] ['button2'] = $button2;
  5811. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5812. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5813. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5814. $receiptList [$key] ['relust'] = $relust;
  5815. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  5816. $receiptList [$key] ['amountABS'] = abs ( $value ['amount'] );
  5817. }
  5818. //执行人是否是最后一位
  5819. $executeCopy = json_decode ( $receiptList [0] ['executeCopy'], true );
  5820. $executeStaff = json_decode ( $receiptList [0] ['executeStaff'], true );
  5821. $executePrimary=count($executeCopy)-1;
  5822. $lastOne=true;
  5823. if($executePrimary!=count($executeStaff)){
  5824. $lastOne=false;
  5825. }
  5826. $data['lastOne']=$lastOne;
  5827. // 是否写入过流水
  5828. $accountType = 0;
  5829. if ($receiptList [0] ['Rtype'] == 0) {
  5830. $accountType = 3;
  5831. } elseif ($receiptList [0] ['Rtype'] == 1) {
  5832. if (!empty($receiptList [0]['accountItem']) )
  5833. $accountType = 2;
  5834. else
  5835. $accountType = 1;
  5836. } elseif ($receiptList [0] ['Rtype'] == 2) {
  5837. $accountType = 4;
  5838. } elseif ($receiptList [0] ['Rtype'] == 3) {
  5839. $accountType = 12;
  5840. }
  5841. Doo::loadModel ( 'wasteBook' );
  5842. $wasteBook = new wasteBook ();
  5843. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $receiptList [0] ['rid'] );
  5844. $data ['wbDetail'] = $wbDetail;
  5845. $wbDetailLoan=array();
  5846. if ($accountType==2){
  5847. $wbDetailLoan = $wasteBook->getWateBookByAD ( 1, $receiptList [0] ['rid'] );
  5848. }
  5849. $data ['wbDetailLoan'] = $wbDetailLoan;
  5850. $data['inputDate']=date ( "Y-m-d H:i:s" );
  5851. //print_r($wbDetail);
  5852. $data ['receiptList'] = $receiptList;
  5853. $data ['memu'] = "receipt";
  5854. $data ['staff'] = $this->staff;
  5855. $data ['receiptMemu'] = 'implement';
  5856. $data ['verifyId'] = $this->verifyId;
  5857. $data ['executeId'] = $this->executeId;
  5858. if ($Rtype=="loan"){
  5859. $this->render ( "/receipt/receiptImplementLoan", $data );
  5860. }elseif($Rtype=="receipt"){
  5861. $this->render ( "/receipt/receiptImplement", $data );
  5862. }elseif($Rtype=="public"){
  5863. $this->render ( "/receipt/receiptImplementPublic", $data );
  5864. }else{
  5865. //$this->render ( "/admin/implement", $data );
  5866. }
  5867. }
  5868. function implementDo() {
  5869. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  5870. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  5871. // $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  5872. // $accountBank = $this->get_args ( 'accountBank' ) ? $this->get_args ( 'accountBank' ) : "";
  5873. // $ab = '';
  5874. // if ($accountBank == 'CGBDeposit')
  5875. // $ab = '纵横广发';
  5876. // elseif ($accountBank == 'ICBCDeposit')
  5877. // $ab = '纵横工行';
  5878. // elseif ($accountBank == 'HUADeposit')
  5879. // $ab = '华润银行';
  5880. // elseif ($accountBank == 'PersonalDeposit')
  5881. // $ab = '个人广发';
  5882. // if (empty ( $ab ))
  5883. // die ( 'illegal request--22' );
  5884. if (! empty ( $rid )) {
  5885. Doo::loadModel ( 'receipt' );
  5886. $receipt = new receipt ();
  5887. Doo::loadClass ( 'XDeode' );
  5888. $XDeode = new XDeode ( 5 );
  5889. $rid=$XDeode->decode($rid);
  5890. if (!is_numeric($rid)){
  5891. die;
  5892. }
  5893. // $rinfo = $receipt->getOne ( array (
  5894. // 'where' => 'rid=' . $rid,
  5895. // 'asArray' => true
  5896. // ) );
  5897. $rinfo = $receipt->getReceiptByRid ( $rid );
  5898. // $accountType = '';
  5899. // if ($rinfo ['Rtype'] == 1) {
  5900. // if ($rinfo ['loanRid'] != 0)//判断有问题
  5901. // $accountType = 2;
  5902. // else
  5903. // $accountType = 1;
  5904. // } elseif ($rinfo ['Rtype'] == 2) {
  5905. // $accountType = 4;
  5906. // } elseif ($rinfo ['Rtype'] == 0)
  5907. // $accountType = 3;
  5908. // if (empty ( $accountType ))
  5909. // die ( 'illegal request' );
  5910. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  5911. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  5912. if (empty ( $executeStaff )) {
  5913. $executeStaff = array (
  5914. $this->staff [0] ['sid'] => array (
  5915. 'date' => date ( 'Y-m-d' ),
  5916. 'opinion' => $implementOpinions,
  5917. 'status' => 1
  5918. )
  5919. );
  5920. } else {
  5921. $executeStaff [$this->staff [0] ['sid']] = array (
  5922. 'date' => date ( 'Y-m-d' ),
  5923. 'opinion' => $implementOpinions,
  5924. 'status' => 1
  5925. );
  5926. }
  5927. if (count ( $executeStaff ) == count ( $executeCopy )) {
  5928. $receipt->executeStaff = json_encode ( $executeStaff );
  5929. $receipt->status = 8;
  5930. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  5931. $receipt->status = 9;
  5932. if ($rinfo ['status'] == 6) {
  5933. $receipt->loanDate = date ( "Y-m-d" );
  5934. }
  5935. $receipt->executeDate = date ( "Y-m-d" );
  5936. } else {
  5937. $receipt->executeStaff = json_encode ( $executeStaff );
  5938. }
  5939. //$receipt->amount = $amount;
  5940. $receipt->update ( array (
  5941. 'where' => 'rid=' . $rid
  5942. ) );
  5943. // 公司流水记录
  5944. // Doo::loadModel ( 'wasteBook' );
  5945. // $wasteBook = new wasteBook ();
  5946. // $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountType, $rid );
  5947. // // 银行
  5948. // if (empty ( $abDetail ) && ! empty ( $amount )) {
  5949. // $item = array (
  5950. // 'dataID' => $rid,
  5951. // 'expensesType' => 2,
  5952. // 'accountType' => $accountType,
  5953. // 'accountPriceShow' => $amount,
  5954. // 'accountPrice' => - $amount,
  5955. // 'accountBank' => $accountBank,
  5956. // 'category' => $rinfo ['category'] [0] ['title'],
  5957. // 'cid' => $rinfo ['category'] [0] ['cid'],
  5958. // 'name' => $rinfo ['staffDetail'] ['username'],
  5959. // 'sid' => $rinfo ['staffDetail'] ['sid'],
  5960. // 'inputDate' => date ( "Y-m-d H:i:s" )
  5961. // );
  5962. // $wasteBook->setAccountBookStatistics ( $item );
  5963. // }
  5964. }
  5965. //$ridKey = $XDeode->encode ( $rid );
  5966. return "/hisImplement";
  5967. // return "/implement/" . $ridKey . ".html";
  5968. }
  5969. function receiptburEdi() {
  5970. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5971. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5972. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5973. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5974. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5975. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5976. if (empty ( $status ))
  5977. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5978. $vidList = array ();
  5979. $button = 0;
  5980. Doo::loadModel ( 'verify' );
  5981. Doo::loadModel ( 'receipt' );
  5982. Doo::loadModel ( 'staff' );
  5983. $staff = new staff ();
  5984. $receipt = new receipt ();
  5985. $verify = new verify ();
  5986. Doo::loadModel ( 'L_category' );
  5987. $Lcategory = new L_category ();
  5988. Doo::loadModel ( 'enclosur' );
  5989. $enclosur = new enclosur ();
  5990. Doo::loadModel ( 'loanReceipt' );
  5991. $loanReceipt = new loanReceipt ();
  5992. // user verify ID
  5993. $verifyDetail = $verify->find ( array (
  5994. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5995. 'asArray' => true
  5996. ) );
  5997. foreach ( $verifyDetail as $key => $value ) {
  5998. array_push ( $vidList, $value ['vid'] );
  5999. }
  6000. $vid = implode ( ",", $vidList );
  6001. if (empty ( $verifyDetail ))
  6002. $vid = 0;
  6003. $categoryList = $Lcategory->find ( array (
  6004. 'asArray' => true
  6005. ) );
  6006. $staffList = $staff->find ( array (
  6007. 'where' => 'cid=' . $cid,
  6008. 'asArray' => true
  6009. ) );
  6010. $ap = "";
  6011. if ($status == 4) {
  6012. $ap = 4;
  6013. $status = 2;
  6014. }
  6015. // get Receipt By verifyID status 2
  6016. $receiptList = $receipt->find ( array (
  6017. 'where' => 'rid =' . $rid . ' and status=2',
  6018. 'desc' => 'rid',
  6019. 'asArray' => true
  6020. ) );
  6021. if (empty ( $receiptList )) {
  6022. die ( 'illegal request' );
  6023. }
  6024. $loanList = $loanReceipt->find ( array (
  6025. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  6026. 'desc' => 'rid',
  6027. 'asArray' => true
  6028. ) );
  6029. $data ['explanation'] = '';
  6030. if (! empty ( $loanList ))
  6031. $data ['explanation'] = $loanList [0] ['explanation'];
  6032. $Locate = 0;
  6033. $roleId = 0;
  6034. $button = 0;
  6035. foreach ( $loanList as $key => $value ) {
  6036. $loanList [$key] ['Locate'] = $Locate;
  6037. $Locate ++;
  6038. $loanList [$key] ['reviseDetail'] = array ();
  6039. if (! empty ( $value ['reviseDetail'] ))
  6040. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6041. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6042. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6043. $categoryDetil = $Lcategory->getOne ( array (
  6044. 'where' => 'cid=' . $value ['cid'],
  6045. 'asArray' => true
  6046. ) );
  6047. $loanList [$key] ['category'] = $categoryDetil ['title'];
  6048. // 检测编辑状态
  6049. $verifyList = $verify->getOne ( array (
  6050. 'where' => 'vid=' . $value ['verify'],
  6051. 'asArray' => true
  6052. ) );
  6053. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6054. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6055. Doo::loadModel ( 'role' );
  6056. $role = new role ();
  6057. $flag = true;
  6058. $roleKey = 0;
  6059. $endStaffArray = array ();
  6060. $roleArrayCopy = array ();
  6061. foreach ( $verifyList as $k => $v ) {
  6062. // init verifyStaff
  6063. if ($v [1] == 'ROLE') {
  6064. if (! empty ( $verifyStaff )) {
  6065. $endStaffArray = end ( $verifyStaff );
  6066. }
  6067. $roleVerify = json_decode ( $v [3], true );
  6068. $roleKey = $k;
  6069. $roleArray = array ();
  6070. $rolename = $role->getOne ( array (
  6071. 'where' => 'rid=' . $v [0],
  6072. 'asArray' => true
  6073. ) );
  6074. foreach ( $roleVerify as $o => $p ) {
  6075. $staffID = explode ( '_', $p );
  6076. $staffInfo = $staff->getOne ( array (
  6077. 'where' => 'sid=' . $staffID [0],
  6078. 'asArray' => true
  6079. ) );
  6080. // print_r($staffID);
  6081. $exp = array (
  6082. 0 => $staffInfo ['sid'],
  6083. 1 => $staffID [1],
  6084. 2 => $staffInfo ['avatar'],
  6085. 'date' => '',
  6086. 'date' => '',
  6087. 'opinion' => '',
  6088. 'status' => '',
  6089. 'rolename' => $rolename ['name']
  6090. );
  6091. array_push ( $roleArray, $exp );
  6092. }
  6093. $roleArrayCopy [$v [0]] = $roleArray;
  6094. // $verifyList[$k]['roleArray']=$roleArray;
  6095. }
  6096. $verifyList [$k] ['date'] = "";
  6097. $verifyList [$k] ['opinion'] = "";
  6098. $verifyList [$k] ['status'] = "";
  6099. if (empty ( $verifyStaff )) {
  6100. $verifyList [$k] ['date'] = "";
  6101. $verifyList [$k] ['opinion'] = "";
  6102. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6103. $verifyList [$k] ['status'] = 4;
  6104. $flag = false;
  6105. }
  6106. } else {
  6107. foreach ( $verifyStaff as $m => $u ) {
  6108. if ($v [0] == $m) {
  6109. $verifyList [$k] ['date'] = $u ['date'];
  6110. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6111. $verifyList [$k] ['status'] = $u ['status'];
  6112. $flag = false;
  6113. break;
  6114. }
  6115. }
  6116. $endStaffArray = end ( $verifyStaff );
  6117. if (isset ( $endStaffArray ['ROLE'] )) {
  6118. } else {
  6119. }
  6120. }
  6121. }
  6122. $rolename ['name'] = '';
  6123. if (! empty ( $roleId )) {
  6124. Doo::loadModel ( 'role' );
  6125. $role = new role ();
  6126. $rolename = $role->getOne ( array (
  6127. 'where' => 'rid=' . $roleId,
  6128. 'asArray' => true
  6129. ) );
  6130. }
  6131. if (! empty ( $verifyStaff ))
  6132. $endStaffArray = end ( $verifyStaff );
  6133. $KOP = false;
  6134. foreach ( $roleArrayCopy as $P => $A ) {
  6135. foreach ( $A as $MKI => $AVL ) {
  6136. if (! empty ( $verifyStaff )) {
  6137. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6138. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6139. $button = 4;
  6140. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6141. }
  6142. foreach ( $verifyStaff as $m => $u ) {
  6143. $AVLFK = $AVL [0] . '_R';
  6144. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6145. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6146. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6147. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6148. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6149. break;
  6150. }
  6151. }
  6152. } else {
  6153. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6154. $button = 4;
  6155. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6156. }
  6157. }
  6158. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6159. $KOP = true;
  6160. }
  6161. }
  6162. foreach ( $roleArrayCopy as $k => $v ) {
  6163. foreach ( $verifyList as $m => $n ) {
  6164. if ($n [0] == $k) {
  6165. array_splice ( $verifyList, $m, 1, $v );
  6166. }
  6167. }
  6168. }
  6169. $loanList [$key] ['verifyList'] = $verifyList;
  6170. }
  6171. $htmlLoan = '';
  6172. $data ['loanReceiptDate'] = '';
  6173. if (isset ( $loanList [0] )) {
  6174. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  6175. if ($value ['status'] == 1)
  6176. $htmlLoan .= '<li class="done" >';
  6177. elseif ($value ['status'] == 3)
  6178. $htmlLoan .= '<li class="undone" >';
  6179. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  6180. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  6181. if (isset ( $value ['rolename'] ))
  6182. $htmlLoan .= $value ['rolename'];
  6183. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  6184. }
  6185. $data ['loanDate'] = $loanList [0] ['date'];
  6186. } else {
  6187. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  6188. }
  6189. $data ['htmlLoan'] = $htmlLoan;
  6190. // $data ['LoanReceipt']=$loanList[0];
  6191. // print_r($loanList);
  6192. $Locate = 0;
  6193. $roleId = 0;
  6194. $button = 0;
  6195. if ($ap == 4)
  6196. $status = 4;
  6197. Doo::loadClass ( 'XDeode' );
  6198. $XDeode = new XDeode ( 5 );
  6199. foreach ( $receiptList as $key => $value ) {
  6200. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  6201. $receiptList [$key] ['Locate'] = $Locate;
  6202. $Locate ++;
  6203. $receiptList [$key] ['reviseDetail'] = array ();
  6204. // 调整金额 代码调整
  6205. if (! empty ( $value ['reviseDetail'] )) {
  6206. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  6207. foreach ( $reviseDetail as $ry => $re ) {
  6208. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  6209. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  6210. }
  6211. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  6212. // print_r($reviseDetail);
  6213. }
  6214. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6215. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6216. $categoryDetil = $Lcategory->getOne ( array (
  6217. 'where' => 'cid=' . $value ['cid'],
  6218. 'asArray' => true
  6219. ) );
  6220. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6221. // 检测编辑状态
  6222. $verifyList = $verify->getOne ( array (
  6223. 'where' => 'vid=' . $value ['verify'],
  6224. 'asArray' => true
  6225. ) );
  6226. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6227. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6228. Doo::loadModel ( 'role' );
  6229. $role = new role ();
  6230. // print_r($verifyList);
  6231. $flag = true;
  6232. $roleKey = 0;
  6233. $endStaffArray = array ();
  6234. $roleArrayCopy = array ();
  6235. foreach ( $verifyList as $k => $v ) {
  6236. // init verifyStaff
  6237. if ($v [1] == 'ROLE') {
  6238. if (! empty ( $verifyStaff )) {
  6239. $endStaffArray = end ( $verifyStaff );
  6240. if ($v [0] == $endStaffArray ['nextStaff']) {
  6241. $roleId = $v [0];
  6242. }
  6243. }
  6244. $roleVerify = json_decode ( $v [3], true );
  6245. $roleKey = $k;
  6246. $roleArray = array ();
  6247. $rolename = $role->getOne ( array (
  6248. 'where' => 'rid=' . $v [0],
  6249. 'asArray' => true
  6250. ) );
  6251. foreach ( $roleVerify as $o => $p ) {
  6252. $staffID = explode ( '_', $p );
  6253. $staffInfo = $staff->getOne ( array (
  6254. 'where' => 'sid=' . $staffID [0],
  6255. 'asArray' => true
  6256. ) );
  6257. // print_r($staffID);
  6258. $exp = array (
  6259. 0 => $staffInfo ['sid'],
  6260. 1 => $staffID [1],
  6261. 2 => $staffInfo ['avatar'],
  6262. 'date' => '',
  6263. 'date' => '',
  6264. 'opinion' => '',
  6265. 'status' => '',
  6266. 'rolename' => $rolename ['name']
  6267. );
  6268. array_push ( $roleArray, $exp );
  6269. }
  6270. $roleArrayCopy [$v [0]] = $roleArray;
  6271. // $verifyList[$k]['roleArray']=$roleArray;
  6272. }
  6273. // print_r($roleArray);
  6274. $verifyList [$k] ['date'] = "";
  6275. $verifyList [$k] ['opinion'] = "";
  6276. $verifyList [$k] ['status'] = "";
  6277. if (empty ( $verifyStaff )) {
  6278. $verifyList [$k] ['date'] = "";
  6279. $verifyList [$k] ['opinion'] = "";
  6280. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6281. $verifyList [$k] ['status'] = 4;
  6282. $button = 4;
  6283. $flag = false;
  6284. }
  6285. } else {
  6286. foreach ( $verifyStaff as $m => $u ) {
  6287. if ($v [0] == $m) {
  6288. $verifyList [$k] ['date'] = $u ['date'];
  6289. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6290. $verifyList [$k] ['status'] = $u ['status'];
  6291. $flag = false;
  6292. break;
  6293. }
  6294. }
  6295. $endStaffArray = end ( $verifyStaff );
  6296. if (isset ( $endStaffArray ['ROLE'] )) {
  6297. } else {
  6298. $endKey = key ( $verifyStaff );
  6299. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6300. $button = 4;
  6301. $verifyList [$k] ['status'] = 4;
  6302. }
  6303. }
  6304. }
  6305. }
  6306. $rolename ['name'] = '';
  6307. if (! empty ( $roleId )) {
  6308. Doo::loadModel ( 'role' );
  6309. $role = new role ();
  6310. $rolename = $role->getOne ( array (
  6311. 'where' => 'rid=' . $roleId,
  6312. 'asArray' => true
  6313. ) );
  6314. }
  6315. if (! empty ( $verifyStaff ))
  6316. $endStaffArray = end ( $verifyStaff );
  6317. $KOP = false;
  6318. foreach ( $roleArrayCopy as $P => $A ) {
  6319. foreach ( $A as $MKI => $AVL ) {
  6320. if (! empty ( $verifyStaff )) {
  6321. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6322. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6323. $button = 4;
  6324. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6325. }
  6326. foreach ( $verifyStaff as $m => $u ) {
  6327. $AVLFK = $AVL [0] . '_R';
  6328. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6329. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6330. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6331. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6332. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6333. break;
  6334. }
  6335. }
  6336. } else {
  6337. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6338. $button = 4;
  6339. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6340. }
  6341. }
  6342. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6343. $KOP = true;
  6344. }
  6345. }
  6346. foreach ( $roleArrayCopy as $k => $v ) {
  6347. foreach ( $verifyList as $m => $n ) {
  6348. if ($n [0] == $k) {
  6349. array_splice ( $verifyList, $m, 1, $v );
  6350. }
  6351. }
  6352. }
  6353. // print_r($verifyList);
  6354. $receiptList [$key] ['verifyList'] = $verifyList;
  6355. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6356. 'where' => 'sid=' . $value ['staff'],
  6357. 'asArray' => true
  6358. ) );
  6359. $receiptList [$key] ['button'] = $button;
  6360. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  6361. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  6362. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  6363. $receiptList [$key] ['relust'] = $relust;
  6364. $receiptList [$key] ['relustABS'] = abs ( $relust );
  6365. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  6366. }
  6367. //print_r($receiptList);die;
  6368. // $data['verifyDetail']=$verifyDetail;
  6369. $mothHtml = "";
  6370. for($i = 1; $i <= 12; $i ++) {
  6371. if ($month == $i)
  6372. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6373. else
  6374. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6375. }
  6376. // 获取审批日志
  6377. Doo::loadModel ( 'receiptLog' );
  6378. $receiptLog = new receiptLog ();
  6379. $rlList = array ();
  6380. $rlInfo = $receiptLog->getOne ( array (
  6381. 'where' => 'rid=' . $rid . ' and status=4',
  6382. 'asArray' => true
  6383. ) );
  6384. $tijdate = $receiptLog->getOne ( array (
  6385. 'where' => 'rid=' . $rid . ' and status=2',
  6386. 'asc' => 'rlid',
  6387. 'asArray' => true
  6388. ) );
  6389. if (! empty ( $rlInfo )) {
  6390. $rlList = $receiptLog->find ( array (
  6391. 'where' => 'rid=' . $rid,
  6392. 'asc' => 'rlid',
  6393. 'asArray' => true
  6394. ) );
  6395. }
  6396. // echo $rid;
  6397. // print_r($receiptList);
  6398. $receiptList [0] ['rlList'] = $rlList;
  6399. // print_r($receiptList);
  6400. $enclosurList = $enclosur->find ( array (
  6401. 'where' => 'rid=' . $rid,
  6402. 'asArray' => true
  6403. ) );
  6404. $enclosurHtml = '';
  6405. foreach ( $enclosurList as $value ) {
  6406. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6407. }
  6408. $data ['enclosurHtml'] = $enclosurHtml;
  6409. $data ['rolename'] = $rolename ['name'];
  6410. $data ['mothHtml'] = $mothHtml;
  6411. // print_r($receiptList);
  6412. $data ['rid'] = $rid;
  6413. $data ['tijdate'] = $tijdate ['date'];
  6414. $data ['receiptList'] = $receiptList;
  6415. $data ['receiptApprovalCount'] = count ( $receiptList );
  6416. $data ['status'] = $status;
  6417. $data ['year'] = $year;
  6418. $data ['categoryList'] = $categoryList;
  6419. $data ['staffList'] = $staffList;
  6420. $data ['cid'] = $cid;
  6421. $data ['sid'] = $sid;
  6422. $data ['ap'] = $ap;
  6423. $data ['memu'] = "receipt";
  6424. $data ['staff'] = $this->staff;
  6425. $data ['receiptMemu'] = 'approvalExpenses';
  6426. $data ['verifyId'] = $this->verifyId;
  6427. $data ['executeId'] = $this->executeId;
  6428. $this->render ( "/admin/receiptburEdi", $data );
  6429. }
  6430. function hisImplement() {
  6431. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  6432. if (empty ( $item ))
  6433. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  6434. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  6435. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6436. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  6437. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6438. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  6439. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  6440. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  6441. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  6442. Doo::loadClass ( 'XDeode' );
  6443. $XDeode = new XDeode ( 5 );
  6444. Doo::loadModel ( 'receipt' );
  6445. $receipt = new receipt ();
  6446. Doo::loadModel ( 'L_category' );
  6447. $Lcategory = new L_category ();
  6448. Doo::loadModel ( 'verify' );
  6449. Doo::loadModel ( 'statistics' );
  6450. $statistics = new statistics ();
  6451. $verify = new verify ();
  6452. Doo::loadModel ( 'staff' );
  6453. $staff = new staff ();
  6454. Doo::loadClass ( 'XDeode' );
  6455. $XDeode = new XDeode ( 5 );
  6456. $XDeode7 = new XDeode ( 7 );
  6457. $cid = $XDeode->decode ( $cidKey );
  6458. $condition = "";
  6459. if ($item == "expenses")
  6460. $condition = " and Rtype=1 ";
  6461. elseif ($item == "receipts")
  6462. $condition = " and Rtype=0 ";
  6463. elseif ($item == "remits")
  6464. $condition = " and Rtype=2 ";
  6465. elseif($item == "train")
  6466. $condition = " and Rtype=3 ";
  6467. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  6468. $sopString = $cidString = "";
  6469. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  6470. if (empty ( $rdate ))
  6471. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  6472. else
  6473. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  6474. if ($status == 'pendImplement') {
  6475. $condition .= ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  6476. } elseif ($status == 'alerpts') {
  6477. $statusCon = '(status=8 or status=9 )';
  6478. if (empty ( $rdate ))
  6479. $dateCondition .= " and Year(date) =" . $year;
  6480. else
  6481. $dateCondition .= " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  6482. }
  6483. if ($sop != 'SOP')
  6484. $sopString = " and staff=" . $sop;
  6485. if ($cidKey != 'ALL')
  6486. $cidString = " and cid=" . $cid;
  6487. //汇款信息需要提取出来
  6488. if(!empty($receiptOrder)){
  6489. $receiptList = $receipt->find ( array (
  6490. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  6491. 'desc' => 'rid',
  6492. 'asArray' => true
  6493. ) );
  6494. // 员工筛选
  6495. $receiptList2 = $receipt->find ( array (
  6496. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  6497. 'desc' => 'rid',
  6498. 'asArray' => true
  6499. ) );
  6500. }else{
  6501. $receiptList = $receipt->find ( array (
  6502. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  6503. 'desc' => 'rid',
  6504. 'asArray' => true
  6505. ) );
  6506. // 员工筛选
  6507. $receiptList2 = $receipt->find ( array (
  6508. 'where' => $statusCon . $condition . $dateCondition,
  6509. 'desc' => 'rid',
  6510. 'asArray' => true
  6511. ) );
  6512. }
  6513. $sopStaff = array ();
  6514. foreach ( $receiptList2 as $key => $value ) {
  6515. $staffDetail = $staff->getOne ( array (
  6516. 'select' => 'username',
  6517. 'where' => 'sid=' . $value ['staff'],
  6518. 'asArray' => true
  6519. ) );
  6520. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  6521. }
  6522. // 办事处筛选
  6523. $categoryScreen = array ();
  6524. $categorList = $Lcategory->getCategory ();
  6525. foreach ( $receiptList2 as $key => $value ) {
  6526. foreach ( $categorList as $k => $v ) {
  6527. if ($value ['cid'] == $v ['cid']) {
  6528. $categoryScreen [$v ['cidKey']] = $v ['title'];
  6529. break;
  6530. }
  6531. }
  6532. }
  6533. $categoryScreenHtml = "";
  6534. foreach ( $categoryScreen as $key => $value ) {
  6535. if ($cidKey == $key)
  6536. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  6537. else
  6538. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  6539. }
  6540. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  6541. $data ['cidKey'] = $cidKey;
  6542. $Locate = 0;
  6543. $roleId = 0;
  6544. $button = 0;
  6545. $staffBatchNumber = 100001;
  6546. $remittanceList = array ();
  6547. foreach ( $receiptList as $key => $value ) {
  6548. $receiptList [$key] ['ridKey7'] = $XDeode7->encode ( $value ['rid'] );
  6549. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  6550. $receiptList [$key] ['Texe'] = 'false';
  6551. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  6552. $receiptList [$key] ['Texe'] = 'true';
  6553. }
  6554. $receiptList [$key] ['TRexe'] = 'true';
  6555. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  6556. $receiptList [$key] ['TRexe'] = 'false';
  6557. }
  6558. $receiptList [$key] ['Locate'] = $Locate;
  6559. $Locate ++;
  6560. $receiptList [$key] ['reviseDetail'] = array ();
  6561. if (! empty ( $value ['reviseDetail'] ))
  6562. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6563. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6564. $categoryDetil = $Lcategory->getOne ( array (
  6565. 'where' => 'cid=' . $value ['cid'],
  6566. 'asArray' => true
  6567. ) );
  6568. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6569. // 检测编辑状态
  6570. $verifyList = $verify->getOne ( array (
  6571. 'where' => 'vid=' . $value ['verify'],
  6572. 'asArray' => true
  6573. ) );
  6574. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6575. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6576. Doo::loadModel ( 'role' );
  6577. $role = new role ();
  6578. $flag = true;
  6579. $roleKey = 0;
  6580. $endStaffArray = array ();
  6581. $roleArrayCopy = array ();
  6582. foreach ( $verifyList as $k => $v ) {
  6583. // init verifyStaff
  6584. if ($v [1] == 'ROLE') {
  6585. if (! empty ( $verifyStaff )) {
  6586. $endStaffArray = end ( $verifyStaff );
  6587. }
  6588. $roleVerify = json_decode ( $v [3], true );
  6589. $roleKey = $k;
  6590. $roleArray = array ();
  6591. $rolename = $role->getOne ( array (
  6592. 'where' => 'rid=' . $v [0],
  6593. 'asArray' => true
  6594. ) );
  6595. foreach ( $roleVerify as $o => $p ) {
  6596. $staffID = explode ( '_', $p );
  6597. $staffInfo = $staff->getOne ( array (
  6598. 'where' => 'sid=' . $staffID [0],
  6599. 'asArray' => true
  6600. ) );
  6601. $exp = array (
  6602. 0 => $staffInfo ['sid'],
  6603. 1 => $staffID [1],
  6604. 2 => $staffInfo ['avatar'],
  6605. 'date' => '',
  6606. 'date' => '',
  6607. 'opinion' => '',
  6608. 'status' => '',
  6609. 'rolename' => $rolename ['name']
  6610. );
  6611. array_push ( $roleArray, $exp );
  6612. }
  6613. $roleArrayCopy [$v [0]] = $roleArray;
  6614. }
  6615. $verifyList [$k] ['date'] = "";
  6616. $verifyList [$k] ['opinion'] = "";
  6617. $verifyList [$k] ['status'] = "";
  6618. if (empty ( $verifyStaff )) {
  6619. $verifyList [$k] ['date'] = "";
  6620. $verifyList [$k] ['opinion'] = "";
  6621. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6622. $verifyList [$k] ['status'] = 4;
  6623. $flag = false;
  6624. }
  6625. } else {
  6626. foreach ( $verifyStaff as $m => $u ) {
  6627. if ($v [0] == $m) {
  6628. $verifyList [$k] ['date'] = $u ['date'];
  6629. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6630. $verifyList [$k] ['status'] = $u ['status'];
  6631. $flag = false;
  6632. break;
  6633. }
  6634. }
  6635. $endStaffArray = end ( $verifyStaff );
  6636. }
  6637. }
  6638. $rolename ['name'] = '';
  6639. if (! empty ( $roleId )) {
  6640. Doo::loadModel ( 'role' );
  6641. $role = new role ();
  6642. $rolename = $role->getOne ( array (
  6643. 'where' => 'rid=' . $roleId,
  6644. 'asArray' => true
  6645. ) );
  6646. }
  6647. if (! empty ( $verifyStaff ))
  6648. $endStaffArray = end ( $verifyStaff );
  6649. $KOP = false;
  6650. foreach ( $roleArrayCopy as $P => $A ) {
  6651. foreach ( $A as $MKI => $AVL ) {
  6652. if (! empty ( $verifyStaff )) {
  6653. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6654. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6655. $button = 4;
  6656. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6657. }
  6658. foreach ( $verifyStaff as $m => $u ) {
  6659. $AVLFK = $AVL [0] . '_R';
  6660. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6661. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6662. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6663. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6664. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6665. break;
  6666. }
  6667. }
  6668. } else {
  6669. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6670. $button = 4;
  6671. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6672. }
  6673. }
  6674. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6675. $KOP = true;
  6676. }
  6677. }
  6678. foreach ( $roleArrayCopy as $k => $v ) {
  6679. foreach ( $verifyList as $m => $n ) {
  6680. if ($n [0] == $k) {
  6681. array_splice ( $verifyList, $m, 1, $v );
  6682. }
  6683. }
  6684. }
  6685. $receiptList [$key] ['verifyList'] = $verifyList;
  6686. $staffDetail = $staff->getOne ( array (
  6687. 'where' => 'sid=' . $value ['staff'],
  6688. 'asArray' => true
  6689. ) );
  6690. $receiptList [$key] ['staffDetail'] = $staffDetail;
  6691. $receiptList [$key] ['button'] = $button;
  6692. if ($value['Rtype']==1){
  6693. $receiptList [$key] ['relust'] = $value['sum']-$value['loanSum'];
  6694. $receiptList [$key] ['relustABS'] = abs($receiptList [$key] ['relust']);
  6695. }elseif($value['Rtype']==3){
  6696. // 收入合计
  6697. Doo::loadModel ( 'invoiceTraining' );
  6698. $invoiceTraining = new invoiceTraining ();
  6699. $invoiceTrainingDetail = array (
  6700. 'invoiceArriveAmount' => '0.00',
  6701. 'RIAmount' => '0.00',
  6702. 'invoiceTotalAmount' => '0.00',
  6703. 'invoiceCompanyAmount' => '0.00',
  6704. 'invoiceArriveAmountM'=>'0.00',
  6705. 'invoiceCompanyAmountM'=>'0.00'
  6706. );
  6707. if ($value ['invoiceTrainId'] != 0) {
  6708. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $value['invoiceTrainId'] );
  6709. }
  6710. $invoiceArriveAmount = $RIAmount = 0;
  6711. if (! empty ( $invoiceTrainingDetail )) {
  6712. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  6713. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  6714. }
  6715. // 备用金
  6716. $sum = 0;
  6717. if (! empty ( $value ['trainLoanRid'] )) {
  6718. $receiptLoanList = $receipt->getReceiptInRid ( $value ['trainLoanRid'] );
  6719. foreach ($receiptLoanList as $kll=>$vll){
  6720. $sum+=$vll['sum'];
  6721. }
  6722. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $value ['trainLoanRid'] );
  6723. // $sum = $receiptLoanDetailBak ['sum'];
  6724. }
  6725. // 支出项金额详情
  6726. // 项目金额合计
  6727. Doo::loadModel ( 'RItem' );
  6728. $RItem = new RItem ();
  6729. Doo::loadModel ( 'accountItem' );
  6730. $accountItem = new accountItem ();
  6731. // 讲师获得
  6732. Doo::loadModel ( 'RILecturer' );
  6733. $RILecturer = new RILecturer ();
  6734. $RItemList = $RItem->getRItemByRid ( $value['rid'] );
  6735. $RILecturerList = $RILecturer->getRILecturerByRid ( $value['rid'] );
  6736. // 支出项金额详情
  6737. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  6738. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  6739. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  6740. $receiptList [$key] ['payment'] =$payment;
  6741. $receiptList [$key] ['paymentABS'] =sprintf("%.2f",abs($payment));
  6742. }
  6743. // 设置导出汇款execl
  6744. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  6745. $remittanceDetail = array (
  6746. $staffBatchNumber,
  6747. $value ['remittanceName'],
  6748. $value ['bankNumber'],
  6749. $value ['bankName'],
  6750. $value ['remittanceBankType'],
  6751. $value ['coupletNumber'],
  6752. $value ['sum']
  6753. );
  6754. array_push ( $remittanceList, $remittanceDetail );
  6755. $staffBatchNumber ++;
  6756. }
  6757. }
  6758. $data ['remittanceList'] = json_encode ( $remittanceList );
  6759. // print_r($receiptList);
  6760. $mothHtml = "";
  6761. for($i = 1; $i <= 12; $i ++) {
  6762. if ($moth == $i)
  6763. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6764. else
  6765. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6766. }
  6767. $dayHtml = "";
  6768. if ($day != "DAY" || $moth != "MONTH") {
  6769. for($i = 1; $i <= 31; $i ++) {
  6770. if ($day == $i)
  6771. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6772. else
  6773. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6774. }
  6775. }
  6776. $sopHtml = "";
  6777. foreach ( $sopStaff as $key => $value ) {
  6778. if ($sop == $key)
  6779. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  6780. else
  6781. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  6782. }
  6783. $data ['status'] = $status;
  6784. $data ['rdate'] = $rdate;
  6785. $data ['sopHtml'] = $sopHtml;
  6786. $data ['dayHtml'] = $dayHtml;
  6787. $data ['mothHtml'] = $mothHtml;
  6788. $data ['receiptList'] = $receiptList;
  6789. $data ['memu'] = "receipt";
  6790. $data ['staff'] = $this->staff;
  6791. $data ['receiptMemu'] = 'implement';
  6792. $data ['verifyId'] = $this->verifyId;
  6793. $data ['executeId'] = $this->executeId;
  6794. $data ['item'] = $item;
  6795. $data ['year'] = $year;
  6796. $data ['moth'] = $moth;
  6797. $data['receiptOrder']=$receiptOrder;
  6798. $data ['day'] = $day;
  6799. $data ['sop'] = $sop;
  6800. $this->render ( "/admin/hisImplement", $data );
  6801. }
  6802. /**
  6803. * 导出汇款信息的exelc
  6804. */
  6805. function exportRemittance() {
  6806. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  6807. if (empty ( $remittanceInfo ))
  6808. die ( 'illegal request' );
  6809. $title = array (
  6810. '员工编号',
  6811. '姓名',
  6812. '员工账号',
  6813. '员工账户开户行',
  6814. '转账类型',
  6815. '联行号',
  6816. '金额'
  6817. );
  6818. $data = json_decode ( $remittanceInfo, true );
  6819. if (empty ( $data ))
  6820. die ( 'illegal request' );
  6821. Doo::loadClass ( 'receipt.func' );
  6822. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  6823. header ( 'Content-Type:text/html;charset=utf-8' );
  6824. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  6825. }
  6826. function ajaxExamine() {
  6827. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6828. Doo::loadModel ( 'receipt' );
  6829. $receipt = new receipt ();
  6830. if (! empty ( $rid )) {
  6831. $rLRes = $receipt->find ( array (
  6832. '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,
  6833. 'asArray' => true
  6834. ) );
  6835. if(!empty($rLRes)){
  6836. Doo::loadClass ( 'XDeode' );
  6837. $XDeode = new XDeode ( 7 );
  6838. $rLRes [0]['ridKey'] = $XDeode->encode( $rLRes [0]['rid'] );
  6839. echo json_encode ( array (
  6840. 'status' => 1,
  6841. 'receipt' => $rLRes [0]
  6842. ) );
  6843. die ();
  6844. }else{
  6845. echo json_encode ( array (
  6846. 'status' => 1,
  6847. 'receipt' => array ()
  6848. ) );
  6849. die ();
  6850. }
  6851. }
  6852. echo json_encode ( array (
  6853. 'status' => 0,
  6854. 'receipt' => array ()
  6855. ) );
  6856. die ();
  6857. }
  6858. /*
  6859. * 废弃
  6860. */
  6861. function myReceipt() {
  6862. // all approval past withdraw
  6863. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  6864. if (empty ( $item ))
  6865. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  6866. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6867. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  6868. Doo::loadModel ( 'receipt' );
  6869. $receipt = new receipt ();
  6870. // pre-loaded
  6871. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  6872. // have cache
  6873. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  6874. if (! empty ( $moth )) // yearPage
  6875. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  6876. $this->showCache ( $path );
  6877. }
  6878. Doo::loadModel ( 'L_category' );
  6879. $Lcategory = new L_category ();
  6880. Doo::loadModel ( 'verify' );
  6881. Doo::loadModel ( 'statistics' );
  6882. $statistics = new statistics ();
  6883. $verify = new verify ();
  6884. Doo::loadModel ( 'staff' );
  6885. $staff = new staff ();
  6886. $condition = " and status!=0 ";
  6887. if ($item == "approval")
  6888. $condition = " and status=2 ";
  6889. elseif ($item == "withdraw")
  6890. $condition = " and status=3 ";
  6891. elseif ($item == "past")
  6892. $condition = " and status=1 ";
  6893. elseif ($item == "whdw")
  6894. $condition = " and status=4 ";
  6895. $dateCondition = " and Year(date) =" . $year;
  6896. if (! empty ( $moth )) {
  6897. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  6898. $stList = $statistics->getOne ( array (
  6899. 'select' => 'rePrice ,agPrice',
  6900. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  6901. 'asArray' => true
  6902. ) );
  6903. } else
  6904. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  6905. if (empty ( $stList ))
  6906. $stList = array (
  6907. 'rePrice' => 0,
  6908. 'agPrice' => 0
  6909. );
  6910. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  6911. $data ['stList'] = array (
  6912. 'rePrice' => $stList ['rePrice'],
  6913. 'agPrice' => $stList ['agPrice'],
  6914. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  6915. );
  6916. $receiptList = $receipt->find ( array (
  6917. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  6918. 'desc' => 'rid',
  6919. 'asArray' => true
  6920. ) );
  6921. $Locate = 0;
  6922. $roleId = 0;
  6923. $button = 0;
  6924. foreach ( $receiptList as $key => $value ) {
  6925. $receiptList [$key] ['Locate'] = $Locate;
  6926. $Locate ++;
  6927. $receiptList [$key] ['reviseDetail'] = array ();
  6928. if (! empty ( $value ['reviseDetail'] ))
  6929. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6930. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6931. $categoryDetil = $Lcategory->getOne ( array (
  6932. 'where' => 'cid=' . $value ['cid'],
  6933. 'asArray' => true
  6934. ) );
  6935. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6936. // 检测编辑状态
  6937. $verifyList = $verify->getOne ( array (
  6938. 'where' => 'vid=' . $value ['verify'],
  6939. 'asArray' => true
  6940. ) );
  6941. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6942. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6943. Doo::loadModel ( 'role' );
  6944. $role = new role ();
  6945. $flag = true;
  6946. $roleKey = 0;
  6947. $endStaffArray = array ();
  6948. $roleArrayCopy = array ();
  6949. foreach ( $verifyList as $k => $v ) {
  6950. // init verifyStaff
  6951. if ($v [1] == 'ROLE') {
  6952. if (! empty ( $verifyStaff )) {
  6953. $endStaffArray = end ( $verifyStaff );
  6954. // if ($v[0]==$endStaffArray['nextStaff']){
  6955. // $roleId=$v[0];
  6956. // }
  6957. }
  6958. $roleVerify = json_decode ( $v [3], true );
  6959. $roleKey = $k;
  6960. $roleArray = array ();
  6961. $rolename = $role->getOne ( array (
  6962. 'where' => 'rid=' . $v [0],
  6963. 'asArray' => true
  6964. ) );
  6965. foreach ( $roleVerify as $o => $p ) {
  6966. $staffID = explode ( '_', $p );
  6967. $staffInfo = $staff->getOne ( array (
  6968. 'where' => 'sid=' . $staffID [0],
  6969. 'asArray' => true
  6970. ) );
  6971. // print_r($staffID);
  6972. $exp = array (
  6973. 0 => $staffInfo ['sid'],
  6974. 1 => $staffID [1],
  6975. 2 => $staffInfo ['avatar'],
  6976. 'date' => '',
  6977. 'date' => '',
  6978. 'opinion' => '',
  6979. 'status' => '',
  6980. 'rolename' => $rolename ['name']
  6981. );
  6982. array_push ( $roleArray, $exp );
  6983. }
  6984. $roleArrayCopy [$v [0]] = $roleArray;
  6985. // $verifyList[$k]['roleArray']=$roleArray;
  6986. }
  6987. $verifyList [$k] ['date'] = "";
  6988. $verifyList [$k] ['opinion'] = "";
  6989. $verifyList [$k] ['status'] = "";
  6990. if (empty ( $verifyStaff )) {
  6991. $verifyList [$k] ['date'] = "";
  6992. $verifyList [$k] ['opinion'] = "";
  6993. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6994. $verifyList [$k] ['status'] = 4;
  6995. $flag = false;
  6996. }
  6997. } else {
  6998. foreach ( $verifyStaff as $m => $u ) {
  6999. if ($v [0] == $m) {
  7000. $verifyList [$k] ['date'] = $u ['date'];
  7001. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7002. $verifyList [$k] ['status'] = $u ['status'];
  7003. $flag = false;
  7004. break;
  7005. }
  7006. }
  7007. $endStaffArray = end ( $verifyStaff );
  7008. if (isset ( $endStaffArray ['ROLE'] )) {
  7009. } else {
  7010. // $endKey=key($verifyStaff);
  7011. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  7012. // $button=4;
  7013. // $verifyList[$k]['status']=4;
  7014. // }
  7015. }
  7016. }
  7017. }
  7018. $rolename ['name'] = '';
  7019. if (! empty ( $roleId )) {
  7020. Doo::loadModel ( 'role' );
  7021. $role = new role ();
  7022. $rolename = $role->getOne ( array (
  7023. 'where' => 'rid=' . $roleId,
  7024. 'asArray' => true
  7025. ) );
  7026. }
  7027. if (! empty ( $verifyStaff ))
  7028. $endStaffArray = end ( $verifyStaff );
  7029. $KOP = false;
  7030. foreach ( $roleArrayCopy as $P => $A ) {
  7031. foreach ( $A as $MKI => $AVL ) {
  7032. if (! empty ( $verifyStaff )) {
  7033. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7034. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7035. $button = 4;
  7036. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7037. }
  7038. foreach ( $verifyStaff as $m => $u ) {
  7039. $AVLFK = $AVL [0] . '_R';
  7040. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7041. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7042. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7043. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7044. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7045. break;
  7046. }
  7047. }
  7048. } else {
  7049. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7050. $button = 4;
  7051. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7052. }
  7053. }
  7054. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7055. $KOP = true;
  7056. }
  7057. }
  7058. foreach ( $roleArrayCopy as $k => $v ) {
  7059. foreach ( $verifyList as $m => $n ) {
  7060. if ($n [0] == $k) {
  7061. array_splice ( $verifyList, $m, 1, $v );
  7062. }
  7063. }
  7064. }
  7065. $receiptList [$key] ['verifyList'] = $verifyList;
  7066. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7067. 'where' => 'sid=' . $value ['staff'],
  7068. 'asArray' => true
  7069. ) );
  7070. $receiptList [$key] ['button'] = $button;
  7071. }
  7072. // print_r($receiptList);die;
  7073. $mothHtml = "";
  7074. for($i = 1; $i <= 12; $i ++) {
  7075. if ($moth == $i)
  7076. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7077. else
  7078. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7079. }
  7080. $data ['mothHtml'] = $mothHtml;
  7081. $data ['receiptList'] = $receiptList;
  7082. $data ['memu'] = "receipt";
  7083. $data ['staff'] = $this->staff;
  7084. $data ['receiptMemu'] = 'receipt';
  7085. $data ['verifyId'] = $this->verifyId;
  7086. $data ['executeId'] = $this->executeId;
  7087. $data ['item'] = $item;
  7088. $data ['year'] = $year;
  7089. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  7090. // sufficient condition to generate cache
  7091. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  7092. $receiptList = $receipt->find ( array (
  7093. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7094. 'asArray' => true
  7095. ) );
  7096. if (empty ( $receiptList )) { // generated files
  7097. ob_start ();
  7098. $this->render ( "/admin/saea_myList", $data );
  7099. $this->cacheFile ( $path );
  7100. die ();
  7101. // $content = ob_get_contents();
  7102. // $fp = fopen($path, "w");
  7103. // fwrite($fp, $content);
  7104. // fclose($fp);
  7105. }
  7106. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  7107. $receiptList = $receipt->find ( array (
  7108. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  7109. 'asArray' => true
  7110. ) );
  7111. if (empty ( $receiptList )) { // generated files
  7112. ob_start ();
  7113. $this->render ( "/admin/saea_myList", $data );
  7114. $this->cacheFile ( $path );
  7115. die ();
  7116. }
  7117. }
  7118. }
  7119. $this->render ( "/admin/saea_myList", $data );
  7120. }
  7121. function approvedReceipt() {
  7122. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7123. Doo::loadModel ( 'receipt' );
  7124. Doo::loadModel ( 'receiptDetail' );
  7125. $receipt = new receipt ();
  7126. $receiptDetail = new receiptDetail ();
  7127. Doo::loadModel ( 'statistics' );
  7128. Doo::loadModel ( 'itemStatistics' );
  7129. $statistics = new statistics ();
  7130. $itemStatistics = new itemStatistics ();
  7131. Doo::loadModel ( "verify" );
  7132. $verify = new verify ();
  7133. // 审批状态的判定
  7134. $receiptDetailList = $receipt->getOne ( array (
  7135. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  7136. 'asArray' => true
  7137. ) );
  7138. if (empty ( $receiptDetailList ))
  7139. return "/saeaBorad";
  7140. $verifyDetail = $verify->getOne ( array (
  7141. 'where' => ' vid =' . $receiptDetailList ['verify'],
  7142. 'asArray' => true
  7143. ) );
  7144. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7145. if (empty ( $receiptDetailList ['nowStaff'] )) {
  7146. $nowStaff = "";
  7147. $nowStaffList = array ();
  7148. if ($verifyDetail [0] [1] == 'ROLE') {
  7149. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7150. foreach ( $vStaffString as $key => $value ) {
  7151. $staffK = explode ( "_", $value );
  7152. array_push ( $nowStaffList, $staffK [0] );
  7153. }
  7154. $nowStaff = implode ( ',', $nowStaffList );
  7155. } else {
  7156. $nowStaff = $verifyDetail [0] [0];
  7157. }
  7158. $receipt->nowStaff = $nowStaff;
  7159. }
  7160. // echo $nowStaff;
  7161. // print_r($verifyDetail);die;
  7162. $receipt->rid = $receiptDetailList ['rid'];
  7163. $receipt->date = date ( "Y-m-d" );
  7164. $receipt->status = 2;
  7165. $receipt->update ();
  7166. $receiptDetail->status = 2;
  7167. $receiptDetail->update ( array (
  7168. 'where' => 'rid=' . $receiptDetailList ['rid']
  7169. ) );
  7170. Doo::loadModel ( "receiptLog" );
  7171. $receiptLog = new receiptLog ();
  7172. Doo::loadModel ( "verify" );
  7173. $verify = new verify ();
  7174. $receiptInfo = $receipt->getOne ( array (
  7175. 'where' => 'rid=' . $rid,
  7176. 'asArray' => true
  7177. ) );
  7178. $vr = $verify->getOne ( array (
  7179. 'where' => 'vid=' . $receiptInfo ['verify'],
  7180. 'asArray' => true
  7181. ) );
  7182. $jd = json_decode ( $vr ['staff'] );
  7183. $roleId = 0;
  7184. foreach ( $jd as $key => $value ) {
  7185. if ($value [1] == 'ROLE') {
  7186. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7187. if ($pos !== false) {
  7188. $roleId = $value [0];
  7189. }
  7190. }
  7191. }
  7192. // 审批日志
  7193. // echo $roleId;die;
  7194. if (! empty ( $roleId )) {
  7195. Doo::loadModel ( "role" );
  7196. $role = new role ();
  7197. $roleInfo = $role->getOne ( array (
  7198. 'where' => 'rid=' . $roleId,
  7199. 'asArray' => true
  7200. ) );
  7201. // $receiptLog->rolename = $roleInfo ['name'];
  7202. }
  7203. $receiptLog->username = $this->staff [0] ['username'];
  7204. $receiptLog->uid = $this->staff [0] ['sid'];
  7205. $receiptLog->date = date ( "Y-m-d" );
  7206. $receiptLog->opinion = '提交审批';
  7207. $receiptLog->img = $this->staff [0] ['avatar'];
  7208. $receiptLog->status = 2;
  7209. $receiptLog->rid = $rid;
  7210. $receiptLog->insert ();
  7211. // statistics item
  7212. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  7213. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7214. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  7215. $stat = $statistics->getOne ( array (
  7216. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7217. 'asArray' => true
  7218. ) );
  7219. if (empty ( $stat )) {
  7220. $statistics->date = date ( "Y-m-d" );
  7221. $statistics->cid = $this->staff [0] ['cid'];
  7222. $statistics->staff = $this->staff [0] ['sid'];
  7223. $statistics->agPrice = 0;
  7224. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7225. $statistics->insert ();
  7226. } else {
  7227. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7228. $statistics->update ( array (
  7229. 'where' => 'sid=' . $stat ['sid']
  7230. ) );
  7231. }
  7232. return "/expenses";
  7233. }
  7234. function approval() {
  7235. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7236. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7237. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7238. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7239. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7240. if (empty ( $status ))
  7241. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7242. $vidList = array ();
  7243. $button = 0;
  7244. Doo::loadModel ( 'verify' );
  7245. $verify = new verify ();
  7246. Doo::loadModel ( 'receipt' );
  7247. $receipt = new receipt ();
  7248. Doo::loadModel ( 'staff' );
  7249. $staff = new staff ();
  7250. Doo::loadModel ( 'L_category' );
  7251. $Lcategory = new L_category ();
  7252. // user verify ID
  7253. $verifyDetail = $verify->find ( array (
  7254. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7255. 'asArray' => true
  7256. ) );
  7257. foreach ( $verifyDetail as $key => $value ) {
  7258. array_push ( $vidList, $value ['vid'] );
  7259. }
  7260. $vid = implode ( ",", $vidList );
  7261. if (empty ( $verifyDetail ))
  7262. $vid = 0;
  7263. /*
  7264. */
  7265. $dateCondition = " and Year(date) =" . $year;
  7266. if (! empty ( $month ))
  7267. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  7268. $categoryList = $Lcategory->find ( array (
  7269. 'asArray' => true
  7270. ) );
  7271. $staffList = $staff->find ( array (
  7272. 'where' => 'cid=' . $cid,
  7273. 'asArray' => true
  7274. ) );
  7275. $cateCondition = "";
  7276. $staffCondition = "";
  7277. $approvalCondition = "";
  7278. if (! empty ( $cid ))
  7279. $cateCondition = ' and cid=' . $cid;
  7280. if (! empty ( $sid )) {
  7281. $staffCondition = ' and staff=' . $sid;
  7282. $cateCondition = "";
  7283. }
  7284. // elseif($status==1){
  7285. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  7286. // }
  7287. if ($status == 2) {
  7288. // 查找角色审批人
  7289. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  7290. }
  7291. $ap = "";
  7292. if ($status == 4) {
  7293. $ap = 4;
  7294. $status = 2;
  7295. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  7296. }
  7297. if ($status == 5) {
  7298. $status = 4;
  7299. $ap = 5;
  7300. }
  7301. // echo $vid;
  7302. // get Receipt By verifyID status 2 .$approvalCondition
  7303. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  7304. $receiptList = $receipt->find ( array (
  7305. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  7306. 'desc' => 'rid',
  7307. 'asArray' => true
  7308. ) );
  7309. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  7310. $Locate = 0;
  7311. if ($ap == 4)
  7312. $status = 4;
  7313. elseif ($ap == 5)
  7314. $status = 5;
  7315. foreach ( $receiptList as $key => $value ) {
  7316. $receiptList [$key] ['Locate'] = $Locate;
  7317. $Locate ++;
  7318. $receiptList [$key] ['reviseDetail'] = array ();
  7319. if (! empty ( $value ['reviseDetail'] ))
  7320. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7321. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7322. $categoryDetil = $Lcategory->getOne ( array (
  7323. 'where' => 'cid=' . $value ['cid'],
  7324. 'asArray' => true
  7325. ) );
  7326. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7327. $verifyList = $verify->getOne ( array (
  7328. 'where' => 'vid=' . $value ['verify'],
  7329. 'asArray' => true
  7330. ) );
  7331. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7332. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7333. foreach ( $verifyList as $k => $v ) {
  7334. // init verifyStaff
  7335. $verifyList [$k] ['date'] = "";
  7336. $verifyList [$k] ['opinion'] = "";
  7337. $verifyList [$k] ['status'] = "";
  7338. if (empty ( $verifyStaff )) {
  7339. $verifyList [$k] ['date'] = "";
  7340. $verifyList [$k] ['opinion'] = "";
  7341. if ($v [0] == $this->staff [0] ['sid']) {
  7342. $verifyList [$k] ['status'] = 4;
  7343. $button = 4;
  7344. }
  7345. } else {
  7346. $flag = true;
  7347. foreach ( $verifyStaff as $m => $u ) {
  7348. if ($v [0] == $m) {
  7349. $verifyList [$k] ['date'] = $u ['date'];
  7350. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7351. $verifyList [$k] ['status'] = $u ['status'];
  7352. $flag = false;
  7353. break;
  7354. }
  7355. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  7356. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  7357. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  7358. }
  7359. if ($flag) { // 检测可编辑
  7360. if ($v [0] == $this->staff [0] ['sid']) {
  7361. $verifyList [$k] ['status'] = 4;
  7362. $button = 4;
  7363. }
  7364. }
  7365. }
  7366. }
  7367. $receiptList [$key] ['verifyList'] = $verifyList;
  7368. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7369. 'where' => 'sid=' . $value ['staff'],
  7370. 'asArray' => true
  7371. ) );
  7372. $receiptList [$key] ['button'] = $button;
  7373. }
  7374. // print_r($receiptList);die;
  7375. // $data['verifyDetail']=$verifyDetail;
  7376. $mothHtml = "";
  7377. for($i = 1; $i <= 12; $i ++) {
  7378. if ($month == $i)
  7379. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7380. else
  7381. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7382. }
  7383. $data ['mothHtml'] = $mothHtml;
  7384. $data ['receiptList'] = $receiptList;
  7385. $data ['receiptApprovalCount'] = count ( $receiptList );
  7386. $data ['status'] = $status;
  7387. $data ['year'] = $year;
  7388. $data ['categoryList'] = $categoryList;
  7389. $data ['staffList'] = $staffList;
  7390. $data ['cid'] = $cid;
  7391. $data ['sid'] = $sid;
  7392. $data ['ap'] = $ap;
  7393. $data ['memu'] = "receipt";
  7394. $data ['staff'] = $this->staff;
  7395. $data ['receiptMemu'] = 'approval';
  7396. $data ['verifyId'] = $this->verifyId;
  7397. $data ['executeId'] = $this->executeId;
  7398. $this->render ( "/admin/saea_reportList", $data );
  7399. }
  7400. function approvalDetails() {
  7401. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7402. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7403. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7404. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7405. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7406. Doo::loadModel ( 'verify' );
  7407. $verify = new verify ();
  7408. Doo::loadModel ( 'receipt' );
  7409. $receipt = new receipt ();
  7410. Doo::loadModel ( 'staff' );
  7411. $staff = new staff ();
  7412. Doo::loadModel ( 'L_category' );
  7413. $Lcategory = new L_category ();
  7414. Doo::loadModel ( 'enclosur' );
  7415. $enclosur = new enclosur ();
  7416. $vidList = array ();
  7417. $verifyDetail = $verify->find ( array (
  7418. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7419. 'asArray' => true
  7420. ) );
  7421. foreach ( $verifyDetail as $key => $value ) {
  7422. array_push ( $vidList, $value ['vid'] );
  7423. }
  7424. $vid = implode ( ",", $vidList );
  7425. if (empty ( $verifyDetail ))
  7426. $vid = 0;
  7427. $categoryList = $Lcategory->find ( array (
  7428. 'asArray' => true
  7429. ) );
  7430. $staffList = $staff->find ( array (
  7431. 'where' => 'cid=' . $cid,
  7432. 'asArray' => true
  7433. ) );
  7434. $ap = 0;
  7435. $receiptList = $receipt->find ( array (
  7436. 'where' => 'rid =' . $rid,
  7437. 'desc' => 'rid',
  7438. 'asArray' => true
  7439. ) );
  7440. $Locate = 0;
  7441. $roleId = 0;
  7442. $button = 0;
  7443. foreach ( $receiptList as $key => $value ) {
  7444. $receiptList [$key] ['Locate'] = $Locate;
  7445. $Locate ++;
  7446. $receiptList [$key] ['reviseDetail'] = array ();
  7447. if (! empty ( $value ['reviseDetail'] ))
  7448. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7449. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7450. $categoryDetil = $Lcategory->getOne ( array (
  7451. 'where' => 'cid=' . $value ['cid'],
  7452. 'asArray' => true
  7453. ) );
  7454. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7455. // 检测编辑状态
  7456. $verifyList = $verify->getOne ( array (
  7457. 'where' => 'vid=' . $value ['verify'],
  7458. 'asArray' => true
  7459. ) );
  7460. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7461. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7462. Doo::loadModel ( 'role' );
  7463. $role = new role ();
  7464. // print_r($verifyList);
  7465. $flag = true;
  7466. $roleKey = 0;
  7467. $endStaffArray = array ();
  7468. $roleArrayCopy = array ();
  7469. foreach ( $verifyList as $k => $v ) {
  7470. // init verifyStaff
  7471. if ($v [1] == 'ROLE') {
  7472. if (! empty ( $verifyStaff )) {
  7473. $endStaffArray = end ( $verifyStaff );
  7474. if ($v [0] == $endStaffArray ['nextStaff']) {
  7475. $roleId = $v [0];
  7476. }
  7477. }
  7478. $roleVerify = json_decode ( $v [3], true );
  7479. $roleKey = $k;
  7480. $roleArray = array ();
  7481. $rolename = $role->getOne ( array (
  7482. 'where' => 'rid=' . $v [0],
  7483. 'asArray' => true
  7484. ) );
  7485. foreach ( $roleVerify as $o => $p ) {
  7486. $staffID = explode ( '_', $p );
  7487. $staffInfo = $staff->getOne ( array (
  7488. 'where' => 'sid=' . $staffID [0],
  7489. 'asArray' => true
  7490. ) );
  7491. // print_r($staffID);
  7492. $exp = array (
  7493. 0 => $staffInfo ['sid'],
  7494. 1 => $staffID [1],
  7495. 2 => $staffInfo ['avatar'],
  7496. 'date' => '',
  7497. 'date' => '',
  7498. 'opinion' => '',
  7499. 'status' => '',
  7500. 'rolename' => $rolename ['name']
  7501. );
  7502. array_push ( $roleArray, $exp );
  7503. }
  7504. $roleArrayCopy [$v [0]] = $roleArray;
  7505. // $verifyList[$k]['roleArray']=$roleArray;
  7506. }
  7507. // print_r($roleArray);
  7508. $verifyList [$k] ['date'] = "";
  7509. $verifyList [$k] ['opinion'] = "";
  7510. $verifyList [$k] ['status'] = "";
  7511. if (empty ( $verifyStaff )) {
  7512. $verifyList [$k] ['date'] = "";
  7513. $verifyList [$k] ['opinion'] = "";
  7514. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7515. $verifyList [$k] ['status'] = 4;
  7516. $button = 4;
  7517. $flag = false;
  7518. }
  7519. } else {
  7520. foreach ( $verifyStaff as $m => $u ) {
  7521. if ($v [0] == $m) {
  7522. $verifyList [$k] ['date'] = $u ['date'];
  7523. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7524. $verifyList [$k] ['status'] = $u ['status'];
  7525. $flag = false;
  7526. break;
  7527. }
  7528. }
  7529. $endStaffArray = end ( $verifyStaff );
  7530. if (isset ( $endStaffArray ['ROLE'] )) {
  7531. } else {
  7532. $endKey = key ( $verifyStaff );
  7533. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7534. $button = 4;
  7535. $verifyList [$k] ['status'] = 4;
  7536. }
  7537. }
  7538. }
  7539. }
  7540. $rolename ['name'] = '';
  7541. if (! empty ( $roleId )) {
  7542. Doo::loadModel ( 'role' );
  7543. $role = new role ();
  7544. $rolename = $role->getOne ( array (
  7545. 'where' => 'rid=' . $roleId,
  7546. 'asArray' => true
  7547. ) );
  7548. }
  7549. if (! empty ( $verifyStaff ))
  7550. $endStaffArray = end ( $verifyStaff );
  7551. $KOP = false;
  7552. foreach ( $roleArrayCopy as $P => $A ) {
  7553. foreach ( $A as $MKI => $AVL ) {
  7554. if (! empty ( $verifyStaff )) {
  7555. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7556. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7557. $button = 4;
  7558. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7559. }
  7560. foreach ( $verifyStaff as $m => $u ) {
  7561. $AVLFK = $AVL [0] . '_R';
  7562. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7563. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7564. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7565. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7566. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7567. break;
  7568. }
  7569. }
  7570. } else {
  7571. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7572. $button = 4;
  7573. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7574. }
  7575. }
  7576. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7577. $KOP = true;
  7578. }
  7579. }
  7580. foreach ( $roleArrayCopy as $k => $v ) {
  7581. foreach ( $verifyList as $m => $n ) {
  7582. if ($n [0] == $k) {
  7583. array_splice ( $verifyList, $m, 1, $v );
  7584. }
  7585. }
  7586. }
  7587. $receiptList [$key] ['verifyList'] = $verifyList;
  7588. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7589. 'where' => 'sid=' . $value ['staff'],
  7590. 'asArray' => true
  7591. ) );
  7592. $receiptList [$key] ['button'] = $button;
  7593. }
  7594. $mothHtml = "";
  7595. for($i = 1; $i <= 12; $i ++) {
  7596. if ($month == $i)
  7597. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7598. else
  7599. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7600. }
  7601. // 获取审批日志
  7602. Doo::loadModel ( 'receiptLog' );
  7603. $receiptLog = new receiptLog ();
  7604. $rlList = array ();
  7605. $rlInfo = $receiptLog->getOne ( array (
  7606. 'where' => 'rid=' . $rid . ' and status=4',
  7607. 'asArray' => true
  7608. ) );
  7609. $tijdate = $receiptLog->getOne ( array (
  7610. 'where' => 'rid=' . $rid . ' and status=2',
  7611. 'asc' => 'rlid',
  7612. 'asArray' => true
  7613. ) );
  7614. if (! empty ( $rlInfo )) {
  7615. $rlList = $receiptLog->find ( array (
  7616. 'where' => 'rid=' . $rid,
  7617. 'asc' => 'rlid',
  7618. 'asArray' => true
  7619. ) );
  7620. }
  7621. $receiptList [0] ['rlList'] = $rlList;
  7622. $enclosurList = $enclosur->find ( array (
  7623. 'where' => 'rid=' . $rid,
  7624. 'asArray' => true
  7625. ) );
  7626. $enclosurHtml = '';
  7627. foreach ( $enclosurList as $value ) {
  7628. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  7629. }
  7630. $data ['enclosurHtml'] = $enclosurHtml;
  7631. $data ['rolename'] = $rolename ['name'];
  7632. $data ['datetij'] = $tijdate ['date'];
  7633. $data ['mothHtml'] = $mothHtml;
  7634. $data ['receiptList'] = $receiptList;
  7635. $data ['receiptApprovalCount'] = count ( $receiptList );
  7636. $data ['year'] = $year;
  7637. $data ['categoryList'] = $categoryList;
  7638. $data ['staffList'] = $staffList;
  7639. $data ['cid'] = $cid;
  7640. $data ['sid'] = $sid;
  7641. $data ['status'] = 0;
  7642. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  7643. $ap = 4;
  7644. } else
  7645. $data ['status'] = $receiptList [0] ['status'];
  7646. if ($receiptList [0] ['status'] == 4) {
  7647. $data ['status'] = 5;
  7648. $ap = 0;
  7649. }
  7650. $data ['ap'] = $ap;
  7651. $data ['memu'] = "receipt";
  7652. $data ['staff'] = $this->staff;
  7653. $data ['receiptMemu'] = 'approval';
  7654. $data ['verifyId'] = $this->verifyId;
  7655. $data ['executeId'] = $this->executeId;
  7656. $this->render ( "/admin/saeaReportListReport", $data );
  7657. }
  7658. function approvalEdi() {
  7659. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7660. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7661. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7662. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7663. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7664. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7665. if (empty ( $status ))
  7666. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7667. $vidList = array ();
  7668. $button = 0;
  7669. Doo::loadModel ( 'verify' );
  7670. Doo::loadModel ( 'receipt' );
  7671. Doo::loadModel ( 'staff' );
  7672. $staff = new staff ();
  7673. $receipt = new receipt ();
  7674. $verify = new verify ();
  7675. Doo::loadModel ( 'L_category' );
  7676. $Lcategory = new L_category ();
  7677. Doo::loadModel ( 'enclosur' );
  7678. $enclosur = new enclosur ();
  7679. // user verify ID
  7680. $verifyDetail = $verify->find ( array (
  7681. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7682. 'asArray' => true
  7683. ) );
  7684. foreach ( $verifyDetail as $key => $value ) {
  7685. array_push ( $vidList, $value ['vid'] );
  7686. }
  7687. $vid = implode ( ",", $vidList );
  7688. if (empty ( $verifyDetail ))
  7689. $vid = 0;
  7690. $categoryList = $Lcategory->find ( array (
  7691. 'asArray' => true
  7692. ) );
  7693. $staffList = $staff->find ( array (
  7694. 'where' => 'cid=' . $cid,
  7695. 'asArray' => true
  7696. ) );
  7697. $ap = "";
  7698. if ($status == 4) {
  7699. $ap = 4;
  7700. $status = 2;
  7701. }
  7702. // get Receipt By verifyID status 2
  7703. $receiptList = $receipt->find ( array (
  7704. 'where' => 'rid =' . $rid,
  7705. 'desc' => 'rid',
  7706. 'asArray' => true
  7707. ) );
  7708. $Locate = 0;
  7709. $roleId = 0;
  7710. if ($ap == 4)
  7711. $status = 4;
  7712. foreach ( $receiptList as $key => $value ) {
  7713. $receiptList [$key] ['Locate'] = $Locate;
  7714. $Locate ++;
  7715. $receiptList [$key] ['reviseDetail'] = array ();
  7716. if (! empty ( $value ['reviseDetail'] ))
  7717. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7718. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7719. $categoryDetil = $Lcategory->getOne ( array (
  7720. 'where' => 'cid=' . $value ['cid'],
  7721. 'asArray' => true
  7722. ) );
  7723. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7724. // 检测编辑状态
  7725. $verifyList = $verify->getOne ( array (
  7726. 'where' => 'vid=' . $value ['verify'],
  7727. 'asArray' => true
  7728. ) );
  7729. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7730. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7731. // print_r($verifyList);
  7732. //
  7733. // if (empty($verifyStaff)){
  7734. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  7735. // $verifyList[0]['status']=4;$button=4;
  7736. // }
  7737. //
  7738. // }else{
  7739. //
  7740. // }
  7741. // die;
  7742. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  7743. // echo array_search("green",$a);
  7744. //
  7745. Doo::loadModel ( 'role' );
  7746. $role = new role ();
  7747. // print_r($verifyList);
  7748. $flag = true;
  7749. $roleKey = 0;
  7750. $endStaffArray = array ();
  7751. $roleArrayCopy = array ();
  7752. foreach ( $verifyList as $k => $v ) {
  7753. // init verifyStaff
  7754. if ($v [1] == 'ROLE') {
  7755. if (! empty ( $verifyStaff )) {
  7756. $endStaffArray = end ( $verifyStaff );
  7757. if ($v [0] == $endStaffArray ['nextStaff']) {
  7758. $roleId = $v [0];
  7759. }
  7760. }
  7761. $roleVerify = json_decode ( $v [3], true );
  7762. $roleKey = $k;
  7763. $roleArray = array ();
  7764. $rolename = $role->getOne ( array (
  7765. 'where' => 'rid=' . $v [0],
  7766. 'asArray' => true
  7767. ) );
  7768. foreach ( $roleVerify as $o => $p ) {
  7769. $staffID = explode ( '_', $p );
  7770. $staffInfo = $staff->getOne ( array (
  7771. 'where' => 'sid=' . $staffID [0],
  7772. 'asArray' => true
  7773. ) );
  7774. // print_r($staffID);
  7775. $exp = array (
  7776. 0 => $staffInfo ['sid'],
  7777. 1 => $staffID [1],
  7778. 2 => $staffInfo ['avatar'],
  7779. 'date' => '',
  7780. 'date' => '',
  7781. 'opinion' => '',
  7782. 'status' => '',
  7783. 'rolename' => $rolename ['name']
  7784. );
  7785. array_push ( $roleArray, $exp );
  7786. }
  7787. $roleArrayCopy [$v [0]] = $roleArray;
  7788. // $verifyList[$k]['roleArray']=$roleArray;
  7789. }
  7790. // print_r($roleArray);
  7791. $verifyList [$k] ['date'] = "";
  7792. $verifyList [$k] ['opinion'] = "";
  7793. $verifyList [$k] ['status'] = "";
  7794. if (empty ( $verifyStaff )) {
  7795. $verifyList [$k] ['date'] = "";
  7796. $verifyList [$k] ['opinion'] = "";
  7797. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7798. $verifyList [$k] ['status'] = 4;
  7799. $button = 4;
  7800. $flag = false;
  7801. }
  7802. } else {
  7803. foreach ( $verifyStaff as $m => $u ) {
  7804. if ($v [0] == $m) {
  7805. $verifyList [$k] ['date'] = $u ['date'];
  7806. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7807. $verifyList [$k] ['status'] = $u ['status'];
  7808. $flag = false;
  7809. break;
  7810. }
  7811. }
  7812. $endStaffArray = end ( $verifyStaff );
  7813. if (isset ( $endStaffArray ['ROLE'] )) {
  7814. } else {
  7815. $endKey = key ( $verifyStaff );
  7816. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7817. $button = 4;
  7818. $verifyList [$k] ['status'] = 4;
  7819. }
  7820. }
  7821. // print_r($endStaffArray);die;
  7822. // if (empty($verifyStaff)){
  7823. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  7824. // $verifyList[$k]['status']=4;$button=4;
  7825. // }
  7826. //
  7827. // }else{
  7828. //
  7829. // }
  7830. // if($flag){//检测可编辑
  7831. // if($v[0]==$this->staff[0]['sid']){
  7832. // $verifyList[$k]['status']=4;$button=4;
  7833. // }
  7834. // }
  7835. }
  7836. }
  7837. $rolename ['name'] = '';
  7838. if (! empty ( $roleId )) {
  7839. Doo::loadModel ( 'role' );
  7840. $role = new role ();
  7841. $rolename = $role->getOne ( array (
  7842. 'where' => 'rid=' . $roleId,
  7843. 'asArray' => true
  7844. ) );
  7845. }
  7846. if (! empty ( $verifyStaff ))
  7847. $endStaffArray = end ( $verifyStaff );
  7848. $KOP = false;
  7849. foreach ( $roleArrayCopy as $P => $A ) {
  7850. foreach ( $A as $MKI => $AVL ) {
  7851. if (! empty ( $verifyStaff )) {
  7852. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7853. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7854. $button = 4;
  7855. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7856. }
  7857. foreach ( $verifyStaff as $m => $u ) {
  7858. $AVLFK = $AVL [0] . '_R';
  7859. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7860. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7861. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7862. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7863. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7864. break;
  7865. }
  7866. }
  7867. } else {
  7868. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7869. $button = 4;
  7870. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7871. }
  7872. }
  7873. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7874. $KOP = true;
  7875. }
  7876. }
  7877. // print_r($roleArrayCopy);
  7878. // echo $roleKey;
  7879. foreach ( $roleArrayCopy as $k => $v ) {
  7880. foreach ( $verifyList as $m => $n ) {
  7881. if ($n [0] == $k) {
  7882. array_splice ( $verifyList, $m, 1, $v );
  7883. }
  7884. }
  7885. }
  7886. // if ($KOP)
  7887. // array_splice($verifyList,$roleKey,1,$roleArray);
  7888. // print_r($verifyList);
  7889. $receiptList [$key] ['verifyList'] = $verifyList;
  7890. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7891. 'where' => 'sid=' . $value ['staff'],
  7892. 'asArray' => true
  7893. ) );
  7894. $receiptList [$key] ['button'] = $button;
  7895. }
  7896. // $data['verifyDetail']=$verifyDetail;
  7897. $mothHtml = "";
  7898. for($i = 1; $i <= 12; $i ++) {
  7899. if ($month == $i)
  7900. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7901. else
  7902. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7903. }
  7904. // 获取审批日志
  7905. Doo::loadModel ( 'receiptLog' );
  7906. $receiptLog = new receiptLog ();
  7907. $rlList = array ();
  7908. $rlInfo = $receiptLog->getOne ( array (
  7909. 'where' => 'rid=' . $rid . ' and status=4',
  7910. 'asArray' => true
  7911. ) );
  7912. $tijdate = $receiptLog->getOne ( array (
  7913. 'where' => 'rid=' . $rid . ' and status=2',
  7914. 'asc' => 'rlid',
  7915. 'asArray' => true
  7916. ) );
  7917. if (! empty ( $rlInfo )) {
  7918. $rlList = $receiptLog->find ( array (
  7919. 'where' => 'rid=' . $rid,
  7920. 'asc' => 'rlid',
  7921. 'asArray' => true
  7922. ) );
  7923. }
  7924. $receiptList [0] ['rlList'] = $rlList;
  7925. $enclosurList = $enclosur->find ( array (
  7926. 'where' => 'rid=' . $rid,
  7927. 'asArray' => true
  7928. ) );
  7929. $enclosurHtml = '';
  7930. foreach ( $enclosurList as $value ) {
  7931. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  7932. }
  7933. $data ['enclosurHtml'] = $enclosurHtml;
  7934. $data ['rolename'] = $rolename ['name'];
  7935. $data ['datetij'] = $tijdate ['date'];
  7936. $data ['mothHtml'] = $mothHtml;
  7937. $data ['receiptList'] = $receiptList;
  7938. $data ['receiptApprovalCount'] = count ( $receiptList );
  7939. $data ['status'] = $status;
  7940. $data ['year'] = $year;
  7941. $data ['categoryList'] = $categoryList;
  7942. $data ['staffList'] = $staffList;
  7943. $data ['cid'] = $cid;
  7944. $data ['sid'] = $sid;
  7945. $data ['ap'] = $ap;
  7946. $data ['memu'] = "receipt";
  7947. $data ['staff'] = $this->staff;
  7948. $data ['receiptMemu'] = 'approval';
  7949. $data ['verifyId'] = $this->verifyId;
  7950. $data ['executeId'] = $this->executeId;
  7951. $this->render ( "/admin/saeaReportListReport", $data );
  7952. }
  7953. function remittanceHky() {
  7954. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7955. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  7956. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  7957. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  7958. $page_size = 15;
  7959. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  7960. Doo::loadModel ( 'receipt' );
  7961. $receipt = new receipt ();
  7962. Doo::loadModel ( 'staff' );
  7963. $staff = new staff ();
  7964. $dateCondition = " and Year(executeDate) =" . $year;
  7965. if ($moth != 'MONTH')
  7966. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  7967. if ($day != 'DAY' && $moth != 'MONTH')
  7968. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  7969. $sql = ' (status =8 or status=9 ) and amount>0 ' . $dateCondition;
  7970. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  7971. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  7972. $limit = $pageinfo ['lower'] . ',' . $page_size;
  7973. $dayList = $receipt->find ( array (
  7974. 'select' => 'executeDate,sum(amount) as amount',
  7975. 'where' => $sql,
  7976. 'desc' => 'executeDate',
  7977. 'groupby' => 'executeDate',
  7978. 'limit' => $limit,
  7979. 'asArray' => true
  7980. ) );
  7981. // print_r($dayList);
  7982. foreach ( $dayList as $key => $value ) {
  7983. $remitString = "";
  7984. $receiptList = $receipt->find ( array (
  7985. 'select' => 'rid,executeDate,amount,staff,cid',
  7986. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  7987. 'desc' => 'executeDate',
  7988. 'asArray' => true
  7989. ) );
  7990. foreach ( $receiptList as $k => $v ) {
  7991. $sinfo = $staff->getOne ( array (
  7992. 'select' => 'username,category',
  7993. 'where' => ' sid=' . $v ['staff'],
  7994. 'asArray' => true
  7995. ) );
  7996. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  7997. }
  7998. $dayList [$key] ['staff'] = $remitString;
  7999. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  8000. }
  8001. // print_r($dayList);
  8002. $mothHtml = "";
  8003. for($i = 1; $i <= 12; $i ++) {
  8004. if ($moth == $i)
  8005. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8006. else
  8007. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8008. }
  8009. $dayHtml = "";
  8010. if ($day != "DAY" || $moth != "MONTH") {
  8011. for($i = 1; $i <= 31; $i ++) {
  8012. if ($day == $i)
  8013. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  8014. else
  8015. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  8016. }
  8017. }
  8018. $dateHtml = "";
  8019. $now = date ( "Y" );
  8020. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  8021. if ($YEARD <= $now) {
  8022. $dateHtml .= '<option ';
  8023. if ($year == $YEARD) {
  8024. $dateHtml .= 'selected ';
  8025. }
  8026. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  8027. }
  8028. }
  8029. $data ['dateHtml'] = $dateHtml;
  8030. $data ['page'] = $pageinfo;
  8031. $data ['year'] = $year;
  8032. $data ['moth'] = $moth;
  8033. $data ['day'] = $day;
  8034. $data ['get'] = $get;
  8035. $data ['dayHtml'] = $dayHtml;
  8036. $data ['mothHtml'] = $mothHtml;
  8037. $data ['receiptList'] = $dayList;
  8038. $data ['memu'] = "receipt";
  8039. $data ['staff'] = $this->staff;
  8040. $data ['receiptMemu'] = 'remittanceHky';
  8041. $data ['verifyId'] = $this->verifyId;
  8042. $data ['executeId'] = $this->executeId;
  8043. $this->render ( "/admin/remittanceHky", $data );
  8044. }
  8045. function remittancep() {
  8046. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  8047. Doo::loadModel ( 'receipt' );
  8048. $receipt = new receipt ();
  8049. Doo::loadModel ( 'staff' );
  8050. $staff = new staff ();
  8051. Doo::loadClass ( 'XDeode' );
  8052. $XDeode = new XDeode ( 5 );
  8053. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  8054. $rplist = $receipt->find ( array (
  8055. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8056. 'asArray' => true
  8057. ) );
  8058. $dayList = $receipt->find ( array (
  8059. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8060. 'desc' => 'executeDate',
  8061. 'groupby' => 'staff',
  8062. 'asArray' => true
  8063. ) );
  8064. $html = '';
  8065. foreach ( $dayList as $key => $value ) {
  8066. $sinfo = $staff->getOne ( array (
  8067. 'select' => 'username,category',
  8068. 'where' => ' sid=' . $value ['staff'],
  8069. 'asArray' => true
  8070. ) );
  8071. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  8072. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  8073. $au = 0;
  8074. foreach ( $rplist as $k => $v ) {
  8075. if ($value ['staff'] == $v ['staff']) {
  8076. $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>';
  8077. $au += $v ['amount'];
  8078. }
  8079. }
  8080. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  8081. }
  8082. $data ['html'] = $html;
  8083. $data ['memu'] = "receipt";
  8084. $data ['staff'] = $this->staff;
  8085. $data ['receiptMemu'] = 'remittanceHky';
  8086. $data ['verifyId'] = $this->verifyId;
  8087. $data ['executeId'] = $this->executeId;
  8088. $this->render ( "/admin/remittancep", $data );
  8089. }
  8090. function ajaxGetReceiptDetails() {
  8091. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  8092. Doo::loadClass ( 'XDeode' );
  8093. $XDeode = new XDeode ( 5 );
  8094. $rid = $XDeode->decode ( $rid );
  8095. if (empty ( $rid )) {
  8096. echo json_encode ( array (
  8097. 'status' => 2,
  8098. 'msg' => 'illegal request'
  8099. ) );
  8100. die ();
  8101. }
  8102. Doo::loadModel ( 'receipt' );
  8103. $receipt = new receipt ();
  8104. Doo::loadModel ( 'staff' );
  8105. $staff = new staff ();
  8106. $rinfo = $receipt->getOne ( array (
  8107. 'where' => 'rid= ' . $rid,
  8108. 'asArray' => true
  8109. ) );
  8110. $sinfo = $staff->getOne ( array (
  8111. 'select' => 'username,category',
  8112. 'where' => ' sid=' . $rinfo ['staff'],
  8113. 'asArray' => true
  8114. ) );
  8115. $rinfo ['reviseDetail'] = array ();
  8116. if (! empty ( $rinfo ['reviseDetail'] ))
  8117. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  8118. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  8119. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  8120. $rinfo ['category'] = $sinfo ['category'];
  8121. $verifyStaff = array ();
  8122. if (! empty ( $rinfo ['verifyStaff'] ))
  8123. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  8124. $relust = bcsub ( $rinfo ['sum'], $rinfo ['loanSum'], 2 );
  8125. $rinfo ['relust'] = $relust;
  8126. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  8127. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  8128. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  8129. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  8130. // 费用执行人相关数据
  8131. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  8132. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  8133. foreach ( $executeCopy as $k => $v ) {
  8134. $executeCopy [$k] ['date'] = '';
  8135. $executeCopy [$k] ['opinion'] = '';
  8136. $executeCopy [$k] ['status'] = '';
  8137. if (! empty ( $executeStaff ))
  8138. foreach ( $executeStaff as $m => $u ) {
  8139. if ($v [0] == $m) {
  8140. $executeCopy [$k] ['date'] = $u ['date'];
  8141. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  8142. $executeCopy [$k] ['status'] = $u ['status'];
  8143. break;
  8144. }
  8145. }
  8146. }
  8147. $rinfo ['executeCopy'] = $executeCopy;
  8148. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  8149. if ($rinfo ['Rtype'] == 1) { // 借款费用
  8150. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8151. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  8152. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  8153. $html .= '<tr><th>' . $value ['name'] . '</th>
  8154. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8155. }
  8156. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8157. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8158. <tr><th class="taC" colspan="2">费用说明</th>
  8159. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8160. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8161. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  8162. </tbody></table>';
  8163. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  8164. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8165. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8166. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8167. $html .= '<tr><th>' . $value ['name'] . '</th>
  8168. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8169. }
  8170. $html .= '<tr><th class="taR">合计</th>
  8171. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8172. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8173. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8174. $html .= '<tr><th>' . $value ['name'] . '</th>
  8175. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8176. }
  8177. $html .= '<tr><th class="taR">合计</th>
  8178. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8179. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8180. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8181. $html .= '<tr><th>' . $value ['name'] . '</th>
  8182. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8183. }
  8184. $html .= '<tr><th class="taR">合计</th>
  8185. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8186. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8187. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8188. $html .= '<tr><th>' . $value ['name'] . '</th>
  8189. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8190. }
  8191. $html .= '<tr><th class="taR">合计</th>
  8192. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8193. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8194. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8195. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8196. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8197. }
  8198. $html .= '<tr><th class="taR">合计</th>
  8199. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8200. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8201. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8202. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8203. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8204. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8205. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8206. <tr';
  8207. if ($rinfo ['relust'] >= 0) {
  8208. $html .= 'class="success"';
  8209. } else {
  8210. $html .= 'class="error"';
  8211. }
  8212. $html .= '><td class="taR"><b>借款结余</b></td>
  8213. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  8214. </tbody></table>
  8215. ';
  8216. }
  8217. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  8218. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8219. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  8220. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8221. $html .= '<tr><th>' . $value ['name'] . '</th>
  8222. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8223. }
  8224. $html .= '<tr><th class="taR">合计</th>
  8225. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8226. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8227. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8228. <tr><th class="taC" colspan="2">费用说明</th>
  8229. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8230. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8231. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8232. </tbody></table>';
  8233. } else {
  8234. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8235. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8236. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8237. $html .= '<tr><th>' . $value ['name'] . '</th>
  8238. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8239. }
  8240. $html .= '<tr><th class="taR">合计</th>
  8241. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8242. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8243. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8244. $html .= '<tr><th>' . $value ['name'] . '</th>
  8245. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8246. }
  8247. $html .= '<tr><th class="taR">合计</th>
  8248. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8249. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8250. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8251. $html .= '<tr><th>' . $value ['name'] . '</th>
  8252. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8253. }
  8254. $html .= '<tr><th class="taR">合计</th>
  8255. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8256. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8257. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8258. $html .= '<tr><th>' . $value ['name'] . '</th>
  8259. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8260. }
  8261. $html .= '<tr><th class="taR">合计</th>
  8262. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8263. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8264. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8265. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8266. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8267. }
  8268. $html .= '<tr><th class="taR">合计</th>
  8269. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8270. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8271. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8272. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8273. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8274. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8275. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  8276. $html .= '</tbody></table>';
  8277. /*
  8278. * <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>
  8279. */
  8280. }
  8281. // print_r($verifyStaff);die;
  8282. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  8283. foreach ( $verifyStaff as $key => $value ) {
  8284. $key = trim ( strtr ( $key, '_R', ' ' ) );
  8285. $sinfo = $staff->getOne ( array (
  8286. 'select' => 'username',
  8287. 'where' => ' sid=' . $key,
  8288. 'asArray' => true
  8289. ) );
  8290. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8291. }
  8292. $html .= '</tbody></table>';
  8293. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  8294. foreach ( $rinfo ['executeCopy'] as $value ) {
  8295. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8296. }
  8297. $html .= '</tbody></table>';
  8298. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  8299. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  8300. </tr></table>';
  8301. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  8302. echo json_encode ( array (
  8303. 'status' => 1,
  8304. 'html' => $html
  8305. ) );
  8306. die ();
  8307. }
  8308. /**
  8309. * 删除附件
  8310. */
  8311. function ajaxRemEnclousur() {
  8312. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  8313. if (empty ( $key ))
  8314. echo json_encode ( array (
  8315. 'status' => 2
  8316. ) );
  8317. Doo::loadModel ( 'enclosur' );
  8318. $enclosur = new enclosur ();
  8319. $enclosur->delEnclosurByEid ( $key );
  8320. echo json_encode ( array (
  8321. 'status' => 1
  8322. ) );
  8323. }
  8324. function remittance() {
  8325. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8326. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8327. Doo::loadModel ( 'receipt' );
  8328. $receipt = new receipt ();
  8329. Doo::loadModel ( 'staff' );
  8330. $staff = new staff ();
  8331. $dateCondition = " and Year(pastDate) =" . $year;
  8332. if (! empty ( $month ))
  8333. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  8334. // get Receipt By verifyID status 1
  8335. $receiptList = $receipt->find ( array (
  8336. 'select' => 'sum(sum) as sum,staff,pastDate',
  8337. 'where' => ' status=1' . $dateCondition,
  8338. 'desc' => 'pastDate',
  8339. 'groupby' => 'staff,pastDate',
  8340. 'asArray' => true
  8341. ) );
  8342. $dateList = $receipt->find ( array (
  8343. 'select' => 'pastDate,verifyStaff',
  8344. 'where' => ' status=1' . $dateCondition,
  8345. 'desc' => 'pastDate',
  8346. 'groupby' => 'pastDate',
  8347. 'asArray' => true
  8348. ) );
  8349. $dataList = array ();
  8350. foreach ( $dateList as $d => $a ) {
  8351. $dataList [$a ['pastDate']] = array ();
  8352. $daySum = 0;
  8353. foreach ( $receiptList as $key => $value ) {
  8354. if ($a ['pastDate'] == $value ['pastDate']) {
  8355. $oderList = $receipt->find ( array (
  8356. 'select' => 'receiptOrder',
  8357. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  8358. 'asArray' => true
  8359. ) );
  8360. $list = array ();
  8361. $html = "";
  8362. foreach ( $oderList as $v ) {
  8363. array_push ( $list, $v ['receiptOrder'] );
  8364. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  8365. }
  8366. $receiptList [$key] ['receiptOrder'] = $html;
  8367. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  8368. $sinfo = $staff->getOne ( array (
  8369. 'select' => 'username ',
  8370. 'where' => ' sid=' . $value ['staff'],
  8371. 'asArray' => true
  8372. ) );
  8373. $receiptList [$key] ['username'] = $sinfo ['username'];
  8374. $daySum += $value ['sum'];
  8375. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  8376. }
  8377. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  8378. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  8379. }
  8380. }
  8381. // print_r($dataList);
  8382. $data ['dataList'] = $dataList;
  8383. $mothHtml = "";
  8384. for($i = 1; $i <= 12; $i ++) {
  8385. if ($month == $i)
  8386. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8387. else
  8388. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8389. }
  8390. $data ['year'] = $year;
  8391. $data ['mothHtml'] = $mothHtml;
  8392. $data ['memu'] = "receipt";
  8393. $data ['staff'] = $this->staff;
  8394. $data ['receiptMemu'] = 'approval';
  8395. $data ['verifyId'] = $this->verifyId;
  8396. $data ['executeId'] = $this->executeId;
  8397. $this->render ( "/admin/saeaReportListPay", $data );
  8398. }
  8399. /**
  8400. * 金额调整,提高稳定性
  8401. * @return string
  8402. */
  8403. function revocationAdjustment() {
  8404. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  8405. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  8406. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  8407. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  8408. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  8409. Doo::loadClass ( 'XDeode' );
  8410. $XDeode = new XDeode ( 5 );
  8411. Doo::loadModel ( 'receipt' );
  8412. $receipt = new receipt ();
  8413. $sid = $XDeode->decode ( $sidKey );
  8414. $rid = $XDeode->decode ( $ridKey );
  8415. $reviseKey = $XDeode->decode ( $reviseKey );
  8416. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  8417. die ( 'illegal request' );
  8418. $receiptDetail = $receipt->getOne ( array (
  8419. 'where' => 'rid=' . $rid,
  8420. 'asArray' => true
  8421. ) );
  8422. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  8423. die ( 'illegal request' );
  8424. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8425. if (! isset ( $reviseDetail [$reviseKey] ))
  8426. die ( 'illegal request' );
  8427. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  8428. unset ( $reviseDetail [$reviseKey] );
  8429. $revisePrice = 0;
  8430. foreach ( $reviseDetail as $key => $value ) {
  8431. $revisePrice += $value ['price'];
  8432. }
  8433. $reviseDetailString = json_encode ( $reviseDetail );
  8434. $receipt->reviseDetail = $reviseDetailString;
  8435. $receipt->sum = $receiptDetail ['sum'] - $price;
  8436. $receipt->revisePrice = $revisePrice;
  8437. $receipt->update ( array (
  8438. 'where' => 'rid=' . $rid
  8439. ) );
  8440. return '/receiptburEdi/' . $rid;
  8441. } else
  8442. die ( 'illegal request2' );
  8443. }
  8444. function updateApprovalReceipt() {
  8445. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  8446. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  8447. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8448. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  8449. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  8450. if (! empty ( $rid )) {
  8451. Doo::loadModel ( "verify" );
  8452. $verify = new verify ();
  8453. Doo::loadModel ( "receiptDetail" );
  8454. $receiptDetailObj = new receiptDetail ();
  8455. Doo::loadModel ( "itemStatistics" );
  8456. Doo::loadModel ( "statistics" );
  8457. $statistics = new statistics ();
  8458. $itemStatistics = new itemStatistics ();
  8459. Doo::loadModel ( "receipt" );
  8460. $receipt = new receipt ();
  8461. $receiptDetail = $receipt->getOne ( array (
  8462. 'where' => 'rid=' . $rid . ' and status=2 ',
  8463. 'asArray' => true
  8464. ) );
  8465. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  8466. $nsflag = true;
  8467. foreach ( $nslist as $value ) {
  8468. if ($value == $this->staff ['0'] ['sid']) {
  8469. $nsflag = false;
  8470. break;
  8471. }
  8472. }
  8473. if (empty ( $receiptDetail ) || $nsflag)
  8474. return "/approvalExpenses/pendApproval";
  8475. $verifyDetail = $verify->getOne ( array (
  8476. 'where' => ' vid =' . $receiptDetail ['verify'],
  8477. 'asArray' => true
  8478. ) );
  8479. $verifyString = $verifyDetail ['staff'];
  8480. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  8481. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  8482. if (empty ( $opinion )) {
  8483. if ($status == 3)
  8484. $opinion = "终止";
  8485. else
  8486. $opinion = "同意支付";
  8487. }
  8488. $nowStaff = 0;
  8489. $nowStaffList = array ();
  8490. if (empty ( $verifyStaff )) {
  8491. // 还需加入是否已经进入角色审批
  8492. if ($verifyDetail [0] [1] == 'ROLE') {
  8493. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  8494. foreach ( $vStaffString as $key => $value ) {
  8495. $staffK = explode ( "_", $value );
  8496. if ($staffK [0] != $this->staff [0] ['sid'])
  8497. array_push ( $nowStaffList, $staffK [0] );
  8498. }
  8499. // print_r($verifyDetail);
  8500. // die;
  8501. if (! empty ( $nowStaffList )) {
  8502. $nowStaff = implode ( ',', $nowStaffList );
  8503. $verifyStaff = array (
  8504. $this->staff [0] ['sid'] . "_R" => array (
  8505. 'date' => date ( 'Y-m-d' ),
  8506. 'opinion' => $opinion,
  8507. 'status' => $status,
  8508. 'nextStaff' => $verifyDetail [0] [0],
  8509. 'ROLE' => 1
  8510. )
  8511. );
  8512. } else {
  8513. $nowStaff = $verifyDetail [1] [0];
  8514. $verifyStaff = array (
  8515. $this->staff [0] ['sid'] . "_R" => array (
  8516. 'date' => date ( 'Y-m-d' ),
  8517. 'opinion' => $opinion,
  8518. 'status' => $status,
  8519. 'nextStaff' => $verifyDetail [1] [0]
  8520. )
  8521. );
  8522. }
  8523. } else {
  8524. if ($verifyDetail [1] [1] == 'ROLE') {
  8525. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  8526. // echo "dd";
  8527. foreach ( $vStaffString as $key => $value ) {
  8528. $staffK = explode ( "_", $value );
  8529. array_push ( $nowStaffList, $staffK [0] );
  8530. }
  8531. $nowStaff = implode ( ',', $nowStaffList );
  8532. $verifyStaff = array (
  8533. $this->staff [0] ['sid'] => array (
  8534. 'date' => date ( 'Y-m-d' ),
  8535. 'opinion' => $opinion,
  8536. 'status' => $status,
  8537. 'nextStaff' => $verifyDetail [1] [0],
  8538. 'ROLE' => 1
  8539. )
  8540. );
  8541. } else {
  8542. $nowStaff = $verifyDetail [1] [0];
  8543. $verifyStaff = array (
  8544. $this->staff [0] ['sid'] => array (
  8545. 'date' => date ( 'Y-m-d' ),
  8546. 'opinion' => $opinion,
  8547. 'status' => $status,
  8548. 'nextStaff' => $verifyDetail [1] [0]
  8549. )
  8550. );
  8551. }
  8552. }
  8553. if ($status == 3)
  8554. $verifyStaff = array (
  8555. 'final' => $status,
  8556. $this->staff [0] ['sid'] => array (
  8557. 'date' => date ( 'Y-m-d' ),
  8558. 'opinion' => $opinion,
  8559. 'status' => $status
  8560. )
  8561. );
  8562. $vStaffString = json_encode ( $verifyStaff );
  8563. $receipt->nowStaff = $nowStaff;
  8564. $receipt->verifyStaff = $vStaffString;
  8565. } else {
  8566. $VS = end ( $verifyStaff );
  8567. // 非角色审批
  8568. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  8569. $nextStaff = 0;
  8570. $roleSTF = false;
  8571. foreach ( $verifyDetail as $key => $value ) {
  8572. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  8573. if (isset ( $verifyDetail [$key + 1] )) {
  8574. $nextStaff = $verifyDetail [$key + 1] [0];
  8575. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  8576. $roleSTF = true;
  8577. }
  8578. break;
  8579. }
  8580. }
  8581. if (! $roleSTF) {
  8582. $nowStaff = $nextStaff;
  8583. $verifyStaff [$this->staff [0] ['sid']] = array (
  8584. 'date' => date ( 'Y-m-d' ),
  8585. 'opinion' => $opinion,
  8586. 'status' => $status,
  8587. 'nextStaff' => $nextStaff
  8588. );
  8589. } else {
  8590. // 获取角色下的所有用户ID
  8591. $nowStaffList = array ();
  8592. foreach ( $verifyDetail as $vfk ) {
  8593. if ($vfk [1] == 'ROLE') {
  8594. $vStaffString = json_decode ( $vfk [3] );
  8595. foreach ( $vStaffString as $key => $value ) {
  8596. $staffK = explode ( "_", $value );
  8597. array_push ( $nowStaffList, $staffK [0] );
  8598. }
  8599. }
  8600. }
  8601. $nowStaff = implode ( ',', $nowStaffList );
  8602. $verifyStaff [$this->staff [0] ['sid']] = array (
  8603. 'date' => date ( 'Y-m-d' ),
  8604. 'opinion' => $opinion,
  8605. 'status' => $status,
  8606. 'nextStaff' => $nextStaff,
  8607. 'ROLE' => 0
  8608. );
  8609. }
  8610. if ($status == 3) {
  8611. $verifyStaff ['final'] = $status;
  8612. $verifyStaff [$this->staff [0] ['sid']] = array (
  8613. 'date' => date ( 'Y-m-d' ),
  8614. 'opinion' => $opinion,
  8615. 'status' => $status
  8616. );
  8617. }
  8618. $vStaffString = json_encode ( $verifyStaff );
  8619. $receipt->nowStaff = $nowStaff;
  8620. $receipt->verifyStaff = $vStaffString;
  8621. }
  8622. // 角色审批
  8623. if (isset ( $VS ['ROLE'] )) {
  8624. // 找出角色人 当前审批角色组
  8625. $verifyJSStaff = array ();
  8626. $nowStaffList2 = array ();
  8627. foreach ( $verifyDetail as $key => $value ) {
  8628. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  8629. $verifyJSStaff = json_decode ( $value [3] );
  8630. foreach ( $verifyJSStaff as $m ) {
  8631. $staffK = explode ( "_", $m );
  8632. array_push ( $nowStaffList2, $staffK [0] );
  8633. }
  8634. // print_r($nowStaffList2);
  8635. }
  8636. }
  8637. $RoleVerifyStaff = array ();
  8638. foreach ( $verifyStaff as $key => $value ) {
  8639. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  8640. foreach ( $nowStaffList2 as $m ) {
  8641. if ($key == $m . "_R")
  8642. $RoleVerifyStaff [$key] = $value;
  8643. }
  8644. }
  8645. }
  8646. // print_r($verifyStaff);
  8647. // print_r($nowStaffList2);
  8648. // print_r($RoleVerifyStaff);
  8649. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  8650. // print_r($verifyJSStaff);
  8651. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  8652. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  8653. // 下一个审批人ID
  8654. $nextStaff = 0;
  8655. $falg = false;
  8656. foreach ( $verifyDetail as $key => $value ) {
  8657. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  8658. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  8659. $falg = true;
  8660. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  8661. $nowStaffList = array ();
  8662. foreach ( $vStaffString as $v ) {
  8663. $staffK = explode ( "_", $v );
  8664. array_push ( $nowStaffList, $staffK [0] );
  8665. }
  8666. $nowStaff = implode ( ',', $nowStaffList );
  8667. $nextStaff = $verifyDetail [$key + 1] [0];
  8668. } elseif (isset ( $verifyDetail [$key + 1] )) {
  8669. $nextStaff = $verifyDetail [$key + 1] [0];
  8670. $nowStaff = $nextStaff;
  8671. } else
  8672. $nowStaff = '';
  8673. break;
  8674. }
  8675. }
  8676. if ($falg)
  8677. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8678. 'date' => date ( 'Y-m-d' ),
  8679. 'opinion' => $opinion,
  8680. 'status' => $status,
  8681. 'nextStaff' => $nextStaff,
  8682. 'ROLE' => 1
  8683. );
  8684. else
  8685. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8686. 'date' => date ( 'Y-m-d' ),
  8687. 'opinion' => $opinion,
  8688. 'status' => $status,
  8689. 'nextStaff' => $nextStaff
  8690. );
  8691. // print_r($verifyStaff);
  8692. // echo $nowStaff;die;
  8693. } else { // 进入下一个角色或者审批人
  8694. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  8695. //
  8696. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  8697. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8698. 'date' => date ( 'Y-m-d' ),
  8699. 'opinion' => $opinion,
  8700. 'status' => $status,
  8701. 'nextStaff' => $VS ['nextStaff'],
  8702. 'ROLE' => 1
  8703. );
  8704. // print_r($verifyStaff);
  8705. // die;
  8706. }
  8707. if ($status == 3) {
  8708. $verifyStaff ['final'] = $status;
  8709. $verifyStaff [$this->staff [0] ['sid']] = array (
  8710. 'date' => date ( 'Y-m-d' ),
  8711. 'opinion' => $opinion,
  8712. 'status' => $status
  8713. );
  8714. }
  8715. $vStaffString = json_encode ( $verifyStaff );
  8716. $receipt->verifyStaff = $vStaffString;
  8717. $receipt->nowStaff = $nowStaff;
  8718. // die;
  8719. // }
  8720. // print_r($verifyStaff);
  8721. // die;
  8722. }
  8723. // print_r($verifyStaff);die;
  8724. }
  8725. // print_r($verifyDetail);
  8726. $roleKey = 0;
  8727. $roleId = 0;
  8728. $verifyDetailCopy = array ();
  8729. foreach ( $verifyDetail as $k => $v ) {
  8730. if ($v [1] == 'ROLE') {
  8731. $roleId = $v [0];
  8732. $roleVerify = json_decode ( $v [3], true );
  8733. $roleKey = $k;
  8734. $roleArray = array ();
  8735. foreach ( $roleVerify as $o => $p ) {
  8736. $staffID = explode ( '_', $p );
  8737. $exp = array (
  8738. 0 => $staffID [0],
  8739. 1 => $staffID [1]
  8740. );
  8741. array_push ( $roleArray, $exp );
  8742. }
  8743. $verifyDetailCopy [$v [0]] = $roleArray;
  8744. }
  8745. }
  8746. // print_r($verifyDetail);
  8747. foreach ( $verifyDetailCopy as $k => $v ) {
  8748. foreach ( $verifyDetail as $m => $n ) {
  8749. if ($n [0] == $k) {
  8750. array_splice ( $verifyDetail, $m, 1, $v );
  8751. }
  8752. }
  8753. }
  8754. // die;
  8755. // if (!empty($roleArray))
  8756. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  8757. // echo $roleId;
  8758. // print_r($verifyStaff);
  8759. // print_r($verifyDetail);
  8760. // die;
  8761. Doo::loadModel ( "receiptLog" );
  8762. $receiptLog = new receiptLog ();
  8763. // 审批日志
  8764. if (! isset ( $verifyStaff ['final'] )) {
  8765. if (! empty ( $roleId )) {
  8766. Doo::loadModel ( "role" );
  8767. $role = new role ();
  8768. $roleInfo = $role->getOne ( array (
  8769. 'where' => 'rid=' . $roleId,
  8770. 'asArray' => true
  8771. ) );
  8772. $receiptLog->rolename = $roleInfo ['name'];
  8773. }
  8774. $receiptLog->username = $this->staff [0] ['username'];
  8775. $receiptLog->uid = $this->staff [0] ['sid'];
  8776. $receiptLog->date = date ( "Y-m-d" );
  8777. $receiptLog->opinion = $opinion;
  8778. $receiptLog->img = $this->staff [0] ['avatar'];
  8779. $receiptLog->status = 1;
  8780. $receiptLog->rid = $rid;
  8781. $receiptLog->insert ();
  8782. }
  8783. if (isset ( $verifyStaff ['final'] )) { // rDetail
  8784. $receipt->verifyBreakup = $verifyString;
  8785. $receipt->status = 3;
  8786. $receiptDetailObj->status = 3;
  8787. $receiptDetailObj->update ( array (
  8788. 'where' => 'rid=' . $rid
  8789. ) );
  8790. if (! empty ( $roleId )) {
  8791. Doo::loadModel ( "role" );
  8792. $role = new role ();
  8793. $roleInfo = $role->getOne ( array (
  8794. 'where' => 'rid=' . $roleId,
  8795. 'asArray' => true
  8796. ) );
  8797. $receiptLog->rolename = $roleInfo ['name'];
  8798. }
  8799. $receiptLog->username = $this->staff [0] ['username'];
  8800. $receiptLog->uid = $this->staff [0] ['sid'];
  8801. $receiptLog->date = date ( "Y-m-d" );
  8802. $receiptLog->opinion = $opinion;
  8803. $receiptLog->img = $this->staff [0] ['avatar'];
  8804. $receiptLog->status = 3;
  8805. $receiptLog->rid = $rid;
  8806. $receiptLog->insert ();
  8807. // 微信企业号通知
  8808. $this->setWXMsg ( $rid, 3 );
  8809. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  8810. $receipt->status = 1;
  8811. $reviseSum = 0;
  8812. $receipt->verifyBreakup = $verifyString;
  8813. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  8814. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8815. foreach ( $reviseDetail as $key => $value ) {
  8816. $receiptDetailObj = new receiptDetail ();
  8817. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8818. $receiptDetailObj->item = $value ['description'];
  8819. $receiptDetailObj->itemCategory = "报销金额调整";
  8820. $receiptDetailObj->price = $value ['price'];
  8821. $receiptDetailObj->date = $receiptDetail ['date'];
  8822. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  8823. $receiptDetailObj->rid = $rid;
  8824. $receiptDetailObj->status = 1;
  8825. $receiptDetailObj->insert ();
  8826. $reviseSum += $value ['price'];
  8827. }
  8828. $itemStatistics = new itemStatistics ();
  8829. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  8830. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8831. $itemStatistics->price = $reviseSum;
  8832. $itemStatistics->itemCategory = "报销金额调整";
  8833. $itemStatistics->date = $receiptDetail ['date'];
  8834. $itemStatistics->insert ();
  8835. }
  8836. $receiptDetailObj = new receiptDetail ();
  8837. $receiptDetailObj->status = 1;
  8838. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  8839. $receiptDetailObj->update ( array (
  8840. 'where' => 'rid=' . $rid
  8841. ) );
  8842. $dateArray = explode ( "-", $receiptDetail ['date'] );
  8843. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  8844. $stat = $statistics->getOne ( array (
  8845. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  8846. 'asArray' => true
  8847. ) );
  8848. if (empty ( $stat )) {
  8849. $statistics->date = $receiptDetail ['date'];
  8850. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  8851. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8852. $statistics->agPrice = $receiptDetail ['sum'];
  8853. $statistics->rePrice = $reviseSum;
  8854. $statistics->insert ();
  8855. } else {
  8856. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  8857. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  8858. $statistics->update ( array (
  8859. 'where' => 'sid=' . $stat ['sid']
  8860. ) );
  8861. }
  8862. $dateArray = explode ( "-", $receiptDetail ['date'] );
  8863. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  8864. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  8865. foreach ( $accountItem ['cSum'] as $key => $value ) {
  8866. if ($key == "agencySum") {
  8867. $iStatistics = $itemStatistics->getOne ( array (
  8868. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  8869. 'asArray' => true
  8870. ) );
  8871. if (empty ( $iStatistics )) {
  8872. $itemStatistics->cid = $receiptDetail ['cid'];
  8873. ;
  8874. $itemStatistics->staff = $receiptDetail ['staff'];
  8875. $itemStatistics->price = $value;
  8876. $itemStatistics->itemCategory = $this->AGENCY;
  8877. $itemStatistics->date = $receiptDetail ['date'];
  8878. $itemStatistics->insert ();
  8879. } else {
  8880. if (! empty ( $value )) {
  8881. $itemStatistics->price = $value + $iStatistics ['price'];
  8882. $itemStatistics->update ( array (
  8883. 'where' => 'sid=' . $iStatistics ['sid']
  8884. ) );
  8885. }
  8886. }
  8887. } elseif ($key == "travelSum") {
  8888. $iStatistics = $itemStatistics->getOne ( array (
  8889. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  8890. 'asArray' => true
  8891. ) );
  8892. if (empty ( $iStatistics )) {
  8893. $itemStatistics->cid = $receiptDetail ['cid'];
  8894. $itemStatistics->staff = $receiptDetail ['staff'];
  8895. $itemStatistics->price = $value;
  8896. $itemStatistics->itemCategory = $this->TRAVEL;
  8897. $itemStatistics->date = $receiptDetail ['date'];
  8898. $itemStatistics->insert ();
  8899. } else {
  8900. if (! empty ( $value )) {
  8901. $itemStatistics->price = $value + $iStatistics ['price'];
  8902. $itemStatistics->update ( array (
  8903. 'where' => 'sid=' . $iStatistics ['sid']
  8904. ) );
  8905. }
  8906. }
  8907. } elseif ($key == "trainSum") {
  8908. $iStatistics = $itemStatistics->getOne ( array (
  8909. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  8910. 'asArray' => true
  8911. ) );
  8912. if (empty ( $iStatistics )) {
  8913. $itemStatistics->cid = $receiptDetail ['cid'];
  8914. $itemStatistics->staff = $receiptDetail ['staff'];
  8915. $itemStatistics->price = $value;
  8916. $itemStatistics->itemCategory = $this->TRAIN;
  8917. $itemStatistics->date = $receiptDetail ['date'];
  8918. $itemStatistics->insert ();
  8919. } else {
  8920. if (! empty ( $value )) {
  8921. $itemStatistics->price = $value + $iStatistics ['price'];
  8922. $itemStatistics->update ( array (
  8923. 'where' => 'sid=' . $iStatistics ['sid']
  8924. ) );
  8925. }
  8926. }
  8927. } elseif ($key == "otherSum") {
  8928. $iStatistics = $itemStatistics->getOne ( array (
  8929. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  8930. 'asArray' => true
  8931. ) );
  8932. if (empty ( $iStatistics )) {
  8933. $itemStatistics->cid = $receiptDetail ['cid'];
  8934. $itemStatistics->staff = $receiptDetail ['staff'];
  8935. $itemStatistics->price = $value;
  8936. $itemStatistics->itemCategory = $this->OTHER;
  8937. $itemStatistics->date = $receiptDetail ['date'];
  8938. $itemStatistics->insert ();
  8939. } else {
  8940. if (! empty ( $value )) {
  8941. $itemStatistics->price = $value + $iStatistics ['price'];
  8942. $itemStatistics->update ( array (
  8943. 'where' => 'sid=' . $iStatistics ['sid']
  8944. ) );
  8945. }
  8946. }
  8947. }
  8948. }
  8949. $receipt->pastDate = date ( "Y-m-d" );
  8950. // 微信企业号通知
  8951. $this->setWXMsg ( $rid, 1 );
  8952. }
  8953. //是否有流水
  8954. Doo::loadModel ( 'wasteBook' );
  8955. $wasteBook = new wasteBook ();
  8956. $accountType=3;
  8957. if ($receiptDetail['Rtype']==1){
  8958. $accountType=2;
  8959. }elseif($receiptDetail['Rtype']==2){
  8960. $accountType=4;
  8961. }
  8962. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $rid );
  8963. if (empty($wbDetail)){
  8964. $rsum=$receiptDetail['sum']-$receiptDetail['loanSum'];
  8965. $receipt->amount = $rsum;//$amount;
  8966. }
  8967. $receipt->update ( array (
  8968. 'where' => ' rid = ' . $rid
  8969. ) );
  8970. // 进入下一条审批费用新加需求
  8971. $vidList = array ();
  8972. $verifyDetail = $verify->find ( array (
  8973. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  8974. 'asArray' => true
  8975. ) );
  8976. foreach ( $verifyDetail as $key => $value ) {
  8977. array_push ( $vidList, $value ['vid'] );
  8978. }
  8979. $vid = implode ( ",", $vidList );
  8980. if (empty ( $verifyDetail ))
  8981. $vid = 0;
  8982. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  8983. $receipt = new receipt ();
  8984. $rd = $receipt->getOne ( array (
  8985. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ') and Rtype!=3',
  8986. 'asc' => 'rid',
  8987. 'asArray' => true
  8988. ) );
  8989. if (empty ( $rd )) {
  8990. return '/approvalExpenses/pendApproval';
  8991. }
  8992. if ($rd ['Rtype'] == 1) {
  8993. if ($rd ['isBK'] == 1) {
  8994. return '/receiptburEdi/' . $rd ['rid'];
  8995. } else {
  8996. return '/expensesEdi/' . $rd ['rid'];
  8997. }
  8998. } elseif ($rd ['Rtype'] == 2) {
  8999. return '/remitApproval/' . $rd ['rid'];
  9000. } else {
  9001. return '/receiptburEdi/' . $rd ['rid'];
  9002. }
  9003. // return "/approvalExpenses/pendApproval";
  9004. }
  9005. }
  9006. function expensesRetreats() {
  9007. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  9008. if (! empty ( $rid )) {
  9009. // 操作记录
  9010. Doo::loadModel ( "receipt" );
  9011. $receipt = new receipt ();
  9012. Doo::loadModel ( "receiptLog" );
  9013. $receiptLog = new receiptLog ();
  9014. Doo::loadModel ( "verify" );
  9015. $verify = new verify ();
  9016. $receiptInfo = $receipt->getOne ( array (
  9017. 'where' => 'rid=' . $rid,
  9018. 'asArray' => true
  9019. ) );
  9020. $vr = $verify->getOne ( array (
  9021. 'where' => 'vid=' . $receiptInfo ['verify'],
  9022. 'asArray' => true
  9023. ) );
  9024. $jd = json_decode ( $vr ['staff'] );
  9025. $roleId = 0;
  9026. foreach ( $jd as $key => $value ) {
  9027. if ($value [1] == 'ROLE') {
  9028. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9029. if ($pos !== false) {
  9030. $roleId = $value [0];
  9031. }
  9032. }
  9033. }
  9034. // 审批日志
  9035. // echo $roleId;die;
  9036. if (! empty ( $roleId )) {
  9037. Doo::loadModel ( "role" );
  9038. $role = new role ();
  9039. $roleInfo = $role->getOne ( array (
  9040. 'where' => 'rid=' . $roleId,
  9041. 'asArray' => true
  9042. ) );
  9043. $receiptLog->rolename = $roleInfo ['name'];
  9044. }
  9045. $receiptLog->username = $this->staff [0] ['username'];
  9046. $receiptLog->uid = $this->staff [0] ['sid'];
  9047. $receiptLog->date = date ( "Y-m-d" );
  9048. $receiptLog->opinion = '撤回';
  9049. $receiptLog->img = $this->staff [0] ['avatar'];
  9050. $receiptLog->status = 4;
  9051. $receiptLog->rid = $rid;
  9052. $receiptLog->insert ();
  9053. $receipt->status = 4;
  9054. $receipt->update ( array (
  9055. 'where' => 'rid=' . $rid
  9056. ) );
  9057. // 微信企业号通知
  9058. $this->setWXMsg ( $rid, 2 );
  9059. }
  9060. // echo "ddd";
  9061. return '/approvalExpenses/pendApproval';
  9062. }
  9063. function updateCheReceipt() {
  9064. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9065. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  9066. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  9067. if (! empty ( $rid )) {
  9068. // 操作记录
  9069. Doo::loadModel ( "receipt" );
  9070. $receipt = new receipt ();
  9071. Doo::loadModel ( "receiptLog" );
  9072. $receiptLog = new receiptLog ();
  9073. Doo::loadModel ( "verify" );
  9074. $verify = new verify ();
  9075. $receiptInfo = $receipt->getOne ( array (
  9076. 'where' => 'rid=' . $rid . ' and status=2',
  9077. 'asArray' => true
  9078. ) );
  9079. if (empty ( $receiptInfo )) {
  9080. echo json_encode ( array (
  9081. 'status' => 2
  9082. ) );
  9083. die ();
  9084. }
  9085. $vr = $verify->getOne ( array (
  9086. 'where' => 'vid=' . $receiptInfo ['verify'],
  9087. 'asArray' => true
  9088. ) );
  9089. $jd = json_decode ( $vr ['staff'] );
  9090. $roleId = 0;
  9091. foreach ( $jd as $key => $value ) {
  9092. if ($value [1] == 'ROLE') {
  9093. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9094. if ($pos !== false) {
  9095. $roleId = $value [0];
  9096. }
  9097. }
  9098. }
  9099. // 审批日志
  9100. // echo $roleId;die;
  9101. if (! empty ( $roleId )) {
  9102. Doo::loadModel ( "role" );
  9103. $role = new role ();
  9104. $roleInfo = $role->getOne ( array (
  9105. 'where' => 'rid=' . $roleId,
  9106. 'asArray' => true
  9107. ) );
  9108. $receiptLog->rolename = $roleInfo ['name'];
  9109. }
  9110. $receiptLog->username = $this->staff [0] ['username'];
  9111. $receiptLog->uid = $this->staff [0] ['sid'];
  9112. $receiptLog->date = date ( "Y-m-d" );
  9113. $receiptLog->opinion = $opinion;
  9114. $receiptLog->img = $this->staff [0] ['avatar'];
  9115. $receiptLog->status = 4;
  9116. $receiptLog->rid = $rid;
  9117. $receiptLog->insert ();
  9118. $receipt->status = 4;
  9119. $receipt->update ( array (
  9120. 'where' => 'rid=' . $rid
  9121. ) );
  9122. // 微信企业号通知
  9123. $this->setWXMsg ( $rid, 2 );
  9124. echo json_encode ( array (
  9125. 'status' => 1
  9126. ) );
  9127. // Header("HTTP/1.1 303 See Other");
  9128. // Header("Location: /approvalExpenses/pendApproval");
  9129. die ();
  9130. }
  9131. echo json_encode ( array (
  9132. 'status' => 2
  9133. ) );
  9134. die ();
  9135. // echo "ddd";
  9136. // return '/saeaBorad';
  9137. }
  9138. function revisePrice() {
  9139. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  9140. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  9141. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9142. // echo $price;die;
  9143. if (! empty ( $rid )) {
  9144. Doo::loadModel ( "receipt" );
  9145. $receipt = new receipt ();
  9146. $receiptDetail = $receipt->getOne ( array (
  9147. 'where' => 'rid=' . $rid . ' and status=2 ',
  9148. 'asArray' => true
  9149. ) );
  9150. if (empty ( $receiptDetail ))
  9151. die ( 'illegal request' );
  9152. $reviseDetail = array ();
  9153. if (empty ( $receiptDetail ['reviseDetail'] )) {
  9154. array_push ( $reviseDetail, array (
  9155. 'sid' => $this->staff [0] ['sid'],
  9156. 'name' => $this->staff [0] ['username'],
  9157. 'description' => $description,
  9158. 'price' => $price
  9159. ) );
  9160. $reviseDetailString = json_encode ( $reviseDetail );
  9161. $receipt->reviseDetail = $reviseDetailString;
  9162. $receipt->revisePrice = $price;
  9163. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9164. } else {
  9165. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9166. array_push ( $reviseDetail, array (
  9167. 'sid' => $this->staff [0] ['sid'],
  9168. 'name' => $this->staff [0] ['username'],
  9169. 'description' => $description,
  9170. 'price' => $price
  9171. ) );
  9172. $reviseDetailString = json_encode ( $reviseDetail );
  9173. $receipt->reviseDetail = $reviseDetailString;
  9174. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  9175. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9176. }
  9177. $receipt->update ( array (
  9178. 'where' => 'rid=' . $rid
  9179. ) );
  9180. if ($receiptDetail ['Rtype'] == 1) {
  9181. if ($receiptDetail ['isBK'] == 1) {
  9182. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9183. }
  9184. } elseif ($receiptDetail ['Rtype'] == 2) {
  9185. } else {
  9186. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9187. }
  9188. }
  9189. die ( 'illegal request' );
  9190. }
  9191. function personalCollect() {
  9192. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9193. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  9194. $this->showCache ( $path );
  9195. Doo::loadModel ( "receiptDetail" );
  9196. Doo::loadModel ( "itemStatistics" );
  9197. Doo::loadModel ( 'statistics' );
  9198. $statistics = new statistics ();
  9199. $itemStatistics = new itemStatistics ();
  9200. $receiptDetail = new receiptDetail ();
  9201. $receiptCollectList = $receiptDetail->find ( array (
  9202. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9203. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9204. 'groupby' => 'itemCategory,Month(date)',
  9205. 'asArray' => true
  9206. ) );
  9207. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  9208. 'where' => 'staff=' . $this->staff [0] ['sid'],
  9209. 'asArray' => true
  9210. ) );
  9211. // create collect html
  9212. $collectArray = array (
  9213. '日常相关费用' => array (),
  9214. '差旅相关费用' => array (),
  9215. '培训班费用' => array (),
  9216. '其他' => array ()
  9217. );
  9218. $adjustment = array ();
  9219. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  9220. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9221. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  9222. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9223. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  9224. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9225. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  9226. array_push ( $collectArray ['其他'], $collectHtml );
  9227. $data ['collectArray'] = $collectArray;
  9228. // statistics html
  9229. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9230. if (empty ( $stList ))
  9231. $stList = array (
  9232. 'rePrice' => 0,
  9233. 'agPrice' => 0
  9234. );
  9235. $data ['stList'] = array (
  9236. 'rePrice' => $stList ['rePrice'],
  9237. 'agPrice' => $stList ['agPrice'],
  9238. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9239. );
  9240. // Adjustment price html
  9241. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9242. array_push ( $adjustment, $collectHtml );
  9243. $data ['adjustment'] = $adjustment;
  9244. // total price html
  9245. $collectHtml = "";
  9246. $total = 0;
  9247. for($i = 1; $i <= 12; $i ++) {
  9248. $sumPrice = 0;
  9249. foreach ( $receiptCollectList as $key => $value ) {
  9250. if ($value ['month'] == $i) {
  9251. $sumPrice += $value ['price'];
  9252. }
  9253. }
  9254. if ($sumPrice == 0)
  9255. $collectHtml .= '<td class="taR">-</td>';
  9256. else
  9257. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9258. $total += $sumPrice;
  9259. }
  9260. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9261. $data ['totalPrice'] = $collectHtml;
  9262. $dateHtml = "";
  9263. $now = date ( "Y" );
  9264. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9265. if ($YEARD <= $now) {
  9266. $dateHtml .= '<option ';
  9267. if ($year == $YEARD) {
  9268. $dateHtml .= 'selected ';
  9269. }
  9270. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9271. }
  9272. }
  9273. $data ['dateHtml'] = $dateHtml;
  9274. $data ['year'] = $year;
  9275. $data ['totalYear'] = $total;
  9276. $data ['memu'] = "receipt";
  9277. $data ['staff'] = $this->staff;
  9278. $data ['receiptMemu'] = 'personalCollect';
  9279. $data ['verifyId'] = $this->verifyId;
  9280. $data ['executeId'] = $this->executeId;
  9281. // year staff status 2,4
  9282. if ($year < date ( "Y" )) {
  9283. Doo::loadModel ( 'receipt' );
  9284. $receipt = new receipt ();
  9285. $receiptList = $receipt->find ( array (
  9286. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9287. 'asArray' => true
  9288. ) );
  9289. if (empty ( $receiptList )) {
  9290. ob_start ();
  9291. $this->render ( "/admin/saea_slist_collect", $data );
  9292. $this->cacheFile ( $path );
  9293. die ();
  9294. }
  9295. }
  9296. $this->render ( "/admin/saea_slist_collect", $data );
  9297. }
  9298. function personalCollectDetail() {
  9299. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9300. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  9301. $this->showCache ( $path );
  9302. Doo::loadModel ( "receiptDetail" );
  9303. Doo::loadModel ( "itemStatistics" );
  9304. Doo::loadModel ( 'statistics' );
  9305. Doo::loadModel ( 'accountItem' );
  9306. $accountItem = new accountItem ();
  9307. $statistics = new statistics ();
  9308. $itemStatistics = new itemStatistics ();
  9309. $receiptDetail = new receiptDetail ();
  9310. $receiptCollectList = $receiptDetail->find ( array (
  9311. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9312. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9313. 'groupby' => 'item,Month(date)',
  9314. 'asArray' => true
  9315. ) );
  9316. $accountList = $accountItem->find ( array (
  9317. 'asArray' => true
  9318. ) );
  9319. // create CollectDetail HTML
  9320. $collectHtml = array ();
  9321. foreach ( $accountList as $key => $value ) {
  9322. $html = "";
  9323. $asum = 0;
  9324. for($i = 1; $i <= 12; $i ++) {
  9325. $falg = true;
  9326. foreach ( $receiptCollectList as $v ) {
  9327. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9328. $asum += $v ['price'];
  9329. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9330. $falg = false;
  9331. break;
  9332. }
  9333. }
  9334. if ($falg)
  9335. $html .= '<td class="taR">-</td>';
  9336. }
  9337. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9338. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9339. }
  9340. $data ['collectHtml'] = $collectHtml;
  9341. // create Adjustment price html
  9342. $receiptCollectList = $receiptDetail->find ( array (
  9343. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9344. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9345. 'groupby' => 'itemCategory,Month(date)',
  9346. 'asArray' => true
  9347. ) );
  9348. $adjustment = array ();
  9349. $collectArray = array (
  9350. '日常相关费用' => array (),
  9351. '差旅相关费用' => array (),
  9352. '培训班费用' => array (),
  9353. '其他' => array ()
  9354. );
  9355. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9356. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9357. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9358. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9359. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9360. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9361. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9362. array_push ( $collectArray ['其他'], $collectHtml );
  9363. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9364. array_push ( $adjustment, $collectHtml );
  9365. // total price html
  9366. $collectHtml = "";
  9367. $total = 0;
  9368. for($i = 1; $i <= 12; $i ++) {
  9369. $sumPrice = 0;
  9370. foreach ( $receiptCollectList as $key => $value ) {
  9371. if ($value ['month'] == $i) {
  9372. $sumPrice += $value ['price'];
  9373. }
  9374. }
  9375. if ($sumPrice == 0)
  9376. $collectHtml .= '<td class="taR">-</td>';
  9377. else
  9378. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9379. $total += $sumPrice;
  9380. }
  9381. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9382. // statistics html
  9383. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9384. if (empty ( $stList ))
  9385. $stList = array (
  9386. 'rePrice' => 0,
  9387. 'agPrice' => 0
  9388. );
  9389. $data ['stList'] = array (
  9390. 'rePrice' => $stList ['rePrice'],
  9391. 'agPrice' => $stList ['agPrice'],
  9392. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9393. );
  9394. $data ['collectArray'] = $collectArray;
  9395. $data ['adjustment'] = $adjustment;
  9396. $data ['totalPrice'] = $collectHtml;
  9397. $data ['totalYear'] = $total;
  9398. $data ['year'] = $year;
  9399. $dateHtml = "";
  9400. $now = date ( "Y" );
  9401. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9402. if ($YEARD <= $now) {
  9403. $dateHtml .= '<option ';
  9404. if ($year == $YEARD) {
  9405. $dateHtml .= 'selected ';
  9406. }
  9407. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9408. }
  9409. }
  9410. $data ['dateHtml'] = $dateHtml;
  9411. $data ['memu'] = "receipt";
  9412. $data ['staff'] = $this->staff;
  9413. $data ['receiptMemu'] = 'personalCollect';
  9414. $data ['verifyId'] = $this->verifyId;
  9415. $data ['executeId'] = $this->executeId;
  9416. // year staff status 2,4
  9417. if ($year < date ( "Y" )) {
  9418. Doo::loadModel ( 'receipt' );
  9419. $receipt = new receipt ();
  9420. $receiptList = $receipt->find ( array (
  9421. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9422. 'asArray' => true
  9423. ) );
  9424. if (empty ( $receiptList )) {
  9425. ob_start ();
  9426. $this->render ( "/admin/saeaCollectArticles", $data );
  9427. $this->cacheFile ( $path );
  9428. die ();
  9429. }
  9430. }
  9431. $this->render ( "/admin/saeaCollectArticles", $data );
  9432. }
  9433. function companyCategoryCollect() {
  9434. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9435. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  9436. $this->showCache ( $path );
  9437. Doo::loadModel ( 'L_category' );
  9438. Doo::loadModel ( 'itemStatistics' );
  9439. Doo::loadModel ( 'statistics' );
  9440. $statistics = new statistics ();
  9441. $Lcategory = new L_category ();
  9442. $itemStatistics = new itemStatistics ();
  9443. Doo::loadModel ( "receiptAuthorityManage" );
  9444. $receiptAuthorityManage = new receiptAuthorityManage ();
  9445. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9446. $cidList = array ();
  9447. foreach ( $imcStaff as $key => $value ) {
  9448. array_push ( $cidList, $value ['cid'] );
  9449. }
  9450. $cidString = implode ( ',', $cidList );
  9451. $LcategoryList = $Lcategory->find ( array (
  9452. 'where' => ' cid in (' . $cidString . ')',
  9453. 'asArray' => true
  9454. ) ); // 'staff='.$this->staff[0]['sid']." and
  9455. $itemStatisticsList = $itemStatistics->find ( array (
  9456. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9457. 'where' => " Year(date)=" . $year,
  9458. 'groupby' => 'cid,Month(date)',
  9459. 'asArray' => true
  9460. ) );
  9461. // ceatre companyCollectHtml
  9462. foreach ( $LcategoryList as $value ) {
  9463. $html = "";
  9464. $asum = 0;
  9465. for($i = 1; $i <= 12; $i ++) {
  9466. $falg = true;
  9467. foreach ( $itemStatisticsList as $v ) {
  9468. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  9469. $asum += $v ['price'];
  9470. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9471. $falg = false;
  9472. break;
  9473. }
  9474. }
  9475. if ($falg)
  9476. $html .= '<td class="taR">-</td>';
  9477. }
  9478. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9479. $collectHtml [$value ['title']] = array (
  9480. 'html' => $html,
  9481. 'cid' => $value ['cid']
  9482. );
  9483. }
  9484. $data ['companyHtml'] = $collectHtml;
  9485. // total price html
  9486. $collectHtml = "";
  9487. $total = 0;
  9488. for($i = 1; $i <= 12; $i ++) {
  9489. $sumPrice = 0;
  9490. foreach ( $itemStatisticsList as $key => $value ) {
  9491. if ($value ['month'] == $i) {
  9492. $sumPrice += $value ['price'];
  9493. }
  9494. }
  9495. if ($sumPrice == 0)
  9496. $collectHtml .= '<td class="taR">-</td>';
  9497. else
  9498. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9499. $total += $sumPrice;
  9500. }
  9501. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9502. $data ['companyTotalHtml'] = $collectHtml;
  9503. $data ['total'] = $total;
  9504. // statistics html
  9505. // echo $cidString;
  9506. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9507. if (empty ( $stList ))
  9508. $stList = array (
  9509. 'rePrice' => 0,
  9510. 'agPrice' => 0
  9511. );
  9512. $data ['stList'] = array (
  9513. 'rePrice' => $stList ['rePrice'],
  9514. 'agPrice' => $stList ['agPrice'],
  9515. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9516. );
  9517. $data ['year'] = $year;
  9518. $data ['memu'] = "receipt";
  9519. $data ['staff'] = $this->staff;
  9520. $data ['receiptMemu'] = 'companyCategoryCollect';
  9521. $data ['verifyId'] = $this->verifyId;
  9522. $data ['executeId'] = $this->executeId;
  9523. $dateHtml = "";
  9524. $now = date ( "Y" );
  9525. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9526. if ($YEARD <= $now) {
  9527. $dateHtml .= '<option ';
  9528. if ($year == $YEARD) {
  9529. $dateHtml .= 'selected ';
  9530. }
  9531. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9532. }
  9533. }
  9534. $data ['dateHtml'] = $dateHtml;
  9535. // year staff status 2,4
  9536. if ($year < date ( "Y" )) {
  9537. Doo::loadModel ( 'receipt' );
  9538. $receipt = new receipt ();
  9539. $receiptList = $receipt->find ( array (
  9540. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  9541. 'asArray' => true
  9542. ) );
  9543. if (empty ( $receiptList )) {
  9544. ob_start ();
  9545. $this->render ( "/admin/saeaCompanyCollect", $data );
  9546. $this->cacheFile ( $path );
  9547. die ();
  9548. }
  9549. }
  9550. $this->render ( "/admin/saeaCompanyCollect", $data );
  9551. }
  9552. function categoryCollectDetail() {
  9553. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9554. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  9555. /* $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  9556. $this->showCache ( $path ); */
  9557. Doo::loadModel ( 'statistics' );
  9558. $statistics = new statistics ();
  9559. Doo::loadModel ( "receiptDetail" );
  9560. $receiptDetail = new receiptDetail ();
  9561. Doo::loadModel ( 'L_category' );
  9562. $Lcategory = new L_category ();
  9563. Doo::loadModel ( 'accountItem' );
  9564. $accountItem = new accountItem ();
  9565. Doo::loadModel ( "receiptAuthorityManage" );
  9566. $receiptAuthorityManage = new receiptAuthorityManage ();
  9567. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9568. $cidList = array ();
  9569. foreach ( $imcStaff as $key => $value ) {
  9570. array_push ( $cidList, $value ['cid'] );
  9571. }
  9572. $cidString = implode ( ',', $cidList );
  9573. $LcategoryList = $Lcategory->find ( array (
  9574. 'where' => 'cid in (' . $cidString . ')',
  9575. 'asArray' => true
  9576. ) );
  9577. if ($cid == 0) {
  9578. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9579. if ($cid == 0)
  9580. $cid = $LcategoryList [0] ['cid'];
  9581. }
  9582. $data ['LcategoryList'] = $LcategoryList;
  9583. $receiptCollectList = $receiptDetail->find ( array (
  9584. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9585. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9586. 'groupby' => 'item,Month(pastDate)',
  9587. 'asArray' => true
  9588. ) );
  9589. $accountList = $accountItem->find ( array (
  9590. 'asArray' => true
  9591. ) );
  9592. // create CollectDetail HTML
  9593. $collectHtml = array ();
  9594. foreach ( $accountList as $key => $value ) {
  9595. $html = "";
  9596. $asum = 0;
  9597. for($i = 1; $i <= 12; $i ++) {
  9598. $falg = true;
  9599. foreach ( $receiptCollectList as $v ) {
  9600. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9601. $asum += $v ['price'];
  9602. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9603. $falg = false;
  9604. break;
  9605. }
  9606. }
  9607. if ($falg)
  9608. $html .= '<td class="taR">-</td>';
  9609. }
  9610. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9611. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9612. }
  9613. $data ['collectHtml'] = $collectHtml;
  9614. // create Adjustment price html
  9615. $receiptCollectList = $receiptDetail->find ( array (
  9616. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9617. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9618. 'groupby' => 'itemCategory,Month(pastDate)',
  9619. 'asArray' => true
  9620. ) );
  9621. $adjustment = array ();
  9622. $collectArray = array (
  9623. '日常相关费用' => array (),
  9624. '差旅相关费用' => array (),
  9625. '培训班费用' => array (),
  9626. '内部培训费用'=>array(),
  9627. '其他' => array ()
  9628. );
  9629. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9630. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9631. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9632. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9633. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9634. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9635. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  9636. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  9637. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9638. array_push ( $collectArray ['其他'], $collectHtml );
  9639. $data ['collectArray'] = $collectArray;
  9640. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9641. array_push ( $adjustment, $collectHtml );
  9642. $data ['adjustment'] = $adjustment;
  9643. // total price html
  9644. $collectHtml = "";
  9645. $total = 0;
  9646. for($i = 1; $i <= 12; $i ++) {
  9647. $sumPrice = 0;
  9648. foreach ( $receiptCollectList as $key => $value ) {
  9649. if ($value ['month'] == $i) {
  9650. $sumPrice += $value ['price'];
  9651. }
  9652. }
  9653. if ($sumPrice == 0)
  9654. $collectHtml .= '<td class="taR">-</td>';
  9655. else
  9656. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9657. $total += $sumPrice;
  9658. }
  9659. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9660. // statistics html
  9661. $stList = $statistics->statisticsByCid ( $year, $cid );
  9662. if (empty ( $stList ))
  9663. $stList = array (
  9664. 'rePrice' => 0,
  9665. 'agPrice' => 0
  9666. );
  9667. $data ['stList'] = array (
  9668. 'rePrice' => $stList ['rePrice'],
  9669. 'agPrice' => $stList ['agPrice'],
  9670. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9671. );
  9672. $data ['totalYear'] = $total;
  9673. $data ['year'] = $year;
  9674. $data ['cid'] = $cid;
  9675. $data ['memu'] = "receipt";
  9676. $data ['staff'] = $this->staff;
  9677. $data ['receiptMemu'] = 'companyCategoryCollect';
  9678. $data ['verifyId'] = $this->verifyId;
  9679. $data ['executeId'] = $this->executeId;
  9680. // year staff status 2,4
  9681. /* if ($year < date ( "Y" )) {
  9682. Doo::loadModel ( 'receipt' );
  9683. $receipt = new receipt ();
  9684. $receiptList = $receipt->find ( array (
  9685. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  9686. 'asArray' => true
  9687. ) );
  9688. if (empty ( $receiptList )) {
  9689. ob_start ();
  9690. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  9691. $this->cacheFile ( $path );
  9692. die ();
  9693. }
  9694. } */
  9695. $dateHtml = "";
  9696. $now = date ( "Y" );
  9697. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9698. if ($YEARD <= $now) {
  9699. $dateHtml .= '<option ';
  9700. if ($year == $YEARD) {
  9701. $dateHtml .= 'selected ';
  9702. }
  9703. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9704. }
  9705. }
  9706. $data ['dateHtml'] = $dateHtml;
  9707. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  9708. }
  9709. function staffCollect() {
  9710. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9711. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ONJOB';//
  9712. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  9713. // $this->showCache($path);
  9714. Doo::loadModel ( 'statistics' );
  9715. $statistics = new statistics ();
  9716. Doo::loadModel ( "receiptDetail" );
  9717. $receiptDetail = new receiptDetail ();
  9718. Doo::loadModel ( 'L_category' );
  9719. $Lcategory = new L_category ();
  9720. Doo::loadModel ( 'accountItem' );
  9721. $accountItem = new accountItem ();
  9722. Doo::loadModel ( 'staff' );
  9723. $staff = new staff ();
  9724. Doo::loadModel ( 'itemStatistics' );
  9725. $itemStatistics = new itemStatistics ();
  9726. Doo::loadModel ( "receiptAuthorityManage" );
  9727. $receiptAuthorityManage = new receiptAuthorityManage ();
  9728. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9729. $cidList = array ();
  9730. foreach ( $imcStaff as $key => $value ) {
  9731. array_push ( $cidList, $value ['cid'] );
  9732. }
  9733. $cidString = implode ( ',', $cidList );
  9734. $naturecon='';
  9735. if ($nature=='ONJOB'){
  9736. $naturecon=' and (nature!=4 )';
  9737. }elseif($nature=='LEAVEJOB'){
  9738. $naturecon=' and (nature=4 )';
  9739. }else{
  9740. die ( 'illegal request--nature' );
  9741. }
  9742. // statistics html
  9743. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9744. if (empty ( $stList ))
  9745. $stList = array (
  9746. 'rePrice' => 0,
  9747. 'agPrice' => 0
  9748. );
  9749. $data ['stList'] = array (
  9750. 'rePrice' => $stList ['rePrice'],
  9751. 'agPrice' => $stList ['agPrice'],
  9752. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9753. );
  9754. // ---
  9755. $staffList = $staff->find ( array (
  9756. 'where' => 'username !="admin" '.$naturecon,
  9757. 'asArray' => true
  9758. ) );
  9759. $LcategoryList = $Lcategory->find ( array (
  9760. 'asArray' => true
  9761. ) ); // 'staff='.$this->staff[0]['sid']." and
  9762. $itemStatisticsList = $itemStatistics->find ( array (
  9763. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9764. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  9765. 'groupby' => 'staff,Month(date)',
  9766. 'asArray' => true
  9767. ) );
  9768. $categoryList = $staff->find ( array (
  9769. 'select' => 'COUNT(*) as count,cid,category',
  9770. 'where' => 'username !="admin" and cid in (' . $cidString . ') '.$naturecon,
  9771. 'groupby' => 'cid',
  9772. 'asArray' => true
  9773. ) );
  9774. // print_r($itemStatisticsList);die;
  9775. // ceatre companyCollectHtml
  9776. foreach ( $categoryList as $vlu ) {
  9777. $count = $vlu ['count'] + 1;
  9778. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  9779. $m1 = 0;
  9780. $m2 = 0;
  9781. $m3 = 0;
  9782. $m4 = 0;
  9783. $m5 = 0;
  9784. $m6 = 0;
  9785. $m7 = 0;
  9786. $m8 = 0;
  9787. $m9 = 0;
  9788. $m10 = 0;
  9789. $m11 = 0;
  9790. $m12 = 0;
  9791. $m13 = 0;
  9792. foreach ( $staffList as $value ) {
  9793. if ($vlu ['cid'] == $value ['cid']) {
  9794. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  9795. $asum = 0;
  9796. for($i = 1; $i <= 12; $i ++) {
  9797. $falg = true;
  9798. foreach ( $itemStatisticsList as $v ) {
  9799. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  9800. if ($v ['month'] == 1)
  9801. $m1 += $v ['price'];
  9802. if ($v ['month'] == 2)
  9803. $m2 += $v ['price'];
  9804. if ($v ['month'] == 3)
  9805. $m3 += $v ['price'];
  9806. if ($v ['month'] == 4)
  9807. $m4 += $v ['price'];
  9808. if ($v ['month'] == 5)
  9809. $m5 += $v ['price'];
  9810. if ($v ['month'] == 6)
  9811. $m6 += $v ['price'];
  9812. if ($v ['month'] == 7)
  9813. $m7 += $v ['price'];
  9814. if ($v ['month'] == 8)
  9815. $m8 += $v ['price'];
  9816. if ($v ['month'] == 9)
  9817. $m9 += $v ['price'];
  9818. if ($v ['month'] == 10)
  9819. $m10 += $v ['price'];
  9820. if ($v ['month'] == 11)
  9821. $m11 += $v ['price'];
  9822. if ($v ['month'] == 12)
  9823. $m12 += $v ['price'];
  9824. $asum += $v ['price'];
  9825. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9826. $falg = false;
  9827. break;
  9828. }
  9829. }
  9830. if ($falg)
  9831. $html .= '<td class="taR">-</td>';
  9832. }
  9833. $m13 += $asum;
  9834. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9835. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  9836. 'html' => $html,
  9837. 'sid' => $value ['sid']
  9838. );
  9839. $html = "";
  9840. }
  9841. }
  9842. $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>
  9843. <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>
  9844. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  9845. $collectHtml [$vlu ['cid']] = array (
  9846. 'html' => $hl,
  9847. 'sid' => ''
  9848. );
  9849. }
  9850. $data ['companyHtml'] = $collectHtml;
  9851. // total price html
  9852. $collectHtml = "";
  9853. $total = 0;
  9854. for($i = 1; $i <= 12; $i ++) {
  9855. $sumPrice = 0;
  9856. foreach ( $itemStatisticsList as $key => $value ) {
  9857. if ($value ['month'] == $i) {
  9858. $sumPrice += $value ['price'];
  9859. }
  9860. }
  9861. if ($sumPrice == 0)
  9862. $collectHtml .= '<td class="taR">-</td>';
  9863. else
  9864. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9865. $total += $sumPrice;
  9866. }
  9867. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9868. $data ['companyTotalHtml'] = $collectHtml;
  9869. $data ['total'] = $total;
  9870. $data ['nature'] =$nature;
  9871. $data ['year'] = $year;
  9872. $data ['memu'] = "receipt";
  9873. $data ['staff'] = $this->staff;
  9874. $data ['receiptMemu'] = 'companyCategoryCollect';
  9875. $data ['verifyId'] = $this->verifyId;
  9876. $data ['executeId'] = $this->executeId;
  9877. if ($year <= date ( "Y" )) {
  9878. Doo::loadModel ( 'receipt' );
  9879. $receipt = new receipt ();
  9880. $receiptList = $receipt->find ( array (
  9881. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  9882. 'asArray' => true
  9883. ) );
  9884. if (empty ( $receiptList )) { // generated files
  9885. ob_start ();
  9886. $this->render ( "/admin/saeaStaffCollectB", $data );
  9887. $this->cacheFile ( $path );
  9888. die ();
  9889. }
  9890. }
  9891. $this->render ( "/admin/saeaStaffCollectB", $data );
  9892. }
  9893. function staffCollectBak() {
  9894. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9895. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  9896. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  9897. $this->showCache ( $path );
  9898. Doo::loadModel ( 'statistics' );
  9899. $statistics = new statistics ();
  9900. Doo::loadModel ( "receiptDetail" );
  9901. $receiptDetail = new receiptDetail ();
  9902. Doo::loadModel ( 'L_category' );
  9903. $Lcategory = new L_category ();
  9904. Doo::loadModel ( 'accountItem' );
  9905. $accountItem = new accountItem ();
  9906. Doo::loadModel ( 'staff' );
  9907. $staff = new staff ();
  9908. Doo::loadModel ( 'itemStatistics' );
  9909. $itemStatistics = new itemStatistics ();
  9910. $itemStatisticsList = $itemStatistics->find ( array (
  9911. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9912. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9913. 'groupby' => 'staff,itemCategory,Month(date)',
  9914. 'asArray' => true
  9915. ) );
  9916. $itemCategoryList = $itemStatistics->find ( array (
  9917. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9918. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9919. 'groupby' => 'cid,itemCategory,Month(date)',
  9920. 'asArray' => true
  9921. ) );
  9922. $LcategoryList = $Lcategory->find ( array (
  9923. 'asArray' => true
  9924. ) );
  9925. $staffList = $staff->find ( array (
  9926. 'asArray' => true
  9927. ) );
  9928. $htmlArray = array ();
  9929. foreach ( $LcategoryList as $value ) {
  9930. $htmlArray [$value ['title']] = array ();
  9931. foreach ( $staffList as $v ) {
  9932. if ($value ['cid'] == $v ['cid']) {
  9933. $html = "";
  9934. $falg = true;
  9935. $staffSumPrice = 0;
  9936. foreach ( $itemStatisticsList as $a ) {
  9937. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  9938. if (empty ( $a ['price'] )) {
  9939. $html .= '<td class="taR">-</td>';
  9940. $falg = false;
  9941. break;
  9942. } else {
  9943. $staffSumPrice += $a ['price'];
  9944. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9945. $falg = false;
  9946. break;
  9947. }
  9948. }
  9949. }
  9950. if ($falg) {
  9951. $html .= '<td class="taR">-</td>';
  9952. $falg = true;
  9953. }
  9954. $falg = true;
  9955. foreach ( $itemStatisticsList as $a ) {
  9956. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  9957. if (empty ( $a ['price'] )) {
  9958. $html .= '<td class="taR">-</td>';
  9959. $falg = false;
  9960. break;
  9961. } else {
  9962. $staffSumPrice += $a ['price'];
  9963. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9964. $falg = false;
  9965. break;
  9966. }
  9967. }
  9968. }
  9969. if ($falg) {
  9970. $html .= '<td class="taR">-</td>';
  9971. $falg = true;
  9972. }
  9973. $falg = true;
  9974. foreach ( $itemStatisticsList as $a ) {
  9975. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  9976. if (empty ( $a ['price'] )) {
  9977. $html .= '<td class="taR">-</td>';
  9978. $falg = false;
  9979. break;
  9980. } else {
  9981. $staffSumPrice += $a ['price'];
  9982. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9983. $falg = false;
  9984. break;
  9985. }
  9986. }
  9987. }
  9988. if ($falg) {
  9989. $html .= '<td class="taR">-</td>';
  9990. $falg = true;
  9991. }
  9992. $falg = true;
  9993. foreach ( $itemStatisticsList as $a ) {
  9994. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  9995. if (! empty ( $a ['price'] )) {
  9996. $staffSumPrice += $a ['price'];
  9997. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9998. $falg = false;
  9999. break;
  10000. } else {
  10001. $html .= '<td class="taR">-</td>';
  10002. $falg = false;
  10003. break;
  10004. }
  10005. }
  10006. }
  10007. if ($falg) {
  10008. $html .= '<td class="taR">-</td>';
  10009. $falg = true;
  10010. }
  10011. $falg = true;
  10012. foreach ( $itemStatisticsList as $a ) {
  10013. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  10014. if (! empty ( $a ['price'] )) {
  10015. $staffSumPrice += $a ['price'];
  10016. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10017. $falg = false;
  10018. break;
  10019. } else {
  10020. $html .= '<td class="taR">-</td>';
  10021. $falg = false;
  10022. break;
  10023. }
  10024. }
  10025. }
  10026. if ($falg) {
  10027. $html .= '<td class="taR">-</td>';
  10028. $falg = true;
  10029. }
  10030. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  10031. $htmlArray [$value ['title']] [$v ['username']] = $html;
  10032. }
  10033. }
  10034. /* -- --- */
  10035. // 合计费用
  10036. $cateHtml = "";
  10037. $catePrice = 0;
  10038. $cateFalg = true;
  10039. foreach ( $itemCategoryList as $l ) {
  10040. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  10041. if (empty ( $l ['price'] )) {
  10042. $cateHtml .= '<td class="colGreen taR">-</td>';
  10043. $cateFalg = false;
  10044. break;
  10045. } else {
  10046. $catePrice += $l ['price'];
  10047. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10048. $cateFalg = false;
  10049. break;
  10050. }
  10051. }
  10052. }
  10053. if ($cateFalg) {
  10054. $cateHtml .= '<td class="colGreen taR">-</td>';
  10055. $cateFalg = true;
  10056. }
  10057. $cateFalg = true;
  10058. foreach ( $itemCategoryList as $l ) {
  10059. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  10060. if (empty ( $l ['price'] )) {
  10061. $cateHtml .= '<td class="colGreen taR">-</td>';
  10062. $cateFalg = false;
  10063. break;
  10064. } else {
  10065. $catePrice += $l ['price'];
  10066. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10067. $cateFalg = false;
  10068. break;
  10069. }
  10070. }
  10071. }
  10072. if ($cateFalg) {
  10073. $cateHtml .= '<td class="colGreen taR">-</td>';
  10074. $cateFalg = true;
  10075. }
  10076. $cateFalg = true;
  10077. foreach ( $itemCategoryList as $l ) {
  10078. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  10079. if (empty ( $l ['price'] )) {
  10080. $cateHtml .= '<td class="colGreen taR">-</td>';
  10081. $cateFalg = false;
  10082. break;
  10083. } else {
  10084. $catePrice += $l ['price'];
  10085. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10086. $cateFalg = false;
  10087. break;
  10088. }
  10089. }
  10090. }
  10091. if ($cateFalg) {
  10092. $cateHtml .= '<td class="colGreen taR">-</td>';
  10093. $cateFalg = true;
  10094. }
  10095. $cateFalg = true;
  10096. foreach ( $itemCategoryList as $l ) {
  10097. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  10098. if (empty ( $l ['price'] )) {
  10099. $cateHtml .= '<td class="colGreen taR">-</td>';
  10100. $cateFalg = false;
  10101. break;
  10102. } else {
  10103. $catePrice += $l ['price'];
  10104. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10105. $cateFalg = false;
  10106. break;
  10107. }
  10108. }
  10109. }
  10110. if ($cateFalg) {
  10111. $cateHtml .= '<td class="colGreen taR">-</td>';
  10112. $cateFalg = true;
  10113. }
  10114. $cateFalg = true;
  10115. foreach ( $itemCategoryList as $l ) {
  10116. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  10117. if (empty ( $l ['price'] )) {
  10118. $cateHtml .= '<td class="colGreen taR">-</td>';
  10119. $cateFalg = false;
  10120. break;
  10121. } else {
  10122. $catePrice += $l ['price'];
  10123. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10124. $cateFalg = false;
  10125. break;
  10126. }
  10127. }
  10128. }
  10129. if ($cateFalg) {
  10130. $cateHtml .= '<td class="colGreen taR">-</td>';
  10131. $cateFalg = true;
  10132. }
  10133. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  10134. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  10135. /* -- --- */
  10136. }
  10137. // print_r($htmlArray);die;
  10138. $data ['htmlArray'] = $htmlArray;
  10139. // statistics html
  10140. $stList = $statistics->getOne ( array (
  10141. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  10142. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10143. 'groupby' => 'Month(date)',
  10144. 'asArray' => true
  10145. ) );
  10146. if (empty ( $stList ))
  10147. $stList = array (
  10148. 'rePrice' => 0,
  10149. 'agPrice' => 0
  10150. );
  10151. $data ['stList'] = array (
  10152. 'rePrice' => $stList ['rePrice'],
  10153. 'agPrice' => $stList ['agPrice'],
  10154. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10155. );
  10156. $monthHtml = "";
  10157. for($i = 1; $i <= 12; $i ++) {
  10158. if ($i == $month)
  10159. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  10160. else
  10161. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  10162. }
  10163. $data ['monthHtml'] = $monthHtml;
  10164. $data ['year'] = $year;
  10165. $data ['month'] = $month;
  10166. $data ['memu'] = "receipt";
  10167. $data ['staff'] = $this->staff;
  10168. $data ['receiptMemu'] = 'companyCategoryCollect';
  10169. $data ['verifyId'] = $this->verifyId;
  10170. $data ['executeId'] = $this->executeId;
  10171. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  10172. Doo::loadModel ( 'receipt' );
  10173. $receipt = new receipt ();
  10174. $receiptList = $receipt->find ( array (
  10175. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  10176. 'asArray' => true
  10177. ) );
  10178. if (empty ( $receiptList )) { // generated files
  10179. ob_start ();
  10180. $this->render ( "/admin/saeaStaffCollect", $data );
  10181. $this->cacheFile ( $path );
  10182. die ();
  10183. }
  10184. }
  10185. $this->render ( "/admin/saeaStaffCollect", $data );
  10186. }
  10187. /**
  10188. * 日常收支
  10189. */
  10190. function payments() {
  10191. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  10192. Doo::loadModel ( "execute" );
  10193. $execute = new execute ();
  10194. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  10195. die ( 'illegal request' );
  10196. }
  10197. Doo::loadModel ( "accountBook" );
  10198. $accountBook = new accountBook ();
  10199. Doo::loadModel ( "accountBookStatistics" );
  10200. $accountBookStatistics = new accountBookStatistics ();
  10201. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  10202. $list = $accountBook->getAccountBookByLimit ( 10 );
  10203. $data ['date'] = date ( "Y-m-d" );
  10204. $data ['statisticsList'] = $statisticsList;
  10205. $data ['list'] = $list;
  10206. $data ['memu'] = "receipt";
  10207. $data ['staff'] = $this->staff;
  10208. $data ['receiptMemu'] = 'payments';
  10209. $data ['verifyId'] = $this->verifyId;
  10210. $data ['executeId'] = $this->executeId;
  10211. $this->render ( "/expenses/payments", $data );
  10212. }
  10213. function paymentsIncomeDo() {
  10214. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10215. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10216. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10217. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10218. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10219. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10220. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10221. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10222. Doo::loadClass ( 'XDeode' );
  10223. $XDeode = new XDeode ( 5 );
  10224. Doo::loadModel ( "accountBook" );
  10225. Doo::loadModel ( "accountBookStatistics" );
  10226. Doo::loadModel ( 'wasteBook' );
  10227. // 记录流水时银行的转换
  10228. $accountBank = '';
  10229. if ($receivedBank == '纵横广发') {
  10230. $accountBank = 'CGBDeposit';
  10231. } elseif ($receivedBank == '纵横工行') {
  10232. $accountBank = 'ICBCDeposit';
  10233. } elseif ($receivedBank == '华润银行') {
  10234. $accountBank = 'HUADeposit';
  10235. } elseif ($receivedBank == '个人广发') {
  10236. $accountBank = 'PersonalDeposit';
  10237. }
  10238. if (empty ( $accountBank ))
  10239. die ( 'illegal request' );
  10240. // 收入为理财时特殊处理
  10241. if ($accountType == 7 || $accountType == 9) {
  10242. if ($receivedBank == '个人广发') {
  10243. die ( '个人广发 illegal request' );
  10244. }
  10245. // 添加一条收入
  10246. $accountBook = new accountBook ();
  10247. $accountBook->accountType = 10;
  10248. $accountBook->accountMsg = $accountMsg;
  10249. $accountBook->receivedPrice = $receivedPrice;
  10250. $accountBook->receivedMsg = $receivedMsg;
  10251. $accountBook->receivedBank = $receivedBank;
  10252. $accountBook->receivedDate = $receivedDate;
  10253. $accountBook->remarks = $remarks;
  10254. $accountBook->expensesType = 1;
  10255. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10256. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10257. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10258. $inComeId = $accountBook->insert ();
  10259. // 收支汇总-添加一条收入日常汇总
  10260. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10261. $accountBookStatistics = new accountBookStatistics ();
  10262. $item = array (
  10263. 'date' => date ( "Y-m-d" ),
  10264. 'accountType' => $abDetail ['accountType'],
  10265. 'accountMsg' => $abDetail ['accountMsg'],
  10266. 'aid' => $abDetail ['aid'],
  10267. 'inComePrice' => $abDetail ['receivedPrice'],
  10268. 'expensesType' => $abDetail ['expensesType']
  10269. );
  10270. $accountBookStatistics->setAccountBookStatistics ( $item );
  10271. // 添加收入流水
  10272. $wasteBook = new wasteBook ();
  10273. $itemWaste = array (
  10274. 'accountPriceShow' => $receivedPrice,
  10275. 'accountPrice' => $receivedPrice,
  10276. 'expensesType' => 1,
  10277. 'accountType' => 6, // 流水类型
  10278. 'dataID' => $inComeId,
  10279. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10280. 'accountBank' => $accountBank,
  10281. 'category' => $this->staff [0] ['category'],
  10282. 'cid' => $this->staff [0] ['cid'],
  10283. 'name' => $this->staff [0] ['username'],
  10284. 'sid' => $this->staff [0] ['sid'],
  10285. 'inputDate' => date ( "Y-m-d H:i:s" )
  10286. );
  10287. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10288. // 添加一条理财支出
  10289. $accountBank = 'CGBDeposit';
  10290. $expenditureBank = '纵横广发';
  10291. $dailyExpenditureType = 4;
  10292. if ($accountType == 9) {
  10293. $accountBank = 'ICBCDeposit';
  10294. $expenditureBank = '纵横工行';
  10295. $dailyExpenditureType = 6;
  10296. }
  10297. $accountBook = new accountBook ();
  10298. $accountBook->expensesType = 2;
  10299. $accountBook->expenditureType = $dailyExpenditureType;
  10300. $accountBook->expenditureMsg = $accountMsg;
  10301. $accountBook->expenditurePrice = $receivedPrice;
  10302. $accountBook->expenditureBank = $expenditureBank;
  10303. $accountBook->expenditureDate = $receivedDate;
  10304. $accountBook->remarks = $remarks;
  10305. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10306. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10307. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10308. $id = $accountBook->insert ();
  10309. // 收支汇总-添加一条理财支出汇总
  10310. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10311. $accountBookStatistics = new accountBookStatistics ();
  10312. $item = array (
  10313. 'date' => date ( "Y-m-d" ),
  10314. 'accountType' => $abDetail ['accountType'],
  10315. 'accountMsg' => $abDetail ['accountMsg'],
  10316. 'aid' => $abDetail ['aid'],
  10317. 'financingPrice' => - $receivedPrice,
  10318. 'expensesType' => 3
  10319. );
  10320. $accountBookStatistics->setAccountBookStatistics ( $item );
  10321. // 添加一条支出理财流水
  10322. $accountTypeWaste = 5;
  10323. if ($accountMsg == '公司固定') {
  10324. $accountTypeWaste = 9;
  10325. } elseif ($accountMsg == '公司活期') {
  10326. $accountTypeWaste = 10;
  10327. } elseif ($accountMsg == '个人(GR)') {
  10328. $accountBank = 'PersonalDeposit';
  10329. }
  10330. $itemWaste = array (
  10331. 'expensesType' => 2,
  10332. 'accountType' => $accountTypeWaste,
  10333. 'accountPriceShow' => $receivedPrice,
  10334. 'accountPrice' => - $receivedPrice,
  10335. 'dataID' => $id,
  10336. 'dailyExpenditureType' => $dailyExpenditureType,
  10337. 'accountBank' => $accountBank,
  10338. 'category' => $this->staff [0] ['category'],
  10339. 'cid' => $this->staff [0] ['cid'],
  10340. 'name' => $this->staff [0] ['username'],
  10341. 'sid' => $this->staff [0] ['sid'],
  10342. 'inputDate' => date ( "Y-m-d H:i:s" )
  10343. );
  10344. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10345. } elseif ($accountType == 1) {
  10346. if ($receivedBank == '个人广发')
  10347. die ( 'illegal request' );
  10348. // 添加一条收入
  10349. $accountBook = new accountBook ();
  10350. $accountBook->accountType = $accountType;
  10351. $accountBook->accountMsg = $accountMsg;
  10352. $accountBook->receivedPrice = $receivedPrice;
  10353. $accountBook->receivedMsg = $receivedMsg;
  10354. $accountBook->receivedBank = $receivedBank;
  10355. $accountBook->receivedDate = $receivedDate;
  10356. $accountBook->remarks = $remarks;
  10357. $accountBook->expensesType = 1;
  10358. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10359. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10360. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10361. $id = $accountBook->insert ();
  10362. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10363. // 收支汇总-添加一条收入日常汇总
  10364. $accountBookStatistics = new accountBookStatistics ();
  10365. $item = array (
  10366. 'date' => date ( "Y-m-d" ),
  10367. 'accountType' => $abDetail ['accountType'],
  10368. 'accountMsg' => $abDetail ['accountMsg'],
  10369. 'aid' => $abDetail ['aid'],
  10370. 'expensesType' => $abDetail ['expensesType']
  10371. );
  10372. if ($abDetail ['accountType'] == 8) {
  10373. $item += array (
  10374. 'inComePrice' => $abDetail ['receivedPrice']
  10375. );
  10376. } else {
  10377. $item += array (
  10378. 'inComePrice' => $abDetail ['receivedPrice']
  10379. );
  10380. }
  10381. $accountBookStatistics->setAccountBookStatistics ( $item );
  10382. // 流水存储方向
  10383. $itemWaste = array (
  10384. 'accountType' => 6
  10385. ); // 流水类型
  10386. // if($accountMsg=='银行存款'||$accountMsg=='固定理财收益'){
  10387. // }else
  10388. if ($accountMsg == '活期理财收益') {
  10389. $itemWaste = array (
  10390. 'accountType' => 10
  10391. ); // 流水类型
  10392. }
  10393. // 添加收入流水
  10394. $wasteBook = new wasteBook ();
  10395. $itemWaste += array (
  10396. 'accountPrice' => $receivedPrice,
  10397. 'accountPriceShow' => $receivedPrice,
  10398. 'expensesType' => 1,
  10399. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10400. 'dataID' => $id,
  10401. 'accountBank' => $accountBank,
  10402. 'category' => $this->staff [0] ['category'],
  10403. 'cid' => $this->staff [0] ['cid'],
  10404. 'name' => $this->staff [0] ['username'],
  10405. 'sid' => $this->staff [0] ['sid'],
  10406. 'inputDate' => date ( "Y-m-d H:i:s" )
  10407. );
  10408. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10409. } else { // 普通日常收入处理
  10410. // 添加一条收入
  10411. $accountBook = new accountBook ();
  10412. $accountBook->accountType = $accountType;
  10413. $accountBook->accountMsg = $accountMsg;
  10414. $accountBook->receivedPrice = $receivedPrice;
  10415. $accountBook->receivedMsg = $receivedMsg;
  10416. $accountBook->receivedBank = $receivedBank;
  10417. $accountBook->receivedDate = $receivedDate;
  10418. $accountBook->remarks = $remarks;
  10419. $accountBook->expensesType = 1;
  10420. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10421. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10422. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10423. $id = $accountBook->insert ();
  10424. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10425. // 收支汇总-添加一条收入日常汇总
  10426. $accountBookStatistics = new accountBookStatistics ();
  10427. $item = array (
  10428. 'date' => date ( "Y-m-d" ),
  10429. 'accountType' => $abDetail ['accountType'],
  10430. 'accountMsg' => $abDetail ['accountMsg'],
  10431. 'aid' => $abDetail ['aid'],
  10432. 'expensesType' => $abDetail ['expensesType']
  10433. );
  10434. if ($abDetail ['accountType'] == 8) {
  10435. $item += array (
  10436. 'inComePrice' => $abDetail ['receivedPrice']
  10437. );
  10438. } else {
  10439. $item += array (
  10440. 'inComePrice' => $abDetail ['receivedPrice']
  10441. );
  10442. }
  10443. $accountBookStatistics->setAccountBookStatistics ( $item );
  10444. // 添加收入流水
  10445. $itemWaste = array (
  10446. 'accountPrice' => $receivedPrice
  10447. );
  10448. if ($receivedBank == '个人广发') {
  10449. $itemWaste = array (
  10450. 'accountPrice' => - $receivedPrice
  10451. );
  10452. }
  10453. $wasteBook = new wasteBook ();
  10454. $itemWaste += array (
  10455. 'accountPriceShow' => $receivedPrice,
  10456. 'expensesType' => 1,
  10457. 'accountType' => 6, // 流水类型
  10458. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10459. 'dataID' => $id,
  10460. 'accountBank' => $accountBank,
  10461. 'category' => $this->staff [0] ['category'],
  10462. 'cid' => $this->staff [0] ['cid'],
  10463. 'name' => $this->staff [0] ['username'],
  10464. 'sid' => $this->staff [0] ['sid'],
  10465. 'inputDate' => date ( "Y-m-d H:i:s" )
  10466. );
  10467. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10468. }
  10469. }
  10470. return '/payments';
  10471. }
  10472. /**
  10473. * 添加收入
  10474. * @return string
  10475. */
  10476. function paymentsIncomeDo_() {
  10477. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10478. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10479. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10480. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10481. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10482. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10483. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10484. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10485. Doo::loadClass ( 'XDeode' );
  10486. $XDeode = new XDeode ( 5 );
  10487. Doo::loadModel ( "accountBook" );
  10488. $accountBook = new accountBook ();
  10489. $accountBank = '';
  10490. $accountTypeWaste = 6;
  10491. if ($receivedBank == '纵横广发') {
  10492. $accountBank = 'CGBDeposit';
  10493. } elseif ($receivedBank == '纵横工行') {
  10494. $accountBank = 'ICBCDeposit';
  10495. } elseif ($receivedBank == '华润银行') {
  10496. $accountBank = 'HUADeposit';
  10497. } elseif ($receivedBank == '个人广发') {
  10498. $accountBank = 'PersonalDeposit';
  10499. }
  10500. if (empty ( $accountBank ))
  10501. die ( 'illegal request' );
  10502. $dailyIncomeType = '';
  10503. $itemWaste = array (
  10504. 'accountPrice' => $receivedPrice,
  10505. 'expensesType' => 1
  10506. );
  10507. if ($receivedBank == '个人广发') {
  10508. $itemWaste = array (
  10509. 'accountPrice' => - $receivedPrice,
  10510. 'expensesType' => 1
  10511. );
  10512. }
  10513. if ($accountType == 4) {
  10514. $dailyIncomeType = 4;
  10515. } elseif ($accountType == 1) {
  10516. $dailyIncomeType = 1;
  10517. } elseif ($accountType == 2) {
  10518. $dailyIncomeType = 2;
  10519. } elseif ($accountType == 3) {
  10520. $dailyIncomeType = 3;
  10521. } elseif ($accountType == 5) {
  10522. $dailyIncomeType = 5;
  10523. } elseif ($accountType == 6) {
  10524. $dailyIncomeType = 6;
  10525. } elseif ($accountType == 7 || $accountType == 9) {
  10526. $dailyIncomeType = 7;
  10527. if ($accountMsg == '公司固定') {
  10528. $accountTypeWaste = 9;
  10529. } elseif ($accountMsg == '公司活期') {
  10530. $accountTypeWaste = 10;
  10531. } elseif ($accountMsg == '个人(GR)') {
  10532. $accountBank = 'PersonalDeposit';
  10533. }
  10534. $itemWaste = array (
  10535. 'accountPrice' => - $receivedPrice,
  10536. 'expensesType' => 2
  10537. );
  10538. } elseif ($accountType == 8) {
  10539. $dailyIncomeType = 8;
  10540. }
  10541. if (empty ( $dailyIncomeType ))
  10542. die ( 'illegal request' );
  10543. $accountBook->accountType = $accountType;
  10544. $accountBook->accountMsg = $accountMsg;
  10545. $accountBook->receivedPrice = $receivedPrice;
  10546. $accountBook->receivedMsg = $receivedMsg;
  10547. $accountBook->receivedBank = $receivedBank;
  10548. $accountBook->receivedDate = $receivedDate;
  10549. $accountBook->remarks = $remarks;
  10550. $accountBook->expensesType = 1;
  10551. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10552. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10553. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10554. $id = $accountBook->insert ();
  10555. //
  10556. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10557. // 收支汇总
  10558. Doo::loadModel ( "accountBookStatistics" );
  10559. $accountBookStatistics = new accountBookStatistics ();
  10560. $item = array (
  10561. 'date' => date ( "Y-m-d" ),
  10562. 'accountType' => $abDetail ['accountType'],
  10563. 'accountMsg' => $abDetail ['accountMsg'],
  10564. 'aid' => $abDetail ['aid']
  10565. );
  10566. if ($abDetail ['expensesType'] == 1) {
  10567. if ($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) {
  10568. $item += array (
  10569. 'financingPrice' => - $receivedPrice,
  10570. 'expensesType' => 3
  10571. );
  10572. } else if ($abDetail ['accountType'] == 8) {
  10573. $item += array (
  10574. 'inComePrice' => - $abDetail ['receivedPrice'],
  10575. 'expensesType' => $abDetail ['expensesType']
  10576. );
  10577. } else {
  10578. $item += array (
  10579. 'inComePrice' => $abDetail ['receivedPrice'],
  10580. 'expensesType' => $abDetail ['expensesType']
  10581. );
  10582. }
  10583. }
  10584. $accountBookStatistics->setAccountBookStatistics ( $item );
  10585. // 为理财时需添加一条日常支出
  10586. if ($accountType == 7 || $accountType == 9) {
  10587. }
  10588. // 公司流水记录
  10589. Doo::loadModel ( 'wasteBook' );
  10590. $wasteBook = new wasteBook ();
  10591. // 银行
  10592. // if (empty($abDetail)){
  10593. $itemWaste += array (
  10594. 'accountPriceShow' => $receivedPrice,
  10595. 'dataID' => $id,
  10596. 'accountType' => $accountTypeWaste,
  10597. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10598. 'accountBank' => $accountBank,
  10599. 'category' => $this->staff [0] ['category'],
  10600. 'cid' => $this->staff [0] ['cid'],
  10601. 'name' => $this->staff [0] ['username'],
  10602. 'sid' => $this->staff [0] ['sid'],
  10603. 'inputDate' => date ( "Y-m-d H:i:s" )
  10604. );
  10605. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10606. // }
  10607. // 类型为理财7或者9 要添加一笔理财支出
  10608. if ($accountType == 7 || $accountType == 9) {
  10609. $accountBank = 'CGBDeposit';
  10610. $expenditureBank = '纵横广发';
  10611. $dailyExpenditureType = 4;
  10612. if ($accountType == 9) {
  10613. $accountBank = 'ICBCDeposit';
  10614. $expenditureBank = '纵横工行';
  10615. $dailyExpenditureType = 6;
  10616. }
  10617. // 添加一条支出
  10618. $accountBook = new accountBook ();
  10619. $accountBook->expenditureType = $dailyExpenditureType;
  10620. $accountBook->expenditureMsg = $accountMsg;
  10621. $accountBook->expenditurePrice = $receivedPrice;
  10622. $accountBook->expenditureBank = $expenditureBank;
  10623. $accountBook->expenditureDate = $receivedDate;
  10624. $accountBook->remarks = $remarks;
  10625. $accountBook->expensesType = 2;
  10626. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10627. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10628. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10629. $id = $accountBook->insert ();
  10630. // 添加一条收入流水
  10631. $itemWaste = array (
  10632. 'accountPriceShow' => $receivedPrice,
  10633. 'accountPrice' => $receivedPrice,
  10634. 'dataID' => $id,
  10635. 'expensesType' => 2,
  10636. 'accountType' => $accountTypeWaste,
  10637. 'dailyExpenditureType' => $dailyExpenditureType,
  10638. 'accountBank' => $accountBank,
  10639. 'category' => $this->staff [0] ['category'],
  10640. 'cid' => $this->staff [0] ['cid'],
  10641. 'name' => $this->staff [0] ['username'],
  10642. 'sid' => $this->staff [0] ['sid'],
  10643. 'inputDate' => date ( "Y-m-d H:i:s" )
  10644. );
  10645. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10646. }
  10647. }
  10648. return '/payments';
  10649. }
  10650. function paymentsExpenditureDo() {
  10651. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10652. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10653. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10654. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10655. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10656. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10657. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10658. // 理财支出特殊处理
  10659. Doo::loadModel ( "accountBook" );
  10660. Doo::loadModel ( "accountBookStatistics" );
  10661. Doo::loadModel ( 'wasteBook' );
  10662. $accountBank = '';
  10663. if ($expenditureBank == '纵横广发') {
  10664. $accountBank = 'CGBDeposit';
  10665. } elseif ($expenditureBank == '纵横工行') {
  10666. $accountBank = 'ICBCDeposit';
  10667. } elseif ($expenditureBank == '华润银行') {
  10668. $accountBank = 'HUADeposit';
  10669. } elseif ($expenditureBank == '个人广发') {
  10670. $accountBank = 'PersonalDeposit';
  10671. }
  10672. if (empty ( $accountBank ))
  10673. die ( 'illegal request' );
  10674. if ($expenditureType == 4 || $expenditureType == 6) {
  10675. if ($expenditureBank == '个人广发') {
  10676. die ( '个人广发 illegal request' );
  10677. }
  10678. // 添加一笔日常支出
  10679. $accountBook = new accountBook ();
  10680. $accountBook->expensesType = 2;
  10681. $accountBook->expenditureType = 7;
  10682. $accountBook->expenditureMsg = $expenditureMsg;
  10683. $accountBook->expenditurePrice = $expenditurePrice;
  10684. $accountBook->expenditureBank = $expenditureBank;
  10685. $accountBook->expenditureDate = $expenditureDate;
  10686. $accountBook->remarks = $remarks;
  10687. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10688. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10689. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10690. $expenditureId = $accountBook->insert ();
  10691. // 添加日常支出汇总
  10692. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  10693. $accountBookStatistics = new accountBookStatistics ();
  10694. $item = array (
  10695. 'date' => date ( "Y-m-d" ),
  10696. 'expenditureType' => $abDetail ['expenditureType'],
  10697. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10698. 'aid' => $abDetail ['aid'],
  10699. 'payPrice' => $abDetail ['expenditurePrice'],
  10700. 'expensesType' => $abDetail ['expensesType']
  10701. );
  10702. $accountBookStatistics->setAccountBookStatistics ( $item );
  10703. // 公司日常支出流水
  10704. $wasteBook = new wasteBook ();
  10705. $itemWaste = array (
  10706. 'accountPrice' => - $expenditurePrice
  10707. );
  10708. if ($expenditureBank == '个人广发') {
  10709. $itemWaste = array (
  10710. 'accountPrice' => $expenditurePrice
  10711. );
  10712. }
  10713. $itemWaste += array (
  10714. 'expensesType' => 2,
  10715. 'accountType' => 5,
  10716. 'dailyExpenditureType' => $expenditureType,
  10717. 'accountPriceShow' => $expenditurePrice,
  10718. 'accountPrice' => - $expenditurePrice,
  10719. 'dataID' => $expenditureId,
  10720. 'accountBank' => $accountBank,
  10721. 'category' => $this->staff [0] ['category'],
  10722. 'cid' => $this->staff [0] ['cid'],
  10723. 'name' => $this->staff [0] ['username'],
  10724. 'sid' => $this->staff [0] ['sid'],
  10725. 'inputDate' => date ( "Y-m-d H:i:s" )
  10726. );
  10727. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10728. // 添加一笔理财收入
  10729. $accountBank = 'CGBDeposit';
  10730. $dailyIncomeType = 7;
  10731. $receivedBank = '纵横广发';
  10732. if ($expenditureType == 6) {
  10733. $accountBank = 'ICBCDeposit';
  10734. $receivedBank = '纵横工行';
  10735. $dailyIncomeType = 9;
  10736. }
  10737. $accountBook = new accountBook ();
  10738. $accountBook->expensesType = 1;
  10739. $accountBook->accountType = $dailyIncomeType;
  10740. $accountBook->accountMsg = $expenditureMsg;
  10741. $accountBook->receivedPrice = $expenditurePrice;
  10742. $accountBook->receivedBank = $receivedBank;
  10743. $accountBook->receivedDate = $expenditureDate;
  10744. $accountBook->remarks = $remarks;
  10745. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10746. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10747. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10748. $id = $accountBook->insert ();
  10749. // 添加日常理财收入汇总
  10750. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  10751. $accountBookStatistics = new accountBookStatistics ();
  10752. $item = array (
  10753. 'date' => date ( "Y-m-d" ),
  10754. 'expenditureType' => $abDetail ['expenditureType'],
  10755. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10756. 'aid' => $abDetail ['aid'],
  10757. 'financingPrice' => $expenditurePrice,
  10758. 'expensesType' => 3
  10759. );
  10760. $accountBookStatistics->setAccountBookStatistics ( $item );
  10761. // 添加一笔收入流水
  10762. if ($expenditureMsg == '公司固定') {
  10763. $accountTypeWaste = 9;
  10764. } elseif ($expenditureMsg == '公司活期') {
  10765. $accountTypeWaste = 10;
  10766. } elseif ($expenditureMsg == '个人(GR)') {
  10767. $accountBank = 'PersonalDeposit';
  10768. }
  10769. $itemWaste = array (
  10770. 'expensesType' => 1,
  10771. 'accountType' => $accountTypeWaste,
  10772. 'accountPriceShow' => $expenditurePrice,
  10773. 'accountPrice' => $expenditurePrice,
  10774. 'dataID' => $id,
  10775. 'dailyIncomeType' => $dailyIncomeType,
  10776. 'accountBank' => $accountBank,
  10777. 'category' => $this->staff [0] ['category'],
  10778. 'cid' => $this->staff [0] ['cid'],
  10779. 'name' => $this->staff [0] ['username'],
  10780. 'sid' => $this->staff [0] ['sid'],
  10781. 'inputDate' => date ( "Y-m-d H:i:s" )
  10782. );
  10783. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10784. } else {
  10785. // 添加一笔日常支出
  10786. $accountBook = new accountBook ();
  10787. $accountBook->expensesType = 2;
  10788. $accountBook->expenditureType = $expenditureType;
  10789. $accountBook->expenditureMsg = $expenditureMsg;
  10790. $accountBook->expenditurePrice = $expenditurePrice;
  10791. $accountBook->expenditureBank = $expenditureBank;
  10792. $accountBook->expenditureDate = $expenditureDate;
  10793. $accountBook->remarks = $remarks;
  10794. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10795. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10796. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10797. $id = $accountBook->insert ();
  10798. // 添加日常支出汇总
  10799. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10800. $accountBookStatistics = new accountBookStatistics ();
  10801. $item = array (
  10802. 'date' => date ( "Y-m-d" ),
  10803. 'expenditureType' => $abDetail ['expenditureType'],
  10804. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10805. 'aid' => $abDetail ['aid'],
  10806. 'expensesType' => $abDetail ['expensesType']
  10807. );
  10808. if ($expenditureType == 5) {
  10809. $item += array (
  10810. 'payPrice' => - $abDetail ['expenditurePrice']
  10811. );
  10812. } else {
  10813. $item += array (
  10814. 'payPrice' => $abDetail ['expenditurePrice']
  10815. );
  10816. }
  10817. $accountBookStatistics->setAccountBookStatistics ( $item );
  10818. // 公司日常支出流水
  10819. $wasteBook = new wasteBook ();
  10820. $itemWaste = array (
  10821. 'accountPrice' => - $expenditurePrice
  10822. );
  10823. if ($expenditureBank == '个人广发') {
  10824. $itemWaste = array (
  10825. 'accountPrice' => $expenditurePrice
  10826. );
  10827. }
  10828. $itemWaste += array (
  10829. 'expensesType' => 2,
  10830. 'accountType' => 5,
  10831. 'accountPriceShow' => $expenditurePrice,
  10832. 'dataID' => $id,
  10833. 'dailyExpenditureType' => $expenditureType,
  10834. 'accountBank' => $accountBank,
  10835. 'category' => $this->staff [0] ['category'],
  10836. 'cid' => $this->staff [0] ['cid'],
  10837. 'name' => $this->staff [0] ['username'],
  10838. 'sid' => $this->staff [0] ['sid'],
  10839. 'inputDate' => date ( "Y-m-d H:i:s" )
  10840. );
  10841. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10842. }
  10843. }
  10844. return '/payments';
  10845. }
  10846. /**
  10847. * 添加支出
  10848. */
  10849. function paymentsExpenditureDo_() {
  10850. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10851. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10852. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10853. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10854. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10855. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10856. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10857. $dailyExpenditureType = '';
  10858. $accountTypeWaste = 5;
  10859. $accountBank = '';
  10860. if ($expenditureBank == '纵横广发') {
  10861. $accountBank = 'CGBDeposit';
  10862. } elseif ($expenditureBank == '纵横工行') {
  10863. $accountBank = 'ICBCDeposit';
  10864. } elseif ($expenditureBank == '华润银行') {
  10865. $accountBank = 'HUADeposit';
  10866. } elseif ($expenditureBank == '个人广发') {
  10867. $accountBank = 'PersonalDeposit';
  10868. }
  10869. if (empty ( $accountBank ))
  10870. die ( 'illegal request' );
  10871. $itemWaste = array (
  10872. 'accountPrice' => - $expenditurePrice
  10873. );
  10874. if ($expenditureBank == '个人广发') {
  10875. $itemWaste = array (
  10876. 'accountPrice' => $expenditurePrice
  10877. );
  10878. }
  10879. if ($expenditureType == 4 || $expenditureType == 6) {
  10880. $dailyExpenditureType = 4;
  10881. if ($expenditureMsg == '公司固定') {
  10882. $accountTypeWaste = 9;
  10883. } elseif ($expenditureMsg == '公司活期') {
  10884. $accountTypeWaste = 10;
  10885. } elseif ($expenditureMsg == '个人(GR)') {
  10886. $accountBank = 'PersonalDeposit';
  10887. }
  10888. $itemWaste = array (
  10889. 'accountPrice' => $expenditurePrice
  10890. );
  10891. } elseif ($expenditureType == 1) {
  10892. $dailyExpenditureType = 1;
  10893. } elseif ($expenditureType == 2) {
  10894. $dailyExpenditureType = 2;
  10895. } elseif ($expenditureType == 3) {
  10896. $dailyExpenditureType = 3;
  10897. } elseif ($expenditureType == 5) {
  10898. $dailyExpenditureType = 5;
  10899. }
  10900. if (empty ( $dailyExpenditureType ))
  10901. die ( 'illegal request' );
  10902. Doo::loadModel ( "accountBook" );
  10903. $accountBook = new accountBook ();
  10904. $accountBook->expenditureType = $expenditureType;
  10905. $accountBook->expenditureMsg = $expenditureMsg;
  10906. $accountBook->expenditurePrice = $expenditurePrice;
  10907. $accountBook->expenditureBank = $expenditureBank;
  10908. $accountBook->expenditureDate = $expenditureDate;
  10909. $accountBook->remarks = $remarks;
  10910. $accountBook->expensesType = 2;
  10911. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10912. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10913. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10914. $id = $accountBook->insert ();
  10915. //
  10916. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10917. Doo::loadModel ( "accountBookStatistics" );
  10918. $accountBookStatistics = new accountBookStatistics ();
  10919. $item = array (
  10920. 'date' => date ( "Y-m-d" ),
  10921. 'expenditureType' => $abDetail ['expenditureType'],
  10922. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10923. 'aid' => $abDetail ['aid']
  10924. );
  10925. if ($abDetail ['expensesType'] == 2) {
  10926. if ($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) {
  10927. $item += array (
  10928. 'financingPrice' => $expenditurePrice,
  10929. 'expensesType' => 3
  10930. );
  10931. } elseif ($abDetail ['expenditureType'] == 5) {
  10932. $item += array (
  10933. 'payPrice' => $abDetail ['expenditurePrice'],
  10934. 'expensesType' => $abDetail ['expensesType']
  10935. );
  10936. } else {
  10937. $item += array (
  10938. 'payPrice' => $abDetail ['expenditurePrice'],
  10939. 'expensesType' => $abDetail ['expensesType']
  10940. );
  10941. }
  10942. }
  10943. $accountBookStatistics->setAccountBookStatistics ( $item );
  10944. // 公司流水记录
  10945. Doo::loadModel ( 'wasteBook' );
  10946. $wasteBook = new wasteBook ();
  10947. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountTypeWaste, $id );
  10948. // 银行
  10949. if (empty ( $abDetail )) {
  10950. $itemWaste += array (
  10951. 'accountPriceShow' => $expenditurePrice,
  10952. 'dataID' => $id,
  10953. 'expensesType' => 2,
  10954. 'accountType' => $accountTypeWaste,
  10955. 'dailyExpenditureType' => $expenditureType,
  10956. 'accountBank' => $accountBank,
  10957. 'category' => $this->staff [0] ['category'],
  10958. 'cid' => $this->staff [0] ['cid'],
  10959. 'name' => $this->staff [0] ['username'],
  10960. 'sid' => $this->staff [0] ['sid'],
  10961. 'inputDate' => date ( "Y-m-d H:i:s" )
  10962. );
  10963. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10964. }
  10965. // 支出类型为4或者6 需要添加一笔收入和收入流水
  10966. if ($expenditureType == 4 || $expenditureType == 6) {
  10967. $accountBank = 'CGBDeposit';
  10968. $dailyIncomeType = 7;
  10969. $receivedBank = '纵横广发';
  10970. if ($expenditureType == 6) {
  10971. $accountBank = 'ICBCDeposit';
  10972. $receivedBank = '纵横工行';
  10973. $dailyIncomeType = 9;
  10974. }
  10975. // 添加一笔收入
  10976. $accountBook = new accountBook ();
  10977. $accountBook->accountType = $dailyIncomeType;
  10978. $accountBook->accountMsg = $expenditureMsg;
  10979. $accountBook->receivedPrice = $expenditurePrice;
  10980. $accountBook->receivedBank = $receivedBank;
  10981. $accountBook->receivedDate = $expenditureDate;
  10982. $accountBook->remarks = $remarks;
  10983. $accountBook->expensesType = 1;
  10984. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10985. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10986. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10987. $id = $accountBook->insert ();
  10988. // 添加一笔收入流水
  10989. $itemWaste = array (
  10990. 'accountPriceShow' => $expenditurePrice,
  10991. 'accountPrice' => - $expenditurePrice,
  10992. 'dataID' => $id,
  10993. 'expensesType' => 1,
  10994. 'accountType' => $accountTypeWaste,
  10995. 'dailyIncomeType' => $dailyIncomeType,
  10996. 'accountBank' => $accountBank,
  10997. 'category' => $this->staff [0] ['category'],
  10998. 'cid' => $this->staff [0] ['cid'],
  10999. 'name' => $this->staff [0] ['username'],
  11000. 'sid' => $this->staff [0] ['sid'],
  11001. 'inputDate' => date ( "Y-m-d H:i:s" )
  11002. );
  11003. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11004. }
  11005. }
  11006. return '/payments';
  11007. }
  11008. /**
  11009. * 所有收支
  11010. */
  11011. function paymentsAchieve() {
  11012. $page_size = 12;
  11013. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  11014. $expensesType = isset ( $this->params ['expensesType'] ) ? $this->params ['expensesType'] : 'ALL';
  11015. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11016. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  11017. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11018. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11019. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11020. $submitType = $this->get_args ( 'submitType' ) ? $this->get_args ( 'submitType' ) : "";
  11021. Doo::loadModel ( "accountBookStatistics" );
  11022. $accountBookStatistics = new accountBookStatistics ();
  11023. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  11024. $data ['statisticsList'] = $statisticsList;
  11025. Doo::loadModel ( "accountBook" );
  11026. $accountBook = new accountBook ();
  11027. $con = '';
  11028. if ($expensesType == 'INCOME')
  11029. $con = ' and expensesType=1 ';
  11030. elseif ($expensesType == 'PAY')
  11031. $con = ' and expensesType=2 ';
  11032. $dateArr = explode ( ':', $date );
  11033. $D1 = $dateString = '';
  11034. $D2 = '';
  11035. if (! empty ( $date )) {
  11036. $D1 = $dateArr [0];
  11037. if (isset ( $dateArr [1] ))
  11038. $D2 = $dateArr [1];
  11039. else
  11040. $D2 = '';
  11041. $dateString = $D1 . " : " . $D2;
  11042. }
  11043. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11044. $con .= ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11045. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11046. $con .= ' and inputDate like "%' . $D1 . '%" ';
  11047. if (! empty ( $price ))
  11048. $con .= ' and (receivedPrice=' . $price . ' or expenditurePrice=' . $price . ')';
  11049. if ($submitType == 1) {
  11050. if ($accountType != '') {
  11051. $expenditureType = '';
  11052. $con .= ' and accountType=' . $accountType;
  11053. if (! empty ( $accountMsg ))
  11054. $con .= ' and (accountType=' . $accountType . ' and accountMsg like "%' . $accountMsg . '%")';
  11055. }
  11056. } elseif ($submitType == 2) {
  11057. if ($expenditureType != '') {
  11058. $accountType = $accountMsg = '';
  11059. $con .= ' and expenditureType=' . $expenditureType;
  11060. }
  11061. } else {
  11062. $accountType = $accountMsg = $expenditureType = '';
  11063. }
  11064. $sql = "" . $con;
  11065. $action = "paymentsAchieve";
  11066. $get = '/' . $expensesType; // "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  11067. $pageinfo = $this->get_page ( "CLD_accountBook", $sql, $page, $page_size, $action, $get, "" );
  11068. $limit = $pageinfo ['lower'] . ',' . $page_size;
  11069. $list = $accountBook->getAccountBookBySql ( $limit, $sql, 'desc' );
  11070. $data ['expenditureType'] = $expenditureType;
  11071. $data ['accountMsg'] = $accountMsg;
  11072. $data ['accountType'] = $accountType;
  11073. $data ['inputDate'] = $date;
  11074. $data ['price'] = $price;
  11075. $data ['expensesType'] = $expensesType;
  11076. $data ['page'] = $pageinfo;
  11077. $data ['list'] = $list;
  11078. $data ['memu'] = "receipt";
  11079. $data ['staff'] = $this->staff;
  11080. $data ['receiptMemu'] = 'payments';
  11081. $data ['verifyId'] = $this->verifyId;
  11082. $data ['executeId'] = $this->executeId;
  11083. $this->render ( "/expenses/paymentsAchieve", $data );
  11084. }
  11085. function paymentsIncomeUpdateDo() {
  11086. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11087. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11088. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11089. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  11090. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  11091. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  11092. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  11093. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11094. if (! empty ( $aidKey ) && ! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  11095. Doo::loadClass ( 'XDeode' );
  11096. $XDeode = new XDeode ( 5 );
  11097. $aid = $XDeode->decode ( $aidKey );
  11098. Doo::loadModel ( "accountBook" );
  11099. $accountBook = new accountBook ();
  11100. //
  11101. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11102. $price = $receivedPrice - $abDetail [inComePrice];
  11103. Doo::loadModel ( "accountBookStatistics" );
  11104. $accountBookStatistics = new accountBookStatistics ();
  11105. if ($abDetail ['accountType'] == 7) {
  11106. $item += array (
  11107. 'date' => date ( "Y-m-d" ),
  11108. 'financingPrice' => - $price,
  11109. 'expensesType' => 3,
  11110. 'aid' => $abDetail ['aid']
  11111. );
  11112. } elseif ($abDetail ['accountType'] == 8) {
  11113. $item += array (
  11114. 'date' => date ( "Y-m-d" ),
  11115. 'expensesType' => $abDetail ['expensesType'],
  11116. 'inComePrice' => - $price,
  11117. 'aid' => $abDetail ['aid']
  11118. );
  11119. } else {
  11120. $item = array (
  11121. 'date' => date ( "Y-m-d" ),
  11122. 'expensesType' => $abDetail ['expensesType'],
  11123. 'inComePrice' => $price,
  11124. 'aid' => $abDetail ['aid']
  11125. );
  11126. }
  11127. $accountBookStatistics->setAccountBookStatistics ( $item );
  11128. $accountBook->accountType = $accountType;
  11129. $accountBook->accountMsg = $accountMsg;
  11130. $accountBook->receivedPrice = $receivedPrice;
  11131. $accountBook->receivedMsg = $receivedMsg;
  11132. $accountBook->receivedBank = $receivedBank;
  11133. $accountBook->receivedDate = $receivedDate;
  11134. $accountBook->remarks = $remarks;
  11135. $accountBook->aid = $aid;
  11136. $accountBook->update ();
  11137. }
  11138. return '/paymentsAchieve';
  11139. }
  11140. function paymentsExpenditureEdiDo() {
  11141. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11142. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11143. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11144. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11145. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11146. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11147. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11148. if (! empty ( $aidKey ) && ! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11149. Doo::loadClass ( 'XDeode' );
  11150. $XDeode = new XDeode ( 5 );
  11151. $aid = $XDeode->decode ( $aidKey );
  11152. Doo::loadModel ( "accountBook" );
  11153. $accountBook = new accountBook ();
  11154. // 汇总信息
  11155. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11156. $price = $expenditurePrice - $abDetail [expenditurePrice];
  11157. Doo::loadModel ( "accountBookStatistics" );
  11158. $accountBookStatistics = new accountBookStatistics ();
  11159. if ($abDetail ['expenditureType'] == 4) {
  11160. $item += array (
  11161. 'date' => date ( "Y-m-d" ),
  11162. 'financingPrice' => $price,
  11163. 'expensesType' => 3,
  11164. 'aid' => $abDetail ['aid']
  11165. );
  11166. } elseif ($abDetail ['expenditureType'] == 5) {
  11167. $item += array (
  11168. 'date' => date ( "Y-m-d" ),
  11169. 'expensesType' => $abDetail ['expensesType'],
  11170. 'payPrice' => $price,
  11171. 'aid' => $abDetail ['aid']
  11172. );
  11173. } else {
  11174. $item = array (
  11175. 'date' => date ( "Y-m-d" ),
  11176. 'expensesType' => $abDetail ['expensesType'],
  11177. 'payPrice' => $price,
  11178. 'aid' => $abDetail ['aid']
  11179. );
  11180. }
  11181. $accountBookStatistics->setAccountBookStatistics ( $item );
  11182. //
  11183. $accountBook->expenditureType = $expenditureType;
  11184. $accountBook->expenditureMsg = $expenditureMsg;
  11185. $accountBook->expenditurePrice = $expenditurePrice;
  11186. $accountBook->expenditureBank = $expenditureBank;
  11187. $accountBook->remarks = $remarks;
  11188. $accountBook->expenditureDate = $expenditureDate;
  11189. $accountBook->aid = $aid;
  11190. $id = $accountBook->update ();
  11191. }
  11192. return '/paymentsAchieve';
  11193. }
  11194. function paymentsDelDo() {
  11195. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11196. if (! empty ( $aidKey )) {
  11197. Doo::loadClass ( 'XDeode' );
  11198. $XDeode = new XDeode ( 5 );
  11199. $aid = $XDeode->decode ( $aidKey );
  11200. Doo::loadModel ( "accountBook" );
  11201. $accountBook = new accountBook ();
  11202. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11203. if (empty ( $abDetail ))
  11204. die ( 'illegal request' );
  11205. // 删除收支
  11206. Doo::loadModel ( "accountBookStatistics" );
  11207. $accountBookStatistics = new accountBookStatistics ();
  11208. $item = array (
  11209. 'date' => date ( "Y-m-d" ),
  11210. 'aid' => $abDetail ['aid']
  11211. );
  11212. $accountType = '';
  11213. if ($abDetail ['expensesType'] == 1) {
  11214. $accountType = 6;
  11215. if ($abDetail ['accountType'] != 7) {
  11216. $item += array (
  11217. 'expensesType' => $abDetail ['expensesType'],
  11218. 'inComePrice' => - $abDetail ['receivedPrice']
  11219. );
  11220. } else {
  11221. $item += array (
  11222. 'financingPrice' => $abDetail ['receivedPrice'],
  11223. 'expensesType' => 3
  11224. );
  11225. }
  11226. } elseif ($abDetail ['expensesType'] == 2) {
  11227. $accountType = 5;
  11228. if ($abDetail ['accountType'] != 7) {
  11229. $item += array (
  11230. 'expensesType' => $abDetail ['expensesType'],
  11231. 'payPrice' => - $abDetail ['expenditurePrice']
  11232. );
  11233. } else {
  11234. $item += array (
  11235. 'financingPrice' => - $abDetail ['expenditurePrice'],
  11236. 'expensesType' => 3
  11237. );
  11238. }
  11239. }
  11240. if (($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) && $abDetail ['expensesType'] == 2) {
  11241. if ($abDetail ['expenditureMsg'] == '公司固定')
  11242. $accountType = 9;
  11243. elseif ($abDetail ['expenditureMsg'] == '公司活期')
  11244. $accountType = 10;
  11245. }
  11246. if (($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) && $abDetail ['expensesType'] == 1) {
  11247. if ($abDetail ['accountMsg'] == '公司固定')
  11248. $accountType = 9;
  11249. elseif ($abDetail ['accountMsg'] == '公司活期')
  11250. $accountType = 10;
  11251. }
  11252. if ($abDetail ['accountMsg'] == '活期理财收益') {
  11253. $accountType = 10;
  11254. }
  11255. $accountBookStatistics->setAccountBookStatistics ( $item );
  11256. $accountBook->delete ( array (
  11257. 'where' => 'aid=' . $aid,
  11258. 'limit' => 1
  11259. ) );
  11260. // 删除收入流水
  11261. if (! empty ( $accountType )) {
  11262. Doo::loadModel ( 'wasteBook' );
  11263. $wasteBook = new wasteBook ();
  11264. $wasteBook->delete ( array (
  11265. 'where' => 'dataID=' . $aid . ' and accountType=' . $accountType,
  11266. 'limit' => 1
  11267. ) );
  11268. }
  11269. }
  11270. return '/paymentsAchieve';
  11271. }
  11272. function paymentsCollect() {
  11273. Doo::loadModel ( "execute" );
  11274. $execute = new execute ();
  11275. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11276. die ( 'illegal request' );
  11277. }
  11278. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11279. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  11280. Doo::loadModel ( "accountBookStatistics" );
  11281. $accountBookStatistics = new accountBookStatistics ();
  11282. Doo::loadClass ( 'receipt.func' );
  11283. $statisticsIncome = $accountBookStatistics->getStatisticsByCollect ( $year );
  11284. $html = _getPaymentsCollectByYearHtml ( $statisticsIncome );
  11285. $data ['html'] = $html ['html'];
  11286. $data ['inSum'] = $html ['sum'];
  11287. $statisticsPay = $accountBookStatistics->getStatisticsByCollect ( $year, 2 );
  11288. $html = _getPaymentsCollectPayByYearHtml ( $statisticsPay );
  11289. $data ['payHtml'] = $html ['html'];
  11290. $data ['paySum'] = $html ['sum'];
  11291. // 余额统计
  11292. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1 );
  11293. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2 );
  11294. include './protected/config/wasteBook.conf.php';
  11295. Doo::loadModel ( 'wasteBook' );
  11296. $wasteBook = new wasteBook ();
  11297. $inComePay = $wasteBook->getWasteBookByStatistics ( 1, $year );
  11298. $pay = $wasteBook->getWasteBookByStatistics ( 2, $year );
  11299. // 获得年份之前所有金额
  11300. $detail = $wasteBook->getWasteBookByStatisticsYear ( $year );
  11301. // print_r($detail);
  11302. // $waste['total'];
  11303. $lastBalanceHtml = '<tr><th colspan="2">截至上月余额</th>';
  11304. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11305. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11306. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11307. $inSum = $paySum = $showInSum = $showPaySum = $balanceSum = 0;
  11308. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11309. $limitMonth = date ( 'm' ); // 限制显示月份参数
  11310. if (date ( 'Y' ) > $year) {
  11311. $limitMonth = 12;
  11312. }
  11313. for($i = 1; $i <= 12; $i ++) {
  11314. $inComeA = $payB = 0;
  11315. $falg = true;
  11316. foreach ( $inComePay as $key => $value ) {
  11317. if ($value ['month'] == $i) {
  11318. $falg = false;
  11319. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11320. $inSum += $value ['accountPrice'];
  11321. $showInSum += $value ['accountPriceShow'];
  11322. $inComeA = $value ['accountPrice'];
  11323. break;
  11324. }
  11325. }
  11326. if ($falg)
  11327. $inComeHtml .= '<td class="taR">-</td>';
  11328. $payFalg = true;
  11329. foreach ( $pay as $key => $value ) {
  11330. if ($value ['month'] == $i) {
  11331. $payFalg = false;
  11332. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11333. $paySum += $value ['accountPrice'];
  11334. $showPaySum += $value ['accountPriceShow'];
  11335. $payB = $value ['accountPrice'];
  11336. break;
  11337. }
  11338. }
  11339. if ($payFalg)
  11340. $payHtml .= '<td class="taR">-</td>';
  11341. if (empty ( $balanceC ) || $limitMonth < $i)
  11342. $lastBalanceHtml .= '<td class="taR">-</td>';
  11343. else
  11344. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11345. $balanceC = $balanceC + $inComeA + $payB;
  11346. $balanceSum += $balanceC;
  11347. if (empty ( $balanceC ) || $limitMonth < $i)
  11348. $BalanceHtml .= '<td class="taR">-</td>';
  11349. else
  11350. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11351. // 余额统计
  11352. }
  11353. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11354. $data ['inComeHtml'] = $inComeHtml;
  11355. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11356. $data ['payBalanceHtml'] = $payHtml;
  11357. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11358. $data ['BalanceHtml'] = $BalanceHtml;
  11359. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11360. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11361. $mothHtml = "";
  11362. for($i = 1; $i <= 12; $i ++) {
  11363. if ($moth == $i)
  11364. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11365. else
  11366. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11367. }
  11368. $data ['mothHtml'] = $mothHtml;
  11369. $dateHtml = "";
  11370. $now = date ( "Y" );
  11371. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11372. if ($YEARD <= $now) {
  11373. $dateHtml .= '<option ';
  11374. if ($year == $YEARD) {
  11375. $dateHtml .= 'selected ';
  11376. }
  11377. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11378. }
  11379. }
  11380. $data ['dateHtml'] = $dateHtml;
  11381. $data ['year'] = $year;
  11382. $data ['memu'] = "receipt";
  11383. $data ['staff'] = $this->staff;
  11384. $data ['receiptMemu'] = 'paymentsCollect';
  11385. $data ['verifyId'] = $this->verifyId;
  11386. $data ['executeId'] = $this->executeId;
  11387. $this->render ( "/expenses/paymentsCollect", $data );
  11388. }
  11389. function paymentsCollectDay() {
  11390. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11391. $moth = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : '';
  11392. if (empty ( $moth ))
  11393. return 'paymentsCollect';
  11394. Doo::loadModel ( "accountBookStatistics" );
  11395. $accountBookStatistics = new accountBookStatistics ();
  11396. $i = 2;
  11397. $y = 2013;
  11398. $day = date ( "t", strtotime ( "$year-$moth" ) );
  11399. Doo::loadClass ( 'receipt.func' );
  11400. $statisticsIncome = $accountBookStatistics->getStatisticsByCollectDay ( $year, 1, $moth );
  11401. $html = _getPaymentsCollectByDayHtml ( $statisticsIncome, $day );
  11402. $data ['html'] = $html ['html'];
  11403. $data ['inSum'] = $html ['sum'];
  11404. $statisticsPay = $accountBookStatistics->getStatisticsByCollectDay ( $year, 2, $moth );
  11405. $html = _getPaymentsCollectPayByDayHtml ( $statisticsPay, $day );
  11406. $data ['payHtml'] = $html ['html'];
  11407. $data ['paySum'] = $html ['sum'];
  11408. $mothHtml = "";
  11409. for($i = 1; $i <= 12; $i ++) {
  11410. if ($moth == $i)
  11411. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11412. else
  11413. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11414. }
  11415. $data ['mothHtml'] = $mothHtml;
  11416. $data ['year'] = $year;
  11417. // 余额
  11418. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1, $moth );
  11419. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2, $moth );
  11420. include './protected/config/wasteBook.conf.php';
  11421. Doo::loadModel ( 'wasteBook' );
  11422. $wasteBook = new wasteBook ();
  11423. $inComePay = $wasteBook->getStatisticsByDay ( 1, $year, $moth );
  11424. $pay = $wasteBook->getStatisticsByDay ( 2, $year, $moth );
  11425. // 获得年份之前所有金额
  11426. $detail = $wasteBook->getWasteBookByStatisticsDay ( $year, $moth );
  11427. $lastBalanceHtml = '<tr><th colspan="2">截至上日余额</th>';
  11428. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11429. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11430. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11431. $dayHtml = '<tr><th class="taC" colspan="2">余额</th>';
  11432. $inSum = $paySum = $showPaySum = $showInSum = $balanceSum = 0;
  11433. // $balanceC = 0;
  11434. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11435. $limitDay = date ( 'd' );
  11436. $monthLK = ( int ) date ( 'm' );
  11437. if (date ( 'Y' ) > $year) {
  11438. $limitDay = cal_days_in_month ( CAL_GREGORIAN, date ( 'm' ), date ( 'Y' ) );
  11439. } elseif (date ( 'Y' ) <= $year && $monthLK < $moth) {
  11440. $limitDay = 0;
  11441. }
  11442. for($i = 1; $i <= $day; $i ++) {
  11443. $dayHtml .= '<td class="taC">' . $i . '日</td>';
  11444. $inComeA = $payB = 0;
  11445. $falg = true;
  11446. foreach ( $inComePay as $key => $value ) {
  11447. if ($value ['day'] == $i) {
  11448. $falg = false;
  11449. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11450. $inSum += $value ['accountPrice'];
  11451. $showInSum += $value ['accountPriceShow'];
  11452. $inComeA = $value ['accountPrice'];
  11453. break;
  11454. }
  11455. }
  11456. if ($falg)
  11457. $inComeHtml .= '<td class="taR">-</td>';
  11458. $payFalg = true;
  11459. foreach ( $pay as $key => $value ) {
  11460. if ($value ['day'] == $i) {
  11461. $payFalg = false;
  11462. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11463. $paySum += $value ['accountPrice'];
  11464. $showPaySum += $value ['accountPriceShow'];
  11465. $payB = $value ['accountPrice'];
  11466. break;
  11467. }
  11468. }
  11469. if ($payFalg)
  11470. $payHtml .= '<td class="taR">-</td>';
  11471. if (empty ( $balanceC ) || $limitDay < $i)
  11472. $lastBalanceHtml .= '<td class="taR">-</td>';
  11473. else
  11474. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11475. $balanceC = $balanceC + $inComeA + $payB;
  11476. $balanceSum += $balanceC;
  11477. if (empty ( $balanceC ) || $limitDay < $i)
  11478. $BalanceHtml .= '<td class="taR">-</td>';
  11479. else
  11480. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11481. }
  11482. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11483. $data ['inComeHtml'] = $inComeHtml;
  11484. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11485. $data ['payBalanceHtml'] = $payHtml;
  11486. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11487. $data ['BalanceHtml'] = $BalanceHtml;
  11488. $dayHtml .= '<td class="taR ">总计</td></tr>';
  11489. $data ['dayHtml'] = $dayHtml;
  11490. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11491. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11492. $dateHtml = "";
  11493. $now = date ( "Y" );
  11494. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11495. if ($YEARD <= $now) {
  11496. $dateHtml .= '<option ';
  11497. if ($year == $YEARD) {
  11498. $dateHtml .= 'selected ';
  11499. }
  11500. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11501. }
  11502. }
  11503. $data ['dateHtml'] = $dateHtml;
  11504. $data ['memu'] = "receipt";
  11505. $data ['staff'] = $this->staff;
  11506. $data ['receiptMemu'] = 'paymentsCollect';
  11507. $data ['verifyId'] = $this->verifyId;
  11508. $data ['executeId'] = $this->executeId;
  11509. $this->render ( "/expenses/paymentsCollectDay", $data );
  11510. }
  11511. // 公司流水
  11512. function wasteBook() {
  11513. Doo::loadModel ( "execute" );
  11514. $execute = new execute ();
  11515. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11516. die ( 'illegal request' );
  11517. }
  11518. include './protected/config/wasteBook.conf.php';
  11519. Doo::loadModel ( 'wasteBook' );
  11520. $wasteBook = new wasteBook ();
  11521. $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  11522. $waste = $this->getWasteBookStatistics ( $waste, $inComeStatistics );
  11523. $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'];
  11524. // print_r($waste);
  11525. $data ['waste'] = $waste;
  11526. $data ['total'] = $total;
  11527. // 月流水数据结构
  11528. $monthStatistics = array ();
  11529. $incomeMothStatistics = array ();
  11530. $expenditureMothStatistics = array ();
  11531. for($i = 1; $i <= 12; $i ++) {
  11532. $month = date ( 'Y' ) . '-' . $i;
  11533. if ($i < 10)
  11534. $month = date ( 'Y' ) . '-0' . $i;
  11535. array_push ( $monthStatistics, $month );
  11536. }
  11537. foreach ( $monthStatistics as $value ) {
  11538. $falg = true;
  11539. foreach ( $inComeStatistics ['incomeReport'] as $k => $v ) {
  11540. if ($value == $v ['inputDate']) {
  11541. array_push ( $incomeMothStatistics, $v ['accountPrice'] );
  11542. $falg = false;
  11543. }
  11544. }
  11545. if ($falg) {
  11546. array_push ( $incomeMothStatistics, '' );
  11547. }
  11548. $falgEx = true;
  11549. foreach ( $inComeStatistics ['expenditureReport'] as $k => $v ) {
  11550. if ($value == $v ['inputDate']) {
  11551. array_push ( $expenditureMothStatistics, $v ['accountPrice'] );
  11552. $falg = false;
  11553. }
  11554. }
  11555. if ($falgEx) {
  11556. array_push ( $expenditureMothStatistics, '' );
  11557. }
  11558. }
  11559. $data ['monthStatistics'] = json_encode ( $monthStatistics );
  11560. $data ['incomeMothStatistics'] = json_encode ( $incomeMothStatistics );
  11561. $data ['expenditureMothStatistics'] = json_encode ( $expenditureMothStatistics );
  11562. $expenditureList = $wasteBook->getAccountBookByExpensesType ( 4, 2 );
  11563. $incomeList = $wasteBook->getAccountBookByExpensesType ( 4, 1 );
  11564. // print_r($incomeList);
  11565. $data ['expenditureList'] = $expenditureList;
  11566. $data ['incomeList'] = $incomeList;
  11567. $data ['memu'] = "receipt";
  11568. $data ['staff'] = $this->staff;
  11569. $data ['receiptMemu'] = 'wasteBook';
  11570. $data ['verifyId'] = $this->verifyId;
  11571. $data ['executeId'] = $this->executeId;
  11572. $this->render ( "/expenses/wasteBook", $data );
  11573. }
  11574. function wasteBookIncome() {
  11575. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11576. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11577. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  11578. $dailyIncomeType = $this->get_args ( 'dailyIncomeType' ) ? $this->get_args ( 'dailyIncomeType' ) : "ALL";
  11579. $data ['dailyIncomeType'] = $dailyIncomeType;
  11580. Doo::loadModel ( 'wasteBook' );
  11581. $wasteBook = new wasteBook ();
  11582. Doo::loadModel ( 'L_category' );
  11583. $L_category = new L_category ();
  11584. Doo::loadClass ( 'XDeode' );
  11585. $XDeode = new XDeode ( 5 );
  11586. // echo $XDeode->encode(1).'<br>';
  11587. // echo $XDeode->encode(2).'<br>';
  11588. // echo $XDeode->encode(3).'<br>';
  11589. // echo $XDeode->encode(4).'<br>';
  11590. // echo $XDeode->encode(5).'<br>';
  11591. // echo $XDeode->encode(6).'<br>';
  11592. // echo $XDeode->encode(7).'<br>';
  11593. // echo $XDeode->encode(8).'<br>';
  11594. // echo $XDeode->encode(9).'<br>';
  11595. // echo $XDeode->encode(10).'<br>';
  11596. $year=date("Y");
  11597. $theDay=date("Y-m-d");
  11598. $dateArr = explode ( ':', $date );
  11599. $D1 = '';
  11600. $D2 = '';
  11601. $con = '';
  11602. if (! empty ( $date )) {
  11603. $D1 = $dateArr [0];
  11604. $D2 = $dateArr [1];
  11605. }
  11606. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11607. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11608. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11609. $con = ' and inputDate = "' . $D1 . '"';
  11610. else{
  11611. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  11612. }
  11613. if ($cid != 'ALL') {
  11614. $cid = $XDeode->decode ( $cid );
  11615. $con .= ' and cid = "' . $cid . '"';
  11616. }
  11617. if ($accountType != 'ALL') {
  11618. if ($accountType == 'INVOICE') {
  11619. $con .= ' and (accountType = 7 or accountType = 8)';
  11620. } elseif ($accountType == 'PAYMENTS') {
  11621. $con .= ' and (accountType = 6 or accountType = 9 or accountType = 10)';
  11622. if ($dailyIncomeType != 'ALL') {
  11623. $dailyIncomeType = $XDeode->decode ( $dailyIncomeType );
  11624. $con .= ' and dailyIncomeType = ' . $dailyIncomeType;
  11625. }
  11626. }
  11627. }
  11628. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 1, $con );
  11629. $sum = 0;$thsDaySum=0;
  11630. foreach ( $incomeList as $key => $value ) {
  11631. $sum += $value ['accountPrice'];
  11632. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  11633. $thsDaySum+=$value ['accountPrice'];
  11634. }
  11635. }
  11636. // print_r($incomeList);
  11637. // 获得办事和部门
  11638. $categoryList = $L_category->getCategory ();
  11639. $data ['accountType'] = $accountType;
  11640. $data ['cid'] = $cid;
  11641. $data ['categoryList'] = $categoryList;
  11642. $data ['sum'] = $sum;
  11643. $data ['incomeList'] = $incomeList;
  11644. $data ['inputDate'] = $date;
  11645. $data['year']=$year;
  11646. $data ['thsDay'] =$theDay;
  11647. $data ['thsDaySum'] =$thsDaySum;
  11648. $data ['memu'] = "receipt";
  11649. $data ['staff'] = $this->staff;
  11650. $data ['receiptMemu'] = 'wasteBook';
  11651. $data ['verifyId'] = $this->verifyId;
  11652. $data ['executeId'] = $this->executeId;
  11653. $this->render ( "/expenses/wasteBookIncome", $data );
  11654. }
  11655. /**
  11656. * 所有支出
  11657. */
  11658. function wasteBookExpenditure() {
  11659. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11660. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11661. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  11662. $dailyExpenditureType = $this->get_args ( 'dailyExpenditureType' ) ? $this->get_args ( 'dailyExpenditureType' ) : "ALL";
  11663. $data ['dailyExpenditureType'] = $dailyExpenditureType;
  11664. $receiptType = $this->get_args ( 'receiptType' ) ? $this->get_args ( 'receiptType' ) : "ALL";
  11665. $data ['receiptType'] = $receiptType;
  11666. Doo::loadModel ( 'wasteBook' );
  11667. $wasteBook = new wasteBook ();
  11668. Doo::loadModel ( 'L_category' );
  11669. $L_category = new L_category ();
  11670. Doo::loadClass ( 'XDeode' );
  11671. $XDeode = new XDeode ( 5 );
  11672. $year=date("Y");
  11673. $theDay=date("Y-m-d");
  11674. $dateArr = explode ( ':', $date );
  11675. $D1 = '';
  11676. $D2 = '';
  11677. $con = '';
  11678. if (! empty ( $date )) {
  11679. $D1 = $dateArr [0];
  11680. $D2 = $dateArr [1];
  11681. }
  11682. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11683. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11684. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11685. $con = ' and inputDate = "' . $D1 . '"';
  11686. else{
  11687. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  11688. }
  11689. if ($cid != 'ALL') {
  11690. $cid = $XDeode->decode ( $cid );
  11691. $con .= ' and cid = "' . $cid . '"';
  11692. }
  11693. if ($accountType != 'ALL') {
  11694. if ($accountType == 'INVOICE') {
  11695. $con .= ' and accountType = 11';
  11696. } elseif ($accountType == 'PAYMENTS') {
  11697. $con .= ' and (accountType = 5 or accountType = 9 or accountType = 10)';
  11698. if ($dailyExpenditureType != 'ALL') {
  11699. $dailyExpenditureType = $XDeode->decode ( $dailyExpenditureType );
  11700. $con .= ' and dailyExpenditureType = ' . $dailyExpenditureType;
  11701. }
  11702. } elseif ($accountType == 'RECEIPT') {
  11703. if ($receiptType == 'ALL') {
  11704. $con .= ' and (accountType = 1 or accountType = 2 or accountType = 3 or accountType = 4)';
  11705. } else {
  11706. $receiptType = $XDeode->decode ( $receiptType );
  11707. echo $receiptType;
  11708. if ($receiptType == 1) {
  11709. $con .= ' and (accountType = 1 or accountType=2)';
  11710. } else {
  11711. $con .= ' and accountType = ' . $receiptType;
  11712. }
  11713. }
  11714. }
  11715. }
  11716. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 2, $con );
  11717. $sum = 0;$thsDaySum=0;
  11718. foreach ( $incomeList as $key => $value ) {
  11719. $sum += $value ['accountPriceShow'];
  11720. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  11721. $thsDaySum+=$value ['accountPriceShow'];
  11722. }
  11723. }
  11724. // print_r($incomeList);
  11725. // 获得办事和部门
  11726. $categoryList = $L_category->getCategory ();
  11727. $data ['accountType'] = $accountType;
  11728. $data ['cid'] = $cid;
  11729. $data ['categoryList'] = $categoryList;
  11730. $data ['sum'] = $sum;
  11731. $data ['incomeList'] = $incomeList;
  11732. $data ['inputDate'] = $date;
  11733. $data['year']=$year;
  11734. $data ['thsDay'] =$theDay;
  11735. $data ['thsDaySum'] =$thsDaySum;
  11736. $data ['memu'] = "receipt";
  11737. $data ['staff'] = $this->staff;
  11738. $data ['receiptMemu'] = 'wasteBook';
  11739. $data ['verifyId'] = $this->verifyId;
  11740. $data ['executeId'] = $this->executeId;
  11741. $this->render ( "/expenses/wasteBookExpenditure", $data );
  11742. }
  11743. function ajaxGetWasteinvoiceReceivables() {
  11744. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11745. Doo::loadClass ( 'XDeode' );
  11746. $XDeode = new XDeode ( 5 );
  11747. $irid = $XDeode->decode ( $serial );
  11748. Doo::loadModel ( 'invoiceReceivables' );
  11749. $invoiceReceivables = new invoiceReceivables ();
  11750. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  11751. echo json_encode ( array (
  11752. 'status' => 1,
  11753. 'detail' => $detail
  11754. ) );
  11755. }
  11756. function ajaxGetPaymentsByAid() {
  11757. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11758. Doo::loadModel ( "accountBook" );
  11759. $accountBook = new accountBook ();
  11760. $detail = $accountBook->getAccountBookByAid ( $serial );
  11761. echo json_encode ( array (
  11762. 'status' => 1,
  11763. 'detail' => $detail
  11764. ) );
  11765. }
  11766. function ajaxGetWasteInvoice() {
  11767. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11768. Doo::loadModel ( 'invoice' );
  11769. $invoice = new invoice ();
  11770. Doo::loadModel ( 'invoiceReceivables' );
  11771. $invoiceReceivables = new invoiceReceivables ();
  11772. $detail = $invoice->getInvoiceByIid ( $serial );
  11773. $detailReceivables = $invoiceReceivables->getInvoiceReceivablesByIrid ( $detail ['irid'] );
  11774. $detail ['receivablesBank'] = $detailReceivables ['receivablesBank'];
  11775. echo json_encode ( array (
  11776. 'status' => 1,
  11777. 'detail' => $detail
  11778. ) );
  11779. }
  11780. /**
  11781. */
  11782. function ajaxGetWasteReceipt() {
  11783. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11784. $accountTypeKey = $this->get_args ( 'accountTypeKey' ) ? $this->get_args ( 'accountTypeKey' ) : "";
  11785. Doo::loadModel ( 'receipt' );
  11786. $receipt = new receipt ();
  11787. Doo::loadClass ( 'XDeode' );
  11788. $XDeode = new XDeode ( 5 );
  11789. $rid = $XDeode->decode ( $serial );
  11790. $accountType= $XDeode->decode ( $accountTypeKey );
  11791. // 获得个数据
  11792. $detail = $receipt->getReceiptByRid ( $rid );
  11793. // 初始化
  11794. $detail ['reviseDetail'] = array ();
  11795. if (! empty ( $value ['reviseDetail'] ))
  11796. $detail ['reviseDetail'] = json_decode ( $detail ['reviseDetail'], true );
  11797. $detail ['accountItem'] = json_decode ( $detail ['accountItem'], true );
  11798. $detail ['loanItem'] = json_decode ( $detail ['loanItem'], true );
  11799. $detail ['loanSumCN'] = $this->num_to_rmb ( $detail ['loanSum'] );
  11800. $detail ['sumCN'] = $this->num_to_rmb ( $detail ['sum'] );
  11801. // 获得费用html
  11802. $html = $this->getWasteReceiptHtml ( $detail ,$accountType);
  11803. // 获得费用审批人数据
  11804. $detail = $this->getReceiptApproverHtml ( $detail );
  11805. // 审批执行
  11806. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  11807. <th class="taC" width="90">审批人</th>
  11808. <th class="taC">审批意见</th></tr>';
  11809. foreach ( $detail ['verifyList'] as $key => $value ) {
  11810. $html .= '<tr>
  11811. <td>' . $value [1] . '</td>
  11812. <td>' . $value ['opinion'] . '</td>
  11813. </tr>
  11814. ';
  11815. }
  11816. $html .= ' </tbody></table>';
  11817. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  11818. <th class="taC" width="90">执行人</th>
  11819. <th class="taC">执行意见</th></tr>';
  11820. foreach ( $detail ['executeCopy'] as $key => $value ) {
  11821. $html .= '<tr>
  11822. <td>' . $value [1] . '</td>
  11823. <td>' . $value ['opinion'] . '</td>
  11824. </tr>
  11825. ';
  11826. }
  11827. $html .= ' </tbody></table>';
  11828. if($accountType==1){
  11829. Doo::loadModel ( 'loanReceipt' );
  11830. $loanReceipt = new loanReceipt ();
  11831. $loanList = $loanReceipt->getOne ( array (
  11832. 'where' => 'rid=' . $detail ['loanRid'],
  11833. 'desc' => 'rid',
  11834. 'asArray' => true
  11835. ) );
  11836. $html .= '<table class="table table-bordered table-condensed">
  11837. <tr class="warning">
  11838. <td class="taR"><b>汇款金额</b></td>
  11839. <td width="140" class="taR"><b style="font-size: 24px">¥'.$loanList['amount'].'</b></td>
  11840. </tr>
  11841. </table>';
  11842. }else{
  11843. $html .= '<table class="table table-bordered table-condensed">
  11844. <tr class="warning">
  11845. <td class="taR"><b>汇款金额</b></td>
  11846. <td width="140" class="taR"><b style="font-size: 24px">¥' . $detail ['amount'] . '</b></td>
  11847. </tr>
  11848. </table>';
  11849. }
  11850. // print_r($detail['verifyList']);
  11851. // header ( 'Content-Type:text/html;charset=utf-8' );
  11852. // echo $html;
  11853. echo json_encode ( array (
  11854. 'status' => 1,
  11855. 'html' => $html,
  11856. 'detail' => $detail
  11857. ) );
  11858. }
  11859. function getReceiptApproverHtml($detail = array()) {
  11860. Doo::loadModel ( 'loanReceipt' );
  11861. $loanReceipt = new loanReceipt ();
  11862. Doo::loadModel ( 'verify' );
  11863. $verify = new verify ();
  11864. Doo::loadModel ( 'staff' );
  11865. $staff = new staff ();
  11866. if (empty ( $detail ))
  11867. return array ();
  11868. $loanList = $loanReceipt->getOne ( array (
  11869. 'where' => 'rid=' . $detail ['loanRid'],
  11870. 'desc' => 'rid',
  11871. 'asArray' => true
  11872. ) );
  11873. if ($detail ['status'] == 3 || $detail ['status'] == 1 || $detail ['status'] == 8 || $detail ['status'] == 9) {
  11874. if ($detail ['status'] == 8 && $detail ['Rtype'] == 1)
  11875. $verifyList ['staff'] = $loanList ['verifyBreakup'];
  11876. else
  11877. $verifyList ['staff'] = $detail ['verifyBreakup'];
  11878. } else
  11879. $verifyList = $verify->getOne ( array (
  11880. 'where' => 'vid=' . $detail ['verify'],
  11881. 'asArray' => true
  11882. ) );
  11883. $verifyList = json_decode ( $verifyList ['staff'], true );
  11884. Doo::loadModel ( 'role' );
  11885. $role = new role ();
  11886. $roleId = 0;
  11887. $flag = true;
  11888. $roleKey = 0;
  11889. $endStaffArray = array ();
  11890. $roleArrayCopy = array ();
  11891. foreach ( $verifyList as $k => $v ) {
  11892. // init verifyStaff
  11893. if ($v [1] == 'ROLE') {
  11894. if (! empty ( $verifyStaff )) {
  11895. $endStaffArray = end ( $verifyStaff );
  11896. }
  11897. $roleVerify = json_decode ( $v [3], true );
  11898. $roleKey = $k;
  11899. $roleArray = array ();
  11900. $rolename = $role->getOne ( array (
  11901. 'where' => 'rid=' . $v [0],
  11902. 'asArray' => true
  11903. ) );
  11904. foreach ( $roleVerify as $o => $p ) {
  11905. $staffID = explode ( '_', $p );
  11906. $staffInfo = $staff->getOne ( array (
  11907. 'where' => 'sid=' . $staffID [0],
  11908. 'asArray' => true
  11909. ) );
  11910. // print_r($staffID);
  11911. $exp = array (
  11912. 0 => $staffInfo ['sid'],
  11913. 1 => $staffID [1],
  11914. 2 => $staffInfo ['avatar'],
  11915. 'date' => '',
  11916. 'date' => '',
  11917. 'opinion' => '',
  11918. 'status' => '',
  11919. 'rolename' => $rolename ['name']
  11920. );
  11921. array_push ( $roleArray, $exp );
  11922. }
  11923. $roleArrayCopy [$v [0]] = $roleArray;
  11924. // $verifyList[$k]['roleArray']=$roleArray;
  11925. }
  11926. $verifyList [$k] ['date'] = "";
  11927. $verifyList [$k] ['opinion'] = "";
  11928. $verifyList [$k] ['status'] = "";
  11929. if (empty ( $verifyStaff )) {
  11930. $verifyList [$k] ['date'] = "";
  11931. $verifyList [$k] ['opinion'] = "";
  11932. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  11933. $verifyList [$k] ['status'] = 4;
  11934. $flag = false;
  11935. }
  11936. } else {
  11937. foreach ( $verifyStaff as $m => $u ) {
  11938. if ($v [0] == $m) {
  11939. $verifyList [$k] ['date'] = $u ['date'];
  11940. $verifyList [$k] ['opinion'] = $u ['opinion'];
  11941. $verifyList [$k] ['status'] = $u ['status'];
  11942. $flag = false;
  11943. break;
  11944. }
  11945. }
  11946. $endStaffArray = end ( $verifyStaff );
  11947. }
  11948. }
  11949. $rolename ['name'] = '';
  11950. if (! empty ( $roleId )) {
  11951. Doo::loadModel ( 'role' );
  11952. $role = new role ();
  11953. $rolename = $role->getOne ( array (
  11954. 'where' => 'rid=' . $roleId,
  11955. 'asArray' => true
  11956. ) );
  11957. }
  11958. if (! empty ( $verifyStaff ))
  11959. $endStaffArray = end ( $verifyStaff );
  11960. $KOP = false;
  11961. foreach ( $roleArrayCopy as $P => $A ) {
  11962. foreach ( $A as $MKI => $AVL ) {
  11963. if (! empty ( $verifyStaff )) {
  11964. // &&$rolename['rid']==$endStaffArray['nextStaff']
  11965. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  11966. $button = 4;
  11967. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  11968. }
  11969. foreach ( $verifyStaff as $m => $u ) {
  11970. $AVLFK = $AVL [0] . '_R';
  11971. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  11972. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  11973. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  11974. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  11975. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  11976. break;
  11977. }
  11978. }
  11979. } else {
  11980. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  11981. $button = 4;
  11982. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  11983. }
  11984. }
  11985. // $roleArray[$MKI]['rolename']=$rolename['name'];
  11986. $KOP = true;
  11987. }
  11988. }
  11989. foreach ( $roleArrayCopy as $k => $v ) {
  11990. foreach ( $verifyList as $m => $n ) {
  11991. if ($n [0] == $k) {
  11992. array_splice ( $verifyList, $m, 1, $v );
  11993. }
  11994. }
  11995. }
  11996. // 费用执行人相关数据
  11997. $executeCopy = json_decode ( $detail ['executeCopy'], true );
  11998. $executeStaff = json_decode ( $detail ['executeStaff'], true );
  11999. foreach ( $executeCopy as $k => $v ) {
  12000. $executeCopy [$k] ['date'] = '';
  12001. $executeCopy [$k] ['opinion'] = '';
  12002. $executeCopy [$k] ['status'] = '';
  12003. if (! empty ( $executeStaff ))
  12004. foreach ( $executeStaff as $m => $u ) {
  12005. if ($v [0] == $m) {
  12006. $executeCopy [$k] ['date'] = $u ['date'];
  12007. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  12008. $executeCopy [$k] ['status'] = $u ['status'];
  12009. break;
  12010. }
  12011. }
  12012. }
  12013. $detail ['executeCopy'] = $executeCopy;
  12014. $detail ['verifyList'] = $verifyList;
  12015. return $detail;
  12016. }
  12017. function getWasteReceiptHtml($detail = array(),$accountType=1) {
  12018. if (empty ( $detail ))
  12019. return '';
  12020. $html = '';
  12021. if ($detail ['Rtype'] == 0) { // 报销单
  12022. $html .= '<table class="table table-bordered table-condensed">
  12023. <tbody>
  12024. <tr>
  12025. <th colspan="2" class="taC">日常相关费用</th>
  12026. </tr>';
  12027. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12028. $html .= '
  12029. <tr>
  12030. <th>' . $value ['name'] . '</th>
  12031. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12032. </tr>';
  12033. }
  12034. $html .= '
  12035. <tr>
  12036. <th class="taR">合计</th>
  12037. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12038. </tr>';
  12039. $html .= '<tr>
  12040. <th colspan="2" class="taC">差旅相关费用</th>
  12041. </tr>';
  12042. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12043. $html .= '
  12044. <tr>
  12045. <th>' . $value ['name'] . '</th>
  12046. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12047. </tr>';
  12048. }
  12049. $html .= '
  12050. <tr>
  12051. <th class="taR">合计</th>
  12052. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12053. </tr>';
  12054. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12055. $html .= '<tr>
  12056. <th colspan="2" class="taC">内部培训费用</th>
  12057. </tr>';
  12058. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12059. $html .= '
  12060. <tr>
  12061. <th>' . $value ['name'] . '</th>
  12062. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12063. </tr>';
  12064. }
  12065. $html .= '
  12066. <tr>
  12067. <th class="taR">合计</th>
  12068. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12069. </tr>';
  12070. }
  12071. $html .= '<tr>
  12072. <th colspan="2" class="taC">其他</th>
  12073. </tr>';
  12074. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12075. $html .= '
  12076. <tr>
  12077. <th>' . $value ['name'] . '</th>
  12078. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12079. </tr>';
  12080. }
  12081. $html .= '
  12082. <tr>
  12083. <th class="taR">合计</th>
  12084. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12085. </tr>';
  12086. $html .= '<tr>
  12087. <th colspan="2" class="taC">报销金额调整</th>
  12088. </tr>';
  12089. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12090. $html .= '
  12091. <tr>
  12092. <th>' . $value ['name'] . '</th>
  12093. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12094. </tr>';
  12095. }
  12096. $html .= '
  12097. <tr>
  12098. <th class="taR">合计</th>
  12099. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12100. </tr>';
  12101. $html .= '
  12102. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12103. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12104. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12105. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12106. <tr class="warning">
  12107. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12108. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12109. </tr>
  12110. </tbody>
  12111. </table>';
  12112. } elseif ($detail ['Rtype'] == 2) {//对公汇款
  12113. $html .= '
  12114. <table class="table table-bordered table-condensed">
  12115. <tbody>
  12116. <tr>
  12117. <th colspan="2" class="taC">办事处相关费用</th>
  12118. </tr>';
  12119. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12120. $html .= '
  12121. <tr>
  12122. <th>' . $value ['name'] . '</th>
  12123. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12124. </tr>';
  12125. }
  12126. $html .= '
  12127. <tr>
  12128. <th class="taR">合计</th>
  12129. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12130. </tr>';
  12131. $html .= '
  12132. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12133. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12134. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12135. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12136. <tr class="warning">
  12137. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12138. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12139. </tr>
  12140. </tbody>
  12141. </table>';
  12142. } elseif ($detail ['Rtype'] == 1) {//借款 或者借款报销
  12143. Doo::loadModel ( 'loanReceipt' );
  12144. $loanReceipt = new loanReceipt ();
  12145. $loanList = $loanReceipt->getOne ( array (
  12146. 'where' => 'rid=' . $detail ['loanRid'],
  12147. 'desc' => 'rid',
  12148. 'asArray' => true
  12149. ) );
  12150. // print_r($loanList);
  12151. $loanList ['sumCN']=$this->num_to_rmb($loanList ['sum']);
  12152. $html .= '<table class="table table-bordered table-condensed">
  12153. <tbody>
  12154. <tr>
  12155. <th colspan="2" class="taC">借款费用</th>
  12156. </tr>';
  12157. foreach ( $detail ['loanItem'] ['借款费用'] as $key => $value ) {
  12158. $html .= '<tr>
  12159. <th>' . $value ['name'] . '</th>
  12160. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12161. </tr>';
  12162. }
  12163. $html .= '<tr>
  12164. <th class="taC" colspan="2">产生费用所在办事处</th>
  12165. </tr>
  12166. <tr>
  12167. <th style="text-align: center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th>
  12168. </tr>
  12169. <tr>
  12170. <th class="taC" colspan="2">费用说明</th>
  12171. </tr>
  12172. <tr>
  12173. <td colspan="2">' . $loanList ['explanation'] . '</td>
  12174. </tr>
  12175. <tr class="warning">
  12176. <td class="taR"><b>(' . $loanList ['receiptOrder'] . ')本次费用合计</b></td>
  12177. <td class="taR"><b style="font-size: 24px">¥' . $loanList ['sum'] . '</b><br>' . $loanList ['sumCN'] . '</td>
  12178. </tr>
  12179. </tbody>
  12180. </table>
  12181. ';
  12182. if ( $accountType==2) {
  12183. $balance=$detail ['sum']-$loanList ['sum'];
  12184. $balanceCN=$this->num_to_rmb($balance);
  12185. $html .= '<table class="table table-bordered table-condensed">
  12186. <tbody>
  12187. <tr>
  12188. <th colspan="2" class="taC">日常相关费用</th>
  12189. </tr>';
  12190. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12191. $html .= '
  12192. <tr>
  12193. <th>' . $value ['name'] . '</th>
  12194. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12195. </tr>';
  12196. }
  12197. $html .= '
  12198. <tr>
  12199. <th class="taR">合计</th>
  12200. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12201. </tr>';
  12202. $html .= '<tr>
  12203. <th colspan="2" class="taC">差旅相关费用</th>
  12204. </tr>';
  12205. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12206. $html .= '
  12207. <tr>
  12208. <th>' . $value ['name'] . '</th>
  12209. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12210. </tr>';
  12211. }
  12212. $html .= '
  12213. <tr>
  12214. <th class="taR">合计</th>
  12215. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12216. </tr>';
  12217. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12218. $html .= '<tr>
  12219. <th colspan="2" class="taC">内部培训费用</th>
  12220. </tr>';
  12221. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12222. $html .= '
  12223. <tr>
  12224. <th>' . $value ['name'] . '</th>
  12225. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12226. </tr>';
  12227. }
  12228. $html .= '
  12229. <tr>
  12230. <th class="taR">合计</th>
  12231. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12232. </tr>';
  12233. }
  12234. $html .= '<tr>
  12235. <th colspan="2" class="taC">其他</th>
  12236. </tr>';
  12237. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12238. $html .= '
  12239. <tr>
  12240. <th>' . $value ['name'] . '</th>
  12241. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12242. </tr>';
  12243. }
  12244. $html .= '
  12245. <tr>
  12246. <th class="taR">合计</th>
  12247. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12248. </tr>';
  12249. $html .= '<tr>
  12250. <th colspan="2" class="taC">报销金额调整</th>
  12251. </tr>';
  12252. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12253. $html .= '
  12254. <tr>
  12255. <th>' . $value ['name'] . '</th>
  12256. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12257. </tr>';
  12258. }
  12259. $html .= '
  12260. <tr>
  12261. <th class="taR">合计</th>
  12262. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12263. </tr>';
  12264. $html .= '
  12265. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12266. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12267. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12268. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12269. <tr class="warning">
  12270. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12271. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12272. </tr>
  12273. <tr class="success">
  12274. <td class="taR"><b>借款结余</b></td>
  12275. <td class="taR"><b style="font-size:24px">¥'.$balance.'</b><br>'.$balanceCN.'</td>
  12276. </tr>
  12277. </tbody>
  12278. </table>';
  12279. }
  12280. }
  12281. return $html;
  12282. }
  12283. /**
  12284. * 计算流水
  12285. */
  12286. function getWasteBookStatistics($waste = array(), $inComeStatistics) {
  12287. $bakWaste ['bank'] = array (
  12288. 'CGBDeposit' => 0,
  12289. 'ICBCDeposit' => 0,
  12290. 'HUADeposit' => 0,
  12291. 'PersonalDeposit' => 0
  12292. );
  12293. $bakWaste ['financial'] = array (
  12294. 'current' => array (
  12295. 'CGBDeposit' => 0,
  12296. 'ICBCDeposit' => 0
  12297. ),
  12298. 'fixed' => array (
  12299. 'CGBDeposit' => 0,
  12300. 'ICBCDeposit' => 0
  12301. )
  12302. );
  12303. // 存款
  12304. foreach ( $waste ['bank'] as $key => $value ) {
  12305. // 收入
  12306. foreach ( $inComeStatistics ['incomeStatistics'] as $k => $v ) {
  12307. // 广发
  12308. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12309. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12310. }
  12311. // 工商
  12312. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12313. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12314. }
  12315. // 华润
  12316. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12317. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12318. }
  12319. // 个人
  12320. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12321. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12322. }
  12323. }
  12324. }
  12325. foreach ( $waste ['bank'] as $key => $value ) {
  12326. // 支出
  12327. foreach ( $inComeStatistics ['expenditureStatistics'] as $k => $v ) {
  12328. // 广发
  12329. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12330. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12331. }
  12332. // 工商
  12333. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12334. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12335. }
  12336. // 华润
  12337. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12338. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12339. }
  12340. // 个人
  12341. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12342. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12343. }
  12344. }
  12345. }
  12346. // 活期
  12347. foreach ( $waste ['financial'] ['current'] as $key => $value ) {
  12348. foreach ( $inComeStatistics ['currentStatistics'] as $k => $v ) {
  12349. // 广发
  12350. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12351. $waste ['financial'] ['current'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  12352. }
  12353. // 工商
  12354. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12355. $waste ['financial'] ['current'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  12356. }
  12357. // 个人
  12358. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12359. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  12360. }
  12361. }
  12362. }
  12363. // print_r($inComeStatistics ['fixedStatistics']);
  12364. // 固期
  12365. foreach ( $waste ['financial'] ['fixed'] as $key => $value ) {
  12366. foreach ( $inComeStatistics ['fixedStatistics'] as $k => $v ) {
  12367. // 广发
  12368. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12369. $waste ['financial'] ['fixed'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  12370. }
  12371. // 工商
  12372. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12373. $waste ['financial'] ['fixed'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  12374. }
  12375. // 个人
  12376. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12377. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  12378. }
  12379. }
  12380. }
  12381. return $waste;
  12382. }
  12383. function lyt() {
  12384. Doo::loadModel ( "receiptDetail" );
  12385. $receiptDetail = new receiptDetail ();
  12386. $receiptCollectList = $receiptDetail->find ( array (
  12387. 'where' => 'status=1 ',
  12388. 'asArray' => true
  12389. ) );
  12390. foreach ( $receiptCollectList as $key => $value ) {
  12391. $receiptDetail = new receiptDetail ();
  12392. $receiptDetail->pastDate = $value ['date'];
  12393. $receiptDetail->update ( array (
  12394. 'where' => "rdid= '" . $value ['rdid'] . "'"
  12395. ) );
  12396. }
  12397. }
  12398. function staffCollectMonthDetail() {
  12399. //include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  12400. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12401. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12402. if (! $year)
  12403. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12404. if (! $month)
  12405. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12406. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  12407. if (! $nature){
  12408. $nature = isset ( $this->params ['nature'] ) ? $this->params ['nature'] : 'ONJOB';
  12409. }
  12410. Doo::loadModel ( 'staff' );
  12411. $staff = new staff ();
  12412. Doo::loadModel ( "receiptDetail" );
  12413. $receiptDetail = new receiptDetail ();
  12414. Doo::loadModel ( 'accountItem' );
  12415. $accountItem = new accountItem ();
  12416. Doo::loadModel ( 'statistics' );
  12417. $statistics = new statistics ();
  12418. Doo::loadModel ( "receiptAuthorityManage" );
  12419. $receiptAuthorityManage = new receiptAuthorityManage ();
  12420. $aiList=$accountItem->getAccountItem();
  12421. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  12422. $cidList = array ();
  12423. foreach ( $imcStaff as $key => $value ) {
  12424. array_push ( $cidList, $value ['cid'] );
  12425. }
  12426. $cidString = implode ( ',', $cidList );
  12427. $naturecon='';
  12428. if ($nature=='ONJOB'){
  12429. $naturecon=' and (nature!=4 )';
  12430. }elseif($nature=='LEAVEJOB'){
  12431. $naturecon=' and (nature=4 )';
  12432. }else{
  12433. die ( 'illegal request--nature' );
  12434. }
  12435. $staffList = $staff->find ( array (
  12436. 'where' => 'username!="admin" and cid in (' . $cidString . ')'.$naturecon,
  12437. 'asArray' => true
  12438. ) );
  12439. $categoryList = $staff->find ( array (
  12440. 'select' => 'COUNT(*) as count,cid,category',
  12441. 'where' => 'username !="admin" and cid in (' . $cidString . ')'.$naturecon,
  12442. 'groupby' => 'cid',
  12443. 'asArray' => true
  12444. ) );
  12445. $list = array ();
  12446. foreach($aiList as $key=>$value){
  12447. foreach ($value as $v){
  12448. $subtotal[$key][$v['name']]=0;
  12449. }
  12450. }
  12451. foreach ( $categoryList as $vlu ) {
  12452. $s1 = 0;
  12453. $m1 = 0;
  12454. $subtotal[$this->AGENCY]['AGENCY']=$subtotal[$this->TRAVEL]['TRAVEL']=$subtotal[$this->INTTRAIN]['INTTRAIN']=$subtotal[$this->TRAIN]['TRAIN']=$subtotal[$this->OTHER]['OTHER']=0;
  12455. foreach ( $staffList as $value ) {
  12456. if ($vlu ['cid'] == $value ['cid']) {
  12457. // pastDate
  12458. $receiptCollectList = $receiptDetail->find ( array (
  12459. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12460. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12461. 'groupby' => 'item,Month(pastDate),itemCategory',
  12462. 'asArray' => true
  12463. ) );
  12464. if (! empty ( $receiptCollectList )) {
  12465. $receiptL = array (
  12466. '日常相关费用' => array (),
  12467. '差旅相关费用' => array (),
  12468. '内部培训费用' => array (),
  12469. '培训班费用' => array (),
  12470. '其他' => array ()
  12471. );
  12472. $html = "";
  12473. $psum = 0;
  12474. foreach ( $aiList[$this->AGENCY] as $va ) {
  12475. $falg = true;
  12476. foreach ( $receiptCollectList as $v ) {
  12477. if ($v ['itemCategory'] == '日常相关费用') {
  12478. if ($v ['item'] == $va['name']) {
  12479. $subtotal[$this->AGENCY][$va['name']]+=$v ['price'];
  12480. $psum += $v ['price'];
  12481. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12482. $falg = false;
  12483. break;
  12484. }
  12485. }
  12486. }
  12487. if ($falg)
  12488. $html .= '<td class="taR">-</td>';
  12489. }
  12490. $subtotal[$this->AGENCY]['AGENCY'] += $psum;
  12491. if (! empty ( $psum ))
  12492. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12493. else
  12494. $psum = '<td class="colGreen taR">-</td>';
  12495. $receiptL ['日常相关费用'] = $psum . $html;
  12496. /* ----------------------------------- */
  12497. $html = "";
  12498. $psum = 0;
  12499. foreach ( $aiList[$this->TRAVEL] as $va ) {
  12500. $falg = true;
  12501. foreach ( $receiptCollectList as $v ) {
  12502. if ($v ['itemCategory'] == '差旅相关费用') {
  12503. if ($v ['item'] == $va['name']) {
  12504. $subtotal[$this->TRAVEL][$va['name']]+=$v ['price'];
  12505. $psum += $v ['price'];
  12506. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12507. $falg = false;
  12508. break;
  12509. }
  12510. }
  12511. }
  12512. if ($falg)
  12513. $html .= '<td class="taR">-</td>';
  12514. }
  12515. $subtotal[$this->TRAVEL]['TRAVEL'] += $psum;
  12516. if (! empty ( $psum ))
  12517. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12518. else
  12519. $psum = '<td class="colGreen taR">-</td>';
  12520. $receiptL ['差旅相关费用'] = $psum . $html;
  12521. /* ------------------------------------- */
  12522. $html = "";
  12523. $psum = 0;
  12524. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  12525. $falg = true;
  12526. foreach ( $receiptCollectList as $v ) {
  12527. if ($v ['itemCategory'] == '内部培训费用') {
  12528. if ($v ['item'] == $va['name']) {
  12529. $subtotal[$this->INTTRAIN][$va['name']]+=$v ['price'];
  12530. $psum += $v ['price'];
  12531. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12532. $falg = false;
  12533. break;
  12534. }
  12535. }
  12536. }
  12537. if ($falg)
  12538. $html .= '<td class="taR">-</td>';
  12539. }
  12540. $subtotal[$this->INTTRAIN]['INTTRAIN'] += $psum;
  12541. if (! empty ( $psum ))
  12542. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12543. else
  12544. $psum = '<td class="colGreen taR">-</td>';
  12545. $receiptL ['内部培训费用'] = $psum . $html;
  12546. /* ----------------------------------- */
  12547. $html = "";
  12548. $psum = 0;
  12549. foreach ( $aiList[$this->TRAIN] as $va ) {
  12550. $falg = true;
  12551. foreach ( $receiptCollectList as $v ) {
  12552. if ($v ['itemCategory'] == '培训班费用') {
  12553. if ($v ['item'] == $va['name']) {
  12554. $subtotal[$this->TRAIN][$va['name']]+=$v ['price'];
  12555. $psum += $v ['price'];
  12556. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12557. $falg = false;
  12558. break;
  12559. }
  12560. }
  12561. }
  12562. if ($falg)
  12563. $html .= '<td class="taR">-</td>';
  12564. }
  12565. $subtotal[$this->TRAIN]['TRAIN'] += $psum;
  12566. if (! empty ( $psum ))
  12567. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12568. else
  12569. $psum = '<td class="colGreen taR">-</td>';
  12570. $receiptL ['培训班费用'] = $psum . $html;
  12571. /* ------------------------------------- */
  12572. $html = "";
  12573. $psum = 0;
  12574. foreach ( $aiList[$this->OTHER] as $va ) {
  12575. $falg = true;
  12576. foreach ( $receiptCollectList as $v ) {
  12577. if ($v ['itemCategory'] == '其他') {
  12578. if (trim ( $v ['item'] ) == $va['name']) {
  12579. $subtotal[$this->OTHER][$va['name']]+=$v ['price'];
  12580. $psum += $v ['price'];
  12581. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12582. $falg = false;
  12583. break;
  12584. }
  12585. }
  12586. }
  12587. if ($falg)
  12588. $html .= '<td class="taR">-</td>';
  12589. }
  12590. $subtotal[$this->OTHER]['OTHER'] += $psum;
  12591. if (! empty ( $psum ))
  12592. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12593. else
  12594. $psum = '<td class="colGreen taR">-</td>';
  12595. $receiptL ['其他'] = $psum . $html;
  12596. /* ------------------------------------- */
  12597. $html = "";
  12598. $psum = 0;
  12599. foreach ( $receiptCollectList as $v ) {
  12600. if ($v ['itemCategory'] == '报销金额调整') {
  12601. if (! empty ( $v ['price'] )) {
  12602. $psum += $v ['price'];
  12603. }
  12604. }
  12605. }
  12606. $s1 += $psum;
  12607. if (! empty ( $psum ))
  12608. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  12609. else
  12610. $psum = '<td class="taR colOrange">-</td>';
  12611. $receiptL ['报销金额调整'] = $psum . $html;
  12612. } else {
  12613. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  12614. foreach ( $aiList[$this->AGENCY] as $va ) {
  12615. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  12616. }
  12617. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  12618. foreach ( $aiList[$this->TRAVEL] as $va ) {
  12619. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  12620. }
  12621. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  12622. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  12623. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  12624. }
  12625. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  12626. foreach ( $aiList[$this->TRAIN] as $va ) {
  12627. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  12628. }
  12629. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  12630. foreach ( $aiList[$this->OTHER] as $va ) {
  12631. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  12632. }
  12633. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  12634. }
  12635. $monthStaffPrice = $receiptDetail->find ( array (
  12636. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12637. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12638. 'groupby' => 'Month(pastDate)',
  12639. 'asArray' => true
  12640. ) );
  12641. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  12642. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  12643. $m1 += $monthStaffPrice [0] ['price'];
  12644. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  12645. } else
  12646. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  12647. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  12648. $list [$value ['username']] = $receiptL;
  12649. }
  12650. }
  12651. $receiptL [$this->AGENCY] ='<td class="colGreen taR">'.$subtotal[$this->AGENCY]['AGENCY'].'</td>';
  12652. foreach ( $aiList[$this->AGENCY] as $va ) {
  12653. $receiptL [$this->AGENCY] .='<td class="taR">' . $subtotal[$this->AGENCY][$va['name']] . '</td>';
  12654. $subtotal[$this->AGENCY][$va['name']]=0;
  12655. }
  12656. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">'.$subtotal[$this->TRAVEL]['TRAVEL'].'</td>';
  12657. foreach ( $aiList[$this->TRAVEL] as $va ) {
  12658. $receiptL [$this->TRAVEL] .='<td class="taR">' . $subtotal[$this->TRAVEL][$va['name']] . '</td>';
  12659. $subtotal[$this->TRAVEL][$va['name']]=0;
  12660. }
  12661. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">'.$subtotal[$this->INTTRAIN]['INTTRAIN'].'</td>';
  12662. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  12663. $receiptL [$this->INTTRAIN] .='<td class="taR">' . $subtotal[$this->INTTRAIN][$va['name']] . '</td>';
  12664. $subtotal[$this->INTTRAIN][$va['name']]=0;
  12665. }
  12666. $receiptL [$this->TRAIN] ='<td class="colGreen taR">'.$subtotal[$this->TRAIN]['TRAIN'].'</td>';
  12667. foreach ( $aiList[$this->TRAIN] as $va ) {
  12668. $receiptL [$this->TRAIN] .='<td class="taR">' . $subtotal[$this->TRAIN][$va['name']] . '</td>';
  12669. $subtotal[$this->TRAIN][$va['name']]=0;
  12670. }
  12671. $receiptL [$this->OTHER] ='<td class="colGreen taR">'.$subtotal[$this->OTHER]['OTHER'].'</td>';
  12672. foreach ( $aiList[$this->OTHER] as $va ) {
  12673. $receiptL [$this->OTHER] .='<td class="taR">' . $subtotal[$this->OTHER][$va['name']] . '</td>';
  12674. $subtotal[$this->OTHER][$va['name']]=0;
  12675. }
  12676. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  12677. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  12678. $receiptL ['usernameEn'] =false;
  12679. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  12680. }
  12681. $data ['list'] = $list;
  12682. // print_r($list);
  12683. $receiptCollectList = $receiptDetail->find ( array (
  12684. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12685. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12686. 'groupby' => 'item,Month(pastDate),itemCategory',
  12687. 'asArray' => true
  12688. ) );
  12689. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  12690. // statistics html
  12691. $stList = $statistics->getOne ( array (
  12692. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  12693. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  12694. 'groupby' => 'Month(date)',
  12695. 'asArray' => true
  12696. ) );
  12697. if (empty ( $stList ))
  12698. $stList = array (
  12699. 'rePrice' => 0,
  12700. 'agPrice' => 0
  12701. );
  12702. $data ['stList'] = array (
  12703. 'rePrice' => $stList ['rePrice'],
  12704. 'agPrice' => $stList ['agPrice'],
  12705. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12706. );
  12707. $monthHtml = "";
  12708. for($i = 1; $i <= 12; $i ++) {
  12709. if ($i == $month)
  12710. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  12711. else
  12712. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  12713. }
  12714. $data ['monthHtml'] = $monthHtml;
  12715. $data ['year'] = $year;
  12716. $data ['month'] = $month;
  12717. $data ['nature'] = $nature;
  12718. $data ['aiList'] = $aiList;
  12719. $data ['memu'] = "receipt";
  12720. $data ['staff'] = $this->staff;
  12721. $data ['receiptMemu'] = 'companyCategoryCollect';
  12722. $data ['verifyId'] = $this->verifyId;
  12723. $data ['executeId'] = $this->executeId;
  12724. $this->render ( "/admin/staffCollectMonthDetail", $data );
  12725. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  12726. }
  12727. function staffCollectMonthDetail2() {
  12728. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12729. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12730. if (! $year)
  12731. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12732. if (! $month)
  12733. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12734. Doo::loadModel ( 'staff' );
  12735. $staff = new staff ();
  12736. Doo::loadModel ( "receiptDetail" );
  12737. $receiptDetail = new receiptDetail ();
  12738. Doo::loadModel ( 'accountItem' );
  12739. $accountItem = new accountItem ();
  12740. Doo::loadModel ( 'statistics' );
  12741. $statistics = new statistics ();
  12742. Doo::loadModel ( 'L_category' );
  12743. $lCategory = new L_category ();
  12744. $staffList = $staff->find ( array (
  12745. 'where' => 'username!="admin"',
  12746. 'asArray' => true
  12747. ) );
  12748. $categoryList = $staff->find ( array (
  12749. 'select' => 'COUNT(*) as count,cid,category',
  12750. 'where' => 'username !="admin"',
  12751. 'groupby' => 'cid',
  12752. 'asArray' => true
  12753. ) );
  12754. $list = array ();
  12755. foreach ( $categoryList as $vlu ) {
  12756. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  12757. $r1 = 0;
  12758. $r2 = 0;
  12759. $r3 = 0;
  12760. $r4 = 0;
  12761. $r5 = 0;
  12762. $r6 = 0;
  12763. $r7 = 0;
  12764. $r8 = 0;
  12765. $r9 = 0;
  12766. $r10 = 0;
  12767. $r11 = 0;
  12768. $r12 = 0;
  12769. $r13 = 0;
  12770. $r14 = 0;
  12771. $r15 = 0;
  12772. $c1 = 0;
  12773. $c2 = 0;
  12774. $c3 = 0;
  12775. $c4 = 0;
  12776. $c5 = 0;
  12777. $c6 = 0;
  12778. $p1 = 0;
  12779. $p2 = 0;
  12780. $p3 = 0;
  12781. $p4 = 0;
  12782. $p5 = 0;
  12783. $p6 = 0;
  12784. $p7 = 0;
  12785. $p8 = 0;
  12786. $p9 = 0;
  12787. $t1 = 0;
  12788. $t2 = 0;
  12789. $t3 = 0;
  12790. $t4 = 0;
  12791. $t5 = 0;
  12792. $s1 = 0;
  12793. $m1 = 0;
  12794. foreach ( $staffList as $value ) {
  12795. if ($vlu ['cid'] == $value ['cid']) {
  12796. $receiptCollectList = $receiptDetail->find ( array (
  12797. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  12798. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  12799. 'groupby' => 'item,Month(date),itemCategory',
  12800. 'asArray' => true
  12801. ) );
  12802. if (! empty ( $receiptCollectList )) {
  12803. $receiptL = array (
  12804. '日常相关费用' => array (),
  12805. '差旅相关费用' => array (),
  12806. '培训班费用' => array (),
  12807. '其他' => array ()
  12808. );
  12809. $html = "";
  12810. $psum = 0;
  12811. $item = array (
  12812. '市内交通费',
  12813. '市内出租费',
  12814. '办事处房租',
  12815. '电话费',
  12816. '水费',
  12817. '电费',
  12818. '办公费用',
  12819. '邮寄费',
  12820. '其他费用',
  12821. '车辆费用',
  12822. '广告费',
  12823. '团队建设费',
  12824. '物业管理费',
  12825. '宽带费'
  12826. );
  12827. foreach ( $item as $va ) {
  12828. $falg = true;
  12829. foreach ( $receiptCollectList as $v ) {
  12830. if ($v ['itemCategory'] == '日常相关费用') {
  12831. if ($v ['item'] == $va) {
  12832. if ($va == '市内交通费')
  12833. $r1 += $v ['price'];
  12834. if ($va == '市内出租费')
  12835. $r2 += $v ['price'];
  12836. if ($va == '办事处房租')
  12837. $r3 += $v ['price'];
  12838. if ($va == '电话费')
  12839. $r4 += $v ['price'];
  12840. if ($va == '水费')
  12841. $r5 += $v ['price'];
  12842. if ($va == '电费')
  12843. $r6 += $v ['price'];
  12844. if ($va == '办公费用')
  12845. $r7 += $v ['price'];
  12846. if ($va == '邮寄费')
  12847. $r8 += $v ['price'];
  12848. if ($va == '其他费用')
  12849. $r9 += $v ['price'];
  12850. if ($va == '车辆费用')
  12851. $r10 += $v ['price'];
  12852. if ($va == '广告费')
  12853. $r11 += $v ['price'];
  12854. if ($va == '团队建设费')
  12855. $r13 += $v ['price'];
  12856. if ($va == '物业管理费')
  12857. $r14 += $v ['price'];
  12858. if ($va == '宽带费')
  12859. $r15 += $v ['price'];
  12860. $psum += $v ['price'];
  12861. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12862. $falg = false;
  12863. break;
  12864. }
  12865. }
  12866. }
  12867. if ($falg)
  12868. $html .= '<td class="taR">-</td>';
  12869. }
  12870. $r12 += $psum;
  12871. if (! empty ( $psum ))
  12872. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12873. else
  12874. $psum = '<td class="colGreen taR">-</td>';
  12875. $receiptL ['日常相关费用'] = $psum . $html;
  12876. /* ----------------------------------- */
  12877. $html = "";
  12878. $psum = 0;
  12879. $item = array (
  12880. '往来交通费',
  12881. '市内交通费',
  12882. '出差住宿费',
  12883. '出差补助',
  12884. '其他费用'
  12885. );
  12886. foreach ( $item as $va ) {
  12887. $falg = true;
  12888. foreach ( $receiptCollectList as $v ) {
  12889. if ($v ['itemCategory'] == '差旅相关费用') {
  12890. if ($v ['item'] == $va) {
  12891. if ($va == '往来交通费')
  12892. $c1 += $v ['price'];
  12893. if ($va == '市内交通费')
  12894. $c2 += $v ['price'];
  12895. if ($va == '出差住宿费')
  12896. $c3 += $v ['price'];
  12897. if ($va == '出差补助')
  12898. $c4 += $v ['price'];
  12899. if ($va == '其他费用')
  12900. $c5 += $v ['price'];
  12901. $psum += $v ['price'];
  12902. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12903. $falg = false;
  12904. break;
  12905. }
  12906. }
  12907. }
  12908. if ($falg)
  12909. $html .= '<td class="taR">-</td>';
  12910. }
  12911. $c6 += $psum;
  12912. if (! empty ( $psum ))
  12913. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12914. else
  12915. $psum = '<td class="colGreen taR">-</td>';
  12916. $receiptL ['差旅相关费用'] = $psum . $html;
  12917. /* ------------------------------------- */
  12918. $html = "";
  12919. $psum = 0;
  12920. $item = array (
  12921. '场租费',
  12922. '薪酬',
  12923. '住宿费',
  12924. '交通费',
  12925. '餐饮费',
  12926. '办公费',
  12927. '公关费',
  12928. '其他'
  12929. );
  12930. foreach ( $item as $va ) {
  12931. $falg = true;
  12932. foreach ( $receiptCollectList as $v ) {
  12933. if ($v ['itemCategory'] == '培训班费用') {
  12934. if ($v ['item'] == $va) {
  12935. if ($va == '场租费')
  12936. $p1 += $v ['price'];
  12937. if ($va == '薪酬')
  12938. $p2 += $v ['price'];
  12939. if ($va == '住宿费')
  12940. $p3 += $v ['price'];
  12941. if ($va == '交通费')
  12942. $p4 += $v ['price'];
  12943. if ($va == '餐饮费')
  12944. $p5 += $v ['price'];
  12945. if ($va == '办公费')
  12946. $p6 += $v ['price'];
  12947. if ($va == '公关费')
  12948. $p7 += $v ['price'];
  12949. if ($va == '其他')
  12950. $p8 += $v ['price'];
  12951. $psum += $v ['price'];
  12952. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12953. $falg = false;
  12954. break;
  12955. }
  12956. }
  12957. }
  12958. if ($falg)
  12959. $html .= '<td class="taR">-</td>';
  12960. }
  12961. $p9 += $psum;
  12962. if (! empty ( $psum ))
  12963. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12964. else
  12965. $psum = '<td class="colGreen taR">-</td>';
  12966. $receiptL ['培训班费用'] = $psum . $html;
  12967. /* ------------------------------------- */
  12968. $html = "";
  12969. $psum = 0;
  12970. $item = array (
  12971. '公关费',
  12972. '广告费',
  12973. '借款',
  12974. '可自加费用'
  12975. );
  12976. foreach ( $item as $va ) {
  12977. $falg = true;
  12978. foreach ( $receiptCollectList as $v ) {
  12979. if ($v ['itemCategory'] == '其他') {
  12980. if ($v ['item'] == $va) {
  12981. if ($va == '公关费')
  12982. $t1 += $v ['price'];
  12983. if ($va == '广告费')
  12984. $t2 += $v ['price'];
  12985. if ($va == '借款')
  12986. $t3 += $v ['price'];
  12987. if ($va == '可自加费用')
  12988. $t4 += $v ['price'];
  12989. $psum += $v ['price'];
  12990. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12991. $falg = false;
  12992. break;
  12993. }
  12994. }
  12995. }
  12996. if ($falg)
  12997. $html .= '<td class="taR">-</td>';
  12998. }
  12999. $t5 += $psum;
  13000. if (! empty ( $psum ))
  13001. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13002. else
  13003. $psum = '<td class="colGreen taR">-</td>';
  13004. $receiptL ['其他'] = $psum . $html;
  13005. /* ------------------------------------- */
  13006. $html = "";
  13007. $psum = 0;
  13008. foreach ( $receiptCollectList as $v ) {
  13009. if ($v ['itemCategory'] == '报销金额调整') {
  13010. if (! empty ( $v ['price'] )) {
  13011. $psum += $v ['price'];
  13012. }
  13013. }
  13014. }
  13015. $s1 += $psum;
  13016. if (! empty ( $psum ))
  13017. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  13018. else
  13019. $psum = '<td class="taR colOrange">-</td>';
  13020. $receiptL ['报销金额调整'] = $psum . $html;
  13021. } else {
  13022. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13023. <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>';
  13024. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  13025. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13026. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13027. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13028. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13029. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13030. }
  13031. $monthStaffPrice = $receiptDetail->find ( array (
  13032. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13033. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13034. 'asArray' => true
  13035. ) );
  13036. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  13037. $m1 += $monthStaffPrice [0] ['price'];
  13038. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13039. } else
  13040. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13041. $list [$value ['username']] = $receiptL;
  13042. }
  13043. }
  13044. $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>
  13045. <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>
  13046. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  13047. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  13048. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  13049. $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>
  13050. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  13051. $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>';
  13052. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  13053. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  13054. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  13055. }
  13056. $data ['list'] = $list;
  13057. $receiptCollectList = $receiptDetail->find ( array (
  13058. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13059. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13060. 'groupby' => 'item,Month(date),itemCategory',
  13061. 'asArray' => true
  13062. ) );
  13063. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  13064. // statistics html
  13065. $stList = $statistics->getOne ( array (
  13066. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13067. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13068. 'groupby' => 'Month(date)',
  13069. 'asArray' => true
  13070. ) );
  13071. if (empty ( $stList ))
  13072. $stList = array (
  13073. 'rePrice' => 0,
  13074. 'agPrice' => 0
  13075. );
  13076. $data ['stList'] = array (
  13077. 'rePrice' => $stList ['rePrice'],
  13078. 'agPrice' => $stList ['agPrice'],
  13079. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13080. );
  13081. $monthHtml = "";
  13082. for($i = 1; $i <= 12; $i ++) {
  13083. if ($i == $month)
  13084. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13085. else
  13086. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13087. }
  13088. $data ['monthHtml'] = $monthHtml;
  13089. $data ['year'] = $year;
  13090. $data ['month'] = $month;
  13091. $data ['memu'] = "receipt";
  13092. $data ['staff'] = $this->staff;
  13093. $data ['receiptMemu'] = 'companyCategoryCollect';
  13094. $data ['verifyId'] = $this->verifyId;
  13095. $data ['executeId'] = $this->executeId;
  13096. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  13097. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13098. }
  13099. /**
  13100. * 用户报销单列表
  13101. */
  13102. function receiptStatisticsStaffDetail() {
  13103. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13104. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13105. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13106. Doo::loadModel ( "receipt" );
  13107. $receipt = new receipt ();
  13108. Doo::loadModel ( "receiptDetail" );
  13109. $receiptDetail = new receiptDetail ();
  13110. Doo::loadModel ( 'staff' );
  13111. $staff = new staff ();
  13112. Doo::loadModel ( 'accountItem' );
  13113. $accountItem = new accountItem ();
  13114. Doo::loadModel ( 'statistics' );
  13115. $statistics = new statistics ();
  13116. if (! empty ( $username )) {
  13117. $username = addslashes ( urldecode ( $username ) );
  13118. $staffDetail = $staff->getStaffByName ( $username );
  13119. if (empty ( $staffDetail ))
  13120. die ( 'illegal request' );
  13121. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  13122. $itemList = $accountItem->getAccountItem ();
  13123. $itemHtml = '';
  13124. $categoryHtml = '';
  13125. $itemKeyList = array_keys ( $itemList );
  13126. $revisePrice = 0;
  13127. // 报销单内容详情
  13128. foreach ( $list as $key => $value ) {
  13129. $accountItemList = json_decode ( $value ['accountItem'], true );
  13130. $list [$key] ['accountItemList'] = $accountItemList;
  13131. $receiptItemHtml = '';
  13132. foreach ( $itemKeyList as $v ) {
  13133. if ($v == '日常相关费用')
  13134. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  13135. elseif ($v == '差旅相关费用')
  13136. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  13137. elseif ($v == '培训班费用')
  13138. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  13139. elseif ($v == '内部培训费用'){
  13140. if (isset($accountItemList ['cSum'] ['inttrainSum'])){
  13141. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['inttrainSum'] . '</td>';
  13142. }else{
  13143. $receiptItemHtml .= '<td class="colGreen taR">0</td>';
  13144. }
  13145. }elseif ($v == '其他')
  13146. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  13147. foreach ( $itemList [$v] as $ke => $va ) {
  13148. $falg = true;
  13149. if (! empty ( $accountItemList [$v] )) {
  13150. foreach ( $accountItemList [$v] as $ve ) {
  13151. if ($va ['name'] == $ve ['name']) {
  13152. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  13153. $falg = false;
  13154. break;
  13155. }
  13156. }
  13157. }
  13158. if ($falg)
  13159. $receiptItemHtml .= '<td class="taR"></td>';
  13160. }
  13161. }
  13162. // 金额调整和费用查看
  13163. $revisePrice += $value ['revisePrice'];
  13164. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  13165. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" id="sen'.$key.'" data="' . htmlspecialchars($value ['explanation']) . '" onclick=showExplanation() >查看</a></td>';
  13166. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  13167. }
  13168. // 报销单合计
  13169. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  13170. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  13171. $receiptTotalHtml = '';
  13172. // 报销单项目抬头
  13173. foreach ( $itemKeyList as $value ) {
  13174. $count = count ( $itemList [$value] ) + 1;
  13175. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  13176. $categoryHtml .= '<th class="taC">合计</th>';
  13177. $sumfalg=true;
  13178. foreach ( $rtl as $rtlValue ) {
  13179. if ($rtlValue ['itemCategory'] == $value) {
  13180. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  13181. $sumfalg=false;
  13182. break;
  13183. }
  13184. }
  13185. if ($sumfalg)
  13186. $receiptTotalHtml .= '<th></th>';
  13187. foreach ( $itemList [$value] as $k => $v ) {
  13188. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  13189. // 合计
  13190. $falg = true;
  13191. foreach ( $receiptTotalList as $ve ) {
  13192. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  13193. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  13194. $falg = false;
  13195. break;
  13196. }
  13197. }
  13198. if ($falg)
  13199. $receiptTotalHtml .= '<th></th>';
  13200. }
  13201. }
  13202. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  13203. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  13204. if (empty ( $stList ))
  13205. $stList = array (
  13206. 'rePrice' => 0,
  13207. 'agPrice' => 0
  13208. );
  13209. $data ['stList'] = array (
  13210. 'rePrice' => $stList ['rePrice'],
  13211. 'agPrice' => $stList ['agPrice'],
  13212. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13213. );
  13214. $monthHtml = "";
  13215. for($i = 1; $i <= 12; $i ++) {
  13216. if ($i == $month)
  13217. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13218. else
  13219. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13220. }
  13221. $data ['username'] = urlencode ( $username );
  13222. $data ['usernameEN'] = $username;
  13223. $data ['monthHtml'] = $monthHtml;
  13224. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  13225. $data ['list'] = $list;
  13226. $data ['categoryHtml'] = $categoryHtml;
  13227. $data ['itemHtml'] = $itemHtml;
  13228. $data ['itemList'] = $itemList;
  13229. $data ['year'] = $year;
  13230. $data ['month'] = $month;
  13231. $data ['memu'] = "receipt";
  13232. $data ['staff'] = $this->staff;
  13233. $data ['receiptMemu'] = 'companyCategoryCollect';
  13234. $data ['verifyId'] = $this->verifyId;
  13235. $data ['executeId'] = $this->executeId;
  13236. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  13237. }
  13238. die ( 'illegal request' );
  13239. }
  13240. function companyMonthCollectDetail() {
  13241. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13242. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13243. if (! $year)
  13244. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13245. if (! $month)
  13246. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13247. Doo::loadModel ( 'staff' );
  13248. $staff = new staff ();
  13249. Doo::loadModel ( "receiptDetail" );
  13250. $receiptDetail = new receiptDetail ();
  13251. Doo::loadModel ( 'accountItem' );
  13252. $accountItem = new accountItem ();
  13253. Doo::loadModel ( 'statistics' );
  13254. $statistics = new statistics ();
  13255. Doo::loadModel ( 'L_category' );
  13256. $lCategory = new L_category ();
  13257. $staffList = $staff->find ( array (
  13258. 'where' => 'username!="admin"',
  13259. 'asArray' => true
  13260. ) );
  13261. $categoryList = $lCategory->find ( array (
  13262. 'asArray' => true
  13263. ) );
  13264. $aiList=$accountItem->getAccountItem();
  13265. $list = array ();
  13266. foreach ( $categoryList as $value ) {
  13267. $receiptCollectList = $receiptDetail->find ( array (
  13268. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13269. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13270. 'groupby' => 'item,Month(pastDate),itemCategory',
  13271. 'asArray' => true
  13272. ) );
  13273. if (! empty ( $receiptCollectList )) {
  13274. $receiptL = array (
  13275. '日常相关费用' => array (),
  13276. '差旅相关费用' => array (),
  13277. '内部培训费用' => array (),
  13278. '培训班费用' => array (),
  13279. '其他' => array ()
  13280. );
  13281. $html = "";
  13282. $psum = 0;
  13283. foreach ( $aiList[$this->AGENCY] as $va ) {
  13284. $falg = true;
  13285. foreach ( $receiptCollectList as $v ) {
  13286. if ($v ['itemCategory'] == $this->AGENCY) {
  13287. if ($v ['item'] == $va['name']) {
  13288. $psum += $v ['price'];
  13289. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13290. $falg = false;
  13291. break;
  13292. }
  13293. }
  13294. }
  13295. if ($falg)
  13296. $html .= '<td class="taR">-</td>';
  13297. }
  13298. if (! empty ( $psum ))
  13299. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13300. else
  13301. $psum = '<td class="colGreen taR">-</td>';
  13302. $receiptL [$this->AGENCY] = $psum . $html;
  13303. /* ----------------------------------- */
  13304. $html = "";
  13305. $psum = 0;
  13306. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13307. $falg = true;
  13308. foreach ( $receiptCollectList as $v ) {
  13309. if ($v ['itemCategory'] == $this->TRAVEL) {
  13310. if ($v ['item'] == $va['name']) {
  13311. $psum += $v ['price'];
  13312. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13313. $falg = false;
  13314. break;
  13315. }
  13316. }
  13317. }
  13318. if ($falg)
  13319. $html .= '<td class="taR">-</td>';
  13320. }
  13321. if (! empty ( $psum ))
  13322. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13323. else
  13324. $psum = '<td class="colGreen taR">-</td>';
  13325. $receiptL [$this->TRAVEL] = $psum . $html;
  13326. /* ------------------------------------- */
  13327. $html = "";
  13328. $psum = 0;
  13329. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13330. $falg = true;
  13331. foreach ( $receiptCollectList as $v ) {
  13332. if ($v ['itemCategory'] == $this->INTTRAIN) {
  13333. if ($v ['item'] == $va['name']) {
  13334. $psum += $v ['price'];
  13335. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13336. $falg = false;
  13337. break;
  13338. }
  13339. }
  13340. }
  13341. if ($falg)
  13342. $html .= '<td class="taR">-</td>';
  13343. }
  13344. if (! empty ( $psum ))
  13345. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13346. else
  13347. $psum = '<td class="colGreen taR">-</td>';
  13348. $receiptL [$this->INTTRAIN] = $psum . $html;
  13349. /* ------------------------------------- */
  13350. $html = "";
  13351. $psum = 0;
  13352. foreach ( $aiList[$this->TRAIN] as $va ) {
  13353. $falg = true;
  13354. foreach ( $receiptCollectList as $v ) {
  13355. if ($v ['itemCategory'] == $this->TRAIN) {
  13356. if ($v ['item'] == $va['name']) {
  13357. $psum += $v ['price'];
  13358. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13359. $falg = false;
  13360. break;
  13361. }
  13362. }
  13363. }
  13364. if ($falg)
  13365. $html .= '<td class="taR">-</td>';
  13366. }
  13367. if (! empty ( $psum ))
  13368. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13369. else
  13370. $psum = '<td class="colGreen taR">-</td>';
  13371. $receiptL [$this->TRAIN] = $psum . $html;
  13372. /* ------------------------------------- */
  13373. $html = "";
  13374. $psum = 0;
  13375. foreach ( $aiList[$this->OTHER] as $va ) {
  13376. $falg = true;
  13377. foreach ( $receiptCollectList as $v ) {
  13378. if ($v ['itemCategory'] == $this->OTHER) {
  13379. if ($v ['item'] == $va['name']) {
  13380. $psum += $v ['price'];
  13381. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13382. $falg = false;
  13383. break;
  13384. }
  13385. }
  13386. }
  13387. if ($falg)
  13388. $html .= '<td class="taR">-</td>';
  13389. }
  13390. if (! empty ( $psum ))
  13391. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13392. else
  13393. $psum = '<td class="colGreen taR">-</td>';
  13394. $receiptL [$this->OTHER] = $psum . $html;
  13395. /* ------------------------------------- */
  13396. $html = "";
  13397. $psum = 0;
  13398. foreach ( $receiptCollectList as $v ) {
  13399. if ($v ['itemCategory'] == '报销金额调整') {
  13400. if (! empty ( $v ['price'] ))
  13401. $psum += $v ['price'];
  13402. }
  13403. }
  13404. if (! empty ( $psum ))
  13405. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  13406. else
  13407. $psum = '<td class="taR colOrange">-</td>';
  13408. $receiptL ['报销金额调整'] = $psum . $html;
  13409. } else {
  13410. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  13411. foreach ( $aiList[$this->AGENCY] as $va ) {
  13412. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  13413. }
  13414. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  13415. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13416. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  13417. }
  13418. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  13419. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13420. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  13421. }
  13422. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  13423. foreach ( $aiList[$this->TRAIN] as $va ) {
  13424. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  13425. }
  13426. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  13427. foreach ( $aiList[$this->OTHER] as $va ) {
  13428. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  13429. }
  13430. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13431. }
  13432. $monthStaffPrice = $receiptDetail->find ( array (
  13433. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13434. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13435. 'asArray' => true
  13436. ) );
  13437. if (! empty ( $monthStaffPrice [0] ['price'] ))
  13438. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13439. else
  13440. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13441. $list [$value ['title']] = $receiptL;
  13442. }
  13443. $data ['list'] = $list;
  13444. $receiptCollectList = $receiptDetail->find ( array (
  13445. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13446. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13447. 'groupby' => 'item,Month(pastDate),itemCategory',
  13448. 'asArray' => true
  13449. ) );
  13450. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  13451. //print_r($data['monthPriceHtml']);
  13452. // foreach ($data['monthPriceHtml'] as $value){
  13453. // echo $value;
  13454. // }
  13455. // die;
  13456. // statistics html
  13457. $stList = $statistics->getOne ( array (
  13458. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13459. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13460. 'groupby' => 'Month(date)',
  13461. 'asArray' => true
  13462. ) );
  13463. if (empty ( $stList ))
  13464. $stList = array (
  13465. 'rePrice' => 0,
  13466. 'agPrice' => 0
  13467. );
  13468. $data ['stList'] = array (
  13469. 'rePrice' => $stList ['rePrice'],
  13470. 'agPrice' => $stList ['agPrice'],
  13471. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13472. );
  13473. $monthHtml = "";
  13474. for($i = 1; $i <= 12; $i ++) {
  13475. if ($i == $month)
  13476. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13477. else
  13478. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13479. }
  13480. $data ['aiList'] = $aiList;
  13481. $dateHtml = "";
  13482. $now = date ( "Y" );
  13483. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  13484. if ($YEARD <= $now) {
  13485. $dateHtml .= '<option ';
  13486. if ($year == $YEARD) {
  13487. $dateHtml .= 'selected ';
  13488. }
  13489. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  13490. }
  13491. }
  13492. $data ['dateHtml'] = $dateHtml;
  13493. $data ['monthHtml'] = $monthHtml;
  13494. $data ['year'] = $year;
  13495. $data ['month'] = $month;
  13496. $data ['memu'] = "receipt";
  13497. $data ['staff'] = $this->staff;
  13498. $data ['receiptMemu'] = 'companyCategoryCollect';
  13499. $data ['verifyId'] = $this->verifyId;
  13500. $data ['executeId'] = $this->executeId;
  13501. $this->render ( "/admin/companyMonthCollectDetail", $data );
  13502. }
  13503. function staffCollectDetail() {
  13504. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  13505. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13506. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  13507. if (! $staffname) {
  13508. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  13509. $staffname = urldecode ( $staffname );
  13510. }
  13511. Doo::loadModel ( 'staff' );
  13512. $staff = new staff ();
  13513. Doo::loadModel ( "receiptDetail" );
  13514. $receiptDetail = new receiptDetail ();
  13515. Doo::loadModel ( 'accountItem' );
  13516. $accountItem = new accountItem ();
  13517. Doo::loadModel ( 'statistics' );
  13518. $statistics = new statistics ();
  13519. Doo::loadModel ( 'L_category' );
  13520. $lCategory = new L_category ();
  13521. Doo::loadModel ( "receiptAuthorityManage" );
  13522. $receiptAuthorityManage = new receiptAuthorityManage ();
  13523. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  13524. $cidList = array ();
  13525. foreach ( $imcStaff as $key => $value ) {
  13526. array_push ( $cidList, $value ['cid'] );
  13527. }
  13528. $cidString = implode ( ',', $cidList );
  13529. $staffList = $staff->find ( array (
  13530. 'where' => ' cid in (' . $cidString . ')',
  13531. 'asArray' => true
  13532. ) );
  13533. $stHtml = '';
  13534. $stTitle = "";
  13535. $staffId = 0;
  13536. $cid = 0;
  13537. $ocid = 0;
  13538. foreach ( $staffList as $value ) {
  13539. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  13540. $stTitle = $value ['category'] . '-' . $value ['username'];
  13541. $staffId = $value ['sid'];
  13542. $cid = $value ['cid'];
  13543. $ocid = $value ['cid'];
  13544. if (! empty ( $value ['othercid'] ))
  13545. $cid = $value ['cid'] . ',' . $value ['othercid'];
  13546. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13547. } elseif ($value ['username'] != 'admin')
  13548. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13549. }
  13550. $data ['lCategoryHtml'] = $lCategory->find ( array (
  13551. 'where' => 'cid in(' . $cid . ')',
  13552. 'asArray' => true
  13553. ) );
  13554. if (empty ( $pcid ))
  13555. $pcid = $ocid;
  13556. $data ['ocid'] = $pcid;
  13557. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  13558. $this->showCache ( $path );
  13559. //
  13560. $receiptCollectList = $receiptDetail->find ( array (
  13561. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13562. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  13563. 'groupby' => 'item,Month(pastDate),itemCategory',
  13564. 'asArray' => true
  13565. ) );
  13566. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  13567. // print_r($receiptCollectList);
  13568. $accountList = $accountItem->find ( array (
  13569. 'asArray' => true
  13570. ) );
  13571. // create CollectDetail HTML
  13572. $collectHtml = array ();
  13573. foreach ( $accountList as $key => $value ) {
  13574. $html = "";
  13575. $asum = 0;
  13576. for($i = 1; $i <= 12; $i ++) {
  13577. $falg = true;
  13578. foreach ( $receiptCollectList as $v ) {
  13579. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  13580. if ($v ['item'] == '可自加费用') {
  13581. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  13582. }
  13583. $asum += $v ['price'];
  13584. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13585. $falg = false;
  13586. break;
  13587. }
  13588. }
  13589. if ($falg)
  13590. $html .= '<td class="taR">-</td>';
  13591. }
  13592. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  13593. $collectHtml [$value ['category']] [$value ['name']] = $html;
  13594. }
  13595. $data ['collectHtml'] = $collectHtml;
  13596. // print_r($collectHtml);
  13597. // create Adjustment price html
  13598. $receiptCollectList = $receiptDetail->find ( array (
  13599. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  13600. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  13601. 'groupby' => 'itemCategory,Month(pastDate)',
  13602. 'asArray' => true
  13603. ) );
  13604. $adjustment = array ();
  13605. $collectArray = array (
  13606. '日常相关费用' => array (),
  13607. '差旅相关费用' => array (),
  13608. '培训班费用' => array (),
  13609. '内部培训费用'=>array(),
  13610. '其他' => array ()
  13611. );
  13612. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  13613. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  13614. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  13615. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  13616. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  13617. array_push ( $collectArray ['培训班费用'], $collectHtml );
  13618. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  13619. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  13620. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  13621. array_push ( $collectArray ['其他'], $collectHtml );
  13622. $data ['collectArray'] = $collectArray;
  13623. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  13624. array_push ( $adjustment, $collectHtml );
  13625. $data ['adjustment'] = $adjustment;
  13626. // total price html
  13627. $collectHtml = "";
  13628. $total = 0;
  13629. for($i = 1; $i <= 12; $i ++) {
  13630. $sumPrice = 0;
  13631. foreach ( $receiptCollectList as $key => $value ) {
  13632. if ($value ['month'] == $i) {
  13633. $sumPrice += $value ['price'];
  13634. }
  13635. }
  13636. if ($sumPrice == 0)
  13637. $collectHtml .= '<td class="taR">-</td>';
  13638. else
  13639. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  13640. $total += $sumPrice;
  13641. }
  13642. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  13643. // statistics html
  13644. $stList = $statistics->statisticsByYear ( $year, $staffId );
  13645. if (empty ( $stList ))
  13646. $stList = array (
  13647. 'rePrice' => 0,
  13648. 'agPrice' => 0
  13649. );
  13650. $data ['stList'] = array (
  13651. 'rePrice' => $stList ['rePrice'],
  13652. 'agPrice' => $stList ['agPrice'],
  13653. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13654. );
  13655. $data ['totalPrice'] = $collectHtml;
  13656. $data ['totalYear'] = $total;
  13657. $data ['stHtml'] = $stHtml;
  13658. $data ['year'] = $year;
  13659. $data ['stTitle'] = $stTitle;
  13660. $data ['staffname'] = urlencode ( $staffname );
  13661. $data ['memu'] = "receipt";
  13662. $data ['staff'] = $this->staff;
  13663. $data ['receiptMemu'] = 'companyCategoryCollect';
  13664. $data ['verifyId'] = $this->verifyId;
  13665. $data ['executeId'] = $this->executeId;
  13666. if ($year < date ( "Y" )) {
  13667. Doo::loadModel ( 'receipt' );
  13668. $receipt = new receipt ();
  13669. $receiptList = $receipt->find ( array (
  13670. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  13671. 'asArray' => true
  13672. ) );
  13673. if (empty ( $receiptList )) { // generated files
  13674. ob_start ();
  13675. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13676. $this->cacheFile ( $path );
  13677. die ();
  13678. }
  13679. }
  13680. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13681. }
  13682. function BUGFLAG() {
  13683. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  13684. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  13685. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13686. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  13687. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  13688. if (empty ( $status ))
  13689. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  13690. $page_size = 12;
  13691. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  13692. $vidList = array ();
  13693. $button = 0;
  13694. Doo::loadModel ( 'verify' );
  13695. $verify = new verify ();
  13696. Doo::loadModel ( 'receipt' );
  13697. $receipt = new receipt ();
  13698. Doo::loadModel ( 'staff' );
  13699. $staff = new staff ();
  13700. Doo::loadModel ( 'L_category' );
  13701. $Lcategory = new L_category ();
  13702. $dateCondition = " and Year(date) =" . $year;
  13703. if (! empty ( $month ))
  13704. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  13705. $categoryList = $Lcategory->find ( array (
  13706. 'asArray' => true
  13707. ) );
  13708. $staffList = $staff->find ( array (
  13709. 'where' => 'cid=' . $cid,
  13710. 'asArray' => true
  13711. ) );
  13712. $cateCondition = "";
  13713. $staffCondition = "";
  13714. $approvalCondition = "";
  13715. if (! empty ( $cid ))
  13716. $cateCondition = ' and cid=' . $cid;
  13717. if (! empty ( $sid )) {
  13718. $staffCondition = ' and staff=' . $sid;
  13719. $cateCondition = "";
  13720. }
  13721. $approvalCondition = " and status=" . $status;
  13722. if ($status == 2) {
  13723. // 查找角色审批人
  13724. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  13725. }
  13726. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  13727. $approvalCondition = ' and status=2 ';
  13728. }
  13729. if ($status == 1) {
  13730. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  13731. }
  13732. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  13733. $pageinfo ['page'] = array (
  13734. 'previous' => ''
  13735. );
  13736. if ($status == 0) {
  13737. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  13738. $receiptList = $receipt->find ( array (
  13739. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  13740. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  13741. 'desc' => 'rid',
  13742. 'asArray' => true
  13743. ) );
  13744. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  13745. } else
  13746. $receiptList = $receipt->find ( array (
  13747. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  13748. 'desc' => 'rid',
  13749. 'asArray' => true
  13750. ) );
  13751. $rLRes = $receipt->find ( array (
  13752. '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,
  13753. 'desc' => 'rid',
  13754. 'asArray' => true
  13755. ) );
  13756. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  13757. // print_r($pageinfo);
  13758. $Locate = 0;
  13759. foreach ( $receiptList as $key => $value ) {
  13760. $receiptList [$key] ['Locate'] = $Locate;
  13761. $Locate ++;
  13762. $receiptList [$key] ['reviseDetail'] = array ();
  13763. if (! empty ( $value ['reviseDetail'] ))
  13764. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  13765. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  13766. $categoryDetil = $Lcategory->getOne ( array (
  13767. 'where' => 'cid=' . $value ['cid'],
  13768. 'asArray' => true
  13769. ) );
  13770. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  13771. $verifyList = $verify->getOne ( array (
  13772. 'where' => 'vid=' . $value ['verify'],
  13773. 'asArray' => true
  13774. ) );
  13775. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  13776. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  13777. foreach ( $verifyList as $k => $v ) {
  13778. // init verifyStaff
  13779. $verifyList [$k] ['date'] = "";
  13780. $verifyList [$k] ['opinion'] = "";
  13781. $verifyList [$k] ['status'] = "";
  13782. if (empty ( $verifyStaff )) {
  13783. $verifyList [$k] ['date'] = "";
  13784. $verifyList [$k] ['opinion'] = "";
  13785. if ($v [0] == $this->staff [0] ['sid']) {
  13786. $verifyList [$k] ['status'] = 4;
  13787. $button = 4;
  13788. }
  13789. } else {
  13790. $flag = true;
  13791. foreach ( $verifyStaff as $m => $u ) {
  13792. if ($v [0] == $m) {
  13793. $verifyList [$k] ['date'] = $u ['date'];
  13794. $verifyList [$k] ['opinion'] = $u ['opinion'];
  13795. $verifyList [$k] ['status'] = $u ['status'];
  13796. $flag = false;
  13797. break;
  13798. }
  13799. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  13800. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  13801. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  13802. }
  13803. if ($flag) { // 检测可编辑
  13804. if ($v [0] == $this->staff [0] ['sid']) {
  13805. $verifyList [$k] ['status'] = 4;
  13806. $button = 4;
  13807. }
  13808. }
  13809. }
  13810. }
  13811. $receiptList [$key] ['verifyList'] = $verifyList;
  13812. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  13813. 'where' => 'sid=' . $value ['staff'],
  13814. 'asArray' => true
  13815. ) );
  13816. $receiptList [$key] ['button'] = $button;
  13817. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  13818. }
  13819. // print_r($receiptList);die;
  13820. // $data['verifyDetail']=$verifyDetail;
  13821. $mothHtml = "";
  13822. for($i = 1; $i <= 12; $i ++) {
  13823. if ($month == $i)
  13824. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  13825. else
  13826. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  13827. }
  13828. $data ['mothHtml'] = $mothHtml;
  13829. $data ['page'] = $pageinfo;
  13830. $data ['receiptList'] = $receiptList;
  13831. $data ['receiptApprovalCount'] = count ( $rLRes );
  13832. $data ['status'] = $status;
  13833. $data ['year'] = $year;
  13834. $data ['categoryList'] = $categoryList;
  13835. $data ['staffList'] = $staffList;
  13836. $data ['cid'] = $cid;
  13837. $data ['sid'] = $sid;
  13838. // print_r($receiptList);
  13839. $data ['memu'] = "receipt";
  13840. $data ['staff'] = $this->staff;
  13841. $data ['receiptMemu'] = 'approvalExpenses';
  13842. $data ['verifyId'] = $this->verifyId;
  13843. $data ['executeId'] = $this->executeId;
  13844. $this->render ( "/admin/FALG", $data );
  13845. }
  13846. function ajaxGetReceiptOrder() {
  13847. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  13848. if (! empty ( $receiptOrder )) {
  13849. Doo::loadModel ( 'receipt' );
  13850. $receipt = new receipt ();
  13851. Doo::loadModel ( 'staff' );
  13852. $staff = new staff ();
  13853. $receiptInfo = $receipt->getOne ( array (
  13854. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  13855. 'asArray' => true
  13856. ) );
  13857. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  13858. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  13859. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  13860. </tbody></table><table class="table table table-bordered"><tbody>';
  13861. foreach ( $verifyStaff as $key => $value ) {
  13862. $staffInfo = $staff->getOne ( array (
  13863. 'select' => 'username',
  13864. 'where' => ' sid="' . $key . '"',
  13865. 'asArray' => true
  13866. ) );
  13867. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  13868. }
  13869. $html .= '</tbody></table></div></div>';
  13870. echo json_encode ( array (
  13871. 'status' => 1,
  13872. 'receiptHtml' => $html
  13873. ) );
  13874. die ();
  13875. }
  13876. echo json_encode ( array (
  13877. 'status' => 2,
  13878. 'receiptHtml' => ''
  13879. ) );
  13880. die ();
  13881. }
  13882. function _getMonthCollectDetail($receiptCollectList,$aiList) {
  13883. if (! empty ( $receiptCollectList )) {
  13884. $receiptL = array (
  13885. '日常相关费用' => array (),
  13886. '差旅相关费用' => array (),
  13887. '内部培训费用'=>array(),
  13888. '培训班费用' => array (),
  13889. '其他' => array ()
  13890. );
  13891. $html = "";
  13892. $psum = 0;
  13893. foreach ( $aiList[$this->AGENCY] as $value ) {
  13894. $falg = true;
  13895. foreach ( $receiptCollectList as $v ) {
  13896. if ($v ['itemCategory'] == '日常相关费用') {
  13897. if ($v ['item'] == $value['name']) {
  13898. $psum += $v ['price'];
  13899. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13900. $falg = false;
  13901. break;
  13902. }
  13903. }
  13904. }
  13905. if ($falg)
  13906. $html .= '<td class="taR">-</td>';
  13907. }
  13908. if (! empty ( $psum ))
  13909. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13910. else
  13911. $psum = '<td class="colGreen taR">-</td>';
  13912. $receiptL ['日常相关费用'] = $psum . $html;
  13913. /* ----------------------------------- */
  13914. $html = "";
  13915. $psum = 0;
  13916. foreach ( $aiList[$this->TRAVEL] as $value ) {
  13917. $falg = true;
  13918. foreach ( $receiptCollectList as $v ) {
  13919. if ($v ['itemCategory'] == '差旅相关费用') {
  13920. if ($v ['item'] == $value['name']) {
  13921. $psum += $v ['price'];
  13922. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13923. $falg = false;
  13924. break;
  13925. }
  13926. }
  13927. }
  13928. if ($falg)
  13929. $html .= '<td class="taR">-</td>';
  13930. }
  13931. if (! empty ( $psum ))
  13932. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13933. else
  13934. $psum = '<td class="colGreen taR">-</td>';
  13935. $receiptL ['差旅相关费用'] = $psum . $html;
  13936. /* ----------------------------------- */
  13937. $html = "";
  13938. $psum = 0;
  13939. foreach ( $aiList[$this->INTTRAIN] as $value ) {
  13940. $falg = true;
  13941. foreach ( $receiptCollectList as $v ) {
  13942. if ($v ['itemCategory'] == '内部培训费用') {
  13943. if ($v ['item'] == $value['name']) {
  13944. $psum += $v ['price'];
  13945. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13946. $falg = false;
  13947. break;
  13948. }
  13949. }
  13950. }
  13951. if ($falg)
  13952. $html .= '<td class="taR">-</td>';
  13953. }
  13954. if (! empty ( $psum ))
  13955. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13956. else
  13957. $psum = '<td class="colGreen taR">-</td>';
  13958. $receiptL ['内部培训费用'] = $psum . $html;
  13959. /* ------------------------------------- */
  13960. $html = "";
  13961. $psum = 0;
  13962. foreach ( $aiList[$this->TRAIN] as $value ) {
  13963. $falg = true;
  13964. foreach ( $receiptCollectList as $v ) {
  13965. if ($v ['itemCategory'] == '培训班费用') {
  13966. if ($v ['item'] == $value['name']) {
  13967. $psum += $v ['price'];
  13968. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13969. $falg = false;
  13970. break;
  13971. }
  13972. }
  13973. }
  13974. if ($falg)
  13975. $html .= '<td class="taR">-</td>';
  13976. }
  13977. if (! empty ( $psum ))
  13978. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13979. else
  13980. $psum = '<td class="colGreen taR">-</td>';
  13981. $receiptL ['培训班费用'] = $psum . $html;
  13982. /* ------------------------------------- */
  13983. $html = "";
  13984. $psum = 0;
  13985. foreach ( $aiList[$this->OTHER] as $value ) {
  13986. $falg = true;
  13987. foreach ( $receiptCollectList as $v ) {
  13988. if ($v ['itemCategory'] == '其他') {
  13989. if ($v ['item'] == $value['name']) {
  13990. $psum += $v ['price'];
  13991. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13992. $falg = false;
  13993. break;
  13994. }
  13995. }
  13996. }
  13997. if ($falg)
  13998. $html .= '<td class="taR">-</td>';
  13999. }
  14000. if (! empty ( $psum ))
  14001. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14002. else
  14003. $psum = '<td class="colGreen taR">-</td>';
  14004. $receiptL ['其他'] = $psum . $html;
  14005. /* ------------------------------------- */
  14006. $html = "";
  14007. $psum = 0;
  14008. foreach ( $receiptCollectList as $v ) {
  14009. if ($v ['itemCategory'] == '报销金额调整') {
  14010. if (! empty ( $v ['price'] ))
  14011. $psum += $v ['price'];
  14012. }
  14013. }
  14014. if (! empty ( $psum ))
  14015. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  14016. else
  14017. $psum = '<td class="taR colOrange">-</td>';
  14018. $receiptL ['报销金额调整'] = $psum . $html;
  14019. } else {
  14020. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  14021. foreach ( $aiList[$this->AGENCY] as $va ) {
  14022. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  14023. }
  14024. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  14025. foreach ( $aiList[$this->TRAVEL] as $va ) {
  14026. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  14027. }
  14028. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  14029. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  14030. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  14031. }
  14032. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  14033. foreach ( $aiList[$this->TRAIN] as $va ) {
  14034. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  14035. }
  14036. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  14037. foreach ( $aiList[$this->OTHER] as $va ) {
  14038. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  14039. }
  14040. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  14041. }
  14042. return $receiptL;
  14043. }
  14044. function eMail() {
  14045. Doo::loadModel ( 'staff' );
  14046. $staff = new staff ();
  14047. Doo::loadModel ( 'receipt' );
  14048. $receipt = new receipt ();
  14049. Doo::loadModel ( 'L_category' );
  14050. $Lcategory = new L_category ();
  14051. Doo::loadModel ( "verify" );
  14052. $verify = new verify ();
  14053. $staffList = $staff->find ( array (
  14054. 'asArray' => true
  14055. ) );
  14056. foreach ( $staffList as $key => $value ) {
  14057. if ($value ['username'] != 'admin') {
  14058. // 提交人
  14059. $receiptList = $receipt->find ( array (
  14060. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  14061. 'asArray' => true
  14062. ) );
  14063. if (! empty ( $receiptList )) {
  14064. $html = '<br><div><style></style>
  14065. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  14066. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  14067. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14068. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  14069. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14070. <tbody><tr>
  14071. <td style="padding: 0 40px;" align="left">
  14072. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14073. </td></tr><tr>
  14074. <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>
  14075. </tr>
  14076. </tbody> </table></td> </tr> <tr><td>
  14077. <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">
  14078. <tbody> <tr><td>
  14079. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  14080. 以下报销单完成了审批,等着收款吧:</p>
  14081. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  14082. foreach ( $receiptList as $k => $v ) {
  14083. $category = $Lcategory->getOne ( array (
  14084. 'where' => 'cid=' . $v ['cid'],
  14085. 'asArray' => true
  14086. ) );
  14087. $html .= '
  14088. <tr>
  14089. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14090. <td align="left">
  14091. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  14092. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  14093. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  14094. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  14095. </tr>';
  14096. }
  14097. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  14098. <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>
  14099. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  14100. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  14101. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  14102. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14103. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14104. $receipt = new receipt ();
  14105. $receipt->notice = 1;
  14106. $receipt->update ( array (
  14107. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  14108. ) );
  14109. }
  14110. }
  14111. // 审批人
  14112. $verifyList = $verify->find ( array (
  14113. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  14114. 'asArray' => true
  14115. ) );
  14116. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  14117. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  14118. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14119. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  14120. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14121. <tbody><tr><td style="padding: 0 40px;" align="left">
  14122. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14123. </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>
  14124. </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">
  14125. <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>
  14126. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  14127. foreach ( $verifyList as $k => $v ) {
  14128. $receiptList = $receipt->find ( array (
  14129. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  14130. 'asArray' => true
  14131. ) );
  14132. foreach ( $receiptList as $r => $l ) {
  14133. $category = $Lcategory->getOne ( array (
  14134. 'where' => 'cid=' . $l ['cid'],
  14135. 'asArray' => true
  14136. ) );
  14137. $staffDetile = $staff->getOne ( array (
  14138. 'where' => 'sid=' . $l ['staff'],
  14139. 'asArray' => true
  14140. ) );
  14141. $html .= '
  14142. <tr>
  14143. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14144. <td align="left">
  14145. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  14146. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  14147. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  14148. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  14149. </tr>';
  14150. }
  14151. }
  14152. $html .= '
  14153. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  14154. <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>
  14155. </tr></tbody></table></td></tr></tbody></table></div><br>';
  14156. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  14157. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  14158. // $receipt=new receipt();
  14159. // $receipt->notice=1;
  14160. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  14161. }
  14162. }
  14163. }
  14164. }
  14165. function setWXMsg($rid, $type) {
  14166. Doo::loadModel ( "receipt" );
  14167. $receipt = new receipt ();
  14168. $receiptDetail = $receipt->getOne ( array (
  14169. 'where' => 'rid=' . $rid,
  14170. 'asArray' => true
  14171. ) );
  14172. if (! empty ( $receiptDetail )) {
  14173. Doo::loadModel ( 'staff' );
  14174. $staff = new staff ();
  14175. $staffmsg = $staff->getOne ( array (
  14176. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  14177. 'asArray' => TRUE
  14178. ) );
  14179. if (! empty ( $staffmsg ['wxid'] )) {
  14180. require_once (SITE_PATH . '/protected/class/client.php');
  14181. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  14182. $user = $staffmsg ['wxid'];
  14183. $receiptName = '';
  14184. $msg = '';
  14185. switch ($receiptDetail ['Rtype']) {
  14186. case 0 :
  14187. $receiptName = '报销';
  14188. break;
  14189. case 1 :
  14190. $receiptName = '借款';
  14191. break;
  14192. case 2 :
  14193. $receiptName = '对公汇款';
  14194. break;
  14195. }
  14196. switch ($type) {
  14197. case 1 :
  14198. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  14199. break;
  14200. case 2 :
  14201. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  14202. break;
  14203. case 3 :
  14204. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  14205. break;
  14206. }
  14207. // $result = $client->SendMsg ( $user, $msg, 'text' );
  14208. }
  14209. }
  14210. }
  14211. // Email发送函数
  14212. function SMail($toemail, $subject, $contents) {
  14213. Doo::loadClass ( 'class.phpmailer' );
  14214. $mail = new PHPMailer ();
  14215. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  14216. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  14217. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  14218. $mail->Password = "cDO1GjtY1seH"; // 密码
  14219. $mail->CharSet = "UTF8";
  14220. $mail->SMTPAuth = true;
  14221. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  14222. $mail->Mailer = "smtp";
  14223. $mail->Port = 25;
  14224. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  14225. $mail->MsgHTML ( $contents );
  14226. $mail->AddAddress ( $toemail );
  14227. $mail->CharSet = "UTF-8";
  14228. return $mail->Send ();
  14229. }
  14230. function h5Upload() {
  14231. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14232. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14233. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14234. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14235. header ( "HTTP/1.1 500 Internal Server Error" );
  14236. echo "POST exceeded maximum allowed size.";
  14237. exit ( 0 );
  14238. }
  14239. // Settings
  14240. $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)
  14241. $upload_name = "Filedata";
  14242. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14243. $extension_whitelist = array (
  14244. "doc",
  14245. "txt",
  14246. "jpg",
  14247. "gif",
  14248. "png"
  14249. ); // Allowed file extensions
  14250. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14251. // Other variables
  14252. $MAX_FILENAME_LENGTH = 260;
  14253. $file_name = "";
  14254. $file_extension = "";
  14255. $uploadErrors = array (
  14256. 0 => "文件上传成功",
  14257. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14258. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14259. 3 => "上传的文件仅为部分文件",
  14260. 4 => "没有文件上传",
  14261. 6 => "缺少临时文件夹"
  14262. );
  14263. $nk = time ();
  14264. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14265. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14266. echo "文件无法保存.";
  14267. exit ( 0 );
  14268. }
  14269. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14270. echo json_encode ( array (
  14271. 'filename' => $file_name,
  14272. 'id' => $nk
  14273. ) );
  14274. exit ( 0 );
  14275. }
  14276. function swfupload() {
  14277. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14278. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14279. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14280. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14281. header ( "HTTP/1.1 500 Internal Server Error" );
  14282. echo "POST exceeded maximum allowed size.";
  14283. exit ( 0 );
  14284. }
  14285. // Settings
  14286. $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)
  14287. $upload_name = "Filedata";
  14288. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14289. $extension_whitelist = array (
  14290. "doc",
  14291. "txt",
  14292. "jpg",
  14293. "gif",
  14294. "png"
  14295. ); // Allowed file extensions
  14296. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14297. // Other variables
  14298. $MAX_FILENAME_LENGTH = 260;
  14299. $file_name = "";
  14300. $file_extension = "";
  14301. $uploadErrors = array (
  14302. 0 => "文件上传成功",
  14303. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14304. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14305. 3 => "上传的文件仅为部分文件",
  14306. 4 => "没有文件上传",
  14307. 6 => "缺少临时文件夹"
  14308. );
  14309. $nk = time ();
  14310. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14311. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14312. echo "文件无法保存.";
  14313. exit ( 0 );
  14314. }
  14315. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14316. echo json_encode ( array (
  14317. 'filename' => $file_name,
  14318. 'id' => $nk
  14319. ) );
  14320. exit ( 0 );
  14321. }
  14322. function _GetFileEXT($filename) {
  14323. $pics = explode ( '.', $filename );
  14324. $num = count ( $pics );
  14325. return $pics [$num - 1];
  14326. }
  14327. /**
  14328. * 获取get或者POST值
  14329. * @param string $name 属性名称
  14330. * @return fixed 值
  14331. */
  14332. function get_args($name) {
  14333. if (isset ( $_GET [$name] )) {
  14334. if (is_array ( $_GET [$name] ))
  14335. return $_GET [$name];
  14336. else
  14337. return addslashes ( $_GET [$name] );
  14338. } elseif (isset ( $_POST [$name] )) {
  14339. if (is_array ( $_POST [$name] ))
  14340. return $_POST [$name];
  14341. else
  14342. return addslashes ( $_POST [$name] );
  14343. } else
  14344. return false;
  14345. }
  14346. function num_to_rmb($num) {
  14347. $c1 = "零壹贰叁肆伍陆柒捌玖";
  14348. $c2 = "分角元拾佰仟万拾佰仟亿";
  14349. // 精确到分后面就不要了,所以只留两个小数位
  14350. $num = round ( $num, 2 );
  14351. // 将数字转化为整数
  14352. $num = $num * 100;
  14353. if (strlen ( $num ) > 10) {
  14354. return "金额太大,请检查";
  14355. }
  14356. $i = 0;
  14357. $c = "";
  14358. while ( 1 ) {
  14359. if ($i == 0) {
  14360. // 获取最后一位数字
  14361. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  14362. } else {
  14363. $n = $num % 10;
  14364. }
  14365. // 每次将最后一位数字转化为中文
  14366. $p1 = substr ( $c1, 3 * $n, 3 );
  14367. $p2 = substr ( $c2, 3 * $i, 3 );
  14368. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  14369. $c = $p1 . $p2 . $c;
  14370. } else {
  14371. $c = $p1 . $c;
  14372. }
  14373. $i = $i + 1;
  14374. // 去掉数字最后一位了
  14375. $num = $num / 10;
  14376. // echo $num.'</br>';
  14377. $num = ( int ) $num;
  14378. // $num =floor($num);
  14379. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  14380. // echo $num.'</br>';
  14381. // 结束循环
  14382. if ($num == 0) {
  14383. break;
  14384. }
  14385. }
  14386. // echo $c.'</br>';
  14387. $j = 0;
  14388. $slen = strlen ( $c );
  14389. while ( $j < $slen ) {
  14390. // utf8一个汉字相当3个字符
  14391. $m = substr ( $c, $j, 6 );
  14392. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  14393. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  14394. $left = substr ( $c, 0, $j );
  14395. $right = substr ( $c, $j + 3 );
  14396. $c = $left . $right;
  14397. $j = $j - 3;
  14398. $slen = $slen - 3;
  14399. }
  14400. $j = $j + 3;
  14401. }
  14402. // 这个是为了去掉类似23.0中最后一个“零”字
  14403. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  14404. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  14405. }
  14406. // 将处理的汉字加上“整”
  14407. if (empty ( $c )) {
  14408. return "零元整";
  14409. } else {
  14410. return $c . "整";
  14411. }
  14412. }
  14413. /**
  14414. * 获得分页数据
  14415. * @param unknown_type $table
  14416. * @param unknown_type $condition
  14417. * @param unknown_type $on_page
  14418. * @param unknown_type $page_size
  14419. */
  14420. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  14421. $page_c = "";
  14422. $page ['previous'] = $this->get_previous ( $on_page );
  14423. $page ['on_page'] = $on_page;
  14424. $total_count = $this->get_table_count ( $table, $condition );
  14425. $total = intval ( $total_count / $page_size );
  14426. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  14427. $page ['total_data'] = $total_count;
  14428. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  14429. $i = 1;
  14430. $page_max = 1;
  14431. $page_width = 3;
  14432. if ($on_page >= $page_width) {
  14433. $page_max = intval ( $on_page / $page_width ) + 1;
  14434. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  14435. }
  14436. for(; $i <= $page ['total_page']; $i ++) {
  14437. if ($i == $on_page)
  14438. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  14439. else
  14440. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  14441. if ($i == ($page_width * $page_max))
  14442. break;
  14443. }
  14444. $page ['page'] = $page_c;
  14445. $page ['lower'] = (-- $on_page) * $page_size;
  14446. return $page;
  14447. }
  14448. /**
  14449. * 获取总页数
  14450. * @param unknown_type $table
  14451. * @param unknown_type $condition
  14452. */
  14453. public function get_table_count($table = "", $condition = "") {
  14454. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14455. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14456. // echo $sql;die;
  14457. $query = Doo::db ()->query ( $sql );
  14458. $result = $query->fetch ();
  14459. return $result ['count'];
  14460. }
  14461. /**
  14462. * 获取上一页
  14463. * @param unknown_type $on_page
  14464. */
  14465. function get_previous($on_page = 1) {
  14466. return $on_page != 0 ? $on_page - 1 : $on_page;
  14467. }
  14468. function _getReceiptTrainPayment($invoiceTrainId,$trainLoanRid,$rid){
  14469. // 收入合计
  14470. Doo::loadModel ( 'invoiceTraining' );
  14471. $invoiceTraining = new invoiceTraining ();
  14472. Doo::loadModel ( 'receipt' );
  14473. $receipt = new receipt ();
  14474. $invoiceTrainingDetail = array (
  14475. 'invoiceArriveAmount' => '0.00',
  14476. 'RIAmount' => '0.00',
  14477. 'invoiceTotalAmount' => '0.00',
  14478. 'invoiceCompanyAmount' => '0.00',
  14479. 'invoiceArriveAmountM'=>'0.00',
  14480. 'invoiceCompanyAmountM'=>'0.00'
  14481. );
  14482. if ($invoiceTrainId != 0) {
  14483. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $invoiceTrainId );
  14484. }
  14485. $invoiceArriveAmount = $RIAmount = 0;
  14486. if (! empty ( $invoiceTrainingDetail )) {
  14487. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  14488. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  14489. }
  14490. // 备用金
  14491. $sum = 0;
  14492. if (! empty ( $trainLoanRid )) {
  14493. $receiptLoanList = $receipt->getReceiptInRid ( $trainLoanRid );
  14494. foreach ($receiptLoanList as $key=>$value){
  14495. $sum+=$value['sum'];
  14496. }
  14497. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $trainLoanRid );
  14498. // $sum = $receiptLoanDetailBak ['sum'];
  14499. }
  14500. // 支出项金额详情
  14501. // 项目金额合计
  14502. Doo::loadModel ( 'RItem' );
  14503. $RItem = new RItem ();
  14504. Doo::loadModel ( 'accountItem' );
  14505. $accountItem = new accountItem ();
  14506. // 讲师获得
  14507. Doo::loadModel ( 'RILecturer' );
  14508. $RILecturer = new RILecturer ();
  14509. $RItemList = $RItem->getRItemByRid ($rid );
  14510. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  14511. // 支出项金额详情
  14512. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  14513. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  14514. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  14515. return $payment;
  14516. }
  14517. }
  14518. ?>