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. $sm = $this->input->post('sm', true);
  466. $cpbz = $this->input->post('cpbz', true);
  467. $type = $this->input->post('type', true);
  468. $ktime = strtotime($ktime);
  469. $jtime = strtotime($jtime);
  470. $where = "1=1";
  471. $gj = "";
  472. $ck = "";
  473. if ($usa) {
  474. if (!$warehouse) {
  475. $where .= " and (warehouse = '5' or warehouse = '8')";
  476. }
  477. }
  478. if ($warehouse) {
  479. $where .= " and warehouse = '$warehouse'";
  480. }
  481. if ($details) {
  482. $where .= " and details = '$details'";
  483. }
  484. if ($purchase) {
  485. $where .= " and purchase = '$purchase'";
  486. }
  487. if ($state) {
  488. $where .= " and state = '$state'";
  489. }
  490. if ($lacetype) {
  491. $where .= " and features like '%-$lacetype-%'";
  492. }
  493. if ($category) {
  494. $where .= " and features like '%-$category-%'";
  495. }
  496. if ($size) {
  497. $where .= " and features like '%-$size-%'";
  498. }
  499. if ($grade) {
  500. $where .= " and features like '%-$grade-%'";
  501. }
  502. if ($color) {
  503. $where .= " and features like '%-$color-%'";
  504. }
  505. if ($lowe) {
  506. $where .= " and features like '%-$lowe-%'";
  507. }
  508. if ($haircap) {
  509. $where .= " and features like '%-$haircap-%'";
  510. }
  511. if ($density) {
  512. $where .= " and features like '%-$density-%'";
  513. }
  514. if ($lacecolor) {
  515. $where .= " and features like '%-$lacecolor-%'";
  516. }
  517. if($sm){
  518. $where .= " and sm like '%".$sm."%'";
  519. }
  520. if($cpbz){
  521. $where .= " and cpbz like '%".$cpbz."%'";
  522. }
  523. if($type){
  524. $where .= " and type = ".$type."";
  525. }
  526. if (!empty($hairnumber)) {
  527. $where .= " and features like '%-128-%' ";
  528. if ($hairnumber < 0) {
  529. $class_list = $this->typeclass->find_all('classid = 43');
  530. foreach ($class_list as $v) {
  531. $where .= " and features not like '%-" . $v['id'] . "-%'";
  532. }
  533. } else {
  534. $where .= " and features like '%-$hairnumber-%'";
  535. }
  536. }
  537. $where_add = '';
  538. if ($cklx) {
  539. $shop = $this->shop->read($cklx);
  540. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  541. }
  542. if ($ktime && $jtime) {
  543. $gj = " and enter > '$ktime' and enter < '$jtime'";
  544. $ck = " and outk > '$ktime' and outk < '$jtime'";
  545. }
  546. //数据排序
  547. $order_str = "id desc";
  548. if (empty($page)) {
  549. $start = 0;
  550. $perpage = 1;
  551. } else {
  552. $start = ($page - 1) * $perpage;
  553. }
  554. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  555. if ($sku) {
  556. $sku = trim($sku, ' ');
  557. $sku = trim($sku, ' ');
  558. $where .= " and sku like '%$sku%'";
  559. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  560. } else if ($title) {
  561. $title = trim($title, ' ');
  562. $title = trim($title, ' ');
  563. $where .= " and title like '%$title%'";
  564. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  565. } else {
  566. //$where .= " and time > '$ktime' and time < '$jtime'";
  567. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  568. }
  569. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  570. foreach ($info_list as $k => $v) {
  571. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  572. unset($info_list[$k]['pm']);
  573. unset($info_list[$k]['jm']);
  574. unset($info_list[$k]['bm']);
  575. }
  576. //取得信息列表
  577. $rows = array();
  578. $list = array();
  579. foreach ($info_list as $key => $value) {
  580. $warehouse = $this->warehouse->read($value['warehouse']);
  581. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  582. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  583. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  584. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  585. $info_list[$key]['label'] = $value['sm'];
  586. $number = $value['number'];
  587. $ftime = time() - 15 * 24 * 3600;
  588. $info_list[$key]['warehouse'] = $warehouse['title'];
  589. $info_list[$key]['features'] = count($c);
  590. $z = count($z); //查看订单号
  591. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  592. $ztdata = '';
  593. if (count($zt) > 0) {
  594. foreach ($zt as $vv) {
  595. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  596. }
  597. }
  598. $info_list[$key]['number'] = $ztdata;
  599. $info_list[$key]['sm'] = $z;
  600. $details = array();
  601. $cpid = array();
  602. foreach ($c as $k => $v) {
  603. $details[$v['details']] = $v['details'];
  604. if ($v['cpid'] != 0) {
  605. $cpid[$v['cpid']] = $v['cpid'];
  606. }
  607. }
  608. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  609. if ($value['shop'] != '') {
  610. $shop = explode(',', trim($value['shop'], ','));
  611. $shop = $this->shop->read($shop[0]);
  612. $info_list[$key]['shop'] = $shop['shopname'];
  613. }
  614. }
  615. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  616. $pagenum = ceil($total / $perpage);
  617. $over = $total - ($start + $perpage);
  618. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  619. echo json_encode($rows);
  620. exit;
  621. }
  622. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  623. $this->_Template('whlabel_typedy', $this->data);
  624. }
  625. //进销存浏览
  626. public function _typedy_ck($arg_array)
  627. {
  628. $prc = array();
  629. $purchase = $this->purchase->find_all();
  630. foreach ($purchase as $k => $v) {
  631. $prc[$v['id']] = $v['title'];
  632. }
  633. $post = $this->input->post(NULL, TRUE);
  634. if (isset($post['page'])) {
  635. $page = $this->input->post('page', true);
  636. $perpage = $this->input->post('perpage', true);
  637. $category = $this->input->post('category', true);
  638. $size = $this->input->post('size', true);
  639. $grade = $this->input->post('grade', true);
  640. $color = $this->input->post('color', true);
  641. $lowe = $this->input->post('lowe', true);
  642. $sku = $this->input->post('sku');
  643. $title = $this->input->post('title');
  644. $warehouse = $this->input->post('warehouse', true);
  645. $usa = $this->input->post('usa', true);
  646. $purchase = $this->input->post('purchase', true);
  647. $lacetype = $this->input->post('lacetype', true);
  648. $haircap = $this->input->post('haircap', true);
  649. $density = $this->input->post('density', true);
  650. $details = $this->input->post('details', true);
  651. $state = $this->input->post('state', true);
  652. $lacecolor = $this->input->post('lacecolor', true);
  653. $cklx = $this->input->post('cklx', true);
  654. $ktime = $this->input->post('ktime', true);
  655. $jtime = $this->input->post('jtime', true);
  656. $ktime = strtotime($ktime);
  657. $jtime = strtotime($jtime);
  658. $where = "1=1";
  659. $gj = "";
  660. $ck = "";
  661. if ($lacetype) {
  662. $where .= " and features like '%-$lacetype-%'";
  663. }
  664. if ($category) {
  665. $where .= " and features like '%-$category-%'";
  666. }
  667. if ($size) {
  668. $where .= " and features like '%-$size-%'";
  669. }
  670. if ($grade) {
  671. $where .= " and features like '%-$grade-%'";
  672. }
  673. if ($color) {
  674. $where .= " and features like '%-$color-%'";
  675. }
  676. if ($lowe) {
  677. $where .= " and features like '%-$lowe-%'";
  678. }
  679. if ($haircap) {
  680. $where .= " and features like '%-$haircap-%'";
  681. }
  682. if ($density) {
  683. $where .= " and features like '%-$density-%'";
  684. }
  685. if ($lacecolor) {
  686. $where .= " and features like '%-$lacecolor-%'";
  687. }
  688. if ($usa) {
  689. if (!$warehouse) {
  690. $where .= " and (warehouse = '5' or warehouse = '8')";
  691. }
  692. }
  693. if ($warehouse) {
  694. $where .= " and warehouse = '$warehouse'";
  695. }
  696. if ($details) {
  697. $where .= " and details = '$details'";
  698. }
  699. if ($purchase) {
  700. $where .= " and purchase = '$purchase'";
  701. }
  702. if ($state) {
  703. $where .= " and state = '$state'";
  704. }
  705. $where_add = '';
  706. if ($cklx) {
  707. $shop = $this->shop->read($cklx);
  708. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  709. }
  710. if ($ktime && $jtime) {
  711. $gj = " and enter > '$ktime' and enter < '$jtime'";
  712. $ck = " and outk > '$ktime' and outk < '$jtime'";
  713. }
  714. //数据排序
  715. $order_str = "id desc";
  716. if (empty($page)) {
  717. $start = 0;
  718. $perpage = 1;
  719. } else {
  720. $start = ($page - 1) * $perpage;
  721. }
  722. if ($sku) {
  723. $sku = trim($sku, ' ');
  724. $sku = trim($sku, ' ');
  725. $where .= " and sku like '%$sku%'";
  726. $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);
  727. } else if ($title) {
  728. $title = trim($title, ' ');
  729. $title = trim($title, ' ');
  730. $where .= " and title like '%$title%'";
  731. $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);
  732. } else {
  733. //$where .= " and time > '$ktime' and time < '$jtime'";
  734. $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);
  735. }
  736. //取得信息列表
  737. $rows = array();
  738. $list = array();
  739. foreach ($info_list as $key => $value) {
  740. $warehouse = $this->warehouse->read($value['warehouse']);
  741. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  742. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  743. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  744. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  745. $ftime = time() - 15 * 24 * 3600;
  746. $info_list[$key]['warehouse'] = $warehouse['title'];
  747. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  748. //$z = count($z);//查看订单号
  749. //$info_list[$key]['zd'] = $z;
  750. $details = array();
  751. $cpid = array();
  752. foreach ($c as $k => $v) {
  753. $details[$v['details']] = $v['details'];
  754. if ($v['cpid'] != 0) {
  755. $cpid[$v['cpid']] = $v['cpid'];
  756. }
  757. }
  758. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  759. if ($value['shop'] != '') {
  760. $shop = explode(',', trim($value['shop'], ','));
  761. $shop = $this->shop->read($shop[0]);
  762. $info_list[$key]['shop'] = $shop['shopname'];
  763. }
  764. }
  765. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  766. $pagenum = ceil($total / $perpage);
  767. $over = $total - ($start + $perpage);
  768. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  769. echo json_encode($rows);
  770. exit;
  771. }
  772. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  773. $this->_Template('whlabel_typedy_ck', $this->data);
  774. }
  775. public function _typeck($arg_array)
  776. {
  777. $prc = array();
  778. $purchase = $this->purchase->find_all();
  779. foreach ($purchase as $k => $v) {
  780. $prc[$v['id']] = $v['title'];
  781. }
  782. $post = $this->input->post(NULL, TRUE);
  783. if (isset($post['page'])) {
  784. $page = $this->input->post('page', true);
  785. $perpage = $this->input->post('perpage', true);
  786. $category = $this->input->post('category', true);
  787. $size = $this->input->post('size', true);
  788. $grade = $this->input->post('grade', true);
  789. $color = $this->input->post('color', true);
  790. $lacecolor = $this->input->post('lacecolor', true);
  791. $lowe = $this->input->post('lowe', true);
  792. $sku = $this->input->post('sku');
  793. $title = $this->input->post('title');
  794. $warehouse = 13;
  795. $usa = $this->input->post('usa', true);
  796. $purchase = $this->input->post('purchase', true);
  797. $lacetype = $this->input->post('lacetype', true);
  798. $haircap = $this->input->post('haircap', true);
  799. $density = $this->input->post('density', true);
  800. $details = $this->input->post('details', true);
  801. $state = $this->input->post('state', true);
  802. $ktime = $this->input->post('ktime', true);
  803. $jtime = $this->input->post('jtime', true);
  804. $ktime = strtotime($ktime);
  805. $jtime = strtotime($jtime);
  806. $where = "1=1";
  807. $gj = "";
  808. $ck = "";
  809. if ($lacetype) {
  810. $where .= " and features like '%-$lacetype-%'";
  811. }
  812. if ($category) {
  813. $where .= " and features like '%-$category-%'";
  814. }
  815. if ($size) {
  816. $where .= " and features like '%-$size-%'";
  817. }
  818. if ($grade) {
  819. $where .= " and features like '%-$grade-%'";
  820. }
  821. if ($color) {
  822. $where .= " and features like '%-$color-%'";
  823. }
  824. if ($lacecolor) {
  825. $where .= " and features like '%-$lacecolor-%'";
  826. }
  827. if ($lowe) {
  828. $where .= " and features like '%-$lowe-%'";
  829. }
  830. if ($haircap) {
  831. $where .= " and features like '%-$haircap-%'";
  832. }
  833. if ($density) {
  834. $where .= " and features like '%-$density-%'";
  835. }
  836. if ($warehouse) {
  837. $where .= " and warehouse = '$warehouse'";
  838. }
  839. if ($details) {
  840. $where .= " and details = '$details'";
  841. }
  842. if ($purchase) {
  843. $where .= " and purchase = '$purchase'";
  844. }
  845. if ($state) {
  846. $where .= " and state = '$state'";
  847. }
  848. if ($ktime && $jtime) {
  849. $gj = " and enter > '$ktime' and enter < '$jtime'";
  850. $ck = " and outk > '$ktime' and outk < '$jtime'";
  851. }
  852. //数据排序
  853. $order_str = "id desc";
  854. if (empty($page)) {
  855. $start = 0;
  856. $perpage = 1;
  857. } else {
  858. $start = ($page - 1) * $perpage;
  859. }
  860. if ($sku) {
  861. $sku = trim($sku, ' ');
  862. $sku = trim($sku, ' ');
  863. $where .= " and sku like '%$sku%'";
  864. } else if ($title) {
  865. $title = trim($title, ' ');
  866. $title = trim($title, ' ');
  867. $where .= " and title like '%$title%'";
  868. }
  869. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  870. //取得信息列表
  871. $t = array();
  872. $typeclass = $this->typeclass->find_all();
  873. foreach ($typeclass as $v) {
  874. $t[$v['id']] = $v;
  875. }
  876. $rows = array();
  877. $list = array();
  878. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  879. foreach ($info_list as $key => $value) {
  880. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  881. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  882. $warehouse = $this->warehouse->read($value['warehouse']);
  883. $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');
  884. $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'] . '"');
  885. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  886. $number = $value['number'];
  887. $ftime = time() - 15 * 24 * 3600;
  888. $z = count($z); //查看订单号
  889. $info_list[$key]['warehouse'] = $warehouse['title'];
  890. $info_list[$key]['features'] = count($c);
  891. $info_list[$key]['number'] = $z;
  892. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  893. $details = array();
  894. $cpid = array();
  895. foreach ($c as $k => $v) {
  896. $details[$v['details']] = $v['details'];
  897. if ($v['cpid'] != 0) {
  898. $cpid[$v['cpid']] = $v['cpid'];
  899. }
  900. }
  901. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  902. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  903. unset($info_list[$key]['pm']);
  904. unset($info_list[$key]['jm']);
  905. unset($info_list[$key]['bm']);
  906. }
  907. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  908. $pagenum = ceil($total / $perpage);
  909. $over = $total - ($start + $perpage);
  910. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  911. echo json_encode($rows);
  912. exit;
  913. }
  914. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  915. $this->_Template('whlabel_typeck', $this->data);
  916. }
  917. //进销存导出
  918. public function _whlabeckdc()
  919. {
  920. $prc = array();
  921. $purchase = $this->purchase->find_all();
  922. foreach ($purchase as $k => $v) {
  923. $prc[$v['id']] = $v['title'];
  924. }
  925. if (isset($_GET['excel'])) {
  926. $where = "sku != 'Preset'";
  927. //数据排序
  928. $order_str = "id desc";
  929. if (empty($page)) {
  930. $start = 0;
  931. $perpage = 1;
  932. } else {
  933. $start = ($page - 1) * $perpage;
  934. }
  935. $category = $this->input->get('category', true);
  936. $color = $this->input->get('color', true);
  937. $lowe = $this->input->get('lowe', true);
  938. $lacetype = $this->input->get('lacetype', true);
  939. $size = $this->input->get('size', true);
  940. $density = $this->input->get('density', true);
  941. $haircap = $this->input->get('haircap', true);
  942. $sku = $this->input->get('sku', true);
  943. $details = $this->input->get('details', true);
  944. $warehouse = 13;
  945. $excelid = $this->input->get('sid', true);
  946. if ($category) {
  947. $where .= " and features like '%-$category-%'";
  948. }
  949. if ($color) {
  950. $where .= " and features like '%-$color-%'";
  951. }
  952. if ($lowe) {
  953. $where .= " and features like '%-$lowe-%'";
  954. }
  955. if ($lacetype) {
  956. $where .= " and features like '%-$lacetype-%'";
  957. }
  958. if ($size) {
  959. $where .= " and features like '%-$size-%'";
  960. }
  961. if ($density) {
  962. $where .= " and features like '%-$density-%'";
  963. }
  964. if ($haircap) {
  965. $where .= " and features like '%-$haircap-%'";
  966. }
  967. if ($warehouse) {
  968. $where .= " and warehouse = '$warehouse'";
  969. }
  970. if ($sku) {
  971. $where .= " and sku like '%$sku%'";
  972. }
  973. if ($details) {
  974. $where .= " and details = '$details'";
  975. }
  976. $xzid = '';
  977. if ($excelid) {
  978. $excelid = explode(',', trim($excelid, ','));
  979. foreach ($excelid as $key => $value) {
  980. $xzid .= " id = " . $value . " or";
  981. }
  982. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  983. }
  984. //取得信息列表
  985. /**
  986. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  987. $rows = array();$list = array();
  988. foreach ($info_list as $key=>$value)
  989. {
  990. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  991. }
  992. **/
  993. $wh = array();
  994. $w = $this->warehouse->find_all('1=1', 'id,title');
  995. foreach ($w as $v) {
  996. $wh[$v['id']] = $v['title'];
  997. }
  998. $tc = array();
  999. $tcdata = array();
  1000. $list = array();
  1001. $classid = $this->classid->sku();
  1002. $tcall = $this->typeclass->find_all();
  1003. $typeclass = array();
  1004. foreach ($tcall as $v)
  1005. {
  1006. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1007. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1008. }
  1009. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1010. foreach ($rows as $key => $value) {
  1011. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1012. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1013. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1014. $rows[$key]['cpbz'] = $u9_info['bm'];
  1015. $rows[$key]['cs'] = $u9_info['jm'];
  1016. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1017. $details = array();
  1018. $cpid = array();
  1019. $cpbz = array();
  1020. $c = 0;
  1021. $g = 0;
  1022. $x = 0;
  1023. $t = 0;
  1024. $s = 0;
  1025. $q = 0;
  1026. foreach ($sd as $k => $v) {
  1027. if ($v['state'] == 0) {
  1028. $c++;
  1029. }
  1030. if ($v['state'] != 9) {
  1031. $g++;
  1032. }
  1033. if ($v['state'] == 1) {
  1034. $x++;
  1035. }
  1036. if ($v['state'] == 2) {
  1037. $t++;
  1038. }
  1039. if ($v['state'] == 8) {
  1040. $s++;
  1041. }
  1042. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1043. $q++;
  1044. }
  1045. $details[$v['details']] = $v['details'];
  1046. if ($v['cpid'] != 0) {
  1047. $cpid[$v['cpid']] = $v['cpid'];
  1048. }
  1049. if ($v['cpbz'] != '') {
  1050. $cpbz[$v['cpbz']] = $v['cpbz'];
  1051. }
  1052. }
  1053. $rows[$key]['details'] = implode("、", $details);
  1054. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1055. $number = $value['number'];
  1056. $ftime = time() - 15 * 24 * 3600;
  1057. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1058. $rows[$key]['number'] = $g;
  1059. $rows[$key]['features'] = $c;
  1060. $rows[$key]['x'] = $x;
  1061. $rows[$key]['t'] = $t;
  1062. $rows[$key]['s'] = $s;
  1063. $rows[$key]['q'] = $q;
  1064. $rows[$key]['wzsl'] = count($details);
  1065. }
  1066. $title = "进销存统计表" . date('Y-m-d', time());
  1067. $titlename = "<table border=1>
  1068. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1069. <tr align='center'>
  1070. <td>仓库</td>
  1071. <td>供应商</td>
  1072. <td>位置</td>
  1073. <td>库存编码</td>
  1074. <td>SKU</td>
  1075. <td>用友编码</td>
  1076. <td>用友料号</td>
  1077. <td>产品英文名</td>
  1078. <td>产品中文名</td>
  1079. <td>入库总量</td>
  1080. <td>库存数量</td>
  1081. <td>销售数量</td>
  1082. <td>退货数量</td>
  1083. <td>删除数量</td>
  1084. <td>其它操作</td>
  1085. <td>位置数量</td>
  1086. </tr>
  1087. </table>";
  1088. $filename = $title . ".xls";
  1089. $tail = "";
  1090. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1091. }
  1092. }
  1093. public function _type()
  1094. {
  1095. $vip = 0;
  1096. if (isset($_SESSION['api'])) {
  1097. $user = $this->user->get_api($_SESSION['api']);
  1098. $fgshop = "";
  1099. $sid = "";
  1100. $usersp = explode('|', trim($user['shop'], '|'));
  1101. foreach ($usersp as $value) {
  1102. $fgshop .= " shop = " . $value . " or";
  1103. $sid .= " id = " . $value . " or";
  1104. }
  1105. if ($user['vip'] == 1) {
  1106. $vip = 1;
  1107. }
  1108. } else {
  1109. header('Location: /');
  1110. exit;
  1111. }
  1112. $prc = array();
  1113. $purchase = $this->purchase->find_all();
  1114. foreach ($purchase as $k => $v) {
  1115. $prc[$v['id']] = $v['title'];
  1116. }
  1117. $company = array();
  1118. $ct = $this->company->find_all();
  1119. foreach ($ct as $k => $v) {
  1120. $company[$v['id']] = $v['title'];
  1121. }
  1122. $sp = array();
  1123. $s = $this->shop->find_all('1=1', 'id,shopname');
  1124. foreach ($s as $v) {
  1125. $sp[$v['id']] = $v['shopname'];
  1126. }
  1127. $wh = array();
  1128. $w = $this->warehouse->find_all('1=1', 'id,title');
  1129. foreach ($w as $v) {
  1130. $wh[$v['id']] = $v['title'];
  1131. }
  1132. $post = $this->input->post(NULL, TRUE);
  1133. if (isset($post['page'])) {
  1134. $page = $this->input->post('page', true);
  1135. $perpage = $this->input->post('perpage', true);
  1136. $category = $this->input->post('category', true);
  1137. $size = $this->input->post('size', true);
  1138. $grade = $this->input->post('grade', true);
  1139. $color = $this->input->post('color', true);
  1140. $lowe = $this->input->post('lowe', true);
  1141. $sku = $this->input->post('sku');
  1142. $title = $this->input->post('title');
  1143. $warehouse = $this->input->post('warehouse', true);
  1144. $usa = $this->input->post('usa', true);
  1145. $purchase = $this->input->post('purchase', true);
  1146. $lacetype = $this->input->post('lacetype', true);
  1147. $haircap = $this->input->post('haircap', true);
  1148. $density = $this->input->post('density', true);
  1149. $details = $this->input->post('details', true);
  1150. $state = $this->input->post('state', true);
  1151. $shop = $this->input->post('shop', true);
  1152. $lacecolor = $this->input->post('lacecolor', true);
  1153. $hairnumber = $this->input->post('hairnumber', true);
  1154. $type = $this->input->post('type', true);
  1155. $ktime = $this->input->post('ktime', true);
  1156. $jtime = $this->input->post('jtime', true);
  1157. $ktime = strtotime($ktime);
  1158. $jtime = strtotime($jtime);
  1159. $cpbz = $this->input->post('cpbz', true);
  1160. $sm = $this->input->post('sm', true);
  1161. $where = "1=1";
  1162. $gj = "";
  1163. $ck = "";
  1164. if ($usa) {
  1165. if (!$warehouse) {
  1166. $where .= " and (warehouse = '5' or warehouse = '8')";
  1167. }
  1168. }
  1169. if ($warehouse) {
  1170. $where .= " and warehouse = '$warehouse'";
  1171. }
  1172. if ($details) {
  1173. $where .= " and details = '$details'";
  1174. }
  1175. if ($purchase) {
  1176. $where .= " and purchase = '$purchase'";
  1177. }
  1178. if ($state) {
  1179. $where .= " and state = '$state'";
  1180. }
  1181. if ($shop) {
  1182. $where .= " and shop like '%$shop%'";
  1183. }
  1184. if ($type) {
  1185. $where .= " and type = '$type'";
  1186. }
  1187. if ($ktime && $jtime) {
  1188. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1189. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1190. }
  1191. if ($cpbz) {
  1192. $where .= " and cpbz like '%$cpbz%' ";
  1193. }
  1194. if ($sm) {
  1195. $where .= " and sm like '%$sm%' ";
  1196. }
  1197. if ($lacecolor) {
  1198. $where .= " and features like '%-$lacecolor-%'";
  1199. }
  1200. if ($lacetype) {
  1201. $where .= " and features like '%-$lacetype-%'";
  1202. }
  1203. if ($category) {
  1204. $where .= " and features like '%-$category-%'";
  1205. }
  1206. if ($size) {
  1207. $where .= " and features like '%-$size-%'";
  1208. }
  1209. if ($grade) {
  1210. $where .= " and features like '%-$grade-%'";
  1211. }
  1212. if ($color) {
  1213. $where .= " and features like '%-$color-%'";
  1214. }
  1215. if ($lowe) {
  1216. $where .= " and features like '%-$lowe-%'";
  1217. }
  1218. if ($haircap) {
  1219. $where .= " and features like '%-$haircap-%'";
  1220. }
  1221. if ($density) {
  1222. $where .= " and features like '%-$density-%'";
  1223. }
  1224. if (!empty($hairnumber)) {
  1225. $where .= " and features like '%-128-%' ";
  1226. if ($hairnumber < 0) {
  1227. $class_list = $this->typeclass->find_all('classid = 43');
  1228. foreach ($class_list as $v) {
  1229. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1230. }
  1231. } else {
  1232. $where .= " and features like '%-$hairnumber-%'";
  1233. }
  1234. }
  1235. //数据排序
  1236. $order_str = "id desc";
  1237. if (empty($page)) {
  1238. $start = 0;
  1239. $perpage = 1;
  1240. } else {
  1241. $start = ($page - 1) * $perpage;
  1242. }
  1243. $fjnr = '';
  1244. if ($sku) {
  1245. $sku = trim($sku, ' ');
  1246. $sku = trim($sku, ' ');
  1247. $fjnr .= " and sku like '%$sku%'";
  1248. }
  1249. if ($title) {
  1250. $title = trim($title, ' ');
  1251. $title = trim($title, ' ');
  1252. $fjnr .= " and title like '%$title%'";
  1253. }
  1254. $wt = array();
  1255. $whlabel_type = $this->whlabel_type->find_all();
  1256. foreach ($whlabel_type as $v) {
  1257. $wt[$v['id']] = $v['title'];
  1258. }
  1259. //$where .= " and time > '$ktime' and time < '$jtime'";
  1260. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,type,features,number,sm', $order_str, $start, $perpage); //改这需要修改_gbhtype
  1261. //取得信息列表
  1262. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1263. $rows = array();
  1264. $list = array();
  1265. foreach ($info_list as $key => $value) {
  1266. if (isset($wt[$value['type']])) {
  1267. $info_list[$key]['type'] = $wt[$value['type']];
  1268. } else {
  1269. $info_list[$key]['type'] = '未设置';
  1270. }
  1271. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1272. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1273. $ztdata = '';
  1274. if (count($zt) > 0) {
  1275. foreach ($zt as $vv) {
  1276. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1277. }
  1278. }
  1279. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1280. $cdata = array_filter($qbdata, function ($item) {
  1281. return $item['state'] < 1;
  1282. });
  1283. $c = array_sum(array_column($cdata, 'jnum'));
  1284. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1285. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1286. });
  1287. $g = array_sum(array_column($gdata, 'jnum'));
  1288. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1289. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1290. });
  1291. $x = array_sum(array_column($xdata, 'jnum'));
  1292. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1293. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1294. });
  1295. $t = array_sum(array_column($tdata, 'jnum'));
  1296. $zdata = array_filter($qbdata, function ($item) {
  1297. return $item['zd'] != "" && $item['state'] < 1;
  1298. });
  1299. $z = array_sum(array_column($zdata, 'jnum'));
  1300. $zdata = array_filter($qbdata, function ($item) {
  1301. return $item['zd'] != "" && $item['state'] < 1;
  1302. });
  1303. $z = array_sum(array_column($zdata, 'jnum'));
  1304. //$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');
  1305. //$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'].'"');
  1306. //$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'].'"');
  1307. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1308. //$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'].'"');
  1309. $details = array();
  1310. $cpid = array();
  1311. $od = array();
  1312. $odid = '';
  1313. $companytitle = '';
  1314. foreach ($qbdata as $v) {
  1315. if ($v['zd'] != "" && $v['state'] < 1) {
  1316. if (!isset($od[$v['zd']])) {
  1317. $od[$v['zd']] = 1; //所有数据sku
  1318. } else {
  1319. $od[$v['zd']] = $od[$v['zd']] + 1;
  1320. }
  1321. }
  1322. if ($v['state'] < 1) {
  1323. $details[$v['details']] = $v['details'];
  1324. if ($v['cpid'] != 0) {
  1325. $cpid[$v['cpid']] = $v['cpid'];
  1326. }
  1327. }
  1328. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1329. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1330. }
  1331. }
  1332. foreach ($od as $k => $vv) {
  1333. $odid .= $k . '数量' . $vv;
  1334. }
  1335. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1336. $info_list[$key]['label'] = $value['sm'];
  1337. $number = $value['number'];
  1338. $ftime = time() - 15 * 24 * 3600;
  1339. $z = $z . '(' . $odid . ')'; //查看订单号
  1340. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1341. $info_list[$key]['features'] = $c;
  1342. $info_list[$key]['number'] = $ztdata;
  1343. $info_list[$key]['sm'] = $g;
  1344. $info_list[$key]['x'] = $x;
  1345. $info_list[$key]['t'] = $t;
  1346. $info_list[$key]['z'] = $z;
  1347. /**
  1348. foreach ($cdata as $k=>$v)
  1349. {
  1350. $details[$v['details']] = $v['details'];
  1351. if($v['cpid'] != 0)
  1352. {
  1353. $cpid[$v['cpid']] = $v['cpid'];
  1354. }
  1355. }
  1356. **/
  1357. $info_list[$key]['shop'] = '';
  1358. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1359. if ($value['shop'] != '') {
  1360. $shop = explode(',', trim($value['shop'], ','));
  1361. $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1362. }
  1363. $info_list[$key]['shop'] .= $companytitle;
  1364. /**
  1365. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1366. if(isset($companytitle[0]))
  1367. {
  1368. foreach ($companytitle as $k=>$v)
  1369. {
  1370. if($v['companytitle'] != '')
  1371. {
  1372. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1373. }
  1374. }
  1375. }
  1376. **/
  1377. }
  1378. $final_all_list = [];
  1379. foreach ($info_list as $k => $v) {
  1380. $final_all_list[] = [
  1381. 'id' => $v['id'],
  1382. "warehouse" => $v["warehouse"],
  1383. "purchase" => $v["purchase"],
  1384. "sku" => $v["sku"],
  1385. "title" => $v["title"] . "<br/>" . $v["pm"],
  1386. "details" => $v["details"],
  1387. "shop" => $v["shop"],
  1388. "cpbz" => $v["cpbz"],
  1389. 'label' => $v['label'],
  1390. "type" => $v["type"],
  1391. "features" => $v["features"],
  1392. "number" => $v["number"],
  1393. "sm" => $v["sm"],
  1394. "x" => $v["x"],
  1395. "t" => $v["t"],
  1396. "z" => $v["z"]
  1397. ];
  1398. }
  1399. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1400. $pagenum = ceil($total / $perpage);
  1401. $over = $total - ($start + $perpage);
  1402. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1403. echo json_encode($rows);
  1404. exit;
  1405. }
  1406. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1407. $this->data['shop'] = $wlshop;
  1408. $this->data['vip'] = $vip;
  1409. $this->_Template('whlabel_type', $this->data);
  1410. }
  1411. //美仓进销存浏览
  1412. public function _usatype()
  1413. {
  1414. if (isset($_SESSION['api'])) {
  1415. $user = $this->user->get_api($_SESSION['api']);
  1416. $usp = $user;
  1417. $fgshop = "";
  1418. $sid = "";
  1419. $wid = "";
  1420. $wtype = "";
  1421. $userwh = explode('|', trim($user['warehouse'], '|'));
  1422. foreach ($userwh as $value) {
  1423. $wid .= " id = " . $value . " or";
  1424. $wtype .= " type = " . $value . " or";
  1425. }
  1426. }
  1427. $prc = array();
  1428. $purchase = $this->purchase->find_all();
  1429. foreach ($purchase as $k => $v) {
  1430. $prc[$v['id']] = $v['title'];
  1431. }
  1432. $post = $this->input->post(NULL, TRUE);
  1433. if (isset($post['page'])) {
  1434. $page = $this->input->post('page', true);
  1435. $perpage = $this->input->post('perpage', true);
  1436. $category = $this->input->post('category', true);
  1437. $size = $this->input->post('size', true);
  1438. $grade = $this->input->post('grade', true);
  1439. $color = $this->input->post('color', true);
  1440. $lowe = $this->input->post('lowe', true);
  1441. $sku = $this->input->post('sku');
  1442. $title = $this->input->post('title');
  1443. $warehouse = $this->input->post('warehouse', true);
  1444. $usa = $this->input->post('usa', true);
  1445. $purchase = $this->input->post('purchase', true);
  1446. $lacetype = $this->input->post('lacetype', true);
  1447. $haircap = $this->input->post('haircap', true);
  1448. $density = $this->input->post('density', true);
  1449. $details = $this->input->post('details', true);
  1450. $state = $this->input->post('state', true);
  1451. $lacecolor = $this->input->post('lacecolor', true);
  1452. $cklx = $this->input->post('cklx', true);
  1453. $ktime = $this->input->post('ktime', true);
  1454. $jtime = $this->input->post('jtime', true);
  1455. $ktime = strtotime($ktime);
  1456. $jtime = strtotime($jtime);
  1457. $where = "1=1";
  1458. $gj = "";
  1459. $ck = "";
  1460. if ($lacetype) {
  1461. $where .= " and features like '%-$lacetype-%'";
  1462. }
  1463. if ($category) {
  1464. $where .= " and features like '%-$category-%'";
  1465. }
  1466. if ($size) {
  1467. $where .= " and features like '%-$size-%'";
  1468. }
  1469. if ($grade) {
  1470. $where .= " and features like '%-$grade-%'";
  1471. }
  1472. if ($color) {
  1473. $where .= " and features like '%-$color-%'";
  1474. }
  1475. if ($lowe) {
  1476. $where .= " and features like '%-$lowe-%'";
  1477. }
  1478. if ($haircap) {
  1479. $where .= " and features like '%-$haircap-%'";
  1480. }
  1481. if ($density) {
  1482. $where .= " and features like '%-$density-%'";
  1483. }
  1484. if ($lacecolor) {
  1485. $where .= " and features like '%-$lacecolor-%'";
  1486. }
  1487. if ($usa) {
  1488. if (!$warehouse) {
  1489. $where .= " and (warehouse = '5' or warehouse = '8')";
  1490. }
  1491. }
  1492. if ($warehouse) {
  1493. $where .= " and warehouse = '$warehouse'";
  1494. }
  1495. if ($details) {
  1496. $where .= " and details = '$details'";
  1497. }
  1498. if ($purchase) {
  1499. $where .= " and purchase = '$purchase'";
  1500. }
  1501. if ($state) {
  1502. $where .= " and state = '$state'";
  1503. }
  1504. $where_add = '';
  1505. if ($cklx) {
  1506. $shop = $this->shop->read($cklx);
  1507. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1508. }
  1509. if ($ktime && $jtime) {
  1510. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1511. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1512. }
  1513. //数据排序
  1514. $order_str = "id desc";
  1515. if (empty($page)) {
  1516. $start = 0;
  1517. $perpage = 1;
  1518. } else {
  1519. $start = ($page - 1) * $perpage;
  1520. }
  1521. if ($sku) {
  1522. $sku = trim($sku, ' ');
  1523. $sku = trim($sku, ' ');
  1524. $where .= " and sku like '%$sku%'";
  1525. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1526. } else if ($title) {
  1527. $title = trim($title, ' ');
  1528. $title = trim($title, ' ');
  1529. $where .= " and title like '%$title%'";
  1530. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1531. } else {
  1532. //$where .= " and time > '$ktime' and time < '$jtime'";
  1533. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1534. }
  1535. //取得信息列表
  1536. $rows = array();
  1537. $list = array();
  1538. foreach ($info_list as $key => $value) {
  1539. $warehouse = $this->warehouse->read($value['warehouse']);
  1540. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1541. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1542. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1543. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1544. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1545. $od = array();
  1546. $odid = '';
  1547. foreach ($z as $v) {
  1548. if (!isset($od[$v['zd']])) {
  1549. $od[$v['zd']] = 1; //所有数据sku
  1550. } else {
  1551. $od[$v['zd']] = $od[$v['zd']] + 1;
  1552. }
  1553. }
  1554. foreach ($od as $k => $vv) {
  1555. $odid .= $k . '数量' . $vv . ' ';
  1556. }
  1557. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1558. $info_list[$key]['features'] = $c;
  1559. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1560. $ztdata = '';
  1561. if (count($zt) > 0) {
  1562. foreach ($zt as $vv) {
  1563. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1564. }
  1565. }
  1566. $info_list[$key]['warehouse'] = $ztdata;
  1567. $info_list[$key]['g'] = $g;
  1568. $info_list[$key]['x'] = $x;
  1569. $info_list[$key]['t'] = $t;
  1570. $info_list[$key]['z'] = $z;
  1571. }
  1572. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1573. $pagenum = ceil($total / $perpage);
  1574. $over = $total - ($start + $perpage);
  1575. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1576. echo json_encode($rows);
  1577. exit;
  1578. }
  1579. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1580. $this->data['warehouse'] = $warehouse;
  1581. $this->_Template('whlabel_typeusa', $this->data);
  1582. }
  1583. //美仓进销存浏览
  1584. public function _usatypeapp()
  1585. {
  1586. $post = $this->input->post(NULL, TRUE);
  1587. if (isset($post['page'])) {
  1588. $page = $this->input->post('page', true);
  1589. $perpage = $this->input->post('perpage', true);
  1590. $sku = $this->input->post('sku', true);
  1591. $warehouse = 5;
  1592. $title = $this->input->post('title', true);
  1593. $state = $this->input->post('state', true);
  1594. $ktime = $this->input->post('ktime', true);
  1595. $jtime = $this->input->post('jtime', true);
  1596. $ktime = strtotime($ktime);
  1597. $jtime = strtotime($jtime);
  1598. $where = "1=1";
  1599. $gj = "";
  1600. $ck = "";
  1601. if ($title) {
  1602. $st = explode(' ', trim($title, ' '));
  1603. foreach ($st as $v) {
  1604. $where .= " and title like '%$v%'";
  1605. }
  1606. }
  1607. if ($warehouse) {
  1608. $where .= " and warehouse = '$warehouse'";
  1609. }
  1610. if ($state) {
  1611. $where .= " and state = '$state'";
  1612. }
  1613. if ($sku) {
  1614. $where .= " and sku like '%$sku%'";
  1615. }
  1616. if ($ktime && $jtime) {
  1617. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1618. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1619. }
  1620. //数据排序
  1621. $order_str = "id desc";
  1622. if (empty($page)) {
  1623. $start = 0;
  1624. $perpage = 1;
  1625. } else {
  1626. $start = ($page - 1) * $perpage;
  1627. }
  1628. //取得信息列表
  1629. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1630. $rows = array();
  1631. $list = array();
  1632. foreach ($info_list as $key => $value) {
  1633. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1634. }
  1635. $rowsdq = array_slice($rows, $start, $perpage);
  1636. foreach ($rowsdq as $value) {
  1637. $warehouse = $this->warehouse->read($value['warehouse']);
  1638. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1639. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1640. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1641. $od = array();
  1642. $odid = '';
  1643. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1644. }
  1645. $total = count($rows);
  1646. $pagenum = ceil($total / $perpage);
  1647. $over = $total - ($start + $perpage);
  1648. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1649. echo json_encode($rows);
  1650. exit;
  1651. }
  1652. $this->_Template('phone/p_usatypeapp', $this->data);
  1653. }
  1654. //入库操作
  1655. public function _enteradd()
  1656. {
  1657. $dt = 0;
  1658. if (isset($_SESSION['api'])) {
  1659. $user = $this->user->get_api($_SESSION['api']);
  1660. $usp = $user;
  1661. $fgshop = "";
  1662. $sid = "";
  1663. $user = explode('|', trim($user['shop'], '|'));
  1664. foreach ($user as $value) {
  1665. $fgshop .= " shop = " . $value . " or";
  1666. $sid .= " id = " . $value . " or";
  1667. }
  1668. }
  1669. $tc = $this->typeclass->find_all();
  1670. $typeclass = array();
  1671. foreach ($tc as $v) {
  1672. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1673. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1674. }
  1675. $post = $this->input->post(NULL, TRUE);
  1676. if (isset($post['sku'])) {
  1677. $list = array();
  1678. $num = "";
  1679. $title = "";
  1680. $features = "";
  1681. $order = $this->input->post('order', true);
  1682. $shop = $this->input->post('shop', true);
  1683. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1684. $sku = $this->input->post('sku', true);
  1685. $post['sm'] = $this->input->post('sm', true);
  1686. $post['warehouse'] = $this->input->post('warehouse', true);
  1687. $post['purchase'] = $this->input->post('purchase', true);
  1688. $post['retreatwarehouse'] = $post['warehouse'];
  1689. $post['state'] = $this->input->post('state', true);
  1690. $post['rktype'] = $this->input->post('rktype', true);
  1691. $post['text'] = $this->input->post('text', true);
  1692. $category = $this->input->post('category', true);
  1693. $list['category'] = $category;
  1694. $list['hairtype'] = $this->input->post('hairtype', true);
  1695. $list['grade'] = $this->input->post('grade', true);
  1696. $size = $this->input->post('size', true);
  1697. $xzsku = $this->input->post('xzsku', true);
  1698. $list['size'] = rtrim($size, ',');
  1699. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1700. $list['extension'] = $this->input->post('extension', true);
  1701. if ($category == 1297) {
  1702. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1703. }
  1704. if ($category == 1702) {
  1705. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1706. $list['syother'] = $this->input->post('syother', true);
  1707. }
  1708. if ($category == 133) {
  1709. $list['fittype'] = $this->input->post('fittype', true);
  1710. $list['acother'] = $this->input->post('acother', true);
  1711. }
  1712. $list['color'] = $this->input->post('color', true);
  1713. $list['lowe'] = $this->input->post('lowe', true);
  1714. if (!$post['purchase']) {
  1715. $post['purchase'] = 1;
  1716. }
  1717. if ($category == 127) {
  1718. $list['type'] = $this->input->post('type', true);
  1719. $list['headroad'] = $this->input->post('headroad', true);
  1720. $list['density'] = $this->input->post('density', true);
  1721. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1722. $list['lacesize'] = $this->input->post('lacesize', true);
  1723. }
  1724. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1725. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1726. }
  1727. if ($category == 128) {
  1728. $list['lacetype'] = $this->input->post('lacetype', true);
  1729. $list['haircap'] = $this->input->post('haircap', true);
  1730. $list['density'] = $this->input->post('density', true);
  1731. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1732. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1733. $list['wigother'] = $this->input->post('wigother', true);
  1734. $list['wigother1'] = $this->input->post('wigother1', true);
  1735. $list['wigother2'] = $this->input->post('wigother2', true);
  1736. }
  1737. if ($category == 129) {
  1738. $list['wide'] = $this->input->post('wide', true);
  1739. }
  1740. if ($category == 131) {
  1741. $list['gifttype'] = $this->input->post('gifttype', true);
  1742. $list['giftother'] = $this->input->post('giftother', true);
  1743. }
  1744. if ($category == 134) {
  1745. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1746. }
  1747. if ($category == 1297) {
  1748. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1749. $list['sywigother'] = $this->input->post('sywigother', true);
  1750. }
  1751. if ($category == 130 || $category == 133 || $category == 1702) {
  1752. $list['items'] = $this->input->post('items', true);
  1753. $list['weight'] = $this->input->post('weight', true);
  1754. }
  1755. if ($category == 1702) {
  1756. $list['syhairther'] = $this->input->post('syhairther', true);
  1757. }
  1758. $classid = $this->classid->sku();
  1759. $scsku = $classid;
  1760. $pm = $classid;
  1761. foreach ($list as $k => $v) {
  1762. if ($v != 0) {
  1763. $num .= $v;
  1764. $features .= $v . '-';
  1765. $post[$k] = $v;
  1766. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1767. if ($k != 'size') {
  1768. $title .= $typeclass[$v]['title'] . " ";
  1769. }
  1770. if (isset($pm[$typeclass[$v]['classid']])) {
  1771. if ($typeclass[$v]['title'] == '9A') {
  1772. $pm[$typeclass[$v]['classid']] = '9A';
  1773. } else if ($typeclass[$v]['title'] == '10A') {
  1774. $pm[$typeclass[$v]['classid']] = '10A';
  1775. } else {
  1776. $clzh = $typeclass[$v]['zh'];
  1777. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1778. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1779. $clzh = $clzh[0];
  1780. }
  1781. $pm[$typeclass[$v]['classid']] = $clzh;
  1782. }
  1783. }
  1784. }
  1785. }
  1786. $zh = implode(" ", $pm);
  1787. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1788. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1789. if ($list['size']) {
  1790. $typeclass = $this->typeclass->read($list['size']);
  1791. $title .= $typeclass['title'];
  1792. }
  1793. $time = time();
  1794. if ($xzsku) {
  1795. $scsku = implode("-", $scsku);
  1796. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1797. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1798. $post['sku'] = trim($scsku, ' ');
  1799. } else {
  1800. $post['sku'] = $sku;
  1801. }
  1802. //$post['sku'] = trim($sku,' ');
  1803. $post['title'] = rtrim($title, ' ');
  1804. $post['number'] = $num;
  1805. $post['features'] = '-' . $features;
  1806. $post['enter'] = $time;
  1807. $post['time'] = $time; //操作时间
  1808. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1809. if ($yza) {
  1810. if ($post['features'] != $yza[0]['features']) {
  1811. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1812. exit;
  1813. }
  1814. }
  1815. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1816. if ($yzb) {
  1817. if ($post['sku'] != $yzb[0]['sku']) {
  1818. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1819. exit;
  1820. }
  1821. }
  1822. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1823. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1824. exit;
  1825. }
  1826. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1827. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1828. exit;
  1829. }
  1830. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1831. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1832. exit;
  1833. }
  1834. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1835. if (isset($yz[0]['type'])) {
  1836. $post['type'] = $yz[0]['type'];
  1837. }
  1838. if ($post['state'] == 9) //如果选择预设库存
  1839. {
  1840. $this->whlabel->insert($post);
  1841. } else {
  1842. /**
  1843. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1844. if($ljg == 1)
  1845. {
  1846. for($i=0;$i<$order;$i++)
  1847. {
  1848. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1849. $this->whlabel->insert($post);
  1850. }
  1851. }
  1852. **/
  1853. //if($post['warehouse'] == '5')
  1854. //{
  1855. //}
  1856. $yydata = $post;
  1857. $yydata['zh'] = $zh;
  1858. /**
  1859. $wl = $this->apiyy->get_cjlp($yydata);
  1860. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1861. {
  1862. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1863. }
  1864. if($wl['Data'][0]['m_isSucess'] != 1)
  1865. {
  1866. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1867. }
  1868. **/
  1869. for ($i = 0; $i < $order; $i++) {
  1870. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1871. $this->whlabel->insert($post);
  1872. }
  1873. }
  1874. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1875. exit;
  1876. }
  1877. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1878. $this->data['wlshop'] = $wlshop;
  1879. $this->_Template('whlabel_enteradd', $this->data);
  1880. }
  1881. //修改产品
  1882. public function _enteredit($arg_array)
  1883. {
  1884. $dt = 0;
  1885. if (isset($_SESSION['api'])) {
  1886. $user = $this->user->get_api($_SESSION['api']);
  1887. $usp = $user;
  1888. $fgshop = "";
  1889. $sid = "";
  1890. $user = explode('|', trim($user['shop'], '|'));
  1891. foreach ($user as $value) {
  1892. $fgshop .= " shop = " . $value . " or";
  1893. $sid .= " id = " . $value . " or";
  1894. }
  1895. }
  1896. $post = $this->input->post(NULL, TRUE);
  1897. if (isset($post['sku'])) {
  1898. $list = array();
  1899. $num = "";
  1900. $title = "";
  1901. $features = "";
  1902. $id = $this->input->post('id', true);
  1903. $order = $this->input->post('order', true);
  1904. $shop = $this->input->post('shop', true);
  1905. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1906. $post['sku'] = $this->input->post('sku', true);
  1907. $post['sm'] = $this->input->post('sm', true);
  1908. $post['warehouse'] = $this->input->post('warehouse', true);
  1909. $post['purchase'] = $this->input->post('purchase', true);
  1910. $post['retreatwarehouse'] = $post['warehouse'];
  1911. $category = $this->input->post('category', true);
  1912. $list['category'] = $category;
  1913. $list['hairtype'] = $this->input->post('hairtype', true);
  1914. $list['grade'] = $this->input->post('grade', true);
  1915. $size = $this->input->post('size', true);
  1916. $list['size'] = rtrim($size, ',');
  1917. $post['rktype'] = $this->input->post('rktype', true);
  1918. $post['text'] = $this->input->post('text', true);
  1919. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1920. $list['extension'] = $this->input->post('extension', true);
  1921. if ($category == 1297) {
  1922. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1923. }
  1924. if ($category == 1702) {
  1925. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1926. $list['syother'] = $this->input->post('syother', true);
  1927. }
  1928. if ($category == 133) {
  1929. $list['fittype'] = $this->input->post('fittype', true);
  1930. $list['acother'] = $this->input->post('acother', true);
  1931. }
  1932. $list['color'] = $this->input->post('color', true);
  1933. $list['lowe'] = $this->input->post('lowe', true);
  1934. if (!$post['purchase']) {
  1935. $post['purchase'] = 1;
  1936. }
  1937. if ($category == 127) {
  1938. $list['type'] = $this->input->post('type', true);
  1939. $list['headroad'] = $this->input->post('headroad', true);
  1940. $list['density'] = $this->input->post('density', true);
  1941. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1942. $list['lacesize'] = $this->input->post('lacesize', true);
  1943. }
  1944. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1945. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1946. }
  1947. if ($category == 128) {
  1948. $list['lacetype'] = $this->input->post('lacetype', true);
  1949. $list['haircap'] = $this->input->post('haircap', true);
  1950. $list['density'] = $this->input->post('density', true);
  1951. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1952. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1953. $list['wigother'] = $this->input->post('wigother', true);
  1954. $list['wigother1'] = $this->input->post('wigother1', true);
  1955. $list['wigother2'] = $this->input->post('wigother2', true);
  1956. }
  1957. if ($category == 129) {
  1958. $list['wide'] = $this->input->post('wide', true);
  1959. }
  1960. if ($category == 131) {
  1961. $list['gifttype'] = $this->input->post('gifttype', true);
  1962. $list['giftother'] = $this->input->post('giftother', true);
  1963. }
  1964. if ($category == 134) {
  1965. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1966. }
  1967. if ($category == 1297) {
  1968. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1969. $list['sywigother'] = $this->input->post('sywigother', true);
  1970. }
  1971. if ($category == 130 || $category == 133 || $category == 1702) {
  1972. $list['items'] = $this->input->post('items', true);
  1973. $list['weight'] = $this->input->post('weight', true);
  1974. }
  1975. if ($category == 1702) {
  1976. $list['syhairther'] = $this->input->post('syhairther', true);
  1977. }
  1978. foreach ($list as $k => $v) {
  1979. if ($v != 0) {
  1980. $num .= $v;
  1981. $features .= $v . '-';
  1982. $typeclass = $this->typeclass->read($v);
  1983. if ($k != 'size') {
  1984. $title .= $typeclass['title'] . " ";
  1985. }
  1986. }
  1987. }
  1988. $typeclass = $this->typeclass->read($list['size']);
  1989. $title .= $typeclass['title'];
  1990. $time = time();
  1991. $post['title'] = rtrim($title, ' ');
  1992. $post['number'] = $num;
  1993. $post['features'] = '-' . $features;
  1994. $post['time'] = $time; //操作时间
  1995. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1996. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1997. exit;
  1998. }
  1999. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2000. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2001. exit;
  2002. }
  2003. $uid = $this->whlabel->read($id);
  2004. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2005. if ($datanum > 0) {
  2006. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2007. exit;
  2008. }
  2009. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2010. {
  2011. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2012. if ($yza) {
  2013. if ($post['features'] != $yza[0]['features']) {
  2014. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2015. exit;
  2016. }
  2017. }
  2018. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2019. if ($yzb) {
  2020. if ($post['sku'] != $yzb[0]['sku']) {
  2021. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2022. exit;
  2023. }
  2024. }
  2025. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2026. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2027. exit;
  2028. }
  2029. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2030. foreach ($data as $v) {
  2031. $post['id'] = $v['id'];
  2032. $this->whlabel->save($post, $v['id']);
  2033. }
  2034. } else {
  2035. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2036. if ($data > 0) {
  2037. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2038. exit;
  2039. } else {
  2040. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2041. foreach ($data as $v) {
  2042. $post['id'] = $v['id'];
  2043. $this->whlabel->save($post, $v['id']);
  2044. }
  2045. }
  2046. }
  2047. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2048. exit;
  2049. }
  2050. $uid = $this->whlabel->read($arg_array[0]);
  2051. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2052. $this->data['enter'] = $uid;
  2053. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2054. $this->data['wlshop'] = $wlshop;
  2055. $this->_Template('whlabel_enteredit', $this->data);
  2056. }
  2057. //入库浏览
  2058. public function _enter()
  2059. {
  2060. $post = $this->input->post(NULL, TRUE);
  2061. if (isset($post['s'])) {
  2062. $id_arr = $this->input->post('s');
  2063. $id_arr = explode(',', $id_arr);
  2064. if (!$id_arr) {
  2065. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2066. exit;
  2067. }
  2068. //循环删除记录
  2069. foreach ($id_arr as $v) {
  2070. $sid = $this->whlabel->read($v);
  2071. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2072. if ($count > 0) {
  2073. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2074. exit;
  2075. }
  2076. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2077. foreach ($info_list as $va) {
  2078. $this->whlabel->remove($va['id']);
  2079. }
  2080. }
  2081. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2082. exit;
  2083. }
  2084. $sp = array();
  2085. $s = $this->shop->find_all('1=1', 'id,shopname');
  2086. foreach ($s as $v) {
  2087. $sp[$v['id']] = $v['shopname'];
  2088. }
  2089. $wh = array();
  2090. $w = $this->warehouse->find_all('1=1', 'id,title');
  2091. foreach ($w as $v) {
  2092. $wh[$v['id']] = $v['title'];
  2093. }
  2094. if (isset($post['page'])) {
  2095. $page = $this->input->post('page', true);
  2096. $perpage = $this->input->post('perpage', true);
  2097. $category = $this->input->post('category', true);
  2098. $size = $this->input->post('size', true);
  2099. $grade = $this->input->post('grade', true);
  2100. $color = $this->input->post('color', true);
  2101. $lowe = $this->input->post('lowe', true);
  2102. $sku = $this->input->post('sku', true);
  2103. $warehouse = $this->input->post('warehouse', true);
  2104. $purchase = $this->input->post('purchase', true);
  2105. $ktime = $this->input->post('ktime', true);
  2106. $jtime = $this->input->post('jtime', true);
  2107. $ktime = strtotime($ktime);
  2108. $jtime = strtotime($jtime);
  2109. $where = "1=1";
  2110. $gj = "";
  2111. $ck = "";
  2112. if ($category) {
  2113. $where .= " and features like '%-$category-%'";
  2114. }
  2115. if ($size) {
  2116. $where .= " and features like '%-$size-%'";
  2117. }
  2118. if ($grade) {
  2119. $where .= " and features like '%-$grade-%'";
  2120. }
  2121. if ($color) {
  2122. $where .= " and features like '%-$color-%'";
  2123. }
  2124. if ($lowe) {
  2125. $where .= " and features like '%-$lowe-%'";
  2126. }
  2127. if ($warehouse) {
  2128. $where .= " and warehouse = '$warehouse'";
  2129. }
  2130. if ($purchase) {
  2131. $where .= " and purchase = '$purchase'";
  2132. }
  2133. if ($sku) {
  2134. $where .= " and sku like '%$sku%'";
  2135. }
  2136. if ($ktime && $jtime) {
  2137. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2138. }
  2139. //数据排序
  2140. $order_str = "enter desc";
  2141. if (empty($page)) {
  2142. $start = 0;
  2143. $perpage = 1;
  2144. } else {
  2145. $start = ($page - 1) * $perpage;
  2146. }
  2147. //取得信息列表
  2148. $info_list = $this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2149. foreach ($info_list as $k => $v) {
  2150. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2151. if ($v['shop'] == '') {
  2152. $s = '通用';
  2153. } else {
  2154. $info_list[$k]['shop'] = '';
  2155. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2156. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2157. }
  2158. }
  2159. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2160. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2161. $info_list[$k]['g'] = $g;
  2162. }
  2163. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2164. $total = count($this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,sku,title,features,number'));
  2165. $pagenum = ceil($total / $perpage);
  2166. $over = $total - ($start + $perpage);
  2167. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2168. echo json_encode($rows);
  2169. exit;
  2170. }
  2171. $this->_Template('whlabel_enter', $this->data);
  2172. }
  2173. //出库浏览
  2174. public function _out()
  2175. {
  2176. $post = $this->input->post(NULL, TRUE);
  2177. if (isset($post['page'])) {
  2178. $page = $this->input->post('page', true);
  2179. $perpage = $this->input->post('perpage', true);
  2180. $category = $this->input->post('category', true);
  2181. $size = $this->input->post('size', true);
  2182. $grade = $this->input->post('grade', true);
  2183. $color = $this->input->post('color', true);
  2184. $lowe = $this->input->post('lowe', true);
  2185. $sku = $this->input->post('sku', true);
  2186. $warehouse = $this->input->post('warehouse', true);
  2187. $purchase = $this->input->post('purchase', true);
  2188. $state = $this->input->post('state', true);
  2189. $ktime = $this->input->post('ktime', true);
  2190. $jtime = $this->input->post('jtime', true);
  2191. $ktime = strtotime($ktime);
  2192. $jtime = strtotime($jtime);
  2193. $where = "state=3";
  2194. $gj = "";
  2195. $ck = "";
  2196. if ($category) {
  2197. $where .= " and features like '%-$category-%'";
  2198. }
  2199. if ($size) {
  2200. $where .= " and features like '%-$size-%'";
  2201. }
  2202. if ($grade) {
  2203. $where .= " and features like '%-$grade-%'";
  2204. }
  2205. if ($color) {
  2206. $where .= " and features like '%-$color-%'";
  2207. }
  2208. if ($lowe) {
  2209. $where .= " and features like '%-$lowe-%'";
  2210. }
  2211. if ($state) {
  2212. $where .= " and state = '$state'";
  2213. }
  2214. if ($warehouse) {
  2215. $where .= " and warehouse = '$warehouse'";
  2216. }
  2217. if ($purchase) {
  2218. $where .= " and purchase = '$purchase'";
  2219. }
  2220. if ($sku) {
  2221. $where .= " and sku = '$sku'";
  2222. }
  2223. if ($ktime && $jtime) {
  2224. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2225. }
  2226. //数据排序
  2227. $order_str = "id desc";
  2228. if (empty($page)) {
  2229. $start = 0;
  2230. $perpage = 1;
  2231. } else {
  2232. $start = ($page - 1) * $perpage;
  2233. }
  2234. //取得信息列表
  2235. $info_list = $this->whlabel->find_all($where, 'sku');
  2236. $rows = array();
  2237. $list = array();
  2238. foreach ($info_list as $key => $value) {
  2239. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2240. }
  2241. $rows = array_unique($rows); //删除重复记录
  2242. foreach ($rows as $key => $value) {
  2243. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2244. $ck = $this->warehouse->read($data['warehouse']);
  2245. $warehouse = $ck['title'];
  2246. $gy = $this->purchase->read($data['purchase']);
  2247. $purchase = $gy['purchase'];
  2248. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2249. $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);
  2250. }
  2251. $total = count($list);
  2252. $pagenum = ceil($total / $perpage);
  2253. $over = $total - ($start + $perpage);
  2254. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2255. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2256. echo json_encode($rows);
  2257. exit;
  2258. }
  2259. $this->_Template('whlabel_out', $this->data);
  2260. }
  2261. //出库标签浏览
  2262. public function _label()
  2263. {
  2264. $post = $this->input->post(NULL, TRUE);
  2265. if (isset($post['page'])) {
  2266. $page = $this->input->post('page', true);
  2267. $perpage = $this->input->post('perpage', true);
  2268. $sku = $this->input->post('sku', true);
  2269. $warehouse = $this->input->post('warehouse', true);
  2270. $purchase = $this->input->post('purchase', true);
  2271. $orderinfo = $this->input->post('orderinfo', true);
  2272. $waybill = $this->input->post('waybill', true);
  2273. $category = $this->input->post('category', true);
  2274. $size = $this->input->post('size', true);
  2275. $grade = $this->input->post('grade', true);
  2276. $color = $this->input->post('color', true);
  2277. $lowe = $this->input->post('lowe', true);
  2278. $where = "state=1";
  2279. if ($sku) {
  2280. $where .= " and sku = '$sku'";
  2281. }
  2282. if ($warehouse) {
  2283. $where .= " and warehouse = '$warehouse'";
  2284. }
  2285. if ($purchase) {
  2286. $where .= " and purchase = '$purchase'";
  2287. }
  2288. if ($orderinfo) {
  2289. $where .= " and orderinfo = '$orderinfo'";
  2290. }
  2291. if ($waybill) {
  2292. $where .= " and waybill = '$waybill'";
  2293. }
  2294. if ($category) {
  2295. $where .= " and features like '%-$category-%'";
  2296. }
  2297. if ($size) {
  2298. $where .= " and features like '%-$size-%'";
  2299. }
  2300. if ($grade) {
  2301. $where .= " and features like '%-$grade-%'";
  2302. }
  2303. if ($color) {
  2304. $where .= " and features like '%-$color-%'";
  2305. }
  2306. if ($lowe) {
  2307. $where .= " and features like '%-$lowe-%'";
  2308. }
  2309. //数据排序
  2310. $order_str = "outk desc";
  2311. if (empty($page)) {
  2312. $start = 0;
  2313. $perpage = 1;
  2314. } else {
  2315. $start = ($page - 1) * $perpage;
  2316. }
  2317. //取得信息列表
  2318. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2319. foreach ($info_list as $key => $value) {
  2320. $warehouse = $this->warehouse->read($value['warehouse']);
  2321. $info_list[$key]['warehouse'] = $warehouse['title'];
  2322. $purchase = $this->purchase->read($value['purchase']);
  2323. $info_list[$key]['purchase'] = $purchase['title'];
  2324. if ($value['outk'] != 0) {
  2325. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2326. } else {
  2327. $info_list[$key]['outk'] = "";
  2328. }
  2329. if ($value['orderinfo'] == 0) {
  2330. $info_list[$key]['orderinfo'] = "";
  2331. }
  2332. if ($value['waybill'] == 0) {
  2333. $info_list[$key]['waybill'] = "";
  2334. }
  2335. }
  2336. $total = $this->whlabel->find_count($where);
  2337. $pagenum = ceil($total / $perpage);
  2338. $over = $total - ($start + $perpage);
  2339. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2340. echo json_encode($rows);
  2341. exit;
  2342. }
  2343. $this->_Template('whlabel_label', $this->data);
  2344. }
  2345. //独立站出库订单
  2346. public function _outorder()
  2347. {
  2348. if (isset($_SESSION['api'])) {
  2349. $user = $this->user->get_api($_SESSION['api']);
  2350. $usp = $user;
  2351. $fgshop = "";
  2352. $sid = "";
  2353. $user = explode('|', trim($user['shop'], '|'));
  2354. foreach ($user as $value) {
  2355. $fgshop .= " shop = " . $value . " or";
  2356. $sid .= " id = " . $value . " or";
  2357. }
  2358. } else {
  2359. echo "请重新登录";
  2360. }
  2361. $post = $this->input->post(NULL, TRUE);
  2362. if (isset($post['page'])) {
  2363. $page = $this->input->post('page', true);
  2364. $perpage = $this->input->post('perpage', true);
  2365. $warehouse = $this->input->post('warehouse', true);
  2366. $xztime = $this->input->post('xztime', true);
  2367. $timetk = $this->input->post('timetkk', true);
  2368. $timetj = $this->input->post('timetjj', true);
  2369. $shop = $this->input->post('shop', true);
  2370. $source = $this->input->post('source', true);
  2371. $orderinfo = $this->input->post('orderinfo', true);
  2372. $number = $this->input->post('number', true);
  2373. $sfxh = $this->input->post('sfxh', true);
  2374. $express = $this->input->post('express', true);
  2375. $waybill = $this->input->post('waybill', true);
  2376. $library = $this->input->post('library', true);
  2377. $country = $this->input->post('country', true);
  2378. $so = $this->input->post('so', true);
  2379. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2380. $print = $this->input->post('print', true);
  2381. $state = $this->input->post('state', true);
  2382. $orderurl = $this->input->post('orderurl', true);
  2383. $timetk = strtotime($timetk);
  2384. $timetj = strtotime($timetj);
  2385. /**
  2386. $sj = $this->input->post('sj',true);
  2387. if($sj)
  2388. {
  2389. $sj = $this->input->post('sj',true);
  2390. }
  2391. else
  2392. {
  2393. $sj = "fullorder";
  2394. }
  2395. **/
  2396. $sj = "fullorder";
  2397. $where = "1=1";
  2398. if ($warehouse) {
  2399. $where .= " and type = '$warehouse'";
  2400. }
  2401. if ($timetk && $timetj) {
  2402. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2403. }
  2404. if ($orderinfo) {
  2405. $where .= " and orderinfo = '$orderinfo'";
  2406. }
  2407. if ($number) {
  2408. $where .= " and number = '$number'";
  2409. }
  2410. if ($express) {
  2411. $where .= " and express = '$express'";
  2412. }
  2413. if ($waybill) {
  2414. $where .= " and waybill = '$waybill'";
  2415. }
  2416. if ($library) {
  2417. $where .= " and library = '$library'";
  2418. }
  2419. if ($print) {
  2420. $where .= " and print = '$print'";
  2421. }
  2422. if ($libraryconfirm) {
  2423. $where .= " and libraryconfirm = '$libraryconfirm'";
  2424. }
  2425. if ($state) {
  2426. $where .= " and state = '$state'";
  2427. }
  2428. if ($shop) {
  2429. $where .= " and shop = '$shop'";
  2430. }
  2431. if ($country) {
  2432. $where .= " and country = '$country'";
  2433. }
  2434. if ($sfxh != '') {
  2435. $where .= " and sfxh = '$sfxh'";
  2436. }
  2437. if ($so) {
  2438. $where .= " and shipremarks like '%$so%'";
  2439. }
  2440. if ($source) {
  2441. if ($source == '2d') {
  2442. $where .= " and source >= '2'";
  2443. } else {
  2444. $where .= " and source = '$source'";
  2445. }
  2446. }
  2447. if (isset($_SESSION['api'])) {
  2448. foreach ($user as $value) {
  2449. $fgshop .= " shop = " . $value . " or";
  2450. }
  2451. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2452. }
  2453. if ($orderurl) {
  2454. $url = $this->orderurl->read($orderurl);
  2455. $where .= " and link like '%" . $url['url'] . "%'";
  2456. }
  2457. //数据排序
  2458. $order_str = "librarytime desc";
  2459. if (empty($page)) {
  2460. $start = 0;
  2461. $perpage = 1;
  2462. } else {
  2463. $start = ($page - 1) * $perpage;
  2464. }
  2465. //取得信息列表
  2466. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2467. //格式化数据
  2468. foreach ($info_list as $key => $value) {
  2469. $shop = $this->shop->read($value['shop']);
  2470. $info_list[$key]['shop'] = $shop['shopname'];
  2471. $express = $this->express->read($value['express']);
  2472. $info_list[$key]['express'] = $express['servicename'];
  2473. $warehouse = $this->warehouse->read($value['type']);
  2474. $info_list[$key]['type'] = $warehouse['title'];
  2475. if ($value['librarytime'] == '0') {
  2476. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2477. } else {
  2478. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2479. }
  2480. }
  2481. $total = $this->$sj->find_count($where);
  2482. $pagenum = ceil($total / $perpage);
  2483. $over = $total - ($start + $perpage);
  2484. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2485. echo json_encode($rows);
  2486. exit;
  2487. }
  2488. $this->data['express'] = $this->express->find_all();
  2489. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2490. $this->data['wlshop'] = $wlshop;
  2491. $user = $this->user->get_api($_SESSION['api']);
  2492. $powerid = $this->power->read($user['power']);
  2493. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2494. $pid = '';
  2495. foreach ($powertext as $v) {
  2496. $pid .= " id = " . $v . " or";
  2497. }
  2498. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2499. $this->data['fullorderexcel'] = $fullorderexcel;
  2500. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2501. $this->data['orderurl'] = $orderurl;
  2502. $this->_Template('whlabel_outorder', $this->data);
  2503. }
  2504. //tt出库
  2505. public function _toutorder()
  2506. {
  2507. if (isset($_SESSION['api'])) {
  2508. $user = $this->user->get_api($_SESSION['api']);
  2509. $usp = $user;
  2510. $fgshop = "";
  2511. $sid = "";
  2512. $user = explode('|', trim($user['shop'], '|'));
  2513. foreach ($user as $value) {
  2514. $fgshop .= " shop = " . $value . " or";
  2515. $sid .= " id = " . $value . " or";
  2516. }
  2517. } else {
  2518. echo "请重新登录";
  2519. }
  2520. $post = $this->input->post(NULL, TRUE);
  2521. if (isset($post['page'])) {
  2522. $page = $this->input->post('page', true);
  2523. $perpage = $this->input->post('perpage', true);
  2524. $warehouse = $this->input->post('warehouse', true);
  2525. $xztime = $this->input->post('xztime', true);
  2526. $timetk = $this->input->post('timetkk', true);
  2527. $timetj = $this->input->post('timetjj', true);
  2528. $shop = $this->input->post('shop', true);
  2529. $source = $this->input->post('source', true);
  2530. $orderinfo = $this->input->post('orderinfo', true);
  2531. $number = $this->input->post('number', true);
  2532. $sfxh = $this->input->post('sfxh', true);
  2533. $express = $this->input->post('express', true);
  2534. $waybill = $this->input->post('waybill', true);
  2535. $library = $this->input->post('library', true);
  2536. $country = $this->input->post('country', true);
  2537. $so = $this->input->post('so', true);
  2538. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2539. $print = $this->input->post('print', true);
  2540. $state = $this->input->post('state', true);
  2541. $orderurl = $this->input->post('orderurl', true);
  2542. $timetk = strtotime($timetk);
  2543. $timetj = strtotime($timetj);
  2544. /**
  2545. $sj = $this->input->post('sj',true);
  2546. if($sj)
  2547. {
  2548. $sj = $this->input->post('sj',true);
  2549. }
  2550. else
  2551. {
  2552. $sj = "fullorder";
  2553. }
  2554. **/
  2555. $sj = "fullordertt";
  2556. $where = "1=1";
  2557. if ($warehouse) {
  2558. $where .= " and type = '$warehouse'";
  2559. }
  2560. if ($timetk && $timetj) {
  2561. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2562. }
  2563. if ($orderinfo) {
  2564. $where .= " and orderinfo = '$orderinfo'";
  2565. }
  2566. if ($number) {
  2567. $where .= " and number = '$number'";
  2568. }
  2569. if ($express) {
  2570. $where .= " and express = '$express'";
  2571. }
  2572. if ($waybill) {
  2573. $where .= " and waybill = '$waybill'";
  2574. }
  2575. if ($library) {
  2576. $where .= " and library = '$library'";
  2577. }
  2578. if ($print) {
  2579. $where .= " and print = '$print'";
  2580. }
  2581. if ($libraryconfirm) {
  2582. $where .= " and libraryconfirm = '$libraryconfirm'";
  2583. }
  2584. if ($state) {
  2585. $where .= " and state = '$state'";
  2586. }
  2587. if ($shop) {
  2588. $where .= " and shop = '$shop'";
  2589. }
  2590. if ($country) {
  2591. $where .= " and country = '$country'";
  2592. }
  2593. if ($sfxh != '') {
  2594. $where .= " and sfxh = '$sfxh'";
  2595. }
  2596. if ($so) {
  2597. $where .= " and shipremarks like '%$so%'";
  2598. }
  2599. if ($source) {
  2600. if ($source == '2d') {
  2601. $where .= " and source >= '2'";
  2602. } else {
  2603. $where .= " and source = '$source'";
  2604. }
  2605. }
  2606. if (isset($_SESSION['api'])) {
  2607. foreach ($user as $value) {
  2608. $fgshop .= " shop = " . $value . " or";
  2609. }
  2610. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2611. }
  2612. if ($orderurl) {
  2613. $url = $this->orderurl->read($orderurl);
  2614. $where .= " and link like '%" . $url['url'] . "%'";
  2615. }
  2616. //数据排序
  2617. $order_str = "librarytime desc";
  2618. if (empty($page)) {
  2619. $start = 0;
  2620. $perpage = 1;
  2621. } else {
  2622. $start = ($page - 1) * $perpage;
  2623. }
  2624. //取得信息列表
  2625. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2626. //格式化数据
  2627. foreach ($info_list as $key => $value) {
  2628. $shop = $this->shop->read($value['shop']);
  2629. $info_list[$key]['shop'] = $shop['shopname'];
  2630. $express = $this->express->read($value['express']);
  2631. $info_list[$key]['express'] = $express['servicename'];
  2632. $warehouse = $this->warehouse->read($value['type']);
  2633. $info_list[$key]['type'] = $warehouse['title'];
  2634. if ($value['librarytime'] == '0') {
  2635. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2636. } else {
  2637. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2638. }
  2639. }
  2640. $total = $this->$sj->find_count($where);
  2641. $pagenum = ceil($total / $perpage);
  2642. $over = $total - ($start + $perpage);
  2643. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2644. echo json_encode($rows);
  2645. exit;
  2646. }
  2647. $this->data['express'] = $this->express->find_all();
  2648. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2649. $this->data['wlshop'] = $wlshop;
  2650. $user = $this->user->get_api($_SESSION['api']);
  2651. $powerid = $this->power->read($user['power']);
  2652. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2653. $pid = '';
  2654. foreach ($powertext as $v) {
  2655. $pid .= " id = " . $v . " or";
  2656. }
  2657. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2658. $this->data['fullorderexcel'] = $fullorderexcel;
  2659. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2660. $this->data['orderurl'] = $orderurl;
  2661. $this->_Template('whlabel_toutorder', $this->data);
  2662. }
  2663. //tt出库
  2664. public function _aoutorder()
  2665. {
  2666. if (isset($_SESSION['api'])) {
  2667. $user = $this->user->get_api($_SESSION['api']);
  2668. $usp = $user;
  2669. $fgshop = "";
  2670. $sid = "";
  2671. $user = explode('|', trim($user['shop'], '|'));
  2672. foreach ($user as $value) {
  2673. $fgshop .= " shop = " . $value . " or";
  2674. $sid .= " id = " . $value . " or";
  2675. }
  2676. } else {
  2677. echo "请重新登录";
  2678. }
  2679. $post = $this->input->post(NULL, TRUE);
  2680. if (isset($post['page'])) {
  2681. $page = $this->input->post('page', true);
  2682. $perpage = $this->input->post('perpage', true);
  2683. $warehouse = $this->input->post('warehouse', true);
  2684. $xztime = $this->input->post('xztime', true);
  2685. $timetk = $this->input->post('timetkk', true);
  2686. $timetj = $this->input->post('timetjj', true);
  2687. $shop = $this->input->post('shop', true);
  2688. $source = $this->input->post('source', true);
  2689. $orderinfo = $this->input->post('orderinfo', true);
  2690. $number = $this->input->post('number', true);
  2691. $sfxh = $this->input->post('sfxh', true);
  2692. $express = $this->input->post('express', true);
  2693. $waybill = $this->input->post('waybill', true);
  2694. $library = $this->input->post('library', true);
  2695. $country = $this->input->post('country', true);
  2696. $so = $this->input->post('so', true);
  2697. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2698. $print = $this->input->post('print', true);
  2699. $state = $this->input->post('state', true);
  2700. $orderurl = $this->input->post('orderurl', true);
  2701. $timetk = strtotime($timetk);
  2702. $timetj = strtotime($timetj);
  2703. /**
  2704. $sj = $this->input->post('sj',true);
  2705. if($sj)
  2706. {
  2707. $sj = $this->input->post('sj',true);
  2708. }
  2709. else
  2710. {
  2711. $sj = "fullorder";
  2712. }
  2713. **/
  2714. $sj = "fullorderamz";
  2715. $where = "1=1";
  2716. if ($warehouse) {
  2717. $where .= " and type = '$warehouse'";
  2718. }
  2719. if ($timetk && $timetj) {
  2720. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2721. }
  2722. if ($orderinfo) {
  2723. $where .= " and orderinfo = '$orderinfo'";
  2724. }
  2725. if ($number) {
  2726. $where .= " and number = '$number'";
  2727. }
  2728. if ($express) {
  2729. $where .= " and express = '$express'";
  2730. }
  2731. if ($waybill) {
  2732. $where .= " and waybill = '$waybill'";
  2733. }
  2734. if ($library) {
  2735. $where .= " and library = '$library'";
  2736. }
  2737. if ($print) {
  2738. $where .= " and print = '$print'";
  2739. }
  2740. if ($libraryconfirm) {
  2741. $where .= " and libraryconfirm = '$libraryconfirm'";
  2742. }
  2743. if ($state) {
  2744. $where .= " and state = '$state'";
  2745. }
  2746. if ($shop) {
  2747. $where .= " and shop = '$shop'";
  2748. }
  2749. if ($country) {
  2750. $where .= " and country = '$country'";
  2751. }
  2752. if ($sfxh != '') {
  2753. $where .= " and sfxh = '$sfxh'";
  2754. }
  2755. if ($so) {
  2756. $where .= " and shipremarks like '%$so%'";
  2757. }
  2758. if ($source) {
  2759. if ($source == '2d') {
  2760. $where .= " and source >= '2'";
  2761. } else {
  2762. $where .= " and source = '$source'";
  2763. }
  2764. }
  2765. if (isset($_SESSION['api'])) {
  2766. foreach ($user as $value) {
  2767. $fgshop .= " shop = " . $value . " or";
  2768. }
  2769. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2770. }
  2771. if ($orderurl) {
  2772. $url = $this->orderurl->read($orderurl);
  2773. $where .= " and link like '%" . $url['url'] . "%'";
  2774. }
  2775. //数据排序
  2776. $order_str = "librarytime desc";
  2777. if (empty($page)) {
  2778. $start = 0;
  2779. $perpage = 1;
  2780. } else {
  2781. $start = ($page - 1) * $perpage;
  2782. }
  2783. //取得信息列表
  2784. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2785. //格式化数据
  2786. foreach ($info_list as $key => $value) {
  2787. $shop = $this->shop->read($value['shop']);
  2788. $info_list[$key]['shop'] = $shop['shopname'];
  2789. $express = $this->express->read($value['express']);
  2790. $info_list[$key]['express'] = $express['servicename'];
  2791. $warehouse = $this->warehouse->read($value['type']);
  2792. $info_list[$key]['type'] = $warehouse['title'];
  2793. if ($value['librarytime'] == '0') {
  2794. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2795. } else {
  2796. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2797. }
  2798. }
  2799. $total = $this->$sj->find_count($where);
  2800. $pagenum = ceil($total / $perpage);
  2801. $over = $total - ($start + $perpage);
  2802. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2803. echo json_encode($rows);
  2804. exit;
  2805. }
  2806. $this->data['express'] = $this->express->find_all();
  2807. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2808. $this->data['wlshop'] = $wlshop;
  2809. $user = $this->user->get_api($_SESSION['api']);
  2810. $powerid = $this->power->read($user['power']);
  2811. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2812. $pid = '';
  2813. foreach ($powertext as $v) {
  2814. $pid .= " id = " . $v . " or";
  2815. }
  2816. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2817. $this->data['fullorderexcel'] = $fullorderexcel;
  2818. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2819. $this->data['orderurl'] = $orderurl;
  2820. $this->_Template('whlabel_aoutorder', $this->data);
  2821. }
  2822. //速卖通出库订单
  2823. public function _soutorder()
  2824. {
  2825. if (isset($_SESSION['api'])) {
  2826. $user = $this->user->get_api($_SESSION['api']);
  2827. $usp = $user;
  2828. $fgshop = "";
  2829. $sid = "";
  2830. $user = explode('|', trim($user['shop'], '|'));
  2831. foreach ($user as $value) {
  2832. $sid .= " id = " . $value . " or";
  2833. }
  2834. }
  2835. $post = $this->input->post(NULL, TRUE);
  2836. if (isset($post['page'])) {
  2837. $page = $this->input->post('page', true);
  2838. $perpage = $this->input->post('perpage', true);
  2839. $warehouse = $this->input->post('warehouse', true);
  2840. $xztime = $this->input->post('xztime', true);
  2841. $timetk = $this->input->post('timetkk', true);
  2842. $timetj = $this->input->post('timetjj', true);
  2843. $shop = $this->input->post('shop', true);
  2844. $source = $this->input->post('source', true);
  2845. $orderinfo = $this->input->post('orderinfo', true);
  2846. $number = $this->input->post('number', true);
  2847. $express = $this->input->post('express', true);
  2848. $waybill = $this->input->post('waybill', true);
  2849. $library = $this->input->post('library', true);
  2850. $country = $this->input->post('country', true);
  2851. $sfxh = $this->input->post('sfxh', true);
  2852. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2853. $print = $this->input->post('print', true);
  2854. $state = $this->input->post('state', true);
  2855. $so = $this->input->post('so', true);
  2856. $timetk = strtotime($timetk);
  2857. $timetj = strtotime($timetj);
  2858. /**
  2859. $sj = $this->input->post('sj',true);
  2860. if($sj)
  2861. {
  2862. $sj = $this->input->post('sj',true);
  2863. }
  2864. else
  2865. {
  2866. $sj = "fullorder";
  2867. }
  2868. **/
  2869. $sj = "fullordersmt";
  2870. $where = "1=1";
  2871. if ($warehouse) {
  2872. $where .= " and type = '$warehouse'";
  2873. }
  2874. if ($timetk && $timetj) {
  2875. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2876. }
  2877. if ($orderinfo) {
  2878. $where .= " and orderinfo = '$orderinfo'";
  2879. }
  2880. if ($number) {
  2881. $where .= " and number = '$number'";
  2882. }
  2883. if ($express) {
  2884. $where .= " and express = '$express'";
  2885. }
  2886. if ($waybill) {
  2887. $where .= " and waybill = '$waybill'";
  2888. }
  2889. if ($library) {
  2890. $where .= " and library = '$library'";
  2891. }
  2892. if ($print) {
  2893. $where .= " and print = '$print'";
  2894. }
  2895. if ($libraryconfirm) {
  2896. $where .= " and libraryconfirm = '$libraryconfirm'";
  2897. }
  2898. if ($state) {
  2899. $where .= " and state = '$state'";
  2900. }
  2901. if ($shop) {
  2902. $where .= " and shop = '$shop'";
  2903. }
  2904. if ($sfxh != '') {
  2905. $where .= " and sfxh = '$sfxh'";
  2906. }
  2907. if ($so) {
  2908. $where .= " and shipremarks like '%$so%'";
  2909. }
  2910. if ($source) {
  2911. $where .= " and source = '$source'";
  2912. }
  2913. if ($country) {
  2914. $where .= " and country = '$country'";
  2915. } else {
  2916. if (isset($_SESSION['api'])) {
  2917. foreach ($user as $value) {
  2918. $fgshop .= " shop = " . $value . " or";
  2919. }
  2920. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2921. }
  2922. }
  2923. //数据排序
  2924. $order_str = "librarytime desc";
  2925. if (empty($page)) {
  2926. $start = 0;
  2927. $perpage = 1;
  2928. } else {
  2929. $start = ($page - 1) * $perpage;
  2930. }
  2931. //取得信息列表
  2932. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2933. //格式化数据
  2934. foreach ($info_list as $key => $value) {
  2935. $shop = $this->shop->read($value['shop']);
  2936. $info_list[$key]['shop'] = $shop['shopname'];
  2937. $express = $this->express->read($value['express']);
  2938. $info_list[$key]['express'] = $express['servicename'];
  2939. $warehouse = $this->warehouse->read($value['type']);
  2940. $info_list[$key]['type'] = $warehouse['title'];
  2941. if ($value['librarytime'] == '0') {
  2942. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2943. } else {
  2944. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2945. }
  2946. }
  2947. $total = $this->$sj->find_count($where);
  2948. $pagenum = ceil($total / $perpage);
  2949. $over = $total - ($start + $perpage);
  2950. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2951. echo json_encode($rows);
  2952. exit;
  2953. }
  2954. $this->data['express'] = $this->express->find_all();
  2955. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2956. $this->data['wlshop'] = $wlshop;
  2957. $user = $this->user->get_api($_SESSION['api']);
  2958. $powerid = $this->power->read($user['power']);
  2959. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2960. $pid = '';
  2961. foreach ($powertext as $v) {
  2962. $pid .= " id = " . $v . " or";
  2963. }
  2964. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2965. $this->data['fullorderexcel'] = $fullorderexcel;
  2966. $this->_Template('whlabel_soutorder', $this->data);
  2967. }
  2968. //订单退库
  2969. public function _retreat()
  2970. {
  2971. $post = $this->input->post(NULL, TRUE);
  2972. if (isset($post['page'])) {
  2973. $page = $this->input->post('page', true);
  2974. $perpage = $this->input->post('perpage', true);
  2975. $warehouse = $this->input->post('warehouse', true);
  2976. $timetk = $this->input->post('timetk', true);
  2977. $timetj = $this->input->post('timetj', true);
  2978. $shop = $this->input->post('shop', true);
  2979. $source = $this->input->post('source', true);
  2980. $state = $this->input->post('state', true);
  2981. $review = $this->input->post('review', true);
  2982. $state = $this->input->post('state', true);
  2983. $express = $this->input->post('express', true);
  2984. $orderinfo = $this->input->post('orderinfo', true);
  2985. $user = $this->input->post('user', true);
  2986. $name = $this->input->post('name', true);
  2987. $waybill = $this->input->post('waybill', true);
  2988. $timetk = strtotime($timetk);
  2989. $timetj = strtotime($timetj);
  2990. $where = "(state=206 or state=210) and mergeid = 0";
  2991. if ($warehouse) {
  2992. $where .= " and state = '$warehouse'";
  2993. }
  2994. if ($timetk && $timetj) {
  2995. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  2996. }
  2997. if ($shop) {
  2998. $where .= " and shop = '$shop'";
  2999. }
  3000. if ($source) {
  3001. $where .= " and source = '$source'";
  3002. }
  3003. if ($state) {
  3004. $where .= " and state = '$state'";
  3005. }
  3006. if ($review) {
  3007. $where .= " and review = '$review'";
  3008. }
  3009. if ($state) {
  3010. $where .= " and state = '$state'";
  3011. }
  3012. if ($express) {
  3013. $where .= " and express = '$express'";
  3014. }
  3015. if ($orderinfo) {
  3016. $where .= " and orderinfo = '$orderinfo'";
  3017. }
  3018. if ($user) {
  3019. $where .= " and user = '$user'";
  3020. }
  3021. if ($name) {
  3022. $where .= " and name = '$name'";
  3023. }
  3024. if ($waybill) {
  3025. $where .= " and waybill = '$waybill'";
  3026. }
  3027. //数据排序
  3028. $order_str = "id desc";
  3029. if (empty($page)) {
  3030. $start = 0;
  3031. $perpage = 1;
  3032. } else {
  3033. $start = ($page - 1) * $perpage;
  3034. }
  3035. //取得信息列表
  3036. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3037. //格式化数据
  3038. foreach ($info_list as $key => $value) {
  3039. $shop = $this->shop->read($value['shop']);
  3040. $info_list[$key]['shop'] = $shop['shopname'];
  3041. $warehouse = $this->warehouse->read($value['warehouse']);
  3042. $info_list[$key]['warehouse'] = $warehouse['title'];
  3043. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3044. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3045. if ($value['waybill'] == 0) {
  3046. $info_list[$key]['waybill'] = "";
  3047. }
  3048. $express = $this->express->read($value['express']);
  3049. $info_list[$key]['express'] = $express['title'];
  3050. $typeclass = $this->typeclass->read($value['state']);
  3051. $info_list[$key]['state'] = $typeclass['title'];
  3052. }
  3053. $total = $this->fullorder->find_count($where);
  3054. $pagenum = ceil($total / $perpage);
  3055. $over = $total - ($start + $perpage);
  3056. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3057. echo json_encode($rows);
  3058. exit;
  3059. }
  3060. $this->data['express'] = $this->express->find_all();
  3061. $this->_Template('whlabel_retreat', $this->data);
  3062. }
  3063. //退库标签浏览
  3064. public function _retreatlk()
  3065. {
  3066. $post = $this->input->post(NULL, TRUE);
  3067. if (isset($post['page'])) {
  3068. $page = $this->input->post('page', true);
  3069. $perpage = $this->input->post('perpage', true);
  3070. $timetk = $this->input->post('timetk', true);
  3071. $timetj = $this->input->post('timetj', true);
  3072. $sku = $this->input->post('sku', true);
  3073. $warehouse = $this->input->post('warehouse', true);
  3074. $purchase = $this->input->post('purchase', true);
  3075. $orderinfo = $this->input->post('orderinfo', true);
  3076. $waybill = $this->input->post('waybill', true);
  3077. $category = $this->input->post('category', true);
  3078. $size = $this->input->post('size', true);
  3079. $grade = $this->input->post('grade', true);
  3080. $color = $this->input->post('color', true);
  3081. $lowe = $this->input->post('lowe', true);
  3082. $state = $this->input->post('state', true);
  3083. $timetk = strtotime($timetk);
  3084. $timetj = strtotime($timetj);
  3085. $where = "state=2";
  3086. if ($timetk && $timetj) {
  3087. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3088. }
  3089. if ($sku) {
  3090. $where .= " and sku = '$sku'";
  3091. }
  3092. if ($warehouse) {
  3093. $where .= " and warehouse = '$warehouse'";
  3094. }
  3095. if ($purchase) {
  3096. $where .= " and purchase = '$purchase'";
  3097. }
  3098. if ($orderinfo) {
  3099. $where .= " and orderinfo = '$orderinfo'";
  3100. }
  3101. if ($waybill) {
  3102. $where .= " and waybill = '$waybill'";
  3103. }
  3104. if ($category) {
  3105. $where .= " and features like '%-$category-%'";
  3106. }
  3107. if ($size) {
  3108. $where .= " and features like '%-$size-%'";
  3109. }
  3110. if ($grade) {
  3111. $where .= " and features like '%-$grade-%'";
  3112. }
  3113. if ($color) {
  3114. $where .= " and features like '%-$color-%'";
  3115. }
  3116. if ($lowe) {
  3117. $where .= " and features like '%-$lowe-%'";
  3118. }
  3119. //数据排序
  3120. $order_str = "time desc";
  3121. if (empty($page)) {
  3122. $start = 0;
  3123. $perpage = 1;
  3124. } else {
  3125. $start = ($page - 1) * $perpage;
  3126. }
  3127. //取得信息列表
  3128. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3129. foreach ($info_list as $key => $value) {
  3130. $warehouse = $this->warehouse->read($value['warehouse']);
  3131. $info_list[$key]['warehouse'] = $warehouse['title'];
  3132. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3133. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3134. $purchase = $this->purchase->read($value['purchase']);
  3135. $info_list[$key]['purchase'] = $purchase['title'];
  3136. if ($value['outk'] != 0) {
  3137. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3138. } else {
  3139. $info_list[$key]['outk'] = "";
  3140. }
  3141. if ($value['retreat'] != 0) {
  3142. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3143. } else {
  3144. $info_list[$key]['retreat'] = "";
  3145. }
  3146. if ($value['orderinfo'] == 0) {
  3147. $info_list[$key]['orderinfo'] = "";
  3148. }
  3149. if ($value['waybill'] == 0) {
  3150. $info_list[$key]['waybill'] = "";
  3151. }
  3152. }
  3153. $total = $this->whlabel->find_count($where);
  3154. $pagenum = ceil($total / $perpage);
  3155. $over = $total - ($start + $perpage);
  3156. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3157. echo json_encode($rows);
  3158. exit;
  3159. }
  3160. $this->_Template('whlabel_retreatlk', $this->data);
  3161. }
  3162. //更换标签及浏览
  3163. public function _change()
  3164. {
  3165. $post = $this->input->post(NULL, TRUE);
  3166. if (isset($post['page'])) {
  3167. $page = $this->input->post('page', true);
  3168. $perpage = $this->input->post('perpage', true);
  3169. $timetk = $this->input->post('timetk', true);
  3170. $timetj = $this->input->post('timetj', true);
  3171. $label = $this->input->post('label', true);
  3172. $oldlabel = $this->input->post('oldlabel', true);
  3173. $timetk = strtotime($timetk);
  3174. $timetj = strtotime($timetj);
  3175. $where = "state=10 ";
  3176. if ($timetk && $timetj) {
  3177. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3178. }
  3179. if ($label) {
  3180. $where .= " and label = '$label'";
  3181. }
  3182. if ($oldlabel) {
  3183. $where .= " and oldlabel = '$oldlabel'";
  3184. }
  3185. //数据排序
  3186. $order_str = "time asc";
  3187. if (empty($page)) {
  3188. $start = 0;
  3189. $perpage = 1;
  3190. } else {
  3191. $start = ($page - 1) * $perpage;
  3192. }
  3193. //取得信息列表
  3194. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3195. foreach ($info_list as $key => $value) {
  3196. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3197. }
  3198. $total = $this->whlabel->find_count($where);
  3199. $pagenum = ceil($total / $perpage);
  3200. $over = $total - ($start + $perpage);
  3201. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3202. echo json_encode($rows);
  3203. exit;
  3204. }
  3205. $this->_Template('whlabel_change', $this->data);
  3206. }
  3207. //产品标签
  3208. public function _cpbqdc()
  3209. {
  3210. if (isset($_GET['excel'])) {
  3211. $where = "1=1";
  3212. //数据排序
  3213. $order_str = "id desc";
  3214. if (empty($page)) {
  3215. $start = 0;
  3216. $perpage = 1;
  3217. } else {
  3218. $start = ($page - 1) * $perpage;
  3219. }
  3220. $warehouse = $this->input->get('warehouse', true);
  3221. $state = $this->input->get('state', true);
  3222. $timetk = $this->input->get('timetkk', true);
  3223. $timetj = $this->input->get('timetjj', true);
  3224. $timetk = strtotime($timetk);
  3225. $timetj = strtotime($timetj);
  3226. if ($warehouse) {
  3227. $where .= " and warehouse = '$warehouse'";
  3228. }
  3229. if ($state || $state == 0) {
  3230. $where .= " and state = '$state'";
  3231. }
  3232. if ($timetk && $timetj) {
  3233. $where .= " and time > '$timetk' and time < '$timetj'";
  3234. }
  3235. //取得信息列表
  3236. $info_list = $this->whlabel->find_all($where, '*');
  3237. $rows = array();
  3238. $list = array();
  3239. foreach ($info_list as $key => $value) {
  3240. $rows[$value['time']] = $value; //所有数据sku
  3241. }
  3242. foreach ($rows as $value) {
  3243. $warehouse = $this->warehouse->read($value['warehouse']);
  3244. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3245. $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);
  3246. }
  3247. $title = "产品标签统计表";
  3248. $titlename = "<table border=1>
  3249. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3250. <tr align='center'>
  3251. <td>仓库</td>
  3252. <td>SKU</td>
  3253. <td>产品</td>
  3254. <td>入库时间</td>
  3255. <td>操作时间</td>
  3256. <td>备注</td>
  3257. <td>数量</td>
  3258. </tr>
  3259. </table>";
  3260. $filename = $title . ".xls";
  3261. $tail = "";
  3262. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3263. }
  3264. }
  3265. //进销存导出
  3266. public function _exceljxc()
  3267. {
  3268. $classid = $this->classid->sku();
  3269. $pm = $classid;
  3270. $typeclass = array();
  3271. $tc = $this->typeclass->find_all();
  3272. foreach ($tc as $v) {
  3273. $typeclass[$v['id']] = $v;
  3274. }
  3275. $prc = array();
  3276. $purchase = $this->purchase->find_all();
  3277. foreach ($purchase as $k => $v) {
  3278. $prc[$v['id']] = $v['title'];
  3279. }
  3280. if (isset($_GET['excel'])) {
  3281. $where = "sku != 'Preset'";
  3282. //数据排序
  3283. $order_str = "id desc";
  3284. if (empty($page)) {
  3285. $start = 0;
  3286. $perpage = 1;
  3287. } else {
  3288. $start = ($page - 1) * $perpage;
  3289. }
  3290. $category = $this->input->get('category', true);
  3291. $warehouse = $this->input->get('warehouse', true);
  3292. $excelid = $this->input->get('sid', true);
  3293. if ($category) {
  3294. $where .= " and features like '%-$category-%'";
  3295. }
  3296. if ($warehouse) {
  3297. $where .= " and warehouse = '$warehouse'";
  3298. }
  3299. $xzid = '';
  3300. if ($excelid) {
  3301. $excelid = explode(',', trim($excelid, ','));
  3302. foreach ($excelid as $key => $value) {
  3303. $xzid .= " id = " . $value . " or";
  3304. }
  3305. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3306. }
  3307. //取得信息列表
  3308. /**
  3309. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3310. $rows = array();$list = array();
  3311. foreach ($info_list as $key=>$value)
  3312. {
  3313. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3314. }
  3315. **/
  3316. $wt = array();
  3317. $whlabel_type = $this->whlabel_type->find_all();
  3318. foreach ($whlabel_type as $v) {
  3319. $wt[$v['id']] = $v['title'];
  3320. }
  3321. $wh = array();
  3322. $w = $this->warehouse->find_all('1=1', 'id,title');
  3323. foreach ($w as $v) {
  3324. $wh[$v['id']] = $v['title'];
  3325. }
  3326. $list = array();
  3327. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3328. foreach ($rows as $key => $value) {
  3329. if (isset($wt[$value['type']])) {
  3330. $rows[$key]['type'] = $wt[$value['type']];
  3331. } else {
  3332. $rows[$key]['type'] = '未设置';
  3333. }
  3334. $bm = '03';
  3335. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3336. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3337. $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');
  3338. $details = array();
  3339. $cpid = array();
  3340. $cpbz = array();
  3341. $c = 0;
  3342. $g = 0;
  3343. $x = 0;
  3344. $t = 0;
  3345. $s = 0;
  3346. $q = 0;
  3347. foreach ($sd as $k => $v) {
  3348. if ($v['state'] == 0) {
  3349. $c++;
  3350. if ($v['cpid'] != 0) {
  3351. $cpid[$v['cpid']] = $v['cpid'];
  3352. }
  3353. if ($v['cpbz'] != '') {
  3354. $cpbz[$v['cpbz']] = $v['cpbz'];
  3355. }
  3356. }
  3357. if ($v['state'] != 9) {
  3358. $g++;
  3359. }
  3360. if ($v['state'] == 1) {
  3361. $x++;
  3362. }
  3363. if ($v['state'] == 2) {
  3364. $t++;
  3365. }
  3366. if ($v['state'] == 8) {
  3367. $s++;
  3368. }
  3369. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3370. $q++;
  3371. }
  3372. $details[$v['details']] = $v['details'];
  3373. }
  3374. $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'] . '"');
  3375. $rows[$key]['details'] = implode("、", $details);
  3376. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3377. $number = $value['number'];
  3378. $ftime = time() - 15 * 24 * 3600;
  3379. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3380. $rows[$key]['number'] = $g;
  3381. $rows[$key]['c'] = $c;
  3382. $rows[$key]['x'] = $x;
  3383. $rows[$key]['t'] = $t;
  3384. $rows[$key]['s'] = $s;
  3385. $rows[$key]['q'] = $q;
  3386. $rows[$key]['z'] = $z;
  3387. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3388. $features = explode('-', trim($features, '-'));
  3389. $rows[$key]['dbcontent'] = $typeclass[$features[0]]['title'];
  3390. // $pm = $classid;
  3391. // $jm = $classid;
  3392. // foreach($features as $k=>$v)
  3393. // {
  3394. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3395. // {
  3396. // if($typeclass[$v]['bm'] != '')
  3397. // {
  3398. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3399. // }
  3400. // }
  3401. // if($v != 0)
  3402. // {
  3403. // if(!isset($typeclass[$v]))
  3404. // {
  3405. // continue;
  3406. // }
  3407. // if(isset($pm[$typeclass[$v]['classid']]))
  3408. // {
  3409. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3410. // {
  3411. // $tz = explode('|',$typeclass[$v]['zh']);
  3412. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3413. // }
  3414. // else
  3415. // {
  3416. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3417. // }
  3418. // }
  3419. // if(isset($jm[$typeclass[$v]['classid']]))
  3420. // {
  3421. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3422. // }
  3423. // }
  3424. // }
  3425. // $jm = array_filter($jm);
  3426. // $rows[$key]['bs'] = implode("-",$jm);
  3427. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3428. // $zh = implode(" ",$pm);
  3429. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3430. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3431. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3432. // $rows[$key]['features'] = $zh;
  3433. }
  3434. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3435. $final_list = [];
  3436. foreach ($list as $k => $v) {
  3437. if (empty($v['sku'])) {
  3438. continue;
  3439. }
  3440. $final_list[] = [
  3441. "warehouse" => $v["warehouse"],
  3442. "purchase" => $v["purchase"],
  3443. "details" => $v["details"],
  3444. "cpid" => $v["cpid"],
  3445. "dbcontent" => $v["dbcontent"],
  3446. "sku" => $v["sku"],
  3447. "cs" => $v["bm"],
  3448. "bs" => $v["jm"],
  3449. "title" => $v["title"],
  3450. "features" => $v["pm"],
  3451. "cpbz" => $v["cpbz"],
  3452. "sm" => $v["sm"],
  3453. "type" => $v["type"],
  3454. "number" => $v["number"],
  3455. "c" => $v["c"],
  3456. "x" => $v["x"],
  3457. "t" => $v["t"],
  3458. "s" => $v["s"],
  3459. "q" => $v["q"],
  3460. "z" => $v["z"],
  3461. "weight" => $v['weight'],
  3462. ];
  3463. }
  3464. $title = "总进销存统计表";
  3465. $titlename = "<table border=1>
  3466. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3467. <tr align='center'>
  3468. <td>仓库</td>
  3469. <td>供应商</td>
  3470. <td>位置</td>
  3471. <td>库存编码</td>
  3472. <td>类目</td>
  3473. <td>SKU</td>
  3474. <td>用友编码</td>
  3475. <td>用友料号</td>
  3476. <td>商品名称</td>
  3477. <td>商品中文</td>
  3478. <td>产品备注</td>
  3479. <td>说明</td>
  3480. <td>类型</td>
  3481. <td>入库总量</td>
  3482. <td>库存数量</td>
  3483. <td>销售数量</td>
  3484. <td>退货数量</td>
  3485. <td>删除数量</td>
  3486. <td>其它操作</td>
  3487. <td>占单数量</td>
  3488. <td>重量(g)</td>
  3489. </tr>
  3490. </table>";
  3491. $filename = $title . ".xls";
  3492. $tail = "";
  3493. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3494. }
  3495. }
  3496. //入库导出
  3497. public function _excelr()
  3498. {
  3499. if (isset($_GET['excel'])) {
  3500. $category = $this->input->get('category', true);
  3501. $size = $this->input->get('size', true);
  3502. $grade = $this->input->get('grade', true);
  3503. $color = $this->input->get('color', true);
  3504. $lowe = $this->input->get('lowe', true);
  3505. $sku = $this->input->get('sku', true);
  3506. $warehouse = $this->input->get('warehouse', true);
  3507. $purchase = $this->input->get('purchase', true);
  3508. $ktime = $this->input->get('ktime', true);
  3509. $jtime = $this->input->get('jtime', true);
  3510. $ktime = strtotime($ktime);
  3511. $jtime = strtotime($jtime);
  3512. $where = "1=1";
  3513. $gj = "";
  3514. $ck = "";
  3515. if ($category) {
  3516. $where .= " and features like '%-$category-%'";
  3517. }
  3518. if ($size) {
  3519. $where .= " and features like '%-$size-%'";
  3520. }
  3521. if ($grade) {
  3522. $where .= " and features like '%-$grade-%'";
  3523. }
  3524. if ($color) {
  3525. $where .= " and features like '%-$color-%'";
  3526. }
  3527. if ($lowe) {
  3528. $where .= " and features like '%-$lowe-%'";
  3529. }
  3530. if ($warehouse) {
  3531. $where .= " and warehouse = '$warehouse'";
  3532. }
  3533. if ($purchase) {
  3534. $where .= " and purchase = '$purchase'";
  3535. }
  3536. if ($sku) {
  3537. $where .= " and sku = '$sku'";
  3538. }
  3539. if ($ktime && $jtime) {
  3540. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3541. }
  3542. //数据排序
  3543. $order_str = "id desc";
  3544. if (empty($page)) {
  3545. $start = 0;
  3546. $perpage = 1;
  3547. } else {
  3548. $start = ($page - 1) * $perpage;
  3549. }
  3550. $list = array();
  3551. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3552. foreach ($rows as $value) {
  3553. $ck = $this->warehouse->read($value['warehouse']);
  3554. $warehouse = $ck['title'];
  3555. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3556. $retreatwarehouse = $tkck['title'];
  3557. $gy = $this->purchase->read($value['purchase']);
  3558. $purchase = $gy['title'];
  3559. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3560. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3561. }
  3562. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3563. $titlename = "<table border=1>
  3564. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3565. <tr align='center'>
  3566. <td>仓库</td>
  3567. <td>SKU</td>
  3568. <td>产品</td>
  3569. <td>时间</td>
  3570. <td>数量</td>
  3571. </tr>
  3572. </table>";
  3573. $filename = $title . ".xls";
  3574. $tail = "";
  3575. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3576. }
  3577. }
  3578. //出库、退库导出
  3579. public function _excelct()
  3580. {
  3581. $classid = $this->classid->sku();
  3582. $pm = $classid;
  3583. $typeclass = array();
  3584. $tc = $this->typeclass->find_all();
  3585. foreach ($tc as $v) {
  3586. $typeclass[$v['id']] = $v;
  3587. }
  3588. $prc = array();
  3589. $purchase = $this->purchase->find_all();
  3590. foreach ($purchase as $k => $v) {
  3591. $prc[$v['id']] = $v['title'];
  3592. }
  3593. if (isset($_GET['excel'])) {
  3594. $wh = array();
  3595. $w = $this->warehouse->find_all('1=1', 'id,title');
  3596. foreach ($w as $v) {
  3597. $wh[$v['id']] = $v['title'];
  3598. }
  3599. $type = $this->input->get('excel', true);
  3600. $category = $this->input->get('category', true);
  3601. $size = $this->input->get('size', true);
  3602. $grade = $this->input->get('grade', true);
  3603. $color = $this->input->get('color', true);
  3604. $lowe = $this->input->get('lowe', true);
  3605. $sku = $this->input->get('sku', true);
  3606. $warehouse = $this->input->get('warehouse', true);
  3607. $lacetype = $this->input->get('lacetype', true);
  3608. $lacecolor = $this->input->get('lacecolor', true);
  3609. $density = $this->input->get('density', true);
  3610. $haircap = $this->input->get('haircap', true);
  3611. $purchase = $this->input->get('purchase', true);
  3612. $title = $this->input->get('title', true);
  3613. $state = $this->input->get('state', true);
  3614. $sid = $this->input->get('sid', true);
  3615. $ktime = $this->input->get('ktime', true);
  3616. $jtime = $this->input->get('jtime', true);
  3617. $ktime = strtotime($ktime);
  3618. $jtime = strtotime($jtime);
  3619. $where = "1=1";
  3620. $gj = "";
  3621. $ck = "";
  3622. if ($category) {
  3623. $where .= " and features like '%-$category-%'";
  3624. }
  3625. if ($size) {
  3626. $where .= " and features like '%-$size-%'";
  3627. }
  3628. if ($grade) {
  3629. $where .= " and features like '%-$grade-%'";
  3630. }
  3631. if ($color) {
  3632. $where .= " and features like '%-$color-%'";
  3633. }
  3634. if ($lowe) {
  3635. $where .= " and features like '%-$lowe-%'";
  3636. }
  3637. if ($warehouse) {
  3638. $where .= " and warehouse = '$warehouse'";
  3639. }
  3640. if ($purchase) {
  3641. $where .= " and purchase = '$purchase'";
  3642. }
  3643. if ($state) {
  3644. $where .= " and state = '$state'";
  3645. }
  3646. if ($lacetype) {
  3647. $where .= " and features like '%-$lacetype-%'";
  3648. }
  3649. if ($lacecolor) {
  3650. $where .= " and features like '%-$lacecolor-%'";
  3651. }
  3652. if ($density) {
  3653. $where .= " and features like '%-$density-%'";
  3654. }
  3655. if ($haircap) {
  3656. $where .= " and features like '%-$haircap-%'";
  3657. }
  3658. if ($title) {
  3659. $title = trim($title, ' ');
  3660. $title = trim($title, ' ');
  3661. $where .= " and title like '%$title%'";
  3662. }
  3663. if ($sku) {
  3664. $sku = trim($sku, ' ');
  3665. $sku = trim($sku, ' ');
  3666. $where .= " and sku like '%$sku%'";
  3667. }
  3668. if ($ktime && $jtime) {
  3669. if ($type == 1) {
  3670. $tl = '出库';
  3671. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3672. } else if ($type == 2) {
  3673. $tl = '退库';
  3674. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3675. } else if ($type == 3) {
  3676. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3677. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3678. } else if ($type == 4) {
  3679. $tl = '出库+零售';
  3680. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3681. } else if ($type == 5) {
  3682. $tl = '零售';
  3683. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3684. }
  3685. }
  3686. $sidwhere = '';
  3687. if ($sid) {
  3688. $sd = "";
  3689. $s = explode(',', trim($sid, ','));
  3690. foreach ($s as $value) {
  3691. $sd .= " id = " . $value . " or";
  3692. }
  3693. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3694. }
  3695. //数据排序
  3696. $order_str = "time desc";
  3697. if (empty($page)) {
  3698. $start = 0;
  3699. $perpage = 1;
  3700. } else {
  3701. $start = ($page - 1) * $perpage;
  3702. }
  3703. //取得信息列表
  3704. if ($type != 3 && $type != 5) {
  3705. if ($type == 1 || $type == 4) {
  3706. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3707. foreach ($info_list as $key => $value) {
  3708. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3709. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3710. $warehouse = $this->warehouse->read($value['warehouse']);
  3711. $info_list[$key]['warehouse'] = $warehouse['title'];
  3712. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3713. $features = explode('-', trim($features, '-'));
  3714. $pm = $classid;
  3715. foreach ($features as $k => $v) {
  3716. if ($v != 0) {
  3717. if (!isset($typeclass[$v])) {
  3718. continue;
  3719. }
  3720. if (isset($pm[$typeclass[$v]['classid']])) {
  3721. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3722. $tz = explode('|', $typeclass[$v]['zh']);
  3723. $pm[$typeclass[$v]['classid']] = $tz[0];
  3724. } else {
  3725. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3726. }
  3727. }
  3728. }
  3729. }
  3730. $zh = implode(" ", $pm);
  3731. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3732. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3733. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3734. $info_list[$key]['features'] = $zh;
  3735. }
  3736. $final_list = [];
  3737. foreach($info_list as $k=>$v){
  3738. $number = "";
  3739. if(!empty($v['orderinfo'])){
  3740. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3741. if(!empty($tmp_info['number'])){
  3742. $number = $tmp_info['number'];
  3743. }
  3744. }
  3745. $final_list[] = [
  3746. 'warehouse'=>$v['warehouse'],
  3747. 'purchase'=>$v['purchase'],
  3748. 'sku'=>$v['sku'],
  3749. 'title'=>$v['title'],
  3750. 'features'=>$v['features'],
  3751. 'label'=>$v['label'],
  3752. 'orderinfo'=>$v['orderinfo'],
  3753. 'number'=>$number,
  3754. 'waybill'=>$v['waybill'],
  3755. 'outk'=>$v['outk'],
  3756. ];
  3757. }
  3758. } else {
  3759. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3760. foreach ($info_list as $key => $value) {
  3761. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3762. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3763. $warehouse = $this->warehouse->read($value['warehouse']);
  3764. $info_list[$key]['warehouse'] = $warehouse['title'];
  3765. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3766. $features = explode('-', trim($features, '-'));
  3767. $pm = $classid;
  3768. foreach ($features as $k => $v) {
  3769. if ($v != 0) {
  3770. if (!isset($typeclass[$v])) {
  3771. continue;
  3772. }
  3773. if (isset($pm[$typeclass[$v]['classid']])) {
  3774. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3775. $tz = explode('|', $typeclass[$v]['zh']);
  3776. $pm[$typeclass[$v]['classid']] = $tz[0];
  3777. } else {
  3778. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3779. }
  3780. }
  3781. }
  3782. }
  3783. $zh = implode(" ", $pm);
  3784. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3785. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3786. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3787. $info_list[$key]['features'] = $zh;
  3788. }
  3789. $final_list = [];
  3790. foreach($info_list as $k=>$v){
  3791. $number = "";
  3792. if(!empty($v['orderinfo'])){
  3793. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3794. if(!empty($tmp_info['number'])){
  3795. $number = $tmp_info['number'];
  3796. }
  3797. }
  3798. $final_list[] = [
  3799. 'warehouse'=>$v['warehouse'],
  3800. 'purchase'=>$v['purchase'],
  3801. 'sku'=>$v['sku'],
  3802. 'title'=>$v['title'],
  3803. 'features'=>$v['features'],
  3804. 'label'=>$v['label'],
  3805. 'orderinfo'=>$v['orderinfo'],
  3806. 'number'=>$number,
  3807. 'waybill'=>$v['waybill'],
  3808. 'retreat'=>$v['retreat'],
  3809. ];
  3810. }
  3811. }
  3812. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3813. $titlename = "<table border=1>
  3814. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3815. <tr align='center'>
  3816. <td>仓库</td>
  3817. <td>供应商</td>
  3818. <td>SKU</td>
  3819. <td>商品名称</td>
  3820. <td>商品中文</td>
  3821. <td>标签</td>
  3822. <td>订单号</td>
  3823. <td>订单编码</td>
  3824. <td>运单号</td>
  3825. <td>" . $tl . "时间(中国时间)</td>
  3826. </tr>
  3827. </table>";
  3828. $filename = $title . ".xls";
  3829. $tail = "";
  3830. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3831. } else if ($type == 5) {
  3832. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3833. foreach ($info_list as $key => $value) {
  3834. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3835. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3836. $warehouse = $this->warehouse->read($value['warehouse']);
  3837. $info_list[$key]['warehouse'] = $warehouse['title'];
  3838. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3839. $features = explode('-', trim($features, '-'));
  3840. $pm = $classid;
  3841. foreach ($features as $k => $v) {
  3842. if ($v != 0) {
  3843. if (!isset($typeclass[$v])) {
  3844. continue;
  3845. }
  3846. if (isset($pm[$typeclass[$v]['classid']])) {
  3847. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3848. $tz = explode('|', $typeclass[$v]['zh']);
  3849. $pm[$typeclass[$v]['classid']] = $tz[0];
  3850. } else {
  3851. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3852. }
  3853. }
  3854. }
  3855. }
  3856. $zh = implode(" ", $pm);
  3857. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3858. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3859. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3860. $info_list[$key]['features'] = $zh;
  3861. }
  3862. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3863. $titlename = "<table border=1>
  3864. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3865. <tr align='center'>
  3866. <td>仓库</td>
  3867. <td>供应商</td>
  3868. <td>SKU</td>
  3869. <td>商品名称</td>
  3870. <td>商品中文</td>
  3871. <td>标签</td>
  3872. <td>" . $tl . "时间(中国时间)</td>
  3873. </tr>
  3874. </table>";
  3875. $filename = $title . ".xls";
  3876. $tail = "";
  3877. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3878. } else {
  3879. /**
  3880. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  3881. $rows = array();$list = array();
  3882. foreach ($info_list as $key=>$value)
  3883. {
  3884. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  3885. }
  3886. **/
  3887. $wh = array();
  3888. $w = $this->warehouse->find_all('1=1', 'id,title');
  3889. foreach ($w as $v) {
  3890. $wh[$v['id']] = $v['title'];
  3891. }
  3892. $wt = array();
  3893. $whlabel_type = $this->whlabel_type->find_all();
  3894. foreach ($whlabel_type as $v) {
  3895. $wt[$v['id']] = $v['title'];
  3896. }
  3897. $classid = $this->classid->sku();
  3898. $list = array();
  3899. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  3900. foreach ($rows as $key => $value) {
  3901. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3902. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3903. $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');
  3904. $details = array();
  3905. $cpid = array();
  3906. $cpbz = array();
  3907. $c = 0;
  3908. $g = 0;
  3909. $x = 0;
  3910. $t = 0;
  3911. $s = 0;
  3912. $q = 0;
  3913. foreach ($sd as $k => $v) {
  3914. if ($v['state'] == 0) {
  3915. $c++;
  3916. }
  3917. if ($v['state'] != 9) {
  3918. $g++;
  3919. }
  3920. if ($v['outk'] > 1) {
  3921. $x++;
  3922. }
  3923. if ($v['retreat'] > 0) {
  3924. $t++;
  3925. }
  3926. if ($v['state'] == 8) {
  3927. $s++;
  3928. }
  3929. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3930. $q++;
  3931. }
  3932. $details[$v['details']] = $v['details'];
  3933. if ($v['cpid'] != 0) {
  3934. $cpid[$v['cpid']] = $v['cpid'];
  3935. }
  3936. if ($v['cpbz'] != '') {
  3937. $cpbz[$v['cpbz']] = $v['cpbz'];
  3938. }
  3939. }
  3940. if (isset($wt[$value['type']])) {
  3941. $rows[$key]['type'] = $wt[$value['type']];
  3942. } else {
  3943. $rows[$key]['type'] = '未设置';
  3944. }
  3945. $rows[$key]['details'] = implode("、", $details);
  3946. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3947. $ftime = time() - 15 * 24 * 3600;
  3948. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3949. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  3950. $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);
  3951. $rows[$key]['c'] = $c;
  3952. $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);
  3953. $rows[$key]['t'] = $t;
  3954. $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'] . '"');
  3955. $rows[$key]['z'] = $z;
  3956. // $jm = $classid;
  3957. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3958. $features = explode('-', trim($features, '-'));
  3959. // $pm = $classid;
  3960. // foreach ($features as $k => $v) {
  3961. // if ($v != 0) {
  3962. // if (!isset($typeclass[$v])) {
  3963. // continue;
  3964. // }
  3965. // if (isset($pm[$typeclass[$v]['classid']])) {
  3966. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3967. // $tz = explode('|', $typeclass[$v]['zh']);
  3968. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3969. // } else {
  3970. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3971. // }
  3972. // if (isset($jm[$typeclass[$v]['classid']])) {
  3973. // if ($typeclass[$v]['jm']) {
  3974. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3975. // }
  3976. // }
  3977. // }
  3978. // }
  3979. // }
  3980. // $zh = implode(" ", $pm);
  3981. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3982. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3983. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3984. // $rows[$key]['features'] = $zh;
  3985. // $jm = array_filter($jm); //去除空值
  3986. // $jm = implode("-", $jm);
  3987. // $rows[$key]['jm'] = $jm;
  3988. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  3989. }
  3990. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  3991. // echo "<pre>";
  3992. // print_r($tmp_list);
  3993. // die;
  3994. $final_list =[];
  3995. foreach($tmp_list as $k=>$v){
  3996. $final_list[] = [
  3997. "warehouse"=>$v['warehouse'],
  3998. "purchase"=>$v['purchase'],
  3999. "details"=>$v['details'],
  4000. "cpid"=>$v['cpid'],
  4001. "sku"=>$v['sku'],
  4002. "title"=>$v['title'],
  4003. "features"=>$v['pm'],
  4004. "cpbz"=>$v['cpbz'],
  4005. "sm"=>$v['sm'],
  4006. "type"=>$v['type'],
  4007. "g"=>$v["g"],
  4008. "c"=>$v["c"],
  4009. "x"=>$v["x"],
  4010. "t"=>$v["t"],
  4011. "z"=>$v["z"],
  4012. "jm"=>$v["jm"],
  4013. "weight"=>$v["weight"],
  4014. "asd"=>$v["asd"],
  4015. ];
  4016. }
  4017. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4018. $titlename = "<table border=1>
  4019. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4020. <tr align='center'>
  4021. <td>仓库</td>
  4022. <td>供应商</td>
  4023. <td>位置</td>
  4024. <td>库存编码</td>
  4025. <td>SKU</td>
  4026. <td>商品名称</td>
  4027. <td>商品中文</td>
  4028. <td>产品备注</td>
  4029. <td>说明</td>
  4030. <td>类型</td>
  4031. <td>入库总量</td>
  4032. <td>库存数量</td>
  4033. <td>销售数量</td>
  4034. <td>退货数量</td>
  4035. <td>占单数量</td>
  4036. <td>料号</td>
  4037. <td>重量</td>
  4038. <td>类目</td>
  4039. </tr>
  4040. </table>";
  4041. $filename = $title . ".xls";
  4042. $tail = "";
  4043. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4044. }
  4045. }
  4046. }
  4047. //出库+入库数据整合
  4048. public function _excelcr()
  4049. {
  4050. if (isset($_GET['excel'])) {
  4051. $type = $this->input->get('excel', true);
  4052. $category = $this->input->get('category', true);
  4053. $size = $this->input->get('size', true);
  4054. $grade = $this->input->get('grade', true);
  4055. $color = $this->input->get('color', true);
  4056. $lowe = $this->input->get('lowe', true);
  4057. $sku = $this->input->get('sku', true);
  4058. $warehouse = $this->input->get('warehouse', true);
  4059. $purchase = $this->input->get('purchase', true);
  4060. $state = $this->input->get('state', true);
  4061. $sid = $this->input->get('sid', true);
  4062. $ktime = $this->input->get('ktime', true);
  4063. $jtime = $this->input->get('jtime', true);
  4064. $ktime = strtotime($ktime);
  4065. $jtime = strtotime($jtime);
  4066. $where = "1=1";
  4067. $gj = "";
  4068. $ck = "";
  4069. if ($category) {
  4070. $where .= " and features like '%-$category-%'";
  4071. }
  4072. if ($size) {
  4073. $where .= " and features like '%-$size-%'";
  4074. }
  4075. if ($grade) {
  4076. $where .= " and features like '%-$grade-%'";
  4077. }
  4078. if ($color) {
  4079. $where .= " and features like '%-$color-%'";
  4080. }
  4081. if ($lowe) {
  4082. $where .= " and features like '%-$lowe-%'";
  4083. }
  4084. if ($warehouse) {
  4085. $where .= " and warehouse = '$warehouse'";
  4086. }
  4087. if ($purchase) {
  4088. $where .= " and purchase = '$purchase'";
  4089. }
  4090. if ($state) {
  4091. $where .= " and state = '$state'";
  4092. }
  4093. if ($sku) {
  4094. $where .= " and sku like '%$sku%'";
  4095. }
  4096. if ($ktime && $jtime) {
  4097. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4098. }
  4099. $sidwhere = '';
  4100. if ($sid) {
  4101. $sd = "";
  4102. $s = explode(',', trim($sid, ','));
  4103. foreach ($s as $value) {
  4104. $sd .= " id = " . $value . " or";
  4105. }
  4106. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4107. }
  4108. //取得信息列表
  4109. $timeread = $ktime;
  4110. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4111. $timelist = array();
  4112. for ($i = 0; $i < $timenum; $i++) {
  4113. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4114. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4115. }
  4116. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4117. //echo "<pre>";
  4118. //print_r($info_list);
  4119. //exit();
  4120. $rows = array();
  4121. $list = array();
  4122. foreach ($info_list as $key => $value) {
  4123. $thistime = $timelist;
  4124. if (isset($rows[strtolower($value['sku'])])) {
  4125. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4126. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4127. }
  4128. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4129. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4130. }
  4131. } else {
  4132. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4133. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4134. }
  4135. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4136. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4137. }
  4138. $rows[strtolower($value['sku'])] = $thistime;
  4139. }
  4140. }
  4141. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4142. <head>
  4143. <!--[if gte mso 9]><xml>
  4144. <x:ExcelWorkbook>
  4145. <x:ExcelWorksheets>
  4146. <x:ExcelWorksheet>
  4147. <x:Name>EXCEL</x:Name>
  4148. <x:WorksheetOptions>
  4149. <x:Print>
  4150. <x:ValidPrinterInfo />
  4151. </x:Print>
  4152. </x:WorksheetOptions>
  4153. </x:ExcelWorksheet>
  4154. </x:ExcelWorksheets>
  4155. </x:ExcelWorkbook>
  4156. </xml>
  4157. <![endif]-->
  4158. </head><body>";
  4159. $str .= "<table border=1><tr><td>SKU</td>";
  4160. foreach ($timelist as $k => $v) {
  4161. $str .= "<td>" . $k . "出库</td>";
  4162. $str .= "<td>" . $k . "入库</td>";
  4163. }
  4164. $str .= "</tr></table>";
  4165. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4166. foreach ($rows as $key => $val) {
  4167. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4168. foreach ($val as $k => $v) {
  4169. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4170. if ($val[$k]['r'] > 0) {
  4171. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4172. } else {
  4173. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4174. }
  4175. }
  4176. $str .= "</tr>";
  4177. }
  4178. $str .= "</table>";
  4179. $str .= "</body></html>";
  4180. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4181. header("Content-type: application/octet-stream");
  4182. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4183. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4184. header("Pragma: no-cache");
  4185. header("Expires: 0");
  4186. exit($str);
  4187. }
  4188. }
  4189. //数量调整模板导出
  4190. public function _presetout()
  4191. {
  4192. if (isset($_GET['excel'])) {
  4193. $where = "sku != 'Preset' and purchase != 0";
  4194. //数据排序
  4195. $order_str = "id desc";
  4196. if (empty($page)) {
  4197. $start = 0;
  4198. $perpage = 1;
  4199. } else {
  4200. $start = ($page - 1) * $perpage;
  4201. }
  4202. //取得信息列表
  4203. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4204. $rows = array();
  4205. $list = array();
  4206. foreach ($info_list as $value) {
  4207. $warehouse = $this->warehouse->read($value['warehouse']);
  4208. $number = $value['number'];
  4209. $ftime = time() - 15 * 24 * 3600;
  4210. $purchase = $this->purchase->read($value['purchase']);
  4211. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4212. }
  4213. $title = "库存模板";
  4214. $titlename = "<table border=1>
  4215. <tr align='center'>
  4216. <td>仓库</td>
  4217. <td>供应商编码</td>
  4218. <td>SKU</td>
  4219. <td>增减数量(正数或负数)</td>
  4220. <td>增减备注</td>
  4221. <td>扣减方式:0减少库存1删除库存</td>
  4222. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4223. <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4224. </tr>
  4225. </table>";
  4226. $filename = $title . ".xls";
  4227. $tail = "";
  4228. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4229. }
  4230. }
  4231. //数量调整模板导入
  4232. public function _presetedit()
  4233. {
  4234. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4235. $config['upload_path'] = '.' . $dir;
  4236. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4237. $config['allowed_types'] = 'xls|xlsx|csv';
  4238. $config['max_size'] = 10240;
  4239. $this->load->library('upload', $config);
  4240. $this->upload->initialize($config);
  4241. if ($this->upload->do_upload('userfile')) {
  4242. $full_path = $dir . $this->upload->data('file_name');
  4243. $fileName = '.' . $full_path;
  4244. if (!file_exists($fileName)) {
  4245. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4246. exit;
  4247. } else {
  4248. require_once "./data/excel/PHPExcel/IOFactory.php";
  4249. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4250. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4251. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4252. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4253. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4254. ++$column; //如果列数大于26行
  4255. $list = array();
  4256. for ($i = 2; $i <= $row; $i++) // 行数循环
  4257. {
  4258. $data = array();
  4259. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4260. {
  4261. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4262. }
  4263. $list[] = $data;
  4264. }
  4265. }
  4266. $i = 0;
  4267. $j = 0;
  4268. $ed = array();
  4269. foreach ($list as $key => $value) {
  4270. $time = time();
  4271. if ($value['0'] == "") {
  4272. continue;
  4273. }
  4274. $warehouse = $this->warehouse->get_title($value['0']);
  4275. $purchase = $this->purchase->get_bm($value['1']);
  4276. $sku = $value['2'];
  4277. $num = $value['3']; //调整数量
  4278. $text = $value['4']; //扣减说明
  4279. $type = $value['5']; //调整方式0扣减1删除
  4280. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4281. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4282. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4283. if (!$purchase) //如果没有这个SKU
  4284. {
  4285. $ed[] = array($purchase . '-不存在此供应商编码');
  4286. $j++;
  4287. continue;
  4288. }
  4289. if (!$d) //如果没有这个SKU
  4290. {
  4291. $ed[] = array($sku . '-库存中不存在此SKU');
  4292. $j++;
  4293. continue;
  4294. }
  4295. if (!isset($warehouse['id'])) {
  4296. $ed[] = array($sku . '-仓库名错误!');
  4297. $j++;
  4298. continue;
  4299. }
  4300. if ($type != '0' && $type != '1') {
  4301. $ed[] = array($sku . '-扣减方式填写错误!');
  4302. $j++;
  4303. continue;
  4304. }
  4305. if ($num < 0) //扣减库存
  4306. {
  4307. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4308. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4309. $j++;
  4310. continue;
  4311. }
  4312. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4313. if (count($data) < abs($num)) {
  4314. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4315. $j++;
  4316. continue;
  4317. }
  4318. if ($type == 0) //如果扣减方式为 扣减库存
  4319. {
  4320. for ($i = 0; $i < abs($num); $i++) {
  4321. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4322. }
  4323. } else if ($type == 1) {
  4324. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4325. if (count($zt) > 0) {
  4326. $ed[] = array($sku . '-有在途库存无法删除!');
  4327. $j++;
  4328. continue;
  4329. }
  4330. for ($i = 0; $i < abs($num); $i++) {
  4331. $this->whlabel->remove($data[$i]['id']);
  4332. }
  4333. }
  4334. } else if ($num > 0) //增加库存
  4335. {
  4336. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4337. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4338. $j++;
  4339. continue;
  4340. }
  4341. $post['sku'] = $d['sku'];
  4342. $post['shop'] = $d['shop'];
  4343. $post['warehouse'] = $warehouse['id'];
  4344. $post['purchase'] = $purchase['id'];
  4345. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4346. $post['state'] = 0;
  4347. $post['title'] = $d['title'];
  4348. $post['number'] = $d['number'];
  4349. $post['features'] = $d['features'];
  4350. $post['enter'] = $time;
  4351. $post['time'] = $time; //操作时间
  4352. $post['rktype'] = $rktype;
  4353. for ($i = 0; $i < $num; $i++) {
  4354. $post['label'] = time() . rand(100, 999) . $i;
  4355. $this->whlabel->insert($post);
  4356. }
  4357. }
  4358. sleep(1); //防止入库时间一样,需要延迟1秒
  4359. }
  4360. if ($j > 0) {
  4361. $tt = date('Ymd', time());
  4362. $title = '库存导入错误信息-' . $tt;
  4363. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4364. $tail = "\n";
  4365. $filename = $title . ".xls";
  4366. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4367. $dir = '/data/excel/' . $time . '/';
  4368. $file_name = 'error_' . $time . rand(1000, 9999);
  4369. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4370. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4371. fwrite($myfile, $ecl);
  4372. fclose($myfile);
  4373. $error = $dir . $file_name . '.xls';
  4374. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4375. exit;
  4376. } else {
  4377. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4378. exit;
  4379. }
  4380. }
  4381. }
  4382. //笛卡儿积
  4383. function cp($ps, $sets, $list)
  4384. {
  4385. $result = array();
  4386. $j = 0;
  4387. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4388. if ($i == 0) {
  4389. $result = $sets[$i];
  4390. }
  4391. $tmp = array();
  4392. foreach ($result as $res) {
  4393. foreach ($sets[$i + 1] as $set) {
  4394. $tmp[] = $res . ',' . $set;
  4395. }
  4396. }
  4397. $result = $tmp;
  4398. }
  4399. $this->db->trans_begin();
  4400. foreach ($result as $v) {
  4401. $post = array();
  4402. $title = "";
  4403. $num = "";
  4404. $data = explode(',', $v);
  4405. for ($i = 0; $i < count($list); $i++) {
  4406. $post[$list[$i]] = $data[$i];
  4407. $typeclass = $this->typeclass->read($data[$i]);
  4408. $title = $title . $typeclass['title'] . " ";
  4409. if ($data[$i] != 0) {
  4410. $num .= $data[$i]; //所有数据ID拼接
  4411. }
  4412. }
  4413. foreach ($ps as $kp => $vp) {
  4414. $post[$kp] = $vp;
  4415. }
  4416. $post['number'] = $num;
  4417. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4418. if ($info_list) {
  4419. $j++;
  4420. } else {
  4421. $skunum = $this->whlabel->find_count();
  4422. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4423. $post['title'] = rtrim($title, ' ');
  4424. $this->whlabel->insert($post);
  4425. }
  4426. }
  4427. if ($this->db->trans_status() === FALSE) {
  4428. $this->db->trans_commit();
  4429. return NULL;
  4430. } else {
  4431. $this->db->trans_commit();
  4432. return $j;
  4433. }
  4434. }
  4435. public function _kj($arg_array)
  4436. {
  4437. if (isset($_POST['sku'])) {
  4438. $time = time();
  4439. $sku = $this->input->post('sku', true);
  4440. $warehouse = $this->input->post('warehouse', true);
  4441. $num = $this->input->post('num', true);
  4442. $text = $this->input->post('text', true);
  4443. $purchase = $this->input->post('purchase', true);
  4444. $cktype = $this->input->post('cktype', true);
  4445. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4446. if ($cktype != 1 && $text == '') {
  4447. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4448. exit;
  4449. }
  4450. if ($num > count($order)) {
  4451. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4452. exit;
  4453. } else {
  4454. for ($i = 0; $i < $num; $i++) {
  4455. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4456. }
  4457. }
  4458. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4459. exit;
  4460. }
  4461. $uid = $this->whlabel->read($arg_array[0]);
  4462. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4463. $this->data['data'] = $uid;
  4464. $this->_Template('whlabel_kj', $this->data);
  4465. }
  4466. public function _summary($arg_array)
  4467. {
  4468. $prc = array();
  4469. $purchase = $this->purchase->find_all();
  4470. foreach ($purchase as $k => $v) {
  4471. $prc[$v['id']] = $v['title'];
  4472. }
  4473. if (isset($_GET['excel'])) {
  4474. $ktime = $this->input->get('ktime', true);
  4475. $jtime = $this->input->get('jtime', true);
  4476. $ktime = strtotime($ktime);
  4477. $jtime = strtotime($jtime);
  4478. $where = "1=1";
  4479. if ($ktime && $jtime) {
  4480. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4481. }
  4482. //数据排序
  4483. $order_str = "time desc";
  4484. if (empty($page)) {
  4485. $start = 0;
  4486. $perpage = 1;
  4487. } else {
  4488. $start = ($page - 1) * $perpage;
  4489. }
  4490. //取得信息列表
  4491. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4492. foreach ($info_list as $key => $value) {
  4493. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4494. $warehouse = $this->warehouse->read($value['warehouse']);
  4495. $info_list[$key]['warehouse'] = $warehouse['title'];
  4496. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4497. $details = array();
  4498. $cpid = array();
  4499. foreach ($x as $k => $v) {
  4500. if ($v['details'] != '') {
  4501. $details[$v['details']] = $v['details'];
  4502. }
  4503. if ($v['cpid'] != 0) {
  4504. $cpid[$v['cpid']] = $v['cpid'];
  4505. }
  4506. }
  4507. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4508. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4509. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4510. $info_list[$key]['s'] = $s;
  4511. $info_list[$key]['x'] = count($x);
  4512. }
  4513. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4514. $titlename = "<table border=1>
  4515. <tr align='center'>
  4516. <td>仓库</td>
  4517. <td>供应商</td>
  4518. <td>出库位置</td>
  4519. <td>出库编码</td>
  4520. <td>SKU</td>
  4521. <td>产品名</td>
  4522. <td>总剩余库存</td>
  4523. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4524. </tr>
  4525. </table>";
  4526. $filename = $title . ".xls";
  4527. $tail = "";
  4528. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4529. }
  4530. }
  4531. //usps发货清单
  4532. public function _manifest()
  4533. {
  4534. if (isset($_POST['manifest'])) {
  4535. $wltext = $this->input->post('wltext', true);
  4536. $time = time() - 16 * 3600;
  4537. $ptime = strtotime(date('Y-m-d', $time));
  4538. $waybill = array();
  4539. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4540. foreach ($fullorder as $v) {
  4541. $waybill[$v['waybill']] = $v['waybill'];
  4542. }
  4543. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4544. foreach ($fullordersmt as $v) {
  4545. $waybill[$v['waybill']] = $v['waybill'];
  4546. }
  4547. $wltext = explode(';', $wltext);
  4548. foreach ($wltext as $v) {
  4549. if (isset($waybill[$v])) {
  4550. unset($waybill[$v]);
  4551. }
  4552. }
  4553. $data = $this->usps->get_manifest($waybill);
  4554. if (isset($data['Description'])) {
  4555. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4556. exit;
  4557. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4558. $bctime = date('Ymd', time());
  4559. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4560. echo json_encode(array('msg' => $pdf, 'success' => true));
  4561. exit;
  4562. } else {
  4563. echo json_encode(array('msg' => $data, 'success' => false));
  4564. exit;
  4565. }
  4566. }
  4567. }
  4568. public function _pdf($pdf, $title, $bctime)
  4569. {
  4570. $pdf_path = './data/pdf/' . $bctime . '/';
  4571. $file_base64 = $pdf;
  4572. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4573. $file_base64 = base64_decode($file_base64);
  4574. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4575. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4576. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4577. }
  4578. /**
  4579. *
  4580. *
  4581. *
  4582. 进销存占单异常索引
  4583. *
  4584. *
  4585. *
  4586. **/
  4587. public function _abnormal()
  4588. {
  4589. $post = $this->input->post(NULL, TRUE);
  4590. if (isset($post['page'])) {
  4591. $page = $this->input->post('page', true);
  4592. $perpage = $this->input->post('perpage', true);
  4593. $sku = $this->input->post('sku', true);
  4594. $where = "1=1";
  4595. //数据排序
  4596. $order_str = "id desc";
  4597. if (empty($page)) {
  4598. $start = 0;
  4599. $perpage = 1;
  4600. } else {
  4601. $start = ($page - 1) * $perpage;
  4602. }
  4603. //取得信息列表
  4604. $info_list = $this->whlabel->find_all($where, '*');
  4605. $rows = array();
  4606. $list = array();
  4607. foreach ($info_list as $key => $value) {
  4608. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4609. }
  4610. foreach ($rows as $value) {
  4611. $warehouse = $this->warehouse->read($value['warehouse']);
  4612. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4613. $number = $value['number'];
  4614. $ftime = time() - 15 * 24 * 3600;
  4615. if ($value['shop'] != '') {
  4616. $shop = $value['shop'];
  4617. $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');
  4618. $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');
  4619. $order = array_merge($orderdlz, $ordersmt);
  4620. $od = 0;
  4621. $a = '';
  4622. $orid = '';
  4623. foreach ($order as $v) {
  4624. $or = explode('|', ltrim($v['whlabel'], '|'));
  4625. for ($i = 0; $i < count($or); $i++) {
  4626. $orod = explode('-', $or[$i]);
  4627. if ($orod[0] == $number) {
  4628. $od += $orod[1];
  4629. }
  4630. }
  4631. $orid .= $v['number'] . '-';
  4632. }
  4633. } else {
  4634. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4635. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4636. $order = array_merge($orderdlz, $ordersmt);
  4637. $od = 0;
  4638. $a = '';
  4639. $orid = '';
  4640. $qt = array();
  4641. foreach ($order as $v) {
  4642. $or = explode('|', ltrim($v['whlabel'], '|'));
  4643. for ($i = 0; $i < count($or); $i++) {
  4644. $orod = explode('-', $or[$i]);
  4645. if ($orod[0] == $number) {
  4646. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4647. if ($czzs > 0) {
  4648. if (isset($qt[$v['shop']])) {
  4649. if ($qt[$v['shop']] < $orod[1]) {
  4650. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4651. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4652. } else {
  4653. $qt[$v['shop']] -= $orod[1];
  4654. }
  4655. } else {
  4656. $qt[$v['shop']] = $czzs;
  4657. }
  4658. } else {
  4659. $od += $orod[1];
  4660. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4661. }
  4662. }
  4663. }
  4664. }
  4665. }
  4666. $z = $od . '(' . $orid . ')'; //查看订单号
  4667. //$z = $od;
  4668. if ($od > $c) {
  4669. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4670. }
  4671. }
  4672. $listdata = array_slice($list, $start, $perpage);
  4673. $total = count($list);
  4674. $pagenum = ceil($total / $perpage);
  4675. $over = $total - ($start + $perpage);
  4676. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4677. echo json_encode($rows);
  4678. exit;
  4679. }
  4680. $this->_Template('whlabel_abnormal', $this->data);
  4681. }
  4682. /**
  4683. *
  4684. *
  4685. *
  4686. 进销存占单异常索引
  4687. *
  4688. *
  4689. *
  4690. **/
  4691. public function _error()
  4692. {
  4693. $post = $this->input->post(NULL, TRUE);
  4694. if (isset($post['page'])) {
  4695. $page = $this->input->post('page', true);
  4696. $perpage = $this->input->post('perpage', true);
  4697. $sku = $this->input->post('sku', true);
  4698. $warehouse = $this->input->post('warehouse', true);
  4699. $ktime = $this->input->post('ktime', true);
  4700. $jtime = $this->input->post('jtime', true);
  4701. $ktime = strtotime($ktime);
  4702. $jtime = strtotime($jtime);
  4703. $where = "sku != 'Preset'";
  4704. $gj = '';
  4705. if ($sku) {
  4706. $where .= " and sku like '%$sku%'";
  4707. } else {
  4708. if ($ktime && $jtime) {
  4709. $gj = " and time > '$ktime' and time < '$jtime'";
  4710. }
  4711. }
  4712. if ($warehouse) {
  4713. $where .= " and warehouse = '$warehouse'";
  4714. }
  4715. //数据排序
  4716. $order_str = "id desc";
  4717. if (empty($page)) {
  4718. $start = 0;
  4719. $perpage = 1;
  4720. } else {
  4721. $start = ($page - 1) * $perpage;
  4722. }
  4723. //取得信息列表
  4724. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4725. $rows = array();
  4726. $list = array();
  4727. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4728. // foreach ($info_list as $value)
  4729. // {
  4730. // $warehouse = $this->warehouse->read($value['warehouse']);
  4731. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4732. // $number = $value['number'];$ftime = time()-15*24*3600;
  4733. // if($c < 1)
  4734. // {
  4735. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4736. // }
  4737. // }
  4738. $warehouse_list = $this->warehouse->find_all();
  4739. $warehouse_list = array_column($warehouse_list, null, 'id');
  4740. foreach ($info_list as $value) {
  4741. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4742. 'title' => "",
  4743. ];
  4744. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4745. $number = $value['number'];
  4746. $ftime = time() - 15 * 24 * 3600;
  4747. if ($c < 1) {
  4748. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4749. }
  4750. }
  4751. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4752. // $query = $this->db->query($sql);
  4753. // $info_list = $query->result_array();
  4754. // $sql_two = "select title,id from crowd_warehouse";
  4755. // $query_two = $this->db->query($sql_two);
  4756. // $warehouse_list = $query_two->result_array();
  4757. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4758. // foreach ($info_list as $value)
  4759. // {
  4760. // if(isset($warehouse_arr[$value['warehouse']])){
  4761. // $warehouse = $warehouse_arr[$value['warehouse']];
  4762. // }else{
  4763. // $warehouse = [
  4764. // 'id'=>0,
  4765. // 'title'=>"异常",
  4766. // ];
  4767. // }
  4768. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4769. // $number = $value['number'];$ftime = time()-15*24*3600;
  4770. // if($c < 1)
  4771. // {
  4772. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4773. // }
  4774. // }
  4775. $listdata = array_slice($list, $start, $perpage);
  4776. $total = count($list);
  4777. $pagenum = ceil($total / $perpage);
  4778. $over = $total - ($start + $perpage);
  4779. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4780. echo json_encode($rows);
  4781. exit;
  4782. }
  4783. if (isset($post['s'])) {
  4784. $id_arr = $this->input->post('s');
  4785. $id_arr = explode(',', trim($id_arr, ','));
  4786. if (!$id_arr) {
  4787. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4788. exit;
  4789. }
  4790. //循环删除记录
  4791. foreach ($id_arr as $v) {
  4792. $dd = $this->whlabel->read($v);
  4793. if (!isset($dd['id'])) {
  4794. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4795. exit;
  4796. }
  4797. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4798. if (isset($zt[0])) {
  4799. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4800. exit;
  4801. }
  4802. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4803. foreach ($deldd as $vv) {
  4804. $this->whlabel->remove($vv['id']);
  4805. }
  4806. }
  4807. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4808. exit;
  4809. }
  4810. $this->_Template('whlabel_error', $this->data);
  4811. }
  4812. public function _errorexcel()
  4813. {
  4814. $post = $this->input->post(NULL, TRUE);
  4815. if (isset($_GET['page'])) {
  4816. $page = $this->input->get('page', true);
  4817. $perpage = $this->input->get('perpage', true);
  4818. $sku = $this->input->get('sku', true);
  4819. $warehouse = $this->input->get('warehouse', true);
  4820. $ktime = $this->input->get('ktime', true);
  4821. $jtime = $this->input->get('jtime', true);
  4822. $ktime = strtotime($ktime);
  4823. $jtime = strtotime($jtime);
  4824. $where = "sku != 'Preset'";
  4825. $gj = '';
  4826. if ($sku) {
  4827. $where .= " and sku like '%$sku%'";
  4828. } else {
  4829. if ($ktime && $jtime) {
  4830. $gj = " and time > '$ktime' and time < '$jtime'";
  4831. }
  4832. }
  4833. if ($warehouse) {
  4834. $where .= " and warehouse = '$warehouse'";
  4835. }
  4836. //数据排序
  4837. $order_str = "id desc";
  4838. if (empty($page)) {
  4839. $start = 0;
  4840. $perpage = 1;
  4841. } else {
  4842. $start = ($page - 1) * $perpage;
  4843. }
  4844. //取得信息列表
  4845. $rows = array();
  4846. $list = array();
  4847. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4848. foreach ($info_list as $value) {
  4849. $warehouse = $this->warehouse->read($value['warehouse']);
  4850. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4851. $number = $value['number'];
  4852. $ftime = time() - 15 * 24 * 3600;
  4853. if ($c < 1) {
  4854. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4855. }
  4856. }
  4857. $title = "0库存汇总";
  4858. $titlename = "<table border=1>
  4859. <tr align='center'>
  4860. <td>仓库</td>
  4861. <td>SKU</td>
  4862. <td>产品</td>
  4863. <td>当前库存</td>
  4864. </tr>
  4865. </table>";
  4866. $filename = $title . ".xls";
  4867. $tail = "";
  4868. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4869. }
  4870. }
  4871. /**
  4872. *
  4873. *
  4874. * 占单
  4875. *
  4876. *
  4877. **/
  4878. public function _kcyz()
  4879. {
  4880. $post = $this->input->post(NULL, TRUE);
  4881. if (isset($post['warehouse'])) {
  4882. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  4883. exit; //不再使用
  4884. $warehouse = $this->input->post('warehouse', true);
  4885. $whlabel = $this->input->post('whlabel', true);
  4886. $id = $this->input->post('id', true);
  4887. $shop = $this->input->post('shop', true);
  4888. $number = $this->input->post('number', true);
  4889. if (!$whlabel || $whlabel == '|') {
  4890. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  4891. exit;
  4892. }
  4893. $pp = explode('|', trim($whlabel, '|'));
  4894. $x = 0;
  4895. $save = array();
  4896. foreach ($pp as $va) {
  4897. $num = explode('-', $va);
  4898. if ($number) {
  4899. $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 = '')"); //通用
  4900. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  4901. } else {
  4902. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  4903. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  4904. }
  4905. $x++;
  4906. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  4907. $save[] = $x - 1;
  4908. continue; //提前先加X不然出错,所以要减1
  4909. }
  4910. }
  4911. if (isset($save[0])) {
  4912. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  4913. exit;
  4914. } else {
  4915. echo json_encode(array('success' => true));
  4916. exit;
  4917. }
  4918. }
  4919. }
  4920. public function _db()
  4921. {
  4922. $post = $this->input->post(NULL, TRUE);
  4923. if (isset($post['page'])) {
  4924. $page = $this->input->post('page', true);
  4925. $perpage = $this->input->post('perpage', true);
  4926. $sku = $this->input->post('sku', true);
  4927. $number = $this->input->post('number', true);
  4928. $warehouse = $this->input->post('warehouse', true);
  4929. $purchase = $this->input->post('purchase', true);
  4930. $orderinfo = $this->input->post('orderinfo', true);
  4931. $waybill = $this->input->post('waybill', true);
  4932. $category = $this->input->post('category', true);
  4933. $size = $this->input->post('size', true);
  4934. $grade = $this->input->post('grade', true);
  4935. $color = $this->input->post('color', true);
  4936. $lowe = $this->input->post('lowe', true);
  4937. $state = $this->input->post('state', true);
  4938. $label = $this->input->post('label', true);
  4939. $timetk = $this->input->post('timetkk', true);
  4940. $timetj = $this->input->post('timetjj', true);
  4941. $timetk = strtotime($timetk);
  4942. $timetj = strtotime($timetj);
  4943. $where = "dbtime > 0";
  4944. if ($timetk && $timetj) {
  4945. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  4946. }
  4947. if ($sku) {
  4948. $where .= " and sku = '$sku'";
  4949. }
  4950. if ($warehouse) {
  4951. $where .= " and warehouse = '$warehouse'";
  4952. if ($warehouse == 12) {
  4953. $w = 'specialstock';
  4954. } else {
  4955. $w = 'whlabel';
  4956. }
  4957. }
  4958. if ($purchase) {
  4959. $where .= " and purchase = '$purchase'";
  4960. }
  4961. if ($category) {
  4962. $where .= " and features like '%-$category-%'";
  4963. }
  4964. if ($size) {
  4965. $where .= " and features like '%-$size-%'";
  4966. }
  4967. if ($grade) {
  4968. $where .= " and features like '%-$grade-%'";
  4969. }
  4970. if ($color) {
  4971. $where .= " and features like '%-$color-%'";
  4972. }
  4973. if ($lowe) {
  4974. $where .= " and features like '%-$lowe-%'";
  4975. }
  4976. if ($state != '') {
  4977. $where .= " and state = '$state'";
  4978. }
  4979. //数据排序
  4980. $order_str = "dbtime desc";
  4981. if (empty($page)) {
  4982. $start = 0;
  4983. $perpage = 1;
  4984. } else {
  4985. $start = ($page - 1) * $perpage;
  4986. }
  4987. //取得信息列表
  4988. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  4989. foreach ($info_list as $key => $value) {
  4990. $warehouse = $this->$w->read($value['warehouse']);
  4991. $info_list[$key]['warehouse'] = $warehouse['title'];
  4992. $purchase = $this->purchase->read($value['purchase']);
  4993. $info_list[$key]['purchase'] = $purchase['title'];
  4994. if ($value['enter'] != 0) {
  4995. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  4996. } else {
  4997. $info_list[$key]['enter'] = "";
  4998. }
  4999. if ($value['dbtime'] != 0) {
  5000. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5001. } else {
  5002. $info_list[$key]['dbtime'] = "";
  5003. }
  5004. if ($value['state'] == 0) {
  5005. $info_list[$key]['state'] = "在库";
  5006. } else if ($value['state'] == 1) {
  5007. $info_list[$key]['state'] = "出库";
  5008. } else if ($value['state'] == 2) {
  5009. $info_list[$key]['state'] = "退库";
  5010. } else if ($value['state'] == 3) {
  5011. $info_list[$key]['state'] = "调拨中";
  5012. } else if ($value['state'] == 4) {
  5013. $info_list[$key]['state'] = "再加工";
  5014. } else if ($value['state'] == 5) {
  5015. $info_list[$key]['state'] = "维修中";
  5016. } else if ($value['state'] == 6) {
  5017. $info_list[$key]['state'] = "盘亏";
  5018. } else if ($value['state'] == 7) {
  5019. $info_list[$key]['state'] = "更换标签";
  5020. } else if ($value['state'] == 8) {
  5021. $info_list[$key]['state'] = "其它";
  5022. } else if ($value['state'] == 9) {
  5023. $info_list[$key]['state'] = "预设";
  5024. }
  5025. }
  5026. $total = $this->whlabel->find_count($where);
  5027. $pagenum = ceil($total / $perpage);
  5028. $over = $total - ($start + $perpage);
  5029. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5030. echo json_encode($rows);
  5031. exit;
  5032. }
  5033. if (isset($post['outsku'])) {
  5034. $time = time();
  5035. $cz = $this->input->post('cz', true);
  5036. $label = $this->input->post('outsku', true);
  5037. $sl = $this->input->post('sl', true);
  5038. $num = $this->input->post('num', true);
  5039. //$warehouse = $this->input->post('warehouse',true);
  5040. if (!$sl) {
  5041. $sl = 1;
  5042. }
  5043. if (!$warehouse) {
  5044. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5045. exit;
  5046. }
  5047. $dblabel = $this->whlabellabel->get_label($label);
  5048. if ($dblabel) {
  5049. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5050. if (count($data) < 1) {
  5051. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5052. exit;
  5053. }
  5054. if (count($data) < $num) {
  5055. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5056. exit;
  5057. }
  5058. for ($i = 0; $i < $sl; $i++) {
  5059. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5060. }
  5061. echo json_encode(array('success' => true));
  5062. exit;
  5063. } else {
  5064. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5065. exit;
  5066. }
  5067. }
  5068. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5069. $this->_Template('whlabel_db', $this->data);
  5070. }
  5071. public function _dbrk()
  5072. {
  5073. $post = $this->input->post(NULL, TRUE);
  5074. if (isset($post['page'])) {
  5075. $page = $this->input->post('page', true);
  5076. $perpage = $this->input->post('perpage', true);
  5077. $sku = $this->input->post('sku', true);
  5078. $number = $this->input->post('number', true);
  5079. $warehouse = $this->input->post('warehouse', true);
  5080. $purchase = $this->input->post('purchase', true);
  5081. $orderinfo = $this->input->post('orderinfo', true);
  5082. $waybill = $this->input->post('waybill', true);
  5083. $category = $this->input->post('category', true);
  5084. $size = $this->input->post('size', true);
  5085. $grade = $this->input->post('grade', true);
  5086. $color = $this->input->post('color', true);
  5087. $lowe = $this->input->post('lowe', true);
  5088. $state = $this->input->post('state', true);
  5089. $label = $this->input->post('label', true);
  5090. $ctime = $this->input->post('ctime', true);
  5091. $timetk = $this->input->post('timetkk', true);
  5092. $timetj = $this->input->post('timetjj', true);
  5093. $timetk = strtotime($timetk);
  5094. $timetj = strtotime($timetj);
  5095. $where = "dbtime > 0";
  5096. if ($timetk && $timetj) {
  5097. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5098. }
  5099. if ($sku) {
  5100. $where .= " and sku = '$sku'";
  5101. }
  5102. if ($warehouse) {
  5103. $where .= " and warehouse = '$warehouse'";
  5104. }
  5105. if ($purchase) {
  5106. $where .= " and purchase = '$purchase'";
  5107. }
  5108. if ($category) {
  5109. $where .= " and features like '%-$category-%'";
  5110. }
  5111. if ($size) {
  5112. $where .= " and features like '%-$size-%'";
  5113. }
  5114. if ($grade) {
  5115. $where .= " and features like '%-$grade-%'";
  5116. }
  5117. if ($color) {
  5118. $where .= " and features like '%-$color-%'";
  5119. }
  5120. if ($lowe) {
  5121. $where .= " and features like '%-$lowe-%'";
  5122. }
  5123. if ($state != '') {
  5124. $where .= " and state = '$state'";
  5125. }
  5126. //数据排序
  5127. $order_str = "dbtime desc";
  5128. if (empty($page)) {
  5129. $start = 0;
  5130. $perpage = 1;
  5131. } else {
  5132. $start = ($page - 1) * $perpage;
  5133. }
  5134. //取得信息列表
  5135. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5136. foreach ($info_list as $key => $value) {
  5137. $warehouse = $this->warehouse->read($value['warehouse']);
  5138. $info_list[$key]['warehouse'] = $warehouse['title'];
  5139. $purchase = $this->purchase->read($value['purchase']);
  5140. $info_list[$key]['purchase'] = $purchase['title'];
  5141. if ($value['enter'] != 0) {
  5142. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5143. } else {
  5144. $info_list[$key]['enter'] = "";
  5145. }
  5146. if ($value['dbtime'] != 0) {
  5147. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5148. } else {
  5149. $info_list[$key]['dbtime'] = "";
  5150. }
  5151. if ($value['state'] == 0) {
  5152. $info_list[$key]['state'] = "在库";
  5153. } else if ($value['state'] == 1) {
  5154. $info_list[$key]['state'] = "出库";
  5155. } else if ($value['state'] == 2) {
  5156. $info_list[$key]['state'] = "退库";
  5157. } else if ($value['state'] == 3) {
  5158. $info_list[$key]['state'] = "调拨中";
  5159. } else if ($value['state'] == 4) {
  5160. $info_list[$key]['state'] = "再加工";
  5161. } else if ($value['state'] == 5) {
  5162. $info_list[$key]['state'] = "维修中";
  5163. } else if ($value['state'] == 6) {
  5164. $info_list[$key]['state'] = "盘亏";
  5165. } else if ($value['state'] == 7) {
  5166. $info_list[$key]['state'] = "更换标签";
  5167. } else if ($value['state'] == 8) {
  5168. $info_list[$key]['state'] = "其它";
  5169. } else if ($value['state'] == 9) {
  5170. $info_list[$key]['state'] = "预设";
  5171. }
  5172. }
  5173. $total = $this->whlabel->find_count($where);
  5174. $pagenum = ceil($total / $perpage);
  5175. $over = $total - ($start + $perpage);
  5176. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5177. echo json_encode($rows);
  5178. exit;
  5179. }
  5180. if (isset($post['rsku'])) {
  5181. $cz = $this->input->post('cz', true);
  5182. $label = $this->input->post('rsku', true);
  5183. $sl = $this->input->post('sl', true);
  5184. $warehouse = $this->input->post('warehouse', true);
  5185. if (!$sl) {
  5186. $sl = 1;
  5187. }
  5188. if (!$warehouse) {
  5189. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5190. exit;
  5191. }
  5192. $dblabel = $this->whlabellabel->get_label($label);
  5193. if ($dblabel) {
  5194. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5195. if (count($data) < 1) {
  5196. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5197. exit;
  5198. }
  5199. if ($sl > count($data)) {
  5200. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5201. exit;
  5202. }
  5203. $time = time();
  5204. for ($i = 0; $i < $sl; $i++) {
  5205. $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']);
  5206. }
  5207. echo json_encode(array('success' => true));
  5208. exit;
  5209. } else {
  5210. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5211. exit;
  5212. }
  5213. }
  5214. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5215. $this->_Template('whlabel_dbrk', $this->data);
  5216. }
  5217. public function _whlabelczdc()
  5218. {
  5219. if (isset($_GET['excel'])) {
  5220. //数据排序
  5221. $order_str = "id desc";
  5222. if (empty($page)) {
  5223. $start = 0;
  5224. $perpage = 1;
  5225. } else {
  5226. $start = ($page - 1) * $perpage;
  5227. }
  5228. $state = $this->input->get('state', true);
  5229. $sku = $this->input->get('sku', true);
  5230. $ctime = $this->input->get('ctime', true);
  5231. $category = $this->input->get('category', true);
  5232. $size = $this->input->get('size', true);
  5233. $grade = $this->input->get('grade', true);
  5234. $color = $this->input->get('color', true);
  5235. $lowe = $this->input->get('lowe', true);
  5236. $timetk = $this->input->get('timetkk', true);
  5237. $timetj = $this->input->get('timetjj', true);
  5238. $timetk = strtotime($timetk);
  5239. $timetj = strtotime($timetj);
  5240. $where = "dbtime > 0";
  5241. if ($timetk && $timetj) {
  5242. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5243. }
  5244. if ($category) {
  5245. $where .= " and features like '%-$category-%'";
  5246. }
  5247. if ($size) {
  5248. $where .= " and features like '%-$size-%'";
  5249. }
  5250. if ($grade) {
  5251. $where .= " and features like '%-$grade-%'";
  5252. }
  5253. if ($color) {
  5254. $where .= " and features like '%-$color-%'";
  5255. }
  5256. if ($lowe) {
  5257. $where .= " and features like '%-$lowe-%'";
  5258. }
  5259. //取得信息列表
  5260. $info_list = $this->whlabel->find_all($where, '*');
  5261. $rows = array();
  5262. $list = array();
  5263. foreach ($info_list as $key => $value) {
  5264. $rows[$value['sku']] = $value; //所有数据sku
  5265. }
  5266. foreach ($rows as $value) {
  5267. $warehouse = $this->warehouse->read($value['warehouse']);
  5268. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5269. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5270. if ($value['orderinfo'] == 0) {
  5271. $info_list[$key]['orderinfo'] = "";
  5272. }
  5273. if ($value['waybill'] == 0) {
  5274. $info_list[$key]['waybill'] = "";
  5275. }
  5276. if ($value['state'] == 0) {
  5277. $value['state'] = "在库";
  5278. } else if ($value['state'] == 3) {
  5279. $value['state'] = "调拨中";
  5280. }
  5281. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5282. }
  5283. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5284. $titlename = "<table border=1>
  5285. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5286. <tr align='center'>
  5287. <td>SKU</td>
  5288. <td>产品</td>
  5289. <td>调拨数量</td>
  5290. <td>入库数量</td>
  5291. </tr>
  5292. </table>";
  5293. $filename = $title . ".xls";
  5294. $tail = "";
  5295. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5296. }
  5297. }
  5298. public function _print($arg_array)
  5299. {
  5300. if (isset($_SESSION['api'])) {
  5301. $user = $this->user->get_api($_SESSION['api']);
  5302. $usp = $user;
  5303. $fgshop = "";
  5304. $sid = "";
  5305. $wid = "";
  5306. $wtype = "";
  5307. $usersp = explode('|', trim($user['shop'], '|'));
  5308. $userwh = explode('|', trim($user['warehouse'], '|'));
  5309. foreach ($usersp as $value) {
  5310. $fgshop .= " shop = " . $value . " or";
  5311. $sid .= " id = " . $value . " or";
  5312. }
  5313. foreach ($userwh as $value) {
  5314. $wid .= " id = " . $value . " or";
  5315. $wtype .= " type = " . $value . " or";
  5316. }
  5317. }
  5318. $post = $this->input->post(NULL, TRUE);
  5319. if (isset($post['tmsku'])) {
  5320. $tmsku = $this->input->post('tmsku', true);
  5321. if (is_numeric($tmsku)) {
  5322. $yyh = $this->whlabellabel->get_label($tmsku);
  5323. } else {
  5324. $yyh = $this->whlabellabel->get_sku($tmsku);
  5325. }
  5326. if ($yyh) {
  5327. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5328. exit;
  5329. } else {
  5330. echo json_encode(array('success' => false));
  5331. exit;
  5332. }
  5333. }
  5334. $classid = $this->classid->sku();
  5335. $pm = $classid;
  5336. $scsku = $classid;
  5337. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5338. if (isset($post['warehouse'])) {
  5339. if ($post['warehouse']) {
  5340. $list = array();
  5341. $num = "";
  5342. $title = "";
  5343. $features = "";
  5344. $order = 0;
  5345. $post['shop'] = '';
  5346. $brand = $this->input->post('brand', true);
  5347. if ($brand != '0,') {
  5348. $b = $this->brand->read(rtrim($brand, ','));
  5349. if ($b) {
  5350. $post['shop'] = str_replace('|', ',', $b['shop']);
  5351. }
  5352. }
  5353. $post['details'] = $this->input->post('details', true); //打印数量
  5354. $xbqnum = $this->input->post('xbqnum', true);
  5355. $post['purchase'] = $this->input->post('purchase', true);
  5356. $post['warehouse'] = $this->input->post('warehouse', true);
  5357. $post['purchase'] = $this->input->post('purchase', true);
  5358. $post['retreatwarehouse'] = $post['warehouse'];
  5359. $post['cpbz'] = $this->input->post('cpbz', true);
  5360. $post['state'] = 9;
  5361. $category = $this->input->post('category', true);
  5362. $list['category'] = $category;
  5363. $list['hairtype'] = $this->input->post('hairtype', true);
  5364. $list['grade'] = $this->input->post('grade', true);
  5365. $size = $this->input->post('size', true);
  5366. $list['size'] = rtrim($size, ',');
  5367. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5368. $list['extension'] = $this->input->post('extension', true);
  5369. if ($category == 1297) {
  5370. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5371. }
  5372. if ($category == 1702) {
  5373. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5374. $list['syother'] = $this->input->post('syother', true);
  5375. }
  5376. if ($category == 133) {
  5377. $list['fittype'] = $this->input->post('fittype', true);
  5378. $list['acother'] = $this->input->post('acother', true);
  5379. }
  5380. $list['color'] = $this->input->post('color', true);
  5381. $list['lowe'] = $this->input->post('lowe', true);
  5382. if ($category == 127) {
  5383. $list['type'] = $this->input->post('type', true);
  5384. $list['headroad'] = $this->input->post('headroad', true);
  5385. $list['density'] = $this->input->post('density', true);
  5386. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5387. $list['lacesize'] = $this->input->post('lacesize', true);
  5388. }
  5389. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5390. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5391. }
  5392. if ($category == 128) {
  5393. $list['lacetype'] = $this->input->post('lacetype', true);
  5394. $list['haircap'] = $this->input->post('haircap', true);
  5395. $list['density'] = $this->input->post('density', true);
  5396. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5397. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5398. $list['wigother'] = $this->input->post('wigother', true);
  5399. $list['wigother1'] = $this->input->post('wigother1', true);
  5400. $list['wigother2'] = $this->input->post('wigother2', true);
  5401. }
  5402. if ($category == 129) {
  5403. $list['wide'] = $this->input->post('wide', true);
  5404. }
  5405. if ($category == 131) {
  5406. $list['gifttype'] = $this->input->post('gifttype', true);
  5407. $list['giftother'] = $this->input->post('giftother', true);
  5408. }
  5409. if ($category == 134) {
  5410. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5411. }
  5412. if ($category == 1297) {
  5413. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5414. $list['sywigother'] = $this->input->post('sywigother', true);
  5415. }
  5416. if ($category == 130 || $category == 133 || $category == 1702) {
  5417. $list['items'] = $this->input->post('items', true);
  5418. $list['weight'] = $this->input->post('weight', true);
  5419. }
  5420. if ($category == 1702) {
  5421. $list['syhairther'] = $this->input->post('syhairther', true);
  5422. }
  5423. foreach ($list as $k => $v) {
  5424. if ($v != 0) {
  5425. $num .= $v;
  5426. $features .= $v . '-';
  5427. $post[$k] = $v;
  5428. $typeclass = $this->typeclass->read($v);
  5429. if (isset($pm[$typeclass['classid']])) {
  5430. if (stripos($typeclass['zh'], '|') !== false) {
  5431. $exzh = explode('|', $typeclass['zh']);
  5432. $pm[$typeclass['classid']] = $exzh[0];
  5433. } else {
  5434. $pm[$typeclass['classid']] = $typeclass['zh'];
  5435. }
  5436. }
  5437. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5438. if ($k != 'size') {
  5439. $title .= $typeclass['title'] . " ";
  5440. }
  5441. }
  5442. }
  5443. $typeclass = $this->typeclass->read($list['size']);
  5444. $title .= $typeclass['title'];
  5445. $time = time();
  5446. $post['title'] = rtrim($title, ' ');
  5447. $post['number'] = $num;
  5448. $post['features'] = '-' . $features;
  5449. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5450. $featurespp = explode('-', trim($featurespp, '-'));
  5451. if (isset($featurespp[5])) {
  5452. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5453. } else {
  5454. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5455. }
  5456. $post['enter'] = $time;
  5457. $post['time'] = $time; //操作时间
  5458. $scsku = implode("-", $scsku);
  5459. $zh = implode(" ", $pm);
  5460. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5461. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5462. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5463. $post['sku'] = $bqsku;
  5464. $label = time() . rand(0, 9);
  5465. $post['label'] = $label;
  5466. $cpid = $this->whlabellabel->find_count();
  5467. $post['cpid'] = $cpid + 1;
  5468. $cpid = $post['cpid'];
  5469. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5470. //if($whlabelbarcode)
  5471. //{
  5472. //$post['label'] = $whlabelbarcode['label'];
  5473. //if(!$this->whlabellabel->insert($post))
  5474. //{
  5475. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5476. //}
  5477. //}
  5478. //else
  5479. //{
  5480. $this->db->trans_begin();
  5481. $this->whlabellabel->insert($post);
  5482. //$this->whlabelbarcode->insert($post);
  5483. if ($this->db->trans_status() === TRUE) {
  5484. $this->db->trans_commit();
  5485. } else {
  5486. $this->db->trans_rollback();
  5487. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5488. exit;
  5489. }
  5490. //}
  5491. $warehouse_name = "";
  5492. $warehouse = $post['warehouse'];
  5493. if($warehouse == 12){
  5494. $warehouse_name = "特殊库存库";
  5495. }
  5496. // if($warehouse == 13){
  5497. // $warehouse_name = "许昌仓";
  5498. // }
  5499. // if($warehouse == 5){
  5500. // $warehouse_name = "美国店";
  5501. // }
  5502. // if($warehouse == 16){
  5503. // $warehouse_name = "定制头套仓";
  5504. // }
  5505. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5506. if(!empty($warehouse_name)){
  5507. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5508. }
  5509. $purchase = $this->purchase->read($post['purchase']);
  5510. 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));
  5511. exit; //特殊仓目前不需要仓库选项
  5512. }
  5513. }
  5514. if (isset($_SESSION['api'])) {
  5515. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5516. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5517. $this->data['wlshop'] = $wlshop;
  5518. $this->data['warehouse'] = $warehouse;
  5519. }
  5520. $whlabelwz = $this->whlabelwz->find_all();
  5521. $this->data['whlabelwz'] = $whlabelwz;
  5522. $this->_Template('whlabel_print', $this->data);
  5523. }
  5524. public function _usaprint($arg_array)
  5525. {
  5526. if (isset($_SESSION['api'])) {
  5527. $user = $this->user->get_api($_SESSION['api']);
  5528. $usp = $user;
  5529. $fgshop = "";
  5530. $sid = "";
  5531. $wid = "";
  5532. $wtype = "";
  5533. $usersp = explode('|', trim($user['shop'], '|'));
  5534. $userwh = explode('|', trim($user['warehouse'], '|'));
  5535. foreach ($usersp as $value) {
  5536. $fgshop .= " shop = " . $value . " or";
  5537. $sid .= " id = " . $value . " or";
  5538. }
  5539. foreach ($userwh as $value) {
  5540. $wid .= " id = " . $value . " or";
  5541. $wtype .= " type = " . $value . " or";
  5542. }
  5543. }
  5544. $post = $this->input->post(NULL, TRUE);
  5545. if (isset($post['tmsku'])) {
  5546. $tmsku = $this->input->post('tmsku', true);
  5547. if (is_numeric($tmsku)) {
  5548. $yyh = $this->whlabellabel->get_label($tmsku);
  5549. } else {
  5550. $yyh = $this->whlabellabel->get_sku($tmsku);
  5551. }
  5552. if ($yyh) {
  5553. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5554. exit;
  5555. } else {
  5556. echo json_encode(array('success' => false));
  5557. exit;
  5558. }
  5559. }
  5560. $classid = $this->classid->sku();
  5561. $pm = $classid;
  5562. $scsku = $classid;
  5563. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5564. if (isset($post['warehouse'])) {
  5565. if ($post['warehouse']) {
  5566. $list = array();
  5567. $num = "";
  5568. $title = "";
  5569. $features = "";
  5570. $order = 0;
  5571. $post['shop'] = '';
  5572. $brand = $this->input->post('brand', true);
  5573. if ($brand != '0,') {
  5574. $b = $this->brand->read(rtrim($brand, ','));
  5575. if ($b) {
  5576. $post['shop'] = str_replace('|', ',', $b['shop']);
  5577. }
  5578. }
  5579. $post['details'] = $this->input->post('details', true); //打印数量
  5580. $xbqnum = $this->input->post('xbqnum', true);
  5581. $post['purchase'] = $this->input->post('purchase', true);
  5582. $post['warehouse'] = $this->input->post('warehouse', true);
  5583. $post['purchase'] = $this->input->post('purchase', true);
  5584. $post['retreatwarehouse'] = $post['warehouse'];
  5585. $post['cpbz'] = $this->input->post('cpbz', true);
  5586. $post['state'] = 9;
  5587. $category = $this->input->post('category', true);
  5588. $list['category'] = $category;
  5589. $list['hairtype'] = $this->input->post('hairtype', true);
  5590. $list['grade'] = $this->input->post('grade', true);
  5591. $size = $this->input->post('size', true);
  5592. $list['size'] = rtrim($size, ',');
  5593. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5594. $list['extension'] = $this->input->post('extension', true);
  5595. if ($category == 1297) {
  5596. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5597. }
  5598. if ($category == 1702) {
  5599. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5600. $list['syother'] = $this->input->post('syother', true);
  5601. }
  5602. if ($category == 133) {
  5603. $list['fittype'] = $this->input->post('fittype', true);
  5604. $list['acother'] = $this->input->post('acother', true);
  5605. }
  5606. $list['color'] = $this->input->post('color', true);
  5607. $list['lowe'] = $this->input->post('lowe', true);
  5608. if ($category == 127) {
  5609. $list['type'] = $this->input->post('type', true);
  5610. $list['headroad'] = $this->input->post('headroad', true);
  5611. $list['density'] = $this->input->post('density', true);
  5612. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5613. $list['lacesize'] = $this->input->post('lacesize', true);
  5614. }
  5615. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5616. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5617. }
  5618. if ($category == 128) {
  5619. $list['lacetype'] = $this->input->post('lacetype', true);
  5620. $list['haircap'] = $this->input->post('haircap', true);
  5621. $list['density'] = $this->input->post('density', true);
  5622. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5623. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5624. $list['wigother'] = $this->input->post('wigother', true);
  5625. $list['wigother1'] = $this->input->post('wigother1', true);
  5626. $list['wigother2'] = $this->input->post('wigother2', true);
  5627. }
  5628. if ($category == 129) {
  5629. $list['wide'] = $this->input->post('wide', true);
  5630. }
  5631. if ($category == 131) {
  5632. $list['gifttype'] = $this->input->post('gifttype', true);
  5633. $list['giftother'] = $this->input->post('giftother', true);
  5634. }
  5635. if ($category == 134) {
  5636. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5637. }
  5638. if ($category == 1297) {
  5639. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5640. $list['sywigother'] = $this->input->post('sywigother', true);
  5641. }
  5642. if ($category == 130 || $category == 133 || $category == 1702) {
  5643. $list['items'] = $this->input->post('items', true);
  5644. $list['weight'] = $this->input->post('weight', true);
  5645. }
  5646. if ($category == 1702) {
  5647. $list['syhairther'] = $this->input->post('syhairther', true);
  5648. }
  5649. foreach ($list as $k => $v) {
  5650. if ($v != 0) {
  5651. $num .= $v;
  5652. $features .= $v . '-';
  5653. $post[$k] = $v;
  5654. $typeclass = $this->typeclass->read($v);
  5655. if (isset($pm[$typeclass['classid']])) {
  5656. if (stripos($typeclass['zh'], '|') !== false) {
  5657. $exzh = explode('|', $typeclass['zh']);
  5658. $pm[$typeclass['classid']] = $exzh[0];
  5659. } else {
  5660. $pm[$typeclass['classid']] = $typeclass['zh'];
  5661. }
  5662. }
  5663. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5664. if ($k != 'size') {
  5665. $title .= $typeclass['title'] . " ";
  5666. }
  5667. }
  5668. }
  5669. $typeclass = $this->typeclass->read($list['size']);
  5670. $title .= $typeclass['title'];
  5671. $time = time();
  5672. $post['title'] = rtrim($title, ' ');
  5673. $post['number'] = $num;
  5674. $post['features'] = '-' . $features;
  5675. $fp = $this->whlabel->get_features($post['features']);
  5676. if (!$fp) {
  5677. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5678. exit;
  5679. }
  5680. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5681. $featurespp = explode('-', trim($featurespp, '-'));
  5682. if (isset($featurespp[5])) {
  5683. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5684. } else {
  5685. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5686. }
  5687. $post['enter'] = $time;
  5688. $post['time'] = $time; //操作时间
  5689. $scsku = implode("-", $scsku);
  5690. $zh = implode(" ", $pm);
  5691. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5692. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5693. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5694. $post['sku'] = $fp['sku'];
  5695. $post['label'] = $fp['sku'];
  5696. $cpid = $this->whlabellabel->find_count();
  5697. $post['cpid'] = $cpid + 1;
  5698. $cpid = $post['cpid'];
  5699. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5700. //if($whlabelbarcode)
  5701. //{
  5702. //$post['label'] = $whlabelbarcode['label'];
  5703. //if(!$this->whlabellabel->insert($post))
  5704. //{
  5705. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5706. //}
  5707. //}
  5708. //else
  5709. //{
  5710. $this->db->trans_begin();
  5711. $this->whlabellabel->insert($post);
  5712. //$this->whlabelbarcode->insert($post);
  5713. if ($this->db->trans_status() === TRUE) {
  5714. $this->db->trans_commit();
  5715. } else {
  5716. $this->db->trans_rollback();
  5717. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5718. exit;
  5719. }
  5720. //}
  5721. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5722. $purchase = $this->purchase->read($post['purchase']);
  5723. 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));
  5724. exit; //特殊仓目前不需要仓库选项
  5725. }
  5726. }
  5727. if (isset($_SESSION['api'])) {
  5728. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5729. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5730. $this->data['wlshop'] = $wlshop;
  5731. $this->data['warehouse'] = $warehouse;
  5732. }
  5733. $whlabelwz = $this->whlabelwz->find_all();
  5734. $this->data['whlabelwz'] = $whlabelwz;
  5735. $this->_Template('whlabel_usaprint', $this->data);
  5736. }
  5737. public function _printrk($arg_array)
  5738. {
  5739. $prc = array();
  5740. $purchase = $this->purchase->find_all();
  5741. foreach ($purchase as $k => $v) {
  5742. $prc[$v['id']] = $v['title'];
  5743. }
  5744. $post = $this->input->post(NULL, TRUE);
  5745. if (isset($post['page'])) {
  5746. $page = $this->input->post('page', true);
  5747. $perpage = $this->input->post('perpage', true);
  5748. $sku = $this->input->post('sku', true);
  5749. $bs = $this->input->post('bs', true);
  5750. $number = $this->input->post('number', true);
  5751. $warehouse = $this->input->post('warehouse', true);
  5752. $purchase = $this->input->post('purchase', true);
  5753. $orderinfo = $this->input->post('orderinfo', true);
  5754. $waybill = $this->input->post('waybill', true);
  5755. $category = $this->input->post('category', true);
  5756. $size = $this->input->post('size', true);
  5757. $grade = $this->input->post('grade', true);
  5758. $color = $this->input->post('color', true);
  5759. $lowe = $this->input->post('lowe', true);
  5760. $state = $this->input->post('state', true);
  5761. $label = $this->input->post('label', true);
  5762. $timetk = $this->input->post('ktime', true);
  5763. $timetj = $this->input->post('jtime', true);
  5764. $timetk = strtotime($timetk);
  5765. $timetj = strtotime($timetj);
  5766. $where = "1=1 ";
  5767. if ($timetk && $timetj) {
  5768. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5769. }
  5770. if ($sku) {
  5771. $where .= " and sku = '$sku'";
  5772. }
  5773. if ($bs != '') {
  5774. $where .= " and bs = '$bs'";
  5775. }
  5776. if ($number) {
  5777. $where .= " and number = '$number'";
  5778. }
  5779. if ($warehouse) {
  5780. $where .= " and warehouse = '$warehouse'";
  5781. }
  5782. if ($purchase) {
  5783. $where .= " and purchase = '$purchase'";
  5784. }
  5785. if ($orderinfo) {
  5786. $where .= " and orderinfo = '$orderinfo'";
  5787. }
  5788. if ($waybill) {
  5789. $where .= " and waybill = '$waybill'";
  5790. }
  5791. if ($category) {
  5792. $where .= " and features like '%-$category-%'";
  5793. }
  5794. if ($size) {
  5795. $where .= " and features like '%-$size-%'";
  5796. }
  5797. if ($grade) {
  5798. $where .= " and features like '%-$grade-%'";
  5799. }
  5800. if ($color) {
  5801. $where .= " and features like '%-$color-%'";
  5802. }
  5803. if ($lowe) {
  5804. $where .= " and features like '%-$lowe-%'";
  5805. }
  5806. if ($label) {
  5807. $where .= " and label = '$label'";
  5808. }
  5809. if ($state || $state == 0) {
  5810. $where .= " and state = '$state'";
  5811. }
  5812. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5813. //数据排序
  5814. $order_str = "enter desc";
  5815. if (empty($page)) {
  5816. $start = 0;
  5817. $perpage = 1;
  5818. } else {
  5819. $start = ($page - 1) * $perpage;
  5820. }
  5821. //取得信息列表
  5822. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5823. foreach ($info_list as $key => $value) {
  5824. $warehouse = $this->warehouse->read($value['warehouse']);
  5825. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5826. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5827. if ($value['state'] == 0) {
  5828. $info_list[$key]['state'] = "在库";
  5829. } else if ($value['state'] == 1) {
  5830. $info_list[$key]['state'] = "出库";
  5831. } else if ($value['state'] == 2) {
  5832. $info_list[$key]['state'] = "退库";
  5833. } else if ($value['state'] == 3) {
  5834. $info_list[$key]['state'] = "调拨中";
  5835. } else if ($value['state'] == 4) {
  5836. $info_list[$key]['state'] = "再加工";
  5837. } else if ($value['state'] == 5) {
  5838. $info_list[$key]['state'] = "维修中";
  5839. } else if ($value['state'] == 6) {
  5840. $info_list[$key]['state'] = "盘亏";
  5841. } else if ($value['state'] == 7) {
  5842. $info_list[$key]['state'] = "更换标签";
  5843. } else if ($value['state'] == 8) {
  5844. $info_list[$key]['state'] = "其它";
  5845. } else if ($value['state'] == 9) {
  5846. $info_list[$key]['state'] = "预设";
  5847. } else if ($value['state'] == 10) {
  5848. $info_list[$key]['state'] = "美店零售";
  5849. }
  5850. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5851. }
  5852. $total = $this->$ck->find_count($where);
  5853. $pagenum = ceil($total / $perpage);
  5854. $over = $total - ($start + $perpage);
  5855. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5856. echo json_encode($rows);
  5857. exit;
  5858. }
  5859. if (isset($post['tmsku'])) {
  5860. $time = time();
  5861. $tmsku = $this->input->post('tmsku', true);
  5862. //$post['shop'] = $this->input->post('shop',true);
  5863. $num = $this->input->post('num', true);
  5864. $rktype = $this->input->post('rktype', true);
  5865. if ($num > 200) {
  5866. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5867. exit;
  5868. }
  5869. if (!$rktype) {
  5870. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5871. }
  5872. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5873. /**
  5874. $wz = array();
  5875. foreach ($rk as $key=>$value)
  5876. {
  5877. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5878. }
  5879. if(count($wz) > 1)
  5880. {
  5881. $wz = array_values($wz);
  5882. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  5883. }
  5884. **/
  5885. if (isset($rk[0]['purchase'])) {
  5886. $rk = $rk[0];
  5887. $j = 0;
  5888. $post['purchase'] = $rk['purchase'];
  5889. $post['warehouse'] = $rk['warehouse'];
  5890. $post['retreatwarehouse'] = $rk['warehouse'];
  5891. $post['sku'] = $rk['sku'];
  5892. $post['number'] = $rk['number'];
  5893. $post['features'] = $rk['features'];
  5894. $post['title'] = $rk['title'];
  5895. $post['enter'] = $time;
  5896. $post['time'] = $time;
  5897. $post['bs'] = 1;
  5898. $post['shop'] = $rk['shop'];
  5899. $post['details'] = $rk['details'];
  5900. $post['cpid'] = $rk['cpid'];
  5901. $post['cpbz'] = $rk['cpbz'];
  5902. //$post['rktype'] = $rktype;
  5903. $warehouse = $this->warehouse->read($rk['warehouse']);
  5904. if ($warehouse['bdck'] == '') {
  5905. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  5906. exit;
  5907. } else {
  5908. $bdck = $warehouse['bdck'];
  5909. }
  5910. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  5911. if (isset($pdwz['details'])) {
  5912. if ($pdwz['details'] != $post['details']) {
  5913. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  5914. exit;
  5915. }
  5916. }
  5917. $post['featurespp'] = $rk['featurespp'];
  5918. if ($post['warehouse'] == '5') {
  5919. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5920. if ($yza) {
  5921. if ($post['features'] != $yza[0]['features']) {
  5922. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  5923. exit;
  5924. }
  5925. }
  5926. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5927. if ($yzb) {
  5928. if ($post['sku'] != $yzb[0]['sku']) {
  5929. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  5930. exit;
  5931. }
  5932. }
  5933. }
  5934. for ($i = 0; $i < $num; $i++) {
  5935. $post['label'] = time() . rand(100, 999) . $i;
  5936. if ($this->$bdck->insert($post)) {
  5937. $j++;
  5938. }
  5939. }
  5940. /**
  5941. if($post['warehouse'] != 12)
  5942. {
  5943. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5944. }
  5945. **/
  5946. if ($j == $num) {
  5947. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  5948. exit;
  5949. } else {
  5950. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  5951. exit;
  5952. }
  5953. } else {
  5954. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  5955. exit;
  5956. }
  5957. }
  5958. $this->_Template('whlabel_printrk', $this->data);
  5959. }
  5960. public function _printxzrk($arg_array)
  5961. {
  5962. $post = $this->input->post(NULL, TRUE);
  5963. if (isset($post['wzid'])) {
  5964. $time = time();
  5965. $id = $this->input->post('wzid', true);
  5966. //$post['shop'] = $this->input->post('shop',true);
  5967. $num = 1;
  5968. $rk = $this->whlabellabel->read($id);
  5969. if (isset($rk['purchase'])) {
  5970. $x = 0;
  5971. $post['purchase'] = $rk['purchase'];
  5972. $post['warehouse'] = $rk['warehouse'];
  5973. $post['retreatwarehouse'] = $rk['warehouse'];
  5974. $post['sku'] = $rk['sku'];
  5975. $post['number'] = $rk['number'];
  5976. $post['features'] = $rk['features'];
  5977. $post['title'] = $rk['title'];
  5978. $post['enter'] = $time;
  5979. $post['time'] = $time;
  5980. $post['bs'] = 1;
  5981. $post['shop'] = $rk['shop'];
  5982. $post['details'] = $rk['details'];
  5983. $post['cpid'] = $rk['cpid'];
  5984. $post['cpbz'] = $rk['cpbz'];
  5985. $warehouse = $this->warehouse->read($rk['warehouse']);
  5986. if ($warehouse['bdck'] == '') {
  5987. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  5988. exit;
  5989. } else {
  5990. $bdck = $warehouse['bdck'];
  5991. }
  5992. $post['featurespp'] = $rk['featurespp'];
  5993. $this->db->trans_begin();
  5994. for ($i = 0; $i < $num; $i++) {
  5995. $post['label'] = time() . rand(100, 999) . $i;
  5996. $this->$bdck->insert($post);
  5997. }
  5998. /**
  5999. if($post['warehouse'] != 12)
  6000. {
  6001. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6002. }
  6003. **/
  6004. if ($this->db->trans_status() === TRUE) {
  6005. $this->db->trans_commit();
  6006. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6007. exit;
  6008. } else {
  6009. $this->db->trans_rollback();
  6010. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6011. exit;
  6012. }
  6013. } else {
  6014. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6015. exit;
  6016. }
  6017. }
  6018. }
  6019. public function _printck($arg_array)
  6020. {
  6021. $prc = array();
  6022. $purchase = $this->purchase->find_all();
  6023. foreach ($purchase as $k => $v) {
  6024. $prc[$v['id']] = $v['title'];
  6025. }
  6026. $post = $this->input->post(NULL, TRUE);
  6027. if (isset($post['page'])) {
  6028. $page = $this->input->post('page', true);
  6029. $perpage = $this->input->post('perpage', true);
  6030. $sku = $this->input->post('sku', true);
  6031. $bs = $this->input->post('bs', true);
  6032. $number = $this->input->post('number', true);
  6033. $warehouse = $this->input->post('warehouse', true);
  6034. $purchase = $this->input->post('purchase', true);
  6035. $orderinfo = $this->input->post('orderinfo', true);
  6036. $waybill = $this->input->post('waybill', true);
  6037. $category = $this->input->post('category', true);
  6038. $size = $this->input->post('size', true);
  6039. $grade = $this->input->post('grade', true);
  6040. $color = $this->input->post('color', true);
  6041. $lowe = $this->input->post('lowe', true);
  6042. $state = $this->input->post('state', true);
  6043. $label = $this->input->post('label', true);
  6044. $timetk = $this->input->post('ktime', true);
  6045. $timetj = $this->input->post('jtime', true);
  6046. $timetk = strtotime($timetk);
  6047. $timetj = strtotime($timetj);
  6048. $where = "state=1 ";
  6049. if ($timetk && $timetj) {
  6050. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6051. }
  6052. if ($sku) {
  6053. $where .= " and sku = '$sku'";
  6054. }
  6055. if ($bs != '') {
  6056. $where .= " and bs = '$bs'";
  6057. }
  6058. if ($number) {
  6059. $where .= " and number = '$number'";
  6060. }
  6061. if ($warehouse) {
  6062. $where .= " and warehouse = '$warehouse'";
  6063. }
  6064. if ($purchase) {
  6065. $where .= " and purchase = '$purchase'";
  6066. }
  6067. if ($orderinfo) {
  6068. $where .= " and orderinfo = '$orderinfo'";
  6069. }
  6070. if ($waybill) {
  6071. $where .= " and waybill = '$waybill'";
  6072. }
  6073. if ($category) {
  6074. $where .= " and features like '%-$category-%'";
  6075. }
  6076. if ($size) {
  6077. $where .= " and features like '%-$size-%'";
  6078. }
  6079. if ($grade) {
  6080. $where .= " and features like '%-$grade-%'";
  6081. }
  6082. if ($color) {
  6083. $where .= " and features like '%-$color-%'";
  6084. }
  6085. if ($lowe) {
  6086. $where .= " and features like '%-$lowe-%'";
  6087. }
  6088. if ($label) {
  6089. $where .= " and label = '$label'";
  6090. }
  6091. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6092. //数据排序
  6093. $order_str = "outk desc";
  6094. if (empty($page)) {
  6095. $start = 0;
  6096. $perpage = 1;
  6097. } else {
  6098. $start = ($page - 1) * $perpage;
  6099. }
  6100. //取得信息列表
  6101. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6102. foreach ($info_list as $key => $value) {
  6103. $warehouse = $this->warehouse->read($value['warehouse']);
  6104. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6105. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6106. if ($value['state'] == 0) {
  6107. $info_list[$key]['state'] = "在库";
  6108. } else if ($value['state'] == 1) {
  6109. $info_list[$key]['state'] = "出库";
  6110. } else if ($value['state'] == 2) {
  6111. $info_list[$key]['state'] = "退库";
  6112. } else if ($value['state'] == 3) {
  6113. $info_list[$key]['state'] = "调拨中";
  6114. } else if ($value['state'] == 4) {
  6115. $info_list[$key]['state'] = "再加工";
  6116. } else if ($value['state'] == 5) {
  6117. $info_list[$key]['state'] = "维修中";
  6118. } else if ($value['state'] == 6) {
  6119. $info_list[$key]['state'] = "盘亏";
  6120. } else if ($value['state'] == 7) {
  6121. $info_list[$key]['state'] = "更换标签";
  6122. } else if ($value['state'] == 8) {
  6123. $info_list[$key]['state'] = "其它";
  6124. } else if ($value['state'] == 9) {
  6125. $info_list[$key]['state'] = "预设";
  6126. } else if ($value['state'] == 10) {
  6127. $info_list[$key]['state'] = "美店零售";
  6128. }
  6129. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6130. }
  6131. $total = $this->$ck->find_count($where);
  6132. $pagenum = ceil($total / $perpage);
  6133. $over = $total - ($start + $perpage);
  6134. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6135. echo json_encode($rows);
  6136. exit;
  6137. }
  6138. if (isset($post['tmsku'])) {
  6139. $time = time();
  6140. $tmsku = $this->input->post('tmsku', true);
  6141. //$post['shop'] = $this->input->post('shop',true);
  6142. $num = $this->input->post('num', true);
  6143. $cktype = $this->input->post('cktype', true);
  6144. $label = $this->whlabellabel->get_label($tmsku);
  6145. if (!$cktype) {
  6146. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6147. }
  6148. if (!isset($label['warehouse'])) {
  6149. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6150. exit;
  6151. }
  6152. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6153. if (stripos($label['features'], '-126-') !== false) {
  6154. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6155. } else {
  6156. $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 = ''");
  6157. }
  6158. $j = 0;
  6159. if (count($ck) >= $num) {
  6160. for ($i = 0; $i < $num; $i++) {
  6161. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6162. {
  6163. $j++;
  6164. }
  6165. }
  6166. if ($j == $num) {
  6167. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6168. exit;
  6169. } else {
  6170. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6171. exit;
  6172. }
  6173. } else {
  6174. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6175. exit;
  6176. }
  6177. }
  6178. if(isset($_SESSION['api']))
  6179. {
  6180. $user = $this->user->get_api($_SESSION['api']);
  6181. if(in_array($user['power'],[1,27])){
  6182. $vip = 1;
  6183. }
  6184. }
  6185. else
  6186. {
  6187. $vip = 0;
  6188. header('Location: /');exit;
  6189. }
  6190. $this->data['vip'] = $vip;
  6191. $this->_Template('whlabel_printck', $this->data);
  6192. }
  6193. public function _printexcel()
  6194. {
  6195. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6196. $config['upload_path'] = '.' . $dir;
  6197. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6198. $config['allowed_types'] = 'xls|xlsx|csv';
  6199. $config['max_size'] = 10240;
  6200. $this->load->library('upload', $config);
  6201. $this->upload->initialize($config);
  6202. if ($this->upload->do_upload('userfile')) {
  6203. $full_path = $dir . $this->upload->data('file_name');
  6204. $fileName = '.' . $full_path;
  6205. if (!file_exists($fileName)) {
  6206. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6207. exit;
  6208. } else {
  6209. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6210. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6211. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6212. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6213. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6214. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6215. ++$column; //如果列数大于26行
  6216. $list = array();
  6217. for ($i = 2; $i <= $row; $i++) // 行数循环
  6218. {
  6219. $data = array();
  6220. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6221. {
  6222. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6223. }
  6224. $list[] = $data;
  6225. }
  6226. }
  6227. $ed = array();
  6228. $i = 0;
  6229. $j = 0;
  6230. $dcdata = array();
  6231. $yc = '';
  6232. $cmf_arr = array_column($list, '1');
  6233. array_multisort($cmf_arr, SORT_ASC, $list);
  6234. foreach ($list as $key => $value) {
  6235. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6236. if ($typeclass) {
  6237. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6238. } else {
  6239. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6240. $i++;
  6241. continue;
  6242. }
  6243. }
  6244. if ($i > 0) {
  6245. $yc = $i . '条异常';
  6246. }
  6247. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6248. exit;
  6249. }
  6250. }
  6251. public function _uck()
  6252. {
  6253. if (isset($_GET['excel'])) {
  6254. $tc = array();
  6255. $typeclass = $this->typeclass->find_all();
  6256. foreach ($typeclass as $v) {
  6257. $tc[$v['id']] = $v['zh'];
  6258. }
  6259. $data = array();
  6260. $t = array();
  6261. $rq = '';
  6262. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6263. $ts = $ts / (24 * 3600);
  6264. for ($i = 0; $i < $ts; $i++) {
  6265. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6266. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6267. }
  6268. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6269. foreach ($info_list as $k => $v) {
  6270. $features = explode('-', trim($v['features'], '-'));
  6271. if (!isset($features[3]) || !isset($features[4])) {
  6272. continue;
  6273. }
  6274. $data[$k][0] = $tc[$features[0]]; //类型
  6275. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6276. $data[$k][2] = $tc[$features[4]]; //曲度
  6277. $data[$k][3] = '';
  6278. if (isset($data[$k][1])) {
  6279. $data[$k][3] .= $data[$k][1];
  6280. }
  6281. if (isset($data[$k][2])) {
  6282. $data[$k][3] .= $data[$k][2];
  6283. }
  6284. if (isset($features[5])) {
  6285. $data[$k][3] .= $tc[$features[5]];
  6286. }
  6287. if (isset($features[2])) {
  6288. $data[$k][3] .= $tc[$features[2]];
  6289. }
  6290. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6291. $data[$k][4] = $v['sku'];
  6292. $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())) . '))'); //月初库存
  6293. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6294. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6295. $ztrq = '';
  6296. $ztsl = '';
  6297. if (count($zt) > 0) {
  6298. foreach ($zt as $vv) {
  6299. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6300. $ztsl .= $vv['num'] . '<br>';
  6301. }
  6302. }
  6303. $data[$k][] = trim($ztsl, '<br>');
  6304. $data[$k][] = trim($ztrq, '<br>');
  6305. $byck = 0;
  6306. foreach ($t as $vv) {
  6307. $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));
  6308. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6309. $byck += $sl;
  6310. }
  6311. $data[$k][] = ($byck > 0) ? $byck : '';
  6312. }
  6313. $title = "详情 " . date("Y-m-d", time());
  6314. $titlename = "<table border=1>
  6315. <tr align='center'>
  6316. <td>类别</td>
  6317. <td>颜色</td>
  6318. <td>曲度</td>
  6319. <td>名称</td>
  6320. <td>SKU</td>
  6321. <td>月初库存</td>
  6322. <td>剩余库存</td>
  6323. <td>在途数量</td>
  6324. <td>预达日期</td>" .
  6325. $rq
  6326. . "<td>本月出库</td></tr>
  6327. </table>";
  6328. $filename = $title . ".xls";
  6329. $tail = "";
  6330. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6331. }
  6332. }
  6333. public function _whlabelexcelzh()
  6334. {
  6335. if (isset($_GET['excel'])) {
  6336. $where = "sku != 'Preset'";
  6337. //数据排序
  6338. $order_str = "id desc";
  6339. if (empty($page)) {
  6340. $start = 0;
  6341. $perpage = 1;
  6342. } else {
  6343. $start = ($page - 1) * $perpage;
  6344. }
  6345. $category = $this->input->get('category', true);
  6346. $warehouse = $this->input->get('warehouse', true);
  6347. $excelid = $this->input->get('sid', true);
  6348. if ($category) {
  6349. $where .= " and features like '%-$category-%'";
  6350. }
  6351. if ($warehouse) {
  6352. $where .= " and warehouse = '$warehouse'";
  6353. }
  6354. $xzid = '';
  6355. if ($excelid) {
  6356. $excelid = explode(',', trim($excelid, ','));
  6357. foreach ($excelid as $key => $value) {
  6358. $xzid .= " id = " . $value . " or";
  6359. }
  6360. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6361. }
  6362. //取得信息列表
  6363. /**
  6364. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6365. $rows = array();$list = array();
  6366. foreach ($info_list as $key=>$value)
  6367. {
  6368. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6369. }
  6370. **/
  6371. $list = array();
  6372. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6373. foreach ($rows as $key => $value) {
  6374. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6375. $zh = '';
  6376. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6377. foreach ($zt as $v) {
  6378. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6379. }
  6380. $zt = array_sum(array_column($zt, 'num'));
  6381. $number = $value['number'];
  6382. $ftime = time() - 15 * 24 * 3600;
  6383. $warehouse = $this->warehouse->read($value['warehouse']);
  6384. $rows[$key]['warehouse'] = $warehouse['title'];
  6385. $rows[$key]['number'] = $c;
  6386. $rows[$key]['features'] = $zh;
  6387. $rows[$key]['hb'] = $c + $zt;
  6388. }
  6389. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6390. $titlename = "<table border=1>
  6391. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6392. <tr align='center'>
  6393. <td>仓库</td>
  6394. <td>SKU</td>
  6395. <td>产品</td>
  6396. <td>库存数量</td>
  6397. <td>在途数量及预达日期</td>
  6398. <td>在途+库存数量</td>
  6399. </tr>
  6400. </table>";
  6401. $filename = $title . ".xls";
  6402. $tail = "";
  6403. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6404. }
  6405. if (isset($_GET['excel'])) {
  6406. $warehouse = $this->input->get('warehouse', true);
  6407. $sku = $this->input->get('sku', true);
  6408. $cz = $this->input->get('cz', true);
  6409. $text = $this->input->post('text', true);
  6410. $xztime = $this->input->get('xztime', true);
  6411. $timetk = $this->input->get('timetk', true);
  6412. $timetj = $this->input->get('timetj', true);
  6413. $timetk = strtotime($timetk);
  6414. $timetj = strtotime($timetj);
  6415. $where = "time = '0' ";
  6416. if ($warehouse) {
  6417. $where .= " and warehouse = '$warehouse'";
  6418. }
  6419. if ($sku) {
  6420. $where .= " and sku = '$sku'";
  6421. }
  6422. if ($text) {
  6423. $where .= " and text like '%$text%'";
  6424. }
  6425. if ($cz != '') {
  6426. $where .= " and cz = '$cz'";
  6427. }
  6428. if ($timetk && $timetj) {
  6429. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6430. }
  6431. //数据排序
  6432. $order_str = $xztime . " desc";
  6433. //取得信息列表
  6434. $zh = array();
  6435. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6436. foreach ($info_list as $v) {
  6437. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6438. $warehouse = $this->warehouse->read($v['warehouse']);
  6439. $v['warehouse'] = $warehouse['title'];
  6440. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6441. $v['stime'] = date('Y-m-d', $v['stime']);
  6442. if (isset($zh[$v['features']])) {
  6443. $zh[$v['features']]['num'] += $v['num'];
  6444. } else {
  6445. $zh[$v['features']] = $v;
  6446. }
  6447. $zh[$v['features']]['features'] = $c;
  6448. }
  6449. $title = "在途数据" . date('Y-m-d', time());
  6450. $titlename = "<table border=1>
  6451. <tr align='center'>
  6452. <td>仓库</td>
  6453. <td>SKU</td>
  6454. <td>名称</td>
  6455. <td>在途数量</td>
  6456. <td>库存数量</td>
  6457. <td>添加在途日期</td>
  6458. <td>预达日期</td>
  6459. <td>备注</td>
  6460. </tr>
  6461. </table>";
  6462. $filename = $title . ".xls";
  6463. $tail = "";
  6464. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6465. }
  6466. }
  6467. public function _fc()
  6468. {
  6469. $vip = 0;
  6470. if (isset($_SESSION['api'])) {
  6471. $user = $this->user->get_api($_SESSION['api']);
  6472. if ($user['vip'] == 1) {
  6473. $vip = 1;
  6474. }
  6475. } else {
  6476. header('Location: /');
  6477. exit;
  6478. }
  6479. $post = $this->input->post(NULL, TRUE);
  6480. if (isset($post['page'])) {
  6481. $page = $this->input->post('page', true);
  6482. $perpage = $this->input->post('perpage', true);
  6483. $category = $this->input->post('category', true);
  6484. $size = $this->input->post('size', true);
  6485. $grade = $this->input->post('grade', true);
  6486. $color = $this->input->post('color', true);
  6487. $lowe = $this->input->post('lowe', true);
  6488. $sku = $this->input->post('sku');
  6489. $title = $this->input->post('title');
  6490. $warehouse = $this->input->post('warehouse', true);
  6491. $usa = $this->input->post('usa', true);
  6492. $purchase = $this->input->post('purchase', true);
  6493. $lacetype = $this->input->post('lacetype', true);
  6494. $haircap = $this->input->post('haircap', true);
  6495. $density = $this->input->post('density', true);
  6496. $details = $this->input->post('details', true);
  6497. $state = $this->input->post('state', true);
  6498. $ktime = $this->input->post('ktime', true);
  6499. $jtime = $this->input->post('jtime', true);
  6500. $ktime = strtotime($ktime);
  6501. $jtime = strtotime($jtime);
  6502. $where = "state = '11'";
  6503. $gj = "";
  6504. $ck = "";
  6505. if ($lacetype) {
  6506. $where .= " and features like '%-$lacetype-%'";
  6507. }
  6508. if ($category) {
  6509. $where .= " and features like '%-$category-%'";
  6510. }
  6511. if ($size) {
  6512. $where .= " and features like '%-$size-%'";
  6513. }
  6514. if ($grade) {
  6515. $where .= " and features like '%-$grade-%'";
  6516. }
  6517. if ($color) {
  6518. $where .= " and features like '%-$color-%'";
  6519. }
  6520. if ($lowe) {
  6521. $where .= " and features like '%-$lowe-%'";
  6522. }
  6523. if ($haircap) {
  6524. $where .= " and features like '%-$haircap-%'";
  6525. }
  6526. if ($density) {
  6527. $where .= " and features like '%-$density-%'";
  6528. }
  6529. if ($usa) {
  6530. if (!$warehouse) {
  6531. $where .= " and (warehouse = '5' or warehouse = '8')";
  6532. }
  6533. }
  6534. if ($warehouse) {
  6535. $where .= " and warehouse = '$warehouse'";
  6536. }
  6537. if ($details) {
  6538. $where .= " and details = '$details'";
  6539. }
  6540. if ($purchase) {
  6541. $where .= " and purchase = '$purchase'";
  6542. }
  6543. if ($state) {
  6544. $where .= " and state = '$state'";
  6545. }
  6546. if ($ktime && $jtime) {
  6547. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6548. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6549. }
  6550. //数据排序
  6551. $order_str = "id desc";
  6552. if (empty($page)) {
  6553. $start = 0;
  6554. $perpage = 1;
  6555. } else {
  6556. $start = ($page - 1) * $perpage;
  6557. }
  6558. if ($sku) {
  6559. $sku = trim($sku, ' ');
  6560. $sku = trim($sku, ' ');
  6561. $where .= " and sku like '%$sku%'";
  6562. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6563. } else if ($title) {
  6564. $title = trim($title, ' ');
  6565. $title = trim($title, ' ');
  6566. $where .= " and title like '%$title%'";
  6567. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6568. } else {
  6569. //$where .= " and time > '$ktime' and time < '$jtime'";
  6570. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6571. }
  6572. //取得信息列表
  6573. $rows = array();
  6574. $list = array();
  6575. foreach ($info_list as $key => $value) {
  6576. $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'] . '"');
  6577. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6578. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6579. $warehouse = $this->warehouse->read($value['warehouse']);
  6580. $info_list[$key]['warehouse'] = $warehouse['title'];
  6581. $info_list[$key]['number'] = $g;
  6582. $info_list[$key]['features'] = $x;
  6583. $info_list[$key]['x'] = $s;
  6584. }
  6585. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6586. $pagenum = ceil($total / $perpage);
  6587. $over = $total - ($start + $perpage);
  6588. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6589. echo json_encode($rows);
  6590. exit;
  6591. }
  6592. $this->data['vip'] = $vip;
  6593. $this->_Template('whlabel_fc', $this->data);
  6594. }
  6595. public function _fcmb()
  6596. {
  6597. $where = "sku != 'Preset'";
  6598. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6599. foreach ($rows as $k => $v) {
  6600. $warehouse = $this->warehouse->read($v['warehouse']);
  6601. $rows[$k]['warehouse'] = $warehouse['title'];
  6602. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6603. $rows[$k]['t'] = '';
  6604. $rows[$k]['n'] = '';
  6605. }
  6606. $title = "封货产品数据导入模板";
  6607. $titlename = "<table border=1>
  6608. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6609. <tr align='center'>
  6610. <td>仓库</td>
  6611. <td>SKU</td>
  6612. <td>产品</td>
  6613. <td>封存产品总数量</td>
  6614. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6615. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6616. </tr>
  6617. </table>";
  6618. $filename = $title . ".xls";
  6619. $tail = "";
  6620. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6621. }
  6622. public function _fcexcel()
  6623. {
  6624. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6625. $config['upload_path'] = '.' . $dir;
  6626. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6627. $config['allowed_types'] = 'xls|xlsx|csv';
  6628. $config['max_size'] = 10240;
  6629. $this->load->library('upload', $config);
  6630. $this->upload->initialize($config);
  6631. if ($this->upload->do_upload('userfile')) {
  6632. $full_path = $dir . $this->upload->data('file_name');
  6633. $fileName = '.' . $full_path;
  6634. if (!file_exists($fileName)) {
  6635. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6636. exit;
  6637. } else {
  6638. libxml_use_internal_errors(true);
  6639. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6640. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6641. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6642. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6643. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6644. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6645. ++$column; //如果列数大于26行
  6646. $list = array();
  6647. for ($i = 2; $i <= $row; $i++) // 行数循环
  6648. {
  6649. $data = array();
  6650. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6651. {
  6652. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6653. }
  6654. $list[] = $data;
  6655. }
  6656. }
  6657. $i = 0;
  6658. $j = 0;
  6659. $ed = array();
  6660. foreach ($list as $key => $value) {
  6661. $time = time();
  6662. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6663. continue;
  6664. }
  6665. $warehouse = $this->warehouse->get_title($value['0']);
  6666. $sku = $value['1'];
  6667. $type = $value['4']; //调整方式0扣减1删除
  6668. $num = $value['5']; //调整数量
  6669. //$text = $value['4'];//扣减说明
  6670. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6671. if (!$d) //如果没有这个SKU
  6672. {
  6673. $ed[] = array($sku . '-库存中不存在此SKU');
  6674. $j++;
  6675. continue;
  6676. }
  6677. if (!isset($warehouse['id'])) {
  6678. $ed[] = array($sku . '-仓库名错误!');
  6679. $j++;
  6680. continue;
  6681. }
  6682. if ($type == 1 || $type == 2) //扣减库存
  6683. {
  6684. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6685. if (count($data) < abs($num)) {
  6686. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6687. $j++;
  6688. continue;
  6689. }
  6690. if ($type == 1) //转入库存
  6691. {
  6692. for ($i = 0; $i < abs($num); $i++) {
  6693. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6694. }
  6695. } else if ($type == 2) //删除
  6696. {
  6697. for ($i = 0; $i < abs($num); $i++) {
  6698. $this->whlabel->remove($data[$i]['id']);
  6699. }
  6700. }
  6701. } else if ($type == 0) //增加库存
  6702. {
  6703. $post['sku'] = $d['sku'];
  6704. $post['shop'] = '';
  6705. $post['warehouse'] = $warehouse['id'];
  6706. $post['purchase'] = $d['purchase'];
  6707. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6708. $post['state'] = 11;
  6709. $post['title'] = $d['title'];
  6710. $post['number'] = $d['number'];
  6711. $post['features'] = $d['features'];
  6712. $post['enter'] = $time;
  6713. $post['time'] = $time; //操作时间
  6714. for ($i = 0; $i < $num; $i++) {
  6715. $post['label'] = time() . rand(100, 999) . $i;
  6716. $this->whlabel->insert($post);
  6717. }
  6718. }
  6719. sleep(1); //防止入库时间一样,需要延迟1秒
  6720. }
  6721. if ($j > 0) {
  6722. $tt = date('Ymd', time());
  6723. $title = '库存导入错误信息-' . $tt;
  6724. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6725. $tail = "\n";
  6726. $filename = $title . ".xls";
  6727. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6728. $dir = '/data/excel/' . $time . '/';
  6729. $file_name = 'error_' . $time . rand(1000, 9999);
  6730. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6731. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6732. fwrite($myfile, $ecl);
  6733. fclose($myfile);
  6734. $error = $dir . $file_name . '.xls';
  6735. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6736. exit;
  6737. } else {
  6738. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6739. exit;
  6740. }
  6741. }
  6742. }
  6743. public function _fcjxc($arg_array)
  6744. {
  6745. if (isset($_GET['excel'])) {
  6746. $category = $this->input->get('category', true);
  6747. $size = $this->input->get('size', true);
  6748. $grade = $this->input->get('grade', true);
  6749. $color = $this->input->get('color', true);
  6750. $lowe = $this->input->get('lowe', true);
  6751. $sku = $this->input->get('sku');
  6752. $title = $this->input->get('title');
  6753. $warehouse = $arg_array[0];
  6754. $usa = $this->input->get('usa', true);
  6755. $purchase = $this->input->get('purchase', true);
  6756. $lacetype = $this->input->get('lacetype', true);
  6757. $haircap = $this->input->get('haircap', true);
  6758. $density = $this->input->get('density', true);
  6759. $title = $this->input->get('title', true);
  6760. $state = $this->input->get('state', true);
  6761. $ktime = $this->input->get('ktime', true);
  6762. $jtime = $this->input->get('jtime', true);
  6763. $where = "state=11";
  6764. $gj = "";
  6765. $ck = "";
  6766. if ($lacetype) {
  6767. $where .= " and features like '%-$lacetype-%'";
  6768. }
  6769. if ($category) {
  6770. $where .= " and features like '%-$category-%'";
  6771. }
  6772. if ($size) {
  6773. $where .= " and features like '%-$size-%'";
  6774. }
  6775. if ($grade) {
  6776. $where .= " and features like '%-$grade-%'";
  6777. }
  6778. if ($color) {
  6779. $where .= " and features like '%-$color-%'";
  6780. }
  6781. if ($lowe) {
  6782. $where .= " and features like '%-$lowe-%'";
  6783. }
  6784. if ($haircap) {
  6785. $where .= " and features like '%-$haircap-%'";
  6786. }
  6787. if ($density) {
  6788. $where .= " and features like '%-$density-%'";
  6789. }
  6790. if ($usa) {
  6791. if (!$warehouse) {
  6792. $where .= " and (warehouse = '5' or warehouse = '8')";
  6793. }
  6794. }
  6795. if ($warehouse) {
  6796. $where .= " and warehouse = '$warehouse'";
  6797. }
  6798. if ($purchase) {
  6799. $where .= " and purchase = '$purchase'";
  6800. }
  6801. if ($state) {
  6802. $where .= " and state = '$state'";
  6803. }
  6804. $order_str = "id desc";
  6805. if ($sku) {
  6806. $sku = trim($sku, ' ');
  6807. $sku = trim($sku, ' ');
  6808. $where .= " and sku like '%$sku%'";
  6809. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6810. } else if ($title) {
  6811. $title = trim($title, ' ');
  6812. $title = trim($title, ' ');
  6813. $where .= " and title like '%$title%'";
  6814. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6815. } else {
  6816. //$where .= " and time > '$ktime' and time < '$jtime'";
  6817. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6818. }
  6819. //取得信息列表
  6820. $rows = array();
  6821. $list = array();
  6822. foreach ($info_list as $key => $value) {
  6823. $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'] . '"');
  6824. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6825. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6826. $rows[$key] = $value;
  6827. $warehouse = $this->warehouse->read($value['warehouse']);
  6828. $rows[$key]['warehouse'] = $warehouse['title'];
  6829. $rows[$key]['features'] = $g;
  6830. $rows[$key]['a'] = $x;
  6831. $rows[$key]['b'] = $s;
  6832. }
  6833. $title = "总统计表";
  6834. $titlename = "<table border=1>
  6835. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6836. <tr align='center'>
  6837. <td>仓库</td>
  6838. <td>SKU</td>
  6839. <td>产品名称</td>
  6840. <td>录入总量</td>
  6841. <td>取出总量</td>
  6842. <td>剩余总量</td>
  6843. </tr>
  6844. </table>";
  6845. $filename = $title . ".xls";
  6846. $tail = "";
  6847. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6848. }
  6849. $vip = 0;
  6850. if (isset($_SESSION['api'])) {
  6851. $user = $this->user->get_api($_SESSION['api']);
  6852. if ($user['vip'] == 1) {
  6853. $vip = 1;
  6854. }
  6855. } else {
  6856. header('Location: /');
  6857. exit;
  6858. }
  6859. $post = $this->input->post(NULL, TRUE);
  6860. if (isset($post['page'])) {
  6861. $page = $this->input->post('page', true);
  6862. $perpage = $this->input->post('perpage', true);
  6863. $category = $this->input->post('category', true);
  6864. $size = $this->input->post('size', true);
  6865. $grade = $this->input->post('grade', true);
  6866. $color = $this->input->post('color', true);
  6867. $lowe = $this->input->post('lowe', true);
  6868. $sku = $this->input->post('sku');
  6869. $title = $this->input->post('title');
  6870. $warehouse = $arg_array[0];
  6871. $usa = $this->input->post('usa', true);
  6872. $purchase = $this->input->post('purchase', true);
  6873. $lacetype = $this->input->post('lacetype', true);
  6874. $haircap = $this->input->post('haircap', true);
  6875. $density = $this->input->post('density', true);
  6876. $title = $this->input->post('title', true);
  6877. $state = $this->input->post('state', true);
  6878. $ktime = $this->input->post('ktime', true);
  6879. $jtime = $this->input->post('jtime', true);
  6880. $ktime = strtotime($ktime);
  6881. $jtime = strtotime($jtime);
  6882. $where = "state=11";
  6883. $gj = "";
  6884. $ck = "";
  6885. if ($lacetype) {
  6886. $where .= " and features like '%-$lacetype-%'";
  6887. }
  6888. if ($category) {
  6889. $where .= " and features like '%-$category-%'";
  6890. }
  6891. if ($size) {
  6892. $where .= " and features like '%-$size-%'";
  6893. }
  6894. if ($grade) {
  6895. $where .= " and features like '%-$grade-%'";
  6896. }
  6897. if ($color) {
  6898. $where .= " and features like '%-$color-%'";
  6899. }
  6900. if ($lowe) {
  6901. $where .= " and features like '%-$lowe-%'";
  6902. }
  6903. if ($haircap) {
  6904. $where .= " and features like '%-$haircap-%'";
  6905. }
  6906. if ($density) {
  6907. $where .= " and features like '%-$density-%'";
  6908. }
  6909. if ($usa) {
  6910. if (!$warehouse) {
  6911. $where .= " and (warehouse = '5' or warehouse = '8')";
  6912. }
  6913. }
  6914. if ($warehouse) {
  6915. $where .= " and warehouse = '$warehouse'";
  6916. }
  6917. if ($purchase) {
  6918. $where .= " and purchase = '$purchase'";
  6919. }
  6920. if ($state) {
  6921. $where .= " and state = '$state'";
  6922. }
  6923. if ($ktime && $jtime) {
  6924. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6925. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6926. }
  6927. //数据排序
  6928. $order_str = "id desc";
  6929. $xs = 0;
  6930. $rows = array();
  6931. $list = array();
  6932. if (empty($page)) {
  6933. $start = 0;
  6934. $perpage = 1;
  6935. } else {
  6936. $start = ($page - 1) * $perpage;
  6937. }
  6938. if ($sku || $title) {
  6939. if ($title) {
  6940. $title = trim($title, ' ');
  6941. $title = trim($title, ' ');
  6942. $where .= " and title like '%$title%'";
  6943. } else {
  6944. $sku = trim($sku, ' ');
  6945. $sku = trim($sku, ' ');
  6946. $where .= " and sku like '%$sku%'";
  6947. }
  6948. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6949. foreach ($info_list as $key => $value) {
  6950. $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'] . '"');
  6951. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6952. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6953. $rows[$key] = $value;
  6954. $warehouse = $this->warehouse->read($value['warehouse']);
  6955. $rows[$key]['warehouse'] = $warehouse['title'];
  6956. $rows[$key]['features'] = $g;
  6957. $rows[$key]['a'] = $x;
  6958. $rows[$key]['b'] = $s;
  6959. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6960. $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天销量
  6961. $yj = $c / ($xl / 30);
  6962. if ($yj < 7) {
  6963. $rows[$key]['y'] = round($yj) . '天销量';
  6964. } else {
  6965. $rows[$key]['y'] = '正常';
  6966. }
  6967. }
  6968. } else {
  6969. //$where .= " and time > '$ktime' and time < '$jtime'";
  6970. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6971. foreach ($info_list as $key => $value) {
  6972. $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'] . '"');
  6973. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6974. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6975. $zs[$key] = $value;
  6976. $warehouse = $this->warehouse->read($value['warehouse']);
  6977. $zs[$key]['warehouse'] = $warehouse['title'];
  6978. $zs[$key]['features'] = $g;
  6979. $zs[$key]['a'] = $x;
  6980. $zs[$key]['b'] = $s;
  6981. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6982. $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天销量
  6983. $yj = $c / ($xl / 30);
  6984. if ($yj < 7) {
  6985. $zs[$key]['y'] = round($yj) . '天销量';
  6986. $rows[$key] = $zs[$key];
  6987. }
  6988. }
  6989. }
  6990. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  6991. $pagenum = ceil($total / $perpage);
  6992. $over = $total - ($start + $perpage);
  6993. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  6994. echo json_encode($rows);
  6995. exit;
  6996. }
  6997. $this->data['arg_array'] = $arg_array[0];
  6998. $this->_Template('whlabel_fcjxc', $this->data);
  6999. }
  7000. public function _0kcdel()
  7001. {
  7002. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7003. $config['upload_path'] = '.' . $dir;
  7004. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7005. $config['allowed_types'] = 'xls|xlsx|csv';
  7006. $config['max_size'] = 10240;
  7007. $this->load->library('upload', $config);
  7008. $this->upload->initialize($config);
  7009. if ($this->upload->do_upload('userfile')) {
  7010. $full_path = $dir . $this->upload->data('file_name');
  7011. $fileName = '.' . $full_path;
  7012. if (!file_exists($fileName)) {
  7013. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7014. exit;
  7015. } else {
  7016. require_once "./data/excel/PHPExcel/IOFactory.php";
  7017. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7018. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7019. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7020. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7021. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7022. ++$column; //如果列数大于26行
  7023. $list = array();
  7024. for ($i = 2; $i <= $row; $i++) // 行数循环
  7025. {
  7026. $data = array();
  7027. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7028. {
  7029. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7030. }
  7031. $list[] = $data;
  7032. }
  7033. }
  7034. $i = 0;
  7035. $j = 0;
  7036. $ed = array();
  7037. foreach ($list as $key => $value) {
  7038. $time = time();
  7039. if ($value['0'] == "" || $value['1'] == "") {
  7040. continue;
  7041. }
  7042. $warehouse = $this->warehouse->get_title($value['0']);
  7043. $sku = $value['1'];
  7044. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7045. if (!$d) //如果没有这个SKU
  7046. {
  7047. $ed[] = array($sku . '-库存中不存在此SKU');
  7048. $j++;
  7049. continue;
  7050. }
  7051. if (!isset($warehouse['id'])) {
  7052. $ed[] = array($sku . '-仓库名错误!');
  7053. $j++;
  7054. continue;
  7055. }
  7056. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7057. if ($z < 1) {
  7058. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7059. foreach ($z as $v) {
  7060. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7061. if (count($zt) > 0) {
  7062. $ed[] = array($sku . '-有在途库存无法删除!');
  7063. $j++;
  7064. continue;
  7065. }
  7066. $this->whlabel->remove($v['id']);
  7067. }
  7068. } else {
  7069. $ed[] = array($sku . '-非0库存!');
  7070. $j++;
  7071. continue;
  7072. }
  7073. }
  7074. if ($j > 0) {
  7075. $tt = date('Ymd', time());
  7076. $title = '删除0库存错误信息-' . $tt;
  7077. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7078. $tail = "\n";
  7079. $filename = $title . ".xls";
  7080. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7081. $dir = '/data/excel/' . $time . '/';
  7082. $file_name = 'error_' . $time . rand(1000, 9999);
  7083. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7084. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7085. fwrite($myfile, $ecl);
  7086. fclose($myfile);
  7087. $error = $dir . $file_name . '.xls';
  7088. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7089. exit;
  7090. } else {
  7091. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7092. exit;
  7093. }
  7094. }
  7095. }
  7096. public function _gbhtype()
  7097. {
  7098. $post = $this->input->post(NULL, TRUE);
  7099. if (isset($post['s'])) {
  7100. $n = $this->input->post('n');
  7101. $d = $this->input->post('s');
  7102. if (!$d) {
  7103. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7104. exit;
  7105. }
  7106. $d = explode(',', trim($d, ','));
  7107. $t = $this->whlabel_type->read($n);
  7108. //循环删除记录
  7109. foreach ($d as $v) {
  7110. $u = $this->whlabel->read($v);
  7111. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7112. foreach ($data as $val) {
  7113. $this->whlabel->save(array('type' => $n), $val['id']);
  7114. }
  7115. }
  7116. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7117. }
  7118. }
  7119. //出库、退库导出
  7120. public function _dccrtype()
  7121. {
  7122. $classid = $this->classid->sku();
  7123. $pm = $classid;
  7124. $typeclass = array();
  7125. $tc = $this->typeclass->find_all();
  7126. foreach ($tc as $v) {
  7127. $typeclass[$v['id']] = $v;
  7128. }
  7129. $prc = array();
  7130. $purchase = $this->purchase->find_all();
  7131. foreach ($purchase as $k => $v) {
  7132. $prc[$v['id']] = $v['title'];
  7133. }
  7134. if (isset($_GET['sid'])) {
  7135. $wh = array();
  7136. $w = $this->warehouse->find_all('1=1', 'id,title');
  7137. foreach ($w as $v) {
  7138. $wh[$v['id']] = $v['title'];
  7139. }
  7140. $type = $this->input->get('excel', true);
  7141. $category = $this->input->get('category', true);
  7142. $size = $this->input->get('size', true);
  7143. $grade = $this->input->get('grade', true);
  7144. $color = $this->input->get('color', true);
  7145. $lowe = $this->input->get('lowe', true);
  7146. $sku = $this->input->get('sku', true);
  7147. $warehouse = $this->input->get('warehouse', true);
  7148. $lacetype = $this->input->get('lacetype', true);
  7149. $lacecolor = $this->input->get('lacecolor', true);
  7150. $density = $this->input->get('density', true);
  7151. $haircap = $this->input->get('haircap', true);
  7152. $purchase = $this->input->get('purchase', true);
  7153. $title = $this->input->get('title', true);
  7154. $state = $this->input->get('state', true);
  7155. $sid = $this->input->get('sid', true);
  7156. $ktime = $this->input->get('ktime', true);
  7157. $jtime = $this->input->get('jtime', true);
  7158. $ktime = strtotime($ktime);
  7159. $jtime = strtotime($jtime);
  7160. $where = "1=1";
  7161. $gj = "";
  7162. $ck = "";
  7163. if ($category) {
  7164. $where .= " and features like '%-$category-%'";
  7165. }
  7166. if ($size) {
  7167. $where .= " and features like '%-$size-%'";
  7168. }
  7169. if ($grade) {
  7170. $where .= " and features like '%-$grade-%'";
  7171. }
  7172. if ($color) {
  7173. $where .= " and features like '%-$color-%'";
  7174. }
  7175. if ($lowe) {
  7176. $where .= " and features like '%-$lowe-%'";
  7177. }
  7178. if ($warehouse) {
  7179. $where .= " and warehouse = '$warehouse'";
  7180. }
  7181. if ($purchase) {
  7182. $where .= " and purchase = '$purchase'";
  7183. }
  7184. if ($state) {
  7185. $where .= " and state = '$state'";
  7186. }
  7187. if ($lacetype) {
  7188. $where .= " and features like '%-$lacetype-%'";
  7189. }
  7190. if ($lacecolor) {
  7191. $where .= " and features like '%-$lacecolor-%'";
  7192. }
  7193. if ($density) {
  7194. $where .= " and features like '%-$density-%'";
  7195. }
  7196. if ($haircap) {
  7197. $where .= " and features like '%-$haircap-%'";
  7198. }
  7199. if ($title) {
  7200. $title = trim($title, ' ');
  7201. $title = trim($title, ' ');
  7202. $where .= " and title like '%$title%'";
  7203. }
  7204. if ($sku) {
  7205. $sku = trim($sku, ' ');
  7206. $sku = trim($sku, ' ');
  7207. $where .= " and sku like '%$sku%'";
  7208. }
  7209. if ($ktime && $jtime) {
  7210. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7211. }
  7212. $sidwhere = '';
  7213. if ($sid) {
  7214. $sd = "";
  7215. $s = explode(',', trim($sid, ','));
  7216. foreach ($s as $value) {
  7217. $sd .= " id = " . $value . " or";
  7218. }
  7219. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7220. }
  7221. //数据排序
  7222. $order_str = "time desc";
  7223. if (empty($page)) {
  7224. $start = 0;
  7225. $perpage = 1;
  7226. } else {
  7227. $start = ($page - 1) * $perpage;
  7228. }
  7229. $wh = array();
  7230. $w = $this->warehouse->find_all('1=1', 'id,title');
  7231. foreach ($w as $v) {
  7232. $wh[$v['id']] = $v['title'];
  7233. }
  7234. $wt = array();
  7235. $whlabel_type = $this->whlabel_type->find_all();
  7236. foreach ($whlabel_type as $v) {
  7237. $wt[$v['id']] = $v['title'];
  7238. }
  7239. $classid = $this->classid->sku();
  7240. $list = array();
  7241. $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');
  7242. foreach ($rows_r as $key => $value) {
  7243. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7244. $pm = $classid;
  7245. $jm = $classid;
  7246. $rows_r[$key]['enter'] = '入库';
  7247. $rows_r[$key]['time'] = $value['enter'];
  7248. if ($value['rktype'] == 1) {
  7249. $rows_r[$key]['rktype'] = '采购入库';
  7250. } else if ($value['rktype'] == 2) {
  7251. $rows_r[$key]['rktype'] = '盘盈调整';
  7252. } else if ($value['rktype'] == 3) {
  7253. $rows_r[$key]['rktype'] = '其他调整入库';
  7254. } else if ($value['rktype'] == 4) {
  7255. $rows_r[$key]['rktype'] = '其他调整入库';
  7256. } else if ($value['rktype'] == 5) {
  7257. $rows_r[$key]['rktype'] = '退库入库';
  7258. } else if ($value['rktype'] == 6) {
  7259. $rows_r[$key]['rktype'] = '退货可用入库';
  7260. } else if ($value['rktype'] == 7) {
  7261. $rows_r[$key]['rktype'] = '形态转换入库';
  7262. } else {
  7263. $rows_r[$key]['rktype'] = '';
  7264. }
  7265. $features = explode('-', trim($value['features'], '-'));
  7266. foreach ($features as $v) {
  7267. if (isset($typeclass[$v])) {
  7268. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7269. $pm[$typeclass[$v]['classid']] = $zh[0];
  7270. }
  7271. if (isset($typeclass[$v])) {
  7272. if (isset($jm[$typeclass[$v]['classid']])) {
  7273. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7274. }
  7275. }
  7276. }
  7277. $zh = implode(" ", $pm);
  7278. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7279. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7280. $rows_r[$key]['zh'] = $zh;
  7281. $jm = array_filter($jm);
  7282. $rows_r[$key]['features'] = implode("-", $jm);
  7283. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7284. }
  7285. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  7286. foreach ($rows_c as $key => $value) {
  7287. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7288. $pm = $classid;
  7289. $jm = $classid;
  7290. $rows_c[$key]['time'] = $value['outk'];
  7291. $rows_c[$key]['outk'] = '出库';
  7292. if ($value['cktype'] == 1) {
  7293. $rows_c[$key]['cktype'] = '销售出库';
  7294. } else if ($value['cktype'] == 2) {
  7295. $rows_c[$key]['cktype'] = '销售美国出库';
  7296. } else if ($value['cktype'] == 3) {
  7297. $rows_c[$key]['cktype'] = '盘亏调整';
  7298. } else if ($value['cktype'] == 4) {
  7299. $rows_c[$key]['cktype'] = '其他调整出库';
  7300. } else if ($value['cktype'] == 5) {
  7301. $rows_c[$key]['cktype'] = '形态转换出库';
  7302. } else {
  7303. $rows_c[$key]['cktype'] = '';
  7304. }
  7305. $features = explode('-', trim($value['features'], '-'));
  7306. foreach ($features as $v) {
  7307. if (isset($typeclass[$v])) {
  7308. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7309. $pm[$typeclass[$v]['classid']] = $zh[0];
  7310. }
  7311. if (isset($typeclass[$v])) {
  7312. if (isset($jm[$typeclass[$v]['classid']])) {
  7313. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7314. }
  7315. }
  7316. }
  7317. $zh = implode(" ", $pm);
  7318. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7319. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7320. $rows_c[$key]['zh'] = $zh;
  7321. $jm = array_filter($jm);
  7322. $rows_c[$key]['features'] = implode("-", $jm);
  7323. $rows_c[$key]['number'] = 1;
  7324. }
  7325. $merged = $rows_r;
  7326. foreach ($rows_c as $key => $value) {
  7327. if (isset($merged[$key])) {
  7328. $merged[] = $value;
  7329. } else {
  7330. $merged[$key] = $value;
  7331. }
  7332. }
  7333. usort($merged, function ($a, $b) {
  7334. return $a['time'] - $b['time'];
  7335. });
  7336. foreach ($merged as $key => $value) {
  7337. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7338. }
  7339. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7340. $titlename = "<table border=1>
  7341. <tr align='center'>
  7342. <td>仓库</td>
  7343. <td>SKU</td>
  7344. <td>商品名称</td>
  7345. <td>仓库品名</td>
  7346. <td>料号</td>
  7347. <td>时间</td>
  7348. <td>操作</td>
  7349. <td>类型</td>
  7350. <td>数量</td>
  7351. <td>备注</td>
  7352. </tr>
  7353. </table>";
  7354. $filename = $title . ".xlsx";
  7355. $tail = "";
  7356. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7357. }
  7358. }
  7359. }