Whlabel.php 258 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504
  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['wigother1'] = $this->input->post('wigother1', true);
  1742. $list['wigother2'] = $this->input->post('wigother2', true);
  1743. }
  1744. if ($category == 129) {
  1745. $list['wide'] = $this->input->post('wide', true);
  1746. }
  1747. if ($category == 131) {
  1748. $list['gifttype'] = $this->input->post('gifttype', true);
  1749. $list['giftother'] = $this->input->post('giftother', true);
  1750. }
  1751. if ($category == 134) {
  1752. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1753. }
  1754. if ($category == 1297) {
  1755. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1756. $list['sywigother'] = $this->input->post('sywigother', true);
  1757. }
  1758. if ($category == 130 || $category == 133 || $category == 1702) {
  1759. $list['items'] = $this->input->post('items', true);
  1760. $list['weight'] = $this->input->post('weight', true);
  1761. }
  1762. if ($category == 1702) {
  1763. $list['syhairther'] = $this->input->post('syhairther', true);
  1764. }
  1765. $classid = $this->classid->sku();
  1766. $scsku = $classid;
  1767. $pm = $classid;
  1768. foreach ($list as $k => $v) {
  1769. if ($v != 0) {
  1770. $num .= $v;
  1771. $features .= $v . '-';
  1772. $post[$k] = $v;
  1773. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1774. if ($k != 'size') {
  1775. $title .= $typeclass[$v]['title'] . " ";
  1776. }
  1777. if (isset($pm[$typeclass[$v]['classid']])) {
  1778. if ($typeclass[$v]['title'] == '9A') {
  1779. $pm[$typeclass[$v]['classid']] = '9A';
  1780. } else if ($typeclass[$v]['title'] == '10A') {
  1781. $pm[$typeclass[$v]['classid']] = '10A';
  1782. } else {
  1783. $clzh = $typeclass[$v]['zh'];
  1784. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1785. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1786. $clzh = $clzh[0];
  1787. }
  1788. $pm[$typeclass[$v]['classid']] = $clzh;
  1789. }
  1790. }
  1791. }
  1792. }
  1793. $zh = implode(" ", $pm);
  1794. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1795. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1796. if ($list['size']) {
  1797. $typeclass = $this->typeclass->read($list['size']);
  1798. $title .= $typeclass['title'];
  1799. }
  1800. $time = time();
  1801. if ($xzsku) {
  1802. $scsku = implode("-", $scsku);
  1803. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1804. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1805. $post['sku'] = trim($scsku, ' ');
  1806. } else {
  1807. $post['sku'] = $sku;
  1808. }
  1809. //$post['sku'] = trim($sku,' ');
  1810. $post['title'] = rtrim($title, ' ');
  1811. $post['number'] = $num;
  1812. $post['features'] = '-' . $features;
  1813. $post['enter'] = $time;
  1814. $post['time'] = $time; //操作时间
  1815. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1816. if ($yza) {
  1817. if ($post['features'] != $yza[0]['features']) {
  1818. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1819. exit;
  1820. }
  1821. }
  1822. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1823. if ($yzb) {
  1824. if ($post['sku'] != $yzb[0]['sku']) {
  1825. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1826. exit;
  1827. }
  1828. }
  1829. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1830. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1831. exit;
  1832. }
  1833. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1834. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1835. exit;
  1836. }
  1837. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1838. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1839. exit;
  1840. }
  1841. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1842. if (isset($yz[0]['type'])) {
  1843. $post['type'] = $yz[0]['type'];
  1844. }
  1845. if ($post['state'] == 9) //如果选择预设库存
  1846. {
  1847. $this->whlabel->insert($post);
  1848. } else {
  1849. /**
  1850. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1851. if($ljg == 1)
  1852. {
  1853. for($i=0;$i<$order;$i++)
  1854. {
  1855. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1856. $this->whlabel->insert($post);
  1857. }
  1858. }
  1859. **/
  1860. //if($post['warehouse'] == '5')
  1861. //{
  1862. //}
  1863. $yydata = $post;
  1864. $yydata['zh'] = $zh;
  1865. /**
  1866. $wl = $this->apiyy->get_cjlp($yydata);
  1867. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1868. {
  1869. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1870. }
  1871. if($wl['Data'][0]['m_isSucess'] != 1)
  1872. {
  1873. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1874. }
  1875. **/
  1876. for ($i = 0; $i < $order; $i++) {
  1877. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1878. $this->whlabel->insert($post);
  1879. }
  1880. }
  1881. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1882. exit;
  1883. }
  1884. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1885. $this->data['wlshop'] = $wlshop;
  1886. $this->_Template('whlabel_enteradd', $this->data);
  1887. }
  1888. //修改产品
  1889. public function _enteredit($arg_array)
  1890. {
  1891. $dt = 0;
  1892. if (isset($_SESSION['api'])) {
  1893. $user = $this->user->get_api($_SESSION['api']);
  1894. $usp = $user;
  1895. $fgshop = "";
  1896. $sid = "";
  1897. $user = explode('|', trim($user['shop'], '|'));
  1898. foreach ($user as $value) {
  1899. $fgshop .= " shop = " . $value . " or";
  1900. $sid .= " id = " . $value . " or";
  1901. }
  1902. }
  1903. $post = $this->input->post(NULL, TRUE);
  1904. if (isset($post['sku'])) {
  1905. $list = array();
  1906. $num = "";
  1907. $title = "";
  1908. $features = "";
  1909. $id = $this->input->post('id', true);
  1910. $order = $this->input->post('order', true);
  1911. $shop = $this->input->post('shop', true);
  1912. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1913. $post['sku'] = $this->input->post('sku', true);
  1914. $post['sm'] = $this->input->post('sm', true);
  1915. $post['warehouse'] = $this->input->post('warehouse', true);
  1916. $post['purchase'] = $this->input->post('purchase', true);
  1917. $post['retreatwarehouse'] = $post['warehouse'];
  1918. $category = $this->input->post('category', true);
  1919. $list['category'] = $category;
  1920. $list['hairtype'] = $this->input->post('hairtype', true);
  1921. $list['grade'] = $this->input->post('grade', true);
  1922. $size = $this->input->post('size', true);
  1923. $list['size'] = rtrim($size, ',');
  1924. $post['rktype'] = $this->input->post('rktype', true);
  1925. $post['text'] = $this->input->post('text', true);
  1926. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1927. $list['extension'] = $this->input->post('extension', true);
  1928. if ($category == 1297) {
  1929. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1930. }
  1931. if ($category == 1702) {
  1932. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1933. $list['syother'] = $this->input->post('syother', true);
  1934. }
  1935. if ($category == 133) {
  1936. $list['fittype'] = $this->input->post('fittype', true);
  1937. $list['acother'] = $this->input->post('acother', true);
  1938. }
  1939. $list['color'] = $this->input->post('color', true);
  1940. $list['lowe'] = $this->input->post('lowe', true);
  1941. if (!$post['purchase']) {
  1942. $post['purchase'] = 1;
  1943. }
  1944. if ($category == 127) {
  1945. $list['type'] = $this->input->post('type', true);
  1946. $list['headroad'] = $this->input->post('headroad', true);
  1947. $list['density'] = $this->input->post('density', true);
  1948. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1949. $list['lacesize'] = $this->input->post('lacesize', true);
  1950. }
  1951. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1952. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1953. }
  1954. if ($category == 128) {
  1955. $list['lacetype'] = $this->input->post('lacetype', true);
  1956. $list['haircap'] = $this->input->post('haircap', true);
  1957. $list['density'] = $this->input->post('density', true);
  1958. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1959. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1960. $list['wigother'] = $this->input->post('wigother', true);
  1961. $list['wigother1'] = $this->input->post('wigother2', true);
  1962. $list['wigother2'] = $this->input->post('wigother2', true);
  1963. }
  1964. if ($category == 129) {
  1965. $list['wide'] = $this->input->post('wide', true);
  1966. }
  1967. if ($category == 131) {
  1968. $list['gifttype'] = $this->input->post('gifttype', true);
  1969. $list['giftother'] = $this->input->post('giftother', true);
  1970. }
  1971. if ($category == 134) {
  1972. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1973. }
  1974. if ($category == 1297) {
  1975. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1976. $list['sywigother'] = $this->input->post('sywigother', true);
  1977. }
  1978. if ($category == 130 || $category == 133 || $category == 1702) {
  1979. $list['items'] = $this->input->post('items', true);
  1980. $list['weight'] = $this->input->post('weight', true);
  1981. }
  1982. if ($category == 1702) {
  1983. $list['syhairther'] = $this->input->post('syhairther', true);
  1984. }
  1985. foreach ($list as $k => $v) {
  1986. if ($v != 0) {
  1987. $num .= $v;
  1988. $features .= $v . '-';
  1989. $typeclass = $this->typeclass->read($v);
  1990. if ($k != 'size') {
  1991. $title .= $typeclass['title'] . " ";
  1992. }
  1993. }
  1994. }
  1995. $typeclass = $this->typeclass->read($list['size']);
  1996. $title .= $typeclass['title'];
  1997. $time = time();
  1998. $post['title'] = rtrim($title, ' ');
  1999. $post['number'] = $num;
  2000. $post['features'] = '-' . $features;
  2001. $post['time'] = $time; //操作时间
  2002. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2003. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2004. exit;
  2005. }
  2006. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2007. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2008. exit;
  2009. }
  2010. $uid = $this->whlabel->read($id);
  2011. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2012. if ($datanum > 0) {
  2013. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2014. exit;
  2015. }
  2016. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2017. {
  2018. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2019. if ($yza) {
  2020. if ($post['features'] != $yza[0]['features']) {
  2021. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2022. exit;
  2023. }
  2024. }
  2025. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2026. if ($yzb) {
  2027. if ($post['sku'] != $yzb[0]['sku']) {
  2028. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2029. exit;
  2030. }
  2031. }
  2032. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2033. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2034. exit;
  2035. }
  2036. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2037. foreach ($data as $v) {
  2038. $post['id'] = $v['id'];
  2039. $this->whlabel->save($post, $v['id']);
  2040. }
  2041. } else {
  2042. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2043. if ($data > 0) {
  2044. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2045. exit;
  2046. } else {
  2047. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2048. foreach ($data as $v) {
  2049. $post['id'] = $v['id'];
  2050. $this->whlabel->save($post, $v['id']);
  2051. }
  2052. }
  2053. }
  2054. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2055. exit;
  2056. }
  2057. $uid = $this->whlabel->read($arg_array[0]);
  2058. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2059. $this->data['enter'] = $uid;
  2060. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2061. $this->data['wlshop'] = $wlshop;
  2062. $this->_Template('whlabel_enteredit', $this->data);
  2063. }
  2064. //入库浏览
  2065. public function _enter()
  2066. {
  2067. $post = $this->input->post(NULL, TRUE);
  2068. if (isset($post['s'])) {
  2069. $id_arr = $this->input->post('s');
  2070. $id_arr = explode(',', $id_arr);
  2071. if (!$id_arr) {
  2072. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2073. exit;
  2074. }
  2075. //循环删除记录
  2076. foreach ($id_arr as $v) {
  2077. $sid = $this->whlabel->read($v);
  2078. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2079. if ($count > 0) {
  2080. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2081. exit;
  2082. }
  2083. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2084. foreach ($info_list as $va) {
  2085. $this->whlabel->remove($va['id']);
  2086. }
  2087. }
  2088. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2089. exit;
  2090. }
  2091. $sp = array();
  2092. $s = $this->shop->find_all('1=1', 'id,shopname');
  2093. foreach ($s as $v) {
  2094. $sp[$v['id']] = $v['shopname'];
  2095. }
  2096. $wh = array();
  2097. $w = $this->warehouse->find_all('1=1', 'id,title');
  2098. foreach ($w as $v) {
  2099. $wh[$v['id']] = $v['title'];
  2100. }
  2101. if (isset($post['page'])) {
  2102. $page = $this->input->post('page', true);
  2103. $perpage = $this->input->post('perpage', true);
  2104. $category = $this->input->post('category', true);
  2105. $size = $this->input->post('size', true);
  2106. $grade = $this->input->post('grade', true);
  2107. $color = $this->input->post('color', true);
  2108. $lowe = $this->input->post('lowe', true);
  2109. $sku = $this->input->post('sku', true);
  2110. $warehouse = $this->input->post('warehouse', true);
  2111. $purchase = $this->input->post('purchase', true);
  2112. $ktime = $this->input->post('ktime', true);
  2113. $jtime = $this->input->post('jtime', true);
  2114. $ktime = strtotime($ktime);
  2115. $jtime = strtotime($jtime);
  2116. $where = "1=1";
  2117. $gj = "";
  2118. $ck = "";
  2119. if ($category) {
  2120. $where .= " and features like '%-$category-%'";
  2121. }
  2122. if ($size) {
  2123. $where .= " and features like '%-$size-%'";
  2124. }
  2125. if ($grade) {
  2126. $where .= " and features like '%-$grade-%'";
  2127. }
  2128. if ($color) {
  2129. $where .= " and features like '%-$color-%'";
  2130. }
  2131. if ($lowe) {
  2132. $where .= " and features like '%-$lowe-%'";
  2133. }
  2134. if ($warehouse) {
  2135. $where .= " and warehouse = '$warehouse'";
  2136. }
  2137. if ($purchase) {
  2138. $where .= " and purchase = '$purchase'";
  2139. }
  2140. if ($sku) {
  2141. $where .= " and sku like '%$sku%'";
  2142. }
  2143. if ($ktime && $jtime) {
  2144. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2145. }
  2146. //数据排序
  2147. $order_str = "enter desc";
  2148. if (empty($page)) {
  2149. $start = 0;
  2150. $perpage = 1;
  2151. } else {
  2152. $start = ($page - 1) * $perpage;
  2153. }
  2154. //取得信息列表
  2155. $info_list = $this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2156. foreach ($info_list as $k => $v) {
  2157. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2158. if ($v['shop'] == '') {
  2159. $s = '通用';
  2160. } else {
  2161. $info_list[$k]['shop'] = '';
  2162. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2163. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2164. }
  2165. }
  2166. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2167. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2168. $info_list[$k]['g'] = $g;
  2169. }
  2170. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2171. $pagenum = ceil($total / $perpage);
  2172. $over = $total - ($start + $perpage);
  2173. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2174. echo json_encode($rows);
  2175. exit;
  2176. }
  2177. $this->_Template('whlabel_enter', $this->data);
  2178. }
  2179. //出库浏览
  2180. public function _out()
  2181. {
  2182. $post = $this->input->post(NULL, TRUE);
  2183. if (isset($post['page'])) {
  2184. $page = $this->input->post('page', true);
  2185. $perpage = $this->input->post('perpage', true);
  2186. $category = $this->input->post('category', true);
  2187. $size = $this->input->post('size', true);
  2188. $grade = $this->input->post('grade', true);
  2189. $color = $this->input->post('color', true);
  2190. $lowe = $this->input->post('lowe', true);
  2191. $sku = $this->input->post('sku', true);
  2192. $warehouse = $this->input->post('warehouse', true);
  2193. $purchase = $this->input->post('purchase', true);
  2194. $state = $this->input->post('state', true);
  2195. $ktime = $this->input->post('ktime', true);
  2196. $jtime = $this->input->post('jtime', true);
  2197. $ktime = strtotime($ktime);
  2198. $jtime = strtotime($jtime);
  2199. $where = "state=3";
  2200. $gj = "";
  2201. $ck = "";
  2202. if ($category) {
  2203. $where .= " and features like '%-$category-%'";
  2204. }
  2205. if ($size) {
  2206. $where .= " and features like '%-$size-%'";
  2207. }
  2208. if ($grade) {
  2209. $where .= " and features like '%-$grade-%'";
  2210. }
  2211. if ($color) {
  2212. $where .= " and features like '%-$color-%'";
  2213. }
  2214. if ($lowe) {
  2215. $where .= " and features like '%-$lowe-%'";
  2216. }
  2217. if ($state) {
  2218. $where .= " and state = '$state'";
  2219. }
  2220. if ($warehouse) {
  2221. $where .= " and warehouse = '$warehouse'";
  2222. }
  2223. if ($purchase) {
  2224. $where .= " and purchase = '$purchase'";
  2225. }
  2226. if ($sku) {
  2227. $where .= " and sku = '$sku'";
  2228. }
  2229. if ($ktime && $jtime) {
  2230. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2231. }
  2232. //数据排序
  2233. $order_str = "id desc";
  2234. if (empty($page)) {
  2235. $start = 0;
  2236. $perpage = 1;
  2237. } else {
  2238. $start = ($page - 1) * $perpage;
  2239. }
  2240. //取得信息列表
  2241. $info_list = $this->whlabel->find_all($where, 'sku');
  2242. $rows = array();
  2243. $list = array();
  2244. foreach ($info_list as $key => $value) {
  2245. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2246. }
  2247. $rows = array_unique($rows); //删除重复记录
  2248. foreach ($rows as $key => $value) {
  2249. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2250. $ck = $this->warehouse->read($data['warehouse']);
  2251. $warehouse = $ck['title'];
  2252. $gy = $this->purchase->read($data['purchase']);
  2253. $purchase = $gy['purchase'];
  2254. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2255. $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);
  2256. }
  2257. $total = count($list);
  2258. $pagenum = ceil($total / $perpage);
  2259. $over = $total - ($start + $perpage);
  2260. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2261. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2262. echo json_encode($rows);
  2263. exit;
  2264. }
  2265. $this->_Template('whlabel_out', $this->data);
  2266. }
  2267. //出库标签浏览
  2268. public function _label()
  2269. {
  2270. $post = $this->input->post(NULL, TRUE);
  2271. if (isset($post['page'])) {
  2272. $page = $this->input->post('page', true);
  2273. $perpage = $this->input->post('perpage', true);
  2274. $sku = $this->input->post('sku', true);
  2275. $warehouse = $this->input->post('warehouse', true);
  2276. $purchase = $this->input->post('purchase', true);
  2277. $orderinfo = $this->input->post('orderinfo', true);
  2278. $waybill = $this->input->post('waybill', true);
  2279. $category = $this->input->post('category', true);
  2280. $size = $this->input->post('size', true);
  2281. $grade = $this->input->post('grade', true);
  2282. $color = $this->input->post('color', true);
  2283. $lowe = $this->input->post('lowe', true);
  2284. $where = "state=1";
  2285. if ($sku) {
  2286. $where .= " and sku = '$sku'";
  2287. }
  2288. if ($warehouse) {
  2289. $where .= " and warehouse = '$warehouse'";
  2290. }
  2291. if ($purchase) {
  2292. $where .= " and purchase = '$purchase'";
  2293. }
  2294. if ($orderinfo) {
  2295. $where .= " and orderinfo = '$orderinfo'";
  2296. }
  2297. if ($waybill) {
  2298. $where .= " and waybill = '$waybill'";
  2299. }
  2300. if ($category) {
  2301. $where .= " and features like '%-$category-%'";
  2302. }
  2303. if ($size) {
  2304. $where .= " and features like '%-$size-%'";
  2305. }
  2306. if ($grade) {
  2307. $where .= " and features like '%-$grade-%'";
  2308. }
  2309. if ($color) {
  2310. $where .= " and features like '%-$color-%'";
  2311. }
  2312. if ($lowe) {
  2313. $where .= " and features like '%-$lowe-%'";
  2314. }
  2315. //数据排序
  2316. $order_str = "outk desc";
  2317. if (empty($page)) {
  2318. $start = 0;
  2319. $perpage = 1;
  2320. } else {
  2321. $start = ($page - 1) * $perpage;
  2322. }
  2323. //取得信息列表
  2324. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2325. foreach ($info_list as $key => $value) {
  2326. $warehouse = $this->warehouse->read($value['warehouse']);
  2327. $info_list[$key]['warehouse'] = $warehouse['title'];
  2328. $purchase = $this->purchase->read($value['purchase']);
  2329. $info_list[$key]['purchase'] = $purchase['title'];
  2330. if ($value['outk'] != 0) {
  2331. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2332. } else {
  2333. $info_list[$key]['outk'] = "";
  2334. }
  2335. if ($value['orderinfo'] == 0) {
  2336. $info_list[$key]['orderinfo'] = "";
  2337. }
  2338. if ($value['waybill'] == 0) {
  2339. $info_list[$key]['waybill'] = "";
  2340. }
  2341. }
  2342. $total = $this->whlabel->find_count($where);
  2343. $pagenum = ceil($total / $perpage);
  2344. $over = $total - ($start + $perpage);
  2345. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2346. echo json_encode($rows);
  2347. exit;
  2348. }
  2349. $this->_Template('whlabel_label', $this->data);
  2350. }
  2351. //独立站出库订单
  2352. public function _outorder()
  2353. {
  2354. if (isset($_SESSION['api'])) {
  2355. $user = $this->user->get_api($_SESSION['api']);
  2356. $usp = $user;
  2357. $fgshop = "";
  2358. $sid = "";
  2359. $user = explode('|', trim($user['shop'], '|'));
  2360. foreach ($user as $value) {
  2361. $fgshop .= " shop = " . $value . " or";
  2362. $sid .= " id = " . $value . " or";
  2363. }
  2364. } else {
  2365. echo "请重新登录";
  2366. }
  2367. $post = $this->input->post(NULL, TRUE);
  2368. if (isset($post['page'])) {
  2369. $page = $this->input->post('page', true);
  2370. $perpage = $this->input->post('perpage', true);
  2371. $warehouse = $this->input->post('warehouse', true);
  2372. $xztime = $this->input->post('xztime', true);
  2373. $timetk = $this->input->post('timetkk', true);
  2374. $timetj = $this->input->post('timetjj', true);
  2375. $shop = $this->input->post('shop', true);
  2376. $source = $this->input->post('source', true);
  2377. $orderinfo = $this->input->post('orderinfo', true);
  2378. $number = $this->input->post('number', true);
  2379. $sfxh = $this->input->post('sfxh', true);
  2380. $express = $this->input->post('express', true);
  2381. $waybill = $this->input->post('waybill', true);
  2382. $library = $this->input->post('library', true);
  2383. $country = $this->input->post('country', true);
  2384. $so = $this->input->post('so', true);
  2385. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2386. $print = $this->input->post('print', true);
  2387. $state = $this->input->post('state', true);
  2388. $orderurl = $this->input->post('orderurl', true);
  2389. $timetk = strtotime($timetk);
  2390. $timetj = strtotime($timetj);
  2391. /**
  2392. $sj = $this->input->post('sj',true);
  2393. if($sj)
  2394. {
  2395. $sj = $this->input->post('sj',true);
  2396. }
  2397. else
  2398. {
  2399. $sj = "fullorder";
  2400. }
  2401. **/
  2402. $sj = "fullorder";
  2403. $where = "1=1";
  2404. if ($warehouse) {
  2405. $where .= " and type = '$warehouse'";
  2406. }
  2407. if ($timetk && $timetj) {
  2408. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2409. }
  2410. if ($orderinfo) {
  2411. $where .= " and orderinfo = '$orderinfo'";
  2412. }
  2413. if ($number) {
  2414. $where .= " and number = '$number'";
  2415. }
  2416. if ($express) {
  2417. $where .= " and express = '$express'";
  2418. }
  2419. if ($waybill) {
  2420. $where .= " and waybill = '$waybill'";
  2421. }
  2422. if ($library) {
  2423. $where .= " and library = '$library'";
  2424. }
  2425. if ($print) {
  2426. $where .= " and print = '$print'";
  2427. }
  2428. if ($libraryconfirm) {
  2429. $where .= " and libraryconfirm = '$libraryconfirm'";
  2430. }
  2431. if ($state) {
  2432. $where .= " and state = '$state'";
  2433. }
  2434. if ($shop) {
  2435. $where .= " and shop = '$shop'";
  2436. }
  2437. if ($country) {
  2438. $where .= " and country = '$country'";
  2439. }
  2440. if ($sfxh != '') {
  2441. $where .= " and sfxh = '$sfxh'";
  2442. }
  2443. if ($so) {
  2444. $where .= " and shipremarks like '%$so%'";
  2445. }
  2446. if ($source) {
  2447. if ($source == '2d') {
  2448. $where .= " and source >= '2'";
  2449. } else {
  2450. $where .= " and source = '$source'";
  2451. }
  2452. }
  2453. if (isset($_SESSION['api'])) {
  2454. foreach ($user as $value) {
  2455. $fgshop .= " shop = " . $value . " or";
  2456. }
  2457. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2458. }
  2459. if ($orderurl) {
  2460. $url = $this->orderurl->read($orderurl);
  2461. $where .= " and link like '%" . $url['url'] . "%'";
  2462. }
  2463. //数据排序
  2464. $order_str = "librarytime desc";
  2465. if (empty($page)) {
  2466. $start = 0;
  2467. $perpage = 1;
  2468. } else {
  2469. $start = ($page - 1) * $perpage;
  2470. }
  2471. //取得信息列表
  2472. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2473. //格式化数据
  2474. foreach ($info_list as $key => $value) {
  2475. $shop = $this->shop->read($value['shop']);
  2476. $info_list[$key]['shop'] = $shop['shopname'];
  2477. $express = $this->express->read($value['express']);
  2478. $info_list[$key]['express'] = $express['servicename'];
  2479. $warehouse = $this->warehouse->read($value['type']);
  2480. $info_list[$key]['type'] = $warehouse['title'];
  2481. if ($value['librarytime'] == '0') {
  2482. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2483. } else {
  2484. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2485. }
  2486. }
  2487. $total = $this->$sj->find_count($where);
  2488. $pagenum = ceil($total / $perpage);
  2489. $over = $total - ($start + $perpage);
  2490. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2491. echo json_encode($rows);
  2492. exit;
  2493. }
  2494. $this->data['express'] = $this->express->find_all();
  2495. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2496. $this->data['wlshop'] = $wlshop;
  2497. $user = $this->user->get_api($_SESSION['api']);
  2498. $powerid = $this->power->read($user['power']);
  2499. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2500. $pid = '';
  2501. foreach ($powertext as $v) {
  2502. $pid .= " id = " . $v . " or";
  2503. }
  2504. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2505. $this->data['fullorderexcel'] = $fullorderexcel;
  2506. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2507. $this->data['orderurl'] = $orderurl;
  2508. $this->_Template('whlabel_outorder', $this->data);
  2509. }
  2510. //tt出库
  2511. public function _toutorder()
  2512. {
  2513. if (isset($_SESSION['api'])) {
  2514. $user = $this->user->get_api($_SESSION['api']);
  2515. $usp = $user;
  2516. $fgshop = "";
  2517. $sid = "";
  2518. $user = explode('|', trim($user['shop'], '|'));
  2519. foreach ($user as $value) {
  2520. $fgshop .= " shop = " . $value . " or";
  2521. $sid .= " id = " . $value . " or";
  2522. }
  2523. } else {
  2524. echo "请重新登录";
  2525. }
  2526. $post = $this->input->post(NULL, TRUE);
  2527. if (isset($post['page'])) {
  2528. $page = $this->input->post('page', true);
  2529. $perpage = $this->input->post('perpage', true);
  2530. $warehouse = $this->input->post('warehouse', true);
  2531. $xztime = $this->input->post('xztime', true);
  2532. $timetk = $this->input->post('timetkk', true);
  2533. $timetj = $this->input->post('timetjj', true);
  2534. $shop = $this->input->post('shop', true);
  2535. $source = $this->input->post('source', true);
  2536. $orderinfo = $this->input->post('orderinfo', true);
  2537. $number = $this->input->post('number', true);
  2538. $sfxh = $this->input->post('sfxh', true);
  2539. $express = $this->input->post('express', true);
  2540. $waybill = $this->input->post('waybill', true);
  2541. $library = $this->input->post('library', true);
  2542. $country = $this->input->post('country', true);
  2543. $so = $this->input->post('so', true);
  2544. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2545. $print = $this->input->post('print', true);
  2546. $state = $this->input->post('state', true);
  2547. $orderurl = $this->input->post('orderurl', true);
  2548. $timetk = strtotime($timetk);
  2549. $timetj = strtotime($timetj);
  2550. /**
  2551. $sj = $this->input->post('sj',true);
  2552. if($sj)
  2553. {
  2554. $sj = $this->input->post('sj',true);
  2555. }
  2556. else
  2557. {
  2558. $sj = "fullorder";
  2559. }
  2560. **/
  2561. $sj = "fullordertt";
  2562. $where = "1=1";
  2563. if ($warehouse) {
  2564. $where .= " and type = '$warehouse'";
  2565. }
  2566. if ($timetk && $timetj) {
  2567. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2568. }
  2569. if ($orderinfo) {
  2570. $where .= " and orderinfo = '$orderinfo'";
  2571. }
  2572. if ($number) {
  2573. $where .= " and number = '$number'";
  2574. }
  2575. if ($express) {
  2576. $where .= " and express = '$express'";
  2577. }
  2578. if ($waybill) {
  2579. $where .= " and waybill = '$waybill'";
  2580. }
  2581. if ($library) {
  2582. $where .= " and library = '$library'";
  2583. }
  2584. if ($print) {
  2585. $where .= " and print = '$print'";
  2586. }
  2587. if ($libraryconfirm) {
  2588. $where .= " and libraryconfirm = '$libraryconfirm'";
  2589. }
  2590. if ($state) {
  2591. $where .= " and state = '$state'";
  2592. }
  2593. if ($shop) {
  2594. $where .= " and shop = '$shop'";
  2595. }
  2596. if ($country) {
  2597. $where .= " and country = '$country'";
  2598. }
  2599. if ($sfxh != '') {
  2600. $where .= " and sfxh = '$sfxh'";
  2601. }
  2602. if ($so) {
  2603. $where .= " and shipremarks like '%$so%'";
  2604. }
  2605. if ($source) {
  2606. if ($source == '2d') {
  2607. $where .= " and source >= '2'";
  2608. } else {
  2609. $where .= " and source = '$source'";
  2610. }
  2611. }
  2612. if (isset($_SESSION['api'])) {
  2613. foreach ($user as $value) {
  2614. $fgshop .= " shop = " . $value . " or";
  2615. }
  2616. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2617. }
  2618. if ($orderurl) {
  2619. $url = $this->orderurl->read($orderurl);
  2620. $where .= " and link like '%" . $url['url'] . "%'";
  2621. }
  2622. //数据排序
  2623. $order_str = "librarytime desc";
  2624. if (empty($page)) {
  2625. $start = 0;
  2626. $perpage = 1;
  2627. } else {
  2628. $start = ($page - 1) * $perpage;
  2629. }
  2630. //取得信息列表
  2631. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2632. //格式化数据
  2633. foreach ($info_list as $key => $value) {
  2634. $shop = $this->shop->read($value['shop']);
  2635. $info_list[$key]['shop'] = $shop['shopname'];
  2636. $express = $this->express->read($value['express']);
  2637. $info_list[$key]['express'] = $express['servicename'];
  2638. $warehouse = $this->warehouse->read($value['type']);
  2639. $info_list[$key]['type'] = $warehouse['title'];
  2640. if ($value['librarytime'] == '0') {
  2641. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2642. } else {
  2643. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2644. }
  2645. }
  2646. $total = $this->$sj->find_count($where);
  2647. $pagenum = ceil($total / $perpage);
  2648. $over = $total - ($start + $perpage);
  2649. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2650. echo json_encode($rows);
  2651. exit;
  2652. }
  2653. $this->data['express'] = $this->express->find_all();
  2654. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2655. $this->data['wlshop'] = $wlshop;
  2656. $user = $this->user->get_api($_SESSION['api']);
  2657. $powerid = $this->power->read($user['power']);
  2658. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2659. $pid = '';
  2660. foreach ($powertext as $v) {
  2661. $pid .= " id = " . $v . " or";
  2662. }
  2663. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2664. $this->data['fullorderexcel'] = $fullorderexcel;
  2665. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2666. $this->data['orderurl'] = $orderurl;
  2667. $this->_Template('whlabel_toutorder', $this->data);
  2668. }
  2669. //tt出库
  2670. public function _aoutorder()
  2671. {
  2672. if (isset($_SESSION['api'])) {
  2673. $user = $this->user->get_api($_SESSION['api']);
  2674. $usp = $user;
  2675. $fgshop = "";
  2676. $sid = "";
  2677. $user = explode('|', trim($user['shop'], '|'));
  2678. foreach ($user as $value) {
  2679. $fgshop .= " shop = " . $value . " or";
  2680. $sid .= " id = " . $value . " or";
  2681. }
  2682. } else {
  2683. echo "请重新登录";
  2684. }
  2685. $post = $this->input->post(NULL, TRUE);
  2686. if (isset($post['page'])) {
  2687. $page = $this->input->post('page', true);
  2688. $perpage = $this->input->post('perpage', true);
  2689. $warehouse = $this->input->post('warehouse', true);
  2690. $xztime = $this->input->post('xztime', true);
  2691. $timetk = $this->input->post('timetkk', true);
  2692. $timetj = $this->input->post('timetjj', true);
  2693. $shop = $this->input->post('shop', true);
  2694. $source = $this->input->post('source', true);
  2695. $orderinfo = $this->input->post('orderinfo', true);
  2696. $number = $this->input->post('number', true);
  2697. $sfxh = $this->input->post('sfxh', true);
  2698. $express = $this->input->post('express', true);
  2699. $waybill = $this->input->post('waybill', true);
  2700. $library = $this->input->post('library', true);
  2701. $country = $this->input->post('country', true);
  2702. $so = $this->input->post('so', true);
  2703. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2704. $print = $this->input->post('print', true);
  2705. $state = $this->input->post('state', true);
  2706. $orderurl = $this->input->post('orderurl', true);
  2707. $timetk = strtotime($timetk);
  2708. $timetj = strtotime($timetj);
  2709. /**
  2710. $sj = $this->input->post('sj',true);
  2711. if($sj)
  2712. {
  2713. $sj = $this->input->post('sj',true);
  2714. }
  2715. else
  2716. {
  2717. $sj = "fullorder";
  2718. }
  2719. **/
  2720. $sj = "fullorderamz";
  2721. $where = "1=1";
  2722. if ($warehouse) {
  2723. $where .= " and type = '$warehouse'";
  2724. }
  2725. if ($timetk && $timetj) {
  2726. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2727. }
  2728. if ($orderinfo) {
  2729. $where .= " and orderinfo = '$orderinfo'";
  2730. }
  2731. if ($number) {
  2732. $where .= " and number = '$number'";
  2733. }
  2734. if ($express) {
  2735. $where .= " and express = '$express'";
  2736. }
  2737. if ($waybill) {
  2738. $where .= " and waybill = '$waybill'";
  2739. }
  2740. if ($library) {
  2741. $where .= " and library = '$library'";
  2742. }
  2743. if ($print) {
  2744. $where .= " and print = '$print'";
  2745. }
  2746. if ($libraryconfirm) {
  2747. $where .= " and libraryconfirm = '$libraryconfirm'";
  2748. }
  2749. if ($state) {
  2750. $where .= " and state = '$state'";
  2751. }
  2752. if ($shop) {
  2753. $where .= " and shop = '$shop'";
  2754. }
  2755. if ($country) {
  2756. $where .= " and country = '$country'";
  2757. }
  2758. if ($sfxh != '') {
  2759. $where .= " and sfxh = '$sfxh'";
  2760. }
  2761. if ($so) {
  2762. $where .= " and shipremarks like '%$so%'";
  2763. }
  2764. if ($source) {
  2765. if ($source == '2d') {
  2766. $where .= " and source >= '2'";
  2767. } else {
  2768. $where .= " and source = '$source'";
  2769. }
  2770. }
  2771. if (isset($_SESSION['api'])) {
  2772. foreach ($user as $value) {
  2773. $fgshop .= " shop = " . $value . " or";
  2774. }
  2775. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2776. }
  2777. if ($orderurl) {
  2778. $url = $this->orderurl->read($orderurl);
  2779. $where .= " and link like '%" . $url['url'] . "%'";
  2780. }
  2781. //数据排序
  2782. $order_str = "librarytime desc";
  2783. if (empty($page)) {
  2784. $start = 0;
  2785. $perpage = 1;
  2786. } else {
  2787. $start = ($page - 1) * $perpage;
  2788. }
  2789. //取得信息列表
  2790. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2791. //格式化数据
  2792. foreach ($info_list as $key => $value) {
  2793. $shop = $this->shop->read($value['shop']);
  2794. $info_list[$key]['shop'] = $shop['shopname'];
  2795. $express = $this->express->read($value['express']);
  2796. $info_list[$key]['express'] = $express['servicename'];
  2797. $warehouse = $this->warehouse->read($value['type']);
  2798. $info_list[$key]['type'] = $warehouse['title'];
  2799. if ($value['librarytime'] == '0') {
  2800. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2801. } else {
  2802. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2803. }
  2804. }
  2805. $total = $this->$sj->find_count($where);
  2806. $pagenum = ceil($total / $perpage);
  2807. $over = $total - ($start + $perpage);
  2808. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2809. echo json_encode($rows);
  2810. exit;
  2811. }
  2812. $this->data['express'] = $this->express->find_all();
  2813. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2814. $this->data['wlshop'] = $wlshop;
  2815. $user = $this->user->get_api($_SESSION['api']);
  2816. $powerid = $this->power->read($user['power']);
  2817. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2818. $pid = '';
  2819. foreach ($powertext as $v) {
  2820. $pid .= " id = " . $v . " or";
  2821. }
  2822. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2823. $this->data['fullorderexcel'] = $fullorderexcel;
  2824. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2825. $this->data['orderurl'] = $orderurl;
  2826. $this->_Template('whlabel_aoutorder', $this->data);
  2827. }
  2828. //速卖通出库订单
  2829. public function _soutorder()
  2830. {
  2831. if (isset($_SESSION['api'])) {
  2832. $user = $this->user->get_api($_SESSION['api']);
  2833. $usp = $user;
  2834. $fgshop = "";
  2835. $sid = "";
  2836. $user = explode('|', trim($user['shop'], '|'));
  2837. foreach ($user as $value) {
  2838. $sid .= " id = " . $value . " or";
  2839. }
  2840. }
  2841. $post = $this->input->post(NULL, TRUE);
  2842. if (isset($post['page'])) {
  2843. $page = $this->input->post('page', true);
  2844. $perpage = $this->input->post('perpage', true);
  2845. $warehouse = $this->input->post('warehouse', true);
  2846. $xztime = $this->input->post('xztime', true);
  2847. $timetk = $this->input->post('timetkk', true);
  2848. $timetj = $this->input->post('timetjj', true);
  2849. $shop = $this->input->post('shop', true);
  2850. $source = $this->input->post('source', true);
  2851. $orderinfo = $this->input->post('orderinfo', true);
  2852. $number = $this->input->post('number', true);
  2853. $express = $this->input->post('express', true);
  2854. $waybill = $this->input->post('waybill', true);
  2855. $library = $this->input->post('library', true);
  2856. $country = $this->input->post('country', true);
  2857. $sfxh = $this->input->post('sfxh', true);
  2858. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2859. $print = $this->input->post('print', true);
  2860. $state = $this->input->post('state', true);
  2861. $so = $this->input->post('so', true);
  2862. $timetk = strtotime($timetk);
  2863. $timetj = strtotime($timetj);
  2864. /**
  2865. $sj = $this->input->post('sj',true);
  2866. if($sj)
  2867. {
  2868. $sj = $this->input->post('sj',true);
  2869. }
  2870. else
  2871. {
  2872. $sj = "fullorder";
  2873. }
  2874. **/
  2875. $sj = "fullordersmt";
  2876. $where = "1=1";
  2877. if ($warehouse) {
  2878. $where .= " and type = '$warehouse'";
  2879. }
  2880. if ($timetk && $timetj) {
  2881. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2882. }
  2883. if ($orderinfo) {
  2884. $where .= " and orderinfo = '$orderinfo'";
  2885. }
  2886. if ($number) {
  2887. $where .= " and number = '$number'";
  2888. }
  2889. if ($express) {
  2890. $where .= " and express = '$express'";
  2891. }
  2892. if ($waybill) {
  2893. $where .= " and waybill = '$waybill'";
  2894. }
  2895. if ($library) {
  2896. $where .= " and library = '$library'";
  2897. }
  2898. if ($print) {
  2899. $where .= " and print = '$print'";
  2900. }
  2901. if ($libraryconfirm) {
  2902. $where .= " and libraryconfirm = '$libraryconfirm'";
  2903. }
  2904. if ($state) {
  2905. $where .= " and state = '$state'";
  2906. }
  2907. if ($shop) {
  2908. $where .= " and shop = '$shop'";
  2909. }
  2910. if ($sfxh != '') {
  2911. $where .= " and sfxh = '$sfxh'";
  2912. }
  2913. if ($so) {
  2914. $where .= " and shipremarks like '%$so%'";
  2915. }
  2916. if ($source) {
  2917. $where .= " and source = '$source'";
  2918. }
  2919. if ($country) {
  2920. $where .= " and country = '$country'";
  2921. } else {
  2922. if (isset($_SESSION['api'])) {
  2923. foreach ($user as $value) {
  2924. $fgshop .= " shop = " . $value . " or";
  2925. }
  2926. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2927. }
  2928. }
  2929. //数据排序
  2930. $order_str = "librarytime desc";
  2931. if (empty($page)) {
  2932. $start = 0;
  2933. $perpage = 1;
  2934. } else {
  2935. $start = ($page - 1) * $perpage;
  2936. }
  2937. //取得信息列表
  2938. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2939. //格式化数据
  2940. foreach ($info_list as $key => $value) {
  2941. $shop = $this->shop->read($value['shop']);
  2942. $info_list[$key]['shop'] = $shop['shopname'];
  2943. $express = $this->express->read($value['express']);
  2944. $info_list[$key]['express'] = $express['servicename'];
  2945. $warehouse = $this->warehouse->read($value['type']);
  2946. $info_list[$key]['type'] = $warehouse['title'];
  2947. if ($value['librarytime'] == '0') {
  2948. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2949. } else {
  2950. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2951. }
  2952. }
  2953. $total = $this->$sj->find_count($where);
  2954. $pagenum = ceil($total / $perpage);
  2955. $over = $total - ($start + $perpage);
  2956. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2957. echo json_encode($rows);
  2958. exit;
  2959. }
  2960. $this->data['express'] = $this->express->find_all();
  2961. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2962. $this->data['wlshop'] = $wlshop;
  2963. $user = $this->user->get_api($_SESSION['api']);
  2964. $powerid = $this->power->read($user['power']);
  2965. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2966. $pid = '';
  2967. foreach ($powertext as $v) {
  2968. $pid .= " id = " . $v . " or";
  2969. }
  2970. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2971. $this->data['fullorderexcel'] = $fullorderexcel;
  2972. $this->_Template('whlabel_soutorder', $this->data);
  2973. }
  2974. //订单退库
  2975. public function _retreat()
  2976. {
  2977. $post = $this->input->post(NULL, TRUE);
  2978. if (isset($post['page'])) {
  2979. $page = $this->input->post('page', true);
  2980. $perpage = $this->input->post('perpage', true);
  2981. $warehouse = $this->input->post('warehouse', true);
  2982. $timetk = $this->input->post('timetk', true);
  2983. $timetj = $this->input->post('timetj', true);
  2984. $shop = $this->input->post('shop', true);
  2985. $source = $this->input->post('source', true);
  2986. $state = $this->input->post('state', true);
  2987. $review = $this->input->post('review', true);
  2988. $state = $this->input->post('state', true);
  2989. $express = $this->input->post('express', true);
  2990. $orderinfo = $this->input->post('orderinfo', true);
  2991. $user = $this->input->post('user', true);
  2992. $name = $this->input->post('name', true);
  2993. $waybill = $this->input->post('waybill', true);
  2994. $timetk = strtotime($timetk);
  2995. $timetj = strtotime($timetj);
  2996. $where = "(state=206 or state=210) and mergeid = 0";
  2997. if ($warehouse) {
  2998. $where .= " and state = '$warehouse'";
  2999. }
  3000. if ($timetk && $timetj) {
  3001. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3002. }
  3003. if ($shop) {
  3004. $where .= " and shop = '$shop'";
  3005. }
  3006. if ($source) {
  3007. $where .= " and source = '$source'";
  3008. }
  3009. if ($state) {
  3010. $where .= " and state = '$state'";
  3011. }
  3012. if ($review) {
  3013. $where .= " and review = '$review'";
  3014. }
  3015. if ($state) {
  3016. $where .= " and state = '$state'";
  3017. }
  3018. if ($express) {
  3019. $where .= " and express = '$express'";
  3020. }
  3021. if ($orderinfo) {
  3022. $where .= " and orderinfo = '$orderinfo'";
  3023. }
  3024. if ($user) {
  3025. $where .= " and user = '$user'";
  3026. }
  3027. if ($name) {
  3028. $where .= " and name = '$name'";
  3029. }
  3030. if ($waybill) {
  3031. $where .= " and waybill = '$waybill'";
  3032. }
  3033. //数据排序
  3034. $order_str = "id desc";
  3035. if (empty($page)) {
  3036. $start = 0;
  3037. $perpage = 1;
  3038. } else {
  3039. $start = ($page - 1) * $perpage;
  3040. }
  3041. //取得信息列表
  3042. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3043. //格式化数据
  3044. foreach ($info_list as $key => $value) {
  3045. $shop = $this->shop->read($value['shop']);
  3046. $info_list[$key]['shop'] = $shop['shopname'];
  3047. $warehouse = $this->warehouse->read($value['warehouse']);
  3048. $info_list[$key]['warehouse'] = $warehouse['title'];
  3049. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3050. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3051. if ($value['waybill'] == 0) {
  3052. $info_list[$key]['waybill'] = "";
  3053. }
  3054. $express = $this->express->read($value['express']);
  3055. $info_list[$key]['express'] = $express['title'];
  3056. $typeclass = $this->typeclass->read($value['state']);
  3057. $info_list[$key]['state'] = $typeclass['title'];
  3058. }
  3059. $total = $this->fullorder->find_count($where);
  3060. $pagenum = ceil($total / $perpage);
  3061. $over = $total - ($start + $perpage);
  3062. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3063. echo json_encode($rows);
  3064. exit;
  3065. }
  3066. $this->data['express'] = $this->express->find_all();
  3067. $this->_Template('whlabel_retreat', $this->data);
  3068. }
  3069. //退库标签浏览
  3070. public function _retreatlk()
  3071. {
  3072. $post = $this->input->post(NULL, TRUE);
  3073. if (isset($post['page'])) {
  3074. $page = $this->input->post('page', true);
  3075. $perpage = $this->input->post('perpage', true);
  3076. $timetk = $this->input->post('timetk', true);
  3077. $timetj = $this->input->post('timetj', true);
  3078. $sku = $this->input->post('sku', true);
  3079. $warehouse = $this->input->post('warehouse', true);
  3080. $purchase = $this->input->post('purchase', true);
  3081. $orderinfo = $this->input->post('orderinfo', true);
  3082. $waybill = $this->input->post('waybill', true);
  3083. $category = $this->input->post('category', true);
  3084. $size = $this->input->post('size', true);
  3085. $grade = $this->input->post('grade', true);
  3086. $color = $this->input->post('color', true);
  3087. $lowe = $this->input->post('lowe', true);
  3088. $state = $this->input->post('state', true);
  3089. $timetk = strtotime($timetk);
  3090. $timetj = strtotime($timetj);
  3091. $where = "state=2";
  3092. if ($timetk && $timetj) {
  3093. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3094. }
  3095. if ($sku) {
  3096. $where .= " and sku = '$sku'";
  3097. }
  3098. if ($warehouse) {
  3099. $where .= " and warehouse = '$warehouse'";
  3100. }
  3101. if ($purchase) {
  3102. $where .= " and purchase = '$purchase'";
  3103. }
  3104. if ($orderinfo) {
  3105. $where .= " and orderinfo = '$orderinfo'";
  3106. }
  3107. if ($waybill) {
  3108. $where .= " and waybill = '$waybill'";
  3109. }
  3110. if ($category) {
  3111. $where .= " and features like '%-$category-%'";
  3112. }
  3113. if ($size) {
  3114. $where .= " and features like '%-$size-%'";
  3115. }
  3116. if ($grade) {
  3117. $where .= " and features like '%-$grade-%'";
  3118. }
  3119. if ($color) {
  3120. $where .= " and features like '%-$color-%'";
  3121. }
  3122. if ($lowe) {
  3123. $where .= " and features like '%-$lowe-%'";
  3124. }
  3125. //数据排序
  3126. $order_str = "time desc";
  3127. if (empty($page)) {
  3128. $start = 0;
  3129. $perpage = 1;
  3130. } else {
  3131. $start = ($page - 1) * $perpage;
  3132. }
  3133. //取得信息列表
  3134. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3135. foreach ($info_list as $key => $value) {
  3136. $warehouse = $this->warehouse->read($value['warehouse']);
  3137. $info_list[$key]['warehouse'] = $warehouse['title'];
  3138. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3139. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3140. $purchase = $this->purchase->read($value['purchase']);
  3141. $info_list[$key]['purchase'] = $purchase['title'];
  3142. if ($value['outk'] != 0) {
  3143. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3144. } else {
  3145. $info_list[$key]['outk'] = "";
  3146. }
  3147. if ($value['retreat'] != 0) {
  3148. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3149. } else {
  3150. $info_list[$key]['retreat'] = "";
  3151. }
  3152. if ($value['orderinfo'] == 0) {
  3153. $info_list[$key]['orderinfo'] = "";
  3154. }
  3155. if ($value['waybill'] == 0) {
  3156. $info_list[$key]['waybill'] = "";
  3157. }
  3158. }
  3159. $total = $this->whlabel->find_count($where);
  3160. $pagenum = ceil($total / $perpage);
  3161. $over = $total - ($start + $perpage);
  3162. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3163. echo json_encode($rows);
  3164. exit;
  3165. }
  3166. $this->_Template('whlabel_retreatlk', $this->data);
  3167. }
  3168. //更换标签及浏览
  3169. public function _change()
  3170. {
  3171. $post = $this->input->post(NULL, TRUE);
  3172. if (isset($post['page'])) {
  3173. $page = $this->input->post('page', true);
  3174. $perpage = $this->input->post('perpage', true);
  3175. $timetk = $this->input->post('timetk', true);
  3176. $timetj = $this->input->post('timetj', true);
  3177. $label = $this->input->post('label', true);
  3178. $oldlabel = $this->input->post('oldlabel', true);
  3179. $timetk = strtotime($timetk);
  3180. $timetj = strtotime($timetj);
  3181. $where = "state=10 ";
  3182. if ($timetk && $timetj) {
  3183. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3184. }
  3185. if ($label) {
  3186. $where .= " and label = '$label'";
  3187. }
  3188. if ($oldlabel) {
  3189. $where .= " and oldlabel = '$oldlabel'";
  3190. }
  3191. //数据排序
  3192. $order_str = "time asc";
  3193. if (empty($page)) {
  3194. $start = 0;
  3195. $perpage = 1;
  3196. } else {
  3197. $start = ($page - 1) * $perpage;
  3198. }
  3199. //取得信息列表
  3200. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3201. foreach ($info_list as $key => $value) {
  3202. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3203. }
  3204. $total = $this->whlabel->find_count($where);
  3205. $pagenum = ceil($total / $perpage);
  3206. $over = $total - ($start + $perpage);
  3207. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3208. echo json_encode($rows);
  3209. exit;
  3210. }
  3211. $this->_Template('whlabel_change', $this->data);
  3212. }
  3213. //产品标签
  3214. public function _cpbqdc()
  3215. {
  3216. if (isset($_GET['excel'])) {
  3217. $where = "1=1";
  3218. //数据排序
  3219. $order_str = "id desc";
  3220. if (empty($page)) {
  3221. $start = 0;
  3222. $perpage = 1;
  3223. } else {
  3224. $start = ($page - 1) * $perpage;
  3225. }
  3226. $warehouse = $this->input->get('warehouse', true);
  3227. $state = $this->input->get('state', true);
  3228. $timetk = $this->input->get('timetkk', true);
  3229. $timetj = $this->input->get('timetjj', true);
  3230. $timetk = strtotime($timetk);
  3231. $timetj = strtotime($timetj);
  3232. if ($warehouse) {
  3233. $where .= " and warehouse = '$warehouse'";
  3234. }
  3235. if ($state || $state == 0) {
  3236. $where .= " and state = '$state'";
  3237. }
  3238. if ($timetk && $timetj) {
  3239. $where .= " and time > '$timetk' and time < '$timetj'";
  3240. }
  3241. //取得信息列表
  3242. $info_list = $this->whlabel->find_all($where, '*');
  3243. $rows = array();
  3244. $list = array();
  3245. foreach ($info_list as $key => $value) {
  3246. $rows[$value['time']] = $value; //所有数据sku
  3247. }
  3248. foreach ($rows as $value) {
  3249. $warehouse = $this->warehouse->read($value['warehouse']);
  3250. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3251. $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);
  3252. }
  3253. $title = "产品标签统计表";
  3254. $titlename = "<table border=1>
  3255. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3256. <tr align='center'>
  3257. <td>仓库</td>
  3258. <td>SKU</td>
  3259. <td>产品</td>
  3260. <td>入库时间</td>
  3261. <td>操作时间</td>
  3262. <td>备注</td>
  3263. <td>数量</td>
  3264. </tr>
  3265. </table>";
  3266. $filename = $title . ".xls";
  3267. $tail = "";
  3268. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3269. }
  3270. }
  3271. //进销存导出
  3272. public function _exceljxc()
  3273. {
  3274. $classid = $this->classid->sku();
  3275. $pm = $classid;
  3276. $typeclass = array();
  3277. $tc = $this->typeclass->find_all();
  3278. foreach ($tc as $v) {
  3279. $typeclass[$v['id']] = $v;
  3280. }
  3281. $prc = array();
  3282. $purchase = $this->purchase->find_all();
  3283. foreach ($purchase as $k => $v) {
  3284. $prc[$v['id']] = $v['title'];
  3285. }
  3286. if (isset($_GET['excel'])) {
  3287. $where = "sku != 'Preset'";
  3288. //数据排序
  3289. $order_str = "id desc";
  3290. if (empty($page)) {
  3291. $start = 0;
  3292. $perpage = 1;
  3293. } else {
  3294. $start = ($page - 1) * $perpage;
  3295. }
  3296. $category = $this->input->get('category', true);
  3297. $warehouse = $this->input->get('warehouse', true);
  3298. $excelid = $this->input->get('sid', true);
  3299. if ($category) {
  3300. $where .= " and features like '%-$category-%'";
  3301. }
  3302. if ($warehouse) {
  3303. $where .= " and warehouse = '$warehouse'";
  3304. }
  3305. $xzid = '';
  3306. if ($excelid) {
  3307. $excelid = explode(',', trim($excelid, ','));
  3308. foreach ($excelid as $key => $value) {
  3309. $xzid .= " id = " . $value . " or";
  3310. }
  3311. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3312. }
  3313. //取得信息列表
  3314. /**
  3315. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3316. $rows = array();$list = array();
  3317. foreach ($info_list as $key=>$value)
  3318. {
  3319. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3320. }
  3321. **/
  3322. $wt = array();
  3323. $whlabel_type = $this->whlabel_type->find_all();
  3324. foreach ($whlabel_type as $v) {
  3325. $wt[$v['id']] = $v['title'];
  3326. }
  3327. $wh = array();
  3328. $w = $this->warehouse->find_all('1=1', 'id,title');
  3329. foreach ($w as $v) {
  3330. $wh[$v['id']] = $v['title'];
  3331. }
  3332. $list = array();
  3333. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3334. foreach ($rows as $key => $value) {
  3335. if (isset($wt[$value['type']])) {
  3336. $rows[$key]['type'] = $wt[$value['type']];
  3337. } else {
  3338. $rows[$key]['type'] = '未设置';
  3339. }
  3340. $bm = '03';
  3341. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3342. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3343. $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');
  3344. $details = array();
  3345. $cpid = array();
  3346. $cpbz = array();
  3347. $c = 0;
  3348. $g = 0;
  3349. $x = 0;
  3350. $t = 0;
  3351. $s = 0;
  3352. $q = 0;
  3353. foreach ($sd as $k => $v) {
  3354. if ($v['state'] == 0) {
  3355. $c++;
  3356. if ($v['cpid'] != 0) {
  3357. $cpid[$v['cpid']] = $v['cpid'];
  3358. }
  3359. if ($v['cpbz'] != '') {
  3360. $cpbz[$v['cpbz']] = $v['cpbz'];
  3361. }
  3362. }
  3363. if ($v['state'] != 9) {
  3364. $g++;
  3365. }
  3366. if ($v['state'] == 1) {
  3367. $x++;
  3368. }
  3369. if ($v['state'] == 2) {
  3370. $t++;
  3371. }
  3372. if ($v['state'] == 8) {
  3373. $s++;
  3374. }
  3375. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3376. $q++;
  3377. }
  3378. $details[$v['details']] = $v['details'];
  3379. }
  3380. $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'] . '"');
  3381. $rows[$key]['details'] = implode("、", $details);
  3382. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3383. $number = $value['number'];
  3384. $ftime = time() - 15 * 24 * 3600;
  3385. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3386. $rows[$key]['number'] = $g;
  3387. $rows[$key]['c'] = $c;
  3388. $rows[$key]['x'] = $x;
  3389. $rows[$key]['t'] = $t;
  3390. $rows[$key]['s'] = $s;
  3391. $rows[$key]['q'] = $q;
  3392. $rows[$key]['z'] = $z;
  3393. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3394. $features = explode('-', trim($features, '-'));
  3395. $rows[$key]['dbcontent'] = $typeclass[$features[0]]['title'];
  3396. // $pm = $classid;
  3397. // $jm = $classid;
  3398. // foreach($features as $k=>$v)
  3399. // {
  3400. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3401. // {
  3402. // if($typeclass[$v]['bm'] != '')
  3403. // {
  3404. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3405. // }
  3406. // }
  3407. // if($v != 0)
  3408. // {
  3409. // if(!isset($typeclass[$v]))
  3410. // {
  3411. // continue;
  3412. // }
  3413. // if(isset($pm[$typeclass[$v]['classid']]))
  3414. // {
  3415. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3416. // {
  3417. // $tz = explode('|',$typeclass[$v]['zh']);
  3418. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3419. // }
  3420. // else
  3421. // {
  3422. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3423. // }
  3424. // }
  3425. // if(isset($jm[$typeclass[$v]['classid']]))
  3426. // {
  3427. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3428. // }
  3429. // }
  3430. // }
  3431. // $jm = array_filter($jm);
  3432. // $rows[$key]['bs'] = implode("-",$jm);
  3433. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3434. // $zh = implode(" ",$pm);
  3435. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3436. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3437. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3438. // $rows[$key]['features'] = $zh;
  3439. }
  3440. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3441. $final_list = [];
  3442. foreach ($list as $k => $v) {
  3443. if (empty($v['sku'])) {
  3444. continue;
  3445. }
  3446. $final_list[] = [
  3447. "warehouse" => $v["warehouse"],
  3448. "purchase" => $v["purchase"],
  3449. "details" => $v["details"],
  3450. "cpid" => $v["cpid"],
  3451. "dbcontent" => $v["dbcontent"],
  3452. "sku" => $v["sku"],
  3453. "cs" => $v["bm"],
  3454. "bs" => $v["jm"],
  3455. "title" => $v["title"],
  3456. "features" => $v["pm"],
  3457. "cpbz" => $v["cpbz"],
  3458. "sm" => $v["sm"],
  3459. "type" => $v["type"],
  3460. "number" => $v["number"],
  3461. "c" => $v["c"],
  3462. "x" => $v["x"],
  3463. "t" => $v["t"],
  3464. "s" => $v["s"],
  3465. "q" => $v["q"],
  3466. "z" => $v["z"],
  3467. "weight" => $v['weight'],
  3468. ];
  3469. }
  3470. $title = "总进销存统计表";
  3471. $titlename = "<table border=1>
  3472. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3473. <tr align='center'>
  3474. <td>仓库</td>
  3475. <td>供应商</td>
  3476. <td>位置</td>
  3477. <td>库存编码</td>
  3478. <td>类目</td>
  3479. <td>SKU</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>其它操作</td>
  3493. <td>占单数量</td>
  3494. <td>重量(g)</td>
  3495. </tr>
  3496. </table>";
  3497. $filename = $title . ".xls";
  3498. $tail = "";
  3499. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3500. }
  3501. }
  3502. //入库导出
  3503. public function _excelr()
  3504. {
  3505. if (isset($_GET['excel'])) {
  3506. $category = $this->input->get('category', true);
  3507. $size = $this->input->get('size', true);
  3508. $grade = $this->input->get('grade', true);
  3509. $color = $this->input->get('color', true);
  3510. $lowe = $this->input->get('lowe', true);
  3511. $sku = $this->input->get('sku', true);
  3512. $warehouse = $this->input->get('warehouse', true);
  3513. $purchase = $this->input->get('purchase', true);
  3514. $ktime = $this->input->get('ktime', true);
  3515. $jtime = $this->input->get('jtime', true);
  3516. $ktime = strtotime($ktime);
  3517. $jtime = strtotime($jtime);
  3518. $where = "1=1";
  3519. $gj = "";
  3520. $ck = "";
  3521. if ($category) {
  3522. $where .= " and features like '%-$category-%'";
  3523. }
  3524. if ($size) {
  3525. $where .= " and features like '%-$size-%'";
  3526. }
  3527. if ($grade) {
  3528. $where .= " and features like '%-$grade-%'";
  3529. }
  3530. if ($color) {
  3531. $where .= " and features like '%-$color-%'";
  3532. }
  3533. if ($lowe) {
  3534. $where .= " and features like '%-$lowe-%'";
  3535. }
  3536. if ($warehouse) {
  3537. $where .= " and warehouse = '$warehouse'";
  3538. }
  3539. if ($purchase) {
  3540. $where .= " and purchase = '$purchase'";
  3541. }
  3542. if ($sku) {
  3543. $where .= " and sku = '$sku'";
  3544. }
  3545. if ($ktime && $jtime) {
  3546. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3547. }
  3548. //数据排序
  3549. $order_str = "id desc";
  3550. if (empty($page)) {
  3551. $start = 0;
  3552. $perpage = 1;
  3553. } else {
  3554. $start = ($page - 1) * $perpage;
  3555. }
  3556. $list = array();
  3557. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3558. foreach ($rows as $value) {
  3559. $ck = $this->warehouse->read($value['warehouse']);
  3560. $warehouse = $ck['title'];
  3561. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3562. $retreatwarehouse = $tkck['title'];
  3563. $gy = $this->purchase->read($value['purchase']);
  3564. $purchase = $gy['title'];
  3565. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3566. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3567. }
  3568. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3569. $titlename = "<table border=1>
  3570. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3571. <tr align='center'>
  3572. <td>仓库</td>
  3573. <td>SKU</td>
  3574. <td>产品</td>
  3575. <td>时间</td>
  3576. <td>数量</td>
  3577. </tr>
  3578. </table>";
  3579. $filename = $title . ".xls";
  3580. $tail = "";
  3581. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3582. }
  3583. }
  3584. //出库、退库导出
  3585. public function _excelct()
  3586. {
  3587. $classid = $this->classid->sku();
  3588. $pm = $classid;
  3589. $typeclass = array();
  3590. $tc = $this->typeclass->find_all();
  3591. foreach ($tc as $v) {
  3592. $typeclass[$v['id']] = $v;
  3593. }
  3594. $prc = array();
  3595. $purchase = $this->purchase->find_all();
  3596. foreach ($purchase as $k => $v) {
  3597. $prc[$v['id']] = $v['title'];
  3598. }
  3599. if (isset($_GET['excel'])) {
  3600. $wh = array();
  3601. $w = $this->warehouse->find_all('1=1', 'id,title');
  3602. foreach ($w as $v) {
  3603. $wh[$v['id']] = $v['title'];
  3604. }
  3605. $type = $this->input->get('excel', true);
  3606. $category = $this->input->get('category', true);
  3607. $size = $this->input->get('size', true);
  3608. $grade = $this->input->get('grade', true);
  3609. $color = $this->input->get('color', true);
  3610. $lowe = $this->input->get('lowe', true);
  3611. $sku = $this->input->get('sku', true);
  3612. $warehouse = $this->input->get('warehouse', true);
  3613. $lacetype = $this->input->get('lacetype', true);
  3614. $lacecolor = $this->input->get('lacecolor', true);
  3615. $density = $this->input->get('density', true);
  3616. $haircap = $this->input->get('haircap', true);
  3617. $purchase = $this->input->get('purchase', true);
  3618. $title = $this->input->get('title', true);
  3619. $state = $this->input->get('state', true);
  3620. $sid = $this->input->get('sid', true);
  3621. $ktime = $this->input->get('ktime', true);
  3622. $jtime = $this->input->get('jtime', true);
  3623. $ktime = strtotime($ktime);
  3624. $jtime = strtotime($jtime);
  3625. $where = "1=1";
  3626. $gj = "";
  3627. $ck = "";
  3628. if ($category) {
  3629. $where .= " and features like '%-$category-%'";
  3630. }
  3631. if ($size) {
  3632. $where .= " and features like '%-$size-%'";
  3633. }
  3634. if ($grade) {
  3635. $where .= " and features like '%-$grade-%'";
  3636. }
  3637. if ($color) {
  3638. $where .= " and features like '%-$color-%'";
  3639. }
  3640. if ($lowe) {
  3641. $where .= " and features like '%-$lowe-%'";
  3642. }
  3643. if ($warehouse) {
  3644. $where .= " and warehouse = '$warehouse'";
  3645. }
  3646. if ($purchase) {
  3647. $where .= " and purchase = '$purchase'";
  3648. }
  3649. if ($state) {
  3650. $where .= " and state = '$state'";
  3651. }
  3652. if ($lacetype) {
  3653. $where .= " and features like '%-$lacetype-%'";
  3654. }
  3655. if ($lacecolor) {
  3656. $where .= " and features like '%-$lacecolor-%'";
  3657. }
  3658. if ($density) {
  3659. $where .= " and features like '%-$density-%'";
  3660. }
  3661. if ($haircap) {
  3662. $where .= " and features like '%-$haircap-%'";
  3663. }
  3664. if ($title) {
  3665. $title = trim($title, ' ');
  3666. $title = trim($title, ' ');
  3667. $where .= " and title like '%$title%'";
  3668. }
  3669. if ($sku) {
  3670. $sku = trim($sku, ' ');
  3671. $sku = trim($sku, ' ');
  3672. $where .= " and sku like '%$sku%'";
  3673. }
  3674. if ($ktime && $jtime) {
  3675. if ($type == 1) {
  3676. $tl = '出库';
  3677. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3678. } else if ($type == 2) {
  3679. $tl = '退库';
  3680. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3681. } else if ($type == 3) {
  3682. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3683. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3684. } else if ($type == 4) {
  3685. $tl = '出库+零售';
  3686. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3687. } else if ($type == 5) {
  3688. $tl = '零售';
  3689. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3690. }
  3691. }
  3692. $sidwhere = '';
  3693. if ($sid) {
  3694. $sd = "";
  3695. $s = explode(',', trim($sid, ','));
  3696. foreach ($s as $value) {
  3697. $sd .= " id = " . $value . " or";
  3698. }
  3699. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3700. }
  3701. //数据排序
  3702. $order_str = "time desc";
  3703. if (empty($page)) {
  3704. $start = 0;
  3705. $perpage = 1;
  3706. } else {
  3707. $start = ($page - 1) * $perpage;
  3708. }
  3709. //取得信息列表
  3710. if ($type != 3 && $type != 5) {
  3711. if ($type == 1 || $type == 4) {
  3712. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3713. foreach ($info_list as $key => $value) {
  3714. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3715. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3716. $warehouse = $this->warehouse->read($value['warehouse']);
  3717. $info_list[$key]['warehouse'] = $warehouse['title'];
  3718. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3719. $features = explode('-', trim($features, '-'));
  3720. $pm = $classid;
  3721. foreach ($features as $k => $v) {
  3722. if ($v != 0) {
  3723. if (!isset($typeclass[$v])) {
  3724. continue;
  3725. }
  3726. if (isset($pm[$typeclass[$v]['classid']])) {
  3727. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3728. $tz = explode('|', $typeclass[$v]['zh']);
  3729. $pm[$typeclass[$v]['classid']] = $tz[0];
  3730. } else {
  3731. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3732. }
  3733. }
  3734. }
  3735. }
  3736. $zh = implode(" ", $pm);
  3737. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3738. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3739. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3740. $info_list[$key]['features'] = $zh;
  3741. }
  3742. $final_list = [];
  3743. foreach($info_list as $k=>$v){
  3744. $number = "";
  3745. if(!empty($v['orderinfo'])){
  3746. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3747. if(!empty($tmp_info['number'])){
  3748. $number = $tmp_info['number'];
  3749. }
  3750. }
  3751. $final_list[] = [
  3752. 'warehouse'=>$v['warehouse'],
  3753. 'purchase'=>$v['purchase'],
  3754. 'sku'=>$v['sku'],
  3755. 'title'=>$v['title'],
  3756. 'features'=>$v['features'],
  3757. 'label'=>$v['label'],
  3758. 'orderinfo'=>$v['orderinfo'],
  3759. 'number'=>$number,
  3760. 'waybill'=>$v['waybill'],
  3761. 'outk'=>$v['outk'],
  3762. ];
  3763. }
  3764. } else {
  3765. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3766. foreach ($info_list as $key => $value) {
  3767. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3768. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3769. $warehouse = $this->warehouse->read($value['warehouse']);
  3770. $info_list[$key]['warehouse'] = $warehouse['title'];
  3771. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3772. $features = explode('-', trim($features, '-'));
  3773. $pm = $classid;
  3774. foreach ($features as $k => $v) {
  3775. if ($v != 0) {
  3776. if (!isset($typeclass[$v])) {
  3777. continue;
  3778. }
  3779. if (isset($pm[$typeclass[$v]['classid']])) {
  3780. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3781. $tz = explode('|', $typeclass[$v]['zh']);
  3782. $pm[$typeclass[$v]['classid']] = $tz[0];
  3783. } else {
  3784. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3785. }
  3786. }
  3787. }
  3788. }
  3789. $zh = implode(" ", $pm);
  3790. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3791. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3792. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3793. $info_list[$key]['features'] = $zh;
  3794. }
  3795. $final_list = [];
  3796. foreach($info_list as $k=>$v){
  3797. $number = "";
  3798. if(!empty($v['orderinfo'])){
  3799. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3800. if(!empty($tmp_info['number'])){
  3801. $number = $tmp_info['number'];
  3802. }
  3803. }
  3804. $final_list[] = [
  3805. 'warehouse'=>$v['warehouse'],
  3806. 'purchase'=>$v['purchase'],
  3807. 'sku'=>$v['sku'],
  3808. 'title'=>$v['title'],
  3809. 'features'=>$v['features'],
  3810. 'label'=>$v['label'],
  3811. 'orderinfo'=>$v['orderinfo'],
  3812. 'number'=>$number,
  3813. 'waybill'=>$v['waybill'],
  3814. 'retreat'=>$v['retreat'],
  3815. ];
  3816. }
  3817. }
  3818. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3819. $titlename = "<table border=1>
  3820. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3821. <tr align='center'>
  3822. <td>仓库</td>
  3823. <td>供应商</td>
  3824. <td>SKU</td>
  3825. <td>商品名称</td>
  3826. <td>商品中文</td>
  3827. <td>标签</td>
  3828. <td>订单号</td>
  3829. <td>订单编码</td>
  3830. <td>运单号</td>
  3831. <td>" . $tl . "时间(中国时间)</td>
  3832. </tr>
  3833. </table>";
  3834. $filename = $title . ".xls";
  3835. $tail = "";
  3836. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3837. } else if ($type == 5) {
  3838. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3839. foreach ($info_list as $key => $value) {
  3840. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3841. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3842. $warehouse = $this->warehouse->read($value['warehouse']);
  3843. $info_list[$key]['warehouse'] = $warehouse['title'];
  3844. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3845. $features = explode('-', trim($features, '-'));
  3846. $pm = $classid;
  3847. foreach ($features as $k => $v) {
  3848. if ($v != 0) {
  3849. if (!isset($typeclass[$v])) {
  3850. continue;
  3851. }
  3852. if (isset($pm[$typeclass[$v]['classid']])) {
  3853. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3854. $tz = explode('|', $typeclass[$v]['zh']);
  3855. $pm[$typeclass[$v]['classid']] = $tz[0];
  3856. } else {
  3857. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3858. }
  3859. }
  3860. }
  3861. }
  3862. $zh = implode(" ", $pm);
  3863. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3864. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3865. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3866. $info_list[$key]['features'] = $zh;
  3867. }
  3868. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3869. $titlename = "<table border=1>
  3870. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3871. <tr align='center'>
  3872. <td>仓库</td>
  3873. <td>供应商</td>
  3874. <td>SKU</td>
  3875. <td>商品名称</td>
  3876. <td>商品中文</td>
  3877. <td>标签</td>
  3878. <td>" . $tl . "时间(中国时间)</td>
  3879. </tr>
  3880. </table>";
  3881. $filename = $title . ".xls";
  3882. $tail = "";
  3883. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3884. } else {
  3885. /**
  3886. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  3887. $rows = array();$list = array();
  3888. foreach ($info_list as $key=>$value)
  3889. {
  3890. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  3891. }
  3892. **/
  3893. $wh = array();
  3894. $w = $this->warehouse->find_all('1=1', 'id,title');
  3895. foreach ($w as $v) {
  3896. $wh[$v['id']] = $v['title'];
  3897. }
  3898. $wt = array();
  3899. $whlabel_type = $this->whlabel_type->find_all();
  3900. foreach ($whlabel_type as $v) {
  3901. $wt[$v['id']] = $v['title'];
  3902. }
  3903. $classid = $this->classid->sku();
  3904. $list = array();
  3905. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  3906. foreach ($rows as $key => $value) {
  3907. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3908. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3909. $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');
  3910. $details = array();
  3911. $cpid = array();
  3912. $cpbz = array();
  3913. $c = 0;
  3914. $g = 0;
  3915. $x = 0;
  3916. $t = 0;
  3917. $s = 0;
  3918. $q = 0;
  3919. foreach ($sd as $k => $v) {
  3920. if ($v['state'] == 0) {
  3921. $c++;
  3922. }
  3923. if ($v['state'] != 9) {
  3924. $g++;
  3925. }
  3926. if ($v['outk'] > 1) {
  3927. $x++;
  3928. }
  3929. if ($v['retreat'] > 0) {
  3930. $t++;
  3931. }
  3932. if ($v['state'] == 8) {
  3933. $s++;
  3934. }
  3935. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3936. $q++;
  3937. }
  3938. $details[$v['details']] = $v['details'];
  3939. if ($v['cpid'] != 0) {
  3940. $cpid[$v['cpid']] = $v['cpid'];
  3941. }
  3942. if ($v['cpbz'] != '') {
  3943. $cpbz[$v['cpbz']] = $v['cpbz'];
  3944. }
  3945. }
  3946. if (isset($wt[$value['type']])) {
  3947. $rows[$key]['type'] = $wt[$value['type']];
  3948. } else {
  3949. $rows[$key]['type'] = '未设置';
  3950. }
  3951. $rows[$key]['details'] = implode("、", $details);
  3952. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3953. $ftime = time() - 15 * 24 * 3600;
  3954. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3955. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  3956. $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);
  3957. $rows[$key]['c'] = $c;
  3958. $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);
  3959. $rows[$key]['t'] = $t;
  3960. $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'] . '"');
  3961. $rows[$key]['z'] = $z;
  3962. // $jm = $classid;
  3963. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3964. $features = explode('-', trim($features, '-'));
  3965. // $pm = $classid;
  3966. // foreach ($features as $k => $v) {
  3967. // if ($v != 0) {
  3968. // if (!isset($typeclass[$v])) {
  3969. // continue;
  3970. // }
  3971. // if (isset($pm[$typeclass[$v]['classid']])) {
  3972. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3973. // $tz = explode('|', $typeclass[$v]['zh']);
  3974. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3975. // } else {
  3976. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3977. // }
  3978. // if (isset($jm[$typeclass[$v]['classid']])) {
  3979. // if ($typeclass[$v]['jm']) {
  3980. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3981. // }
  3982. // }
  3983. // }
  3984. // }
  3985. // }
  3986. // $zh = implode(" ", $pm);
  3987. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3988. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3989. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3990. // $rows[$key]['features'] = $zh;
  3991. // $jm = array_filter($jm); //去除空值
  3992. // $jm = implode("-", $jm);
  3993. // $rows[$key]['jm'] = $jm;
  3994. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  3995. }
  3996. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  3997. // echo "<pre>";
  3998. // print_r($tmp_list);
  3999. // die;
  4000. $final_list =[];
  4001. foreach($tmp_list as $k=>$v){
  4002. $final_list[] = [
  4003. "warehouse"=>$v['warehouse'],
  4004. "purchase"=>$v['purchase'],
  4005. "details"=>$v['details'],
  4006. "cpid"=>$v['cpid'],
  4007. "sku"=>$v['sku'],
  4008. "title"=>$v['title'],
  4009. "features"=>$v['pm'],
  4010. "cpbz"=>$v['cpbz'],
  4011. "sm"=>$v['sm'],
  4012. "type"=>$v['type'],
  4013. "g"=>$v["g"],
  4014. "c"=>$v["c"],
  4015. "x"=>$v["x"],
  4016. "t"=>$v["t"],
  4017. "z"=>$v["z"],
  4018. "jm"=>$v["jm"],
  4019. "weight"=>$v["weight"],
  4020. "asd"=>$v["asd"],
  4021. ];
  4022. }
  4023. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4024. $titlename = "<table border=1>
  4025. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4026. <tr align='center'>
  4027. <td>仓库</td>
  4028. <td>供应商</td>
  4029. <td>位置</td>
  4030. <td>库存编码</td>
  4031. <td>SKU</td>
  4032. <td>商品名称</td>
  4033. <td>商品中文</td>
  4034. <td>产品备注</td>
  4035. <td>说明</td>
  4036. <td>类型</td>
  4037. <td>入库总量</td>
  4038. <td>库存数量</td>
  4039. <td>销售数量</td>
  4040. <td>退货数量</td>
  4041. <td>占单数量</td>
  4042. <td>料号</td>
  4043. <td>重量</td>
  4044. <td>类目</td>
  4045. </tr>
  4046. </table>";
  4047. $filename = $title . ".xls";
  4048. $tail = "";
  4049. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4050. }
  4051. }
  4052. }
  4053. //出库+入库数据整合
  4054. public function _excelcr()
  4055. {
  4056. if (isset($_GET['excel'])) {
  4057. $type = $this->input->get('excel', true);
  4058. $category = $this->input->get('category', true);
  4059. $size = $this->input->get('size', true);
  4060. $grade = $this->input->get('grade', true);
  4061. $color = $this->input->get('color', true);
  4062. $lowe = $this->input->get('lowe', true);
  4063. $sku = $this->input->get('sku', true);
  4064. $warehouse = $this->input->get('warehouse', true);
  4065. $purchase = $this->input->get('purchase', true);
  4066. $state = $this->input->get('state', true);
  4067. $sid = $this->input->get('sid', true);
  4068. $ktime = $this->input->get('ktime', true);
  4069. $jtime = $this->input->get('jtime', true);
  4070. $ktime = strtotime($ktime);
  4071. $jtime = strtotime($jtime);
  4072. $where = "1=1";
  4073. $gj = "";
  4074. $ck = "";
  4075. if ($category) {
  4076. $where .= " and features like '%-$category-%'";
  4077. }
  4078. if ($size) {
  4079. $where .= " and features like '%-$size-%'";
  4080. }
  4081. if ($grade) {
  4082. $where .= " and features like '%-$grade-%'";
  4083. }
  4084. if ($color) {
  4085. $where .= " and features like '%-$color-%'";
  4086. }
  4087. if ($lowe) {
  4088. $where .= " and features like '%-$lowe-%'";
  4089. }
  4090. if ($warehouse) {
  4091. $where .= " and warehouse = '$warehouse'";
  4092. }
  4093. if ($purchase) {
  4094. $where .= " and purchase = '$purchase'";
  4095. }
  4096. if ($state) {
  4097. $where .= " and state = '$state'";
  4098. }
  4099. if ($sku) {
  4100. $where .= " and sku like '%$sku%'";
  4101. }
  4102. if ($ktime && $jtime) {
  4103. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4104. }
  4105. $sidwhere = '';
  4106. if ($sid) {
  4107. $sd = "";
  4108. $s = explode(',', trim($sid, ','));
  4109. foreach ($s as $value) {
  4110. $sd .= " id = " . $value . " or";
  4111. }
  4112. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4113. }
  4114. //取得信息列表
  4115. $timeread = $ktime;
  4116. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4117. $timelist = array();
  4118. for ($i = 0; $i < $timenum; $i++) {
  4119. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4120. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4121. }
  4122. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4123. //echo "<pre>";
  4124. //print_r($info_list);
  4125. //exit();
  4126. $rows = array();
  4127. $list = array();
  4128. foreach ($info_list as $key => $value) {
  4129. $thistime = $timelist;
  4130. if (isset($rows[strtolower($value['sku'])])) {
  4131. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4132. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4133. }
  4134. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4135. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4136. }
  4137. } else {
  4138. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4139. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4140. }
  4141. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4142. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4143. }
  4144. $rows[strtolower($value['sku'])] = $thistime;
  4145. }
  4146. }
  4147. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4148. <head>
  4149. <!--[if gte mso 9]><xml>
  4150. <x:ExcelWorkbook>
  4151. <x:ExcelWorksheets>
  4152. <x:ExcelWorksheet>
  4153. <x:Name>EXCEL</x:Name>
  4154. <x:WorksheetOptions>
  4155. <x:Print>
  4156. <x:ValidPrinterInfo />
  4157. </x:Print>
  4158. </x:WorksheetOptions>
  4159. </x:ExcelWorksheet>
  4160. </x:ExcelWorksheets>
  4161. </x:ExcelWorkbook>
  4162. </xml>
  4163. <![endif]-->
  4164. </head><body>";
  4165. $str .= "<table border=1><tr><td>SKU</td>";
  4166. foreach ($timelist as $k => $v) {
  4167. $str .= "<td>" . $k . "出库</td>";
  4168. $str .= "<td>" . $k . "入库</td>";
  4169. }
  4170. $str .= "</tr></table>";
  4171. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4172. foreach ($rows as $key => $val) {
  4173. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4174. foreach ($val as $k => $v) {
  4175. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4176. if ($val[$k]['r'] > 0) {
  4177. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4178. } else {
  4179. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4180. }
  4181. }
  4182. $str .= "</tr>";
  4183. }
  4184. $str .= "</table>";
  4185. $str .= "</body></html>";
  4186. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4187. header("Content-type: application/octet-stream");
  4188. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4189. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4190. header("Pragma: no-cache");
  4191. header("Expires: 0");
  4192. exit($str);
  4193. }
  4194. }
  4195. //数量调整模板导出
  4196. public function _presetout()
  4197. {
  4198. if (isset($_GET['excel'])) {
  4199. $where = "sku != 'Preset' and purchase != 0";
  4200. //数据排序
  4201. $order_str = "id desc";
  4202. if (empty($page)) {
  4203. $start = 0;
  4204. $perpage = 1;
  4205. } else {
  4206. $start = ($page - 1) * $perpage;
  4207. }
  4208. //取得信息列表
  4209. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4210. $rows = array();
  4211. $list = array();
  4212. foreach ($info_list as $value) {
  4213. $warehouse = $this->warehouse->read($value['warehouse']);
  4214. $number = $value['number'];
  4215. $ftime = time() - 15 * 24 * 3600;
  4216. $purchase = $this->purchase->read($value['purchase']);
  4217. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4218. }
  4219. $title = "库存模板";
  4220. $titlename = "<table border=1>
  4221. <tr align='center'>
  4222. <td>仓库</td>
  4223. <td>供应商编码</td>
  4224. <td>SKU</td>
  4225. <td>增减数量(正数或负数)</td>
  4226. <td>增减备注</td>
  4227. <td>扣减方式:0减少库存1删除库存</td>
  4228. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4229. <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4230. </tr>
  4231. </table>";
  4232. $filename = $title . ".xls";
  4233. $tail = "";
  4234. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4235. }
  4236. }
  4237. //数量调整模板导入
  4238. public function _presetedit()
  4239. {
  4240. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4241. $config['upload_path'] = '.' . $dir;
  4242. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4243. $config['allowed_types'] = 'xls|xlsx|csv';
  4244. $config['max_size'] = 10240;
  4245. $this->load->library('upload', $config);
  4246. $this->upload->initialize($config);
  4247. if ($this->upload->do_upload('userfile')) {
  4248. $full_path = $dir . $this->upload->data('file_name');
  4249. $fileName = '.' . $full_path;
  4250. if (!file_exists($fileName)) {
  4251. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4252. exit;
  4253. } else {
  4254. require_once "./data/excel/PHPExcel/IOFactory.php";
  4255. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4256. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4257. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4258. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4259. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4260. ++$column; //如果列数大于26行
  4261. $list = array();
  4262. for ($i = 2; $i <= $row; $i++) // 行数循环
  4263. {
  4264. $data = array();
  4265. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4266. {
  4267. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4268. }
  4269. $list[] = $data;
  4270. }
  4271. }
  4272. $i = 0;
  4273. $j = 0;
  4274. $ed = array();
  4275. foreach ($list as $key => $value) {
  4276. $time = time();
  4277. if ($value['0'] == "") {
  4278. continue;
  4279. }
  4280. $warehouse = $this->warehouse->get_title($value['0']);
  4281. $purchase = $this->purchase->get_bm($value['1']);
  4282. $sku = $value['2'];
  4283. $num = $value['3']; //调整数量
  4284. $text = $value['4']; //扣减说明
  4285. $type = $value['5']; //调整方式0扣减1删除
  4286. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4287. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4288. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4289. if (!$purchase) //如果没有这个SKU
  4290. {
  4291. $ed[] = array($purchase . '-不存在此供应商编码');
  4292. $j++;
  4293. continue;
  4294. }
  4295. if (!$d) //如果没有这个SKU
  4296. {
  4297. $ed[] = array($sku . '-库存中不存在此SKU');
  4298. $j++;
  4299. continue;
  4300. }
  4301. if (!isset($warehouse['id'])) {
  4302. $ed[] = array($sku . '-仓库名错误!');
  4303. $j++;
  4304. continue;
  4305. }
  4306. if ($type != '0' && $type != '1') {
  4307. $ed[] = array($sku . '-扣减方式填写错误!');
  4308. $j++;
  4309. continue;
  4310. }
  4311. if ($num < 0) //扣减库存
  4312. {
  4313. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4314. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4315. $j++;
  4316. continue;
  4317. }
  4318. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4319. if (count($data) < abs($num)) {
  4320. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4321. $j++;
  4322. continue;
  4323. }
  4324. if ($type == 0) //如果扣减方式为 扣减库存
  4325. {
  4326. for ($i = 0; $i < abs($num); $i++) {
  4327. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4328. }
  4329. } else if ($type == 1) {
  4330. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4331. if (count($zt) > 0) {
  4332. $ed[] = array($sku . '-有在途库存无法删除!');
  4333. $j++;
  4334. continue;
  4335. }
  4336. for ($i = 0; $i < abs($num); $i++) {
  4337. $this->whlabel->remove($data[$i]['id']);
  4338. }
  4339. }
  4340. } else if ($num > 0) //增加库存
  4341. {
  4342. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4343. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4344. $j++;
  4345. continue;
  4346. }
  4347. $post['sku'] = $d['sku'];
  4348. $post['shop'] = $d['shop'];
  4349. $post['warehouse'] = $warehouse['id'];
  4350. $post['purchase'] = $purchase['id'];
  4351. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4352. $post['state'] = 0;
  4353. $post['title'] = $d['title'];
  4354. $post['number'] = $d['number'];
  4355. $post['features'] = $d['features'];
  4356. $post['enter'] = $time;
  4357. $post['time'] = $time; //操作时间
  4358. $post['rktype'] = $rktype;
  4359. for ($i = 0; $i < $num; $i++) {
  4360. $post['label'] = time() . rand(100, 999) . $i;
  4361. $this->whlabel->insert($post);
  4362. }
  4363. }
  4364. sleep(1); //防止入库时间一样,需要延迟1秒
  4365. }
  4366. if ($j > 0) {
  4367. $tt = date('Ymd', time());
  4368. $title = '库存导入错误信息-' . $tt;
  4369. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4370. $tail = "\n";
  4371. $filename = $title . ".xls";
  4372. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4373. $dir = '/data/excel/' . $time . '/';
  4374. $file_name = 'error_' . $time . rand(1000, 9999);
  4375. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4376. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4377. fwrite($myfile, $ecl);
  4378. fclose($myfile);
  4379. $error = $dir . $file_name . '.xls';
  4380. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4381. exit;
  4382. } else {
  4383. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4384. exit;
  4385. }
  4386. }
  4387. }
  4388. //笛卡儿积
  4389. function cp($ps, $sets, $list)
  4390. {
  4391. $result = array();
  4392. $j = 0;
  4393. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4394. if ($i == 0) {
  4395. $result = $sets[$i];
  4396. }
  4397. $tmp = array();
  4398. foreach ($result as $res) {
  4399. foreach ($sets[$i + 1] as $set) {
  4400. $tmp[] = $res . ',' . $set;
  4401. }
  4402. }
  4403. $result = $tmp;
  4404. }
  4405. $this->db->trans_begin();
  4406. foreach ($result as $v) {
  4407. $post = array();
  4408. $title = "";
  4409. $num = "";
  4410. $data = explode(',', $v);
  4411. for ($i = 0; $i < count($list); $i++) {
  4412. $post[$list[$i]] = $data[$i];
  4413. $typeclass = $this->typeclass->read($data[$i]);
  4414. $title = $title . $typeclass['title'] . " ";
  4415. if ($data[$i] != 0) {
  4416. $num .= $data[$i]; //所有数据ID拼接
  4417. }
  4418. }
  4419. foreach ($ps as $kp => $vp) {
  4420. $post[$kp] = $vp;
  4421. }
  4422. $post['number'] = $num;
  4423. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4424. if ($info_list) {
  4425. $j++;
  4426. } else {
  4427. $skunum = $this->whlabel->find_count();
  4428. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4429. $post['title'] = rtrim($title, ' ');
  4430. $this->whlabel->insert($post);
  4431. }
  4432. }
  4433. if ($this->db->trans_status() === FALSE) {
  4434. $this->db->trans_commit();
  4435. return NULL;
  4436. } else {
  4437. $this->db->trans_commit();
  4438. return $j;
  4439. }
  4440. }
  4441. public function _kj($arg_array)
  4442. {
  4443. if (isset($_POST['sku'])) {
  4444. $time = time();
  4445. $sku = $this->input->post('sku', true);
  4446. $warehouse = $this->input->post('warehouse', true);
  4447. $num = $this->input->post('num', true);
  4448. $text = $this->input->post('text', true);
  4449. $purchase = $this->input->post('purchase', true);
  4450. $cktype = $this->input->post('cktype', true);
  4451. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4452. if ($cktype != 1 && $text == '') {
  4453. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4454. exit;
  4455. }
  4456. if ($num > count($order)) {
  4457. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4458. exit;
  4459. } else {
  4460. for ($i = 0; $i < $num; $i++) {
  4461. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4462. }
  4463. }
  4464. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4465. exit;
  4466. }
  4467. $uid = $this->whlabel->read($arg_array[0]);
  4468. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4469. $this->data['data'] = $uid;
  4470. $this->_Template('whlabel_kj', $this->data);
  4471. }
  4472. public function _summary($arg_array)
  4473. {
  4474. $prc = array();
  4475. $purchase = $this->purchase->find_all();
  4476. foreach ($purchase as $k => $v) {
  4477. $prc[$v['id']] = $v['title'];
  4478. }
  4479. if (isset($_GET['excel'])) {
  4480. $ktime = $this->input->get('ktime', true);
  4481. $jtime = $this->input->get('jtime', true);
  4482. $ktime = strtotime($ktime);
  4483. $jtime = strtotime($jtime);
  4484. $where = "1=1";
  4485. if ($ktime && $jtime) {
  4486. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4487. }
  4488. //数据排序
  4489. $order_str = "time desc";
  4490. if (empty($page)) {
  4491. $start = 0;
  4492. $perpage = 1;
  4493. } else {
  4494. $start = ($page - 1) * $perpage;
  4495. }
  4496. //取得信息列表
  4497. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4498. foreach ($info_list as $key => $value) {
  4499. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4500. $warehouse = $this->warehouse->read($value['warehouse']);
  4501. $info_list[$key]['warehouse'] = $warehouse['title'];
  4502. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4503. $details = array();
  4504. $cpid = array();
  4505. foreach ($x as $k => $v) {
  4506. if ($v['details'] != '') {
  4507. $details[$v['details']] = $v['details'];
  4508. }
  4509. if ($v['cpid'] != 0) {
  4510. $cpid[$v['cpid']] = $v['cpid'];
  4511. }
  4512. }
  4513. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4514. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4515. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4516. $info_list[$key]['s'] = $s;
  4517. $info_list[$key]['x'] = count($x);
  4518. }
  4519. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4520. $titlename = "<table border=1>
  4521. <tr align='center'>
  4522. <td>仓库</td>
  4523. <td>供应商</td>
  4524. <td>出库位置</td>
  4525. <td>出库编码</td>
  4526. <td>SKU</td>
  4527. <td>产品名</td>
  4528. <td>总剩余库存</td>
  4529. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4530. </tr>
  4531. </table>";
  4532. $filename = $title . ".xls";
  4533. $tail = "";
  4534. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4535. }
  4536. }
  4537. //usps发货清单
  4538. public function _manifest()
  4539. {
  4540. if (isset($_POST['manifest'])) {
  4541. $wltext = $this->input->post('wltext', true);
  4542. $time = time() - 16 * 3600;
  4543. $ptime = strtotime(date('Y-m-d', $time));
  4544. $waybill = array();
  4545. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4546. foreach ($fullorder as $v) {
  4547. $waybill[$v['waybill']] = $v['waybill'];
  4548. }
  4549. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4550. foreach ($fullordersmt as $v) {
  4551. $waybill[$v['waybill']] = $v['waybill'];
  4552. }
  4553. $wltext = explode(';', $wltext);
  4554. foreach ($wltext as $v) {
  4555. if (isset($waybill[$v])) {
  4556. unset($waybill[$v]);
  4557. }
  4558. }
  4559. $data = $this->usps->get_manifest($waybill);
  4560. if (isset($data['Description'])) {
  4561. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4562. exit;
  4563. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4564. $bctime = date('Ymd', time());
  4565. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4566. echo json_encode(array('msg' => $pdf, 'success' => true));
  4567. exit;
  4568. } else {
  4569. echo json_encode(array('msg' => $data, 'success' => false));
  4570. exit;
  4571. }
  4572. }
  4573. }
  4574. public function _pdf($pdf, $title, $bctime)
  4575. {
  4576. $pdf_path = './data/pdf/' . $bctime . '/';
  4577. $file_base64 = $pdf;
  4578. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4579. $file_base64 = base64_decode($file_base64);
  4580. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4581. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4582. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4583. }
  4584. /**
  4585. *
  4586. *
  4587. *
  4588. 进销存占单异常索引
  4589. *
  4590. *
  4591. *
  4592. **/
  4593. public function _abnormal()
  4594. {
  4595. $post = $this->input->post(NULL, TRUE);
  4596. if (isset($post['page'])) {
  4597. $page = $this->input->post('page', true);
  4598. $perpage = $this->input->post('perpage', true);
  4599. $sku = $this->input->post('sku', true);
  4600. $where = "1=1";
  4601. //数据排序
  4602. $order_str = "id desc";
  4603. if (empty($page)) {
  4604. $start = 0;
  4605. $perpage = 1;
  4606. } else {
  4607. $start = ($page - 1) * $perpage;
  4608. }
  4609. //取得信息列表
  4610. $info_list = $this->whlabel->find_all($where, '*');
  4611. $rows = array();
  4612. $list = array();
  4613. foreach ($info_list as $key => $value) {
  4614. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4615. }
  4616. foreach ($rows as $value) {
  4617. $warehouse = $this->warehouse->read($value['warehouse']);
  4618. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4619. $number = $value['number'];
  4620. $ftime = time() - 15 * 24 * 3600;
  4621. if ($value['shop'] != '') {
  4622. $shop = $value['shop'];
  4623. $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');
  4624. $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');
  4625. $order = array_merge($orderdlz, $ordersmt);
  4626. $od = 0;
  4627. $a = '';
  4628. $orid = '';
  4629. foreach ($order as $v) {
  4630. $or = explode('|', ltrim($v['whlabel'], '|'));
  4631. for ($i = 0; $i < count($or); $i++) {
  4632. $orod = explode('-', $or[$i]);
  4633. if ($orod[0] == $number) {
  4634. $od += $orod[1];
  4635. }
  4636. }
  4637. $orid .= $v['number'] . '-';
  4638. }
  4639. } else {
  4640. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4641. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4642. $order = array_merge($orderdlz, $ordersmt);
  4643. $od = 0;
  4644. $a = '';
  4645. $orid = '';
  4646. $qt = array();
  4647. foreach ($order as $v) {
  4648. $or = explode('|', ltrim($v['whlabel'], '|'));
  4649. for ($i = 0; $i < count($or); $i++) {
  4650. $orod = explode('-', $or[$i]);
  4651. if ($orod[0] == $number) {
  4652. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4653. if ($czzs > 0) {
  4654. if (isset($qt[$v['shop']])) {
  4655. if ($qt[$v['shop']] < $orod[1]) {
  4656. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4657. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4658. } else {
  4659. $qt[$v['shop']] -= $orod[1];
  4660. }
  4661. } else {
  4662. $qt[$v['shop']] = $czzs;
  4663. }
  4664. } else {
  4665. $od += $orod[1];
  4666. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4667. }
  4668. }
  4669. }
  4670. }
  4671. }
  4672. $z = $od . '(' . $orid . ')'; //查看订单号
  4673. //$z = $od;
  4674. if ($od > $c) {
  4675. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4676. }
  4677. }
  4678. $listdata = array_slice($list, $start, $perpage);
  4679. $total = count($list);
  4680. $pagenum = ceil($total / $perpage);
  4681. $over = $total - ($start + $perpage);
  4682. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4683. echo json_encode($rows);
  4684. exit;
  4685. }
  4686. $this->_Template('whlabel_abnormal', $this->data);
  4687. }
  4688. /**
  4689. *
  4690. *
  4691. *
  4692. 进销存占单异常索引
  4693. *
  4694. *
  4695. *
  4696. **/
  4697. public function _error()
  4698. {
  4699. $post = $this->input->post(NULL, TRUE);
  4700. if (isset($post['page'])) {
  4701. $page = $this->input->post('page', true);
  4702. $perpage = $this->input->post('perpage', true);
  4703. $sku = $this->input->post('sku', true);
  4704. $warehouse = $this->input->post('warehouse', true);
  4705. $ktime = $this->input->post('ktime', true);
  4706. $jtime = $this->input->post('jtime', true);
  4707. $ktime = strtotime($ktime);
  4708. $jtime = strtotime($jtime);
  4709. $where = "sku != 'Preset'";
  4710. $gj = '';
  4711. if ($sku) {
  4712. $where .= " and sku like '%$sku%'";
  4713. } else {
  4714. if ($ktime && $jtime) {
  4715. $gj = " and time > '$ktime' and time < '$jtime'";
  4716. }
  4717. }
  4718. if ($warehouse) {
  4719. $where .= " and warehouse = '$warehouse'";
  4720. }
  4721. //数据排序
  4722. $order_str = "id desc";
  4723. if (empty($page)) {
  4724. $start = 0;
  4725. $perpage = 1;
  4726. } else {
  4727. $start = ($page - 1) * $perpage;
  4728. }
  4729. //取得信息列表
  4730. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4731. $rows = array();
  4732. $list = array();
  4733. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4734. // foreach ($info_list as $value)
  4735. // {
  4736. // $warehouse = $this->warehouse->read($value['warehouse']);
  4737. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4738. // $number = $value['number'];$ftime = time()-15*24*3600;
  4739. // if($c < 1)
  4740. // {
  4741. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4742. // }
  4743. // }
  4744. $warehouse_list = $this->warehouse->find_all();
  4745. $warehouse_list = array_column($warehouse_list, null, 'id');
  4746. foreach ($info_list as $value) {
  4747. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4748. 'title' => "",
  4749. ];
  4750. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4751. $number = $value['number'];
  4752. $ftime = time() - 15 * 24 * 3600;
  4753. if ($c < 1) {
  4754. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4755. }
  4756. }
  4757. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4758. // $query = $this->db->query($sql);
  4759. // $info_list = $query->result_array();
  4760. // $sql_two = "select title,id from crowd_warehouse";
  4761. // $query_two = $this->db->query($sql_two);
  4762. // $warehouse_list = $query_two->result_array();
  4763. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4764. // foreach ($info_list as $value)
  4765. // {
  4766. // if(isset($warehouse_arr[$value['warehouse']])){
  4767. // $warehouse = $warehouse_arr[$value['warehouse']];
  4768. // }else{
  4769. // $warehouse = [
  4770. // 'id'=>0,
  4771. // 'title'=>"异常",
  4772. // ];
  4773. // }
  4774. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4775. // $number = $value['number'];$ftime = time()-15*24*3600;
  4776. // if($c < 1)
  4777. // {
  4778. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4779. // }
  4780. // }
  4781. $listdata = array_slice($list, $start, $perpage);
  4782. $total = count($list);
  4783. $pagenum = ceil($total / $perpage);
  4784. $over = $total - ($start + $perpage);
  4785. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4786. echo json_encode($rows);
  4787. exit;
  4788. }
  4789. if (isset($post['s'])) {
  4790. $id_arr = $this->input->post('s');
  4791. $id_arr = explode(',', trim($id_arr, ','));
  4792. if (!$id_arr) {
  4793. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4794. exit;
  4795. }
  4796. //循环删除记录
  4797. foreach ($id_arr as $v) {
  4798. $dd = $this->whlabel->read($v);
  4799. if (!isset($dd['id'])) {
  4800. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4801. exit;
  4802. }
  4803. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4804. if (isset($zt[0])) {
  4805. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4806. exit;
  4807. }
  4808. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4809. foreach ($deldd as $vv) {
  4810. $this->whlabel->remove($vv['id']);
  4811. }
  4812. }
  4813. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4814. exit;
  4815. }
  4816. $this->_Template('whlabel_error', $this->data);
  4817. }
  4818. public function _errorexcel()
  4819. {
  4820. $post = $this->input->post(NULL, TRUE);
  4821. if (isset($_GET['page'])) {
  4822. $page = $this->input->get('page', true);
  4823. $perpage = $this->input->get('perpage', true);
  4824. $sku = $this->input->get('sku', true);
  4825. $warehouse = $this->input->get('warehouse', true);
  4826. $ktime = $this->input->get('ktime', true);
  4827. $jtime = $this->input->get('jtime', true);
  4828. $ktime = strtotime($ktime);
  4829. $jtime = strtotime($jtime);
  4830. $where = "sku != 'Preset'";
  4831. $gj = '';
  4832. if ($sku) {
  4833. $where .= " and sku like '%$sku%'";
  4834. } else {
  4835. if ($ktime && $jtime) {
  4836. $gj = " and time > '$ktime' and time < '$jtime'";
  4837. }
  4838. }
  4839. if ($warehouse) {
  4840. $where .= " and warehouse = '$warehouse'";
  4841. }
  4842. //数据排序
  4843. $order_str = "id desc";
  4844. if (empty($page)) {
  4845. $start = 0;
  4846. $perpage = 1;
  4847. } else {
  4848. $start = ($page - 1) * $perpage;
  4849. }
  4850. //取得信息列表
  4851. $rows = array();
  4852. $list = array();
  4853. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4854. foreach ($info_list as $value) {
  4855. $warehouse = $this->warehouse->read($value['warehouse']);
  4856. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4857. $number = $value['number'];
  4858. $ftime = time() - 15 * 24 * 3600;
  4859. if ($c < 1) {
  4860. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4861. }
  4862. }
  4863. $title = "0库存汇总";
  4864. $titlename = "<table border=1>
  4865. <tr align='center'>
  4866. <td>仓库</td>
  4867. <td>SKU</td>
  4868. <td>产品</td>
  4869. <td>当前库存</td>
  4870. </tr>
  4871. </table>";
  4872. $filename = $title . ".xls";
  4873. $tail = "";
  4874. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4875. }
  4876. }
  4877. /**
  4878. *
  4879. *
  4880. * 占单
  4881. *
  4882. *
  4883. **/
  4884. public function _kcyz()
  4885. {
  4886. $post = $this->input->post(NULL, TRUE);
  4887. if (isset($post['warehouse'])) {
  4888. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  4889. exit; //不再使用
  4890. $warehouse = $this->input->post('warehouse', true);
  4891. $whlabel = $this->input->post('whlabel', true);
  4892. $id = $this->input->post('id', true);
  4893. $shop = $this->input->post('shop', true);
  4894. $number = $this->input->post('number', true);
  4895. if (!$whlabel || $whlabel == '|') {
  4896. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  4897. exit;
  4898. }
  4899. $pp = explode('|', trim($whlabel, '|'));
  4900. $x = 0;
  4901. $save = array();
  4902. foreach ($pp as $va) {
  4903. $num = explode('-', $va);
  4904. if ($number) {
  4905. $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 = '')"); //通用
  4906. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  4907. } else {
  4908. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  4909. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  4910. }
  4911. $x++;
  4912. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  4913. $save[] = $x - 1;
  4914. continue; //提前先加X不然出错,所以要减1
  4915. }
  4916. }
  4917. if (isset($save[0])) {
  4918. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  4919. exit;
  4920. } else {
  4921. echo json_encode(array('success' => true));
  4922. exit;
  4923. }
  4924. }
  4925. }
  4926. public function _db()
  4927. {
  4928. $post = $this->input->post(NULL, TRUE);
  4929. if (isset($post['page'])) {
  4930. $page = $this->input->post('page', true);
  4931. $perpage = $this->input->post('perpage', true);
  4932. $sku = $this->input->post('sku', true);
  4933. $number = $this->input->post('number', true);
  4934. $warehouse = $this->input->post('warehouse', true);
  4935. $purchase = $this->input->post('purchase', true);
  4936. $orderinfo = $this->input->post('orderinfo', true);
  4937. $waybill = $this->input->post('waybill', true);
  4938. $category = $this->input->post('category', true);
  4939. $size = $this->input->post('size', true);
  4940. $grade = $this->input->post('grade', true);
  4941. $color = $this->input->post('color', true);
  4942. $lowe = $this->input->post('lowe', true);
  4943. $state = $this->input->post('state', true);
  4944. $label = $this->input->post('label', true);
  4945. $timetk = $this->input->post('timetkk', true);
  4946. $timetj = $this->input->post('timetjj', true);
  4947. $timetk = strtotime($timetk);
  4948. $timetj = strtotime($timetj);
  4949. $where = "dbtime > 0";
  4950. if ($timetk && $timetj) {
  4951. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  4952. }
  4953. if ($sku) {
  4954. $where .= " and sku = '$sku'";
  4955. }
  4956. if ($warehouse) {
  4957. $where .= " and warehouse = '$warehouse'";
  4958. if ($warehouse == 12) {
  4959. $w = 'specialstock';
  4960. } else {
  4961. $w = 'whlabel';
  4962. }
  4963. }
  4964. if ($purchase) {
  4965. $where .= " and purchase = '$purchase'";
  4966. }
  4967. if ($category) {
  4968. $where .= " and features like '%-$category-%'";
  4969. }
  4970. if ($size) {
  4971. $where .= " and features like '%-$size-%'";
  4972. }
  4973. if ($grade) {
  4974. $where .= " and features like '%-$grade-%'";
  4975. }
  4976. if ($color) {
  4977. $where .= " and features like '%-$color-%'";
  4978. }
  4979. if ($lowe) {
  4980. $where .= " and features like '%-$lowe-%'";
  4981. }
  4982. if ($state != '') {
  4983. $where .= " and state = '$state'";
  4984. }
  4985. //数据排序
  4986. $order_str = "dbtime desc";
  4987. if (empty($page)) {
  4988. $start = 0;
  4989. $perpage = 1;
  4990. } else {
  4991. $start = ($page - 1) * $perpage;
  4992. }
  4993. //取得信息列表
  4994. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  4995. foreach ($info_list as $key => $value) {
  4996. $warehouse = $this->$w->read($value['warehouse']);
  4997. $info_list[$key]['warehouse'] = $warehouse['title'];
  4998. $purchase = $this->purchase->read($value['purchase']);
  4999. $info_list[$key]['purchase'] = $purchase['title'];
  5000. if ($value['enter'] != 0) {
  5001. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5002. } else {
  5003. $info_list[$key]['enter'] = "";
  5004. }
  5005. if ($value['dbtime'] != 0) {
  5006. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5007. } else {
  5008. $info_list[$key]['dbtime'] = "";
  5009. }
  5010. if ($value['state'] == 0) {
  5011. $info_list[$key]['state'] = "在库";
  5012. } else if ($value['state'] == 1) {
  5013. $info_list[$key]['state'] = "出库";
  5014. } else if ($value['state'] == 2) {
  5015. $info_list[$key]['state'] = "退库";
  5016. } else if ($value['state'] == 3) {
  5017. $info_list[$key]['state'] = "调拨中";
  5018. } else if ($value['state'] == 4) {
  5019. $info_list[$key]['state'] = "再加工";
  5020. } else if ($value['state'] == 5) {
  5021. $info_list[$key]['state'] = "维修中";
  5022. } else if ($value['state'] == 6) {
  5023. $info_list[$key]['state'] = "盘亏";
  5024. } else if ($value['state'] == 7) {
  5025. $info_list[$key]['state'] = "更换标签";
  5026. } else if ($value['state'] == 8) {
  5027. $info_list[$key]['state'] = "其它";
  5028. } else if ($value['state'] == 9) {
  5029. $info_list[$key]['state'] = "预设";
  5030. }
  5031. }
  5032. $total = $this->whlabel->find_count($where);
  5033. $pagenum = ceil($total / $perpage);
  5034. $over = $total - ($start + $perpage);
  5035. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5036. echo json_encode($rows);
  5037. exit;
  5038. }
  5039. if (isset($post['outsku'])) {
  5040. $time = time();
  5041. $cz = $this->input->post('cz', true);
  5042. $label = $this->input->post('outsku', true);
  5043. $sl = $this->input->post('sl', true);
  5044. $num = $this->input->post('num', true);
  5045. //$warehouse = $this->input->post('warehouse',true);
  5046. if (!$sl) {
  5047. $sl = 1;
  5048. }
  5049. if (!$warehouse) {
  5050. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5051. exit;
  5052. }
  5053. $dblabel = $this->whlabellabel->get_label($label);
  5054. if ($dblabel) {
  5055. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5056. if (count($data) < 1) {
  5057. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5058. exit;
  5059. }
  5060. if (count($data) < $num) {
  5061. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5062. exit;
  5063. }
  5064. for ($i = 0; $i < $sl; $i++) {
  5065. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5066. }
  5067. echo json_encode(array('success' => true));
  5068. exit;
  5069. } else {
  5070. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5071. exit;
  5072. }
  5073. }
  5074. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5075. $this->_Template('whlabel_db', $this->data);
  5076. }
  5077. public function _dbrk()
  5078. {
  5079. $post = $this->input->post(NULL, TRUE);
  5080. if (isset($post['page'])) {
  5081. $page = $this->input->post('page', true);
  5082. $perpage = $this->input->post('perpage', true);
  5083. $sku = $this->input->post('sku', true);
  5084. $number = $this->input->post('number', true);
  5085. $warehouse = $this->input->post('warehouse', true);
  5086. $purchase = $this->input->post('purchase', true);
  5087. $orderinfo = $this->input->post('orderinfo', true);
  5088. $waybill = $this->input->post('waybill', true);
  5089. $category = $this->input->post('category', true);
  5090. $size = $this->input->post('size', true);
  5091. $grade = $this->input->post('grade', true);
  5092. $color = $this->input->post('color', true);
  5093. $lowe = $this->input->post('lowe', true);
  5094. $state = $this->input->post('state', true);
  5095. $label = $this->input->post('label', true);
  5096. $ctime = $this->input->post('ctime', true);
  5097. $timetk = $this->input->post('timetkk', true);
  5098. $timetj = $this->input->post('timetjj', true);
  5099. $timetk = strtotime($timetk);
  5100. $timetj = strtotime($timetj);
  5101. $where = "dbtime > 0";
  5102. if ($timetk && $timetj) {
  5103. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5104. }
  5105. if ($sku) {
  5106. $where .= " and sku = '$sku'";
  5107. }
  5108. if ($warehouse) {
  5109. $where .= " and warehouse = '$warehouse'";
  5110. }
  5111. if ($purchase) {
  5112. $where .= " and purchase = '$purchase'";
  5113. }
  5114. if ($category) {
  5115. $where .= " and features like '%-$category-%'";
  5116. }
  5117. if ($size) {
  5118. $where .= " and features like '%-$size-%'";
  5119. }
  5120. if ($grade) {
  5121. $where .= " and features like '%-$grade-%'";
  5122. }
  5123. if ($color) {
  5124. $where .= " and features like '%-$color-%'";
  5125. }
  5126. if ($lowe) {
  5127. $where .= " and features like '%-$lowe-%'";
  5128. }
  5129. if ($state != '') {
  5130. $where .= " and state = '$state'";
  5131. }
  5132. //数据排序
  5133. $order_str = "dbtime desc";
  5134. if (empty($page)) {
  5135. $start = 0;
  5136. $perpage = 1;
  5137. } else {
  5138. $start = ($page - 1) * $perpage;
  5139. }
  5140. //取得信息列表
  5141. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5142. foreach ($info_list as $key => $value) {
  5143. $warehouse = $this->warehouse->read($value['warehouse']);
  5144. $info_list[$key]['warehouse'] = $warehouse['title'];
  5145. $purchase = $this->purchase->read($value['purchase']);
  5146. $info_list[$key]['purchase'] = $purchase['title'];
  5147. if ($value['enter'] != 0) {
  5148. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5149. } else {
  5150. $info_list[$key]['enter'] = "";
  5151. }
  5152. if ($value['dbtime'] != 0) {
  5153. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5154. } else {
  5155. $info_list[$key]['dbtime'] = "";
  5156. }
  5157. if ($value['state'] == 0) {
  5158. $info_list[$key]['state'] = "在库";
  5159. } else if ($value['state'] == 1) {
  5160. $info_list[$key]['state'] = "出库";
  5161. } else if ($value['state'] == 2) {
  5162. $info_list[$key]['state'] = "退库";
  5163. } else if ($value['state'] == 3) {
  5164. $info_list[$key]['state'] = "调拨中";
  5165. } else if ($value['state'] == 4) {
  5166. $info_list[$key]['state'] = "再加工";
  5167. } else if ($value['state'] == 5) {
  5168. $info_list[$key]['state'] = "维修中";
  5169. } else if ($value['state'] == 6) {
  5170. $info_list[$key]['state'] = "盘亏";
  5171. } else if ($value['state'] == 7) {
  5172. $info_list[$key]['state'] = "更换标签";
  5173. } else if ($value['state'] == 8) {
  5174. $info_list[$key]['state'] = "其它";
  5175. } else if ($value['state'] == 9) {
  5176. $info_list[$key]['state'] = "预设";
  5177. }
  5178. }
  5179. $total = $this->whlabel->find_count($where);
  5180. $pagenum = ceil($total / $perpage);
  5181. $over = $total - ($start + $perpage);
  5182. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5183. echo json_encode($rows);
  5184. exit;
  5185. }
  5186. if (isset($post['rsku'])) {
  5187. $cz = $this->input->post('cz', true);
  5188. $label = $this->input->post('rsku', true);
  5189. $sl = $this->input->post('sl', true);
  5190. $warehouse = $this->input->post('warehouse', true);
  5191. if (!$sl) {
  5192. $sl = 1;
  5193. }
  5194. if (!$warehouse) {
  5195. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5196. exit;
  5197. }
  5198. $dblabel = $this->whlabellabel->get_label($label);
  5199. if ($dblabel) {
  5200. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5201. if (count($data) < 1) {
  5202. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5203. exit;
  5204. }
  5205. if ($sl > count($data)) {
  5206. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5207. exit;
  5208. }
  5209. $time = time();
  5210. for ($i = 0; $i < $sl; $i++) {
  5211. $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']);
  5212. }
  5213. echo json_encode(array('success' => true));
  5214. exit;
  5215. } else {
  5216. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5217. exit;
  5218. }
  5219. }
  5220. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5221. $this->_Template('whlabel_dbrk', $this->data);
  5222. }
  5223. public function _whlabelczdc()
  5224. {
  5225. if (isset($_GET['excel'])) {
  5226. //数据排序
  5227. $order_str = "id desc";
  5228. if (empty($page)) {
  5229. $start = 0;
  5230. $perpage = 1;
  5231. } else {
  5232. $start = ($page - 1) * $perpage;
  5233. }
  5234. $state = $this->input->get('state', true);
  5235. $sku = $this->input->get('sku', true);
  5236. $ctime = $this->input->get('ctime', true);
  5237. $category = $this->input->get('category', true);
  5238. $size = $this->input->get('size', true);
  5239. $grade = $this->input->get('grade', true);
  5240. $color = $this->input->get('color', true);
  5241. $lowe = $this->input->get('lowe', true);
  5242. $timetk = $this->input->get('timetkk', true);
  5243. $timetj = $this->input->get('timetjj', true);
  5244. $timetk = strtotime($timetk);
  5245. $timetj = strtotime($timetj);
  5246. $where = "dbtime > 0";
  5247. if ($timetk && $timetj) {
  5248. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5249. }
  5250. if ($category) {
  5251. $where .= " and features like '%-$category-%'";
  5252. }
  5253. if ($size) {
  5254. $where .= " and features like '%-$size-%'";
  5255. }
  5256. if ($grade) {
  5257. $where .= " and features like '%-$grade-%'";
  5258. }
  5259. if ($color) {
  5260. $where .= " and features like '%-$color-%'";
  5261. }
  5262. if ($lowe) {
  5263. $where .= " and features like '%-$lowe-%'";
  5264. }
  5265. //取得信息列表
  5266. $info_list = $this->whlabel->find_all($where, '*');
  5267. $rows = array();
  5268. $list = array();
  5269. foreach ($info_list as $key => $value) {
  5270. $rows[$value['sku']] = $value; //所有数据sku
  5271. }
  5272. foreach ($rows as $value) {
  5273. $warehouse = $this->warehouse->read($value['warehouse']);
  5274. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5275. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5276. if ($value['orderinfo'] == 0) {
  5277. $info_list[$key]['orderinfo'] = "";
  5278. }
  5279. if ($value['waybill'] == 0) {
  5280. $info_list[$key]['waybill'] = "";
  5281. }
  5282. if ($value['state'] == 0) {
  5283. $value['state'] = "在库";
  5284. } else if ($value['state'] == 3) {
  5285. $value['state'] = "调拨中";
  5286. }
  5287. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5288. }
  5289. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5290. $titlename = "<table border=1>
  5291. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5292. <tr align='center'>
  5293. <td>SKU</td>
  5294. <td>产品</td>
  5295. <td>调拨数量</td>
  5296. <td>入库数量</td>
  5297. </tr>
  5298. </table>";
  5299. $filename = $title . ".xls";
  5300. $tail = "";
  5301. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5302. }
  5303. }
  5304. public function _print($arg_array)
  5305. {
  5306. if (isset($_SESSION['api'])) {
  5307. $user = $this->user->get_api($_SESSION['api']);
  5308. $usp = $user;
  5309. $fgshop = "";
  5310. $sid = "";
  5311. $wid = "";
  5312. $wtype = "";
  5313. $usersp = explode('|', trim($user['shop'], '|'));
  5314. $userwh = explode('|', trim($user['warehouse'], '|'));
  5315. foreach ($usersp as $value) {
  5316. $fgshop .= " shop = " . $value . " or";
  5317. $sid .= " id = " . $value . " or";
  5318. }
  5319. foreach ($userwh as $value) {
  5320. $wid .= " id = " . $value . " or";
  5321. $wtype .= " type = " . $value . " or";
  5322. }
  5323. }
  5324. $post = $this->input->post(NULL, TRUE);
  5325. if (isset($post['tmsku'])) {
  5326. $tmsku = $this->input->post('tmsku', true);
  5327. if (is_numeric($tmsku)) {
  5328. $yyh = $this->whlabellabel->get_label($tmsku);
  5329. } else {
  5330. $yyh = $this->whlabellabel->get_sku($tmsku);
  5331. }
  5332. if ($yyh) {
  5333. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5334. exit;
  5335. } else {
  5336. echo json_encode(array('success' => false));
  5337. exit;
  5338. }
  5339. }
  5340. $classid = $this->classid->sku();
  5341. $pm = $classid;
  5342. $scsku = $classid;
  5343. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5344. if (isset($post['warehouse'])) {
  5345. if ($post['warehouse']) {
  5346. $list = array();
  5347. $num = "";
  5348. $title = "";
  5349. $features = "";
  5350. $order = 0;
  5351. $post['shop'] = '';
  5352. $brand = $this->input->post('brand', true);
  5353. if ($brand != '0,') {
  5354. $b = $this->brand->read(rtrim($brand, ','));
  5355. if ($b) {
  5356. $post['shop'] = str_replace('|', ',', $b['shop']);
  5357. }
  5358. }
  5359. $post['details'] = $this->input->post('details', true); //打印数量
  5360. $xbqnum = $this->input->post('xbqnum', true);
  5361. $post['purchase'] = $this->input->post('purchase', true);
  5362. $post['warehouse'] = $this->input->post('warehouse', true);
  5363. $post['purchase'] = $this->input->post('purchase', true);
  5364. $post['retreatwarehouse'] = $post['warehouse'];
  5365. $post['cpbz'] = $this->input->post('cpbz', true);
  5366. $post['state'] = 9;
  5367. $category = $this->input->post('category', true);
  5368. $list['category'] = $category;
  5369. $list['hairtype'] = $this->input->post('hairtype', true);
  5370. $list['grade'] = $this->input->post('grade', true);
  5371. $size = $this->input->post('size', true);
  5372. $list['size'] = rtrim($size, ',');
  5373. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5374. $list['extension'] = $this->input->post('extension', true);
  5375. if ($category == 1297) {
  5376. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5377. }
  5378. if ($category == 1702) {
  5379. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5380. $list['syother'] = $this->input->post('syother', true);
  5381. }
  5382. if ($category == 133) {
  5383. $list['fittype'] = $this->input->post('fittype', true);
  5384. $list['acother'] = $this->input->post('acother', true);
  5385. }
  5386. $list['color'] = $this->input->post('color', true);
  5387. $list['lowe'] = $this->input->post('lowe', true);
  5388. if ($category == 127) {
  5389. $list['type'] = $this->input->post('type', true);
  5390. $list['headroad'] = $this->input->post('headroad', true);
  5391. $list['density'] = $this->input->post('density', true);
  5392. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5393. $list['lacesize'] = $this->input->post('lacesize', true);
  5394. }
  5395. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5396. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5397. }
  5398. if ($category == 128) {
  5399. $list['lacetype'] = $this->input->post('lacetype', true);
  5400. $list['haircap'] = $this->input->post('haircap', true);
  5401. $list['density'] = $this->input->post('density', true);
  5402. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5403. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5404. $list['wigother'] = $this->input->post('wigother', true);
  5405. $list['wigother1'] = $this->input->post('wigother1', true);
  5406. $list['wigother2'] = $this->input->post('wigother2', true);
  5407. }
  5408. if ($category == 129) {
  5409. $list['wide'] = $this->input->post('wide', true);
  5410. }
  5411. if ($category == 131) {
  5412. $list['gifttype'] = $this->input->post('gifttype', true);
  5413. $list['giftother'] = $this->input->post('giftother', true);
  5414. }
  5415. if ($category == 134) {
  5416. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5417. }
  5418. if ($category == 1297) {
  5419. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5420. $list['sywigother'] = $this->input->post('sywigother', true);
  5421. }
  5422. if ($category == 130 || $category == 133 || $category == 1702) {
  5423. $list['items'] = $this->input->post('items', true);
  5424. $list['weight'] = $this->input->post('weight', true);
  5425. }
  5426. if ($category == 1702) {
  5427. $list['syhairther'] = $this->input->post('syhairther', true);
  5428. }
  5429. foreach ($list as $k => $v) {
  5430. if ($v != 0) {
  5431. $num .= $v;
  5432. $features .= $v . '-';
  5433. $post[$k] = $v;
  5434. $typeclass = $this->typeclass->read($v);
  5435. if (isset($pm[$typeclass['classid']])) {
  5436. if (stripos($typeclass['zh'], '|') !== false) {
  5437. $exzh = explode('|', $typeclass['zh']);
  5438. $pm[$typeclass['classid']] = $exzh[0];
  5439. } else {
  5440. $pm[$typeclass['classid']] = $typeclass['zh'];
  5441. }
  5442. }
  5443. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5444. if ($k != 'size') {
  5445. $title .= $typeclass['title'] . " ";
  5446. }
  5447. }
  5448. }
  5449. $typeclass = $this->typeclass->read($list['size']);
  5450. $title .= $typeclass['title'];
  5451. $time = time();
  5452. $post['title'] = rtrim($title, ' ');
  5453. $post['number'] = $num;
  5454. $post['features'] = '-' . $features;
  5455. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5456. $featurespp = explode('-', trim($featurespp, '-'));
  5457. if (isset($featurespp[5])) {
  5458. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5459. } else {
  5460. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5461. }
  5462. $post['enter'] = $time;
  5463. $post['time'] = $time; //操作时间
  5464. $scsku = implode("-", $scsku);
  5465. $zh = implode(" ", $pm);
  5466. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5467. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5468. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5469. $post['sku'] = $bqsku;
  5470. $label = time() . rand(0, 9);
  5471. $post['label'] = $label;
  5472. $cpid = $this->whlabellabel->find_count();
  5473. $post['cpid'] = $cpid + 1;
  5474. $cpid = $post['cpid'];
  5475. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5476. //if($whlabelbarcode)
  5477. //{
  5478. //$post['label'] = $whlabelbarcode['label'];
  5479. //if(!$this->whlabellabel->insert($post))
  5480. //{
  5481. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5482. //}
  5483. //}
  5484. //else
  5485. //{
  5486. $this->db->trans_begin();
  5487. $this->whlabellabel->insert($post);
  5488. //$this->whlabelbarcode->insert($post);
  5489. if ($this->db->trans_status() === TRUE) {
  5490. $this->db->trans_commit();
  5491. } else {
  5492. $this->db->trans_rollback();
  5493. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5494. exit;
  5495. }
  5496. //}
  5497. $warehouse_name = "";
  5498. $warehouse = $post['warehouse'];
  5499. if($warehouse == 12){
  5500. $warehouse_name = "特殊库存库";
  5501. }
  5502. // if($warehouse == 13){
  5503. // $warehouse_name = "许昌仓";
  5504. // }
  5505. // if($warehouse == 5){
  5506. // $warehouse_name = "美国店";
  5507. // }
  5508. // if($warehouse == 16){
  5509. // $warehouse_name = "定制头套仓";
  5510. // }
  5511. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5512. if(!empty($warehouse_name)){
  5513. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5514. }
  5515. $purchase = $this->purchase->read($post['purchase']);
  5516. 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));
  5517. exit; //特殊仓目前不需要仓库选项
  5518. }
  5519. }
  5520. if (isset($_SESSION['api'])) {
  5521. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5522. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5523. $this->data['wlshop'] = $wlshop;
  5524. $this->data['warehouse'] = $warehouse;
  5525. }
  5526. $whlabelwz = $this->whlabelwz->find_all();
  5527. $this->data['whlabelwz'] = $whlabelwz;
  5528. $this->_Template('whlabel_print', $this->data);
  5529. }
  5530. public function _usaprint($arg_array)
  5531. {
  5532. if (isset($_SESSION['api'])) {
  5533. $user = $this->user->get_api($_SESSION['api']);
  5534. $usp = $user;
  5535. $fgshop = "";
  5536. $sid = "";
  5537. $wid = "";
  5538. $wtype = "";
  5539. $usersp = explode('|', trim($user['shop'], '|'));
  5540. $userwh = explode('|', trim($user['warehouse'], '|'));
  5541. foreach ($usersp as $value) {
  5542. $fgshop .= " shop = " . $value . " or";
  5543. $sid .= " id = " . $value . " or";
  5544. }
  5545. foreach ($userwh as $value) {
  5546. $wid .= " id = " . $value . " or";
  5547. $wtype .= " type = " . $value . " or";
  5548. }
  5549. }
  5550. $post = $this->input->post(NULL, TRUE);
  5551. if (isset($post['tmsku'])) {
  5552. $tmsku = $this->input->post('tmsku', true);
  5553. if (is_numeric($tmsku)) {
  5554. $yyh = $this->whlabellabel->get_label($tmsku);
  5555. } else {
  5556. $yyh = $this->whlabellabel->get_sku($tmsku);
  5557. }
  5558. if ($yyh) {
  5559. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5560. exit;
  5561. } else {
  5562. echo json_encode(array('success' => false));
  5563. exit;
  5564. }
  5565. }
  5566. $classid = $this->classid->sku();
  5567. $pm = $classid;
  5568. $scsku = $classid;
  5569. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5570. if (isset($post['warehouse'])) {
  5571. if ($post['warehouse']) {
  5572. $list = array();
  5573. $num = "";
  5574. $title = "";
  5575. $features = "";
  5576. $order = 0;
  5577. $post['shop'] = '';
  5578. $brand = $this->input->post('brand', true);
  5579. if ($brand != '0,') {
  5580. $b = $this->brand->read(rtrim($brand, ','));
  5581. if ($b) {
  5582. $post['shop'] = str_replace('|', ',', $b['shop']);
  5583. }
  5584. }
  5585. $post['details'] = $this->input->post('details', true); //打印数量
  5586. $xbqnum = $this->input->post('xbqnum', true);
  5587. $post['purchase'] = $this->input->post('purchase', true);
  5588. $post['warehouse'] = $this->input->post('warehouse', true);
  5589. $post['purchase'] = $this->input->post('purchase', true);
  5590. $post['retreatwarehouse'] = $post['warehouse'];
  5591. $post['cpbz'] = $this->input->post('cpbz', true);
  5592. $post['state'] = 9;
  5593. $category = $this->input->post('category', true);
  5594. $list['category'] = $category;
  5595. $list['hairtype'] = $this->input->post('hairtype', true);
  5596. $list['grade'] = $this->input->post('grade', true);
  5597. $size = $this->input->post('size', true);
  5598. $list['size'] = rtrim($size, ',');
  5599. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5600. $list['extension'] = $this->input->post('extension', true);
  5601. if ($category == 1297) {
  5602. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5603. }
  5604. if ($category == 1702) {
  5605. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5606. $list['syother'] = $this->input->post('syother', true);
  5607. }
  5608. if ($category == 133) {
  5609. $list['fittype'] = $this->input->post('fittype', true);
  5610. $list['acother'] = $this->input->post('acother', true);
  5611. }
  5612. $list['color'] = $this->input->post('color', true);
  5613. $list['lowe'] = $this->input->post('lowe', true);
  5614. if ($category == 127) {
  5615. $list['type'] = $this->input->post('type', true);
  5616. $list['headroad'] = $this->input->post('headroad', true);
  5617. $list['density'] = $this->input->post('density', true);
  5618. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5619. $list['lacesize'] = $this->input->post('lacesize', true);
  5620. }
  5621. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5622. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5623. }
  5624. if ($category == 128) {
  5625. $list['lacetype'] = $this->input->post('lacetype', true);
  5626. $list['haircap'] = $this->input->post('haircap', true);
  5627. $list['density'] = $this->input->post('density', true);
  5628. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5629. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5630. $list['wigother'] = $this->input->post('wigother', true);
  5631. $list['wigother1'] = $this->input->post('wigother1', true);
  5632. $list['wigother2'] = $this->input->post('wigother2', true);
  5633. }
  5634. if ($category == 129) {
  5635. $list['wide'] = $this->input->post('wide', true);
  5636. }
  5637. if ($category == 131) {
  5638. $list['gifttype'] = $this->input->post('gifttype', true);
  5639. $list['giftother'] = $this->input->post('giftother', true);
  5640. }
  5641. if ($category == 134) {
  5642. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5643. }
  5644. if ($category == 1297) {
  5645. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5646. $list['sywigother'] = $this->input->post('sywigother', true);
  5647. }
  5648. if ($category == 130 || $category == 133 || $category == 1702) {
  5649. $list['items'] = $this->input->post('items', true);
  5650. $list['weight'] = $this->input->post('weight', true);
  5651. }
  5652. if ($category == 1702) {
  5653. $list['syhairther'] = $this->input->post('syhairther', true);
  5654. }
  5655. foreach ($list as $k => $v) {
  5656. if ($v != 0) {
  5657. $num .= $v;
  5658. $features .= $v . '-';
  5659. $post[$k] = $v;
  5660. $typeclass = $this->typeclass->read($v);
  5661. if (isset($pm[$typeclass['classid']])) {
  5662. if (stripos($typeclass['zh'], '|') !== false) {
  5663. $exzh = explode('|', $typeclass['zh']);
  5664. $pm[$typeclass['classid']] = $exzh[0];
  5665. } else {
  5666. $pm[$typeclass['classid']] = $typeclass['zh'];
  5667. }
  5668. }
  5669. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5670. if ($k != 'size') {
  5671. $title .= $typeclass['title'] . " ";
  5672. }
  5673. }
  5674. }
  5675. $typeclass = $this->typeclass->read($list['size']);
  5676. $title .= $typeclass['title'];
  5677. $time = time();
  5678. $post['title'] = rtrim($title, ' ');
  5679. $post['number'] = $num;
  5680. $post['features'] = '-' . $features;
  5681. $fp = $this->whlabel->get_features($post['features']);
  5682. if (!$fp) {
  5683. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5684. exit;
  5685. }
  5686. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5687. $featurespp = explode('-', trim($featurespp, '-'));
  5688. if (isset($featurespp[5])) {
  5689. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5690. } else {
  5691. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5692. }
  5693. $post['enter'] = $time;
  5694. $post['time'] = $time; //操作时间
  5695. $scsku = implode("-", $scsku);
  5696. $zh = implode(" ", $pm);
  5697. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5698. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5699. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5700. $post['sku'] = $fp['sku'];
  5701. $post['label'] = $fp['sku'];
  5702. $cpid = $this->whlabellabel->find_count();
  5703. $post['cpid'] = $cpid + 1;
  5704. $cpid = $post['cpid'];
  5705. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5706. //if($whlabelbarcode)
  5707. //{
  5708. //$post['label'] = $whlabelbarcode['label'];
  5709. //if(!$this->whlabellabel->insert($post))
  5710. //{
  5711. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5712. //}
  5713. //}
  5714. //else
  5715. //{
  5716. $this->db->trans_begin();
  5717. $this->whlabellabel->insert($post);
  5718. //$this->whlabelbarcode->insert($post);
  5719. if ($this->db->trans_status() === TRUE) {
  5720. $this->db->trans_commit();
  5721. } else {
  5722. $this->db->trans_rollback();
  5723. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5724. exit;
  5725. }
  5726. //}
  5727. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5728. $purchase = $this->purchase->read($post['purchase']);
  5729. 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));
  5730. exit; //特殊仓目前不需要仓库选项
  5731. }
  5732. }
  5733. if (isset($_SESSION['api'])) {
  5734. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5735. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5736. $this->data['wlshop'] = $wlshop;
  5737. $this->data['warehouse'] = $warehouse;
  5738. }
  5739. $whlabelwz = $this->whlabelwz->find_all();
  5740. $this->data['whlabelwz'] = $whlabelwz;
  5741. $this->_Template('whlabel_usaprint', $this->data);
  5742. }
  5743. public function _printrk($arg_array)
  5744. {
  5745. $prc = array();
  5746. $purchase = $this->purchase->find_all();
  5747. foreach ($purchase as $k => $v) {
  5748. $prc[$v['id']] = $v['title'];
  5749. }
  5750. $post = $this->input->post(NULL, TRUE);
  5751. if (isset($post['page'])) {
  5752. $page = $this->input->post('page', true);
  5753. $perpage = $this->input->post('perpage', true);
  5754. $sku = $this->input->post('sku', true);
  5755. $bs = $this->input->post('bs', true);
  5756. $number = $this->input->post('number', true);
  5757. $warehouse = $this->input->post('warehouse', true);
  5758. $purchase = $this->input->post('purchase', true);
  5759. $orderinfo = $this->input->post('orderinfo', true);
  5760. $waybill = $this->input->post('waybill', true);
  5761. $category = $this->input->post('category', true);
  5762. $size = $this->input->post('size', true);
  5763. $grade = $this->input->post('grade', true);
  5764. $color = $this->input->post('color', true);
  5765. $lowe = $this->input->post('lowe', true);
  5766. $state = $this->input->post('state', true);
  5767. $label = $this->input->post('label', true);
  5768. $timetk = $this->input->post('ktime', true);
  5769. $timetj = $this->input->post('jtime', true);
  5770. $timetk = strtotime($timetk);
  5771. $timetj = strtotime($timetj);
  5772. $where = "1=1 ";
  5773. if ($timetk && $timetj) {
  5774. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5775. }
  5776. if ($sku) {
  5777. $where .= " and sku = '$sku'";
  5778. }
  5779. if ($bs != '') {
  5780. $where .= " and bs = '$bs'";
  5781. }
  5782. if ($number) {
  5783. $where .= " and number = '$number'";
  5784. }
  5785. if ($warehouse) {
  5786. $where .= " and warehouse = '$warehouse'";
  5787. }
  5788. if ($purchase) {
  5789. $where .= " and purchase = '$purchase'";
  5790. }
  5791. if ($orderinfo) {
  5792. $where .= " and orderinfo = '$orderinfo'";
  5793. }
  5794. if ($waybill) {
  5795. $where .= " and waybill = '$waybill'";
  5796. }
  5797. if ($category) {
  5798. $where .= " and features like '%-$category-%'";
  5799. }
  5800. if ($size) {
  5801. $where .= " and features like '%-$size-%'";
  5802. }
  5803. if ($grade) {
  5804. $where .= " and features like '%-$grade-%'";
  5805. }
  5806. if ($color) {
  5807. $where .= " and features like '%-$color-%'";
  5808. }
  5809. if ($lowe) {
  5810. $where .= " and features like '%-$lowe-%'";
  5811. }
  5812. if ($label) {
  5813. $where .= " and label = '$label'";
  5814. }
  5815. if ($state || $state == 0) {
  5816. $where .= " and state = '$state'";
  5817. }
  5818. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5819. //数据排序
  5820. $order_str = "enter desc";
  5821. if (empty($page)) {
  5822. $start = 0;
  5823. $perpage = 1;
  5824. } else {
  5825. $start = ($page - 1) * $perpage;
  5826. }
  5827. //取得信息列表
  5828. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5829. foreach ($info_list as $key => $value) {
  5830. $warehouse = $this->warehouse->read($value['warehouse']);
  5831. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5832. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5833. if ($value['state'] == 0) {
  5834. $info_list[$key]['state'] = "在库";
  5835. } else if ($value['state'] == 1) {
  5836. $info_list[$key]['state'] = "出库";
  5837. } else if ($value['state'] == 2) {
  5838. $info_list[$key]['state'] = "退库";
  5839. } else if ($value['state'] == 3) {
  5840. $info_list[$key]['state'] = "调拨中";
  5841. } else if ($value['state'] == 4) {
  5842. $info_list[$key]['state'] = "再加工";
  5843. } else if ($value['state'] == 5) {
  5844. $info_list[$key]['state'] = "维修中";
  5845. } else if ($value['state'] == 6) {
  5846. $info_list[$key]['state'] = "盘亏";
  5847. } else if ($value['state'] == 7) {
  5848. $info_list[$key]['state'] = "更换标签";
  5849. } else if ($value['state'] == 8) {
  5850. $info_list[$key]['state'] = "其它";
  5851. } else if ($value['state'] == 9) {
  5852. $info_list[$key]['state'] = "预设";
  5853. } else if ($value['state'] == 10) {
  5854. $info_list[$key]['state'] = "美店零售";
  5855. }
  5856. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5857. }
  5858. $total = $this->$ck->find_count($where);
  5859. $pagenum = ceil($total / $perpage);
  5860. $over = $total - ($start + $perpage);
  5861. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5862. echo json_encode($rows);
  5863. exit;
  5864. }
  5865. if (isset($post['tmsku'])) {
  5866. $time = time();
  5867. $tmsku = $this->input->post('tmsku', true);
  5868. //$post['shop'] = $this->input->post('shop',true);
  5869. $num = $this->input->post('num', true);
  5870. $rktype = $this->input->post('rktype', true);
  5871. if ($num > 200) {
  5872. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5873. exit;
  5874. }
  5875. if (!$rktype) {
  5876. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5877. }
  5878. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5879. /**
  5880. $wz = array();
  5881. foreach ($rk as $key=>$value)
  5882. {
  5883. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5884. }
  5885. if(count($wz) > 1)
  5886. {
  5887. $wz = array_values($wz);
  5888. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  5889. }
  5890. **/
  5891. if (isset($rk[0]['purchase'])) {
  5892. $rk = $rk[0];
  5893. $j = 0;
  5894. $post['purchase'] = $rk['purchase'];
  5895. $post['warehouse'] = $rk['warehouse'];
  5896. $post['retreatwarehouse'] = $rk['warehouse'];
  5897. $post['sku'] = $rk['sku'];
  5898. $post['number'] = $rk['number'];
  5899. $post['features'] = $rk['features'];
  5900. $post['title'] = $rk['title'];
  5901. $post['enter'] = $time;
  5902. $post['time'] = $time;
  5903. $post['bs'] = 1;
  5904. $post['shop'] = $rk['shop'];
  5905. $post['details'] = $rk['details'];
  5906. $post['cpid'] = $rk['cpid'];
  5907. $post['cpbz'] = $rk['cpbz'];
  5908. //$post['rktype'] = $rktype;
  5909. $warehouse = $this->warehouse->read($rk['warehouse']);
  5910. if ($warehouse['bdck'] == '') {
  5911. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  5912. exit;
  5913. } else {
  5914. $bdck = $warehouse['bdck'];
  5915. }
  5916. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  5917. if (isset($pdwz['details'])) {
  5918. if ($pdwz['details'] != $post['details']) {
  5919. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  5920. exit;
  5921. }
  5922. }
  5923. $post['featurespp'] = $rk['featurespp'];
  5924. if ($post['warehouse'] == '5') {
  5925. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5926. if ($yza) {
  5927. if ($post['features'] != $yza[0]['features']) {
  5928. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  5929. exit;
  5930. }
  5931. }
  5932. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5933. if ($yzb) {
  5934. if ($post['sku'] != $yzb[0]['sku']) {
  5935. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  5936. exit;
  5937. }
  5938. }
  5939. }
  5940. for ($i = 0; $i < $num; $i++) {
  5941. $post['label'] = time() . rand(100, 999) . $i;
  5942. if ($this->$bdck->insert($post)) {
  5943. $j++;
  5944. }
  5945. }
  5946. /**
  5947. if($post['warehouse'] != 12)
  5948. {
  5949. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5950. }
  5951. **/
  5952. if ($j == $num) {
  5953. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  5954. exit;
  5955. } else {
  5956. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  5957. exit;
  5958. }
  5959. } else {
  5960. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  5961. exit;
  5962. }
  5963. }
  5964. $this->_Template('whlabel_printrk', $this->data);
  5965. }
  5966. public function _printxzrk($arg_array)
  5967. {
  5968. $post = $this->input->post(NULL, TRUE);
  5969. if (isset($post['wzid'])) {
  5970. $time = time();
  5971. $id = $this->input->post('wzid', true);
  5972. //$post['shop'] = $this->input->post('shop',true);
  5973. $num = 1;
  5974. $rk = $this->whlabellabel->read($id);
  5975. if (isset($rk['purchase'])) {
  5976. $x = 0;
  5977. $post['purchase'] = $rk['purchase'];
  5978. $post['warehouse'] = $rk['warehouse'];
  5979. $post['retreatwarehouse'] = $rk['warehouse'];
  5980. $post['sku'] = $rk['sku'];
  5981. $post['number'] = $rk['number'];
  5982. $post['features'] = $rk['features'];
  5983. $post['title'] = $rk['title'];
  5984. $post['enter'] = $time;
  5985. $post['time'] = $time;
  5986. $post['bs'] = 1;
  5987. $post['shop'] = $rk['shop'];
  5988. $post['details'] = $rk['details'];
  5989. $post['cpid'] = $rk['cpid'];
  5990. $post['cpbz'] = $rk['cpbz'];
  5991. $warehouse = $this->warehouse->read($rk['warehouse']);
  5992. if ($warehouse['bdck'] == '') {
  5993. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  5994. exit;
  5995. } else {
  5996. $bdck = $warehouse['bdck'];
  5997. }
  5998. $post['featurespp'] = $rk['featurespp'];
  5999. $this->db->trans_begin();
  6000. for ($i = 0; $i < $num; $i++) {
  6001. $post['label'] = time() . rand(100, 999) . $i;
  6002. $this->$bdck->insert($post);
  6003. }
  6004. /**
  6005. if($post['warehouse'] != 12)
  6006. {
  6007. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6008. }
  6009. **/
  6010. if ($this->db->trans_status() === TRUE) {
  6011. $this->db->trans_commit();
  6012. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6013. exit;
  6014. } else {
  6015. $this->db->trans_rollback();
  6016. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6017. exit;
  6018. }
  6019. } else {
  6020. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6021. exit;
  6022. }
  6023. }
  6024. }
  6025. public function _printck($arg_array)
  6026. {
  6027. $prc = array();
  6028. $purchase = $this->purchase->find_all();
  6029. foreach ($purchase as $k => $v) {
  6030. $prc[$v['id']] = $v['title'];
  6031. }
  6032. $post = $this->input->post(NULL, TRUE);
  6033. if (isset($post['page'])) {
  6034. $page = $this->input->post('page', true);
  6035. $perpage = $this->input->post('perpage', true);
  6036. $sku = $this->input->post('sku', true);
  6037. $bs = $this->input->post('bs', true);
  6038. $number = $this->input->post('number', true);
  6039. $warehouse = $this->input->post('warehouse', true);
  6040. $purchase = $this->input->post('purchase', true);
  6041. $orderinfo = $this->input->post('orderinfo', true);
  6042. $waybill = $this->input->post('waybill', true);
  6043. $category = $this->input->post('category', true);
  6044. $size = $this->input->post('size', true);
  6045. $grade = $this->input->post('grade', true);
  6046. $color = $this->input->post('color', true);
  6047. $lowe = $this->input->post('lowe', true);
  6048. $state = $this->input->post('state', true);
  6049. $label = $this->input->post('label', true);
  6050. $timetk = $this->input->post('ktime', true);
  6051. $timetj = $this->input->post('jtime', true);
  6052. $timetk = strtotime($timetk);
  6053. $timetj = strtotime($timetj);
  6054. $where = "state=1 ";
  6055. if ($timetk && $timetj) {
  6056. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6057. }
  6058. if ($sku) {
  6059. $where .= " and sku = '$sku'";
  6060. }
  6061. if ($bs != '') {
  6062. $where .= " and bs = '$bs'";
  6063. }
  6064. if ($number) {
  6065. $where .= " and number = '$number'";
  6066. }
  6067. if ($warehouse) {
  6068. $where .= " and warehouse = '$warehouse'";
  6069. }
  6070. if ($purchase) {
  6071. $where .= " and purchase = '$purchase'";
  6072. }
  6073. if ($orderinfo) {
  6074. $where .= " and orderinfo = '$orderinfo'";
  6075. }
  6076. if ($waybill) {
  6077. $where .= " and waybill = '$waybill'";
  6078. }
  6079. if ($category) {
  6080. $where .= " and features like '%-$category-%'";
  6081. }
  6082. if ($size) {
  6083. $where .= " and features like '%-$size-%'";
  6084. }
  6085. if ($grade) {
  6086. $where .= " and features like '%-$grade-%'";
  6087. }
  6088. if ($color) {
  6089. $where .= " and features like '%-$color-%'";
  6090. }
  6091. if ($lowe) {
  6092. $where .= " and features like '%-$lowe-%'";
  6093. }
  6094. if ($label) {
  6095. $where .= " and label = '$label'";
  6096. }
  6097. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6098. //数据排序
  6099. $order_str = "outk desc";
  6100. if (empty($page)) {
  6101. $start = 0;
  6102. $perpage = 1;
  6103. } else {
  6104. $start = ($page - 1) * $perpage;
  6105. }
  6106. //取得信息列表
  6107. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6108. foreach ($info_list as $key => $value) {
  6109. $warehouse = $this->warehouse->read($value['warehouse']);
  6110. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6111. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6112. if ($value['state'] == 0) {
  6113. $info_list[$key]['state'] = "在库";
  6114. } else if ($value['state'] == 1) {
  6115. $info_list[$key]['state'] = "出库";
  6116. } else if ($value['state'] == 2) {
  6117. $info_list[$key]['state'] = "退库";
  6118. } else if ($value['state'] == 3) {
  6119. $info_list[$key]['state'] = "调拨中";
  6120. } else if ($value['state'] == 4) {
  6121. $info_list[$key]['state'] = "再加工";
  6122. } else if ($value['state'] == 5) {
  6123. $info_list[$key]['state'] = "维修中";
  6124. } else if ($value['state'] == 6) {
  6125. $info_list[$key]['state'] = "盘亏";
  6126. } else if ($value['state'] == 7) {
  6127. $info_list[$key]['state'] = "更换标签";
  6128. } else if ($value['state'] == 8) {
  6129. $info_list[$key]['state'] = "其它";
  6130. } else if ($value['state'] == 9) {
  6131. $info_list[$key]['state'] = "预设";
  6132. } else if ($value['state'] == 10) {
  6133. $info_list[$key]['state'] = "美店零售";
  6134. }
  6135. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6136. }
  6137. $total = $this->$ck->find_count($where);
  6138. $pagenum = ceil($total / $perpage);
  6139. $over = $total - ($start + $perpage);
  6140. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6141. echo json_encode($rows);
  6142. exit;
  6143. }
  6144. if (isset($post['tmsku'])) {
  6145. $time = time();
  6146. $tmsku = $this->input->post('tmsku', true);
  6147. //$post['shop'] = $this->input->post('shop',true);
  6148. $num = $this->input->post('num', true);
  6149. $cktype = $this->input->post('cktype', true);
  6150. $label = $this->whlabellabel->get_label($tmsku);
  6151. if (!$cktype) {
  6152. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6153. }
  6154. if (!isset($label['warehouse'])) {
  6155. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6156. exit;
  6157. }
  6158. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6159. if (stripos($label['features'], '-126-') !== false) {
  6160. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6161. } else {
  6162. $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 = ''");
  6163. }
  6164. $j = 0;
  6165. if (count($ck) >= $num) {
  6166. for ($i = 0; $i < $num; $i++) {
  6167. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6168. {
  6169. $j++;
  6170. }
  6171. }
  6172. if ($j == $num) {
  6173. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6174. exit;
  6175. } else {
  6176. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6177. exit;
  6178. }
  6179. } else {
  6180. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6181. exit;
  6182. }
  6183. }
  6184. if(isset($_SESSION['api']))
  6185. {
  6186. $user = $this->user->get_api($_SESSION['api']);
  6187. if(in_array($user['power'],[1,27])){
  6188. $vip = 1;
  6189. }
  6190. }
  6191. else
  6192. {
  6193. $vip = 0;
  6194. header('Location: /');exit;
  6195. }
  6196. $this->data['vip'] = $vip;
  6197. $this->_Template('whlabel_printck', $this->data);
  6198. }
  6199. public function _printexcel()
  6200. {
  6201. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6202. $config['upload_path'] = '.' . $dir;
  6203. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6204. $config['allowed_types'] = 'xls|xlsx|csv';
  6205. $config['max_size'] = 10240;
  6206. $this->load->library('upload', $config);
  6207. $this->upload->initialize($config);
  6208. if ($this->upload->do_upload('userfile')) {
  6209. $full_path = $dir . $this->upload->data('file_name');
  6210. $fileName = '.' . $full_path;
  6211. if (!file_exists($fileName)) {
  6212. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6213. exit;
  6214. } else {
  6215. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6216. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6217. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6218. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6219. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6220. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6221. ++$column; //如果列数大于26行
  6222. $list = array();
  6223. for ($i = 2; $i <= $row; $i++) // 行数循环
  6224. {
  6225. $data = array();
  6226. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6227. {
  6228. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6229. }
  6230. $list[] = $data;
  6231. }
  6232. }
  6233. $ed = array();
  6234. $i = 0;
  6235. $j = 0;
  6236. $dcdata = array();
  6237. $yc = '';
  6238. $cmf_arr = array_column($list, '1');
  6239. array_multisort($cmf_arr, SORT_ASC, $list);
  6240. foreach ($list as $key => $value) {
  6241. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6242. if ($typeclass) {
  6243. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6244. } else {
  6245. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6246. $i++;
  6247. continue;
  6248. }
  6249. }
  6250. if ($i > 0) {
  6251. $yc = $i . '条异常';
  6252. }
  6253. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6254. exit;
  6255. }
  6256. }
  6257. public function _uck()
  6258. {
  6259. if (isset($_GET['excel'])) {
  6260. $tc = array();
  6261. $typeclass = $this->typeclass->find_all();
  6262. foreach ($typeclass as $v) {
  6263. $tc[$v['id']] = $v['zh'];
  6264. }
  6265. $data = array();
  6266. $t = array();
  6267. $rq = '';
  6268. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6269. $ts = $ts / (24 * 3600);
  6270. for ($i = 0; $i < $ts; $i++) {
  6271. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6272. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6273. }
  6274. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6275. foreach ($info_list as $k => $v) {
  6276. $features = explode('-', trim($v['features'], '-'));
  6277. if (!isset($features[3]) || !isset($features[4])) {
  6278. continue;
  6279. }
  6280. $data[$k][0] = $tc[$features[0]]; //类型
  6281. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6282. $data[$k][2] = $tc[$features[4]]; //曲度
  6283. $data[$k][3] = '';
  6284. if (isset($data[$k][1])) {
  6285. $data[$k][3] .= $data[$k][1];
  6286. }
  6287. if (isset($data[$k][2])) {
  6288. $data[$k][3] .= $data[$k][2];
  6289. }
  6290. if (isset($features[5])) {
  6291. $data[$k][3] .= $tc[$features[5]];
  6292. }
  6293. if (isset($features[2])) {
  6294. $data[$k][3] .= $tc[$features[2]];
  6295. }
  6296. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6297. $data[$k][4] = $v['sku'];
  6298. $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())) . '))'); //月初库存
  6299. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6300. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6301. $ztrq = '';
  6302. $ztsl = '';
  6303. if (count($zt) > 0) {
  6304. foreach ($zt as $vv) {
  6305. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6306. $ztsl .= $vv['num'] . '<br>';
  6307. }
  6308. }
  6309. $data[$k][] = trim($ztsl, '<br>');
  6310. $data[$k][] = trim($ztrq, '<br>');
  6311. $byck = 0;
  6312. foreach ($t as $vv) {
  6313. $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));
  6314. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6315. $byck += $sl;
  6316. }
  6317. $data[$k][] = ($byck > 0) ? $byck : '';
  6318. }
  6319. $title = "详情 " . date("Y-m-d", time());
  6320. $titlename = "<table border=1>
  6321. <tr align='center'>
  6322. <td>类别</td>
  6323. <td>颜色</td>
  6324. <td>曲度</td>
  6325. <td>名称</td>
  6326. <td>SKU</td>
  6327. <td>月初库存</td>
  6328. <td>剩余库存</td>
  6329. <td>在途数量</td>
  6330. <td>预达日期</td>" .
  6331. $rq
  6332. . "<td>本月出库</td></tr>
  6333. </table>";
  6334. $filename = $title . ".xls";
  6335. $tail = "";
  6336. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6337. }
  6338. }
  6339. public function _whlabelexcelzh()
  6340. {
  6341. if (isset($_GET['excel'])) {
  6342. $where = "sku != 'Preset'";
  6343. //数据排序
  6344. $order_str = "id desc";
  6345. if (empty($page)) {
  6346. $start = 0;
  6347. $perpage = 1;
  6348. } else {
  6349. $start = ($page - 1) * $perpage;
  6350. }
  6351. $category = $this->input->get('category', true);
  6352. $warehouse = $this->input->get('warehouse', true);
  6353. $excelid = $this->input->get('sid', true);
  6354. if ($category) {
  6355. $where .= " and features like '%-$category-%'";
  6356. }
  6357. if ($warehouse) {
  6358. $where .= " and warehouse = '$warehouse'";
  6359. }
  6360. $xzid = '';
  6361. if ($excelid) {
  6362. $excelid = explode(',', trim($excelid, ','));
  6363. foreach ($excelid as $key => $value) {
  6364. $xzid .= " id = " . $value . " or";
  6365. }
  6366. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6367. }
  6368. //取得信息列表
  6369. /**
  6370. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6371. $rows = array();$list = array();
  6372. foreach ($info_list as $key=>$value)
  6373. {
  6374. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6375. }
  6376. **/
  6377. $list = array();
  6378. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6379. foreach ($rows as $key => $value) {
  6380. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6381. $zh = '';
  6382. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6383. foreach ($zt as $v) {
  6384. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6385. }
  6386. $zt = array_sum(array_column($zt, 'num'));
  6387. $number = $value['number'];
  6388. $ftime = time() - 15 * 24 * 3600;
  6389. $warehouse = $this->warehouse->read($value['warehouse']);
  6390. $rows[$key]['warehouse'] = $warehouse['title'];
  6391. $rows[$key]['number'] = $c;
  6392. $rows[$key]['features'] = $zh;
  6393. $rows[$key]['hb'] = $c + $zt;
  6394. }
  6395. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6396. $titlename = "<table border=1>
  6397. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6398. <tr align='center'>
  6399. <td>仓库</td>
  6400. <td>SKU</td>
  6401. <td>产品</td>
  6402. <td>库存数量</td>
  6403. <td>在途数量及预达日期</td>
  6404. <td>在途+库存数量</td>
  6405. </tr>
  6406. </table>";
  6407. $filename = $title . ".xls";
  6408. $tail = "";
  6409. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6410. }
  6411. if (isset($_GET['excel'])) {
  6412. $warehouse = $this->input->get('warehouse', true);
  6413. $sku = $this->input->get('sku', true);
  6414. $cz = $this->input->get('cz', true);
  6415. $text = $this->input->post('text', true);
  6416. $xztime = $this->input->get('xztime', true);
  6417. $timetk = $this->input->get('timetk', true);
  6418. $timetj = $this->input->get('timetj', true);
  6419. $timetk = strtotime($timetk);
  6420. $timetj = strtotime($timetj);
  6421. $where = "time = '0' ";
  6422. if ($warehouse) {
  6423. $where .= " and warehouse = '$warehouse'";
  6424. }
  6425. if ($sku) {
  6426. $where .= " and sku = '$sku'";
  6427. }
  6428. if ($text) {
  6429. $where .= " and text like '%$text%'";
  6430. }
  6431. if ($cz != '') {
  6432. $where .= " and cz = '$cz'";
  6433. }
  6434. if ($timetk && $timetj) {
  6435. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6436. }
  6437. //数据排序
  6438. $order_str = $xztime . " desc";
  6439. //取得信息列表
  6440. $zh = array();
  6441. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6442. foreach ($info_list as $v) {
  6443. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6444. $warehouse = $this->warehouse->read($v['warehouse']);
  6445. $v['warehouse'] = $warehouse['title'];
  6446. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6447. $v['stime'] = date('Y-m-d', $v['stime']);
  6448. if (isset($zh[$v['features']])) {
  6449. $zh[$v['features']]['num'] += $v['num'];
  6450. } else {
  6451. $zh[$v['features']] = $v;
  6452. }
  6453. $zh[$v['features']]['features'] = $c;
  6454. }
  6455. $title = "在途数据" . date('Y-m-d', time());
  6456. $titlename = "<table border=1>
  6457. <tr align='center'>
  6458. <td>仓库</td>
  6459. <td>SKU</td>
  6460. <td>名称</td>
  6461. <td>在途数量</td>
  6462. <td>库存数量</td>
  6463. <td>添加在途日期</td>
  6464. <td>预达日期</td>
  6465. <td>备注</td>
  6466. </tr>
  6467. </table>";
  6468. $filename = $title . ".xls";
  6469. $tail = "";
  6470. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6471. }
  6472. }
  6473. public function _fc()
  6474. {
  6475. $vip = 0;
  6476. if (isset($_SESSION['api'])) {
  6477. $user = $this->user->get_api($_SESSION['api']);
  6478. if ($user['vip'] == 1) {
  6479. $vip = 1;
  6480. }
  6481. } else {
  6482. header('Location: /');
  6483. exit;
  6484. }
  6485. $post = $this->input->post(NULL, TRUE);
  6486. if (isset($post['page'])) {
  6487. $page = $this->input->post('page', true);
  6488. $perpage = $this->input->post('perpage', true);
  6489. $category = $this->input->post('category', true);
  6490. $size = $this->input->post('size', true);
  6491. $grade = $this->input->post('grade', true);
  6492. $color = $this->input->post('color', true);
  6493. $lowe = $this->input->post('lowe', true);
  6494. $sku = $this->input->post('sku');
  6495. $title = $this->input->post('title');
  6496. $warehouse = $this->input->post('warehouse', true);
  6497. $usa = $this->input->post('usa', true);
  6498. $purchase = $this->input->post('purchase', true);
  6499. $lacetype = $this->input->post('lacetype', true);
  6500. $haircap = $this->input->post('haircap', true);
  6501. $density = $this->input->post('density', true);
  6502. $details = $this->input->post('details', true);
  6503. $state = $this->input->post('state', true);
  6504. $ktime = $this->input->post('ktime', true);
  6505. $jtime = $this->input->post('jtime', true);
  6506. $ktime = strtotime($ktime);
  6507. $jtime = strtotime($jtime);
  6508. $where = "state = '11'";
  6509. $gj = "";
  6510. $ck = "";
  6511. if ($lacetype) {
  6512. $where .= " and features like '%-$lacetype-%'";
  6513. }
  6514. if ($category) {
  6515. $where .= " and features like '%-$category-%'";
  6516. }
  6517. if ($size) {
  6518. $where .= " and features like '%-$size-%'";
  6519. }
  6520. if ($grade) {
  6521. $where .= " and features like '%-$grade-%'";
  6522. }
  6523. if ($color) {
  6524. $where .= " and features like '%-$color-%'";
  6525. }
  6526. if ($lowe) {
  6527. $where .= " and features like '%-$lowe-%'";
  6528. }
  6529. if ($haircap) {
  6530. $where .= " and features like '%-$haircap-%'";
  6531. }
  6532. if ($density) {
  6533. $where .= " and features like '%-$density-%'";
  6534. }
  6535. if ($usa) {
  6536. if (!$warehouse) {
  6537. $where .= " and (warehouse = '5' or warehouse = '8')";
  6538. }
  6539. }
  6540. if ($warehouse) {
  6541. $where .= " and warehouse = '$warehouse'";
  6542. }
  6543. if ($details) {
  6544. $where .= " and details = '$details'";
  6545. }
  6546. if ($purchase) {
  6547. $where .= " and purchase = '$purchase'";
  6548. }
  6549. if ($state) {
  6550. $where .= " and state = '$state'";
  6551. }
  6552. if ($ktime && $jtime) {
  6553. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6554. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6555. }
  6556. //数据排序
  6557. $order_str = "id desc";
  6558. if (empty($page)) {
  6559. $start = 0;
  6560. $perpage = 1;
  6561. } else {
  6562. $start = ($page - 1) * $perpage;
  6563. }
  6564. if ($sku) {
  6565. $sku = trim($sku, ' ');
  6566. $sku = trim($sku, ' ');
  6567. $where .= " and sku like '%$sku%'";
  6568. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6569. } else if ($title) {
  6570. $title = trim($title, ' ');
  6571. $title = trim($title, ' ');
  6572. $where .= " and title like '%$title%'";
  6573. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6574. } else {
  6575. //$where .= " and time > '$ktime' and time < '$jtime'";
  6576. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6577. }
  6578. //取得信息列表
  6579. $rows = array();
  6580. $list = array();
  6581. foreach ($info_list as $key => $value) {
  6582. $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'] . '"');
  6583. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6584. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6585. $warehouse = $this->warehouse->read($value['warehouse']);
  6586. $info_list[$key]['warehouse'] = $warehouse['title'];
  6587. $info_list[$key]['number'] = $g;
  6588. $info_list[$key]['features'] = $x;
  6589. $info_list[$key]['x'] = $s;
  6590. }
  6591. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6592. $pagenum = ceil($total / $perpage);
  6593. $over = $total - ($start + $perpage);
  6594. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6595. echo json_encode($rows);
  6596. exit;
  6597. }
  6598. $this->data['vip'] = $vip;
  6599. $this->_Template('whlabel_fc', $this->data);
  6600. }
  6601. public function _fcmb()
  6602. {
  6603. $where = "sku != 'Preset'";
  6604. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6605. foreach ($rows as $k => $v) {
  6606. $warehouse = $this->warehouse->read($v['warehouse']);
  6607. $rows[$k]['warehouse'] = $warehouse['title'];
  6608. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6609. $rows[$k]['t'] = '';
  6610. $rows[$k]['n'] = '';
  6611. }
  6612. $title = "封货产品数据导入模板";
  6613. $titlename = "<table border=1>
  6614. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6615. <tr align='center'>
  6616. <td>仓库</td>
  6617. <td>SKU</td>
  6618. <td>产品</td>
  6619. <td>封存产品总数量</td>
  6620. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6621. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6622. </tr>
  6623. </table>";
  6624. $filename = $title . ".xls";
  6625. $tail = "";
  6626. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6627. }
  6628. public function _fcexcel()
  6629. {
  6630. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6631. $config['upload_path'] = '.' . $dir;
  6632. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6633. $config['allowed_types'] = 'xls|xlsx|csv';
  6634. $config['max_size'] = 10240;
  6635. $this->load->library('upload', $config);
  6636. $this->upload->initialize($config);
  6637. if ($this->upload->do_upload('userfile')) {
  6638. $full_path = $dir . $this->upload->data('file_name');
  6639. $fileName = '.' . $full_path;
  6640. if (!file_exists($fileName)) {
  6641. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6642. exit;
  6643. } else {
  6644. libxml_use_internal_errors(true);
  6645. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6646. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6647. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6648. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6649. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6650. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6651. ++$column; //如果列数大于26行
  6652. $list = array();
  6653. for ($i = 2; $i <= $row; $i++) // 行数循环
  6654. {
  6655. $data = array();
  6656. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6657. {
  6658. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6659. }
  6660. $list[] = $data;
  6661. }
  6662. }
  6663. $i = 0;
  6664. $j = 0;
  6665. $ed = array();
  6666. foreach ($list as $key => $value) {
  6667. $time = time();
  6668. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6669. continue;
  6670. }
  6671. $warehouse = $this->warehouse->get_title($value['0']);
  6672. $sku = $value['1'];
  6673. $type = $value['4']; //调整方式0扣减1删除
  6674. $num = $value['5']; //调整数量
  6675. //$text = $value['4'];//扣减说明
  6676. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6677. if (!$d) //如果没有这个SKU
  6678. {
  6679. $ed[] = array($sku . '-库存中不存在此SKU');
  6680. $j++;
  6681. continue;
  6682. }
  6683. if (!isset($warehouse['id'])) {
  6684. $ed[] = array($sku . '-仓库名错误!');
  6685. $j++;
  6686. continue;
  6687. }
  6688. if ($type == 1 || $type == 2) //扣减库存
  6689. {
  6690. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6691. if (count($data) < abs($num)) {
  6692. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6693. $j++;
  6694. continue;
  6695. }
  6696. if ($type == 1) //转入库存
  6697. {
  6698. for ($i = 0; $i < abs($num); $i++) {
  6699. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6700. }
  6701. } else if ($type == 2) //删除
  6702. {
  6703. for ($i = 0; $i < abs($num); $i++) {
  6704. $this->whlabel->remove($data[$i]['id']);
  6705. }
  6706. }
  6707. } else if ($type == 0) //增加库存
  6708. {
  6709. $post['sku'] = $d['sku'];
  6710. $post['shop'] = '';
  6711. $post['warehouse'] = $warehouse['id'];
  6712. $post['purchase'] = $d['purchase'];
  6713. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6714. $post['state'] = 11;
  6715. $post['title'] = $d['title'];
  6716. $post['number'] = $d['number'];
  6717. $post['features'] = $d['features'];
  6718. $post['enter'] = $time;
  6719. $post['time'] = $time; //操作时间
  6720. for ($i = 0; $i < $num; $i++) {
  6721. $post['label'] = time() . rand(100, 999) . $i;
  6722. $this->whlabel->insert($post);
  6723. }
  6724. }
  6725. sleep(1); //防止入库时间一样,需要延迟1秒
  6726. }
  6727. if ($j > 0) {
  6728. $tt = date('Ymd', time());
  6729. $title = '库存导入错误信息-' . $tt;
  6730. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6731. $tail = "\n";
  6732. $filename = $title . ".xls";
  6733. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6734. $dir = '/data/excel/' . $time . '/';
  6735. $file_name = 'error_' . $time . rand(1000, 9999);
  6736. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6737. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6738. fwrite($myfile, $ecl);
  6739. fclose($myfile);
  6740. $error = $dir . $file_name . '.xls';
  6741. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6742. exit;
  6743. } else {
  6744. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6745. exit;
  6746. }
  6747. }
  6748. }
  6749. public function _fcjxc($arg_array)
  6750. {
  6751. if (isset($_GET['excel'])) {
  6752. $category = $this->input->get('category', true);
  6753. $size = $this->input->get('size', true);
  6754. $grade = $this->input->get('grade', true);
  6755. $color = $this->input->get('color', true);
  6756. $lowe = $this->input->get('lowe', true);
  6757. $sku = $this->input->get('sku');
  6758. $title = $this->input->get('title');
  6759. $warehouse = $arg_array[0];
  6760. $usa = $this->input->get('usa', true);
  6761. $purchase = $this->input->get('purchase', true);
  6762. $lacetype = $this->input->get('lacetype', true);
  6763. $haircap = $this->input->get('haircap', true);
  6764. $density = $this->input->get('density', true);
  6765. $title = $this->input->get('title', true);
  6766. $state = $this->input->get('state', true);
  6767. $ktime = $this->input->get('ktime', true);
  6768. $jtime = $this->input->get('jtime', true);
  6769. $where = "state=11";
  6770. $gj = "";
  6771. $ck = "";
  6772. if ($lacetype) {
  6773. $where .= " and features like '%-$lacetype-%'";
  6774. }
  6775. if ($category) {
  6776. $where .= " and features like '%-$category-%'";
  6777. }
  6778. if ($size) {
  6779. $where .= " and features like '%-$size-%'";
  6780. }
  6781. if ($grade) {
  6782. $where .= " and features like '%-$grade-%'";
  6783. }
  6784. if ($color) {
  6785. $where .= " and features like '%-$color-%'";
  6786. }
  6787. if ($lowe) {
  6788. $where .= " and features like '%-$lowe-%'";
  6789. }
  6790. if ($haircap) {
  6791. $where .= " and features like '%-$haircap-%'";
  6792. }
  6793. if ($density) {
  6794. $where .= " and features like '%-$density-%'";
  6795. }
  6796. if ($usa) {
  6797. if (!$warehouse) {
  6798. $where .= " and (warehouse = '5' or warehouse = '8')";
  6799. }
  6800. }
  6801. if ($warehouse) {
  6802. $where .= " and warehouse = '$warehouse'";
  6803. }
  6804. if ($purchase) {
  6805. $where .= " and purchase = '$purchase'";
  6806. }
  6807. if ($state) {
  6808. $where .= " and state = '$state'";
  6809. }
  6810. $order_str = "id desc";
  6811. if ($sku) {
  6812. $sku = trim($sku, ' ');
  6813. $sku = trim($sku, ' ');
  6814. $where .= " and sku like '%$sku%'";
  6815. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6816. } else if ($title) {
  6817. $title = trim($title, ' ');
  6818. $title = trim($title, ' ');
  6819. $where .= " and title like '%$title%'";
  6820. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6821. } else {
  6822. //$where .= " and time > '$ktime' and time < '$jtime'";
  6823. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6824. }
  6825. //取得信息列表
  6826. $rows = array();
  6827. $list = array();
  6828. foreach ($info_list as $key => $value) {
  6829. $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'] . '"');
  6830. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6831. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6832. $rows[$key] = $value;
  6833. $warehouse = $this->warehouse->read($value['warehouse']);
  6834. $rows[$key]['warehouse'] = $warehouse['title'];
  6835. $rows[$key]['features'] = $g;
  6836. $rows[$key]['a'] = $x;
  6837. $rows[$key]['b'] = $s;
  6838. }
  6839. $title = "总统计表";
  6840. $titlename = "<table border=1>
  6841. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6842. <tr align='center'>
  6843. <td>仓库</td>
  6844. <td>SKU</td>
  6845. <td>产品名称</td>
  6846. <td>录入总量</td>
  6847. <td>取出总量</td>
  6848. <td>剩余总量</td>
  6849. </tr>
  6850. </table>";
  6851. $filename = $title . ".xls";
  6852. $tail = "";
  6853. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6854. }
  6855. $vip = 0;
  6856. if (isset($_SESSION['api'])) {
  6857. $user = $this->user->get_api($_SESSION['api']);
  6858. if ($user['vip'] == 1) {
  6859. $vip = 1;
  6860. }
  6861. } else {
  6862. header('Location: /');
  6863. exit;
  6864. }
  6865. $post = $this->input->post(NULL, TRUE);
  6866. if (isset($post['page'])) {
  6867. $page = $this->input->post('page', true);
  6868. $perpage = $this->input->post('perpage', true);
  6869. $category = $this->input->post('category', true);
  6870. $size = $this->input->post('size', true);
  6871. $grade = $this->input->post('grade', true);
  6872. $color = $this->input->post('color', true);
  6873. $lowe = $this->input->post('lowe', true);
  6874. $sku = $this->input->post('sku');
  6875. $title = $this->input->post('title');
  6876. $warehouse = $arg_array[0];
  6877. $usa = $this->input->post('usa', true);
  6878. $purchase = $this->input->post('purchase', true);
  6879. $lacetype = $this->input->post('lacetype', true);
  6880. $haircap = $this->input->post('haircap', true);
  6881. $density = $this->input->post('density', true);
  6882. $title = $this->input->post('title', true);
  6883. $state = $this->input->post('state', true);
  6884. $ktime = $this->input->post('ktime', true);
  6885. $jtime = $this->input->post('jtime', true);
  6886. $ktime = strtotime($ktime);
  6887. $jtime = strtotime($jtime);
  6888. $where = "state=11";
  6889. $gj = "";
  6890. $ck = "";
  6891. if ($lacetype) {
  6892. $where .= " and features like '%-$lacetype-%'";
  6893. }
  6894. if ($category) {
  6895. $where .= " and features like '%-$category-%'";
  6896. }
  6897. if ($size) {
  6898. $where .= " and features like '%-$size-%'";
  6899. }
  6900. if ($grade) {
  6901. $where .= " and features like '%-$grade-%'";
  6902. }
  6903. if ($color) {
  6904. $where .= " and features like '%-$color-%'";
  6905. }
  6906. if ($lowe) {
  6907. $where .= " and features like '%-$lowe-%'";
  6908. }
  6909. if ($haircap) {
  6910. $where .= " and features like '%-$haircap-%'";
  6911. }
  6912. if ($density) {
  6913. $where .= " and features like '%-$density-%'";
  6914. }
  6915. if ($usa) {
  6916. if (!$warehouse) {
  6917. $where .= " and (warehouse = '5' or warehouse = '8')";
  6918. }
  6919. }
  6920. if ($warehouse) {
  6921. $where .= " and warehouse = '$warehouse'";
  6922. }
  6923. if ($purchase) {
  6924. $where .= " and purchase = '$purchase'";
  6925. }
  6926. if ($state) {
  6927. $where .= " and state = '$state'";
  6928. }
  6929. if ($ktime && $jtime) {
  6930. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6931. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6932. }
  6933. //数据排序
  6934. $order_str = "id desc";
  6935. $xs = 0;
  6936. $rows = array();
  6937. $list = array();
  6938. if (empty($page)) {
  6939. $start = 0;
  6940. $perpage = 1;
  6941. } else {
  6942. $start = ($page - 1) * $perpage;
  6943. }
  6944. if ($sku || $title) {
  6945. if ($title) {
  6946. $title = trim($title, ' ');
  6947. $title = trim($title, ' ');
  6948. $where .= " and title like '%$title%'";
  6949. } else {
  6950. $sku = trim($sku, ' ');
  6951. $sku = trim($sku, ' ');
  6952. $where .= " and sku like '%$sku%'";
  6953. }
  6954. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6955. foreach ($info_list as $key => $value) {
  6956. $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'] . '"');
  6957. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6958. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6959. $rows[$key] = $value;
  6960. $warehouse = $this->warehouse->read($value['warehouse']);
  6961. $rows[$key]['warehouse'] = $warehouse['title'];
  6962. $rows[$key]['features'] = $g;
  6963. $rows[$key]['a'] = $x;
  6964. $rows[$key]['b'] = $s;
  6965. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6966. $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天销量
  6967. $yj = $c / ($xl / 30);
  6968. if ($yj < 7) {
  6969. $rows[$key]['y'] = round($yj) . '天销量';
  6970. } else {
  6971. $rows[$key]['y'] = '正常';
  6972. }
  6973. }
  6974. } else {
  6975. //$where .= " and time > '$ktime' and time < '$jtime'";
  6976. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6977. foreach ($info_list as $key => $value) {
  6978. $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'] . '"');
  6979. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6980. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6981. $zs[$key] = $value;
  6982. $warehouse = $this->warehouse->read($value['warehouse']);
  6983. $zs[$key]['warehouse'] = $warehouse['title'];
  6984. $zs[$key]['features'] = $g;
  6985. $zs[$key]['a'] = $x;
  6986. $zs[$key]['b'] = $s;
  6987. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6988. $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天销量
  6989. $yj = $c / ($xl / 30);
  6990. if ($yj < 7) {
  6991. $zs[$key]['y'] = round($yj) . '天销量';
  6992. $rows[$key] = $zs[$key];
  6993. }
  6994. }
  6995. }
  6996. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  6997. $pagenum = ceil($total / $perpage);
  6998. $over = $total - ($start + $perpage);
  6999. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7000. echo json_encode($rows);
  7001. exit;
  7002. }
  7003. $this->data['arg_array'] = $arg_array[0];
  7004. $this->_Template('whlabel_fcjxc', $this->data);
  7005. }
  7006. public function _0kcdel()
  7007. {
  7008. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7009. $config['upload_path'] = '.' . $dir;
  7010. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7011. $config['allowed_types'] = 'xls|xlsx|csv';
  7012. $config['max_size'] = 10240;
  7013. $this->load->library('upload', $config);
  7014. $this->upload->initialize($config);
  7015. if ($this->upload->do_upload('userfile')) {
  7016. $full_path = $dir . $this->upload->data('file_name');
  7017. $fileName = '.' . $full_path;
  7018. if (!file_exists($fileName)) {
  7019. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7020. exit;
  7021. } else {
  7022. require_once "./data/excel/PHPExcel/IOFactory.php";
  7023. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7024. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7025. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7026. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7027. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7028. ++$column; //如果列数大于26行
  7029. $list = array();
  7030. for ($i = 2; $i <= $row; $i++) // 行数循环
  7031. {
  7032. $data = array();
  7033. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7034. {
  7035. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7036. }
  7037. $list[] = $data;
  7038. }
  7039. }
  7040. $i = 0;
  7041. $j = 0;
  7042. $ed = array();
  7043. foreach ($list as $key => $value) {
  7044. $time = time();
  7045. if ($value['0'] == "" || $value['1'] == "") {
  7046. continue;
  7047. }
  7048. $warehouse = $this->warehouse->get_title($value['0']);
  7049. $sku = $value['1'];
  7050. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7051. if (!$d) //如果没有这个SKU
  7052. {
  7053. $ed[] = array($sku . '-库存中不存在此SKU');
  7054. $j++;
  7055. continue;
  7056. }
  7057. if (!isset($warehouse['id'])) {
  7058. $ed[] = array($sku . '-仓库名错误!');
  7059. $j++;
  7060. continue;
  7061. }
  7062. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7063. if ($z < 1) {
  7064. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7065. foreach ($z as $v) {
  7066. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7067. if (count($zt) > 0) {
  7068. $ed[] = array($sku . '-有在途库存无法删除!');
  7069. $j++;
  7070. continue;
  7071. }
  7072. $this->whlabel->remove($v['id']);
  7073. }
  7074. } else {
  7075. $ed[] = array($sku . '-非0库存!');
  7076. $j++;
  7077. continue;
  7078. }
  7079. }
  7080. if ($j > 0) {
  7081. $tt = date('Ymd', time());
  7082. $title = '删除0库存错误信息-' . $tt;
  7083. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7084. $tail = "\n";
  7085. $filename = $title . ".xls";
  7086. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7087. $dir = '/data/excel/' . $time . '/';
  7088. $file_name = 'error_' . $time . rand(1000, 9999);
  7089. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7090. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7091. fwrite($myfile, $ecl);
  7092. fclose($myfile);
  7093. $error = $dir . $file_name . '.xls';
  7094. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7095. exit;
  7096. } else {
  7097. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7098. exit;
  7099. }
  7100. }
  7101. }
  7102. public function _gbhtype()
  7103. {
  7104. $post = $this->input->post(NULL, TRUE);
  7105. if (isset($post['s'])) {
  7106. $n = $this->input->post('n');
  7107. $d = $this->input->post('s');
  7108. if (!$d) {
  7109. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7110. exit;
  7111. }
  7112. $d = explode(',', trim($d, ','));
  7113. $t = $this->whlabel_type->read($n);
  7114. //循环删除记录
  7115. foreach ($d as $v) {
  7116. $u = $this->whlabel->read($v);
  7117. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7118. foreach ($data as $val) {
  7119. $this->whlabel->save(array('type' => $n), $val['id']);
  7120. }
  7121. }
  7122. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7123. }
  7124. }
  7125. //出库、退库导出
  7126. public function _dccrtype()
  7127. {
  7128. $classid = $this->classid->sku();
  7129. $pm = $classid;
  7130. $typeclass = array();
  7131. $tc = $this->typeclass->find_all();
  7132. foreach ($tc as $v) {
  7133. $typeclass[$v['id']] = $v;
  7134. }
  7135. $prc = array();
  7136. $purchase = $this->purchase->find_all();
  7137. foreach ($purchase as $k => $v) {
  7138. $prc[$v['id']] = $v['title'];
  7139. }
  7140. if (isset($_GET['sid'])) {
  7141. $wh = array();
  7142. $w = $this->warehouse->find_all('1=1', 'id,title');
  7143. foreach ($w as $v) {
  7144. $wh[$v['id']] = $v['title'];
  7145. }
  7146. $type = $this->input->get('excel', true);
  7147. $category = $this->input->get('category', true);
  7148. $size = $this->input->get('size', true);
  7149. $grade = $this->input->get('grade', true);
  7150. $color = $this->input->get('color', true);
  7151. $lowe = $this->input->get('lowe', true);
  7152. $sku = $this->input->get('sku', true);
  7153. $warehouse = $this->input->get('warehouse', true);
  7154. $lacetype = $this->input->get('lacetype', true);
  7155. $lacecolor = $this->input->get('lacecolor', true);
  7156. $density = $this->input->get('density', true);
  7157. $haircap = $this->input->get('haircap', true);
  7158. $purchase = $this->input->get('purchase', true);
  7159. $title = $this->input->get('title', true);
  7160. $state = $this->input->get('state', true);
  7161. $sid = $this->input->get('sid', true);
  7162. $ktime = $this->input->get('ktime', true);
  7163. $jtime = $this->input->get('jtime', true);
  7164. $ktime = strtotime($ktime);
  7165. $jtime = strtotime($jtime);
  7166. $where = "1=1";
  7167. $gj = "";
  7168. $ck = "";
  7169. if ($category) {
  7170. $where .= " and features like '%-$category-%'";
  7171. }
  7172. if ($size) {
  7173. $where .= " and features like '%-$size-%'";
  7174. }
  7175. if ($grade) {
  7176. $where .= " and features like '%-$grade-%'";
  7177. }
  7178. if ($color) {
  7179. $where .= " and features like '%-$color-%'";
  7180. }
  7181. if ($lowe) {
  7182. $where .= " and features like '%-$lowe-%'";
  7183. }
  7184. if ($warehouse) {
  7185. $where .= " and warehouse = '$warehouse'";
  7186. }
  7187. if ($purchase) {
  7188. $where .= " and purchase = '$purchase'";
  7189. }
  7190. if ($state) {
  7191. $where .= " and state = '$state'";
  7192. }
  7193. if ($lacetype) {
  7194. $where .= " and features like '%-$lacetype-%'";
  7195. }
  7196. if ($lacecolor) {
  7197. $where .= " and features like '%-$lacecolor-%'";
  7198. }
  7199. if ($density) {
  7200. $where .= " and features like '%-$density-%'";
  7201. }
  7202. if ($haircap) {
  7203. $where .= " and features like '%-$haircap-%'";
  7204. }
  7205. if ($title) {
  7206. $title = trim($title, ' ');
  7207. $title = trim($title, ' ');
  7208. $where .= " and title like '%$title%'";
  7209. }
  7210. if ($sku) {
  7211. $sku = trim($sku, ' ');
  7212. $sku = trim($sku, ' ');
  7213. $where .= " and sku like '%$sku%'";
  7214. }
  7215. if ($ktime && $jtime) {
  7216. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7217. }
  7218. $sidwhere = '';
  7219. if ($sid) {
  7220. $sd = "";
  7221. $s = explode(',', trim($sid, ','));
  7222. foreach ($s as $value) {
  7223. $sd .= " id = " . $value . " or";
  7224. }
  7225. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7226. }
  7227. //数据排序
  7228. $order_str = "time desc";
  7229. if (empty($page)) {
  7230. $start = 0;
  7231. $perpage = 1;
  7232. } else {
  7233. $start = ($page - 1) * $perpage;
  7234. }
  7235. $wh = array();
  7236. $w = $this->warehouse->find_all('1=1', 'id,title');
  7237. foreach ($w as $v) {
  7238. $wh[$v['id']] = $v['title'];
  7239. }
  7240. $wt = array();
  7241. $whlabel_type = $this->whlabel_type->find_all();
  7242. foreach ($whlabel_type as $v) {
  7243. $wt[$v['id']] = $v['title'];
  7244. }
  7245. $classid = $this->classid->sku();
  7246. $list = array();
  7247. $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');
  7248. foreach ($rows_r as $key => $value) {
  7249. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7250. $pm = $classid;
  7251. $jm = $classid;
  7252. $rows_r[$key]['enter'] = '入库';
  7253. $rows_r[$key]['time'] = $value['enter'];
  7254. if ($value['rktype'] == 1) {
  7255. $rows_r[$key]['rktype'] = '采购入库';
  7256. } else if ($value['rktype'] == 2) {
  7257. $rows_r[$key]['rktype'] = '盘盈调整';
  7258. } else if ($value['rktype'] == 3) {
  7259. $rows_r[$key]['rktype'] = '其他调整入库';
  7260. } else if ($value['rktype'] == 4) {
  7261. $rows_r[$key]['rktype'] = '其他调整入库';
  7262. } else if ($value['rktype'] == 5) {
  7263. $rows_r[$key]['rktype'] = '退库入库';
  7264. } else if ($value['rktype'] == 6) {
  7265. $rows_r[$key]['rktype'] = '退货可用入库';
  7266. } else if ($value['rktype'] == 7) {
  7267. $rows_r[$key]['rktype'] = '形态转换入库';
  7268. } else {
  7269. $rows_r[$key]['rktype'] = '';
  7270. }
  7271. $features = explode('-', trim($value['features'], '-'));
  7272. foreach ($features as $v) {
  7273. if (isset($typeclass[$v])) {
  7274. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7275. $pm[$typeclass[$v]['classid']] = $zh[0];
  7276. }
  7277. if (isset($typeclass[$v])) {
  7278. if (isset($jm[$typeclass[$v]['classid']])) {
  7279. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7280. }
  7281. }
  7282. }
  7283. $zh = implode(" ", $pm);
  7284. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7285. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7286. $rows_r[$key]['zh'] = $zh;
  7287. $jm = array_filter($jm);
  7288. $rows_r[$key]['features'] = implode("-", $jm);
  7289. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7290. }
  7291. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  7292. foreach ($rows_c as $key => $value) {
  7293. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7294. $pm = $classid;
  7295. $jm = $classid;
  7296. $rows_c[$key]['time'] = $value['outk'];
  7297. $rows_c[$key]['outk'] = '出库';
  7298. if ($value['cktype'] == 1) {
  7299. $rows_c[$key]['cktype'] = '销售出库';
  7300. } else if ($value['cktype'] == 2) {
  7301. $rows_c[$key]['cktype'] = '销售美国出库';
  7302. } else if ($value['cktype'] == 3) {
  7303. $rows_c[$key]['cktype'] = '盘亏调整';
  7304. } else if ($value['cktype'] == 4) {
  7305. $rows_c[$key]['cktype'] = '其他调整出库';
  7306. } else if ($value['cktype'] == 5) {
  7307. $rows_c[$key]['cktype'] = '形态转换出库';
  7308. } else {
  7309. $rows_c[$key]['cktype'] = '';
  7310. }
  7311. $features = explode('-', trim($value['features'], '-'));
  7312. foreach ($features as $v) {
  7313. if (isset($typeclass[$v])) {
  7314. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7315. $pm[$typeclass[$v]['classid']] = $zh[0];
  7316. }
  7317. if (isset($typeclass[$v])) {
  7318. if (isset($jm[$typeclass[$v]['classid']])) {
  7319. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7320. }
  7321. }
  7322. }
  7323. $zh = implode(" ", $pm);
  7324. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7325. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7326. $rows_c[$key]['zh'] = $zh;
  7327. $jm = array_filter($jm);
  7328. $rows_c[$key]['features'] = implode("-", $jm);
  7329. $rows_c[$key]['number'] = 1;
  7330. }
  7331. $merged = $rows_r;
  7332. foreach ($rows_c as $key => $value) {
  7333. if (isset($merged[$key])) {
  7334. $merged[] = $value;
  7335. } else {
  7336. $merged[$key] = $value;
  7337. }
  7338. }
  7339. usort($merged, function ($a, $b) {
  7340. return $a['time'] - $b['time'];
  7341. });
  7342. foreach ($merged as $key => $value) {
  7343. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7344. }
  7345. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7346. $titlename = "<table border=1>
  7347. <tr align='center'>
  7348. <td>仓库</td>
  7349. <td>SKU</td>
  7350. <td>商品名称</td>
  7351. <td>仓库品名</td>
  7352. <td>料号</td>
  7353. <td>时间</td>
  7354. <td>操作</td>
  7355. <td>类型</td>
  7356. <td>数量</td>
  7357. <td>备注</td>
  7358. </tr>
  7359. </table>";
  7360. $filename = $title . ".xlsx";
  7361. $tail = "";
  7362. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7363. }
  7364. }
  7365. }