1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464 |
- <?php defined('BASEPATH') OR exit('No direct script access allowed');
- class Whlabel extends Start_Controller {
- public function __construct(){
- parent::__construct();
- $this->load->library('session');
- $this->load->_model('Model_whlabel','whlabel');
- $this->load->_model('Model_warehouse','warehouse');
- $this->load->_model('Model_purchase','purchase');
- $this->load->_model('Model_excel','excel');
- $this->load->_model('Model_fullorder','fullorder');
- $this->load->_model('Model_fullordertt','fullordertt');
- $this->load->_model('Model_fullorder_smt','fullorder_smt');
- $this->load->_model('Model_fullordersmt','fullordersmt');
- $this->load->_model('Model_express','express');
- $this->load->_model('Model_shop','shop');
- $this->load->_model('Model_typeclass','typeclass');
- $this->load->_model('Model_country','country');
- $this->load->_model('Model_warehouse','warehouse');
- $this->load->_model('Model_kdniao','kdniao');
- $this->load->_model('Model_notice','notice');
- $this->load->_model('Model_dhl','dhl');
- $this->load->_model('Model_shop','shop');
- $this->load->_model('Model_fullorderexcel','fullorderexcel');
- $this->load->_model('Model_ljg','ljg');
- $this->load->_model('Model_usps','usps');
- $this->load->_model('Model_specialstock','specialstock');
- $this->load->_model('Model_whlabellabel','whlabellabel');
- $this->load->_model('Model_whlabelwz','whlabelwz');
- $this->load->_model('Model_whlabelbarcode','whlabelbarcode');
- $this->load->_model('Model_whlabeltransport','whlabeltransport');
- $this->load->_model('Model_orderurl','orderurl');
- $this->load->_model('Model_brand','brand');
- $this->load->_model('Model_classid','classid');
- $this->load->_model('Model_apiyy','apiyy');
- $this->load->_model('Model_power','power');
- $this->load->_model('Model_whlabel_type','whlabel_type');
- $this->load->_model('Model_company','company');
- $this->load->_model('Model_whlabel_list','whlabel_list');
- $this->load->_model("Model_logic_whlabel","logic_whlabel");
- }
- //定义方法的调用规则 获取URI第二段值
- public function _remap($arg,$arg_array)
- {
- if($arg == 'existence')//在库标签
- {
- $this->_existence();
- }
- else if($arg == 'cpbqdc')//在库标签
- {
- $this->_cpbqdc();
- }
- else if($arg == 'type')//进销存浏览
- {
- $this->_type();
- }
- else if($arg == 'typedy')//进销存浏览店员页面
- {
- $this->_typedy($arg_array);
- }
- else if($arg == 'typedy_ck')//进销存浏览店员页面
- {
- $this->_typedy_ck($arg_array);
- }
- else if($arg == 'typeck')
- {
- $this->_typeck($arg_array);
- }
- else if($arg == 'whlabeckdc')
- {
- $this->_whlabeckdc($arg_array);
- }
- else if($arg == 'usatype')//美仓进销存浏览
- {
- $this->_usatype();
- }
- else if($arg == 'usatypeapp')//美仓APP进销存浏览
- {
- $this->_usatypeapp();
- }
- else if($arg == 'enteradd')//入库操作
- {
- $this->_enteradd();
- }
- else if($arg == 'enteredit')//修改
- {
- $this->_enteredit($arg_array);
- }
- else if($arg == 'enter')//入库浏览
- {
- $this->_enter();
- }
- else if($arg == 'out')//出库浏览
- {
- $this->_out();
- }
- else if($arg == 'label')//出库标签浏览
- {
- $this->_label();
- }
- else if($arg == 'outorder')//独立站出库订单
- {
- $this->_outorder();
- }
- else if($arg == 'soutorder')//速卖通出库订单
- {
- $this->_soutorder();
- }
- else if($arg == 'toutorder')//TT出库订单
- {
- $this->_toutorder();
- }
- else if($arg == 'retreat')//退库订单
- {
- $this->_retreat();
- }
- else if($arg == 'retreatlk')//退库订单
- {
- $this->_retreatlk();
- }
- else if($arg == 'change')//更换标签
- {
- $this->_change();
- }
- else if($arg == 'del')//删除
- {
- $this->_del();
- }
- else if($arg == 'exceljxc')//进销存信息导出
- {
- $this->_exceljxc();
- }
- else if($arg == 'excelr')//入库信息导出
- {
- $this->_excelr();
- }
- else if($arg == 'excelct')//出库、退库信息导出
- {
- $this->_excelct();
- }
- else if($arg == 'dccrtype')//根据出入库类型导出
- {
- $this->_dccrtype();
- }
- else if($arg == 'excelcr')//出库、退库信息导出
- {
- $this->_excelcr();
- }
- else if($arg == 'kcyz')//库存验证
- {
- $this->_kcyz();
- }
- else if($arg == 'kj')//库存扣减
- {
- $this->_kj($arg_array);
- }
- else if($arg == 'presetout')//预设库存导入
- {
- $this->_presetout($arg_array);
- }
- else if($arg == 'presetedit')//预设库存导入
- {
- $this->_presetedit($arg_array);
- }
- else if($arg == 'summary')//汇总导出
- {
- $this->_summary($arg_array);
- }
- else if($arg == 'manifest')//usps发货清单
- {
- $this->_manifest();
- }
- else if($arg == 'abnormal')//占单异常
- {
- $this->_abnormal();
- }
- else if($arg == 'error')//0库存SKU
- {
- $this->_error();
- }
- else if($arg == 'errorexcel')//0库存SKU导出
- {
- $this->_errorexcel();
- }
- else if($arg == 'db')
- {
- $this->_db();
- }
- else if($arg == 'dbrk')
- {
- $this->_dbrk();
- }
- else if($arg == 'whlabelczdc')
- {
- $this->_whlabelczdc();
- }
- else if($arg == 'print')
- {
- $this->_print($arg_array);
- }
- else if($arg == 'usaprint')
- {
- $this->_usaprint($arg_array);
- }
- else if($arg == 'printck')
- {
- $this->_printck($arg_array);
- }
- else if($arg == 'printrk')
- {
- $this->_printrk($arg_array);
- }
- else if($arg == 'printxzrk')
- {
- $this->_printxzrk($arg_array);
- }
- else if($arg == 'printexcel')
- {
- $this->_printexcel($arg_array);
- }
- else if($arg == 'uck')
- {
- $this->_uck();
- }
- else if($arg == 'whlabelexcelzh')
- {
- $this->_whlabelexcelzh();
- }
- else if($arg == 'fc')
- {
- $this->_fc();
- }
- else if($arg == 'fcmb')
- {
- $this->_fcmb();
- }
- else if($arg == 'fcexcel')
- {
- $this->_fcexcel();
- }
- else if($arg == 'fcjxc')
- {
- $this->_fcjxc($arg_array);
- }
- else if($arg == '0kcdel')
- {
- $this->_0kcdel();//导表删除0库存
- }
- else if($arg == 'gbhtype')
- {
- $this->_gbhtype();//更改备货状态
- }
- else
- {
- $this->_index();
- }
- }
- //管理
- public function _index()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $sku = $this->input->post('sku',true);
- $number = $this->input->post('number',true);
- $warehouse = $this->input->post('warehouse',true);
- $purchase = $this->input->post('purchase',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $waybill = $this->input->post('waybill',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $state = $this->input->post('state',true);
- $label = $this->input->post('label',true);
- $timetk = $this->input->post('timetkk',true);
- $timetj = $this->input->post('timetjj',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "1=1 ";
- if($timetk && $timetj)
- {
- $where .= " and time > '$timetk' and time < '$timetj'";
- }
- if($sku)
- {
- $where .= " and sku = '$sku'";
- }
- if($number)
- {
- $where .= " and number = '$number'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($label)
- {
- $where .= " and label = '$label'";
- }
- if($state != '')
- {
- $where .= " and state = '$state'";
- }
- //数据排序
- $order_str = "time desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->whlabel->find_all($where,'id,state,purchase,sku,title,label,printing,enter,warehouse,outk,orderinfo,waybill,text,time',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $purchase = $this->purchase->read($value['purchase']);
- $info_list[$key]['purchase'] = $purchase['title'];
- if($value['enter'] != 0)
- {
- $info_list[$key]['enter'] = '<p>'.date('Y-m-d',$value['enter']).'</p><p>'.date('H:i:s',$value['enter']).'</p>';
- }
- else
- {
- $info_list[$key]['enter'] = "";
- }
- if($value['outk'] != 0)
- {
- $info_list[$key]['outk'] = '<p>'.date('Y-m-d',$value['outk']).'</p><p>'.date('H:i:s',$value['outk']).'</p>';
- }
- else
- {
- $info_list[$key]['outk'] = "";
- }
- if($value['printing'] != 0)
- {
- $info_list[$key]['printing'] = '<p>'.date('Y-m-d',$value['printing']).'</p><p>'.date('H:i:s',$value['printing']).'</p>';
- }
- else
- {
- $info_list[$key]['printing'] = "";
- }
- if($value['orderinfo'] == 0)
- {
- $info_list[$key]['orderinfo'] = "";
- }
- if($value['waybill'] == 0)
- {
- $info_list[$key]['waybill'] = "";
- }
- if($value['state'] == 0)
- {
- $info_list[$key]['state'] = "在库";
- }
- else if($value['state'] == 1)
- {
- $info_list[$key]['state'] = "出库";
- }
- else if($value['state'] == 2)
- {
- $info_list[$key]['state'] = "退库";
- }
- else if($value['state'] == 3)
- {
- $info_list[$key]['state'] = "调拨中";
- }
- else if($value['state'] == 4)
- {
- $info_list[$key]['state'] = "再加工";
- }
- else if($value['state'] == 5)
- {
- $info_list[$key]['state'] = "维修中";
- }
- else if($value['state'] == 6)
- {
- $info_list[$key]['state'] = "盘亏";
- }
- else if($value['state'] == 7)
- {
- $info_list[$key]['state'] = "更换标签";
- }
- else if($value['state'] == 8)
- {
- $info_list[$key]['state'] = "其它";
- }
- else if($value['state'] == 9)
- {
- $info_list[$key]['state'] = "预设";
- }
- else if($value['state'] == 10)
- {
- $info_list[$key]['state'] = "美店零售";
- }
- if($value['text'] == "")
- {
- $info_list[$key]['text'] = "";
- }
- $info_list[$key]['time'] = '<p>'.date('Y-m-d',$value['time']).'</p><p>'.date('H:i:s',$value['time']).'</p>';
- }
- $total = $this->whlabel->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- if(isset($post['outsku']))
- {
- $cz = $this->input->post('cz',true);
- if($cz == '1')
- {
- $sku = $this->input->post('outsku',true);
- if($sku)
- {
- $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
- if(count($data) < 1)
- {
- echo json_encode(array('msg'=>'库存不足!','success'=>false));exit;
- }
- $this->whlabel->save(array('state'=>10,'outk'=>time(),'time'=>time(),'cktype'=>1),$data[0]['id']);
- echo json_encode(array('success'=>true));exit;
- }
- }
- else
- {
- $sku = $this->input->post('outsku',true);
- if($sku)
- {
- $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
- if(count($data) < 1)
- {
- echo json_encode(array('msg'=>'没有此SKU出库数据!','success'=>false));exit;
- }
- $this->whlabel->save(array('state'=>0,'outk'=>0,'time'=>time()),$data[0]['id']);
- echo json_encode(array('success'=>true));exit;
- }
- }
- }
- $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
- $this->_Template('whlabel',$this->data);
- }
- //在库标签
- public function _existence()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['s']))
- {
- $id_arr = $this->input->post('s');
- $id_arr = explode(',',$id_arr);
- if(!$id_arr)
- {
- echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
- }
- //循环删除记录
- foreach ($id_arr as $v)
- {
- $sid = $this->whlabel->read($v);
- $count = $this->whlabel->find_count("state = 0 and sku = '".$sid['sku']."' and warehouse = '".$sid['warehouse']."' and zd != ''");
- if($count > 0)
- {
- echo json_encode(array('msg'=>'有占单,需要先解除占单!','success'=>true));exit;
- }
- $zt = $this->whlabeltransport->find_all('sku = "'.$sid['sku'].'" and warehouse = "'.$sid['warehouse'].'" and features = "'.$sid['features'].'" and cz = "0"');
- if(count($zt) > 0)
- {
- echo json_encode(array('msg'=>'有在途库存无法删除!','success'=>false));exit;
- }
- $this->whlabel->remove($v);
- }
- echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
- }
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $warehouse = $this->input->post('warehouse',true);
- $label = $this->input->post('label',true);
-
- $where = "1=1 and state = 0";
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($label)
- {
- $where .= " and label = '$label'";
- }
- //数据排序
- $order_str = "time asc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->whlabel->find_all($where,'id,sku,title,label,printing,enter',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
- if($value['enter'] != 0)
- {
- $info_list[$key]['enter'] = date('Y-m-d H:i:s',$value['enter']);
- }
- else
- {
- $info_list[$key]['enter'] = "";
- }
- if($value['printing'] != 0)
- {
- $info_list[$key]['printing'] = date('Y-m-d H:i:s',$value['printing']);
- }
- else
- {
- $info_list[$key]['printing'] = "";
- }
-
- }
- $total = $this->whlabel->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->_Template('whlabel_existence',$this->data);
- }
- //进销存浏览
- public function _typedy($arg_array)
- {
- $prc = array();
- $purchase = $this->purchase->find_all();
- foreach($purchase as $k=>$v)
- {
- $prc[$v['id']] = $v['title'];
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $sku = $this->input->post('sku');
- $title = $this->input->post('title');
- $warehouse = $this->input->post('warehouse',true);
- $usa = $this->input->post('usa',true);
- $purchase = $this->input->post('purchase',true);
- $lacetype = $this->input->post('lacetype',true);
- $haircap = $this->input->post('haircap',true);
- $density = $this->input->post('density',true);
- $details = $this->input->post('details',true);
- $state = $this->input->post('state',true);
- $lacecolor = $this->input->post('lacecolor',true);
- $hairnumber = $this->input->post('hairnumber',true);
- $cklx = $this->input->post('cklx',true);
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";$gj = "";$ck = "";
-
- if($usa)
- {
- if(!$warehouse)
- {
- $where .= " and (warehouse = '5' or warehouse = '8')";
- }
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($details)
- {
- $where .= " and details = '$details'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($haircap)
- {
- $where .= " and features like '%-$haircap-%'";
- }
- if($density)
- {
- $where .= " and features like '%-$density-%'";
- }
- if($lacecolor)
- {
- $where .= " and features like '%-$lacecolor-%'";
- }
- if(!empty($hairnumber)){
- $where .= " and features like '%-128-%' ";
- if($hairnumber < 0){
- $class_list = $this->typeclass->find_all('classid = 43');
- foreach($class_list as $v){
- $where .= " and features not like '%-".$v['id']."-%'";
- }
- }else{
- $where .= " and features like '%-$hairnumber-%'";
- }
- }
- $where_add = '';
- if($cklx)
- {
- $shop = $this->shop->read($cklx);
- $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
- }
- if($ktime && $jtime)
- {
- $gj = " and enter > '$ktime' and enter < '$jtime'";
- $ck = " and outk > '$ktime' and outk < '$jtime'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- if($sku)
- {
- $sku = trim($sku,' ');
- $sku = trim($sku,' ');
- $where .= " and sku like '%$sku%'";
- $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm',$order_str,$start,$perpage);
- }
- else if($title)
- {
- $title = trim($title,' ');
- $title = trim($title,' ');
- $where .= " and title like '%$title%'";
- $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm',$order_str,$start,$perpage);
- }
- else
- {
- //$where .= " and time > '$ktime' and time < '$jtime'";
- $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm',$order_str,$start,$perpage);
- }
- //取得信息列表
-
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- $c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
- $z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
- $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$value['sm'].'</p>';
- $number = $value['number'];$ftime = time()-15*24*3600;
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $info_list[$key]['features'] = count($c);
- $z = count($z);//查看订单号
- $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
- $ztdata = '';
- if(count($zt) > 0)
- {
- foreach ($zt as $vv)
- {
- $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
- }
- }
- $info_list[$key]['number'] = $ztdata;
- $info_list[$key]['sm'] = $z;
- $details = array();
- $cpid = array();
- foreach ($c as $k=>$v)
- {
- $details[$v['details']] = $v['details'];
- if($v['cpid'] != 0)
- {
- $cpid[$v['cpid']] = $v['cpid'];
- }
- }
- $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
- if($value['shop'] != '')
- {
- $shop = explode(',',trim($value['shop'],','));
- $shop = $this->shop->read($shop[0]);
- $info_list[$key]['shop'] = $shop['shopname'];
- }
- }
- $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
- echo json_encode($rows);exit;
- }
- $this->data['warehouse'] = (isset($arg_array[0]))?$arg_array[0]:5;
- $this->_Template('whlabel_typedy',$this->data);
- }
-
- //进销存浏览
- public function _typedy_ck($arg_array)
- {
- $prc = array();
- $purchase = $this->purchase->find_all();
- foreach($purchase as $k=>$v)
- {
- $prc[$v['id']] = $v['title'];
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $sku = $this->input->post('sku');
- $title = $this->input->post('title');
- $warehouse = $this->input->post('warehouse',true);
- $usa = $this->input->post('usa',true);
- $purchase = $this->input->post('purchase',true);
- $lacetype = $this->input->post('lacetype',true);
- $haircap = $this->input->post('haircap',true);
- $density = $this->input->post('density',true);
- $details = $this->input->post('details',true);
- $state = $this->input->post('state',true);
- $lacecolor = $this->input->post('lacecolor',true);
- $cklx = $this->input->post('cklx',true);
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";$gj = "";$ck = "";
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($haircap)
- {
- $where .= " and features like '%-$haircap-%'";
- }
- if($density)
- {
- $where .= " and features like '%-$density-%'";
- }
- if($lacecolor)
- {
- $where .= " and features like '%-$lacecolor-%'";
- }
- if($usa)
- {
- if(!$warehouse)
- {
- $where .= " and (warehouse = '5' or warehouse = '8')";
- }
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($details)
- {
- $where .= " and details = '$details'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- $where_add = '';
- if($cklx)
- {
- $shop = $this->shop->read($cklx);
- $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
- }
- if($ktime && $jtime)
- {
- $gj = " and enter > '$ktime' and enter < '$jtime'";
- $ck = " and outk > '$ktime' and outk < '$jtime'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- if($sku)
- {
- $sku = trim($sku,' ');
- $sku = trim($sku,' ');
- $where .= " and sku like '%$sku%'";
- $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,purchase,sku,title,details,shop,cpbz,features,number',$order_str,$start,$perpage);
- }
- else if($title)
- {
- $title = trim($title,' ');
- $title = trim($title,' ');
- $where .= " and title like '%$title%'";
- $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,purchase,sku,title,details,shop,cpbz,features,number',$order_str,$start,$perpage);
- }
- else
- {
- //$where .= " and time > '$ktime' and time < '$jtime'";
- $info_list = $this->whlabel->find_pc($where.$where_add.' and zd != ""','sku,features,warehouse','id,warehouse,purchase,sku,title,details,shop,cpbz,features,zd,COUNT(CASE WHEN zd != "" and state = 0 THEN 1 ELSE NULL END) AS zd','zd desc',$start,$perpage);
- }
- //取得信息列表
-
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- $c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid,text');
- //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
- $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$c[0]['text'].'</p>';
- $ftime = time()-15*24*3600;
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $info_list[$key]['features'] = count($c)<10?"<em style='color:#F00'>".count($c)."</em>":count($c);
- //$z = count($z);//查看订单号
- //$info_list[$key]['zd'] = $z;
- $details = array();
- $cpid = array();
- foreach ($c as $k=>$v)
- {
- $details[$v['details']] = $v['details'];
- if($v['cpid'] != 0)
- {
- $cpid[$v['cpid']] = $v['cpid'];
- }
- }
- $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
- if($value['shop'] != '')
- {
- $shop = explode(',',trim($value['shop'],','));
- $shop = $this->shop->read($shop[0]);
- $info_list[$key]['shop'] = $shop['shopname'];
- }
- }
-
- $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
- echo json_encode($rows);exit;
- }
- $this->data['warehouse'] = (isset($arg_array[0]))?$arg_array[0]:5;
- $this->_Template('whlabel_typedy_ck',$this->data);
- }
-
-
- public function _typeck($arg_array)
- {
- $prc = array();
- $purchase = $this->purchase->find_all();
- foreach($purchase as $k=>$v)
- {
- $prc[$v['id']] = $v['title'];
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lacecolor = $this->input->post('lacecolor',true);
- $lowe = $this->input->post('lowe',true);
- $sku = $this->input->post('sku');
- $title = $this->input->post('title');
- $warehouse = 13;
- $usa = $this->input->post('usa',true);
- $purchase = $this->input->post('purchase',true);
- $lacetype = $this->input->post('lacetype',true);
- $haircap = $this->input->post('haircap',true);
- $density = $this->input->post('density',true);
- $details = $this->input->post('details',true);
- $state = $this->input->post('state',true);
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";$gj = "";$ck = "";
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lacecolor)
- {
- $where .= " and features like '%-$lacecolor-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($haircap)
- {
- $where .= " and features like '%-$haircap-%'";
- }
- if($density)
- {
- $where .= " and features like '%-$density-%'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($details)
- {
- $where .= " and details = '$details'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($ktime && $jtime)
- {
- $gj = " and enter > '$ktime' and enter < '$jtime'";
- $ck = " and outk > '$ktime' and outk < '$jtime'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- if($sku)
- {
- $sku = trim($sku,' ');
- $sku = trim($sku,' ');
- $where .= " and sku like '%$sku%'";
- }
- else if($title)
- {
- $title = trim($title,' ');
- $title = trim($title,' ');
- $where .= " and title like '%$title%'";
- }
- $info_list = $this->whlabel->find_pc($where,'sku,purchase,features,warehouse','id,warehouse,purchase,sku,sm,details,cpbz,features,number,',$order_str,$start,$perpage);
- //取得信息列表
- $t = array();
- $typeclass = $this->typeclass->find_all();
- foreach ($typeclass as $v)
- {
- $t[$v['id']] = $v;
- }
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- $mc = $this->whlabel->find_all("sku = '".$value['sku']."' and features = '".$value['features']."' and warehouse = '".$value['warehouse']."'",'cpbz','id desc',0,1);
- $warehouse = $this->warehouse->read($value['warehouse']);
- $c = $this->whlabel->find_all($where.' and purchase = "'.$value['purchase'].'" and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
- $z = $this->whlabel->find_all($where.' and purchase = "'.$value['purchase'].'" and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
- $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$value['sm'].'</p>';
- $number = $value['number'];$ftime = time()-15*24*3600;
- $z = count($z);//查看订单号
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $info_list[$key]['features'] = count($c);
- $info_list[$key]['number'] = $z;
- //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
- $details = array();
- $cpid = array();
- foreach ($c as $k=>$v)
- {
- $details[$v['details']] = $v['details'];
- if($v['cpid'] != 0)
- {
- $cpid[$v['cpid']] = $v['cpid'];
- }
- }
- $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
- $classid = $this->classid->sku();
- $pm = $classid;
- $features = explode('-',trim($value['features'],'-'));
- foreach($features as $v)
- {
- $zh = explode('|',trim($t[$v]['zh'],'|'));
- $pm[$t[$v]['classid']] = $zh[0];
- }
- $zh = implode(" ",$pm);
- $zh = str_replace('自然色 ','',rtrim($zh,' '));
- $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
- $info_list[$key]['sm'] = $zh;
-
- }
- $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
- echo json_encode($rows);exit;
- }
- $this->data['warehouse'] = (isset($arg_array[0]))?$arg_array[0]:5;
- $this->_Template('whlabel_typeck',$this->data);
- }
- //进销存导出
- public function _whlabeckdc()
- {
- $prc = array();
- $purchase = $this->purchase->find_all();
- foreach($purchase as $k=>$v)
- {
- $prc[$v['id']] = $v['title'];
- }
- if(isset($_GET['excel']))
- {
- $where = "sku != 'Preset'";
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $category = $this->input->get('category',true);
- $color = $this->input->get('color',true);
- $lowe = $this->input->get('lowe',true);
- $lacetype = $this->input->get('lacetype',true);
- $size = $this->input->get('size',true);
- $density = $this->input->get('density',true);
- $haircap = $this->input->get('haircap',true);
- $sku = $this->input->get('sku',true);
- $details = $this->input->get('details',true);
- $warehouse = 13;
- $excelid = $this->input->get('sid',true);
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($density)
- {
- $where .= " and features like '%-$density-%'";
- }
- if($haircap)
- {
- $where .= " and features like '%-$haircap-%'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($sku)
- {
- $where .= " and sku like '%$sku%'";
- }
- if($details)
- {
- $where .= " and details = '$details'";
- }
- $xzid = '';
- if($excelid)
- {
- $excelid = explode(',',trim($excelid,','));
- foreach ($excelid as $key=>$value)
- {
- $xzid .= " id = ".$value." or";
- }
- $xzid = " and (".rtrim($xzid,'or').")";;
- }
- //取得信息列表
- /**
- $info_list = $this->whlabel->find_all($where.$xzid,'*');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
- }
- **/
- $wh = array();
- $w = $this->warehouse->find_all('1=1','id,title');
- foreach ($w as $v)
- {
- $wh[$v['id']] = $v['title'];
- }
- $tc = array();$tcdata = array();
- $typeclass = $this->typeclass->find_all();
- foreach ($typeclass as $v)
- {
- $tc[$v['id']] = $v;
- }
- $list = array();
- $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
- foreach ($rows as $key=>$value)
- {
- $bm = '03';
- $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
- $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- $classid = $this->classid->sku();
- $pm = $classid;
- $jm = $classid;
- $features = explode('-',trim($value['features'],'-'));
- foreach($features as $v)
- {
- if(isset($tc[$v]) && isset($bmpx[$tc[$v]['classid']]))
- {
- if($tc[$v]['bm'] != '')
- {
- $bmpx[$tc[$v]['classid']] = $tc[$v]['bm'];
- }
- }
- if(isset($tc[$v]))
- {
- $zh = explode('|',trim($tc[$v]['zh'],'|'));
- $pm[$tc[$v]['classid']] = $zh[0];
- }
- if(isset($tc[$v]))
- {
- if(isset($jm[$tc[$v]['classid']]))
- {
- $jm[$tc[$v]['classid']] = $tc[$v]['jm'];
-
- }
- }
- }
- $zh = implode(" ",$pm);
- $zh = str_replace('自然色 ','',rtrim($zh,' '));
- $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
- $rows[$key]['dbcontent'] = $zh;
- $rows[$key]['cpbz'] = $bm.implode("",$bmpx);
- $jm = array_filter($jm);
- $rows[$key]['cs'] = implode("-",$jm);
- $sd = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid,cpbz,state');
- $details = array();
- $cpid = array();
- $cpbz = array();
- $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
- foreach ($sd as $k=>$v)
- {
- if($v['state'] == 0)
- {
- $c++;
- }
- if($v['state'] != 9)
- {
- $g++;
- }
- if($v['state'] == 1)
- {
- $x++;
- }
- if($v['state'] == 2)
- {
- $t++;
- }
- if($v['state'] == 8)
- {
- $s++;
- }
- if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
- {
- $q++;
- }
- $details[$v['details']] = $v['details'];
- if($v['cpid'] != 0)
- {
- $cpid[$v['cpid']] = $v['cpid'];
- }
- if($v['cpbz'] != '')
- {
- $cpbz[$v['cpbz']] = $v['cpbz'];
- }
- }
- $rows[$key]['details'] = implode("、",$details);
- $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
- $number = $value['number'];
- $ftime = time()-15*24*3600;
- $rows[$key]['warehouse'] = $wh[$value['warehouse']];
- $rows[$key]['number'] = $g;
- $rows[$key]['features'] = $c;
- $rows[$key]['x'] = $x;
- $rows[$key]['t'] = $t;
- $rows[$key]['s'] = $s;
- $rows[$key]['q'] = $q;
- $rows[$key]['wzsl'] = count($details);
- }
- $title = "进销存统计表".date('Y-m-d',time());
- $titlename = "<table border=1>
- <tr><th colspan='12' align='center'><h3>".$title."<h3></th></tr>
- <tr align='center'>
- <td>仓库</td>
- <td>供应商</td>
- <td>位置</td>
- <td>库存编码</td>
- <td>SKU</td>
- <td>用友编码</td>
- <td>用友料号</td>
- <td>产品英文名</td>
- <td>产品中文名</td>
- <td>入库总量</td>
- <td>库存数量</td>
- <td>销售数量</td>
- <td>退货数量</td>
- <td>删除数量</td>
- <td>其它操作</td>
- <td>位置数量</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($rows,$titlename,$filename,$tail);
- }
- }
-
- public function _type()
- {
- $vip = 0;
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $fgshop = "";$sid = "";
- $usersp = explode('|',trim($user['shop'],'|'));
- foreach ($usersp as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- if($user['vip'] == 1)
- {
- $vip = 1;
- }
- }
- else
- {
- header('Location: /');exit;
- }
- $prc = array();
- $purchase = $this->purchase->find_all();
- foreach($purchase as $k=>$v)
- {
- $prc[$v['id']] = $v['title'];
- }
- $company = array();
- $ct = $this->company->find_all();
- foreach($ct as $k=>$v)
- {
- $company[$v['id']] = $v['title'];
- }
- $sp = array();
- $s = $this->shop->find_all('1=1','id,shopname');
- foreach ($s as $v)
- {
- $sp[$v['id']] = $v['shopname'];
- }
- $wh = array();
- $w = $this->warehouse->find_all('1=1','id,title');
- foreach ($w as $v)
- {
- $wh[$v['id']] = $v['title'];
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $sku = $this->input->post('sku');
- $title = $this->input->post('title');
- $warehouse = $this->input->post('warehouse',true);
- $usa = $this->input->post('usa',true);
- $purchase = $this->input->post('purchase',true);
- $lacetype = $this->input->post('lacetype',true);
- $haircap = $this->input->post('haircap',true);
- $density = $this->input->post('density',true);
- $details = $this->input->post('details',true);
- $state = $this->input->post('state',true);
- $shop = $this->input->post('shop',true);
- $lacecolor = $this->input->post('lacecolor',true);
- $hairnumber = $this->input->post('hairnumber',true);
- $type = $this->input->post('type',true);
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $cpbz = $this->input->post('cpbz',true);
- $where = "1=1";$gj = "";$ck = "";
-
- if($usa)
- {
- if(!$warehouse)
- {
- $where .= " and (warehouse = '5' or warehouse = '8')";
- }
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($details)
- {
- $where .= " and details = '$details'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($shop)
- {
- $where .= " and shop like '%$shop%'";
- }
-
- if($type)
- {
- $where .= " and type = '$type'";
- }
- if($ktime && $jtime)
- {
- $gj = " and enter > '$ktime' and enter < '$jtime'";
- $ck = " and outk > '$ktime' and outk < '$jtime'";
- }
- if($cpbz){
- $where .= " and cpbz like '%$cpbz%' ";
- }
- if($lacecolor)
- {
- $where .= " and features like '%-$lacecolor-%'";
- }
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($haircap)
- {
- $where .= " and features like '%-$haircap-%'";
- }
- if($density)
- {
- $where .= " and features like '%-$density-%'";
- }
- if(!empty($hairnumber)){
- $where .= " and features like '%-128-%' ";
- if($hairnumber < 0){
- $class_list = $this->typeclass->find_all('classid = 43');
- foreach($class_list as $v){
- $where .= " and features not like '%-".$v['id']."-%'";
- }
- }else{
- $where .= " and features like '%-$hairnumber-%'";
- }
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $fjnr = '';
- if($sku)
- {
- $sku = trim($sku,' ');
- $sku = trim($sku,' ');
- $fjnr .= " and sku like '%$sku%'";
- }
- if($title)
- {
- $title = trim($title,' ');
- $title = trim($title,' ');
- $fjnr .= " and title like '%$title%'";
- }
- $wt = array();
- $whlabel_type = $this->whlabel_type->find_all();
- foreach ($whlabel_type as $v)
- {
- $wt[$v['id']] = $v['title'];
- }
-
- //$where .= " and time > '$ktime' and time < '$jtime'";
- $info_list = $this->whlabel->find_pc($where.$fjnr,'sku,purchase,features,warehouse','id,warehouse,purchase,sku,title,details,shop,cpbz,type,features,number,sm',$order_str,$start,$perpage);//改这需要修改_gbhtype
-
- //取得信息列表
- $info_list = $this->logic_whlabel->dataTran($info_list,['pm']);
-
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- if(isset($wt[$value['type']]))
- {
- $info_list[$key]['type'] = $wt[$value['type']];
- }
- else
- {
- $info_list[$key]['type'] = '未设置';
- }
- $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
- $ztdata = '';
- if(count($zt) > 0)
- {
- foreach ($zt as $vv)
- {
- $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
- }
- }
- $qbdata = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
- $cdata = array_filter($qbdata, function($item) {
- return $item['state'] < 1;
- });
- $c = array_sum(array_column($cdata, 'jnum'));
-
- $gdata = array_filter($qbdata, function($item) use ($ktime, $jtime) {
- return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
- });
- $g = array_sum(array_column($gdata, 'jnum'));
-
- $xdata = array_filter($qbdata, function($item) use ($ktime, $jtime) {
- return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
- });
- $x = array_sum(array_column($xdata, 'jnum'));
-
- $tdata = array_filter($qbdata, function($item) use ($ktime, $jtime) {
- return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
- });
- $t = array_sum(array_column($tdata, 'jnum'));
-
- $zdata = array_filter($qbdata, function($item) {
- return $item['zd'] != "" && $item['state'] < 1;
- });
- $z = array_sum(array_column($zdata, 'jnum'));
-
- $zdata = array_filter($qbdata, function($item) {
- return $item['zd'] != "" && $item['state'] < 1;
- });
- $z = array_sum(array_column($zdata, 'jnum'));
-
- //$c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
- //$g = $this->whlabel->find_count($where.$gj.' and sku = "'.$value['sku'].'" and state < 100 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
- //$x = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and state = 1 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
- //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
- //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
- $details = array();
- $cpid = array();
- $od = array();$odid = '';
- $companytitle = '';
- foreach ($qbdata as $v)
- {
- if($v['zd'] != "" && $v['state'] < 1)
- {
- if(!isset($od[$v['zd']]))
- {
- $od[$v['zd']] = 1;//所有数据sku
- }
- else
- {
- $od[$v['zd']] = $od[$v['zd']]+1;
- }
- }
- if($v['state'] < 1)
- {
- $details[$v['details']] = $v['details'];
- if($v['cpid'] != 0)
- {
- $cpid[$v['cpid']] = $v['cpid'];
- }
- }
- if($v['companytitle'] != '' && stripos($companytitle,$company[$v['companytitle']]) === false)
- {
- $companytitle .= '<p>'.$company[$v['companytitle']].'</p>';
- }
- }
- foreach ($od as $k=>$vv)
- {
- $odid .= $k.'数量'.$vv;
- }
- $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$value['sm'].'</p>';
- $number = $value['number'];$ftime = time()-15*24*3600;
- $z = $z.'('.$odid.')';//查看订单号
- $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:'无';
- $info_list[$key]['features'] = $c;
- $info_list[$key]['number'] = $ztdata;
- $info_list[$key]['sm'] = $g;
- $info_list[$key]['x'] = $x;
- $info_list[$key]['t'] = $t;
- $info_list[$key]['z'] = $z;
- /**
- foreach ($cdata as $k=>$v)
- {
- $details[$v['details']] = $v['details'];
- if($v['cpid'] != 0)
- {
- $cpid[$v['cpid']] = $v['cpid'];
- }
- }
- **/
- $info_list[$key]['shop'] = '';
- $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
- if($value['shop'] != '')
- {
- $shop = explode(',',trim($value['shop'],','));
- $info_list[$key]['shop'] = '<p>'.$sp[$shop[0]].'</p>';
- }
- $info_list[$key]['shop'] .= $companytitle;
- /**
- $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
- if(isset($companytitle[0]))
- {
- foreach ($companytitle as $k=>$v)
- {
- if($v['companytitle'] != '')
- {
- $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
- }
- }
- }
- **/
- }
- $final_all_list = [];
- foreach($info_list as $k=>$v){
- $final_all_list[] = [
- 'id'=>$v['id'],
- "warehouse"=>$v["warehouse"],
- "purchase"=>$v["purchase"],
- "sku"=>$v["sku"],
- "title"=>$v["title"]."<br/>".$v["pm"],
- "details"=>$v["details"],
- "shop"=>$v["shop"],
- "cpbz"=>$v["cpbz"],
- "type"=>$v["type"],
- "features"=>$v["features"],
- "number"=>$v["number"],
- "sm"=>$v["sm"],
- "x"=>$v["x"],
- "t"=>$v["t"],
- "z"=>$v["z"]
- ];
- }
-
- $total = count($this->whlabel->find_pc($where.$fjnr,'sku,purchase,features,warehouse','id,warehouse,sku,title,features,number'));
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_all_list));
- echo json_encode($rows);exit;
- }
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $this->data['shop'] = $wlshop;
- $this->data['vip'] = $vip;
- $this->_Template('whlabel_type',$this->data);
- }
-
- //美仓进销存浏览
- public function _usatype()
- {
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";$wid="";$wtype="";
- $userwh = explode('|',trim($user['warehouse'],'|'));
- foreach ($userwh as $value)
- {
- $wid .= " id = ".$value." or";
- $wtype .= " type = ".$value." or";
- }
- }
- $prc = array();
- $purchase = $this->purchase->find_all();
- foreach($purchase as $k=>$v)
- {
- $prc[$v['id']] = $v['title'];
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $sku = $this->input->post('sku');
- $title = $this->input->post('title');
- $warehouse = $this->input->post('warehouse',true);
- $usa = $this->input->post('usa',true);
- $purchase = $this->input->post('purchase',true);
- $lacetype = $this->input->post('lacetype',true);
- $haircap = $this->input->post('haircap',true);
- $density = $this->input->post('density',true);
- $details = $this->input->post('details',true);
- $state = $this->input->post('state',true);
- $lacecolor = $this->input->post('lacecolor',true);
- $cklx = $this->input->post('cklx',true);
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";$gj = "";$ck = "";
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($haircap)
- {
- $where .= " and features like '%-$haircap-%'";
- }
- if($density)
- {
- $where .= " and features like '%-$density-%'";
- }
- if($lacecolor)
- {
- $where .= " and features like '%-$lacecolor-%'";
- }
- if($usa)
- {
- if(!$warehouse)
- {
- $where .= " and (warehouse = '5' or warehouse = '8')";
- }
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($details)
- {
- $where .= " and details = '$details'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- $where_add = '';
- if($cklx)
- {
- $shop = $this->shop->read($cklx);
- $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
- }
- if($ktime && $jtime)
- {
- $gj = " and enter > '$ktime' and enter < '$jtime'";
- $ck = " and outk > '$ktime' and outk < '$jtime'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- if($sku)
- {
- $sku = trim($sku,' ');
- $sku = trim($sku,' ');
- $where .= " and sku like '%$sku%'";
- $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
- }
- else if($title)
- {
- $title = trim($title,' ');
- $title = trim($title,' ');
- $where .= " and title like '%$title%'";
- $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
- }
- else
- {
- //$where .= " and time > '$ktime' and time < '$jtime'";
- $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
- }
- //取得信息列表
-
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
- $g = $this->whlabel->find_count($where.$gj.' and sku = "'.$value['sku'].'" and state < 100 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
- $x = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
- $t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
- $z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
- $od = array();$odid = '';
- foreach ($z as $v)
- {
- if(!isset($od[$v['zd']]))
- {
- $od[$v['zd']] = 1;//所有数据sku
- }
- else
- {
- $od[$v['zd']] = $od[$v['zd']]+1;
- }
- }
- foreach ($od as $k=>$vv)
- {
- $odid .= $k.'数量'.$vv.' ';
- }
- $z = count($z).'('.$odid.')';//查看订单号
- $info_list[$key]['features'] = $c;
- $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
- $ztdata = '';
- if(count($zt) > 0)
- {
- foreach ($zt as $vv)
- {
- $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
- }
- }
- $info_list[$key]['warehouse'] = $ztdata;
- $info_list[$key]['g'] = $g;
- $info_list[$key]['x'] = $x;
- $info_list[$key]['t'] = $t;
- $info_list[$key]['z'] = $z;
- }
- $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title'));
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
- echo json_encode($rows);exit;
- }
- $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
- $this->data['warehouse'] = $warehouse;
- $this->_Template('whlabel_typeusa',$this->data);
- }
- //美仓进销存浏览
- public function _usatypeapp()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $sku = $this->input->post('sku',true);
- $warehouse = 5;
- $title = $this->input->post('title',true);
- $state = $this->input->post('state',true);
-
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";$gj = "";$ck = "";
- if($title)
- {
- $st = explode(' ',trim($title,' '));
- foreach ($st as $v)
- {
- $where .= " and title like '%$v%'";
- }
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($sku)
- {
- $where .= " and sku like '%$sku%'";
- }
- if($ktime && $jtime)
- {
- $gj = " and enter > '$ktime' and enter < '$jtime'";
- $ck = " and outk > '$ktime' and outk < '$jtime'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->whlabel->find_all($where.' and '.rtrim($wid,'or'),'*');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
- }
- $rowsdq = array_slice($rows,$start,$perpage);
- foreach ($rowsdq as $value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'"');
- $x = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$value['warehouse'].'"');
- $t = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
- $od = array();$odid = '';
- $list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'x'=>$x,'t'=>$t);
- }
- $total = count($rows);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
- echo json_encode($rows);exit;
- }
- $this->_Template('phone/p_usatypeapp',$this->data);
- }
- //入库操作
- public function _enteradd()
- {
- $dt = 0;
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";
- $user = explode('|',trim($user['shop'],'|'));
- foreach ($user as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- }
- $tc = $this->typeclass->find_all();
- $typeclass = array();
- foreach ($tc as $v)
- {
- $tcjm[$v['id']] = array($v['jm'],$v['classid']);
- $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'bqsku'=>$v['bqsku']);
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['sku']))
- {
- $list = array();$num = "";$title = "";$features = "";
- $order = $this->input->post('order',true);
- $shop = $this->input->post('shop',true);
- $post['shop'] = ($shop!="")?','.$shop:"";
- $sku = $this->input->post('sku',true);
- $post['sm'] = $this->input->post('sm',true);
- $post['warehouse'] = $this->input->post('warehouse',true);
- $post['purchase'] = $this->input->post('purchase',true);
- $post['retreatwarehouse'] = $post['warehouse'];
- $post['state'] = $this->input->post('state',true);
- $post['rktype'] = $this->input->post('rktype',true);
- $post['text'] = $this->input->post('text',true);
- $category = $this->input->post('category',true);
- $list['category'] = $category;
- $list['hairtype'] = $this->input->post('hairtype',true);
- $list['grade'] = $this->input->post('grade',true);
- $size = $this->input->post('size',true);
- $xzsku = $this->input->post('xzsku',true);
- $list['size'] = rtrim($size,',');
- $list['hairnumber'] = $this->input->post('hairnumber',true);
- $list['extension'] = $this->input->post('extension',true);
- if($category == 1297)
- {
- $list['sywignumber'] = $this->input->post('sywignumber',true);
- }
- if($category == 1702)
- {
- $list['syhairnumber'] = $this->input->post('syhairnumber',true);
- $list['syother'] = $this->input->post('syother',true);
- }
- if($category == 133)
- {
- $list['fittype'] = $this->input->post('fittype',true);
- $list['acother'] = $this->input->post('acother',true);
- }
- $list['color'] = $this->input->post('color',true);
- $list['lowe'] = $this->input->post('lowe',true);
- if(!$post['purchase'])
- {
- $post['purchase'] = 1;
- }
- if($category == 127)
- {
- $list['type'] = $this->input->post('type',true);
- $list['headroad'] = $this->input->post('headroad',true);
- $list['density'] = $this->input->post('density',true);
- if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
- {
- $list['lacesize'] = $this->input->post('lacesize',true);
- }
- $list['lacecolor'] = $this->input->post('lacecolor',true);
- $list['lacetypes'] = $this->input->post('lacetypes',true);
- }
- if($category == 128)
- {
- $list['lacetype'] = $this->input->post('lacetype',true);
- $list['haircap'] = $this->input->post('haircap',true);
- $list['density'] = $this->input->post('density',true);
- $list['lacecolor'] = $this->input->post('lacecolor',true);
- $list['lacetypes'] = $this->input->post('lacetypes',true);
- $list['wigother'] = $this->input->post('wigother',true);
- $list['wigother2'] = $this->input->post('wigother2',true);
- }
- if($category == 129)
- {
- $list['wide'] = $this->input->post('wide',true);
- }
-
- if($category == 131)
- {
- $list['gifttype'] = $this->input->post('gifttype',true);
- $list['giftother'] = $this->input->post('giftother',true);
- }
-
- if($category == 134)
- {
- $list['pieceweight'] = $this->input->post('pieceweight',true);
- }
- if($category == 1297)
- {
- $list['synthetictype'] = $this->input->post('synthetictype',true);
- $list['sywigother'] = $this->input->post('sywigother',true);
- }
- if($category == 130 || $category == 133 || $category == 1702)
- {
- $list['items'] = $this->input->post('items',true);
- $list['weight'] = $this->input->post('weight',true);
- }
- if($category == 1702)
- {
- $list['syhairther'] = $this->input->post('syhairther',true);
- }
- $classid = $this->classid->sku();
- $scsku = $classid;
- $pm = $classid;
- foreach($list as $k=>$v)
- {
- if($v != 0)
- {
- $num .=$v;
- $features .=$v.'-';
- $post[$k] = $v;
- $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
- if($k != 'size')
- {
- $title .= $typeclass[$v]['title']." ";
- }
- if(isset($pm[$typeclass[$v]['classid']]))
- {
- if($typeclass[$v]['title'] == '9A')
- {
- $pm[$typeclass[$v]['classid']] = '9A';
- }
- else if($typeclass[$v]['title'] == '10A')
- {
- $pm[$typeclass[$v]['classid']] = '10A';
- }
- else
- {
- $clzh = $typeclass[$v]['zh'];
- if(stripos($typeclass[$v]['zh'],'|') !== false)
- {
- $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
- $clzh = $clzh[0];
- }
- $pm[$typeclass[$v]['classid']] = $clzh;
- }
- }
- }
- }
- $zh = implode(" ",$pm);
- $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
- $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
- if($list['size'])
- {
- $typeclass = $this->typeclass->read($list['size']);
- $title .= $typeclass['title'];
- }
- $time = time();
- if($xzsku)
- {
- $scsku = implode("-",$scsku);
- $scsku = str_replace('- ','-',trim($scsku,'-'));
- $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
- $post['sku'] = trim($scsku,' ');
- }
- else
- {
- $post['sku'] = $sku;
- }
- //$post['sku'] = trim($sku,' ');
- $post['title'] = rtrim($title,' ');
- $post['number'] = $num;
- $post['features'] = '-'.$features;
- $post['enter'] = $time;
- $post['time'] = $time;//操作时间
- $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
- if($yza)
- {
- if($post['features'] != $yza[0]['features'])
- {
- echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','new'=>$post['features'].'-'.$post['sku'],'old'=>$yza[0]['features'],'success'=>false));exit;
- }
- }
- $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
- if($yzb)
- {
- if($post['sku'] != $yzb[0]['sku'])
- {
- echo json_encode(array('msg'=>'此产品信息的SKU和现有'.$yzb[0]['sku'].'不一致!','success'=>false));exit;
- }
- }
- if(isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop'])
- {
- echo json_encode(array('msg'=>'此产品店铺信息和现有不一致!','success'=>false));exit;
- }
- if($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5)
- {
- echo json_encode(array('msg'=>'非采购入库必须填写入库分类备注!','success'=>false));exit;
- }
- if($post['rktype'] == '' && $post['warehouse'] == 5)
- {
- echo json_encode(array('msg'=>'美仓必须填写入库分类!','success'=>false));exit;
- }
- $yz = $this->whlabel->find_all("sku = '".$post['sku']."' and features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'",'type');
- if(isset($yz[0]['type']))
- {
- $post['type'] = $yz[0]['type'];
- }
- if($post['state'] == 9)//如果选择预设库存
- {
- $this->whlabel->insert($post);
- }
- else
- {
- /**
- $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
- if($ljg == 1)
- {
- for($i=0;$i<$order;$i++)
- {
- $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
- $this->whlabel->insert($post);
- }
- }
- **/
- //if($post['warehouse'] == '5')
- //{
-
- //}
- $yydata = $post;
- $yydata['zh'] = $zh;
- /**
- $wl = $this->apiyy->get_cjlp($yydata);
- if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
- {
- echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
- }
- if($wl['Data'][0]['m_isSucess'] != 1)
- {
- echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
- }
- **/
- for($i=0;$i<$order;$i++)
- {
- $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
- $this->whlabel->insert($post);
- }
- }
- echo json_encode(array('msg'=>'入库成功','success'=>true));exit;
- }
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $this->data['wlshop'] = $wlshop;
- $this->_Template('whlabel_enteradd',$this->data);
- }
- //修改产品
- public function _enteredit($arg_array)
- {
- $dt = 0;
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";
- $user = explode('|',trim($user['shop'],'|'));
- foreach ($user as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['sku']))
- {
- $list = array();$num = "";$title = "";$features = "";
- $id = $this->input->post('id',true);
- $order = $this->input->post('order',true);
- $shop = $this->input->post('shop',true);
- $post['shop'] = ($shop!="")?','.$shop:"";
- $post['sku'] = $this->input->post('sku',true);
- $post['sm'] = $this->input->post('sm',true);
- $post['warehouse'] = $this->input->post('warehouse',true);
- $post['purchase'] = $this->input->post('purchase',true);
- $post['retreatwarehouse'] = $post['warehouse'];
- $category = $this->input->post('category',true);
- $list['category'] = $category;
- $list['hairtype'] = $this->input->post('hairtype',true);
- $list['grade'] = $this->input->post('grade',true);
- $size = $this->input->post('size',true);
- $list['size'] = rtrim($size,',');
- $post['rktype'] = $this->input->post('rktype',true);
- $post['text'] = $this->input->post('text',true);
- $list['hairnumber'] = $this->input->post('hairnumber',true);
- $list['extension'] = $this->input->post('extension',true);
- if($category == 1297)
- {
- $list['sywignumber'] = $this->input->post('sywignumber',true);
- }
- if($category == 1702)
- {
- $list['syhairnumber'] = $this->input->post('syhairnumber',true);
- $list['syother'] = $this->input->post('syother',true);
- }
- if($category == 133)
- {
- $list['fittype'] = $this->input->post('fittype',true);
- $list['acother'] = $this->input->post('acother',true);
- }
- $list['color'] = $this->input->post('color',true);
- $list['lowe'] = $this->input->post('lowe',true);
- if(!$post['purchase'])
- {
- $post['purchase'] = 1;
- }
- if($category == 127)
- {
- $list['type'] = $this->input->post('type',true);
- $list['headroad'] = $this->input->post('headroad',true);
- $list['density'] = $this->input->post('density',true);
- if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
- {
- $list['lacesize'] = $this->input->post('lacesize',true);
- }
- $list['lacecolor'] = $this->input->post('lacecolor',true);
- $list['lacetypes'] = $this->input->post('lacetypes',true);
- }
- if($category == 128)
- {
- $list['lacetype'] = $this->input->post('lacetype',true);
- $list['haircap'] = $this->input->post('haircap',true);
- $list['density'] = $this->input->post('density',true);
- $list['lacecolor'] = $this->input->post('lacecolor',true);
- $list['lacetypes'] = $this->input->post('lacetypes',true);
- $list['wigother'] = $this->input->post('wigother',true);
- $list['wigother2'] = $this->input->post('wigother2',true);
- }
- if($category == 129)
- {
- $list['wide'] = $this->input->post('wide',true);
- }
-
- if($category == 131)
- {
- $list['gifttype'] = $this->input->post('gifttype',true);
- $list['giftother'] = $this->input->post('giftother',true);
- }
-
- if($category == 134)
- {
- $list['pieceweight'] = $this->input->post('pieceweight',true);
- }
- if($category == 1297)
- {
- $list['synthetictype'] = $this->input->post('synthetictype',true);
- $list['sywigother'] = $this->input->post('sywigother',true);
- }
- if($category == 130 || $category == 133 || $category == 1702)
- {
- $list['items'] = $this->input->post('items',true);
- $list['weight'] = $this->input->post('weight',true);
- }
- if($category == 1702)
- {
- $list['syhairther'] = $this->input->post('syhairther',true);
- }
- foreach($list as $k=>$v)
- {
- if($v != 0)
- {
- $num .=$v;
- $features .=$v.'-';
- $typeclass = $this->typeclass->read($v);
- if($k != 'size')
- {
- $title .= $typeclass['title']." ";
- }
- }
- }
- $typeclass = $this->typeclass->read($list['size']);
- $title .= $typeclass['title'];
- $time = time();
- $post['title'] = rtrim($title,' ');
- $post['number'] = $num;
- $post['features'] = '-'.$features;
- $post['time'] = $time;//操作时间
- if($post['rktype'] == '' && $post['warehouse'] == 5)
- {
- echo json_encode(array('msg'=>'美仓必须填写入库分类!','success'=>false));exit;
- }
- if($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5)
- {
- echo json_encode(array('msg'=>'非采购入库必须填写入库分类备注!','success'=>false));exit;
- }
- $uid = $this->whlabel->read($id);
- $datanum = $this->whlabel->find_count("state = 0 and sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."' and zd != ''");
- if($datanum > 0)
- {
- echo json_encode(array('msg'=>'此SKU有占单,请解除占单后再修改!','success'=>false));exit;
- }
- if($post['warehouse'] != '99999')//现在所有仓都检测,之前只有美仓5检测
- {
- $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."'");
- if($yza)
- {
- if($post['features'] != $yza[0]['features'])
- {
- echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','success'=>false));exit;
- }
- }
- $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."'");
- if($yzb)
- {
- if($post['sku'] != $yzb[0]['sku'])
- {
- echo json_encode(array('msg'=>'此产品信息的SKU和现有不一致!','success'=>false));exit;
- }
- }
- if($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop'])
- {
- echo json_encode(array('msg'=>'此产品店铺信息和现有不一致!','success'=>false));exit;
- }
- $data = $this->whlabel->find_all("sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."'");// and enter = '".$uid['enter']."'
- foreach ($data as $v)
- {
- $post['id'] = $v['id'];
- $this->whlabel->save($post,$v['id']);
- }
- }
- else
- {
- $data = $this->whlabel->find_count("state = 0 and sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."' and zd != ''");
- if($data > 0)
- {
- echo json_encode(array('msg'=>'此产品有占单,无法修改!','success'=>false));exit;
- }
- else
- {
- $data = $this->whlabel->find_all("sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."'");// and enter = '".$uid['enter']."'
- foreach ($data as $v)
- {
- $post['id'] = $v['id'];
- $this->whlabel->save($post,$v['id']);
- }
- }
- }
- echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
- }
- $uid = $this->whlabel->read($arg_array[0]);
- $uid['order'] = $this->whlabel->find_count('enter = "'.$uid['enter'].'" and sku = "'.$uid['sku'].'" and state = "0"');
- $this->data['enter'] = $uid ;
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $this->data['wlshop'] = $wlshop;
- $this->_Template('whlabel_enteredit',$this->data);
- }
- //入库浏览
- public function _enter()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['s']))
- {
- $id_arr = $this->input->post('s');
- $id_arr = explode(',',$id_arr);
- if(!$id_arr)
- {
- echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
- }
- //循环删除记录
- foreach ($id_arr as $v)
- {
- $sid = $this->whlabel->read($v);
- $count = $this->whlabel->find_count("state = 0 and sku = '".$sid['sku']."' and warehouse = '".$sid['warehouse']."' and zd != ''");
- if($count > 0)
- {
- echo json_encode(array('msg'=>'有占单,需要先解除占单!','success'=>true));exit;
- }
- $info_list = $this->whlabel->find_all('enter ='.$sid['enter']);
- foreach ($info_list as $va)
- {
- $this->whlabel->remove($va['id']);
- }
- }
- echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
- }
- $sp = array();
- $s = $this->shop->find_all('1=1','id,shopname');
- foreach ($s as $v)
- {
- $sp[$v['id']] = $v['shopname'];
- }
- $wh = array();
- $w = $this->warehouse->find_all('1=1','id,title');
- foreach ($w as $v)
- {
- $wh[$v['id']] = $v['title'];
- }
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $sku = $this->input->post('sku',true);
- $warehouse = $this->input->post('warehouse',true);
- $purchase = $this->input->post('purchase',true);
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";$gj = "";$ck = "";
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($sku)
- {
- $where .= " and sku like '%$sku%'";
- }
- if($ktime && $jtime)
- {
- $where .= " and enter > '$ktime' and enter < '$jtime'";
- }
- //数据排序
- $order_str = "enter desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->whlabel->find_pc($where,'enter,warehouse,sku','id,warehouse,shop,sku,title,enter',$order_str,$start,$perpage);
- foreach ($info_list as $k=>$v)
- {
- $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
- if($v['shop']=='')
- {
- $s = '通用';
- }
- else
- {
- $info_list[$k]['shop'] = '';
- foreach (explode(',',trim($v['shop'],',')) as $val)
- {
- $info_list[$k]['shop'] .= $sp[$val].'</br>';
- }
- }
- $info_list[$k]['enter'] = date('Y-m-d H:i:s',$v['enter']);
- $g = $this->whlabel->find_count($where.' and enter = "'.$v['enter'].'" and sku = "'.$v['sku'].'" and warehouse = "'.$v['warehouse'].'"');
- $info_list[$k]['g'] = $g;
- }
- $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->_Template('whlabel_enter',$this->data);
- }
- //出库浏览
- public function _out()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $sku = $this->input->post('sku',true);
- $warehouse = $this->input->post('warehouse',true);
- $purchase = $this->input->post('purchase',true);
- $state = $this->input->post('state',true);
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "state=3";$gj = "";$ck = "";
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($sku)
- {
- $where .= " and sku = '$sku'";
- }
- if($ktime && $jtime)
- {
- $where .= " and outk > '$ktime' and outk < '$jtime'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->whlabel->find_all($where,'sku');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[] = $value['sku'].'warehouse'.$value['warehouse'];//所有数据sku
- }
- $rows = array_unique($rows);//删除重复记录
- foreach ($rows as $key=>$value)
- {
- $data = $this->whlabel->get_sku($value);//获取目前sku的所有数据
- $ck = $this->warehouse->read($data['warehouse']);
- $warehouse = $ck['title'];
- $gy = $this->purchase->read($data['purchase']);
- $purchase = $gy['purchase'];
- $g = $this->whlabel->find_count($where.' and sku = "'.$value.'" and state = 3');
- $list[] = array('id'=>$data['id'],'warehouse'=>$warehouse,'purchase'=>$purchase,'sku'=>$data['sku'],'title'=>$data['title'],'time'=>date('Y-m-d H:i:s',$data['enter']),'number'=>$g);
- }
- $total = count($list);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $list = array_slice($list,$start,$perpage);//数组中提取分页指定的内容 +true key排序不变
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
- echo json_encode($rows);exit;
- }
- $this->_Template('whlabel_out',$this->data);
- }
-
- //出库标签浏览
- public function _label()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $sku = $this->input->post('sku',true);
- $warehouse = $this->input->post('warehouse',true);
- $purchase = $this->input->post('purchase',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $waybill = $this->input->post('waybill',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
-
- $where = "state=1";
- if($sku)
- {
- $where .= " and sku = '$sku'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- //数据排序
- $order_str = "outk desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->whlabel->find_all($where,'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $purchase = $this->purchase->read($value['purchase']);
- $info_list[$key]['purchase'] = $purchase['title'];
- if($value['outk'] != 0)
- {
- $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
- }
- else
- {
- $info_list[$key]['outk'] = "";
- }
- if($value['orderinfo'] == 0)
- {
- $info_list[$key]['orderinfo'] = "";
- }
- if($value['waybill'] == 0)
- {
- $info_list[$key]['waybill'] = "";
- }
- }
- $total = $this->whlabel->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->_Template('whlabel_label',$this->data);
- }
- //独立站出库订单
- public function _outorder()
- {
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";
- $user = explode('|',trim($user['shop'],'|'));
- foreach ($user as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- }
- else
- {
- echo "请重新登录";
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $warehouse = $this->input->post('warehouse',true);
- $xztime = $this->input->post('xztime',true);
- $timetk = $this->input->post('timetkk',true);
- $timetj = $this->input->post('timetjj',true);
- $shop = $this->input->post('shop',true);
- $source = $this->input->post('source',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $number = $this->input->post('number',true);
- $sfxh = $this->input->post('sfxh',true);
- $express = $this->input->post('express',true);
- $waybill = $this->input->post('waybill',true);
- $library = $this->input->post('library',true);
- $country = $this->input->post('country',true);
- $so = $this->input->post('so',true);
- $libraryconfirm = $this->input->post('libraryconfirm',true);
- $print = $this->input->post('print',true);
- $state = $this->input->post('state',true);
- $orderurl = $this->input->post('orderurl',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- /**
- $sj = $this->input->post('sj',true);
- if($sj)
- {
- $sj = $this->input->post('sj',true);
- }
- else
- {
- $sj = "fullorder";
- }
- **/
- $sj = "fullorder";
- $where = "1=1";
- if($warehouse)
- {
- $where .= " and type = '$warehouse'";
- }
- if($timetk && $timetj)
- {
- $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($number)
- {
- $where .= " and number = '$number'";
- }
- if($express)
- {
- $where .= " and express = '$express'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- if($library)
- {
- $where .= " and library = '$library'";
- }
- if($print)
- {
- $where .= " and print = '$print'";
- }
- if($libraryconfirm)
- {
- $where .= " and libraryconfirm = '$libraryconfirm'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($shop)
- {
- $where .= " and shop = '$shop'";
- }
- if($country)
- {
- $where .= " and country = '$country'";
- }
- if($sfxh != '')
- {
- $where .= " and sfxh = '$sfxh'";
- }
- if($so)
- {
- $where .= " and shipremarks like '%$so%'";
- }
- if($source)
- {
- if($source == '2d')
- {
- $where .= " and source >= '2'";
- }
- else
- {
- $where .= " and source = '$source'";
- }
- }
- if(isset($_SESSION['api']))
- {
- foreach ($user as $value)
- {
- $fgshop .= " shop = ".$value." or";
- }
- $where .= " and (".rtrim($fgshop,'or').")";
- }
- if($orderurl)
- {
- $url = $this->orderurl->read($orderurl);
- $where .= " and link like '%".$url['url']."%'";
- }
- //数据排序
- $order_str = "librarytime desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_list as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_list[$key]['shop'] = $shop['shopname'];
- $express = $this->express->read($value['express']);
- $info_list[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_list[$key]['type'] = $warehouse['title'];
- if($value['librarytime'] == '0')
- {
- $info_list[$key]['librarytime'] = '<em class="t"></em>';
- }
- else
- {
- $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
- }
- }
- $total = $this->$sj->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->data['express'] = $this->express->find_all();
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $this->data['wlshop'] = $wlshop;
- $user = $this->user->get_api($_SESSION['api']);
- $powerid = $this->power->read($user['power']);
- $powertext = explode('|',trim($powerid['excelid'],'|'));
- $pid = '';
- foreach ($powertext as $v)
- {
- $pid .= " id = ".$v." or";
- }
- $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
- $this->data['fullorderexcel'] = $fullorderexcel;
- $orderurl = $this->orderurl->find_all(rtrim($fgshop,'or'));
- $this->data['orderurl'] = $orderurl;
- $this->_Template('whlabel_outorder',$this->data);
- }
-
- //tt出库
- public function _toutorder()
- {
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";
- $user = explode('|',trim($user['shop'],'|'));
- foreach ($user as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- }
- else
- {
- echo "请重新登录";
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $warehouse = $this->input->post('warehouse',true);
- $xztime = $this->input->post('xztime',true);
- $timetk = $this->input->post('timetkk',true);
- $timetj = $this->input->post('timetjj',true);
- $shop = $this->input->post('shop',true);
- $source = $this->input->post('source',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $number = $this->input->post('number',true);
- $sfxh = $this->input->post('sfxh',true);
- $express = $this->input->post('express',true);
- $waybill = $this->input->post('waybill',true);
- $library = $this->input->post('library',true);
- $country = $this->input->post('country',true);
- $so = $this->input->post('so',true);
- $libraryconfirm = $this->input->post('libraryconfirm',true);
- $print = $this->input->post('print',true);
- $state = $this->input->post('state',true);
- $orderurl = $this->input->post('orderurl',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- /**
- $sj = $this->input->post('sj',true);
- if($sj)
- {
- $sj = $this->input->post('sj',true);
- }
- else
- {
- $sj = "fullorder";
- }
- **/
- $sj = "fullordertt";
- $where = "1=1";
- if($warehouse)
- {
- $where .= " and type = '$warehouse'";
- }
- if($timetk && $timetj)
- {
- $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($number)
- {
- $where .= " and number = '$number'";
- }
- if($express)
- {
- $where .= " and express = '$express'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- if($library)
- {
- $where .= " and library = '$library'";
- }
- if($print)
- {
- $where .= " and print = '$print'";
- }
- if($libraryconfirm)
- {
- $where .= " and libraryconfirm = '$libraryconfirm'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($shop)
- {
- $where .= " and shop = '$shop'";
- }
- if($country)
- {
- $where .= " and country = '$country'";
- }
- if($sfxh != '')
- {
- $where .= " and sfxh = '$sfxh'";
- }
- if($so)
- {
- $where .= " and shipremarks like '%$so%'";
- }
- if($source)
- {
- if($source == '2d')
- {
- $where .= " and source >= '2'";
- }
- else
- {
- $where .= " and source = '$source'";
- }
- }
- if(isset($_SESSION['api']))
- {
- foreach ($user as $value)
- {
- $fgshop .= " shop = ".$value." or";
- }
- $where .= " and (".rtrim($fgshop,'or').")";
- }
- if($orderurl)
- {
- $url = $this->orderurl->read($orderurl);
- $where .= " and link like '%".$url['url']."%'";
- }
- //数据排序
- $order_str = "librarytime desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_list as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_list[$key]['shop'] = $shop['shopname'];
- $express = $this->express->read($value['express']);
- $info_list[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_list[$key]['type'] = $warehouse['title'];
- if($value['librarytime'] == '0')
- {
- $info_list[$key]['librarytime'] = '<em class="t"></em>';
- }
- else
- {
- $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
- }
- }
- $total = $this->$sj->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->data['express'] = $this->express->find_all();
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $this->data['wlshop'] = $wlshop;
- $user = $this->user->get_api($_SESSION['api']);
- $powerid = $this->power->read($user['power']);
- $powertext = explode('|',trim($powerid['excelid'],'|'));
- $pid = '';
- foreach ($powertext as $v)
- {
- $pid .= " id = ".$v." or";
- }
- $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
- $this->data['fullorderexcel'] = $fullorderexcel;
- $orderurl = $this->orderurl->find_all(rtrim($fgshop,'or'));
- $this->data['orderurl'] = $orderurl;
- $this->_Template('whlabel_toutorder',$this->data);
- }
-
- //速卖通出库订单
- public function _soutorder()
- {
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";
- $user = explode('|',trim($user['shop'],'|'));
- foreach ($user as $value)
- {
- $sid .= " id = ".$value." or";
- }
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $warehouse = $this->input->post('warehouse',true);
- $xztime = $this->input->post('xztime',true);
- $timetk = $this->input->post('timetkk',true);
- $timetj = $this->input->post('timetjj',true);
- $shop = $this->input->post('shop',true);
- $source = $this->input->post('source',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $number = $this->input->post('number',true);
- $express = $this->input->post('express',true);
- $waybill = $this->input->post('waybill',true);
- $library = $this->input->post('library',true);
- $country = $this->input->post('country',true);
- $sfxh = $this->input->post('sfxh',true);
- $libraryconfirm = $this->input->post('libraryconfirm',true);
- $print = $this->input->post('print',true);
- $state = $this->input->post('state',true);
- $so = $this->input->post('so',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- /**
- $sj = $this->input->post('sj',true);
- if($sj)
- {
- $sj = $this->input->post('sj',true);
- }
- else
- {
- $sj = "fullorder";
- }
- **/
- $sj = "fullordersmt";
- $where = "1=1";
- if($warehouse)
- {
- $where .= " and type = '$warehouse'";
- }
- if($timetk && $timetj)
- {
- $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($number)
- {
- $where .= " and number = '$number'";
- }
- if($express)
- {
- $where .= " and express = '$express'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- if($library)
- {
- $where .= " and library = '$library'";
- }
- if($print)
- {
- $where .= " and print = '$print'";
- }
- if($libraryconfirm)
- {
- $where .= " and libraryconfirm = '$libraryconfirm'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($shop)
- {
- $where .= " and shop = '$shop'";
- }
- if($sfxh != '')
- {
- $where .= " and sfxh = '$sfxh'";
- }
- if($so)
- {
- $where .= " and shipremarks like '%$so%'";
- }
- if($source)
- {
- $where .= " and source = '$source'";
- }
- if($country)
- {
- $where .= " and country = '$country'";
- }
- else
- {
- if(isset($_SESSION['api']))
- {
- foreach ($user as $value)
- {
- $fgshop .= " shop = ".$value." or";
- }
- $where .= " and (".rtrim($fgshop,'or').")";
- }
- }
- //数据排序
- $order_str = "librarytime desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_list as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_list[$key]['shop'] = $shop['shopname'];
- $express = $this->express->read($value['express']);
- $info_list[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_list[$key]['type'] = $warehouse['title'];
- if($value['librarytime'] == '0')
- {
- $info_list[$key]['librarytime'] = '<em class="t"></em>';
- }
- else
- {
- $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
- }
- }
- $total = $this->$sj->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->data['express'] = $this->express->find_all();
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $this->data['wlshop'] = $wlshop;
- $user = $this->user->get_api($_SESSION['api']);
- $powerid = $this->power->read($user['power']);
- $powertext = explode('|',trim($powerid['excelid'],'|'));
- $pid = '';
- foreach ($powertext as $v)
- {
- $pid .= " id = ".$v." or";
- }
- $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
- $this->data['fullorderexcel'] = $fullorderexcel;
- $this->_Template('whlabel_soutorder',$this->data);
- }
-
- //订单退库
- public function _retreat()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $warehouse = $this->input->post('warehouse',true);
- $timetk = $this->input->post('timetk',true);
- $timetj = $this->input->post('timetj',true);
- $shop = $this->input->post('shop',true);
- $source = $this->input->post('source',true);
- $state = $this->input->post('state',true);
- $review = $this->input->post('review',true);
- $state = $this->input->post('state',true);
- $express = $this->input->post('express',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $user = $this->input->post('user',true);
- $name = $this->input->post('name',true);
- $waybill = $this->input->post('waybill',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "(state=206 or state=210) and mergeid = 0";
- if($warehouse)
- {
- $where .= " and state = '$warehouse'";
- }
- if($timetk && $timetj)
- {
- $where .= " and buytime > '$timetk' and buytime < '$timetj'";
- }
- if($shop)
- {
- $where .= " and shop = '$shop'";
- }
- if($source)
- {
- $where .= " and source = '$source'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($review)
- {
- $where .= " and review = '$review'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($express)
- {
- $where .= " and express = '$express'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($user)
- {
- $where .= " and user = '$user'";
- }
- if($name)
- {
- $where .= " and name = '$name'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->fullorder->find_all($where,'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_list as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_list[$key]['shop'] = $shop['shopname'];
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/".$value['id']."'>".$value['orderinfo']."</a>";
- $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']).'</p><p>'.date('H:i:s',$value['buytime']).'</p>';
- if($value['waybill'] == 0)
- {
- $info_list[$key]['waybill'] = "";
- }
- $express = $this->express->read($value['express']);
- $info_list[$key]['express'] = $express['title'];
- $typeclass = $this->typeclass->read($value['state']);
- $info_list[$key]['state'] = $typeclass['title'];
- }
- $total = $this->fullorder->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->data['express'] = $this->express->find_all();
- $this->_Template('whlabel_retreat',$this->data);
- }
- //退库标签浏览
- public function _retreatlk()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $timetk = $this->input->post('timetk',true);
- $timetj = $this->input->post('timetj',true);
- $sku = $this->input->post('sku',true);
- $warehouse = $this->input->post('warehouse',true);
- $purchase = $this->input->post('purchase',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $waybill = $this->input->post('waybill',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $state = $this->input->post('state',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
-
- $where = "state=2";
- if($timetk && $timetj)
- {
- $where .= " and retreat > '$timetk' and retreat < '$timetj'";
- }
- if($sku)
- {
- $where .= " and sku = '$sku'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- //数据排序
- $order_str = "time desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->whlabel->find_all($where,'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
- $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
- $purchase = $this->purchase->read($value['purchase']);
- $info_list[$key]['purchase'] = $purchase['title'];
- if($value['outk'] != 0)
- {
- $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
- }
- else
- {
- $info_list[$key]['outk'] = "";
- }
- if($value['retreat'] != 0)
- {
- $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);
- }
- else
- {
- $info_list[$key]['retreat'] = "";
- }
- if($value['orderinfo'] == 0)
- {
- $info_list[$key]['orderinfo'] = "";
- }
- if($value['waybill'] == 0)
- {
- $info_list[$key]['waybill'] = "";
- }
- }
- $total = $this->whlabel->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->_Template('whlabel_retreatlk',$this->data);
- }
- //更换标签及浏览
- public function _change()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $timetk = $this->input->post('timetk',true);
- $timetj = $this->input->post('timetj',true);
- $label = $this->input->post('label',true);
- $oldlabel = $this->input->post('oldlabel',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "state=10 ";
- if($timetk && $timetj)
- {
- $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
- }
- if($label)
- {
- $where .= " and label = '$label'";
- }
- if($oldlabel)
- {
- $where .= " and oldlabel = '$oldlabel'";
- }
- //数据排序
- $order_str = "time asc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->whlabel->find_all($where,'id,oldlabel,oldtitle,label,title, labeltime',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
- $info_list[$key]['labeltime'] = date('Y-m-d H:i:s',$value['labeltime']);
- }
- $total = $this->whlabel->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->_Template('whlabel_change',$this->data);
- }
-
- //产品标签
- public function _cpbqdc()
- {
- if(isset($_GET['excel']))
- {
- $where = "1=1";
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $warehouse = $this->input->get('warehouse',true);
- $state = $this->input->get('state',true);
- $timetk = $this->input->get('timetkk',true);
- $timetj = $this->input->get('timetjj',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($state || $state == 0)
- {
- $where .= " and state = '$state'";
- }
- if($timetk && $timetj)
- {
- $where .= " and time > '$timetk' and time < '$timetj'";
- }
- //取得信息列表
- $info_list = $this->whlabel->find_all($where,'*');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[$value['time']] = $value;//所有数据sku
- }
- foreach ($rows as $value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $s = $this->whlabel->find_count($where.' and time = "'.$value['time'].'"');
- $list[] = array($warehouse['title'],$value['sku'],$value['title'],date('Y-m-d H:i:s',$value['enter']),date('Y-m-d H:i:s',$value['time']),$value['text'],$s);
- }
- $title = "产品标签统计表";
- $titlename = "<table border=1>
- <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
- <tr align='center'>
- <td>仓库</td>
- <td>SKU</td>
- <td>产品</td>
- <td>入库时间</td>
- <td>操作时间</td>
- <td>备注</td>
- <td>数量</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($list,$titlename,$filename,$tail);
- }
- }
- //进销存导出
- public function _exceljxc()
- {
- $classid = $this->classid->sku();
- $pm = $classid;
- $typeclass = array();
- $tc = $this->typeclass->find_all();
- foreach ($tc as $v)
- {
- $typeclass[$v['id']] = $v;
- }
- $prc = array();
- $purchase = $this->purchase->find_all();
- foreach($purchase as $k=>$v)
- {
- $prc[$v['id']] = $v['title'];
- }
- if(isset($_GET['excel']))
- {
- $where = "sku != 'Preset'";
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $category = $this->input->get('category',true);
- $warehouse = $this->input->get('warehouse',true);
- $excelid = $this->input->get('sid',true);
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- $xzid = '';
- if($excelid)
- {
- $excelid = explode(',',trim($excelid,','));
- foreach ($excelid as $key=>$value)
- {
- $xzid .= " id = ".$value." or";
- }
- $xzid = " and (".rtrim($xzid,'or').")";;
- }
- //取得信息列表
- /**
- $info_list = $this->whlabel->find_all($where.$xzid,'*');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
- }
- **/
-
- $wt = array();
- $whlabel_type = $this->whlabel_type->find_all();
- foreach ($whlabel_type as $v)
- {
- $wt[$v['id']] = $v['title'];
- }
- $wh = array();
- $w = $this->warehouse->find_all('1=1','id,title');
- foreach ($w as $v)
- {
- $wh[$v['id']] = $v['title'];
- }
- $list = array();
- $rows = $this->whlabel->find_pc($where,'sku,purchase,features,warehouse','warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
- foreach ($rows as $key=>$value)
- {
- if(isset($wt[$value['type']]))
- {
- $rows[$key]['type'] = $wt[$value['type']];
- }
- else
- {
- $rows[$key]['type'] = '未设置';
- }
- $bm = '03';
- $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
- $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- $sd = $this->whlabel->find_all($where.' and purchase = "'.$value['purchase'].'" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid,cpbz,state');
- $details = array();
- $cpid = array();
- $cpbz = array();
- $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
- foreach ($sd as $k=>$v)
- {
- if($v['state'] == 0)
- {
- $c++;
- if($v['cpid'] != 0)
- {
- $cpid[$v['cpid']] = $v['cpid'];
- }
- if($v['cpbz'] != '')
- {
- $cpbz[$v['cpbz']] = $v['cpbz'];
- }
- }
- if($v['state'] != 9)
- {
- $g++;
- }
- if($v['state'] == 1)
- {
- $x++;
- }
- if($v['state'] == 2)
- {
- $t++;
- }
- if($v['state'] == 8)
- {
- $s++;
- }
- if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
- {
- $q++;
- }
- $details[$v['details']] = $v['details'];
- }
- $z = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
- $rows[$key]['details'] = implode("、",$details);
- $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
- $number = $value['number'];
- $ftime = time()-15*24*3600;
- $rows[$key]['warehouse'] = $wh[$value['warehouse']];
- $rows[$key]['number'] = $g;
- $rows[$key]['c'] = $c;
- $rows[$key]['x'] = $x;
- $rows[$key]['t'] = $t;
- $rows[$key]['s'] = $s;
- $rows[$key]['q'] = $q;
- $rows[$key]['z'] = $z;
-
- $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
- $features = explode('-',trim($features,'-'));
- $rows[$key]['dbcontent'] = $typeclass[$features[0]]['title'];
- $pm = $classid;
- $jm = $classid;
- foreach($features as $k=>$v)
- {
- if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
- {
- if($typeclass[$v]['bm'] != '')
- {
- $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
- }
- }
- if($v != 0)
- {
- if(!isset($typeclass[$v]))
- {
- continue;
- }
- if(isset($pm[$typeclass[$v]['classid']]))
- {
- if(stripos($typeclass[$v]['zh'],'|') !== false)
- {
- $tz = explode('|',$typeclass[$v]['zh']);
- $pm[$typeclass[$v]['classid']] = $tz[0];
- }
- else
- {
- $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
- }
- }
- if(isset($jm[$typeclass[$v]['classid']]))
- {
- $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
-
- }
- }
- }
- $jm = array_filter($jm);
- $rows[$key]['bs'] = implode("-",$jm);
- $rows[$key]['cs'] = $bm.implode("",$bmpx);
- $zh = implode(" ",$pm);
- $zh = str_replace('自然色 ','',trim($zh,' '));
- $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
- $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
- $rows[$key]['features'] = $zh;
-
- }
- $title = "总进销存统计表";
- $titlename = "<table border=1>
- <tr><th colspan='20' align='center'><h3>".$title."<h3></th></tr>
- <tr align='center'>
- <td>仓库</td>
- <td>供应商</td>
- <td>位置</td>
- <td>库存编码</td>
- <td>类目</td>
- <td>SKU</td>
- <td>用友编码</td>
- <td>用友料号</td>
- <td>商品名称</td>
- <td>商品中文</td>
- <td>产品备注</td>
- <td>说明</td>
- <td>类型</td>
- <td>入库总量</td>
- <td>库存数量</td>
- <td>销售数量</td>
- <td>退货数量</td>
- <td>删除数量</td>
- <td>其它操作</td>
- <td>占单数量</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($rows,$titlename,$filename,$tail);
- }
- }
- //入库导出
- public function _excelr()
- {
- if(isset($_GET['excel']))
- {
- $category = $this->input->get('category',true);
- $size = $this->input->get('size',true);
- $grade = $this->input->get('grade',true);
- $color = $this->input->get('color',true);
- $lowe = $this->input->get('lowe',true);
- $sku = $this->input->get('sku',true);
- $warehouse = $this->input->get('warehouse',true);
- $purchase = $this->input->get('purchase',true);
- $ktime = $this->input->get('ktime',true);
- $jtime = $this->input->get('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";$gj = "";$ck = "";
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($sku)
- {
- $where .= " and sku = '$sku'";
- }
- if($ktime && $jtime)
- {
- $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $list = array();
- $rows = $this->whlabel->find_pc($where,'enter,sku,warehouse','*',$order_str);
- foreach ($rows as $value)
- {
- $ck = $this->warehouse->read($value['warehouse']);
- $warehouse = $ck['title'];
- $tkck = $this->warehouse->read($value['retreatwarehouse']);//退库仓库
- $retreatwarehouse = $tkck['title'];
- $gy = $this->purchase->read($value['purchase']);
- $purchase = $gy['title'];
- $g = $this->whlabel->find_count($where.' and enter = "'.$value['enter'].'" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'"');
- $list[] = array('warehouse'=>$warehouse,'sku'=>$value['sku'],'title'=>$value['title'],'time'=>date('Y-m-d H:i:s',$value['enter']),'number'=>$g);
- }
- $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."入库详情";
- $titlename = "<table border=1>
- <tr><th colspan='5' align='center'><h3>".$title."<h3></th></tr>
- <tr align='center'>
- <td>仓库</td>
- <td>SKU</td>
- <td>产品</td>
- <td>时间</td>
- <td>数量</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($list,$titlename,$filename,$tail);
- }
- }
-
- //出库、退库导出
- public function _excelct()
- {
- $classid = $this->classid->sku();
- $pm = $classid;
- $typeclass = array();
- $tc = $this->typeclass->find_all();
- foreach ($tc as $v)
- {
- $typeclass[$v['id']] = $v;
- }
- $prc = array();
- $purchase = $this->purchase->find_all();
- foreach($purchase as $k=>$v)
- {
- $prc[$v['id']] = $v['title'];
- }
- if(isset($_GET['excel']))
- {
- $wh = array();
- $w = $this->warehouse->find_all('1=1','id,title');
- foreach ($w as $v)
- {
- $wh[$v['id']] = $v['title'];
- }
- $type = $this->input->get('excel',true);
- $category = $this->input->get('category',true);
- $size = $this->input->get('size',true);
- $grade = $this->input->get('grade',true);
- $color = $this->input->get('color',true);
- $lowe = $this->input->get('lowe',true);
- $sku = $this->input->get('sku',true);
- $warehouse = $this->input->get('warehouse',true);
- $lacetype = $this->input->get('lacetype',true);
- $lacecolor = $this->input->get('lacecolor',true);
- $density = $this->input->get('density',true);
- $haircap = $this->input->get('haircap',true);
- $purchase = $this->input->get('purchase',true);
- $title = $this->input->get('title',true);
- $state = $this->input->get('state',true);
- $sid = $this->input->get('sid',true);
- $ktime = $this->input->get('ktime',true);
- $jtime = $this->input->get('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";$gj = "";$ck = "";
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($lacecolor)
- {
- $where .= " and features like '%-$lacecolor-%'";
- }
- if($density)
- {
- $where .= " and features like '%-$density-%'";
- }
- if($haircap)
- {
- $where .= " and features like '%-$haircap-%'";
- }
- if($title)
- {
- $title = trim($title,' ');
- $title = trim($title,' ');
- $where .= " and title like '%$title%'";
- }
- if($sku)
- {
- $sku = trim($sku,' ');
- $sku = trim($sku,' ');
- $where .= " and sku like '%$sku%'";
- }
- if($ktime && $jtime)
- {
- if($type == 1)
- {
- $tl = '出库';
- $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
- }
- else if($type == 2)
- {
- $tl = '退库';
- $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
- }
- else if($type == 3)
- {
- $gj = " and enter > '$ktime' and enter < '$jtime'";
- $ck = " and outk > '$ktime' and outk < '$jtime'";
- }
- else if($type == 4)
- {
- $tl = '出库+零售';
- $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
- }
- else if($type == 5)
- {
- $tl = '零售';
- $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
- }
- }
- $sidwhere = '';
- if($sid)
- {
- $sd = "";
- $s = explode(',',trim($sid,','));
- foreach ($s as $value)
- {
- $sd .= " id = ".$value." or";
- }
- $sidwhere = " and (".rtrim($sd,'or').")";
- }
- //数据排序
- $order_str = "time desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- if($type != 3 && $type != 5)
- {
- if($type == 1 || $type == 4)
- {
- $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk',$order_str);
- foreach ($info_list as $key=>$value)
- {
- $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
- $features = explode('-',trim($features,'-'));
- $pm = $classid;
- foreach($features as $k=>$v)
- {
- if($v != 0)
- {
- if(!isset($typeclass[$v]))
- {
- continue;
- }
- if(isset($pm[$typeclass[$v]['classid']]))
- {
- if(stripos($typeclass[$v]['zh'],'|') !== false)
- {
- $tz = explode('|',$typeclass[$v]['zh']);
- $pm[$typeclass[$v]['classid']] = $tz[0];
- }
- else
- {
- $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
- }
- }
- }
- }
- $zh = implode(" ",$pm);
- $zh = str_replace('自然色 ','',trim($zh,' '));
- $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
- $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
- $info_list[$key]['features'] = $zh;
- }
- }
- else
- {
- $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat',$order_str);
- foreach ($info_list as $key=>$value)
- {
- $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);//减12调整美国时间
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
- $features = explode('-',trim($features,'-'));
- $pm = $classid;
- foreach($features as $k=>$v)
- {
- if($v != 0)
- {
- if(!isset($typeclass[$v]))
- {
- continue;
- }
- if(isset($pm[$typeclass[$v]['classid']]))
- {
- if(stripos($typeclass[$v]['zh'],'|') !== false)
- {
- $tz = explode('|',$typeclass[$v]['zh']);
- $pm[$typeclass[$v]['classid']] = $tz[0];
- }
- else
- {
- $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
- }
- }
- }
- }
- $zh = implode(" ",$pm);
- $zh = str_replace('自然色 ','',trim($zh,' '));
- $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
- $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
- $info_list[$key]['features'] = $zh;
- }
- }
- $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
- $titlename = "<table border=1>
- <tr><th colspan='8' align='center'><h3>".$title."<h3></th></tr>
- <tr align='center'>
- <td>仓库</td>
- <td>供应商</td>
- <td>SKU</td>
- <td>商品名称</td>
- <td>商品中文</td>
- <td>标签</td>
- <td>订单号</td>
- <td>运单号</td>
- <td>".$tl."时间(中国时间)</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
- }
- else if($type == 5)
- {
- $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,outk',$order_str);
- foreach ($info_list as $key=>$value)
- {
- $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
- $features = explode('-',trim($features,'-'));
- $pm = $classid;
- foreach($features as $k=>$v)
- {
- if($v != 0)
- {
- if(!isset($typeclass[$v]))
- {
- continue;
- }
- if(isset($pm[$typeclass[$v]['classid']]))
- {
- if(stripos($typeclass[$v]['zh'],'|') !== false)
- {
- $tz = explode('|',$typeclass[$v]['zh']);
- $pm[$typeclass[$v]['classid']] = $tz[0];
- }
- else
- {
- $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
- }
- }
- }
- }
- $zh = implode(" ",$pm);
- $zh = str_replace('自然色 ','',trim($zh,' '));
- $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
- $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
- $info_list[$key]['features'] = $zh;
- }
- $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
- $titlename = "<table border=1>
- <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
- <tr align='center'>
- <td>仓库</td>
- <td>供应商</td>
- <td>SKU</td>
- <td>商品名称</td>
- <td>商品中文</td>
- <td>标签</td>
- <td>".$tl."时间(中国时间)</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
- }
- else
- {
- /**
- $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
- }
- **/
- $wh = array();
- $w = $this->warehouse->find_all('1=1','id,title');
- foreach ($w as $v)
- {
- $wh[$v['id']] = $v['title'];
- }
- $wt = array();
- $whlabel_type = $this->whlabel_type->find_all();
- foreach ($whlabel_type as $v)
- {
- $wt[$v['id']] = $v['title'];
- }
- $classid = $this->classid->sku();
- $list = array();
- $rows = $this->whlabel->find_pc($where.$sidwhere,'sku,purchase,features,warehouse','warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
- foreach ($rows as $key=>$value)
- {
- $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- $sd = $this->whlabel->find_all($where.' and purchase = "'.$value['purchase'].'" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid,cpbz,state,outk,retreat');
- $details = array();
- $cpid = array();
- $cpbz = array();
- $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
- foreach ($sd as $k=>$v)
- {
- if($v['state'] == 0)
- {
- $c++;
- }
- if($v['state'] != 9)
- {
- $g++;
- }
- if($v['outk'] > 1)
- {
- $x++;
- }
- if($v['retreat'] > 0)
- {
- $t++;
- }
- if($v['state'] == 8)
- {
- $s++;
- }
- if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
- {
- $q++;
- }
- $details[$v['details']] = $v['details'];
- if($v['cpid'] != 0)
- {
- $cpid[$v['cpid']] = $v['cpid'];
- }
- if($v['cpbz'] != '')
- {
- $cpbz[$v['cpbz']] = $v['cpbz'];
- }
- }
- if(isset($wt[$value['type']]))
- {
- $rows[$key]['type'] = $wt[$value['type']];
- }
- else
- {
- $rows[$key]['type'] = '未设置';
- }
- $rows[$key]['details'] = implode("、",$details);
- $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
- $ftime = time()-15*24*3600;
- $rows[$key]['warehouse'] = $wh[$value['warehouse']];
- $rows[$key]['cpbz'] = ($cpbz)?implode(" ",$cpbz):'';
- $rows[$key]['g'] = $this->whlabel->find_count($where.' and purchase = "'.$value['purchase'].'" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and state != 9'.$gj);
- $rows[$key]['c'] = $c;
- $rows[$key]['x'] = $this->whlabel->find_count($where.' and purchase = "'.$value['purchase'].'" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and state = 1'.$ck);
- $rows[$key]['t'] = $t;
-
-
- $z = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
- $rows[$key]['z'] = $z;
- $jm = $classid;
-
- $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
- $features = explode('-',trim($features,'-'));
- $pm = $classid;
- foreach($features as $k=>$v)
- {
- if($v != 0)
- {
- if(!isset($typeclass[$v]))
- {
- continue;
- }
- if(isset($pm[$typeclass[$v]['classid']]))
- {
- if(stripos($typeclass[$v]['zh'],'|') !== false)
- {
- $tz = explode('|',$typeclass[$v]['zh']);
- $pm[$typeclass[$v]['classid']] = $tz[0];
- }
- else
- {
- $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
- }
- if(isset($jm[$typeclass[$v]['classid']]))
- {
- if($typeclass[$v]['jm'])
- {
- $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
- }
- }
- }
- }
- }
- $zh = implode(" ",$pm);
- $zh = str_replace('自然色 ','',trim($zh,' '));
- $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
- $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
- $rows[$key]['features'] = $zh;
- $jm = array_filter($jm);//去除空值
- $jm = implode("-",$jm);
- $rows[$key]['jm'] = $jm;
- $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
- }
- $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'进销存详情';
- $titlename = "<table border=1>
- <tr><th colspan='17' align='center'><h3>".$title."<h3></th></tr>
- <tr align='center'>
- <td>仓库</td>
- <td>供应商</td>
- <td>位置</td>
- <td>库存编码</td>
- <td>SKU</td>
- <td>商品名称</td>
- <td>商品中文</td>
- <td>产品备注</td>
- <td>说明</td>
- <td>类型</td>
- <td>入库总量</td>
- <td>库存数量</td>
- <td>销售数量</td>
- <td>退货数量</td>
- <td>占单数量</td>
- <td>料号</td>
- <td>类目</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($rows,$titlename,$filename,$tail);
- }
- }
- }
-
- //出库+入库数据整合
- public function _excelcr()
- {
- if(isset($_GET['excel']))
- {
- $type = $this->input->get('excel',true);
- $category = $this->input->get('category',true);
- $size = $this->input->get('size',true);
- $grade = $this->input->get('grade',true);
- $color = $this->input->get('color',true);
- $lowe = $this->input->get('lowe',true);
- $sku = $this->input->get('sku',true);
- $warehouse = $this->input->get('warehouse',true);
- $purchase = $this->input->get('purchase',true);
- $state = $this->input->get('state',true);
- $sid = $this->input->get('sid',true);
- $ktime = $this->input->get('ktime',true);
- $jtime = $this->input->get('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";$gj = "";$ck = "";
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($sku)
- {
- $where .= " and sku like '%$sku%'";
- }
- if($ktime && $jtime)
- {
- $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
- }
- $sidwhere = '';
- if($sid)
- {
- $sd = "";
- $s = explode(',',trim($sid,','));
- foreach ($s as $value)
- {
- $sd .= " id = ".$value." or";
- }
- $sidwhere .= " and (".rtrim($sd,'or').")";
- }
-
- //取得信息列表
- $timeread = $ktime;
- $timenum = ceil(($jtime - $ktime) / (24*3600));
- $timelist = array();
- for($i=0;$i<$timenum;$i++)
- {
- $timeread = ($i>0)?$ktime+$i*24*3600:$ktime;
- $timelist[date('Y-m-d',$timeread)] = array('c'=>0,'r'=>0);
- }
-
- $info_list = $this->whlabel->find_all($where.$sidwhere,'outk,enter,sku,state');
- //echo "<pre>";
- //print_r($info_list);
- //exit();
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $thistime = $timelist;
- if(isset($rows[strtolower($value['sku'])]))
- {
- if($value['outk'] > $ktime && $value['state'] < $jtime)
- {
- $rows[strtolower($value['sku'])][date('Y-m-d',$value['outk'])]['c'] += 1;
- }
- if($value['enter'] > $ktime && $value['enter'] < $jtime)
- {
- $rows[strtolower($value['sku'])][date('Y-m-d',$value['enter'])]['r'] += 1;
- }
- }
- else
- {
- if($value['outk'] > $ktime && $value['outk'] < $jtime)
- {
- $thistime[date('Y-m-d',$value['outk'])]['c'] += 1;
- }
- if($value['enter'] > $ktime && $value['enter'] < $jtime)
- {
- $thistime[date('Y-m-d',$value['enter'])]['r'] += 1;
- }
- $rows[strtolower($value['sku'])] = $thistime;
- }
- }
- $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
- <head>
- <!--[if gte mso 9]><xml>
- <x:ExcelWorkbook>
- <x:ExcelWorksheets>
- <x:ExcelWorksheet>
- <x:Name>EXCEL</x:Name>
- <x:WorksheetOptions>
- <x:Print>
- <x:ValidPrinterInfo />
- </x:Print>
- </x:WorksheetOptions>
- </x:ExcelWorksheet>
- </x:ExcelWorksheets>
- </x:ExcelWorkbook>
- </xml>
- <![endif]-->
- </head><body>";
-
- $str .= "<table border=1><tr><td>SKU</td>";
- foreach ($timelist as $k=>$v)
- {
- $str .="<td>".$k."出库</td>";
- $str .="<td>".$k."入库</td>";
- }
- $str .= "</tr></table>";
- $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
- foreach ($rows as $key=>$val)
- {
- $str .= "<tr><td>".strtoupper($key)."</td>";
- foreach ($val as $k=>$v)
- {
- $str .= "<td>".$val[$k]['c']."</td>";
- if($val[$k]['r'] > 0)
- {
- $str .= "<td style='color:#f00'>-".$val[$k]['r']."</td>";
- }
- else
- {
- $str .= "<td>".$val[$k]['r']."</td>";
- }
- }
- $str .= "</tr>";
- }
- $str .= "</table>";
- $str .= "</body></html>";
- header( "Content-Type: application/vnd.ms-excel; name='excel'" );
- header( "Content-type: application/octet-stream" );
- header( "Content-Disposition: attachment; filename=".time().'.xls' );
- header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
- header( "Pragma: no-cache" );
- header( "Expires: 0" );
- exit($str);
-
- }
- }
-
-
- //数量调整模板导出
- public function _presetout()
- {
- if(isset($_GET['excel']))
- {
- $where = "sku != 'Preset' and purchase != 0";
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->whlabel->find_pc($where,'warehouse,purchase,sku','*','id desc',0,1);
- $rows = array();$list = array();
- foreach ($info_list as $value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $number = $value['number'];$ftime = time()-15*24*3600;
- $purchase = $this->purchase->read($value['purchase']);
- $list[] = array($warehouse['title'],$purchase['bm'],$value['sku'],'0','','0','','');
- }
- $title = "库存模板";
- $titlename = "<table border=1>
- <tr align='center'>
- <td>仓库</td>
- <td>供应商编码</td>
- <td>SKU</td>
- <td>增减数量(正数或负数)</td>
- <td>增减备注</td>
- <td>扣减方式:0减少库存1删除库存</td>
- <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
- <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($list,$titlename,$filename,$tail);
- }
- }
- //数量调整模板导入
- public function _presetedit()
- {
- $dir = '/data/excel/'.date('Ymd',time()).'/';
- $config['upload_path'] = '.'.$dir ;
- $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
- $config['allowed_types'] = 'xls|xlsx|csv';
- $config['max_size'] = 10240;
- $this->load->library('upload', $config);
- $this->upload->initialize($config);
- if ($this->upload->do_upload('userfile'))
- {
- $full_path = $dir.$this->upload->data('file_name');
- $fileName = '.' . $full_path;
- if (!file_exists($fileName))
- {
- echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
- }
- else
- {
- require_once "./data/excel/PHPExcel/IOFactory.php";
- $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
- $phpExcel->setActiveSheetIndex(0);// 设置为默认表
- $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
- $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
- $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
- ++$column;//如果列数大于26行
- $list = array();
- for ($i = 2; $i <= $row; $i++) // 行数循环
- {
- $data = array();
- for ($c = 'A'; $c != $column; $c++) // 列数循环
- {
- $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
- }
- $list[] = $data;
- }
- }
- $i = 0;$j = 0;$ed = array();
- foreach ($list as $key=>$value)
- {
- $time = time();
- if($value['0'] == "")
- {
- continue;
- }
- $warehouse = $this->warehouse->get_title($value['0']);
- $purchase = $this->purchase->get_bm($value['1']);
- $sku = $value['2'];
- $num = $value['3'];//调整数量
- $text = $value['4'];//扣减说明
- $type = $value['5'];//调整方式0扣减1删除
- $rktype = $value['6']!=''?$value['6']:0;//增加库存
- $cktype = $value['7']!=''?$value['7']:0;//减少库存
- $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
- if(!$purchase)//如果没有这个SKU
- {
- $ed[] = array($purchase.'-不存在此供应商编码');
- $j++;
- continue;
- }
- if(!$d)//如果没有这个SKU
- {
- $ed[] = array($sku.'-库存中不存在此SKU');
- $j++;
- continue;
- }
- if(!isset($warehouse['id']))
- {
- $ed[] = array($sku.'-仓库名错误!');
- $j++;
- continue;
- }
- if($type != '0' && $type != '1')
- {
- $ed[] = array($sku.'-扣减方式填写错误!');
- $j++;
- continue;
- }
- if($num < 0)//扣减库存
- {
- if($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == '')))
- {
- $ed[] = array($sku.'-扣减必须填写扣减类型,非类型1必须填写备注');
- $j++;
- continue;
- }
- $data = $this->whlabel->find_all('warehouse = "'.$warehouse['id'].'" and sku = "'.$sku.'" and zd = "" and state = 0');
- if(count($data) < abs($num))
- {
- $ed[] = array($sku.'-扣减数量大于库存剩余数量!');
- $j++;
- continue;
- }
- if($type == 0)//如果扣减方式为 扣减库存
- {
- for($i=0;$i<abs($num);$i++)
- {
- $this->whlabel->save(array('state'=>8,'textout'=>$text,'deltime'=>$time,'cktype'=>$cktype,'time'=>$time,'outk'=>$time),$data[$i]['id']);
- }
- }
- else if($type == 1)
- {
- $zt = $this->whlabeltransport->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'" and features = "'.$d['features'].'" and cz = "0"');
- if(count($zt) > 0)
- {
- $ed[] = array($sku.'-有在途库存无法删除!');
- $j++;
- continue;
- }
- for($i=0;$i<abs($num);$i++)
- {
- $this->whlabel->remove($data[$i]['id']);
- }
- }
- }
- else if($num > 0)//增加库存
- {
- if($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == '')))
- {
- $ed[] = array($sku.'-增加必须填写增加类型,非类型1必须填写备注');
- $j++;
- continue;
- }
- $post['sku'] = $d['sku'];
- $post['shop'] = $d['shop'];
- $post['warehouse'] = $warehouse['id'];
- $post['purchase'] = $purchase['id'];
- $post['retreatwarehouse'] = $d['retreatwarehouse'];
- $post['state'] = 0;
- $post['title'] = $d['title'];
- $post['number'] = $d['number'];
- $post['features'] = $d['features'];
- $post['enter'] = $time;
- $post['time'] = $time;//操作时间
- $post['rktype'] = $rktype;
- for($i=0;$i<$num;$i++)
- {
- $post['label'] = time().rand(100,999).$i;
- $this->whlabel->insert($post);
- }
- }
- sleep(1);//防止入库时间一样,需要延迟1秒
- }
- if($j > 0)
- {
- $tt = date('Ymd',time());
- $title = '库存导入错误信息-'.$tt;
- $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
- $tail = "\n";
- $filename = $title.".xls";
- $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
- $dir = '/data/excel/'.$time.'/';
- $file_name = 'error_'.$time.rand(1000,9999);
- if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
- $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
- fwrite($myfile,$ecl);
- fclose($myfile);
- $error = $dir.$file_name.'.xls';
- echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
- }
- }
- }
- //笛卡儿积
- function cp($ps,$sets,$list)
- {
- $result = array();$j=0;
- for($i=0,$count=count($sets); $i<$count-1; $i++)
- {
- if($i==0)
- {
- $result = $sets[$i];
- }
- $tmp = array();
- foreach($result as $res)
- {
- foreach($sets[$i+1] as $set)
- {
- $tmp[] = $res.','.$set;
- }
- }
- $result = $tmp;
- }
- $this->db->trans_begin();
- foreach ($result as $v)
- {
- $post = array();$title = "";$num="";
- $data = explode(',',$v);
- for($i=0;$i<count($list); $i++)
- {
- $post[$list[$i]] = $data[$i];
- $typeclass = $this->typeclass->read($data[$i]);
- $title = $title.$typeclass['title']." ";
- if($data[$i] != 0)
- {
- $num .=$data[$i];//所有数据ID拼接
- }
- }
- foreach ($ps as $kp=>$vp)
- {
- $post[$kp] = $vp;
- }
- $post['number'] = $num;
- $info_list = $this->whlabel->get_number($num);//查询whlabel是否存在此拼接的数据ID
- if($info_list)
- {
- $j++;
- }
- else
- {
- $skunum = $this->whlabel->find_count();
- $post['sku'] = 'LY'.substr(strval($skunum+1+10000000),1,7);
- $post['title'] = rtrim($title,' ');
- $this->whlabel->insert($post);
- }
-
- }
- if ($this->db->trans_status() === FALSE)
- {
- $this->db->trans_commit();
- return NULL;
- }
- else
- {
- $this->db->trans_commit();
- return $j;
- }
- }
- public function _kj($arg_array)
- {
- if(isset($_POST['sku']))
- {
- $time = time();
- $sku = $this->input->post('sku',true);
- $warehouse = $this->input->post('warehouse',true);
- $num = $this->input->post('num',true);
- $text = $this->input->post('text',true);
- $purchase = $this->input->post('purchase',true);
- $cktype = $this->input->post('cktype',true);
- $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
- if($cktype != 1 && $text == '')
- {
- echo json_encode(array('msg'=>"非销售出库必须填写备注!",'success'=>false));exit;
- }
- if($num > count($order))
- {
- echo json_encode(array('msg'=>"扣减数量大于剩余库存数量!",'success'=>false));exit;
- }
- else
- {
- for($i=0;$i<$num;$i++)
- {
- $this->whlabel->save(array('state'=>8,'cktype'=>$cktype,'textout'=>$text,'deltime'=>$time,'time'=>$time,'outk'=>$time),$order[$i]['id']);
- }
- }
- echo json_encode(array('msg'=>"扣减成功!",'success'=>false));exit;
- }
- $uid = $this->whlabel->read($arg_array[0]);
- $uid['num'] = $this->whlabel->find_count('purchase = "'.$uid['purchase']. '" and sku = "'.$uid['sku']. '" and warehouse = "'.$uid['warehouse']. '" and zd = "" and state = 0');
- $this->data['data'] = $uid ;
- $this->_Template('whlabel_kj',$this->data);
- }
- public function _summary($arg_array)
- {
- $prc = array();
- $purchase = $this->purchase->find_all();
- foreach($purchase as $k=>$v)
- {
- $prc[$v['id']] = $v['title'];
- }
- if(isset($_GET['excel']))
- {
- $ktime = $this->input->get('ktime',true);
- $jtime = $this->input->get('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";
- if($ktime && $jtime)
- {
- $where .= " and outk > '$ktime' and outk < '$jtime'";
- }
- //数据排序
- $order_str = "time desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->whlabel->find_pc($where,'sku','warehouse,purchase,details,cpid,sku,title');
- foreach ($info_list as $key=>$value)
- {
- $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $x = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'"','details,cpid');
- $details = array();
- $cpid = array();
- foreach ($x as $k=>$v)
- {
- if($v['details'] != '')
- {
- $details[$v['details']] = $v['details'];
- }
- if($v['cpid'] != 0)
- {
- $cpid[$v['cpid']] = $v['cpid'];
- }
- }
- $info_list[$key]['details'] = ($details)?implode(" ",$details):'';
- $info_list[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
- $s = $this->whlabel->find_count('state = 0 and sku = "'.$value['sku'].'"');
- $info_list[$key]['s'] = $s;
- $info_list[$key]['x'] = count($x);
- }
- $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'出库汇总详情';
- $titlename = "<table border=1>
- <tr align='center'>
- <td>仓库</td>
- <td>供应商</td>
- <td>出库位置</td>
- <td>出库编码</td>
- <td>SKU</td>
- <td>产品名</td>
- <td>总剩余库存</td>
- <td>".date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."销售数量</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
- }
- }
- //usps发货清单
- public function _manifest()
- {
- if(isset($_POST['manifest']))
- {
- $wltext = $this->input->post('wltext',true);
- $time = time()-16*3600;
- $ptime = strtotime(date('Y-m-d',$time));
- $waybill = array();
- $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
- foreach ($fullorder as $v)
- {
- $waybill[$v['waybill']] = $v['waybill'];
- }
- $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
- foreach ($fullordersmt as $v)
- {
- $waybill[$v['waybill']] = $v['waybill'];
- }
- $wltext = explode(';',$wltext);
- foreach ($wltext as $v)
- {
- if(isset($waybill[$v]))
- {
- unset($waybill[$v]);
- }
- }
- $data = $this->usps->get_manifest($waybill);
- if(isset($data['Description']))
- {
- echo json_encode(array('msg'=>$data['Description'],'success'=>false));exit;
- }
- else if(isset($data['SCANFormImage']) && isset($data['SCANFormNumber']))
- {
- $bctime = date('Ymd',time());
- $pdf = $this->_pdf($data['SCANFormImage'],$data['SCANFormNumber'],$bctime);
- echo json_encode(array('msg'=>$pdf,'success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>$data,'success'=>false));exit;
- }
- }
- }
- public function _pdf($pdf,$title,$bctime)
- {
- $pdf_path = './data/pdf/'.$bctime.'/';
- $file_base64 = $pdf;
- $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
- $file_base64 = base64_decode($file_base64);
- if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
- file_put_contents($pdf_path.$title.'.pdf',$file_base64);
- return 'http://'.$_SERVER['HTTP_HOST'].'/data/pdf/'.$bctime.'/'.$title.'.pdf';
- }
-
-
-
-
- /**
- *
- *
- *
- 进销存占单异常索引
- *
- *
- *
- **/
-
- public function _abnormal()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $sku = $this->input->post('sku',true);
- $where = "1=1";
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->whlabel->find_all($where,'*');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[strtolower($value['sku'])] = $value;//所有数据sku
- }
- foreach ($rows as $value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "5"');
- $number = $value['number'];$ftime = time()-15*24*3600;
- if($value['shop'] != '')
- {
- $shop = $value['shop'];
- $orderdlz = $this->fullorder->find_all("time > '$ftime' and shop = '$shop' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'",'whlabel,shop,orderinfo,number');
- $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and shop = '$shop' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'",'whlabel,shop,orderinfo,number');
- $order = array_merge($orderdlz,$ordersmt);
- $od = 0;$a = '';$orid = '';
- foreach ($order as $v)
- {
- $or = explode('|',ltrim($v['whlabel'],'|'));
- for($i=0;$i<count($or);$i++)
- {
- $orod = explode('-',$or[$i]);
- if($orod[0] == $number)
- {
- $od += $orod[1];
- }
- }
- $orid .= $v['number'].'-';
- }
- }
- else
- {
- $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'",'whlabel,shop,orderinfo,number');
- $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'",'whlabel,shop,orderinfo,number');
- $order = array_merge($orderdlz,$ordersmt);
- $od = 0;$a = '';$orid = '';$qt = array();
- foreach ($order as $v)
- {
- $or = explode('|',ltrim($v['whlabel'],'|'));
- for($i=0;$i<count($or);$i++)
- {
- $orod = explode('-',$or[$i]);
- if($orod[0] == $number)
- {
- $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '".$v['shop']."' and state = 0");
- if($czzs > 0)
- {
- if(isset($qt[$v['shop']]))
- {
- if($qt[$v['shop']] < $orod[1])
- {
- $od += $orod[1];//专属小于单量不计算剩余直接归入通用
- $orid .= $v['number'].'+数量'.$orod[1].'-';
- }
- else
- {
- $qt[$v['shop']] -= $orod[1];
- }
- }
- else
- {
- $qt[$v['shop']] = $czzs;
- }
- }
- else
- {
- $od += $orod[1];
- $orid .= $v['number'].'+数量'.$orod[1].'-';
- }
- }
- }
- }
- }
- $z = $od.'('.$orid.')';//查看订单号
- //$z = $od;
- if($od > $c)
- {
- $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'z'=>$z);
- }
- }
- $listdata = array_slice($list,$start,$perpage);
- $total = count($list);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
- echo json_encode($rows);exit;
- }
- $this->_Template('whlabel_abnormal',$this->data);
- }
- /**
- *
- *
- *
- 进销存占单异常索引
- *
- *
- *
- **/
-
- public function _error()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $sku = $this->input->post('sku',true);
- $warehouse = $this->input->post('warehouse',true);
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "sku != 'Preset'";
- $gj = '';
- if($sku)
- {
- $where .= " and sku like '%$sku%'";
- }
- else
- {
- if($ktime && $jtime)
- {
- $gj = " and time > '$ktime' and time < '$jtime'";
- }
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- //$info_list = $this->whlabel->find_all($where.$gj,'*');
- $rows = array();$list = array();
- $info_list = $this->whlabel->find_pc($where,'warehouse,features,sku','*');
- // foreach ($info_list as $value)
- // {
- // $warehouse = $this->warehouse->read($value['warehouse']);
- // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
- // $number = $value['number'];$ftime = time()-15*24*3600;
- // if($c < 1)
- // {
- // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
- // }
- // }
-
-
- $warehouse_list = $this->warehouse->find_all();
- $warehouse_list = array_column($warehouse_list,null,'id');
-
- foreach ($info_list as $value)
- {
- $warehouse = isset($warehouse_list[$value['warehouse']])?$warehouse_list[$value['warehouse']]:[
- 'title'=>"",
- ];
- $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
- $number = $value['number'];$ftime = time()-15*24*3600;
- if($c < 1)
- {
- $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
- }
- }
- // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
- // $query = $this->db->query($sql);
-
- // $info_list = $query->result_array();
- // $sql_two = "select title,id from crowd_warehouse";
- // $query_two = $this->db->query($sql_two);
- // $warehouse_list = $query_two->result_array();
- // $warehouse_arr = array_column($warehouse_list,null,'id');
- // foreach ($info_list as $value)
- // {
- // if(isset($warehouse_arr[$value['warehouse']])){
- // $warehouse = $warehouse_arr[$value['warehouse']];
- // }else{
- // $warehouse = [
- // 'id'=>0,
- // 'title'=>"异常",
- // ];
- // }
- // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
- // $number = $value['number'];$ftime = time()-15*24*3600;
- // if($c < 1)
- // {
- // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
- // }
- // }
- $listdata = array_slice($list,$start,$perpage);
- $total = count($list);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
- echo json_encode($rows);exit;
- }
- if(isset($post['s']))
- {
- $id_arr = $this->input->post('s');
- $id_arr = explode(',',trim($id_arr,','));
- if(!$id_arr)
- {
- echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
- }
- //循环删除记录
- foreach ($id_arr as $v)
- {
- $dd = $this->whlabel->read($v);
- if(!isset($dd['id']))
- {
- echo json_encode(array('msg'=>$dd['sku'].'已被删除,请刷新页面','success'=>false));exit;
- }
- $zt = $this->whlabeltransport->find_all('sku = "'.$dd['sku'].'" and warehouse = "'.$dd['warehouse'].'" and features = "'.$dd['features'].'" and cz = "0"');
- if(isset($zt[0]))
- {
- echo json_encode(array('msg'=>'有在途库存无法删除!','success'=>false));exit;
- }
- $deldd = $this->whlabel->find_all("sku = '".$dd['sku']."' and warehouse = '".$dd['warehouse']."'");
- foreach ($deldd as $vv)
- {
- $this->whlabel->remove($vv['id']);
- }
- }
- echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
- }
- $this->_Template('whlabel_error',$this->data);
- }
-
- public function _errorexcel()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($_GET['page']))
- {
- $page = $this->input->get('page',true);
- $perpage = $this->input->get('perpage',true);
- $sku = $this->input->get('sku',true);
- $warehouse = $this->input->get('warehouse',true);
- $ktime = $this->input->get('ktime',true);
- $jtime = $this->input->get('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "sku != 'Preset'";
- $gj = '';
- if($sku)
- {
- $where .= " and sku like '%$sku%'";
- }
- else
- {
- if($ktime && $jtime)
- {
- $gj = " and time > '$ktime' and time < '$jtime'";
- }
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $rows = array();$list = array();
- $info_list = $this->whlabel->find_pc($where,'warehouse,features,sku','*');
- foreach ($info_list as $value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
- $number = $value['number'];$ftime = time()-15*24*3600;
- if($c < 1)
- {
- $list[] = array('warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
- }
- }
- $title = "0库存汇总";
- $titlename = "<table border=1>
- <tr align='center'>
- <td>仓库</td>
- <td>SKU</td>
- <td>产品</td>
- <td>当前库存</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($list,$titlename,$filename,$tail);
- }
- }
- /**
- *
- *
- * 占单
- *
- *
- **/
- public function _kcyz()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['warehouse']))
- {
- return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请更新浏览器缓存!','success'=>false)));exit;//不再使用
- $warehouse = $this->input->post('warehouse',true);
- $whlabel = $this->input->post('whlabel',true);
- $id = $this->input->post('id',true);
- $shop = $this->input->post('shop',true);
- $number = $this->input->post('number',true);
- if(!$whlabel || $whlabel == '|')
- {
- return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请先添加产品信息!','success'=>false)));exit;
- }
- $pp = explode('|',trim($whlabel,'|'));
- $x = 0;$save = array();
- foreach ($pp as $va)
- {
- $num = explode('-',$va);
- if($number)
- {
- $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and (shop IS NULL or shop = '')");//通用
- $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%,".$shop.",%'");//专属
- }
- else
- {
- $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')");//通用
- $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%,".$shop.",%'");//专属
- }
- $x++;
- if(count($whlabel)+count($shopwhlabel) < $num[1])
- {
- $save[] = $x-1;continue;//提前先加X不然出错,所以要减1
- }
- }
- if(isset($save[0]))
- {
- echo json_encode(array('t'=>2,'msg'=>"红色商品名库存匹配错误或库存不够扣减",'error'=>$save,'success'=>false));exit;
- }
- else
- {
- echo json_encode(array('success'=>true));exit;
- }
- }
- }
-
- public function _db()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $sku = $this->input->post('sku',true);
- $number = $this->input->post('number',true);
- $warehouse = $this->input->post('warehouse',true);
- $purchase = $this->input->post('purchase',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $waybill = $this->input->post('waybill',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $state = $this->input->post('state',true);
- $label = $this->input->post('label',true);
- $timetk = $this->input->post('timetkk',true);
- $timetj = $this->input->post('timetjj',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "dbtime > 0";
- if($timetk && $timetj)
- {
- $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
- }
- if($sku)
- {
- $where .= " and sku = '$sku'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- if($warehouse == 12)
- {
- $w = 'specialstock';
- }
- else
- {
- $w = 'whlabel';
- }
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($state != '')
- {
- $where .= " and state = '$state'";
- }
- //数据排序
- $order_str = "dbtime desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->$w->find_all($where,'id,state,purchase,sku,title,warehouse,dbtime,enter',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
- $warehouse = $this->$w->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $purchase = $this->purchase->read($value['purchase']);
- $info_list[$key]['purchase'] = $purchase['title'];
- if($value['enter'] != 0)
- {
- $info_list[$key]['enter'] = '<p>'.date('Y-m-d H:i:s',$value['enter']).'</p>';
- }
- else
- {
- $info_list[$key]['enter'] = "";
- }
- if($value['dbtime'] != 0)
- {
- $info_list[$key]['dbtime'] = '<p>'.date('Y-m-d H:i:s',$value['dbtime']).'</p>';
- }
- else
- {
- $info_list[$key]['dbtime'] = "";
- }
-
- if($value['state'] == 0)
- {
- $info_list[$key]['state'] = "在库";
- }
- else if($value['state'] == 1)
- {
- $info_list[$key]['state'] = "出库";
- }
- else if($value['state'] == 2)
- {
- $info_list[$key]['state'] = "退库";
- }
- else if($value['state'] == 3)
- {
- $info_list[$key]['state'] = "调拨中";
- }
- else if($value['state'] == 4)
- {
- $info_list[$key]['state'] = "再加工";
- }
- else if($value['state'] == 5)
- {
- $info_list[$key]['state'] = "维修中";
- }
- else if($value['state'] == 6)
- {
- $info_list[$key]['state'] = "盘亏";
- }
- else if($value['state'] == 7)
- {
- $info_list[$key]['state'] = "更换标签";
- }
- else if($value['state'] == 8)
- {
- $info_list[$key]['state'] = "其它";
- }
- else if($value['state'] == 9)
- {
- $info_list[$key]['state'] = "预设";
- }
-
- }
- $total = $this->whlabel->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- if(isset($post['outsku']))
- {
- $time = time();
- $cz = $this->input->post('cz',true);
- $label = $this->input->post('outsku',true);
- $sl = $this->input->post('sl',true);
- $num = $this->input->post('num',true);
- //$warehouse = $this->input->post('warehouse',true);
- if(!$sl)
- {
- $sl = 1;
- }
- if(!$warehouse)
- {
- echo json_encode(array('msg'=>'请选择调拨到的仓库','success'=>false));exit;
- }
- $dblabel = $this->whlabellabel->get_label($label);
- if($dblabel)
- {
- $data = $this->whlabel->find_all("features = '".$dblabel['features']."' and warehouse = '".$dblabel['warehouse']."' and shop = '".$dblabel['shop']."' and state = '0' and zd = ''");
- if(count($data) < 1)
- {
- echo json_encode(array('msg'=>'没有此产品数据!','success'=>false));exit;
- }
- if(count($data) < $num)
- {
- echo json_encode(array('msg'=>'库存数量少于调拨数量!','success'=>false));exit;
- }
- for($i=0;$i<$sl;$i++)
- {
- $this->whlabel->save(array('state'=>3,'dbtime'=>$dbtime,'dbcontent'=>$data[$i]['warehouse'].'-'.$time.'|','time'=>$time),$data[$i]['id']);
- }
- echo json_encode(array('success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'未找到此条码产品!','success'=>false));exit;
- }
- }
- $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
- $this->_Template('whlabel_db',$this->data);
- }
-
- public function _dbrk()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $sku = $this->input->post('sku',true);
- $number = $this->input->post('number',true);
- $warehouse = $this->input->post('warehouse',true);
- $purchase = $this->input->post('purchase',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $waybill = $this->input->post('waybill',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $state = $this->input->post('state',true);
- $label = $this->input->post('label',true);
- $ctime = $this->input->post('ctime',true);
- $timetk = $this->input->post('timetkk',true);
- $timetj = $this->input->post('timetjj',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "dbtime > 0";
- if($timetk && $timetj)
- {
- $where .= " and ".$ctime." > '$timetk' and ".$ctime." < '$timetj'";
- }
- if($sku)
- {
- $where .= " and sku = '$sku'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($state != '')
- {
- $where .= " and state = '$state'";
- }
- //数据排序
- $order_str = "dbtime desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->whlabel->find_all($where,'id,state,purchase,sku,title,warehouse,dbtime,enter',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $purchase = $this->purchase->read($value['purchase']);
- $info_list[$key]['purchase'] = $purchase['title'];
- if($value['enter'] != 0)
- {
- $info_list[$key]['enter'] = '<p>'.date('Y-m-d H:i:s',$value['enter']).'</p>';
- }
- else
- {
- $info_list[$key]['enter'] = "";
- }
- if($value['dbtime'] != 0)
- {
- $info_list[$key]['dbtime'] = '<p>'.date('Y-m-d H:i:s',$value['dbtime']).'</p>';
- }
- else
- {
- $info_list[$key]['dbtime'] = "";
- }
-
- if($value['state'] == 0)
- {
- $info_list[$key]['state'] = "在库";
- }
- else if($value['state'] == 1)
- {
- $info_list[$key]['state'] = "出库";
- }
- else if($value['state'] == 2)
- {
- $info_list[$key]['state'] = "退库";
- }
- else if($value['state'] == 3)
- {
- $info_list[$key]['state'] = "调拨中";
- }
- else if($value['state'] == 4)
- {
- $info_list[$key]['state'] = "再加工";
- }
- else if($value['state'] == 5)
- {
- $info_list[$key]['state'] = "维修中";
- }
- else if($value['state'] == 6)
- {
- $info_list[$key]['state'] = "盘亏";
- }
- else if($value['state'] == 7)
- {
- $info_list[$key]['state'] = "更换标签";
- }
- else if($value['state'] == 8)
- {
- $info_list[$key]['state'] = "其它";
- }
- else if($value['state'] == 9)
- {
- $info_list[$key]['state'] = "预设";
- }
-
- }
- $total = $this->whlabel->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- if(isset($post['rsku']))
- {
- $cz = $this->input->post('cz',true);
- $label = $this->input->post('rsku',true);
- $sl = $this->input->post('sl',true);
- $warehouse = $this->input->post('warehouse',true);
- if(!$sl)
- {
- $sl = 1;
- }
- if(!$warehouse)
- {
- echo json_encode(array('msg'=>'请选择入库仓库','success'=>false));exit;
- }
- $dblabel = $this->whlabellabel->get_label($label);
- if($dblabel)
- {
- $data = $this->whlabel->find_all("features = '".$dblabel['features']."' and warehouse = '".$dblabel['warehouse']."' and shop = '".$dblabel['shop']."' and state = '3' and zd = ''");
- if(count($data) < 1)
- {
- echo json_encode(array('msg'=>'没有此SKU调拨数据!','success'=>false));exit;
- }
- if($sl > count($data))
- {
- echo json_encode(array('msg'=>'入库数量大于调拨数量!','success'=>false));exit;
- }
- $time = time();
- for($i=0;$i<$sl;$i++)
- {
- $this->whlabel->save(array('state'=>0,'dbwarehouse'=>$data[$i]['warehouse'],'warehouse'=>$warehouse,'enter'=>$time,'time'=>$time,'dbcontent'=>$data[$i]['dbcontent'].$warehouse.'-'.$time.'|',),$data[$i]['id']);
- }
- echo json_encode(array('success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'没有此条码的库存信息!','success'=>false));exit;
- }
- }
- $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
- $this->_Template('whlabel_dbrk',$this->data);
- }
-
-
- public function _whlabelczdc()
- {
- if(isset($_GET['excel']))
- {
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $state = $this->input->get('state',true);
- $sku = $this->input->get('sku',true);
- $ctime = $this->input->get('ctime',true);
- $category = $this->input->get('category',true);
- $size = $this->input->get('size',true);
- $grade = $this->input->get('grade',true);
- $color = $this->input->get('color',true);
- $lowe = $this->input->get('lowe',true);
- $timetk = $this->input->get('timetkk',true);
- $timetj = $this->input->get('timetjj',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "dbtime > 0";
- if($timetk && $timetj)
- {
- $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- //取得信息列表
- $info_list = $this->whlabel->find_all($where,'*');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[$value['sku']] = $value;//所有数据sku
- }
- foreach ($rows as $value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $db = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'"');
- $rk = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and enter > 0');
- if($value['orderinfo'] == 0)
- {
- $info_list[$key]['orderinfo'] = "";
- }
- if($value['waybill'] == 0)
- {
- $info_list[$key]['waybill'] = "";
- }
-
- if($value['state'] == 0)
- {
- $value['state'] = "在库";
- }
- else if($value['state'] == 3)
- {
- $value['state'] = "调拨中";
- }
- $list[] = array($value['sku'],$value['title'],$db,$rk);
- }
- $title = date('Y-m-d',$timetk).'至'.date('Y-m-d',$timetj)."统计表";
- $titlename = "<table border=1>
- <tr><th colspan='4' align='center'><h3>".$title."<h3></th></tr>
- <tr align='center'>
- <td>SKU</td>
- <td>产品</td>
- <td>调拨数量</td>
- <td>入库数量</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($list,$titlename,$filename,$tail);
- }
- }
-
- public function _print($arg_array)
- {
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";$wid="";$wtype="";
- $usersp = explode('|',trim($user['shop'],'|'));
- $userwh = explode('|',trim($user['warehouse'],'|'));
- foreach ($usersp as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- foreach ($userwh as $value)
- {
- $wid .= " id = ".$value." or";
- $wtype .= " type = ".$value." or";
- }
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['tmsku']))
- {
- $tmsku = $this->input->post('tmsku',true);
- if(is_numeric($tmsku))
- {
- $yyh = $this->whlabellabel->get_label($tmsku);
- }
- else
- {
- $yyh = $this->whlabellabel->get_sku($tmsku);
- }
- if($yyh)
- {
- echo json_encode(array('features'=>$yyh['features'],'success'=>true));exit;
- }
- else
- {
- echo json_encode(array('success'=>false));exit;
- }
- }
- $classid = $this->classid->sku();
- $pm = $classid;
- $scsku = $classid;
- //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
- if(isset($post['warehouse']))
- {
- if($post['warehouse'])
- {
- $list = array();$num = "";$title = "";$features = "";
- $order = 0;
- $post['shop'] = '';
- $brand = $this->input->post('brand',true);
- if($brand != '0,')
- {
- $b = $this->brand->read(rtrim($brand,','));
- if($b)
- {
- $post['shop'] = str_replace('|',',',$b['shop']);
- }
- }
- $post['details'] = $this->input->post('details',true);//打印数量
- $xbqnum = $this->input->post('xbqnum',true);
- $post['purchase'] = $this->input->post('purchase',true);
- $post['warehouse'] = $this->input->post('warehouse',true);
- $post['purchase'] = $this->input->post('purchase',true);
- $post['retreatwarehouse'] = $post['warehouse'];
- $post['cpbz'] = $this->input->post('cpbz',true);
- $post['state'] = 9;
- $category = $this->input->post('category',true);
- $list['category'] = $category;
- $list['hairtype'] = $this->input->post('hairtype',true);
- $list['grade'] = $this->input->post('grade',true);
- $size = $this->input->post('size',true);
- $list['size'] = rtrim($size,',');
- $list['hairnumber'] = $this->input->post('hairnumber',true);
- $list['extension'] = $this->input->post('extension',true);
- if($category == 1297)
- {
- $list['sywignumber'] = $this->input->post('sywignumber',true);
- }
- if($category == 1702)
- {
- $list['syhairnumber'] = $this->input->post('syhairnumber',true);
- $list['syother'] = $this->input->post('syother',true);
- }
- if($category == 133)
- {
- $list['fittype'] = $this->input->post('fittype',true);
- $list['acother'] = $this->input->post('acother',true);
- }
- $list['color'] = $this->input->post('color',true);
- $list['lowe'] = $this->input->post('lowe',true);
-
- if($category == 127)
- {
- $list['type'] = $this->input->post('type',true);
- $list['headroad'] = $this->input->post('headroad',true);
- $list['density'] = $this->input->post('density',true);
- if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
- {
- $list['lacesize'] = $this->input->post('lacesize',true);
- }
- $list['lacecolor'] = $this->input->post('lacecolor',true);
- $list['lacetypes'] = $this->input->post('lacetypes',true);
- }
- if($category == 128)
- {
- $list['lacetype'] = $this->input->post('lacetype',true);
- $list['haircap'] = $this->input->post('haircap',true);
- $list['density'] = $this->input->post('density',true);
- $list['lacecolor'] = $this->input->post('lacecolor',true);
- $list['lacetypes'] = $this->input->post('lacetypes',true);
- $list['wigother'] = $this->input->post('wigother',true);
- $list['wigother2'] = $this->input->post('wigother2',true);
- }
- if($category == 129)
- {
- $list['wide'] = $this->input->post('wide',true);
- }
-
- if($category == 131)
- {
- $list['gifttype'] = $this->input->post('gifttype',true);
- $list['giftother'] = $this->input->post('giftother',true);
- }
-
- if($category == 134)
- {
- $list['pieceweight'] = $this->input->post('pieceweight',true);
- }
- if($category == 1297)
- {
- $list['synthetictype'] = $this->input->post('synthetictype',true);
- $list['sywigother'] = $this->input->post('sywigother',true);
- }
- if($category == 130 || $category == 133 || $category == 1702)
- {
- $list['items'] = $this->input->post('items',true);
- $list['weight'] = $this->input->post('weight',true);
- }
- if($category == 1702)
- {
- $list['syhairther'] = $this->input->post('syhairther',true);
- }
- foreach($list as $k=>$v)
- {
- if($v != 0)
- {
- $num .=$v;
- $features .=$v.'-';
- $post[$k] = $v;
- $typeclass = $this->typeclass->read($v);
- if(isset($pm[$typeclass['classid']]))
- {
- if(stripos($typeclass['zh'],'|') !== false)
- {
- $exzh = explode('|',$typeclass['zh']);
- $pm[$typeclass['classid']] = $exzh[0];
- }
- else
- {
- $pm[$typeclass['classid']] = $typeclass['zh'];
- }
- }
- $scsku[$typeclass['classid']] = $typeclass['bqsku'];
- if($k != 'size')
- {
- $title .= $typeclass['title']." ";
- }
- }
- }
- $typeclass = $this->typeclass->read($list['size']);
- $title .= $typeclass['title'];
- $time = time();
- $post['title'] = rtrim($title,' ');
- $post['number'] = $num;
- $post['features'] = '-'.$features;
- $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
- $featurespp = explode('-',trim($featurespp,'-'));
- if(isset($featurespp[5]))
- {
- $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
- }
- else
- {
- $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
- }
- $post['enter'] = $time;
- $post['time'] = $time;//操作时间
- $scsku = implode("-",$scsku);
- $zh = implode(" ",$pm);
- $scsku = str_replace('- ','-',trim($scsku,'-'));
- $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
- $bqsku = (isset($b['title']))?$b['title'].'-'.$scsku:$scsku;;
- $post['sku'] = $bqsku;
- $label = time().rand(0,9);
- $post['label'] = $label;
- $cpid = $this->whlabellabel->find_count();
- $post['cpid'] = $cpid+1;
- $cpid = $post['cpid'];
- //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
-
- //if($whlabelbarcode)
- //{
- //$post['label'] = $whlabelbarcode['label'];
- //if(!$this->whlabellabel->insert($post))
- //{
- // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
- //}
- //}
- //else
- //{
- $this->db->trans_begin();
- $this->whlabellabel->insert($post);
- //$this->whlabelbarcode->insert($post);
- if ($this->db->trans_status() === TRUE)
- {
- $this->db->trans_commit();
- }
- else
- {
- $this->db->trans_rollback();
- echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
- }
- //}
- $details = ($post['details'] != '')?'位置:('.$post['details'].') <font style="font-size: 18px;">'.$cpid.'</font>':'';
- $purchase = $this->purchase->read($post['purchase']);
- echo json_encode(array('title'=>$title,'num'=>$post['label'],'bqsku'=>$bqsku,'xbqnum'=>$xbqnum,'zh'=>str_replace('自然色 ','',rtrim($zh,' ')),'details'=>$details,'purchase'=>$purchase['title'],'cpbz'=>$post['cpbz'],'usa'=>0,'success'=>true));exit;//特殊仓目前不需要仓库选项
- }
- }
- if(isset($_SESSION['api']))
- {
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
- $this->data['wlshop'] = $wlshop;
- $this->data['warehouse'] = $warehouse;
- }
- $whlabelwz = $this->whlabelwz->find_all();
- $this->data['whlabelwz'] = $whlabelwz;
- $this->_Template('whlabel_print',$this->data);
- }
-
-
- public function _usaprint($arg_array)
- {
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";$wid="";$wtype="";
- $usersp = explode('|',trim($user['shop'],'|'));
- $userwh = explode('|',trim($user['warehouse'],'|'));
- foreach ($usersp as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- foreach ($userwh as $value)
- {
- $wid .= " id = ".$value." or";
- $wtype .= " type = ".$value." or";
- }
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['tmsku']))
- {
- $tmsku = $this->input->post('tmsku',true);
- if(is_numeric($tmsku))
- {
- $yyh = $this->whlabellabel->get_label($tmsku);
- }
- else
- {
- $yyh = $this->whlabellabel->get_sku($tmsku);
- }
- if($yyh)
- {
- echo json_encode(array('features'=>$yyh['features'],'success'=>true));exit;
- }
- else
- {
- echo json_encode(array('success'=>false));exit;
- }
- }
- $classid = $this->classid->sku();
- $pm = $classid;
- $scsku = $classid;
- //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
- if(isset($post['warehouse']))
- {
- if($post['warehouse'])
- {
- $list = array();$num = "";$title = "";$features = "";
- $order = 0;
- $post['shop'] = '';
- $brand = $this->input->post('brand',true);
- if($brand != '0,')
- {
- $b = $this->brand->read(rtrim($brand,','));
- if($b)
- {
- $post['shop'] = str_replace('|',',',$b['shop']);
- }
- }
- $post['details'] = $this->input->post('details',true);//打印数量
- $xbqnum = $this->input->post('xbqnum',true);
- $post['purchase'] = $this->input->post('purchase',true);
- $post['warehouse'] = $this->input->post('warehouse',true);
- $post['purchase'] = $this->input->post('purchase',true);
- $post['retreatwarehouse'] = $post['warehouse'];
- $post['cpbz'] = $this->input->post('cpbz',true);
- $post['state'] = 9;
- $category = $this->input->post('category',true);
- $list['category'] = $category;
- $list['hairtype'] = $this->input->post('hairtype',true);
- $list['grade'] = $this->input->post('grade',true);
- $size = $this->input->post('size',true);
- $list['size'] = rtrim($size,',');
- $list['hairnumber'] = $this->input->post('hairnumber',true);
- $list['extension'] = $this->input->post('extension',true);
- if($category == 1297)
- {
- $list['sywignumber'] = $this->input->post('sywignumber',true);
- }
- if($category == 1702)
- {
- $list['syhairnumber'] = $this->input->post('syhairnumber',true);
- $list['syother'] = $this->input->post('syother',true);
- }
- if($category == 133)
- {
- $list['fittype'] = $this->input->post('fittype',true);
- $list['acother'] = $this->input->post('acother',true);
- }
- $list['color'] = $this->input->post('color',true);
- $list['lowe'] = $this->input->post('lowe',true);
-
- if($category == 127)
- {
- $list['type'] = $this->input->post('type',true);
- $list['headroad'] = $this->input->post('headroad',true);
- $list['density'] = $this->input->post('density',true);
- if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
- {
- $list['lacesize'] = $this->input->post('lacesize',true);
- }
- $list['lacecolor'] = $this->input->post('lacecolor',true);
- $list['lacetypes'] = $this->input->post('lacetypes',true);
- }
- if($category == 128)
- {
- $list['lacetype'] = $this->input->post('lacetype',true);
- $list['haircap'] = $this->input->post('haircap',true);
- $list['density'] = $this->input->post('density',true);
- $list['lacecolor'] = $this->input->post('lacecolor',true);
- $list['lacetypes'] = $this->input->post('lacetypes',true);
- $list['wigother'] = $this->input->post('wigother',true);
- $list['wigother2'] = $this->input->post('wigother2',true);
- }
- if($category == 129)
- {
- $list['wide'] = $this->input->post('wide',true);
- }
-
- if($category == 131)
- {
- $list['gifttype'] = $this->input->post('gifttype',true);
- $list['giftother'] = $this->input->post('giftother',true);
- }
-
- if($category == 134)
- {
- $list['pieceweight'] = $this->input->post('pieceweight',true);
- }
- if($category == 1297)
- {
- $list['synthetictype'] = $this->input->post('synthetictype',true);
- $list['sywigother'] = $this->input->post('sywigother',true);
- }
- if($category == 130 || $category == 133 || $category == 1702)
- {
- $list['items'] = $this->input->post('items',true);
- $list['weight'] = $this->input->post('weight',true);
- }
- if($category == 1702)
- {
- $list['syhairther'] = $this->input->post('syhairther',true);
- }
- foreach($list as $k=>$v)
- {
- if($v != 0)
- {
- $num .=$v;
- $features .=$v.'-';
- $post[$k] = $v;
- $typeclass = $this->typeclass->read($v);
- if(isset($pm[$typeclass['classid']]))
- {
- if(stripos($typeclass['zh'],'|') !== false)
- {
- $exzh = explode('|',$typeclass['zh']);
- $pm[$typeclass['classid']] = $exzh[0];
- }
- else
- {
- $pm[$typeclass['classid']] = $typeclass['zh'];
- }
- }
- $scsku[$typeclass['classid']] = $typeclass['bqsku'];
- if($k != 'size')
- {
- $title .= $typeclass['title']." ";
- }
- }
- }
- $typeclass = $this->typeclass->read($list['size']);
- $title .= $typeclass['title'];
- $time = time();
- $post['title'] = rtrim($title,' ');
- $post['number'] = $num;
- $post['features'] = '-'.$features;
- $fp = $this->whlabel->get_features($post['features']);
- if(!$fp)
- {
- echo json_encode(array('msg'=>'美仓无此产品,需要添加后才可打印','success'=>false));exit;
- }
- $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
- $featurespp = explode('-',trim($featurespp,'-'));
- if(isset($featurespp[5]))
- {
- $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
- }
- else
- {
- $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
- }
- $post['enter'] = $time;
- $post['time'] = $time;//操作时间
- $scsku = implode("-",$scsku);
- $zh = implode(" ",$pm);
- $scsku = str_replace('- ','-',trim($scsku,'-'));
- $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
- $bqsku = (isset($b['title']))?$b['title'].'-'.$scsku:$scsku;;
- $post['sku'] = $fp['sku'];
- $post['label'] = $fp['sku'];
- $cpid = $this->whlabellabel->find_count();
- $post['cpid'] = $cpid+1;
- $cpid = $post['cpid'];
- //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
-
- //if($whlabelbarcode)
- //{
- //$post['label'] = $whlabelbarcode['label'];
- //if(!$this->whlabellabel->insert($post))
- //{
- // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
- //}
- //}
- //else
- //{
- $this->db->trans_begin();
- $this->whlabellabel->insert($post);
- //$this->whlabelbarcode->insert($post);
- if ($this->db->trans_status() === TRUE)
- {
- $this->db->trans_commit();
- }
- else
- {
- $this->db->trans_rollback();
- echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
- }
- //}
- $details = ($post['details'] != '')?'位置:('.$post['details'].') <font style="font-size: 18px;">'.$cpid.'</font>':'';
- $purchase = $this->purchase->read($post['purchase']);
- echo json_encode(array('title'=>$title,'num'=>$post['label'],'bqsku'=>$bqsku,'xbqnum'=>$xbqnum,'zh'=>str_replace('自然色 ','',rtrim($zh,' ')),'details'=>$details,'purchase'=>$purchase['title'],'cpbz'=>$post['cpbz'],'usa'=>1,'success'=>true));exit;//特殊仓目前不需要仓库选项
- }
- }
- if(isset($_SESSION['api']))
- {
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
- $this->data['wlshop'] = $wlshop;
- $this->data['warehouse'] = $warehouse;
- }
- $whlabelwz = $this->whlabelwz->find_all();
- $this->data['whlabelwz'] = $whlabelwz;
- $this->_Template('whlabel_usaprint',$this->data);
- }
-
-
- public function _printrk($arg_array)
- {
- $prc = array();
- $purchase = $this->purchase->find_all();
- foreach($purchase as $k=>$v)
- {
- $prc[$v['id']] = $v['title'];
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $sku = $this->input->post('sku',true);
- $bs = $this->input->post('bs',true);
- $number = $this->input->post('number',true);
- $warehouse = $this->input->post('warehouse',true);
- $purchase = $this->input->post('purchase',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $waybill = $this->input->post('waybill',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $state = $this->input->post('state',true);
- $label = $this->input->post('label',true);
- $timetk = $this->input->post('ktime',true);
- $timetj = $this->input->post('jtime',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "1=1 ";
- if($timetk && $timetj)
- {
- $where .= " and enter > '$timetk' and enter < '$timetj'";
- }
- if($sku)
- {
- $where .= " and sku = '$sku'";
- }
- if($bs != '')
- {
- $where .= " and bs = '$bs'";
- }
- if($number)
- {
- $where .= " and number = '$number'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($label)
- {
- $where .= " and label = '$label'";
- }
- if($state || $state == 0)
- {
- $where .= " and state = '$state'";
- }
- $ck = ($warehouse == '12')?'specialstock':'whlabel';
- //数据排序
- $order_str = "enter desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->$ck->find_all($where,'id,warehouse,purchase,sku,title,state,enter,details',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = ($ck=='specialstock')?'特殊仓':$warehouse['title'];
- $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- if($value['state'] == 0)
- {
- $info_list[$key]['state'] = "在库";
- }
- else if($value['state'] == 1)
- {
- $info_list[$key]['state'] = "出库";
- }
- else if($value['state'] == 2)
- {
- $info_list[$key]['state'] = "退库";
- }
- else if($value['state'] == 3)
- {
- $info_list[$key]['state'] = "调拨中";
- }
- else if($value['state'] == 4)
- {
- $info_list[$key]['state'] = "再加工";
- }
- else if($value['state'] == 5)
- {
- $info_list[$key]['state'] = "维修中";
- }
- else if($value['state'] == 6)
- {
- $info_list[$key]['state'] = "盘亏";
- }
- else if($value['state'] == 7)
- {
- $info_list[$key]['state'] = "更换标签";
- }
- else if($value['state'] == 8)
- {
- $info_list[$key]['state'] = "其它";
- }
- else if($value['state'] == 9)
- {
- $info_list[$key]['state'] = "预设";
- }
- else if($value['state'] == 10)
- {
- $info_list[$key]['state'] = "美店零售";
- }
- $info_list[$key]['enter'] = date('Y-m-d H:i:s',$value['enter']);
- }
- $total = $this->$ck->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- if(isset($post['tmsku']))
- {
- $time = time();
- $tmsku = $this->input->post('tmsku',true);
- //$post['shop'] = $this->input->post('shop',true);
- $num = $this->input->post('num',true);
- $rktype = $this->input->post('rktype',true);
- if($num > 200)
- {
- echo json_encode(array('msg'=>'入库数量不允许超过200!','c'=>0,'success'=>false));exit;
- }
- if(!$rktype)
- {
- //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
- }
- $rk = $this->whlabellabel->find_all("label = '$tmsku'","*","id desc");
- /**
- $wz = array();
- foreach ($rk as $key=>$value)
- {
- $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
- }
- if(count($wz) > 1)
- {
- $wz = array_values($wz);
- echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
- }
- **/
- if(isset($rk[0]['purchase']))
- {
- $rk = $rk[0];
- $j = 0;
- $post['purchase'] = $rk['purchase'];
- $post['warehouse'] = $rk['warehouse'];
- $post['retreatwarehouse'] = $rk['warehouse'];
- $post['sku'] = $rk['sku'];
- $post['number'] = $rk['number'];
- $post['features'] = $rk['features'];
- $post['title'] = $rk['title'];
- $post['enter'] = $time;
- $post['time'] = $time;
- $post['bs'] = 1;
- $post['shop'] = $rk['shop'];
- $post['details'] = $rk['details'];
- $post['cpid'] = $rk['cpid'];
- $post['cpbz'] = $rk['cpbz'];
- //$post['rktype'] = $rktype;
- $warehouse = $this->warehouse->read($rk['warehouse']);
- if($warehouse['bdck'] == '')
- {
- echo json_encode(array('msg'=>'此仓库没有设置现货,无法入库!','c'=>0,'success'=>false));exit;
- }
- else
- {
- $bdck = $warehouse['bdck'];
- }
- $pdwz = $this->whlabel->get_warehousesku($post['warehouse'],$post['sku']);
- if(isset($pdwz['details']))
- {
- if($pdwz['details'] != $post['details'])
- {
- echo json_encode(array('msg'=>'此产品位置应为:'.$pdwz['details'],'c'=>0,'cs'=>$pdwz['details'].' - '.$post['details'],'success'=>false));exit;
- }
- }
- $post['featurespp'] = $rk['featurespp'];
-
- if($post['warehouse'] == '5')
- {
- $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
- if($yza)
- {
- if($post['features'] != $yza[0]['features'])
- {
- echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','new'=>$post['features'].'-'.$post['sku'],'old'=>$yza[0]['features'],'c'=>0,'success'=>false));exit;
- }
- }
- $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
- if($yzb)
- {
- if($post['sku'] != $yzb[0]['sku'])
- {
- echo json_encode(array('msg'=>'此产品信息的SKU和现有'.$yzb[0]['sku'].'不一致!','c'=>0,'success'=>false));exit;
- }
- }
- }
- for($i=0;$i<$num;$i++)
- {
- $post['label'] = time().rand(100,999).$i;
- if($this->$bdck->insert($post))
- {
- $j++;
- }
- }
- /**
- if($post['warehouse'] != 12)
- {
- echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
- }
- **/
- if($j == $num)
- {
- echo json_encode(array('msg'=>'入库成功!','success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'未成功入库数量:'.$num-$j.',请补入','c'=>0,'success'=>false));exit;
- }
- }
- else
- {
- echo json_encode(array('msg'=>'未找到此条码数据!','c'=>0,'success'=>false));exit;
- }
- }
- $this->_Template('whlabel_printrk',$this->data);
- }
- public function _printxzrk($arg_array)
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['wzid']))
- {
- $time = time();
- $id = $this->input->post('wzid',true);
- //$post['shop'] = $this->input->post('shop',true);
- $num = 1;
- $rk = $this->whlabellabel->read($id);
- if(isset($rk['purchase']))
- {
- $x = 0;
- $post['purchase'] = $rk['purchase'];
- $post['warehouse'] = $rk['warehouse'];
- $post['retreatwarehouse'] = $rk['warehouse'];
- $post['sku'] = $rk['sku'];
- $post['number'] = $rk['number'];
- $post['features'] = $rk['features'];
- $post['title'] = $rk['title'];
- $post['enter'] = $time;
- $post['time'] = $time;
- $post['bs'] = 1;
- $post['shop'] = $rk['shop'];
- $post['details'] = $rk['details'];
- $post['cpid'] = $rk['cpid'];
- $post['cpbz'] = $rk['cpbz'];
- $warehouse = $this->warehouse->read($rk['warehouse']);
- if($warehouse['bdck'] == '')
- {
- echo json_encode(array('msg'=>'此仓库没有设置现货,无法入库!','success'=>false));exit;
- }
- else
- {
- $bdck = $warehouse['bdck'];
- }
- $post['featurespp'] = $rk['featurespp'];
- $this->db->trans_begin();
- for($i=0;$i<$num;$i++)
- {
- $post['label'] = time().rand(100,999).$i;
- $this->$bdck->insert($post);
- }
- /**
- if($post['warehouse'] != 12)
- {
- echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
- }
- **/
- if ($this->db->trans_status() === TRUE)
- {
- $this->db->trans_commit();
- echo json_encode(array('msg'=>'入库成功!','cs'=>$post,'cs2'=>$warehouse,'success'=>true));exit;
- }
- else
- {
- $this->db->trans_rollback();
- echo json_encode(array('msg'=>'入库失败,请重试','c'=>0,'success'=>false));exit;
- }
- }
- else
- {
- echo json_encode(array('msg'=>'未找到此条码数据!','c'=>0,'success'=>false));exit;
- }
- }
- }
- public function _printck($arg_array)
- {
- $prc = array();
- $purchase = $this->purchase->find_all();
- foreach($purchase as $k=>$v)
- {
- $prc[$v['id']] = $v['title'];
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $sku = $this->input->post('sku',true);
- $bs = $this->input->post('bs',true);
- $number = $this->input->post('number',true);
- $warehouse = $this->input->post('warehouse',true);
- $purchase = $this->input->post('purchase',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $waybill = $this->input->post('waybill',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $state = $this->input->post('state',true);
- $label = $this->input->post('label',true);
- $timetk = $this->input->post('ktime',true);
- $timetj = $this->input->post('jtime',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "state=1 ";
- if($timetk && $timetj)
- {
- $where .= " and outk > '$timetk' and outk < '$timetj'";
- }
- if($sku)
- {
- $where .= " and sku = '$sku'";
- }
- if($bs != '')
- {
- $where .= " and bs = '$bs'";
- }
- if($number)
- {
- $where .= " and number = '$number'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($label)
- {
- $where .= " and label = '$label'";
- }
- $ck = ($warehouse == '12')?'specialstock':'whlabel';
- //数据排序
- $order_str = "outk desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->$ck->find_all($where,'id,warehouse,purchase,sku,title,state,outk,details',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = ($ck=='specialstock')?'特殊仓':$warehouse['title'];
- $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- if($value['state'] == 0)
- {
- $info_list[$key]['state'] = "在库";
- }
- else if($value['state'] == 1)
- {
- $info_list[$key]['state'] = "出库";
- }
- else if($value['state'] == 2)
- {
- $info_list[$key]['state'] = "退库";
- }
- else if($value['state'] == 3)
- {
- $info_list[$key]['state'] = "调拨中";
- }
- else if($value['state'] == 4)
- {
- $info_list[$key]['state'] = "再加工";
- }
- else if($value['state'] == 5)
- {
- $info_list[$key]['state'] = "维修中";
- }
- else if($value['state'] == 6)
- {
- $info_list[$key]['state'] = "盘亏";
- }
- else if($value['state'] == 7)
- {
- $info_list[$key]['state'] = "更换标签";
- }
- else if($value['state'] == 8)
- {
- $info_list[$key]['state'] = "其它";
- }
- else if($value['state'] == 9)
- {
- $info_list[$key]['state'] = "预设";
- }
- else if($value['state'] == 10)
- {
- $info_list[$key]['state'] = "美店零售";
- }
- $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
- }
- $total = $this->$ck->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- if(isset($post['tmsku']))
- {
- $time = time();
- $tmsku = $this->input->post('tmsku',true);
- //$post['shop'] = $this->input->post('shop',true);
- $num = $this->input->post('num',true);
- $cktype = $this->input->post('cktype',true);
- $label = $this->whlabellabel->get_label($tmsku);
- if(!$cktype)
- {
- //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
- }
- if(!isset($label['warehouse']))
- {
- echo json_encode(array('msg'=>'没有此条码信息!','success'=>false));exit;
- }
- $xzck = ($label['warehouse'] == '12')?'specialstock':'whlabel';
- if(stripos($label['features'],'-126-') !== false)
- {
- $ck = $this->$xzck->find_all("state = '0' and shop = '".$label['shop']."' and number = '".$label['number']."' and warehouse = '".$label['warehouse']."' and zd = ''");
- }
- else
- {
- $ck = $this->$xzck->find_all("state = '0' and shop = '".$label['shop']."' and number = '".$label['number']."' and warehouse = '".$label['warehouse']."' and purchase = '".$label['purchase']."' and zd = ''");
- }
- $j = 0;
- if(count($ck) >= $num)
- {
- for($i=0;$i<$num;$i++)
- {
- if($this->$xzck->save(array('state'=>1,'outk'=>$time,'time'=>$time),$ck[$i]['id']))//,'cktype'=>$cktype
- {
- $j++;
- }
- }
- if($j == $num)
- {
- echo json_encode(array('msg'=>'出库成功!','success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'未成功出库数量:'.$num-$j.',请补入','c'=>0,'success'=>false));exit;
- }
- }
- else
- {
- echo json_encode(array('msg'=>'没有足够的库存!','cs'=>$label['sku'].' - '.$label['purchase'],'success'=>false));exit;
- }
- }
- $this->_Template('whlabel_printck',$this->data);
- }
-
-
- public function _printexcel()
- {
- $dir = '/data/excel/'.date('Ymd',time()).'/';
- $config['upload_path'] = '.'.$dir ;
- $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
- $config['allowed_types'] = 'xls|xlsx|csv';
- $config['max_size'] = 10240;
- $this->load->library('upload', $config);
- $this->upload->initialize($config);
- if ($this->upload->do_upload('userfile'))
- {
- $full_path = $dir.$this->upload->data('file_name');
- $fileName = '.' . $full_path;
- if (!file_exists($fileName))
- {
- echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
- }
- else
- {
- require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
- $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
- $phpExcel->setActiveSheetIndex(0);// 设置为默认表
- $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
- $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
- $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
- ++$column;//如果列数大于26行
- $list = array();
- for ($i = 2; $i <= $row; $i++) // 行数循环
- {
- $data = array();
- for ($c = 'A'; $c != $column; $c++) // 列数循环
- {
- $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
- }
- $list[] = $data;
- }
- }
- $ed = array();$i = 0;$j = 0;$dcdata = array();$yc = '';
- $cmf_arr = array_column($list, '1');
- array_multisort($cmf_arr, SORT_ASC, $list);
- foreach ($list as $key=>$value)
- {
- $typeclass = $this->typeclass->get_bqsku($value['1'],$value['2']);
- if($typeclass)
- {
- $this->typeclass->save(array('bqsku'=>$value['3']),$typeclass['id']);
- }
- else
- {
- $ed[] = array($value['1'].'-系统未找到此订单信息');
- $i++;
- continue;
- }
- }
- if($i > 0)
- {
- $yc = $i.'条异常';
- }
- echo json_encode(array('msg'=>'操作成功 '.$yc,'yc'=>$ed,'success'=>true));exit;
-
- }
- }
-
- public function _uck()
- {
- if(isset($_GET['excel']))
- {
- $tc = array();
- $typeclass = $this->typeclass->find_all();
- foreach ($typeclass as $v)
- {
- $tc[$v['id']] = $v['zh'];
- }
- $data = array();$t = array();$rq = '';
- $ts = strtotime(date("Y-m-d",time()))-strtotime(date("Y-m",time()));
- $ts = $ts/(24*3600);
- for($i=0;$i<$ts;$i++)
- {
- $t[] = date("Y-m-d",strtotime('-'.($ts-$i).' day'));
- $rq .= "<td>".date("Y-m-d",strtotime('-'.($ts-$i).' day'))."</td>";
- }
- $info_list = $this->whlabel->find_pc("warehouse = '5'",'sku','warehouse,sku,features');
- foreach ($info_list as $k=>$v)
- {
- $features = explode('-',trim($v['features'],'-'));
- if(!isset($features[3]) || !isset($features[4]))
- {
- continue;
- }
- $data[$k][0] = $tc[$features[0]];//类型
- $data[$k][1] = ($features[3] != 57)?$tc[$features[3]]:'';//颜色,自然色不显示
- $data[$k][2] = $tc[$features[4]];//曲度
- $data[$k][3] = '';
- if(isset($data[$k][1]))
- {
- $data[$k][3] .= $data[$k][1];
- }
- if(isset($data[$k][2]))
- {
- $data[$k][3] .= $data[$k][2];
- }
- if(isset($features[5]))
- {
- $data[$k][3] .= $tc[$features[5]];
- }
- if(isset($features[2]))
- {
- $data[$k][3] .= $tc[$features[2]];
- }
- //$data[$k][3] 颜色,曲度,头套种类,尺寸
- $data[$k][4] = $v['sku'];
- $data[$k][5] = $this->whlabel->find_count('sku = "'.$v['sku'].'" and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'" and (state = 0 or (state = 1 and outk > '.strtotime(date("Y-m",time())).'))');//月初库存
- $data[$k][] = $this->whlabel->find_count('sku = "'.$v['sku'].'" and state = 0 and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'"');//剩余库存
- $zt = $this->whlabeltransport->find_all('sku = "'.$v['sku'].'" and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'" and cz = "0"');
- $ztrq = '';$ztsl = '';
- if(count($zt) > 0)
- {
- foreach ($zt as $vv)
- {
- $ztrq .= date('Y-m-d',$vv['stime']).'<br>';
- $ztsl .= $vv['num'].'<br>';
- }
- }
- $data[$k][] = trim($ztsl,'<br>');
- $data[$k][] = trim($ztrq,'<br>');
- $byck = 0;
- foreach ($t as $vv)
- {
- $sl = $this->whlabel->find_count('sku = "'.$v['sku'].'" and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'" and state = 1 and outk > '.strtotime($vv).' and outk < '.(strtotime($vv)+24*3600));
- $data[$k][] = ($sl > 0)?'<b>'.$sl.'</b>':'';
- $byck += $sl;
- }
- $data[$k][] = ($byck > 0)?$byck:'';
- }
-
- $title = "详情 ".date("Y-m-d",time());
- $titlename = "<table border=1>
- <tr align='center'>
- <td>类别</td>
- <td>颜色</td>
- <td>曲度</td>
- <td>名称</td>
- <td>SKU</td>
- <td>月初库存</td>
- <td>剩余库存</td>
- <td>在途数量</td>
- <td>预达日期</td>".
- $rq
- ."<td>本月出库</td></tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($data,$titlename,$filename,$tail);
- }
- }
-
- public function _whlabelexcelzh()
- {
- if(isset($_GET['excel']))
- {
- $where = "sku != 'Preset'";
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $category = $this->input->get('category',true);
- $warehouse = $this->input->get('warehouse',true);
- $excelid = $this->input->get('sid',true);
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- $xzid = '';
- if($excelid)
- {
- $excelid = explode(',',trim($excelid,','));
- foreach ($excelid as $key=>$value)
- {
- $xzid .= " id = ".$value." or";
- }
- $xzid = " and (".rtrim($xzid,'or').")";;
- }
- //取得信息列表
- /**
- $info_list = $this->whlabel->find_all($where.$xzid,'*');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
- }
- **/
- $list = array();
- $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,number,features');
- foreach ($rows as $key=>$value)
- {
- $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "0" and features = "'.$value['features'].'"');
- $zh = '';
- $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and time = "0" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','num,stime');
- foreach ($zt as $v)
- {
- $zh .= $v['num']." / ".date('Y-m-d',$v['stime'])."<br>";
- }
- $zt = array_sum(array_column($zt,'num'));
- $number = $value['number'];
- $ftime = time()-15*24*3600;
- $warehouse = $this->warehouse->read($value['warehouse']);
- $rows[$key]['warehouse'] = $warehouse['title'];
- $rows[$key]['number'] = $c;
- $rows[$key]['features'] = $zh;
- $rows[$key]['hb'] = $c+$zt;
- }
- $title = "导出库存数据及在途中数据".date('Y-m-d',time());
- $titlename = "<table border=1>
- <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
- <tr align='center'>
- <td>仓库</td>
- <td>SKU</td>
- <td>产品</td>
- <td>库存数量</td>
- <td>在途数量及预达日期</td>
- <td>在途+库存数量</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($rows,$titlename,$filename,$tail);
- }
- if(isset($_GET['excel']))
- {
- $warehouse = $this->input->get('warehouse',true);
- $sku = $this->input->get('sku',true);
- $cz = $this->input->get('cz',true);
- $text = $this->input->post('text',true);
- $xztime = $this->input->get('xztime',true);
- $timetk = $this->input->get('timetk',true);
- $timetj = $this->input->get('timetj',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "time = '0' ";
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($sku)
- {
- $where .= " and sku = '$sku'";
- }
- if($text)
- {
- $where .= " and text like '%$text%'";
- }
- if($cz != '')
- {
- $where .= " and cz = '$cz'";
- }
- if($timetk && $timetj)
- {
- $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
- }
- //数据排序
- $order_str = $xztime." desc";
- //取得信息列表
- $zh = array();
- $info_list = $this->whlabeltransport->find_all($where,'warehouse,sku,title,num,features,enter,stime,text');
- foreach ($info_list as $v)
- {
- $c = $this->whlabel->find_count('state = 0 and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'"');
- $warehouse = $this->warehouse->read($v['warehouse']);
- $v['warehouse'] = $warehouse['title'];
- $v['enter'] = date('Y-m-d H:i:s',$v['enter']);
- $v['stime'] = date('Y-m-d',$v['stime']);
- if(isset($zh[$v['features']]))
- {
- $zh[$v['features']]['num'] += $v['num'];
- }
- else
- {
- $zh[$v['features']] = $v;
- }
- $zh[$v['features']]['features'] = $c;
- }
- $title = "在途数据".date('Y-m-d',time());
- $titlename = "<table border=1>
- <tr align='center'>
- <td>仓库</td>
- <td>SKU</td>
- <td>名称</td>
- <td>在途数量</td>
- <td>库存数量</td>
- <td>添加在途日期</td>
- <td>预达日期</td>
- <td>备注</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($zh,$titlename,$filename,$tail);
- }
- }
-
- public function _fc()
- {
- $vip = 0;
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- if($user['vip'] == 1)
- {
- $vip = 1;
- }
- }
- else
- {
- header('Location: /');exit;
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $sku = $this->input->post('sku');
- $title = $this->input->post('title');
- $warehouse = $this->input->post('warehouse',true);
- $usa = $this->input->post('usa',true);
- $purchase = $this->input->post('purchase',true);
- $lacetype = $this->input->post('lacetype',true);
- $haircap = $this->input->post('haircap',true);
- $density = $this->input->post('density',true);
- $details = $this->input->post('details',true);
- $state = $this->input->post('state',true);
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "state = '11'";$gj = "";$ck = "";
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($haircap)
- {
- $where .= " and features like '%-$haircap-%'";
- }
- if($density)
- {
- $where .= " and features like '%-$density-%'";
- }
- if($usa)
- {
- if(!$warehouse)
- {
- $where .= " and (warehouse = '5' or warehouse = '8')";
- }
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($details)
- {
- $where .= " and details = '$details'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($ktime && $jtime)
- {
- $gj = " and enter > '$ktime' and enter < '$jtime'";
- $ck = " and outk > '$ktime' and outk < '$jtime'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- if($sku)
- {
- $sku = trim($sku,' ');
- $sku = trim($sku,' ');
- $where .= " and sku like '%$sku%'";
- $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
- }
- else if($title)
- {
- $title = trim($title,' ');
- $title = trim($title,' ');
- $where .= " and title like '%$title%'";
- $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
- }
- else
- {
- //$where .= " and time > '$ktime' and time < '$jtime'";
- $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
- }
- //取得信息列表
-
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $g = $this->whlabel->find_count($where.' and (oldstate = "11" or state = "11") and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state != "9" and features = "'.$value['features'].'"');
- $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
- $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $info_list[$key]['number'] = $g;
- $info_list[$key]['features'] = $x;
- $info_list[$key]['x'] = $s;
- }
- $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->data['vip'] = $vip;
- $this->_Template('whlabel_fc',$this->data);
- }
-
- public function _fcmb()
- {
- $where = "sku != 'Preset'";
- $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title');
- foreach ($rows as $k=>$v)
- {
- $warehouse = $this->warehouse->read($v['warehouse']);
- $rows[$k]['warehouse'] = $warehouse['title'];
- $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "'.$v['warehouse'].'" and sku = "'.$v['sku'].'" and state = 11');
- $rows[$k]['t'] = '';
- $rows[$k]['n'] = '';
- }
- $title = "封货产品数据导入模板";
- $titlename = "<table border=1>
- <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
- <tr align='center'>
- <td>仓库</td>
- <td>SKU</td>
- <td>产品</td>
- <td>封存产品总数量</td>
- <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
- <td>数量(填写正整数,留空导入时自动跳过此行)</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($rows,$titlename,$filename,$tail);
-
- }
- public function _fcexcel()
- {
- $dir = '/data/excel/'.date('Ymd',time()).'/';
- $config['upload_path'] = '.'.$dir ;
- $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
- $config['allowed_types'] = 'xls|xlsx|csv';
- $config['max_size'] = 10240;
- $this->load->library('upload', $config);
- $this->upload->initialize($config);
- if ($this->upload->do_upload('userfile'))
- {
- $full_path = $dir.$this->upload->data('file_name');
- $fileName = '.' . $full_path;
- if (!file_exists($fileName))
- {
- echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
- }
- else
- {
- libxml_use_internal_errors(true);
- require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
- $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
- $phpExcel->setActiveSheetIndex(0);// 设置为默认表
- $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
- $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
- $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
- ++$column;//如果列数大于26行
- $list = array();
- for ($i = 2; $i <= $row; $i++) // 行数循环
- {
- $data = array();
- for ($c = 'A'; $c != $column; $c++) // 列数循环
- {
- $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
- }
- $list[] = $data;
- }
- }
- $i = 0;$j = 0;$ed = array();
- foreach ($list as $key=>$value)
- {
- $time = time();
- if($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4']))
- {
- continue;
- }
- $warehouse = $this->warehouse->get_title($value['0']);
- $sku = $value['1'];
- $type = $value['4'];//调整方式0扣减1删除
- $num = $value['5'];//调整数量
- //$text = $value['4'];//扣减说明
- $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
- if(!$d)//如果没有这个SKU
- {
- $ed[] = array($sku.'-库存中不存在此SKU');
- $j++;
- continue;
- }
- if(!isset($warehouse['id']))
- {
- $ed[] = array($sku.'-仓库名错误!');
- $j++;
- continue;
- }
- if($type == 1 || $type == 2)//扣减库存
- {
- $data = $this->whlabel->find_all('warehouse = "'.$warehouse['id'].'" and sku = "'.$sku.'" and state = 11');
- if(count($data) < abs($num))
- {
- $ed[] = array($sku.'-数量大于封存产品剩余数量!');
- $j++;
- continue;
- }
- if($type == 1)//转入库存
- {
- for($i=0;$i<abs($num);$i++)
- {
- $this->whlabel->save(array('state'=>0,'oldstate'=>11,'time'=>$time),$data[$i]['id']);
- }
- }
- else if($type == 2)//删除
- {
- for($i=0;$i<abs($num);$i++)
- {
- $this->whlabel->remove($data[$i]['id']);
- }
- }
- }
- else if($type == 0)//增加库存
- {
- $post['sku'] = $d['sku'];
- $post['shop'] = '';
- $post['warehouse'] = $warehouse['id'];
- $post['purchase'] = $d['purchase'];
- $post['retreatwarehouse'] = $d['retreatwarehouse'];
- $post['state'] = 11;
- $post['title'] = $d['title'];
- $post['number'] = $d['number'];
- $post['features'] = $d['features'];
- $post['enter'] = $time;
- $post['time'] = $time;//操作时间
- for($i=0;$i<$num;$i++)
- {
- $post['label'] = time().rand(100,999).$i;
- $this->whlabel->insert($post);
- }
- }
- sleep(1);//防止入库时间一样,需要延迟1秒
- }
- if($j > 0)
- {
- $tt = date('Ymd',time());
- $title = '库存导入错误信息-'.$tt;
- $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
- $tail = "\n";
- $filename = $title.".xls";
- $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
- $dir = '/data/excel/'.$time.'/';
- $file_name = 'error_'.$time.rand(1000,9999);
- if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
- $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
- fwrite($myfile,$ecl);
- fclose($myfile);
- $error = $dir.$file_name.'.xls';
- echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
- }
- }
- }
-
- public function _fcjxc($arg_array)
- {
- if(isset($_GET['excel']))
- {
- $category = $this->input->get('category',true);
- $size = $this->input->get('size',true);
- $grade = $this->input->get('grade',true);
- $color = $this->input->get('color',true);
- $lowe = $this->input->get('lowe',true);
- $sku = $this->input->get('sku');
- $title = $this->input->get('title');
- $warehouse = $arg_array[0];
- $usa = $this->input->get('usa',true);
- $purchase = $this->input->get('purchase',true);
- $lacetype = $this->input->get('lacetype',true);
- $haircap = $this->input->get('haircap',true);
- $density = $this->input->get('density',true);
- $title = $this->input->get('title',true);
- $state = $this->input->get('state',true);
- $ktime = $this->input->get('ktime',true);
- $jtime = $this->input->get('jtime',true);
- $where = "state=11";$gj = "";$ck = "";
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($haircap)
- {
- $where .= " and features like '%-$haircap-%'";
- }
- if($density)
- {
- $where .= " and features like '%-$density-%'";
- }
- if($usa)
- {
- if(!$warehouse)
- {
- $where .= " and (warehouse = '5' or warehouse = '8')";
- }
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- $order_str = "id desc";
- if($sku)
- {
- $sku = trim($sku,' ');
- $sku = trim($sku,' ');
- $where .= " and sku like '%$sku%'";
- $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
- }
- else if($title)
- {
- $title = trim($title,' ');
- $title = trim($title,' ');
- $where .= " and title like '%$title%'";
- $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
- }
- else
- {
- //$where .= " and time > '$ktime' and time < '$jtime'";
- $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
- }
- //取得信息列表
-
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
-
- $g = $this->whlabel->find_count($where.' and (oldstate = "11" or state = "11") and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state != "9" and features = "'.$value['features'].'"');
- $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
- $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
- $rows[$key] = $value;
- $warehouse = $this->warehouse->read($value['warehouse']);
- $rows[$key]['warehouse'] = $warehouse['title'];
- $rows[$key]['features'] = $g;
- $rows[$key]['a'] = $x;
- $rows[$key]['b'] = $s;
- }
- $title = "总统计表";
- $titlename = "<table border=1>
- <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
- <tr align='center'>
- <td>仓库</td>
- <td>SKU</td>
- <td>产品名称</td>
- <td>录入总量</td>
- <td>取出总量</td>
- <td>剩余总量</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($rows,$titlename,$filename,$tail);
- }
- $vip = 0;
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- if($user['vip'] == 1)
- {
- $vip = 1;
- }
- }
- else
- {
- header('Location: /');exit;
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $sku = $this->input->post('sku');
- $title = $this->input->post('title');
- $warehouse = $arg_array[0];
- $usa = $this->input->post('usa',true);
- $purchase = $this->input->post('purchase',true);
- $lacetype = $this->input->post('lacetype',true);
- $haircap = $this->input->post('haircap',true);
- $density = $this->input->post('density',true);
- $title = $this->input->post('title',true);
- $state = $this->input->post('state',true);
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "state=11";$gj = "";$ck = "";
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($haircap)
- {
- $where .= " and features like '%-$haircap-%'";
- }
- if($density)
- {
- $where .= " and features like '%-$density-%'";
- }
- if($usa)
- {
- if(!$warehouse)
- {
- $where .= " and (warehouse = '5' or warehouse = '8')";
- }
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($ktime && $jtime)
- {
- $gj = " and enter > '$ktime' and enter < '$jtime'";
- $ck = " and outk > '$ktime' and outk < '$jtime'";
- }
- //数据排序
- $order_str = "id desc";$xs=0;
- $rows = array();$list = array();
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- if($sku || $title)
- {
- if($title)
- {
- $title = trim($title,' ');
- $title = trim($title,' ');
- $where .= " and title like '%$title%'";
- }
- else
- {
- $sku = trim($sku,' ');
- $sku = trim($sku,' ');
- $where .= " and sku like '%$sku%'";
- }
- $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
-
- $g = $this->whlabel->find_count($where.' and (oldstate = "11" or state = "11") and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state != "9" and features = "'.$value['features'].'"');
- $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
- $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
- $rows[$key] = $value;
- $warehouse = $this->warehouse->read($value['warehouse']);
- $rows[$key]['warehouse'] = $warehouse['title'];
- $rows[$key]['features'] = $g;
- $rows[$key]['a'] = $x;
- $rows[$key]['b'] = $s;
- $kc = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');//现有库存
- $xl = $this->whlabel->find_count($where." and outk > '".(time()-30*24*3600)."' and outk < '".time()."'".' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');//30天销量
- $yj = $c/($xl/30);
-
- if($yj < 7)
- {
- $rows[$key]['y'] = round($yj).'天销量';
- }
- else
- {
- $rows[$key]['y'] = '正常';
- }
- }
- }
- else
- {
- //$where .= " and time > '$ktime' and time < '$jtime'";
- $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
-
- $g = $this->whlabel->find_count($where.' and (oldstate = "11" or state = "11") and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state != "9" and features = "'.$value['features'].'"');
- $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
- $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
- $zs[$key] = $value;
- $warehouse = $this->warehouse->read($value['warehouse']);
- $zs[$key]['warehouse'] = $warehouse['title'];
- $zs[$key]['features'] = $g;
- $zs[$key]['a'] = $x;
- $zs[$key]['b'] = $s;
- $kc = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');//现有库存
- $xl = $this->whlabel->find_count($where." and outk > '".(time()-30*24*3600)."' and outk < '".time()."'".' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');//30天销量
- $yj = $c/($xl/30);
-
- if($yj < 7)
- {
- $zs[$key]['y'] = round($yj).'天销量';
- $rows[$key] = $zs[$key];
- }
- }
- }
-
-
- $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id'));
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows));
- echo json_encode($rows);exit;
- }
- $this->data['arg_array'] = $arg_array[0];
- $this->_Template('whlabel_fcjxc',$this->data);
- }
-
- public function _0kcdel()
- {
- $dir = '/data/excel/'.date('Ymd',time()).'/';
- $config['upload_path'] = '.'.$dir ;
- $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
- $config['allowed_types'] = 'xls|xlsx|csv';
- $config['max_size'] = 10240;
- $this->load->library('upload', $config);
- $this->upload->initialize($config);
- if ($this->upload->do_upload('userfile'))
- {
- $full_path = $dir.$this->upload->data('file_name');
- $fileName = '.' . $full_path;
- if (!file_exists($fileName))
- {
- echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
- }
- else
- {
- require_once "./data/excel/PHPExcel/IOFactory.php";
- @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
- @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
- $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
- $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
- $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
- ++$column;//如果列数大于26行
- $list = array();
- for ($i = 2; $i <= $row; $i++) // 行数循环
- {
- $data = array();
- for ($c = 'A'; $c != $column; $c++) // 列数循环
- {
- $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
- }
- $list[] = $data;
- }
- }
- $i = 0;$j = 0;$ed = array();
- foreach ($list as $key=>$value)
- {
- $time = time();
- if($value['0'] == "" || $value['1'] == "")
- {
- continue;
- }
- $warehouse = $this->warehouse->get_title($value['0']);
- $sku = $value['1'];
- $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
- if(!$d)//如果没有这个SKU
- {
- $ed[] = array($sku.'-库存中不存在此SKU');
- $j++;
- continue;
- }
- if(!isset($warehouse['id']))
- {
- $ed[] = array($sku.'-仓库名错误!');
- $j++;
- continue;
- }
- $z = $this->whlabel->find_count('sku = "'.$sku.'" and zd = "" and state = 0 and warehouse = "'.$warehouse['id'].'"');
- if($z < 1)
- {
- $z = $this->whlabel->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'"');
- foreach ($z as $v)
- {
- $zt = $this->whlabeltransport->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'" and features = "'.$d['features'].'" and cz = "0"');
- if(count($zt) > 0)
- {
- $ed[] = array($sku.'-有在途库存无法删除!');
- $j++;
- continue;
- }
- $this->whlabel->remove($v['id']);
- }
- }
- else
- {
- $ed[] = array($sku.'-非0库存!');
- $j++;
- continue;
- }
- }
- if($j > 0)
- {
- $tt = date('Ymd',time());
- $title = '删除0库存错误信息-'.$tt;
- $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
- $tail = "\n";
- $filename = $title.".xls";
- $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
- $dir = '/data/excel/'.$time.'/';
- $file_name = 'error_'.$time.rand(1000,9999);
- if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
- $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
- fwrite($myfile,$ecl);
- fclose($myfile);
- $error = $dir.$file_name.'.xls';
- echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
- }
- }
- }
-
- public function _gbhtype()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['s']))
- {
- $n = $this->input->post('n');
- $d = $this->input->post('s');
- if(!$d)
- {
- echo json_encode(array('msg'=>'未选择需要更改的商品','success'=>false));exit;
- }
- $d = explode(',',trim($d,','));
- $t = $this->whlabel_type->read($n);
- //循环删除记录
- foreach ($d as $v)
- {
- $u = $this->whlabel->read($v);
- $data = $this->whlabel->find_all("sku = '".$u['sku']."' and purchase = '".$u['purchase']."' and features = '".$u['features']."' and warehouse = '".$u['warehouse']."'");
- foreach ($data as $val)
- {
- $this->whlabel->save(array('type'=>$n),$val['id']);
- }
- }
- echo json_encode(array('d'=>$d,'t'=>$t['title'],'msg'=>'修改成功!','success'=>true));
- }
- }
-
-
- //出库、退库导出
- public function _dccrtype()
- {
- $classid = $this->classid->sku();
- $pm = $classid;
- $typeclass = array();
- $tc = $this->typeclass->find_all();
- foreach ($tc as $v)
- {
- $typeclass[$v['id']] = $v;
- }
- $prc = array();
- $purchase = $this->purchase->find_all();
- foreach($purchase as $k=>$v)
- {
- $prc[$v['id']] = $v['title'];
- }
- if(isset($_GET['sid']))
- {
- $wh = array();
- $w = $this->warehouse->find_all('1=1','id,title');
- foreach ($w as $v)
- {
- $wh[$v['id']] = $v['title'];
- }
- $type = $this->input->get('excel',true);
- $category = $this->input->get('category',true);
- $size = $this->input->get('size',true);
- $grade = $this->input->get('grade',true);
- $color = $this->input->get('color',true);
- $lowe = $this->input->get('lowe',true);
- $sku = $this->input->get('sku',true);
- $warehouse = $this->input->get('warehouse',true);
- $lacetype = $this->input->get('lacetype',true);
- $lacecolor = $this->input->get('lacecolor',true);
- $density = $this->input->get('density',true);
- $haircap = $this->input->get('haircap',true);
- $purchase = $this->input->get('purchase',true);
- $title = $this->input->get('title',true);
- $state = $this->input->get('state',true);
- $sid = $this->input->get('sid',true);
- $ktime = $this->input->get('ktime',true);
- $jtime = $this->input->get('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";$gj = "";$ck = "";
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($lacecolor)
- {
- $where .= " and features like '%-$lacecolor-%'";
- }
- if($density)
- {
- $where .= " and features like '%-$density-%'";
- }
- if($haircap)
- {
- $where .= " and features like '%-$haircap-%'";
- }
- if($title)
- {
- $title = trim($title,' ');
- $title = trim($title,' ');
- $where .= " and title like '%$title%'";
- }
- if($sku)
- {
- $sku = trim($sku,' ');
- $sku = trim($sku,' ');
- $where .= " and sku like '%$sku%'";
- }
- if($ktime && $jtime)
- {
- //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
- }
- $sidwhere = '';
- if($sid)
- {
- $sd = "";
- $s = explode(',',trim($sid,','));
- foreach ($s as $value)
- {
- $sd .= " id = ".$value." or";
- }
- $sidwhere = " and (".rtrim($sd,'or').")";
- }
- //数据排序
- $order_str = "time desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $wh = array();
- $w = $this->warehouse->find_all('1=1','id,title');
- foreach ($w as $v)
- {
- $wh[$v['id']] = $v['title'];
- }
- $wt = array();
- $whlabel_type = $this->whlabel_type->find_all();
- foreach ($whlabel_type as $v)
- {
- $wt[$v['id']] = $v['title'];
- }
- $classid = $this->classid->sku();
- $list = array();
- $rows_r = $this->whlabel->find_pc($where." and enter > '$ktime' and enter < '$jtime' ".$sidwhere,'sku,features,warehouse,enter','warehouse,sku,title,zh,features,time,enter,rktype,number,text');
- foreach ($rows_r as $key=>$value)
- {
- $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
- $pm = $classid;
- $jm = $classid;
- $rows_r[$key]['enter'] = '入库';
- $rows_r[$key]['time'] = $value['enter'];
- if($value['rktype'] == 1)
- {
- $rows_r[$key]['rktype'] = '采购入库';
- }
- else if($value['rktype'] == 2)
- {
- $rows_r[$key]['rktype'] = '盘盈调整';
- }
- else if($value['rktype'] == 3)
- {
- $rows_r[$key]['rktype'] = '其他调整入库';
- }
- else if($value['rktype'] == 4)
- {
- $rows_r[$key]['rktype'] = '其他调整入库';
- }
- else if($value['rktype'] == 5)
- {
- $rows_r[$key]['rktype'] = '退库入库';
- }
- else if($value['rktype'] == 6)
- {
- $rows_r[$key]['rktype'] = '退货可用入库';
- }
- else if($value['rktype'] == 7)
- {
- $rows_r[$key]['rktype'] = '形态转换入库';
- }
- else
- {
- $rows_r[$key]['rktype'] = '';
- }
- $features = explode('-',trim($value['features'],'-'));
- foreach($features as $v)
- {
- if(isset($typeclass[$v]))
- {
- $zh = explode('|',trim($typeclass[$v]['zh'],'|'));
- $pm[$typeclass[$v]['classid']] = $zh[0];
- }
- if(isset($typeclass[$v]))
- {
- if(isset($jm[$typeclass[$v]['classid']]))
- {
- $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
-
- }
- }
- }
- $zh = implode(" ",$pm);
- $zh = str_replace('自然色 ','',rtrim($zh,' '));
- $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
- $rows_r[$key]['zh'] = $zh;
- $jm = array_filter($jm);
- $rows_r[$key]['features'] = implode("-",$jm);
- $rows_r[$key]['number'] = $this->whlabel->find_count($where." and enter = '".$value['enter']."' ".$sidwhere);
- }
-
- $rows_c = $this->whlabel->find_all($where." and outk > '$ktime' and outk < '$jtime' ".$sidwhere,'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
- foreach ($rows_c as $key=>$value)
- {
- $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
- $pm = $classid;
- $jm = $classid;
- $rows_c[$key]['time'] = $value['outk'];
- $rows_c[$key]['outk'] = '出库';
- if($value['cktype'] == 1)
- {
- $rows_c[$key]['cktype'] = '销售出库';
- }
- else if($value['cktype'] == 2)
- {
- $rows_c[$key]['cktype'] = '销售美国出库';
- }
- else if($value['cktype'] == 3)
- {
- $rows_c[$key]['cktype'] = '盘亏调整';
- }
- else if($value['cktype'] == 4)
- {
- $rows_c[$key]['cktype'] = '其他调整出库';
- }
- else if($value['cktype'] == 5)
- {
- $rows_c[$key]['cktype'] = '形态转换出库';
- }
- else
- {
- $rows_c[$key]['cktype'] = '';
- }
- $features = explode('-',trim($value['features'],'-'));
- foreach($features as $v)
- {
- if(isset($typeclass[$v]))
- {
- $zh = explode('|',trim($typeclass[$v]['zh'],'|'));
- $pm[$typeclass[$v]['classid']] = $zh[0];
- }
- if(isset($typeclass[$v]))
- {
- if(isset($jm[$typeclass[$v]['classid']]))
- {
- $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
-
- }
- }
- }
- $zh = implode(" ",$pm);
- $zh = str_replace('自然色 ','',rtrim($zh,' '));
- $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
- $rows_c[$key]['zh'] = $zh;
- $jm = array_filter($jm);
- $rows_c[$key]['features'] = implode("-",$jm);
- $rows_c[$key]['number'] = 1;
- }
- $merged = $rows_r;
- foreach ($rows_c as $key => $value)
- {
- if (isset($merged[$key]))
- {
- $merged[] = $value;
- }
- else
- {
- $merged[$key] = $value;
- }
- }
- usort($merged, function($a, $b)
- {
- return $a['time'] - $b['time'];
- });
- foreach ($merged as $key=>$value)
- {
- $merged[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
- }
- $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime);
- $titlename = "<table border=1>
- <tr align='center'>
- <td>仓库</td>
- <td>SKU</td>
- <td>商品名称</td>
- <td>仓库品名</td>
- <td>料号</td>
- <td>时间</td>
- <td>操作</td>
- <td>类型</td>
- <td>数量</td>
- <td>备注</td>
- </tr>
- </table>";
- $filename = $title.".xlsx";
- $tail = "";
- $this->excel->get_fz2($merged,$titlename,$filename,$tail);
-
- }
- }
-
- }
|