1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184 |
- <?php
- /**
- * 开票功能控制器
- * @author CP
- * @version 1.0
- * @namespace invoice
- * @package invoiceController
- */
- require "protected/services/invoice_service.php";
- class InvoiceController extends DooController {
- public $staff;
- public $NEW;
- public $data;
- public $invoiceService;
- private $INVOICEKEY = "APPROVAL";
- private $INVOICECOLLECTPATH = "protected/cache/invoiceCollect/";
- private $ACTION = '';
- private $appId = 'wx3ee46531947a1384';
- private $appSecret = 'awGWzy3J5q_96VXKBLA2BQ9RpiT0LiPXnkMF-xV6h5o'; // awGWzy3J5q_96VXKBLA2BXU6mVCGynPGD-sxUCsdNDE //'PeiQVH8tbQE7pM9pVO4AIPlX9FFNpwu7O6Iy6VFcAVtpjTA3Qn42dbNmktBFkUHo';
- public function beforeRun($resource, $action) {
- Doo::loadModel ( "invoiceManage" );
- $invoiceManage = new invoiceManage ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- $sid = $XDeode->decode ( $_COOKIE ["staff"] );
- header ( 'Content-Type:text/html;charset=utf-8' );
- $moldList = $invoiceManage->getInvoiceByStaff ( $sid );
-
- if (empty ( $moldList )) {
- $flag = false;
- $uGroups = 'ordinary';
- if (Doo::acl ()->isAllowed ( $uGroups, $resource, $action )) {
- $flag = true;
- }
- } else {
- $flag = false;
- array_push ( $moldList, array (
- 'mold' => 'ordinary'
- ) );
-
- // 删除审批人后-加入权限问题-暂时关闭
- $fileInvoice = file_get_contents ( "protected/config/invoice/invoice.ini" );
- $fiML = json_decode ( $fileInvoice, true );
- if (empty ( $fiML ))
- $fiML = array ();
- foreach ( $fiML as $key => $value ) {
- $sidList = explode ( ',', $value );
- foreach ( $sidList as $k => $v ) {
- if ($v == $sid) {
- array_push ( $moldList, array (
- 'mold' => $key
- ) );
- break;
- }
- }
- }
-
- foreach ( $moldList as $value ) {
- if (Doo::acl ()->isAllowed ( $value ['mold'], $resource, $action )) {
- $flag = true;
- break;
- }
- }
- }
- /*
- * Doo::acl()->isAllowed($uGroups['groups'], $resource, $action);
- */
-
- // 单独判断办事处汇总的访问权限 invoiceAggregateCategoryDetail,invoiceAggregateStaffDetail
- if ($action == 'invoiceAggregateCategoryDetail' || $action == 'invoiceAggregateStaffDetail') {
- Doo::loadModel ( "invoiceCategoryManage" );
- $invoiceCategoryManage = new invoiceCategoryManage ();
-
- $icm = $invoiceCategoryManage->getInvoiceCMByStaff ( $sid );
- if (empty ( $icm ))
- die ( 'illegal request-iacd' );
- }
- // 单独判断应收款访问权限
- if ($action == 'invoiceAggregateCompanyDetail') {
- Doo::loadModel ( "invoiceCompanyManage" );
- $invoiceCompanyManage = new invoiceCompanyManage ();
-
- $icm = $invoiceCompanyManage->getInvoiceCMByStaff ( $sid );
- if (empty ( $icm ))
- die ( 'illegal request' );
- }
-
- // 主权限获得与判断
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- $detail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
-
- $accessModular = 'INVOICE';
- if (empty ( $detail ['cldAccessArray'] ))
- die ( 'illegal request' );
- else {
-
- if (in_array ( $accessModular, $detail ['cldAccessArray'] )) {
- if (Doo::acl ()->isAllowed ( $accessModular, $resource, $action )) {
- $flag = true;
- } else {
- $flag = false;
- }
- } else {
- die ( 'illegal request' );
- }
- }
-
- if (! $flag)
- die ( 'illegal request' );
- }
- function __construct() {
- $this->invoiceService = new invoice_service ();
- //echo $routeRs ['1'];
- //die('dd');
- if (isset ( $_COOKIE ["staff"] )) {
- if (! empty ( $_COOKIE ["staff"] )) {
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- $uriPartsOrig = explode ( '/', $_SERVER ['REQUEST_URI'] );
- $this->ACTION = $uriPartsOrig [1];
- $this->data ['new'] = $this->isInvoiceNew ();
- $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
-
- $this->data ['isStaffCompleteMsg'] = false;
- $detail = $staff->checkStaffInfoIsComplete ( $_COOKIE ["staff"] );
- if (! empty ( $detail ))
- $this->data ['isStaffCompleteMsg'] = true;
-
- return "/";
- }
- }
-
- Doo::loadCore ( 'uri/DooUriRouter' );
- $router = new DooUriRouter ();
- $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
-
- if ($routeRs ['1'] != "login") {
- header ( 'Content-Type:text/html;charset=utf-8' );
- @header ( "Location: /login" );
- }
- }
- function testSend() {
-
- // 测试根据规则发送信息 普通发送
-
- // $pendingApprovalsSid = 41;
- // Doo::loadModel ( 'staff' );
- // $staff = new staff ();
- // $username2 = $staff->getOne ( array ( 'select' => 'wxid', 'where' => 'sid=' . $pendingApprovalsSid, 'asArray' => TRUE ) );
- // // 发送微信审批通知
- // $title2 = '[通知]用户提交了一条开票申请,快到“我的发票”中查看,给用户确认审批。';
- // $this->msgSend ( '', $title2, '', $username2 ['wxid'], $pendingApprovalsSid, 'approval' );
-
- // Doo::loadModel ( 'staff' );
- // $staff = new staff ();
- // $toparty = $this->getToparty ( '广东办' );
- // $wxList = array ();
- // if (! empty ( $toparty )) {
- // $userList = $this->getUserByToparty ( $toparty );
- // $userCon = implode ( ',', $userList );
- // // echo $userCon;
- // $sidList = $staff->getStaffByWxid ( $userCon );
- // foreach ( $sidList as $key => $value ) {
- // $falg = $this->isSendNotification ( $value ['sid'], 'receivables' );
- // if ($falg) {
- // array_push ( $wxList, $value ['wxid'] );
- // }
- // }
- // $wxString = implode ( '|', $wxList );
- // print_r ( $wxList );
- // echo $wxString;
- // }
-
- // 测试发送
- /*
- * //$toparty = $this->getWxidByCategory( $receivablesCategory [1] ); $toparty = $this->getToparty ( $receivablesCategory [1] ); $msg = '[通知]财务录入了一笔待认领款项,快到“我的收款”中查看,确认是否是您的客户给您打款了。'; if ($toparty != 0) $this->msgSendToparty ( $msg, '', '', $toparty, 'text' );
- */
-
- // print_r ( $userList );
-
- // $msTouser='caipin|outaozhen';
- // $toparty = $this->getToparty ( $receivablesCategory [1] );
- // $title2 = '[通知]财务录入了一笔待认领款项,快到“我的收款”中查看,确认是否是您的客户给您打款了。';
-
- // $hfreult = $this->msgSend ( '', $title2, '', 'outaozhen' );
-
- // $toparty= $this->getToparty('广东办');
- // $msg = '[通知]财务录入了一笔待认领款项,快到“我的收款”中查看,确认是否是您的客户给您打款了。';
- // $toparty = 26;
- // $msg = '';
- // $url = 'http://m.cld.smartcost.com.cn/invoicePrintDetail/1.html';
- // $hfreult = $this->msgSendToparty ( $msg, '', '', $toparty,'text' );
- }
- function invoice() {
-
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'express' );
- $express = new express ();
- $expressList = $express->getExpressByAll ();
- $this->data ['expressList'] = $expressList;
- // Doo::loadModel ( 'invoiceReceivables' );
- // $invoiceReceivables = new invoiceReceivables ();
- // $list = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- $sid = $XDeode->decode ( $_COOKIE ["staff"] );
-
- Doo::loadModel ( 'invoiceStatistics' );
- $invoiceStatistics = new invoiceStatistics ();
-
- $isMonth = $invoiceStatistics->getStatisticsByMonth ( $sid );
-
- // 缓存统计结果
- $year = date ( "Y" );
- $tmp_date = date ( "Ym" );
- $tmp_year = substr ( $tmp_date, 0, 4 );
- $tmp_mon = substr ( $tmp_date, 4, 2 );
- $tmp_forwardmonth = mktime ( 0, 0, 0, $tmp_mon - 1, 1, $tmp_year );
- $fm_forward_month = date ( "m", $tmp_forwardmonth );
- $path = SITE_PATH . $this->INVOICECOLLECTPATH . "invoiceCollect_" . $year . "_" . $fm_forward_month . "_" . $sid . ".htm";
-
- if (is_file ( $path ))
- $htm = file_get_contents ( $path );
- else
- $htm = $this->showCache ( $path, $sid );
-
- $invoiceList = $invoice->getMyInvoice ( $sid );
-
- $sql = 'status=2 and printStatus=1 and irid!="" and sid=' . $sid;
- $list = $invoice->getInvoiceByUntreadStatusPage ( 4, $sql );
- // 我的待入账发票 and irid='' and ( (doPost=1 and postStatus=1) or doPost=0 )
- $sql = "status=2 and printStatus=1 and untreadStatus=0 and isDelete=0 and sid=" . $sid;
- $myInvoiceUnAccount = $invoice->getInvoiceByUntreadStatusPage ( 4, $sql );
-
- // 获得已退票功能
- $untreadStatusList = $invoice->getMyInvoiceByUntreadStatus ( 2, 0, 5, $sid );
- $this->data ['untreadStatusList'] = $untreadStatusList;
- // print_r($untreadStatusList);
-
- $this->data ['isMonth'] = $isMonth;
- $this->data ['htm'] = $htm;
-
- $this->data ['invoiceList'] = $invoiceList;
- $this->data ['receivablesList'] = $list;
- $this->data ['myInvoiceUnAccount'] = $myInvoiceUnAccount;
-
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoice';
- $this->render ( "/admin/invoice", $this->data );
- }
- function invoiceExpress() {
- $expressCom = isset ( $this->params ['expressCom'] ) ? $this->params ['expressCom'] : "";
- $expressNumber = isset ( $this->params ['expressNumber'] ) ? $this->params ['expressNumber'] : "";
-
- $this->data ['expressCom'] = $expressCom;
- $this->data ['expressNumber'] = $expressNumber;
- $this->render ( "/admin/invoiceExpress", $this->data );
- }
- function invoiceAdd() {
- session_start ();
- /*Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- $detail = $invoice->getInvoiceByNew ( $this->staff [0] ['sid'] );*/
-
- Doo::loadModel ( 'L_category' );
- $lCategory = new L_category ();
-
- $category = $lCategory->find ( array (
- 'asArray' => true
- ) );
- $this->data ['category'] = $category;
-
- Doo::loadModel ( 'invoiceTraining' );
- $invoiceTraining = new invoiceTraining ();
-
- $itList = $invoiceTraining->findAll( array (
- 'where' => " cid=" . $this->staff [0] ['cid'].' or creator ='.$this->staff [0]['sid'],
- 'desc'=>'itid',
- 'asArray' => TRUE
- ) );
-
- //$itList = $invoiceTraining->getInvoiceTrainingByCid ( $this->staff [0] ['cid'] );
-
- Doo::loadModel ( 'receipt' );
- $receipt = new receipt ();
- foreach ( $itList as $key => $value ) { // 不展示已结算完结的培训班
- $receiptDetail = $receipt->getReceiptByinvoiceTrainId ( $value ['itid'] );
- if (! empty ( $receiptDetail )) {
- if ($receiptDetail ['status'] == 8 || $receiptDetail ['status'] == 9) {
- unset ( $itList [$key] );
- }
- }
- }
- $this->data ['itList'] = $itList;
-
- $token = $this->set_token ();
- $tokenTime=time().rand(5, 15);
- $_SESSION ['token_' . $this->staff [0] ['sidKey'].'_'.$tokenTime] = $token;
- $this->data ['token'] = $token;
- $this->data['tokenTime']=$tokenTime;
-
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoice';
- $this->render ( "/admin/invoiceAdd", $this->data );
- }
-
- /**
- * 自更新发票信息库
- * @param unknown $invoicePrintDetail
- */
- function autoUpdateInvoiceInfoBase($invoicePrintDetail) {
- // 发票信息库
- Doo::loadModel ( 'invoiceInfoBase' );
- $invoiceInfoBase = new invoiceInfoBase ();
-
- $updateDate = strtotime ( $invoicePrintDetail ['date'] );
-
- $TIN = $invoicePrintDetail ['TIN'];
- $invoiceTitle = $invoicePrintDetail ['invoiceTitle'];
- if (empty ( $invoiceTitle ))
- $invoiceTitle = $invoicePrintDetail ['invoiceCompany'];
-
- $IIBList = $invoiceInfoBase->getInvoiceInfoByTT ( $TIN, $invoiceTitle );
- // 确认有该条发票信息
- $invoiceInfoBase = new invoiceInfoBase ();
- if (! empty ( $IIBList )) {
- // 发票库里的信息数量
- $IIBListCount = count ( $IIBList );
- if ($IIBListCount == 1) { // 更新发票--提交是最新的时间
- $item = array (
- 'iibID' => $IIBList [0] ['iibID'],
- 'invoiceTitle' => $invoiceTitle,
- 'TIN' => $TIN
- );
- if (! empty ( $invoicePrintDetail ['address'] )) {
- $item += array (
- 'address' => $invoicePrintDetail ['address']
- );
- }
- if (! empty ( $invoicePrintDetail ['phone'] )) {
- $item += array (
- 'phone' => $invoicePrintDetail ['phone']
- );
- }
- if (! empty ( $invoicePrintDetail ['bank'] )) {
- $item += array (
- 'bank' => $invoicePrintDetail ['bank']
- );
- }
- if (! empty ( $invoicePrintDetail ['bankAccount'] )) {
- $item += array (
- 'bankAccount' => $invoicePrintDetail ['bankAccount']
- );
- }
- if ($updateDate >= strtotime ($IIBList [0] ['updateDate'])) {
- $item += array (
- 'updateDate' => $invoicePrintDetail ['date']
- );
- $invoiceInfoBase->setInvoiceInfoBaseByCondition ( $item );
- }
- } else { // 删除多张发票,重新添加发票
- $iibIDStr = '';
- $iibID = array ();
- foreach ( $IIBList as $key => $value ) {
- array_push ( $iibID, $value ['iibID'] );
- }
- $iibIDStr = implode ( ",", $iibID ); // 删除
- $invoiceInfoBase->delInvoiceInfoBaseByIibStr ( $iibIDStr );
-
- $item = array (
- 'invoiceTitle' => $invoiceTitle,
- 'TIN' => $TIN,
-
- 'address' => $invoicePrintDetail ['address'],
- 'phone' => $invoicePrintDetail ['phone'],
- 'bank' => $invoicePrintDetail ['bank'],
- 'bankAccount' => $invoicePrintDetail ['bankAccount'],
- 'updateDate' => $invoicePrintDetail ['date']
- );
- $invoiceInfoBase->addInvoiceInfoBase ( $item );
- }
- } else { // 没有新增发票信息
- $item = array (
- 'invoiceTitle' => $invoiceTitle,
- 'TIN' => $TIN,
-
- 'address' => $invoicePrintDetail ['address'],
- 'phone' => $invoicePrintDetail ['phone'],
- 'bank' => $invoicePrintDetail ['bank'],
- 'bankAccount' => $invoicePrintDetail ['bankAccount'],
- 'updateDate' => $invoicePrintDetail ['date']
- );
- $invoiceInfoBase->addInvoiceInfoBase ( $item );
- }
- }
- function invoiceAddFill() {
- session_start ();
- Doo::loadModel ( 'L_category' );
- $lCategory = new L_category ();
-
- $category = $lCategory->find ( array (
- 'asArray' => true
- ) );
- $this->data ['category'] = $category;
-
- Doo::loadModel ( 'invoiceTraining' );
- $invoiceTraining = new invoiceTraining ();
- $itList = $invoiceTraining->getInvoiceTrainingByCid ( $this->staff [0] ['cid'] );
- $this->data ['itList'] = $itList;
-
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- $detail = $invoice->getInvoiceByNew ( $this->staff [0] ['sid'] );
- $detail ['mailItemsArray'] = json_decode ( $detail ['mailItemsJson'], true );
-
- $token = $this->set_token ();
- $tokenTime=time().rand(5, 15);
- $_SESSION ['token_' . $this->staff [0] ['sidKey'].'_'.$tokenTime] = $token;
- $this->data ['token'] = $token;
- $this->data['tokenTime']=$tokenTime;
- $this->data ['invoiceDetail'] = $detail;
-
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoice';
- $this->render ( "/admin/invoiceAddFill", $this->data );
- }
-
- /**
- * 提交一份开票申请,并记录下操作日志
- *
- * @since 1.0.0
- * @var integer cid 办事处ID
- * @var integer invoiceType 发票类型
- * @var integer doPost 是否邮寄
- * @var integer invoicePrice 开票金额
- * @var string invoiceElement 开票内容
- * @var string invoiceTitle 发票抬头
- * @var string invoiceCompany 单位名称
- * @var string TIN 纳税人识别码
- * @var string address 注册地址
- * @var string phone 注册电话
- * @var string bank 开户银行
- * @var string bankAccount 银行账户
- * @var string recipients 收件人
- * @var string recipientsPhone 收件人手机/电话
- * @var string recipientsAddress 收件地址
- * @var string mailItems 邮寄物品
- * @var string remark 备注
- * @return string 返回跳转开票主页路径
- */
- function invoiceAddDo() {
- // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
- $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
- $invoiceType = $this->get_args ( 'invoiceType' ) && is_numeric ( $this->get_args ( 'invoiceType' ) ) ? $this->get_args ( 'invoiceType' ) : 0;
- $doPost = $this->get_args ( 'doPost' ) && is_numeric ( $this->get_args ( 'doPost' ) ) ? $this->get_args ( 'doPost' ) : 0;
- // $invoicePrice = $this->get_args ( 'invoicePrice' ) ? $this->get_args ( 'invoicePrice' ) : "";
-
- $invoiceQuantity = $this->get_args ( 'invoiceQuantity' ) && is_numeric ( $this->get_args ( 'invoiceQuantity' ) ) ? $this->get_args ( 'invoiceQuantity' ) : 0;
- $invoiceUnitPrice = $this->get_args ( 'invoiceUnitPrice' ) && is_numeric ( $this->get_args ( 'invoiceUnitPrice' ) ) ? $this->get_args ( 'invoiceUnitPrice' ) : 0;
-
- $invoiceForm = $this->get_args ( 'invoiceForm' ) ? $this->get_args ( 'invoiceForm' ) : "";
-
- $invoiceElement = $this->get_args ( 'invoiceElement' ) ? $this->get_args ( 'invoiceElement' ) : "";
- $invoiceTitle = $this->get_args ( 'invoiceTitle' ) ? $this->get_args ( 'invoiceTitle' ) : "";
- $invoiceCompany = $this->get_args ( 'invoiceCompany' ) ? $this->get_args ( 'invoiceCompany' ) : "";
- $TIN = $this->get_args ( 'TIN' ) ? $this->get_args ( 'TIN' ) : "";
- $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
- $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
- $bank = $this->get_args ( 'bank' ) ? $this->get_args ( 'bank' ) : "";
- $bankAccount = $this->get_args ( 'bankAccount' ) ? $this->get_args ( 'bankAccount' ) : "";
- $recipients = $this->get_args ( 'recipients' ) ? $this->get_args ( 'recipients' ) : "";
- $recipientsPhone = $this->get_args ( 'recipientsPhone' ) ? $this->get_args ( 'recipientsPhone' ) : "";
- $recipientsAddress = $this->get_args ( 'recipientsAddress' ) ? $this->get_args ( 'recipientsAddress' ) : "";
-
- $remark = $this->get_args ( 'remark' ) ? $this->get_args ( 'remark' ) : "";
-
- $TINT = $this->get_args ( 'TINT' ) ? $this->get_args ( 'TINT' ) : "";
- $addressT = $this->get_args ( 'addressT' ) ? $this->get_args ( 'addressT' ) : "";
- $phoneT = $this->get_args ( 'phoneT' ) ? $this->get_args ( 'phoneT' ) : "";
- $bankT = $this->get_args ( 'bankT' ) ? $this->get_args ( 'bankT' ) : "";
- $bankAccountT = $this->get_args ( 'bankAccountT' ) ? $this->get_args ( 'bankAccountT' ) : "";
-
- $softLock = $this->get_args ( 'softLock' ) ? $this->get_args ( 'softLock' ) : 0;
- $softLockNum = $this->get_args ( 'softLockNum' ) ? $this->get_args ( 'softLockNum' ) : 0;
- $contract = $this->get_args ( 'contract' ) ? $this->get_args ( 'contract' ) : 0;
- $contractNum = $this->get_args ( 'contractNum' ) ? $this->get_args ( 'contractNum' ) : 0;
- $instructions = $this->get_args ( 'instructions' ) ? $this->get_args ( 'instructions' ) : 0;
- $instructionsNum = $this->get_args ( 'instructionsNum' ) ? $this->get_args ( 'instructionsNum' ) : 0;
- $remittance = $this->get_args ( 'remittance' ) ? $this->get_args ( 'remittance' ) : 0;
-
- $mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
-
- $trainId = $this->get_args ( 'trainId' ) ? $this->get_args ( 'trainId' ) : 0;
- $settlementType = $this->get_args ( 'settlementType' ) ? $this->get_args ( 'settlementType' ) : "";
-
- $electronicPhone= $this->get_args ( 'electronicPhone' ) ? $this->get_args ( 'electronicPhone' ) : "";
- $electronicEmail = $this->get_args ( 'electronicEmail' ) ? $this->get_args ( 'electronicEmail' ) : "";
-
- /*
- * $mailList=array(); array_push($mailList, array('invoice'=>1)); array_push($mailList, array('mailItems'=>$mailItems)); if (!empty($softLock)) array_push($mailList, array('softLock'=>$softLockNum)); if (!empty($contract)) array_push($mailList, array('contract'=>$contractNum)); if (!empty($instructions)) array_push($mailList, array('instructions'=>$instructionsNum)); if (!empty($remittance)) array_push($mailList, array('remittance'=>$remittance)); echo json_encode($mailList) ; print_r($mailList); die;
- */
- $token = $this->get_args ( 'token' ) ? $this->get_args ( 'token' ) : "";
- $tokenTime = $this->get_args ( 'tokenTime' ) ? $this->get_args ( 'tokenTime' ) : "";
- if (empty ( $token )) {
- die ( 'illegal request-token' );
- } else {
- session_start ();
- $sessionKey='token_' . $this->staff [0] ['sidKey'].'_'.$tokenTime;
- header ( 'Content-Type:text/html;charset=utf-8' );
- if (!isset($_SESSION [$sessionKey])||empty($_SESSION [$sessionKey])) {
- die ( '请重新刷新发票申请页面' );
- }elseif($_SESSION [$sessionKey]=='repeat'){
- die ( '请勿重复申请发票' );
- } else {
-
- if ($_SESSION [$sessionKey] != $token){
- die ( '请勿重复申请发票' );
- }else{
- $_SESSION [$sessionKey] = 'repeat';
- }
- }
- }
-
-
-
- if($invoiceForm=='electronic'){
- if(empty(trim($electronicPhone))&&empty(trim($electronicEmail))){
- die ( '请至少填写一种联系方式--电子发票' );
- }
- }
-
- if ($invoiceType == 1) {
- $temporary = $invoiceQuantity * $invoiceUnitPrice;
- if ($temporary > 100001) {
- header ( 'Content-Type:text/html;charset=utf-8' );
- die ( '专用发票总金额暂时不能超过100000.00(十万)元。' );
- }
- }elseif($invoiceType == 0){
- $temporary = $invoiceQuantity * $invoiceUnitPrice;
- if ($temporary > 100001) {
- header ( 'Content-Type:text/html;charset=utf-8' );
- die ( '专用发票总金额暂时不能超过100000.00(十万)元。' );
- }
- }else{
- die ( 'illegal request-invoiceType' );
- }
-
- if (empty ( $this->staff [0] ))
- die ( 'illegal request-Please login' );
-
- if (! empty ( $cid ) && ! empty ( $invoiceQuantity ) && ! empty ( $invoiceUnitPrice ) && ! empty ( $invoiceElement ) && ! empty ( $settlementType )&&!empty($invoiceForm)) {
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'L_category' );
- $lCategory = new L_category ();
- Doo::loadModel ( 'invoiceManage' );
- $invoiceManage = new invoiceManage ();
- Doo::loadModel ( 'invoiceOperationLog' );
- $invoiceOperationLog = new invoiceOperationLog ();
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- $trainId = $XDeode->decode ( $trainId );
-
- $categoryDetil = $lCategory->getOne ( array (
- 'SELECT' => 'title',
- 'where' => 'cid=' . $cid,
- 'asArray' => true
- ) );
-
- $invoicePrice = $invoiceQuantity * $invoiceUnitPrice;
-
- $invoiceManageList = $invoiceManage->getInvoiceByAll ();
- $invoiceManageDetail = $invoiceManage->getInvoiceByMold ( "发票审批" );
- // print_r(current($invoiceManageDetail ['staffList']));
- // die;
-
- $moldManage = array ();
- foreach ( $invoiceManageList as $key => $value ) {
- if ($value ['mold'] == '发票打印')
- $moldManage [$value ['mold']] = $value ['staffList'];
- elseif ($value ['mold'] == '发票邮寄')
- $moldManage [$value ['mold']] = $value ['staffList'];
- elseif ($value ['mold'] == '发票退票')
- $moldManage [$value ['mold']] = $value ['staffList'];
- }
-
- $pendingApprovalsSid = current ( $invoiceManageDetail ['staffList'] ) [0];
-
- $st = '';
- if ($settlementType == 'SOFTWARE') {
- $st = 0;
- $trainId = 0;
- } elseif ($settlementType == 'TRAINING') {
- $st = 1;
- if (empty ( $trainId ) && ! is_numeric ( $trainId )) {
- die ( 'illegal request-trainingIdError' );
- }
- } else {
- die ( 'illegal request-settlementError' );
- }
-
- if($invoiceForm=='electronic'){
- $invoiceSerial="#FE" . date('Ymd') . str_pad(mt_rand(1, 99999), 5, '0', STR_PAD_LEFT);
- $invoiceForm=1;
- $invoiceType=0;
- if(!empty($electronicPhone)||!empty($electronicEmail)){
-
- }else{
- die ( 'illegal request-electronicContact' );
- }
-
- $mailList = array ();
- $mailString = '备注:' . $mailItems;
- }elseif($invoiceForm=='paper'){
-
- $invoiceSerial="#F" . date('Ymd') . str_pad(mt_rand(1, 99999), 5, '0', STR_PAD_LEFT);
- $invoiceForm=0;
-
- $mailList = array (
- 'invoice' => 1,
- 'mailItems' => $mailItems
- );
- $mailString = '发票x1张,备注:' . $mailItems;
- }else{
- die ( 'illegal request-invoiceForm' );
- }
-
- $item = array (
- 'cid' => $cid,
- 'categoryName' => $categoryDetil ['title'],
- 'invoiceElement' => $invoiceElement,
- 'invoiceForm'=>$invoiceForm,
-
- 'electronicPhone'=>$electronicPhone,
- 'electronicEmail'=>$electronicEmail,
-
- 'invoiceQuantity' => $invoiceQuantity,
- 'invoiceUnitPrice' => $invoiceUnitPrice,
-
- 'invoicePrice' => $invoicePrice,
- 'invoiceType' => $invoiceType,
- 'settlementType' => $st,
- 'doPost' => $doPost,
- 'status' => 1,
- 'invoiceSerial' => $invoiceSerial,
- 'date' => date ( "Y-m-d H:i:s" ),
- 'updateTime' => date ( "Y-m-d H:i:s" ),
- 'sid' => $this->staff [0] ['sid'],
- 'userName' => $this->staff [0] ['username'],
- 'invoiceManage' => $invoiceManageDetail ['staff'],
- 'pendingApprovals' => $pendingApprovalsSid,
- 'moldManage' => json_encode ( $moldManage ),
- 'remark' => $remark,
- 'trainId' => $trainId
- );
- if ($invoiceType == 0)
- $item += array (
- 'invoiceTitle' => $invoiceTitle,
- 'TIN' => $TINT,
- 'address' => $addressT,
- 'phone' => $phoneT,
- 'bank' => $bankT,
- 'bankAccount' => $bankAccountT
- );
- else {
- $item += array (
- 'invoiceCompany' => $invoiceCompany,
- 'TIN' => $TIN,
- 'address' => $address,
- 'phone' => $phone,
- 'bank' => $bank,
- 'bankAccount' => $bankAccount
- );
- }
- if ($doPost == 1) {
-
- if (! empty ( $softLock ))
- $mailList += array (
- 'softLock' => $softLockNum
- );
- else
- $mailList += array (
- 'softLock' => 0
- );
- if (! empty ( $contract ))
- $mailList += array (
- 'contract' => $contractNum
- );
- else
- $mailList += array (
- 'contract' => 0
- );
- if (! empty ( $instructions ))
- $mailList += array (
- 'instructions' => $instructionsNum
- );
- else
- $mailList += array (
- 'instructions' => 0
- );
- if (! empty ( $remittance ))
- $mailList += array (
- 'remittance' => $remittance
- );
- else
- $mailList += array (
- 'remittance' => ''
- );
-
-
- if (! empty ( $softLock ))
- $mailString .= ',软件锁x' . $softLockNum . '个';
- if (! empty ( $contract ))
- $mailString .= ',合同x' . $contractNum . '份';
- if (! empty ( $instructions ))
- $mailString .= ',说明书x' . $instructionsNum . '本';
- if (! empty ( $remittance ))
- $mailString .= ',汇款账号单(张)';
-
- $item += array (
- 'recipients' => $recipients,
- 'recipientsPhone' => $recipientsPhone,
- 'recipientsAddress' => $recipientsAddress,
- 'mailItems' => $mailString,
- 'mailItemsJson' => json_encode ( $mailList )
- );
- }
-
- $iid = $invoice->addInvoice ( $item );
-
- // 如果是培训班结算 创建培训班发票到培训班备份中
- if (! empty ( $st ) && $st == 1) {
- Doo::loadModel ( 'invoiceStore' );
- $invoiceStore = new invoiceStore ();
- Doo::loadModel ( 'invoiceTraining' );
- $invoiceTraining = new invoiceTraining ();
-
- $isid = $invoiceStore->setInvoiceToInvoiceStore ( $iid );
- $itemIS = array (
- 'isid' => $isid,
- 'ipSource' => 1,
- 'apStatus' => 1,
- 'iid' => $iid
- );
- $invoiceStore->setInvoiceStoreByCondition ( $itemIS );
-
- // 更新培训班总数量
- $detailIT = $invoiceTraining->getInvoiceTrainingByItid ( $trainId );
- $item = array (
- 'itid' => $trainId,
- 'invoiceTotal' => $detailIT ['invoiceTotal'] + 1,
- 'submitStatus' => 1
- );
- $itid = $invoiceTraining->setInvoiceTrainByCondition ( $item );
- }
-
- // 操作日志
- $item = array (
- 'date' => date ( "Y-m-d H:i:s" ),
- 'operation' => "创建",
- 'status' => 1,
- 'img' => $this->staff [0] ['avatar'],
- 'username' => $this->staff [0] ['username'],
- 'uid' => $this->staff [0] ['sid'],
- 'category' => $this->staff [0] ['category'],
- 'iid' => $iid
- );
- $invoiceOperationLog->setInvoiceOperationLog ( $item );
- $item = array (
- 'date' => date ( "Y-m-d H:i:s" ),
- 'operation' => "提交审批",
- 'status' => 1,
- 'img' => $this->staff [0] ['avatar'],
- 'username' => $this->staff [0] ['username'],
- 'uid' => $this->staff [0] ['sid'],
- 'category' => $this->staff [0] ['category'],
- 'iid' => $iid
- );
- $invoiceOperationLog->setInvoiceOperationLog ( $item );
-
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- $username2 = $staff->getOne ( array (
- 'select' => 'wxid',
- 'where' => 'sid=' . $pendingApprovalsSid,
- 'asArray' => TRUE
- ) );
- // 发送微信审批通知
- $title2 = '[通知]用户提交了一条开票申请,快到“我的发票”中查看,给用户确认审批。';
-
- $this->msgSend ( '', $title2, '', $username2 ['wxid'], $pendingApprovalsSid, 'approval' );
- }
- return "/invoice";
- }
- function invoiceEdit() {
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
- $iid = $XDeode->decode ( $iid );
- if (! is_numeric ( $iid ))
- die ( 'illegal request' );
-
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'invoiceOperationLog' );
- $invoiceOperationLog = new invoiceOperationLog ();
-
- $invoiceDetail = $invoice->getInvoiceByIid ( $iid );
- $operation = $invoiceOperationLog->getInvoiceOperationByDropped ( $iid );
-
- $invoiceDetail ['mailItemsJson'] ='';
- if(isset($invoiceDetail ['mailItemsJson'])){
- $invoiceDetail ['mailItemsJson'] = json_decode ( $invoiceDetail ['mailItemsJson'], true );
- }
-
-
- $this->data ['operation'] = $operation;
- $this->data ['invoiceDetail'] = $invoiceDetail;
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoice';
- $this->render ( "/admin/invoiceEdit", $this->data );
- }
- /**
- * 重新编辑退回的发票
- * @return string
- */
- function invoiceEditDo() {
- $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : '';
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- $iid = $invoice->authcode ( $iidKey );
- if (! empty ( $iid ) && ! is_numeric ( $iid ))
- die ( 'illegal request' );
-
- $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
- $invoiceType = $this->get_args ( 'invoiceType' ) && is_numeric ( $this->get_args ( 'invoiceType' ) ) ? $this->get_args ( 'invoiceType' ) : 0;
- $doPost = $this->get_args ( 'doPost' ) && is_numeric ( $this->get_args ( 'doPost' ) ) ? $this->get_args ( 'doPost' ) : 0;
- $invoicePrice = $this->get_args ( 'invoicePrice' ) ? $this->get_args ( 'invoicePrice' ) : "";
-
- $invoiceQuantity = $this->get_args ( 'invoiceQuantity' ) && is_numeric ( $this->get_args ( 'invoiceQuantity' ) ) ? $this->get_args ( 'invoiceQuantity' ) : 0;
- $invoiceUnitPrice = $this->get_args ( 'invoiceUnitPrice' ) && is_numeric ( $this->get_args ( 'invoiceUnitPrice' ) ) ? $this->get_args ( 'invoiceUnitPrice' ) : 0;
-
- $invoiceElement = $this->get_args ( 'invoiceElement' ) ? $this->get_args ( 'invoiceElement' ) : "";
- $invoiceTitle = $this->get_args ( 'invoiceTitle' ) ? $this->get_args ( 'invoiceTitle' ) : "";
- $invoiceCompany = $this->get_args ( 'invoiceCompany' ) ? $this->get_args ( 'invoiceCompany' ) : "";
- $TIN = $this->get_args ( 'TIN' ) ? $this->get_args ( 'TIN' ) : "";
- $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
- $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
- $bank = $this->get_args ( 'bank' ) ? $this->get_args ( 'bank' ) : "";
- $bankAccount = $this->get_args ( 'bankAccount' ) ? $this->get_args ( 'bankAccount' ) : "";
- $recipients = $this->get_args ( 'recipients' ) ? $this->get_args ( 'recipients' ) : "";
- $recipientsPhone = $this->get_args ( 'recipientsPhone' ) ? $this->get_args ( 'recipientsPhone' ) : "";
- $recipientsAddress = $this->get_args ( 'recipientsAddress' ) ? $this->get_args ( 'recipientsAddress' ) : "";
-
- $mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
- $remark = $this->get_args ( 'remark' ) ? $this->get_args ( 'remark' ) : "";
-
- $TINT = $this->get_args ( 'TINT' ) ? $this->get_args ( 'TINT' ) : "";
- $addressT = $this->get_args ( 'addressT' ) ? $this->get_args ( 'addressT' ) : "";
- $phoneT = $this->get_args ( 'phoneT' ) ? $this->get_args ( 'phoneT' ) : "";
- $bankT = $this->get_args ( 'bankT' ) ? $this->get_args ( 'bankT' ) : "";
- $bankAccountT = $this->get_args ( 'bankAccountT' ) ? $this->get_args ( 'bankAccountT' ) : "";
-
- $softLock = $this->get_args ( 'softLock' ) ? $this->get_args ( 'softLock' ) : 0;
- $softLockNum = $this->get_args ( 'softLockNum' ) ? $this->get_args ( 'softLockNum' ) : 0;
- $contract = $this->get_args ( 'contract' ) ? $this->get_args ( 'contract' ) : 0;
- $contractNum = $this->get_args ( 'contractNum' ) ? $this->get_args ( 'contractNum' ) : 0;
- $instructions = $this->get_args ( 'instructions' ) ? $this->get_args ( 'instructions' ) : 0;
- $instructionsNum = $this->get_args ( 'instructionsNum' ) ? $this->get_args ( 'instructionsNum' ) : 0;
- $remittance = $this->get_args ( 'remittance' ) ? $this->get_args ( 'remittance' ) : 0;
-
-
- $electronicPhone = $this->get_args ( 'electronicPhone' ) ? $this->get_args ( 'electronicPhone' ) : "";
- $electronicEmail = $this->get_args ( 'electronicEmail' ) ? $this->get_args ( 'electronicEmail' ) : "";
- $invoiceForm = $this->get_args ( 'invoiceForm' ) ? $this->get_args ( 'invoiceForm' ) : "";
-
- if ($invoiceType == 1) {
- $temporary = $invoiceQuantity * $invoiceUnitPrice;
- if ($temporary > 100001)
- die ( 'illegal request-Please priceError' );
- }
-
- if($invoiceForm=='electronic'){
- if(empty(trim($electronicPhone))&&empty(trim($electronicEmail))){
- die ( '请至少填写一种联系方式--电子发票' );
- }
- }
-
-
- if (! empty ( $cid ) && ! empty ( $invoiceQuantity ) && ! empty ( $invoiceUnitPrice ) && ! empty ( $invoiceElement ) && ! empty ( $iid )) {
-
- Doo::loadModel ( 'invoiceManage' );
- $invoiceManage = new invoiceManage ();
- Doo::loadModel ( 'invoiceOperationLog' );
- $invoiceOperationLog = new invoiceOperationLog ();
- Doo::loadModel ( 'invoiceStore' );
- $invoiceStore = new invoiceStore ();
-
- $cid = explode ( ':', $cid );
-
- $invoiceManageList = $invoiceManage->getInvoiceByAll ();
- $invoiceManageDetail = $invoiceManage->getInvoiceByMold ( "发票审批" );
-
- $moldManage = array ();
- foreach ( $invoiceManageList as $key => $value ) {
- if ($value ['mold'] == '发票打印')
- $moldManage [$value ['mold']] = $value ['staffList'];
- elseif ($value ['mold'] == '发票邮寄')
- $moldManage [$value ['mold']] = $value ['staffList'];
- elseif ($value ['mold'] == '发票打印')
- $moldManage [$value ['mold']] = $value ['staffList'];
- }
-
- $invoicePrice = $invoiceQuantity * $invoiceUnitPrice;
-
-
-
- if($invoiceForm=='electronic'){
-
- $invoiceForm=1;
- $invoiceType=0;
- if(!empty($electronicPhone)||!empty($electronicEmail)){
-
- }else{
- die ( 'illegal request-electronicContact' );
- }
-
- $mailList = array ();
- $mailString = '备注:' . $mailItems;
- }elseif($invoiceForm=='paper'){
-
- $invoiceForm=0;
-
- $mailList = array (
- 'invoice' => 1,
- 'mailItems' => $mailItems
- );
- $mailString = '发票x1张,备注:' . $mailItems;
- }else{
- die ( 'illegal request-invoiceForm' );
- }
-
-
-
-
-
- $item = array (
- 'iid' => $iid,
- 'cid' => $cid [0],
- 'categoryName' => $cid [1],
- 'invoiceElement' => $invoiceElement,
-
- 'invoiceForm'=>$invoiceForm,
- 'electronicPhone'=>$electronicPhone,
- 'electronicEmail'=>$electronicEmail,
-
-
- 'invoiceQuantity' => $invoiceQuantity,
- 'invoiceUnitPrice' => $invoiceUnitPrice,
-
- 'invoicePrice' => $invoicePrice,
- 'invoiceType' => $invoiceType,
- 'doPost' => $doPost,
- 'status' => 1,
- 'updateTime' => date ( "Y-m-d H:i:s" ),
- 'remark' => $remark
- );
- if ($invoiceType == 0)
- $item += array (
- 'invoiceTitle' => $invoiceTitle,
-
- 'TIN' => $TINT,
- 'address' => $addressT,
- 'phone' => $phoneT,
- 'bank' => $bankT,
- 'bankAccount' => $bankAccountT
- );
- else {
- $item += array (
- 'invoiceCompany' => $invoiceCompany,
- 'TIN' => $TIN,
- 'address' => $address,
- 'phone' => $phone,
- 'bank' => $bank,
- 'bankAccount' => $bankAccount
- );
- }
- if ($doPost == 1) {
-
-
- if (! empty ( $softLock ))
- $mailList += array (
- 'softLock' => $softLockNum
- );
- else
- $mailList += array (
- 'softLock' => '0'
- );
- if (! empty ( $contract ))
- $mailList += array (
- 'contract' => $contractNum
- );
- else
- $mailList += array (
- 'contract' => '0'
- );
- if (! empty ( $instructions ))
- $mailList += array (
- 'instructions' => $instructionsNum
- );
- else
- $mailList += array (
- 'instructions' => '0'
- );
- if (! empty ( $remittance ))
- $mailList += array (
- 'remittance' => $remittance
- );
- else
- $mailList += array (
- 'remittance' => ''
- );
-
-
- if (! empty ( $softLock ))
- $mailString .= ',软件锁x' . $softLockNum;
- if (! empty ( $contract ))
- $mailString .= ',合同x' . $contractNum;
- if (! empty ( $instructions ))
- $mailString .= ',说明书x' . $instructionsNum;
- if (! empty ( $remittance ))
- $mailString .= ',汇款账号单';
-
- $item += array (
- 'recipients' => $recipients,
- 'recipientsPhone' => $recipientsPhone,
- 'recipientsAddress' => $recipientsAddress,
- 'mailItems' => $mailString,
- 'mailItemsJson' => json_encode ( $mailList )
- );
- }
- $invoice->setInvoiceByCondition ( $item );
- // 更新培训班仓库里的发票
- $detail = $invoice->getInvoiceByIid ( $iid );
- if (! empty ( $detail ['isid'] )) {
- $invoiceStore->isid = $detail ['isid'];
- $invoiceStore->invoiceQuantity = $invoiceQuantity;
- $invoiceStore->invoiceUnitPrice = $invoiceUnitPrice;
- $invoiceStore->invoicePrice = $invoicePrice;
- $invoiceStore->update ();
- }
-
- $item = array (
- 'date' => date ( "Y-m-d H:i:s" ),
- 'operation' => "重新提交审批",
- 'status' => 1,
- 'img' => $this->staff [0] ['avatar'],
- 'username' => $this->staff [0] ['username'],
- 'uid' => $this->staff [0] ['sid'],
- 'category' => $this->staff [0] ['category'],
- 'iid' => $iid
- );
- $invoiceOperationLog->setInvoiceOperationLog ( $item );
- }
- return "/invoice";
- }
-
- /**
- * 培训班
- */
- function invoiceTraining() {
- Doo::loadModel ( 'L_category' );
- $lCategory = new L_category ();
- Doo::loadModel ( 'invoiceTraining' );
- $invoiceTraining = new invoiceTraining ();
-
- Doo::loadModel ( 'invoiceTrainManage' );
- $invoiceTrainManage = new invoiceTrainManage ();
- $imcStaff = $invoiceTrainManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
- $cidList = array ();
- foreach ( $imcStaff as $key => $value ) {
- array_push ( $cidList, $value ['cid'] );
- }
- if (empty ( $cidList )) {
- $cidString = $this->staff [0] ['cid'];
- } else {
- $cidString = implode ( ',', $cidList );
- $cidString .= $cidString . ',' . $this->staff [0] ['cid'];
- }
-
- // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
- // $itTodoList = $invoiceTraining->getInvoiceTrainingByTodo ( '', $cidString, $this->staff [0] ['sid'] );
- //TODO 待完成入账培训班
- $itTodoList=$this->invoiceService->getTrainByCategoryStaff(0,$cidString,$this->staff [0] ['sid']);
- // if($this->staff [0] ['sid']==94){
- // $itTodoList=$this->invoiceService->getTrainByCategoryStaff(0,$cidString,$this->staff [0] ['sid']);
- // }else{
- // $itTodoList = $invoiceTraining->getInvoiceTrainingByTodo ( '', $cidString, $this->staff [0] ['sid'] );
- // }
- // $itTodoList=$this->invoiceService->getTrainByCategoryStaff(0,$cidString,$this->staff [0] ['sid']);
-
-
-
- $itedList = $invoiceTraining->getInvoiceTrainingByStatus ( 2, '', $cidString, $this->staff [0] ['sid'] );
- $category = $lCategory->getCategory ();
-
- $itid = array ();
- foreach ( $itTodoList as $key => $value ) {
- array_push ( $itid, $value ['itid'] );
- // 如果入账100%更新为已完成
- if ($itTodoList [$key] ['arriveSchedule'] >= 100) {
- $invoiceTraining = new invoiceTraining ();
- $invoiceTraining->itid = $value ['itid'];
- $invoiceTraining->status = 2;
- $invoiceTraining->update ();
- }
- }
- foreach ( $itedList as $value ) {
- array_push ( $itid, $value ['itid'] );
- }
-
- $itid = implode ( ',', $itid );
- $this->data ['itStatist'] = $invoiceTraining->getInvoiceTrainStatistics ( $itid );
-
- // print_r($itTodoList);
-
- $this->data ['trainCount'] = count ( $itTodoList ) + count ( $itedList );
- $this->data ['itTodoList'] = $itTodoList;
- $this->data ['itedList'] = $itedList;
- $this->data ['category'] = $category;
-
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoiceTraining';
- $this->render ( "/admin/invoiceTraining", $this->data );
- }
-
- /**
- * 创建培训班
- */
- function invoiceTrainingAdd() {
- $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
- $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
- $trainDate = $this->get_args ( 'trainDate' ) ? $this->get_args ( 'trainDate' ) : "";
-
- if (empty ( $this->staff [0] ))
- die ( 'illegal request' );
-
- if (! empty ( $cid ) && ! empty ( $trainName ) && ! empty ( $trainDate )) {
-
- Doo::loadModel ( 'invoiceTraining' );
- $invoiceTraining = new invoiceTraining ();
-
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'L_category' );
- $lCategory = new L_category ();
- Doo::loadModel ( 'invoiceManage' );
- $invoiceManage = new invoiceManage ();
- Doo::loadModel ( 'invoiceOperationLog' );
- $invoiceOperationLog = new invoiceOperationLog ();
-
- $item = array (
- 'cid' => $cid,
- 'trainName' => $trainName,
- 'trainDate' => $trainDate,
- 'creator' => $this->staff [0] ['sid'],
- 'creatorDate' => date ( "Y-m-d H:i:s" )
- );
- $itid = $invoiceTraining->addInvoiceTraining ( $item );
- }
-
- return "/invoiceTraining";
- }
-
- /**
- * 删除培训班
- */
- function invoiceTrainingDelDo() {
- $itid = $this->get_args ( 'trainingKey' ) ? $this->get_args ( 'trainingKey' ) : "";
- if (! empty ( $itid )) {
- Doo::loadModel ( 'invoiceTraining' );
- $invoiceTraining = new invoiceTraining ();
-
- $invoiceTraining->delInvoiceTrainingByItid ( $itid );
- }
- return "/invoiceTraining";
- }
-
- /**
- * 培训班详情
- */
- function invoiceTrainingDetail() {
- // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
- $trainStatus = $this->get_args ( 'trainStatus' ) ? $this->get_args ( 'trainStatus' ) : "ALL";
-
- $itid = isset ( $this->params ['trainingKey'] ) ? $this->params ['trainingKey'] : "";
- Doo::loadModel ( 'invoiceTraining' );
- $invoiceTraining = new invoiceTraining ();
- Doo::loadModel ( 'invoiceStore' );
- $invoiceStore = new invoiceStore ();
-
- if (empty ( $itid ))
- die ( 'illegal request' );
-
- $con = '(b.untreadStatus is null or b.untreadStatus!=2) and ';
- if ($trainStatus == "SUBED")
- $con = ' (b.untreadStatus is null ) and ';
- elseif ($trainStatus == "APPROVAL")
- $con = ' ( b.status=1 and b.untreadStatus!=2 ) and ';
- elseif ($trainStatus == "TICKET")
- $con = ' (b.printStatus=1 and b.status=2 and b.untreadStatus!=2) and ';
- elseif ($trainStatus == "TICKETING") {
- $con = ' (b.status=2 and b.untreadStatus=1) and ';
- }
-
- $con.=' a.invoiceForm=0 and ';
-
- $detail = $invoiceTraining->getInvoiceTrainingByItid ( $itid );
- $isList = $invoiceStore->getinvoiceStoreByItid ( $itid, $con,0 );
- //print_r($isList);
-
- $trainlistJson=$this->_trainList($isList);
-
- if (empty ( $detail ))
- die ( 'illegal request' );
- // 培训班结算是否有和是否已经结算完成
- Doo::loadModel ( 'receipt' );
- $receipt = new receipt ();
- $receiptDetail = $receipt->getReceiptByinvoiceTrainId ( $itid );
-
- $this->data ['receiptDetail'] = $receiptDetail;
- $this->data ['trainStatus'] = $trainStatus;
- $this->data ['itid'] = $itid;
- $this->data ['trainlistJson'] = $trainlistJson;
- $this->data ['iTrainDetail'] = $detail;
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoiceTraining';
- $this->render ( "/admin/invoiceTrainingDetail", $this->data );
- }
-
- function invoiceTrainingElectronicDetail(){
- $trainStatus = $this->get_args ( 'trainStatus' ) ? $this->get_args ( 'trainStatus' ) : "ALL";
-
- $itid = isset ( $this->params ['trainingKey'] ) ? $this->params ['trainingKey'] : "";
- Doo::loadModel ( 'invoiceTraining' );
- $invoiceTraining = new invoiceTraining ();
- Doo::loadModel ( 'invoiceStore' );
- $invoiceStore = new invoiceStore ();
-
- if (empty ( $itid ))
- die ( 'illegal request' );
-
- $con = ' (b.untreadStatus is null or b.untreadStatus!=2) and ';
- if ($trainStatus == "SUBED")
- $con = ' (b.untreadStatus is null ) and ';
- elseif ($trainStatus == "APPROVAL")
- $con = ' ( b.status=1 and b.untreadStatus!=2 ) and ';
- elseif ($trainStatus == "TICKET")
- $con = ' (b.printStatus=1 and b.status=2 and b.untreadStatus!=2) and ';
- elseif ($trainStatus == "TICKETING") {
- $con = ' (b.status=2 and b.untreadStatus=1) and ';
- }
-
- $con.=' a.invoiceForm=1 and ';
-
- $detail = $invoiceTraining->getInvoiceTrainingByItid ( $itid );
-
-
- // TODO 获得电子票
- $isList = $invoiceStore->getinvoiceStoreByItid ( $itid, $con,1 );
- //print_r($isList);
-
- if (empty ( $detail )){
- die ( 'illegal request' );
- }
-
-
-
-
- $trainlistJson=$this->_trainList($isList,1);
-
-
- // 培训班结算是否有和是否已经结算完成
- Doo::loadModel ( 'receipt' );
- $receipt = new receipt ();
- $receiptDetail = $receipt->getReceiptByinvoiceTrainId ( $itid );
-
- $this->data ['receiptDetail'] = $receiptDetail;
- $this->data ['trainStatus'] = $trainStatus;
- $this->data ['itid'] = $itid;
- $this->data ['trainlistJson'] = $trainlistJson;
- $this->data ['iTrainDetail'] = $detail;
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoiceTraining';
- $this->render ( "/invoice/invoiceTrainingElectronicDetail", $this->data );
- }
-
- function _trainList($isList,$type=0){
-
- $trainlist = array ();
- foreach ( $isList as $key => $value ) {
- $irDetail = array ();
- if ($value ['apStatus'] == 1) {
- // array_push ( $irDetail, '' );
- array_push ( $irDetail, '<input disabled type="checkbox" style="display:none" >' );
- } else {
-
- array_push ( $irDetail, '<input type="checkbox" class="hide" id="' . $value ['storeKey'] . '" name="isBox" value="' . $value ['storeKey'] . '" > <a href="/invoiceStoreEdit/' . $value ['storeKey'] . '.html">编辑</a>
- <a href="#confirm" onclick="invoiceStoreApproval(\'' . $value ['storeKey'] . '\')" data-toggle="modal">提交审批</a>
- <a href="#del" node-iStore="del" data-key="' . $value ['storeKey'] . '" onclick="invoiceStoreDel(\'' . $value ['storeKey'] . '\')" data-toggle="modal" class="colRed">移除</a>' );
- }
- array_push ( $irDetail, $value ['invoiceSerial'] );
-
- if ($value ['invoiceType'] == 1)
- array_push ( $irDetail, $value ['invoiceCompany'] );
- else
- array_push ( $irDetail, $value ['invoiceTitle'] );
- array_push ( $irDetail, $value ['TIN'] );
- array_push ( $irDetail, $value ['userName'] );
- if (empty ( $value ['mailItems'] ) && $value ['apStatus'] != 1) {
- array_push ( $irDetail, '<a href="#confirm-erro" onclick="invoiceStoreMail(\'' . $value ['storeKey'] . '\')" data-toggle="modal">设置邮寄物品</a>' );
- } else
- array_push ( $irDetail, $value ['mailItems'] );
- array_push ( $irDetail, $value ['recipientsAddress'] . $value ['recipients'] . $value ['recipientsPhone'] );
-
- if($type==1){
- array_push ( $irDetail, $value ['electronicPhone'] );
- array_push ( $irDetail, $value ['electronicEmail'] );
- }
-
-
- array_push ( $irDetail, $value ['address'] . $value ['phone'] );
- array_push ( $irDetail, $value ['bank'] . $value ['bankAccount'] );
- array_push ( $irDetail, $value ['invoiceElement'] );
- array_push ( $irDetail, $value ['invoiceQuantity'] );
- array_push ( $irDetail, $value ['invoiceUnitPrice'] );
-
- if ($value ['invoiceType'] == 1)
- array_push ( $irDetail, '¥' . $value ['invoicePrice'] . '<sup>专</sup>' );
- else
- array_push ( $irDetail, '¥' . $value ['invoicePrice'] );
- array_push ( $irDetail, $value ['remark'] );
-
- if ($value ['status'] == 1)
- array_push ( $irDetail, '审批中' );
- elseif ($value ['status'] == 2 && $value ['printStatus'] == 1)
- array_push ( $irDetail, '已出票' );
- elseif ($value ['status'] == 2 && $value ['printStatus'] == 1 && $value ['printStatus'] != 'irid' && ($value ['untreadStatus'] == 3 || $value ['untreadStatus'] == 0))
- array_push ( $irDetail, '已入账' );
- else
- array_push ( $irDetail, '' );
-
- array_push ( $irDetail, $value ['invoiceNo'] );
- array_push ( $irDetail, $value ['printTime'] );
- $html = '';
- foreach ( $value ['invoiceReceivables'] as $v ) {
-
- $html .= ' <a href="#billing" node-invoice="INFO" data-type="receivables" data-iskey="' . $v [2] . '" data-toggle="modal">' . $v [1] . '</a>';
- }
- array_push ( $irDetail, $html );
- array_push ( $trainlist, $irDetail );
- }
-
- $trainlistJson = json_encode ( $trainlist );
- return $trainlistJson;
- }
-
-
- /**
- * 上传培训班发票
- * @return string
- */
- function invoiceTrainingUpload() {
-
- $POST_MAX_SIZE = ini_get ( 'post_max_size' );
- $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
- $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
-
- if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
- header ( "HTTP/1.1 500 Internal Server Error" );
- echo "POST exceeded maximum allowed size.";
- exit ( 0 );
- }
-
- // Settings
- $save_path = DOO::conf ()->SITE_PATH . "upload/invoiceTraining/"; // The path were we will save the file (getcwd() may not be reliable and should be tested in your environment)
- $upload_name = "Filedata";
- $max_file_size_in_bytes = 2147483647; // 2GB in bytes
- $extension_whitelist = array (
- "doc",
- "txt",
- "jpg",
- "gif",
- "png"
- ); // Allowed file extensions
- $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
-
- // Other variables
- $MAX_FILENAME_LENGTH = 260;
- $file_name = "";
- $file_extension = "";
- $uploadErrors = array (
- 0 => "文件上传成功",
- 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
- 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
- 3 => "上传的文件仅为部分文件",
- 4 => "没有文件上传",
- 6 => "缺少临时文件夹"
- );
-
- $nk = time ();
- $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
-
- if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
- echo "文件无法保存.";
- exit ( 0 );
- }
-
- // Return output to the browser (only supported by SWFUpload for Flash Player 9)
-
- echo json_encode ( array (
- 'filename' => $file_name,
- 'id' => $nk
- ) );
- exit ( 0 );
- }
-
- /**
- * 导入发票临时仓库
- */
- function invoiceStoreImport() {
- // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
- $trainingKey = $this->get_args ( 'trainingKey' ) ? $this->get_args ( 'trainingKey' ) : "";
- $path = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
-
- if ($path != "" && ! empty ( $trainingKey )) {
- Doo::loadModel ( 'invoiceStore' );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel ( 'invoiceTraining' );
- $invoiceTraining = new invoiceTraining ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- $itid = $XDeode->decode ( $trainingKey );
-
- // 培训班结算是否有和是否已经结算完成
- Doo::loadModel ( 'receipt' );
- $receipt = new receipt ();
- $receiptDetail = $receipt->getReceiptByinvoiceTrainId ( $itid );
- if (! empty ( $receiptDetail )) {
- if ($receiptDetail ['status'] == 8 || $receiptDetail ['status'] == 9)
- die ( 'illegal request--status' );
- }
-
- $exlArray = $this->formatExcelToArrayTrain ( DOO::conf ()->SITE_PATH . "upload/invoiceTraining/" . $path );
-
- $userName = $this->staff [0] ['username'];
- $sDetail = $staff->getStaffByName ( $userName );
-
- //print_r($exlArray);die;
-
- // die('sdd');
- // 可以优化
- foreach ( $exlArray as $key => $value ) {
- // 开票
- $invoice = new invoiceStore ();
-
- $invoice->trainId = $itid;
-
- $invoice->invoiceType = 0;
- if ($value ['invoiceType'] == '专' || $value ['invoiceType'] == '专票')
- $invoice->invoiceType = 1;
- elseif($value ['invoiceType'] == '电子'){
- $invoice->invoiceType = 0;
- $invoice->invoiceForm=1;
- }
-
- $invoice->invoiceQuantity = $value ['invoiceQuantity'];
- $invoice->invoiceUnitPrice = $value ['invoiceUnitPrice'];
-
- $invoice->invoicePrice = $value ['invoiceQuantity'] * $value ['invoiceUnitPrice'];
-
- $invoice->invoiceTitle = $value ['invoiceTitle'];
- if ($value ['invoiceType'] == '专' || $value ['invoiceType'] == '专票')
- $invoice->invoiceCompany = $value ['invoiceTitle'];
-
- $invoice->userName = $userName;
-
- $invoice->sid = $sDetail ['sid'];
- $invoice->cid = $sDetail ['cid'];
- $invoice->categoryName = $sDetail ['category'];
-
- $invoice->invoiceElement = $value ['invoiceElement'];
- $invoice->remark = $value ['remark'];
- // $invoice->date = $value ['date'];
-
- // $invoice->printTime = $value ['date'];
-
- $invoice->ipSource = 1;
-
- $invoice->printStatus = 0;
- $invoice->status = 0;
- $invoice->postStatus = 1;
- $invoice->untreadStatus = 0;
- // $invoice->invoiceSerial = "#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
-
- $invoice->TIN = $value ['TIN'];
- $invoice->address = $value ['address'];
- $invoice->phone = $value ['phone'];
- $invoice->bank = $value ['bank'];
- $invoice->bankAccount = $value ['bankAccount'];
- $invoice->recipientsAddress = $value ['recipientsAddress'];
-
- $invoice->recipients = $value ['recipients'];
- $invoice->recipientsPhone = $value ['recipientsPhone'];
-
- $invoice->electronicPhone = $value ['electronicPhone'];
- $invoice->electronicEmail = $value ['electronicEmail'];
-
- $iid = $invoice->insert ();
- }
- // 加入发票总数量
-
- $item = array (
- 'itid' => $itid,
- 'invoiceTotal' => count ( $exlArray )
- );
- $invoiceTraining->setInvoiceTrainByCondition ( $item );
-
- return '/invoiceTrainingDetail/' . $trainingKey . ".html";
- }
- echo 'no file';
- }
-
- /**
- * 编辑仓库里的发票
- */
- function invoiceStoreEdit() {
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $iid = isset ( $this->params ['storeKey'] ) ? $this->params ['storeKey'] : "";
- $iid = $XDeode->decode ( $iid );
- if (! is_numeric ( $iid ))
- die ( 'illegal request' );
-
- Doo::loadModel ( 'invoiceStore' );
- $invoiceStore = new invoiceStore ();
-
- $invoiceDetail = $invoiceStore->getInvoiceStoreByIsid ( $iid );
- // print_r($invoiceDetail);
- $invoiceDetail ['mailItemsJson'] = json_decode ( $invoiceDetail ['mailItemsJson'], true );
-
- $this->data ['invoiceDetail'] = $invoiceDetail;
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoiceTraining';
- $this->render ( "/admin/invoiceStoreEdit", $this->data );
- }
- function invoiceStoreEditDo() {
- $storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : '';
- $trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
-
- Doo::loadModel ( 'invoiceStore' );
- $invoice = new invoiceStore ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $iid = $XDeode->decode ( $storeKey );
-
- if (! empty ( $iid ) && ! is_numeric ( $iid ))
- die ( 'illegal request' );
-
- $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
- $invoiceType = $this->get_args ( 'invoiceType' ) && is_numeric ( $this->get_args ( 'invoiceType' ) ) ? $this->get_args ( 'invoiceType' ) : 0;
- $doPost = $this->get_args ( 'doPost' ) && is_numeric ( $this->get_args ( 'doPost' ) ) ? $this->get_args ( 'doPost' ) : 0;
- $invoicePrice = $this->get_args ( 'invoicePrice' ) ? $this->get_args ( 'invoicePrice' ) : "";
-
- $invoiceQuantity = $this->get_args ( 'invoiceQuantity' ) && is_numeric ( $this->get_args ( 'invoiceQuantity' ) ) ? $this->get_args ( 'invoiceQuantity' ) : 0;
- $invoiceUnitPrice = $this->get_args ( 'invoiceUnitPrice' ) && is_numeric ( $this->get_args ( 'invoiceUnitPrice' ) ) ? $this->get_args ( 'invoiceUnitPrice' ) : 0;
-
- $invoiceElement = $this->get_args ( 'invoiceElement' ) ? $this->get_args ( 'invoiceElement' ) : "";
- $invoiceTitle = $this->get_args ( 'invoiceTitle' ) ? $this->get_args ( 'invoiceTitle' ) : "";
- $invoiceCompany = $this->get_args ( 'invoiceCompany' ) ? $this->get_args ( 'invoiceCompany' ) : "";
- $TIN = $this->get_args ( 'TIN' ) ? $this->get_args ( 'TIN' ) : "";
- $address = $this->get_args ( 'address' ) ? $this->get_args ( 'address' ) : "";
- $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
- $bank = $this->get_args ( 'bank' ) ? $this->get_args ( 'bank' ) : "";
- $bankAccount = $this->get_args ( 'bankAccount' ) ? $this->get_args ( 'bankAccount' ) : "";
- $recipients = $this->get_args ( 'recipients' ) ? $this->get_args ( 'recipients' ) : "";
- $recipientsPhone = $this->get_args ( 'recipientsPhone' ) ? $this->get_args ( 'recipientsPhone' ) : "";
- $recipientsAddress = $this->get_args ( 'recipientsAddress' ) ? $this->get_args ( 'recipientsAddress' ) : "";
-
- $mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
- $remark = $this->get_args ( 'remark' ) ? $this->get_args ( 'remark' ) : "";
-
- $TINT = $this->get_args ( 'TINT' ) ? $this->get_args ( 'TINT' ) : "";
- $addressT = $this->get_args ( 'addressT' ) ? $this->get_args ( 'addressT' ) : "";
- $phoneT = $this->get_args ( 'phoneT' ) ? $this->get_args ( 'phoneT' ) : "";
- $bankT = $this->get_args ( 'bankT' ) ? $this->get_args ( 'bankT' ) : "";
- $bankAccountT = $this->get_args ( 'bankAccountT' ) ? $this->get_args ( 'bankAccountT' ) : "";
-
- $softLock = $this->get_args ( 'softLock' ) ? $this->get_args ( 'softLock' ) : 0;
- $softLockNum = $this->get_args ( 'softLockNum' ) ? $this->get_args ( 'softLockNum' ) : 0;
- $contract = $this->get_args ( 'contract' ) ? $this->get_args ( 'contract' ) : 0;
- $contractNum = $this->get_args ( 'contractNum' ) ? $this->get_args ( 'contractNum' ) : 0;
- $instructions = $this->get_args ( 'instructions' ) ? $this->get_args ( 'instructions' ) : 0;
- $instructionsNum = $this->get_args ( 'instructionsNum' ) ? $this->get_args ( 'instructionsNum' ) : 0;
- $remittance = $this->get_args ( 'remittance' ) ? $this->get_args ( 'remittance' ) : 0;
-
- $electronicPhone = $this->get_args ( 'electronicPhone' ) ? $this->get_args ( 'electronicPhone' ) : "";
- $electronicEmail = $this->get_args ( 'electronicEmail' ) ? $this->get_args ( 'electronicEmail' ) : "";
- $invoiceForm = $this->get_args ( 'invoiceForm' ) ? $this->get_args ( 'invoiceForm' ) : "";
-
- if (! empty ( $cid ) && ! empty ( $invoiceQuantity ) && ! empty ( $invoiceUnitPrice ) && ! empty ( $invoiceElement ) && ! empty ( $iid )) {
-
- $cid = explode ( ':', $cid );
-
- $invoicePrice = $invoiceQuantity * $invoiceUnitPrice;
-
- $item = array (
- 'isid' => $iid,
- 'cid' => $cid [0],
- 'categoryName' => $cid [1],
- 'invoiceElement' => $invoiceElement,
-
- 'invoiceQuantity' => $invoiceQuantity,
- 'invoiceUnitPrice' => $invoiceUnitPrice,
-
- 'invoicePrice' => $invoicePrice,
- 'invoiceType' => $invoiceType,
- 'doPost' => $doPost,
- 'status' => 1,
- 'updateTime' => date ( "Y-m-d H:i:s" ),
- 'remark' => $remark
- );
- if ($invoiceType == 0)
- $item += array (
- 'invoiceTitle' => $invoiceTitle,
-
- 'TIN' => $TINT,
- 'address' => $addressT,
- 'phone' => $phoneT,
- 'bank' => $bankT,
- 'bankAccount' => $bankAccountT
- );
- else {
- $item += array (
- 'invoiceCompany' => $invoiceCompany,
- 'TIN' => $TIN,
- 'address' => $address,
- 'phone' => $phone,
- 'bank' => $bank,
- 'bankAccount' => $bankAccount
- );
- }
-
- if($invoiceForm=='paper'){
- $item += array (
- 'invoiceForm' => 0
- );
- }elseif($invoiceForm=='electronic'){
- $item += array (
- 'invoiceForm' => 1,
- 'electronicPhone' => $electronicPhone,
- 'electronicEmail' => $electronicEmail,
- );
- }
-
- if ($doPost == 1) {
-
- $mailList = array (
- 'invoice' => 1,
- 'mailItems' => $mailItems
- );
- if (! empty ( $softLock ))
- $mailList += array (
- 'softLock' => $softLockNum
- );
- else
- $mailList += array (
- 'softLock' => '0'
- );
- if (! empty ( $contract ))
- $mailList += array (
- 'contract' => $contractNum
- );
- else
- $mailList += array (
- 'contract' => '0'
- );
- if (! empty ( $instructions ))
- $mailList += array (
- 'instructions' => $instructionsNum
- );
- else
- $mailList += array (
- 'instructions' => '0'
- );
- if (! empty ( $remittance ))
- $mailList += array (
- 'remittance' => $remittance
- );
- else
- $mailList += array (
- 'remittance' => ''
- );
-
- $mailString = '发票x1,备注:' . $mailItems;
- if (! empty ( $softLock ))
- $mailString .= ',软件锁x' . $softLockNum;
- if (! empty ( $contract ))
- $mailString .= ',合同x' . $contractNum;
- if (! empty ( $instructions ))
- $mailString .= ',说明书x' . $instructionsNum;
- if (! empty ( $remittance ))
- $mailString .= ',汇款账号单';
-
- $item += array (
- 'recipients' => $recipients,
- 'recipientsPhone' => $recipientsPhone,
- 'recipientsAddress' => $recipientsAddress,
- 'mailItems' => $mailString,
- 'mailItemsJson' => json_encode ( $mailList )
- );
- }
- $invoice->setInvoiceStoreByCondition ( $item );
- }
- if(!empty($invoiceForm)&&$invoiceForm=='electronic'){
- return "/invoiceTrainingElectronicDetail/" . $trainKey . ".html";
- }else{
- return "/invoiceTrainingDetail/" . $trainKey . ".html";
- }
- }
- /**
- *
- * @return string
- */
- function invoiceStoreDelete() {
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
- $iStoreKey = $this->get_args ( 'iStoreKey' ) ? $this->get_args ( 'iStoreKey' ) : 0;
-
- $invoiceFrom = $this->get_args ( 'invoiceFrom' ) ? $this->get_args ( 'invoiceFrom' ) : "";
-
- $isid = $XDeode->decode ( $iStoreKey );
- $itid = $XDeode->decode ( $trainKey );
- if (! is_numeric ( $isid ))
- die ( 'illegal request' );
-
- Doo::loadModel ( 'invoiceStore' );
- $invoiceStore = new invoiceStore ();
-
- $invoiceStore->delete ( array (
- 'where' => 'isid=' . $isid,
- 'limit' => 1
- ) );
-
- Doo::loadModel ( 'invoiceTraining' );
- $invoiceTraining = new invoiceTraining ();
- $itDetail = $invoiceTraining->getInvoiceTrainingByItid ( $trainKey );
-
- $item = array (
- 'itid' => $itid,
- 'invoiceTotal' => $itDetail ['invoiceTotal'] - 1
- );
- $invoiceTraining->setInvoiceTrainByCondition ( $item );
-
- if(!empty($invoiceFrom)&&$invoiceFrom=='electronic'){
- return "/invoiceTrainingElectronicDetail/" . $trainKey . ".html";
- }else{
- return "/invoiceTrainingDetail/" . $trainKey . ".html";
- }
- }
-
- /**
- * 批量删除库里发票
- */
- function invoiceStoreBatchDelete() {
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
- $storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : '';
-
- $invoiceFrom = $this->get_args ( 'invoiceFrom' ) ? $this->get_args ( 'invoiceFrom' ) : "";
-
- if (empty ( $trainKey ) || empty ( $storeKey ))
- die ( 'illegal request-IdKey' );
-
- $tid = $XDeode->decode ( $trainKey );
- if (! is_numeric ( $tid ) && ! empty ( $storeKey ))
- die ( 'illegal request' );
-
- Doo::loadModel ( 'invoiceStore' );
-
- $isidKeyList = explode ( ',', $storeKey );
- $isidList = array ();
- foreach ( $isidKeyList as $value ) {
- $isid = $XDeode->decode ( $value );
- if (! empty ( $isid ) && is_numeric ( $isid ))
- array_push ( $isidList, $isid );
- }
- $isidString = implode ( ',', $isidList );
-
- $invoiceStore = new invoiceStore ();
- $isList = $invoiceStore->getInvoiceStoreInIsid ( $isidString, 'isid,apStatus' );
- $isidList = array ();
- foreach ( $isList as $key => $value ) {
- if ($value ['apStatus'] == 0)
- array_push ( $isidList, $value ['isid'] );
- }
- $isidString = implode ( ',', $isidList );
- // print_r($isList);
- // echo $isidString;
-
- $invoiceStore = new invoiceStore ();
- $invoiceStore->delete ( array (
- 'where' => "isid in ( " . $isidString . ")",
- 'asArray' => TRUE
- ) );
-
- Doo::loadModel ( 'invoiceTraining' );
- $invoiceTraining = new invoiceTraining ();
- $itDetail = $invoiceTraining->getInvoiceTrainingByItid ( $trainKey );
-
- $item = array (
- 'itid' => $tid,
- 'invoiceTotal' => $itDetail ['invoiceTotal'] - count ( $isidList )
- );
- $invoiceTraining->setInvoiceTrainByCondition ( $item );
-
- // echo $tid;
- // echo $storeKey;
- if(!empty($invoiceFrom)&&$invoiceFrom=='electronic'){
- return "/invoiceTrainingElectronicDetail/" . $trainKey . ".html";
- }else{
- return "/invoiceTrainingDetail/" . $trainKey . ".html";
- }
- }
-
- function invoiceStoreBatchElectronicPhone(){
- $electronicPhone = $this->get_args ( 'electronicPhone' ) ? $this->get_args ( 'electronicPhone' ) : '';
- $invoiceFrom = $this->get_args ( 'invoiceFrom' ) ? $this->get_args ( 'invoiceFrom' ) : "";
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
- $storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : '';
-
- if (empty ( $trainKey ) || empty ( $storeKey ))
- die ( 'illegal request-IdKey' );
-
- $isidKeyList = explode ( ',', $storeKey );
- $isidList = array ();
- foreach ( $isidKeyList as $value ) {
- $isid = $XDeode->decode ( $value );
- if (! empty ( $isid ) && is_numeric ( $isid ))
- array_push ( $isidList, $isid );
- }
- $isidString = implode ( ',', $isidList );
-
- $trainId = $XDeode->decode ( $trainKey );
-
- if (! is_numeric ( $isid ))
- die ( 'illegal request--isid' );
-
- Doo::loadModel ( 'invoiceStore' );
- $invoiceStore = new invoiceStore ();
-
- $item = array (
- 'electronicPhone' => $electronicPhone
- );
-
- $invoiceStore->setInvoiceStoreByCondition ( $item, $isidString );
-
- return "/invoiceTrainingElectronicDetail/" . $trainKey . ".html";
- }
- function invoiceStoreBatchElectronicEmail(){
- $electronicEmail = $this->get_args ( 'electronicEmail' ) ? $this->get_args ( 'electronicEmail' ) : '';
- $invoiceFrom = $this->get_args ( 'invoiceFrom' ) ? $this->get_args ( 'invoiceFrom' ) : "";
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
- $storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : '';
-
- if (empty ( $trainKey ) || empty ( $storeKey ))
- die ( 'illegal request-IdKey' );
-
- $isidKeyList = explode ( ',', $storeKey );
- $isidList = array ();
- foreach ( $isidKeyList as $value ) {
- $isid = $XDeode->decode ( $value );
- if (! empty ( $isid ) && is_numeric ( $isid ))
- array_push ( $isidList, $isid );
- }
- $isidString = implode ( ',', $isidList );
-
- $trainId = $XDeode->decode ( $trainKey );
-
- if (! is_numeric ( $isid ))
- die ( 'illegal request' );
-
- Doo::loadModel ( 'invoiceStore' );
- $invoiceStore = new invoiceStore ();
-
- $item = array (
- 'electronicEmail' => $electronicEmail
- );
-
- $invoiceStore->setInvoiceStoreByCondition ( $item, $isidString );
-
- return "/invoiceTrainingElectronicDetail/" . $trainKey . ".html";
- }
-
- /**
- * 仓库发票提交审批
- * @return string
- */
- function invoiceStoreApproval() {
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
- $iStoreKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : 0;
-
- $invoiceFrom = $this->get_args ( 'invoiceFrom' ) ? $this->get_args ( 'invoiceFrom' ) : "";
-
- $isid = $XDeode->decode ( $iStoreKey );
- $trainId = $XDeode->decode ( $trainKey );
- if (! is_numeric ( $isid ))
- die ( 'illegal request' );
-
- Doo::loadModel ( 'invoiceStore' );
-
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
-
- // 加入限制必须填写入开票内容和邮寄物品
- $invoiceStore = new invoiceStore ();
- $isDetail = $invoiceStore->getInvoiceStoreByIsid ( $isid, 'isid,trainId ,invoiceElement,mailItemsJson,electronicPhone,electronicEmail' );
- if (empty ( $isDetail ['invoiceElement'] ) || empty ( $isDetail ['mailItemsJson'] )) {
- header ( 'Content-Type:text/html;charset=utf-8' );
- die ( 'illegal request! 请设置开票内容或邮寄物品' );
- }
- if(!empty($invoiceFrom)&&$invoiceFrom=='electronic'){
-
- if (empty ( $isDetail ['electronicPhone'] ) && empty ( $isDetail ['electronicEmail'] )) {
- header ( 'Content-Type:text/html;charset=utf-8' );
- die ( 'illegal request! 请设置电子开票的收件人手机或者邮箱' );
- }
- }
-
-
- // 拷贝插入一条发票数据
- $invoiceStore = new invoiceStore ();
- $iid = $invoiceStore->setInvoiceStoreToApproval ( $isid );
-
- $invoiceStore = new invoiceStore ();
- $item = array (
- 'isid' => $isid,
- 'iid' => $iid,
- 'apStatus' => 1
- );
- $invoiceStore->setInvoiceStoreByCondition ( $item );
-
- Doo::loadModel ( 'invoiceManage' );
- $invoiceManage = new invoiceManage ();
- Doo::loadModel ( 'invoiceOperationLog' );
- $invoiceOperationLog = new invoiceOperationLog ();
-
- $invoiceManageList = $invoiceManage->getInvoiceByAll ();
- $invoiceManageDetail = $invoiceManage->getInvoiceByMold ( "发票审批" );
- $moldManage = array ();
- foreach ( $invoiceManageList as $key => $value ) {
- if ($value ['mold'] == '发票打印')
- $moldManage [$value ['mold']] = $value ['staffList'];
- elseif ($value ['mold'] == '发票邮寄')
- $moldManage [$value ['mold']] = $value ['staffList'];
- elseif ($value ['mold'] == '发票退票')
- $moldManage [$value ['mold']] = $value ['staffList'];
- }
-
- $pendingApprovalsSid = current ( $invoiceManageDetail ['staffList'] ) [0];
-
- if(!empty($invoiceFrom)&&$invoiceFrom=='electronic'){
- $invoiceSerial="#FE" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
- }else{
- $invoiceSerial="#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
- }
-
- $item = array (
- 'iid' => $iid,
- 'isid' => $isid,
- 'invoiceSerial' => $invoiceSerial,
- 'date' => date ( "Y-m-d H:i:s" ),
- 'status' => 1,
- 'updateTime' => date ( "Y-m-d H:i:s" ),
- 'trainId' => $trainId,
- 'invoiceManage' => $invoiceManageDetail ['staff'],
- 'moldManage' => json_encode ( $moldManage ),
- 'settlementType' => 1,
- 'pendingApprovals' => $pendingApprovalsSid
- );
- $invoice->setInvoiceByCondition ( $item );
-
- Doo::loadModel ( 'invoiceTraining' );
- $invoiceTraining = new invoiceTraining ();
-
- $item = array (
- 'itid' => $trainId,
- 'submitStatus' => 1
- );
- $invoiceTraining->setInvoiceTrainByCondition ( $item );
-
- $item = array (
- 'date' => date ( "Y-m-d H:i:s" ),
- 'operation' => "创建",
- 'status' => 1,
- 'img' => $this->staff [0] ['avatar'],
- 'username' => $this->staff [0] ['username'],
- 'uid' => $this->staff [0] ['sid'],
- 'category' => $this->staff [0] ['category'],
- 'iid' => $iid
- );
- $invoiceOperationLog->setInvoiceOperationLog ( $item );
- $item = array (
- 'date' => date ( "Y-m-d H:i:s" ),
- 'operation' => "提交审批",
- 'status' => 1,
- 'img' => $this->staff [0] ['avatar'],
- 'username' => $this->staff [0] ['username'],
- 'uid' => $this->staff [0] ['sid'],
- 'category' => $this->staff [0] ['category'],
- 'iid' => $iid
- );
- $invoiceOperationLog->setInvoiceOperationLog ( $item );
-
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- $username2 = $staff->getOne ( array (
- 'select' => 'wxid',
- 'where' => 'sid=' . $pendingApprovalsSid,
- 'asArray' => TRUE
- ) );
- // 发送微信审批通知
- $title2 = '[通知]用户提交了一条开票申请,快到“我的发票”中查看,给用户确认审批。';
- $this->msgSend ( '', $title2, '', $username2 ['wxid'], $pendingApprovalsSid, 'approval' );
-
- if(!empty($invoiceFrom)&&$invoiceFrom=='electronic'){
- return "/invoiceTrainingElectronicDetail/" . $trainKey . ".html";
- }else{
- return "/invoiceTrainingDetail/" . $trainKey . ".html";
- }
- }
-
- /**
- * 批量提交发票
- * @return string
- */
- function invoiceStoreBatchApproval() {
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
- $storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : 0;
-
- $invoiceFrom = $this->get_args ( 'invoiceFrom' ) ? $this->get_args ( 'invoiceFrom' ) : '';
-
- if (empty ( $trainKey ) || empty ( $storeKey ))
- die ( 'illegal request-IdKey' );
-
- $trainId = $XDeode->decode ( $trainKey );
-
- $isidKeyList = explode ( ',', $storeKey );
- $isidList = array ();
- foreach ( $isidKeyList as $value ) {
- $isid = $XDeode->decode ( $value );
- if (! empty ( $isid ) && is_numeric ( $isid ))
- array_push ( $isidList, $isid );
- }
- $isidString = implode ( ',', $isidList );
-
- if (! is_numeric ( $trainId ))
- die ( 'illegal request' );
-
- Doo::loadModel ( 'invoiceStore' );
- Doo::loadModel ( 'invoice' );
-
- // 判断哪些已经加入审批过
-
- // 加入限制必须填写入开票内容和邮寄物品
- $invoiceStore = new invoiceStore ();
- $isList = $invoiceStore->getInvoiceStoreInIsid ( $isidString, 'isid,trainId ,invoiceElement,mailItemsJson,electronicPhone,electronicEmail,invoiceForm' );
- foreach ( $isList as $key => $value ) {
- if (empty ( $value ['invoiceElement'] ) || empty ( $value ['mailItemsJson'] )) {
- header ( 'Content-Type:text/html;charset=utf-8' );
- die ( 'illegal request! 请设置开票内容或邮寄物品' );
- }
- if(!empty($invoiceFrom)&&$invoiceFrom=='electronic' ){
- $value ['electronicPhone']=trim($value ['electronicPhone']);
- $value ['electronicEmail']=trim($value ['electronicEmail']);
- if(empty ( $value ['electronicPhone'] )&&empty ( $value ['electronicEmail'] )){
- header ( 'Content-Type:text/html;charset=utf-8' );
- die ( 'illegal request! 请设置电子开票的收件人手机或者邮箱' );
- }
- }
-
- }
-
- // 拷贝插入一条发票数据
- $invoiceStore = new invoiceStore ();
- $invoiceStore->setInvoiceStoreBatchToApproval ( $isidString );
-
- $invoiceStore = new invoiceStore ();
- $item = array (
- 'apStatus' => 1
- );
- $invoiceStore->setInvoiceStoreByCondition ( $item, $isidString );
-
- // 获得正式发票ID
- $invoice = new invoice ();
- $iidList = $invoice->getInvoiceByIstoreid ( $isidString, 'iid,isid' );
-
- $sqlList = array ();
- $iidString = '';
- $iida = array ();
- foreach ( $iidList as $key => $value ) {
- $sqlList [$value ['isid']] = $value ['iid'];
- array_push ( $iida, $value ['iid'] );
- }
- $iidString = implode ( ',', $iida );
- $ids = implode ( ',', array_keys ( $sqlList ) );
- $sql = "UPDATE CLD_invoiceStore SET iid = CASE isid ";
- foreach ( $sqlList as $id => $ordinal ) {
- $sql .= sprintf ( "WHEN %d THEN %d ", $id, $ordinal );
- }
- $sql .= "END WHERE isid IN ($ids)";
-
- $invoiceStore = new invoiceStore ();
- $invoiceStore->UpdateBatchInvoiceStore ( $sql );
-
- Doo::loadModel ( 'invoiceManage' );
- $invoiceManage = new invoiceManage ();
-
- $invoiceManageList = $invoiceManage->getInvoiceByAll ();
- $invoiceManageDetail = $invoiceManage->getInvoiceByMold ( "发票审批" );
- $moldManage = array ();
- foreach ( $invoiceManageList as $key => $value ) {
- if ($value ['mold'] == '发票打印')
- $moldManage [$value ['mold']] = $value ['staffList'];
- elseif ($value ['mold'] == '发票邮寄')
- $moldManage [$value ['mold']] = $value ['staffList'];
- elseif ($value ['mold'] == '发票退票')
- $moldManage [$value ['mold']] = $value ['staffList'];
- }
-
- $pendingApprovalsSid = current ( $invoiceManageDetail ['staffList'] ) [0];
-
-
-
- // 批量更新发票信息
- $item = array (
- 'date' => date ( "Y-m-d H:i:s" ),
- 'status' => 1,
- 'updateTime' => date ( "Y-m-d H:i:s" ),
- 'trainId' => $trainId,
- 'invoiceManage' => $invoiceManageDetail ['staff'],
- 'moldManage' => json_encode ( $moldManage ),
- 'settlementType' => 1,
- 'pendingApprovals' => $pendingApprovalsSid
- );
- $invoice = new invoice ();
- $invoice->BatchInvoiceByCondition ( $item, $iidString );
- // 批量更新发票中仓库isid
- $sql = "UPDATE CLD_invoiceStore SET isid = CASE iid ";
- foreach ( $sqlList as $isid => $iid ) {
- $sql .= sprintf ( "WHEN %d THEN %d ", $iid, $isid );
- }
- $sql .= "END WHERE iid IN ($iidString)";
- $invoice = new invoice ();
- $invoice->UpdateBatchInvoice ( $sql );
-
- // 批量更新发票序列号
- $sqlList = array ();
- foreach ( $iida as $value ) {
-
- if(!empty($invoiceFrom)&&$invoiceFrom=='electronic'){
- $sqlList [$value] = "#FE" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
-
- }else{
- $sqlList [$value] = "#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
-
- }
-
-
- }
- $ids = implode ( ',', array_keys ( $sqlList ) );
- $sql = "UPDATE CLD_invoice SET invoiceSerial = CASE iid ";
- foreach ( $sqlList as $id => $ordinal ) {
- $sql .= sprintf ( "WHEN %d THEN '%s' ", $id, $ordinal );
- }
- $sql .= "END WHERE iid IN ($ids)";
- $invoiceStore = new invoiceStore ();
- $invoiceStore->UpdateBatchInvoiceStore ( $sql );
-
- // 批量生产操作日志
- Doo::loadModel ( 'invoiceOperationLog' );
-
- $sqlList = array ();
- foreach ( $iida as $key => $value ) {
- $sql = '("' . date ( "Y-m-d H:i:s" ) . '","创建","1","' . $this->staff [0] ['avatar'] . '","' . $this->staff [0] ['username'] . '","' . $this->staff [0] ['sid'] . '","' . $this->staff [0] ['category'] . '","' . $value . '"),
- ("' . date ( "Y-m-d H:i:s" ) . '","提交审批","1","' . $this->staff [0] ['avatar'] . '","' . $this->staff [0] ['username'] . '","' . $this->staff [0] ['sid'] . '","' . $this->staff [0] ['category'] . '","' . $value . '") ';
- array_push ( $sqlList, $sql );
- }
- $iolSql = implode ( ',', $sqlList );
-
- $sql = "INSERT INTO `CLD_invoiceOperationLog` (`date`, `operation`, `status`, `img`, `username`, `uid`, `category`, `iid`) VALUES " . $iolSql;
-
- $invoiceOperationLog = new invoiceOperationLog ();
- $invoiceOperationLog->setInvoiceOperationLogBySql ( $sql );
-
- Doo::loadModel ( 'invoiceTraining' );
- $invoiceTraining = new invoiceTraining ();
-
- $item = array (
- 'itid' => $trainId,
- 'submitStatus' => 1
- );
- $invoiceTraining->setInvoiceTrainByCondition ( $item );
-
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- $username2 = $staff->getOne ( array (
- 'select' => 'wxid',
- 'where' => 'sid=' . $pendingApprovalsSid,
- 'asArray' => TRUE
- ) );
- // 发送微信审批通知
- $title2 = '[通知]用户提交了一条开票申请,快到“我的发票”中查看,给用户确认审批。';
- $this->msgSend ( '', $title2, '', $username2 ['wxid'], $pendingApprovalsSid, 'approval' );
-
- if(!empty($invoiceFrom)&&$invoiceFrom=='electronic'){
- return "/invoiceTrainingElectronicDetail/" . $trainKey . ".html";
- }else{
- return "/invoiceTrainingDetail/" . $trainKey . ".html";
- }
- }
-
- /**
- */
- function invoiceStoreMailItemSet() {
- $softLock = $this->get_args ( 'softLock' ) ? $this->get_args ( 'softLock' ) : 0;
- $softLockNum = $this->get_args ( 'softLockNum' ) ? $this->get_args ( 'softLockNum' ) : 0;
- $contract = $this->get_args ( 'contract' ) ? $this->get_args ( 'contract' ) : 0;
- $contractNum = $this->get_args ( 'contractNum' ) ? $this->get_args ( 'contractNum' ) : 0;
- $instructions = $this->get_args ( 'instructions' ) ? $this->get_args ( 'instructions' ) : 0;
- $instructionsNum = $this->get_args ( 'instructionsNum' ) ? $this->get_args ( 'instructionsNum' ) : 0;
- $remittance = $this->get_args ( 'remittance' ) ? $this->get_args ( 'remittance' ) : 0;
-
- $mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
-
- $recipients = $this->get_args ( 'recipients' ) ? $this->get_args ( 'recipients' ) : "";
- $recipientsPhone = $this->get_args ( 'recipientsPhone' ) ? $this->get_args ( 'recipientsPhone' ) : "";
- $recipientsAddress = $this->get_args ( 'recipientsAddress' ) ? $this->get_args ( 'recipientsAddress' ) : "";
-
- $invoiceFrom = $this->get_args ( 'invoiceFrom' ) ? $this->get_args ( 'invoiceFrom' ) : "";
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
- $storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : '';
-
- $isid = $XDeode->decode ( $storeKey );
- $trainId = $XDeode->decode ( $trainKey );
-
- if (! is_numeric ( $isid ))
- die ( 'illegal request' );
-
- Doo::loadModel ( 'invoiceStore' );
- $invoiceStore = new invoiceStore ();
-
- $mailList = array (
- 'mailItems' => $mailItems
- );
- $mailString = '发票x1,备注:' . $mailItems;
- if(!empty($invoiceFrom)&&$invoiceFrom=='electronic'){
- $mailString = '备注:' . $mailItems;
- }else{
- $mailList += array (
- 'invoice' => 1,
- );
- }
-
-
- if (! empty ( $softLock ))
- $mailList += array (
- 'softLock' => $softLockNum
- );
- else
- $mailList += array (
- 'softLock' => 0
- );
- if (! empty ( $contract ))
- $mailList += array (
- 'contract' => $contractNum
- );
- else
- $mailList += array (
- 'contract' => 0
- );
- if (! empty ( $instructions ))
- $mailList += array (
- 'instructions' => $instructionsNum
- );
- else
- $mailList += array (
- 'instructions' => 0
- );
- if (! empty ( $remittance ))
- $mailList += array (
- 'remittance' => $remittance
- );
- else
- $mailList += array (
- 'remittance' => ''
- );
-
-
- if (! empty ( $softLock ))
- $mailString .= ',软件锁x' . $softLockNum;
- if (! empty ( $contract ))
- $mailString .= ',合同x' . $contractNum;
- if (! empty ( $instructions ))
- $mailString .= ',说明书x' . $instructionsNum;
- if (! empty ( $remittance ))
- $mailString .= ',汇款账号单';
-
- $item = array (
- 'isid' => $isid,
- 'doPost' => 1,
- 'mailItems' => $mailString,
- 'mailItemsJson' => json_encode ( $mailList )
- );
-
- $invoiceStore->setInvoiceStoreByCondition ( $item );
-
- if(!empty($invoiceFrom)&&$invoiceFrom=='electronic'){
- return "/invoiceTrainingElectronicDetail/" . $trainKey . ".html";
- }else{
- return "/invoiceTrainingDetail/" . $trainKey . ".html";
- }
-
-
- }
-
- /**
- * 批量设置邮寄物品
- */
- function invoiceStoreBatchMailItemSet() {
- $softLock = $this->get_args ( 'softLock' ) ? $this->get_args ( 'softLock' ) : 0;
- $softLockNum = $this->get_args ( 'softLockNum' ) ? $this->get_args ( 'softLockNum' ) : 0;
- $contract = $this->get_args ( 'contract' ) ? $this->get_args ( 'contract' ) : 0;
- $contractNum = $this->get_args ( 'contractNum' ) ? $this->get_args ( 'contractNum' ) : 0;
- $instructions = $this->get_args ( 'instructions' ) ? $this->get_args ( 'instructions' ) : 0;
- $instructionsNum = $this->get_args ( 'instructionsNum' ) ? $this->get_args ( 'instructionsNum' ) : 0;
- $remittance = $this->get_args ( 'remittance' ) ? $this->get_args ( 'remittance' ) : 0;
-
- $mailItems = $this->get_args ( 'mailItems' ) ? $this->get_args ( 'mailItems' ) : "";
-
- $recipients = $this->get_args ( 'recipients' ) ? $this->get_args ( 'recipients' ) : "";
- $recipientsPhone = $this->get_args ( 'recipientsPhone' ) ? $this->get_args ( 'recipientsPhone' ) : "";
- $recipientsAddress = $this->get_args ( 'recipientsAddress' ) ? $this->get_args ( 'recipientsAddress' ) : "";
-
- $invoiceFrom = $this->get_args ( 'invoiceFrom' ) ? $this->get_args ( 'invoiceFrom' ) : "";
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $trainKey = $this->get_args ( 'trainKey' ) ? $this->get_args ( 'trainKey' ) : '';
- $storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : '';
-
- if (empty ( $trainKey ) || empty ( $storeKey ))
- die ( 'illegal request-IdKey' );
-
- $isidKeyList = explode ( ',', $storeKey );
- $isidList = array ();
- foreach ( $isidKeyList as $value ) {
- $isid = $XDeode->decode ( $value );
- if (! empty ( $isid ) && is_numeric ( $isid ))
- array_push ( $isidList, $isid );
- }
- $isidString = implode ( ',', $isidList );
-
- $trainId = $XDeode->decode ( $trainKey );
-
- if (! is_numeric ( $isid ))
- die ( 'illegal request' );
-
- Doo::loadModel ( 'invoiceStore' );
- $invoiceStore = new invoiceStore ();
-
-
- $mailList = array (
- 'mailItems' => $mailItems
- );
- $mailString = '发票x1,备注:' . $mailItems;
- if(!empty($invoiceFrom)&&$invoiceFrom=='electronic'){
- $mailString = '备注:' . $mailItems;
- }else{
- $mailList += array (
- 'invoice' => 1,
- );
- }
-
-
- if (! empty ( $softLock ))
- $mailList += array (
- 'softLock' => $softLockNum
- );
- else
- $mailList += array (
- 'softLock' => 0
- );
- if (! empty ( $contract ))
- $mailList += array (
- 'contract' => $contractNum
- );
- else
- $mailList += array (
- 'contract' => 0
- );
- if (! empty ( $instructions ))
- $mailList += array (
- 'instructions' => $instructionsNum
- );
- else
- $mailList += array (
- 'instructions' => 0
- );
- if (! empty ( $remittance ))
- $mailList += array (
- 'remittance' => $remittance
- );
- else
- $mailList += array (
- 'remittance' => ''
- );
-
-
- if (! empty ( $softLock ))
- $mailString .= ',软件锁x' . $softLockNum;
- if (! empty ( $contract ))
- $mailString .= ',合同x' . $contractNum;
- if (! empty ( $instructions ))
- $mailString .= ',说明书x' . $instructionsNum;
- if (! empty ( $remittance ))
- $mailString .= ',汇款账号单';
-
- $item = array (
- 'doPost' => 1,
- 'mailItems' => $mailString,
- 'mailItemsJson' => json_encode ( $mailList )
- );
-
- $invoiceStore->setInvoiceStoreByCondition ( $item, $isidString );
- if(!empty($invoiceFrom)&&$invoiceFrom=='electronic'){
- return "/invoiceTrainingElectronicDetail/" . $trainKey . ".html";
- }else{
- return "/invoiceTrainingDetail/" . $trainKey . ".html";
- }
-
- }
-
- /**
- * 废弃
- */
- function ajaxGetMailItemByIstore() {
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- $storeKey = $this->get_args ( 'storeKey' ) ? $this->get_args ( 'storeKey' ) : '';
- $isid = $XDeode->decode ( $storeKey );
-
- if (! is_numeric ( $isid ))
- die ( 'illegal request' );
-
- Doo::loadModel ( 'invoiceStore' );
- $invoiceStore = new invoiceStore ();
-
- $isDetail = $invoiceStore->getInvoiceStoreByIsid ( $isid );
-
- $isDetail ['mailItemsJson'] = json_decode ( $isDetail ['mailItemsJson'], true );
-
- echo json_encode ( $isDetail ['mailItemsJson'] );
- exit ();
- }
-
- /**
- * 终止开票
- */
- function invoiceDroppedDo() {
- $droppedIidKey = $this->get_args ( 'droppedIidKey' ) ? $this->get_args ( 'droppedIidKey' ) : '';
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'invoiceOperationLog' );
- $invoiceOperationLog = new invoiceOperationLog ();
-
- $iid = $invoice->authcode ( $droppedIidKey );
- if (! empty ( $iid ) && ! is_numeric ( $iid ))
- die ( 'illegal request' );
-
- $item = array (
- 'iid' => $iid,
- 'status' => 4,
- 'updateTime' => date ( "Y-m-d H:i:s" )
- );
- $invoice->setInvoiceByCondition ( $item );
- $item = array (
- 'date' => date ( "Y-m-d H:i:s" ),
- 'operation' => '终止了开票',
- 'status' => 4,
- 'img' => $this->staff [0] ['avatar'],
- 'username' => $this->staff [0] ['username'],
- 'uid' => $this->staff [0] ['sid'],
- 'category' => $this->staff [0] ['category'],
- 'iid' => $iid
- );
- $invoiceOperationLog->setInvoiceOperationLog ( $item );
- return "/invoice";
- }
-
- /**
- * 更新退票的邮寄信息
- */
- function invoiceUntreadMailDo() {
- $untreadIidKey = $this->get_args ( 'untreadIidKey' ) ? $this->get_args ( 'untreadIidKey' ) : '';
- $untreadCompany = $this->get_args ( 'untreadCompany' ) ? $this->get_args ( 'untreadCompany' ) : "";
- $untreadNumber = $this->get_args ( 'untreadNumber' ) ? $this->get_args ( 'untreadNumber' ) : "";
- $untreadItems = $this->get_args ( 'untreadItems' ) ? $this->get_args ( 'untreadItems' ) : "";
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
-
- $iid = $invoice->authcode ( $untreadIidKey );
- if (! empty ( $iid ) && ! is_numeric ( $iid ))
- die ( 'illegal request' );
-
- $item = array (
- 'iid' => $iid,
- 'untreadCompany' => $untreadCompany,
- 'untreadNumber' => $untreadNumber,
- 'untreadItems' => $untreadItems
- );
-
- $invoice->setInvoiceByCondition ( $item );
-
- return "/invoice";
- }
- /**
- * 申请退票 --
- */
- function invoiceUntreadDo() {
- $untreadIidKey = $this->get_args ( 'untreadIidKey' ) ? $this->get_args ( 'untreadIidKey' ) : '';
- $untreadReason = $this->get_args ( 'untreadReason' ) ? $this->get_args ( 'untreadReason' ) : "";
- $untreadPost = $this->get_args ( 'untreadPost' ) ? $this->get_args ( 'untreadPost' ) : 0;
-
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'invoiceOperationLog' );
- $invoiceOperationLog = new invoiceOperationLog ();
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
-
- $iid = $invoice->authcode ( $untreadIidKey );
- if (! empty ( $iid ) && ! is_numeric ( $iid ))
- die ( 'illegal request' );
-
- /*
- * 需求变革 有绑定收款也可以退票 $lt = $invoiceReceivables->getInvoiceReceivablesByIid ( $untreadIidKey ); if (! empty ( $lt )) { header ( 'Content-Type:text/html;charset=utf-8' ); die ( '该发票有收款绑定,请先移除!' ); }
- */
-
- $item = array (
- 'iid' => $iid,
- 'untreadStatus' => 1,
- 'untreadReason' => $untreadReason,
- 'untreadPost' => $untreadPost,
- 'updateTime' => date ( "Y-m-d H:i:s" )
- );
-
- $invoice->setInvoiceByCondition ( $item );
- $item = array (
- 'date' => date ( "Y-m-d H:i:s" ),
- 'operation' => '申请退票',
- 'status' => 7,
- 'img' => $this->staff [0] ['avatar'],
- 'username' => $this->staff [0] ['username'],
- 'uid' => $this->staff [0] ['sid'],
- 'category' => $this->staff [0] ['category'],
- 'iid' => $iid
- );
- $invoiceOperationLog->setInvoiceOperationLog ( $item );
-
- return "/invoice";
- }
-
- /**
- * 删除已终止的开票
- */
- function invoiceDelDo() {
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'invoiceOperationLog' );
- $invoiceOperationLog = new invoiceOperationLog ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- $sid = $XDeode->decode ( $_COOKIE ["staff"] );
- $iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
- $iid = $XDeode->decode ( $iid );
- Doo::loadModel ( 'invoiceStore' );
- $invoiceStore = new invoiceStore ();
-
- if (! is_numeric ( $iid ))
- die ( 'illegal request' );
- $invoiceDetail = $invoice->getMyInvoice ( $sid, $iid );
- if (empty ( $invoiceDetail ))
- die ( 'illegal request' );
- $item = array (
- 'iid' => $iid,
- 'isDelete' => 1,
- 'updateTime' => date ( "Y-m-d H:i:s" )
- );
- $invoice->setInvoiceByCondition ( $item );
- $item = array (
- 'date' => date ( "Y-m-d H:i:s" ),
- 'operation' => '删除了已终止的发票',
- 'status' => 4,
- 'img' => $this->staff [0] ['avatar'],
- 'username' => $this->staff [0] ['username'],
- 'uid' => $this->staff [0] ['sid'],
- 'category' => $this->staff [0] ['category'],
- 'iid' => $iid
- );
- $invoiceOperationLog->setInvoiceOperationLog ( $item );
- // 删除培训班发票仓库里的发票
- $invoiceStore->delInvoiceStoreByIsid ( $invoiceDetail ['isid'] );
- return "/invoice";
- }
- /**
- */
- function invoiceApproval() {
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- $invoiceList = $invoice->find ( array (
- 'where' => 'status=1 and pendingApprovals=' . $this->staff [0] ['sid'],
- 'desc' => 'iid',
- 'limit' => 10,
- 'asArray' => true
- ) );
- foreach ( $invoiceList as $key => $value ) {
- $invoiceList [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
-
- $lastApprover = json_decode ( $value ['processApprovals'], true );
- if (! empty ( $lastApprover )) {
- $lastApproverKey = array_keys ( $lastApprover );
- $lastApprover = end ( $lastApprover );
-
- $staffDetail = $staff->getOne ( array (
- 'where' => 'sid=' . end ( $lastApproverKey ),
- 'asArray' => true
- ) );
- $lastApprover ['username'] = $staffDetail ['username'];
- }
- $invoiceList [$key] ['lastApprover'] = $lastApprover;
- }
-
- $ilist = $invoice->getInvoiceByProcessStatus ();
- foreach ( $ilist as $key => $value ) {
- $ilist [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
-
- $lastApprover = json_decode ( $value ['processApprovals'], true );
- if (! empty ( $lastApprover )) {
- $lastApproverKey = array_keys ( $lastApprover );
- $lastApprover = end ( $lastApprover );
-
- $staffDetail = $staff->getOne ( array (
- 'where' => 'sid=' . end ( $lastApproverKey ),
- 'asArray' => true
- ) );
- $lastApprover ['username'] = $staffDetail ['username'];
- }
- $ilist [$key] ['lastApprover'] = $lastApprover;
- }
-
- // print_r($ilist);
-
- $this->data ['invoiceList'] = $invoiceList;
- $this->data ['ilist'] = $ilist;
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoiceApproval';
- $this->render ( "/admin/invoiceApproval", $this->data );
- }
- function invoiceDetail() {
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
- $iid = $XDeode->decode ( $iid );
- if (! is_numeric ( $iid ))
- die ( 'illegal request' );
-
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'invoiceOperationLog' );
- $invoiceOperationLog = new invoiceOperationLog ();
-
- $invoiceDetail = $invoice->getOne ( array (
- 'where' => 'status=1 and pendingApprovals=' . $this->staff [0] ['sid'] . ' and iid=' . $iid,
- 'asArray' => true
- ) );
- if (empty ( $invoiceDetail ))
- die ( 'illegal request' );
-
- if ($invoiceDetail ['settlementType'] == 1) {
- Doo::loadModel ( 'invoiceTraining' );
- $invoiceTraining = new invoiceTraining ();
- $invoiceDetail ['invoiceTraining'] = $invoiceTraining->getInvoiceTrainingByItid ( $invoiceDetail ['trainId'] );
- }
-
- $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $iid );
-
- $this->data ['invoiceDetail'] = $invoiceDetail;
- $this->data ['invoiceOperationLogList'] = $invoiceOperationLogList;
- $this->data ['INVOICEKEY'] = $invoice->authcode ( $invoiceDetail ['iid'], '' );
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoiceApproval';
- $this->render ( "/admin/invoiceApprovalDetail", $this->data );
- }
-
- /**
- * 对发票进行审批,其中操作有终止,退回,同意动作。操作成功并记录下操作日志
- *
- * @since 1.0.0
- * @var integer iid 开票ID 已加密
- * @var integer status 发票审批状态
- * @var integer opintion 审批发票的意见
- * @return string 如操作成功返回审批首页
- */
- function invoiceApprovalDo() {
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
-
- $iid = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
- $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
- $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
-
- $divApproval = $this->get_args ( 'divApproval' ) ? $this->get_args ( 'divApproval' ) : "";
-
- $iid = $invoice->authcode ( $iid );
- if (! is_numeric ( $iid ))
- die ( 'illegal request' );
- // && ! empty ( $opinion )
- if (! empty ( $iid ) && ! empty ( $status )) {
- if (! ($status == 2 || $status == 3 || $status == 4))
- die ( 'illegal request' );
-
- Doo::loadModel ( 'invoiceOperationLog' );
- $invoiceOperationLog = new invoiceOperationLog ();
-
- $invoiceDetail = $invoice->getOne ( array (
- 'where' => 'status=1 and iid=' . $iid . ' and pendingApprovals=' . $this->staff [0] ['sid'],
- 'asArray' => true
- ) );
- if (empty ( $invoiceDetail ))
- die ( 'illegal request' );
-
- $processApprovals = json_decode ( $invoiceDetail ['processApprovals'], true );
- $invoiceManage = json_decode ( $invoiceDetail ['invoiceManage'], true );
-
- if ($status == 3) {
- $invoice->status = $status;
- $item = array (
- 'operation' => $opinion
- );
- } else {
- if (empty ( $processApprovals )) {
- $processApprovals = array (
- $this->staff [0] ['sid'] => array (
- 'date' => date ( "Y-m-d H:i:s" ),
- 'opinion' => $opinion,
- 'status' => $status
- )
- );
- // var_dump(next($invoiceManage));
- $nextInvoiceManage = next ( $invoiceManage );
-
- // print_r($nextInvoiceManage);
- if ($status != 4 && $nextInvoiceManage !== false)
- $invoice->pendingApprovals = $nextInvoiceManage [0];
- $invoice->processApprovals = json_encode ( $processApprovals );
- // var_dump($invoice);
- // print_r($invoiceManage);
- } else {
- $processApprovals [$this->staff [0] ['sid']] = array (
- 'date' => date ( "Y-m-d H:i:s" ),
- 'opinion' => $opinion,
- 'status' => $status
- );
-
- $pendingApprovals = 0;
- foreach ( $invoiceManage as $key => $value ) {
- if ($value [0] == $this->staff [0] ['sid']) {
- if (isset ( $invoiceManage [$key + 1] ))
- $pendingApprovals = $invoiceManage [$key + 1] [0];
- break;
- }
- }
-
- if ($status != 4 && ! empty ( $pendingApprovals ))
- $invoice->pendingApprovals = $pendingApprovals;
- $invoice->processApprovals = json_encode ( $processApprovals );
- }
-
- $item = array (
- 'operation' => $opinion
- );
- if (count ( $processApprovals ) == count ( $invoiceManage ) && $status != 4) {
- $invoice->status = $status;
- $invoice->pendingApprovals = 0;
- $invoice->approvalTime = date ( "Y-m-d H:i:s" );
- } elseif ($status == 4) {
- $invoice->status = $status;
- $item = array (
- 'operation' => $opinion
- );
- }
- }
- $invoice->updateTime = date ( "Y-m-d H:i:s" );
- $invoice->update ( array (
- 'where' => 'iid=' . $iid
- ) );
-
- $item += array (
- 'date' => date ( "Y-m-d H:i:s" ),
- 'img' => $this->staff [0] ['avatar'],
- 'username' => $this->staff [0] ['username'],
- 'uid' => $this->staff [0] ['sid'],
- 'category' => $this->staff [0] ['category'],
- 'status' => $status,
- 'iid' => $iid
- );
- $invoiceOperationLog->setInvoiceOperationLog ( $item );
- if (empty ( $divApproval ))
- return '/invoiceApproval';
- else
- return '/invoiceApprovalAchieve/PEND';
- }
- die ( 'illegal request' );
- }
-
- /**
- * 展示需要打印的发票数据
- *
- * @since 1.0.0
- */
- function invoicePrint() {
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- $toPrint = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 0 );
- $printed = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 1 );
-
- foreach ( $toPrint as $key => $value ) {
- $toPrint [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
-
- $lastApprover = json_decode ( $value ['processApprovals'], true );
- if (! empty ( $lastApprover )) {
- $lastApproverKey = array_keys ( $lastApprover );
- $lastApprover = end ( $lastApprover );
-
- $staffDetail = $staff->getOne ( array (
- 'where' => 'sid=' . end ( $lastApproverKey ),
- 'asArray' => true
- ) );
- $lastApprover ['username'] = $staffDetail ['username'];
- }
- $toPrint [$key] ['lastApprover'] = $lastApprover;
- }
-
- foreach ( $printed as $key => $value ) {
- $printed [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
-
- $lastApprover = json_decode ( $value ['processApprovals'], true );
- if (! empty ( $lastApprover )) {
- $lastApproverKey = array_keys ( $lastApprover );
- $lastApprover = end ( $lastApprover );
-
- $staffDetail = $staff->getOne ( array (
- 'where' => 'sid=' . end ( $lastApproverKey ),
- 'asArray' => true
- ) );
- $lastApprover ['username'] = $staffDetail ['username'];
- }
- $printed [$key] ['lastApprover'] = $lastApprover;
- }
-
- $this->data ['printed'] = $printed;
- $this->data ['toPrint'] = $toPrint;
-
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoicePrint';
- $this->render ( "/admin/invoicePrint", $this->data );
- }
- /**
- * 展示发票打印的详情页面
- *
- * @since 1.0.0
- */
- function invoicePrintDetail() {
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $iid = isset ( $this->params ['iid'] ) ? $this->params ['iid'] : "";
- $iid = $XDeode->decode ( $iid );
- if (! is_numeric ( $iid ))
- die ( 'illegal request' );
-
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'invoiceOperationLog' );
- $invoiceOperationLog = new invoiceOperationLog ();
- Doo::loadModel ( 'invoicePaper' );
- $invoicePaper = new invoicePaper ();
-
- $invoiceDetail = $invoice->getPrintInvoiceByManage ( $this->staff [0] ['sid'], 0, $iid );
- if (empty ( $invoiceDetail ))
- die ( 'illegal request' );
-
- $invoicePaperList = $invoicePaper->getInvoicePaperByInvoiceType ( $invoiceDetail ['invoiceType'],$invoiceDetail['invoiceForm'] );
- $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $iid );
-
- if ($invoiceDetail ['settlementType'] == 1) {
- Doo::loadModel ( 'invoiceTraining' );
- $invoiceTraining = new invoiceTraining ();
- $invoiceDetail ['invoiceTraining'] = $invoiceTraining->getInvoiceTrainingByItid ( $invoiceDetail ['trainId'] );
- }
-
- $this->data ['invoicePaperList'] = $invoicePaperList;
- $this->data ['invoiceDetail'] = $invoiceDetail;
- $this->data ['invoiceOperationLogList'] = $invoiceOperationLogList;
- $this->data ['INVOICEKEY'] = $invoice->authcode ( $invoiceDetail ['iid'], '' );
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoicePrint';
- $this->render ( "/admin/invoicePrintDetail", $this->data );
- }
-
- /**
- * 所有待打印 发票
- */
- function invoicePrintStayAchieve() {
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- $MebSea = $this->get_args ( 'MebSea' ) ? urldecode ( $this->get_args ( 'MebSea' ) ) : "";
-
- $invoiceType = $this->get_args ( 'invoiceType' ) ? $this->get_args ( 'invoiceType' ) : "ALL";
- $invoiceTrain = $this->get_args ( 'invoiceTrain' ) ? $this->get_args ( 'invoiceTrain' ) : "ALL";
- $invoiceTrainName = $this->get_args ( 'invoiceTrainName' ) ? $this->get_args ( 'invoiceTrainName' ) : "ALL";
-
- Doo::loadModel ( 'invoiceTraining' );
- $invoiceTraining = new invoiceTraining ();
- $trainList = $invoiceTraining->getInvoiceTrainingBySubmitStatus ();
-
- $page_size = 12;
- $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
-
- $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : "ALL";
- // $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : "ALL";
-
- $get = "/" . $status;
- $con = ' and status=2 ';
- if ($status == 'TOPRINT')
- $con = ' and status=2 and printStatus=0 ';
- elseif ($status == 'PRINTED')
- $con = ' and status=2 and printStatus=1';
-
- if ($invoiceType == 'ORDINARY')
- $con .= ' and invoiceType=0 and invoiceForm=0 ';
- elseif ($invoiceType == 'SPECIAL'){
- $con .= ' and invoiceType=1 ';
- }elseif($invoiceType == 'ELECTRON'){
- $con .= ' and invoiceType=0 and invoiceForm=1 ';
- }
-
- if ($invoiceTrain == 'ORDINARY')
- $con .= ' and trainId=0 ';
- elseif ($invoiceTrain == 'TRAIN')
- $con .= ' and trainId!=0 ';
-
- if ($invoiceTrainName != 'ALL') {
- $trainId = $XDeode->decode ( $invoiceTrainName );
- if (is_numeric ( $trainId ))
- $con .= ' and trainId =' . $trainId;
- }
-
- $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
- $dateArr = explode ( ':', $date );
- $D1 = '';
- $D2 = '';
- if (! empty ( $date )) {
- $D1 = $dateArr [0];
- $D2 = $dateArr [1];
- }
-
- if (! empty ( $D1 ) && ! empty ( $D2 ) && ! empty ( $date )){
- $D1= $D1.":00.00.00";
- $D2= $D2.":23.59.59";
- $con .= ' and printTime BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
- }
-
-
- if (! empty ( $MebSea )) {
- $con .= ' and ( invoiceNo like "%' . $MebSea . '%" or invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" or invoiceNo like "%' . $MebSea . '%" )';
- }
- $pageinfo ['page'] = array (
- 'previous' => ''
- );
-
- $get .= "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea ) . "&invoiceType=" . urlencode ( $invoiceType ) . "&invoiceTrain=" . urlencode ( $invoiceTrain ) . "";
-
- $sql = " (untreadStatus=0 or untreadStatus=3 or untreadStatus=4) and moldManage like '%[\"" . $this->staff [0] ['sid'] . "\",%'" . $con;
- $action = "invoicePrintStayAchieve";
- //echo $sql;
- $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, $action, $get, "" );
- $limit = $pageinfo ['lower'] . ',' . $page_size;
- $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql, 'desc', 5 );
-
- $this->data ['trainList'] = $trainList;
-
- $this->data ['invoiceType'] = $invoiceType;
- $this->data ['invoiceTrain'] = $invoiceTrain;
- $this->data ['invoiceTrainName'] = $invoiceTrainName;
-
- $this->data ['MebSeaEn'] = $MebSea;
- $this->data ['MebSea'] = urlencode ( $MebSea );
- $this->data ['get'] = $get;
- $this->data ['page'] = $pageinfo;
- $this->data ['date'] = $date;
- $this->data ['status'] = $status;
- $this->data ['invoiceType'] = $invoiceType;
-
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
-
- foreach ( $list as $key => $value ) {
- $list [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
-
- $lastApprover = json_decode ( $value ['processApprovals'], true );
- if (! empty ( $lastApprover )) {
- $lastApproverKey = array_keys ( $lastApprover );
- $lastApprover = end ( $lastApprover );
-
- $staffDetail = $staff->getOne ( array (
- 'where' => 'sid=' . end ( $lastApproverKey ),
- 'asArray' => true
- ) );
- $lastApprover ['username'] = $staffDetail ['username'];
- }
- $list [$key] ['lastApprover'] = $lastApprover;
- }
- $this->data ['receiptMemu'] = 'invoicePrint';
- $this->data ['list'] = $list;
- $this->render ( "/admin/invoicePrintStayAchieve", $this->data );
- }
-
- /**
- * 填写票号并完成打印
- * @since 1.0.0
- */
- function invoicePrintDo() {
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- $iid = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
- $invoiceNo = $this->get_args ( 'invoiceNo' ) ? $this->get_args ( 'invoiceNo' ) : "";
- $invoicePrintType = $this->get_args ( 'invoicePrintType' ) ? $this->get_args ( 'invoicePrintType' ) : "";
-
- $iid = $invoice->authcode ( $iid );
- if (! is_numeric ( $iid ))
- die ( 'illegal request-iid' );
- if (! empty ( $iid ) && ! empty ( $invoiceNo )) {
-
- Doo::loadModel ( 'invoiceOperationLog' );
- $invoiceOperationLog = new invoiceOperationLog ();
- Doo::loadModel ( 'invoiceStatistics' );
- $invoiceStatistics = new invoiceStatistics ();
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'invoicePaper' );
- $invoicePaper = new invoicePaper ();
-
- $invoicePrintDetail = $invoice->getInvoiceByPrint ( $iid );
- if (empty ( $invoicePrintDetail ))
- die ( 'illegal request-data_empty' );
-
- //
- $ipid = $XDeode->decode ( $invoiceNo );
- $paperDetail = $invoicePaper->getInvoicePaperByIpid ( $ipid );
- if (empty ( $paperDetail ))
- die ( 'illegal request-paper_empty' );
- $invoicePaper = new invoicePaper ();
- $item = array (
- 'iid' => $iid,
- 'ipid' => $ipid
- );
- $invoicePaper->setInvoicePaperByCondition ( $item );
-
- $item = array (
- 'iid' => $iid,
- 'printStatus' => 1,
- 'updateTime' => date ( "Y-m-d H:i:s" ),
- 'printer' => $this->staff [0] ['username'],
- 'printTime' => date ( "Y-m-d H:i:s" ),
- 'invoiceNo' => $paperDetail ['invoiceNo']
- );
- $invoice->setInvoiceByCondition ( $item );
- $item = array (
- 'date' => date ( "Y-m-d H:i:s" ),
- 'operation' => '打印发票号:' . $paperDetail ['invoiceNo'],
- 'status' => 5,
- 'img' => $this->staff [0] ['avatar'],
- 'username' => $this->staff [0] ['username'],
- 'uid' => $this->staff [0] ['sid'],
- 'category' => $this->staff [0] ['category'],
- 'iid' => $iid
- );
- $invoiceOperationLog->setInvoiceOperationLog ( $item );
-
- // 去统计--负票不汇总
- if ($invoicePrintDetail ['untreadStatus'] != 4) {
- $item = array (
- 'date' => date ( "Y-m-d H:i:s" ),
- 'priceClass' => 1,
- 'cid' => $invoicePrintDetail ['cid'],
- 'staff' => $invoicePrintDetail ['sid'],
- 'invoicePrice' => $invoicePrintDetail ['invoicePrice']
- );
- $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
- }
- // 发送通知信息到微信-去除
- // $this->setWXMsg($iid,'PRINT');
-
- // 发票信息库
- $this->autoUpdateInvoiceInfoBase ( $invoicePrintDetail );
-
- // 申请人获取微信通知
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- $username2 = $staff->getOne ( array (
- 'select' => 'wxid',
- 'where' => 'sid=' . $invoicePrintDetail ['sid'],
- 'asArray' => TRUE
- ) );
- $title2 = '[结果]您的发票' . $invoicePrintDetail ['invoiceSerial'] . '完成打印';
-
- $msg = '';
- $url = 'http://m.cld.smartcost.com.cn/invoicePrintDetail/' . $XDeode->encode ( $invoicePrintDetail ['iid'] ) . '.html';
- $hfreult = $this->msgSend ( $msg, $title2, $url, $username2 ['wxid'], $invoicePrintDetail ['sid'], 'print' );
- if (empty ( $invoicePrintType ))
- return "/invoicePrint";
- else
- return "/invoicePrintStayAchieve";
- }
- }
-
- /**
- * 需要邮寄的发票
- * @since 1.0.0
- */
- function invoicePost() {
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'express' );
- $express = new express ();
-
- $invoicePost = $invoice->getPostByInvoice ();
- $invoicePosted = $invoice->getPostByInvoice ( 1 );
- $expressList = $express->getExpressByAll ();
-
- $invoicePostExpress = "";
- if (isset ( $_COOKIE ["invoicePostExpress"] ))
- $invoicePostExpress = $_COOKIE ["invoicePostExpress"];
- $this->data ['invoicePostExpress'] = $invoicePostExpress;
-
- $this->data ['expressList'] = $expressList;
- $this->data ['invoicePost'] = $invoicePost;
- $this->data ['invoicePosted'] = $invoicePosted;
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoicePost';
- $this->render ( "/admin/invoicePost", $this->data );
- }
- /**
- * 添加发票邮寄信息
- */
- function invoiceExpressAddDo() {
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
-
- $iid = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
- $expressCompany = $this->get_args ( 'express' ) ? $this->get_args ( 'express' ) : "";
- $expressNumber = $this->get_args ( 'nu' ) ? $this->get_args ( 'nu' ) : "";
- $actualItems = $this->get_args ( 'actualItems' ) ? $this->get_args ( 'actualItems' ) : "";
- $iid = $iid = $invoice->authcode ( $iid );
- if (! is_numeric ( $iid ) && empty ( $expressCompany ) && empty ( $expressNumber ) && empty ( $actualItems ))
- die ( 'illegal request' );
-
- $invoicePrintDetail = $invoice->getInvoiceByIid ( $iid );
-
- setcookie ( 'invoicePostExpress', $expressNumber );
-
- $item = array (
- 'iid' => $iid,
- 'postStatus' => 1,
- 'updateTime' => date ( "Y-m-d H:i:s" ),
- 'postTime' => date ( "Y-m-d H:i:s" ),
- 'expressCompany' => $expressCompany,
- 'expressNumber' => $expressNumber,
- 'actualItems' => $actualItems,
- 'poster' => $this->staff [0] ['username']
- );
- $invoice->setInvoiceByCondition ( $item );
-
- // 微信通知-去掉
- // $this->setWXMsg ( $iid );
-
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- $username2 = $staff->getOne ( array (
- 'select' => 'wxid',
- 'where' => 'sid=' . $invoicePrintDetail ['sid'],
- 'asArray' => TRUE
- ) );
- $title2 = '[结果]您的发票' . $invoicePrintDetail ['invoiceSerial'] . '已邮寄';
-
- $expCom = explode ( ":", $invoicePrintDetail ['expressCompany'] );
- if (empty ( $expCom ))
- $expCom [0] = '';
-
- $msg = $expCom [0] . ':' . $invoicePrintDetail ['expressNumber'] . '';
-
- $url = 'https://m.kuaidi100.com/result.jsp?nu=' . $invoicePrintDetail ['expressNumber'];
- $hfreult = $this->msgSend ( $msg, $title2, $url, $username2 ['wxid'], $invoicePrintDetail ['sid'], 'print' );
-
- return '/invoicePost';
- }
- function invoiceExpressUpdateDo() {
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
-
- $action = $this->get_args ( 'action' ) ? $this->get_args ( 'action' ) : "";
-
- $iid = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
- $expressCompany = $this->get_args ( 'express' ) ? $this->get_args ( 'express' ) : "";
- $expressNumber = $this->get_args ( 'nu' ) ? $this->get_args ( 'nu' ) : "";
- $actualItems = $this->get_args ( 'actualItems' ) ? $this->get_args ( 'actualItems' ) : "";
- $iid = $invoice->authcode ( $iid );
- if (! is_numeric ( $iid ) && empty ( $expressCompany ) && empty ( $expressNumber ) && empty ( $actualItems ))
- die ( 'illegal request' );
-
- $item = array (
- 'iid' => $iid,
- 'updateTime' => date ( "Y-m-d H:i:s" ),
-
- 'expressCompany' => $expressCompany,
- 'expressNumber' => $expressNumber,
- 'actualItems' => $actualItems,
- 'poster' => $this->staff [0] ['username']
- );
-
- $invoice->setInvoiceByCondition ( $item );
- return $action;
- }
-
- /**
- * 可退票管理
- */
- function invoiceUntreadIsAchieve() {
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
-
- $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : "";
-
- /*
- * Doo::loadClass ( 'XDeode' ); $XDeode = new XDeode ( 5 ); $page_size = 18; $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1; $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : ""; $get = "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea ); $dateArr = explode ( ':', $date ); $D1 = ''; $D2 = ''; if (! empty ( $date )) { $D1 = $dateArr [0]; $D2 = $dateArr [1]; } $con = ''; if (! empty ( $D1 ) && ! empty ( $D2 )) $con = ' and bindTime BETWEEN "' . $D1 . '" AND "' . $D2 . '" '; // if ($date == 'MONTHO') // $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)'; // elseif ($date == 'MONTHT') // $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)'; // elseif ($date == 'MONTHY') // $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)'; if (! empty ( $MebSea )) { $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )'; } $pageinfo ['page'] = array ( 'previous' => '' );
- */
- if (empty ( $MebSea )) {//
- $con = ' and invoiceNo like "NULL" ';
- } else {
- $con = ' and (invoiceNo like "%' . $MebSea . '%" or invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" )';
- }
- // printStatus=1 and
- $sql = " (untreadStatus=0 or untreadStatus=3) and status=2 and sid=" . $this->staff [0] ['sid'] . $con;
-
- /*
- * $action = "invoiceUntreadIsAchieve"; $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, $action, $get, "" ); $limit = $pageinfo ['lower'] . ',' . $page_size;
- */
- $limit = '0,50';
- $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
-
- //print_r($list);
- $this->data ['MebSeaEn'] = $MebSea;
- /*
- * $this->data ['get'] = $get; $this->data ['page'] = $pageinfo; $this->data ['date'] = $date;
- */
- $this->data ['list'] = $list;
-
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoice';
-
- $this->render ( "/admin/invoiceUntreadIsAchieve", $this->data );
- }
-
- // 已经退票的发票
- function invoiceUntreadED() {
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
-
- $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : "";
- $invoiceType = $this->get_args ( 'invoiceType' ) ? $this->get_args ( 'invoiceType' ) : "";
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- $page_size = 18;
- $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
- $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
- $get = "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
-
- $dateArr = explode ( ':', $date );
- $D1 = '';
- $D2 = '';
- if (! empty ( $date )) {
- $D1 = $dateArr [0];
- $D2 = $dateArr [1];
- }
- $con = '';
- if (! empty ( $D1 ) && ! empty ( $D2 )) {
- $con = ' and bindTime BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
- }
- // if ($date == 'MONTHO')
- // $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
- // elseif ($date == 'MONTHT')
- // $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
- // elseif ($date == 'MONTHY')
- // $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
- if (! empty ( $MebSea )) {
- $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" or invoiceNo like "%' . $MebSea . '%" )';
- }
-
- if ($invoiceType == 'ORDINARY') {
- $con .= ' and invoiceType=0 ';
- } elseif ($invoiceType == 'SPECIAL') {
- $con .= ' and invoiceType=1 ';
- }
- $pageinfo ['page'] = array (
- 'previous' => ''
- );
-
- // printStatus=1 and
- $sql = " (untreadStatus=2 ) and status=2 and sid=" . $this->staff [0] ['sid'] . $con;
-
- $action = "invoiceUntreadED";
- $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, $action, $get, "" );
- $limit = $pageinfo ['lower'] . ',' . $page_size;
-
- $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
-
- // print_r($list);
- $this->data ['MebSeaEn'] = $MebSea;
-
- $this->data ['get'] = $get;
- $this->data ['page'] = $pageinfo;
- $this->data ['date'] = $date;
- $this->data ['invoiceType'] = $invoiceType;
-
- $this->data ['list'] = $list;
-
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoice';
-
- $this->render ( "/admin/invoiceUntreadED", $this->data );
- }
-
- /**
- * 退票处理页面
- */
- function invoiceUntread() {
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
-
- $untreadInvoice = $invoice->getInvoiceByUntreadStatus ( 1, 0, 50 );
- $establishedInvoice = $invoice->getInvoiceByUntreadStatus ( 2 );
- //print_r($establishedInvoice);
- // foreach ( $establishedInvoice as $key => $value ) {
- // // months
- // $lossDate = strtotime ( "+1 month", strtotime ( $value ['OperationLog'] ['date'] ) );
- // $nowDate = strtotime ( 'now' );
- // $establishedInvoice [$key] ['lossShow'] = false;
- // if ($lossDate < $nowDate)
- // $establishedInvoice [$key] ['lossShow'] = true;
- // }
-
- $this->data ['untreadInvoice'] = $untreadInvoice;
- $this->data ['establishedInvoice'] = $establishedInvoice;
-
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoiceUntread';
- $this->render ( "/admin/invoiceUntread", $this->data );
- }
-
- /**
- * 确认收到退回的发票,开票状态为退回 //收款状态解绑,公司统计扣除入账额度
- */
- function invoiceUntreadEstablishedDo() {
- $untreadIidKey = $this->get_args ( 'untreadIidKey' ) ? $this->get_args ( 'untreadIidKey' ) : '';
-
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'invoiceOperationLog' );
- $invoiceOperationLog = new invoiceOperationLog ();
- Doo::loadModel ( 'invoiceReceivables' );
-
- Doo::loadModel ( 'invoiceStatistics' );
-
- $iid = $invoice->authcode ( $untreadIidKey );
- if (! empty ( $iid ) && ! is_numeric ( $iid ))
- die ( 'illegal request' );
-
- $invoiceDetails = $invoice->getInvoiceByIid ( $iid );
- if ($invoiceDetails ['untreadStatus'] != 1)
- die ( 'illegal request untreadStatus error !=1' );
-
- $item = array (
- 'iid' => $iid,
- // 'irid'=>'',
- 'untreadStatus' => 2,
- 'untreadTime'=>date ( "Y-m-d H:i:s" ) ,
- 'updateTime' => date ( "Y-m-d H:i:s" )
- );
- $invoice->setInvoiceByCondition ( $item );
-
- $item = array (
- 'date' => date ( "Y-m-d H:i:s" ),
- 'operation' => '已确认退票',
- 'status' => 6,
- 'img' => $this->staff [0] ['avatar'],
- 'username' => $this->staff [0] ['username'],
- 'uid' => $this->staff [0] ['sid'],
- 'category' => $this->staff [0] ['category'],
- 'iid' => $iid
- );
- $invoiceOperationLog->setInvoiceOperationLog ( $item );
-
- // 收款解绑以及入账扣除 收款扣除
- if (! empty ( $invoiceDetails ['irid'] )) {
- $iridList = explode ( ',', $invoiceDetails ['irid'] );
-
- foreach ( $iridList as $value ) {
-
- $invoiceReceivables = new invoiceReceivables ();
-
- $irDetails = $invoiceReceivables->getOne ( array (
- 'where' => " irid=" . $value . ' ',
- 'asArray' => TRUE
- ) );
-
- $bindPrice=$irDetails['bindPrice']-$invoiceDetails['invoicePrice'];
- if($bindPrice<0){
- $bindPrice=0;
- }
-
-
-
- $iidExtend = explode ( ',', $irDetails ['iidExtend'] );
- $item = array (
- 'irid' => $value,
- 'bindStatus' => 0,
- 'untreadStatus' => 1,
- 'bindPrice'=>$bindPrice,
- 'untreadStaff' => $invoiceDetails ['userName'],
- 'unbundlingTime' => date ( "Y-m-d H:i:s" ),
- );
-
- if($irDetails['iid']==$iid){
- $item+=array(
- 'iid' => 0
- );
- }else{
- foreach ($iidExtend as $iek=>$iev){
- if($iev==$iid){
- unset($iidExtend[$iek]);
- break;
- }
- }
- if(empty($iidExtend)){
- $item+=array(
- 'iidExtend' => ''
- );
- }else{
- $iidExtend=implode(",", $iidExtend);
- $item+=array(
- 'iidExtend' => $iidExtend
- );
- }
-
- }
-
- $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
-
- if (! empty ( $irDetails )) {
- // 扣除入账
- $invoiceStatistics = new invoiceStatistics ();
- $item = array (
- 'date' => date ( 'Y-m-d', strtotime ( $irDetails ['receivablesDate'] ) ),
- 'priceClass' => 3,
- 'cid' => $invoiceDetails ['cid'],
- 'staff' => $invoiceDetails ['sid'],
- 'accountPrice' => - $irDetails ['receivablesPrice']
- );
- $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
- // 扣除收款
- $invoiceStatistics = new invoiceStatistics ();
- $item = array (
- 'date' => date ( 'Y-m-d', strtotime ( $irDetails ['receivablesDate'] ) ),
- 'priceClass' => 2,
- 'cid' => $invoiceDetails ['cid'],
- 'staff' => $invoiceDetails ['sid'],
- 'irid' => $irDetails ['irid'],
- 'receivablesPrice' => - $irDetails ['receivablesPrice']
- );
- $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
- }
-
- // 解绑时删除收入流水--退票不删除流水
- // Doo::loadModel ( 'wasteBook' );
- // $wasteBook = new wasteBook ();
- // $wasteBook->delete ( array (
- // 'where' => 'dataID=' . $value . ' and accountType=7',
- // 'limit' => 1
- // ) );
- }
- }
-
- return "/invoiceUntread";
- }
- function invoiceUntreadRecallDo() {
- $iidKey = isset ( $this->params ['iidKey'] ) ? $this->params ['iidKey'] : "";
-
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'invoiceOperationLog' );
- $invoiceOperationLog = new invoiceOperationLog ();
-
- $iid = $XDeode->decode ( $iidKey );
- $invoiceDetail = $invoice->getInvoiceByIid ( $iid );
- if (empty ( $invoiceDetail )) {
- die ( 'illegal request-DATANULL' );
- }
-
- $item = array (
- 'iid' => $iid,
- 'untreadStatus' => 0
- );
- $invoice->setInvoiceByCondition ( $item );
-
- $item = array (
- 'date' => date ( "Y-m-d H:i:s" ),
- 'operation' => '撤回申请退票',
- 'status' => 13,
- 'img' => $this->staff [0] ['avatar'],
- 'username' => $this->staff [0] ['username'],
- 'uid' => $this->staff [0] ['sid'],
- 'category' => $this->staff [0] ['category'],
- 'iid' => $iid
- );
- $invoiceOperationLog->setInvoiceOperationLog ( $item );
-
- return "/invoiceUntread";
- }
-
- /**
- * 建立负票,关联原来发票
- */
- function invoiceLossDo() {
- $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
-
- if (! empty ( $iidKey )) {
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'invoiceOperationLog' );
- $invoiceOperationLog = new invoiceOperationLog ();
-
- $iidKey = $XDeode->decode ( $iidKey );
-
- $invoiceDetail = $invoice->getInvoiceByIid ( $iidKey );
-
- // 拷贝插入一条发票数据
- $iid = $invoice->setInvoiceLoss ( $iidKey );
- // 更新负票
- if($invoiceDetail['invoiceForm']==1){
- $invoiceSerial = "#FE" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
- }else{
- $invoiceSerial = "#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
- }
-
- $invoice = new invoice ();
- $item = array (
- 'iid' => $iid,
- 'sid' => $this->staff [0] ['sid'],
- 'userName' => $this->staff [0] ['username'],
- 'cid' => $this->staff [0] ['cid'],
- 'categoryName' => $this->staff [0] ['category'],
-
- 'invoiceQuantity' => - $invoiceDetail ['invoiceQuantity'],
-
- 'invoicePrice' => - $invoiceDetail ['invoicePrice'],
-
- 'invoiceSerial' => $invoiceSerial,
- 'invoiceNo' => '',
- 'printStatus' => 0,
- 'untreadStatus' => 4,
- // 关联发票号
- 'lossIid' => $invoiceDetail ['iid']
- );
- $invoice->setInvoiceByCondition ( $item );
- // 更新原发票
- $invoice = new invoice ();
- $item = array (
- 'iid' => $invoiceDetail ['iid'],
- 'lossIid' => $iid
- );
- $invoice->setInvoiceByCondition ( $item );
-
- // 操作日志
- $item = array (
- 'date' => date ( "Y-m-d H:i:s" ),
- 'operation' => "创建负票" . $invoiceSerial,
- 'status' => 12,
- 'img' => $this->staff [0] ['avatar'],
- 'username' => $this->staff [0] ['username'],
- 'uid' => $this->staff [0] ['sid'],
- 'category' => $this->staff [0] ['category'],
- 'iid' => $iid
- );
- $invoiceOperationLog->setInvoiceOperationLog ( $item );
- // print_r($invoiceDetail);
- // echo $iid;die;
- }
- return '/invoiceUntread';
- }
-
- /**
- * 上传银行到账 收款文件
- */
- function invoiceReceivablesBankUpload() {
- $POST_MAX_SIZE = ini_get ( 'post_max_size' );
- $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
- $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
-
- if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
- header ( "HTTP/1.1 500 Internal Server Error" );
- echo "POST exceeded maximum allowed size.";
- exit ( 0 );
- }
-
- // Settings
- $save_path = DOO::conf ()->SITE_PATH . "upload/invoiceReceivablesBank/"; // The path were we will save the file (getcwd() may not be reliable and should be tested in your environment)
- $upload_name = "Filedata";
-
- $file_name = "";
-
- $nk = time ();
- $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
-
- if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
- echo "文件无法保存.";
- exit ( 0 );
- }
-
- echo json_encode ( array (
- 'filename' => $file_name,
- 'id' => $nk
- ) );
- exit ( 0 );
- }
-
- /**
- * 解析银行到账收款execl并导入库中
- */
- function invoiceReceivablesImport() {
- $path = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
-
- if ($path != "") {
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
- Doo::loadClass ( 'invoice.func' );
-
- Doo::loadModel ( 'invoiceROLog' );
- $invoiceROLog = new invoiceROLog ();
- Doo::loadModel ( 'invoiceStatistics' );
- $invoiceStatistics = new invoiceStatistics ();
-
- $exlArray = formatExcelToArrayBank ( DOO::conf ()->SITE_PATH . "upload/invoiceReceivablesBank/" . $path );
- $bankBatchNumber = 'BBN_' . time ();
-
- Doo::db ()->beginTransaction ();
- // 批量存储收款--由于必须获得收款ID,
- $sql = 'INSERT INTO CLD_invoiceReceivables (OriginalPrice,receivablesPrice, receivablesMessage,receivablesSerial,receivablesBank,receivablesDate,inputStaff,date,receivablesCategory,receivablesStaff,bankBatchNumber,recepitTitleMark)
- VALUES ';
- $date = date ( "Y-m-d" );
- $receivablesList = array ();
- foreach ( $exlArray as $key => $value ) {
- $receivablesSql = '(' . $value ["receivablesPrice"] . ',' . $value ["receivablesPrice"] . ',"' . $value ["receivablesMessage"] . '",' . '"#SK' . date ( "Ymd" ) . mt_rand ( 1000, 9999 ) . '","' . $value ["receivablesBank"] . '","' . $value ["receivablesDate"] . '","' . $this->staff [0] ['username'] . '","' . $date . '","PUBLIC","PUBLIC","' . $bankBatchNumber . '","' . $value ["receivablesMessage"] . '")';
- array_push ( $receivablesList, $receivablesSql );
- }
- $sql = $sql . implode ( ',', $receivablesList );
- // echo $sql;
- Doo::db ()->query ( $sql );
-
- // 批量存储收款统计
- // 获得刚刚导入数据的irid组-缺少办事处和人员
- $iridList = $invoiceReceivables->getInvoiceReceivablesByBBN ( $bankBatchNumber );
- // 没有irid 回滚所有操作
- if (empty ( $iridList )) {
- Doo::db ()->rollBack ();
- header ( 'Content-Type:text/html;charset=utf-8' );
- die ( '文档或数据不正确,请重新<a href="/invoiceReceivables">上传</a>.' );
- }
-
- $sql = 'INSERT INTO CLD_invoiceStatistics (date, priceClass,irid,receivablesPrice)
- VALUES ';
- $statisticsList = array ();
- foreach ( $iridList as $value ) {
- $statisticsSql = '("' . $date . '",2,' . $value ['irid'] . ',' . $value ["receivablesPrice"] . ')';
- array_push ( $statisticsList, $statisticsSql );
- }
- $sql = $sql . implode ( ',', $statisticsList );
- Doo::db ()->query ( $sql );
-
- // 批量存储操作日志
- $sql = 'INSERT INTO CLD_invoiceROLog (operation, date,status,img, username,uid,category,irid)
- VALUES ';
- $ROLogList = array ();
- foreach ( $iridList as $value ) {
- $ROLogSql = '("' . $this->staff [0] ['username'] . ' 转入 公共待认领款项","' . $date . '",1,"' . $this->staff [0] ['avatar'] . '","' . $this->staff [0] ['username'] . '","' . $this->staff [0] ['sid'] . '","' . $this->staff [0] ['category'] . '","' . $value ['irid'] . '")';
- array_push ( $ROLogList, $ROLogSql );
- }
- $sql = $sql . implode ( ',', $ROLogList );
- Doo::db ()->query ( $sql );
-
- // 批量写入流水
- $sql = 'INSERT INTO CLD_wasteBook (dataID, expensesType,accountType,accountPriceShow, accountPrice,accountBank,category,cid,name,sid,inputDate)
- VALUES ';
- $wasteBookList = array ();
- foreach ( $iridList as $value ) {
-
- $accountBank = '';
- if ($value ['receivablesBank'] == '纵横广发') {
- $accountBank = 'CGBDeposit';
- } elseif ($value ['receivablesBank'] == '纵横工行') {
- $accountBank = 'ICBCDeposit';
- } elseif ($value ['receivablesBank'] == '华润银行') {
- $accountBank = 'HUADeposit';
- } elseif ($value ['receivablesBank'] == '个人广发') {
- $accountBank = 'PersonalDeposit';
- }
-
- $wasteBookSql = '("' . $value ['irid'] . ' ",1,7,"' . $value ['receivablesPrice'] . '","' . $value ['receivablesPrice'] . '","' . $accountBank . '",
- "' . $this->staff [0] ['category'] . '","' . $this->staff [0] ['cid'] . '","' . $this->staff [0] ['username'] . '","' . $this->staff [0] ['sid'] . '","' . date ( "Y-m-d H:i:s" ) . '")';
- array_push ( $wasteBookList, $wasteBookSql );
- }
- $sql = $sql . implode ( ',', $wasteBookList );
- Doo::db ()->query ( $sql );
-
- Doo::db ()->commit ();
-
- return "/invoiceReceivables";
- }
- echo 'no file';
- }
- function invoiceReceivables() {
- $invoiceTC = $this->get_args ( 'invoiceTC' ) ? $this->get_args ( 'invoiceTC' ) : '';
- Doo::loadModel ( 'L_category' );
- $lCategory = new L_category ();
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $category = $lCategory->getCategory ();
- $staffList = $staff->getStaffByCid ( $this->staff [0] ['cid'] );
-
- $sql = 'bindStatus=1 and iid!=0';
- $receivablesList = $invoiceReceivables->getInvoiceReceivablesByNew ( 4, $sql );
-
- // 获取未入账发票
- $invoiceUnAccount = $invoice->getInvoiceByUnAccount ( $invoiceTC );
- $invoiceExistAccount = $invoice->getInvoiceByUnAccount ( '', true );
-
- foreach ( $invoiceUnAccount as $key => $value ) {
- $invoiceUnAccount [$key] ['iidKey'] = $XDeode->encode ( $value ['iid'] );
-
- $lastApprover = json_decode ( $value ['processApprovals'], true );
- if (! empty ( $lastApprover )) {
- $lastApproverKey = array_keys ( $lastApprover );
- $lastApprover = end ( $lastApprover );
-
- $staffDetail = $staff->getOne ( array (
- 'where' => 'sid=' . end ( $lastApproverKey ),
- 'asArray' => true
- ) );
- $lastApprover ['username'] = $staffDetail ['username'];
- }
- $invoiceUnAccount [$key] ['lastApprover'] = $lastApprover;
- }
-
- foreach ( $invoiceExistAccount as $key => $value ) {
- // $irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $value ['irid'] );
- // if (empty ( $irList ))
- // $irList [0] ['sumPrice'] = 0;
-
- //$balance = $value ['invoicePrice'] - $irList [0] ['sumPrice'];
- $invoiceExistAccount [$key] ['existAccount'] = $value ['invoicePrice']-$value ['invoiceBalance'];
- //$invoiceExistAccount [$key] ['balance'] = $balance;
- }
-
- $receivablesInput = $invoiceReceivables->getInvoiceReceivablesByInput ();
-
- $halfList = $invoiceReceivables->getInvoiceReceivablesByHalf ();
- $this->data ['halfList'] = $halfList;
- $this->data ['halfCount'] = count ( $halfList );
-
- // print_r($receivablesList);
- $this->data ['receivablesDate'] = date ( "Y-m-d" );
- $this->data ['ieaCount'] = count ( $invoiceExistAccount );
- $this->data ['invoiceExistAccount'] = $invoiceExistAccount;
- $this->data ['receivablesInput'] = $receivablesInput;
- $this->data ['year'] = date ( 'Y' );
- $this->data ['invoiceUnAccount'] = $invoiceUnAccount;
- $this->data ['receivablesList'] = $receivablesList;
- $this->data ['staffList'] = $staffList;
- $this->data ['category'] = $category;
-
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoiceReceivables';
- $this->render ( "/admin/invoiceReceivables", $this->data );
- }
-
- /**
- * 设置收款认领地区
- */
- function setInvoiceReceivablesClaim() {
- $iridKey = $this->get_args ( 'iridKey' ) ? $this->get_args ( 'iridKey' ) : "";
- $receivablesCategory = $this->get_args ( 'receivablesCategory' ) ? $this->get_args ( 'receivablesCategory' ) : "";
- $action = $this->get_args ( 'action' ) ? $this->get_args ( 'action' ) : "";
-
- if (! empty ( $iridKey ) && ! empty ( $receivablesCategory )) {
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'invoiceROLog' );
- $invoiceROLog = new invoiceROLog ();
-
- $irid = $XDeode->decode ( $iridKey );
- $irDetail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
- if (empty ( $irDetail ))
- die ( 'illegal request' );
-
- $item = array (
- 'irid' => $irid,
- 'receivablesCategory' => $receivablesCategory
- );
- if ($receivablesCategory != 'PUBLIC') {
- $item += array (
- 'confirmTime' => date ( "Y-m-d H:i:s" ),
- 'inputType' => 1
- );
- }
- $invoiceReceivables = new invoiceReceivables ();
- $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
-
- // 收款操作日志
- $item = array (
- 'operation' => $this->staff [0] ['username'] . " 转入 公共待认领款项 ",
- 'date' => date ( "Y-m-d" ),
- 'status' => 1,
- 'img' => $this->staff [0] ['avatar'],
- 'username' => $this->staff [0] ['username'],
- 'uid' => $this->staff [0] ['sid'],
- 'category' => $this->staff [0] ['category'],
- 'irid' => $irid
- );
- $invoiceROLog->setInvoiceROLog ( $item );
-
- if (empty ( $action ))
- return '/invoiceReceivables';
- else
- return "/invoiceReceivablesAS";
- }
- die ( 'illegal request' );
- }
-
- /**
- * 新添加收款直接入账发票
- */
- function invoiceCompareClaimPrice() {
- // 收款录入
- $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
-
- $receivablesPrice = $this->get_args ( 'receivablesPrice' ) ? $this->get_args ( 'receivablesPrice' ) : "";
- $receivablesMessage = $this->get_args ( 'receivablesMessage' ) ? $this->get_args ( 'receivablesMessage' ) : "";
- $receivablesBank = $this->get_args ( 'receivablesBank' ) ? $this->get_args ( 'receivablesBank' ) : "";
- $receivablesDate = $this->get_args ( 'receivablesDate' ) ? $this->get_args ( 'receivablesDate' ) : "";
-
- if (! empty ( $receivablesPrice ) && ! empty ( $receivablesMessage ) && ! empty ( $receivablesBank ) && ! empty ( $receivablesDate ) && ! empty ( $iidKey )) {
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
- Doo::loadModel ( 'invoiceROLog' );
- $invoiceROLog = new invoiceROLog ();
- Doo::loadModel ( 'invoiceStatistics' );
-
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'bill' );
- $bill = new bill ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'invoiceOperationLog' );
- $invoiceOperationLog = new invoiceOperationLog ();
-
- $iidKey = $XDeode->decode ( $iidKey );
-
- $invoiceDetail = $invoice->getInvoiceByIid ( $iidKey );
- if (! ($invoiceDetail ['status'] == 2 && $invoiceDetail ['printStatus'] == 1 && $invoiceDetail ['untreadStatus'] == 0))
- die ( 'illegal request' );
-
- $receivablesSerial = "#SK" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
-
- // 收款录入 并绑定发票
- Doo::db ()->beginTransaction ();
-
- //获得发票入账余额
- //$bindInvicePrice=$invoiceReceivables->getSumOfReceivablesPrice ( $invoiceDetail['irid'] );
- //$bindPrice=$invoiceDetail ['invoiceBalance']-$bindInvicePrice;
-
- $bindStatus = 0;
- $invoiceBalance=$invoiceDetail ['invoicePrice'];
- if($invoiceDetail ['invoiceBalance']!=0){
- $invoiceBalance=$invoiceDetail ['invoiceBalance'];
- }
-
- if ($receivablesPrice <= $invoiceBalance){
- $bindStatus = 1;
- //$bindPrice=$receivablesPrice;
- }
-
- $titleMark = $invoiceDetail ['invoiceTitle'];
- if (! empty ( $invoiceDetail ['invoiceCompany'] ))
- $titleMark = $invoiceDetail ['invoiceCompany'];
- $item = array (
- 'recepitTitleMark' => $titleMark,
- 'bindStatus' => $bindStatus,
- 'iid' => $invoiceDetail ['iid'],
- 'bindPrice' => $receivablesPrice,
- 'bindDate' => date ( "Y-m-d H:i:s" ),
- 'receivablesPrice' => $receivablesPrice,
- 'OriginalPrice' => $receivablesPrice,
- 'receivablesMessage' => $receivablesMessage,
- 'receivablesSerial' => $receivablesSerial,
- 'receivablesBank' => $receivablesBank,
- 'receivablesDate' => $receivablesDate,
- 'inputStaff' => $this->staff [0] ['username'],
- 'accountClerk' => $this->staff [0] ['username'],
- 'date' => date ( "Y-m-d" ),
- 'receivablesCategory' => $invoiceDetail ['cid'] . ':' . $invoiceDetail ['categoryName'],
- 'receivablesStaff' => $invoiceDetail ['sid'] . '-' . $invoiceDetail ['userName'],
- 'confirmTime' => date ( "Y-m-d H:i:s" )
- );
-
- $irid = $invoiceReceivables->addInvoiceReceivables ( $item );
-
- $item = array ();
- // 收款操作日志
- $item = array (
- 'operation' => $this->staff [0] ['username'] . " 转入 " . $invoiceDetail ['userName']
- );
- $item += array (
- 'date' => date ( "Y-m-d" ),
- 'status' => 1,
- 'img' => $this->staff [0] ['avatar'],
- 'username' => $this->staff [0] ['username'],
- 'uid' => $this->staff [0] ['sid'],
- 'category' => $this->staff [0] ['category'],
- 'irid' => $irid
- );
- $invoiceROLog->setInvoiceROLog ( $item );
- // 收款统计
- $invoiceStatistics = new invoiceStatistics ();
- $item = array (
- 'date' => $receivablesDate,
- 'priceClass' => 2,
- 'irid' => $irid,
- 'cid' => $invoiceDetail ['cid'],
- 'staff' => $invoiceDetail ['sid'],
- 'receivablesPrice' => $receivablesPrice
- );
- $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
-
- // 收款 入 发票
- $detail = $invoiceDetail;
-
- $iridString = "";
- if (empty ( $detail ['irid'] ))
- $iridString = $irid;
- else
- $iridString = $detail ['irid'] . ',' . $irid;
-
- $item = array (
- 'irid' => $iridString,
- 'bindTime' => date ( "Y-m-d H:i:s" ),
- 'updateTime' => date ( "Y-m-d H:i:s" ),
- 'iid' => $detail ['iid']
- );
- // $invoiceReceivables = new invoiceReceivables ();
- // $sum = $invoiceReceivables->getSumOfReceivablesPrice ( $iridString );
-
- // $sumBind = $bindInvicePrice;
- // $sumBalance=$invoiceReceivables->balanceOfReceivablesPrice($irid);
- // $sum=$sumBind+$sumBalance;
-
- // ;
-
- if ($receivablesPrice>=$invoiceBalance){
- $item += array (
- 'invoiceBalance'=>0,
- 'untreadStatus' => 3
- );
- }else{
- $item += array (
- 'invoiceBalance'=>$invoiceBalance-$receivablesPrice
- );
- }
-
- $invoice->setInvoiceByCondition ( $item );
-
- // 操作日志
- $item = array (
- 'date' => date ( "Y-m-d H:i:s" ),
- 'operation' => "收款入账" . $receivablesSerial . "到发票" . $detail ['invoiceSerial'],
- 'status' => 8,
- 'img' => $this->staff [0] ['avatar'],
- 'username' => $this->staff [0] ['username'],
- 'uid' => $this->staff [0] ['sid'],
- 'category' => $this->staff [0] ['category'],
- 'iid' => $detail ['iid']
- );
- $invoiceOperationLog->setInvoiceOperationLog ( $item );
-
- // 入账汇总
- $invoiceStatistics = new invoiceStatistics ();
- // $list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $iridString );
- // $accountPrice = 0;
- // foreach ( $list as $key => $value ) {
- // $accountPrice += $value ['receivablesPrice'];
- // }
- $item = array (
- 'date' => $receivablesDate,
- 'priceClass' => 3,
-
- 'cid' => $invoiceDetail ['cid'],
- 'staff' => $invoiceDetail ['sid'],
- 'accountPrice' => $receivablesPrice
- );
- $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
-
- //发票入账记录
- $bill->iid=$invoiceDetail['iid'];
- $bill->trainId=$invoiceDetail['trainId'];
- $bill->irid=$irid;
- $bill->create_time=date ( "Y-m-d H:i:s" );
- $bill->price=$invoiceBalance;
- $bill->insert ();
-
- // 公司流水记录
- Doo::loadModel ( 'wasteBook' );
- $wasteBook = new wasteBook ();
-
- $abDetail = $wasteBook->getAccountBookByAid ( 1, 7, $irid );
- $accountBank=$wasteBook->_getAccountBankEN($receivablesBank);
-
- if (empty ( $abDetail )) {
- $item = array (
- 'dataID' => $irid,
- 'expensesType' => 1,
- 'accountType' => 7,
- 'accountPrice' => $receivablesPrice,
- 'accountPriceShow' => $receivablesPrice,
- 'accountBank' => $accountBank,
- 'cid'=>$invoiceDetail['cid'],
- 'category' => $invoiceDetail ['categoryName'],
- 'name' => $this->staff [0] ['username'],
- 'sid' => $this->staff [0] ['sid'],
- 'inputDate' => $receivablesDate//date ( "Y-m-d H:i:s" )
- );
- $wasteBook->setAccountBookStatistics ( $item );
- }
-
- Doo::db ()->commit ();
- }
-
- return '/invoiceReceivables';
- }
-
- /**
- * 录入收款数据
- * @return string
- */
- function invoiceReceivablesDo() {
- $receivablesPrice = $this->get_args ( 'receivablesPrice' ) ? $this->get_args ( 'receivablesPrice' ) : "";
- $receivablesMessage = $this->get_args ( 'receivablesMessage' ) ? $this->get_args ( 'receivablesMessage' ) : "";
- $receivablesBank = $this->get_args ( 'receivablesBank' ) ? $this->get_args ( 'receivablesBank' ) : "";
- $receivablesDate = $this->get_args ( 'receivablesDate' ) ? $this->get_args ( 'receivablesDate' ) : "";
- $receivablesCategory = $this->get_args ( 'receivablesCategory' ) ? $this->get_args ( 'receivablesCategory' ) : "";
- $receivablesStaff = $receivablesStaff2 = $this->get_args ( 'receivablesStaff' ) ? $this->get_args ( 'receivablesStaff' ) : "";
-
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
- Doo::loadModel ( 'invoiceROLog' );
- $invoiceROLog = new invoiceROLog ();
- Doo::loadModel ( 'invoiceStatistics' );
- $invoiceStatistics = new invoiceStatistics ();
-
- if (! empty ( $receivablesPrice ) && ! empty ( $receivablesMessage ) && ! empty ( $receivablesBank ) && ! empty ( $receivablesDate ) && ! empty ( $receivablesCategory ) && ! empty ( $receivablesStaff )) {
-
- $item = array (
- 'receivablesPrice' => $receivablesPrice,
- 'OriginalPrice' => $receivablesPrice,
- 'receivablesMessage' => $receivablesMessage,
- 'receivablesSerial' => "#SK" . date ( "Ymd" ) . mt_rand ( 1000, 9999 ),
- 'receivablesBank' => $receivablesBank,
- 'receivablesDate' => $receivablesDate,
- 'inputStaff' => $this->staff [0] ['username'],
- 'date' => date ( "Y-m-d" ),
- 'receivablesCategory' => $receivablesCategory,
- 'receivablesStaff' => $receivablesStaff
- );
- if ($receivablesCategory != 'PUBLIC') {
- $item += array (
- 'confirmTime' => date ( "Y-m-d H:i:s" ),
- 'inputType' => 1
- );
- }
-
- $irid = $invoiceReceivables->addInvoiceReceivables ( $item );
-
- $item = array ();
- // 收款操作日志
- if ($receivablesCategory == 'PUBLIC' && $receivablesStaff == 'PUBLIC')
- $item = array (
- 'operation' => $this->staff [0] ['username'] . " 转入 公共待认领款项 "
- );
- elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff == 'PUBLIC')
- $item = array (
- 'operation' => $this->staff [0] ['username'] . "转入 办事处待认领款项"
- );
- elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff != 'PUBLIC') {
- $receivablesStaff = explode ( '-', $receivablesStaff );
- $item = array (
- 'operation' => $this->staff [0] ['username'] . " 转入 " . $receivablesStaff [1]
- );
- }
- $item += array (
- 'date' => date ( "Y-m-d" ),
- 'status' => 1,
- 'img' => $this->staff [0] ['avatar'],
- 'username' => $this->staff [0] ['username'],
- 'uid' => $this->staff [0] ['sid'],
- 'category' => $this->staff [0] ['category'],
- 'irid' => $irid
- );
- $invoiceROLog->setInvoiceROLog ( $item );
-
- $item = array (
- 'date' => $receivablesDate,
- 'priceClass' => 2,
- 'irid' => $irid,
- 'receivablesPrice' => $receivablesPrice
- );
- if ($receivablesCategory != 'PUBLIC') {
- $receivablesCategory = explode ( ":", $receivablesCategory );
- $item += array (
- 'cid' => $receivablesCategory [0]
- );
- }
-
- if ($receivablesStaff2 != 'PUBLIC') {
- $receivablesStaff = explode ( "-", $receivablesStaff2 );
- $item += array (
- 'staff' => $receivablesStaff [0]
- );
- }
- $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
-
- $toparty = $this->getWxidByCategory ( $receivablesCategory [1] );
- // $toparty = $this->getToparty ( $receivablesCategory [1] );
- $msg = '[通知]财务录入了一笔待认领款项,快到“我的收款”中查看,确认是否是您的客户给您打款了。';
- if ($toparty != 0)
- $this->msgSendToparty ( $msg, '', '', $toparty, 'text' );
-
- // 公司流水记录
- Doo::loadModel ( 'wasteBook' );
- $wasteBook = new wasteBook ();
-
- $abDetail = $wasteBook->getAccountBookByAid ( 1, 7, $irid );
- $accountBank=$wasteBook->_getAccountBankEN($receivablesBank);
-
-
- $item = array (
- 'dataID' => $irid,
- 'expensesType' => 1,
- 'accountType' => 7,
-
- 'accountPriceShow' => $receivablesPrice,
- 'accountPrice' => $receivablesPrice,
-
- 'accountBank' => $accountBank,
- 'category' => $this->staff [0] ['category'],
- 'cid' => $this->staff [0] ['cid'],
- 'name' => $this->staff [0] ['username'],
- 'sid' => $this->staff [0] ['sid'],
- 'inputDate' => $receivablesDate ,
- //'createAt'=>date ( "Y-m-d H:i:s" ) ,
- 'synPaymentDate'=>1
- );
- $wasteBook->setAccountBookStatistics ( $item );
- }
-
- return "/invoiceReceivables";
- }
-
- /**
- * 收款认领页面-包括公共认领 办事处认领 最近已认领数据
- */
- function invoiceReceivablesClaim() {
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
-
- $receivablesList = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
-
- $this->data ['receivablesList'] = $receivablesList;
-
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoiceReceivablesClaim';
- $this->render ( "/admin/invoiceReceivablesClaim", $this->data );
- }
- function invoiceReceivablesTitleMarkSet() {
- $iridKey = $this->get_args ( 'iridKey' ) ? $this->get_args ( 'iridKey' ) : "";
- $recepitTitleMark = $this->get_args ( 'recepitTitleMark' ) ? $this->get_args ( 'recepitTitleMark' ) : "";
-
- if (empty ( $iridKey ) || empty ( $recepitTitleMark ))
- die ( 'illegal request' );
-
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $irid = $XDeode->decode ( $iridKey );
-
- if (! is_numeric ( $irid ))
- die ( 'illegal request' );
-
- $invoiceReceivables->recepitTitleMark = $recepitTitleMark;
- $invoiceReceivables->update ( array (
- 'where' => 'irid = ' . $irid
- ) );
- return '/invoiceReceivablesClaim';
- }
-
- /**
- * 更新收款相关数据
- */
- function invoiceReceivablesUpdateClaim() {
- $receivablesPrice = $this->get_args ( 'receivablesPrice' ) ? $this->get_args ( 'receivablesPrice' ) : "";
- $receivablesMessage = $this->get_args ( 'receivablesMessage' ) ? $this->get_args ( 'receivablesMessage' ) : "";
- $receivablesBank = $this->get_args ( 'receivablesBank' ) ? $this->get_args ( 'receivablesBank' ) : "";
- $receivablesDate = $this->get_args ( 'receivablesDate' ) ? $this->get_args ( 'receivablesDate' ) : "";
- $receivablesCategory = $this->get_args ( 'receivablesCategory' ) ? $this->get_args ( 'receivablesCategory' ) : "";
- $receivablesStaff = $receivablesStaff2 = $this->get_args ( 'receivablesStaff' ) ? $this->get_args ( 'receivablesStaff' ) : "";
-
- $claimKey = $this->get_args ( 'claimKey' ) ? $this->get_args ( 'claimKey' ) : "";
-
- if (empty ( $claimKey ))
- die ( 'illegal request' );
-
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
- Doo::loadModel ( 'invoiceROLog' );
- $invoiceROLog = new invoiceROLog ();
- $con = ' and iid=0 and bindStatus=0'; // and receivablesCategory!="PUBLIC" and receivablesStaff!="PUBLIC"
- $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $claimKey, $con );
- if (empty ( $detail ))
- die ( 'illegal request' );
-
- $invoiceReceivables = new invoiceReceivables ();
-
- $item = array (
- 'irid' => $detail ['irid']
- );
- if ($receivablesCategory != 'PUBLIC' && $receivablesStaff != 'PUBLIC') {
- $item += array (
- 'confirmTime' => date ( "Y-m-d H:i:s" )
- );
- }
- if (! empty ( $receivablesCategory ))
- $item += array (
- 'receivablesCategory' => $receivablesCategory
- );
- if (! empty ( $receivablesStaff ))
- $item += array (
- 'receivablesStaff' => $receivablesStaff
- );
- if (! empty ( $receivablesPrice ))
- $item += array (
- 'receivablesPrice' => $receivablesPrice
- );
- if (! empty ( $receivablesMessage ))
- $item += array (
- 'receivablesMessage' => $receivablesMessage
- );
- if (! empty ( $receivablesBank ))
- $item += array (
- 'receivablesBank' => $receivablesBank
- );
- if (! empty ( $receivablesDate ))
- $item += array (
- 'receivablesDate' => $receivablesDate
- );
- $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
-
- // 收款操作日志
- $item = array ();
- if ($receivablesCategory == 'PUBLIC' && $receivablesStaff == 'PUBLIC')
- $item = array (
- 'operation' => $this->staff [0] ['username'] . " 转入 公共待认领款项 "
- );
- elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff == 'PUBLIC')
- $item = array (
- 'operation' => $this->staff [0] ['username'] . "转入 办事处待认领款项"
- );
- elseif ($receivablesCategory != 'PUBLIC' && $receivablesStaff != 'PUBLIC') {
- $receivablesStaff = explode ( '-', $receivablesStaff );
- $item = array (
- 'operation' => $this->staff [0] ['username'] . " 转入 " . $receivablesStaff [1]
- );
- }
- $item += array (
- 'date' => date ( "Y-m-d" ),
- 'status' => 1,
- 'img' => $this->staff [0] ['avatar'],
- 'username' => $this->staff [0] ['username'],
- 'uid' => $this->staff [0] ['sid'],
- 'category' => $this->staff [0] ['category'],
- 'irid' => $detail ['irid']
- );
- $invoiceROLog->setInvoiceROLog ( $item );
-
- return '/invoiceReceivablesAS';
- }
- function invoiceReceivablesDelete() {
- $claimKey = $this->get_args ( 'claimKey' ) ? $this->get_args ( 'claimKey' ) : "";
- $skll = $this->get_args ( 'skll' ) ? $this->get_args ( 'skll' ) : "";
-
- if ($skll != '删除到款')
- die ( 'illegal request-未填写 删除到款' );
- if (empty ( $claimKey ))
- die ( 'illegal request-收款key不正确' );
-
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
-
- $con = ' and bindStatus=0 ';
- $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $claimKey, $con );
- if (empty ( $detail ))
- die ( 'illegal request-未找到该收款或者未解绑' );
-
- $invoiceReceivables->delInvoiceReceivablesByIrid ( $detail ['irid'] );
-
- // 扣除收款汇总信息 汇总
- Doo::loadModel ( 'invoiceStatistics' );
- $invoiceStatistics = new invoiceStatistics ();
- $item = array (
- 'date' => $detail ['receivablesDate'],
- 'priceClass' => 2,
- 'irid' => $detail ['irid'],
- 'receivablesPrice' => - $detail ['receivablesPrice']
- );
- if ($detail ['receivablesCategory'] != 'PUBLIC') {
- $receivablesCategory = explode ( ":", $detail ['receivablesCategory'] );
- $item += array (
- 'cid' => $receivablesCategory [0]
- );
- }
- if ($detail ['receivablesStaff'] != 'PUBLIC') {
- $receivablesStaff = explode ( "-", $detail ['receivablesStaff'] );
- $item += array (
- 'staff' => $receivablesStaff [0]
- );
- }
- $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
-
- // 公司流水-删除时删除流水
- Doo::loadModel ( 'wasteBook' );
- $wasteBook = new wasteBook ();
-
- $wasteBook->delete ( array (
- 'where' => 'dataID=' . $detail ['irid'] . ' and accountType=7',
- 'limit' => 1
- ) );
-
- return '/invoiceReceivablesAS';
- }
-
- /**
- * 管理员录入的收款 ,确认认领到谁的名下.统计收款金额
- */
- function invoiceReceivablesAscription() {
- $irid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
- $recepitTitleMark = $this->get_args ( 'recepitTitleMark' ) ? $this->get_args ( 'recepitTitleMark' ) : "";
-
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
- Doo::loadModel ( 'invoiceROLog' );
- $invoiceROLog = new invoiceROLog ();
- Doo::loadModel ( 'invoiceStatistics' );
- $invoiceStatistics = new invoiceStatistics ();
-
- $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
- $irid = $invoiceReceivables->authcode ( $irid );
-
- if (! empty ( $detail ) && $detail ['receivablesStaff'] == 'PUBLIC' && ! empty ( $recepitTitleMark )) {
- $item = array (
- 'irid' => $detail ['irid'],
- 'receivablesCategory' => $this->staff [0] ['cid'] . ":" . $this->staff [0] ['category'],
- 'receivablesStaff' => $this->staff [0] ['sid'] . "-" . $this->staff [0] ['username'],
- 'confirmTime' => date ( "Y-m-d H:i:s" ),
- 'recepitTitleMark' => $recepitTitleMark,
- 'source' => 1
- );
- $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
-
- $item = array (
- 'date' => date ( "Y-m-d" ),
- 'operation' => $this->staff [0] ['username'] . " 认领 ",
- 'status' => 2,
- 'img' => $this->staff [0] ['avatar'],
- 'username' => $this->staff [0] ['username'],
- 'uid' => $this->staff [0] ['sid'],
- 'category' => $this->staff [0] ['category'],
- 'irid' => $irid
- );
-
- $invoiceROLog->setInvoiceROLog ( $item );
-
- $item = array (
- 'cid' => $this->staff [0] ['cid'],
- 'staff' => $this->staff [0] ['sid']
- );
- $invoiceStatistics->updateInvoiceStatisticsByIrid ( $item, $detail ['irid'], 2 );
-
- //更新流水的办事处
- Doo::loadModel ( 'wasteBook' );
- $wasteBook = new wasteBook ();
- $abDetail = $wasteBook->getAccountBookByAid ( 1, 7, $detail ['irid'] );
-
- $wasteBook->wid = $abDetail ['wid'];
- $wasteBook->category = $this->staff [0] ['category'];
- $wasteBook->cid = $this->staff [0] ['cid'];
- $wasteBook->update ();
-
- }
-
- return "/invoiceReceivablesClaim";
- }
-
- /**
- */
- function invoiceMyReceivables() {
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
- Doo::loadModel ( 'invoiceStatistics' );
- $invoiceStatistics = new invoiceStatistics ();
-
- $isMonth = $invoiceStatistics->getStatisticsByMonth ( $this->staff [0] ['sid'] );
-
- $year = date ( "Y" );
- $tmp_date = date ( "Ym" );
- $tmp_year = substr ( $tmp_date, 0, 4 );
- $tmp_mon = substr ( $tmp_date, 4, 2 );
- $tmp_forwardmonth = mktime ( 0, 0, 0, $tmp_mon - 1, 1, $tmp_year );
- $fm_forward_month = date ( "m", $tmp_forwardmonth );
- $path = SITE_PATH . $this->INVOICECOLLECTPATH . "invoiceCollect_" . $year . "_" . $fm_forward_month . ".htm";
- $htm = $this->showCache ( $path );
-
- $list = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] );
-
- $this->data ['isMonth'] = $isMonth;
- $this->data ['htm'] = $htm;
- $this->data ['list'] = $list;
-
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoiceMyReceivables';
- $this->render ( "/admin/invoiceMyReceivables", $this->data );
- }
-
- /**
- * 纸票管理
- */
- function invoicePaper() {
- $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'ALL';
- $invoiceType = $this->get_args ( 'invoiceType' ) ? $this->get_args ( 'invoiceType' ) : "ALL";
-
- $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
-
- $this->data ['dateString'] = $date;
- $this->data ['status'] = $status;
- $this->data ['invoiceType'] = $invoiceType;
-
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoicePaper';
- $this->render ( "/admin/invoicePaper", $this->data );
- }
-
- /**
- * 电子发票管理
- */
- function invoiceElectronic() {
- $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'ALL';
- $invoiceType = $this->get_args ( 'invoiceType' ) ? $this->get_args ( 'invoiceType' ) : "ALL";
-
- $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
-
- $this->data ['dateString'] = $date;
- $this->data ['status'] = $status;
- $this->data ['invoiceType'] = $invoiceType;
-
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoicePaper';
- $this->render ( "/invoice/invoiceElectronic", $this->data );
- }
-
- /**
- * 获得纸票分页数据
- */
- function ajaxGetinvoicePaperAchieve() {
-
- //include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
-
- Doo::loadModel ( 'invoicePaper' );
- $invoicePaper = new invoicePaper ();
-
- $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'ALL';
- $invoiceType = $this->get_args ( 'invoiceType' ) ? $this->get_args ( 'invoiceType' ) : "ALL";
-
- $invoiceForm = $this->get_args ( 'invoiceForm' )&&is_numeric($this->get_args ( 'invoiceForm' )) ? $this->get_args ( 'invoiceForm' ) : "0";
-
- $invoiceTrain = $this->get_args ( 'invoiceTrain' ) ? $this->get_args ( 'invoiceTrain' ) : "ORDINARY";
- $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
-
- $page = $this->get_args ( 'start' ) && is_numeric ( $this->get_args ( 'start' ) ) ? $this->get_args ( 'start' ) : 0;
- $draw = $this->get_args ( 'draw' ) && is_numeric ( $this->get_args ( 'draw' ) ) ? $this->get_args ( 'draw' ) : 1;
- $length = $this->get_args ( 'length' ) && is_numeric ( $this->get_args ( 'length' ) ) ? $this->get_args ( 'length' ) : 10;
-
- $MebSea = $this->get_args ( 'search' );
- $MebSea = $MebSea ['value'];
-
- $page_size = $length;
-
- $con = '';
- if ($status == 'ALL')
- $con = ' where 1 ';
- elseif ($status == 'PRINTED')
- $con = ' where a.iid!=0 '; // $con = ' where b.isDelete=0 and a.iid!=0 and b.status=2 and b.untreadStatus=0 ';
- elseif ($status == 'UNPRINT')
- $con = ' where a.iid=0 '; // $con = ' where b.isDelete=0 and a.iid=0 and b.status=2 and b.untreadStatus=0 ';
- elseif ($status == 'TICKET')
- $con = ' where b.isDelete=0 and b.untreadStatus=2';
-
- if ($invoiceType == 'ORDINARY')
- $con .= ' and a.invoiceType=0 ';
- elseif ($invoiceType == 'SPECIAL')
- $con .= ' and a.invoiceType=1 ';
-
- if($invoiceForm==0){
- $con .= ' and a.invoiceForm=0 ';
- }else{
- $con .= ' and a.invoiceForm=1 ';
- }
-
- $dateArr = explode ( ':', $date );
- $D1 = $dateString = '';
- $D2 = '';
- if (! empty ( $date )) {
- $D1 = $dateArr [0];
- if (isset ( $dateArr [1] ))
- $D2 = $dateArr [1];
- else
- $D2 = '';
- $dateString = $D1 . " : " . $D2;
- }
- if (! empty ( $D1 ) && ! empty ( $D2 ))
- $con .= ' and b.printTime BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
- elseif (! empty ( $D1 ) && empty ( $D2 ))
- $con .= ' and b.printTime like "%' . $D1 . '%" ';
-
- if (! empty ( $MebSea ))
- $con .= ' and ( b.invoiceTitle like "%' . $MebSea . '%" or b.invoiceCompany like "%' . $MebSea . '%" or a.invoiceNo like "%' . $MebSea . '%" )';
-
- $invoiceTotal = $invoicePaper->getInvoicePaperCount ($invoiceForm);
-
- $sql = ' ' . $con;
- $limit = $page . ',' . $page_size;
- $list = $invoicePaper->getInvoicePaper ( $limit, $sql, 'desc' );
-
- $paperList = array ();
- foreach ( $list as $key => $value ) {
- $irDetail = array ();
- if ($value ['iid'] == 0)
- array_push ( $irDetail, '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/invoicePaperDel/' . $value ['ipidKey'] . '\'" >删除</a>' );
- else
- array_push ( $irDetail, '' );
- array_push ( $irDetail, $value ['invoiceCode'] );
- array_push ( $irDetail, $value ['invoiceNo'] );
- array_push ( $irDetail, '<a href="#approvalInvice" onclick="nodeInvoice(\'' . $value ['iidKey'] . '\')" data-toggle="modal">' . $value ['invoiceSerial'] . '</a>' );
- if ($value ['invoiceType'] == 1)
- array_push ( $irDetail, $value ['invoiceCompany'] );
- else
- array_push ( $irDetail, $value ['invoiceTitle'] );
- if ($value ['invoiceType'] == 1)
- array_push ( $irDetail, '¥' . $value ['invoicePrice'] . '<sup>专</sup>' );
- else
- array_push ( $irDetail, '¥' . $value ['invoicePrice'] );
- array_push ( $irDetail, $value ['invoiceElement'] );
- array_push ( $irDetail, $value ['categoryName'] . '-' . $value ['userName'] );
- array_push ( $irDetail, $value ['printTime'] );
-
- array_push ( $paperList, $irDetail );
- }
- // $approvalListJson = json_encode ( $approvalList );
-
- $recordsFiltered = $invoiceTotal;
-
- echo json_encode ( array (
- "draw" => intval ( $draw ),
- "recordsTotal" => intval ( $invoiceTotal ),
- "recordsFiltered" => intval ( $recordsFiltered ),
- "data" => $paperList
- ), JSON_UNESCAPED_UNICODE );
- }
- function invoicePaperDel() {
- $ipidKey = isset ( $this->params ['ipidKey'] ) ? $this->params ['ipidKey'] : "";
-
- $XDeode = new XDeode ( 5 );
- $ipid = $XDeode->decode ( $ipidKey );
-
- if (empty ( $ipid ))
- die ( 'illegal request' );
-
- Doo::loadModel ( 'invoicePaper' );
- $invoicePaper = new invoicePaper ();
-
-
- $ipdetail=$invoicePaper->getInvoicePaperByIpid($ipid);
-
- $invoicePaper->delete ( array (
- 'where' => 'ipid=' . $ipid . ' and iid=0',
- 'limit' => 1
- ) );
-
- if($ipdetail['invoiceForm']==1){
- return '/invoiceElectronic';
- }else{
- return '/invoicePaper';
- }
-
-
- }
-
- /**
- * 添加纸质发票号
- */
- function invoicePaperAdd() {
- $invoiceType = $this->get_args ( 'invoiceType' ) && is_numeric ( $this->get_args ( 'invoiceType' ) ) ? $this->get_args ( 'invoiceType' ) : '0';
- $invoiceCode = $this->get_args ( 'invoiceCode' ) ? $this->get_args ( 'invoiceCode' ) : "";
- $invoiceNoStart = $this->get_args ( 'invoiceNoStart' ) && is_numeric ( $this->get_args ( 'invoiceNoStart' ) ) ? $this->get_args ( 'invoiceNoStart' ) : 0;
- $invoiceNoTotal = $this->get_args ( 'invoiceNoTotal' ) && is_numeric ( $this->get_args ( 'invoiceNoTotal' ) ) ? $this->get_args ( 'invoiceNoTotal' ) : 0;
-
- $invoiceForm = $this->get_args ( 'invoiceForm' ) && is_numeric ( $this->get_args ( 'invoiceForm' ) ) ? $this->get_args ( 'invoiceForm' ) : 0;
-
- if ($invoiceType != '' && ! empty ( $invoiceCode ) && ! empty ( $invoiceNoStart ) && ! empty ( $invoiceNoTotal )) {
-
- $sum = $invoiceNoStart + $invoiceNoTotal;
- if (empty ( $sum ))
- die ( 'illegal request' );
-
- // echo $invoiceNoStart;
- // echo $sum;
- // echo strlen((int)$invoiceNoStart);
-
- $sumLenght = strlen ( $invoiceNoStart ) - strlen ( ( int ) $invoiceNoStart );
-
- if($invoiceType==0||$invoiceType==1){
-
- }else{
- die ( 'illegal request invoiceType' );
- }
-
- if($invoiceForm==1){
- $invoiceType=0;
- }
-
-
- Doo::db ()->beginTransaction ();
- // 批量存储纸质发票
- $date = date ( "Y-m-d H:i:s" );
- $sql = 'INSERT INTO CLD_invoicePaper (invoiceType, invoiceCode,invoiceNo,date,invoiceForm)
- VALUES ';
- $paperList = array ();
- for($invoiceNoStart; $invoiceNoStart <= $sum - 1; $invoiceNoStart ++) {
-
- // 数字前面自加0
- $INLENGHT = strlen ( ( int ) $invoiceNoStart ) + $sumLenght;
- $var = sprintf ( "%0" . $INLENGHT . "d", $invoiceNoStart );
-
- $paperSql = '(' . $invoiceType . ',"' . $invoiceCode . '","' . $var . '","' . $date . '","'.$invoiceForm.'")';
- array_push ( $paperList, $paperSql );
- }
-
- if (empty ( $paperList ))
- die ( 'illegal request' );
- $sql = $sql . implode ( ',', $paperList );
-
- Doo::db ()->query ( $sql );
- Doo::db ()->commit ();
- if($invoiceForm==1){
- return 'invoiceElectronic';
- }else{
- return 'invoicePaper';
- }
-
- }
- die ( 'illegal request' );
- }
-
- /**
- * 收款绑定发票 ,//一个收款只能绑定一个发票
- */
- function invoiceBindReceivables() {
- $claimKey = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
- $invoiceKey = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
-
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
- Doo::loadModel ( 'invoiceOperationLog' );
- $invoiceOperationLog = new invoiceOperationLog ();
-
- if (empty ( $invoiceKey ) || empty ( $claimKey ))
- die ( 'illegal request' );
-
- $detail = $invoice->getInvoiceByIid ( $invoiceKey );
- $detailM = $invoiceReceivables->getInvoiceReceivablesByIrid ( $claimKey );
-
- if (empty ( $detail ) && empty ( $detailM ))
- die ( 'illegal request' );
- if ($detail ['untreadStatus'] == 3)
- die ( 'illegal request' );
-
- // 修改 绑定状态改为 金额
- $invoiceReceivables = new invoiceReceivables ();
-
- $invoicePrice = $detail ['invoicePrice'] + $detailM ['bindPrice'];
- $billPrice=0;
- if ($detailM ['receivablesPrice'] > $invoicePrice) {
- $item = array (
- 'bindPrice' => $invoicePrice
- );
- $billPrice=$invoicePrice;
- } elseif ($detailM ['receivablesPrice'] <= $invoicePrice) { //发票金额大于收款金额,绑定金额为收款金额
- $item = array (
- 'bindPrice' => $detailM ['receivablesPrice'],
- 'bindStatus' => 1,
- 'bindDate' => date ( "Y-m-d H:i:s" )
- );
- $billPrice=$detailM ['receivablesPrice'];
- } else {
- die ( 'illegal request' );
- }
-
- if ($detailM ['iid'] == 0) {
- $item += array (
- 'iid' => $detail ['iid']
- );
- } else {
- $iidExtend = explode ( ',', $detailM ['iidExtend'] );
- array_push ( $iidExtend, $detail ['iid'] );
- $item += array (
- 'iidExtend' => implode ( ',', $iidExtend )
- );
- }
-
- $titleMark = $detail ['invoiceTitle'];
- if (! empty ( $detail ['invoiceCompany'] ))
- $titleMark = $detail ['invoiceCompany'];
- $item += array (
- 'irid' => $detailM ['irid'],
- 'recepitTitleMark' => $titleMark,
- 'accountClerk' => $this->staff [0] ['username']
- );
- // 如何没有人收款 则自动绑定收款
- if ($detailM ['receivablesCategory'] == 'PUBLIC' || $detailM ['receivablesStaff'] == 'PUBLIC') {
- $item += array (
- 'receivablesCategory' => $detail ['cid'] . ':' . $detail ['categoryName'],
- 'receivablesStaff' => $detail ['sid'] . '-' . $detail ['userName']
- );
- }
-
- $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
-
- $iridString = "";
- if (empty ( $detail ['irid'] ))
- $iridString = $detailM ['irid'];
- else
- $iridString = $detail ['irid'] . ',' . $detailM ['irid'];
-
-
-
- // $invoiceReceivables = new invoiceReceivables ();
- // $sumBind = $invoiceReceivables->getSumOfReceivablesPrice ( $detail ['irid'] );
- // //这个收款余额
- // $sumBalance=$invoiceReceivables->balanceOfReceivablesPrice($detailM ['irid']);
- // $sum=$sumBind+$sumBalance;
-
- //这个收款余额
- $sumBalance=$detailM ['receivablesPrice']-$detailM ['bindPrice'];
-
- // echo $detailM ['irid'].'/'.$sumBalance.'/'.$detail ['invoicePrice'];
- // die;
- $invoice = new invoice ();
- $item = array (
- 'iid' => $detail ['iid'],
- 'irid' => $iridString
- );
-
- if ($detail ['invoicePrice'] <= $sumBalance){
- $item += array (
- 'invoiceBalance'=>0,
- 'untreadStatus' => 3,
- 'bindTime' => date ( "Y-m-d H:i:s" )
- );
- }else{
- $item += array (
- 'invoiceBalance'=>$detail ['invoicePrice']-$sumBalance,
- );
- }
- // print_r($item);
- // echo $sum;die;
- $invoice->setInvoiceByCondition ( $item );
-
- //发票入账记录
- Doo::loadModel ( 'bill' );
- $bill = new bill ();
- $bill->iid=$detail ['iid'];
- $bill->trainId=$detail['trainId'];
- $bill->irid=$detailM ['irid'];
- $bill->create_time=date ( "Y-m-d H:i:s" );
- $bill->price=$billPrice;
- $bill->insert ();
-
- // 操作日志
- $item = array (
- 'date' => date ( "Y-m-d H:i:s" ),
- 'operation' => "收款" . $detailM ['receivablesSerial'] . "入账到发票" . $detail ['invoiceSerial'],
- 'status' => 8,
- 'img' => $this->staff [0] ['avatar'],
- 'username' => $this->staff [0] ['username'],
- 'uid' => $this->staff [0] ['sid'],
- 'category' => $this->staff [0] ['category'],
- 'iid' => $detail ['iid']
- );
- $invoiceOperationLog->setInvoiceOperationLog ( $item );
-
- Doo::loadModel ( 'invoiceStatistics' );
- $invoiceStatistics = new invoiceStatistics ();
-
- $item = array (
- 'date' => $detailM ['receivablesDate'],
- 'priceClass' => 3,
-
- 'cid' => $detail ['cid'],
- 'staff' => $detail ['sid'],
- 'accountPrice' => $detailM ['receivablesPrice']
- );
- $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
- //TODO
- // 公司流水记录
- // Doo::loadModel ( 'wasteBook' );
- // $wasteBook = new wasteBook ();
-
- // $abDetail = $wasteBook->getAccountBookByAid (1,8,$detail ['iid'] );
- // $accountBank='';
- // if ($detailM ['receivablesBank']=='纵横广发'){
- // $accountBank='CGBDeposit';
- // }elseif($detailM ['receivablesBank']=='纵横工行'){
- // $accountBank='ICBCDeposit';
- // }elseif($detailM ['receivablesBank']=='华润银行'){
- // $accountBank='HUADeposit';
- // }elseif($detailM ['receivablesBank']=='个人广发'){
- // $accountBank='PersonalDeposit';
- // }
- // if (empty($abDetail)){
- // $item = array (
- // 'dataID' => $detail ['iid'],
- // 'expensesType' => 1,
- // 'accountType' => 8,
-
- // 'accountPriceShow'=>$detail ['invoicePrice'],
-
- // 'accountPrice'=>$detail ['invoicePrice'],
- // 'accountBank'=>$accountBank,
- // 'category'=>$this->staff[0]['category'],
- // 'cid'=>$this->staff[0]['cid'],
- // 'name'=>$this->staff[0]['username'],
- // 'sid'=>$this->staff[0]['sid'],
- // 'inputDate'=>date ( "Y-m-d H:i:s" )
- // );
- // $wasteBook->setAccountBookStatistics($item);
- // }
-
- return "/invoiceReceivables";
- }
-
- /**
- * 核销 动作,确认入账统计 发票收款完成--需求更变 废弃 function invoiceEnterReceivables() { $invoiceKey = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : ""; // $invoiceClaim = $this->get_args ( 'invoiceClaim' ) ? $this->get_args ( 'invoiceClaim' ) : ""; Doo::loadModel ( 'invoice' ); $invoice = new invoice (); Doo::loadModel ( 'invoiceOperationLog' ); $invoiceOperationLog = new invoiceOperationLog (); Doo::loadModel ( 'invoiceStatistics' ); $invoiceStatistics = new invoiceStatistics (); Doo::loadModel ( 'invoiceReceivables' ); $invoiceReceivables = new invoiceReceivables (); $detail = $invoice->getInvoiceByIid ( $invoiceKey ); if (empty ( $detail )) die ( 'illegal request' ); if (empty ( $detail ['irid'] )) die ( 'illegal request' ); $item = array ( 'untreadStatus' => 3, 'updateTime' => date ( "Y-m-d H:i:s" ), 'iid' => $detail ['iid'] ); $invoice->setInvoiceByCondition ( $item ); // 操作日志 $item = array ( 'date' => date ( "Y-m-d H:i:s" ), 'operation' => "发票" . $detail ['invoiceSerial'] . "收款完成", 'status' => 9, 'img' => $this->staff [0] ['avatar'], 'username' => $this->staff [0] ['username'], 'uid' => $this->staff [0] ['sid'], 'category' => $this->staff [0] ['category'], 'iid' => $detail ['iid'] ); $invoiceOperationLog->setInvoiceOperationLog ( $item ); $list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $detail ['irid'] ); $accountPrice = 0; foreach ( $list as $key => $value ) { $accountPrice += $value ['receivablesPrice']; } $item = array ( 'date' => date ( "Y-m-d H:i:s" ), 'priceClass' => 3, 'cid' => $this->staff [0] ['cid'], 'staff' => $this->staff [0] ['sid'], 'accountPrice' => $accountPrice ); $invoiceStatistics->setInvoiceStatisticsByCondition ( $item ); return "/invoice"; }
- */
- function invoiceAggregate() {
- $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
-
- Doo::loadModel ( 'invoiceStatistics' );
- $invoiceStatistics = new invoiceStatistics ();
- Doo::loadModel ( 'L_category' );
- $Lcategory = new L_category ();
-
- $isList = $invoiceStatistics->getInvoiceStatisticsByYear ( $year );
- $LcategoryList = $Lcategory->getCategory ();
- // print_r($isList);
-
- $html = ""; // $invoicePriceCategory=0;$receivablesPriceCategory=0;$accountPriceCategory=0;
- foreach ( $LcategoryList as $key => $value ) {
- $html .= '<tr><th><a href="/invoiceAggregateCategory/' . $value ['cidKey'] . '">' . $value ['title'] . '</a></th>';
- $month = 1;
- $invoicePriceYear = 0;
- $receivablesPriceYear = 0;
- $accountPriceYear = 0;
- for(; $month <= 12; $month ++) {
- $flag = true;
- foreach ( $isList ['statisticsMonthCid'] as $k => $v ) {
- if ($value ['cid'] == $v ['cid'] && $month == $v ['month']) {
- $html .= '<td class="taR">¥' . $v ['invoicePrice'] . '</td>
- <td class="taR">¥' . $v ['receivablesPrice'] . '</td>
- <td class="taR"><b>¥' . $v ['accountPrice'] . '</b></td>
- ';
- $invoicePriceYear += $v ['invoicePrice'];
- $receivablesPriceYear += $v ['receivablesPrice'];
- $accountPriceYear += $v ['accountPrice'];
- $flag = false;
- break;
- }
- }
- if ($flag)
- $html .= '<td class="taR"></td>
- <td class="taR"></td>
- <td class="taR"><b></b></td>
- ';
- }
- $html .= '<td class="taR colRed">' . $invoicePriceYear . '</td>
- <td class="taR colOrange">' . $receivablesPriceYear . '</td>
- <td class="taR colGreen"><b>' . $accountPriceYear . '</b></td>
- ';
- $html .= '</tr>';
- }
-
- $html .= '<tr><th><b class="colGreen">月合计</b></th>';
- $invoicePriceYear = 0;
- $receivablesPriceYear = 0;
- $accountPriceYear = 0;
- for($month = 1; $month <= 12; $month ++) {
- $flag = true;
- foreach ( $isList ['statisticsMonth'] as $k => $v ) {
- if ($month == $v ['month']) {
- $html .= '<td class="taR">¥' . $v ['invoicePrice'] . '</td>
- <td class="taR">¥' . $v ['receivablesPrice'] . '</td>
- <td class="taR"><b>¥' . $v ['accountPrice'] . '</b></td>
- ';
- $invoicePriceYear += $v ['invoicePrice'];
- $receivablesPriceYear += $v ['receivablesPrice'];
- $accountPriceYear += $v ['accountPrice'];
- $flag = false;
- break;
- }
- }
- if ($flag) {
- $html .= '<td class="taR"></td>
- <td class="taR"></td>
- <td class="taR"><b></b></td>
- ';
- }
- }
- $html .= '<td class="taR colRed">' . $invoicePriceYear . '</td>
- <td class="taR colOrange">' . $receivablesPriceYear . '</td>
- <td class="taR colGreen"><b>' . $accountPriceYear . '</b></td>
- ';
- $html .= '</tr>';
-
- // print_r($isList);
-
- $this->data ['html'] = $html;
- $this->data ['LcategoryList'] = $LcategoryList;
- $this->data ['isList'] = $isList;
-
- $this->data ['year'] = $year;
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoiceAggregate';
- $this->render ( "/admin/invoiceAggregate", $this->data );
- }
- function invoiceAggregateStaff() {
- $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
-
- Doo::loadModel ( 'invoiceStatistics' );
- $invoiceStatistics = new invoiceStatistics ();
- Doo::loadModel ( 'L_category' );
- $Lcategory = new L_category ();
-
- $toteList = $invoiceStatistics->getInvoiceStatisticsByTote ( $year );
- $staffList = $invoiceStatistics->getInvoiceStatisticsByStaff ( $year );
- $cStaff = $Lcategory->getCategoryStaff ();
-
- $html = '';
- foreach ( $cStaff as $key => $value ) {
- $categoryFir = true;
- foreach ( $value ['staff'] as $k => $v ) {
- if ($categoryFir) {
- $width = count ( $value ['staff'] ) + 1;
- $html .= '<tr><th rowspan="' . $width . '">' . $value ['title'] . ' </th>';
- $categoryFir = false;
- } else
- $html .= '<tr>';
- $html .= '<th>' . $v ['username'] . '</th>';
- $invoicePriceStaffYear = 0;
- $receivablesPriceStaffYear = 0;
- $accountPriceStaffYear = 0;
- for($month = 1; $month <= 12; $month ++) {
- $flag = true;
- foreach ( $staffList ['statisticsMonthStaff'] as $sl => $slv ) {
- if ($v ['sid'] == $slv ['staff'] && $month == $slv ['month']) {
- $html .= '<td class="taR">¥' . $slv ['invoicePrice'] . '</td>
- <td class="taR">¥' . $slv ['receivablesPrice'] . '</td>
- <td class="taR"><b>¥' . $slv ['accountPrice'] . '</b></td>
- ';
- $invoicePriceStaffYear += $slv ['invoicePrice'];
- $receivablesPriceStaffYear += $slv ['receivablesPrice'];
- $accountPriceStaffYear += $slv ['accountPrice'];
- $flag = false;
- break;
- }
- }
- if ($flag)
- $html .= '<td class="taR"></td>
- <td class="taR"></td>
- <td class="taR"><b></b></td>
- ';
- }
- $html .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>
- <td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>
- <td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>
- ';
- }
- $html .= '</tr>';
-
- // 小计
- if (! empty ( $value ['staff'] )) {
- $html .= '<tr><th class="taR">小计</th>';
- $invoicePriceStaffYear = 0;
- $receivablesPriceStaffYear = 0;
- $accountPriceStaffYear = 0;
- for($month = 1; $month <= 12; $month ++) {
- $flag = true;
- foreach ( $staffList ['statisticsMonthCid'] as $smc => $smcv ) {
- if ($value ['cid'] == $smcv ['cid'] && $month == $slv ['month']) {
- $html .= '<td class="taR">¥' . $smcv ['invoicePrice'] . '</td>
- <td class="taR">¥' . $smcv ['receivablesPrice'] . '</td>
- <td class="taR"><b>¥' . $smcv ['accountPrice'] . '</b></td>
- ';
- $invoicePriceStaffYear += $slv ['invoicePrice'];
- $receivablesPriceStaffYear += $slv ['receivablesPrice'];
- $accountPriceStaffYear += $slv ['accountPrice'];
- $flag = false;
- break;
- }
- }
- if ($flag)
- $html .= '<td class="taR"></td>
- <td class="taR"></td>
- <td class="taR"><b></b></td>
- ';
- }
- $html .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>
- <td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>
- <td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>
- ';
- $html .= '</tr>';
- }
- }
-
- $html .= '<tr class="warning"><th colspan="2"><b class="colGreen" >月合计</b></th>';
- $invoicePriceYear = 0;
- $receivablesPriceYear = 0;
- $accountPriceYear = 0;
- for($month = 1; $month <= 12; $month ++) {
- $flag = true;
- foreach ( $staffList ['statisticsMonth'] as $k => $v ) {
- if ($month == $v ['month']) {
- $html .= '<td class="taR colRed">¥' . $v ['invoicePrice'] . '</td>
- <td class="taR colOrange">¥' . $v ['receivablesPrice'] . '</td>
- <td class="taR colGreen"><b>¥' . $v ['accountPrice'] . '</b></td>
- ';
- $invoicePriceYear += $v ['invoicePrice'];
- $receivablesPriceYear += $v ['receivablesPrice'];
- $accountPriceYear += $v ['accountPrice'];
- $flag = false;
- break;
- }
- }
- if ($flag)
- $html .= '<td class="taR"></td>
- <td class="taR"></td>
- <td class="taR"><b></b></td>
- ';
- }
- $html .= '<td class="taR colRed">' . $invoicePriceYear . '</td>
- <td class="taR colOrange">' . $receivablesPriceYear . '</td>
- <td class="taR colGreen"><b>' . $accountPriceYear . '</b></td>
- ';
- $html .= '</tr>';
-
- $this->data ['html'] = $html;
- $this->data ['isList'] = $toteList;
- $this->data ['year'] = $year;
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoiceAggregate';
- $this->render ( "/admin/invoiceAggregateStaff", $this->data );
- }
- function invoiceAggregateCategory() {
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $cid = $cidKey = isset ( $this->params ['cid'] ) ? $this->params ['cid'] : "";
- $cid = $XDeode->decode ( $cid );
- if (! is_numeric ( $cid ))
- die ( 'illegal request' );
-
- $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
-
- Doo::loadModel ( 'invoiceStatistics' );
- $invoiceStatistics = new invoiceStatistics ();
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- $list = $staff->getStaffByCid ( $cid );
- $isCategory = $invoiceStatistics->getInvoiceStatisticsByStaff ( $year, $cid );
- $toteList = $invoiceStatistics->getInvoiceStatisticsByTote ( $year, $cid );
-
- if (empty ( $list ))
- die ( '该办事处没有成员' );
- $htmlA = $htmlB = $htmlC = $html = '';
- foreach ( $list as $key => $value ) {
- $htmlA = '<tr><th rowspan="3">' . $value ['username'] . '</th><th class="taC">开票</th>';
- $htmlB = '<tr><th class="taC">收款</th>';
- $htmlC = '<tr><th class="taC">入账</th>';
- $invoicePriceStaffYear = 0;
- $receivablesPriceStaffYear = 0;
- $accountPriceStaffYear = 0;
- for($month = 1; $month <= 12; $month ++) {
- $flag = true;
- foreach ( $isCategory ['statisticsMonthStaff'] as $k => $v ) {
- if ($value ['sid'] == $v ['staff'] && $month == $v ['month']) {
- $htmlA .= '<td class="taR">¥' . $v ['invoicePrice'] . '</td>';
- $htmlB .= '<td class="taR">¥' . $v ['receivablesPrice'] . '</td>';
- $htmlC .= '<td class="taR"><b>¥' . $v ['accountPrice'] . '</b></td>';
- $invoicePriceStaffYear += $v ['invoicePrice'];
- $receivablesPriceStaffYear += $v ['receivablesPrice'];
- $accountPriceStaffYear += $v ['accountPrice'];
- $flag = false;
- break;
- }
- }
- if ($flag) {
- $htmlA .= '<td class="taR">-</td>';
- $htmlB .= '<td class="taR">-</td>';
- $htmlC .= '<td class="taR"><b>-</b></td>';
- }
- }
- $htmlA .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>';
- $htmlB .= '<td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>';
- $htmlC .= '<td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>';
-
- $htmlA .= '</tr>';
- $htmlB .= '</tr>';
- $htmlC .= '</tr>';
- $html .= $htmlA . $htmlB . $htmlC;
- }
-
- $htmlA = $htmlB = $htmlC = "";
-
- $htmlA = '<tr><th rowspan="3">月合计</th><th class="taC">开票</th>';
- $htmlB = '<tr><th class="taC">收款</th>';
- $htmlC = '<tr><th class="taC">入账</th>';
- $invoicePriceStaffYear = 0;
- $receivablesPriceStaffYear = 0;
- $accountPriceStaffYear = 0;
- for($month = 1; $month <= 12; $month ++) {
- $flag = true;
- foreach ( $isCategory ['statisticsMonth'] as $k => $v ) {
- if ($month == $v ['month']) {
- $htmlA .= '<td class="taR colRed">¥' . $v ['invoicePrice'] . '</td>';
- $htmlB .= '<td class="taR colOrange">¥' . $v ['receivablesPrice'] . '</td>';
- $htmlC .= '<td class="taR colGreen"><b>¥' . $v ['accountPrice'] . '</b></td>';
- $invoicePriceStaffYear += $v ['invoicePrice'];
- $receivablesPriceStaffYear += $v ['receivablesPrice'];
- $accountPriceStaffYear += $v ['accountPrice'];
- $flag = false;
- break;
- }
- }
- if ($flag) {
- $htmlA .= '<td class="taR">-</td>';
- $htmlB .= '<td class="taR">-</td>';
- $htmlC .= '<td class="taR"><b>-</b></td>';
- }
- }
- $htmlA .= '<td class="taR colRed">' . $invoicePriceStaffYear . '</td>';
- $htmlB .= '<td class="taR colOrange">' . $receivablesPriceStaffYear . '</td>';
- $htmlC .= '<td class="taR colGreen"><b>' . $accountPriceStaffYear . '</b></td>';
-
- $htmlA .= '</tr>';
- $htmlB .= '</tr>';
- $htmlC .= '</tr>';
- $html .= $htmlA . $htmlB . $htmlC;
-
- $this->data ['html'] = $html;
-
- $this->data ['cidKey'] = $cidKey;
- $this->data ['slist'] = $list;
- $this->data ['isList'] = $toteList;
- $this->data ['year'] = $year;
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoiceAggregate';
- $this->render ( "/admin/invoiceAggregateCategory", $this->data );
- }
-
- /**
- * 办事处汇总信息
- */
- function invoiceAggregateCategoryDetail() {
- $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : '';
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'invoiceStatistics' );
- $invoiceStatistics = new invoiceStatistics ();
- Doo::loadModel ( 'L_category' );
- $category = new L_category ();
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel ( "invoiceCategoryManage" );
- $invoiceCategoryManage = new invoiceCategoryManage ();
-
- $imcStaff = $invoiceCategoryManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
- $cidList = array ();
- foreach ( $imcStaff as $key => $value ) {
- array_push ( $cidList, $value ['cid'] );
- if (empty ( $cidKey ))
- $cidKey = $XDeode->encode ( $value ['cid'] );
- }
- $categoryList = $category->getCategoryInCid ( implode ( ',', $cidList ) );
-
- $cid = $XDeode->decode ( $cidKey );
- $month = date ( "m", strtotime ( "-1 month" ) );
- $YearMonth = date ( "Y-m", strtotime ( "-1 month" ) );
- $redis = new Redis ();
- $redis->connect ( '127.0.0.1', '6379' );
-
- $redisKey = ''; // date('Y-m-d').'_iacd_'.$cid;
- $redisValue = ''; // $redis->lrange($redisKey, 0, -1);
-
- if (empty ( $redisValue )) {
-
- $isMC = $invoiceStatistics->getInvoiceStatistiscsMothByCategory ( $cid );
- $schedule = $invoice->getInvoiceScheduleByCid ( $cid );
-
- // 获得办事处人员下的汇总
- $slist = $staff->getStaffByCid ( $cid );
- $ismsbMonth = $invoiceStatistics->getISMSByCategoryByMonth ( $cid, $YearMonth ); // 上一个月的汇总
- $ismsb = $invoiceStatistics->getISMSByCategory ( $cid ); // 当月汇总
- $ISAS = $invoiceStatistics->getISASByCategory ( $cid ); // 全部汇总
- $scheduleStaff = $invoice->getInvoiceScheduleByCidGroupSid ( $cid ); // 完成度
-
- foreach ( $slist as $key => $value ) {
- $slist [$key] ['invoicePrice'] = 0;
- $slist [$key] ['receivablesPrice'] = 0;
- $slist [$key] ['accountPrice'] = 0;
- $slist [$key] ['invoiceAllPrice'] = 0;
- $slist [$key] ['receivablesAllPrice'] = 0;
- $slist [$key] ['accountAllPrice'] = 0;
- $slist [$key] ['schedule'] = 0;
- $slist [$key] ['invoiceMonthPrice'] = 0;
- $slist [$key] ['receivablesMonthPrice'] = 0;
- $slist [$key] ['accountMonthPrice'] = 0;
-
- foreach ( $ismsbMonth as $y => $l ) {
- if ($value ['sid'] == $l ['staff']) {
- $slist [$key] ['invoiceMonthPrice'] = $l ['invoicePrice'];
- $slist [$key] ['receivablesMonthPrice'] = $l ['receivablesPrice'];
- $slist [$key] ['accountMonthPrice'] = $l ['accountPrice'];
- }
- }
-
- foreach ( $ismsb as $k => $v ) {
- if ($value ['sid'] == $v ['staff']) {
- $slist [$key] ['invoicePrice'] = $v ['invoicePrice'];
- $slist [$key] ['receivablesPrice'] = $v ['receivablesPrice'];
- $slist [$key] ['accountPrice'] = $v ['accountPrice'];
- }
- }
- foreach ( $ISAS as $e => $a ) {
- if ($value ['sid'] == $a ['staff']) {
- $slist [$key] ['invoiceAllPrice'] = $a ['invoicePrice'];
- $slist [$key] ['receivablesAllPrice'] = $a ['receivablesPrice'];
- $slist [$key] ['accountAllPrice'] = $a ['accountPrice'];
- }
- }
- if (isset ( $scheduleStaff [$value ['sid']] ))
- $slist [$key] ['schedule'] = $scheduleStaff [$value ['sid']];
- }
- $this->data ['cidKey'] = $cidKey;
- $schedule = ( int ) ($schedule * 100);
-
- $this->data ['slist'] = $slist;
- $this->data ['isMC'] = $isMC;
- $this->data ['schedule'] = $schedule;
-
- $slist = json_encode ( $slist );
- $isMC = json_encode ( $isMC );
- $schedule = json_encode ( $schedule );
- $redis->lpush ( $redisKey, $slist );
- $redis->lpush ( $redisKey, $isMC );
- $redis->lpush ( $redisKey, $schedule );
- } else {
- $this->data ['cidKey'] = $cidKey;
-
- $this->data ['slist'] = json_decode ( $redisValue [2], true );
- $this->data ['isMC'] = json_decode ( $redisValue [1], true );
- $this->data ['schedule'] = json_decode ( $redisValue [0], true );
- }
-
- $this->data ['month'] = $month;
- $this->data ['categoryList'] = $categoryList;
-
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoiceAggregateCategoryDetail';
- $this->render ( "/admin/invoiceAggregateCategoryDetail", $this->data );
- }
-
- /**
- * 办事处人员汇总详情
- */
- function invoiceAggregateStaffDetail() {
- $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : '';
- // $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel ( "invoiceCategoryManage" );
- $invoiceCategoryManage = new invoiceCategoryManage ();
-
- $sid = $XDeode->decode ( $sidKey );
-
- $imcStaff = $invoiceCategoryManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
- $cidList = array ();
- foreach ( $imcStaff as $key => $value ) {
- array_push ( $cidList, $value ['cid'] );
- if (empty ( $cidKey ))
- $cidKey = $XDeode->encode ( $value ['cid'] );
- }
-
- $cidString = implode ( ',', $cidList );
- $staffList = $staff->getStaffInCid ( $cidString );
- $staffDetail = $staff->getStaffBySid ( $sid );
-
- $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : "";
-
- $page_size = 18;
- $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
- $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 'All';
-
- $BeginDate = date ( 'Y-m-01', strtotime ( date ( "Y-m-d" ) ) );
- $endDate = date ( 'Y-m-d', strtotime ( "$BeginDate +1 month -1 day" ) );
-
- $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : $BeginDate . " : " . $endDate;
- $dateArr = explode ( ':', $date );
- $D1 = '';
- $D2 = '';
- if (! empty ( $date )) {
- $D1 = $dateArr [0] . " 00:00:00 ";
- if (isset ( $dateArr [1] ))
- $D2 = $dateArr [1] . " 23:59:59 ";
- else
- $D2 = $dateArr [0] . " 23:59:59 "; // date ( "Y-m-d" );
- // $D2 = $dateArr [1];
- }
-
- $con = ' status=2 ';
- if (! empty ( $D1 ) && ! empty ( $D2 ))
- $con .= ' and printTime BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
-
- if ($status == 'UNRECORD')
- $con .= ' and printStatus=1 and untreadStatus=0';
- elseif ($status == 'RECORD')
- $con .= ' and printStatus=1 and untreadStatus=3';
- elseif ($status == 'BOUNCED')
- $con .= ' and untreadStatus=2';
- elseif ($status == 'PARTRECORD')
- $con .= ' and untreadStatus=0 and printStatus=1 and irid!=""';
- elseif ($status == 'All') {
- $con .= ' and ( untreadStatus=2 or untreadStatus=0 or untreadStatus=3 )';
- }
-
- $con .= ' and sid=' . $sid;
-
- $get = "/" . $status . "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea ) . "&sidKey=" . urlencode ( $sidKey );
-
- if (! empty ( $MebSea )) {
- $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" )';
- }
- $pageinfo ['page'] = array (
- 'previous' => ''
- );
- $pageinfo = $this->get_page ( "CLD_invoice", $con, $page, $page_size, "invoiceAggregateStaffDetail", $get, "" );
- $limit = $pageinfo ['lower'] . ',' . $page_size;
-
- $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $con );
-
- $this->data ['staffDetail'] = $staffDetail;
- $this->data ['staffList'] = $staffList;
- $this->data ['MebSeaEn'] = $MebSea;
- $this->data ['MebSea'] = urlencode ( $MebSea );
- $this->data ['date'] = $date;
- $this->data ['page'] = $pageinfo;
- $this->data ['get'] = $get;
- $this->data ['list'] = $list;
- $this->data ['status'] = $status;
- $this->data ['sidKey'] = $sidKey;
-
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoiceAggregateCategoryDetail';
-
- $this->render ( "/admin/invoiceAggregateStaffDetail", $this->data );
- }
-
- /**
- * 办事处人员汇总收款情
- */
- function invoiceAggregateStaffReceivablesDetail() {
- $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : '';
- // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel ( "invoiceCategoryManage" );
- $invoiceCategoryManage = new invoiceCategoryManage ();
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $sid = $XDeode->decode ( $sidKey );
- $staffDetail = $staff->getStaffBySid ( $sid );
-
- $imcStaff = $invoiceCategoryManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
- $cidList = array ();
- foreach ( $imcStaff as $key => $value ) {
- array_push ( $cidList, $value ['cid'] );
- if (empty ( $cidKey ))
- $cidKey = $XDeode->encode ( $value ['cid'] );
- }
-
- $cidString = implode ( ',', $cidList );
- $staffList = $staff->getStaffInCid ( $cidString );
-
- $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : "";
-
- $timeType = $this->get_args ( 'timeType' ) ? $this->get_args ( 'timeType' ) : "CREATE";
-
- $page_size = 10;
- $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
- $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 'All';
-
- if ($timeType == "BINDOTP") {
- $status = 'Credited';
- }
-
- $BeginDate = date ( 'Y-m-01', strtotime ( date ( "Y-m-d" ) ) );
- $endDate = date ( 'Y-m-d', strtotime ( "$BeginDate +1 month -1 day" ) );
-
- $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : $BeginDate . " : " . $endDate;
- $dateArr = explode ( ':', $date );
- $D1 = '';
- $D2 = '';
- if (! empty ( $date )) {
- $D1 = $dateArr [0] . " 00:00:00 ";
- if (isset ( $dateArr [1] ))
- $D2 = $dateArr [1] . " 23:59:59 ";
- else
- $D2 = $dateArr [0] . " 23:59:59 "; // date ( "Y-m-d" );
- }
-
- $con = ' a.receivablesStaff like "%' . $staffDetail ['username'] . '%" ';
-
- $descField = 'a.bindDate';
- if ($timeType == 'CREATE')
- $descField = 'a.date';
-
- if (! empty ( $D1 ) && ! empty ( $D2 ))
- $con .= ' and ' . $descField . ' BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
- elseif (! empty ( $D1 ) && empty ( $D2 ))
- $con .= ' and ' . $descField . ' like "%' . $D1 . '%" ';
-
- if ($status == 'Unclaimed')
- $con .= ' and a.bindStatus=0';
- elseif ($status == 'Credited')
- $con .= ' and a.bindStatus=1';
- elseif ($status == 'Claim')
- $con .= ' and a.bindStatus=0 and a.receivablesStaff="PUBLIC"';
- elseif ($status == 'BBN')
- $con .= ' and a.bindPrice>a.receivablesPrice';
-
- $get = "/" . $status . "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea ) . "&sidKey=" . urlencode ( $sidKey );
-
- if (! empty ( $MebSea )) {
- $con .= ' and ( a.receivablesMessage like "%' . $MebSea . '%" or a.receivablesPrice like "%' . $MebSea . '%" )';
- }
- $pageinfo ['page'] = array (
- 'previous' => ''
- );
-
- // $sql = 'select group_concat(b.invoiceSerial) as invoiceSerial ,group_concat(b.iid) as invoiceId
- // from CLD_invoiceReceivables as a left join CLD_invoice as b on
- // find_in_set(b.iid,a.iidExtend) or a.iid=b.iid
- // where ' . $con . ' group by a.irid ';
-
- $pageinfo =$this->get_page ( "CLD_invoiceReceivables as a", $con, $page, $page_size, "invoiceAggregateStaffReceivablesDetail", $get, "" );
-
- //$pageinfo = $this->getPageBySql ( $sql, $page, $page_size, "invoiceAggregateStaffReceivablesDetail", $get, "" );
-
-
- $limit = $pageinfo ['lower'] . ',' . $page_size;
- $list = $invoiceReceivables->getInvoiceReceivablesByConditionPage ( $limit, $con, 'desc', $descField);
- foreach ( $list as $key => $value ) {
- $list [$key] ['category'] = '';
- if ($value ['receivablesCategory'] != 'PUBLIC') {
- $receivablesCategory = explode ( ":", $value ['receivablesCategory'] );
- $list [$key] ['category'] = $receivablesCategory [1];
- }
- }
- // print_r($list);
-
- $this->data ['staffDetail'] = $staffDetail;
- $this->data ['sidKey'] = $sidKey;
- $this->data ['staffList'] = $staffList;
-
- $this->data ['timeType'] = $timeType;
-
- $this->data ['MebSeaEn'] = $MebSea;
- $this->data ['MebSea'] = urlencode ( $MebSea );
- $this->data ['date'] = $date;
- $this->data ['page'] = $pageinfo;
- $this->data ['get'] = $get;
- $this->data ['list'] = $list;
- $this->data ['status'] = $status;
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoiceAggregateCategoryDetail';
- $this->render ( "/admin/invoiceAggregateStaffReceivablesDetail", $this->data );
- }
- function invoiceAchieve() {
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- $sid = $XDeode->decode ( $_COOKIE ["staff"] );
- $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : "";
-
- $page_size = 18;
- $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
- $date = isset ( $this->params ['date'] ) ? $this->params ['date'] : 'MONTHO';
-
- $get = "/" . $date;
-
- $con = '';
- if ($date == 'MONTHO')
- $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
- elseif ($date == 'MONTHT')
- $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
- elseif ($date == 'MONTHY')
- $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
-
- if (! empty ( $MebSea )) {
- $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
- $get .= "/" . $MebSea;
- }
- $pageinfo ['page'] = array (
- 'previous' => ''
- );
- $sql = 'status=2 and printStatus=1 and irid!="" and ( untreadStatus=3 or untreadStatus=0 ) and sid=' . $sid . $con;
- $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, "invoiceAchieve", $get, "" );
-
- $limit = $pageinfo ['lower'] . ',' . $page_size;
-
- $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
- // print_r($pageinfo);
- $this->data ['MebSeaEn'] = $MebSea;
- $this->data ['MebSea'] = urlencode ( $MebSea );
- $this->data ['get'] = $get;
- $this->data ['page'] = $pageinfo;
- $this->data ['list'] = $list;
- $this->data ['date'] = $date;
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoice';
- $this->render ( "/admin/invoiceAchieve", $this->data );
- }
-
- /**
- */
- function invoiceMyUnAccountAchieve() {
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- $sid = $XDeode->decode ( $_COOKIE ["staff"] );
- $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : "";
-
- $page_size = 18;
- $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
- $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
-
- $get = "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
-
- $dateArr = explode ( ':', $date );
- $D1 = '';
- $D2 = '';
- if (! empty ( $date )) {
- $D1 = $dateArr [0];
- $D2 = $dateArr [1];
- }
- $con = '';
- if (! empty ( $D1 ) && ! empty ( $D2 ))
- $con = ' and printTime BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
-
- if (! empty ( $MebSea )) {
- $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
- }
- $pageinfo ['page'] = array (
- 'previous' => ''
- );
- // and irid='' and ( (doPost=1 and postStatus=1) or doPost=0 )
- $sql = " status=2 and printStatus=1 and untreadStatus=0 and isDelete=0 and sid= " . $sid . $con;
- $action = "invoiceMyUnAccountAchieve";
-
- $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, $action, $get, "" );
- $limit = $pageinfo ['lower'] . ',' . $page_size;
-
- $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql, 'desc', 'desc', 'printTime' );
-
- Doo::loadModel ( 'express' );
- $express = new express ();
- $expressList = $express->getExpressByAll ();
- $this->data ['expressList'] = $expressList;
-
- // print_r($list);
-
- $this->data ['MebSeaEn'] = $MebSea;
-
- $this->data ['get'] = $get;
- $this->data ['page'] = $pageinfo;
-
- $this->data ['date'] = $date;
- $this->data ['list'] = $list;
-
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoice';
-
- $this->render ( "/admin/invoiceMyUnAccountAchieve", $this->data );
- }
- function invoiceReceivablesAchieve() {
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- $sid = $XDeode->decode ( $_COOKIE ["staff"] );
- $MebSea = isset ( $this->params ['MebSea'] ) ? urldecode ( $this->params ['MebSea'] ) : '';
-
- $page_size = 12;
- $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
- $date = isset ( $this->params ['date'] ) ? $this->params ['date'] : 'MONTHO';
-
- $get = "/" . $date;
-
- $con = '';
- if ($date == 'MONTHO')
- $con = ' and bindDate>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
- elseif ($date == 'MONTHT')
- $con = ' and bindDate>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
- elseif ($date == 'MONTHY')
- $con = ' and bindDate>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
-
- if (! empty ( $MebSea )) {
- $con .= ' and ( receivablesMessage like "%' . $MebSea . '%" or receivablesPrice like "%' . $MebSea . '%" )';
- $get .= "/" . $MebSea;
- }
- $pageinfo ['page'] = array (
- 'previous' => ''
- );
- $sql = " bindStatus=1 and receivablesStaff like '" . $sid . "-%' " . $con;
- $pageinfo = $this->get_page ( "CLD_invoiceReceivables", $sql, $page, $page_size, "invoiceReceivablesAchieve", $get, "" );
-
- $limit = $pageinfo ['lower'] . ',' . $page_size;
-
- $list = $invoiceReceivables->getReceivablesByUntreadStatusPage ( $limit, $sql );
- // print_r($pageinfo);
- $this->data ['MebSeaEn'] = $MebSea;
- $this->data ['MebSea'] = urlencode ( $MebSea );
- $this->data ['get'] = $get;
- $this->data ['page'] = $pageinfo;
- $this->data ['list'] = $list;
- $this->data ['date'] = $date;
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoiceMyReceivables';
- $this->render ( "/admin/invoiceReceivablesAchieve", $this->data );
- }
-
- /**
- * 收款解绑
- */
- function invoiceUnBundLing() {
- $unBundKey = $this->get_args ( 'unBundKey' ) ? $this->get_args ( 'unBundKey' ) : '';
- $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : '';
-
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
- Doo::loadModel ( 'invoiceOperationLog' );
- $invoiceOperationLog = new invoiceOperationLog ();
- Doo::loadModel ( 'invoiceROLog' );
- $invoiceROLog = new invoiceROLog ();
- Doo::loadModel ( 'invoiceStatistics' );
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- if (empty ( $iidKey ) || empty ( $unBundKey ))
- die ( 'illegal request' );
-
- $iid = $XDeode->decode ( $iidKey );
- $irid = $invoice->authcode ( $unBundKey );
- if ((! empty ( $irid ) && ! is_numeric ( $irid )) || (! empty ( $iid ) && ! is_numeric ( $iid )))
- die ( 'illegal request' );
-
- $irDetails = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
- $invoiceDetails = $invoice->getInvoiceByIid ( $iid );
-
- if (empty ( $irDetails ) || empty ( $invoiceDetails ) || (empty ( $irDetails ['iid'] ) && empty ( $irDetails ['iidExtend'] )) || $invoiceDetails ['untreadStatus'] == 2)
- die ( 'illegal request' );
-
- // 收款
- $item = array (
- 'irid' => $irDetails ['irid'],
- 'bindPrice' => $irDetails ['bindPrice'] - $invoiceDetails ['invoicePrice'],
- 'bindStatus' => 0
- );
- if ($irDetails ['iid'] == $iid)
- $item += array (
- 'iid' => 0
- );
- else {
- $iidExtend = explode ( ',', $irDetails ['iidExtend'] );
- foreach ( $iidExtend as $key => $value ) {
- if ($value == $iid)
- unset ( $iidExtend [$key] );
- }
- $iidExtend = implode ( ',', $iidExtend );
- $item += array (
- 'iidExtend' => $iidExtend
- );
- }
-
- $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
-
- // 收款操作日志
- $item = array (
- 'operation' => $this->staff [0] ['username'] . " 解绑 " . $irDetails ['receivablesSerial'],
- 'date' => date ( "Y-m-d" ),
- 'status' => 3,
- 'img' => $this->staff [0] ['avatar'],
- 'username' => $this->staff [0] ['username'],
- 'uid' => $this->staff [0] ['sid'],
- 'category' => $this->staff [0] ['category'],
- 'irid' => $irid
- );
- $invoiceROLog->setInvoiceROLog ( $item );
-
- // 扣除入账统计金额
- $invoiceStatistics = new invoiceStatistics ();
- $item = array (
- 'date' => date ( 'Y-m-d', strtotime ( $irDetails ['receivablesDate'] ) ),
- 'priceClass' => 3,
- 'cid' => $invoiceDetails ['cid'],
- 'staff' => $invoiceDetails ['sid'],
- 'accountPrice' => - $invoiceDetails ['invoicePrice']
- );
- $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
- // 扣除收款统计金额
- $invoiceStatistics = new invoiceStatistics ();
- $item = array (
- 'date' => date ( 'Y-m-d', strtotime ( $irDetails ['receivablesDate'] ) ),
- 'priceClass' => 2,
- 'cid' => $invoiceDetails ['cid'],
- 'staff' => $invoiceDetails ['sid'],
- 'irid' => $irDetails ['irid'],
- 'receivablesPrice' => - $invoiceDetails ['invoicePrice']
- );
- $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
-
- // 发票解绑去收款ID
- $iridString = $invoiceDetails ['irid'];
- if (! empty ( $invoiceDetails ['irid'] )) {
- $list = explode ( ',', $invoiceDetails ['irid'] );
- foreach ( $list as $key => $value ) {
- if ($value == $irDetails ['irid']) {
- unset ( $list [$key] );
- break;
- }
- }
- $iridString = implode ( ",", $list );
- }
-
- //解绑后余额 加回去
-
- $invoiceBalance=$invoiceDetails['invoiceBalance']+$irDetails['receivablesPrice'];
- if ($invoiceBalance<0){
- $invoiceBalance=0;
- }
- if($invoiceBalance>$invoiceDetails['invoicePrice']){
- $invoiceBalance=$invoiceDetails['invoicePrice'];
- }
-
- $item = array (
- 'iid' => $invoiceDetails ['iid'],
- 'irid' => $iridString,
- 'invoiceBalance'=>$invoiceBalance,
- 'updateTime' => date ( "Y-m-d H:i:s" )
- );
- if ($invoiceDetails ['untreadStatus'] == 3)
- $item += array (
- 'untreadStatus' => 0
- );
- $invoice->setInvoiceByCondition ( $item );
-
-
- Doo::loadModel ( 'bill' );
- $bill = new bill ();
- $bill->iid=$invoiceDetails ['iid'];
- $bill->trainId=$invoiceDetails['trainId'];
- $bill->irid=$irDetails ['irid'];
- $bill->create_time=date ( "Y-m-d H:i:s" );
- $bill->price=-$invoiceDetails ['invoicePrice'];
- $bill->remark='解绑-扣除入账';
- $bill->insert ();
-
-
-
- $item = array (
- 'date' => date ( "Y-m-d H:i:s" ),
- 'operation' => '解绑 收款 ' . $irDetails ['receivablesSerial'],
- 'status' => 11,
- 'img' => $this->staff [0] ['avatar'],
- 'username' => $this->staff [0] ['username'],
- 'uid' => $this->staff [0] ['sid'],
- 'category' => $this->staff [0] ['category'],
- 'iid' => $invoiceDetails ['iid']
- );
- $invoiceOperationLog->setInvoiceOperationLog ( $item );
-
- // 公司流水-解绑时删除流水
- // Doo::loadModel ( 'wasteBook' );
- // $wasteBook = new wasteBook ();
-
- // $wasteBook->delete ( array (
- // 'where' => 'dataID=' . $irDetails ['irid'] . ' and accountType=7',
- // 'limit' => 1
- // ) );
-
- // 银行
-
- /*
- * $abDetail = $wasteBook->getAccountBookByAid (2,7,$irDetails ['irid'] ); $accountBank=''; if ($irDetails ['receivablesBank']=='纵横广发'){ $accountBank='CGBDeposit'; }elseif($irDetails ['receivablesBank']=='纵横工行'){ $accountBank='ICBCDeposit'; }elseif($irDetails ['receivablesBank']=='华润银行'){ $accountBank='HUADeposit'; }elseif($irDetails ['receivablesBank']=='个人广发'){ $accountBank='PersonalDeposit'; } if (empty($abDetail)){ $item = array ( 'dataID' => $irDetails ['irid'], 'expensesType' => 2, 'accountType' => 7, 'accountPriceShow'=>$irDetails ['receivablesPrice'], 'accountPrice' => -$irDetails ['receivablesPrice'], 'accountBank'=>$accountBank, 'cid'=>$this->staff[0]['cid'], 'name'=>$this->staff[0]['username'], 'sid'=>$this->staff[0]['sid'], 'inputDate'=>date ( "Y-m-d H:i:s" ) ); $wasteBook->setAccountBookStatistics($item); }
- */
- return "/invoiceReceivablesAS";
- }
-
- /**
- * 或者该收款下的所以发票
- */
- function ajaxGetInvoiceReceivablesByInvoice() {
- $irid = $this->get_args ( 'postData' ) ? $this->get_args ( 'postData' ) : '';
-
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
-
- $irid = $invoice->authcode ( $irid );
- if (! empty ( $irid ) && ! is_numeric ( $irid ))
- die ( 'illegal request' );
-
- $irDetails = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
- $iidString = $irDetails ['iid'];
-
- $iidExtend = array_filter ( explode ( ',', $irDetails ['iidExtend'] ) );
- if (! empty ( $irDetails ['iidExtend'] ))
- $iidString .= ',' . implode ( ',', $iidExtend );
-
- $invoiceList = $invoice->getInvoiceInIid ( $iidString, 'iid,invoiceSerial,invoicePrice,invoiceTitle,invoiceCompany,invoiceElement' );
-
- $html = "";
- foreach ( $invoiceList as $key => $value ) {
- $title = $value ['invoiceTitle'];
- if (! empty ( $value ['invoiceCompany'] ))
- $title = $value ['invoiceCompany'];
- $html .= '<tr><td>' . $value ['invoiceSerial'] . '</td><td>¥' . $value ['invoicePrice'] . '</td><td>' . $title . '</td><td>' . $value ['invoiceElement'] . '</td><td><input type="radio" name="iidKey" value="' . $value ['iidKey'] . '"></td></tr>';
- }
- echo json_encode ( array (
- 'status' => 1,
- 'html' => $html
- ) );
- }
-
- /**
- * 发票管理
- */
- function invoiceAS() {
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
-
- $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : "";
-
- $page_size = 18;
- $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
- $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 'All';
-
- $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
- $dateArr = explode ( ':', $date );
- $D1 = '';
- $D2 = '';
- if (! empty ( $date )) {
- $D1 = $dateArr [0] . " 00:00:00 ";
- if (isset ( $dateArr [1] ))
- $D2 = $dateArr [1] . " 23:59:59 ";
- else
- $D2 = $dateArr [0] . " 23:59:59 "; // date ( "Y-m-d" );
- // $D2 = $dateArr [1];
- }
-
- $con = ' status=2 ';
- if (! empty ( $D1 ) && ! empty ( $D2 ))
- $con .= ' and printTime BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
-
- if ($status == 'UNRECORD')
- $con .= ' and printStatus=1 and untreadStatus=0';
- elseif ($status == 'RECORD')
- $con .= ' and printStatus=1 and untreadStatus=3';
- elseif ($status == 'BOUNCED')
- $con .= ' and untreadStatus=2';
- elseif ($status == 'PARTRECORD')
- $con .= ' and untreadStatus=0 and printStatus=1 and irid!=""';
- elseif ($status == 'All') {
- $con .= ' and ( untreadStatus=2 or untreadStatus=1 or untreadStatus=0 or untreadStatus=3 )';
- }
- $get = "/" . $status . "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
-
- if (! empty ( $MebSea )) {
- $con .= ' and ( invoiceSerial like "%' . $MebSea . '%" or invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoiceNo like "%' . $MebSea . '%" )';
- }
- $pageinfo ['page'] = array (
- 'previous' => ''
- );
- $pageinfo = $this->get_page ( "CLD_invoice", $con, $page, $page_size, "invoiceAS", $get, "" );
- $limit = $pageinfo ['lower'] . ',' . $page_size;
-
- $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $con );
-
- $this->data ['MebSeaEn'] = $MebSea;
- $this->data ['MebSea'] = urlencode ( $MebSea );
- $this->data ['date'] = $date;
- $this->data ['page'] = $pageinfo;
- $this->data ['get'] = $get;
- $this->data ['list'] = $list;
- $this->data ['status'] = $status;
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoiceReceivables';
-
- $this->render ( "/admin/invoiceAS", $this->data );
- }
-
- /**
- * 收款管理
- */
- function invoiceReceivablesAS() {
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
- Doo::loadModel ( 'L_category' );
- $lCategory = new L_category ();
-
- $category = $lCategory->getCategory ();
-
- $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : "";
- $timeType = $this->get_args ( 'timeType' ) ? $this->get_args ( 'timeType' ) : "CREATE";
-
- $page_size = 10;
- $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
- $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 'All';
-
- $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
- $dateArr = explode ( ':', $date );
- $D1 = '';
- $D2 = '';
- if (! empty ( $date )) {
- $D1 = $dateArr [0]; // ." 00:00:00 ";
- if (isset ( $dateArr [1] ))
- $D2 = $dateArr [1]; // ." 23:59:59 ";
- else
- $D2 = $dateArr [0]; // ." 23:59:59 ";//date ( "Y-m-d" );
- }
-
- $descField = 'a.receivablesDate';
- if ($timeType == 'CREATE')
- $descField = 'a.date';
-
- $con = ' 1 ';
- if (! empty ( $D1 ) && ! empty ( $D2 ))
- $con .= ' and ' . $descField . ' BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
- elseif (! empty ( $D1 ) && empty ( $D2 ))
- $con .= ' and ' . $descField . ' like "%' . $D1 . '%" ';
-
- if ($status == 'Unclaimed')
- $con .= ' and a.bindStatus=0';
- elseif ($status == 'Credited')
- $con .= ' and a.bindStatus=1';
- elseif ($status == 'Claim')
- $con .= ' and a.bindStatus=0 and a.receivablesStaff="PUBLIC"';
- elseif ($status == 'BBN')
- $con .= ' and a.bankBatchNumber!=""';
- elseif ($status == 'REFUND')
- $con .= ' and ( (a.bindStatus=0 and a.refundLog!="" ) or a.bindStatus=2)';
-
- $get = "/" . $status . "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
-
- if (! empty ( $MebSea )) {
- $con .= ' and ( a.receivablesMessage like "%' . $MebSea . '%" or a.receivablesPrice like "%' . $MebSea . '%" or a.receivablesSerial like "%' . $MebSea . '%" )';
- }
- $pageinfo ['page'] = array (
- 'previous' => ''
- );
-
- // if(!empty($con)){
- // $con=' where 1 '.$con;
- // }
-
- // $sql = 'select a.iid from CLD_invoiceReceivables as a
- // ' . $con ;
-
-
-
-
- $pageinfo =$this->get_page ( "CLD_invoiceReceivables as a", $con, $page, $page_size, "invoiceReceivablesAS", $get, "" );
- //echo $sql;
- //$pageinfo = $this->getPageBySql ( $sql, $page, $page_size, "invoiceReceivablesAS", $get, "" );
- $limit = $pageinfo ['lower'] . ',' . $page_size;
- $list = $invoiceReceivables->getInvoiceReceivablesByConditionPage ( $limit, $con, 'desc', $descField );
- foreach ( $list as $key => $value ) {
- $list [$key] ['category'] = '';
- if ($value ['receivablesCategory'] != 'PUBLIC') {
- $receivablesCategory = explode ( ":", $value ['receivablesCategory'] );
- $list [$key] ['category'] = $receivablesCategory [1];
- }
- }
- // print_r($list);
-
- $this->data ['category'] = $category;
- $this->data ['timeType'] = $timeType;
- $this->data ['MebSeaEn'] = $MebSea;
- $this->data ['MebSea'] = urlencode ( $MebSea );
- $this->data ['date'] = $date;
- $this->data ['page'] = $pageinfo;
- $this->data ['get'] = $get;
- $this->data ['list'] = $list;
- $this->data ['status'] = $status;
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoiceReceivables';
- $this->render ( "/admin/invoiceReceivablesAS", $this->data );
- }
-
- /**
- * 删除一条收款
- */
- function delInvoiceReceivables() {
- $iridKey = $this->get_args ( 'iridKey' ) ? $this->get_args ( 'iridKey' ) : "";
-
- if (empty ( $iridKey ))
- die ( 'illegal request' );
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- $irid = $XDeode->decode ( $iridKey );
-
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
-
- $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
- if (empty ( $detail ))
- die ( 'illegal request' );
-
- $invoiceReceivables->delInvoiceReceivablesByIrid ( $detail ['irid'] );
-
- // 扣除收款汇总信息 汇总
- Doo::loadModel ( 'invoiceStatistics' );
- $invoiceStatistics = new invoiceStatistics ();
- $item = array (
- 'date' => $detail ['receivablesDate'],
- 'priceClass' => 2,
- 'irid' => $detail ['irid'],
- 'receivablesPrice' => - $detail ['receivablesPrice']
- );
- if ($detail ['receivablesCategory'] != 'PUBLIC') {
- $receivablesCategory = explode ( ":", $detail ['receivablesCategory'] );
- $item += array (
- 'cid' => $receivablesCategory [0]
- );
- }
- if ($detail ['receivablesStaff'] != 'PUBLIC') {
- $receivablesStaff = explode ( "-", $detail ['receivablesStaff'] );
- $item += array (
- 'staff' => $receivablesStaff [0]
- );
- }
- $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
-
- return '/invoiceReceivablesAS';
- }
-
- /**
- * 添加退款信息
- */
- function setInvoiceReceivablesRefund() {
- $iridKey = $this->get_args ( 'iridKey' ) ? $this->get_args ( 'iridKey' ) : '';
-
- $refundType = $this->get_args ( 'refundType' ) && is_numeric ( $this->get_args ( 'refundType' ) ) ? $this->get_args ( 'refundType' ) : '0';
- $refundCompany = $this->get_args ( 'refundCompany' ) ? $this->get_args ( 'refundCompany' ) : "";
- $refundNumber = $this->get_args ( 'refundNumber' ) ? $this->get_args ( 'refundNumber' ) : "";
- $refundPrice = $this->get_args ( 'refundPrice' ) ? $this->get_args ( 'refundPrice' ) : "";
- $refundRemarks = $this->get_args ( 'refundRemarks' ) ? $this->get_args ( 'refundRemarks' ) : "";
-
- if ($refundPrice < 0)
- die ( 'illegal request' );
- if (! empty ( $iridKey ) && ! empty ( $refundCompany ) && ! empty ( $refundNumber ) && ! empty ( $refundPrice )) {
-
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
- Doo::loadModel ( 'invoiceRefund' );
- $invoiceRefund = new invoiceRefund ();
-
- $irid = $invoiceReceivables->authcode ( $iridKey );
- $irDetail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
-
- if ($irDetail ['receivablesPrice'] < $refundPrice)
- die ( 'illegal request' );
-
- $invoiceReceivables = new invoiceReceivables ();
- $refundLog = $this->staff [0] ['username'] . ' 退款 <b class="colRed">¥' . $refundPrice . '</b>
- <br/><a href="#refunded" onclick="getRefundByDetail(\'' . $iridKey . '\')" data-toggle="modal">退款信息</a> <br/>' . date ( "Y-m-d H:i:s" ) . '
- ';
- $item = array (
- 'irid' => $irid,
- 'refundCompany' => $refundCompany,
- 'refundNumber' => $refundNumber,
- 'refundPrice' => $refundPrice,
- 'refundRemarks' => $refundRemarks,
- 'refundLog' => $refundLog
- );
- if ($refundType == 1) {
- $item += array (
- 'refundType' => $refundType,
- 'receivablesPrice' => $irDetail ['receivablesPrice'] - $refundPrice,
- 'bindStatus' => 2
- );
- } elseif ($refundType == 0 && $irDetail ['receivablesPrice'] <= $refundPrice) {
- $item += array (
- 'refundType' => 1,
- 'receivablesPrice' => $irDetail ['receivablesPrice'] - $refundPrice,
- 'bindStatus' => 2
- );
- } else {
- $item += array (
- 'refundType' => $refundType,
- 'receivablesPrice' => $irDetail ['receivablesPrice'] - $refundPrice
- );
- }
- $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
-
- // 添加退款记录
- $item = array (
- 'irid' => $irid,
- 'refundType' => $refundType,
- 'refundCompany' => $refundCompany,
- 'refundNumber' => $refundNumber,
- 'refundPrice' => $refundPrice,
- 'refundLog' => $refundLog,
- 'refundRemarks' => $refundRemarks,
- 'date' => date ( "Y-m-d H:i:s" )
- );
- $invoiceRefund->addInvoiceRefund ( $item );
-
- // 扣除收款汇总信息 汇总
- Doo::loadModel ( 'invoiceStatistics' );
- $invoiceStatistics = new invoiceStatistics ();
- $item = array (
- 'date' => $irDetail ['receivablesDate'],
- 'priceClass' => 2,
- 'irid' => $irDetail ['irid'],
- 'receivablesPrice' => - $refundPrice
- );
- $receivablesCategory=array(0=>'',1=>'');
- if ($irDetail ['receivablesCategory'] != 'PUBLIC') {
- $receivablesCategory = explode ( ":", $irDetail ['receivablesCategory'] );
- $item += array (
- 'cid' => $receivablesCategory [0]
- );
- }
- if ($irDetail ['receivablesStaff'] != 'PUBLIC') {
- $receivablesStaff = explode ( "-", $irDetail ['receivablesStaff'] );
- $item += array (
- 'staff' => $receivablesStaff [0]
- );
- }
- $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
-
- // 公司日常支出流水
-
- Doo::loadModel ( 'wasteBook' );
- $wasteBook = new wasteBook ();
- $accountBank=$wasteBook->_getAccountBankEN($irDetail ['receivablesBank']);
-
- $itemWaste = array (
- 'accountPrice' => - $refundPrice,
- 'expensesType' => 2,
- 'accountType' => 11,
- 'accountPriceShow' => $refundPrice,
- 'dataID' => $irid,
-
- 'accountBank' => $accountBank,
- 'category' => $receivablesCategory[1],
- 'cid' => $receivablesCategory[0],
- 'name' => $this->staff [0] ['username'],
- 'sid' => $this->staff [0] ['sid'],
- 'inputDate' => date ( "Y-m-d H:i:s" )
- );
- $wasteBook->setAccountBookStatistics ( $itemWaste );
-
- return '/invoiceReceivablesAS';
- }
- die ( 'illegal request' );
- }
- function ajaxCheckInvoiceReceivablesRefund() {
- $iridKey = $this->get_args ( 'iridKey' ) ? $this->get_args ( 'iridKey' ) : '';
- $refundPrice = $this->get_args ( 'refundPrice' ) ? $this->get_args ( 'refundPrice' ) : "";
-
- if ($refundPrice < 0) {
- echo json_encode ( array (
- 'error' => '金额不能为负'
- ) );
- die ();
- }
-
- if (! empty ( $refundPrice ) && ! empty ( $iridKey )) {
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
-
- $irid = $invoiceReceivables->authcode ( $iridKey );
- $irDetail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
-
- if ($irDetail ['receivablesPrice'] < $refundPrice) {
- echo json_encode ( array (
- 'error' => '退款金额不能超过收款金额'
- ) );
- die ();
- }
- echo json_encode ( array (
- 'ok' => '可以使用!'
- ) );
- die ();
- }
- }
-
- /**
- * 获得收款退款信息
- */
- function getRefundByDetail() {
- $iridKey = $this->get_args ( 'iridKey' ) ? $this->get_args ( 'iridKey' ) : '';
-
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
- if (! empty ( $iridKey )) {
- $irid = $invoiceReceivables->authcode ( $iridKey );
- $irDetail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
-
- echo json_encode ( array (
- 'status' => 1,
- 'irDetail' => $irDetail
- ) );
- die ();
- }
- echo json_encode ( array (
- 'status' => 2
- ) );
- }
-
- /**
- * 根据收款序列号获得收款退款信息
- */
- function ajaxGetInvoiceReceivablesBySerial() {
- $receivablesSerial = $this->get_args ( 'receivablesSerial' ) ? $this->get_args ( 'receivablesSerial' ) : '';
-
- if (! empty ( $receivablesSerial )) {
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
- // , ' and refundLog=""'
- $irDetail = $invoiceReceivables->getInvoiceReceivablesBySerial ( $receivablesSerial );
- $html = '';
- if (! empty ( $irDetail ))
- $html = '<td><b>¥' . $irDetail ['receivablesPrice'] . '</b></td>
- <td>' . $irDetail ['receivablesMessage'] . '</td>
- <td>' . $irDetail ['receivablesBank'] . '<br>' . $irDetail ['receivablesDate'] . '</td>
- <td>' . $irDetail ['title'] . '-' . $irDetail ['username'] . '<br>' . $irDetail ['confirmTime'] . '</td>
- <td>' . $irDetail ['recepitTitleMark'] . '
- <input type="hidden" name="iridKey" id="iridKey" value="' . $irDetail ['iridKey'] . '">
- </td>';
-
- echo json_encode ( array (
- 'status' => 1,
- 'html' => $html,
- 'irDetail' => $irDetail
- ) );
- die ();
- }
- echo json_encode ( array (
- 'status' => 2
- ) );
- }
-
- /**
- * 绑定新收款
- */
- function relationNewInvoiceReceivables() {
- $iridKeyOld = $this->get_args ( 'iridKeyOld' ) ? $this->get_args ( 'iridKeyOld' ) : '';
- $iridKey = $this->get_args ( 'iridKey' ) ? $this->get_args ( 'iridKey' ) : '';
-
- if (! empty ( $iridKeyOld ) && ! empty ( $iridKey )) {
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $irid = $XDeode->decode ( $iridKey );
- $iridOld = $invoiceReceivables->authcode ( $iridKeyOld );
- echo $irid . 'bbb' . $iridOld;
- $oldIrDetail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $iridOld );
- $IrDetail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
-
- if (empty ( $oldIrDetail ) || empty ( $IrDetail ))
- die ( 'illegal request' );
-
- $relationLog = $this->staff [0] ['username'] . ' 关联新款 <a href="#billing" onclick="invoiceReceivblesDivShow(\'' . $iridKey . '\',\'receivables\')" data-toggle="modal">' . $IrDetail ['receivablesSerial'] . '</a>
- <br/>' . date ( "Y-m-d H:i:s" ) . '
- ';
- $invoiceReceivables = new invoiceReceivables ();
- $item = array (
- 'irid' => $iridOld,
- 'relationIrid' => $irid,
- 'relationLog' => $relationLog
- );
- $invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
-
- return '/invoiceReceivablesAS';
- }
- die ( 'illegal request' );
- }
-
- // function invoiceApprovalAchieve() {
- // Doo::loadModel ( 'invoice' );
- // $invoice = new invoice ();
-
- // $MebSea = isset ( $this->params ['MebSea'] ) ? urldecode ( $this->params ['MebSea'] ) : '';
-
- // $page_size = 12;
- // $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
- // $date = isset ( $this->params ['date'] ) ? $this->params ['date'] : 'MONTHO';
-
- // $get = "/" . $date;
-
- // $con = '';
- // if ($date == 'MONTHO')
- // $con = ' and approvalTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
- // elseif ($date == 'MONTHT')
- // $con = ' and approvalTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
- // elseif ($date == 'MONTHY')
- // $con = ' and approvalTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
-
- // if (! empty ( $MebSea )) {
- // $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
- // $get .= "/" . $MebSea;
- // }
- // $pageinfo ['page'] = array (
- // 'previous' => ''
- // );
- // $sql = '(status=1 or status=2 or status=3 or status=4) and processApprovals!=""' . $con; // echo $sql;
- // $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, "invoiceApprovalAchieve", $get, "" );
-
- // $limit = $pageinfo ['lower'] . ',' . $page_size;
-
- // $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql, 'desc', 2 );
- // // print_r($list);
- // $this->data ['MebSeaEn'] = $MebSea;
- // $this->data ['MebSea'] = urlencode ( $MebSea );
- // $this->data ['get'] = $get;
- // $this->data ['page'] = $pageinfo;
- // $this->data ['list'] = $list;
- // $this->data ['date'] = $date;
-
- // $this->data ['memu'] = "invoice";
- // $this->data ['staff'] = $this->staff;
- // $this->data ['receiptMemu'] = 'invoiceApproval';
- // $this->render ( "/admin/invoiceApprovalAchieve", $this->data );
- // }
-
- /**
- * 获得审批发票的信息以及审批页面
- */
- function ajaxGetInvoiceApprovalDetail() {
- $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
-
- if (empty ( $serial )) {
- echo json_encode ( array (
- 'status' => 2,
- 'msg' => 'illegal request'
- ) );
- die ();
- }
-
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'invoiceOperationLog' );
- $invoiceOperationLog = new invoiceOperationLog ();
-
- $detail = $invoice->getInvoiceByIsid ( $serial, $this->staff [0] ['sid'] );
- $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $detail ['iid'] );
-
- if (empty ( $detail ))
- $html = '';
- else {
- $html = '
-
- <form action="/invoiceApprovalDo" method="post" name="invoiceApproval" class="nice-validator n-yellow" novalidate="novalidate">
- <input type="hidden" name="invoiceKey" value="' . $detail ['iidKeyXD'] . '">
- <input type="hidden" name="status" value="">
- <input type="hidden" name="divApproval" value="divApproval">
-
- <div class="modal-dialog modal-lg">
- <div class="modal-content"><div class="modal-header"><h3>发票审批详情</h3></div>
- <div class="modal-body saeaList"><table class="table table-bordered table-condensed"><tbody>
-
- <tr>
- <th class="taC" width="150">发票审批</th><td><textarea name="opinion" style="width:98%" placeholder="在这写下您的审批意见,选填。"></textarea></td>
- </tr>
-
- <tr>
- <th class="taC" width="150">开票流水号</th><td>' . $detail ['invoiceSerial'] . '</td>
- <th class="taC" width="150">提交时间</th><td>' . $detail ['date'] . '</td>
- </tr>
- <tr>
- <th class="taC" width="150">所在办事处</th><td>' . $detail ['categoryName'] . '(' . $detail ['userName'] . ')</td>
- <th class="taC" width="150">开票内容</th><td>' . $detail ['invoiceElement'] . '</td>
- </tr>
-
- <tr>
- <th class="taC">发票备注</th><td colspan="3">' . $detail ['remark'] . '
- </td>
- </tr>
-
- <tr>
- <th class="taC" width="150">数量</th><td><b>' . $detail ['invoiceQuantity'] . '</b></td>
- <th class="taC">单价</th><td><b>¥' . $detail ['invoiceUnitPrice'] . '</b></td>
- </tr>
-
- <tr>
- <th class="taC">开票金额</th><td colspan="3"><b class="colOrange" style="font-size:18px">¥' . $detail ['invoicePrice'] . '</b></td>
-
- </tr></tbody></table>';
-
- if ($detail ['invoiceType'] == 0)
- $html .= '<table class="table table-bordered table-condensed"><tbody>
- <tr><th colspan="4" class="taC">增值税普通发票</th></tr><tr>
- <th class="taC" width="150">发票抬头</th><td >' . $detail ['invoiceTitle'] . '</td>
- <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td>
- </tr>';
- else
- $html .= '<table class="table table-bordered table-condensed"><tbody>
- <tr><th colspan="4" class="taC">增值税专用发票</th></tr><tr>
- <th class="taC" width="150">单位名称</th><td>' . $detail ['invoiceCompany'] . '</td>
- <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td></tr>
-
- ';
-
- $html .= '<tr>
- <th class="taC">注册地址</th><td>' . $detail ['address'] . '</td>
- <th class="taC">注册电话</th><td>' . $detail ['phone'] . '</td>
- </tr>
- <tr>
- <th class="taC">开户银行</th><td>' . $detail ['bank'] . '</td>
- <th class="taC">银行账号</th><td>' . $detail ['bankAccount'] . '</td>
- </tr></tbody></table>';
-
- if ($detail ['doPost'] == 1) {
- $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th colspan="4" class="taC">邮寄信息</th></tr><tr>
- <th class="taC" width="150">收件人</th><td>' . $detail ['recipients'] . '</td>
- <th class="taC" width="150">收件人手机/电话</th><td>' . $detail ['recipientsPhone'] . '</td>
- </tr><tr>
- <th class="taC" width="150">收件地址</th><td colspan="3">' . $detail ['recipientsAddress'] . '</td>
- </tr><tr>
- <th class="taC" width="150">邮寄物品</th><td colspan="3">' . $detail ['mailItems'] . '</td>
- </tr>
- ';
-
- if ($detail ['expressCom'] == 'SF')
- $html .= '<tr><th class="taC" width="150">快递单号</th><td colspan="3">' . $detail ['expressCompany'] . ' <a target="_blank" href="http://www.sf-express.com/cn/sc/dynamic_function/waybill/#search/bill-number/">' . $detail ['expressNumber'] . '</a> </td></tr>';
- else
- $html .= '<tr><th class="taC" width="150">快递单号</th><td colspan="3">' . $detail ['expressCompany'] . ' <a target="_blank" href="/invoiceExpress/' . $detail ['expressCom'] . '/' . $detail ['expressNumber'] . '.html">' . $detail ['expressNumber'] . '</a> </td></tr>';
- $html .= '</tbody></table>';
- }
- if (! empty ( $invoiceOperationLogList )) {
- $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th width="60%" class="taC">审批流程</th></tr><tr><td>';
- foreach ( $invoiceOperationLogList as $key => $value ) {
- if ($value ['status'] == 1 || $value ['status'] == 2 || $value ['status'] == 3 || $value ['status'] == 4) {
- $html .= '<blockquote><p><span class="colGray">' . $value ['date'] . '</span>
- ' . $value ['category'] . '-' . $value ['username'] . ' ';
- if ($value ['status'] == 2) {
- $html .= '<span class="colGreen">同意</span>';
- } elseif ($value ['status'] == 3) {
- $html .= '<span class="colOrange">退回</span>';
- } elseif ($value ['status'] == 5) {
- $html .= '<span class="colGreen">打印</span>';
- } elseif ($value ['status'] == 4) {
- $html .= '<span class="colRed">终止</span>';
- }
- $html .= $value ['operation'] . '</p></blockquote>';
- }
- }
- $html .= '</td></tr></tbody></table>';
- }
- $html .= '</div><div class="modal-footer">
- <a href="javascript:void(0)" node-approval="approval" diss-data="2" class="button btn-done" data-placement="top" data-toggle="ctooltip" >同意</a>
- <a href="javascript:void(0)" node-approval="approval" diss-data="3" class="button btn-back" data-placement="top" data-toggle="ctooltip" data-original-title="上报人修改后重新审批">退回</a>
- <a href="javascript:void(0)" node-approval="approval" diss-data="4" class="button btn-undone" data-placement="top" data-toggle="ctooltip" data-original-title="终止发票申请">终止</a>
-
- <a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>
- </form>
- <script type="text/javascript">
- $("a[node-approval^=\'approval\']").click(function() {
- $("input[name=\'status\']").val($(this).attr("diss-data"));
- $("form[name=\'invoiceApproval\']").submit();
- });
- </script>
-
- ';
- }
- echo json_encode ( array (
- 'status' => 1,
- 'html' => $html
- ) );
- die ();
- }
-
- /**
- * 获得审批发票分页数据
- */
- function ajaxGetinvoiceApprovalAchieve() {
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'invoiceTraining' );
- $invoiceTraining = new invoiceTraining ();
-
- $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'ALL';
- $invoiceType = $this->get_args ( 'invoiceType' ) ? $this->get_args ( 'invoiceType' ) : "ALL";
- $invoiceTrain = $this->get_args ( 'invoiceTrain' ) ? $this->get_args ( 'invoiceTrain' ) : "ALL";
- $invoiceTrainName = $this->get_args ( 'invoiceTrainName' ) ? $this->get_args ( 'invoiceTrainName' ) : "ALL";
- $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
-
- $page = $this->get_args ( 'start' ) && is_numeric ( $this->get_args ( 'start' ) ) ? $this->get_args ( 'start' ) : 0;
- $draw = $this->get_args ( 'draw' ) && is_numeric ( $this->get_args ( 'draw' ) ) ? $this->get_args ( 'draw' ) : 1;
- $length = $this->get_args ( 'length' ) && is_numeric ( $this->get_args ( 'length' ) ) ? $this->get_args ( 'length' ) : 10;
-
- $MebSea = $this->get_args ( 'search' );
- $MebSea = $MebSea ['value'];
-
- $page_size = $length;
-
- $con = '';
- if ($status == 'ALL')
- $con = ' (status=1 or status=2 or status=3 or status=4) and isDelete=0 ';
- elseif ($status == 'PEND')
- $con = ' isDelete=0 and status=1';
- elseif ($status == 'APPROVED')
- $con = ' isDelete=0 and status=2';
-
- if ($invoiceType == 'ORDINARY')
- $con .= ' and invoiceType=0 ';
- elseif ($invoiceType == 'SPECIAL')
- $con .= ' and invoiceType=1 ';
-
- if ($invoiceTrain == 'ORDINARY')
- $con .= ' and trainId=0 ';
- elseif ($invoiceTrain == 'TRAIN')
- $con .= ' and trainId!=0 ';
-
- if ($invoiceTrainName != 'ALL') {
- $trainId = $XDeode->decode ( $invoiceTrainName );
- if (is_numeric ( $trainId ))
- $con .= ' and trainId =' . $trainId;
- }
-
- $dateArr = explode ( ':', $date );
- $D1 = $dateString = '';
- $D2 = '';
- if (! empty ( $date )) {
- $D1 = $dateArr [0];
- if (isset ( $dateArr [1] ))
- $D2 = $dateArr [1];
- else
- $D2 = '';
- $dateString = $D1 . " : " . $D2;
- }
- if (! empty ( $D1 ) && ! empty ( $D2 ))
- $con .= ' and approvalTime BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
- elseif (! empty ( $D1 ) && empty ( $D2 ))
- $con .= ' and approvalTime like "%' . $D1 . '%" ';
-
- if (! empty ( $MebSea ))
- $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" or invoiceSerial like "%' . $MebSea . '%" )';
-
- // /
- $pageinfo ['page'] = array (
- 'previous' => ''
- );
- $sql = ' ' . $con;
- $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, "invoiceApprovalAchieve", '', "" );
-
- $limit = $page . ',' . $page_size;
- $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql, 'desc', 2 );
-
- $approvalList = array ();
-
- $html = '<script type="text/javascript">
-
- </script>';
-
- // 结算结束不能修改方式
- Doo::loadModel ( 'receipt' );
- $receipt = new receipt ();
-
- foreach ( $list as $key => $value ) {
- $irDetail = array ();
-
- // 结算方式
- $receiptDetail = array ();
- if ($value ['trainId'] != 0) {
- $receiptDetail = $receipt->getReceiptByinvoiceTrainId ( $value ['trainId'] );
- }
-
- if (! empty ( $receiptDetail )) {
- if ($receiptDetail ['status'] == 8 || $receiptDetail ['status'] == 9) {
- array_push ( $irDetail, '' );
- } else {
- if ($value ['status'] == 1 && $value ['pendingApprovals'] == $this->staff [0] ['sid']) {
- array_push ( $irDetail, '<a href="#approvalInvice" onclick="nodeInvoiceApproval(\'' . $value ['iidKeyK'] . '\')" data-toggle="modal">审批发票</a>' );
- } elseif ($value ['status'] == 2) {
- array_push ( $irDetail, '<a href="#editPay" class="fnSettlementType" data-iidKey="' . $value ['iidKeyK'] . '" data-toggle="modal">结算方式</a>' );
- } else
- array_push ( $irDetail, '' );
- }
- } else {
- if ($value ['status'] == 2) {
- array_push ( $irDetail, '<a href="#editPay" class="fnSettlementType" data-iidKey="' . $value ['iidKeyK'] . '" data-toggle="modal">结算方式</a>' );
- } else{
- if ($value ['status'] == 1 && $value ['pendingApprovals'] == $this->staff [0] ['sid']) {
- array_push ( $irDetail, '<a href="#approvalInvice" onclick="nodeInvoiceApproval(\'' . $value ['iidKeyK'] . '\')" data-toggle="modal">审批发票</a>' );
- }else{
- array_push ( $irDetail, '' );
- }
-
-
- }
-
- }
-
- array_push ( $irDetail, '<a href="#approvalInvice" onclick="nodeInvoice(\'' . $value ['iidKeyK'] . '\')" data-toggle="modal">' . $value ['invoiceSerial'] . '</a>' );
-
- if ($value ['invoiceType'] == 1)
- array_push ( $irDetail, $value ['invoiceCompany'] );
- else
- array_push ( $irDetail, $value ['invoiceTitle'] );
- array_push ( $irDetail, $value ['TIN'] );
- array_push ( $irDetail, $value ['address'] . $value ['phone'] );
- array_push ( $irDetail, $value ['bank'] . $value ['bankAccount'] );
- array_push ( $irDetail, $value ['remark'] );
- array_push ( $irDetail, $value ['invoiceElement'] );
- array_push ( $irDetail, $value ['invoiceQuantity'] );
- array_push ( $irDetail, $value ['invoiceUnitPrice'] );
- if ($value ['invoiceType'] == 1) {
- array_push ( $irDetail, '¥' . $value ['invoicePrice'] . '<sup>专</sup>' );
- } else {
- array_push ( $irDetail, '¥' . $value ['invoicePrice'] );
- }
-
- if ($value ['settlementType'] == 0) {
- array_push ( $irDetail, '软件销售' );
- } else {
- $itDetail = $invoiceTraining->getInvoiceTrainingByItid ( $value ['trainId'] );
- array_push ( $irDetail, $itDetail ['trainName'] );
- }
-
- array_push ( $irDetail, $value ['recipients'] . $value ['recipientsPhone'] );
- array_push ( $irDetail, $value ['recipientsAddress'] );
- array_push ( $irDetail, $value ['mailItems'] );
-
- array_push ( $irDetail, $value ['userName'] . ' ' . $value ['date'] );
-
- $fchtml = $value ['OL'] ['operation'];
- if (count ( $list ) == $page_size)
- $fchtml = $value ['OL'] ['operation'] . $html;
- // 最后的审批意见
- array_push ( $irDetail, $fchtml );
-
- if ($value ['status'] == 2)
- array_push ( $irDetail, '<span class="colGreen">同意</span>' . $value ['OL'] ['username'] . $value ['OL'] ['date'] );
- elseif ($value ['status'] == 3)
- array_push ( $irDetail, '<span class="colOrange">退回</span>' . $value ['OL'] ['username'] . $value ['OL'] ['date'] );
- elseif ($value ['status'] == 4)
- array_push ( $irDetail, '<span class="colRed">终止</span>' . $value ['OL'] ['username'] . $value ['OL'] ['date'] );
- else
- array_push ( $irDetail, '' );
-
- array_push ( $approvalList, $irDetail );
- }
- // $approvalListJson = json_encode ( $approvalList );
-
- $recordsFiltered = $pageinfo ['total_data'];
-
- echo json_encode ( array (
- "draw" => intval ( $draw ),
- "recordsTotal" => intval ( $pageinfo ['total_data'] ),
- "recordsFiltered" => intval ( $recordsFiltered ),
- "data" => $approvalList
- ), JSON_UNESCAPED_UNICODE );
- }
-
- /**
- * 审批发票查看更多--重构
- */
- function invoiceApprovalAchieve() {
- $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 'ALL';
- $invoiceType = $this->get_args ( 'invoiceType' ) ? $this->get_args ( 'invoiceType' ) : "ALL";
- $invoiceTrain = $this->get_args ( 'invoiceTrain' ) ? $this->get_args ( 'invoiceTrain' ) : "ALL";
- $invoiceTrainName = $this->get_args ( 'invoiceTrainName' ) ? $this->get_args ( 'invoiceTrainName' ) : "ALL";
- $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
-
- Doo::loadModel ( 'invoiceTraining' );
- $invoiceTraining = new invoiceTraining ();
- $trainList = $invoiceTraining->getInvoiceTrainingBySubmitStatus ();
-
- $this->data ['trainList'] = $trainList;
- $this->data ['dateString'] = $date;
- $this->data ['status'] = $status;
- $this->data ['invoiceType'] = $invoiceType;
- $this->data ['invoiceTrain'] = $invoiceTrain;
- $this->data ['invoiceTrainName'] = $invoiceTrainName;
-
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoiceApproval';
- $this->render ( "/admin/invoiceApprovalAchieve", $this->data );
- }
- function invoiceTAchieve() {
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- $MebSea = isset ( $this->params ['MebSea'] ) ? urldecode ( $this->params ['MebSea'] ) : '';
-
- $page_size = 12;
- $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
- $date = isset ( $this->params ['date'] ) ? $this->params ['date'] : 'MONTHO';
-
- $invoiceType = $this->get_args ( 'invoiceType' ) ? $this->get_args ( 'invoiceType' ) : "ALL";
- $invoiceTrain = $this->get_args ( 'invoiceTrain' ) ? $this->get_args ( 'invoiceTrain' ) : "ALL";
- $invoiceTrainName = $this->get_args ( 'invoiceTrainName' ) ? $this->get_args ( 'invoiceTrainName' ) : "ALL";
-
- Doo::loadModel ( 'invoiceTraining' );
- $invoiceTraining = new invoiceTraining ();
- $trainList = $invoiceTraining->getInvoiceTrainingBySubmitStatus ();
-
- $get = "/" . $date;
-
- $con = '';
- if ($date == 'MONTHO')
- $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 MONTH)';
- elseif ($date == 'MONTHT')
- $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)';
- elseif ($date == 'MONTHY')
- $con = ' and YEAR(updateTime) = YEAR(NOW())'; // $con = ' and updateTime>DATE_SUB(CURDATE(), INTERVAL 1 YEAR)';
-
- if ($invoiceType == 'ORDINARY')
- $con .= ' and invoiceType=0 ';
- elseif ($invoiceType == 'SPECIAL')
- $con .= ' and invoiceType=1 ';
-
- if ($invoiceTrain == 'ORDINARY')
- $con .= ' and trainId=0 ';
- elseif ($invoiceTrain == 'TRAIN')
- $con .= ' and trainId!=0 ';
-
- if ($invoiceTrainName != 'ALL') {
- $trainId = $XDeode->decode ( $invoiceTrainName );
- if (is_numeric ( $trainId ))
- $con .= ' and trainId =' . $trainId;
- }
-
- if (! empty ( $MebSea )) {
- $con .= ' and ( invoiceTitle like "%' . $MebSea . '%" or invoiceCompany like "%' . $MebSea . '%" or invoicePrice like "%' . $MebSea . '%" )';
- $get .= "/" . $MebSea;
- }
- $pageinfo ['page'] = array (
- 'previous' => ''
- );
-
- $sql = "";
- $action = "";
- if ($this->ACTION == 'invoicePrintAchieve') {
- $sql = "status=2 and printStatus=1 and moldManage like '%[\"" . $this->staff [0] ['sid'] . "\",%'" . $con;
- $action = "invoicePrintAchieve";
- } elseif ($this->ACTION == 'invoicePostAchieve') {
- // and untreadStatus=0
- $sql = "postStatus=1 and doPost=1 and status=2 and isDelete=0" . $con;
- $action = "invoicePostAchieve";
- } elseif ($this->ACTION == 'invoiceUntreadAchieve') { // printStatus=1 and
- $sql = " untreadStatus=2 and status=2 " . $con;
- $action = "invoiceUntreadAchieve";
- }
-
- $pageinfo = $this->get_page ( "CLD_invoice", $sql, $page, $page_size, $action, $get, "" );
- $limit = $pageinfo ['lower'] . ',' . $page_size;
-
- $this->data ['MebSeaEn'] = $MebSea;
- $this->data ['MebSea'] = urlencode ( $MebSea );
- $this->data ['get'] = $get;
- $this->data ['page'] = $pageinfo;
-
- $this->data ['trainList'] = $trainList;
- $this->data ['invoiceType'] = $invoiceType;
- $this->data ['invoiceTrain'] = $invoiceTrain;
- $this->data ['invoiceTrainName'] = $invoiceTrainName;
-
- $this->data ['date'] = $date;
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
-
- if ($this->ACTION == 'invoicePrintAchieve') {
- $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql, 'desc', 5 );
-
- $this->data ['receiptMemu'] = 'invoicePrint';
- $this->data ['list'] = $list;
- $this->render ( "/admin/invoicePrintAchieve", $this->data );
- } elseif ($this->ACTION == 'invoicePostAchieve') {
- $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql );
- Doo::loadModel ( 'express' );
- $express = new express ();
- $expressList = $express->getExpressByAll ();
-
- $this->data ['expressList'] = $expressList;
- $this->data ['receiptMemu'] = 'invoicePost';
- $this->data ['list'] = $list;
- $this->render ( "/admin/invoicePostAchieve", $this->data );
- } elseif ($this->ACTION == 'invoiceUntreadAchieve') {
- $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $sql,'desc','desc','untreadTime' );
- $this->data ['receiptMemu'] = 'invoiceUntread';
- $this->data ['list'] = $list;
- $this->render ( "/admin/invoiceUntreadAchieve", $this->data );
- }
- }
-
- /**
- * 公司应收款
- */
- function invoiceAggregateCompanyDetail() {
- $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : '';
- $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : '';
- $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : 'ALL';
- $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
- $invoiceElement = $this->get_args ( 'invoiceElement' ) ? $this->get_args ( 'invoiceElement' ) : "";
-
- $titleORno = $this->get_args ( 'titleORno' ) ? $this->get_args ( 'titleORno' ) : "";
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel ( "invoiceCompanyManage" );
- $invoiceCompanyManage = new invoiceCompanyManage ();
- Doo::loadModel ( 'L_category' );
- $category = new L_category ();
-
- $sid = '';
- if (! empty ( $sidKey )) {
-
- $sid = $XDeode->decode ( $sidKey );
- }
- $staffDetail = $staff->getStaffBySid ( $sid );
-
- $cid = '';
- if (! empty ( $cidKey )) {
-
- $cid = $XDeode->decode ( $cidKey );
- }
-
- $imcStaff = $invoiceCompanyManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
- $cidList = array ();
- foreach ( $imcStaff as $key => $value ) {
- array_push ( $cidList, $value ['cid'] );
- }
- $categoryList = $category->getCategoryInCid ( implode ( ',', $cidList ) );
-
- $cidString = implode ( ',', $cidList );
-
- if (empty ( $cid ))
- $staffList = $staff->getStaffInCid ( $cidString );
- else
- $staffList = $staff->getStaffByCidAll ( $cid ); //
-
- //$MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : "";
-
- $page_size = 25;
- $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
- $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 'All';
-
- $con = ' status=2 and untreadStatus!=2 and invalid=0 and isDelete=0 and badDebt=0 ';
-
- $statisticsCon = '';
- if (! empty ( $year ) && is_numeric ( $year ))
- $con .= ' and Year(printTime)=' . $year . '';
- if (! empty ( $month ) && is_numeric ( $month ))
- $con .= ' and Month(printTime)="' . $month . '" ';
-
- if ($status == 'UNRECORD')
- $con .= ' and printStatus=1 and untreadStatus=0';
- elseif ($status == 'RECORD')
- $con .= ' and printStatus=1 and untreadStatus=3';
- elseif ($status == 'BOUNCED')
- $con .= ' and untreadStatus=2';
- elseif ($status == 'PARTRECORD')
- $con .= ' and untreadStatus=0 and printStatus=1 and irid!=""';
- elseif ($status == 'All') {
- $con .= ' and printStatus=1 and ( untreadStatus=0 or untreadStatus=3 )';
- }
-
- if (! empty ( $sid ) && is_numeric ( $sid ))
- $con .= ' and sid=' . $sid;
-
- if (! empty ( $cid ) && is_numeric ( $cid ))
- $con .= ' and cid=' . $cid;
- else
- $con .= ' and cid in (' . $cidString . ')';
- // 开票内容筛选
- if (! empty ( $invoiceElement ) && $invoiceElement != 'ALL') {
- $con .= ' and invoiceElement="' . $invoiceElement . '"';
- }
-
- $get = "/" . $status . "?cidKey=" . $cidKey . "&sidKey=" . $sidKey . "&year=" . $year . "&month=" . $month
- . "&invoiceElement=" . $invoiceElement."&titleORno=".urlencode ( $titleORno );
-
- if (! empty ( $titleORno )) {
- $con .= ' and ( invoiceTitle like "%' . $titleORno . '%" or invoiceCompany like "%' . $titleORno . '%" or invoiceNo like "%'.$titleORno.'%" )';
- }
-
- $pageinfo ['page'] = array (
- 'previous' => ''
- );
- $pageinfo = $this->get_page ( "CLD_invoice", $con, $page, $page_size, "invoiceAggregateCompanyDetail", $get, "" );
- $limit = $pageinfo ['lower'] . ',' . $page_size;
-
- // 应收款合计
- $ics = $invoice->getInvoiceCompanyStatistics ( $con );
-
- //,'desc','desc','printTime'
- $list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $con );
-
- $totalPrice=array('invoicePrice'=>0.00,'receivePrice'=>0.00,'receivablesPrice'=>0.00);
- foreach ($list as $key=>$value){
-
- $totalPrice['invoicePrice']=bcadd($totalPrice['invoicePrice'], $value['invoicePrice'],2);
- if($value['sumPrice']!=0){
- $totalPrice['receivePrice']=bcadd($totalPrice['receivePrice'], $value['sumPrice'],2);
- }
- if($value['diffPrice']!=0){
- $totalPrice['receivablesPrice']=bcadd($totalPrice['receivablesPrice'], $value['diffPrice'],2);
- }
- }
- $this->data ['totalPrice'] = $totalPrice;
-
- $monthHtml = "";
- if ($year != "ALL") {
- for($i = 1; $i <= 12; $i ++) {
- if ($i == $month)
- $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
- else
- $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
- }
- }
- $this->data ['monthHtml'] = $monthHtml;
- $this->data ['year'] = $year;
- $this->data ['month'] = $month;
-
- $this->data ['ics'] = $ics;
- $this->data ['cidKey'] = $cidKey;
- $this->data ['sid'] = $sid;
- $this->data ['staffDetail'] = $staffDetail;
- $this->data ['staffList'] = $staffList;
- $this->data ['titleORnoEn'] = $titleORno;
- $this->data ['titleORno'] = urlencode ( $titleORno );
-
- $this->data ['invoiceDetail'] = array (
- 'invoiceElement' => $invoiceElement
- );
- $this->data ['page'] = $pageinfo;
- $this->data ['get'] = $get;
- $this->data ['list'] = $list;
- $this->data ['status'] = $status;
- $this->data ['categoryList'] = $categoryList;
-
- $this->data ['memu'] = "invoice";
- $this->data ['staff'] = $this->staff;
- $this->data ['receiptMemu'] = 'invoiceAggregateCompanyDetail';
-
- $this->render ( "/admin/invoiceAggregateCompanyDetail", $this->data );
- }
-
- /**
- * 获取一条收款信息
- */
- function ajaxGetInvoiceReceivables() {
- $irid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
-
- $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
-
- echo json_encode ( array (
- 'status' => 1,
- 'detail' => $detail
- ) );
- }
-
- /**
- * 异步获取办事处用户
- */
- function ajaxGetStaffByCategory() {
- $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "";
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- if ($cid == "PUBLIC") {
- echo json_encode ( array (
- 'status' => 1,
- 'html' => '<option value="PUBLIC">办事处待认领款项</option>'
- ) );
- die ();
- }
-
- if (! is_numeric ( $cid )) {
- echo json_encode ( array (
- 'status' => 0,
- 'msg' => 'illegal request'
- ) );
- die ();
- }
-
- $staffList = $staff->getStaffByCid ( $cid );
-
- $html = '<option value="PUBLIC">办事处待认领款项</option>';
- foreach ( $staffList as $key => $value ) {
- $html .= '<option value="' . $value ['sid'] . '-' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
- }
-
- echo json_encode ( array (
- 'status' => 1,
- 'html' => $html
- ) );
- }
-
- /**
- * 异步获取一条发票的邮寄信息
- */
- function ajaxGetInvoicePostDetail() {
- $iid = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- $iid = $invoice->authcode ( $iid );
- Doo::loadModel ( 'express' );
- $express = new express ();
- $expressList = $express->getExpressByAll ();
-
- if (! is_numeric ( $iid )) {
- echo json_encode ( array (
- 'status' => 0,
- 'msg' => 'illegal request'
- ) );
- die ();
- }
-
- $select = "iid,recipients,recipientsPhone,recipientsAddress,mailItems,expressCompany,expressNumber,actualItems";
- $invoiceDetail = $invoice->getInvoiceByIid ( $iid, $select );
-
- $html = "";
- foreach ( $expressList as $key => $value ) {
- if ($value ['company'] == $invoiceDetail ['expressCompany'])
- $html .= '<option selected value="' . $value ['company'] . ':' . $value ['com'] . '">' . $value ['company'] . '</option>';
- else
- $html .= '<option value="' . $value ['company'] . ':' . $value ['com'] . '">' . $value ['company'] . '</option>';
- }
-
- $invoiceDetail ['eaHtml'] = $html;
-
- echo json_encode ( array (
- 'status' => 1,
- 'invoiceDetail' => $invoiceDetail
- ) );
- }
-
- /**
- *
- * @deprecated --需求变更 废弃 function ajaxCompareClaimPrice() { $irid = $this->get_args ( 'irid' ) ? $this->get_args ( 'irid' ) : ""; $invoiceKey = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : ""; Doo::loadModel ( 'invoice' ); $invoice = new invoice (); Doo::loadModel ( 'invoiceReceivables' ); $invoiceReceivables = new invoiceReceivables (); Doo::loadModel ( 'invoiceOperationLog' ); $invoiceOperationLog = new invoiceOperationLog (); $detail = $invoice->getInvoiceByIid ( $invoiceKey ); $detailM = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid ); if (empty ( $detail ) || empty ( $detailM )) { echo json_encode ( array ( 'status' => 2, 'msg' => '非法请求,请重新登录' ) ); die (); } $iridString = ""; if (empty ( $detail ['irid'] )) $iridString = $detailM ['irid']; else $iridString = $detail ['irid'] . ',' . $detailM ['irid']; $item = array ( 'irid' => $iridString, 'bindTime' => date ( "Y-m-d H:i:s" ), 'updateTime' => date ( "Y-m-d H:i:s" ), 'iid' => $detail ['iid'] ); $invoice->setInvoiceByCondition ( $item ); // 操作日志 $item = array ( 'date' => date ( "Y-m-d H:i:s" ), 'operation' => "收款入账" . $detailM ['receivablesSerial'] . "到发票" . $detail ['invoiceSerial'], 'status' => 8, 'img' => $this->staff [0] ['avatar'], 'username' => $this->staff [0] ['username'], 'uid' => $this->staff [0] ['sid'], 'category' => $this->staff [0] ['category'], 'iid' => $detail ['iid'] ); $invoiceOperationLog->setInvoiceOperationLog ( $item ); $item = array ( 'iid' => $detail ['iid'], 'irid' => $detailM ['irid'], 'bindDate' => date ( "Y-m-d H:i:s" ), 'bindStatus' => 1 ); $invoiceReceivables->setInvoiceReceivablesByCondition ( $item ); $price = 0; $priceStatus = 0; $isReceivables = 0; $invoiceReceivables = new invoiceReceivables (); $list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $iridString ); if (! empty ( $list )) $isReceivables = 1; $receivablesPrice = 0; foreach ( $list as $key => $value ) { $receivablesPrice += $value ['receivablesPrice']; } if ($receivablesPrice > $detail ['invoicePrice']) { $price = $receivablesPrice - $detail ['invoicePrice']; $priceStatus = 1; } elseif ($receivablesPrice < $detail ['invoicePrice']) { $price = $detail ['invoicePrice'] - $receivablesPrice; $priceStatus = 2; } echo json_encode ( array ( 'status' => 1, 'html' => '<tr><td>¥' . $detailM ['receivablesPrice'] . '</td><td>' . $detailM ['receivablesMessage'] . '</td><td>' . $detailM ['receivablesBank'] . '</td> <td>' . $detailM ['receivablesDate'] . '</td><td><a node-remove="Da' . $detailM ['iridKey'] . '" href="javascript:void(0);">移除</a></td></tr> <script> $(\'a[node-remove="Da' . $detailM ['iridKey'] . '"]\').click(function() { var invoiceKey=$("input[name=\'key\']").val(); var irid= $(this).attr("p-data"); var iridKey="' . $detailM ["iridEn"] . '"; var element=($(this)); $("p[node-loading=\"true\"]").show(); $("p[node-loading=\"true\"]").html("移除处理中..."); $("p[node-msg=\"true2\"]").hide(); $("p[node-msg=\"true\"]").hide(); var url = "/ajaxReceivablesRemove"; $.ajax({ url : url, type : "post", cache : false, dataType : "json", data : { key : iridKey, invoiceKey:invoiceKey }, global : true, success : function(data) { $("input[name=\'invoiceKey\']").val("' . $detailM ['iridEn'] . '"); if (data.status == 1) { $(element).parent().parent().remove(); $("tbody[data-invoice=\"myReceivables\"]").append(data.html); $("p[node-loading=\"true\"]").hide(); if(data.priceStatus == 1){ $("p[node-msg=\"true\"]").html("收款金额超出开票金额 ¥"+data.price+"元,请谨慎操作。"); $("p[node-msg=\"true\"]").show(); }else if(data.priceStatus == 2&& data.isReceivables != 0){ $("p[node-msg=\"true\"]").html("收款金额少于开票金额 ¥"+data.price+"元,请谨慎操作。"); $("p[node-msg=\"true\"]").show(); } }else if(data.status == 2){ $("p[node-loading=\"true\"]").html(data.msg); } }, error : function(err) { } }); }); </script> ', 'price' => $price, 'priceStatus' => $priceStatus, 'isReceivables' => $isReceivables ) ); }
- */
-
- /**
- *
- * @deprecated 从发票中移除已经入账的收款 --需求变更 废弃 function ajaxReceivablesRemove() { $iridKey = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : ""; $invoiceKey = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : ""; Doo::loadModel ( 'invoice' ); $invoice = new invoice (); Doo::loadModel ( 'invoiceReceivables' ); $invoiceReceivables = new invoiceReceivables (); Doo::loadModel ( 'invoiceOperationLog' ); $invoiceOperationLog = new invoiceOperationLog (); $detail = $invoice->getInvoiceByIid ( $invoiceKey ); $detailM = $invoiceReceivables->getInvoiceReceivablesByIrid ( $iridKey ); // echo $detail['irid']."<br/>"; $invoiceIrid = explode ( ",", $detail ['irid'] ); foreach ( $invoiceIrid as $key => $value ) { if ($value == $detailM ['irid']) unset ( $invoiceIrid [$key] ); } $invoiceIrid = implode ( ",", $invoiceIrid ); // echo $invoiceIrid."ddd"; // print_r($invoiceIrid); $item = array ( 'irid' => $invoiceIrid, 'iid' => $detail ['iid'] ); $invoice->setInvoiceByCondition ( $item ); $item = array ( 'iid' => 0, 'irid' => $detailM ['irid'], 'bindDate' => '', 'bindStatus' => 0 ); $invoiceReceivables->setInvoiceReceivablesByCondition ( $item ); // 操作日志 $item = array ( 'date' => date ( "Y-m-d H:i:s" ), 'operation' => "收款移除" . $detailM ['receivablesSerial'], 'status' => 10, 'img' => $this->staff [0] ['avatar'], 'username' => $this->staff [0] ['username'], 'uid' => $this->staff [0] ['sid'], 'category' => $this->staff [0] ['category'], 'iid' => $detail ['iid'] ); $invoiceOperationLog->setInvoiceOperationLog ( $item ); $price = 0; $priceStatus = 0; $isReceivables = 0; $invoiceReceivables = new invoiceReceivables (); $list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $invoiceIrid ); if (! empty ( $list )) $isReceivables = 1; $receivablesPrice = 0; foreach ( $list as $key => $value ) { $receivablesPrice += $value ['receivablesPrice']; } if ($receivablesPrice > $detail ['invoicePrice']) { $price = $receivablesPrice - $detail ['invoicePrice']; $priceStatus = 1; } elseif ($receivablesPrice < $detail ['invoicePrice']) { $price = $detail ['invoicePrice'] - $receivablesPrice; $priceStatus = 2; } echo json_encode ( array ( 'status' => 1, 'html' => '<tr id="' . $detailM ['receivablesSerial'] . '" > <td>¥' . $detailM ['receivablesPrice'] . '</td> <td>' . $detailM ['receivablesMessage'] . '</td> <td>' . $detailM ['receivablesBank'] . '</td> <td>' . $detailM ['receivablesDate'] . '</td><td> <a href="javascript:void(0)" node-Claim="true_' . $detailM ['iridKey'] . '" p-data="' . $detailM ['iridEn'] . '" name="invoiceClaim" class="button">入账</a> </td></tr> <script> $(\'a[node-Claim="true_' . $detailM ['iridKey'] . '"]\').click(function() { var invoiceKey=$("input[name=\'key\']").val(); var irid= $(this).attr("p-data"); var element=($(this)); $("p[node-loading=\"true\"]").show(); $("p[node-loading=\"true\"]").html("入账处理中..."); $("p[node-msg=\"true2\"]").hide(); $("p[node-msg=\"true\"]").hide(); var url = "/ajaxCompareClaimPrice"; $.ajax({ url : url, type : "post", cache : false, dataType : "json", data : { irid : irid, invoiceKey:invoiceKey }, global : true, success : function(data) { $("input[name=\'invoiceKey\']").val("' . $detailM ['iridEn'] . '"); if (data.status == 1) { $(element).parent().parent().remove(); $("tbody[box-enter=\"true\"]").append(data.html); $("p[node-loading=\"true\"]").hide(); if(data.priceStatus == 1){ $("p[node-msg=\"true\"]").html("收款金额超出开票金额 ¥"+data.price+"元,请谨慎操作。"); $("p[node-msg=\"true\"]").show(); }else if(data.priceStatus == 2&& data.isReceivables != 0){ $("p[node-msg=\"true\"]").html("收款金额少于开票金额 ¥"+data.price+"元,请谨慎操作。"); $("p[node-msg=\"true\"]").show(); } }else if(data.status == 2){ $("p[node-loading=\"true\"]").html(data.msg); } }, error : function(err) { } }); }); </script> ', 'price' => $price, 'priceStatus' => $priceStatus, 'isReceivables' => $isReceivables ) ); }
- */
-
- /**
- * 我的收款中 选择哪个发票入账,进行金额判断
- */
- function ajaxCompareInvoicePrice() {
- $claimKey = $this->get_args ( 'claimKey' ) ? $this->get_args ( 'claimKey' ) : "";
- $invoiceKey = $this->get_args ( 'invoiceKey' ) ? $this->get_args ( 'invoiceKey' ) : "";
-
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
-
- $detail = $invoice->getInvoiceByIid ( $invoiceKey );
-
- $keyList = explode ( ';', $claimKey );
- $receivablesPrice = 0;
- foreach ( $keyList as $key => $value ) {
- $detailM = $invoiceReceivables->getInvoiceReceivablesByIrid ( $value );
- $receivablesPrice += $detailM ['receivablesPrice'];
- }
-
- if ($receivablesPrice > $detail ['invoicePrice']) {
- $price = $receivablesPrice - $detail ['invoicePrice'];
- echo json_encode ( array (
- 'status' => 1,
- 'price' => $price
- ) );
- } else
- echo json_encode ( array (
- 'status' => 2
- ) );
- }
-
- /**
- * 获得打印发票
- */
- function ajaxGetInvoiceInfoByPrint() {
- $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
-
- if (empty ( $serial )) {
- echo json_encode ( array (
- 'status' => 2,
- 'msg' => 'illegal request'
- ) );
- die ();
- }
-
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'invoiceOperationLog' );
- $invoiceOperationLog = new invoiceOperationLog ();
-
- $detail = $invoice->getInvoiceByIsid ( $serial, $this->staff [0] ['sid'] );
- $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $detail ['iid'] );
-
- Doo::loadModel ( 'invoicePaper' );
- $invoicePaper = new invoicePaper ();
-
- $invoicePaperList = $invoicePaper->getInvoicePaperByInvoiceType ( $detail ['invoiceType'] );
-
- if (empty ( $detail ))
- $html = '';
- else {
- $html = '
-
- <form action="/invoicePrintDo" method="post" name="invoicePrint" class="nice-validator n-yellow" onSubmit="return checkPrintForm()" novalidate="novalidate">
- <input type="hidden" name="invoiceKey" value="' . $detail ['iidKeyXD'] . '">
- <input type="hidden" name="invoicePrintType" value="invoicePrintType">
- <div class="modal-dialog modal-lg">
-
- <div class="modal-content"><div class="modal-header"><h3>发票单详情</h3></div>
- <div class="modal-body saeaList">
-
- <table class="table table-bordered table-condensed"><tbody>
- <tr>
- <th class="taC" width="150">开票流水号</th><td>' . $detail ['invoiceSerial'] . '</td>
- <th class="taC" width="150">提交时间</th><td>' . $detail ['date'] . '</td>
- </tr>
- <tr>
- <th class="taC" width="150">所在办事处</th><td>' . $detail ['categoryName'] . '(' . $detail ['userName'] . ')</td>
- <th class="taC" width="150">开票内容</th><td>' . $detail ['invoiceElement'] . '</td>
- </tr>
-
- <tr>
- <th class="taC">发票备注</th><td colspan="3">' . $detail ['remark'] . '
- </td>
- </tr>
-
- <tr>
- <th class="taC" width="150">数量</th><td><b>' . $detail ['invoiceQuantity'] . '</b></td>
- <th class="taC">单价</th><td><b>¥' . $detail ['invoiceUnitPrice'] . '</b></td>
- </tr>
-
- <tr>
- <th class="taC">开票金额</th><td colspan="3"><b class="colOrange" style="font-size:18px">¥' . $detail ['invoicePrice'] . '</b></td>
-
- </tr></tbody></table>';
-
- if ($detail ['invoiceType'] == 0)
- $html .= '<table class="table table-bordered table-condensed"><tbody>
- <tr><th colspan="4" class="taC">增值税普通发票</th></tr><tr>
- <th class="taC" width="150">发票抬头</th><td >' . $detail ['invoiceTitle'] . '</td>
- <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td>
- </tr>';
- else
- $html .= '<table class="table table-bordered table-condensed"><tbody>
- <tr><th colspan="4" class="taC">增值税专用发票</th></tr><tr>
- <th class="taC" width="150">单位名称</th><td>' . $detail ['invoiceCompany'] . '</td>
- <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td></tr>
-
- ';
-
- $html .= '<tr>
- <th class="taC">注册地址</th><td>' . $detail ['address'] . '</td>
- <th class="taC">注册电话</th><td>' . $detail ['phone'] . '</td>
- </tr>
- <tr>
- <th class="taC">开户银行</th><td>' . $detail ['bank'] . '</td>
- <th class="taC">银行账号</th><td>' . $detail ['bankAccount'] . '</td>
- </tr></tbody></table>';
-
- if ($detail ['doPost'] == 1)
- $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th colspan="4" class="taC">邮寄信息</th></tr><tr>
- <th class="taC" width="150">收件人</th><td>' . $detail ['recipients'] . '</td>
- <th class="taC" width="150">收件人手机/电话</th><td>' . $detail ['recipientsPhone'] . '</td>
- </tr><tr>
- <th class="taC" width="150">收件地址</th><td colspan="3">' . $detail ['recipientsAddress'] . '</td>
- </tr><tr>
- <th class="taC" width="150">邮寄物品</th><td colspan="3">' . $detail ['mailItems'] . '</td>
- </tr></tbody></table>';
- if (! empty ( $invoiceOperationLogList )) {
- $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th width="60%" class="taC">审批流程</th><th class="taC">发票打印</th></tr><tr><td>';
- foreach ( $invoiceOperationLogList as $key => $value ) {
- if ($value ['status'] == 1 || $value ['status'] == 2 || $value ['status'] == 3 || $value ['status'] == 4) {
- $html .= '<blockquote><p><span class="colGray">' . $value ['date'] . '</span>
- ' . $value ['category'] . '-' . $value ['username'] . ' ';
- if ($value ['status'] == 2) {
- $html .= '<span class="colGreen">同意</span>';
- } elseif ($value ['status'] == 3) {
- $html .= '<span class="colOrange">退回</span>';
- } elseif ($value ['status'] == 5) {
- $html .= '<span class="colGreen">打印</span>';
- } elseif ($value ['status'] == 4) {
- $html .= '<span class="colRed">终止</span>';
- }
- $html .= $value ['operation'] . '</p></blockquote>';
- }
- }
- $html .= '</td>
-
- <td><span class="colRed">*</span>
-
- <select name="invoiceNo" id="invoiceNo" style="width:97%">';
-
- foreach ( $invoicePaperList as $key => $value ) {
- $html .= '<option value="' . $value ['ipidKey'] . '">No.' . $value ['invoiceNo'] . '</option>';
- }
-
- $html .= '</select>
-
-
-
-
-
- <span class="red" id="p-msg"></span>
- </td>
-
-
- </tr></tbody></table>';
- }
- $html .= '</div><div class="modal-footer"><button type="submit" class="button btn-green" data-toggle="modal">完成打印</button><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div>
- </div></div></form>
- <link rel=stylesheet href="' . WEB_SITE_GLOBAL . 'css/jquery.validator.css">
- <script type="text/javascript" src="' . WEB_SITE_GLOBAL . 'js/jquery.validator.min.js"></script>
- <script type="text/javascript" src="' . WEB_SITE_GLOBAL . 'js/zh-CN.js"></script>
- <script src="' . WEB_SITE_GLOBAL . 'js/invoice.validator.js"></script>
-
-
- ';
- }
- echo json_encode ( array (
- 'status' => 1,
- 'html' => $html
- ) );
- die ();
- }
-
- /**
- * @ 获得与我有关收款数据 --需求变更 废弃 function ajaxGetReceivalblesByStaff() { $iid = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : ""; Doo::loadModel ( 'invoiceReceivables' ); $invoiceReceivables = new invoiceReceivables (); Doo::loadModel ( 'invoice' ); $invoice = new invoice (); $detail = $invoice->getInvoiceByIid ( $iid ); $list = $invoiceReceivables->getInvoiceReceivablesByClaim ( $this->staff [0] ['cid'], $this->staff [0] ['sid'] ); $html = ""; $i = 1; foreach ( $list ['myClaim'] as $key => $value ) { $html .= '<tr id="' . $value ['receivablesSerial'] . '" > <td>¥' . $value ['receivablesPrice'] . '</td> <td>' . $value ['receivablesMessage'] . '</td> <td>' . $value ['receivablesBank'] . '</td> <td>' . $value ['receivablesDate'] . '</td>'; $html .= '<td> <a href="javascript:void(0)" node-Claim="true_' . $i . '" p-data="' . $value ['iidKey'] . '" name="invoiceClaim" class="button">入账</a> </td></tr> <script> $(\'a[node-Claim="true_' . $i . '"]\').click(function() { var invoiceKey=$("input[name=\'key\']").val(); var irid= $(this).attr("p-data"); var element=($(this)); $("p[node-loading=\"true\"]").show(); $("p[node-loading=\"true\"]").html("入账处理中..."); $("p[node-msg=\"true2\"]").hide(); $("p[node-msg=\"true\"]").hide(); var url = "/ajaxCompareClaimPrice"; $.ajax({ url : url, type : "post", cache : false, dataType : "json", data : { irid : irid, invoiceKey:invoiceKey }, global : true, success : function(data) { $("input[name=\'invoiceKey\']").val("' . $value ['iidKey'] . '"); if (data.status == 1) { $(element).parent().parent().remove(); $("tbody[box-enter=\"true\"]").append(data.html); $("p[node-loading=\"true\"]").hide(); if(data.priceStatus == 1){ $("p[node-msg=\"true\"]").html("收款金额超出开票金额 ¥"+data.price+"元,请谨慎操作。"); $("p[node-msg=\"true\"]").show(); }else if(data.priceStatus == 2&& data.isReceivables != 0){ $("p[node-msg=\"true\"]").html("收款金额少于开票金额 ¥"+data.price+"元,请谨慎操作。"); $("p[node-msg=\"true\"]").show(); } }else if(data.status == 2){ $("p[node-loading=\"true\"]").html(data.msg); } }, error : function(err) { } }); }); </script> '; $i ++; } $html2 = ""; $list2 = $invoiceReceivables->getInvoiceReceivablesByIid ( $iid, 1 ); foreach ( $list2 as $key => $value ) { $html2 .= '<tr id="' . $value ['receivablesSerial'] . '" > <td>¥' . $value ['receivablesPrice'] . '</td> <td>' . $value ['receivablesMessage'] . '</td> <td>' . $value ['receivablesBank'] . '</td> <td>' . $value ['receivablesDate'] . '</td>'; $html2 .= '<td> <a href="javascript:void(0)" node-remove="Da' . $value ['iridKey'] . '" >移除</a> </td></tr> <script> $(\'a[node-remove="Da' . $value ['iridKey'] . '"]\').click(function() { var invoiceKey=$("input[name=\'key\']").val(); var irid= $(this).attr("p-data"); var iridKey="' . $value ["iidKey"] . '"; var element=($(this)); $("p[node-loading=\"true\"]").show(); $("p[node-loading=\"true\"]").html("移除处理中..."); $("p[node-msg=\"true2\"]").hide(); $("p[node-msg=\"true\"]").hide(); var url = "/ajaxReceivablesRemove"; $.ajax({ url : url, type : "post", cache : false, dataType : "json", data : { key : iridKey, invoiceKey:invoiceKey }, global : true, success : function(data) { $("input[name=\'invoiceKey\']").val("' . $value ['iidKey'] . '"); if (data.status == 1) { $(element).parent().parent().remove(); $("tbody[data-invoice=\"myReceivables\"]").append(data.html); $("p[node-loading=\"true\"]").hide(); if(data.priceStatus == 1){ $("p[node-msg=\"true\"]").html("收款金额超出开票金额 ¥"+data.price+"元,请谨慎操作。"); $("p[node-msg=\"true\"]").show(); }else if(data.priceStatus == 2&& data.isReceivables != 0){ $("p[node-msg=\"true\"]").html("收款金额少于开票金额 ¥"+data.price+"元,请谨慎操作。"); $("p[node-msg=\"true\"]").show(); } }else if(data.status == 2){ $("p[node-loading=\"true\"]").html(data.msg); } }, error : function(err) { } }); }); </script> '; $i ++; } $price = 0; $priceStatus = 0; $isReceivables = 0; $list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $detail ['irid'] ); if (! empty ( $list )) $isReceivables = 1; $receivablesPrice = 0; foreach ( $list as $key => $value ) { $receivablesPrice += $value ['receivablesPrice']; } if ($receivablesPrice > $detail ['invoicePrice']) { $price = $receivablesPrice - $detail ['invoicePrice']; $priceStatus = 1; } elseif ($receivablesPrice < $detail ['invoicePrice']) { $price = $detail ['invoicePrice'] - $receivablesPrice; $priceStatus = 2; } echo json_encode ( array ( 'status' => 1, 'html' => $html, 'html2' => $html2, 'price' => $price, 'priceStatus' => $priceStatus, 'isReceivables' => $isReceivables ) ); }
- */
- function ajaxGetInvoiceInfoByType() {
- $type = $this->get_args ( 'type' ) ? $this->get_args ( 'type' ) : "";
- $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
- $loss = $this->get_args ( 'loss' ) ? $this->get_args ( 'loss' ) : false;
- // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
- if (empty ( $serial )) {
- echo json_encode ( array (
- 'status' => 2,
- 'msg' => 'illegal request'
- ) );
- die ();
- }
-
- if ($type == 'INVOICE') {
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'invoiceOperationLog' );
- $invoiceOperationLog = new invoiceOperationLog ();
-
- $detail = $invoice->getInvoiceByIsid ( $serial, $this->staff [0] ['sid'] );
- $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $detail ['iid'] );
-
- if (empty ( $detail ))
- $html = '';
- else {
- $html = '
- <div class="modal-dialog modal-lg">
- <div class="modal-content"><div class="modal-header"><h3>发票单详情</h3></div>
- <div class="modal-body saeaList"><table class="table table-bordered table-condensed"><tbody>
- <tr>
- <th class="taC" width="150">开票流水号</th><td>' . $detail ['invoiceSerial'] . '</td>
- <th class="taC" width="150">提交时间</th><td>' . $detail ['date'] . '</td>
- </tr>
- <tr>
- <th class="taC" width="150">所在办事处</th><td>' . $detail ['categoryName'] . '(' . $detail ['userName'] . ')</td>
- <th class="taC" width="150">开票内容</th><td>' . $detail ['invoiceElement'] . '</td>
- </tr>
-
- <tr>
- <th class="taC">发票备注</th><td colspan="3">' . $detail ['remark'] . '
- </td>
- </tr>
-
- <tr>
- <th class="taC" width="150">数量</th><td><b>' . $detail ['invoiceQuantity'] . '</b></td>
- <th class="taC">单价</th><td><b>¥' . $detail ['invoiceUnitPrice'] . '</b></td>
- </tr>
-
- <tr>
- <th class="taC">开票金额</th><td colspan="3"><b class="colOrange" style="font-size:18px">¥' . $detail ['invoicePrice'] . '</b></td>
- </tr>';
-
- if ($detail ['settlementType'] == 1)
- $html .= '<tr>
- <th class="taC" width="150">结算方式</th><td colspan="3">培训班(<a href="/invoiceTrainingDetail/' . $detail ['invoiceTraining'] ['trainingKey'] . '.html" target="_blank">' . $detail ['invoiceTraining'] ['trainName'] . '</a>)</td>
- </tr>';
- else
- $html .= '<tr>
- <th class="taC" width="150">结算方式</th><td colspan="3">软件销售</td>
- </tr>';
- $html .= ' </tbody></table>';
- if ($detail ['invoiceType'] == 0){
- $html .= '<table class="table table-bordered table-condensed"><tbody>
- <tr><th colspan="4" class="taC">增值税普通发票';
- if($detail ['invoiceForm']==1){
- $html .= '( <span class="colRed">电子发票</span> )';
- }
- $html .= '</th></tr><tr>
- <th class="taC" width="150">发票抬头</th><td >' . $detail ['invoiceTitle'] . '</td>
- <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td>
- </tr>';
- }else{
- $html .= '<table class="table table-bordered table-condensed"><tbody>
- <tr><th colspan="4" class="taC">增值税专用发票';
- if($detail ['invoiceForm']==1){
- $html .= '( <span class="colRed">电子发票</span> )';
- }
- $html .= '</th></tr><tr>
- <th class="taC" width="150">单位名称</th><td>' . $detail ['invoiceCompany'] . '</td>
- <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td></tr>
- ';
- }
- $html .= '<tr>
- <th class="taC">注册地址</th><td>' . $detail ['address'] . '</td>
- <th class="taC">注册电话</th><td>' . $detail ['phone'] . '</td>
- </tr>
- <tr>
- <th class="taC">开户银行</th><td>' . $detail ['bank'] . '</td>
- <th class="taC">银行账号</th><td>' . $detail ['bankAccount'] . '</td>
- </tr>
- <tr>
- <th class="taC">发票号</th><td>' . $detail ['invoiceNo'] . '</td>
- <th class="taC"></th><td></td>
- </tr>
- </tbody></table>';
-
- if ($detail ['doPost'] == 1) {
- $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th colspan="4" class="taC">邮寄信息</th></tr><tr>
- <th class="taC" width="150">收件人</th><td>' . $detail ['recipients'] . '</td>
- <th class="taC" width="150">收件人手机/电话</th><td>' . $detail ['recipientsPhone'] . '</td>
- </tr><tr>
- <th class="taC" width="150">收件地址</th><td colspan="3">' . $detail ['recipientsAddress'] . '</td>
- </tr><tr>
- <th class="taC" width="150">邮寄物品</th><td colspan="3">' . $detail ['mailItems'] . '</td>
- </tr>
- ';
-
- if ($detail ['expressCom'] == 'SF')
- $html .= '<tr><th class="taC" width="150">快递单号</th><td colspan="3">' . $detail ['expressCompany'] . ' <a target="_blank" href="http://www.sf-express.com/cn/sc/dynamic_function/waybill/#search/bill-number/">' . $detail ['expressNumber'] . '</a> </td></tr>';
- else
- $html .= '<tr><th class="taC" width="150">快递单号</th><td colspan="3">' . $detail ['expressCompany'] . ' <a target="_blank" href="/invoiceExpress/' . $detail ['expressCom'] . '/' . $detail ['expressNumber'] . '.html">' . $detail ['expressNumber'] . '</a> </td></tr>';
- $html .= '</tbody></table>';
- }
-
- if ($detail ['invoiceForm'] == 1) {
- $html .= '<table class="table table-bordered table-condensed">
- <tbody><tr><th colspan="4" class="taC">电子发票发送方式</th></tr>
- <tr>
- <th class="taC" width="150">收件人手机</th><td>'.$detail ['electronicPhone'].'</td>
- <th class="taC" width="150">收件人邮箱</th><td>'.$detail ['electronicEmail'].'</td>
- </tr></tbody></table>';
- }
-
-
-
-
- if (! empty ( $invoiceOperationLogList )) {
- $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th width="60%" class="taC">审批流程</th></tr><tr><td>';
- foreach ( $invoiceOperationLogList as $key => $value ) {
- if ($value ['status'] == 1 || $value ['status'] == 2 || $value ['status'] == 3 || $value ['status'] == 4) {
- $html .= '<blockquote><p><span class="colGray">' . $value ['date'] . '</span>
- ' . $value ['category'] . '-' . $value ['username'] . ' ';
- if ($value ['status'] == 2) {
- $html .= '<span class="colGreen">同意</span>';
- } elseif ($value ['status'] == 3) {
- $html .= '<span class="colOrange">退回</span>';
- } elseif ($value ['status'] == 5) {
- $html .= '<span class="colGreen">打印</span>';
- } elseif ($value ['status'] == 4) {
- $html .= '<span class="colRed">终止</span>';
- }
- $html .= $value ['operation'] . '</p></blockquote>';
- }
- }
- $html .= '</td></tr></tbody></table>';
- }
- $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
- }
- echo json_encode ( array (
- 'status' => 1,
- 'html' => $html
- ) );
- die ();
- } elseif ($type == 'RECEIVABLES') {
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
- Doo::loadModel ( 'invoiceRefund' );
- $invoiceRefund = new invoiceRefund ();
-
- $detail = $invoiceReceivables->getInvoiceReceivablesByIrsid ( $serial );
- $ireList = $invoiceRefund->getInvoiceRefundIrid ( $detail ['irid'] );
-
- if (empty ( $detail ))
- $html = '';
- else {
- $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>收款单详情</h3></div><div class="modal-body saeaList">
-
- <table class="table table-bordered table-condensed">
- <tbody><tr>
- <th class="taC">收款流水号</th><td>' . $detail ['receivablesSerial'] . '</td>
- <th class="taC">录入收款</th><td>' . $detail ['inputStaff'] . ' ' . $detail ['date'] . '</td>
- </tr><tr>
- <th class="taC">收款金额</th><td><b>¥' . $detail ['receivablesPrice'] . '</b></td>
- <th class="taC">收款信息</th><td>' . $detail ['receivablesMessage'] . '</td>
- </tr>
- <tr>
- <th class="taC">收款银行</th><td>' . $detail ['receivablesBank'] . '</td>
- <th class="taC">银行到账</th><td>' . $detail ['receivablesDate'] . '</td>
- </tr>
- <tr>
- <th class="taC">认领收款</th><td colspan="3">' . $detail ['inputStaff'] . ' 转入 ' . $detail ['username'] . ' ' . $detail ['confirmTime'] . '</td>
- </tr>
- </tbody></table>';
- if (! empty ( $ireList )) {
- $html .= '
- <table class="table table-bordered table-condensed"><tbody><tr><th class="taC" colspan="5">退款记录</th></tr>
- <tr>
- <th class="taC">退款单位名称</th>
- <th class="taC">退款的账号</th>
- <th class="taC">退款金额</th>
- <th class="taC">退款</th>
- <th class="taC">备注</th>
- </tr>
- ';
-
- foreach ( $ireList as $key => $value ) {
-
- $refundLogList = explode ( "<br/>", $value ['refundLog'] );
-
- $html .= '<tr>
- <td>' . $value ['refundCompany'] . '</td>
- <td>' . $value ['refundNumber'] . '</td>
- <td><b class="colRed">¥' . $value ['refundPrice'] . '</b></td>
- <td>' . $refundLogList [0] . $refundLogList [2] . '</td>
- <td>' . $value ['refundRemarks'] . '</td>
- </tr>
- ';
- }
- }
- $html .= '</tbody></table></div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
- }
- echo json_encode ( array (
- 'status' => 1,
- 'html' => $html
- ) );
- die ();
- } elseif ($type == 'IRTC') {
-
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'invoiceOperationLog' );
- $invoiceOperationLog = new invoiceOperationLog ();
- // Doo::loadModel ( 'invoiceReceivables' );
- // $invoiceReceivables = new invoiceReceivables ();
-
- $detail = $invoice->getInvoiceByIsid ( $serial, $this->staff [0] ['sid'] );
- $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $detail ['iid'] );
-
- if (empty ( $detail ))
- $html = '';
- else {
-
- $receivablesPriceedHtml = '';
- $receivablesPrice = $detail ['invoicePrice'];
- if (! empty ( $detail ['irid'] )) {
-
- // $irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $detail ['irid'] );
-
- // if (empty ( $irList ))
- // $irList [0] ['sumPrice'] = 0;
-
- // $balance = $detail ['invoicePrice'] - $irList [0] ['sumPrice'];
-
- $enteredPrice=$detail ['invoicePrice']-$detail ['invoiceBalance'];
- $receivablesPriceedHtml = '<table class="table table-bordered table-condensed"><tbody><tr>
-
- <th class="taC">已入账金额</th><td><b class="colGreen" style="font-size:18px">¥' . $enteredPrice . '</b></td>
- <th class="taC">剩余入账金额</th><td><b class="colRed" style="font-size:18px">¥' . $detail ['invoiceBalance'] . '</b></td>
-
- </tr></tbody></table>';
- $receivablesPrice = $detail ['invoiceBalance'];
- }
-
- if ($loss)
- $detail ['invoicePrice'] = - $detail ['invoicePrice'];
- $html = $receivablesPriceedHtml . '
- <table class="table table-bordered table-condensed"><tbody>
- <tr>
- <th class="taC" width="150">开票流水号</th><td>' . $detail ['invoiceSerial'] . '</td>
- <th class="taC" width="150">提交时间</th><td>' . $detail ['date'] . '</td>
- </tr>
- <tr>
- <th class="taC" width="150">所在办事处</th><td>' . $detail ['categoryName'] . '(' . $detail ['userName'] . ')</td>
- <th class="taC" width="150">开票内容</th><td>' . $detail ['invoiceElement'] . '</td>
- </tr>
-
- <tr>
- <th class="taC" width="150">发票备注</th><td colspan="3">' . $detail ['remark'] . '</td>
- </tr>
-
- <tr>
- <th class="taC" width="150">数量</th><td><b>' . $detail ['invoiceQuantity'] . '</b></td>
- <th class="taC">单价</th><td><b>¥' . $detail ['invoiceUnitPrice'] . '</b></td>
- </tr>
-
- <tr>
- <th class="taC">开票金额</th><td colspan="3"><b class="colOrange" style="font-size:18px">¥' . $detail ['invoicePrice'] . '</b></td>
-
- </tr></tbody></table>';
-
- if ($detail ['invoiceType'] == 0) {
- $html .= '<table class="table table-bordered table-condensed"><tbody>
- <tr><th colspan="4" class="taC">增值税普通发票';
- if($detail ['invoiceForm']==1){
- $html .= '( <span class="colRed">电子发票</span> )';
- }
-
- $html.='</th></tr><tr>
- <th class="taC" width="150">发票抬头</th><td >' . $detail ['invoiceTitle'] . '</td>
- <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td>
- </tr>';
- $receivablesMessage = $detail ['invoiceTitle'];
- } else {
- $html .= '<table class="table table-bordered table-condensed"><tbody>
- <tr><th colspan="4" class="taC">增值税专用发票';
- if($detail ['invoiceForm']==1){
- $html .= '( <span class="colRed">电子发票</span> )';
- }
- $html .= '</th></tr><tr>
- <th class="taC" width="150">单位名称</th><td>' . $detail ['invoiceCompany'] . '</td>
- <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td></tr>
-
- ';
- $receivablesMessage = $detail ['invoiceCompany'];
- }
- $html .= '<tr>
- <th class="taC">注册地址</th><td>' . $detail ['address'] . '</td>
- <th class="taC">注册电话</th><td>' . $detail ['phone'] . '</td>
- </tr>
- <tr>
- <th class="taC">开户银行</th><td>' . $detail ['bankAccount'] . '</td>
- <th class="taC">银行账号</th><td>' . $detail ['bank'] . '</td>
- </tr></tbody></table>';
-
- if ($detail ['doPost'] == 1)
- $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th colspan="4" class="taC">邮寄信息</th></tr><tr>
- <th class="taC" width="150">收件人</th><td>' . $detail ['recipients'] . '</td>
- <th class="taC" width="150">收件人手机/电话</th><td>' . $detail ['recipientsPhone'] . '</td>
- </tr><tr>
- <th class="taC" width="150">收件地址</th><td colspan="3">' . $detail ['recipientsAddress'] . '</td>
- </tr><tr>
- <th class="taC" width="150">邮寄物品</th><td colspan="3">' . $detail ['mailItems'] . '</td>
- </tr></tbody></table>';
- if (! empty ( $invoiceOperationLogList )) {
- $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th width="60%" class="taC">审批流程</th></tr><tr><td>';
- foreach ( $invoiceOperationLogList as $key => $value ) {
- if ($value ['status'] == 1 || $value ['status'] == 2 || $value ['status'] == 3 || $value ['status'] == 4) {
- $html .= '<blockquote><p><span class="colGray">' . $value ['date'] . '</span>
- ' . $value ['category'] . '-' . $value ['username'] . ' ';
- if ($value ['status'] == 2) {
- $html .= '<span class="colGreen">同意</span>';
- } elseif ($value ['status'] == 3) {
- $html .= '<span class="colOrange">退回</span>';
- } elseif ($value ['status'] == 5) {
- $html .= '<span class="colGreen">打印</span>';
- }
- $html .= $value ['operation'] . '</p></blockquote>';
- }
- }
- $html .= '</td></tr></tbody></table>';
- }
- }
-
- echo json_encode ( array (
- 'status' => 1,
- 'html' => $html,
- 'receivablesPrice' => $receivablesPrice,
- 'receivablesMessage' => $receivablesMessage,
- 'receivablesDate' => date ( "Y-m-d" ),
- 'iidKey' => $serial
- ) );
- die ();
- }
- }
- function ajaxGetInvoiceReceivablesByStaff() {
- $postData = $this->get_args ( 'postData' ) ? $this->get_args ( 'postData' ) : "";
-
- if (empty ( $postData )) {
- echo json_encode ( array (
- 'status' => 2,
- 'msg' => 'illegal request'
- ) );
- die ();
- }
-
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
-
- $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $postData );
- if (empty ( $detail )) {
- echo json_encode ( array (
- 'status' => 2,
- 'msg' => 'illegal request'
- ) );
- die ();
- }
-
- Doo::loadModel ( 'L_category' );
- $lCategory = new L_category ();
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- $staffList = $staff->getStaffByCid ( $detail ['cid'] );
- $category = $lCategory->getCategory ();
-
- $categoryHtml = '<option post-data="PUBLIC" value="PUBLIC" >公共待认领款项</option>';
- $staffHtml = '<option value="PUBLIC">办事处待认领款项</option>';
- foreach ( $category as $key => $value ) {
- $categoryHtml .= '<option post-data="' . $value ['cid'] . '" value="' . $value ['cid'] . ':' . $value ['title'] . '" >' . $value ['title'] . '</option>';
- if ($value ['cid'] == $detail ['cid'])
- $categoryHtml .= '<option selected post-data="' . $value ['cid'] . '" value="' . $value ['cid'] . ':' . $value ['title'] . '" >' . $value ['title'] . '</option>';
- }
- foreach ( $staffList as $key => $value ) {
- $staffHtml .= '<option value="' . $value ['sid'] . '-' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
- if ($value ['sid'] == $detail ['sid'])
- $staffHtml .= '<option selected value="' . $value ['sid'] . '-' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
- }
-
- $rbankHtml = '<option value="广发银行珠海分行柠溪支行">广发银行珠海分行柠溪支行</option>';
-
- echo json_encode ( array (
- 'status' => 1,
- 'categoryHtml' => $categoryHtml,
- 'staffHtml' => $staffHtml,
- 'rbankHtml' => $rbankHtml,
- 'detail' => $detail
- ) );
- }
- function ajaxGetInvoiceReceivablesByIrid() {
- $irid = $this->get_args ( 'irid' ) ? $this->get_args ( 'irid' ) : "";
-
- if (empty ( $irid )) {
- echo json_encode ( array (
- 'status' => 2,
- 'msg' => 'illegal request'
- ) );
- die ();
- }
-
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
-
- $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid ); // 入账完成 待定 and postStatus=1
- $flag = true;
- $invoiceDetail = $invoice->getInvoiceByTitle ( $detail ['recepitTitleMark'], 'EXACTLY', " and status=2 and printStatus=1 and untreadStatus=0 ", $flag ); //
- $bakDetail = array ();
- if ($flag === false) {
- array_push ( $bakDetail, $invoiceDetail );
- $invoiceDetail = $bakDetail;
- }
-
- $receivablesHtml = '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="70">收款金额</th><th class="taC">银行到账信息</th><th class="taC">银行/到账时间</th><th class="taC">收款认领</th><th class="taC">开票单位</th></tr>
- <tr>
- <td><b>¥' . $detail ['receivablesPrice'] . '</b></td>
- <td>' . $detail ['receivablesMessage'] . '</td>
- <td>' . $detail ['receivablesBank'] . '<br>' . $detail ['receivablesDate'] . '</td>
- <td>' . $detail ['title'] . '-' . $detail ['username'] . '<br>' . $detail ['confirmTime'] . '</td>
- <td>' . $detail ['recepitTitleMark'] . '</td>
- </tr></tbody></table>';
-
- $isInvoice = false;
- $invoiceHtml = '';
- if (empty ( $invoiceDetail )) {
- $isInvoice = true;
- } else {
- $invoiceHtml = '<table class="table table-bordered table-condensed">
- <thead><tr><th>开票单位(抬头)</th><th>开票金额</th><th>提交开票</th><th>出票</th><th>开票流水号</th><th width="80">入账</th></tr></thead><tbody>';
-
- foreach ( $invoiceDetail as $key => $value ) {
-
- $invoiceHtml .= '<tr>';
- if (! empty ( $value ['invoiceType'] )) {
- $invoiceHtml .= '<td>' . $value ['invoiceCompany'] . '</td>';
- } else {
- $invoiceHtml .= '<td>' . $value ['invoiceTitle'] . '</td>';
- }
-
- if (! empty ( $value ['invoiceType'] )) {
- $invoiceHtml .= '<td>' . $value ['invoicePrice'] . '专</td>';
- } else {
- $invoiceHtml .= '<td>' . $value ['invoicePrice'] . '</td>';
- }
-
- $invoiceHtml .= '
- <td>' . $value ['categoryName'] . $value ['userName'] . ' ' . $value ['date'] . '</td>
- <td>' . $value ['printer'] . ' ' . $value ['printTime'] . '</td>
- <td>' . $value ['invoiceSerial'] . '</td><td><a class="button btn-block" bind-receivables="ir" data-ikey="' . $value ['iidKey'] . '" href="javascript:void(0)">入账</a></td>
- </tr>
- ';
-
- $irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $value ['irid'] );
- if (empty ( $irList ))
- $irList [0] ['sumPrice'] = 0;
- $balance = $value ['invoicePrice'] - $irList [0] ['sumPrice'];
-
- $priceString = '';
- if ($balance < $detail ['receivablesPrice']) {
- $priceString = '收款金额超过开票金额,';
- }
- if ($balance > $detail ['receivablesPrice']) {
- $priceString = '收款金额低于开票金额,';
- }
- }
-
- $invoiceHtml .= '
- <script>
- $(\'a[bind-receivables^="ir"]\').click(function() {
-
- var data = $(this).attr("data-ikey");
-
- $("input[name=\'invoiceKey\']").val(data);
- var invoiceKey=data;
-
- if(invoiceKey==""){
- alert("入账错误,请重新刷新页面");
- return false;
- }
- if(window.confirm("' . $priceString . '确定入账吗?")){
- $("#IBR").submit();
- }else{
- return false;
- }
- });
- </script>
- ';
-
- $invoiceHtml .= '</tbody></table>';
- }
-
- echo json_encode ( array (
- 'status' => 1,
- 'irkey' => $detail ['iridEn'],
- 'receivablesHtml' => $receivablesHtml,
- 'isInvoice' => $isInvoice,
- 'invoiceHtml' => $invoiceHtml
- ) );
- }
- function ajaxGetInvoiceReceivablesByTitle() {
- $title = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
-
- if (empty ( $title )) {
- echo json_encode ( array (
- 'status' => 2,
- 'msg' => 'illegal request'
- ) );
- die ();
- }
-
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
-
-
-
- $invoiceDetail = $invoice->getInvoiceByTitle ( $title, 'FUZZY', " and status=2 and printStatus=1 and untreadStatus=0 and (irid='' or irid is null) ", true );
-
-
-
- $invoiceHtml = '';
- if (! empty ( $invoiceDetail )) {
- $invoiceHtml = '<table class="table table-bordered table-condensed">
- <thead><tr><th>开票单位(抬头)</th><th>开票金额</th><th>提交开票</th><th>出票</th><th>开票流水号</th><th width="80">入账</th></tr></thead><tbody><tr>';
- foreach ( $invoiceDetail as $key => $value ) {
- if (! empty ( $value ['invoiceType'] )) {
- $invoiceHtml .= '<td>' . $value ['invoiceCompany'] . '</td>';
- } else {
- $invoiceHtml .= '<td>' . $value ['invoiceTitle'] . '</td>';
- }
-
- if (! empty ( $value ['invoiceType'] )) {
- $invoiceHtml .= '<td>' . $value ['invoicePrice'] . '专</td>';
- } else {
- $invoiceHtml .= '<td>' . $value ['invoicePrice'] . '</td>';
- }
-
- $invoiceHtml .= '
- <td>' . $value ['categoryName'] . $value ['userName'] . ' ' . $value ['date'] . '</td>
- <td>' . $value ['printer'] . ' ' . $value ['printTime'] . '</td>
- <td>' . $value ['invoiceSerial'] . '</td><td><a class="button btn-block" bind-receivables="ir' . $value ['iidKeyXD'] . '" data-ikey="' . $value ['iidKey'] . '" href="#">入账</a></td>
- </tr>
- ';
- }
- $invoiceHtml .= '</tbody></table>
-
- <script>
- $(\'a[bind-receivables^="ir"]\').click(function() {
-
- var data = $(this).attr("data-ikey");
-
- $("input[name=\'invoiceKey\']").val(data);
- var invoiceKey=$("input[name=\'invoiceKey\']").val();
- if(invoiceKey==""){
- alert("入账错误,请重新刷新页面");
- return false;
- }
- if(window.confirm("确定入账吗?")){
- $("#IBR").submit();
- }else{
- return false;
- }
- });
- </script>
- ';
- }
-
- echo json_encode ( array (
- 'status' => 1,
- 'invoiceHtml' => $invoiceHtml
- ) );
- }
- function ajaxInvoicePushNotice() {
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
-
- $approval = $invoice->getOne ( array (
- 'where' => 'status=1 and pendingApprovals=' . $this->staff [0] ['sid'],
- 'desc' => 'iid',
- 'asArray' => true
- ) );
-
- $isNotice = false;
- if (! empty ( $approval ))
- $isNotice = true;
- $response = array (
- 'error' => 0,
- 'isNotice' => $isNotice
- );
-
- echo json_encode ( $response );
- exit ();
- }
- public function ajaxCheckInvoiceNoUniqueness() {
- $invoiceNo = $this->get_args ( 'invoiceNo' ) ? $this->get_args ( 'invoiceNo' ) : "";
-
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
-
- if (! empty ( $invoiceNo )) {
-
- Doo::loadModel ( 'invoicePaper' );
- $invoicePaper = new invoicePaper ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $ipid = $XDeode->decode ( $invoiceNo );
- $paperDetail = $invoicePaper->getInvoicePaperByIpid ( $ipid );
-
- $info = $invoice->getOne ( array (
- 'where' => "invoiceNo = '" . $paperDetail ['invoiceNo'] . "'",
- 'asArray' => TRUE
- ) );
- if (! empty ( $info )) {
- echo json_encode ( array (
- 'error' => '发票号已存在'
- ) );
- die ();
- } else
- echo json_encode ( array (
- 'ok' => '可以使用!'
- ) );
- die ();
- }
- }
- function ajaxCheckInvoicePrice() {
- $receivablesPrice = $this->get_args ( 'receivablesPrice' ) && is_numeric ( $this->get_args ( 'receivablesPrice' ) ) ? $this->get_args ( 'receivablesPrice' ) : "";
- $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
-
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- if (! empty ( $receivablesPrice ) && ! empty ( $iidKey )) {
-
- $iidKey = $XDeode->decode ( $iidKey );
- $info = $invoice->getInvoiceByIid ( $iidKey );
-
- $irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $info ['irid'] );
- if (empty ( $irList ))
- $irList [0] ['sumPrice'] = 0;
-
- $balance = $info ['invoicePrice'] - $irList [0] ['sumPrice'];
- if ($balance < $receivablesPrice) {
- echo json_encode ( array (
- 'error' => '收款金额超过开票金额。'
- ) );
- die ();
- }
- if ($balance > $receivablesPrice) {
- echo json_encode ( array (
- 'error' => '收款金额低于开票金额。'
- ) );
- die ();
- }
- }
- }
- function ajaxGetInvoiceByNew() {
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- $detail = $invoice->getInvoiceByNew ( $this->staff [0] ['sid'] );
-
- echo json_encode ( array (
- 'status' => 1,
- 'detail' => $detail
- ) );
- }
-
- /**
- * 旧输入导入
- */
- function importInvoice() {
- $emsg = isset ( $this->params ['emsg'] ) ? $this->params ['emsg'] : "";
- $data ['emsg'] = "";
-
- if ($emsg != "")
- $data ['emsg'] = "请填写完整的数据";
-
- $data ['time'] = time ();
- $this->render ( "/admin/invoiceImport", $data );
- }
- function uploadInvoice() {
- // move_uploaded_file($_FILES['Filedata']['tmp_name'], "/upload/".$_FILES['Filedata']['name']);
- if (isset ( $_FILES ['Filedata'] ['name'] )) {
- $file = $_FILES ['Filedata'] ['tmp_name'];
- $error = false;
-
- if (! is_uploaded_file ( $file )) {
- $error = '400 Bad Request';
- }
-
- if ($error) {
- header ( 'HTTP/1.0 ' . $error );
- die ( 'Error ' . $error );
- } else {
-
- include (DOO::conf ()->SITE_PATH . 'protected/plugin/io.han.php');
- $this->IoHandler = new IoHandler ();
-
- $pics = explode ( '.', $_FILES ['Filedata'] ['name'] );
-
- // $filedir=$_POST['time'];
-
- // 调用定义物理路径
- $t = DOO::conf ()->SITE_PATH . "upload/invoice/";
- $this->IoHandler->MakeDir ( $t );
- $filename = $this->_GetFileEXT ( $_FILES ['Filedata'] ['name'] );
-
- if ($filename != 'xlsx')
- return "";
- // $upload_dir = $t."/".time().rand(10,100).".".$filename;
- $upload_file = iconv ( "UTF-8", "GB2312", $_FILES ["Filedata"] ["name"] );
- $upload_dir = $t . "/" . $upload_file;
- $k = move_uploaded_file ( $file, $upload_dir );
-
- if ($k) {
- $m = round ( $_FILES ['Filedata'] ['size'] / 1024 / 1024, 2 );
- echo $pics [0] . "." . $filename . "#" . $m . "#" . $_FILES ['Filedata'] ['size'];
- }
- }
- }
- }
- function importInvoiceDo() {
- $path = $this->get_args ( 'path' ) ? $this->get_args ( 'path' ) : "";
-
- if ($path != "") {
- Doo::loadModel ( 'invoice' );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel ( 'invoiceStatistics' );
- Doo::loadModel ( 'invoiceOperationLog' );
-
- echo DOO::conf ()->SITE_PATH . "upload/invoice/" . iconv ( "UTF-8", "GB2312", $path );
- $exlArray = $this->_format_excel_to_array ( DOO::conf ()->SITE_PATH . "upload/invoice/" . $path );
- // print_r ( $exlArray );
- // die ();
- // echo json_encode($exlArray);die;
-
- foreach ( $exlArray as $key => $value ) {
- // 开票
- $invoice = new invoice ();
-
- $invoice->invoiceNo = $value ['invoiceNo'];
-
- $invoice->invoiceType = 0;
- if ($value ['invoiceType'] == '专')
- $invoice->invoiceType = 1;
-
- $invoice->invoicePrice = $value ['invoicePrice'];
-
- $invoice->invoiceQuantity = 1;
- $invoice->invoiceUnitPrice = $value ['invoicePrice'];
-
- $invoice->invoiceTitle = $value ['invoiceTitle'];
- if ($value ['invoiceType'] == '专')
- $invoice->invoiceCompany = $value ['invoiceTitle'];
-
- $invoice->userName = $value ['userName'];
-
- $sDetail = $staff->getStaffByName ( $value ['userName'] );
- $invoice->sid = $sDetail ['sid'];
- $invoice->cid = $sDetail ['cid'];
- $invoice->categoryName = $sDetail ['category'];
-
- $invoice->invoiceElement = $value ['invoiceElement'];
- $invoice->remark = $value ['remark'];
- $invoice->date = $value ['date'];
-
- $invoice->printTime = $value ['date'];
-
- $invoice->ipSource = 1;
-
- $invoice->printStatus = 1;
- $invoice->status = 2;
- $invoice->postStatus = 1;
- $invoice->untreadStatus = 0;
- $invoice->invoiceSerial = "#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
-
- $iid = $invoice->insert ();
-
- // 汇总
- $invoiceStatistics = new invoiceStatistics ();
- //
- $item = array (
- 'date' => $value ['date'],
- 'priceClass' => 1,
- 'cid' => $sDetail ['cid'],
- 'staff' => $sDetail ['sid'],
- 'invoicePrice' => $value ['invoicePrice']
- );
- $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
-
- $invoiceOperationLog = new invoiceOperationLog ();
- $item = array (
- 'date' => date ( "Y-m-d H:i:s" ),
- 'operation' => date ( "Y-m-d" ) . " 导入",
- 'status' => 1,
- 'img' => $sDetail ['avatar'],
- 'username' => $sDetail ['username'],
- 'uid' => $sDetail ['sid'],
- 'category' => $sDetail ['category'],
- 'iid' => $iid
- );
- $invoiceOperationLog->setInvoiceOperationLog ( $item );
- }
- return '/importInvoice?count=' . count ( $exlArray );
-
- // return "/keyonline";
- }
- echo 'no file';
- }
- function importInvoiceReceivables() {
- $emsg = isset ( $this->params ['emsg'] ) ? $this->params ['emsg'] : "";
- $data ['emsg'] = "";
-
- if ($emsg != "")
- $data ['emsg'] = "请填写完整的数据";
-
- $data ['time'] = time ();
- $this->render ( "/admin/invoiceReceivablesImport", $data );
- }
- // 导入入账数据
- function importInvoiceReceivablesDo() {
- $path = $this->get_args ( 'path' ) ? $this->get_args ( 'path' ) : "";
- // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
- if ($path != "") {
- Doo::loadModel ( 'invoiceReceivables' );
- Doo::loadModel ( 'invoice' );
-
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel ( 'invoiceStatistics' );
-
- // echo DOO::conf ()->SITE_PATH . "upload/invoice/" . iconv ( "UTF-8", "GB2312", $path );
- $exlArray = $this->_format_excel_to_array ( DOO::conf ()->SITE_PATH . "upload/invoice/" . iconv ( "UTF-8", "GB2312", $path ), 'invoiceReceivables' );
- // print_r ( $exlArray );
- // die ();
- // echo json_encode($exlArray);die;
-
- foreach ( $exlArray as $key => $value ) {
- // 收款
- $invoiceReceivables = new invoiceReceivables ();
- $invoice = new invoice ();
-
- $invoiceReceivables->bindStatus = 1;
-
- $invoiceReceivables->receivablesPrice = $value ['receivablesPrice'];
- $invoiceReceivables->receivablesMessage = $value ['receivablesMessage'];
- $invoiceReceivables->receivablesBank = $value ['receivablesBank'];
- $invoiceReceivables->receivablesDate = $value ['receivablesDate'];
-
- $sDetail = $staff->getStaffByName ( $value ['receivablesStaff'] );
- $invoiceReceivables->receivablesCategory = $sDetail ['cid'] . ':' . $sDetail ['category'];
- $invoiceReceivables->receivablesStaff = $sDetail ['sid'] . '-' . $sDetail ['username'];
-
- $invoiceReceivables->receivablesSerial = "#SK" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
- $invoiceReceivables->sourcePrice = $value ['sourcePrice'];
-
- $iDetail = $invoice->getInvoiceByInvoiceNo ( $value ['invoiceNo'] );
- $invoiceReceivables->iid = $iDetail ['iid'];
-
- $irid = $invoiceReceivables->insert ();
-
- // 发票绑定收款
- $detail = $iDetail;
-
- $iridString = "";
- if (empty ( $detail ['irid'] ))
- $iridString = $irid;
- else
- $iridString = $detail ['irid'] . ',' . $irid;
-
- $item = array (
- 'irid' => $iridString,
- 'iid' => $detail ['iid']
- );
- $invoice->setInvoiceByCondition ( $item );
-
- // 汇总
- $invoiceStatistics = new invoiceStatistics ();
- // 扣除入账统计金额
- $item = array (
- 'date' => $value ['receivablesDate'],
- 'priceClass' => 3,
- 'cid' => $sDetail ['cid'],
- 'staff' => $sDetail ['sid'],
- // 'irid' => $irid,
- 'accountPrice' => $value ['receivablesPrice']
- );
- $invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
- }
- return '/importInvoiceReceivables?count=' . count ( $exlArray );
- echo 'data count ' . count ( $exlArray );
- die ();
- // return "/keyonline";
- }
- echo 'no file';
- }
- function formatExcelToArrayTrain($file_url = "") {
- if (! file_exists ( $file_url )) {
- return array ();
- }
-
- // Doo::loadClass ( 'PHPExcel' );
- Doo::loadClass ( 'PHPExcel1.7.9/PHPExcel' );
-
- $PHPExcel = new PHPExcel ();
- $PHPReader = new PHPExcel_Reader_Excel2007 ();
-
- if (! $PHPReader->canRead ( $file_url )) {
- $PHPReader = new PHPExcel_Reader_Excel5 ();
- if (! $PHPReader->canRead ( $file_url )) {
-
- echo 'no Excel';
- return;
- }
- }
-
- $PHPExcel = $PHPReader->load ( $file_url );
- /* * 读取excel文件中的第一个工作表 */
- $currentSheet = $PHPExcel->getSheet ( 0 );
- /* * 取得最大的列号 */
- $allColumn = $currentSheet->getHighestColumn ();
- /* * 取得一共有多少行 */
- $allRow = $currentSheet->getHighestRow ();
- $excel_array = array ();
- // die($file_url);
- $conk = 2;
-
- for($currentRow = $conk; $currentRow <= $allRow; $currentRow ++) {
-
- $excel_column = array ();
- // 后期改进
- if ($allColumn == 'AM')
- $allColumn = 'Z';
-
- /* * 从第A列开始输出 */
- for($currentColumn = 'A'; $currentColumn <= $allColumn; $currentColumn ++) {
- $val = $currentSheet->getCellByColumnAndRow ( ord ( $currentColumn ) - 65, $currentRow )->getValue ();
- if ($val instanceof PHPExcel_RichText)
- $val = $val->__toString ();
- /* * ord()将字符转为十进制数 iconv ( 'utf-8', 'gb2312', */
- // $val = "'" . addslashes ( $val ) . "'";
-
- if ($currentColumn == 'A') {
- $excel_column ['invoiceTitle'] = $val;
- } elseif ($currentColumn == 'B')
- $excel_column ['invoiceType'] = $val;
- elseif ($currentColumn == 'C') {
- $excel_column ['TIN'] = $val;
- } elseif ($currentColumn == 'D') {
- $excel_column ['address'] = $val;
- } elseif ($currentColumn == 'E') {
- $excel_column ['phone'] = $val;
- } elseif ($currentColumn == 'F') {
- $excel_column ['bank'] = $val;
- } elseif ($currentColumn == 'G') {
- $excel_column ['bankAccount'] = $val;
- } elseif ($currentColumn == 'H') {
- $excel_column ['invoiceElement'] = $val;
- } elseif ($currentColumn == 'I') {
- $excel_column ['invoiceQuantity'] = $val;
- } elseif ($currentColumn == 'J') {
- $excel_column ['invoiceUnitPrice'] = $val;
- } elseif ($currentColumn == 'K') {
- $excel_column ['remark'] = $val;
- } elseif ($currentColumn == 'L') {
- $excel_column ['recipientsAddress'] = $val;
- } elseif ($currentColumn == 'M') {
- $excel_column ['recipients'] = $val;
- } elseif ($currentColumn == 'N') {
- $excel_column ['recipientsPhone'] = $val;
- }elseif ($currentColumn == 'O') {
- $excel_column ['electronicPhone'] = $val;
- } elseif ($currentColumn == 'P') {
- $excel_column ['electronicEmail'] = $val;
- }
- }
- if (! empty ( $excel_column ['invoiceTitle'] ) && ! empty ( $excel_column ['invoiceQuantity'] ) && ! empty ( $excel_column ['invoiceUnitPrice'] ))
- array_push ( $excel_array, $excel_column );
- }
- return $excel_array;
- }
-
- /**
- * 格式化excel文件为数组
- * @param unknown_type $file_url
- * @param unknown_type $mcid
- */
- function _format_excel_to_array($file_url = "", $sType = "") {
- if (! file_exists ( $file_url )) {
- return array ();
- }
-
- Doo::loadClass ( 'PHPExcel' );
- // Doo::loadClass ( 'PHPExcel1.7.9/PHPExcel' );
-
- $PHPExcel = new PHPExcel ();
- $PHPReader = new PHPExcel_Reader_Excel2007 ();
-
- if (! $PHPReader->canRead ( $file_url )) {
- $PHPReader = new PHPExcel_Reader_Excel5 ();
- if (! $PHPReader->canRead ( $file_url )) {
-
- echo 'no Excel';
- return;
- }
- }
-
- $PHPExcel = $PHPReader->load ( $file_url );
- /* * 读取excel文件中的第一个工作表 */
- $currentSheet = $PHPExcel->getSheet ( 0 );
- /* * 取得最大的列号 */
- $allColumn = $currentSheet->getHighestColumn ();
- /* * 取得一共有多少行 */
- $allRow = $currentSheet->getHighestRow ();
- $excel_array = array ();
- // die($file_url);
- $conk = 2;
-
- for($currentRow = $conk; $currentRow <= $allRow; $currentRow ++) {
-
- $excel_column = array ();
- // 后期改进
- if ($allColumn == 'AM')
- $allColumn = 'Z';
-
- /* * 从第A列开始输出 */
- for($currentColumn = 'A'; $currentColumn <= $allColumn; $currentColumn ++) {
- $val = $currentSheet->getCellByColumnAndRow ( ord ( $currentColumn ) - 65, $currentRow )->getValue ();
- if ($val instanceof PHPExcel_RichText)
- $val = $val->__toString ();
- /* * ord()将字符转为十进制数 iconv ( 'utf-8', 'gb2312', */
- // $val = "'" . addslashes ( $val ) . "'";
-
- if ($sType == 'invoiceReceivables') {
- if ($currentColumn == 'A')
- $excel_column ['invoiceNo'] = $val;
- elseif ($currentColumn == 'B')
- $excel_column ['receivablesPrice'] = $val;
- elseif ($currentColumn == 'C') {
- $excel_column ['receivablesMessage'] = $val;
- } elseif ($currentColumn == 'D') {
- $excel_column ['receivablesBank'] = $val;
- } elseif ($currentColumn == 'E') {
- $excel_column ['receivablesDate'] = $this->excelTime ( $val );
- } elseif ($currentColumn == 'F') {
- $excel_column ['receivablesStaff'] = $val;
- } elseif ($currentColumn == 'G') {
- $excel_column ['sourcePrice'] = $val;
- }
- } elseif ($sType == "invoiceTrain") {
-
- if ($currentColumn == 'A') {
- $excel_column ['invoiceTitle'] = $val;
- } elseif ($currentColumn == 'B')
- $excel_column ['invoiceType'] = $val;
- elseif ($currentColumn == 'C') {
- $excel_column ['TIN'] = $val;
- } elseif ($currentColumn == 'D') {
- $excel_column ['address'] = $val;
- } elseif ($currentColumn == 'E') {
- $excel_column ['phone'] = $val;
- } elseif ($currentColumn == 'F') {
- $excel_column ['bank'] = $val;
- } elseif ($currentColumn == 'G') {
- $excel_column ['bankAccount'] = $val;
- } elseif ($currentColumn == 'H') {
- $excel_column ['invoiceElement'] = $val;
- } elseif ($currentColumn == 'I') {
- $excel_column ['invoiceQuantity'] = $val;
- } elseif ($currentColumn == 'J') {
- $excel_column ['invoiceUnitPrice'] = $val;
- } elseif ($currentColumn == 'K') {
- $excel_column ['remark'] = $val;
- } elseif ($currentColumn == 'L') {
- $excel_column ['recipientsAddress'] = $val;
- } elseif ($currentColumn == 'M') {
- $excel_column ['recipients'] = $val;
- } elseif ($currentColumn == 'N') {
- $excel_column ['recipientsPhone'] = $val;
- }
- } else {
- if ($currentColumn == 'A')
- $excel_column ['invoiceNo'] = $val;
- elseif ($currentColumn == 'B')
- $excel_column ['invoiceType'] = $val;
- elseif ($currentColumn == 'C') {
- $excel_column ['invoicePrice'] = $val;
- } elseif ($currentColumn == 'D') {
- $excel_column ['invoiceTitle'] = $val;
- } elseif ($currentColumn == 'E') {
- $excel_column ['userName'] = $val;
- } elseif ($currentColumn == 'F') {
- $excel_column ['categoryName'] = $val;
- } elseif ($currentColumn == 'G') {
- $excel_column ['invoiceElement'] = $val;
- } elseif ($currentColumn == 'H') {
- $excel_column ['remark'] = $val;
- } elseif ($currentColumn == 'I') {
- $excel_column ['date'] = $this->excelTime ( $val );
- }
- }
- }
- array_push ( $excel_array, $excel_column );
- }
- return $excel_array;
- }
- function excelTime($date, $time = false) {
- if (function_exists ( 'GregorianToJD' )) {
- if (is_numeric ( $date )) {
- $jd = GregorianToJD ( 1, 1, 1970 );
- $gregorian = JDToGregorian ( $jd + intval ( $date ) - 25569 );
- $date = explode ( '/', $gregorian );
- $date_str = str_pad ( $date [2], 4, '0', STR_PAD_LEFT ) . "-" . str_pad ( $date [0], 2, '0', STR_PAD_LEFT ) . "-" . str_pad ( $date [1], 2, '0', STR_PAD_LEFT ) . ($time ? " 00:00:00" : '');
- return $date_str;
- }
- } else {
- $date = $date > 25568 ? $date + 1 : 25569;
- /* There was a bug if Converting date before 1-1-1970 (tstamp 0) */
- $ofs = (70 * 365 + 17 + 2) * 86400;
- $date = date ( "Y-m-d", ($date * 86400) - $ofs ) . ($time ? " 00:00:00" : '');
- }
- return $date;
- }
- /**
- * 旧输入导入
- */
- function _GetFileEXT($filename) {
- $pics = explode ( '.', $filename );
- $num = count ( $pics );
- return $pics [$num - 1];
- }
- function showCache($path = "", $sid = 0) {
- // if (file_exists ( $path )) {
- // $htm = file_get_contents ( $path );
- // } else {
- Doo::loadModel ( 'invoiceStatistics' );
- $invoiceStatistics = new invoiceStatistics ();
-
- $isBriefly = $invoiceStatistics->getBrieflyStatistics ( $sid );
- $htm = '<tr><th class="taC">' . $isBriefly ['statisticsMonth'] [0] ['month'] . '月累计开票</th>
- <td>¥' . $isBriefly ['statisticsMonth'] [0] ['invoicePrice'] . '</td>
- <th class="taC">' . $isBriefly ['statisticsMonth'] [0] ['month'] . '月累计入账</th>
- <td>¥' . $isBriefly ['statisticsMonth'] [0] ['accountPrice'] . '</td></tr>';
- /*
- * '<tr><th class="taC">今年累计开票</th><td>¥' . $isBriefly ['statisticsYear'] [0] ['invoicePrice'] . '</td> <th class="taC">今年累计入账</th><td>¥' . $isBriefly ['statisticsYear'] [0] ['accountPrice'] . '</td></tr>';
- */
- file_put_contents ( $path, $htm );
- // }
- return $htm;
- }
-
- /**
- * 生成token
- * @return string
- */
- function set_token() {
- $str = md5 ( uniqid ( md5 ( microtime ( true ) ), true ) ); // 生成一个不会重复的字符串
- $str = sha1 ( $str ); // 加密
- return $str;
- }
-
- /**
- * 获取get或者POST值
- *
- * @param string $name 属性名称
- * @return fixed 值
- */
- function get_args($name) {
- if (isset ( $_GET [$name] )) {
- if (is_array ( $_GET [$name] ))
- return $_GET [$name];
- else
- return addslashes ( $_GET [$name] );
- } elseif (isset ( $_POST [$name] )) {
- if (is_array ( $_POST [$name] ))
- return $_POST [$name];
- else
- return addslashes ( $_POST [$name] );
- } else
- return false;
- }
- function SafeFilter(&$arr) {
- $ra = Array (
- '/([\x00-\x08,\x0b-\x0c,\x0e-\x19])/',
- '/script/',
- '/javascript/',
- '/vbscript/',
- '/expression/',
- '/applet/',
- '/meta/',
- '/xml/',
- '/blink/',
- '/link/',
- '/style/',
- '/embed/',
- '/object/',
- '/frame/',
- '/layer/',
- '/title/',
- '/bgsound/',
- '/base/',
- '/onload/',
- '/onunload/',
- '/onchange/',
- '/onsubmit/',
- '/onreset/',
- '/onselect/',
- '/onblur/',
- '/onfocus/',
- '/onabort/',
- '/onkeydown/',
- '/onkeypress/',
- '/onkeyup/',
- '/onclick/',
- '/ondblclick/',
- '/onmousedown/',
- '/onmousemove/',
- '/onmouseout/',
- '/onmouseover/',
- '/onmouseup/',
- '/onunload/'
- );
-
- if (is_array ( $arr )) {
- foreach ( $arr as $key => $value ) {
- if (! is_array ( $value )) {
- if (! get_magic_quotes_gpc ()) // 不对magic_quotes_gpc转义过的字符使用addslashes(),避免双重转义。
- {
- $value = addslashes ( $value ); // 给单引号(')、双引号(")、反斜线(\)与 NUL(NULL 字符)加上反斜线转义
- }
- $value = preg_replace ( $ra, '', $value ); // 删除非打印字符,粗暴式过滤xss可疑字符串
- $arr [$key] = htmlentities ( strip_tags ( $value ) ); // 去除 HTML 和 PHP 标记并转换为 HTML 实体
- } else {
- SafeFilter ( $arr [$key] );
- }
- }
- }
- }
-
- /**
- * Escape String
- *
- * @access public
- * @param string
- * @param bool whether or not the string will be used in a LIKE condition
- * @return string
- */
- function escape_str($str, $like = FALSE) {
- if (is_array ( $str )) {
- foreach ( $str as $key => $val ) {
- $str [$key] = $this->escape_str ( $val, $like );
- }
- return $str;
- }
-
- var_dump ( Doo::db ()->getDbObject () );
- die ();
-
- if (function_exists ( 'mysql_real_escape_string' ) and is_resource ( Doo::db ()->getDbObject () )) { // Doo::db ()->getDbObject()
- $str = mysql_real_escape_string ( $str, Doo::db ()->getDbObject () );
- } elseif (function_exists ( 'mysql_escape_string' )) {
- $str = mysql_escape_string ( $str );
- } else {
- $str = addslashes ( $str );
- }
- // escape LIKE condition wildcards
- if ($like === TRUE) {
- $str = str_replace ( array (
- '%',
- '_'
- ), array (
- '\\%',
- '\\_'
- ), $str );
- }
- return $str;
- }
-
- /**
- * 获得分页数据
- * @param unknown_type $table
- * @param unknown_type $condition
- * @param unknown_type $on_page
- * @param unknown_type $page_size
- */
- function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
- $page_c = "";
- $page ['previous'] = $this->get_previous ( $on_page );
- $page ['on_page'] = $on_page;
- $total_count = $this->get_table_count ( $table, $condition );
- $total = intval ( $total_count / $page_size );
-
- $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
- $page ['total_data'] = $total_count;
- $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
-
- $i = 1;
- $page_max = 1;
- $page_width = 3;
-
- if ($on_page >= $page_width) {
- $page_max = intval ( $on_page / $page_width ) + 1;
- $i = intval ( $on_page / $page_width ) * $page_width - 1;
- }
-
- for(; $i <= $page ['total_page']; $i ++) {
- if ($i == $on_page)
- $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
- else
- $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
-
- if ($i == ($page_width * $page_max))
- break;
- }
-
- $page ['page'] = $page_c;
- $page ['lower'] = (-- $on_page) * $page_size;
- return $page;
- }
- /**
- * 获取上一页
- * @param unknown_type $on_page
- */
- function get_previous($on_page = 1) {
- return $on_page != 0 ? $on_page - 1 : $on_page;
- }
- /**
- * 获取总页数
- * @param unknown_type $table
- * @param unknown_type $condition
- */
- public function get_table_count($table = "", $condition = "") {
- // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
- $sql = "select count(*) as count from " . $table . " where " . $condition;
-
- // echo $sql;die;
- $query = Doo::db ()->query ( $sql );
- $result = $query->fetch ();
- return $result ['count'];
- }
-
-
- function isInvoiceNew($type = "GLOBAL") {
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- $st = $staff->getUserByIdList ( $_COOKIE ["staff"] );
-
- // 我的发票待处理
- $pendingInvoice = $invoice->getOne ( array ( // or (status=2 and printStatus=1 and untreadStatus=0 ) or (status=2 and printStatus=1 and untreadStatus=2 )
- 'where' => "(status=3 or status=4) and isDelete=0 and sid=" . $st [0] ['sid'],
- 'desc' => 'iid',
- 'asArray' => TRUE
- ) );
- // 我的收款待入账
- /*
- * $myClaim = $invoiceReceivables->getOne ( array ( 'where' => " receivablesStaff like '" . $st [0] ['sid'] . "-%' and receivablesCategory like '" . $st [0] ['cid'] . ":%' and bindStatus=0", 'desc' => 'irid', 'asArray' => TRUE ) );
- */
- // 发票审批
- $approval = $invoice->getOne ( array (
- 'where' => 'status=1 and pendingApprovals=' . $st [0] ['sid'],
- 'desc' => 'iid',
- 'asArray' => true
- ) );
- // 发票邮寄
- $post = $invoice->getOne ( array (
- 'where' => "postStatus=0 and printStatus=1 and isDelete=0 and doPost=1 and status=2",
- 'asArray' => TRUE
- ) );
- // 发票打印
- $print = $invoice->getOne ( array (
- 'where' => "status=2 and printStatus=0 and untreadStatus=0 and moldManage like '%[\"" . $st [0] ['sid'] . "\",%'",
- 'desc' => 'iid',
- 'asArray' => TRUE
- ) );
- // 发票退票 printStatus=1 and
- $untread = $invoice->getOne ( array (
- 'where' => " untreadStatus=1 and status=2 ",
- 'asArray' => TRUE
- ) );
-
- $new = array (
- 'GLOBAL' => FALSE,
- 'pendingInvoice' => FALSE,
- // 'myClaim' => FALSE,
- 'approval' => FALSE,
- 'post' => FALSE,
- 'print' => FALSE,
- 'untread' => FALSE
- );
- // || ! empty ( $myClaim )
- if (! empty ( $pendingInvoice ) || ! empty ( $approval ) || ! empty ( $post ) || ! empty ( $print ) || ! empty ( $untread ))
- $new ['GLOBAL'] = TRUE;
- if (! empty ( $pendingInvoice ))
- $new ['pendingInvoice'] = TRUE;
- // if (! empty ( $myClaim ))
- // $new ['myClaim'] = TRUE;
- if (! empty ( $approval ))
- $new ['approval'] = TRUE;
- if (! empty ( $post ))
- $new ['post'] = TRUE;
- if (! empty ( $print ))
- $new ['print'] = TRUE;
- if (! empty ( $untread ))
- $new ['untread'] = TRUE;
- return $new;
- }
- function setWXMsg($rid, $typeMsg = '') {
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
-
- $invoiceDetail = $invoice->getOne ( array (
- 'where' => 'iid=' . $rid,
- 'asArray' => true
- ) );
-
- if (! empty ( $invoiceDetail )) {
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- $staffmsg = $staff->getOne ( array (
- 'where' => "sid='" . $invoiceDetail ['sid'] . "'",
- 'asArray' => TRUE
- ) );
- if (! empty ( $staffmsg ['wxid'] )) {
- require_once (SITE_PATH . '/protected/class/client.php');
- $client = new client ( 'http://m.cld.smartcost.com.cn/' );
- $user = $staffmsg ['wxid'];
-
- $expCom = explode ( ":", $invoiceDetail ['expressCompany'] );
- if (empty ( $expCom ))
- $expCom [0] = '';
-
- $msg = "";
- if (empty ( $typeMsg ))
- $msg = '太好了,您的发票' . $invoiceDetail ['invoiceSerial'] . ' 已邮寄 ' . $expCom [0] . ' ,快递号: <a href="https://m.kuaidi100.com/result.jsp?nu=' . $invoiceDetail ['expressNumber'] . '" >' . $invoiceDetail ['expressNumber'] . '</a>';
- elseif ($typeMsg == "PRINT")
- $msg = '太好了,您的发票已打印完成。';
-
- $result = $client->SendMsg ( $user, $msg, 'text' );
- }
- }
- }
- /**
- * 获取微信部门
- * @param string $category
- * @return number|mixed
- */
- function getToparty($category = '') {
- $token = $this->getAccessToken (); //
- $result = json_decode ( $this->httpGet ( "https://qyapi.weixin.qq.com/cgi-bin/department/list?access_token={$token}&id=5" ), true );
- $toparty = 0;
- foreach ( $result ['department'] as $key => $value ) {
- if ($value ['name'] == $category)
- $toparty = $value ['id'];
- }
- return $toparty;
- }
-
- /**
- * 获得某部门下的用户
- * @param string $toparty
- */
- function getUserByToparty($toparty = '') {
- $token = $this->getAccessToken (); //
-
- $result = json_decode ( $this->httpGet ( "https://qyapi.weixin.qq.com/cgi-bin/user/simplelist?access_token={$token}&department_id={$toparty}" ), true );
-
- $userList = array ();
- foreach ( $result ['userlist'] as $key => $value ) {
- array_push ( $userList, "'" . $value ['userid'] . "'" );
- }
- return $userList;
- }
- function msgSendToparty($msg, $title, $url, $toparty, $text = '') {
- $token = $this->getAccessToken ();
- if ($text == 'text') {
- $data = '{
- "touser": "' . $toparty . '",
- "toparty": "",
- "totag": "",
- "msgtype": "text",
- "agentid": 1000002,
- "text": {
- "content": "' . $msg . '"
- },
- "safe":0
- }';
- }
- $result = json_decode ( $this->httpPOST ( "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={$token}", $data ) );
- if ($result->errmsg != 'ok') {
- return 0;
- } else {
- return 1;
- }
- }
-
- /**
- * 获得可以发送微信用户列表
- * @param string $category
- * @return string
- */
- function getWxidByCategory($category = "") {
- if (empty ( $category ))
- return "";
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- $toparty = $this->getToparty ( $category );
- $wxList = array ();
- $wxString = "";
- if (! empty ( $toparty )) {
- $userList = $this->getUserByToparty ( $toparty );
- $userCon = implode ( ',', $userList );
- // echo $userCon;
- $sidList = $staff->getStaffByWxid ( $userCon );
- foreach ( $sidList as $key => $value ) {
- $falg = $this->isSendNotification ( $value ['sid'], 'receivables' );
- if ($falg) {
- array_push ( $wxList, $value ['wxid'] );
- }
- }
- $wxString = implode ( '|', $wxList );
- }
- return $wxString;
- }
-
- /**
- * 读取发送信息规则判断是否需要发送
- * @param number $sid
- * @param string $sendType
- * @return boolean
- */
- function isSendNotification($sid = 0, $sendType = '') {
- Doo::loadModel ( "notificationConf" );
- $notificationConf = new notificationConf ();
-
- $detail = $notificationConf->getNotificationConfBySid ( $sid );
-
- $conf = array ();
- $sendFlag = true;
- if (! empty ( $detail )) {
- $conf = json_decode ( $detail ['conf'], true );
- if (! empty ( $sendType )) {
- if (isset ( $conf [$sendType] )) {
- if ($conf [$sendType] == "CLOSE")
- $sendFlag = false;
- elseif ($conf [$sendType] == "Weekend") {
- $day = date ( "w" );
- if (1 <= $day && 5 >= $day)
- $sendFlag = false;
- } elseif ($conf [$sendType] == "OneToFriday") {
- $day = date ( "w" );
- if (0 == $day || 6 == $day)
- $sendFlag = false;
- }
- }
- } else
- $sendFlag = false;
- }
- return $sendFlag;
- }
-
- /**
- * 根据规则发送信息
- * @param unknown $msg
- * @param unknown $title
- * @param unknown $url
- * @param unknown $user
- * @param string $text
- * @return number
- */
- private function msgSend($msg, $title, $url, $user, $sid = 0, $sendType = '') {
- $token = $this->getAccessToken ();
- $falg = $this->isSendNotification ( $sid, $sendType );
- // if ($text == 'text') {
- // $data = '{
- // "touser": "' . $user . '",
- // "toparty": "",
- // "totag": "",
- // "msgtype": "text",
- // "agentid": 1000002,
- // "text": {
- // "content": "' . $msg . '"
- // },
- // "safe":0
- // }';
- // } else {
- $data = '{
- "touser": "' . $user . '",
- "toparty": "",
- "totag": "",
- "msgtype": "news",
- "agentid": 1000002,
- "news": {
- "articles":[
- {
- "title": "' . $title . '",
- "description": "' . $msg . '",
- "url": "' . $url . '",
- "picurl": ""
- }
- ]
- }
- }';
- // }
- if ($falg) {
- $result = json_decode ( $this->httpPOST ( "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={$token}", $data ) );
- if ($result->errmsg != 'ok') {
- return 0;
- } else {
- return 1;
- }
- } else
- return 0;
- }
- private function getAccessToken() {
- // access_token 应该全局存储与更新,以下代码以写入到文件中做示例
- // $file = './access_token.txt';
- // $data = json_decode ( file_get_contents ( $file ) );
- // if ($data->expire_time < time () or ! $data->expire_time) {
- // 如果是企业号用以下URL获取access_token
- $url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$this->appId&corpsecret=$this->appSecret";
-
- // $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$this->appId&secret=$this->appSecret";
- $res = json_decode ( $this->httpGet ( $url ) );
- $access_token = $res->access_token;
- // echo $access_token;
- // if ($access_token) {
- // $data->expire_time = time () + 7000;
- // $data->access_token = $access_token;
- // $fp = fopen ( $file, "w" );
- // fwrite ( $fp, json_encode ( $data ) );
- // fclose ( $fp );
- // }
- // } else {
- // $access_token = $data->access_token;
- // }
- return $access_token;
- }
- private function httpGet($url) {
- $curl = curl_init ();
- curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, true );
- curl_setopt ( $curl, CURLOPT_TIMEOUT, 500 );
- // 为保证第三方服务器与微信服务器之间数据传输的安全性,所有微信接口采用https方式调用,必须使用下面2行代码打开ssl安全校验。
- // 如果在部署过程中代码在此处验证失败,请到 http://curl.haxx.se/ca/cacert.pem 下载新的证书判别文件。
- curl_setopt ( $curl, CURLOPT_SSL_VERIFYPEER, true );
- curl_setopt ( $curl, CURLOPT_SSL_VERIFYHOST, false );
- curl_setopt ( $curl, CURLOPT_URL, $url );
-
- $res = curl_exec ( $curl );
- curl_close ( $curl );
-
- return $res;
- }
- private function httpPost($url, $data) {
- $curl = curl_init ();
- curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, true );
- curl_setopt ( $curl, CURLOPT_TIMEOUT, 500 );
- // 为保证第三方服务器与微信服务器之间数据传输的安全性,所有微信接口采用https方式调用,必须使用下面2行代码打开ssl安全校验。
- // 如果在部署过程中代码在此处验证失败,请到 http://curl.haxx.se/ca/cacert.pem 下载新的证书判别文件。
- curl_setopt ( $curl, CURLOPT_SSL_VERIFYPEER, true );
- curl_setopt ( $curl, CURLOPT_SSL_VERIFYHOST, false );
- curl_setopt ( $curl, CURLOPT_URL, $url );
- curl_setopt ( $curl, CURLOPT_POST, 1 );
- curl_setopt ( $curl, CURLOPT_POSTFIELDS, $data );
- $res = curl_exec ( $curl );
- curl_close ( $curl );
-
- return $res;
- }
- }
- ?>
|