Whlabel.php 257 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. }
  45. //定义方法的调用规则 获取URI第二段值
  46. public function _remap($arg, $arg_array)
  47. {
  48. if ($arg == 'existence') //在库标签
  49. {
  50. $this->_existence();
  51. } else if ($arg == 'cpbqdc') //在库标签
  52. {
  53. $this->_cpbqdc();
  54. } else if ($arg == 'type') //进销存浏览
  55. {
  56. $this->_type();
  57. } else if ($arg == 'typedy') //进销存浏览店员页面
  58. {
  59. $this->_typedy($arg_array);
  60. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  61. {
  62. $this->_typedy_ck($arg_array);
  63. } else if ($arg == 'typeck') {
  64. $this->_typeck($arg_array);
  65. } else if ($arg == 'whlabeckdc') {
  66. $this->_whlabeckdc($arg_array);
  67. } else if ($arg == 'usatype') //美仓进销存浏览
  68. {
  69. $this->_usatype();
  70. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  71. {
  72. $this->_usatypeapp();
  73. } else if ($arg == 'enteradd') //入库操作
  74. {
  75. $this->_enteradd();
  76. } else if ($arg == 'enteredit') //修改
  77. {
  78. $this->_enteredit($arg_array);
  79. } else if ($arg == 'enter') //入库浏览
  80. {
  81. $this->_enter();
  82. } else if ($arg == 'out') //出库浏览
  83. {
  84. $this->_out();
  85. } else if ($arg == 'label') //出库标签浏览
  86. {
  87. $this->_label();
  88. } else if ($arg == 'outorder') //独立站出库订单
  89. {
  90. $this->_outorder();
  91. } else if ($arg == 'soutorder') //速卖通出库订单
  92. {
  93. $this->_soutorder();
  94. } else if ($arg == 'toutorder') //TT出库订单
  95. {
  96. $this->_toutorder();
  97. }else if ($arg == 'aoutorder') //amz出库订单
  98. {
  99. $this->_aoutorder();
  100. } else if ($arg == 'retreat') //退库订单
  101. {
  102. $this->_retreat();
  103. } else if ($arg == 'retreatlk') //退库订单
  104. {
  105. $this->_retreatlk();
  106. } else if ($arg == 'change') //更换标签
  107. {
  108. $this->_change();
  109. } else if ($arg == 'del') //删除
  110. {
  111. $this->_del();
  112. } else if ($arg == 'exceljxc') //进销存信息导出
  113. {
  114. $this->_exceljxc();
  115. } else if ($arg == 'excelr') //入库信息导出
  116. {
  117. $this->_excelr();
  118. } else if ($arg == 'excelct') //出库、退库信息导出
  119. {
  120. $this->_excelct();
  121. } else if ($arg == 'dccrtype') //根据出入库类型导出
  122. {
  123. $this->_dccrtype();
  124. } else if ($arg == 'excelcr') //出库、退库信息导出
  125. {
  126. $this->_excelcr();
  127. } else if ($arg == 'kcyz') //库存验证
  128. {
  129. $this->_kcyz();
  130. } else if ($arg == 'kj') //库存扣减
  131. {
  132. $this->_kj($arg_array);
  133. } else if ($arg == 'presetout') //预设库存导入
  134. {
  135. $this->_presetout($arg_array);
  136. } else if ($arg == 'presetedit') //预设库存导入
  137. {
  138. $this->_presetedit($arg_array);
  139. } else if ($arg == 'summary') //汇总导出
  140. {
  141. $this->_summary($arg_array);
  142. } else if ($arg == 'manifest') //usps发货清单
  143. {
  144. $this->_manifest();
  145. } else if ($arg == 'abnormal') //占单异常
  146. {
  147. $this->_abnormal();
  148. } else if ($arg == 'error') //0库存SKU
  149. {
  150. $this->_error();
  151. } else if ($arg == 'errorexcel') //0库存SKU导出
  152. {
  153. $this->_errorexcel();
  154. } else if ($arg == 'db') {
  155. $this->_db();
  156. } else if ($arg == 'dbrk') {
  157. $this->_dbrk();
  158. } else if ($arg == 'whlabelczdc') {
  159. $this->_whlabelczdc();
  160. } else if ($arg == 'print') {
  161. $this->_print($arg_array);
  162. } else if ($arg == 'usaprint') {
  163. $this->_usaprint($arg_array);
  164. } else if ($arg == 'printck') {
  165. $this->_printck($arg_array);
  166. } else if ($arg == 'printrk') {
  167. $this->_printrk($arg_array);
  168. } else if ($arg == 'printxzrk') {
  169. $this->_printxzrk($arg_array);
  170. } else if ($arg == 'printexcel') {
  171. $this->_printexcel($arg_array);
  172. } else if ($arg == 'uck') {
  173. $this->_uck();
  174. } else if ($arg == 'whlabelexcelzh') {
  175. $this->_whlabelexcelzh();
  176. } else if ($arg == 'fc') {
  177. $this->_fc();
  178. } else if ($arg == 'fcmb') {
  179. $this->_fcmb();
  180. } else if ($arg == 'fcexcel') {
  181. $this->_fcexcel();
  182. } else if ($arg == 'fcjxc') {
  183. $this->_fcjxc($arg_array);
  184. } else if ($arg == '0kcdel') {
  185. $this->_0kcdel(); //导表删除0库存
  186. } else if ($arg == 'gbhtype') {
  187. $this->_gbhtype(); //更改备货状态
  188. } else {
  189. $this->_index();
  190. }
  191. }
  192. //管理
  193. public function _index()
  194. {
  195. $post = $this->input->post(NULL, TRUE);
  196. if (isset($post['page'])) {
  197. $page = $this->input->post('page', true);
  198. $perpage = $this->input->post('perpage', true);
  199. $sku = $this->input->post('sku', true);
  200. $number = $this->input->post('number', true);
  201. $warehouse = $this->input->post('warehouse', true);
  202. $purchase = $this->input->post('purchase', true);
  203. $orderinfo = $this->input->post('orderinfo', true);
  204. $waybill = $this->input->post('waybill', true);
  205. $category = $this->input->post('category', true);
  206. $size = $this->input->post('size', true);
  207. $grade = $this->input->post('grade', true);
  208. $color = $this->input->post('color', true);
  209. $lowe = $this->input->post('lowe', true);
  210. $state = $this->input->post('state', true);
  211. $label = $this->input->post('label', true);
  212. $timetk = $this->input->post('timetkk', true);
  213. $timetj = $this->input->post('timetjj', true);
  214. $timetk = strtotime($timetk);
  215. $timetj = strtotime($timetj);
  216. $where = "1=1 ";
  217. if ($timetk && $timetj) {
  218. $where .= " and time > '$timetk' and time < '$timetj'";
  219. }
  220. if ($sku) {
  221. $where .= " and sku = '$sku'";
  222. }
  223. if ($number) {
  224. $where .= " and number = '$number'";
  225. }
  226. if ($warehouse) {
  227. $where .= " and warehouse = '$warehouse'";
  228. }
  229. if ($purchase) {
  230. $where .= " and purchase = '$purchase'";
  231. }
  232. if ($orderinfo) {
  233. $where .= " and orderinfo = '$orderinfo'";
  234. }
  235. if ($waybill) {
  236. $where .= " and waybill = '$waybill'";
  237. }
  238. if ($category) {
  239. $where .= " and features like '%-$category-%'";
  240. }
  241. if ($size) {
  242. $where .= " and features like '%-$size-%'";
  243. }
  244. if ($grade) {
  245. $where .= " and features like '%-$grade-%'";
  246. }
  247. if ($color) {
  248. $where .= " and features like '%-$color-%'";
  249. }
  250. if ($lowe) {
  251. $where .= " and features like '%-$lowe-%'";
  252. }
  253. if ($label) {
  254. $where .= " and label = '$label'";
  255. }
  256. if ($state != '') {
  257. $where .= " and state = '$state'";
  258. }
  259. //数据排序
  260. $order_str = "time desc";
  261. if (empty($page)) {
  262. $start = 0;
  263. $perpage = 1;
  264. } else {
  265. $start = ($page - 1) * $perpage;
  266. }
  267. //取得信息列表
  268. $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);
  269. foreach ($info_list as $key => $value) {
  270. $warehouse = $this->warehouse->read($value['warehouse']);
  271. $info_list[$key]['warehouse'] = $warehouse['title'];
  272. $purchase = $this->purchase->read($value['purchase']);
  273. $info_list[$key]['purchase'] = $purchase['title'];
  274. if ($value['enter'] != 0) {
  275. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  276. } else {
  277. $info_list[$key]['enter'] = "";
  278. }
  279. if ($value['outk'] != 0) {
  280. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  281. } else {
  282. $info_list[$key]['outk'] = "";
  283. }
  284. if ($value['printing'] != 0) {
  285. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  286. } else {
  287. $info_list[$key]['printing'] = "";
  288. }
  289. if ($value['orderinfo'] == 0) {
  290. $info_list[$key]['orderinfo'] = "";
  291. }
  292. if ($value['waybill'] == 0) {
  293. $info_list[$key]['waybill'] = "";
  294. }
  295. if ($value['state'] == 0) {
  296. $info_list[$key]['state'] = "在库";
  297. } else if ($value['state'] == 1) {
  298. $info_list[$key]['state'] = "出库";
  299. } else if ($value['state'] == 2) {
  300. $info_list[$key]['state'] = "退库";
  301. } else if ($value['state'] == 3) {
  302. $info_list[$key]['state'] = "调拨中";
  303. } else if ($value['state'] == 4) {
  304. $info_list[$key]['state'] = "再加工";
  305. } else if ($value['state'] == 5) {
  306. $info_list[$key]['state'] = "维修中";
  307. } else if ($value['state'] == 6) {
  308. $info_list[$key]['state'] = "盘亏";
  309. } else if ($value['state'] == 7) {
  310. $info_list[$key]['state'] = "更换标签";
  311. } else if ($value['state'] == 8) {
  312. $info_list[$key]['state'] = "其它";
  313. } else if ($value['state'] == 9) {
  314. $info_list[$key]['state'] = "预设";
  315. } else if ($value['state'] == 10) {
  316. $info_list[$key]['state'] = "美店零售";
  317. }
  318. if ($value['text'] == "") {
  319. $info_list[$key]['text'] = "";
  320. }
  321. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  322. }
  323. $total = $this->whlabel->find_count($where);
  324. $pagenum = ceil($total / $perpage);
  325. $over = $total - ($start + $perpage);
  326. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  327. echo json_encode($rows);
  328. exit;
  329. }
  330. if (isset($post['outsku'])) {
  331. $cz = $this->input->post('cz', true);
  332. if ($cz == '1') {
  333. $sku = $this->input->post('outsku', true);
  334. if ($sku) {
  335. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  336. if (count($data) < 1) {
  337. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  338. exit;
  339. }
  340. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 1), $data[0]['id']);
  341. echo json_encode(array('success' => true));
  342. exit;
  343. }
  344. } else {
  345. $sku = $this->input->post('outsku', true);
  346. if ($sku) {
  347. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  348. if (count($data) < 1) {
  349. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  350. exit;
  351. }
  352. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  353. echo json_encode(array('success' => true));
  354. exit;
  355. }
  356. }
  357. }
  358. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  359. $this->_Template('whlabel', $this->data);
  360. }
  361. //在库标签
  362. public function _existence()
  363. {
  364. $post = $this->input->post(NULL, TRUE);
  365. if (isset($post['s'])) {
  366. $id_arr = $this->input->post('s');
  367. $id_arr = explode(',', $id_arr);
  368. if (!$id_arr) {
  369. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  370. exit;
  371. }
  372. //循环删除记录
  373. foreach ($id_arr as $v) {
  374. $sid = $this->whlabel->read($v);
  375. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  376. if ($count > 0) {
  377. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  378. exit;
  379. }
  380. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  381. if (count($zt) > 0) {
  382. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  383. exit;
  384. }
  385. $this->whlabel->remove($v);
  386. }
  387. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  388. exit;
  389. }
  390. if (isset($post['page'])) {
  391. $page = $this->input->post('page', true);
  392. $perpage = $this->input->post('perpage', true);
  393. $warehouse = $this->input->post('warehouse', true);
  394. $label = $this->input->post('label', true);
  395. $where = "1=1 and state = 0";
  396. if ($warehouse) {
  397. $where .= " and warehouse = '$warehouse'";
  398. }
  399. if ($label) {
  400. $where .= " and label = '$label'";
  401. }
  402. //数据排序
  403. $order_str = "time asc";
  404. if (empty($page)) {
  405. $start = 0;
  406. $perpage = 1;
  407. } else {
  408. $start = ($page - 1) * $perpage;
  409. }
  410. //取得信息列表
  411. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  412. foreach ($info_list as $key => $value) {
  413. if ($value['enter'] != 0) {
  414. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  415. } else {
  416. $info_list[$key]['enter'] = "";
  417. }
  418. if ($value['printing'] != 0) {
  419. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  420. } else {
  421. $info_list[$key]['printing'] = "";
  422. }
  423. }
  424. $total = $this->whlabel->find_count($where);
  425. $pagenum = ceil($total / $perpage);
  426. $over = $total - ($start + $perpage);
  427. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  428. echo json_encode($rows);
  429. exit;
  430. }
  431. $this->_Template('whlabel_existence', $this->data);
  432. }
  433. //进销存浏览
  434. public function _typedy($arg_array)
  435. {
  436. $prc = array();
  437. $purchase = $this->purchase->find_all();
  438. foreach ($purchase as $k => $v) {
  439. $prc[$v['id']] = $v['title'];
  440. }
  441. $post = $this->input->post(NULL, TRUE);
  442. if (isset($post['page'])) {
  443. $page = $this->input->post('page', true);
  444. $perpage = $this->input->post('perpage', true);
  445. $category = $this->input->post('category', true);
  446. $size = $this->input->post('size', true);
  447. $grade = $this->input->post('grade', true);
  448. $color = $this->input->post('color', true);
  449. $lowe = $this->input->post('lowe', true);
  450. $sku = $this->input->post('sku');
  451. $title = $this->input->post('title');
  452. $warehouse = $this->input->post('warehouse', true);
  453. $usa = $this->input->post('usa', true);
  454. $purchase = $this->input->post('purchase', true);
  455. $lacetype = $this->input->post('lacetype', true);
  456. $haircap = $this->input->post('haircap', true);
  457. $density = $this->input->post('density', true);
  458. $details = $this->input->post('details', true);
  459. $state = $this->input->post('state', true);
  460. $lacecolor = $this->input->post('lacecolor', true);
  461. $hairnumber = $this->input->post('hairnumber', true);
  462. $cklx = $this->input->post('cklx', true);
  463. $ktime = $this->input->post('ktime', true);
  464. $jtime = $this->input->post('jtime', true);
  465. $ktime = strtotime($ktime);
  466. $jtime = strtotime($jtime);
  467. $where = "1=1";
  468. $gj = "";
  469. $ck = "";
  470. if ($usa) {
  471. if (!$warehouse) {
  472. $where .= " and (warehouse = '5' or warehouse = '8')";
  473. }
  474. }
  475. if ($warehouse) {
  476. $where .= " and warehouse = '$warehouse'";
  477. }
  478. if ($details) {
  479. $where .= " and details = '$details'";
  480. }
  481. if ($purchase) {
  482. $where .= " and purchase = '$purchase'";
  483. }
  484. if ($state) {
  485. $where .= " and state = '$state'";
  486. }
  487. if ($lacetype) {
  488. $where .= " and features like '%-$lacetype-%'";
  489. }
  490. if ($category) {
  491. $where .= " and features like '%-$category-%'";
  492. }
  493. if ($size) {
  494. $where .= " and features like '%-$size-%'";
  495. }
  496. if ($grade) {
  497. $where .= " and features like '%-$grade-%'";
  498. }
  499. if ($color) {
  500. $where .= " and features like '%-$color-%'";
  501. }
  502. if ($lowe) {
  503. $where .= " and features like '%-$lowe-%'";
  504. }
  505. if ($haircap) {
  506. $where .= " and features like '%-$haircap-%'";
  507. }
  508. if ($density) {
  509. $where .= " and features like '%-$density-%'";
  510. }
  511. if ($lacecolor) {
  512. $where .= " and features like '%-$lacecolor-%'";
  513. }
  514. if (!empty($hairnumber)) {
  515. $where .= " and features like '%-128-%' ";
  516. if ($hairnumber < 0) {
  517. $class_list = $this->typeclass->find_all('classid = 43');
  518. foreach ($class_list as $v) {
  519. $where .= " and features not like '%-" . $v['id'] . "-%'";
  520. }
  521. } else {
  522. $where .= " and features like '%-$hairnumber-%'";
  523. }
  524. }
  525. $where_add = '';
  526. if ($cklx) {
  527. $shop = $this->shop->read($cklx);
  528. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  529. }
  530. if ($ktime && $jtime) {
  531. $gj = " and enter > '$ktime' and enter < '$jtime'";
  532. $ck = " and outk > '$ktime' and outk < '$jtime'";
  533. }
  534. //数据排序
  535. $order_str = "id desc";
  536. if (empty($page)) {
  537. $start = 0;
  538. $perpage = 1;
  539. } else {
  540. $start = ($page - 1) * $perpage;
  541. }
  542. if ($sku) {
  543. $sku = trim($sku, ' ');
  544. $sku = trim($sku, ' ');
  545. $where .= " and sku like '%$sku%'";
  546. $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);
  547. } else if ($title) {
  548. $title = trim($title, ' ');
  549. $title = trim($title, ' ');
  550. $where .= " and title like '%$title%'";
  551. $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);
  552. } else {
  553. //$where .= " and time > '$ktime' and time < '$jtime'";
  554. $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);
  555. }
  556. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  557. foreach ($info_list as $k => $v) {
  558. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  559. unset($info_list[$k]['pm']);
  560. unset($info_list[$k]['jm']);
  561. unset($info_list[$k]['bm']);
  562. }
  563. //取得信息列表
  564. $rows = array();
  565. $list = array();
  566. foreach ($info_list as $key => $value) {
  567. $warehouse = $this->warehouse->read($value['warehouse']);
  568. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  569. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  570. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  571. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  572. $number = $value['number'];
  573. $ftime = time() - 15 * 24 * 3600;
  574. $info_list[$key]['warehouse'] = $warehouse['title'];
  575. $info_list[$key]['features'] = count($c);
  576. $z = count($z); //查看订单号
  577. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  578. $ztdata = '';
  579. if (count($zt) > 0) {
  580. foreach ($zt as $vv) {
  581. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  582. }
  583. }
  584. $info_list[$key]['number'] = $ztdata;
  585. $info_list[$key]['sm'] = $z;
  586. $details = array();
  587. $cpid = array();
  588. foreach ($c as $k => $v) {
  589. $details[$v['details']] = $v['details'];
  590. if ($v['cpid'] != 0) {
  591. $cpid[$v['cpid']] = $v['cpid'];
  592. }
  593. }
  594. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  595. if ($value['shop'] != '') {
  596. $shop = explode(',', trim($value['shop'], ','));
  597. $shop = $this->shop->read($shop[0]);
  598. $info_list[$key]['shop'] = $shop['shopname'];
  599. }
  600. }
  601. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  602. $pagenum = ceil($total / $perpage);
  603. $over = $total - ($start + $perpage);
  604. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  605. echo json_encode($rows);
  606. exit;
  607. }
  608. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  609. $this->_Template('whlabel_typedy', $this->data);
  610. }
  611. //进销存浏览
  612. public function _typedy_ck($arg_array)
  613. {
  614. $prc = array();
  615. $purchase = $this->purchase->find_all();
  616. foreach ($purchase as $k => $v) {
  617. $prc[$v['id']] = $v['title'];
  618. }
  619. $post = $this->input->post(NULL, TRUE);
  620. if (isset($post['page'])) {
  621. $page = $this->input->post('page', true);
  622. $perpage = $this->input->post('perpage', true);
  623. $category = $this->input->post('category', true);
  624. $size = $this->input->post('size', true);
  625. $grade = $this->input->post('grade', true);
  626. $color = $this->input->post('color', true);
  627. $lowe = $this->input->post('lowe', true);
  628. $sku = $this->input->post('sku');
  629. $title = $this->input->post('title');
  630. $warehouse = $this->input->post('warehouse', true);
  631. $usa = $this->input->post('usa', true);
  632. $purchase = $this->input->post('purchase', true);
  633. $lacetype = $this->input->post('lacetype', true);
  634. $haircap = $this->input->post('haircap', true);
  635. $density = $this->input->post('density', true);
  636. $details = $this->input->post('details', true);
  637. $state = $this->input->post('state', true);
  638. $lacecolor = $this->input->post('lacecolor', true);
  639. $cklx = $this->input->post('cklx', true);
  640. $ktime = $this->input->post('ktime', true);
  641. $jtime = $this->input->post('jtime', true);
  642. $ktime = strtotime($ktime);
  643. $jtime = strtotime($jtime);
  644. $where = "1=1";
  645. $gj = "";
  646. $ck = "";
  647. if ($lacetype) {
  648. $where .= " and features like '%-$lacetype-%'";
  649. }
  650. if ($category) {
  651. $where .= " and features like '%-$category-%'";
  652. }
  653. if ($size) {
  654. $where .= " and features like '%-$size-%'";
  655. }
  656. if ($grade) {
  657. $where .= " and features like '%-$grade-%'";
  658. }
  659. if ($color) {
  660. $where .= " and features like '%-$color-%'";
  661. }
  662. if ($lowe) {
  663. $where .= " and features like '%-$lowe-%'";
  664. }
  665. if ($haircap) {
  666. $where .= " and features like '%-$haircap-%'";
  667. }
  668. if ($density) {
  669. $where .= " and features like '%-$density-%'";
  670. }
  671. if ($lacecolor) {
  672. $where .= " and features like '%-$lacecolor-%'";
  673. }
  674. if ($usa) {
  675. if (!$warehouse) {
  676. $where .= " and (warehouse = '5' or warehouse = '8')";
  677. }
  678. }
  679. if ($warehouse) {
  680. $where .= " and warehouse = '$warehouse'";
  681. }
  682. if ($details) {
  683. $where .= " and details = '$details'";
  684. }
  685. if ($purchase) {
  686. $where .= " and purchase = '$purchase'";
  687. }
  688. if ($state) {
  689. $where .= " and state = '$state'";
  690. }
  691. $where_add = '';
  692. if ($cklx) {
  693. $shop = $this->shop->read($cklx);
  694. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  695. }
  696. if ($ktime && $jtime) {
  697. $gj = " and enter > '$ktime' and enter < '$jtime'";
  698. $ck = " and outk > '$ktime' and outk < '$jtime'";
  699. }
  700. //数据排序
  701. $order_str = "id desc";
  702. if (empty($page)) {
  703. $start = 0;
  704. $perpage = 1;
  705. } else {
  706. $start = ($page - 1) * $perpage;
  707. }
  708. if ($sku) {
  709. $sku = trim($sku, ' ');
  710. $sku = trim($sku, ' ');
  711. $where .= " and sku like '%$sku%'";
  712. $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);
  713. } else if ($title) {
  714. $title = trim($title, ' ');
  715. $title = trim($title, ' ');
  716. $where .= " and title like '%$title%'";
  717. $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);
  718. } else {
  719. //$where .= " and time > '$ktime' and time < '$jtime'";
  720. $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);
  721. }
  722. //取得信息列表
  723. $rows = array();
  724. $list = array();
  725. foreach ($info_list as $key => $value) {
  726. $warehouse = $this->warehouse->read($value['warehouse']);
  727. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  728. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  729. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  730. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  731. $ftime = time() - 15 * 24 * 3600;
  732. $info_list[$key]['warehouse'] = $warehouse['title'];
  733. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  734. //$z = count($z);//查看订单号
  735. //$info_list[$key]['zd'] = $z;
  736. $details = array();
  737. $cpid = array();
  738. foreach ($c as $k => $v) {
  739. $details[$v['details']] = $v['details'];
  740. if ($v['cpid'] != 0) {
  741. $cpid[$v['cpid']] = $v['cpid'];
  742. }
  743. }
  744. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  745. if ($value['shop'] != '') {
  746. $shop = explode(',', trim($value['shop'], ','));
  747. $shop = $this->shop->read($shop[0]);
  748. $info_list[$key]['shop'] = $shop['shopname'];
  749. }
  750. }
  751. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  752. $pagenum = ceil($total / $perpage);
  753. $over = $total - ($start + $perpage);
  754. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  755. echo json_encode($rows);
  756. exit;
  757. }
  758. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  759. $this->_Template('whlabel_typedy_ck', $this->data);
  760. }
  761. public function _typeck($arg_array)
  762. {
  763. $prc = array();
  764. $purchase = $this->purchase->find_all();
  765. foreach ($purchase as $k => $v) {
  766. $prc[$v['id']] = $v['title'];
  767. }
  768. $post = $this->input->post(NULL, TRUE);
  769. if (isset($post['page'])) {
  770. $page = $this->input->post('page', true);
  771. $perpage = $this->input->post('perpage', true);
  772. $category = $this->input->post('category', true);
  773. $size = $this->input->post('size', true);
  774. $grade = $this->input->post('grade', true);
  775. $color = $this->input->post('color', true);
  776. $lacecolor = $this->input->post('lacecolor', true);
  777. $lowe = $this->input->post('lowe', true);
  778. $sku = $this->input->post('sku');
  779. $title = $this->input->post('title');
  780. $warehouse = 13;
  781. $usa = $this->input->post('usa', true);
  782. $purchase = $this->input->post('purchase', true);
  783. $lacetype = $this->input->post('lacetype', true);
  784. $haircap = $this->input->post('haircap', true);
  785. $density = $this->input->post('density', true);
  786. $details = $this->input->post('details', true);
  787. $state = $this->input->post('state', true);
  788. $ktime = $this->input->post('ktime', true);
  789. $jtime = $this->input->post('jtime', true);
  790. $ktime = strtotime($ktime);
  791. $jtime = strtotime($jtime);
  792. $where = "1=1";
  793. $gj = "";
  794. $ck = "";
  795. if ($lacetype) {
  796. $where .= " and features like '%-$lacetype-%'";
  797. }
  798. if ($category) {
  799. $where .= " and features like '%-$category-%'";
  800. }
  801. if ($size) {
  802. $where .= " and features like '%-$size-%'";
  803. }
  804. if ($grade) {
  805. $where .= " and features like '%-$grade-%'";
  806. }
  807. if ($color) {
  808. $where .= " and features like '%-$color-%'";
  809. }
  810. if ($lacecolor) {
  811. $where .= " and features like '%-$lacecolor-%'";
  812. }
  813. if ($lowe) {
  814. $where .= " and features like '%-$lowe-%'";
  815. }
  816. if ($haircap) {
  817. $where .= " and features like '%-$haircap-%'";
  818. }
  819. if ($density) {
  820. $where .= " and features like '%-$density-%'";
  821. }
  822. if ($warehouse) {
  823. $where .= " and warehouse = '$warehouse'";
  824. }
  825. if ($details) {
  826. $where .= " and details = '$details'";
  827. }
  828. if ($purchase) {
  829. $where .= " and purchase = '$purchase'";
  830. }
  831. if ($state) {
  832. $where .= " and state = '$state'";
  833. }
  834. if ($ktime && $jtime) {
  835. $gj = " and enter > '$ktime' and enter < '$jtime'";
  836. $ck = " and outk > '$ktime' and outk < '$jtime'";
  837. }
  838. //数据排序
  839. $order_str = "id desc";
  840. if (empty($page)) {
  841. $start = 0;
  842. $perpage = 1;
  843. } else {
  844. $start = ($page - 1) * $perpage;
  845. }
  846. if ($sku) {
  847. $sku = trim($sku, ' ');
  848. $sku = trim($sku, ' ');
  849. $where .= " and sku like '%$sku%'";
  850. } else if ($title) {
  851. $title = trim($title, ' ');
  852. $title = trim($title, ' ');
  853. $where .= " and title like '%$title%'";
  854. }
  855. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  856. //取得信息列表
  857. $t = array();
  858. $typeclass = $this->typeclass->find_all();
  859. foreach ($typeclass as $v) {
  860. $t[$v['id']] = $v;
  861. }
  862. $rows = array();
  863. $list = array();
  864. foreach ($info_list as $key => $value) {
  865. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  866. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  867. $warehouse = $this->warehouse->read($value['warehouse']);
  868. $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');
  869. $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'] . '"');
  870. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  871. $number = $value['number'];
  872. $ftime = time() - 15 * 24 * 3600;
  873. $z = count($z); //查看订单号
  874. $info_list[$key]['warehouse'] = $warehouse['title'];
  875. $info_list[$key]['features'] = count($c);
  876. $info_list[$key]['number'] = $z;
  877. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  878. $details = array();
  879. $cpid = array();
  880. foreach ($c as $k => $v) {
  881. $details[$v['details']] = $v['details'];
  882. if ($v['cpid'] != 0) {
  883. $cpid[$v['cpid']] = $v['cpid'];
  884. }
  885. }
  886. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  887. $classid = $this->classid->sku();
  888. $pm = $classid;
  889. $features = explode('-', trim($value['features'], '-'));
  890. foreach ($features as $v) {
  891. $zh = explode('|', trim($t[$v]['zh'], '|'));
  892. $pm[$t[$v]['classid']] = $zh[0];
  893. }
  894. $zh = implode(" ", $pm);
  895. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  896. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  897. $info_list[$key]['sm'] = $zh;
  898. }
  899. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  900. $pagenum = ceil($total / $perpage);
  901. $over = $total - ($start + $perpage);
  902. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  903. echo json_encode($rows);
  904. exit;
  905. }
  906. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  907. $this->_Template('whlabel_typeck', $this->data);
  908. }
  909. //进销存导出
  910. public function _whlabeckdc()
  911. {
  912. $prc = array();
  913. $purchase = $this->purchase->find_all();
  914. foreach ($purchase as $k => $v) {
  915. $prc[$v['id']] = $v['title'];
  916. }
  917. if (isset($_GET['excel'])) {
  918. $where = "sku != 'Preset'";
  919. //数据排序
  920. $order_str = "id desc";
  921. if (empty($page)) {
  922. $start = 0;
  923. $perpage = 1;
  924. } else {
  925. $start = ($page - 1) * $perpage;
  926. }
  927. $category = $this->input->get('category', true);
  928. $color = $this->input->get('color', true);
  929. $lowe = $this->input->get('lowe', true);
  930. $lacetype = $this->input->get('lacetype', true);
  931. $size = $this->input->get('size', true);
  932. $density = $this->input->get('density', true);
  933. $haircap = $this->input->get('haircap', true);
  934. $sku = $this->input->get('sku', true);
  935. $details = $this->input->get('details', true);
  936. $warehouse = 13;
  937. $excelid = $this->input->get('sid', true);
  938. if ($category) {
  939. $where .= " and features like '%-$category-%'";
  940. }
  941. if ($color) {
  942. $where .= " and features like '%-$color-%'";
  943. }
  944. if ($lowe) {
  945. $where .= " and features like '%-$lowe-%'";
  946. }
  947. if ($lacetype) {
  948. $where .= " and features like '%-$lacetype-%'";
  949. }
  950. if ($size) {
  951. $where .= " and features like '%-$size-%'";
  952. }
  953. if ($density) {
  954. $where .= " and features like '%-$density-%'";
  955. }
  956. if ($haircap) {
  957. $where .= " and features like '%-$haircap-%'";
  958. }
  959. if ($warehouse) {
  960. $where .= " and warehouse = '$warehouse'";
  961. }
  962. if ($sku) {
  963. $where .= " and sku like '%$sku%'";
  964. }
  965. if ($details) {
  966. $where .= " and details = '$details'";
  967. }
  968. $xzid = '';
  969. if ($excelid) {
  970. $excelid = explode(',', trim($excelid, ','));
  971. foreach ($excelid as $key => $value) {
  972. $xzid .= " id = " . $value . " or";
  973. }
  974. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  975. }
  976. //取得信息列表
  977. /**
  978. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  979. $rows = array();$list = array();
  980. foreach ($info_list as $key=>$value)
  981. {
  982. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  983. }
  984. **/
  985. $wh = array();
  986. $w = $this->warehouse->find_all('1=1', 'id,title');
  987. foreach ($w as $v) {
  988. $wh[$v['id']] = $v['title'];
  989. }
  990. $tc = array();
  991. $tcdata = array();
  992. $typeclass = $this->typeclass->find_all();
  993. foreach ($typeclass as $v) {
  994. $tc[$v['id']] = $v;
  995. }
  996. $list = array();
  997. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  998. foreach ($rows as $key => $value) {
  999. $bm = '03';
  1000. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  1001. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1002. $classid = $this->classid->sku();
  1003. $pm = $classid;
  1004. $jm = $classid;
  1005. $features = explode('-', trim($value['features'], '-'));
  1006. foreach ($features as $v) {
  1007. if (isset($tc[$v]) && isset($bmpx[$tc[$v]['classid']])) {
  1008. if ($tc[$v]['bm'] != '') {
  1009. $bmpx[$tc[$v]['classid']] = $tc[$v]['bm'];
  1010. }
  1011. }
  1012. if (isset($tc[$v])) {
  1013. $zh = explode('|', trim($tc[$v]['zh'], '|'));
  1014. $pm[$tc[$v]['classid']] = $zh[0];
  1015. }
  1016. if (isset($tc[$v])) {
  1017. if (isset($jm[$tc[$v]['classid']])) {
  1018. $jm[$tc[$v]['classid']] = $tc[$v]['jm'];
  1019. }
  1020. }
  1021. }
  1022. $zh = implode(" ", $pm);
  1023. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  1024. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1025. $rows[$key]['dbcontent'] = $zh;
  1026. $rows[$key]['cpbz'] = $bm . implode("", $bmpx);
  1027. $jm = array_filter($jm);
  1028. $rows[$key]['cs'] = implode("-", $jm);
  1029. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1030. $details = array();
  1031. $cpid = array();
  1032. $cpbz = array();
  1033. $c = 0;
  1034. $g = 0;
  1035. $x = 0;
  1036. $t = 0;
  1037. $s = 0;
  1038. $q = 0;
  1039. foreach ($sd as $k => $v) {
  1040. if ($v['state'] == 0) {
  1041. $c++;
  1042. }
  1043. if ($v['state'] != 9) {
  1044. $g++;
  1045. }
  1046. if ($v['state'] == 1) {
  1047. $x++;
  1048. }
  1049. if ($v['state'] == 2) {
  1050. $t++;
  1051. }
  1052. if ($v['state'] == 8) {
  1053. $s++;
  1054. }
  1055. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1056. $q++;
  1057. }
  1058. $details[$v['details']] = $v['details'];
  1059. if ($v['cpid'] != 0) {
  1060. $cpid[$v['cpid']] = $v['cpid'];
  1061. }
  1062. if ($v['cpbz'] != '') {
  1063. $cpbz[$v['cpbz']] = $v['cpbz'];
  1064. }
  1065. }
  1066. $rows[$key]['details'] = implode("、", $details);
  1067. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1068. $number = $value['number'];
  1069. $ftime = time() - 15 * 24 * 3600;
  1070. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1071. $rows[$key]['number'] = $g;
  1072. $rows[$key]['features'] = $c;
  1073. $rows[$key]['x'] = $x;
  1074. $rows[$key]['t'] = $t;
  1075. $rows[$key]['s'] = $s;
  1076. $rows[$key]['q'] = $q;
  1077. $rows[$key]['wzsl'] = count($details);
  1078. }
  1079. $title = "进销存统计表" . date('Y-m-d', time());
  1080. $titlename = "<table border=1>
  1081. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1082. <tr align='center'>
  1083. <td>仓库</td>
  1084. <td>供应商</td>
  1085. <td>位置</td>
  1086. <td>库存编码</td>
  1087. <td>SKU</td>
  1088. <td>用友编码</td>
  1089. <td>用友料号</td>
  1090. <td>产品英文名</td>
  1091. <td>产品中文名</td>
  1092. <td>入库总量</td>
  1093. <td>库存数量</td>
  1094. <td>销售数量</td>
  1095. <td>退货数量</td>
  1096. <td>删除数量</td>
  1097. <td>其它操作</td>
  1098. <td>位置数量</td>
  1099. </tr>
  1100. </table>";
  1101. $filename = $title . ".xls";
  1102. $tail = "";
  1103. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1104. }
  1105. }
  1106. public function _type()
  1107. {
  1108. $vip = 0;
  1109. if (isset($_SESSION['api'])) {
  1110. $user = $this->user->get_api($_SESSION['api']);
  1111. $fgshop = "";
  1112. $sid = "";
  1113. $usersp = explode('|', trim($user['shop'], '|'));
  1114. foreach ($usersp as $value) {
  1115. $fgshop .= " shop = " . $value . " or";
  1116. $sid .= " id = " . $value . " or";
  1117. }
  1118. if ($user['vip'] == 1) {
  1119. $vip = 1;
  1120. }
  1121. } else {
  1122. header('Location: /');
  1123. exit;
  1124. }
  1125. $prc = array();
  1126. $purchase = $this->purchase->find_all();
  1127. foreach ($purchase as $k => $v) {
  1128. $prc[$v['id']] = $v['title'];
  1129. }
  1130. $company = array();
  1131. $ct = $this->company->find_all();
  1132. foreach ($ct as $k => $v) {
  1133. $company[$v['id']] = $v['title'];
  1134. }
  1135. $sp = array();
  1136. $s = $this->shop->find_all('1=1', 'id,shopname');
  1137. foreach ($s as $v) {
  1138. $sp[$v['id']] = $v['shopname'];
  1139. }
  1140. $wh = array();
  1141. $w = $this->warehouse->find_all('1=1', 'id,title');
  1142. foreach ($w as $v) {
  1143. $wh[$v['id']] = $v['title'];
  1144. }
  1145. $post = $this->input->post(NULL, TRUE);
  1146. if (isset($post['page'])) {
  1147. $page = $this->input->post('page', true);
  1148. $perpage = $this->input->post('perpage', true);
  1149. $category = $this->input->post('category', true);
  1150. $size = $this->input->post('size', true);
  1151. $grade = $this->input->post('grade', true);
  1152. $color = $this->input->post('color', true);
  1153. $lowe = $this->input->post('lowe', true);
  1154. $sku = $this->input->post('sku');
  1155. $title = $this->input->post('title');
  1156. $warehouse = $this->input->post('warehouse', true);
  1157. $usa = $this->input->post('usa', true);
  1158. $purchase = $this->input->post('purchase', true);
  1159. $lacetype = $this->input->post('lacetype', true);
  1160. $haircap = $this->input->post('haircap', true);
  1161. $density = $this->input->post('density', true);
  1162. $details = $this->input->post('details', true);
  1163. $state = $this->input->post('state', true);
  1164. $shop = $this->input->post('shop', true);
  1165. $lacecolor = $this->input->post('lacecolor', true);
  1166. $hairnumber = $this->input->post('hairnumber', true);
  1167. $type = $this->input->post('type', true);
  1168. $ktime = $this->input->post('ktime', true);
  1169. $jtime = $this->input->post('jtime', true);
  1170. $ktime = strtotime($ktime);
  1171. $jtime = strtotime($jtime);
  1172. $cpbz = $this->input->post('cpbz', true);
  1173. $where = "1=1";
  1174. $gj = "";
  1175. $ck = "";
  1176. if ($usa) {
  1177. if (!$warehouse) {
  1178. $where .= " and (warehouse = '5' or warehouse = '8')";
  1179. }
  1180. }
  1181. if ($warehouse) {
  1182. $where .= " and warehouse = '$warehouse'";
  1183. }
  1184. if ($details) {
  1185. $where .= " and details = '$details'";
  1186. }
  1187. if ($purchase) {
  1188. $where .= " and purchase = '$purchase'";
  1189. }
  1190. if ($state) {
  1191. $where .= " and state = '$state'";
  1192. }
  1193. if ($shop) {
  1194. $where .= " and shop like '%$shop%'";
  1195. }
  1196. if ($type) {
  1197. $where .= " and type = '$type'";
  1198. }
  1199. if ($ktime && $jtime) {
  1200. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1201. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1202. }
  1203. if ($cpbz) {
  1204. $where .= " and cpbz like '%$cpbz%' ";
  1205. }
  1206. if ($lacecolor) {
  1207. $where .= " and features like '%-$lacecolor-%'";
  1208. }
  1209. if ($lacetype) {
  1210. $where .= " and features like '%-$lacetype-%'";
  1211. }
  1212. if ($category) {
  1213. $where .= " and features like '%-$category-%'";
  1214. }
  1215. if ($size) {
  1216. $where .= " and features like '%-$size-%'";
  1217. }
  1218. if ($grade) {
  1219. $where .= " and features like '%-$grade-%'";
  1220. }
  1221. if ($color) {
  1222. $where .= " and features like '%-$color-%'";
  1223. }
  1224. if ($lowe) {
  1225. $where .= " and features like '%-$lowe-%'";
  1226. }
  1227. if ($haircap) {
  1228. $where .= " and features like '%-$haircap-%'";
  1229. }
  1230. if ($density) {
  1231. $where .= " and features like '%-$density-%'";
  1232. }
  1233. if (!empty($hairnumber)) {
  1234. $where .= " and features like '%-128-%' ";
  1235. if ($hairnumber < 0) {
  1236. $class_list = $this->typeclass->find_all('classid = 43');
  1237. foreach ($class_list as $v) {
  1238. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1239. }
  1240. } else {
  1241. $where .= " and features like '%-$hairnumber-%'";
  1242. }
  1243. }
  1244. //数据排序
  1245. $order_str = "id desc";
  1246. if (empty($page)) {
  1247. $start = 0;
  1248. $perpage = 1;
  1249. } else {
  1250. $start = ($page - 1) * $perpage;
  1251. }
  1252. $fjnr = '';
  1253. if ($sku) {
  1254. $sku = trim($sku, ' ');
  1255. $sku = trim($sku, ' ');
  1256. $fjnr .= " and sku like '%$sku%'";
  1257. }
  1258. if ($title) {
  1259. $title = trim($title, ' ');
  1260. $title = trim($title, ' ');
  1261. $fjnr .= " and title like '%$title%'";
  1262. }
  1263. $wt = array();
  1264. $whlabel_type = $this->whlabel_type->find_all();
  1265. foreach ($whlabel_type as $v) {
  1266. $wt[$v['id']] = $v['title'];
  1267. }
  1268. //$where .= " and time > '$ktime' and time < '$jtime'";
  1269. $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
  1270. //取得信息列表
  1271. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1272. $rows = array();
  1273. $list = array();
  1274. foreach ($info_list as $key => $value) {
  1275. if (isset($wt[$value['type']])) {
  1276. $info_list[$key]['type'] = $wt[$value['type']];
  1277. } else {
  1278. $info_list[$key]['type'] = '未设置';
  1279. }
  1280. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1281. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1282. $ztdata = '';
  1283. if (count($zt) > 0) {
  1284. foreach ($zt as $vv) {
  1285. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1286. }
  1287. }
  1288. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1289. $cdata = array_filter($qbdata, function ($item) {
  1290. return $item['state'] < 1;
  1291. });
  1292. $c = array_sum(array_column($cdata, 'jnum'));
  1293. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1294. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1295. });
  1296. $g = array_sum(array_column($gdata, 'jnum'));
  1297. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1298. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1299. });
  1300. $x = array_sum(array_column($xdata, 'jnum'));
  1301. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1302. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1303. });
  1304. $t = array_sum(array_column($tdata, 'jnum'));
  1305. $zdata = array_filter($qbdata, function ($item) {
  1306. return $item['zd'] != "" && $item['state'] < 1;
  1307. });
  1308. $z = array_sum(array_column($zdata, 'jnum'));
  1309. $zdata = array_filter($qbdata, function ($item) {
  1310. return $item['zd'] != "" && $item['state'] < 1;
  1311. });
  1312. $z = array_sum(array_column($zdata, 'jnum'));
  1313. //$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');
  1314. //$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'].'"');
  1315. //$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'].'"');
  1316. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1317. //$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'].'"');
  1318. $details = array();
  1319. $cpid = array();
  1320. $od = array();
  1321. $odid = '';
  1322. $companytitle = '';
  1323. foreach ($qbdata as $v) {
  1324. if ($v['zd'] != "" && $v['state'] < 1) {
  1325. if (!isset($od[$v['zd']])) {
  1326. $od[$v['zd']] = 1; //所有数据sku
  1327. } else {
  1328. $od[$v['zd']] = $od[$v['zd']] + 1;
  1329. }
  1330. }
  1331. if ($v['state'] < 1) {
  1332. $details[$v['details']] = $v['details'];
  1333. if ($v['cpid'] != 0) {
  1334. $cpid[$v['cpid']] = $v['cpid'];
  1335. }
  1336. }
  1337. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1338. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1339. }
  1340. }
  1341. foreach ($od as $k => $vv) {
  1342. $odid .= $k . '数量' . $vv;
  1343. }
  1344. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  1345. $number = $value['number'];
  1346. $ftime = time() - 15 * 24 * 3600;
  1347. $z = $z . '(' . $odid . ')'; //查看订单号
  1348. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1349. $info_list[$key]['features'] = $c;
  1350. $info_list[$key]['number'] = $ztdata;
  1351. $info_list[$key]['sm'] = $g;
  1352. $info_list[$key]['x'] = $x;
  1353. $info_list[$key]['t'] = $t;
  1354. $info_list[$key]['z'] = $z;
  1355. /**
  1356. foreach ($cdata as $k=>$v)
  1357. {
  1358. $details[$v['details']] = $v['details'];
  1359. if($v['cpid'] != 0)
  1360. {
  1361. $cpid[$v['cpid']] = $v['cpid'];
  1362. }
  1363. }
  1364. **/
  1365. $info_list[$key]['shop'] = '';
  1366. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1367. if ($value['shop'] != '') {
  1368. $shop = explode(',', trim($value['shop'], ','));
  1369. $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1370. }
  1371. $info_list[$key]['shop'] .= $companytitle;
  1372. /**
  1373. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1374. if(isset($companytitle[0]))
  1375. {
  1376. foreach ($companytitle as $k=>$v)
  1377. {
  1378. if($v['companytitle'] != '')
  1379. {
  1380. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1381. }
  1382. }
  1383. }
  1384. **/
  1385. }
  1386. $final_all_list = [];
  1387. foreach ($info_list as $k => $v) {
  1388. $final_all_list[] = [
  1389. 'id' => $v['id'],
  1390. "warehouse" => $v["warehouse"],
  1391. "purchase" => $v["purchase"],
  1392. "sku" => $v["sku"],
  1393. "title" => $v["title"] . "<br/>" . $v["pm"],
  1394. "details" => $v["details"],
  1395. "shop" => $v["shop"],
  1396. "cpbz" => $v["cpbz"],
  1397. "type" => $v["type"],
  1398. "features" => $v["features"],
  1399. "number" => $v["number"],
  1400. "sm" => $v["sm"],
  1401. "x" => $v["x"],
  1402. "t" => $v["t"],
  1403. "z" => $v["z"]
  1404. ];
  1405. }
  1406. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1407. $pagenum = ceil($total / $perpage);
  1408. $over = $total - ($start + $perpage);
  1409. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1410. echo json_encode($rows);
  1411. exit;
  1412. }
  1413. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1414. $this->data['shop'] = $wlshop;
  1415. $this->data['vip'] = $vip;
  1416. $this->_Template('whlabel_type', $this->data);
  1417. }
  1418. //美仓进销存浏览
  1419. public function _usatype()
  1420. {
  1421. if (isset($_SESSION['api'])) {
  1422. $user = $this->user->get_api($_SESSION['api']);
  1423. $usp = $user;
  1424. $fgshop = "";
  1425. $sid = "";
  1426. $wid = "";
  1427. $wtype = "";
  1428. $userwh = explode('|', trim($user['warehouse'], '|'));
  1429. foreach ($userwh as $value) {
  1430. $wid .= " id = " . $value . " or";
  1431. $wtype .= " type = " . $value . " or";
  1432. }
  1433. }
  1434. $prc = array();
  1435. $purchase = $this->purchase->find_all();
  1436. foreach ($purchase as $k => $v) {
  1437. $prc[$v['id']] = $v['title'];
  1438. }
  1439. $post = $this->input->post(NULL, TRUE);
  1440. if (isset($post['page'])) {
  1441. $page = $this->input->post('page', true);
  1442. $perpage = $this->input->post('perpage', true);
  1443. $category = $this->input->post('category', true);
  1444. $size = $this->input->post('size', true);
  1445. $grade = $this->input->post('grade', true);
  1446. $color = $this->input->post('color', true);
  1447. $lowe = $this->input->post('lowe', true);
  1448. $sku = $this->input->post('sku');
  1449. $title = $this->input->post('title');
  1450. $warehouse = $this->input->post('warehouse', true);
  1451. $usa = $this->input->post('usa', true);
  1452. $purchase = $this->input->post('purchase', true);
  1453. $lacetype = $this->input->post('lacetype', true);
  1454. $haircap = $this->input->post('haircap', true);
  1455. $density = $this->input->post('density', true);
  1456. $details = $this->input->post('details', true);
  1457. $state = $this->input->post('state', true);
  1458. $lacecolor = $this->input->post('lacecolor', true);
  1459. $cklx = $this->input->post('cklx', true);
  1460. $ktime = $this->input->post('ktime', true);
  1461. $jtime = $this->input->post('jtime', true);
  1462. $ktime = strtotime($ktime);
  1463. $jtime = strtotime($jtime);
  1464. $where = "1=1";
  1465. $gj = "";
  1466. $ck = "";
  1467. if ($lacetype) {
  1468. $where .= " and features like '%-$lacetype-%'";
  1469. }
  1470. if ($category) {
  1471. $where .= " and features like '%-$category-%'";
  1472. }
  1473. if ($size) {
  1474. $where .= " and features like '%-$size-%'";
  1475. }
  1476. if ($grade) {
  1477. $where .= " and features like '%-$grade-%'";
  1478. }
  1479. if ($color) {
  1480. $where .= " and features like '%-$color-%'";
  1481. }
  1482. if ($lowe) {
  1483. $where .= " and features like '%-$lowe-%'";
  1484. }
  1485. if ($haircap) {
  1486. $where .= " and features like '%-$haircap-%'";
  1487. }
  1488. if ($density) {
  1489. $where .= " and features like '%-$density-%'";
  1490. }
  1491. if ($lacecolor) {
  1492. $where .= " and features like '%-$lacecolor-%'";
  1493. }
  1494. if ($usa) {
  1495. if (!$warehouse) {
  1496. $where .= " and (warehouse = '5' or warehouse = '8')";
  1497. }
  1498. }
  1499. if ($warehouse) {
  1500. $where .= " and warehouse = '$warehouse'";
  1501. }
  1502. if ($details) {
  1503. $where .= " and details = '$details'";
  1504. }
  1505. if ($purchase) {
  1506. $where .= " and purchase = '$purchase'";
  1507. }
  1508. if ($state) {
  1509. $where .= " and state = '$state'";
  1510. }
  1511. $where_add = '';
  1512. if ($cklx) {
  1513. $shop = $this->shop->read($cklx);
  1514. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1515. }
  1516. if ($ktime && $jtime) {
  1517. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1518. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1519. }
  1520. //数据排序
  1521. $order_str = "id desc";
  1522. if (empty($page)) {
  1523. $start = 0;
  1524. $perpage = 1;
  1525. } else {
  1526. $start = ($page - 1) * $perpage;
  1527. }
  1528. if ($sku) {
  1529. $sku = trim($sku, ' ');
  1530. $sku = trim($sku, ' ');
  1531. $where .= " and sku like '%$sku%'";
  1532. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1533. } else if ($title) {
  1534. $title = trim($title, ' ');
  1535. $title = trim($title, ' ');
  1536. $where .= " and title like '%$title%'";
  1537. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1538. } else {
  1539. //$where .= " and time > '$ktime' and time < '$jtime'";
  1540. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1541. }
  1542. //取得信息列表
  1543. $rows = array();
  1544. $list = array();
  1545. foreach ($info_list as $key => $value) {
  1546. $warehouse = $this->warehouse->read($value['warehouse']);
  1547. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1548. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1549. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1550. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1551. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1552. $od = array();
  1553. $odid = '';
  1554. foreach ($z as $v) {
  1555. if (!isset($od[$v['zd']])) {
  1556. $od[$v['zd']] = 1; //所有数据sku
  1557. } else {
  1558. $od[$v['zd']] = $od[$v['zd']] + 1;
  1559. }
  1560. }
  1561. foreach ($od as $k => $vv) {
  1562. $odid .= $k . '数量' . $vv . ' ';
  1563. }
  1564. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1565. $info_list[$key]['features'] = $c;
  1566. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1567. $ztdata = '';
  1568. if (count($zt) > 0) {
  1569. foreach ($zt as $vv) {
  1570. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1571. }
  1572. }
  1573. $info_list[$key]['warehouse'] = $ztdata;
  1574. $info_list[$key]['g'] = $g;
  1575. $info_list[$key]['x'] = $x;
  1576. $info_list[$key]['t'] = $t;
  1577. $info_list[$key]['z'] = $z;
  1578. }
  1579. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1580. $pagenum = ceil($total / $perpage);
  1581. $over = $total - ($start + $perpage);
  1582. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1583. echo json_encode($rows);
  1584. exit;
  1585. }
  1586. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1587. $this->data['warehouse'] = $warehouse;
  1588. $this->_Template('whlabel_typeusa', $this->data);
  1589. }
  1590. //美仓进销存浏览
  1591. public function _usatypeapp()
  1592. {
  1593. $post = $this->input->post(NULL, TRUE);
  1594. if (isset($post['page'])) {
  1595. $page = $this->input->post('page', true);
  1596. $perpage = $this->input->post('perpage', true);
  1597. $sku = $this->input->post('sku', true);
  1598. $warehouse = 5;
  1599. $title = $this->input->post('title', true);
  1600. $state = $this->input->post('state', true);
  1601. $ktime = $this->input->post('ktime', true);
  1602. $jtime = $this->input->post('jtime', true);
  1603. $ktime = strtotime($ktime);
  1604. $jtime = strtotime($jtime);
  1605. $where = "1=1";
  1606. $gj = "";
  1607. $ck = "";
  1608. if ($title) {
  1609. $st = explode(' ', trim($title, ' '));
  1610. foreach ($st as $v) {
  1611. $where .= " and title like '%$v%'";
  1612. }
  1613. }
  1614. if ($warehouse) {
  1615. $where .= " and warehouse = '$warehouse'";
  1616. }
  1617. if ($state) {
  1618. $where .= " and state = '$state'";
  1619. }
  1620. if ($sku) {
  1621. $where .= " and sku like '%$sku%'";
  1622. }
  1623. if ($ktime && $jtime) {
  1624. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1625. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1626. }
  1627. //数据排序
  1628. $order_str = "id desc";
  1629. if (empty($page)) {
  1630. $start = 0;
  1631. $perpage = 1;
  1632. } else {
  1633. $start = ($page - 1) * $perpage;
  1634. }
  1635. //取得信息列表
  1636. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1637. $rows = array();
  1638. $list = array();
  1639. foreach ($info_list as $key => $value) {
  1640. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1641. }
  1642. $rowsdq = array_slice($rows, $start, $perpage);
  1643. foreach ($rowsdq as $value) {
  1644. $warehouse = $this->warehouse->read($value['warehouse']);
  1645. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1646. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1647. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1648. $od = array();
  1649. $odid = '';
  1650. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1651. }
  1652. $total = count($rows);
  1653. $pagenum = ceil($total / $perpage);
  1654. $over = $total - ($start + $perpage);
  1655. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1656. echo json_encode($rows);
  1657. exit;
  1658. }
  1659. $this->_Template('phone/p_usatypeapp', $this->data);
  1660. }
  1661. //入库操作
  1662. public function _enteradd()
  1663. {
  1664. $dt = 0;
  1665. if (isset($_SESSION['api'])) {
  1666. $user = $this->user->get_api($_SESSION['api']);
  1667. $usp = $user;
  1668. $fgshop = "";
  1669. $sid = "";
  1670. $user = explode('|', trim($user['shop'], '|'));
  1671. foreach ($user as $value) {
  1672. $fgshop .= " shop = " . $value . " or";
  1673. $sid .= " id = " . $value . " or";
  1674. }
  1675. }
  1676. $tc = $this->typeclass->find_all();
  1677. $typeclass = array();
  1678. foreach ($tc as $v) {
  1679. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1680. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1681. }
  1682. $post = $this->input->post(NULL, TRUE);
  1683. if (isset($post['sku'])) {
  1684. $list = array();
  1685. $num = "";
  1686. $title = "";
  1687. $features = "";
  1688. $order = $this->input->post('order', true);
  1689. $shop = $this->input->post('shop', true);
  1690. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1691. $sku = $this->input->post('sku', true);
  1692. $post['sm'] = $this->input->post('sm', true);
  1693. $post['warehouse'] = $this->input->post('warehouse', true);
  1694. $post['purchase'] = $this->input->post('purchase', true);
  1695. $post['retreatwarehouse'] = $post['warehouse'];
  1696. $post['state'] = $this->input->post('state', true);
  1697. $post['rktype'] = $this->input->post('rktype', true);
  1698. $post['text'] = $this->input->post('text', true);
  1699. $category = $this->input->post('category', true);
  1700. $list['category'] = $category;
  1701. $list['hairtype'] = $this->input->post('hairtype', true);
  1702. $list['grade'] = $this->input->post('grade', true);
  1703. $size = $this->input->post('size', true);
  1704. $xzsku = $this->input->post('xzsku', true);
  1705. $list['size'] = rtrim($size, ',');
  1706. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1707. $list['extension'] = $this->input->post('extension', true);
  1708. if ($category == 1297) {
  1709. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1710. }
  1711. if ($category == 1702) {
  1712. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1713. $list['syother'] = $this->input->post('syother', true);
  1714. }
  1715. if ($category == 133) {
  1716. $list['fittype'] = $this->input->post('fittype', true);
  1717. $list['acother'] = $this->input->post('acother', true);
  1718. }
  1719. $list['color'] = $this->input->post('color', true);
  1720. $list['lowe'] = $this->input->post('lowe', true);
  1721. if (!$post['purchase']) {
  1722. $post['purchase'] = 1;
  1723. }
  1724. if ($category == 127) {
  1725. $list['type'] = $this->input->post('type', true);
  1726. $list['headroad'] = $this->input->post('headroad', true);
  1727. $list['density'] = $this->input->post('density', true);
  1728. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1729. $list['lacesize'] = $this->input->post('lacesize', true);
  1730. }
  1731. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1732. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1733. }
  1734. if ($category == 128) {
  1735. $list['lacetype'] = $this->input->post('lacetype', true);
  1736. $list['haircap'] = $this->input->post('haircap', true);
  1737. $list['density'] = $this->input->post('density', true);
  1738. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1739. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1740. $list['wigother'] = $this->input->post('wigother', true);
  1741. $list['wigother2'] = $this->input->post('wigother2', true);
  1742. }
  1743. if ($category == 129) {
  1744. $list['wide'] = $this->input->post('wide', true);
  1745. }
  1746. if ($category == 131) {
  1747. $list['gifttype'] = $this->input->post('gifttype', true);
  1748. $list['giftother'] = $this->input->post('giftother', true);
  1749. }
  1750. if ($category == 134) {
  1751. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1752. }
  1753. if ($category == 1297) {
  1754. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1755. $list['sywigother'] = $this->input->post('sywigother', true);
  1756. }
  1757. if ($category == 130 || $category == 133 || $category == 1702) {
  1758. $list['items'] = $this->input->post('items', true);
  1759. $list['weight'] = $this->input->post('weight', true);
  1760. }
  1761. if ($category == 1702) {
  1762. $list['syhairther'] = $this->input->post('syhairther', true);
  1763. }
  1764. $classid = $this->classid->sku();
  1765. $scsku = $classid;
  1766. $pm = $classid;
  1767. foreach ($list as $k => $v) {
  1768. if ($v != 0) {
  1769. $num .= $v;
  1770. $features .= $v . '-';
  1771. $post[$k] = $v;
  1772. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1773. if ($k != 'size') {
  1774. $title .= $typeclass[$v]['title'] . " ";
  1775. }
  1776. if (isset($pm[$typeclass[$v]['classid']])) {
  1777. if ($typeclass[$v]['title'] == '9A') {
  1778. $pm[$typeclass[$v]['classid']] = '9A';
  1779. } else if ($typeclass[$v]['title'] == '10A') {
  1780. $pm[$typeclass[$v]['classid']] = '10A';
  1781. } else {
  1782. $clzh = $typeclass[$v]['zh'];
  1783. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1784. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1785. $clzh = $clzh[0];
  1786. }
  1787. $pm[$typeclass[$v]['classid']] = $clzh;
  1788. }
  1789. }
  1790. }
  1791. }
  1792. $zh = implode(" ", $pm);
  1793. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1794. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1795. if ($list['size']) {
  1796. $typeclass = $this->typeclass->read($list['size']);
  1797. $title .= $typeclass['title'];
  1798. }
  1799. $time = time();
  1800. if ($xzsku) {
  1801. $scsku = implode("-", $scsku);
  1802. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1803. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1804. $post['sku'] = trim($scsku, ' ');
  1805. } else {
  1806. $post['sku'] = $sku;
  1807. }
  1808. //$post['sku'] = trim($sku,' ');
  1809. $post['title'] = rtrim($title, ' ');
  1810. $post['number'] = $num;
  1811. $post['features'] = '-' . $features;
  1812. $post['enter'] = $time;
  1813. $post['time'] = $time; //操作时间
  1814. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1815. if ($yza) {
  1816. if ($post['features'] != $yza[0]['features']) {
  1817. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1818. exit;
  1819. }
  1820. }
  1821. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1822. if ($yzb) {
  1823. if ($post['sku'] != $yzb[0]['sku']) {
  1824. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1825. exit;
  1826. }
  1827. }
  1828. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1829. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1830. exit;
  1831. }
  1832. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1833. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1834. exit;
  1835. }
  1836. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1837. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1838. exit;
  1839. }
  1840. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1841. if (isset($yz[0]['type'])) {
  1842. $post['type'] = $yz[0]['type'];
  1843. }
  1844. if ($post['state'] == 9) //如果选择预设库存
  1845. {
  1846. $this->whlabel->insert($post);
  1847. } else {
  1848. /**
  1849. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1850. if($ljg == 1)
  1851. {
  1852. for($i=0;$i<$order;$i++)
  1853. {
  1854. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1855. $this->whlabel->insert($post);
  1856. }
  1857. }
  1858. **/
  1859. //if($post['warehouse'] == '5')
  1860. //{
  1861. //}
  1862. $yydata = $post;
  1863. $yydata['zh'] = $zh;
  1864. /**
  1865. $wl = $this->apiyy->get_cjlp($yydata);
  1866. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1867. {
  1868. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1869. }
  1870. if($wl['Data'][0]['m_isSucess'] != 1)
  1871. {
  1872. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1873. }
  1874. **/
  1875. for ($i = 0; $i < $order; $i++) {
  1876. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1877. $this->whlabel->insert($post);
  1878. }
  1879. }
  1880. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1881. exit;
  1882. }
  1883. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1884. $this->data['wlshop'] = $wlshop;
  1885. $this->_Template('whlabel_enteradd', $this->data);
  1886. }
  1887. //修改产品
  1888. public function _enteredit($arg_array)
  1889. {
  1890. $dt = 0;
  1891. if (isset($_SESSION['api'])) {
  1892. $user = $this->user->get_api($_SESSION['api']);
  1893. $usp = $user;
  1894. $fgshop = "";
  1895. $sid = "";
  1896. $user = explode('|', trim($user['shop'], '|'));
  1897. foreach ($user as $value) {
  1898. $fgshop .= " shop = " . $value . " or";
  1899. $sid .= " id = " . $value . " or";
  1900. }
  1901. }
  1902. $post = $this->input->post(NULL, TRUE);
  1903. if (isset($post['sku'])) {
  1904. $list = array();
  1905. $num = "";
  1906. $title = "";
  1907. $features = "";
  1908. $id = $this->input->post('id', true);
  1909. $order = $this->input->post('order', true);
  1910. $shop = $this->input->post('shop', true);
  1911. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1912. $post['sku'] = $this->input->post('sku', true);
  1913. $post['sm'] = $this->input->post('sm', true);
  1914. $post['warehouse'] = $this->input->post('warehouse', true);
  1915. $post['purchase'] = $this->input->post('purchase', true);
  1916. $post['retreatwarehouse'] = $post['warehouse'];
  1917. $category = $this->input->post('category', true);
  1918. $list['category'] = $category;
  1919. $list['hairtype'] = $this->input->post('hairtype', true);
  1920. $list['grade'] = $this->input->post('grade', true);
  1921. $size = $this->input->post('size', true);
  1922. $list['size'] = rtrim($size, ',');
  1923. $post['rktype'] = $this->input->post('rktype', true);
  1924. $post['text'] = $this->input->post('text', true);
  1925. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1926. $list['extension'] = $this->input->post('extension', true);
  1927. if ($category == 1297) {
  1928. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1929. }
  1930. if ($category == 1702) {
  1931. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1932. $list['syother'] = $this->input->post('syother', true);
  1933. }
  1934. if ($category == 133) {
  1935. $list['fittype'] = $this->input->post('fittype', true);
  1936. $list['acother'] = $this->input->post('acother', true);
  1937. }
  1938. $list['color'] = $this->input->post('color', true);
  1939. $list['lowe'] = $this->input->post('lowe', true);
  1940. if (!$post['purchase']) {
  1941. $post['purchase'] = 1;
  1942. }
  1943. if ($category == 127) {
  1944. $list['type'] = $this->input->post('type', true);
  1945. $list['headroad'] = $this->input->post('headroad', true);
  1946. $list['density'] = $this->input->post('density', true);
  1947. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1948. $list['lacesize'] = $this->input->post('lacesize', true);
  1949. }
  1950. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1951. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1952. }
  1953. if ($category == 128) {
  1954. $list['lacetype'] = $this->input->post('lacetype', true);
  1955. $list['haircap'] = $this->input->post('haircap', true);
  1956. $list['density'] = $this->input->post('density', true);
  1957. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1958. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1959. $list['wigother'] = $this->input->post('wigother', true);
  1960. $list['wigother2'] = $this->input->post('wigother2', true);
  1961. }
  1962. if ($category == 129) {
  1963. $list['wide'] = $this->input->post('wide', true);
  1964. }
  1965. if ($category == 131) {
  1966. $list['gifttype'] = $this->input->post('gifttype', true);
  1967. $list['giftother'] = $this->input->post('giftother', true);
  1968. }
  1969. if ($category == 134) {
  1970. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1971. }
  1972. if ($category == 1297) {
  1973. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1974. $list['sywigother'] = $this->input->post('sywigother', true);
  1975. }
  1976. if ($category == 130 || $category == 133 || $category == 1702) {
  1977. $list['items'] = $this->input->post('items', true);
  1978. $list['weight'] = $this->input->post('weight', true);
  1979. }
  1980. if ($category == 1702) {
  1981. $list['syhairther'] = $this->input->post('syhairther', true);
  1982. }
  1983. foreach ($list as $k => $v) {
  1984. if ($v != 0) {
  1985. $num .= $v;
  1986. $features .= $v . '-';
  1987. $typeclass = $this->typeclass->read($v);
  1988. if ($k != 'size') {
  1989. $title .= $typeclass['title'] . " ";
  1990. }
  1991. }
  1992. }
  1993. $typeclass = $this->typeclass->read($list['size']);
  1994. $title .= $typeclass['title'];
  1995. $time = time();
  1996. $post['title'] = rtrim($title, ' ');
  1997. $post['number'] = $num;
  1998. $post['features'] = '-' . $features;
  1999. $post['time'] = $time; //操作时间
  2000. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2001. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2002. exit;
  2003. }
  2004. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2005. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2006. exit;
  2007. }
  2008. $uid = $this->whlabel->read($id);
  2009. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2010. if ($datanum > 0) {
  2011. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2012. exit;
  2013. }
  2014. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2015. {
  2016. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2017. if ($yza) {
  2018. if ($post['features'] != $yza[0]['features']) {
  2019. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2020. exit;
  2021. }
  2022. }
  2023. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2024. if ($yzb) {
  2025. if ($post['sku'] != $yzb[0]['sku']) {
  2026. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2027. exit;
  2028. }
  2029. }
  2030. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2031. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2032. exit;
  2033. }
  2034. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2035. foreach ($data as $v) {
  2036. $post['id'] = $v['id'];
  2037. $this->whlabel->save($post, $v['id']);
  2038. }
  2039. } else {
  2040. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2041. if ($data > 0) {
  2042. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2043. exit;
  2044. } else {
  2045. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2046. foreach ($data as $v) {
  2047. $post['id'] = $v['id'];
  2048. $this->whlabel->save($post, $v['id']);
  2049. }
  2050. }
  2051. }
  2052. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2053. exit;
  2054. }
  2055. $uid = $this->whlabel->read($arg_array[0]);
  2056. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2057. $this->data['enter'] = $uid;
  2058. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2059. $this->data['wlshop'] = $wlshop;
  2060. $this->_Template('whlabel_enteredit', $this->data);
  2061. }
  2062. //入库浏览
  2063. public function _enter()
  2064. {
  2065. $post = $this->input->post(NULL, TRUE);
  2066. if (isset($post['s'])) {
  2067. $id_arr = $this->input->post('s');
  2068. $id_arr = explode(',', $id_arr);
  2069. if (!$id_arr) {
  2070. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2071. exit;
  2072. }
  2073. //循环删除记录
  2074. foreach ($id_arr as $v) {
  2075. $sid = $this->whlabel->read($v);
  2076. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2077. if ($count > 0) {
  2078. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2079. exit;
  2080. }
  2081. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2082. foreach ($info_list as $va) {
  2083. $this->whlabel->remove($va['id']);
  2084. }
  2085. }
  2086. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2087. exit;
  2088. }
  2089. $sp = array();
  2090. $s = $this->shop->find_all('1=1', 'id,shopname');
  2091. foreach ($s as $v) {
  2092. $sp[$v['id']] = $v['shopname'];
  2093. }
  2094. $wh = array();
  2095. $w = $this->warehouse->find_all('1=1', 'id,title');
  2096. foreach ($w as $v) {
  2097. $wh[$v['id']] = $v['title'];
  2098. }
  2099. if (isset($post['page'])) {
  2100. $page = $this->input->post('page', true);
  2101. $perpage = $this->input->post('perpage', true);
  2102. $category = $this->input->post('category', true);
  2103. $size = $this->input->post('size', true);
  2104. $grade = $this->input->post('grade', true);
  2105. $color = $this->input->post('color', true);
  2106. $lowe = $this->input->post('lowe', true);
  2107. $sku = $this->input->post('sku', true);
  2108. $warehouse = $this->input->post('warehouse', true);
  2109. $purchase = $this->input->post('purchase', true);
  2110. $ktime = $this->input->post('ktime', true);
  2111. $jtime = $this->input->post('jtime', true);
  2112. $ktime = strtotime($ktime);
  2113. $jtime = strtotime($jtime);
  2114. $where = "1=1";
  2115. $gj = "";
  2116. $ck = "";
  2117. if ($category) {
  2118. $where .= " and features like '%-$category-%'";
  2119. }
  2120. if ($size) {
  2121. $where .= " and features like '%-$size-%'";
  2122. }
  2123. if ($grade) {
  2124. $where .= " and features like '%-$grade-%'";
  2125. }
  2126. if ($color) {
  2127. $where .= " and features like '%-$color-%'";
  2128. }
  2129. if ($lowe) {
  2130. $where .= " and features like '%-$lowe-%'";
  2131. }
  2132. if ($warehouse) {
  2133. $where .= " and warehouse = '$warehouse'";
  2134. }
  2135. if ($purchase) {
  2136. $where .= " and purchase = '$purchase'";
  2137. }
  2138. if ($sku) {
  2139. $where .= " and sku like '%$sku%'";
  2140. }
  2141. if ($ktime && $jtime) {
  2142. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2143. }
  2144. //数据排序
  2145. $order_str = "enter desc";
  2146. if (empty($page)) {
  2147. $start = 0;
  2148. $perpage = 1;
  2149. } else {
  2150. $start = ($page - 1) * $perpage;
  2151. }
  2152. //取得信息列表
  2153. $info_list = $this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2154. foreach ($info_list as $k => $v) {
  2155. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2156. if ($v['shop'] == '') {
  2157. $s = '通用';
  2158. } else {
  2159. $info_list[$k]['shop'] = '';
  2160. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2161. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2162. }
  2163. }
  2164. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2165. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2166. $info_list[$k]['g'] = $g;
  2167. }
  2168. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2169. $pagenum = ceil($total / $perpage);
  2170. $over = $total - ($start + $perpage);
  2171. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2172. echo json_encode($rows);
  2173. exit;
  2174. }
  2175. $this->_Template('whlabel_enter', $this->data);
  2176. }
  2177. //出库浏览
  2178. public function _out()
  2179. {
  2180. $post = $this->input->post(NULL, TRUE);
  2181. if (isset($post['page'])) {
  2182. $page = $this->input->post('page', true);
  2183. $perpage = $this->input->post('perpage', true);
  2184. $category = $this->input->post('category', true);
  2185. $size = $this->input->post('size', true);
  2186. $grade = $this->input->post('grade', true);
  2187. $color = $this->input->post('color', true);
  2188. $lowe = $this->input->post('lowe', true);
  2189. $sku = $this->input->post('sku', true);
  2190. $warehouse = $this->input->post('warehouse', true);
  2191. $purchase = $this->input->post('purchase', true);
  2192. $state = $this->input->post('state', true);
  2193. $ktime = $this->input->post('ktime', true);
  2194. $jtime = $this->input->post('jtime', true);
  2195. $ktime = strtotime($ktime);
  2196. $jtime = strtotime($jtime);
  2197. $where = "state=3";
  2198. $gj = "";
  2199. $ck = "";
  2200. if ($category) {
  2201. $where .= " and features like '%-$category-%'";
  2202. }
  2203. if ($size) {
  2204. $where .= " and features like '%-$size-%'";
  2205. }
  2206. if ($grade) {
  2207. $where .= " and features like '%-$grade-%'";
  2208. }
  2209. if ($color) {
  2210. $where .= " and features like '%-$color-%'";
  2211. }
  2212. if ($lowe) {
  2213. $where .= " and features like '%-$lowe-%'";
  2214. }
  2215. if ($state) {
  2216. $where .= " and state = '$state'";
  2217. }
  2218. if ($warehouse) {
  2219. $where .= " and warehouse = '$warehouse'";
  2220. }
  2221. if ($purchase) {
  2222. $where .= " and purchase = '$purchase'";
  2223. }
  2224. if ($sku) {
  2225. $where .= " and sku = '$sku'";
  2226. }
  2227. if ($ktime && $jtime) {
  2228. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2229. }
  2230. //数据排序
  2231. $order_str = "id desc";
  2232. if (empty($page)) {
  2233. $start = 0;
  2234. $perpage = 1;
  2235. } else {
  2236. $start = ($page - 1) * $perpage;
  2237. }
  2238. //取得信息列表
  2239. $info_list = $this->whlabel->find_all($where, 'sku');
  2240. $rows = array();
  2241. $list = array();
  2242. foreach ($info_list as $key => $value) {
  2243. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2244. }
  2245. $rows = array_unique($rows); //删除重复记录
  2246. foreach ($rows as $key => $value) {
  2247. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2248. $ck = $this->warehouse->read($data['warehouse']);
  2249. $warehouse = $ck['title'];
  2250. $gy = $this->purchase->read($data['purchase']);
  2251. $purchase = $gy['purchase'];
  2252. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2253. $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);
  2254. }
  2255. $total = count($list);
  2256. $pagenum = ceil($total / $perpage);
  2257. $over = $total - ($start + $perpage);
  2258. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2259. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2260. echo json_encode($rows);
  2261. exit;
  2262. }
  2263. $this->_Template('whlabel_out', $this->data);
  2264. }
  2265. //出库标签浏览
  2266. public function _label()
  2267. {
  2268. $post = $this->input->post(NULL, TRUE);
  2269. if (isset($post['page'])) {
  2270. $page = $this->input->post('page', true);
  2271. $perpage = $this->input->post('perpage', true);
  2272. $sku = $this->input->post('sku', true);
  2273. $warehouse = $this->input->post('warehouse', true);
  2274. $purchase = $this->input->post('purchase', true);
  2275. $orderinfo = $this->input->post('orderinfo', true);
  2276. $waybill = $this->input->post('waybill', true);
  2277. $category = $this->input->post('category', true);
  2278. $size = $this->input->post('size', true);
  2279. $grade = $this->input->post('grade', true);
  2280. $color = $this->input->post('color', true);
  2281. $lowe = $this->input->post('lowe', true);
  2282. $where = "state=1";
  2283. if ($sku) {
  2284. $where .= " and sku = '$sku'";
  2285. }
  2286. if ($warehouse) {
  2287. $where .= " and warehouse = '$warehouse'";
  2288. }
  2289. if ($purchase) {
  2290. $where .= " and purchase = '$purchase'";
  2291. }
  2292. if ($orderinfo) {
  2293. $where .= " and orderinfo = '$orderinfo'";
  2294. }
  2295. if ($waybill) {
  2296. $where .= " and waybill = '$waybill'";
  2297. }
  2298. if ($category) {
  2299. $where .= " and features like '%-$category-%'";
  2300. }
  2301. if ($size) {
  2302. $where .= " and features like '%-$size-%'";
  2303. }
  2304. if ($grade) {
  2305. $where .= " and features like '%-$grade-%'";
  2306. }
  2307. if ($color) {
  2308. $where .= " and features like '%-$color-%'";
  2309. }
  2310. if ($lowe) {
  2311. $where .= " and features like '%-$lowe-%'";
  2312. }
  2313. //数据排序
  2314. $order_str = "outk desc";
  2315. if (empty($page)) {
  2316. $start = 0;
  2317. $perpage = 1;
  2318. } else {
  2319. $start = ($page - 1) * $perpage;
  2320. }
  2321. //取得信息列表
  2322. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2323. foreach ($info_list as $key => $value) {
  2324. $warehouse = $this->warehouse->read($value['warehouse']);
  2325. $info_list[$key]['warehouse'] = $warehouse['title'];
  2326. $purchase = $this->purchase->read($value['purchase']);
  2327. $info_list[$key]['purchase'] = $purchase['title'];
  2328. if ($value['outk'] != 0) {
  2329. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2330. } else {
  2331. $info_list[$key]['outk'] = "";
  2332. }
  2333. if ($value['orderinfo'] == 0) {
  2334. $info_list[$key]['orderinfo'] = "";
  2335. }
  2336. if ($value['waybill'] == 0) {
  2337. $info_list[$key]['waybill'] = "";
  2338. }
  2339. }
  2340. $total = $this->whlabel->find_count($where);
  2341. $pagenum = ceil($total / $perpage);
  2342. $over = $total - ($start + $perpage);
  2343. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2344. echo json_encode($rows);
  2345. exit;
  2346. }
  2347. $this->_Template('whlabel_label', $this->data);
  2348. }
  2349. //独立站出库订单
  2350. public function _outorder()
  2351. {
  2352. if (isset($_SESSION['api'])) {
  2353. $user = $this->user->get_api($_SESSION['api']);
  2354. $usp = $user;
  2355. $fgshop = "";
  2356. $sid = "";
  2357. $user = explode('|', trim($user['shop'], '|'));
  2358. foreach ($user as $value) {
  2359. $fgshop .= " shop = " . $value . " or";
  2360. $sid .= " id = " . $value . " or";
  2361. }
  2362. } else {
  2363. echo "请重新登录";
  2364. }
  2365. $post = $this->input->post(NULL, TRUE);
  2366. if (isset($post['page'])) {
  2367. $page = $this->input->post('page', true);
  2368. $perpage = $this->input->post('perpage', true);
  2369. $warehouse = $this->input->post('warehouse', true);
  2370. $xztime = $this->input->post('xztime', true);
  2371. $timetk = $this->input->post('timetkk', true);
  2372. $timetj = $this->input->post('timetjj', true);
  2373. $shop = $this->input->post('shop', true);
  2374. $source = $this->input->post('source', true);
  2375. $orderinfo = $this->input->post('orderinfo', true);
  2376. $number = $this->input->post('number', true);
  2377. $sfxh = $this->input->post('sfxh', true);
  2378. $express = $this->input->post('express', true);
  2379. $waybill = $this->input->post('waybill', true);
  2380. $library = $this->input->post('library', true);
  2381. $country = $this->input->post('country', true);
  2382. $so = $this->input->post('so', true);
  2383. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2384. $print = $this->input->post('print', true);
  2385. $state = $this->input->post('state', true);
  2386. $orderurl = $this->input->post('orderurl', true);
  2387. $timetk = strtotime($timetk);
  2388. $timetj = strtotime($timetj);
  2389. /**
  2390. $sj = $this->input->post('sj',true);
  2391. if($sj)
  2392. {
  2393. $sj = $this->input->post('sj',true);
  2394. }
  2395. else
  2396. {
  2397. $sj = "fullorder";
  2398. }
  2399. **/
  2400. $sj = "fullorder";
  2401. $where = "1=1";
  2402. if ($warehouse) {
  2403. $where .= " and type = '$warehouse'";
  2404. }
  2405. if ($timetk && $timetj) {
  2406. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2407. }
  2408. if ($orderinfo) {
  2409. $where .= " and orderinfo = '$orderinfo'";
  2410. }
  2411. if ($number) {
  2412. $where .= " and number = '$number'";
  2413. }
  2414. if ($express) {
  2415. $where .= " and express = '$express'";
  2416. }
  2417. if ($waybill) {
  2418. $where .= " and waybill = '$waybill'";
  2419. }
  2420. if ($library) {
  2421. $where .= " and library = '$library'";
  2422. }
  2423. if ($print) {
  2424. $where .= " and print = '$print'";
  2425. }
  2426. if ($libraryconfirm) {
  2427. $where .= " and libraryconfirm = '$libraryconfirm'";
  2428. }
  2429. if ($state) {
  2430. $where .= " and state = '$state'";
  2431. }
  2432. if ($shop) {
  2433. $where .= " and shop = '$shop'";
  2434. }
  2435. if ($country) {
  2436. $where .= " and country = '$country'";
  2437. }
  2438. if ($sfxh != '') {
  2439. $where .= " and sfxh = '$sfxh'";
  2440. }
  2441. if ($so) {
  2442. $where .= " and shipremarks like '%$so%'";
  2443. }
  2444. if ($source) {
  2445. if ($source == '2d') {
  2446. $where .= " and source >= '2'";
  2447. } else {
  2448. $where .= " and source = '$source'";
  2449. }
  2450. }
  2451. if (isset($_SESSION['api'])) {
  2452. foreach ($user as $value) {
  2453. $fgshop .= " shop = " . $value . " or";
  2454. }
  2455. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2456. }
  2457. if ($orderurl) {
  2458. $url = $this->orderurl->read($orderurl);
  2459. $where .= " and link like '%" . $url['url'] . "%'";
  2460. }
  2461. //数据排序
  2462. $order_str = "librarytime desc";
  2463. if (empty($page)) {
  2464. $start = 0;
  2465. $perpage = 1;
  2466. } else {
  2467. $start = ($page - 1) * $perpage;
  2468. }
  2469. //取得信息列表
  2470. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2471. //格式化数据
  2472. foreach ($info_list as $key => $value) {
  2473. $shop = $this->shop->read($value['shop']);
  2474. $info_list[$key]['shop'] = $shop['shopname'];
  2475. $express = $this->express->read($value['express']);
  2476. $info_list[$key]['express'] = $express['servicename'];
  2477. $warehouse = $this->warehouse->read($value['type']);
  2478. $info_list[$key]['type'] = $warehouse['title'];
  2479. if ($value['librarytime'] == '0') {
  2480. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2481. } else {
  2482. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2483. }
  2484. }
  2485. $total = $this->$sj->find_count($where);
  2486. $pagenum = ceil($total / $perpage);
  2487. $over = $total - ($start + $perpage);
  2488. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2489. echo json_encode($rows);
  2490. exit;
  2491. }
  2492. $this->data['express'] = $this->express->find_all();
  2493. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2494. $this->data['wlshop'] = $wlshop;
  2495. $user = $this->user->get_api($_SESSION['api']);
  2496. $powerid = $this->power->read($user['power']);
  2497. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2498. $pid = '';
  2499. foreach ($powertext as $v) {
  2500. $pid .= " id = " . $v . " or";
  2501. }
  2502. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2503. $this->data['fullorderexcel'] = $fullorderexcel;
  2504. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2505. $this->data['orderurl'] = $orderurl;
  2506. $this->_Template('whlabel_outorder', $this->data);
  2507. }
  2508. //tt出库
  2509. public function _toutorder()
  2510. {
  2511. if (isset($_SESSION['api'])) {
  2512. $user = $this->user->get_api($_SESSION['api']);
  2513. $usp = $user;
  2514. $fgshop = "";
  2515. $sid = "";
  2516. $user = explode('|', trim($user['shop'], '|'));
  2517. foreach ($user as $value) {
  2518. $fgshop .= " shop = " . $value . " or";
  2519. $sid .= " id = " . $value . " or";
  2520. }
  2521. } else {
  2522. echo "请重新登录";
  2523. }
  2524. $post = $this->input->post(NULL, TRUE);
  2525. if (isset($post['page'])) {
  2526. $page = $this->input->post('page', true);
  2527. $perpage = $this->input->post('perpage', true);
  2528. $warehouse = $this->input->post('warehouse', true);
  2529. $xztime = $this->input->post('xztime', true);
  2530. $timetk = $this->input->post('timetkk', true);
  2531. $timetj = $this->input->post('timetjj', true);
  2532. $shop = $this->input->post('shop', true);
  2533. $source = $this->input->post('source', true);
  2534. $orderinfo = $this->input->post('orderinfo', true);
  2535. $number = $this->input->post('number', true);
  2536. $sfxh = $this->input->post('sfxh', true);
  2537. $express = $this->input->post('express', true);
  2538. $waybill = $this->input->post('waybill', true);
  2539. $library = $this->input->post('library', true);
  2540. $country = $this->input->post('country', true);
  2541. $so = $this->input->post('so', true);
  2542. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2543. $print = $this->input->post('print', true);
  2544. $state = $this->input->post('state', true);
  2545. $orderurl = $this->input->post('orderurl', true);
  2546. $timetk = strtotime($timetk);
  2547. $timetj = strtotime($timetj);
  2548. /**
  2549. $sj = $this->input->post('sj',true);
  2550. if($sj)
  2551. {
  2552. $sj = $this->input->post('sj',true);
  2553. }
  2554. else
  2555. {
  2556. $sj = "fullorder";
  2557. }
  2558. **/
  2559. $sj = "fullordertt";
  2560. $where = "1=1";
  2561. if ($warehouse) {
  2562. $where .= " and type = '$warehouse'";
  2563. }
  2564. if ($timetk && $timetj) {
  2565. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2566. }
  2567. if ($orderinfo) {
  2568. $where .= " and orderinfo = '$orderinfo'";
  2569. }
  2570. if ($number) {
  2571. $where .= " and number = '$number'";
  2572. }
  2573. if ($express) {
  2574. $where .= " and express = '$express'";
  2575. }
  2576. if ($waybill) {
  2577. $where .= " and waybill = '$waybill'";
  2578. }
  2579. if ($library) {
  2580. $where .= " and library = '$library'";
  2581. }
  2582. if ($print) {
  2583. $where .= " and print = '$print'";
  2584. }
  2585. if ($libraryconfirm) {
  2586. $where .= " and libraryconfirm = '$libraryconfirm'";
  2587. }
  2588. if ($state) {
  2589. $where .= " and state = '$state'";
  2590. }
  2591. if ($shop) {
  2592. $where .= " and shop = '$shop'";
  2593. }
  2594. if ($country) {
  2595. $where .= " and country = '$country'";
  2596. }
  2597. if ($sfxh != '') {
  2598. $where .= " and sfxh = '$sfxh'";
  2599. }
  2600. if ($so) {
  2601. $where .= " and shipremarks like '%$so%'";
  2602. }
  2603. if ($source) {
  2604. if ($source == '2d') {
  2605. $where .= " and source >= '2'";
  2606. } else {
  2607. $where .= " and source = '$source'";
  2608. }
  2609. }
  2610. if (isset($_SESSION['api'])) {
  2611. foreach ($user as $value) {
  2612. $fgshop .= " shop = " . $value . " or";
  2613. }
  2614. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2615. }
  2616. if ($orderurl) {
  2617. $url = $this->orderurl->read($orderurl);
  2618. $where .= " and link like '%" . $url['url'] . "%'";
  2619. }
  2620. //数据排序
  2621. $order_str = "librarytime desc";
  2622. if (empty($page)) {
  2623. $start = 0;
  2624. $perpage = 1;
  2625. } else {
  2626. $start = ($page - 1) * $perpage;
  2627. }
  2628. //取得信息列表
  2629. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2630. //格式化数据
  2631. foreach ($info_list as $key => $value) {
  2632. $shop = $this->shop->read($value['shop']);
  2633. $info_list[$key]['shop'] = $shop['shopname'];
  2634. $express = $this->express->read($value['express']);
  2635. $info_list[$key]['express'] = $express['servicename'];
  2636. $warehouse = $this->warehouse->read($value['type']);
  2637. $info_list[$key]['type'] = $warehouse['title'];
  2638. if ($value['librarytime'] == '0') {
  2639. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2640. } else {
  2641. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2642. }
  2643. }
  2644. $total = $this->$sj->find_count($where);
  2645. $pagenum = ceil($total / $perpage);
  2646. $over = $total - ($start + $perpage);
  2647. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2648. echo json_encode($rows);
  2649. exit;
  2650. }
  2651. $this->data['express'] = $this->express->find_all();
  2652. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2653. $this->data['wlshop'] = $wlshop;
  2654. $user = $this->user->get_api($_SESSION['api']);
  2655. $powerid = $this->power->read($user['power']);
  2656. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2657. $pid = '';
  2658. foreach ($powertext as $v) {
  2659. $pid .= " id = " . $v . " or";
  2660. }
  2661. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2662. $this->data['fullorderexcel'] = $fullorderexcel;
  2663. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2664. $this->data['orderurl'] = $orderurl;
  2665. $this->_Template('whlabel_toutorder', $this->data);
  2666. }
  2667. //tt出库
  2668. public function _aoutorder()
  2669. {
  2670. if (isset($_SESSION['api'])) {
  2671. $user = $this->user->get_api($_SESSION['api']);
  2672. $usp = $user;
  2673. $fgshop = "";
  2674. $sid = "";
  2675. $user = explode('|', trim($user['shop'], '|'));
  2676. foreach ($user as $value) {
  2677. $fgshop .= " shop = " . $value . " or";
  2678. $sid .= " id = " . $value . " or";
  2679. }
  2680. } else {
  2681. echo "请重新登录";
  2682. }
  2683. $post = $this->input->post(NULL, TRUE);
  2684. if (isset($post['page'])) {
  2685. $page = $this->input->post('page', true);
  2686. $perpage = $this->input->post('perpage', true);
  2687. $warehouse = $this->input->post('warehouse', true);
  2688. $xztime = $this->input->post('xztime', true);
  2689. $timetk = $this->input->post('timetkk', true);
  2690. $timetj = $this->input->post('timetjj', true);
  2691. $shop = $this->input->post('shop', true);
  2692. $source = $this->input->post('source', true);
  2693. $orderinfo = $this->input->post('orderinfo', true);
  2694. $number = $this->input->post('number', true);
  2695. $sfxh = $this->input->post('sfxh', true);
  2696. $express = $this->input->post('express', true);
  2697. $waybill = $this->input->post('waybill', true);
  2698. $library = $this->input->post('library', true);
  2699. $country = $this->input->post('country', true);
  2700. $so = $this->input->post('so', true);
  2701. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2702. $print = $this->input->post('print', true);
  2703. $state = $this->input->post('state', true);
  2704. $orderurl = $this->input->post('orderurl', true);
  2705. $timetk = strtotime($timetk);
  2706. $timetj = strtotime($timetj);
  2707. /**
  2708. $sj = $this->input->post('sj',true);
  2709. if($sj)
  2710. {
  2711. $sj = $this->input->post('sj',true);
  2712. }
  2713. else
  2714. {
  2715. $sj = "fullorder";
  2716. }
  2717. **/
  2718. $sj = "fullorderamz";
  2719. $where = "1=1";
  2720. if ($warehouse) {
  2721. $where .= " and type = '$warehouse'";
  2722. }
  2723. if ($timetk && $timetj) {
  2724. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2725. }
  2726. if ($orderinfo) {
  2727. $where .= " and orderinfo = '$orderinfo'";
  2728. }
  2729. if ($number) {
  2730. $where .= " and number = '$number'";
  2731. }
  2732. if ($express) {
  2733. $where .= " and express = '$express'";
  2734. }
  2735. if ($waybill) {
  2736. $where .= " and waybill = '$waybill'";
  2737. }
  2738. if ($library) {
  2739. $where .= " and library = '$library'";
  2740. }
  2741. if ($print) {
  2742. $where .= " and print = '$print'";
  2743. }
  2744. if ($libraryconfirm) {
  2745. $where .= " and libraryconfirm = '$libraryconfirm'";
  2746. }
  2747. if ($state) {
  2748. $where .= " and state = '$state'";
  2749. }
  2750. if ($shop) {
  2751. $where .= " and shop = '$shop'";
  2752. }
  2753. if ($country) {
  2754. $where .= " and country = '$country'";
  2755. }
  2756. if ($sfxh != '') {
  2757. $where .= " and sfxh = '$sfxh'";
  2758. }
  2759. if ($so) {
  2760. $where .= " and shipremarks like '%$so%'";
  2761. }
  2762. if ($source) {
  2763. if ($source == '2d') {
  2764. $where .= " and source >= '2'";
  2765. } else {
  2766. $where .= " and source = '$source'";
  2767. }
  2768. }
  2769. if (isset($_SESSION['api'])) {
  2770. foreach ($user as $value) {
  2771. $fgshop .= " shop = " . $value . " or";
  2772. }
  2773. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2774. }
  2775. if ($orderurl) {
  2776. $url = $this->orderurl->read($orderurl);
  2777. $where .= " and link like '%" . $url['url'] . "%'";
  2778. }
  2779. //数据排序
  2780. $order_str = "librarytime desc";
  2781. if (empty($page)) {
  2782. $start = 0;
  2783. $perpage = 1;
  2784. } else {
  2785. $start = ($page - 1) * $perpage;
  2786. }
  2787. //取得信息列表
  2788. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2789. //格式化数据
  2790. foreach ($info_list as $key => $value) {
  2791. $shop = $this->shop->read($value['shop']);
  2792. $info_list[$key]['shop'] = $shop['shopname'];
  2793. $express = $this->express->read($value['express']);
  2794. $info_list[$key]['express'] = $express['servicename'];
  2795. $warehouse = $this->warehouse->read($value['type']);
  2796. $info_list[$key]['type'] = $warehouse['title'];
  2797. if ($value['librarytime'] == '0') {
  2798. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2799. } else {
  2800. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2801. }
  2802. }
  2803. $total = $this->$sj->find_count($where);
  2804. $pagenum = ceil($total / $perpage);
  2805. $over = $total - ($start + $perpage);
  2806. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2807. echo json_encode($rows);
  2808. exit;
  2809. }
  2810. $this->data['express'] = $this->express->find_all();
  2811. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2812. $this->data['wlshop'] = $wlshop;
  2813. $user = $this->user->get_api($_SESSION['api']);
  2814. $powerid = $this->power->read($user['power']);
  2815. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2816. $pid = '';
  2817. foreach ($powertext as $v) {
  2818. $pid .= " id = " . $v . " or";
  2819. }
  2820. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2821. $this->data['fullorderexcel'] = $fullorderexcel;
  2822. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2823. $this->data['orderurl'] = $orderurl;
  2824. $this->_Template('whlabel_aoutorder', $this->data);
  2825. }
  2826. //速卖通出库订单
  2827. public function _soutorder()
  2828. {
  2829. if (isset($_SESSION['api'])) {
  2830. $user = $this->user->get_api($_SESSION['api']);
  2831. $usp = $user;
  2832. $fgshop = "";
  2833. $sid = "";
  2834. $user = explode('|', trim($user['shop'], '|'));
  2835. foreach ($user as $value) {
  2836. $sid .= " id = " . $value . " or";
  2837. }
  2838. }
  2839. $post = $this->input->post(NULL, TRUE);
  2840. if (isset($post['page'])) {
  2841. $page = $this->input->post('page', true);
  2842. $perpage = $this->input->post('perpage', true);
  2843. $warehouse = $this->input->post('warehouse', true);
  2844. $xztime = $this->input->post('xztime', true);
  2845. $timetk = $this->input->post('timetkk', true);
  2846. $timetj = $this->input->post('timetjj', true);
  2847. $shop = $this->input->post('shop', true);
  2848. $source = $this->input->post('source', true);
  2849. $orderinfo = $this->input->post('orderinfo', true);
  2850. $number = $this->input->post('number', true);
  2851. $express = $this->input->post('express', true);
  2852. $waybill = $this->input->post('waybill', true);
  2853. $library = $this->input->post('library', true);
  2854. $country = $this->input->post('country', true);
  2855. $sfxh = $this->input->post('sfxh', true);
  2856. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2857. $print = $this->input->post('print', true);
  2858. $state = $this->input->post('state', true);
  2859. $so = $this->input->post('so', true);
  2860. $timetk = strtotime($timetk);
  2861. $timetj = strtotime($timetj);
  2862. /**
  2863. $sj = $this->input->post('sj',true);
  2864. if($sj)
  2865. {
  2866. $sj = $this->input->post('sj',true);
  2867. }
  2868. else
  2869. {
  2870. $sj = "fullorder";
  2871. }
  2872. **/
  2873. $sj = "fullordersmt";
  2874. $where = "1=1";
  2875. if ($warehouse) {
  2876. $where .= " and type = '$warehouse'";
  2877. }
  2878. if ($timetk && $timetj) {
  2879. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2880. }
  2881. if ($orderinfo) {
  2882. $where .= " and orderinfo = '$orderinfo'";
  2883. }
  2884. if ($number) {
  2885. $where .= " and number = '$number'";
  2886. }
  2887. if ($express) {
  2888. $where .= " and express = '$express'";
  2889. }
  2890. if ($waybill) {
  2891. $where .= " and waybill = '$waybill'";
  2892. }
  2893. if ($library) {
  2894. $where .= " and library = '$library'";
  2895. }
  2896. if ($print) {
  2897. $where .= " and print = '$print'";
  2898. }
  2899. if ($libraryconfirm) {
  2900. $where .= " and libraryconfirm = '$libraryconfirm'";
  2901. }
  2902. if ($state) {
  2903. $where .= " and state = '$state'";
  2904. }
  2905. if ($shop) {
  2906. $where .= " and shop = '$shop'";
  2907. }
  2908. if ($sfxh != '') {
  2909. $where .= " and sfxh = '$sfxh'";
  2910. }
  2911. if ($so) {
  2912. $where .= " and shipremarks like '%$so%'";
  2913. }
  2914. if ($source) {
  2915. $where .= " and source = '$source'";
  2916. }
  2917. if ($country) {
  2918. $where .= " and country = '$country'";
  2919. } else {
  2920. if (isset($_SESSION['api'])) {
  2921. foreach ($user as $value) {
  2922. $fgshop .= " shop = " . $value . " or";
  2923. }
  2924. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2925. }
  2926. }
  2927. //数据排序
  2928. $order_str = "librarytime desc";
  2929. if (empty($page)) {
  2930. $start = 0;
  2931. $perpage = 1;
  2932. } else {
  2933. $start = ($page - 1) * $perpage;
  2934. }
  2935. //取得信息列表
  2936. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2937. //格式化数据
  2938. foreach ($info_list as $key => $value) {
  2939. $shop = $this->shop->read($value['shop']);
  2940. $info_list[$key]['shop'] = $shop['shopname'];
  2941. $express = $this->express->read($value['express']);
  2942. $info_list[$key]['express'] = $express['servicename'];
  2943. $warehouse = $this->warehouse->read($value['type']);
  2944. $info_list[$key]['type'] = $warehouse['title'];
  2945. if ($value['librarytime'] == '0') {
  2946. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2947. } else {
  2948. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2949. }
  2950. }
  2951. $total = $this->$sj->find_count($where);
  2952. $pagenum = ceil($total / $perpage);
  2953. $over = $total - ($start + $perpage);
  2954. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2955. echo json_encode($rows);
  2956. exit;
  2957. }
  2958. $this->data['express'] = $this->express->find_all();
  2959. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2960. $this->data['wlshop'] = $wlshop;
  2961. $user = $this->user->get_api($_SESSION['api']);
  2962. $powerid = $this->power->read($user['power']);
  2963. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2964. $pid = '';
  2965. foreach ($powertext as $v) {
  2966. $pid .= " id = " . $v . " or";
  2967. }
  2968. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2969. $this->data['fullorderexcel'] = $fullorderexcel;
  2970. $this->_Template('whlabel_soutorder', $this->data);
  2971. }
  2972. //订单退库
  2973. public function _retreat()
  2974. {
  2975. $post = $this->input->post(NULL, TRUE);
  2976. if (isset($post['page'])) {
  2977. $page = $this->input->post('page', true);
  2978. $perpage = $this->input->post('perpage', true);
  2979. $warehouse = $this->input->post('warehouse', true);
  2980. $timetk = $this->input->post('timetk', true);
  2981. $timetj = $this->input->post('timetj', true);
  2982. $shop = $this->input->post('shop', true);
  2983. $source = $this->input->post('source', true);
  2984. $state = $this->input->post('state', true);
  2985. $review = $this->input->post('review', true);
  2986. $state = $this->input->post('state', true);
  2987. $express = $this->input->post('express', true);
  2988. $orderinfo = $this->input->post('orderinfo', true);
  2989. $user = $this->input->post('user', true);
  2990. $name = $this->input->post('name', true);
  2991. $waybill = $this->input->post('waybill', true);
  2992. $timetk = strtotime($timetk);
  2993. $timetj = strtotime($timetj);
  2994. $where = "(state=206 or state=210) and mergeid = 0";
  2995. if ($warehouse) {
  2996. $where .= " and state = '$warehouse'";
  2997. }
  2998. if ($timetk && $timetj) {
  2999. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3000. }
  3001. if ($shop) {
  3002. $where .= " and shop = '$shop'";
  3003. }
  3004. if ($source) {
  3005. $where .= " and source = '$source'";
  3006. }
  3007. if ($state) {
  3008. $where .= " and state = '$state'";
  3009. }
  3010. if ($review) {
  3011. $where .= " and review = '$review'";
  3012. }
  3013. if ($state) {
  3014. $where .= " and state = '$state'";
  3015. }
  3016. if ($express) {
  3017. $where .= " and express = '$express'";
  3018. }
  3019. if ($orderinfo) {
  3020. $where .= " and orderinfo = '$orderinfo'";
  3021. }
  3022. if ($user) {
  3023. $where .= " and user = '$user'";
  3024. }
  3025. if ($name) {
  3026. $where .= " and name = '$name'";
  3027. }
  3028. if ($waybill) {
  3029. $where .= " and waybill = '$waybill'";
  3030. }
  3031. //数据排序
  3032. $order_str = "id desc";
  3033. if (empty($page)) {
  3034. $start = 0;
  3035. $perpage = 1;
  3036. } else {
  3037. $start = ($page - 1) * $perpage;
  3038. }
  3039. //取得信息列表
  3040. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3041. //格式化数据
  3042. foreach ($info_list as $key => $value) {
  3043. $shop = $this->shop->read($value['shop']);
  3044. $info_list[$key]['shop'] = $shop['shopname'];
  3045. $warehouse = $this->warehouse->read($value['warehouse']);
  3046. $info_list[$key]['warehouse'] = $warehouse['title'];
  3047. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3048. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3049. if ($value['waybill'] == 0) {
  3050. $info_list[$key]['waybill'] = "";
  3051. }
  3052. $express = $this->express->read($value['express']);
  3053. $info_list[$key]['express'] = $express['title'];
  3054. $typeclass = $this->typeclass->read($value['state']);
  3055. $info_list[$key]['state'] = $typeclass['title'];
  3056. }
  3057. $total = $this->fullorder->find_count($where);
  3058. $pagenum = ceil($total / $perpage);
  3059. $over = $total - ($start + $perpage);
  3060. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3061. echo json_encode($rows);
  3062. exit;
  3063. }
  3064. $this->data['express'] = $this->express->find_all();
  3065. $this->_Template('whlabel_retreat', $this->data);
  3066. }
  3067. //退库标签浏览
  3068. public function _retreatlk()
  3069. {
  3070. $post = $this->input->post(NULL, TRUE);
  3071. if (isset($post['page'])) {
  3072. $page = $this->input->post('page', true);
  3073. $perpage = $this->input->post('perpage', true);
  3074. $timetk = $this->input->post('timetk', true);
  3075. $timetj = $this->input->post('timetj', true);
  3076. $sku = $this->input->post('sku', true);
  3077. $warehouse = $this->input->post('warehouse', true);
  3078. $purchase = $this->input->post('purchase', true);
  3079. $orderinfo = $this->input->post('orderinfo', true);
  3080. $waybill = $this->input->post('waybill', true);
  3081. $category = $this->input->post('category', true);
  3082. $size = $this->input->post('size', true);
  3083. $grade = $this->input->post('grade', true);
  3084. $color = $this->input->post('color', true);
  3085. $lowe = $this->input->post('lowe', true);
  3086. $state = $this->input->post('state', true);
  3087. $timetk = strtotime($timetk);
  3088. $timetj = strtotime($timetj);
  3089. $where = "state=2";
  3090. if ($timetk && $timetj) {
  3091. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3092. }
  3093. if ($sku) {
  3094. $where .= " and sku = '$sku'";
  3095. }
  3096. if ($warehouse) {
  3097. $where .= " and warehouse = '$warehouse'";
  3098. }
  3099. if ($purchase) {
  3100. $where .= " and purchase = '$purchase'";
  3101. }
  3102. if ($orderinfo) {
  3103. $where .= " and orderinfo = '$orderinfo'";
  3104. }
  3105. if ($waybill) {
  3106. $where .= " and waybill = '$waybill'";
  3107. }
  3108. if ($category) {
  3109. $where .= " and features like '%-$category-%'";
  3110. }
  3111. if ($size) {
  3112. $where .= " and features like '%-$size-%'";
  3113. }
  3114. if ($grade) {
  3115. $where .= " and features like '%-$grade-%'";
  3116. }
  3117. if ($color) {
  3118. $where .= " and features like '%-$color-%'";
  3119. }
  3120. if ($lowe) {
  3121. $where .= " and features like '%-$lowe-%'";
  3122. }
  3123. //数据排序
  3124. $order_str = "time desc";
  3125. if (empty($page)) {
  3126. $start = 0;
  3127. $perpage = 1;
  3128. } else {
  3129. $start = ($page - 1) * $perpage;
  3130. }
  3131. //取得信息列表
  3132. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3133. foreach ($info_list as $key => $value) {
  3134. $warehouse = $this->warehouse->read($value['warehouse']);
  3135. $info_list[$key]['warehouse'] = $warehouse['title'];
  3136. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3137. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3138. $purchase = $this->purchase->read($value['purchase']);
  3139. $info_list[$key]['purchase'] = $purchase['title'];
  3140. if ($value['outk'] != 0) {
  3141. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3142. } else {
  3143. $info_list[$key]['outk'] = "";
  3144. }
  3145. if ($value['retreat'] != 0) {
  3146. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3147. } else {
  3148. $info_list[$key]['retreat'] = "";
  3149. }
  3150. if ($value['orderinfo'] == 0) {
  3151. $info_list[$key]['orderinfo'] = "";
  3152. }
  3153. if ($value['waybill'] == 0) {
  3154. $info_list[$key]['waybill'] = "";
  3155. }
  3156. }
  3157. $total = $this->whlabel->find_count($where);
  3158. $pagenum = ceil($total / $perpage);
  3159. $over = $total - ($start + $perpage);
  3160. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3161. echo json_encode($rows);
  3162. exit;
  3163. }
  3164. $this->_Template('whlabel_retreatlk', $this->data);
  3165. }
  3166. //更换标签及浏览
  3167. public function _change()
  3168. {
  3169. $post = $this->input->post(NULL, TRUE);
  3170. if (isset($post['page'])) {
  3171. $page = $this->input->post('page', true);
  3172. $perpage = $this->input->post('perpage', true);
  3173. $timetk = $this->input->post('timetk', true);
  3174. $timetj = $this->input->post('timetj', true);
  3175. $label = $this->input->post('label', true);
  3176. $oldlabel = $this->input->post('oldlabel', true);
  3177. $timetk = strtotime($timetk);
  3178. $timetj = strtotime($timetj);
  3179. $where = "state=10 ";
  3180. if ($timetk && $timetj) {
  3181. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3182. }
  3183. if ($label) {
  3184. $where .= " and label = '$label'";
  3185. }
  3186. if ($oldlabel) {
  3187. $where .= " and oldlabel = '$oldlabel'";
  3188. }
  3189. //数据排序
  3190. $order_str = "time asc";
  3191. if (empty($page)) {
  3192. $start = 0;
  3193. $perpage = 1;
  3194. } else {
  3195. $start = ($page - 1) * $perpage;
  3196. }
  3197. //取得信息列表
  3198. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3199. foreach ($info_list as $key => $value) {
  3200. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3201. }
  3202. $total = $this->whlabel->find_count($where);
  3203. $pagenum = ceil($total / $perpage);
  3204. $over = $total - ($start + $perpage);
  3205. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3206. echo json_encode($rows);
  3207. exit;
  3208. }
  3209. $this->_Template('whlabel_change', $this->data);
  3210. }
  3211. //产品标签
  3212. public function _cpbqdc()
  3213. {
  3214. if (isset($_GET['excel'])) {
  3215. $where = "1=1";
  3216. //数据排序
  3217. $order_str = "id desc";
  3218. if (empty($page)) {
  3219. $start = 0;
  3220. $perpage = 1;
  3221. } else {
  3222. $start = ($page - 1) * $perpage;
  3223. }
  3224. $warehouse = $this->input->get('warehouse', true);
  3225. $state = $this->input->get('state', true);
  3226. $timetk = $this->input->get('timetkk', true);
  3227. $timetj = $this->input->get('timetjj', true);
  3228. $timetk = strtotime($timetk);
  3229. $timetj = strtotime($timetj);
  3230. if ($warehouse) {
  3231. $where .= " and warehouse = '$warehouse'";
  3232. }
  3233. if ($state || $state == 0) {
  3234. $where .= " and state = '$state'";
  3235. }
  3236. if ($timetk && $timetj) {
  3237. $where .= " and time > '$timetk' and time < '$timetj'";
  3238. }
  3239. //取得信息列表
  3240. $info_list = $this->whlabel->find_all($where, '*');
  3241. $rows = array();
  3242. $list = array();
  3243. foreach ($info_list as $key => $value) {
  3244. $rows[$value['time']] = $value; //所有数据sku
  3245. }
  3246. foreach ($rows as $value) {
  3247. $warehouse = $this->warehouse->read($value['warehouse']);
  3248. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3249. $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);
  3250. }
  3251. $title = "产品标签统计表";
  3252. $titlename = "<table border=1>
  3253. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3254. <tr align='center'>
  3255. <td>仓库</td>
  3256. <td>SKU</td>
  3257. <td>产品</td>
  3258. <td>入库时间</td>
  3259. <td>操作时间</td>
  3260. <td>备注</td>
  3261. <td>数量</td>
  3262. </tr>
  3263. </table>";
  3264. $filename = $title . ".xls";
  3265. $tail = "";
  3266. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3267. }
  3268. }
  3269. //进销存导出
  3270. public function _exceljxc()
  3271. {
  3272. $classid = $this->classid->sku();
  3273. $pm = $classid;
  3274. $typeclass = array();
  3275. $tc = $this->typeclass->find_all();
  3276. foreach ($tc as $v) {
  3277. $typeclass[$v['id']] = $v;
  3278. }
  3279. $prc = array();
  3280. $purchase = $this->purchase->find_all();
  3281. foreach ($purchase as $k => $v) {
  3282. $prc[$v['id']] = $v['title'];
  3283. }
  3284. if (isset($_GET['excel'])) {
  3285. $where = "sku != 'Preset'";
  3286. //数据排序
  3287. $order_str = "id desc";
  3288. if (empty($page)) {
  3289. $start = 0;
  3290. $perpage = 1;
  3291. } else {
  3292. $start = ($page - 1) * $perpage;
  3293. }
  3294. $category = $this->input->get('category', true);
  3295. $warehouse = $this->input->get('warehouse', true);
  3296. $excelid = $this->input->get('sid', true);
  3297. if ($category) {
  3298. $where .= " and features like '%-$category-%'";
  3299. }
  3300. if ($warehouse) {
  3301. $where .= " and warehouse = '$warehouse'";
  3302. }
  3303. $xzid = '';
  3304. if ($excelid) {
  3305. $excelid = explode(',', trim($excelid, ','));
  3306. foreach ($excelid as $key => $value) {
  3307. $xzid .= " id = " . $value . " or";
  3308. }
  3309. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3310. }
  3311. //取得信息列表
  3312. /**
  3313. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3314. $rows = array();$list = array();
  3315. foreach ($info_list as $key=>$value)
  3316. {
  3317. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3318. }
  3319. **/
  3320. $wt = array();
  3321. $whlabel_type = $this->whlabel_type->find_all();
  3322. foreach ($whlabel_type as $v) {
  3323. $wt[$v['id']] = $v['title'];
  3324. }
  3325. $wh = array();
  3326. $w = $this->warehouse->find_all('1=1', 'id,title');
  3327. foreach ($w as $v) {
  3328. $wh[$v['id']] = $v['title'];
  3329. }
  3330. $list = array();
  3331. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3332. foreach ($rows as $key => $value) {
  3333. if (isset($wt[$value['type']])) {
  3334. $rows[$key]['type'] = $wt[$value['type']];
  3335. } else {
  3336. $rows[$key]['type'] = '未设置';
  3337. }
  3338. $bm = '03';
  3339. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3340. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3341. $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');
  3342. $details = array();
  3343. $cpid = array();
  3344. $cpbz = array();
  3345. $c = 0;
  3346. $g = 0;
  3347. $x = 0;
  3348. $t = 0;
  3349. $s = 0;
  3350. $q = 0;
  3351. foreach ($sd as $k => $v) {
  3352. if ($v['state'] == 0) {
  3353. $c++;
  3354. if ($v['cpid'] != 0) {
  3355. $cpid[$v['cpid']] = $v['cpid'];
  3356. }
  3357. if ($v['cpbz'] != '') {
  3358. $cpbz[$v['cpbz']] = $v['cpbz'];
  3359. }
  3360. }
  3361. if ($v['state'] != 9) {
  3362. $g++;
  3363. }
  3364. if ($v['state'] == 1) {
  3365. $x++;
  3366. }
  3367. if ($v['state'] == 2) {
  3368. $t++;
  3369. }
  3370. if ($v['state'] == 8) {
  3371. $s++;
  3372. }
  3373. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3374. $q++;
  3375. }
  3376. $details[$v['details']] = $v['details'];
  3377. }
  3378. $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'] . '"');
  3379. $rows[$key]['details'] = implode("、", $details);
  3380. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3381. $number = $value['number'];
  3382. $ftime = time() - 15 * 24 * 3600;
  3383. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3384. $rows[$key]['number'] = $g;
  3385. $rows[$key]['c'] = $c;
  3386. $rows[$key]['x'] = $x;
  3387. $rows[$key]['t'] = $t;
  3388. $rows[$key]['s'] = $s;
  3389. $rows[$key]['q'] = $q;
  3390. $rows[$key]['z'] = $z;
  3391. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3392. $features = explode('-', trim($features, '-'));
  3393. $rows[$key]['dbcontent'] = $typeclass[$features[0]]['title'];
  3394. // $pm = $classid;
  3395. // $jm = $classid;
  3396. // foreach($features as $k=>$v)
  3397. // {
  3398. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3399. // {
  3400. // if($typeclass[$v]['bm'] != '')
  3401. // {
  3402. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3403. // }
  3404. // }
  3405. // if($v != 0)
  3406. // {
  3407. // if(!isset($typeclass[$v]))
  3408. // {
  3409. // continue;
  3410. // }
  3411. // if(isset($pm[$typeclass[$v]['classid']]))
  3412. // {
  3413. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3414. // {
  3415. // $tz = explode('|',$typeclass[$v]['zh']);
  3416. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3417. // }
  3418. // else
  3419. // {
  3420. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3421. // }
  3422. // }
  3423. // if(isset($jm[$typeclass[$v]['classid']]))
  3424. // {
  3425. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3426. // }
  3427. // }
  3428. // }
  3429. // $jm = array_filter($jm);
  3430. // $rows[$key]['bs'] = implode("-",$jm);
  3431. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3432. // $zh = implode(" ",$pm);
  3433. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3434. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3435. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3436. // $rows[$key]['features'] = $zh;
  3437. }
  3438. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3439. $final_list = [];
  3440. foreach ($list as $k => $v) {
  3441. if (empty($v['sku'])) {
  3442. continue;
  3443. }
  3444. $final_list[] = [
  3445. "warehouse" => $v["warehouse"],
  3446. "purchase" => $v["purchase"],
  3447. "details" => $v["details"],
  3448. "cpid" => $v["cpid"],
  3449. "dbcontent" => $v["dbcontent"],
  3450. "sku" => $v["sku"],
  3451. "cs" => $v["bm"],
  3452. "bs" => $v["jm"],
  3453. "title" => $v["title"],
  3454. "features" => $v["pm"],
  3455. "cpbz" => $v["cpbz"],
  3456. "sm" => $v["sm"],
  3457. "type" => $v["type"],
  3458. "number" => $v["number"],
  3459. "c" => $v["c"],
  3460. "x" => $v["x"],
  3461. "t" => $v["t"],
  3462. "s" => $v["s"],
  3463. "q" => $v["q"],
  3464. "z" => $v["z"],
  3465. "weight" => $v['weight'],
  3466. ];
  3467. }
  3468. $title = "总进销存统计表";
  3469. $titlename = "<table border=1>
  3470. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3471. <tr align='center'>
  3472. <td>仓库</td>
  3473. <td>供应商</td>
  3474. <td>位置</td>
  3475. <td>库存编码</td>
  3476. <td>类目</td>
  3477. <td>SKU</td>
  3478. <td>用友编码</td>
  3479. <td>用友料号</td>
  3480. <td>商品名称</td>
  3481. <td>商品中文</td>
  3482. <td>产品备注</td>
  3483. <td>说明</td>
  3484. <td>类型</td>
  3485. <td>入库总量</td>
  3486. <td>库存数量</td>
  3487. <td>销售数量</td>
  3488. <td>退货数量</td>
  3489. <td>删除数量</td>
  3490. <td>其它操作</td>
  3491. <td>占单数量</td>
  3492. <td>重量(g)</td>
  3493. </tr>
  3494. </table>";
  3495. $filename = $title . ".xls";
  3496. $tail = "";
  3497. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3498. }
  3499. }
  3500. //入库导出
  3501. public function _excelr()
  3502. {
  3503. if (isset($_GET['excel'])) {
  3504. $category = $this->input->get('category', true);
  3505. $size = $this->input->get('size', true);
  3506. $grade = $this->input->get('grade', true);
  3507. $color = $this->input->get('color', true);
  3508. $lowe = $this->input->get('lowe', true);
  3509. $sku = $this->input->get('sku', true);
  3510. $warehouse = $this->input->get('warehouse', true);
  3511. $purchase = $this->input->get('purchase', true);
  3512. $ktime = $this->input->get('ktime', true);
  3513. $jtime = $this->input->get('jtime', true);
  3514. $ktime = strtotime($ktime);
  3515. $jtime = strtotime($jtime);
  3516. $where = "1=1";
  3517. $gj = "";
  3518. $ck = "";
  3519. if ($category) {
  3520. $where .= " and features like '%-$category-%'";
  3521. }
  3522. if ($size) {
  3523. $where .= " and features like '%-$size-%'";
  3524. }
  3525. if ($grade) {
  3526. $where .= " and features like '%-$grade-%'";
  3527. }
  3528. if ($color) {
  3529. $where .= " and features like '%-$color-%'";
  3530. }
  3531. if ($lowe) {
  3532. $where .= " and features like '%-$lowe-%'";
  3533. }
  3534. if ($warehouse) {
  3535. $where .= " and warehouse = '$warehouse'";
  3536. }
  3537. if ($purchase) {
  3538. $where .= " and purchase = '$purchase'";
  3539. }
  3540. if ($sku) {
  3541. $where .= " and sku = '$sku'";
  3542. }
  3543. if ($ktime && $jtime) {
  3544. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3545. }
  3546. //数据排序
  3547. $order_str = "id desc";
  3548. if (empty($page)) {
  3549. $start = 0;
  3550. $perpage = 1;
  3551. } else {
  3552. $start = ($page - 1) * $perpage;
  3553. }
  3554. $list = array();
  3555. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3556. foreach ($rows as $value) {
  3557. $ck = $this->warehouse->read($value['warehouse']);
  3558. $warehouse = $ck['title'];
  3559. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3560. $retreatwarehouse = $tkck['title'];
  3561. $gy = $this->purchase->read($value['purchase']);
  3562. $purchase = $gy['title'];
  3563. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3564. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3565. }
  3566. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3567. $titlename = "<table border=1>
  3568. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3569. <tr align='center'>
  3570. <td>仓库</td>
  3571. <td>SKU</td>
  3572. <td>产品</td>
  3573. <td>时间</td>
  3574. <td>数量</td>
  3575. </tr>
  3576. </table>";
  3577. $filename = $title . ".xls";
  3578. $tail = "";
  3579. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3580. }
  3581. }
  3582. //出库、退库导出
  3583. public function _excelct()
  3584. {
  3585. $classid = $this->classid->sku();
  3586. $pm = $classid;
  3587. $typeclass = array();
  3588. $tc = $this->typeclass->find_all();
  3589. foreach ($tc as $v) {
  3590. $typeclass[$v['id']] = $v;
  3591. }
  3592. $prc = array();
  3593. $purchase = $this->purchase->find_all();
  3594. foreach ($purchase as $k => $v) {
  3595. $prc[$v['id']] = $v['title'];
  3596. }
  3597. if (isset($_GET['excel'])) {
  3598. $wh = array();
  3599. $w = $this->warehouse->find_all('1=1', 'id,title');
  3600. foreach ($w as $v) {
  3601. $wh[$v['id']] = $v['title'];
  3602. }
  3603. $type = $this->input->get('excel', true);
  3604. $category = $this->input->get('category', true);
  3605. $size = $this->input->get('size', true);
  3606. $grade = $this->input->get('grade', true);
  3607. $color = $this->input->get('color', true);
  3608. $lowe = $this->input->get('lowe', true);
  3609. $sku = $this->input->get('sku', true);
  3610. $warehouse = $this->input->get('warehouse', true);
  3611. $lacetype = $this->input->get('lacetype', true);
  3612. $lacecolor = $this->input->get('lacecolor', true);
  3613. $density = $this->input->get('density', true);
  3614. $haircap = $this->input->get('haircap', true);
  3615. $purchase = $this->input->get('purchase', true);
  3616. $title = $this->input->get('title', true);
  3617. $state = $this->input->get('state', true);
  3618. $sid = $this->input->get('sid', true);
  3619. $ktime = $this->input->get('ktime', true);
  3620. $jtime = $this->input->get('jtime', true);
  3621. $ktime = strtotime($ktime);
  3622. $jtime = strtotime($jtime);
  3623. $where = "1=1";
  3624. $gj = "";
  3625. $ck = "";
  3626. if ($category) {
  3627. $where .= " and features like '%-$category-%'";
  3628. }
  3629. if ($size) {
  3630. $where .= " and features like '%-$size-%'";
  3631. }
  3632. if ($grade) {
  3633. $where .= " and features like '%-$grade-%'";
  3634. }
  3635. if ($color) {
  3636. $where .= " and features like '%-$color-%'";
  3637. }
  3638. if ($lowe) {
  3639. $where .= " and features like '%-$lowe-%'";
  3640. }
  3641. if ($warehouse) {
  3642. $where .= " and warehouse = '$warehouse'";
  3643. }
  3644. if ($purchase) {
  3645. $where .= " and purchase = '$purchase'";
  3646. }
  3647. if ($state) {
  3648. $where .= " and state = '$state'";
  3649. }
  3650. if ($lacetype) {
  3651. $where .= " and features like '%-$lacetype-%'";
  3652. }
  3653. if ($lacecolor) {
  3654. $where .= " and features like '%-$lacecolor-%'";
  3655. }
  3656. if ($density) {
  3657. $where .= " and features like '%-$density-%'";
  3658. }
  3659. if ($haircap) {
  3660. $where .= " and features like '%-$haircap-%'";
  3661. }
  3662. if ($title) {
  3663. $title = trim($title, ' ');
  3664. $title = trim($title, ' ');
  3665. $where .= " and title like '%$title%'";
  3666. }
  3667. if ($sku) {
  3668. $sku = trim($sku, ' ');
  3669. $sku = trim($sku, ' ');
  3670. $where .= " and sku like '%$sku%'";
  3671. }
  3672. if ($ktime && $jtime) {
  3673. if ($type == 1) {
  3674. $tl = '出库';
  3675. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3676. } else if ($type == 2) {
  3677. $tl = '退库';
  3678. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3679. } else if ($type == 3) {
  3680. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3681. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3682. } else if ($type == 4) {
  3683. $tl = '出库+零售';
  3684. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3685. } else if ($type == 5) {
  3686. $tl = '零售';
  3687. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3688. }
  3689. }
  3690. $sidwhere = '';
  3691. if ($sid) {
  3692. $sd = "";
  3693. $s = explode(',', trim($sid, ','));
  3694. foreach ($s as $value) {
  3695. $sd .= " id = " . $value . " or";
  3696. }
  3697. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3698. }
  3699. //数据排序
  3700. $order_str = "time desc";
  3701. if (empty($page)) {
  3702. $start = 0;
  3703. $perpage = 1;
  3704. } else {
  3705. $start = ($page - 1) * $perpage;
  3706. }
  3707. //取得信息列表
  3708. if ($type != 3 && $type != 5) {
  3709. if ($type == 1 || $type == 4) {
  3710. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3711. foreach ($info_list as $key => $value) {
  3712. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3713. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3714. $warehouse = $this->warehouse->read($value['warehouse']);
  3715. $info_list[$key]['warehouse'] = $warehouse['title'];
  3716. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3717. $features = explode('-', trim($features, '-'));
  3718. $pm = $classid;
  3719. foreach ($features as $k => $v) {
  3720. if ($v != 0) {
  3721. if (!isset($typeclass[$v])) {
  3722. continue;
  3723. }
  3724. if (isset($pm[$typeclass[$v]['classid']])) {
  3725. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3726. $tz = explode('|', $typeclass[$v]['zh']);
  3727. $pm[$typeclass[$v]['classid']] = $tz[0];
  3728. } else {
  3729. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3730. }
  3731. }
  3732. }
  3733. }
  3734. $zh = implode(" ", $pm);
  3735. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3736. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3737. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3738. $info_list[$key]['features'] = $zh;
  3739. }
  3740. } else {
  3741. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3742. foreach ($info_list as $key => $value) {
  3743. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3744. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3745. $warehouse = $this->warehouse->read($value['warehouse']);
  3746. $info_list[$key]['warehouse'] = $warehouse['title'];
  3747. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3748. $features = explode('-', trim($features, '-'));
  3749. $pm = $classid;
  3750. foreach ($features as $k => $v) {
  3751. if ($v != 0) {
  3752. if (!isset($typeclass[$v])) {
  3753. continue;
  3754. }
  3755. if (isset($pm[$typeclass[$v]['classid']])) {
  3756. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3757. $tz = explode('|', $typeclass[$v]['zh']);
  3758. $pm[$typeclass[$v]['classid']] = $tz[0];
  3759. } else {
  3760. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3761. }
  3762. }
  3763. }
  3764. }
  3765. $zh = implode(" ", $pm);
  3766. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3767. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3768. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3769. $info_list[$key]['features'] = $zh;
  3770. }
  3771. }
  3772. $final_list = [];
  3773. foreach($info_list as $k=>$v){
  3774. //getInfo
  3775. $number = "";
  3776. if(!empty($v['orderinfo'])){
  3777. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number');
  3778. if(!empty($tmp_info['number'])){
  3779. $number = $tmp_info['number'];
  3780. }
  3781. }
  3782. $outtk = "";
  3783. if(isset($v['outtk'])){
  3784. $outtk = $v['outtk'];
  3785. }
  3786. if(isset($v['retreat'])){
  3787. $outtk = $v['retreat'];
  3788. }
  3789. $final_list[] = [
  3790. 'warehouse'=>$v['warehouse'],
  3791. 'purchase'=>$v['purchase'],
  3792. 'sku'=>$v['sku'],
  3793. 'title'=>$v['title'],
  3794. 'features'=>$v['features'],
  3795. 'label'=>$v['label'],
  3796. 'orderinfo'=>$v['orderinfo'],
  3797. 'number'=>$number,
  3798. 'waybill'=>$v['waybill'],
  3799. 'outtk'=>$outtk,
  3800. ];
  3801. }
  3802. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3803. $titlename = "<table border=1>
  3804. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3805. <tr align='center'>
  3806. <td>仓库</td>
  3807. <td>供应商</td>
  3808. <td>SKU</td>
  3809. <td>商品名称</td>
  3810. <td>商品中文</td>
  3811. <td>标签</td>
  3812. <td>订单号</td>
  3813. <td>订单编码</td>
  3814. <td>运单号</td>
  3815. <td>" . $tl . "时间(中国时间)</td>
  3816. </tr>
  3817. </table>";
  3818. $filename = $title . ".xls";
  3819. $tail = "";
  3820. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3821. } else if ($type == 5) {
  3822. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3823. foreach ($info_list as $key => $value) {
  3824. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3825. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3826. $warehouse = $this->warehouse->read($value['warehouse']);
  3827. $info_list[$key]['warehouse'] = $warehouse['title'];
  3828. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3829. $features = explode('-', trim($features, '-'));
  3830. $pm = $classid;
  3831. foreach ($features as $k => $v) {
  3832. if ($v != 0) {
  3833. if (!isset($typeclass[$v])) {
  3834. continue;
  3835. }
  3836. if (isset($pm[$typeclass[$v]['classid']])) {
  3837. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3838. $tz = explode('|', $typeclass[$v]['zh']);
  3839. $pm[$typeclass[$v]['classid']] = $tz[0];
  3840. } else {
  3841. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3842. }
  3843. }
  3844. }
  3845. }
  3846. $zh = implode(" ", $pm);
  3847. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3848. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3849. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3850. $info_list[$key]['features'] = $zh;
  3851. }
  3852. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3853. $titlename = "<table border=1>
  3854. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3855. <tr align='center'>
  3856. <td>仓库</td>
  3857. <td>供应商</td>
  3858. <td>SKU</td>
  3859. <td>商品名称</td>
  3860. <td>商品中文</td>
  3861. <td>标签</td>
  3862. <td>" . $tl . "时间(中国时间)</td>
  3863. </tr>
  3864. </table>";
  3865. $filename = $title . ".xls";
  3866. $tail = "";
  3867. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3868. } else {
  3869. /**
  3870. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  3871. $rows = array();$list = array();
  3872. foreach ($info_list as $key=>$value)
  3873. {
  3874. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  3875. }
  3876. **/
  3877. $wh = array();
  3878. $w = $this->warehouse->find_all('1=1', 'id,title');
  3879. foreach ($w as $v) {
  3880. $wh[$v['id']] = $v['title'];
  3881. }
  3882. $wt = array();
  3883. $whlabel_type = $this->whlabel_type->find_all();
  3884. foreach ($whlabel_type as $v) {
  3885. $wt[$v['id']] = $v['title'];
  3886. }
  3887. $classid = $this->classid->sku();
  3888. $list = array();
  3889. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  3890. foreach ($rows as $key => $value) {
  3891. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3892. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3893. $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');
  3894. $details = array();
  3895. $cpid = array();
  3896. $cpbz = array();
  3897. $c = 0;
  3898. $g = 0;
  3899. $x = 0;
  3900. $t = 0;
  3901. $s = 0;
  3902. $q = 0;
  3903. foreach ($sd as $k => $v) {
  3904. if ($v['state'] == 0) {
  3905. $c++;
  3906. }
  3907. if ($v['state'] != 9) {
  3908. $g++;
  3909. }
  3910. if ($v['outk'] > 1) {
  3911. $x++;
  3912. }
  3913. if ($v['retreat'] > 0) {
  3914. $t++;
  3915. }
  3916. if ($v['state'] == 8) {
  3917. $s++;
  3918. }
  3919. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3920. $q++;
  3921. }
  3922. $details[$v['details']] = $v['details'];
  3923. if ($v['cpid'] != 0) {
  3924. $cpid[$v['cpid']] = $v['cpid'];
  3925. }
  3926. if ($v['cpbz'] != '') {
  3927. $cpbz[$v['cpbz']] = $v['cpbz'];
  3928. }
  3929. }
  3930. if (isset($wt[$value['type']])) {
  3931. $rows[$key]['type'] = $wt[$value['type']];
  3932. } else {
  3933. $rows[$key]['type'] = '未设置';
  3934. }
  3935. $rows[$key]['details'] = implode("、", $details);
  3936. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3937. $ftime = time() - 15 * 24 * 3600;
  3938. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3939. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  3940. $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);
  3941. $rows[$key]['c'] = $c;
  3942. $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);
  3943. $rows[$key]['t'] = $t;
  3944. $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'] . '"');
  3945. $rows[$key]['z'] = $z;
  3946. // $jm = $classid;
  3947. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3948. $features = explode('-', trim($features, '-'));
  3949. // $pm = $classid;
  3950. // foreach ($features as $k => $v) {
  3951. // if ($v != 0) {
  3952. // if (!isset($typeclass[$v])) {
  3953. // continue;
  3954. // }
  3955. // if (isset($pm[$typeclass[$v]['classid']])) {
  3956. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3957. // $tz = explode('|', $typeclass[$v]['zh']);
  3958. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3959. // } else {
  3960. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3961. // }
  3962. // if (isset($jm[$typeclass[$v]['classid']])) {
  3963. // if ($typeclass[$v]['jm']) {
  3964. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3965. // }
  3966. // }
  3967. // }
  3968. // }
  3969. // }
  3970. // $zh = implode(" ", $pm);
  3971. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3972. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3973. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3974. // $rows[$key]['features'] = $zh;
  3975. // $jm = array_filter($jm); //去除空值
  3976. // $jm = implode("-", $jm);
  3977. // $rows[$key]['jm'] = $jm;
  3978. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  3979. }
  3980. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  3981. // echo "<pre>";
  3982. // print_r($tmp_list);
  3983. // die;
  3984. $final_list =[];
  3985. foreach($tmp_list as $k=>$v){
  3986. $final_list[] = [
  3987. "warehouse"=>$v['warehouse'],
  3988. "purchase"=>$v['purchase'],
  3989. "details"=>$v['details'],
  3990. "cpid"=>$v['cpid'],
  3991. "sku"=>$v['sku'],
  3992. "title"=>$v['title'],
  3993. "features"=>$v['pm'],
  3994. "cpbz"=>$v['cpbz'],
  3995. "sm"=>$v['sm'],
  3996. "type"=>$v['type'],
  3997. "g"=>$v["g"],
  3998. "c"=>$v["c"],
  3999. "x"=>$v["x"],
  4000. "t"=>$v["t"],
  4001. "z"=>$v["z"],
  4002. "jm"=>$v["jm"],
  4003. "weight"=>$v["weight"],
  4004. "asd"=>$v["asd"],
  4005. ];
  4006. }
  4007. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4008. $titlename = "<table border=1>
  4009. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4010. <tr align='center'>
  4011. <td>仓库</td>
  4012. <td>供应商</td>
  4013. <td>位置</td>
  4014. <td>库存编码</td>
  4015. <td>SKU</td>
  4016. <td>商品名称</td>
  4017. <td>商品中文</td>
  4018. <td>产品备注</td>
  4019. <td>说明</td>
  4020. <td>类型</td>
  4021. <td>入库总量</td>
  4022. <td>库存数量</td>
  4023. <td>销售数量</td>
  4024. <td>退货数量</td>
  4025. <td>占单数量</td>
  4026. <td>料号</td>
  4027. <td>重量</td>
  4028. <td>类目</td>
  4029. </tr>
  4030. </table>";
  4031. $filename = $title . ".xls";
  4032. $tail = "";
  4033. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4034. }
  4035. }
  4036. }
  4037. //出库+入库数据整合
  4038. public function _excelcr()
  4039. {
  4040. if (isset($_GET['excel'])) {
  4041. $type = $this->input->get('excel', true);
  4042. $category = $this->input->get('category', true);
  4043. $size = $this->input->get('size', true);
  4044. $grade = $this->input->get('grade', true);
  4045. $color = $this->input->get('color', true);
  4046. $lowe = $this->input->get('lowe', true);
  4047. $sku = $this->input->get('sku', true);
  4048. $warehouse = $this->input->get('warehouse', true);
  4049. $purchase = $this->input->get('purchase', true);
  4050. $state = $this->input->get('state', true);
  4051. $sid = $this->input->get('sid', true);
  4052. $ktime = $this->input->get('ktime', true);
  4053. $jtime = $this->input->get('jtime', true);
  4054. $ktime = strtotime($ktime);
  4055. $jtime = strtotime($jtime);
  4056. $where = "1=1";
  4057. $gj = "";
  4058. $ck = "";
  4059. if ($category) {
  4060. $where .= " and features like '%-$category-%'";
  4061. }
  4062. if ($size) {
  4063. $where .= " and features like '%-$size-%'";
  4064. }
  4065. if ($grade) {
  4066. $where .= " and features like '%-$grade-%'";
  4067. }
  4068. if ($color) {
  4069. $where .= " and features like '%-$color-%'";
  4070. }
  4071. if ($lowe) {
  4072. $where .= " and features like '%-$lowe-%'";
  4073. }
  4074. if ($warehouse) {
  4075. $where .= " and warehouse = '$warehouse'";
  4076. }
  4077. if ($purchase) {
  4078. $where .= " and purchase = '$purchase'";
  4079. }
  4080. if ($state) {
  4081. $where .= " and state = '$state'";
  4082. }
  4083. if ($sku) {
  4084. $where .= " and sku like '%$sku%'";
  4085. }
  4086. if ($ktime && $jtime) {
  4087. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4088. }
  4089. $sidwhere = '';
  4090. if ($sid) {
  4091. $sd = "";
  4092. $s = explode(',', trim($sid, ','));
  4093. foreach ($s as $value) {
  4094. $sd .= " id = " . $value . " or";
  4095. }
  4096. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4097. }
  4098. //取得信息列表
  4099. $timeread = $ktime;
  4100. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4101. $timelist = array();
  4102. for ($i = 0; $i < $timenum; $i++) {
  4103. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4104. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4105. }
  4106. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4107. //echo "<pre>";
  4108. //print_r($info_list);
  4109. //exit();
  4110. $rows = array();
  4111. $list = array();
  4112. foreach ($info_list as $key => $value) {
  4113. $thistime = $timelist;
  4114. if (isset($rows[strtolower($value['sku'])])) {
  4115. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4116. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4117. }
  4118. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4119. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4120. }
  4121. } else {
  4122. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4123. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4124. }
  4125. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4126. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4127. }
  4128. $rows[strtolower($value['sku'])] = $thistime;
  4129. }
  4130. }
  4131. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4132. <head>
  4133. <!--[if gte mso 9]><xml>
  4134. <x:ExcelWorkbook>
  4135. <x:ExcelWorksheets>
  4136. <x:ExcelWorksheet>
  4137. <x:Name>EXCEL</x:Name>
  4138. <x:WorksheetOptions>
  4139. <x:Print>
  4140. <x:ValidPrinterInfo />
  4141. </x:Print>
  4142. </x:WorksheetOptions>
  4143. </x:ExcelWorksheet>
  4144. </x:ExcelWorksheets>
  4145. </x:ExcelWorkbook>
  4146. </xml>
  4147. <![endif]-->
  4148. </head><body>";
  4149. $str .= "<table border=1><tr><td>SKU</td>";
  4150. foreach ($timelist as $k => $v) {
  4151. $str .= "<td>" . $k . "出库</td>";
  4152. $str .= "<td>" . $k . "入库</td>";
  4153. }
  4154. $str .= "</tr></table>";
  4155. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4156. foreach ($rows as $key => $val) {
  4157. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4158. foreach ($val as $k => $v) {
  4159. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4160. if ($val[$k]['r'] > 0) {
  4161. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4162. } else {
  4163. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4164. }
  4165. }
  4166. $str .= "</tr>";
  4167. }
  4168. $str .= "</table>";
  4169. $str .= "</body></html>";
  4170. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4171. header("Content-type: application/octet-stream");
  4172. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4173. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4174. header("Pragma: no-cache");
  4175. header("Expires: 0");
  4176. exit($str);
  4177. }
  4178. }
  4179. //数量调整模板导出
  4180. public function _presetout()
  4181. {
  4182. if (isset($_GET['excel'])) {
  4183. $where = "sku != 'Preset' and purchase != 0";
  4184. //数据排序
  4185. $order_str = "id desc";
  4186. if (empty($page)) {
  4187. $start = 0;
  4188. $perpage = 1;
  4189. } else {
  4190. $start = ($page - 1) * $perpage;
  4191. }
  4192. //取得信息列表
  4193. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4194. $rows = array();
  4195. $list = array();
  4196. foreach ($info_list as $value) {
  4197. $warehouse = $this->warehouse->read($value['warehouse']);
  4198. $number = $value['number'];
  4199. $ftime = time() - 15 * 24 * 3600;
  4200. $purchase = $this->purchase->read($value['purchase']);
  4201. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4202. }
  4203. $title = "库存模板";
  4204. $titlename = "<table border=1>
  4205. <tr align='center'>
  4206. <td>仓库</td>
  4207. <td>供应商编码</td>
  4208. <td>SKU</td>
  4209. <td>增减数量(正数或负数)</td>
  4210. <td>增减备注</td>
  4211. <td>扣减方式:0减少库存1删除库存</td>
  4212. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4213. <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4214. </tr>
  4215. </table>";
  4216. $filename = $title . ".xls";
  4217. $tail = "";
  4218. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4219. }
  4220. }
  4221. //数量调整模板导入
  4222. public function _presetedit()
  4223. {
  4224. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4225. $config['upload_path'] = '.' . $dir;
  4226. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4227. $config['allowed_types'] = 'xls|xlsx|csv';
  4228. $config['max_size'] = 10240;
  4229. $this->load->library('upload', $config);
  4230. $this->upload->initialize($config);
  4231. if ($this->upload->do_upload('userfile')) {
  4232. $full_path = $dir . $this->upload->data('file_name');
  4233. $fileName = '.' . $full_path;
  4234. if (!file_exists($fileName)) {
  4235. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4236. exit;
  4237. } else {
  4238. require_once "./data/excel/PHPExcel/IOFactory.php";
  4239. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4240. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4241. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4242. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4243. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4244. ++$column; //如果列数大于26行
  4245. $list = array();
  4246. for ($i = 2; $i <= $row; $i++) // 行数循环
  4247. {
  4248. $data = array();
  4249. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4250. {
  4251. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4252. }
  4253. $list[] = $data;
  4254. }
  4255. }
  4256. $i = 0;
  4257. $j = 0;
  4258. $ed = array();
  4259. foreach ($list as $key => $value) {
  4260. $time = time();
  4261. if ($value['0'] == "") {
  4262. continue;
  4263. }
  4264. $warehouse = $this->warehouse->get_title($value['0']);
  4265. $purchase = $this->purchase->get_bm($value['1']);
  4266. $sku = $value['2'];
  4267. $num = $value['3']; //调整数量
  4268. $text = $value['4']; //扣减说明
  4269. $type = $value['5']; //调整方式0扣减1删除
  4270. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4271. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4272. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4273. if (!$purchase) //如果没有这个SKU
  4274. {
  4275. $ed[] = array($purchase . '-不存在此供应商编码');
  4276. $j++;
  4277. continue;
  4278. }
  4279. if (!$d) //如果没有这个SKU
  4280. {
  4281. $ed[] = array($sku . '-库存中不存在此SKU');
  4282. $j++;
  4283. continue;
  4284. }
  4285. if (!isset($warehouse['id'])) {
  4286. $ed[] = array($sku . '-仓库名错误!');
  4287. $j++;
  4288. continue;
  4289. }
  4290. if ($type != '0' && $type != '1') {
  4291. $ed[] = array($sku . '-扣减方式填写错误!');
  4292. $j++;
  4293. continue;
  4294. }
  4295. if ($num < 0) //扣减库存
  4296. {
  4297. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4298. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4299. $j++;
  4300. continue;
  4301. }
  4302. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4303. if (count($data) < abs($num)) {
  4304. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4305. $j++;
  4306. continue;
  4307. }
  4308. if ($type == 0) //如果扣减方式为 扣减库存
  4309. {
  4310. for ($i = 0; $i < abs($num); $i++) {
  4311. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4312. }
  4313. } else if ($type == 1) {
  4314. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4315. if (count($zt) > 0) {
  4316. $ed[] = array($sku . '-有在途库存无法删除!');
  4317. $j++;
  4318. continue;
  4319. }
  4320. for ($i = 0; $i < abs($num); $i++) {
  4321. $this->whlabel->remove($data[$i]['id']);
  4322. }
  4323. }
  4324. } else if ($num > 0) //增加库存
  4325. {
  4326. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4327. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4328. $j++;
  4329. continue;
  4330. }
  4331. $post['sku'] = $d['sku'];
  4332. $post['shop'] = $d['shop'];
  4333. $post['warehouse'] = $warehouse['id'];
  4334. $post['purchase'] = $purchase['id'];
  4335. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4336. $post['state'] = 0;
  4337. $post['title'] = $d['title'];
  4338. $post['number'] = $d['number'];
  4339. $post['features'] = $d['features'];
  4340. $post['enter'] = $time;
  4341. $post['time'] = $time; //操作时间
  4342. $post['rktype'] = $rktype;
  4343. for ($i = 0; $i < $num; $i++) {
  4344. $post['label'] = time() . rand(100, 999) . $i;
  4345. $this->whlabel->insert($post);
  4346. }
  4347. }
  4348. sleep(1); //防止入库时间一样,需要延迟1秒
  4349. }
  4350. if ($j > 0) {
  4351. $tt = date('Ymd', time());
  4352. $title = '库存导入错误信息-' . $tt;
  4353. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4354. $tail = "\n";
  4355. $filename = $title . ".xls";
  4356. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4357. $dir = '/data/excel/' . $time . '/';
  4358. $file_name = 'error_' . $time . rand(1000, 9999);
  4359. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4360. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4361. fwrite($myfile, $ecl);
  4362. fclose($myfile);
  4363. $error = $dir . $file_name . '.xls';
  4364. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4365. exit;
  4366. } else {
  4367. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4368. exit;
  4369. }
  4370. }
  4371. }
  4372. //笛卡儿积
  4373. function cp($ps, $sets, $list)
  4374. {
  4375. $result = array();
  4376. $j = 0;
  4377. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4378. if ($i == 0) {
  4379. $result = $sets[$i];
  4380. }
  4381. $tmp = array();
  4382. foreach ($result as $res) {
  4383. foreach ($sets[$i + 1] as $set) {
  4384. $tmp[] = $res . ',' . $set;
  4385. }
  4386. }
  4387. $result = $tmp;
  4388. }
  4389. $this->db->trans_begin();
  4390. foreach ($result as $v) {
  4391. $post = array();
  4392. $title = "";
  4393. $num = "";
  4394. $data = explode(',', $v);
  4395. for ($i = 0; $i < count($list); $i++) {
  4396. $post[$list[$i]] = $data[$i];
  4397. $typeclass = $this->typeclass->read($data[$i]);
  4398. $title = $title . $typeclass['title'] . " ";
  4399. if ($data[$i] != 0) {
  4400. $num .= $data[$i]; //所有数据ID拼接
  4401. }
  4402. }
  4403. foreach ($ps as $kp => $vp) {
  4404. $post[$kp] = $vp;
  4405. }
  4406. $post['number'] = $num;
  4407. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4408. if ($info_list) {
  4409. $j++;
  4410. } else {
  4411. $skunum = $this->whlabel->find_count();
  4412. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4413. $post['title'] = rtrim($title, ' ');
  4414. $this->whlabel->insert($post);
  4415. }
  4416. }
  4417. if ($this->db->trans_status() === FALSE) {
  4418. $this->db->trans_commit();
  4419. return NULL;
  4420. } else {
  4421. $this->db->trans_commit();
  4422. return $j;
  4423. }
  4424. }
  4425. public function _kj($arg_array)
  4426. {
  4427. if (isset($_POST['sku'])) {
  4428. $time = time();
  4429. $sku = $this->input->post('sku', true);
  4430. $warehouse = $this->input->post('warehouse', true);
  4431. $num = $this->input->post('num', true);
  4432. $text = $this->input->post('text', true);
  4433. $purchase = $this->input->post('purchase', true);
  4434. $cktype = $this->input->post('cktype', true);
  4435. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4436. if ($cktype != 1 && $text == '') {
  4437. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4438. exit;
  4439. }
  4440. if ($num > count($order)) {
  4441. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4442. exit;
  4443. } else {
  4444. for ($i = 0; $i < $num; $i++) {
  4445. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4446. }
  4447. }
  4448. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4449. exit;
  4450. }
  4451. $uid = $this->whlabel->read($arg_array[0]);
  4452. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4453. $this->data['data'] = $uid;
  4454. $this->_Template('whlabel_kj', $this->data);
  4455. }
  4456. public function _summary($arg_array)
  4457. {
  4458. $prc = array();
  4459. $purchase = $this->purchase->find_all();
  4460. foreach ($purchase as $k => $v) {
  4461. $prc[$v['id']] = $v['title'];
  4462. }
  4463. if (isset($_GET['excel'])) {
  4464. $ktime = $this->input->get('ktime', true);
  4465. $jtime = $this->input->get('jtime', true);
  4466. $ktime = strtotime($ktime);
  4467. $jtime = strtotime($jtime);
  4468. $where = "1=1";
  4469. if ($ktime && $jtime) {
  4470. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4471. }
  4472. //数据排序
  4473. $order_str = "time desc";
  4474. if (empty($page)) {
  4475. $start = 0;
  4476. $perpage = 1;
  4477. } else {
  4478. $start = ($page - 1) * $perpage;
  4479. }
  4480. //取得信息列表
  4481. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4482. foreach ($info_list as $key => $value) {
  4483. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4484. $warehouse = $this->warehouse->read($value['warehouse']);
  4485. $info_list[$key]['warehouse'] = $warehouse['title'];
  4486. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4487. $details = array();
  4488. $cpid = array();
  4489. foreach ($x as $k => $v) {
  4490. if ($v['details'] != '') {
  4491. $details[$v['details']] = $v['details'];
  4492. }
  4493. if ($v['cpid'] != 0) {
  4494. $cpid[$v['cpid']] = $v['cpid'];
  4495. }
  4496. }
  4497. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4498. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4499. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4500. $info_list[$key]['s'] = $s;
  4501. $info_list[$key]['x'] = count($x);
  4502. }
  4503. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4504. $titlename = "<table border=1>
  4505. <tr align='center'>
  4506. <td>仓库</td>
  4507. <td>供应商</td>
  4508. <td>出库位置</td>
  4509. <td>出库编码</td>
  4510. <td>SKU</td>
  4511. <td>产品名</td>
  4512. <td>总剩余库存</td>
  4513. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4514. </tr>
  4515. </table>";
  4516. $filename = $title . ".xls";
  4517. $tail = "";
  4518. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4519. }
  4520. }
  4521. //usps发货清单
  4522. public function _manifest()
  4523. {
  4524. if (isset($_POST['manifest'])) {
  4525. $wltext = $this->input->post('wltext', true);
  4526. $time = time() - 16 * 3600;
  4527. $ptime = strtotime(date('Y-m-d', $time));
  4528. $waybill = array();
  4529. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4530. foreach ($fullorder as $v) {
  4531. $waybill[$v['waybill']] = $v['waybill'];
  4532. }
  4533. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4534. foreach ($fullordersmt as $v) {
  4535. $waybill[$v['waybill']] = $v['waybill'];
  4536. }
  4537. $wltext = explode(';', $wltext);
  4538. foreach ($wltext as $v) {
  4539. if (isset($waybill[$v])) {
  4540. unset($waybill[$v]);
  4541. }
  4542. }
  4543. $data = $this->usps->get_manifest($waybill);
  4544. if (isset($data['Description'])) {
  4545. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4546. exit;
  4547. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4548. $bctime = date('Ymd', time());
  4549. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4550. echo json_encode(array('msg' => $pdf, 'success' => true));
  4551. exit;
  4552. } else {
  4553. echo json_encode(array('msg' => $data, 'success' => false));
  4554. exit;
  4555. }
  4556. }
  4557. }
  4558. public function _pdf($pdf, $title, $bctime)
  4559. {
  4560. $pdf_path = './data/pdf/' . $bctime . '/';
  4561. $file_base64 = $pdf;
  4562. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4563. $file_base64 = base64_decode($file_base64);
  4564. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4565. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4566. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4567. }
  4568. /**
  4569. *
  4570. *
  4571. *
  4572. 进销存占单异常索引
  4573. *
  4574. *
  4575. *
  4576. **/
  4577. public function _abnormal()
  4578. {
  4579. $post = $this->input->post(NULL, TRUE);
  4580. if (isset($post['page'])) {
  4581. $page = $this->input->post('page', true);
  4582. $perpage = $this->input->post('perpage', true);
  4583. $sku = $this->input->post('sku', true);
  4584. $where = "1=1";
  4585. //数据排序
  4586. $order_str = "id desc";
  4587. if (empty($page)) {
  4588. $start = 0;
  4589. $perpage = 1;
  4590. } else {
  4591. $start = ($page - 1) * $perpage;
  4592. }
  4593. //取得信息列表
  4594. $info_list = $this->whlabel->find_all($where, '*');
  4595. $rows = array();
  4596. $list = array();
  4597. foreach ($info_list as $key => $value) {
  4598. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4599. }
  4600. foreach ($rows as $value) {
  4601. $warehouse = $this->warehouse->read($value['warehouse']);
  4602. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4603. $number = $value['number'];
  4604. $ftime = time() - 15 * 24 * 3600;
  4605. if ($value['shop'] != '') {
  4606. $shop = $value['shop'];
  4607. $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');
  4608. $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');
  4609. $order = array_merge($orderdlz, $ordersmt);
  4610. $od = 0;
  4611. $a = '';
  4612. $orid = '';
  4613. foreach ($order as $v) {
  4614. $or = explode('|', ltrim($v['whlabel'], '|'));
  4615. for ($i = 0; $i < count($or); $i++) {
  4616. $orod = explode('-', $or[$i]);
  4617. if ($orod[0] == $number) {
  4618. $od += $orod[1];
  4619. }
  4620. }
  4621. $orid .= $v['number'] . '-';
  4622. }
  4623. } else {
  4624. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4625. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4626. $order = array_merge($orderdlz, $ordersmt);
  4627. $od = 0;
  4628. $a = '';
  4629. $orid = '';
  4630. $qt = array();
  4631. foreach ($order as $v) {
  4632. $or = explode('|', ltrim($v['whlabel'], '|'));
  4633. for ($i = 0; $i < count($or); $i++) {
  4634. $orod = explode('-', $or[$i]);
  4635. if ($orod[0] == $number) {
  4636. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4637. if ($czzs > 0) {
  4638. if (isset($qt[$v['shop']])) {
  4639. if ($qt[$v['shop']] < $orod[1]) {
  4640. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4641. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4642. } else {
  4643. $qt[$v['shop']] -= $orod[1];
  4644. }
  4645. } else {
  4646. $qt[$v['shop']] = $czzs;
  4647. }
  4648. } else {
  4649. $od += $orod[1];
  4650. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4651. }
  4652. }
  4653. }
  4654. }
  4655. }
  4656. $z = $od . '(' . $orid . ')'; //查看订单号
  4657. //$z = $od;
  4658. if ($od > $c) {
  4659. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4660. }
  4661. }
  4662. $listdata = array_slice($list, $start, $perpage);
  4663. $total = count($list);
  4664. $pagenum = ceil($total / $perpage);
  4665. $over = $total - ($start + $perpage);
  4666. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4667. echo json_encode($rows);
  4668. exit;
  4669. }
  4670. $this->_Template('whlabel_abnormal', $this->data);
  4671. }
  4672. /**
  4673. *
  4674. *
  4675. *
  4676. 进销存占单异常索引
  4677. *
  4678. *
  4679. *
  4680. **/
  4681. public function _error()
  4682. {
  4683. $post = $this->input->post(NULL, TRUE);
  4684. if (isset($post['page'])) {
  4685. $page = $this->input->post('page', true);
  4686. $perpage = $this->input->post('perpage', true);
  4687. $sku = $this->input->post('sku', true);
  4688. $warehouse = $this->input->post('warehouse', true);
  4689. $ktime = $this->input->post('ktime', true);
  4690. $jtime = $this->input->post('jtime', true);
  4691. $ktime = strtotime($ktime);
  4692. $jtime = strtotime($jtime);
  4693. $where = "sku != 'Preset'";
  4694. $gj = '';
  4695. if ($sku) {
  4696. $where .= " and sku like '%$sku%'";
  4697. } else {
  4698. if ($ktime && $jtime) {
  4699. $gj = " and time > '$ktime' and time < '$jtime'";
  4700. }
  4701. }
  4702. if ($warehouse) {
  4703. $where .= " and warehouse = '$warehouse'";
  4704. }
  4705. //数据排序
  4706. $order_str = "id desc";
  4707. if (empty($page)) {
  4708. $start = 0;
  4709. $perpage = 1;
  4710. } else {
  4711. $start = ($page - 1) * $perpage;
  4712. }
  4713. //取得信息列表
  4714. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4715. $rows = array();
  4716. $list = array();
  4717. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4718. // foreach ($info_list as $value)
  4719. // {
  4720. // $warehouse = $this->warehouse->read($value['warehouse']);
  4721. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4722. // $number = $value['number'];$ftime = time()-15*24*3600;
  4723. // if($c < 1)
  4724. // {
  4725. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4726. // }
  4727. // }
  4728. $warehouse_list = $this->warehouse->find_all();
  4729. $warehouse_list = array_column($warehouse_list, null, 'id');
  4730. foreach ($info_list as $value) {
  4731. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4732. 'title' => "",
  4733. ];
  4734. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4735. $number = $value['number'];
  4736. $ftime = time() - 15 * 24 * 3600;
  4737. if ($c < 1) {
  4738. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4739. }
  4740. }
  4741. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4742. // $query = $this->db->query($sql);
  4743. // $info_list = $query->result_array();
  4744. // $sql_two = "select title,id from crowd_warehouse";
  4745. // $query_two = $this->db->query($sql_two);
  4746. // $warehouse_list = $query_two->result_array();
  4747. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4748. // foreach ($info_list as $value)
  4749. // {
  4750. // if(isset($warehouse_arr[$value['warehouse']])){
  4751. // $warehouse = $warehouse_arr[$value['warehouse']];
  4752. // }else{
  4753. // $warehouse = [
  4754. // 'id'=>0,
  4755. // 'title'=>"异常",
  4756. // ];
  4757. // }
  4758. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4759. // $number = $value['number'];$ftime = time()-15*24*3600;
  4760. // if($c < 1)
  4761. // {
  4762. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4763. // }
  4764. // }
  4765. $listdata = array_slice($list, $start, $perpage);
  4766. $total = count($list);
  4767. $pagenum = ceil($total / $perpage);
  4768. $over = $total - ($start + $perpage);
  4769. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4770. echo json_encode($rows);
  4771. exit;
  4772. }
  4773. if (isset($post['s'])) {
  4774. $id_arr = $this->input->post('s');
  4775. $id_arr = explode(',', trim($id_arr, ','));
  4776. if (!$id_arr) {
  4777. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4778. exit;
  4779. }
  4780. //循环删除记录
  4781. foreach ($id_arr as $v) {
  4782. $dd = $this->whlabel->read($v);
  4783. if (!isset($dd['id'])) {
  4784. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4785. exit;
  4786. }
  4787. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4788. if (isset($zt[0])) {
  4789. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4790. exit;
  4791. }
  4792. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4793. foreach ($deldd as $vv) {
  4794. $this->whlabel->remove($vv['id']);
  4795. }
  4796. }
  4797. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4798. exit;
  4799. }
  4800. $this->_Template('whlabel_error', $this->data);
  4801. }
  4802. public function _errorexcel()
  4803. {
  4804. $post = $this->input->post(NULL, TRUE);
  4805. if (isset($_GET['page'])) {
  4806. $page = $this->input->get('page', true);
  4807. $perpage = $this->input->get('perpage', true);
  4808. $sku = $this->input->get('sku', true);
  4809. $warehouse = $this->input->get('warehouse', true);
  4810. $ktime = $this->input->get('ktime', true);
  4811. $jtime = $this->input->get('jtime', true);
  4812. $ktime = strtotime($ktime);
  4813. $jtime = strtotime($jtime);
  4814. $where = "sku != 'Preset'";
  4815. $gj = '';
  4816. if ($sku) {
  4817. $where .= " and sku like '%$sku%'";
  4818. } else {
  4819. if ($ktime && $jtime) {
  4820. $gj = " and time > '$ktime' and time < '$jtime'";
  4821. }
  4822. }
  4823. if ($warehouse) {
  4824. $where .= " and warehouse = '$warehouse'";
  4825. }
  4826. //数据排序
  4827. $order_str = "id desc";
  4828. if (empty($page)) {
  4829. $start = 0;
  4830. $perpage = 1;
  4831. } else {
  4832. $start = ($page - 1) * $perpage;
  4833. }
  4834. //取得信息列表
  4835. $rows = array();
  4836. $list = array();
  4837. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4838. foreach ($info_list as $value) {
  4839. $warehouse = $this->warehouse->read($value['warehouse']);
  4840. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4841. $number = $value['number'];
  4842. $ftime = time() - 15 * 24 * 3600;
  4843. if ($c < 1) {
  4844. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4845. }
  4846. }
  4847. $title = "0库存汇总";
  4848. $titlename = "<table border=1>
  4849. <tr align='center'>
  4850. <td>仓库</td>
  4851. <td>SKU</td>
  4852. <td>产品</td>
  4853. <td>当前库存</td>
  4854. </tr>
  4855. </table>";
  4856. $filename = $title . ".xls";
  4857. $tail = "";
  4858. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4859. }
  4860. }
  4861. /**
  4862. *
  4863. *
  4864. * 占单
  4865. *
  4866. *
  4867. **/
  4868. public function _kcyz()
  4869. {
  4870. $post = $this->input->post(NULL, TRUE);
  4871. if (isset($post['warehouse'])) {
  4872. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  4873. exit; //不再使用
  4874. $warehouse = $this->input->post('warehouse', true);
  4875. $whlabel = $this->input->post('whlabel', true);
  4876. $id = $this->input->post('id', true);
  4877. $shop = $this->input->post('shop', true);
  4878. $number = $this->input->post('number', true);
  4879. if (!$whlabel || $whlabel == '|') {
  4880. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  4881. exit;
  4882. }
  4883. $pp = explode('|', trim($whlabel, '|'));
  4884. $x = 0;
  4885. $save = array();
  4886. foreach ($pp as $va) {
  4887. $num = explode('-', $va);
  4888. if ($number) {
  4889. $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 = '')"); //通用
  4890. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  4891. } else {
  4892. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  4893. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  4894. }
  4895. $x++;
  4896. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  4897. $save[] = $x - 1;
  4898. continue; //提前先加X不然出错,所以要减1
  4899. }
  4900. }
  4901. if (isset($save[0])) {
  4902. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  4903. exit;
  4904. } else {
  4905. echo json_encode(array('success' => true));
  4906. exit;
  4907. }
  4908. }
  4909. }
  4910. public function _db()
  4911. {
  4912. $post = $this->input->post(NULL, TRUE);
  4913. if (isset($post['page'])) {
  4914. $page = $this->input->post('page', true);
  4915. $perpage = $this->input->post('perpage', true);
  4916. $sku = $this->input->post('sku', true);
  4917. $number = $this->input->post('number', true);
  4918. $warehouse = $this->input->post('warehouse', true);
  4919. $purchase = $this->input->post('purchase', true);
  4920. $orderinfo = $this->input->post('orderinfo', true);
  4921. $waybill = $this->input->post('waybill', true);
  4922. $category = $this->input->post('category', true);
  4923. $size = $this->input->post('size', true);
  4924. $grade = $this->input->post('grade', true);
  4925. $color = $this->input->post('color', true);
  4926. $lowe = $this->input->post('lowe', true);
  4927. $state = $this->input->post('state', true);
  4928. $label = $this->input->post('label', true);
  4929. $timetk = $this->input->post('timetkk', true);
  4930. $timetj = $this->input->post('timetjj', true);
  4931. $timetk = strtotime($timetk);
  4932. $timetj = strtotime($timetj);
  4933. $where = "dbtime > 0";
  4934. if ($timetk && $timetj) {
  4935. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  4936. }
  4937. if ($sku) {
  4938. $where .= " and sku = '$sku'";
  4939. }
  4940. if ($warehouse) {
  4941. $where .= " and warehouse = '$warehouse'";
  4942. if ($warehouse == 12) {
  4943. $w = 'specialstock';
  4944. } else {
  4945. $w = 'whlabel';
  4946. }
  4947. }
  4948. if ($purchase) {
  4949. $where .= " and purchase = '$purchase'";
  4950. }
  4951. if ($category) {
  4952. $where .= " and features like '%-$category-%'";
  4953. }
  4954. if ($size) {
  4955. $where .= " and features like '%-$size-%'";
  4956. }
  4957. if ($grade) {
  4958. $where .= " and features like '%-$grade-%'";
  4959. }
  4960. if ($color) {
  4961. $where .= " and features like '%-$color-%'";
  4962. }
  4963. if ($lowe) {
  4964. $where .= " and features like '%-$lowe-%'";
  4965. }
  4966. if ($state != '') {
  4967. $where .= " and state = '$state'";
  4968. }
  4969. //数据排序
  4970. $order_str = "dbtime desc";
  4971. if (empty($page)) {
  4972. $start = 0;
  4973. $perpage = 1;
  4974. } else {
  4975. $start = ($page - 1) * $perpage;
  4976. }
  4977. //取得信息列表
  4978. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  4979. foreach ($info_list as $key => $value) {
  4980. $warehouse = $this->$w->read($value['warehouse']);
  4981. $info_list[$key]['warehouse'] = $warehouse['title'];
  4982. $purchase = $this->purchase->read($value['purchase']);
  4983. $info_list[$key]['purchase'] = $purchase['title'];
  4984. if ($value['enter'] != 0) {
  4985. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  4986. } else {
  4987. $info_list[$key]['enter'] = "";
  4988. }
  4989. if ($value['dbtime'] != 0) {
  4990. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  4991. } else {
  4992. $info_list[$key]['dbtime'] = "";
  4993. }
  4994. if ($value['state'] == 0) {
  4995. $info_list[$key]['state'] = "在库";
  4996. } else if ($value['state'] == 1) {
  4997. $info_list[$key]['state'] = "出库";
  4998. } else if ($value['state'] == 2) {
  4999. $info_list[$key]['state'] = "退库";
  5000. } else if ($value['state'] == 3) {
  5001. $info_list[$key]['state'] = "调拨中";
  5002. } else if ($value['state'] == 4) {
  5003. $info_list[$key]['state'] = "再加工";
  5004. } else if ($value['state'] == 5) {
  5005. $info_list[$key]['state'] = "维修中";
  5006. } else if ($value['state'] == 6) {
  5007. $info_list[$key]['state'] = "盘亏";
  5008. } else if ($value['state'] == 7) {
  5009. $info_list[$key]['state'] = "更换标签";
  5010. } else if ($value['state'] == 8) {
  5011. $info_list[$key]['state'] = "其它";
  5012. } else if ($value['state'] == 9) {
  5013. $info_list[$key]['state'] = "预设";
  5014. }
  5015. }
  5016. $total = $this->whlabel->find_count($where);
  5017. $pagenum = ceil($total / $perpage);
  5018. $over = $total - ($start + $perpage);
  5019. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5020. echo json_encode($rows);
  5021. exit;
  5022. }
  5023. if (isset($post['outsku'])) {
  5024. $time = time();
  5025. $cz = $this->input->post('cz', true);
  5026. $label = $this->input->post('outsku', true);
  5027. $sl = $this->input->post('sl', true);
  5028. $num = $this->input->post('num', true);
  5029. //$warehouse = $this->input->post('warehouse',true);
  5030. if (!$sl) {
  5031. $sl = 1;
  5032. }
  5033. if (!$warehouse) {
  5034. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5035. exit;
  5036. }
  5037. $dblabel = $this->whlabellabel->get_label($label);
  5038. if ($dblabel) {
  5039. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5040. if (count($data) < 1) {
  5041. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5042. exit;
  5043. }
  5044. if (count($data) < $num) {
  5045. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5046. exit;
  5047. }
  5048. for ($i = 0; $i < $sl; $i++) {
  5049. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5050. }
  5051. echo json_encode(array('success' => true));
  5052. exit;
  5053. } else {
  5054. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5055. exit;
  5056. }
  5057. }
  5058. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5059. $this->_Template('whlabel_db', $this->data);
  5060. }
  5061. public function _dbrk()
  5062. {
  5063. $post = $this->input->post(NULL, TRUE);
  5064. if (isset($post['page'])) {
  5065. $page = $this->input->post('page', true);
  5066. $perpage = $this->input->post('perpage', true);
  5067. $sku = $this->input->post('sku', true);
  5068. $number = $this->input->post('number', true);
  5069. $warehouse = $this->input->post('warehouse', true);
  5070. $purchase = $this->input->post('purchase', true);
  5071. $orderinfo = $this->input->post('orderinfo', true);
  5072. $waybill = $this->input->post('waybill', true);
  5073. $category = $this->input->post('category', true);
  5074. $size = $this->input->post('size', true);
  5075. $grade = $this->input->post('grade', true);
  5076. $color = $this->input->post('color', true);
  5077. $lowe = $this->input->post('lowe', true);
  5078. $state = $this->input->post('state', true);
  5079. $label = $this->input->post('label', true);
  5080. $ctime = $this->input->post('ctime', true);
  5081. $timetk = $this->input->post('timetkk', true);
  5082. $timetj = $this->input->post('timetjj', true);
  5083. $timetk = strtotime($timetk);
  5084. $timetj = strtotime($timetj);
  5085. $where = "dbtime > 0";
  5086. if ($timetk && $timetj) {
  5087. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5088. }
  5089. if ($sku) {
  5090. $where .= " and sku = '$sku'";
  5091. }
  5092. if ($warehouse) {
  5093. $where .= " and warehouse = '$warehouse'";
  5094. }
  5095. if ($purchase) {
  5096. $where .= " and purchase = '$purchase'";
  5097. }
  5098. if ($category) {
  5099. $where .= " and features like '%-$category-%'";
  5100. }
  5101. if ($size) {
  5102. $where .= " and features like '%-$size-%'";
  5103. }
  5104. if ($grade) {
  5105. $where .= " and features like '%-$grade-%'";
  5106. }
  5107. if ($color) {
  5108. $where .= " and features like '%-$color-%'";
  5109. }
  5110. if ($lowe) {
  5111. $where .= " and features like '%-$lowe-%'";
  5112. }
  5113. if ($state != '') {
  5114. $where .= " and state = '$state'";
  5115. }
  5116. //数据排序
  5117. $order_str = "dbtime desc";
  5118. if (empty($page)) {
  5119. $start = 0;
  5120. $perpage = 1;
  5121. } else {
  5122. $start = ($page - 1) * $perpage;
  5123. }
  5124. //取得信息列表
  5125. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5126. foreach ($info_list as $key => $value) {
  5127. $warehouse = $this->warehouse->read($value['warehouse']);
  5128. $info_list[$key]['warehouse'] = $warehouse['title'];
  5129. $purchase = $this->purchase->read($value['purchase']);
  5130. $info_list[$key]['purchase'] = $purchase['title'];
  5131. if ($value['enter'] != 0) {
  5132. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5133. } else {
  5134. $info_list[$key]['enter'] = "";
  5135. }
  5136. if ($value['dbtime'] != 0) {
  5137. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5138. } else {
  5139. $info_list[$key]['dbtime'] = "";
  5140. }
  5141. if ($value['state'] == 0) {
  5142. $info_list[$key]['state'] = "在库";
  5143. } else if ($value['state'] == 1) {
  5144. $info_list[$key]['state'] = "出库";
  5145. } else if ($value['state'] == 2) {
  5146. $info_list[$key]['state'] = "退库";
  5147. } else if ($value['state'] == 3) {
  5148. $info_list[$key]['state'] = "调拨中";
  5149. } else if ($value['state'] == 4) {
  5150. $info_list[$key]['state'] = "再加工";
  5151. } else if ($value['state'] == 5) {
  5152. $info_list[$key]['state'] = "维修中";
  5153. } else if ($value['state'] == 6) {
  5154. $info_list[$key]['state'] = "盘亏";
  5155. } else if ($value['state'] == 7) {
  5156. $info_list[$key]['state'] = "更换标签";
  5157. } else if ($value['state'] == 8) {
  5158. $info_list[$key]['state'] = "其它";
  5159. } else if ($value['state'] == 9) {
  5160. $info_list[$key]['state'] = "预设";
  5161. }
  5162. }
  5163. $total = $this->whlabel->find_count($where);
  5164. $pagenum = ceil($total / $perpage);
  5165. $over = $total - ($start + $perpage);
  5166. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5167. echo json_encode($rows);
  5168. exit;
  5169. }
  5170. if (isset($post['rsku'])) {
  5171. $cz = $this->input->post('cz', true);
  5172. $label = $this->input->post('rsku', true);
  5173. $sl = $this->input->post('sl', true);
  5174. $warehouse = $this->input->post('warehouse', true);
  5175. if (!$sl) {
  5176. $sl = 1;
  5177. }
  5178. if (!$warehouse) {
  5179. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5180. exit;
  5181. }
  5182. $dblabel = $this->whlabellabel->get_label($label);
  5183. if ($dblabel) {
  5184. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5185. if (count($data) < 1) {
  5186. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5187. exit;
  5188. }
  5189. if ($sl > count($data)) {
  5190. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5191. exit;
  5192. }
  5193. $time = time();
  5194. for ($i = 0; $i < $sl; $i++) {
  5195. $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']);
  5196. }
  5197. echo json_encode(array('success' => true));
  5198. exit;
  5199. } else {
  5200. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5201. exit;
  5202. }
  5203. }
  5204. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5205. $this->_Template('whlabel_dbrk', $this->data);
  5206. }
  5207. public function _whlabelczdc()
  5208. {
  5209. if (isset($_GET['excel'])) {
  5210. //数据排序
  5211. $order_str = "id desc";
  5212. if (empty($page)) {
  5213. $start = 0;
  5214. $perpage = 1;
  5215. } else {
  5216. $start = ($page - 1) * $perpage;
  5217. }
  5218. $state = $this->input->get('state', true);
  5219. $sku = $this->input->get('sku', true);
  5220. $ctime = $this->input->get('ctime', true);
  5221. $category = $this->input->get('category', true);
  5222. $size = $this->input->get('size', true);
  5223. $grade = $this->input->get('grade', true);
  5224. $color = $this->input->get('color', true);
  5225. $lowe = $this->input->get('lowe', true);
  5226. $timetk = $this->input->get('timetkk', true);
  5227. $timetj = $this->input->get('timetjj', true);
  5228. $timetk = strtotime($timetk);
  5229. $timetj = strtotime($timetj);
  5230. $where = "dbtime > 0";
  5231. if ($timetk && $timetj) {
  5232. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5233. }
  5234. if ($category) {
  5235. $where .= " and features like '%-$category-%'";
  5236. }
  5237. if ($size) {
  5238. $where .= " and features like '%-$size-%'";
  5239. }
  5240. if ($grade) {
  5241. $where .= " and features like '%-$grade-%'";
  5242. }
  5243. if ($color) {
  5244. $where .= " and features like '%-$color-%'";
  5245. }
  5246. if ($lowe) {
  5247. $where .= " and features like '%-$lowe-%'";
  5248. }
  5249. //取得信息列表
  5250. $info_list = $this->whlabel->find_all($where, '*');
  5251. $rows = array();
  5252. $list = array();
  5253. foreach ($info_list as $key => $value) {
  5254. $rows[$value['sku']] = $value; //所有数据sku
  5255. }
  5256. foreach ($rows as $value) {
  5257. $warehouse = $this->warehouse->read($value['warehouse']);
  5258. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5259. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5260. if ($value['orderinfo'] == 0) {
  5261. $info_list[$key]['orderinfo'] = "";
  5262. }
  5263. if ($value['waybill'] == 0) {
  5264. $info_list[$key]['waybill'] = "";
  5265. }
  5266. if ($value['state'] == 0) {
  5267. $value['state'] = "在库";
  5268. } else if ($value['state'] == 3) {
  5269. $value['state'] = "调拨中";
  5270. }
  5271. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5272. }
  5273. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5274. $titlename = "<table border=1>
  5275. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5276. <tr align='center'>
  5277. <td>SKU</td>
  5278. <td>产品</td>
  5279. <td>调拨数量</td>
  5280. <td>入库数量</td>
  5281. </tr>
  5282. </table>";
  5283. $filename = $title . ".xls";
  5284. $tail = "";
  5285. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5286. }
  5287. }
  5288. public function _print($arg_array)
  5289. {
  5290. if (isset($_SESSION['api'])) {
  5291. $user = $this->user->get_api($_SESSION['api']);
  5292. $usp = $user;
  5293. $fgshop = "";
  5294. $sid = "";
  5295. $wid = "";
  5296. $wtype = "";
  5297. $usersp = explode('|', trim($user['shop'], '|'));
  5298. $userwh = explode('|', trim($user['warehouse'], '|'));
  5299. foreach ($usersp as $value) {
  5300. $fgshop .= " shop = " . $value . " or";
  5301. $sid .= " id = " . $value . " or";
  5302. }
  5303. foreach ($userwh as $value) {
  5304. $wid .= " id = " . $value . " or";
  5305. $wtype .= " type = " . $value . " or";
  5306. }
  5307. }
  5308. $post = $this->input->post(NULL, TRUE);
  5309. if (isset($post['tmsku'])) {
  5310. $tmsku = $this->input->post('tmsku', true);
  5311. if (is_numeric($tmsku)) {
  5312. $yyh = $this->whlabellabel->get_label($tmsku);
  5313. } else {
  5314. $yyh = $this->whlabellabel->get_sku($tmsku);
  5315. }
  5316. if ($yyh) {
  5317. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5318. exit;
  5319. } else {
  5320. echo json_encode(array('success' => false));
  5321. exit;
  5322. }
  5323. }
  5324. $classid = $this->classid->sku();
  5325. $pm = $classid;
  5326. $scsku = $classid;
  5327. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5328. if (isset($post['warehouse'])) {
  5329. if ($post['warehouse']) {
  5330. $list = array();
  5331. $num = "";
  5332. $title = "";
  5333. $features = "";
  5334. $order = 0;
  5335. $post['shop'] = '';
  5336. $brand = $this->input->post('brand', true);
  5337. if ($brand != '0,') {
  5338. $b = $this->brand->read(rtrim($brand, ','));
  5339. if ($b) {
  5340. $post['shop'] = str_replace('|', ',', $b['shop']);
  5341. }
  5342. }
  5343. $post['details'] = $this->input->post('details', true); //打印数量
  5344. $xbqnum = $this->input->post('xbqnum', true);
  5345. $post['purchase'] = $this->input->post('purchase', true);
  5346. $post['warehouse'] = $this->input->post('warehouse', true);
  5347. $post['purchase'] = $this->input->post('purchase', true);
  5348. $post['retreatwarehouse'] = $post['warehouse'];
  5349. $post['cpbz'] = $this->input->post('cpbz', true);
  5350. $post['state'] = 9;
  5351. $category = $this->input->post('category', true);
  5352. $list['category'] = $category;
  5353. $list['hairtype'] = $this->input->post('hairtype', true);
  5354. $list['grade'] = $this->input->post('grade', true);
  5355. $size = $this->input->post('size', true);
  5356. $list['size'] = rtrim($size, ',');
  5357. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5358. $list['extension'] = $this->input->post('extension', true);
  5359. if ($category == 1297) {
  5360. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5361. }
  5362. if ($category == 1702) {
  5363. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5364. $list['syother'] = $this->input->post('syother', true);
  5365. }
  5366. if ($category == 133) {
  5367. $list['fittype'] = $this->input->post('fittype', true);
  5368. $list['acother'] = $this->input->post('acother', true);
  5369. }
  5370. $list['color'] = $this->input->post('color', true);
  5371. $list['lowe'] = $this->input->post('lowe', true);
  5372. if ($category == 127) {
  5373. $list['type'] = $this->input->post('type', true);
  5374. $list['headroad'] = $this->input->post('headroad', true);
  5375. $list['density'] = $this->input->post('density', true);
  5376. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5377. $list['lacesize'] = $this->input->post('lacesize', true);
  5378. }
  5379. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5380. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5381. }
  5382. if ($category == 128) {
  5383. $list['lacetype'] = $this->input->post('lacetype', true);
  5384. $list['haircap'] = $this->input->post('haircap', true);
  5385. $list['density'] = $this->input->post('density', true);
  5386. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5387. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5388. $list['wigother'] = $this->input->post('wigother', true);
  5389. $list['wigother2'] = $this->input->post('wigother2', true);
  5390. }
  5391. if ($category == 129) {
  5392. $list['wide'] = $this->input->post('wide', true);
  5393. }
  5394. if ($category == 131) {
  5395. $list['gifttype'] = $this->input->post('gifttype', true);
  5396. $list['giftother'] = $this->input->post('giftother', true);
  5397. }
  5398. if ($category == 134) {
  5399. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5400. }
  5401. if ($category == 1297) {
  5402. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5403. $list['sywigother'] = $this->input->post('sywigother', true);
  5404. }
  5405. if ($category == 130 || $category == 133 || $category == 1702) {
  5406. $list['items'] = $this->input->post('items', true);
  5407. $list['weight'] = $this->input->post('weight', true);
  5408. }
  5409. if ($category == 1702) {
  5410. $list['syhairther'] = $this->input->post('syhairther', true);
  5411. }
  5412. foreach ($list as $k => $v) {
  5413. if ($v != 0) {
  5414. $num .= $v;
  5415. $features .= $v . '-';
  5416. $post[$k] = $v;
  5417. $typeclass = $this->typeclass->read($v);
  5418. if (isset($pm[$typeclass['classid']])) {
  5419. if (stripos($typeclass['zh'], '|') !== false) {
  5420. $exzh = explode('|', $typeclass['zh']);
  5421. $pm[$typeclass['classid']] = $exzh[0];
  5422. } else {
  5423. $pm[$typeclass['classid']] = $typeclass['zh'];
  5424. }
  5425. }
  5426. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5427. if ($k != 'size') {
  5428. $title .= $typeclass['title'] . " ";
  5429. }
  5430. }
  5431. }
  5432. $typeclass = $this->typeclass->read($list['size']);
  5433. $title .= $typeclass['title'];
  5434. $time = time();
  5435. $post['title'] = rtrim($title, ' ');
  5436. $post['number'] = $num;
  5437. $post['features'] = '-' . $features;
  5438. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5439. $featurespp = explode('-', trim($featurespp, '-'));
  5440. if (isset($featurespp[5])) {
  5441. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5442. } else {
  5443. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5444. }
  5445. $post['enter'] = $time;
  5446. $post['time'] = $time; //操作时间
  5447. $scsku = implode("-", $scsku);
  5448. $zh = implode(" ", $pm);
  5449. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5450. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5451. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5452. $post['sku'] = $bqsku;
  5453. $label = time() . rand(0, 9);
  5454. $post['label'] = $label;
  5455. $cpid = $this->whlabellabel->find_count();
  5456. $post['cpid'] = $cpid + 1;
  5457. $cpid = $post['cpid'];
  5458. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5459. //if($whlabelbarcode)
  5460. //{
  5461. //$post['label'] = $whlabelbarcode['label'];
  5462. //if(!$this->whlabellabel->insert($post))
  5463. //{
  5464. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5465. //}
  5466. //}
  5467. //else
  5468. //{
  5469. $this->db->trans_begin();
  5470. $this->whlabellabel->insert($post);
  5471. //$this->whlabelbarcode->insert($post);
  5472. if ($this->db->trans_status() === TRUE) {
  5473. $this->db->trans_commit();
  5474. } else {
  5475. $this->db->trans_rollback();
  5476. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5477. exit;
  5478. }
  5479. //}
  5480. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5481. $purchase = $this->purchase->read($post['purchase']);
  5482. 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));
  5483. exit; //特殊仓目前不需要仓库选项
  5484. }
  5485. }
  5486. if (isset($_SESSION['api'])) {
  5487. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5488. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5489. $this->data['wlshop'] = $wlshop;
  5490. $this->data['warehouse'] = $warehouse;
  5491. }
  5492. $whlabelwz = $this->whlabelwz->find_all();
  5493. $this->data['whlabelwz'] = $whlabelwz;
  5494. $this->_Template('whlabel_print', $this->data);
  5495. }
  5496. public function _usaprint($arg_array)
  5497. {
  5498. if (isset($_SESSION['api'])) {
  5499. $user = $this->user->get_api($_SESSION['api']);
  5500. $usp = $user;
  5501. $fgshop = "";
  5502. $sid = "";
  5503. $wid = "";
  5504. $wtype = "";
  5505. $usersp = explode('|', trim($user['shop'], '|'));
  5506. $userwh = explode('|', trim($user['warehouse'], '|'));
  5507. foreach ($usersp as $value) {
  5508. $fgshop .= " shop = " . $value . " or";
  5509. $sid .= " id = " . $value . " or";
  5510. }
  5511. foreach ($userwh as $value) {
  5512. $wid .= " id = " . $value . " or";
  5513. $wtype .= " type = " . $value . " or";
  5514. }
  5515. }
  5516. $post = $this->input->post(NULL, TRUE);
  5517. if (isset($post['tmsku'])) {
  5518. $tmsku = $this->input->post('tmsku', true);
  5519. if (is_numeric($tmsku)) {
  5520. $yyh = $this->whlabellabel->get_label($tmsku);
  5521. } else {
  5522. $yyh = $this->whlabellabel->get_sku($tmsku);
  5523. }
  5524. if ($yyh) {
  5525. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5526. exit;
  5527. } else {
  5528. echo json_encode(array('success' => false));
  5529. exit;
  5530. }
  5531. }
  5532. $classid = $this->classid->sku();
  5533. $pm = $classid;
  5534. $scsku = $classid;
  5535. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5536. if (isset($post['warehouse'])) {
  5537. if ($post['warehouse']) {
  5538. $list = array();
  5539. $num = "";
  5540. $title = "";
  5541. $features = "";
  5542. $order = 0;
  5543. $post['shop'] = '';
  5544. $brand = $this->input->post('brand', true);
  5545. if ($brand != '0,') {
  5546. $b = $this->brand->read(rtrim($brand, ','));
  5547. if ($b) {
  5548. $post['shop'] = str_replace('|', ',', $b['shop']);
  5549. }
  5550. }
  5551. $post['details'] = $this->input->post('details', true); //打印数量
  5552. $xbqnum = $this->input->post('xbqnum', true);
  5553. $post['purchase'] = $this->input->post('purchase', true);
  5554. $post['warehouse'] = $this->input->post('warehouse', true);
  5555. $post['purchase'] = $this->input->post('purchase', true);
  5556. $post['retreatwarehouse'] = $post['warehouse'];
  5557. $post['cpbz'] = $this->input->post('cpbz', true);
  5558. $post['state'] = 9;
  5559. $category = $this->input->post('category', true);
  5560. $list['category'] = $category;
  5561. $list['hairtype'] = $this->input->post('hairtype', true);
  5562. $list['grade'] = $this->input->post('grade', true);
  5563. $size = $this->input->post('size', true);
  5564. $list['size'] = rtrim($size, ',');
  5565. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5566. $list['extension'] = $this->input->post('extension', true);
  5567. if ($category == 1297) {
  5568. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5569. }
  5570. if ($category == 1702) {
  5571. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5572. $list['syother'] = $this->input->post('syother', true);
  5573. }
  5574. if ($category == 133) {
  5575. $list['fittype'] = $this->input->post('fittype', true);
  5576. $list['acother'] = $this->input->post('acother', true);
  5577. }
  5578. $list['color'] = $this->input->post('color', true);
  5579. $list['lowe'] = $this->input->post('lowe', true);
  5580. if ($category == 127) {
  5581. $list['type'] = $this->input->post('type', true);
  5582. $list['headroad'] = $this->input->post('headroad', true);
  5583. $list['density'] = $this->input->post('density', true);
  5584. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5585. $list['lacesize'] = $this->input->post('lacesize', true);
  5586. }
  5587. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5588. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5589. }
  5590. if ($category == 128) {
  5591. $list['lacetype'] = $this->input->post('lacetype', true);
  5592. $list['haircap'] = $this->input->post('haircap', true);
  5593. $list['density'] = $this->input->post('density', true);
  5594. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5595. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5596. $list['wigother'] = $this->input->post('wigother', true);
  5597. $list['wigother2'] = $this->input->post('wigother2', true);
  5598. }
  5599. if ($category == 129) {
  5600. $list['wide'] = $this->input->post('wide', true);
  5601. }
  5602. if ($category == 131) {
  5603. $list['gifttype'] = $this->input->post('gifttype', true);
  5604. $list['giftother'] = $this->input->post('giftother', true);
  5605. }
  5606. if ($category == 134) {
  5607. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5608. }
  5609. if ($category == 1297) {
  5610. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5611. $list['sywigother'] = $this->input->post('sywigother', true);
  5612. }
  5613. if ($category == 130 || $category == 133 || $category == 1702) {
  5614. $list['items'] = $this->input->post('items', true);
  5615. $list['weight'] = $this->input->post('weight', true);
  5616. }
  5617. if ($category == 1702) {
  5618. $list['syhairther'] = $this->input->post('syhairther', true);
  5619. }
  5620. foreach ($list as $k => $v) {
  5621. if ($v != 0) {
  5622. $num .= $v;
  5623. $features .= $v . '-';
  5624. $post[$k] = $v;
  5625. $typeclass = $this->typeclass->read($v);
  5626. if (isset($pm[$typeclass['classid']])) {
  5627. if (stripos($typeclass['zh'], '|') !== false) {
  5628. $exzh = explode('|', $typeclass['zh']);
  5629. $pm[$typeclass['classid']] = $exzh[0];
  5630. } else {
  5631. $pm[$typeclass['classid']] = $typeclass['zh'];
  5632. }
  5633. }
  5634. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5635. if ($k != 'size') {
  5636. $title .= $typeclass['title'] . " ";
  5637. }
  5638. }
  5639. }
  5640. $typeclass = $this->typeclass->read($list['size']);
  5641. $title .= $typeclass['title'];
  5642. $time = time();
  5643. $post['title'] = rtrim($title, ' ');
  5644. $post['number'] = $num;
  5645. $post['features'] = '-' . $features;
  5646. $fp = $this->whlabel->get_features($post['features']);
  5647. if (!$fp) {
  5648. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5649. exit;
  5650. }
  5651. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5652. $featurespp = explode('-', trim($featurespp, '-'));
  5653. if (isset($featurespp[5])) {
  5654. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5655. } else {
  5656. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5657. }
  5658. $post['enter'] = $time;
  5659. $post['time'] = $time; //操作时间
  5660. $scsku = implode("-", $scsku);
  5661. $zh = implode(" ", $pm);
  5662. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5663. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5664. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5665. $post['sku'] = $fp['sku'];
  5666. $post['label'] = $fp['sku'];
  5667. $cpid = $this->whlabellabel->find_count();
  5668. $post['cpid'] = $cpid + 1;
  5669. $cpid = $post['cpid'];
  5670. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5671. //if($whlabelbarcode)
  5672. //{
  5673. //$post['label'] = $whlabelbarcode['label'];
  5674. //if(!$this->whlabellabel->insert($post))
  5675. //{
  5676. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5677. //}
  5678. //}
  5679. //else
  5680. //{
  5681. $this->db->trans_begin();
  5682. $this->whlabellabel->insert($post);
  5683. //$this->whlabelbarcode->insert($post);
  5684. if ($this->db->trans_status() === TRUE) {
  5685. $this->db->trans_commit();
  5686. } else {
  5687. $this->db->trans_rollback();
  5688. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5689. exit;
  5690. }
  5691. //}
  5692. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5693. $purchase = $this->purchase->read($post['purchase']);
  5694. 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));
  5695. exit; //特殊仓目前不需要仓库选项
  5696. }
  5697. }
  5698. if (isset($_SESSION['api'])) {
  5699. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5700. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5701. $this->data['wlshop'] = $wlshop;
  5702. $this->data['warehouse'] = $warehouse;
  5703. }
  5704. $whlabelwz = $this->whlabelwz->find_all();
  5705. $this->data['whlabelwz'] = $whlabelwz;
  5706. $this->_Template('whlabel_usaprint', $this->data);
  5707. }
  5708. public function _printrk($arg_array)
  5709. {
  5710. $prc = array();
  5711. $purchase = $this->purchase->find_all();
  5712. foreach ($purchase as $k => $v) {
  5713. $prc[$v['id']] = $v['title'];
  5714. }
  5715. $post = $this->input->post(NULL, TRUE);
  5716. if (isset($post['page'])) {
  5717. $page = $this->input->post('page', true);
  5718. $perpage = $this->input->post('perpage', true);
  5719. $sku = $this->input->post('sku', true);
  5720. $bs = $this->input->post('bs', true);
  5721. $number = $this->input->post('number', true);
  5722. $warehouse = $this->input->post('warehouse', true);
  5723. $purchase = $this->input->post('purchase', true);
  5724. $orderinfo = $this->input->post('orderinfo', true);
  5725. $waybill = $this->input->post('waybill', true);
  5726. $category = $this->input->post('category', true);
  5727. $size = $this->input->post('size', true);
  5728. $grade = $this->input->post('grade', true);
  5729. $color = $this->input->post('color', true);
  5730. $lowe = $this->input->post('lowe', true);
  5731. $state = $this->input->post('state', true);
  5732. $label = $this->input->post('label', true);
  5733. $timetk = $this->input->post('ktime', true);
  5734. $timetj = $this->input->post('jtime', true);
  5735. $timetk = strtotime($timetk);
  5736. $timetj = strtotime($timetj);
  5737. $where = "1=1 ";
  5738. if ($timetk && $timetj) {
  5739. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5740. }
  5741. if ($sku) {
  5742. $where .= " and sku = '$sku'";
  5743. }
  5744. if ($bs != '') {
  5745. $where .= " and bs = '$bs'";
  5746. }
  5747. if ($number) {
  5748. $where .= " and number = '$number'";
  5749. }
  5750. if ($warehouse) {
  5751. $where .= " and warehouse = '$warehouse'";
  5752. }
  5753. if ($purchase) {
  5754. $where .= " and purchase = '$purchase'";
  5755. }
  5756. if ($orderinfo) {
  5757. $where .= " and orderinfo = '$orderinfo'";
  5758. }
  5759. if ($waybill) {
  5760. $where .= " and waybill = '$waybill'";
  5761. }
  5762. if ($category) {
  5763. $where .= " and features like '%-$category-%'";
  5764. }
  5765. if ($size) {
  5766. $where .= " and features like '%-$size-%'";
  5767. }
  5768. if ($grade) {
  5769. $where .= " and features like '%-$grade-%'";
  5770. }
  5771. if ($color) {
  5772. $where .= " and features like '%-$color-%'";
  5773. }
  5774. if ($lowe) {
  5775. $where .= " and features like '%-$lowe-%'";
  5776. }
  5777. if ($label) {
  5778. $where .= " and label = '$label'";
  5779. }
  5780. if ($state || $state == 0) {
  5781. $where .= " and state = '$state'";
  5782. }
  5783. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5784. //数据排序
  5785. $order_str = "enter desc";
  5786. if (empty($page)) {
  5787. $start = 0;
  5788. $perpage = 1;
  5789. } else {
  5790. $start = ($page - 1) * $perpage;
  5791. }
  5792. //取得信息列表
  5793. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5794. foreach ($info_list as $key => $value) {
  5795. $warehouse = $this->warehouse->read($value['warehouse']);
  5796. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5797. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5798. if ($value['state'] == 0) {
  5799. $info_list[$key]['state'] = "在库";
  5800. } else if ($value['state'] == 1) {
  5801. $info_list[$key]['state'] = "出库";
  5802. } else if ($value['state'] == 2) {
  5803. $info_list[$key]['state'] = "退库";
  5804. } else if ($value['state'] == 3) {
  5805. $info_list[$key]['state'] = "调拨中";
  5806. } else if ($value['state'] == 4) {
  5807. $info_list[$key]['state'] = "再加工";
  5808. } else if ($value['state'] == 5) {
  5809. $info_list[$key]['state'] = "维修中";
  5810. } else if ($value['state'] == 6) {
  5811. $info_list[$key]['state'] = "盘亏";
  5812. } else if ($value['state'] == 7) {
  5813. $info_list[$key]['state'] = "更换标签";
  5814. } else if ($value['state'] == 8) {
  5815. $info_list[$key]['state'] = "其它";
  5816. } else if ($value['state'] == 9) {
  5817. $info_list[$key]['state'] = "预设";
  5818. } else if ($value['state'] == 10) {
  5819. $info_list[$key]['state'] = "美店零售";
  5820. }
  5821. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5822. }
  5823. $total = $this->$ck->find_count($where);
  5824. $pagenum = ceil($total / $perpage);
  5825. $over = $total - ($start + $perpage);
  5826. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5827. echo json_encode($rows);
  5828. exit;
  5829. }
  5830. if (isset($post['tmsku'])) {
  5831. $time = time();
  5832. $tmsku = $this->input->post('tmsku', true);
  5833. //$post['shop'] = $this->input->post('shop',true);
  5834. $num = $this->input->post('num', true);
  5835. $rktype = $this->input->post('rktype', true);
  5836. if ($num > 200) {
  5837. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5838. exit;
  5839. }
  5840. if (!$rktype) {
  5841. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5842. }
  5843. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5844. /**
  5845. $wz = array();
  5846. foreach ($rk as $key=>$value)
  5847. {
  5848. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5849. }
  5850. if(count($wz) > 1)
  5851. {
  5852. $wz = array_values($wz);
  5853. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  5854. }
  5855. **/
  5856. if (isset($rk[0]['purchase'])) {
  5857. $rk = $rk[0];
  5858. $j = 0;
  5859. $post['purchase'] = $rk['purchase'];
  5860. $post['warehouse'] = $rk['warehouse'];
  5861. $post['retreatwarehouse'] = $rk['warehouse'];
  5862. $post['sku'] = $rk['sku'];
  5863. $post['number'] = $rk['number'];
  5864. $post['features'] = $rk['features'];
  5865. $post['title'] = $rk['title'];
  5866. $post['enter'] = $time;
  5867. $post['time'] = $time;
  5868. $post['bs'] = 1;
  5869. $post['shop'] = $rk['shop'];
  5870. $post['details'] = $rk['details'];
  5871. $post['cpid'] = $rk['cpid'];
  5872. $post['cpbz'] = $rk['cpbz'];
  5873. //$post['rktype'] = $rktype;
  5874. $warehouse = $this->warehouse->read($rk['warehouse']);
  5875. if ($warehouse['bdck'] == '') {
  5876. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  5877. exit;
  5878. } else {
  5879. $bdck = $warehouse['bdck'];
  5880. }
  5881. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  5882. if (isset($pdwz['details'])) {
  5883. if ($pdwz['details'] != $post['details']) {
  5884. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  5885. exit;
  5886. }
  5887. }
  5888. $post['featurespp'] = $rk['featurespp'];
  5889. if ($post['warehouse'] == '5') {
  5890. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5891. if ($yza) {
  5892. if ($post['features'] != $yza[0]['features']) {
  5893. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  5894. exit;
  5895. }
  5896. }
  5897. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5898. if ($yzb) {
  5899. if ($post['sku'] != $yzb[0]['sku']) {
  5900. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  5901. exit;
  5902. }
  5903. }
  5904. }
  5905. for ($i = 0; $i < $num; $i++) {
  5906. $post['label'] = time() . rand(100, 999) . $i;
  5907. if ($this->$bdck->insert($post)) {
  5908. $j++;
  5909. }
  5910. }
  5911. /**
  5912. if($post['warehouse'] != 12)
  5913. {
  5914. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5915. }
  5916. **/
  5917. if ($j == $num) {
  5918. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  5919. exit;
  5920. } else {
  5921. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  5922. exit;
  5923. }
  5924. } else {
  5925. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  5926. exit;
  5927. }
  5928. }
  5929. $this->_Template('whlabel_printrk', $this->data);
  5930. }
  5931. public function _printxzrk($arg_array)
  5932. {
  5933. $post = $this->input->post(NULL, TRUE);
  5934. if (isset($post['wzid'])) {
  5935. $time = time();
  5936. $id = $this->input->post('wzid', true);
  5937. //$post['shop'] = $this->input->post('shop',true);
  5938. $num = 1;
  5939. $rk = $this->whlabellabel->read($id);
  5940. if (isset($rk['purchase'])) {
  5941. $x = 0;
  5942. $post['purchase'] = $rk['purchase'];
  5943. $post['warehouse'] = $rk['warehouse'];
  5944. $post['retreatwarehouse'] = $rk['warehouse'];
  5945. $post['sku'] = $rk['sku'];
  5946. $post['number'] = $rk['number'];
  5947. $post['features'] = $rk['features'];
  5948. $post['title'] = $rk['title'];
  5949. $post['enter'] = $time;
  5950. $post['time'] = $time;
  5951. $post['bs'] = 1;
  5952. $post['shop'] = $rk['shop'];
  5953. $post['details'] = $rk['details'];
  5954. $post['cpid'] = $rk['cpid'];
  5955. $post['cpbz'] = $rk['cpbz'];
  5956. $warehouse = $this->warehouse->read($rk['warehouse']);
  5957. if ($warehouse['bdck'] == '') {
  5958. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  5959. exit;
  5960. } else {
  5961. $bdck = $warehouse['bdck'];
  5962. }
  5963. $post['featurespp'] = $rk['featurespp'];
  5964. $this->db->trans_begin();
  5965. for ($i = 0; $i < $num; $i++) {
  5966. $post['label'] = time() . rand(100, 999) . $i;
  5967. $this->$bdck->insert($post);
  5968. }
  5969. /**
  5970. if($post['warehouse'] != 12)
  5971. {
  5972. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5973. }
  5974. **/
  5975. if ($this->db->trans_status() === TRUE) {
  5976. $this->db->trans_commit();
  5977. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  5978. exit;
  5979. } else {
  5980. $this->db->trans_rollback();
  5981. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  5982. exit;
  5983. }
  5984. } else {
  5985. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  5986. exit;
  5987. }
  5988. }
  5989. }
  5990. public function _printck($arg_array)
  5991. {
  5992. $prc = array();
  5993. $purchase = $this->purchase->find_all();
  5994. foreach ($purchase as $k => $v) {
  5995. $prc[$v['id']] = $v['title'];
  5996. }
  5997. $post = $this->input->post(NULL, TRUE);
  5998. if (isset($post['page'])) {
  5999. $page = $this->input->post('page', true);
  6000. $perpage = $this->input->post('perpage', true);
  6001. $sku = $this->input->post('sku', true);
  6002. $bs = $this->input->post('bs', true);
  6003. $number = $this->input->post('number', true);
  6004. $warehouse = $this->input->post('warehouse', true);
  6005. $purchase = $this->input->post('purchase', true);
  6006. $orderinfo = $this->input->post('orderinfo', true);
  6007. $waybill = $this->input->post('waybill', true);
  6008. $category = $this->input->post('category', true);
  6009. $size = $this->input->post('size', true);
  6010. $grade = $this->input->post('grade', true);
  6011. $color = $this->input->post('color', true);
  6012. $lowe = $this->input->post('lowe', true);
  6013. $state = $this->input->post('state', true);
  6014. $label = $this->input->post('label', true);
  6015. $timetk = $this->input->post('ktime', true);
  6016. $timetj = $this->input->post('jtime', true);
  6017. $timetk = strtotime($timetk);
  6018. $timetj = strtotime($timetj);
  6019. $where = "state=1 ";
  6020. if ($timetk && $timetj) {
  6021. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6022. }
  6023. if ($sku) {
  6024. $where .= " and sku = '$sku'";
  6025. }
  6026. if ($bs != '') {
  6027. $where .= " and bs = '$bs'";
  6028. }
  6029. if ($number) {
  6030. $where .= " and number = '$number'";
  6031. }
  6032. if ($warehouse) {
  6033. $where .= " and warehouse = '$warehouse'";
  6034. }
  6035. if ($purchase) {
  6036. $where .= " and purchase = '$purchase'";
  6037. }
  6038. if ($orderinfo) {
  6039. $where .= " and orderinfo = '$orderinfo'";
  6040. }
  6041. if ($waybill) {
  6042. $where .= " and waybill = '$waybill'";
  6043. }
  6044. if ($category) {
  6045. $where .= " and features like '%-$category-%'";
  6046. }
  6047. if ($size) {
  6048. $where .= " and features like '%-$size-%'";
  6049. }
  6050. if ($grade) {
  6051. $where .= " and features like '%-$grade-%'";
  6052. }
  6053. if ($color) {
  6054. $where .= " and features like '%-$color-%'";
  6055. }
  6056. if ($lowe) {
  6057. $where .= " and features like '%-$lowe-%'";
  6058. }
  6059. if ($label) {
  6060. $where .= " and label = '$label'";
  6061. }
  6062. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6063. //数据排序
  6064. $order_str = "outk desc";
  6065. if (empty($page)) {
  6066. $start = 0;
  6067. $perpage = 1;
  6068. } else {
  6069. $start = ($page - 1) * $perpage;
  6070. }
  6071. //取得信息列表
  6072. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6073. foreach ($info_list as $key => $value) {
  6074. $warehouse = $this->warehouse->read($value['warehouse']);
  6075. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6076. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6077. if ($value['state'] == 0) {
  6078. $info_list[$key]['state'] = "在库";
  6079. } else if ($value['state'] == 1) {
  6080. $info_list[$key]['state'] = "出库";
  6081. } else if ($value['state'] == 2) {
  6082. $info_list[$key]['state'] = "退库";
  6083. } else if ($value['state'] == 3) {
  6084. $info_list[$key]['state'] = "调拨中";
  6085. } else if ($value['state'] == 4) {
  6086. $info_list[$key]['state'] = "再加工";
  6087. } else if ($value['state'] == 5) {
  6088. $info_list[$key]['state'] = "维修中";
  6089. } else if ($value['state'] == 6) {
  6090. $info_list[$key]['state'] = "盘亏";
  6091. } else if ($value['state'] == 7) {
  6092. $info_list[$key]['state'] = "更换标签";
  6093. } else if ($value['state'] == 8) {
  6094. $info_list[$key]['state'] = "其它";
  6095. } else if ($value['state'] == 9) {
  6096. $info_list[$key]['state'] = "预设";
  6097. } else if ($value['state'] == 10) {
  6098. $info_list[$key]['state'] = "美店零售";
  6099. }
  6100. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6101. }
  6102. $total = $this->$ck->find_count($where);
  6103. $pagenum = ceil($total / $perpage);
  6104. $over = $total - ($start + $perpage);
  6105. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6106. echo json_encode($rows);
  6107. exit;
  6108. }
  6109. if (isset($post['tmsku'])) {
  6110. $time = time();
  6111. $tmsku = $this->input->post('tmsku', true);
  6112. //$post['shop'] = $this->input->post('shop',true);
  6113. $num = $this->input->post('num', true);
  6114. $cktype = $this->input->post('cktype', true);
  6115. $label = $this->whlabellabel->get_label($tmsku);
  6116. if (!$cktype) {
  6117. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6118. }
  6119. if (!isset($label['warehouse'])) {
  6120. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6121. exit;
  6122. }
  6123. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6124. if (stripos($label['features'], '-126-') !== false) {
  6125. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6126. } else {
  6127. $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 = ''");
  6128. }
  6129. $j = 0;
  6130. if (count($ck) >= $num) {
  6131. for ($i = 0; $i < $num; $i++) {
  6132. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6133. {
  6134. $j++;
  6135. }
  6136. }
  6137. if ($j == $num) {
  6138. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6139. exit;
  6140. } else {
  6141. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6142. exit;
  6143. }
  6144. } else {
  6145. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6146. exit;
  6147. }
  6148. }
  6149. $this->_Template('whlabel_printck', $this->data);
  6150. }
  6151. public function _printexcel()
  6152. {
  6153. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6154. $config['upload_path'] = '.' . $dir;
  6155. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6156. $config['allowed_types'] = 'xls|xlsx|csv';
  6157. $config['max_size'] = 10240;
  6158. $this->load->library('upload', $config);
  6159. $this->upload->initialize($config);
  6160. if ($this->upload->do_upload('userfile')) {
  6161. $full_path = $dir . $this->upload->data('file_name');
  6162. $fileName = '.' . $full_path;
  6163. if (!file_exists($fileName)) {
  6164. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6165. exit;
  6166. } else {
  6167. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6168. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6169. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6170. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6171. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6172. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6173. ++$column; //如果列数大于26行
  6174. $list = array();
  6175. for ($i = 2; $i <= $row; $i++) // 行数循环
  6176. {
  6177. $data = array();
  6178. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6179. {
  6180. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6181. }
  6182. $list[] = $data;
  6183. }
  6184. }
  6185. $ed = array();
  6186. $i = 0;
  6187. $j = 0;
  6188. $dcdata = array();
  6189. $yc = '';
  6190. $cmf_arr = array_column($list, '1');
  6191. array_multisort($cmf_arr, SORT_ASC, $list);
  6192. foreach ($list as $key => $value) {
  6193. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6194. if ($typeclass) {
  6195. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6196. } else {
  6197. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6198. $i++;
  6199. continue;
  6200. }
  6201. }
  6202. if ($i > 0) {
  6203. $yc = $i . '条异常';
  6204. }
  6205. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6206. exit;
  6207. }
  6208. }
  6209. public function _uck()
  6210. {
  6211. if (isset($_GET['excel'])) {
  6212. $tc = array();
  6213. $typeclass = $this->typeclass->find_all();
  6214. foreach ($typeclass as $v) {
  6215. $tc[$v['id']] = $v['zh'];
  6216. }
  6217. $data = array();
  6218. $t = array();
  6219. $rq = '';
  6220. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6221. $ts = $ts / (24 * 3600);
  6222. for ($i = 0; $i < $ts; $i++) {
  6223. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6224. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6225. }
  6226. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6227. foreach ($info_list as $k => $v) {
  6228. $features = explode('-', trim($v['features'], '-'));
  6229. if (!isset($features[3]) || !isset($features[4])) {
  6230. continue;
  6231. }
  6232. $data[$k][0] = $tc[$features[0]]; //类型
  6233. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6234. $data[$k][2] = $tc[$features[4]]; //曲度
  6235. $data[$k][3] = '';
  6236. if (isset($data[$k][1])) {
  6237. $data[$k][3] .= $data[$k][1];
  6238. }
  6239. if (isset($data[$k][2])) {
  6240. $data[$k][3] .= $data[$k][2];
  6241. }
  6242. if (isset($features[5])) {
  6243. $data[$k][3] .= $tc[$features[5]];
  6244. }
  6245. if (isset($features[2])) {
  6246. $data[$k][3] .= $tc[$features[2]];
  6247. }
  6248. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6249. $data[$k][4] = $v['sku'];
  6250. $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())) . '))'); //月初库存
  6251. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6252. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6253. $ztrq = '';
  6254. $ztsl = '';
  6255. if (count($zt) > 0) {
  6256. foreach ($zt as $vv) {
  6257. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6258. $ztsl .= $vv['num'] . '<br>';
  6259. }
  6260. }
  6261. $data[$k][] = trim($ztsl, '<br>');
  6262. $data[$k][] = trim($ztrq, '<br>');
  6263. $byck = 0;
  6264. foreach ($t as $vv) {
  6265. $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));
  6266. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6267. $byck += $sl;
  6268. }
  6269. $data[$k][] = ($byck > 0) ? $byck : '';
  6270. }
  6271. $title = "详情 " . date("Y-m-d", time());
  6272. $titlename = "<table border=1>
  6273. <tr align='center'>
  6274. <td>类别</td>
  6275. <td>颜色</td>
  6276. <td>曲度</td>
  6277. <td>名称</td>
  6278. <td>SKU</td>
  6279. <td>月初库存</td>
  6280. <td>剩余库存</td>
  6281. <td>在途数量</td>
  6282. <td>预达日期</td>" .
  6283. $rq
  6284. . "<td>本月出库</td></tr>
  6285. </table>";
  6286. $filename = $title . ".xls";
  6287. $tail = "";
  6288. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6289. }
  6290. }
  6291. public function _whlabelexcelzh()
  6292. {
  6293. if (isset($_GET['excel'])) {
  6294. $where = "sku != 'Preset'";
  6295. //数据排序
  6296. $order_str = "id desc";
  6297. if (empty($page)) {
  6298. $start = 0;
  6299. $perpage = 1;
  6300. } else {
  6301. $start = ($page - 1) * $perpage;
  6302. }
  6303. $category = $this->input->get('category', true);
  6304. $warehouse = $this->input->get('warehouse', true);
  6305. $excelid = $this->input->get('sid', true);
  6306. if ($category) {
  6307. $where .= " and features like '%-$category-%'";
  6308. }
  6309. if ($warehouse) {
  6310. $where .= " and warehouse = '$warehouse'";
  6311. }
  6312. $xzid = '';
  6313. if ($excelid) {
  6314. $excelid = explode(',', trim($excelid, ','));
  6315. foreach ($excelid as $key => $value) {
  6316. $xzid .= " id = " . $value . " or";
  6317. }
  6318. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6319. }
  6320. //取得信息列表
  6321. /**
  6322. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6323. $rows = array();$list = array();
  6324. foreach ($info_list as $key=>$value)
  6325. {
  6326. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6327. }
  6328. **/
  6329. $list = array();
  6330. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6331. foreach ($rows as $key => $value) {
  6332. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6333. $zh = '';
  6334. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6335. foreach ($zt as $v) {
  6336. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6337. }
  6338. $zt = array_sum(array_column($zt, 'num'));
  6339. $number = $value['number'];
  6340. $ftime = time() - 15 * 24 * 3600;
  6341. $warehouse = $this->warehouse->read($value['warehouse']);
  6342. $rows[$key]['warehouse'] = $warehouse['title'];
  6343. $rows[$key]['number'] = $c;
  6344. $rows[$key]['features'] = $zh;
  6345. $rows[$key]['hb'] = $c + $zt;
  6346. }
  6347. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6348. $titlename = "<table border=1>
  6349. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6350. <tr align='center'>
  6351. <td>仓库</td>
  6352. <td>SKU</td>
  6353. <td>产品</td>
  6354. <td>库存数量</td>
  6355. <td>在途数量及预达日期</td>
  6356. <td>在途+库存数量</td>
  6357. </tr>
  6358. </table>";
  6359. $filename = $title . ".xls";
  6360. $tail = "";
  6361. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6362. }
  6363. if (isset($_GET['excel'])) {
  6364. $warehouse = $this->input->get('warehouse', true);
  6365. $sku = $this->input->get('sku', true);
  6366. $cz = $this->input->get('cz', true);
  6367. $text = $this->input->post('text', true);
  6368. $xztime = $this->input->get('xztime', true);
  6369. $timetk = $this->input->get('timetk', true);
  6370. $timetj = $this->input->get('timetj', true);
  6371. $timetk = strtotime($timetk);
  6372. $timetj = strtotime($timetj);
  6373. $where = "time = '0' ";
  6374. if ($warehouse) {
  6375. $where .= " and warehouse = '$warehouse'";
  6376. }
  6377. if ($sku) {
  6378. $where .= " and sku = '$sku'";
  6379. }
  6380. if ($text) {
  6381. $where .= " and text like '%$text%'";
  6382. }
  6383. if ($cz != '') {
  6384. $where .= " and cz = '$cz'";
  6385. }
  6386. if ($timetk && $timetj) {
  6387. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6388. }
  6389. //数据排序
  6390. $order_str = $xztime . " desc";
  6391. //取得信息列表
  6392. $zh = array();
  6393. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6394. foreach ($info_list as $v) {
  6395. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6396. $warehouse = $this->warehouse->read($v['warehouse']);
  6397. $v['warehouse'] = $warehouse['title'];
  6398. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6399. $v['stime'] = date('Y-m-d', $v['stime']);
  6400. if (isset($zh[$v['features']])) {
  6401. $zh[$v['features']]['num'] += $v['num'];
  6402. } else {
  6403. $zh[$v['features']] = $v;
  6404. }
  6405. $zh[$v['features']]['features'] = $c;
  6406. }
  6407. $title = "在途数据" . date('Y-m-d', time());
  6408. $titlename = "<table border=1>
  6409. <tr align='center'>
  6410. <td>仓库</td>
  6411. <td>SKU</td>
  6412. <td>名称</td>
  6413. <td>在途数量</td>
  6414. <td>库存数量</td>
  6415. <td>添加在途日期</td>
  6416. <td>预达日期</td>
  6417. <td>备注</td>
  6418. </tr>
  6419. </table>";
  6420. $filename = $title . ".xls";
  6421. $tail = "";
  6422. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6423. }
  6424. }
  6425. public function _fc()
  6426. {
  6427. $vip = 0;
  6428. if (isset($_SESSION['api'])) {
  6429. $user = $this->user->get_api($_SESSION['api']);
  6430. if ($user['vip'] == 1) {
  6431. $vip = 1;
  6432. }
  6433. } else {
  6434. header('Location: /');
  6435. exit;
  6436. }
  6437. $post = $this->input->post(NULL, TRUE);
  6438. if (isset($post['page'])) {
  6439. $page = $this->input->post('page', true);
  6440. $perpage = $this->input->post('perpage', true);
  6441. $category = $this->input->post('category', true);
  6442. $size = $this->input->post('size', true);
  6443. $grade = $this->input->post('grade', true);
  6444. $color = $this->input->post('color', true);
  6445. $lowe = $this->input->post('lowe', true);
  6446. $sku = $this->input->post('sku');
  6447. $title = $this->input->post('title');
  6448. $warehouse = $this->input->post('warehouse', true);
  6449. $usa = $this->input->post('usa', true);
  6450. $purchase = $this->input->post('purchase', true);
  6451. $lacetype = $this->input->post('lacetype', true);
  6452. $haircap = $this->input->post('haircap', true);
  6453. $density = $this->input->post('density', true);
  6454. $details = $this->input->post('details', true);
  6455. $state = $this->input->post('state', true);
  6456. $ktime = $this->input->post('ktime', true);
  6457. $jtime = $this->input->post('jtime', true);
  6458. $ktime = strtotime($ktime);
  6459. $jtime = strtotime($jtime);
  6460. $where = "state = '11'";
  6461. $gj = "";
  6462. $ck = "";
  6463. if ($lacetype) {
  6464. $where .= " and features like '%-$lacetype-%'";
  6465. }
  6466. if ($category) {
  6467. $where .= " and features like '%-$category-%'";
  6468. }
  6469. if ($size) {
  6470. $where .= " and features like '%-$size-%'";
  6471. }
  6472. if ($grade) {
  6473. $where .= " and features like '%-$grade-%'";
  6474. }
  6475. if ($color) {
  6476. $where .= " and features like '%-$color-%'";
  6477. }
  6478. if ($lowe) {
  6479. $where .= " and features like '%-$lowe-%'";
  6480. }
  6481. if ($haircap) {
  6482. $where .= " and features like '%-$haircap-%'";
  6483. }
  6484. if ($density) {
  6485. $where .= " and features like '%-$density-%'";
  6486. }
  6487. if ($usa) {
  6488. if (!$warehouse) {
  6489. $where .= " and (warehouse = '5' or warehouse = '8')";
  6490. }
  6491. }
  6492. if ($warehouse) {
  6493. $where .= " and warehouse = '$warehouse'";
  6494. }
  6495. if ($details) {
  6496. $where .= " and details = '$details'";
  6497. }
  6498. if ($purchase) {
  6499. $where .= " and purchase = '$purchase'";
  6500. }
  6501. if ($state) {
  6502. $where .= " and state = '$state'";
  6503. }
  6504. if ($ktime && $jtime) {
  6505. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6506. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6507. }
  6508. //数据排序
  6509. $order_str = "id desc";
  6510. if (empty($page)) {
  6511. $start = 0;
  6512. $perpage = 1;
  6513. } else {
  6514. $start = ($page - 1) * $perpage;
  6515. }
  6516. if ($sku) {
  6517. $sku = trim($sku, ' ');
  6518. $sku = trim($sku, ' ');
  6519. $where .= " and sku like '%$sku%'";
  6520. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6521. } else if ($title) {
  6522. $title = trim($title, ' ');
  6523. $title = trim($title, ' ');
  6524. $where .= " and title like '%$title%'";
  6525. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6526. } else {
  6527. //$where .= " and time > '$ktime' and time < '$jtime'";
  6528. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6529. }
  6530. //取得信息列表
  6531. $rows = array();
  6532. $list = array();
  6533. foreach ($info_list as $key => $value) {
  6534. $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'] . '"');
  6535. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6536. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6537. $warehouse = $this->warehouse->read($value['warehouse']);
  6538. $info_list[$key]['warehouse'] = $warehouse['title'];
  6539. $info_list[$key]['number'] = $g;
  6540. $info_list[$key]['features'] = $x;
  6541. $info_list[$key]['x'] = $s;
  6542. }
  6543. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6544. $pagenum = ceil($total / $perpage);
  6545. $over = $total - ($start + $perpage);
  6546. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6547. echo json_encode($rows);
  6548. exit;
  6549. }
  6550. $this->data['vip'] = $vip;
  6551. $this->_Template('whlabel_fc', $this->data);
  6552. }
  6553. public function _fcmb()
  6554. {
  6555. $where = "sku != 'Preset'";
  6556. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6557. foreach ($rows as $k => $v) {
  6558. $warehouse = $this->warehouse->read($v['warehouse']);
  6559. $rows[$k]['warehouse'] = $warehouse['title'];
  6560. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6561. $rows[$k]['t'] = '';
  6562. $rows[$k]['n'] = '';
  6563. }
  6564. $title = "封货产品数据导入模板";
  6565. $titlename = "<table border=1>
  6566. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6567. <tr align='center'>
  6568. <td>仓库</td>
  6569. <td>SKU</td>
  6570. <td>产品</td>
  6571. <td>封存产品总数量</td>
  6572. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6573. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6574. </tr>
  6575. </table>";
  6576. $filename = $title . ".xls";
  6577. $tail = "";
  6578. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6579. }
  6580. public function _fcexcel()
  6581. {
  6582. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6583. $config['upload_path'] = '.' . $dir;
  6584. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6585. $config['allowed_types'] = 'xls|xlsx|csv';
  6586. $config['max_size'] = 10240;
  6587. $this->load->library('upload', $config);
  6588. $this->upload->initialize($config);
  6589. if ($this->upload->do_upload('userfile')) {
  6590. $full_path = $dir . $this->upload->data('file_name');
  6591. $fileName = '.' . $full_path;
  6592. if (!file_exists($fileName)) {
  6593. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6594. exit;
  6595. } else {
  6596. libxml_use_internal_errors(true);
  6597. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6598. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6599. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6600. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6601. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6602. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6603. ++$column; //如果列数大于26行
  6604. $list = array();
  6605. for ($i = 2; $i <= $row; $i++) // 行数循环
  6606. {
  6607. $data = array();
  6608. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6609. {
  6610. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6611. }
  6612. $list[] = $data;
  6613. }
  6614. }
  6615. $i = 0;
  6616. $j = 0;
  6617. $ed = array();
  6618. foreach ($list as $key => $value) {
  6619. $time = time();
  6620. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6621. continue;
  6622. }
  6623. $warehouse = $this->warehouse->get_title($value['0']);
  6624. $sku = $value['1'];
  6625. $type = $value['4']; //调整方式0扣减1删除
  6626. $num = $value['5']; //调整数量
  6627. //$text = $value['4'];//扣减说明
  6628. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6629. if (!$d) //如果没有这个SKU
  6630. {
  6631. $ed[] = array($sku . '-库存中不存在此SKU');
  6632. $j++;
  6633. continue;
  6634. }
  6635. if (!isset($warehouse['id'])) {
  6636. $ed[] = array($sku . '-仓库名错误!');
  6637. $j++;
  6638. continue;
  6639. }
  6640. if ($type == 1 || $type == 2) //扣减库存
  6641. {
  6642. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6643. if (count($data) < abs($num)) {
  6644. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6645. $j++;
  6646. continue;
  6647. }
  6648. if ($type == 1) //转入库存
  6649. {
  6650. for ($i = 0; $i < abs($num); $i++) {
  6651. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6652. }
  6653. } else if ($type == 2) //删除
  6654. {
  6655. for ($i = 0; $i < abs($num); $i++) {
  6656. $this->whlabel->remove($data[$i]['id']);
  6657. }
  6658. }
  6659. } else if ($type == 0) //增加库存
  6660. {
  6661. $post['sku'] = $d['sku'];
  6662. $post['shop'] = '';
  6663. $post['warehouse'] = $warehouse['id'];
  6664. $post['purchase'] = $d['purchase'];
  6665. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6666. $post['state'] = 11;
  6667. $post['title'] = $d['title'];
  6668. $post['number'] = $d['number'];
  6669. $post['features'] = $d['features'];
  6670. $post['enter'] = $time;
  6671. $post['time'] = $time; //操作时间
  6672. for ($i = 0; $i < $num; $i++) {
  6673. $post['label'] = time() . rand(100, 999) . $i;
  6674. $this->whlabel->insert($post);
  6675. }
  6676. }
  6677. sleep(1); //防止入库时间一样,需要延迟1秒
  6678. }
  6679. if ($j > 0) {
  6680. $tt = date('Ymd', time());
  6681. $title = '库存导入错误信息-' . $tt;
  6682. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6683. $tail = "\n";
  6684. $filename = $title . ".xls";
  6685. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6686. $dir = '/data/excel/' . $time . '/';
  6687. $file_name = 'error_' . $time . rand(1000, 9999);
  6688. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6689. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6690. fwrite($myfile, $ecl);
  6691. fclose($myfile);
  6692. $error = $dir . $file_name . '.xls';
  6693. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6694. exit;
  6695. } else {
  6696. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6697. exit;
  6698. }
  6699. }
  6700. }
  6701. public function _fcjxc($arg_array)
  6702. {
  6703. if (isset($_GET['excel'])) {
  6704. $category = $this->input->get('category', true);
  6705. $size = $this->input->get('size', true);
  6706. $grade = $this->input->get('grade', true);
  6707. $color = $this->input->get('color', true);
  6708. $lowe = $this->input->get('lowe', true);
  6709. $sku = $this->input->get('sku');
  6710. $title = $this->input->get('title');
  6711. $warehouse = $arg_array[0];
  6712. $usa = $this->input->get('usa', true);
  6713. $purchase = $this->input->get('purchase', true);
  6714. $lacetype = $this->input->get('lacetype', true);
  6715. $haircap = $this->input->get('haircap', true);
  6716. $density = $this->input->get('density', true);
  6717. $title = $this->input->get('title', true);
  6718. $state = $this->input->get('state', true);
  6719. $ktime = $this->input->get('ktime', true);
  6720. $jtime = $this->input->get('jtime', true);
  6721. $where = "state=11";
  6722. $gj = "";
  6723. $ck = "";
  6724. if ($lacetype) {
  6725. $where .= " and features like '%-$lacetype-%'";
  6726. }
  6727. if ($category) {
  6728. $where .= " and features like '%-$category-%'";
  6729. }
  6730. if ($size) {
  6731. $where .= " and features like '%-$size-%'";
  6732. }
  6733. if ($grade) {
  6734. $where .= " and features like '%-$grade-%'";
  6735. }
  6736. if ($color) {
  6737. $where .= " and features like '%-$color-%'";
  6738. }
  6739. if ($lowe) {
  6740. $where .= " and features like '%-$lowe-%'";
  6741. }
  6742. if ($haircap) {
  6743. $where .= " and features like '%-$haircap-%'";
  6744. }
  6745. if ($density) {
  6746. $where .= " and features like '%-$density-%'";
  6747. }
  6748. if ($usa) {
  6749. if (!$warehouse) {
  6750. $where .= " and (warehouse = '5' or warehouse = '8')";
  6751. }
  6752. }
  6753. if ($warehouse) {
  6754. $where .= " and warehouse = '$warehouse'";
  6755. }
  6756. if ($purchase) {
  6757. $where .= " and purchase = '$purchase'";
  6758. }
  6759. if ($state) {
  6760. $where .= " and state = '$state'";
  6761. }
  6762. $order_str = "id desc";
  6763. if ($sku) {
  6764. $sku = trim($sku, ' ');
  6765. $sku = trim($sku, ' ');
  6766. $where .= " and sku like '%$sku%'";
  6767. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6768. } else if ($title) {
  6769. $title = trim($title, ' ');
  6770. $title = trim($title, ' ');
  6771. $where .= " and title like '%$title%'";
  6772. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6773. } else {
  6774. //$where .= " and time > '$ktime' and time < '$jtime'";
  6775. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6776. }
  6777. //取得信息列表
  6778. $rows = array();
  6779. $list = array();
  6780. foreach ($info_list as $key => $value) {
  6781. $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'] . '"');
  6782. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6783. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6784. $rows[$key] = $value;
  6785. $warehouse = $this->warehouse->read($value['warehouse']);
  6786. $rows[$key]['warehouse'] = $warehouse['title'];
  6787. $rows[$key]['features'] = $g;
  6788. $rows[$key]['a'] = $x;
  6789. $rows[$key]['b'] = $s;
  6790. }
  6791. $title = "总统计表";
  6792. $titlename = "<table border=1>
  6793. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6794. <tr align='center'>
  6795. <td>仓库</td>
  6796. <td>SKU</td>
  6797. <td>产品名称</td>
  6798. <td>录入总量</td>
  6799. <td>取出总量</td>
  6800. <td>剩余总量</td>
  6801. </tr>
  6802. </table>";
  6803. $filename = $title . ".xls";
  6804. $tail = "";
  6805. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6806. }
  6807. $vip = 0;
  6808. if (isset($_SESSION['api'])) {
  6809. $user = $this->user->get_api($_SESSION['api']);
  6810. if ($user['vip'] == 1) {
  6811. $vip = 1;
  6812. }
  6813. } else {
  6814. header('Location: /');
  6815. exit;
  6816. }
  6817. $post = $this->input->post(NULL, TRUE);
  6818. if (isset($post['page'])) {
  6819. $page = $this->input->post('page', true);
  6820. $perpage = $this->input->post('perpage', true);
  6821. $category = $this->input->post('category', true);
  6822. $size = $this->input->post('size', true);
  6823. $grade = $this->input->post('grade', true);
  6824. $color = $this->input->post('color', true);
  6825. $lowe = $this->input->post('lowe', true);
  6826. $sku = $this->input->post('sku');
  6827. $title = $this->input->post('title');
  6828. $warehouse = $arg_array[0];
  6829. $usa = $this->input->post('usa', true);
  6830. $purchase = $this->input->post('purchase', true);
  6831. $lacetype = $this->input->post('lacetype', true);
  6832. $haircap = $this->input->post('haircap', true);
  6833. $density = $this->input->post('density', true);
  6834. $title = $this->input->post('title', true);
  6835. $state = $this->input->post('state', true);
  6836. $ktime = $this->input->post('ktime', true);
  6837. $jtime = $this->input->post('jtime', true);
  6838. $ktime = strtotime($ktime);
  6839. $jtime = strtotime($jtime);
  6840. $where = "state=11";
  6841. $gj = "";
  6842. $ck = "";
  6843. if ($lacetype) {
  6844. $where .= " and features like '%-$lacetype-%'";
  6845. }
  6846. if ($category) {
  6847. $where .= " and features like '%-$category-%'";
  6848. }
  6849. if ($size) {
  6850. $where .= " and features like '%-$size-%'";
  6851. }
  6852. if ($grade) {
  6853. $where .= " and features like '%-$grade-%'";
  6854. }
  6855. if ($color) {
  6856. $where .= " and features like '%-$color-%'";
  6857. }
  6858. if ($lowe) {
  6859. $where .= " and features like '%-$lowe-%'";
  6860. }
  6861. if ($haircap) {
  6862. $where .= " and features like '%-$haircap-%'";
  6863. }
  6864. if ($density) {
  6865. $where .= " and features like '%-$density-%'";
  6866. }
  6867. if ($usa) {
  6868. if (!$warehouse) {
  6869. $where .= " and (warehouse = '5' or warehouse = '8')";
  6870. }
  6871. }
  6872. if ($warehouse) {
  6873. $where .= " and warehouse = '$warehouse'";
  6874. }
  6875. if ($purchase) {
  6876. $where .= " and purchase = '$purchase'";
  6877. }
  6878. if ($state) {
  6879. $where .= " and state = '$state'";
  6880. }
  6881. if ($ktime && $jtime) {
  6882. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6883. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6884. }
  6885. //数据排序
  6886. $order_str = "id desc";
  6887. $xs = 0;
  6888. $rows = array();
  6889. $list = array();
  6890. if (empty($page)) {
  6891. $start = 0;
  6892. $perpage = 1;
  6893. } else {
  6894. $start = ($page - 1) * $perpage;
  6895. }
  6896. if ($sku || $title) {
  6897. if ($title) {
  6898. $title = trim($title, ' ');
  6899. $title = trim($title, ' ');
  6900. $where .= " and title like '%$title%'";
  6901. } else {
  6902. $sku = trim($sku, ' ');
  6903. $sku = trim($sku, ' ');
  6904. $where .= " and sku like '%$sku%'";
  6905. }
  6906. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6907. foreach ($info_list as $key => $value) {
  6908. $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'] . '"');
  6909. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6910. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6911. $rows[$key] = $value;
  6912. $warehouse = $this->warehouse->read($value['warehouse']);
  6913. $rows[$key]['warehouse'] = $warehouse['title'];
  6914. $rows[$key]['features'] = $g;
  6915. $rows[$key]['a'] = $x;
  6916. $rows[$key]['b'] = $s;
  6917. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6918. $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天销量
  6919. $yj = $c / ($xl / 30);
  6920. if ($yj < 7) {
  6921. $rows[$key]['y'] = round($yj) . '天销量';
  6922. } else {
  6923. $rows[$key]['y'] = '正常';
  6924. }
  6925. }
  6926. } else {
  6927. //$where .= " and time > '$ktime' and time < '$jtime'";
  6928. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6929. foreach ($info_list as $key => $value) {
  6930. $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'] . '"');
  6931. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6932. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6933. $zs[$key] = $value;
  6934. $warehouse = $this->warehouse->read($value['warehouse']);
  6935. $zs[$key]['warehouse'] = $warehouse['title'];
  6936. $zs[$key]['features'] = $g;
  6937. $zs[$key]['a'] = $x;
  6938. $zs[$key]['b'] = $s;
  6939. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6940. $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天销量
  6941. $yj = $c / ($xl / 30);
  6942. if ($yj < 7) {
  6943. $zs[$key]['y'] = round($yj) . '天销量';
  6944. $rows[$key] = $zs[$key];
  6945. }
  6946. }
  6947. }
  6948. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  6949. $pagenum = ceil($total / $perpage);
  6950. $over = $total - ($start + $perpage);
  6951. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  6952. echo json_encode($rows);
  6953. exit;
  6954. }
  6955. $this->data['arg_array'] = $arg_array[0];
  6956. $this->_Template('whlabel_fcjxc', $this->data);
  6957. }
  6958. public function _0kcdel()
  6959. {
  6960. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6961. $config['upload_path'] = '.' . $dir;
  6962. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6963. $config['allowed_types'] = 'xls|xlsx|csv';
  6964. $config['max_size'] = 10240;
  6965. $this->load->library('upload', $config);
  6966. $this->upload->initialize($config);
  6967. if ($this->upload->do_upload('userfile')) {
  6968. $full_path = $dir . $this->upload->data('file_name');
  6969. $fileName = '.' . $full_path;
  6970. if (!file_exists($fileName)) {
  6971. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6972. exit;
  6973. } else {
  6974. require_once "./data/excel/PHPExcel/IOFactory.php";
  6975. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6976. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6977. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6978. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6979. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6980. ++$column; //如果列数大于26行
  6981. $list = array();
  6982. for ($i = 2; $i <= $row; $i++) // 行数循环
  6983. {
  6984. $data = array();
  6985. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6986. {
  6987. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6988. }
  6989. $list[] = $data;
  6990. }
  6991. }
  6992. $i = 0;
  6993. $j = 0;
  6994. $ed = array();
  6995. foreach ($list as $key => $value) {
  6996. $time = time();
  6997. if ($value['0'] == "" || $value['1'] == "") {
  6998. continue;
  6999. }
  7000. $warehouse = $this->warehouse->get_title($value['0']);
  7001. $sku = $value['1'];
  7002. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7003. if (!$d) //如果没有这个SKU
  7004. {
  7005. $ed[] = array($sku . '-库存中不存在此SKU');
  7006. $j++;
  7007. continue;
  7008. }
  7009. if (!isset($warehouse['id'])) {
  7010. $ed[] = array($sku . '-仓库名错误!');
  7011. $j++;
  7012. continue;
  7013. }
  7014. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7015. if ($z < 1) {
  7016. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7017. foreach ($z as $v) {
  7018. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7019. if (count($zt) > 0) {
  7020. $ed[] = array($sku . '-有在途库存无法删除!');
  7021. $j++;
  7022. continue;
  7023. }
  7024. $this->whlabel->remove($v['id']);
  7025. }
  7026. } else {
  7027. $ed[] = array($sku . '-非0库存!');
  7028. $j++;
  7029. continue;
  7030. }
  7031. }
  7032. if ($j > 0) {
  7033. $tt = date('Ymd', time());
  7034. $title = '删除0库存错误信息-' . $tt;
  7035. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7036. $tail = "\n";
  7037. $filename = $title . ".xls";
  7038. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7039. $dir = '/data/excel/' . $time . '/';
  7040. $file_name = 'error_' . $time . rand(1000, 9999);
  7041. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7042. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7043. fwrite($myfile, $ecl);
  7044. fclose($myfile);
  7045. $error = $dir . $file_name . '.xls';
  7046. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7047. exit;
  7048. } else {
  7049. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7050. exit;
  7051. }
  7052. }
  7053. }
  7054. public function _gbhtype()
  7055. {
  7056. $post = $this->input->post(NULL, TRUE);
  7057. if (isset($post['s'])) {
  7058. $n = $this->input->post('n');
  7059. $d = $this->input->post('s');
  7060. if (!$d) {
  7061. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7062. exit;
  7063. }
  7064. $d = explode(',', trim($d, ','));
  7065. $t = $this->whlabel_type->read($n);
  7066. //循环删除记录
  7067. foreach ($d as $v) {
  7068. $u = $this->whlabel->read($v);
  7069. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7070. foreach ($data as $val) {
  7071. $this->whlabel->save(array('type' => $n), $val['id']);
  7072. }
  7073. }
  7074. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7075. }
  7076. }
  7077. //出库、退库导出
  7078. public function _dccrtype()
  7079. {
  7080. $classid = $this->classid->sku();
  7081. $pm = $classid;
  7082. $typeclass = array();
  7083. $tc = $this->typeclass->find_all();
  7084. foreach ($tc as $v) {
  7085. $typeclass[$v['id']] = $v;
  7086. }
  7087. $prc = array();
  7088. $purchase = $this->purchase->find_all();
  7089. foreach ($purchase as $k => $v) {
  7090. $prc[$v['id']] = $v['title'];
  7091. }
  7092. if (isset($_GET['sid'])) {
  7093. $wh = array();
  7094. $w = $this->warehouse->find_all('1=1', 'id,title');
  7095. foreach ($w as $v) {
  7096. $wh[$v['id']] = $v['title'];
  7097. }
  7098. $type = $this->input->get('excel', true);
  7099. $category = $this->input->get('category', true);
  7100. $size = $this->input->get('size', true);
  7101. $grade = $this->input->get('grade', true);
  7102. $color = $this->input->get('color', true);
  7103. $lowe = $this->input->get('lowe', true);
  7104. $sku = $this->input->get('sku', true);
  7105. $warehouse = $this->input->get('warehouse', true);
  7106. $lacetype = $this->input->get('lacetype', true);
  7107. $lacecolor = $this->input->get('lacecolor', true);
  7108. $density = $this->input->get('density', true);
  7109. $haircap = $this->input->get('haircap', true);
  7110. $purchase = $this->input->get('purchase', true);
  7111. $title = $this->input->get('title', true);
  7112. $state = $this->input->get('state', true);
  7113. $sid = $this->input->get('sid', true);
  7114. $ktime = $this->input->get('ktime', true);
  7115. $jtime = $this->input->get('jtime', true);
  7116. $ktime = strtotime($ktime);
  7117. $jtime = strtotime($jtime);
  7118. $where = "1=1";
  7119. $gj = "";
  7120. $ck = "";
  7121. if ($category) {
  7122. $where .= " and features like '%-$category-%'";
  7123. }
  7124. if ($size) {
  7125. $where .= " and features like '%-$size-%'";
  7126. }
  7127. if ($grade) {
  7128. $where .= " and features like '%-$grade-%'";
  7129. }
  7130. if ($color) {
  7131. $where .= " and features like '%-$color-%'";
  7132. }
  7133. if ($lowe) {
  7134. $where .= " and features like '%-$lowe-%'";
  7135. }
  7136. if ($warehouse) {
  7137. $where .= " and warehouse = '$warehouse'";
  7138. }
  7139. if ($purchase) {
  7140. $where .= " and purchase = '$purchase'";
  7141. }
  7142. if ($state) {
  7143. $where .= " and state = '$state'";
  7144. }
  7145. if ($lacetype) {
  7146. $where .= " and features like '%-$lacetype-%'";
  7147. }
  7148. if ($lacecolor) {
  7149. $where .= " and features like '%-$lacecolor-%'";
  7150. }
  7151. if ($density) {
  7152. $where .= " and features like '%-$density-%'";
  7153. }
  7154. if ($haircap) {
  7155. $where .= " and features like '%-$haircap-%'";
  7156. }
  7157. if ($title) {
  7158. $title = trim($title, ' ');
  7159. $title = trim($title, ' ');
  7160. $where .= " and title like '%$title%'";
  7161. }
  7162. if ($sku) {
  7163. $sku = trim($sku, ' ');
  7164. $sku = trim($sku, ' ');
  7165. $where .= " and sku like '%$sku%'";
  7166. }
  7167. if ($ktime && $jtime) {
  7168. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7169. }
  7170. $sidwhere = '';
  7171. if ($sid) {
  7172. $sd = "";
  7173. $s = explode(',', trim($sid, ','));
  7174. foreach ($s as $value) {
  7175. $sd .= " id = " . $value . " or";
  7176. }
  7177. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7178. }
  7179. //数据排序
  7180. $order_str = "time desc";
  7181. if (empty($page)) {
  7182. $start = 0;
  7183. $perpage = 1;
  7184. } else {
  7185. $start = ($page - 1) * $perpage;
  7186. }
  7187. $wh = array();
  7188. $w = $this->warehouse->find_all('1=1', 'id,title');
  7189. foreach ($w as $v) {
  7190. $wh[$v['id']] = $v['title'];
  7191. }
  7192. $wt = array();
  7193. $whlabel_type = $this->whlabel_type->find_all();
  7194. foreach ($whlabel_type as $v) {
  7195. $wt[$v['id']] = $v['title'];
  7196. }
  7197. $classid = $this->classid->sku();
  7198. $list = array();
  7199. $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');
  7200. foreach ($rows_r as $key => $value) {
  7201. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7202. $pm = $classid;
  7203. $jm = $classid;
  7204. $rows_r[$key]['enter'] = '入库';
  7205. $rows_r[$key]['time'] = $value['enter'];
  7206. if ($value['rktype'] == 1) {
  7207. $rows_r[$key]['rktype'] = '采购入库';
  7208. } else if ($value['rktype'] == 2) {
  7209. $rows_r[$key]['rktype'] = '盘盈调整';
  7210. } else if ($value['rktype'] == 3) {
  7211. $rows_r[$key]['rktype'] = '其他调整入库';
  7212. } else if ($value['rktype'] == 4) {
  7213. $rows_r[$key]['rktype'] = '其他调整入库';
  7214. } else if ($value['rktype'] == 5) {
  7215. $rows_r[$key]['rktype'] = '退库入库';
  7216. } else if ($value['rktype'] == 6) {
  7217. $rows_r[$key]['rktype'] = '退货可用入库';
  7218. } else if ($value['rktype'] == 7) {
  7219. $rows_r[$key]['rktype'] = '形态转换入库';
  7220. } else {
  7221. $rows_r[$key]['rktype'] = '';
  7222. }
  7223. $features = explode('-', trim($value['features'], '-'));
  7224. foreach ($features as $v) {
  7225. if (isset($typeclass[$v])) {
  7226. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7227. $pm[$typeclass[$v]['classid']] = $zh[0];
  7228. }
  7229. if (isset($typeclass[$v])) {
  7230. if (isset($jm[$typeclass[$v]['classid']])) {
  7231. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7232. }
  7233. }
  7234. }
  7235. $zh = implode(" ", $pm);
  7236. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7237. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7238. $rows_r[$key]['zh'] = $zh;
  7239. $jm = array_filter($jm);
  7240. $rows_r[$key]['features'] = implode("-", $jm);
  7241. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7242. }
  7243. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  7244. foreach ($rows_c as $key => $value) {
  7245. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7246. $pm = $classid;
  7247. $jm = $classid;
  7248. $rows_c[$key]['time'] = $value['outk'];
  7249. $rows_c[$key]['outk'] = '出库';
  7250. if ($value['cktype'] == 1) {
  7251. $rows_c[$key]['cktype'] = '销售出库';
  7252. } else if ($value['cktype'] == 2) {
  7253. $rows_c[$key]['cktype'] = '销售美国出库';
  7254. } else if ($value['cktype'] == 3) {
  7255. $rows_c[$key]['cktype'] = '盘亏调整';
  7256. } else if ($value['cktype'] == 4) {
  7257. $rows_c[$key]['cktype'] = '其他调整出库';
  7258. } else if ($value['cktype'] == 5) {
  7259. $rows_c[$key]['cktype'] = '形态转换出库';
  7260. } else {
  7261. $rows_c[$key]['cktype'] = '';
  7262. }
  7263. $features = explode('-', trim($value['features'], '-'));
  7264. foreach ($features as $v) {
  7265. if (isset($typeclass[$v])) {
  7266. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7267. $pm[$typeclass[$v]['classid']] = $zh[0];
  7268. }
  7269. if (isset($typeclass[$v])) {
  7270. if (isset($jm[$typeclass[$v]['classid']])) {
  7271. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7272. }
  7273. }
  7274. }
  7275. $zh = implode(" ", $pm);
  7276. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7277. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7278. $rows_c[$key]['zh'] = $zh;
  7279. $jm = array_filter($jm);
  7280. $rows_c[$key]['features'] = implode("-", $jm);
  7281. $rows_c[$key]['number'] = 1;
  7282. }
  7283. $merged = $rows_r;
  7284. foreach ($rows_c as $key => $value) {
  7285. if (isset($merged[$key])) {
  7286. $merged[] = $value;
  7287. } else {
  7288. $merged[$key] = $value;
  7289. }
  7290. }
  7291. usort($merged, function ($a, $b) {
  7292. return $a['time'] - $b['time'];
  7293. });
  7294. foreach ($merged as $key => $value) {
  7295. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7296. }
  7297. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7298. $titlename = "<table border=1>
  7299. <tr align='center'>
  7300. <td>仓库</td>
  7301. <td>SKU</td>
  7302. <td>商品名称</td>
  7303. <td>仓库品名</td>
  7304. <td>料号</td>
  7305. <td>时间</td>
  7306. <td>操作</td>
  7307. <td>类型</td>
  7308. <td>数量</td>
  7309. <td>备注</td>
  7310. </tr>
  7311. </table>";
  7312. $filename = $title . ".xlsx";
  7313. $tail = "";
  7314. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7315. }
  7316. }
  7317. }