Whlabel.php 259 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537
  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. $this->load->_model("Model_logic_ding","logic_ding");
  45. }
  46. //定义方法的调用规则 获取URI第二段值
  47. public function _remap($arg, $arg_array)
  48. {
  49. if ($arg == 'existence') //在库标签
  50. {
  51. $this->_existence();
  52. } else if ($arg == 'cpbqdc') //在库标签
  53. {
  54. $this->_cpbqdc();
  55. } else if ($arg == 'type') //进销存浏览
  56. {
  57. $this->_type();
  58. } else if ($arg == 'typedy') //进销存浏览店员页面
  59. {
  60. $this->_typedy($arg_array);
  61. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  62. {
  63. $this->_typedy_ck($arg_array);
  64. } else if ($arg == 'typeck') {
  65. $this->_typeck($arg_array);
  66. } else if ($arg == 'whlabeckdc') {
  67. $this->_whlabeckdc($arg_array);
  68. } else if ($arg == 'usatype') //美仓进销存浏览
  69. {
  70. $this->_usatype();
  71. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  72. {
  73. $this->_usatypeapp();
  74. } else if ($arg == 'enteradd') //入库操作
  75. {
  76. $this->_enteradd();
  77. } else if ($arg == 'enteredit') //修改
  78. {
  79. $this->_enteredit($arg_array);
  80. } else if ($arg == 'enter') //入库浏览
  81. {
  82. $this->_enter();
  83. } else if ($arg == 'out') //出库浏览
  84. {
  85. $this->_out();
  86. } else if ($arg == 'label') //出库标签浏览
  87. {
  88. $this->_label();
  89. } else if ($arg == 'outorder') //独立站出库订单
  90. {
  91. $this->_outorder();
  92. } else if ($arg == 'soutorder') //速卖通出库订单
  93. {
  94. $this->_soutorder();
  95. } else if ($arg == 'toutorder') //TT出库订单
  96. {
  97. $this->_toutorder();
  98. }else if ($arg == 'aoutorder') //amz出库订单
  99. {
  100. $this->_aoutorder();
  101. } else if ($arg == 'retreat') //退库订单
  102. {
  103. $this->_retreat();
  104. } else if ($arg == 'retreatlk') //退库订单
  105. {
  106. $this->_retreatlk();
  107. } else if ($arg == 'change') //更换标签
  108. {
  109. $this->_change();
  110. } else if ($arg == 'del') //删除
  111. {
  112. $this->_del();
  113. } else if ($arg == 'exceljxc') //进销存信息导出
  114. {
  115. $this->_exceljxc();
  116. } else if ($arg == 'excelr') //入库信息导出
  117. {
  118. $this->_excelr();
  119. } else if ($arg == 'excelct') //出库、退库信息导出
  120. {
  121. $this->_excelct();
  122. } else if ($arg == 'dccrtype') //根据出入库类型导出
  123. {
  124. $this->_dccrtype();
  125. } else if ($arg == 'excelcr') //出库、退库信息导出
  126. {
  127. $this->_excelcr();
  128. } else if ($arg == 'kcyz') //库存验证
  129. {
  130. $this->_kcyz();
  131. } else if ($arg == 'kj') //库存扣减
  132. {
  133. $this->_kj($arg_array);
  134. } else if ($arg == 'presetout') //预设库存导入
  135. {
  136. $this->_presetout($arg_array);
  137. } else if ($arg == 'presetedit') //预设库存导入
  138. {
  139. $this->_presetedit($arg_array);
  140. } else if ($arg == 'summary') //汇总导出
  141. {
  142. $this->_summary($arg_array);
  143. } else if ($arg == 'manifest') //usps发货清单
  144. {
  145. $this->_manifest();
  146. } else if ($arg == 'abnormal') //占单异常
  147. {
  148. $this->_abnormal();
  149. } else if ($arg == 'error') //0库存SKU
  150. {
  151. $this->_error();
  152. } else if ($arg == 'errorexcel') //0库存SKU导出
  153. {
  154. $this->_errorexcel();
  155. } else if ($arg == 'db') {
  156. $this->_db();
  157. } else if ($arg == 'dbrk') {
  158. $this->_dbrk();
  159. } else if ($arg == 'whlabelczdc') {
  160. $this->_whlabelczdc();
  161. } else if ($arg == 'print') {
  162. $this->_print($arg_array);
  163. } else if ($arg == 'usaprint') {
  164. $this->_usaprint($arg_array);
  165. } else if ($arg == 'printck') {
  166. $this->_printck($arg_array);
  167. } else if ($arg == 'printrk') {
  168. $this->_printrk($arg_array);
  169. } else if ($arg == 'printxzrk') {
  170. $this->_printxzrk($arg_array);
  171. } else if ($arg == 'printexcel') {
  172. $this->_printexcel($arg_array);
  173. } else if ($arg == 'uck') {
  174. $this->_uck();
  175. } else if ($arg == 'whlabelexcelzh') {
  176. $this->_whlabelexcelzh();
  177. } else if ($arg == 'fc') {
  178. $this->_fc();
  179. } else if ($arg == 'fcmb') {
  180. $this->_fcmb();
  181. } else if ($arg == 'fcexcel') {
  182. $this->_fcexcel();
  183. } else if ($arg == 'fcjxc') {
  184. $this->_fcjxc($arg_array);
  185. } else if ($arg == '0kcdel') {
  186. $this->_0kcdel(); //导表删除0库存
  187. } else if ($arg == 'gbhtype') {
  188. $this->_gbhtype(); //更改备货状态
  189. } else {
  190. $this->_index();
  191. }
  192. }
  193. //管理
  194. public function _index()
  195. {
  196. $post = $this->input->post(NULL, TRUE);
  197. if (isset($post['page'])) {
  198. $page = $this->input->post('page', true);
  199. $perpage = $this->input->post('perpage', true);
  200. $sku = $this->input->post('sku', true);
  201. $number = $this->input->post('number', true);
  202. $warehouse = $this->input->post('warehouse', true);
  203. $purchase = $this->input->post('purchase', true);
  204. $orderinfo = $this->input->post('orderinfo', true);
  205. $waybill = $this->input->post('waybill', true);
  206. $category = $this->input->post('category', true);
  207. $size = $this->input->post('size', true);
  208. $grade = $this->input->post('grade', true);
  209. $color = $this->input->post('color', true);
  210. $lowe = $this->input->post('lowe', true);
  211. $state = $this->input->post('state', true);
  212. $label = $this->input->post('label', true);
  213. $timetk = $this->input->post('timetkk', true);
  214. $timetj = $this->input->post('timetjj', true);
  215. $timetk = strtotime($timetk);
  216. $timetj = strtotime($timetj);
  217. $where = "1=1 ";
  218. if ($timetk && $timetj) {
  219. $where .= " and time > '$timetk' and time < '$timetj'";
  220. }
  221. if ($sku) {
  222. $where .= " and sku = '$sku'";
  223. }
  224. if ($number) {
  225. $where .= " and number = '$number'";
  226. }
  227. if ($warehouse) {
  228. $where .= " and warehouse = '$warehouse'";
  229. }
  230. if ($purchase) {
  231. $where .= " and purchase = '$purchase'";
  232. }
  233. if ($orderinfo) {
  234. $where .= " and orderinfo = '$orderinfo'";
  235. }
  236. if ($waybill) {
  237. $where .= " and waybill = '$waybill'";
  238. }
  239. if ($category) {
  240. $where .= " and features like '%-$category-%'";
  241. }
  242. if ($size) {
  243. $where .= " and features like '%-$size-%'";
  244. }
  245. if ($grade) {
  246. $where .= " and features like '%-$grade-%'";
  247. }
  248. if ($color) {
  249. $where .= " and features like '%-$color-%'";
  250. }
  251. if ($lowe) {
  252. $where .= " and features like '%-$lowe-%'";
  253. }
  254. if ($label) {
  255. $where .= " and label = '$label'";
  256. }
  257. if ($state != '') {
  258. $where .= " and state = '$state'";
  259. }
  260. //数据排序
  261. $order_str = "time desc";
  262. if (empty($page)) {
  263. $start = 0;
  264. $perpage = 1;
  265. } else {
  266. $start = ($page - 1) * $perpage;
  267. }
  268. //取得信息列表
  269. $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);
  270. foreach ($info_list as $key => $value) {
  271. $warehouse = $this->warehouse->read($value['warehouse']);
  272. $info_list[$key]['warehouse'] = $warehouse['title'];
  273. $purchase = $this->purchase->read($value['purchase']);
  274. $info_list[$key]['purchase'] = $purchase['title'];
  275. if ($value['enter'] != 0) {
  276. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  277. } else {
  278. $info_list[$key]['enter'] = "";
  279. }
  280. if ($value['outk'] != 0) {
  281. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  282. } else {
  283. $info_list[$key]['outk'] = "";
  284. }
  285. if ($value['printing'] != 0) {
  286. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  287. } else {
  288. $info_list[$key]['printing'] = "";
  289. }
  290. if ($value['orderinfo'] == 0) {
  291. $info_list[$key]['orderinfo'] = "";
  292. }
  293. if ($value['waybill'] == 0) {
  294. $info_list[$key]['waybill'] = "";
  295. }
  296. if ($value['state'] == 0) {
  297. $info_list[$key]['state'] = "在库";
  298. } else if ($value['state'] == 1) {
  299. $info_list[$key]['state'] = "出库";
  300. } else if ($value['state'] == 2) {
  301. $info_list[$key]['state'] = "退库";
  302. } else if ($value['state'] == 3) {
  303. $info_list[$key]['state'] = "调拨中";
  304. } else if ($value['state'] == 4) {
  305. $info_list[$key]['state'] = "再加工";
  306. } else if ($value['state'] == 5) {
  307. $info_list[$key]['state'] = "维修中";
  308. } else if ($value['state'] == 6) {
  309. $info_list[$key]['state'] = "盘亏";
  310. } else if ($value['state'] == 7) {
  311. $info_list[$key]['state'] = "更换标签";
  312. } else if ($value['state'] == 8) {
  313. $info_list[$key]['state'] = "其它";
  314. } else if ($value['state'] == 9) {
  315. $info_list[$key]['state'] = "预设";
  316. } else if ($value['state'] == 10) {
  317. $info_list[$key]['state'] = "美店零售";
  318. }
  319. if ($value['text'] == "") {
  320. $info_list[$key]['text'] = "";
  321. }
  322. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  323. }
  324. $total = $this->whlabel->find_count($where);
  325. $pagenum = ceil($total / $perpage);
  326. $over = $total - ($start + $perpage);
  327. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  328. echo json_encode($rows);
  329. exit;
  330. }
  331. if (isset($post['outsku'])) {
  332. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  333. $cz = $this->input->post('cz', true);
  334. if ($cz == '1') {
  335. $sku = $this->input->post('outsku', true);
  336. if ($sku) {
  337. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  338. if (count($data) < 1) {
  339. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  340. exit;
  341. }
  342. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  343. echo json_encode(array('success' => true));
  344. exit;
  345. }
  346. } else {
  347. echo json_encode(array('msg' => '此方法禁用!', 'success' => false));
  348. exit;
  349. $sku = $this->input->post('outsku', true);
  350. if ($sku) {
  351. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  352. if (count($data) < 1) {
  353. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  354. exit;
  355. }
  356. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  357. echo json_encode(array('success' => true));
  358. exit;
  359. }
  360. }
  361. }
  362. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  363. $this->_Template('whlabel', $this->data);
  364. }
  365. //在库标签
  366. public function _existence()
  367. {
  368. $post = $this->input->post(NULL, TRUE);
  369. if (isset($post['s'])) {
  370. $id_arr = $this->input->post('s');
  371. $id_arr = explode(',', $id_arr);
  372. if (!$id_arr) {
  373. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  374. exit;
  375. }
  376. //循环删除记录
  377. foreach ($id_arr as $v) {
  378. $sid = $this->whlabel->read($v);
  379. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  380. if ($count > 0) {
  381. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  382. exit;
  383. }
  384. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  385. if (count($zt) > 0) {
  386. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  387. exit;
  388. }
  389. $this->whlabel->remove($v);
  390. }
  391. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  392. exit;
  393. }
  394. if (isset($post['page'])) {
  395. $page = $this->input->post('page', true);
  396. $perpage = $this->input->post('perpage', true);
  397. $warehouse = $this->input->post('warehouse', true);
  398. $label = $this->input->post('label', true);
  399. $where = "1=1 and state = 0";
  400. if ($warehouse) {
  401. $where .= " and warehouse = '$warehouse'";
  402. }
  403. if ($label) {
  404. $where .= " and label = '$label'";
  405. }
  406. //数据排序
  407. $order_str = "time asc";
  408. if (empty($page)) {
  409. $start = 0;
  410. $perpage = 1;
  411. } else {
  412. $start = ($page - 1) * $perpage;
  413. }
  414. //取得信息列表
  415. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  416. foreach ($info_list as $key => $value) {
  417. if ($value['enter'] != 0) {
  418. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  419. } else {
  420. $info_list[$key]['enter'] = "";
  421. }
  422. if ($value['printing'] != 0) {
  423. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  424. } else {
  425. $info_list[$key]['printing'] = "";
  426. }
  427. }
  428. $total = $this->whlabel->find_count($where);
  429. $pagenum = ceil($total / $perpage);
  430. $over = $total - ($start + $perpage);
  431. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  432. echo json_encode($rows);
  433. exit;
  434. }
  435. $this->_Template('whlabel_existence', $this->data);
  436. }
  437. //进销存浏览
  438. public function _typedy($arg_array)
  439. {
  440. $prc = array();
  441. $purchase = $this->purchase->find_all();
  442. foreach ($purchase as $k => $v) {
  443. $prc[$v['id']] = $v['title'];
  444. }
  445. $post = $this->input->post(NULL, TRUE);
  446. if (isset($post['page'])) {
  447. $page = $this->input->post('page', true);
  448. $perpage = $this->input->post('perpage', true);
  449. $category = $this->input->post('category', true);
  450. $size = $this->input->post('size', true);
  451. $grade = $this->input->post('grade', true);
  452. $color = $this->input->post('color', true);
  453. $lowe = $this->input->post('lowe', true);
  454. $sku = $this->input->post('sku');
  455. $title = $this->input->post('title');
  456. $warehouse = $this->input->post('warehouse', true);
  457. $usa = $this->input->post('usa', true);
  458. $purchase = $this->input->post('purchase', true);
  459. $lacetype = $this->input->post('lacetype', true);
  460. $haircap = $this->input->post('haircap', true);
  461. $density = $this->input->post('density', true);
  462. $details = $this->input->post('details', true);
  463. $state = $this->input->post('state', true);
  464. $lacecolor = $this->input->post('lacecolor', true);
  465. $hairnumber = $this->input->post('hairnumber', true);
  466. $cklx = $this->input->post('cklx', true);
  467. $ktime = $this->input->post('ktime', true);
  468. $jtime = $this->input->post('jtime', true);
  469. $sm = $this->input->post('sm', true);
  470. $cpbz = $this->input->post('cpbz', true);
  471. $type = $this->input->post('type', true);
  472. $ktime = strtotime($ktime);
  473. $jtime = strtotime($jtime);
  474. $where = "1=1";
  475. $gj = "";
  476. $ck = "";
  477. if ($usa) {
  478. if (!$warehouse) {
  479. $where .= " and (warehouse = '5' or warehouse = '8')";
  480. }
  481. }
  482. if ($warehouse) {
  483. $where .= " and warehouse = '$warehouse'";
  484. }
  485. if ($details) {
  486. $where .= " and details = '$details'";
  487. }
  488. if ($purchase) {
  489. $where .= " and purchase = '$purchase'";
  490. }
  491. if (isset($state)) {
  492. $where .= " and state = '$state'";
  493. }
  494. if ($lacetype) {
  495. $where .= " and features like '%-$lacetype-%'";
  496. }
  497. if ($category) {
  498. $where .= " and features like '%-$category-%'";
  499. }
  500. if ($size) {
  501. $where .= " and features like '%-$size-%'";
  502. }
  503. if ($grade) {
  504. $where .= " and features like '%-$grade-%'";
  505. }
  506. if ($color) {
  507. $where .= " and features like '%-$color-%'";
  508. }
  509. if ($lowe) {
  510. $where .= " and features like '%-$lowe-%'";
  511. }
  512. if ($haircap) {
  513. $where .= " and features like '%-$haircap-%'";
  514. }
  515. if ($density) {
  516. $where .= " and features like '%-$density-%'";
  517. }
  518. if ($lacecolor) {
  519. $where .= " and features like '%-$lacecolor-%'";
  520. }
  521. if($sm){
  522. $where .= " and sm like '%".$sm."%'";
  523. }
  524. if($cpbz){
  525. $where .= " and cpbz like '%".$cpbz."%'";
  526. }
  527. if($type){
  528. $where .= " and type = ".$type."";
  529. }
  530. if (!empty($hairnumber)) {
  531. $where .= " and features like '%-128-%' ";
  532. if ($hairnumber < 0) {
  533. $class_list = $this->typeclass->find_all('classid = 43');
  534. foreach ($class_list as $v) {
  535. $where .= " and features not like '%-" . $v['id'] . "-%'";
  536. }
  537. } else {
  538. $where .= " and features like '%-$hairnumber-%'";
  539. }
  540. }
  541. $where_add = '';
  542. if ($cklx) {
  543. $shop = $this->shop->read($cklx);
  544. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  545. }
  546. if ($ktime && $jtime) {
  547. $gj = " and enter > '$ktime' and enter < '$jtime'";
  548. $ck = " and outk > '$ktime' and outk < '$jtime'";
  549. }
  550. //数据排序
  551. $order_str = "id desc";
  552. if (empty($page)) {
  553. $start = 0;
  554. $perpage = 1;
  555. } else {
  556. $start = ($page - 1) * $perpage;
  557. }
  558. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  559. if ($sku) {
  560. $sku = trim($sku, ' ');
  561. $sku = trim($sku, ' ');
  562. $where .= " and sku like '%$sku%'";
  563. $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);
  564. } else if ($title) {
  565. $title = trim($title, ' ');
  566. $title = trim($title, ' ');
  567. $where .= " and title like '%$title%'";
  568. $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);
  569. } else {
  570. //$where .= " and time > '$ktime' and time < '$jtime'";
  571. $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);
  572. }
  573. $this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  574. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  575. foreach ($info_list as $k => $v) {
  576. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  577. unset($info_list[$k]['pm']);
  578. unset($info_list[$k]['jm']);
  579. unset($info_list[$k]['bm']);
  580. }
  581. //取得信息列表
  582. $rows = array();
  583. $list = array();
  584. foreach ($info_list as $key => $value) {
  585. $warehouse = $this->warehouse->read($value['warehouse']);
  586. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  587. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  588. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  589. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  590. $info_list[$key]['label'] = $value['sm'];
  591. $number = $value['number'];
  592. $ftime = time() - 15 * 24 * 3600;
  593. $info_list[$key]['warehouse'] = $warehouse['title'];
  594. $info_list[$key]['features'] = count($c);
  595. $z = count($z); //查看订单号
  596. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  597. $ztdata = '';
  598. if (count($zt) > 0) {
  599. foreach ($zt as $vv) {
  600. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  601. }
  602. }
  603. $info_list[$key]['number'] = $ztdata;
  604. $info_list[$key]['sm'] = $z;
  605. $details = array();
  606. $cpid = array();
  607. foreach ($c as $k => $v) {
  608. $details[$v['details']] = $v['details'];
  609. if ($v['cpid'] != 0) {
  610. $cpid[$v['cpid']] = $v['cpid'];
  611. }
  612. }
  613. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  614. if ($value['shop'] != '') {
  615. $shop = explode(',', trim($value['shop'], ','));
  616. $shop = $this->shop->read($shop[0]);
  617. $info_list[$key]['shop'] = $shop['shopname'];
  618. }
  619. }
  620. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  621. $pagenum = ceil($total / $perpage);
  622. $over = $total - ($start + $perpage);
  623. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  624. echo json_encode($rows);
  625. exit;
  626. }
  627. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  628. $this->_Template('whlabel_typedy', $this->data);
  629. }
  630. //进销存浏览
  631. public function _typedy_ck($arg_array)
  632. {
  633. $prc = array();
  634. $purchase = $this->purchase->find_all();
  635. foreach ($purchase as $k => $v) {
  636. $prc[$v['id']] = $v['title'];
  637. }
  638. $post = $this->input->post(NULL, TRUE);
  639. if (isset($post['page'])) {
  640. $page = $this->input->post('page', true);
  641. $perpage = $this->input->post('perpage', true);
  642. $category = $this->input->post('category', true);
  643. $size = $this->input->post('size', true);
  644. $grade = $this->input->post('grade', true);
  645. $color = $this->input->post('color', true);
  646. $lowe = $this->input->post('lowe', true);
  647. $sku = $this->input->post('sku');
  648. $title = $this->input->post('title');
  649. $warehouse = $this->input->post('warehouse', true);
  650. $usa = $this->input->post('usa', true);
  651. $purchase = $this->input->post('purchase', true);
  652. $lacetype = $this->input->post('lacetype', true);
  653. $haircap = $this->input->post('haircap', true);
  654. $density = $this->input->post('density', true);
  655. $details = $this->input->post('details', true);
  656. $state = $this->input->post('state', true);
  657. $lacecolor = $this->input->post('lacecolor', true);
  658. $cklx = $this->input->post('cklx', true);
  659. $ktime = $this->input->post('ktime', true);
  660. $jtime = $this->input->post('jtime', true);
  661. $ktime = strtotime($ktime);
  662. $jtime = strtotime($jtime);
  663. $where = "1=1";
  664. $gj = "";
  665. $ck = "";
  666. if ($lacetype) {
  667. $where .= " and features like '%-$lacetype-%'";
  668. }
  669. if ($category) {
  670. $where .= " and features like '%-$category-%'";
  671. }
  672. if ($size) {
  673. $where .= " and features like '%-$size-%'";
  674. }
  675. if ($grade) {
  676. $where .= " and features like '%-$grade-%'";
  677. }
  678. if ($color) {
  679. $where .= " and features like '%-$color-%'";
  680. }
  681. if ($lowe) {
  682. $where .= " and features like '%-$lowe-%'";
  683. }
  684. if ($haircap) {
  685. $where .= " and features like '%-$haircap-%'";
  686. }
  687. if ($density) {
  688. $where .= " and features like '%-$density-%'";
  689. }
  690. if ($lacecolor) {
  691. $where .= " and features like '%-$lacecolor-%'";
  692. }
  693. if ($usa) {
  694. if (!$warehouse) {
  695. $where .= " and (warehouse = '5' or warehouse = '8')";
  696. }
  697. }
  698. if ($warehouse) {
  699. $where .= " and warehouse = '$warehouse'";
  700. }
  701. if ($details) {
  702. $where .= " and details = '$details'";
  703. }
  704. if ($purchase) {
  705. $where .= " and purchase = '$purchase'";
  706. }
  707. if ($state) {
  708. $where .= " and state = '$state'";
  709. }
  710. $where_add = '';
  711. if ($cklx) {
  712. $shop = $this->shop->read($cklx);
  713. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  714. }
  715. if ($ktime && $jtime) {
  716. $gj = " and enter > '$ktime' and enter < '$jtime'";
  717. $ck = " and outk > '$ktime' and outk < '$jtime'";
  718. }
  719. //数据排序
  720. $order_str = "id desc";
  721. if (empty($page)) {
  722. $start = 0;
  723. $perpage = 1;
  724. } else {
  725. $start = ($page - 1) * $perpage;
  726. }
  727. if ($sku) {
  728. $sku = trim($sku, ' ');
  729. $sku = trim($sku, ' ');
  730. $where .= " and sku like '%$sku%'";
  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 if ($title) {
  733. $title = trim($title, ' ');
  734. $title = trim($title, ' ');
  735. $where .= " and title like '%$title%'";
  736. $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);
  737. } else {
  738. //$where .= " and time > '$ktime' and time < '$jtime'";
  739. $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);
  740. }
  741. //取得信息列表
  742. $rows = array();
  743. $list = array();
  744. foreach ($info_list as $key => $value) {
  745. $warehouse = $this->warehouse->read($value['warehouse']);
  746. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  747. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  748. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  749. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  750. $ftime = time() - 15 * 24 * 3600;
  751. $info_list[$key]['warehouse'] = $warehouse['title'];
  752. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  753. //$z = count($z);//查看订单号
  754. //$info_list[$key]['zd'] = $z;
  755. $details = array();
  756. $cpid = array();
  757. foreach ($c as $k => $v) {
  758. $details[$v['details']] = $v['details'];
  759. if ($v['cpid'] != 0) {
  760. $cpid[$v['cpid']] = $v['cpid'];
  761. }
  762. }
  763. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  764. if ($value['shop'] != '') {
  765. $shop = explode(',', trim($value['shop'], ','));
  766. $shop = $this->shop->read($shop[0]);
  767. $info_list[$key]['shop'] = $shop['shopname'];
  768. }
  769. }
  770. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  771. $pagenum = ceil($total / $perpage);
  772. $over = $total - ($start + $perpage);
  773. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  774. echo json_encode($rows);
  775. exit;
  776. }
  777. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  778. $this->_Template('whlabel_typedy_ck', $this->data);
  779. }
  780. public function _typeck($arg_array)
  781. {
  782. $prc = array();
  783. $purchase = $this->purchase->find_all();
  784. foreach ($purchase as $k => $v) {
  785. $prc[$v['id']] = $v['title'];
  786. }
  787. $post = $this->input->post(NULL, TRUE);
  788. if (isset($post['page'])) {
  789. $page = $this->input->post('page', true);
  790. $perpage = $this->input->post('perpage', true);
  791. $category = $this->input->post('category', true);
  792. $size = $this->input->post('size', true);
  793. $grade = $this->input->post('grade', true);
  794. $color = $this->input->post('color', true);
  795. $lacecolor = $this->input->post('lacecolor', true);
  796. $lowe = $this->input->post('lowe', true);
  797. $sku = $this->input->post('sku');
  798. $title = $this->input->post('title');
  799. $warehouse = 13;
  800. $usa = $this->input->post('usa', true);
  801. $purchase = $this->input->post('purchase', true);
  802. $lacetype = $this->input->post('lacetype', true);
  803. $haircap = $this->input->post('haircap', true);
  804. $density = $this->input->post('density', true);
  805. $details = $this->input->post('details', true);
  806. $state = $this->input->post('state', true);
  807. $ktime = $this->input->post('ktime', true);
  808. $jtime = $this->input->post('jtime', true);
  809. $ktime = strtotime($ktime);
  810. $jtime = strtotime($jtime);
  811. $where = "1=1";
  812. $gj = "";
  813. $ck = "";
  814. if ($lacetype) {
  815. $where .= " and features like '%-$lacetype-%'";
  816. }
  817. if ($category) {
  818. $where .= " and features like '%-$category-%'";
  819. }
  820. if ($size) {
  821. $where .= " and features like '%-$size-%'";
  822. }
  823. if ($grade) {
  824. $where .= " and features like '%-$grade-%'";
  825. }
  826. if ($color) {
  827. $where .= " and features like '%-$color-%'";
  828. }
  829. if ($lacecolor) {
  830. $where .= " and features like '%-$lacecolor-%'";
  831. }
  832. if ($lowe) {
  833. $where .= " and features like '%-$lowe-%'";
  834. }
  835. if ($haircap) {
  836. $where .= " and features like '%-$haircap-%'";
  837. }
  838. if ($density) {
  839. $where .= " and features like '%-$density-%'";
  840. }
  841. if ($warehouse) {
  842. $where .= " and warehouse = '$warehouse'";
  843. }
  844. if ($details) {
  845. $where .= " and details = '$details'";
  846. }
  847. if ($purchase) {
  848. $where .= " and purchase = '$purchase'";
  849. }
  850. if ($state) {
  851. $where .= " and state = '$state'";
  852. }
  853. if ($ktime && $jtime) {
  854. $gj = " and enter > '$ktime' and enter < '$jtime'";
  855. $ck = " and outk > '$ktime' and outk < '$jtime'";
  856. }
  857. //数据排序
  858. $order_str = "id desc";
  859. if (empty($page)) {
  860. $start = 0;
  861. $perpage = 1;
  862. } else {
  863. $start = ($page - 1) * $perpage;
  864. }
  865. if ($sku) {
  866. $sku = trim($sku, ' ');
  867. $sku = trim($sku, ' ');
  868. $where .= " and sku like '%$sku%'";
  869. } else if ($title) {
  870. $title = trim($title, ' ');
  871. $title = trim($title, ' ');
  872. $where .= " and title like '%$title%'";
  873. }
  874. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  875. //取得信息列表
  876. $t = array();
  877. $typeclass = $this->typeclass->find_all();
  878. foreach ($typeclass as $v) {
  879. $t[$v['id']] = $v;
  880. }
  881. $rows = array();
  882. $list = array();
  883. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  884. foreach ($info_list as $key => $value) {
  885. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  886. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  887. $warehouse = $this->warehouse->read($value['warehouse']);
  888. $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');
  889. $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'] . '"');
  890. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  891. $number = $value['number'];
  892. $ftime = time() - 15 * 24 * 3600;
  893. $z = count($z); //查看订单号
  894. $info_list[$key]['warehouse'] = $warehouse['title'];
  895. $info_list[$key]['features'] = count($c);
  896. $info_list[$key]['number'] = $z;
  897. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  898. $details = array();
  899. $cpid = array();
  900. foreach ($c as $k => $v) {
  901. $details[$v['details']] = $v['details'];
  902. if ($v['cpid'] != 0) {
  903. $cpid[$v['cpid']] = $v['cpid'];
  904. }
  905. }
  906. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  907. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  908. unset($info_list[$key]['pm']);
  909. unset($info_list[$key]['jm']);
  910. unset($info_list[$key]['bm']);
  911. }
  912. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  913. $pagenum = ceil($total / $perpage);
  914. $over = $total - ($start + $perpage);
  915. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  916. echo json_encode($rows);
  917. exit;
  918. }
  919. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  920. $this->_Template('whlabel_typeck', $this->data);
  921. }
  922. //进销存导出
  923. public function _whlabeckdc()
  924. {
  925. $prc = array();
  926. $purchase = $this->purchase->find_all();
  927. foreach ($purchase as $k => $v) {
  928. $prc[$v['id']] = $v['title'];
  929. }
  930. if (isset($_GET['excel'])) {
  931. $where = "sku != 'Preset'";
  932. //数据排序
  933. $order_str = "id desc";
  934. if (empty($page)) {
  935. $start = 0;
  936. $perpage = 1;
  937. } else {
  938. $start = ($page - 1) * $perpage;
  939. }
  940. $category = $this->input->get('category', true);
  941. $color = $this->input->get('color', true);
  942. $lowe = $this->input->get('lowe', true);
  943. $lacetype = $this->input->get('lacetype', true);
  944. $size = $this->input->get('size', true);
  945. $density = $this->input->get('density', true);
  946. $haircap = $this->input->get('haircap', true);
  947. $sku = $this->input->get('sku', true);
  948. $details = $this->input->get('details', true);
  949. $warehouse = 13;
  950. $excelid = $this->input->get('sid', true);
  951. if ($category) {
  952. $where .= " and features like '%-$category-%'";
  953. }
  954. if ($color) {
  955. $where .= " and features like '%-$color-%'";
  956. }
  957. if ($lowe) {
  958. $where .= " and features like '%-$lowe-%'";
  959. }
  960. if ($lacetype) {
  961. $where .= " and features like '%-$lacetype-%'";
  962. }
  963. if ($size) {
  964. $where .= " and features like '%-$size-%'";
  965. }
  966. if ($density) {
  967. $where .= " and features like '%-$density-%'";
  968. }
  969. if ($haircap) {
  970. $where .= " and features like '%-$haircap-%'";
  971. }
  972. if ($warehouse) {
  973. $where .= " and warehouse = '$warehouse'";
  974. }
  975. if ($sku) {
  976. $where .= " and sku like '%$sku%'";
  977. }
  978. if ($details) {
  979. $where .= " and details = '$details'";
  980. }
  981. $xzid = '';
  982. if ($excelid) {
  983. $excelid = explode(',', trim($excelid, ','));
  984. foreach ($excelid as $key => $value) {
  985. $xzid .= " id = " . $value . " or";
  986. }
  987. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  988. }
  989. //取得信息列表
  990. /**
  991. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  992. $rows = array();$list = array();
  993. foreach ($info_list as $key=>$value)
  994. {
  995. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  996. }
  997. **/
  998. $wh = array();
  999. $w = $this->warehouse->find_all('1=1', 'id,title');
  1000. foreach ($w as $v) {
  1001. $wh[$v['id']] = $v['title'];
  1002. }
  1003. $tc = array();
  1004. $tcdata = array();
  1005. $list = array();
  1006. $classid = $this->classid->sku();
  1007. $tcall = $this->typeclass->find_all();
  1008. $typeclass = array();
  1009. foreach ($tcall as $v)
  1010. {
  1011. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1012. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1013. }
  1014. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1015. foreach ($rows as $key => $value) {
  1016. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1017. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1018. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1019. $rows[$key]['cpbz'] = $u9_info['bm'];
  1020. $rows[$key]['cs'] = $u9_info['jm'];
  1021. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1022. $details = array();
  1023. $cpid = array();
  1024. $cpbz = array();
  1025. $c = 0;
  1026. $g = 0;
  1027. $x = 0;
  1028. $t = 0;
  1029. $s = 0;
  1030. $q = 0;
  1031. foreach ($sd as $k => $v) {
  1032. if ($v['state'] == 0) {
  1033. $c++;
  1034. }
  1035. if ($v['state'] != 9) {
  1036. $g++;
  1037. }
  1038. if ($v['state'] == 1) {
  1039. $x++;
  1040. }
  1041. if ($v['state'] == 2) {
  1042. $t++;
  1043. }
  1044. if ($v['state'] == 8) {
  1045. $s++;
  1046. }
  1047. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1048. $q++;
  1049. }
  1050. $details[$v['details']] = $v['details'];
  1051. if ($v['cpid'] != 0) {
  1052. $cpid[$v['cpid']] = $v['cpid'];
  1053. }
  1054. if ($v['cpbz'] != '') {
  1055. $cpbz[$v['cpbz']] = $v['cpbz'];
  1056. }
  1057. }
  1058. $rows[$key]['details'] = implode("、", $details);
  1059. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1060. $number = $value['number'];
  1061. $ftime = time() - 15 * 24 * 3600;
  1062. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1063. $rows[$key]['number'] = $g;
  1064. $rows[$key]['features'] = $c;
  1065. $rows[$key]['x'] = $x;
  1066. $rows[$key]['t'] = $t;
  1067. $rows[$key]['s'] = $s;
  1068. $rows[$key]['q'] = $q;
  1069. $rows[$key]['wzsl'] = count($details);
  1070. }
  1071. $title = "进销存统计表" . date('Y-m-d', time());
  1072. $titlename = "<table border=1>
  1073. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1074. <tr align='center'>
  1075. <td>仓库</td>
  1076. <td>供应商</td>
  1077. <td>位置</td>
  1078. <td>库存编码</td>
  1079. <td>SKU</td>
  1080. <td>用友编码</td>
  1081. <td>用友料号</td>
  1082. <td>产品英文名</td>
  1083. <td>产品中文名</td>
  1084. <td>入库总量</td>
  1085. <td>库存数量</td>
  1086. <td>销售数量</td>
  1087. <td>退货数量</td>
  1088. <td>删除数量</td>
  1089. <td>其它操作</td>
  1090. <td>位置数量</td>
  1091. </tr>
  1092. </table>";
  1093. $filename = $title . ".xls";
  1094. $tail = "";
  1095. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1096. }
  1097. }
  1098. public function _type()
  1099. {
  1100. $vip = 0;
  1101. if (isset($_SESSION['api'])) {
  1102. $user = $this->user->get_api($_SESSION['api']);
  1103. $fgshop = "";
  1104. $sid = "";
  1105. $usersp = explode('|', trim($user['shop'], '|'));
  1106. foreach ($usersp as $value) {
  1107. $fgshop .= " shop = " . $value . " or";
  1108. $sid .= " id = " . $value . " or";
  1109. }
  1110. if ($user['vip'] == 1) {
  1111. $vip = 1;
  1112. }
  1113. } else {
  1114. header('Location: /');
  1115. exit;
  1116. }
  1117. $prc = array();
  1118. $purchase = $this->purchase->find_all();
  1119. foreach ($purchase as $k => $v) {
  1120. $prc[$v['id']] = $v['title'];
  1121. }
  1122. $company = array();
  1123. $ct = $this->company->find_all();
  1124. foreach ($ct as $k => $v) {
  1125. $company[$v['id']] = $v['title'];
  1126. }
  1127. $sp = array();
  1128. $s = $this->shop->find_all('1=1', 'id,shopname');
  1129. foreach ($s as $v) {
  1130. $sp[$v['id']] = $v['shopname'];
  1131. }
  1132. $wh = array();
  1133. $w = $this->warehouse->find_all('1=1', 'id,title');
  1134. foreach ($w as $v) {
  1135. $wh[$v['id']] = $v['title'];
  1136. }
  1137. $post = $this->input->post(NULL, TRUE);
  1138. if (isset($post['page'])) {
  1139. $page = $this->input->post('page', true);
  1140. $perpage = $this->input->post('perpage', true);
  1141. $category = $this->input->post('category', true);
  1142. $size = $this->input->post('size', true);
  1143. $grade = $this->input->post('grade', true);
  1144. $color = $this->input->post('color', true);
  1145. $lowe = $this->input->post('lowe', true);
  1146. $sku = $this->input->post('sku');
  1147. $title = $this->input->post('title');
  1148. $warehouse = $this->input->post('warehouse', true);
  1149. $usa = $this->input->post('usa', true);
  1150. $purchase = $this->input->post('purchase', true);
  1151. $lacetype = $this->input->post('lacetype', true);
  1152. $haircap = $this->input->post('haircap', true);
  1153. $density = $this->input->post('density', true);
  1154. $details = $this->input->post('details', true);
  1155. $state = $this->input->post('state', true);
  1156. $shop = $this->input->post('shop', true);
  1157. $lacecolor = $this->input->post('lacecolor', true);
  1158. $hairnumber = $this->input->post('hairnumber', true);
  1159. $type = $this->input->post('type', true);
  1160. $ktime = $this->input->post('ktime', true);
  1161. $jtime = $this->input->post('jtime', true);
  1162. $ktime = strtotime($ktime);
  1163. $jtime = strtotime($jtime);
  1164. $cpbz = $this->input->post('cpbz', true);
  1165. $sm = $this->input->post('sm', true);
  1166. $where = "1=1";
  1167. $gj = "";
  1168. $ck = "";
  1169. if ($usa) {
  1170. if (!$warehouse) {
  1171. $where .= " and (warehouse = '5' or warehouse = '8')";
  1172. }
  1173. }
  1174. if ($warehouse) {
  1175. $where .= " and warehouse = '$warehouse'";
  1176. }
  1177. if ($details) {
  1178. $where .= " and details = '$details'";
  1179. }
  1180. if ($purchase) {
  1181. $where .= " and purchase = '$purchase'";
  1182. }
  1183. if ($state) {
  1184. $where .= " and state = '$state'";
  1185. }
  1186. if ($shop) {
  1187. $where .= " and shop like '%$shop%'";
  1188. }
  1189. if ($type) {
  1190. $where .= " and type = '$type'";
  1191. }
  1192. if ($ktime && $jtime) {
  1193. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1194. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1195. }
  1196. if ($cpbz) {
  1197. $where .= " and cpbz like '%$cpbz%' ";
  1198. }
  1199. if ($sm) {
  1200. $where .= " and sm like '%$sm%' ";
  1201. }
  1202. if ($lacecolor) {
  1203. $where .= " and features like '%-$lacecolor-%'";
  1204. }
  1205. if ($lacetype) {
  1206. $where .= " and features like '%-$lacetype-%'";
  1207. }
  1208. if ($category) {
  1209. $where .= " and features like '%-$category-%'";
  1210. }
  1211. if ($size) {
  1212. $where .= " and features like '%-$size-%'";
  1213. }
  1214. if ($grade) {
  1215. $where .= " and features like '%-$grade-%'";
  1216. }
  1217. if ($color) {
  1218. $where .= " and features like '%-$color-%'";
  1219. }
  1220. if ($lowe) {
  1221. $where .= " and features like '%-$lowe-%'";
  1222. }
  1223. if ($haircap) {
  1224. $where .= " and features like '%-$haircap-%'";
  1225. }
  1226. if ($density) {
  1227. $where .= " and features like '%-$density-%'";
  1228. }
  1229. if (!empty($hairnumber)) {
  1230. $where .= " and features like '%-128-%' ";
  1231. if ($hairnumber < 0) {
  1232. $class_list = $this->typeclass->find_all('classid = 43');
  1233. foreach ($class_list as $v) {
  1234. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1235. }
  1236. } else {
  1237. $where .= " and features like '%-$hairnumber-%'";
  1238. }
  1239. }
  1240. //数据排序
  1241. $order_str = "id desc";
  1242. if (empty($page)) {
  1243. $start = 0;
  1244. $perpage = 1;
  1245. } else {
  1246. $start = ($page - 1) * $perpage;
  1247. }
  1248. $fjnr = '';
  1249. if ($sku) {
  1250. $sku = trim($sku, ' ');
  1251. $sku = trim($sku, ' ');
  1252. $fjnr .= " and sku like '%$sku%'";
  1253. }
  1254. if ($title) {
  1255. $title = trim($title, ' ');
  1256. $title = trim($title, ' ');
  1257. $fjnr .= " and title like '%$title%'";
  1258. }
  1259. $wt = array();
  1260. $whlabel_type = $this->whlabel_type->find_all();
  1261. foreach ($whlabel_type as $v) {
  1262. $wt[$v['id']] = $v['title'];
  1263. }
  1264. //$where .= " and time > '$ktime' and time < '$jtime'";
  1265. $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
  1266. //取得信息列表
  1267. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1268. $rows = array();
  1269. $list = array();
  1270. foreach ($info_list as $key => $value) {
  1271. if (isset($wt[$value['type']])) {
  1272. $info_list[$key]['type'] = $wt[$value['type']];
  1273. } else {
  1274. $info_list[$key]['type'] = '未设置';
  1275. }
  1276. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1277. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1278. $ztdata = '';
  1279. if (count($zt) > 0) {
  1280. foreach ($zt as $vv) {
  1281. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1282. }
  1283. }
  1284. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1285. $cdata = array_filter($qbdata, function ($item) {
  1286. return $item['state'] < 1;
  1287. });
  1288. $c = array_sum(array_column($cdata, 'jnum'));
  1289. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1290. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1291. });
  1292. $g = array_sum(array_column($gdata, 'jnum'));
  1293. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1294. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1295. });
  1296. $x = array_sum(array_column($xdata, 'jnum'));
  1297. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1298. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1299. });
  1300. $t = array_sum(array_column($tdata, 'jnum'));
  1301. $zdata = array_filter($qbdata, function ($item) {
  1302. return $item['zd'] != "" && $item['state'] < 1;
  1303. });
  1304. $z = array_sum(array_column($zdata, 'jnum'));
  1305. $zdata = array_filter($qbdata, function ($item) {
  1306. return $item['zd'] != "" && $item['state'] < 1;
  1307. });
  1308. $z = array_sum(array_column($zdata, 'jnum'));
  1309. //$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');
  1310. //$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'].'"');
  1311. //$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'].'"');
  1312. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1313. //$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'].'"');
  1314. $details = array();
  1315. $cpid = array();
  1316. $od = array();
  1317. $odid = '';
  1318. $companytitle = '';
  1319. $shop_list = [];
  1320. foreach ($qbdata as $v) {
  1321. if ($v['zd'] != "" && $v['state'] < 1) {
  1322. if (!isset($od[$v['zd']])) {
  1323. $od[$v['zd']] = 1; //所有数据sku
  1324. } else {
  1325. $od[$v['zd']] = $od[$v['zd']] + 1;
  1326. }
  1327. }
  1328. if ($v['state'] < 1) {
  1329. $details[$v['details']] = $v['details'];
  1330. if ($v['cpid'] != 0) {
  1331. $cpid[$v['cpid']] = $v['cpid'];
  1332. }
  1333. }
  1334. if($v['state'] == 0){
  1335. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1336. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1337. }
  1338. if ($v['shop'] != '') {
  1339. $shop = explode(',', trim($v['shop'], ','));
  1340. foreach ($shop as $vv) {
  1341. if (!in_array($vv, $shop_list)) {
  1342. $shop_list[] = $vv;
  1343. }
  1344. }
  1345. }
  1346. }
  1347. }
  1348. foreach ($od as $k => $vv) {
  1349. $odid .= $k . '数量' . $vv;
  1350. }
  1351. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1352. $info_list[$key]['label'] = $value['sm'];
  1353. $number = $value['number'];
  1354. $ftime = time() - 15 * 24 * 3600;
  1355. $z = $z . '(' . $odid . ')'; //查看订单号
  1356. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1357. $info_list[$key]['features'] = $c;
  1358. $info_list[$key]['number'] = $ztdata;
  1359. $info_list[$key]['sm'] = $g;
  1360. $info_list[$key]['x'] = $x;
  1361. $info_list[$key]['t'] = $t;
  1362. $info_list[$key]['z'] = $z;
  1363. /**
  1364. foreach ($cdata as $k=>$v)
  1365. {
  1366. $details[$v['details']] = $v['details'];
  1367. if($v['cpid'] != 0)
  1368. {
  1369. $cpid[$v['cpid']] = $v['cpid'];
  1370. }
  1371. }
  1372. **/
  1373. $info_list[$key]['shop'] = '';
  1374. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1375. // if ($value['shop'] != '') {
  1376. // $shop = explode(',', trim($value['shop'], ','));
  1377. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1378. // }
  1379. $shop_list = array_unique($shop_list);
  1380. $shop_str = '';
  1381. foreach ($shop_list as $v) {
  1382. if(isset($sp[$v])){
  1383. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1384. }
  1385. }
  1386. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1387. /**
  1388. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1389. if(isset($companytitle[0]))
  1390. {
  1391. foreach ($companytitle as $k=>$v)
  1392. {
  1393. if($v['companytitle'] != '')
  1394. {
  1395. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1396. }
  1397. }
  1398. }
  1399. **/
  1400. }
  1401. $final_all_list = [];
  1402. foreach ($info_list as $k => $v) {
  1403. $final_all_list[] = [
  1404. 'id' => $v['id'],
  1405. "warehouse" => $v["warehouse"],
  1406. "purchase" => $v["purchase"],
  1407. "sku" => $v["sku"],
  1408. "title" => $v["title"] . "<br/>" . $v["pm"],
  1409. "details" => $v["details"],
  1410. "shop" => $v["shop"],
  1411. "cpbz" => $v["cpbz"],
  1412. 'label' => $v['label'],
  1413. "type" => $v["type"],
  1414. "features" => $v["features"],
  1415. "number" => $v["number"],
  1416. "sm" => $v["sm"],
  1417. "x" => $v["x"],
  1418. "t" => $v["t"],
  1419. "z" => $v["z"]
  1420. ];
  1421. }
  1422. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1423. $pagenum = ceil($total / $perpage);
  1424. $over = $total - ($start + $perpage);
  1425. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1426. echo json_encode($rows);
  1427. exit;
  1428. }
  1429. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1430. $this->data['shop'] = $wlshop;
  1431. $this->data['vip'] = $vip;
  1432. $this->_Template('whlabel_type', $this->data);
  1433. }
  1434. //美仓进销存浏览
  1435. public function _usatype()
  1436. {
  1437. if (isset($_SESSION['api'])) {
  1438. $user = $this->user->get_api($_SESSION['api']);
  1439. $usp = $user;
  1440. $fgshop = "";
  1441. $sid = "";
  1442. $wid = "";
  1443. $wtype = "";
  1444. $userwh = explode('|', trim($user['warehouse'], '|'));
  1445. foreach ($userwh as $value) {
  1446. $wid .= " id = " . $value . " or";
  1447. $wtype .= " type = " . $value . " or";
  1448. }
  1449. }
  1450. $prc = array();
  1451. $purchase = $this->purchase->find_all();
  1452. foreach ($purchase as $k => $v) {
  1453. $prc[$v['id']] = $v['title'];
  1454. }
  1455. $post = $this->input->post(NULL, TRUE);
  1456. if (isset($post['page'])) {
  1457. $page = $this->input->post('page', true);
  1458. $perpage = $this->input->post('perpage', true);
  1459. $category = $this->input->post('category', true);
  1460. $size = $this->input->post('size', true);
  1461. $grade = $this->input->post('grade', true);
  1462. $color = $this->input->post('color', true);
  1463. $lowe = $this->input->post('lowe', true);
  1464. $sku = $this->input->post('sku');
  1465. $title = $this->input->post('title');
  1466. $warehouse = $this->input->post('warehouse', true);
  1467. $usa = $this->input->post('usa', true);
  1468. $purchase = $this->input->post('purchase', true);
  1469. $lacetype = $this->input->post('lacetype', true);
  1470. $haircap = $this->input->post('haircap', true);
  1471. $density = $this->input->post('density', true);
  1472. $details = $this->input->post('details', true);
  1473. $state = $this->input->post('state', true);
  1474. $lacecolor = $this->input->post('lacecolor', true);
  1475. $cklx = $this->input->post('cklx', true);
  1476. $ktime = $this->input->post('ktime', true);
  1477. $jtime = $this->input->post('jtime', true);
  1478. $ktime = strtotime($ktime);
  1479. $jtime = strtotime($jtime);
  1480. $where = "1=1";
  1481. $gj = "";
  1482. $ck = "";
  1483. if ($lacetype) {
  1484. $where .= " and features like '%-$lacetype-%'";
  1485. }
  1486. if ($category) {
  1487. $where .= " and features like '%-$category-%'";
  1488. }
  1489. if ($size) {
  1490. $where .= " and features like '%-$size-%'";
  1491. }
  1492. if ($grade) {
  1493. $where .= " and features like '%-$grade-%'";
  1494. }
  1495. if ($color) {
  1496. $where .= " and features like '%-$color-%'";
  1497. }
  1498. if ($lowe) {
  1499. $where .= " and features like '%-$lowe-%'";
  1500. }
  1501. if ($haircap) {
  1502. $where .= " and features like '%-$haircap-%'";
  1503. }
  1504. if ($density) {
  1505. $where .= " and features like '%-$density-%'";
  1506. }
  1507. if ($lacecolor) {
  1508. $where .= " and features like '%-$lacecolor-%'";
  1509. }
  1510. if ($usa) {
  1511. if (!$warehouse) {
  1512. $where .= " and (warehouse = '5' or warehouse = '8')";
  1513. }
  1514. }
  1515. if ($warehouse) {
  1516. $where .= " and warehouse = '$warehouse'";
  1517. }
  1518. if ($details) {
  1519. $where .= " and details = '$details'";
  1520. }
  1521. if ($purchase) {
  1522. $where .= " and purchase = '$purchase'";
  1523. }
  1524. if ($state) {
  1525. $where .= " and state = '$state'";
  1526. }
  1527. $where_add = '';
  1528. if ($cklx) {
  1529. $shop = $this->shop->read($cklx);
  1530. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1531. }
  1532. if ($ktime && $jtime) {
  1533. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1534. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1535. }
  1536. //数据排序
  1537. $order_str = "id desc";
  1538. if (empty($page)) {
  1539. $start = 0;
  1540. $perpage = 1;
  1541. } else {
  1542. $start = ($page - 1) * $perpage;
  1543. }
  1544. if ($sku) {
  1545. $sku = trim($sku, ' ');
  1546. $sku = trim($sku, ' ');
  1547. $where .= " and sku like '%$sku%'";
  1548. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1549. } else if ($title) {
  1550. $title = trim($title, ' ');
  1551. $title = trim($title, ' ');
  1552. $where .= " and title like '%$title%'";
  1553. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1554. } else {
  1555. //$where .= " and time > '$ktime' and time < '$jtime'";
  1556. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1557. }
  1558. //取得信息列表
  1559. $rows = array();
  1560. $list = array();
  1561. foreach ($info_list as $key => $value) {
  1562. $warehouse = $this->warehouse->read($value['warehouse']);
  1563. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1564. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1565. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1566. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1567. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1568. $od = array();
  1569. $odid = '';
  1570. foreach ($z as $v) {
  1571. if (!isset($od[$v['zd']])) {
  1572. $od[$v['zd']] = 1; //所有数据sku
  1573. } else {
  1574. $od[$v['zd']] = $od[$v['zd']] + 1;
  1575. }
  1576. }
  1577. foreach ($od as $k => $vv) {
  1578. $odid .= $k . '数量' . $vv . ' ';
  1579. }
  1580. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1581. $info_list[$key]['features'] = $c;
  1582. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1583. $ztdata = '';
  1584. if (count($zt) > 0) {
  1585. foreach ($zt as $vv) {
  1586. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1587. }
  1588. }
  1589. $info_list[$key]['warehouse'] = $ztdata;
  1590. $info_list[$key]['g'] = $g;
  1591. $info_list[$key]['x'] = $x;
  1592. $info_list[$key]['t'] = $t;
  1593. $info_list[$key]['z'] = $z;
  1594. }
  1595. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1596. $pagenum = ceil($total / $perpage);
  1597. $over = $total - ($start + $perpage);
  1598. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1599. echo json_encode($rows);
  1600. exit;
  1601. }
  1602. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1603. $this->data['warehouse'] = $warehouse;
  1604. $this->_Template('whlabel_typeusa', $this->data);
  1605. }
  1606. //美仓进销存浏览
  1607. public function _usatypeapp()
  1608. {
  1609. $post = $this->input->post(NULL, TRUE);
  1610. if (isset($post['page'])) {
  1611. $page = $this->input->post('page', true);
  1612. $perpage = $this->input->post('perpage', true);
  1613. $sku = $this->input->post('sku', true);
  1614. $warehouse = 5;
  1615. $title = $this->input->post('title', true);
  1616. $state = $this->input->post('state', true);
  1617. $ktime = $this->input->post('ktime', true);
  1618. $jtime = $this->input->post('jtime', true);
  1619. $ktime = strtotime($ktime);
  1620. $jtime = strtotime($jtime);
  1621. $where = "1=1";
  1622. $gj = "";
  1623. $ck = "";
  1624. if ($title) {
  1625. $st = explode(' ', trim($title, ' '));
  1626. foreach ($st as $v) {
  1627. $where .= " and title like '%$v%'";
  1628. }
  1629. }
  1630. if ($warehouse) {
  1631. $where .= " and warehouse = '$warehouse'";
  1632. }
  1633. if ($state) {
  1634. $where .= " and state = '$state'";
  1635. }
  1636. if ($sku) {
  1637. $where .= " and sku like '%$sku%'";
  1638. }
  1639. if ($ktime && $jtime) {
  1640. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1641. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1642. }
  1643. //数据排序
  1644. $order_str = "id desc";
  1645. if (empty($page)) {
  1646. $start = 0;
  1647. $perpage = 1;
  1648. } else {
  1649. $start = ($page - 1) * $perpage;
  1650. }
  1651. //取得信息列表
  1652. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1653. $rows = array();
  1654. $list = array();
  1655. foreach ($info_list as $key => $value) {
  1656. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1657. }
  1658. $rowsdq = array_slice($rows, $start, $perpage);
  1659. foreach ($rowsdq as $value) {
  1660. $warehouse = $this->warehouse->read($value['warehouse']);
  1661. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1662. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1663. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1664. $od = array();
  1665. $odid = '';
  1666. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1667. }
  1668. $total = count($rows);
  1669. $pagenum = ceil($total / $perpage);
  1670. $over = $total - ($start + $perpage);
  1671. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1672. echo json_encode($rows);
  1673. exit;
  1674. }
  1675. $this->_Template('phone/p_usatypeapp', $this->data);
  1676. }
  1677. //入库操作
  1678. public function _enteradd()
  1679. {
  1680. $dt = 0;
  1681. if (isset($_SESSION['api'])) {
  1682. $user = $this->user->get_api($_SESSION['api']);
  1683. $usp = $user;
  1684. $fgshop = "";
  1685. $sid = "";
  1686. $user = explode('|', trim($user['shop'], '|'));
  1687. foreach ($user as $value) {
  1688. $fgshop .= " shop = " . $value . " or";
  1689. $sid .= " id = " . $value . " or";
  1690. }
  1691. }
  1692. $tc = $this->typeclass->find_all();
  1693. $typeclass = array();
  1694. foreach ($tc as $v) {
  1695. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1696. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1697. }
  1698. $post = $this->input->post(NULL, TRUE);
  1699. if (isset($post['sku'])) {
  1700. $list = array();
  1701. $num = "";
  1702. $title = "";
  1703. $features = "";
  1704. $order = $this->input->post('order', true);
  1705. $shop = $this->input->post('shop', true);
  1706. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1707. $sku = $this->input->post('sku', true);
  1708. $post['sm'] = $this->input->post('sm', true);
  1709. $post['warehouse'] = $this->input->post('warehouse', true);
  1710. $post['purchase'] = $this->input->post('purchase', true);
  1711. $post['retreatwarehouse'] = $post['warehouse'];
  1712. $post['state'] = $this->input->post('state', true);
  1713. $post['rktype'] = $this->input->post('rktype', true);
  1714. $post['text'] = $this->input->post('text', true);
  1715. $category = $this->input->post('category', true);
  1716. $list['category'] = $category;
  1717. $list['hairtype'] = $this->input->post('hairtype', true);
  1718. $list['grade'] = $this->input->post('grade', true);
  1719. $size = $this->input->post('size', true);
  1720. $xzsku = $this->input->post('xzsku', true);
  1721. $list['size'] = rtrim($size, ',');
  1722. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1723. $list['extension'] = $this->input->post('extension', true);
  1724. if ($category == 1297) {
  1725. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1726. }
  1727. if ($category == 1702) {
  1728. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1729. $list['syother'] = $this->input->post('syother', true);
  1730. }
  1731. if ($category == 133) {
  1732. $list['fittype'] = $this->input->post('fittype', true);
  1733. $list['acother'] = $this->input->post('acother', true);
  1734. }
  1735. $list['color'] = $this->input->post('color', true);
  1736. $list['lowe'] = $this->input->post('lowe', true);
  1737. if (!$post['purchase']) {
  1738. $post['purchase'] = 1;
  1739. }
  1740. if ($category == 127) {
  1741. $list['type'] = $this->input->post('type', true);
  1742. $list['headroad'] = $this->input->post('headroad', true);
  1743. $list['density'] = $this->input->post('density', true);
  1744. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1745. $list['lacesize'] = $this->input->post('lacesize', true);
  1746. }
  1747. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1748. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1749. }
  1750. if ($category == 128) {
  1751. $list['lacetype'] = $this->input->post('lacetype', true);
  1752. $list['haircap'] = $this->input->post('haircap', true);
  1753. $list['density'] = $this->input->post('density', true);
  1754. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1755. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1756. $list['wigother'] = $this->input->post('wigother', true);
  1757. $list['wigother1'] = $this->input->post('wigother1', true);
  1758. $list['wigother2'] = $this->input->post('wigother2', true);
  1759. }
  1760. if ($category == 129) {
  1761. $list['wide'] = $this->input->post('wide', true);
  1762. }
  1763. if ($category == 131) {
  1764. $list['gifttype'] = $this->input->post('gifttype', true);
  1765. $list['giftother'] = $this->input->post('giftother', true);
  1766. }
  1767. if ($category == 134) {
  1768. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1769. }
  1770. if ($category == 1297) {
  1771. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1772. $list['sywigother'] = $this->input->post('sywigother', true);
  1773. }
  1774. if ($category == 130 || $category == 133 || $category == 1702) {
  1775. $list['items'] = $this->input->post('items', true);
  1776. $list['weight'] = $this->input->post('weight', true);
  1777. }
  1778. if ($category == 1702) {
  1779. $list['syhairther'] = $this->input->post('syhairther', true);
  1780. }
  1781. $classid = $this->classid->sku();
  1782. $scsku = $classid;
  1783. $pm = $classid;
  1784. foreach ($list as $k => $v) {
  1785. if ($v != 0) {
  1786. $num .= $v;
  1787. $features .= $v . '-';
  1788. $post[$k] = $v;
  1789. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1790. if ($k != 'size') {
  1791. $title .= $typeclass[$v]['title'] . " ";
  1792. }
  1793. if (isset($pm[$typeclass[$v]['classid']])) {
  1794. if ($typeclass[$v]['title'] == '9A') {
  1795. $pm[$typeclass[$v]['classid']] = '9A';
  1796. } else if ($typeclass[$v]['title'] == '10A') {
  1797. $pm[$typeclass[$v]['classid']] = '10A';
  1798. } else {
  1799. $clzh = $typeclass[$v]['zh'];
  1800. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1801. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1802. $clzh = $clzh[0];
  1803. }
  1804. $pm[$typeclass[$v]['classid']] = $clzh;
  1805. }
  1806. }
  1807. }
  1808. }
  1809. $zh = implode(" ", $pm);
  1810. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1811. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1812. if ($list['size']) {
  1813. $typeclass = $this->typeclass->read($list['size']);
  1814. $title .= $typeclass['title'];
  1815. }
  1816. $time = time();
  1817. if ($xzsku) {
  1818. $scsku = implode("-", $scsku);
  1819. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1820. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1821. $post['sku'] = trim($scsku, ' ');
  1822. } else {
  1823. $post['sku'] = $sku;
  1824. }
  1825. //$post['sku'] = trim($sku,' ');
  1826. $post['title'] = rtrim($title, ' ');
  1827. $post['number'] = $num;
  1828. $post['features'] = '-' . $features;
  1829. $post['enter'] = $time;
  1830. $post['time'] = $time; //操作时间
  1831. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1832. if ($yza) {
  1833. if ($post['features'] != $yza[0]['features']) {
  1834. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1835. exit;
  1836. }
  1837. }
  1838. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1839. if ($yzb) {
  1840. if ($post['sku'] != $yzb[0]['sku']) {
  1841. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1842. exit;
  1843. }
  1844. }
  1845. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1846. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1847. exit;
  1848. }
  1849. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1850. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1851. exit;
  1852. }
  1853. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1854. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1855. exit;
  1856. }
  1857. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1858. if (isset($yz[0]['type'])) {
  1859. $post['type'] = $yz[0]['type'];
  1860. }
  1861. if ($post['state'] == 9) //如果选择预设库存
  1862. {
  1863. $this->whlabel->insert($post);
  1864. } else {
  1865. /**
  1866. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1867. if($ljg == 1)
  1868. {
  1869. for($i=0;$i<$order;$i++)
  1870. {
  1871. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1872. $this->whlabel->insert($post);
  1873. }
  1874. }
  1875. **/
  1876. //if($post['warehouse'] == '5')
  1877. //{
  1878. //}
  1879. $yydata = $post;
  1880. $yydata['zh'] = $zh;
  1881. /**
  1882. $wl = $this->apiyy->get_cjlp($yydata);
  1883. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1884. {
  1885. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1886. }
  1887. if($wl['Data'][0]['m_isSucess'] != 1)
  1888. {
  1889. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1890. }
  1891. **/
  1892. for ($i = 0; $i < $order; $i++) {
  1893. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1894. $this->whlabel->insert($post);
  1895. }
  1896. }
  1897. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1898. exit;
  1899. }
  1900. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1901. $this->data['wlshop'] = $wlshop;
  1902. $this->_Template('whlabel_enteradd', $this->data);
  1903. }
  1904. //修改产品
  1905. public function _enteredit($arg_array)
  1906. {
  1907. $dt = 0;
  1908. if (isset($_SESSION['api'])) {
  1909. $user = $this->user->get_api($_SESSION['api']);
  1910. $usp = $user;
  1911. $fgshop = "";
  1912. $sid = "";
  1913. $user = explode('|', trim($user['shop'], '|'));
  1914. foreach ($user as $value) {
  1915. $fgshop .= " shop = " . $value . " or";
  1916. $sid .= " id = " . $value . " or";
  1917. }
  1918. }
  1919. $post = $this->input->post(NULL, TRUE);
  1920. if (isset($post['sku'])) {
  1921. $list = array();
  1922. $num = "";
  1923. $title = "";
  1924. $features = "";
  1925. $id = $this->input->post('id', true);
  1926. $order = $this->input->post('order', true);
  1927. $shop = $this->input->post('shop', true);
  1928. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1929. $post['sku'] = $this->input->post('sku', true);
  1930. $post['sm'] = $this->input->post('sm', true);
  1931. $post['warehouse'] = $this->input->post('warehouse', true);
  1932. $post['purchase'] = $this->input->post('purchase', true);
  1933. $post['retreatwarehouse'] = $post['warehouse'];
  1934. $category = $this->input->post('category', true);
  1935. $list['category'] = $category;
  1936. $list['hairtype'] = $this->input->post('hairtype', true);
  1937. $list['grade'] = $this->input->post('grade', true);
  1938. $size = $this->input->post('size', true);
  1939. $list['size'] = rtrim($size, ',');
  1940. $post['rktype'] = $this->input->post('rktype', true);
  1941. $post['text'] = $this->input->post('text', true);
  1942. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1943. $list['extension'] = $this->input->post('extension', true);
  1944. if ($category == 1297) {
  1945. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1946. }
  1947. if ($category == 1702) {
  1948. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1949. $list['syother'] = $this->input->post('syother', true);
  1950. }
  1951. if ($category == 133) {
  1952. $list['fittype'] = $this->input->post('fittype', true);
  1953. $list['acother'] = $this->input->post('acother', true);
  1954. }
  1955. $list['color'] = $this->input->post('color', true);
  1956. $list['lowe'] = $this->input->post('lowe', true);
  1957. if (!$post['purchase']) {
  1958. $post['purchase'] = 1;
  1959. }
  1960. if ($category == 127) {
  1961. $list['type'] = $this->input->post('type', true);
  1962. $list['headroad'] = $this->input->post('headroad', true);
  1963. $list['density'] = $this->input->post('density', true);
  1964. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1965. $list['lacesize'] = $this->input->post('lacesize', true);
  1966. }
  1967. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1968. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1969. }
  1970. if ($category == 128) {
  1971. $list['lacetype'] = $this->input->post('lacetype', true);
  1972. $list['haircap'] = $this->input->post('haircap', true);
  1973. $list['density'] = $this->input->post('density', true);
  1974. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1975. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1976. $list['wigother'] = $this->input->post('wigother', true);
  1977. $list['wigother1'] = $this->input->post('wigother1', true);
  1978. $list['wigother2'] = $this->input->post('wigother2', true);
  1979. }
  1980. if ($category == 129) {
  1981. $list['wide'] = $this->input->post('wide', true);
  1982. }
  1983. if ($category == 131) {
  1984. $list['gifttype'] = $this->input->post('gifttype', true);
  1985. $list['giftother'] = $this->input->post('giftother', true);
  1986. }
  1987. if ($category == 134) {
  1988. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1989. }
  1990. if ($category == 1297) {
  1991. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1992. $list['sywigother'] = $this->input->post('sywigother', true);
  1993. }
  1994. if ($category == 130 || $category == 133 || $category == 1702) {
  1995. $list['items'] = $this->input->post('items', true);
  1996. $list['weight'] = $this->input->post('weight', true);
  1997. }
  1998. if ($category == 1702) {
  1999. $list['syhairther'] = $this->input->post('syhairther', true);
  2000. }
  2001. foreach ($list as $k => $v) {
  2002. if ($v != 0) {
  2003. $num .= $v;
  2004. $features .= $v . '-';
  2005. $typeclass = $this->typeclass->read($v);
  2006. if ($k != 'size') {
  2007. $title .= $typeclass['title'] . " ";
  2008. }
  2009. }
  2010. }
  2011. $typeclass = $this->typeclass->read($list['size']);
  2012. $title .= $typeclass['title'];
  2013. $time = time();
  2014. $post['title'] = rtrim($title, ' ');
  2015. $post['number'] = $num;
  2016. $post['features'] = '-' . $features;
  2017. $post['time'] = $time; //操作时间
  2018. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2019. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2020. exit;
  2021. }
  2022. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2023. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2024. exit;
  2025. }
  2026. $uid = $this->whlabel->read($id);
  2027. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2028. if ($datanum > 0) {
  2029. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2030. exit;
  2031. }
  2032. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2033. {
  2034. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2035. if ($yza) {
  2036. if ($post['features'] != $yza[0]['features']) {
  2037. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2038. exit;
  2039. }
  2040. }
  2041. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2042. if ($yzb) {
  2043. if ($post['sku'] != $yzb[0]['sku']) {
  2044. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2045. exit;
  2046. }
  2047. }
  2048. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2049. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2050. exit;
  2051. }
  2052. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2053. foreach ($data as $v) {
  2054. $post['id'] = $v['id'];
  2055. $this->whlabel->save($post, $v['id']);
  2056. }
  2057. } else {
  2058. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2059. if ($data > 0) {
  2060. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2061. exit;
  2062. } else {
  2063. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2064. foreach ($data as $v) {
  2065. $post['id'] = $v['id'];
  2066. $this->whlabel->save($post, $v['id']);
  2067. }
  2068. }
  2069. }
  2070. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2071. exit;
  2072. }
  2073. $uid = $this->whlabel->read($arg_array[0]);
  2074. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2075. $this->data['enter'] = $uid;
  2076. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2077. $this->data['wlshop'] = $wlshop;
  2078. $this->_Template('whlabel_enteredit', $this->data);
  2079. }
  2080. //入库浏览
  2081. public function _enter()
  2082. {
  2083. $post = $this->input->post(NULL, TRUE);
  2084. if (isset($post['s'])) {
  2085. $id_arr = $this->input->post('s');
  2086. $id_arr = explode(',', $id_arr);
  2087. if (!$id_arr) {
  2088. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2089. exit;
  2090. }
  2091. //循环删除记录
  2092. foreach ($id_arr as $v) {
  2093. $sid = $this->whlabel->read($v);
  2094. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2095. if ($count > 0) {
  2096. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2097. exit;
  2098. }
  2099. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2100. foreach ($info_list as $va) {
  2101. $this->whlabel->remove($va['id']);
  2102. }
  2103. }
  2104. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2105. exit;
  2106. }
  2107. $sp = array();
  2108. $s = $this->shop->find_all('1=1', 'id,shopname');
  2109. foreach ($s as $v) {
  2110. $sp[$v['id']] = $v['shopname'];
  2111. }
  2112. $wh = array();
  2113. $w = $this->warehouse->find_all('1=1', 'id,title');
  2114. foreach ($w as $v) {
  2115. $wh[$v['id']] = $v['title'];
  2116. }
  2117. if (isset($post['page'])) {
  2118. $page = $this->input->post('page', true);
  2119. $perpage = $this->input->post('perpage', true);
  2120. $category = $this->input->post('category', true);
  2121. $size = $this->input->post('size', true);
  2122. $grade = $this->input->post('grade', true);
  2123. $color = $this->input->post('color', true);
  2124. $lowe = $this->input->post('lowe', true);
  2125. $sku = $this->input->post('sku', true);
  2126. $warehouse = $this->input->post('warehouse', true);
  2127. $purchase = $this->input->post('purchase', true);
  2128. $ktime = $this->input->post('ktime', true);
  2129. $jtime = $this->input->post('jtime', true);
  2130. $ktime = strtotime($ktime);
  2131. $jtime = strtotime($jtime);
  2132. $where = "1=1";
  2133. $gj = "";
  2134. $ck = "";
  2135. if ($category) {
  2136. $where .= " and features like '%-$category-%'";
  2137. }
  2138. if ($size) {
  2139. $where .= " and features like '%-$size-%'";
  2140. }
  2141. if ($grade) {
  2142. $where .= " and features like '%-$grade-%'";
  2143. }
  2144. if ($color) {
  2145. $where .= " and features like '%-$color-%'";
  2146. }
  2147. if ($lowe) {
  2148. $where .= " and features like '%-$lowe-%'";
  2149. }
  2150. if ($warehouse) {
  2151. $where .= " and warehouse = '$warehouse'";
  2152. }
  2153. if ($purchase) {
  2154. $where .= " and purchase = '$purchase'";
  2155. }
  2156. if ($sku) {
  2157. $where .= " and sku like '%$sku%'";
  2158. }
  2159. if ($ktime && $jtime) {
  2160. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2161. }
  2162. //数据排序
  2163. $order_str = "enter desc";
  2164. if (empty($page)) {
  2165. $start = 0;
  2166. $perpage = 1;
  2167. } else {
  2168. $start = ($page - 1) * $perpage;
  2169. }
  2170. //取得信息列表
  2171. $info_list = $this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2172. foreach ($info_list as $k => $v) {
  2173. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2174. if ($v['shop'] == '') {
  2175. $s = '通用';
  2176. } else {
  2177. $info_list[$k]['shop'] = '';
  2178. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2179. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2180. }
  2181. }
  2182. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2183. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2184. $info_list[$k]['g'] = $g;
  2185. }
  2186. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2187. $total = count($this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,sku,title,features,number'));
  2188. $pagenum = ceil($total / $perpage);
  2189. $over = $total - ($start + $perpage);
  2190. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2191. echo json_encode($rows);
  2192. exit;
  2193. }
  2194. $this->_Template('whlabel_enter', $this->data);
  2195. }
  2196. //出库浏览
  2197. public function _out()
  2198. {
  2199. $post = $this->input->post(NULL, TRUE);
  2200. if (isset($post['page'])) {
  2201. $page = $this->input->post('page', true);
  2202. $perpage = $this->input->post('perpage', true);
  2203. $category = $this->input->post('category', true);
  2204. $size = $this->input->post('size', true);
  2205. $grade = $this->input->post('grade', true);
  2206. $color = $this->input->post('color', true);
  2207. $lowe = $this->input->post('lowe', true);
  2208. $sku = $this->input->post('sku', true);
  2209. $warehouse = $this->input->post('warehouse', true);
  2210. $purchase = $this->input->post('purchase', true);
  2211. $state = $this->input->post('state', true);
  2212. $ktime = $this->input->post('ktime', true);
  2213. $jtime = $this->input->post('jtime', true);
  2214. $ktime = strtotime($ktime);
  2215. $jtime = strtotime($jtime);
  2216. $where = "state=3";
  2217. $gj = "";
  2218. $ck = "";
  2219. if ($category) {
  2220. $where .= " and features like '%-$category-%'";
  2221. }
  2222. if ($size) {
  2223. $where .= " and features like '%-$size-%'";
  2224. }
  2225. if ($grade) {
  2226. $where .= " and features like '%-$grade-%'";
  2227. }
  2228. if ($color) {
  2229. $where .= " and features like '%-$color-%'";
  2230. }
  2231. if ($lowe) {
  2232. $where .= " and features like '%-$lowe-%'";
  2233. }
  2234. if ($state) {
  2235. $where .= " and state = '$state'";
  2236. }
  2237. if ($warehouse) {
  2238. $where .= " and warehouse = '$warehouse'";
  2239. }
  2240. if ($purchase) {
  2241. $where .= " and purchase = '$purchase'";
  2242. }
  2243. if ($sku) {
  2244. $where .= " and sku = '$sku'";
  2245. }
  2246. if ($ktime && $jtime) {
  2247. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2248. }
  2249. //数据排序
  2250. $order_str = "id desc";
  2251. if (empty($page)) {
  2252. $start = 0;
  2253. $perpage = 1;
  2254. } else {
  2255. $start = ($page - 1) * $perpage;
  2256. }
  2257. //取得信息列表
  2258. $info_list = $this->whlabel->find_all($where, 'sku');
  2259. $rows = array();
  2260. $list = array();
  2261. foreach ($info_list as $key => $value) {
  2262. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2263. }
  2264. $rows = array_unique($rows); //删除重复记录
  2265. foreach ($rows as $key => $value) {
  2266. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2267. $ck = $this->warehouse->read($data['warehouse']);
  2268. $warehouse = $ck['title'];
  2269. $gy = $this->purchase->read($data['purchase']);
  2270. $purchase = $gy['purchase'];
  2271. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2272. $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);
  2273. }
  2274. $total = count($list);
  2275. $pagenum = ceil($total / $perpage);
  2276. $over = $total - ($start + $perpage);
  2277. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2278. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2279. echo json_encode($rows);
  2280. exit;
  2281. }
  2282. $this->_Template('whlabel_out', $this->data);
  2283. }
  2284. //出库标签浏览
  2285. public function _label()
  2286. {
  2287. $post = $this->input->post(NULL, TRUE);
  2288. if (isset($post['page'])) {
  2289. $page = $this->input->post('page', true);
  2290. $perpage = $this->input->post('perpage', true);
  2291. $sku = $this->input->post('sku', true);
  2292. $warehouse = $this->input->post('warehouse', true);
  2293. $purchase = $this->input->post('purchase', true);
  2294. $orderinfo = $this->input->post('orderinfo', true);
  2295. $waybill = $this->input->post('waybill', true);
  2296. $category = $this->input->post('category', true);
  2297. $size = $this->input->post('size', true);
  2298. $grade = $this->input->post('grade', true);
  2299. $color = $this->input->post('color', true);
  2300. $lowe = $this->input->post('lowe', true);
  2301. $where = "state=1";
  2302. if ($sku) {
  2303. $where .= " and sku = '$sku'";
  2304. }
  2305. if ($warehouse) {
  2306. $where .= " and warehouse = '$warehouse'";
  2307. }
  2308. if ($purchase) {
  2309. $where .= " and purchase = '$purchase'";
  2310. }
  2311. if ($orderinfo) {
  2312. $where .= " and orderinfo = '$orderinfo'";
  2313. }
  2314. if ($waybill) {
  2315. $where .= " and waybill = '$waybill'";
  2316. }
  2317. if ($category) {
  2318. $where .= " and features like '%-$category-%'";
  2319. }
  2320. if ($size) {
  2321. $where .= " and features like '%-$size-%'";
  2322. }
  2323. if ($grade) {
  2324. $where .= " and features like '%-$grade-%'";
  2325. }
  2326. if ($color) {
  2327. $where .= " and features like '%-$color-%'";
  2328. }
  2329. if ($lowe) {
  2330. $where .= " and features like '%-$lowe-%'";
  2331. }
  2332. //数据排序
  2333. $order_str = "outk desc";
  2334. if (empty($page)) {
  2335. $start = 0;
  2336. $perpage = 1;
  2337. } else {
  2338. $start = ($page - 1) * $perpage;
  2339. }
  2340. //取得信息列表
  2341. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2342. foreach ($info_list as $key => $value) {
  2343. $warehouse = $this->warehouse->read($value['warehouse']);
  2344. $info_list[$key]['warehouse'] = $warehouse['title'];
  2345. $purchase = $this->purchase->read($value['purchase']);
  2346. $info_list[$key]['purchase'] = $purchase['title'];
  2347. if ($value['outk'] != 0) {
  2348. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2349. } else {
  2350. $info_list[$key]['outk'] = "";
  2351. }
  2352. if ($value['orderinfo'] == 0) {
  2353. $info_list[$key]['orderinfo'] = "";
  2354. }
  2355. if ($value['waybill'] == 0) {
  2356. $info_list[$key]['waybill'] = "";
  2357. }
  2358. }
  2359. $total = $this->whlabel->find_count($where);
  2360. $pagenum = ceil($total / $perpage);
  2361. $over = $total - ($start + $perpage);
  2362. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2363. echo json_encode($rows);
  2364. exit;
  2365. }
  2366. $this->_Template('whlabel_label', $this->data);
  2367. }
  2368. //独立站出库订单
  2369. public function _outorder()
  2370. {
  2371. if (isset($_SESSION['api'])) {
  2372. $user = $this->user->get_api($_SESSION['api']);
  2373. $usp = $user;
  2374. $fgshop = "";
  2375. $sid = "";
  2376. $user = explode('|', trim($user['shop'], '|'));
  2377. foreach ($user as $value) {
  2378. $fgshop .= " shop = " . $value . " or";
  2379. $sid .= " id = " . $value . " or";
  2380. }
  2381. } else {
  2382. echo "请重新登录";
  2383. }
  2384. $post = $this->input->post(NULL, TRUE);
  2385. if (isset($post['page'])) {
  2386. $page = $this->input->post('page', true);
  2387. $perpage = $this->input->post('perpage', true);
  2388. $warehouse = $this->input->post('warehouse', true);
  2389. $xztime = $this->input->post('xztime', true);
  2390. $timetk = $this->input->post('timetkk', true);
  2391. $timetj = $this->input->post('timetjj', true);
  2392. $shop = $this->input->post('shop', true);
  2393. $source = $this->input->post('source', true);
  2394. $orderinfo = $this->input->post('orderinfo', true);
  2395. $number = $this->input->post('number', true);
  2396. $sfxh = $this->input->post('sfxh', true);
  2397. $express = $this->input->post('express', true);
  2398. $waybill = $this->input->post('waybill', true);
  2399. $library = $this->input->post('library', true);
  2400. $country = $this->input->post('country', true);
  2401. $so = $this->input->post('so', true);
  2402. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2403. $print = $this->input->post('print', true);
  2404. $state = $this->input->post('state', true);
  2405. $orderurl = $this->input->post('orderurl', true);
  2406. $timetk = strtotime($timetk);
  2407. $timetj = strtotime($timetj);
  2408. /**
  2409. $sj = $this->input->post('sj',true);
  2410. if($sj)
  2411. {
  2412. $sj = $this->input->post('sj',true);
  2413. }
  2414. else
  2415. {
  2416. $sj = "fullorder";
  2417. }
  2418. **/
  2419. $sj = "fullorder";
  2420. $where = "1=1";
  2421. if ($warehouse) {
  2422. $where .= " and type = '$warehouse'";
  2423. }
  2424. if ($timetk && $timetj) {
  2425. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2426. }
  2427. if ($orderinfo) {
  2428. $where .= " and orderinfo = '$orderinfo'";
  2429. }
  2430. if ($number) {
  2431. $where .= " and number = '$number'";
  2432. }
  2433. if ($express) {
  2434. $where .= " and express = '$express'";
  2435. }
  2436. if ($waybill) {
  2437. $where .= " and waybill = '$waybill'";
  2438. }
  2439. if ($library) {
  2440. $where .= " and library = '$library'";
  2441. }
  2442. if ($print) {
  2443. $where .= " and print = '$print'";
  2444. }
  2445. if ($libraryconfirm) {
  2446. $where .= " and libraryconfirm = '$libraryconfirm'";
  2447. }
  2448. if ($state) {
  2449. $where .= " and state = '$state'";
  2450. }
  2451. if ($shop) {
  2452. $where .= " and shop = '$shop'";
  2453. }
  2454. if ($country) {
  2455. $where .= " and country = '$country'";
  2456. }
  2457. if ($sfxh != '') {
  2458. $where .= " and sfxh = '$sfxh'";
  2459. }
  2460. if ($so) {
  2461. $where .= " and shipremarks like '%$so%'";
  2462. }
  2463. if ($source) {
  2464. if ($source == '2d') {
  2465. $where .= " and source >= '2'";
  2466. } else {
  2467. $where .= " and source = '$source'";
  2468. }
  2469. }
  2470. if (isset($_SESSION['api'])) {
  2471. foreach ($user as $value) {
  2472. $fgshop .= " shop = " . $value . " or";
  2473. }
  2474. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2475. }
  2476. if ($orderurl) {
  2477. $url = $this->orderurl->read($orderurl);
  2478. $where .= " and link like '%" . $url['url'] . "%'";
  2479. }
  2480. //数据排序
  2481. $order_str = "librarytime desc";
  2482. if (empty($page)) {
  2483. $start = 0;
  2484. $perpage = 1;
  2485. } else {
  2486. $start = ($page - 1) * $perpage;
  2487. }
  2488. //取得信息列表
  2489. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2490. //格式化数据
  2491. foreach ($info_list as $key => $value) {
  2492. $shop = $this->shop->read($value['shop']);
  2493. $info_list[$key]['shop'] = $shop['shopname'];
  2494. $express = $this->express->read($value['express']);
  2495. $info_list[$key]['express'] = $express['servicename'];
  2496. $warehouse = $this->warehouse->read($value['type']);
  2497. $info_list[$key]['type'] = $warehouse['title'];
  2498. if ($value['librarytime'] == '0') {
  2499. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2500. } else {
  2501. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2502. }
  2503. }
  2504. $total = $this->$sj->find_count($where);
  2505. $pagenum = ceil($total / $perpage);
  2506. $over = $total - ($start + $perpage);
  2507. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2508. echo json_encode($rows);
  2509. exit;
  2510. }
  2511. $this->data['express'] = $this->express->find_all();
  2512. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2513. $this->data['wlshop'] = $wlshop;
  2514. $user = $this->user->get_api($_SESSION['api']);
  2515. $powerid = $this->power->read($user['power']);
  2516. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2517. $pid = '';
  2518. foreach ($powertext as $v) {
  2519. $pid .= " id = " . $v . " or";
  2520. }
  2521. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2522. $this->data['fullorderexcel'] = $fullorderexcel;
  2523. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2524. $this->data['orderurl'] = $orderurl;
  2525. $this->_Template('whlabel_outorder', $this->data);
  2526. }
  2527. //tt出库
  2528. public function _toutorder()
  2529. {
  2530. $fgshop = "";
  2531. $sid = "";
  2532. if (isset($_SESSION['api'])) {
  2533. $user = $this->user->get_api($_SESSION['api']);
  2534. $usp = $user;
  2535. $user = explode('|', trim($user['shop'], '|'));
  2536. foreach ($user as $value) {
  2537. $fgshop .= " shop = " . $value . " or";
  2538. $sid .= " id = " . $value . " or";
  2539. }
  2540. } else {
  2541. echo "请重新登录";
  2542. }
  2543. $post = $this->input->post(NULL, TRUE);
  2544. if (isset($post['page'])) {
  2545. $page = $this->input->post('page', true);
  2546. $perpage = $this->input->post('perpage', true);
  2547. $warehouse = $this->input->post('warehouse', true);
  2548. $xztime = $this->input->post('xztime', true);
  2549. $timetk = $this->input->post('timetkk', true);
  2550. $timetj = $this->input->post('timetjj', true);
  2551. $shop = $this->input->post('shop', true);
  2552. $source = $this->input->post('source', true);
  2553. $orderinfo = $this->input->post('orderinfo', true);
  2554. $number = $this->input->post('number', true);
  2555. $sfxh = $this->input->post('sfxh', true);
  2556. $express = $this->input->post('express', true);
  2557. $waybill = $this->input->post('waybill', true);
  2558. $library = $this->input->post('library', true);
  2559. $country = $this->input->post('country', true);
  2560. $so = $this->input->post('so', true);
  2561. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2562. $print = $this->input->post('print', true);
  2563. $state = $this->input->post('state', true);
  2564. $orderurl = $this->input->post('orderurl', true);
  2565. $timetk = strtotime($timetk);
  2566. $timetj = strtotime($timetj);
  2567. /**
  2568. $sj = $this->input->post('sj',true);
  2569. if($sj)
  2570. {
  2571. $sj = $this->input->post('sj',true);
  2572. }
  2573. else
  2574. {
  2575. $sj = "fullorder";
  2576. }
  2577. **/
  2578. $sj = "fullordertt";
  2579. $where = "1=1";
  2580. if ($warehouse) {
  2581. $where .= " and type = '$warehouse'";
  2582. }
  2583. if ($timetk && $timetj) {
  2584. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2585. }
  2586. if ($orderinfo) {
  2587. $where .= " and orderinfo = '$orderinfo'";
  2588. }
  2589. if ($number) {
  2590. $where .= " and number = '$number'";
  2591. }
  2592. if ($express) {
  2593. $where .= " and express = '$express'";
  2594. }
  2595. if ($waybill) {
  2596. $where .= " and waybill = '$waybill'";
  2597. }
  2598. if ($library) {
  2599. $where .= " and library = '$library'";
  2600. }
  2601. if ($print) {
  2602. $where .= " and print = '$print'";
  2603. }
  2604. if ($libraryconfirm) {
  2605. $where .= " and libraryconfirm = '$libraryconfirm'";
  2606. }
  2607. if ($state) {
  2608. $where .= " and state = '$state'";
  2609. }
  2610. if ($shop) {
  2611. $where .= " and shop = '$shop'";
  2612. }
  2613. if ($country) {
  2614. $where .= " and country = '$country'";
  2615. }
  2616. if ($sfxh != '') {
  2617. $where .= " and sfxh = '$sfxh'";
  2618. }
  2619. if ($so) {
  2620. $where .= " and shipremarks like '%$so%'";
  2621. }
  2622. if ($source) {
  2623. if ($source == '2d') {
  2624. $where .= " and source >= '2'";
  2625. } else {
  2626. $where .= " and source = '$source'";
  2627. }
  2628. }
  2629. if (isset($_SESSION['api'])) {
  2630. foreach ($user as $value) {
  2631. $fgshop .= " shop = " . $value . " or";
  2632. }
  2633. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2634. }
  2635. if ($orderurl) {
  2636. $url = $this->orderurl->read($orderurl);
  2637. $where .= " and link like '%" . $url['url'] . "%'";
  2638. }
  2639. //数据排序
  2640. $order_str = "librarytime desc";
  2641. if (empty($page)) {
  2642. $start = 0;
  2643. $perpage = 1;
  2644. } else {
  2645. $start = ($page - 1) * $perpage;
  2646. }
  2647. //取得信息列表
  2648. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2649. //格式化数据
  2650. foreach ($info_list as $key => $value) {
  2651. $shop = $this->shop->read($value['shop']);
  2652. $info_list[$key]['shop'] = $shop['shopname'];
  2653. $express = $this->express->read($value['express']);
  2654. $info_list[$key]['express'] = $express['servicename'];
  2655. $warehouse = $this->warehouse->read($value['type']);
  2656. $info_list[$key]['type'] = $warehouse['title'];
  2657. if ($value['librarytime'] == '0') {
  2658. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2659. } else {
  2660. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2661. }
  2662. }
  2663. $total = $this->$sj->find_count($where);
  2664. $pagenum = ceil($total / $perpage);
  2665. $over = $total - ($start + $perpage);
  2666. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2667. echo json_encode($rows);
  2668. exit;
  2669. }
  2670. $this->data['express'] = $this->express->find_all();
  2671. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2672. $this->data['wlshop'] = $wlshop;
  2673. $user = $this->user->get_api($_SESSION['api']);
  2674. $powerid = $this->power->read($user['power']);
  2675. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2676. $pid = '';
  2677. foreach ($powertext as $v) {
  2678. $pid .= " id = " . $v . " or";
  2679. }
  2680. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2681. $this->data['fullorderexcel'] = $fullorderexcel;
  2682. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2683. $this->data['orderurl'] = $orderurl;
  2684. $this->_Template('whlabel_toutorder', $this->data);
  2685. }
  2686. //tt出库
  2687. public function _aoutorder()
  2688. {
  2689. if (isset($_SESSION['api'])) {
  2690. $user = $this->user->get_api($_SESSION['api']);
  2691. $usp = $user;
  2692. $fgshop = "";
  2693. $sid = "";
  2694. $user = explode('|', trim($user['shop'], '|'));
  2695. foreach ($user as $value) {
  2696. $fgshop .= " shop = " . $value . " or";
  2697. $sid .= " id = " . $value . " or";
  2698. }
  2699. } else {
  2700. echo "请重新登录";
  2701. }
  2702. $post = $this->input->post(NULL, TRUE);
  2703. if (isset($post['page'])) {
  2704. $page = $this->input->post('page', true);
  2705. $perpage = $this->input->post('perpage', true);
  2706. $warehouse = $this->input->post('warehouse', true);
  2707. $xztime = $this->input->post('xztime', true);
  2708. $timetk = $this->input->post('timetkk', true);
  2709. $timetj = $this->input->post('timetjj', true);
  2710. $shop = $this->input->post('shop', true);
  2711. $source = $this->input->post('source', true);
  2712. $orderinfo = $this->input->post('orderinfo', true);
  2713. $number = $this->input->post('number', true);
  2714. $sfxh = $this->input->post('sfxh', true);
  2715. $express = $this->input->post('express', true);
  2716. $waybill = $this->input->post('waybill', true);
  2717. $library = $this->input->post('library', true);
  2718. $country = $this->input->post('country', true);
  2719. $so = $this->input->post('so', true);
  2720. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2721. $print = $this->input->post('print', true);
  2722. $state = $this->input->post('state', true);
  2723. $orderurl = $this->input->post('orderurl', true);
  2724. $timetk = strtotime($timetk);
  2725. $timetj = strtotime($timetj);
  2726. /**
  2727. $sj = $this->input->post('sj',true);
  2728. if($sj)
  2729. {
  2730. $sj = $this->input->post('sj',true);
  2731. }
  2732. else
  2733. {
  2734. $sj = "fullorder";
  2735. }
  2736. **/
  2737. $sj = "fullorderamz";
  2738. $where = "1=1";
  2739. if ($warehouse) {
  2740. $where .= " and type = '$warehouse'";
  2741. }
  2742. if ($timetk && $timetj) {
  2743. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2744. }
  2745. if ($orderinfo) {
  2746. $where .= " and orderinfo = '$orderinfo'";
  2747. }
  2748. if ($number) {
  2749. $where .= " and number = '$number'";
  2750. }
  2751. if ($express) {
  2752. $where .= " and express = '$express'";
  2753. }
  2754. if ($waybill) {
  2755. $where .= " and waybill = '$waybill'";
  2756. }
  2757. if ($library) {
  2758. $where .= " and library = '$library'";
  2759. }
  2760. if ($print) {
  2761. $where .= " and print = '$print'";
  2762. }
  2763. if ($libraryconfirm) {
  2764. $where .= " and libraryconfirm = '$libraryconfirm'";
  2765. }
  2766. if ($state) {
  2767. $where .= " and state = '$state'";
  2768. }
  2769. if ($shop) {
  2770. $where .= " and shop = '$shop'";
  2771. }
  2772. if ($country) {
  2773. $where .= " and country = '$country'";
  2774. }
  2775. if ($sfxh != '') {
  2776. $where .= " and sfxh = '$sfxh'";
  2777. }
  2778. if ($so) {
  2779. $where .= " and shipremarks like '%$so%'";
  2780. }
  2781. if ($source) {
  2782. if ($source == '2d') {
  2783. $where .= " and source >= '2'";
  2784. } else {
  2785. $where .= " and source = '$source'";
  2786. }
  2787. }
  2788. if (isset($_SESSION['api'])) {
  2789. foreach ($user as $value) {
  2790. $fgshop .= " shop = " . $value . " or";
  2791. }
  2792. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2793. }
  2794. if ($orderurl) {
  2795. $url = $this->orderurl->read($orderurl);
  2796. $where .= " and link like '%" . $url['url'] . "%'";
  2797. }
  2798. //数据排序
  2799. $order_str = "librarytime desc";
  2800. if (empty($page)) {
  2801. $start = 0;
  2802. $perpage = 1;
  2803. } else {
  2804. $start = ($page - 1) * $perpage;
  2805. }
  2806. //取得信息列表
  2807. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2808. //格式化数据
  2809. foreach ($info_list as $key => $value) {
  2810. $shop = $this->shop->read($value['shop']);
  2811. $info_list[$key]['shop'] = $shop['shopname'];
  2812. $express = $this->express->read($value['express']);
  2813. $info_list[$key]['express'] = $express['servicename'];
  2814. $warehouse = $this->warehouse->read($value['type']);
  2815. $info_list[$key]['type'] = $warehouse['title'];
  2816. if ($value['librarytime'] == '0') {
  2817. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2818. } else {
  2819. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2820. }
  2821. }
  2822. $total = $this->$sj->find_count($where);
  2823. $pagenum = ceil($total / $perpage);
  2824. $over = $total - ($start + $perpage);
  2825. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2826. echo json_encode($rows);
  2827. exit;
  2828. }
  2829. $this->data['express'] = $this->express->find_all();
  2830. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2831. $this->data['wlshop'] = $wlshop;
  2832. $user = $this->user->get_api($_SESSION['api']);
  2833. $powerid = $this->power->read($user['power']);
  2834. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2835. $pid = '';
  2836. foreach ($powertext as $v) {
  2837. $pid .= " id = " . $v . " or";
  2838. }
  2839. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2840. $this->data['fullorderexcel'] = $fullorderexcel;
  2841. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2842. $this->data['orderurl'] = $orderurl;
  2843. $this->_Template('whlabel_aoutorder', $this->data);
  2844. }
  2845. //速卖通出库订单
  2846. public function _soutorder()
  2847. {
  2848. if (isset($_SESSION['api'])) {
  2849. $user = $this->user->get_api($_SESSION['api']);
  2850. $usp = $user;
  2851. $fgshop = "";
  2852. $sid = "";
  2853. $user = explode('|', trim($user['shop'], '|'));
  2854. foreach ($user as $value) {
  2855. $sid .= " id = " . $value . " or";
  2856. }
  2857. }
  2858. $post = $this->input->post(NULL, TRUE);
  2859. if (isset($post['page'])) {
  2860. $page = $this->input->post('page', true);
  2861. $perpage = $this->input->post('perpage', true);
  2862. $warehouse = $this->input->post('warehouse', true);
  2863. $xztime = $this->input->post('xztime', true);
  2864. $timetk = $this->input->post('timetkk', true);
  2865. $timetj = $this->input->post('timetjj', true);
  2866. $shop = $this->input->post('shop', true);
  2867. $source = $this->input->post('source', true);
  2868. $orderinfo = $this->input->post('orderinfo', true);
  2869. $number = $this->input->post('number', true);
  2870. $express = $this->input->post('express', true);
  2871. $waybill = $this->input->post('waybill', true);
  2872. $library = $this->input->post('library', true);
  2873. $country = $this->input->post('country', true);
  2874. $sfxh = $this->input->post('sfxh', true);
  2875. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2876. $print = $this->input->post('print', true);
  2877. $state = $this->input->post('state', true);
  2878. $so = $this->input->post('so', true);
  2879. $timetk = strtotime($timetk);
  2880. $timetj = strtotime($timetj);
  2881. /**
  2882. $sj = $this->input->post('sj',true);
  2883. if($sj)
  2884. {
  2885. $sj = $this->input->post('sj',true);
  2886. }
  2887. else
  2888. {
  2889. $sj = "fullorder";
  2890. }
  2891. **/
  2892. $sj = "fullordersmt";
  2893. $where = "1=1";
  2894. if ($warehouse) {
  2895. $where .= " and type = '$warehouse'";
  2896. }
  2897. if ($timetk && $timetj) {
  2898. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2899. }
  2900. if ($orderinfo) {
  2901. $where .= " and orderinfo = '$orderinfo'";
  2902. }
  2903. if ($number) {
  2904. $where .= " and number = '$number'";
  2905. }
  2906. if ($express) {
  2907. $where .= " and express = '$express'";
  2908. }
  2909. if ($waybill) {
  2910. $where .= " and waybill = '$waybill'";
  2911. }
  2912. if ($library) {
  2913. $where .= " and library = '$library'";
  2914. }
  2915. if ($print) {
  2916. $where .= " and print = '$print'";
  2917. }
  2918. if ($libraryconfirm) {
  2919. $where .= " and libraryconfirm = '$libraryconfirm'";
  2920. }
  2921. if ($state) {
  2922. $where .= " and state = '$state'";
  2923. }
  2924. if ($shop) {
  2925. $where .= " and shop = '$shop'";
  2926. }
  2927. if ($sfxh != '') {
  2928. $where .= " and sfxh = '$sfxh'";
  2929. }
  2930. if ($so) {
  2931. $where .= " and shipremarks like '%$so%'";
  2932. }
  2933. if ($source) {
  2934. $where .= " and source = '$source'";
  2935. }
  2936. if ($country) {
  2937. $where .= " and country = '$country'";
  2938. } else {
  2939. if (isset($_SESSION['api'])) {
  2940. foreach ($user as $value) {
  2941. $fgshop .= " shop = " . $value . " or";
  2942. }
  2943. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2944. }
  2945. }
  2946. //数据排序
  2947. $order_str = "librarytime desc";
  2948. if (empty($page)) {
  2949. $start = 0;
  2950. $perpage = 1;
  2951. } else {
  2952. $start = ($page - 1) * $perpage;
  2953. }
  2954. //取得信息列表
  2955. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2956. //格式化数据
  2957. foreach ($info_list as $key => $value) {
  2958. $shop = $this->shop->read($value['shop']);
  2959. $info_list[$key]['shop'] = $shop['shopname'];
  2960. $express = $this->express->read($value['express']);
  2961. $info_list[$key]['express'] = $express['servicename'];
  2962. $warehouse = $this->warehouse->read($value['type']);
  2963. $info_list[$key]['type'] = $warehouse['title'];
  2964. if ($value['librarytime'] == '0') {
  2965. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2966. } else {
  2967. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2968. }
  2969. }
  2970. $total = $this->$sj->find_count($where);
  2971. $pagenum = ceil($total / $perpage);
  2972. $over = $total - ($start + $perpage);
  2973. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2974. echo json_encode($rows);
  2975. exit;
  2976. }
  2977. $this->data['express'] = $this->express->find_all();
  2978. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2979. $this->data['wlshop'] = $wlshop;
  2980. $user = $this->user->get_api($_SESSION['api']);
  2981. $powerid = $this->power->read($user['power']);
  2982. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2983. $pid = '';
  2984. foreach ($powertext as $v) {
  2985. $pid .= " id = " . $v . " or";
  2986. }
  2987. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2988. $this->data['fullorderexcel'] = $fullorderexcel;
  2989. $this->_Template('whlabel_soutorder', $this->data);
  2990. }
  2991. //订单退库
  2992. public function _retreat()
  2993. {
  2994. $post = $this->input->post(NULL, TRUE);
  2995. if (isset($post['page'])) {
  2996. $page = $this->input->post('page', true);
  2997. $perpage = $this->input->post('perpage', true);
  2998. $warehouse = $this->input->post('warehouse', true);
  2999. $timetk = $this->input->post('timetk', true);
  3000. $timetj = $this->input->post('timetj', true);
  3001. $shop = $this->input->post('shop', true);
  3002. $source = $this->input->post('source', true);
  3003. $state = $this->input->post('state', true);
  3004. $review = $this->input->post('review', true);
  3005. $state = $this->input->post('state', true);
  3006. $express = $this->input->post('express', true);
  3007. $orderinfo = $this->input->post('orderinfo', true);
  3008. $user = $this->input->post('user', true);
  3009. $name = $this->input->post('name', true);
  3010. $waybill = $this->input->post('waybill', true);
  3011. $timetk = strtotime($timetk);
  3012. $timetj = strtotime($timetj);
  3013. $where = "(state=206 or state=210) and mergeid = 0";
  3014. if ($warehouse) {
  3015. $where .= " and state = '$warehouse'";
  3016. }
  3017. if ($timetk && $timetj) {
  3018. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3019. }
  3020. if ($shop) {
  3021. $where .= " and shop = '$shop'";
  3022. }
  3023. if ($source) {
  3024. $where .= " and source = '$source'";
  3025. }
  3026. if ($state) {
  3027. $where .= " and state = '$state'";
  3028. }
  3029. if ($review) {
  3030. $where .= " and review = '$review'";
  3031. }
  3032. if ($state) {
  3033. $where .= " and state = '$state'";
  3034. }
  3035. if ($express) {
  3036. $where .= " and express = '$express'";
  3037. }
  3038. if ($orderinfo) {
  3039. $where .= " and orderinfo = '$orderinfo'";
  3040. }
  3041. if ($user) {
  3042. $where .= " and user = '$user'";
  3043. }
  3044. if ($name) {
  3045. $where .= " and name = '$name'";
  3046. }
  3047. if ($waybill) {
  3048. $where .= " and waybill = '$waybill'";
  3049. }
  3050. //数据排序
  3051. $order_str = "id desc";
  3052. if (empty($page)) {
  3053. $start = 0;
  3054. $perpage = 1;
  3055. } else {
  3056. $start = ($page - 1) * $perpage;
  3057. }
  3058. //取得信息列表
  3059. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3060. //格式化数据
  3061. foreach ($info_list as $key => $value) {
  3062. $shop = $this->shop->read($value['shop']);
  3063. $info_list[$key]['shop'] = $shop['shopname'];
  3064. $warehouse = $this->warehouse->read($value['warehouse']);
  3065. $info_list[$key]['warehouse'] = $warehouse['title'];
  3066. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3067. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3068. if ($value['waybill'] == 0) {
  3069. $info_list[$key]['waybill'] = "";
  3070. }
  3071. $express = $this->express->read($value['express']);
  3072. $info_list[$key]['express'] = $express['title'];
  3073. $typeclass = $this->typeclass->read($value['state']);
  3074. $info_list[$key]['state'] = $typeclass['title'];
  3075. }
  3076. $total = $this->fullorder->find_count($where);
  3077. $pagenum = ceil($total / $perpage);
  3078. $over = $total - ($start + $perpage);
  3079. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3080. echo json_encode($rows);
  3081. exit;
  3082. }
  3083. $this->data['express'] = $this->express->find_all();
  3084. $this->_Template('whlabel_retreat', $this->data);
  3085. }
  3086. //退库标签浏览
  3087. public function _retreatlk()
  3088. {
  3089. $post = $this->input->post(NULL, TRUE);
  3090. if (isset($post['page'])) {
  3091. $page = $this->input->post('page', true);
  3092. $perpage = $this->input->post('perpage', true);
  3093. $timetk = $this->input->post('timetk', true);
  3094. $timetj = $this->input->post('timetj', true);
  3095. $sku = $this->input->post('sku', true);
  3096. $warehouse = $this->input->post('warehouse', true);
  3097. $purchase = $this->input->post('purchase', true);
  3098. $orderinfo = $this->input->post('orderinfo', true);
  3099. $waybill = $this->input->post('waybill', true);
  3100. $category = $this->input->post('category', true);
  3101. $size = $this->input->post('size', true);
  3102. $grade = $this->input->post('grade', true);
  3103. $color = $this->input->post('color', true);
  3104. $lowe = $this->input->post('lowe', true);
  3105. $state = $this->input->post('state', true);
  3106. $timetk = strtotime($timetk);
  3107. $timetj = strtotime($timetj);
  3108. $where = "state=2";
  3109. if ($timetk && $timetj) {
  3110. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3111. }
  3112. if ($sku) {
  3113. $where .= " and sku = '$sku'";
  3114. }
  3115. if ($warehouse) {
  3116. $where .= " and warehouse = '$warehouse'";
  3117. }
  3118. if ($purchase) {
  3119. $where .= " and purchase = '$purchase'";
  3120. }
  3121. if ($orderinfo) {
  3122. $where .= " and orderinfo = '$orderinfo'";
  3123. }
  3124. if ($waybill) {
  3125. $where .= " and waybill = '$waybill'";
  3126. }
  3127. if ($category) {
  3128. $where .= " and features like '%-$category-%'";
  3129. }
  3130. if ($size) {
  3131. $where .= " and features like '%-$size-%'";
  3132. }
  3133. if ($grade) {
  3134. $where .= " and features like '%-$grade-%'";
  3135. }
  3136. if ($color) {
  3137. $where .= " and features like '%-$color-%'";
  3138. }
  3139. if ($lowe) {
  3140. $where .= " and features like '%-$lowe-%'";
  3141. }
  3142. //数据排序
  3143. $order_str = "time desc";
  3144. if (empty($page)) {
  3145. $start = 0;
  3146. $perpage = 1;
  3147. } else {
  3148. $start = ($page - 1) * $perpage;
  3149. }
  3150. //取得信息列表
  3151. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3152. foreach ($info_list as $key => $value) {
  3153. $warehouse = $this->warehouse->read($value['warehouse']);
  3154. $info_list[$key]['warehouse'] = $warehouse['title'];
  3155. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3156. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3157. $purchase = $this->purchase->read($value['purchase']);
  3158. $info_list[$key]['purchase'] = $purchase['title'];
  3159. if ($value['outk'] != 0) {
  3160. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3161. } else {
  3162. $info_list[$key]['outk'] = "";
  3163. }
  3164. if ($value['retreat'] != 0) {
  3165. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3166. } else {
  3167. $info_list[$key]['retreat'] = "";
  3168. }
  3169. if ($value['orderinfo'] == 0) {
  3170. $info_list[$key]['orderinfo'] = "";
  3171. }
  3172. if ($value['waybill'] == 0) {
  3173. $info_list[$key]['waybill'] = "";
  3174. }
  3175. }
  3176. $total = $this->whlabel->find_count($where);
  3177. $pagenum = ceil($total / $perpage);
  3178. $over = $total - ($start + $perpage);
  3179. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3180. echo json_encode($rows);
  3181. exit;
  3182. }
  3183. $this->_Template('whlabel_retreatlk', $this->data);
  3184. }
  3185. //更换标签及浏览
  3186. public function _change()
  3187. {
  3188. $post = $this->input->post(NULL, TRUE);
  3189. if (isset($post['page'])) {
  3190. $page = $this->input->post('page', true);
  3191. $perpage = $this->input->post('perpage', true);
  3192. $timetk = $this->input->post('timetk', true);
  3193. $timetj = $this->input->post('timetj', true);
  3194. $label = $this->input->post('label', true);
  3195. $oldlabel = $this->input->post('oldlabel', true);
  3196. $timetk = strtotime($timetk);
  3197. $timetj = strtotime($timetj);
  3198. $where = "state=10 ";
  3199. if ($timetk && $timetj) {
  3200. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3201. }
  3202. if ($label) {
  3203. $where .= " and label = '$label'";
  3204. }
  3205. if ($oldlabel) {
  3206. $where .= " and oldlabel = '$oldlabel'";
  3207. }
  3208. //数据排序
  3209. $order_str = "time asc";
  3210. if (empty($page)) {
  3211. $start = 0;
  3212. $perpage = 1;
  3213. } else {
  3214. $start = ($page - 1) * $perpage;
  3215. }
  3216. //取得信息列表
  3217. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3218. foreach ($info_list as $key => $value) {
  3219. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3220. }
  3221. $total = $this->whlabel->find_count($where);
  3222. $pagenum = ceil($total / $perpage);
  3223. $over = $total - ($start + $perpage);
  3224. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3225. echo json_encode($rows);
  3226. exit;
  3227. }
  3228. $this->_Template('whlabel_change', $this->data);
  3229. }
  3230. //产品标签
  3231. public function _cpbqdc()
  3232. {
  3233. if (isset($_GET['excel'])) {
  3234. $where = "1=1";
  3235. //数据排序
  3236. $order_str = "id desc";
  3237. if (empty($page)) {
  3238. $start = 0;
  3239. $perpage = 1;
  3240. } else {
  3241. $start = ($page - 1) * $perpage;
  3242. }
  3243. $warehouse = $this->input->get('warehouse', true);
  3244. $state = $this->input->get('state', true);
  3245. $timetk = $this->input->get('timetkk', true);
  3246. $timetj = $this->input->get('timetjj', true);
  3247. $timetk = strtotime($timetk);
  3248. $timetj = strtotime($timetj);
  3249. if ($warehouse) {
  3250. $where .= " and warehouse = '$warehouse'";
  3251. }
  3252. if ($state || $state == 0) {
  3253. $where .= " and state = '$state'";
  3254. }
  3255. if ($timetk && $timetj) {
  3256. $where .= " and time > '$timetk' and time < '$timetj'";
  3257. }
  3258. //取得信息列表
  3259. $info_list = $this->whlabel->find_all($where, '*');
  3260. $rows = array();
  3261. $list = array();
  3262. foreach ($info_list as $key => $value) {
  3263. $rows[$value['time']] = $value; //所有数据sku
  3264. }
  3265. foreach ($rows as $value) {
  3266. $warehouse = $this->warehouse->read($value['warehouse']);
  3267. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3268. $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);
  3269. }
  3270. $title = "产品标签统计表";
  3271. $titlename = "<table border=1>
  3272. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3273. <tr align='center'>
  3274. <td>仓库</td>
  3275. <td>SKU</td>
  3276. <td>产品</td>
  3277. <td>入库时间</td>
  3278. <td>操作时间</td>
  3279. <td>备注</td>
  3280. <td>数量</td>
  3281. </tr>
  3282. </table>";
  3283. $filename = $title . ".xls";
  3284. $tail = "";
  3285. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3286. }
  3287. }
  3288. //进销存导出
  3289. public function _exceljxc()
  3290. {
  3291. $classid = $this->classid->sku();
  3292. $pm = $classid;
  3293. $typeclass = array();
  3294. $tc = $this->typeclass->find_all();
  3295. foreach ($tc as $v) {
  3296. $typeclass[$v['id']] = $v;
  3297. }
  3298. $prc = array();
  3299. $purchase = $this->purchase->find_all();
  3300. foreach ($purchase as $k => $v) {
  3301. $prc[$v['id']] = $v['title'];
  3302. }
  3303. if (isset($_GET['excel'])) {
  3304. $where = "sku != 'Preset'";
  3305. //数据排序
  3306. $order_str = "id desc";
  3307. if (empty($page)) {
  3308. $start = 0;
  3309. $perpage = 1;
  3310. } else {
  3311. $start = ($page - 1) * $perpage;
  3312. }
  3313. $category = $this->input->get('category', true);
  3314. $warehouse = $this->input->get('warehouse', true);
  3315. $excelid = $this->input->get('sid', true);
  3316. if ($category) {
  3317. $where .= " and features like '%-$category-%'";
  3318. }
  3319. if ($warehouse) {
  3320. $where .= " and warehouse = '$warehouse'";
  3321. }
  3322. $xzid = '';
  3323. if ($excelid) {
  3324. $excelid = explode(',', trim($excelid, ','));
  3325. foreach ($excelid as $key => $value) {
  3326. $xzid .= " id = " . $value . " or";
  3327. }
  3328. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3329. }
  3330. //取得信息列表
  3331. /**
  3332. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3333. $rows = array();$list = array();
  3334. foreach ($info_list as $key=>$value)
  3335. {
  3336. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3337. }
  3338. **/
  3339. $wt = array();
  3340. $whlabel_type = $this->whlabel_type->find_all();
  3341. foreach ($whlabel_type as $v) {
  3342. $wt[$v['id']] = $v['title'];
  3343. }
  3344. $wh = array();
  3345. $w = $this->warehouse->find_all('1=1', 'id,title');
  3346. foreach ($w as $v) {
  3347. $wh[$v['id']] = $v['title'];
  3348. }
  3349. $list = array();
  3350. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3351. foreach ($rows as $key => $value) {
  3352. if (isset($wt[$value['type']])) {
  3353. $rows[$key]['type'] = $wt[$value['type']];
  3354. } else {
  3355. $rows[$key]['type'] = '未设置';
  3356. }
  3357. $bm = '03';
  3358. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3359. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3360. $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');
  3361. $details = array();
  3362. $cpid = array();
  3363. $cpbz = array();
  3364. $c = 0;
  3365. $g = 0;
  3366. $x = 0;
  3367. $t = 0;
  3368. $s = 0;
  3369. $q = 0;
  3370. foreach ($sd as $k => $v) {
  3371. if ($v['state'] == 0) {
  3372. $c++;
  3373. if ($v['cpid'] != 0) {
  3374. $cpid[$v['cpid']] = $v['cpid'];
  3375. }
  3376. if ($v['cpbz'] != '') {
  3377. $cpbz[$v['cpbz']] = $v['cpbz'];
  3378. }
  3379. }
  3380. if ($v['state'] != 9) {
  3381. $g++;
  3382. }
  3383. if ($v['state'] == 1) {
  3384. $x++;
  3385. }
  3386. if ($v['state'] == 2) {
  3387. $t++;
  3388. }
  3389. if ($v['state'] == 8) {
  3390. $s++;
  3391. }
  3392. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3393. $q++;
  3394. }
  3395. $details[$v['details']] = $v['details'];
  3396. }
  3397. $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'] . '"');
  3398. $rows[$key]['details'] = implode("、", $details);
  3399. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3400. $number = $value['number'];
  3401. $ftime = time() - 15 * 24 * 3600;
  3402. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3403. $rows[$key]['number'] = $g;
  3404. $rows[$key]['c'] = $c;
  3405. $rows[$key]['x'] = $x;
  3406. $rows[$key]['t'] = $t;
  3407. $rows[$key]['s'] = $s;
  3408. $rows[$key]['q'] = $q;
  3409. $rows[$key]['z'] = $z;
  3410. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3411. $features = explode('-', trim($features, '-'));
  3412. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3413. // $pm = $classid;
  3414. // $jm = $classid;
  3415. // foreach($features as $k=>$v)
  3416. // {
  3417. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3418. // {
  3419. // if($typeclass[$v]['bm'] != '')
  3420. // {
  3421. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3422. // }
  3423. // }
  3424. // if($v != 0)
  3425. // {
  3426. // if(!isset($typeclass[$v]))
  3427. // {
  3428. // continue;
  3429. // }
  3430. // if(isset($pm[$typeclass[$v]['classid']]))
  3431. // {
  3432. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3433. // {
  3434. // $tz = explode('|',$typeclass[$v]['zh']);
  3435. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3436. // }
  3437. // else
  3438. // {
  3439. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3440. // }
  3441. // }
  3442. // if(isset($jm[$typeclass[$v]['classid']]))
  3443. // {
  3444. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3445. // }
  3446. // }
  3447. // }
  3448. // $jm = array_filter($jm);
  3449. // $rows[$key]['bs'] = implode("-",$jm);
  3450. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3451. // $zh = implode(" ",$pm);
  3452. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3453. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3454. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3455. // $rows[$key]['features'] = $zh;
  3456. }
  3457. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3458. $final_list = [];
  3459. foreach ($list as $k => $v) {
  3460. if (empty($v['sku'])) {
  3461. continue;
  3462. }
  3463. $final_list[] = [
  3464. "warehouse" => $v["warehouse"],
  3465. "purchase" => $v["purchase"],
  3466. "details" => $v["details"],
  3467. "cpid" => $v["cpid"],
  3468. "dbcontent" => $v["dbcontent"],
  3469. "sku" => $v["sku"],
  3470. "cs" => $v["bm"],
  3471. "bs" => $v["jm"],
  3472. "title" => $v["title"],
  3473. "features" => $v["pm"],
  3474. "cpbz" => $v["cpbz"],
  3475. "sm" => $v["sm"],
  3476. "type" => $v["type"],
  3477. "number" => $v["number"],
  3478. "c" => $v["c"],
  3479. "x" => $v["x"],
  3480. "t" => $v["t"],
  3481. "s" => $v["s"],
  3482. "q" => $v["q"],
  3483. "z" => $v["z"],
  3484. "weight" => $v['weight'],
  3485. ];
  3486. }
  3487. $title = "总进销存统计表";
  3488. $titlename = "<table border=1>
  3489. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3490. <tr align='center'>
  3491. <td>仓库</td>
  3492. <td>供应商</td>
  3493. <td>位置</td>
  3494. <td>库存编码</td>
  3495. <td>类目</td>
  3496. <td>SKU</td>
  3497. <td>用友编码</td>
  3498. <td>用友料号</td>
  3499. <td>商品名称</td>
  3500. <td>商品中文</td>
  3501. <td>产品备注</td>
  3502. <td>说明</td>
  3503. <td>类型</td>
  3504. <td>入库总量</td>
  3505. <td>库存数量</td>
  3506. <td>销售数量</td>
  3507. <td>退货数量</td>
  3508. <td>删除数量</td>
  3509. <td>其它操作</td>
  3510. <td>占单数量</td>
  3511. <td>重量(g)</td>
  3512. </tr>
  3513. </table>";
  3514. $filename = $title . ".xls";
  3515. $tail = "";
  3516. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3517. }
  3518. }
  3519. //入库导出
  3520. public function _excelr()
  3521. {
  3522. if (isset($_GET['excel'])) {
  3523. $category = $this->input->get('category', true);
  3524. $size = $this->input->get('size', true);
  3525. $grade = $this->input->get('grade', true);
  3526. $color = $this->input->get('color', true);
  3527. $lowe = $this->input->get('lowe', true);
  3528. $sku = $this->input->get('sku', true);
  3529. $warehouse = $this->input->get('warehouse', true);
  3530. $purchase = $this->input->get('purchase', true);
  3531. $ktime = $this->input->get('ktime', true);
  3532. $jtime = $this->input->get('jtime', true);
  3533. $ktime = strtotime($ktime);
  3534. $jtime = strtotime($jtime);
  3535. $where = "1=1";
  3536. $gj = "";
  3537. $ck = "";
  3538. if ($category) {
  3539. $where .= " and features like '%-$category-%'";
  3540. }
  3541. if ($size) {
  3542. $where .= " and features like '%-$size-%'";
  3543. }
  3544. if ($grade) {
  3545. $where .= " and features like '%-$grade-%'";
  3546. }
  3547. if ($color) {
  3548. $where .= " and features like '%-$color-%'";
  3549. }
  3550. if ($lowe) {
  3551. $where .= " and features like '%-$lowe-%'";
  3552. }
  3553. if ($warehouse) {
  3554. $where .= " and warehouse = '$warehouse'";
  3555. }
  3556. if ($purchase) {
  3557. $where .= " and purchase = '$purchase'";
  3558. }
  3559. if ($sku) {
  3560. $where .= " and sku = '$sku'";
  3561. }
  3562. if ($ktime && $jtime) {
  3563. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3564. }
  3565. //数据排序
  3566. $order_str = "id desc";
  3567. if (empty($page)) {
  3568. $start = 0;
  3569. $perpage = 1;
  3570. } else {
  3571. $start = ($page - 1) * $perpage;
  3572. }
  3573. $list = array();
  3574. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3575. foreach ($rows as $value) {
  3576. $ck = $this->warehouse->read($value['warehouse']);
  3577. $warehouse = $ck['title'];
  3578. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3579. $retreatwarehouse = $tkck['title'];
  3580. $gy = $this->purchase->read($value['purchase']);
  3581. $purchase = $gy['title'];
  3582. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3583. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3584. }
  3585. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3586. $titlename = "<table border=1>
  3587. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3588. <tr align='center'>
  3589. <td>仓库</td>
  3590. <td>SKU</td>
  3591. <td>产品</td>
  3592. <td>时间</td>
  3593. <td>数量</td>
  3594. </tr>
  3595. </table>";
  3596. $filename = $title . ".xls";
  3597. $tail = "";
  3598. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3599. }
  3600. }
  3601. //出库、退库导出
  3602. public function _excelct()
  3603. {
  3604. $classid = $this->classid->sku();
  3605. $pm = $classid;
  3606. $typeclass = array();
  3607. $tc = $this->typeclass->find_all();
  3608. foreach ($tc as $v) {
  3609. $typeclass[$v['id']] = $v;
  3610. }
  3611. $prc = array();
  3612. $purchase = $this->purchase->find_all();
  3613. foreach ($purchase as $k => $v) {
  3614. $prc[$v['id']] = $v['title'];
  3615. }
  3616. if (isset($_GET['excel'])) {
  3617. $wh = array();
  3618. $w = $this->warehouse->find_all('1=1', 'id,title');
  3619. foreach ($w as $v) {
  3620. $wh[$v['id']] = $v['title'];
  3621. }
  3622. $type = $this->input->get('excel', true);
  3623. $category = $this->input->get('category', true);
  3624. $size = $this->input->get('size', true);
  3625. $grade = $this->input->get('grade', true);
  3626. $color = $this->input->get('color', true);
  3627. $lowe = $this->input->get('lowe', true);
  3628. $sku = $this->input->get('sku', true);
  3629. $warehouse = $this->input->get('warehouse', true);
  3630. $lacetype = $this->input->get('lacetype', true);
  3631. $lacecolor = $this->input->get('lacecolor', true);
  3632. $density = $this->input->get('density', true);
  3633. $haircap = $this->input->get('haircap', true);
  3634. $purchase = $this->input->get('purchase', true);
  3635. $title = $this->input->get('title', true);
  3636. $state = $this->input->get('state', true);
  3637. $sid = $this->input->get('sid', true);
  3638. $ktime = $this->input->get('ktime', true);
  3639. $jtime = $this->input->get('jtime', true);
  3640. $ktime = strtotime($ktime);
  3641. $jtime = strtotime($jtime);
  3642. $where = "1=1";
  3643. $gj = "";
  3644. $ck = "";
  3645. if ($category) {
  3646. $where .= " and features like '%-$category-%'";
  3647. }
  3648. if ($size) {
  3649. $where .= " and features like '%-$size-%'";
  3650. }
  3651. if ($grade) {
  3652. $where .= " and features like '%-$grade-%'";
  3653. }
  3654. if ($color) {
  3655. $where .= " and features like '%-$color-%'";
  3656. }
  3657. if ($lowe) {
  3658. $where .= " and features like '%-$lowe-%'";
  3659. }
  3660. if ($warehouse) {
  3661. $where .= " and warehouse = '$warehouse'";
  3662. }
  3663. if ($purchase) {
  3664. $where .= " and purchase = '$purchase'";
  3665. }
  3666. if ($state) {
  3667. $where .= " and state = '$state'";
  3668. }
  3669. if ($lacetype) {
  3670. $where .= " and features like '%-$lacetype-%'";
  3671. }
  3672. if ($lacecolor) {
  3673. $where .= " and features like '%-$lacecolor-%'";
  3674. }
  3675. if ($density) {
  3676. $where .= " and features like '%-$density-%'";
  3677. }
  3678. if ($haircap) {
  3679. $where .= " and features like '%-$haircap-%'";
  3680. }
  3681. if ($title) {
  3682. $title = trim($title, ' ');
  3683. $title = trim($title, ' ');
  3684. $where .= " and title like '%$title%'";
  3685. }
  3686. if ($sku) {
  3687. $sku = trim($sku, ' ');
  3688. $sku = trim($sku, ' ');
  3689. $where .= " and sku like '%$sku%'";
  3690. }
  3691. if ($ktime && $jtime) {
  3692. if ($type == 1) {
  3693. $tl = '出库';
  3694. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3695. } else if ($type == 2) {
  3696. $tl = '退库';
  3697. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3698. } else if ($type == 3) {
  3699. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3700. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3701. } else if ($type == 4) {
  3702. $tl = '出库+零售';
  3703. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3704. } else if ($type == 5) {
  3705. $tl = '零售';
  3706. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3707. }
  3708. }
  3709. $sidwhere = '';
  3710. if ($sid) {
  3711. $sd = "";
  3712. $s = explode(',', trim($sid, ','));
  3713. foreach ($s as $value) {
  3714. $sd .= " id = " . $value . " or";
  3715. }
  3716. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3717. }
  3718. //数据排序
  3719. $order_str = "time desc";
  3720. if (empty($page)) {
  3721. $start = 0;
  3722. $perpage = 1;
  3723. } else {
  3724. $start = ($page - 1) * $perpage;
  3725. }
  3726. //取得信息列表
  3727. if ($type != 3 && $type != 5) {
  3728. if ($type == 1 || $type == 4) {
  3729. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3730. foreach ($info_list as $key => $value) {
  3731. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3732. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3733. $warehouse = $this->warehouse->read($value['warehouse']);
  3734. $info_list[$key]['warehouse'] = $warehouse['title'];
  3735. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3736. $features = explode('-', trim($features, '-'));
  3737. $pm = $classid;
  3738. foreach ($features as $k => $v) {
  3739. if ($v != 0) {
  3740. if (!isset($typeclass[$v])) {
  3741. continue;
  3742. }
  3743. if (isset($pm[$typeclass[$v]['classid']])) {
  3744. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3745. $tz = explode('|', $typeclass[$v]['zh']);
  3746. $pm[$typeclass[$v]['classid']] = $tz[0];
  3747. } else {
  3748. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3749. }
  3750. }
  3751. }
  3752. }
  3753. $zh = implode(" ", $pm);
  3754. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3755. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3756. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3757. $info_list[$key]['features'] = $zh;
  3758. }
  3759. $final_list = [];
  3760. foreach($info_list as $k=>$v){
  3761. $number = "";
  3762. if(!empty($v['orderinfo'])){
  3763. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3764. if(!empty($tmp_info['number'])){
  3765. $number = $tmp_info['number'];
  3766. }
  3767. }
  3768. $final_list[] = [
  3769. 'warehouse'=>$v['warehouse'],
  3770. 'purchase'=>$v['purchase'],
  3771. 'sku'=>$v['sku'],
  3772. 'title'=>$v['title'],
  3773. 'features'=>$v['features'],
  3774. 'label'=>$v['label'],
  3775. 'orderinfo'=>$v['orderinfo'],
  3776. 'number'=>$number,
  3777. 'waybill'=>$v['waybill'],
  3778. 'outk'=>$v['outk'],
  3779. ];
  3780. }
  3781. } else {
  3782. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3783. foreach ($info_list as $key => $value) {
  3784. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3785. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3786. $warehouse = $this->warehouse->read($value['warehouse']);
  3787. $info_list[$key]['warehouse'] = $warehouse['title'];
  3788. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3789. $features = explode('-', trim($features, '-'));
  3790. $pm = $classid;
  3791. foreach ($features as $k => $v) {
  3792. if ($v != 0) {
  3793. if (!isset($typeclass[$v])) {
  3794. continue;
  3795. }
  3796. if (isset($pm[$typeclass[$v]['classid']])) {
  3797. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3798. $tz = explode('|', $typeclass[$v]['zh']);
  3799. $pm[$typeclass[$v]['classid']] = $tz[0];
  3800. } else {
  3801. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3802. }
  3803. }
  3804. }
  3805. }
  3806. $zh = implode(" ", $pm);
  3807. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3808. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3809. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3810. $info_list[$key]['features'] = $zh;
  3811. }
  3812. $final_list = [];
  3813. foreach($info_list as $k=>$v){
  3814. $number = "";
  3815. if(!empty($v['orderinfo'])){
  3816. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3817. if(!empty($tmp_info['number'])){
  3818. $number = $tmp_info['number'];
  3819. }
  3820. }
  3821. $final_list[] = [
  3822. 'warehouse'=>$v['warehouse'],
  3823. 'purchase'=>$v['purchase'],
  3824. 'sku'=>$v['sku'],
  3825. 'title'=>$v['title'],
  3826. 'features'=>$v['features'],
  3827. 'label'=>$v['label'],
  3828. 'orderinfo'=>$v['orderinfo'],
  3829. 'number'=>$number,
  3830. 'waybill'=>$v['waybill'],
  3831. 'retreat'=>$v['retreat'],
  3832. ];
  3833. }
  3834. }
  3835. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3836. $titlename = "<table border=1>
  3837. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3838. <tr align='center'>
  3839. <td>仓库</td>
  3840. <td>供应商</td>
  3841. <td>SKU</td>
  3842. <td>商品名称</td>
  3843. <td>商品中文</td>
  3844. <td>标签</td>
  3845. <td>订单号</td>
  3846. <td>订单编码</td>
  3847. <td>运单号</td>
  3848. <td>" . $tl . "时间(中国时间)</td>
  3849. </tr>
  3850. </table>";
  3851. $filename = $title . ".xls";
  3852. $tail = "";
  3853. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3854. } else if ($type == 5) {
  3855. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3856. foreach ($info_list as $key => $value) {
  3857. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3858. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3859. $warehouse = $this->warehouse->read($value['warehouse']);
  3860. $info_list[$key]['warehouse'] = $warehouse['title'];
  3861. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3862. $features = explode('-', trim($features, '-'));
  3863. $pm = $classid;
  3864. foreach ($features as $k => $v) {
  3865. if ($v != 0) {
  3866. if (!isset($typeclass[$v])) {
  3867. continue;
  3868. }
  3869. if (isset($pm[$typeclass[$v]['classid']])) {
  3870. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3871. $tz = explode('|', $typeclass[$v]['zh']);
  3872. $pm[$typeclass[$v]['classid']] = $tz[0];
  3873. } else {
  3874. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3875. }
  3876. }
  3877. }
  3878. }
  3879. $zh = implode(" ", $pm);
  3880. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3881. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3882. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3883. $info_list[$key]['features'] = $zh;
  3884. }
  3885. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3886. $titlename = "<table border=1>
  3887. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3888. <tr align='center'>
  3889. <td>仓库</td>
  3890. <td>供应商</td>
  3891. <td>SKU</td>
  3892. <td>商品名称</td>
  3893. <td>商品中文</td>
  3894. <td>标签</td>
  3895. <td>" . $tl . "时间(中国时间)</td>
  3896. </tr>
  3897. </table>";
  3898. $filename = $title . ".xls";
  3899. $tail = "";
  3900. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3901. } else {
  3902. /**
  3903. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  3904. $rows = array();$list = array();
  3905. foreach ($info_list as $key=>$value)
  3906. {
  3907. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  3908. }
  3909. **/
  3910. $wh = array();
  3911. $w = $this->warehouse->find_all('1=1', 'id,title');
  3912. foreach ($w as $v) {
  3913. $wh[$v['id']] = $v['title'];
  3914. }
  3915. $wt = array();
  3916. $whlabel_type = $this->whlabel_type->find_all();
  3917. foreach ($whlabel_type as $v) {
  3918. $wt[$v['id']] = $v['title'];
  3919. }
  3920. $classid = $this->classid->sku();
  3921. $list = array();
  3922. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  3923. foreach ($rows as $key => $value) {
  3924. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3925. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3926. $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');
  3927. $details = array();
  3928. $cpid = array();
  3929. $cpbz = array();
  3930. $c = 0;
  3931. $g = 0;
  3932. $x = 0;
  3933. $t = 0;
  3934. $s = 0;
  3935. $q = 0;
  3936. foreach ($sd as $k => $v) {
  3937. if ($v['state'] == 0) {
  3938. $c++;
  3939. }
  3940. if ($v['state'] != 9) {
  3941. $g++;
  3942. }
  3943. if ($v['outk'] > 1) {
  3944. $x++;
  3945. }
  3946. if ($v['retreat'] > 0) {
  3947. $t++;
  3948. }
  3949. if ($v['state'] == 8) {
  3950. $s++;
  3951. }
  3952. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3953. $q++;
  3954. }
  3955. $details[$v['details']] = $v['details'];
  3956. if ($v['cpid'] != 0) {
  3957. $cpid[$v['cpid']] = $v['cpid'];
  3958. }
  3959. if ($v['cpbz'] != '') {
  3960. $cpbz[$v['cpbz']] = $v['cpbz'];
  3961. }
  3962. }
  3963. if (isset($wt[$value['type']])) {
  3964. $rows[$key]['type'] = $wt[$value['type']];
  3965. } else {
  3966. $rows[$key]['type'] = '未设置';
  3967. }
  3968. $rows[$key]['details'] = implode("、", $details);
  3969. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3970. $ftime = time() - 15 * 24 * 3600;
  3971. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3972. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  3973. $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);
  3974. $rows[$key]['c'] = $c;
  3975. $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);
  3976. $rows[$key]['t'] = $t;
  3977. $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'] . '"');
  3978. $rows[$key]['z'] = $z;
  3979. // $jm = $classid;
  3980. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3981. $features = explode('-', trim($features, '-'));
  3982. // $pm = $classid;
  3983. // foreach ($features as $k => $v) {
  3984. // if ($v != 0) {
  3985. // if (!isset($typeclass[$v])) {
  3986. // continue;
  3987. // }
  3988. // if (isset($pm[$typeclass[$v]['classid']])) {
  3989. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3990. // $tz = explode('|', $typeclass[$v]['zh']);
  3991. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3992. // } else {
  3993. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3994. // }
  3995. // if (isset($jm[$typeclass[$v]['classid']])) {
  3996. // if ($typeclass[$v]['jm']) {
  3997. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3998. // }
  3999. // }
  4000. // }
  4001. // }
  4002. // }
  4003. // $zh = implode(" ", $pm);
  4004. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4005. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4006. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4007. // $rows[$key]['features'] = $zh;
  4008. // $jm = array_filter($jm); //去除空值
  4009. // $jm = implode("-", $jm);
  4010. // $rows[$key]['jm'] = $jm;
  4011. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4012. }
  4013. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4014. // echo "<pre>";
  4015. // print_r($tmp_list);
  4016. // die;
  4017. $final_list =[];
  4018. foreach($tmp_list as $k=>$v){
  4019. $final_list[] = [
  4020. "warehouse"=>$v['warehouse'],
  4021. "purchase"=>$v['purchase'],
  4022. "details"=>$v['details'],
  4023. "cpid"=>$v['cpid'],
  4024. "sku"=>$v['sku'],
  4025. "title"=>$v['title'],
  4026. "features"=>$v['pm'],
  4027. "cpbz"=>$v['cpbz'],
  4028. "sm"=>$v['sm'],
  4029. "type"=>$v['type'],
  4030. "g"=>$v["g"],
  4031. "c"=>$v["c"],
  4032. "x"=>$v["x"],
  4033. "t"=>$v["t"],
  4034. "z"=>$v["z"],
  4035. "jm"=>$v["jm"],
  4036. "weight"=>$v["weight"],
  4037. "asd"=>$v["asd"],
  4038. ];
  4039. }
  4040. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4041. $titlename = "<table border=1>
  4042. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4043. <tr align='center'>
  4044. <td>仓库</td>
  4045. <td>供应商</td>
  4046. <td>位置</td>
  4047. <td>库存编码</td>
  4048. <td>SKU</td>
  4049. <td>商品名称</td>
  4050. <td>商品中文</td>
  4051. <td>产品备注</td>
  4052. <td>说明</td>
  4053. <td>类型</td>
  4054. <td>入库总量</td>
  4055. <td>库存数量</td>
  4056. <td>销售数量</td>
  4057. <td>退货数量</td>
  4058. <td>占单数量</td>
  4059. <td>料号</td>
  4060. <td>重量</td>
  4061. <td>类目</td>
  4062. </tr>
  4063. </table>";
  4064. $filename = $title . ".xls";
  4065. $tail = "";
  4066. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4067. }
  4068. }
  4069. }
  4070. //出库+入库数据整合
  4071. public function _excelcr()
  4072. {
  4073. if (isset($_GET['excel'])) {
  4074. $type = $this->input->get('excel', true);
  4075. $category = $this->input->get('category', true);
  4076. $size = $this->input->get('size', true);
  4077. $grade = $this->input->get('grade', true);
  4078. $color = $this->input->get('color', true);
  4079. $lowe = $this->input->get('lowe', true);
  4080. $sku = $this->input->get('sku', true);
  4081. $warehouse = $this->input->get('warehouse', true);
  4082. $purchase = $this->input->get('purchase', true);
  4083. $state = $this->input->get('state', true);
  4084. $sid = $this->input->get('sid', true);
  4085. $ktime = $this->input->get('ktime', true);
  4086. $jtime = $this->input->get('jtime', true);
  4087. $ktime = strtotime($ktime);
  4088. $jtime = strtotime($jtime);
  4089. $where = "1=1";
  4090. $gj = "";
  4091. $ck = "";
  4092. if ($category) {
  4093. $where .= " and features like '%-$category-%'";
  4094. }
  4095. if ($size) {
  4096. $where .= " and features like '%-$size-%'";
  4097. }
  4098. if ($grade) {
  4099. $where .= " and features like '%-$grade-%'";
  4100. }
  4101. if ($color) {
  4102. $where .= " and features like '%-$color-%'";
  4103. }
  4104. if ($lowe) {
  4105. $where .= " and features like '%-$lowe-%'";
  4106. }
  4107. if ($warehouse) {
  4108. $where .= " and warehouse = '$warehouse'";
  4109. }
  4110. if ($purchase) {
  4111. $where .= " and purchase = '$purchase'";
  4112. }
  4113. if ($state) {
  4114. $where .= " and state = '$state'";
  4115. }
  4116. if ($sku) {
  4117. $where .= " and sku like '%$sku%'";
  4118. }
  4119. if ($ktime && $jtime) {
  4120. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4121. }
  4122. $sidwhere = '';
  4123. if ($sid) {
  4124. $sd = "";
  4125. $s = explode(',', trim($sid, ','));
  4126. foreach ($s as $value) {
  4127. $sd .= " id = " . $value . " or";
  4128. }
  4129. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4130. }
  4131. //取得信息列表
  4132. $timeread = $ktime;
  4133. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4134. $timelist = array();
  4135. for ($i = 0; $i < $timenum; $i++) {
  4136. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4137. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4138. }
  4139. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4140. //echo "<pre>";
  4141. //print_r($info_list);
  4142. //exit();
  4143. $rows = array();
  4144. $list = array();
  4145. foreach ($info_list as $key => $value) {
  4146. $thistime = $timelist;
  4147. if (isset($rows[strtolower($value['sku'])])) {
  4148. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4149. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4150. }
  4151. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4152. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4153. }
  4154. } else {
  4155. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4156. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4157. }
  4158. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4159. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4160. }
  4161. $rows[strtolower($value['sku'])] = $thistime;
  4162. }
  4163. }
  4164. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4165. <head>
  4166. <!--[if gte mso 9]><xml>
  4167. <x:ExcelWorkbook>
  4168. <x:ExcelWorksheets>
  4169. <x:ExcelWorksheet>
  4170. <x:Name>EXCEL</x:Name>
  4171. <x:WorksheetOptions>
  4172. <x:Print>
  4173. <x:ValidPrinterInfo />
  4174. </x:Print>
  4175. </x:WorksheetOptions>
  4176. </x:ExcelWorksheet>
  4177. </x:ExcelWorksheets>
  4178. </x:ExcelWorkbook>
  4179. </xml>
  4180. <![endif]-->
  4181. </head><body>";
  4182. $str .= "<table border=1><tr><td>SKU</td>";
  4183. foreach ($timelist as $k => $v) {
  4184. $str .= "<td>" . $k . "出库</td>";
  4185. $str .= "<td>" . $k . "入库</td>";
  4186. }
  4187. $str .= "</tr></table>";
  4188. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4189. foreach ($rows as $key => $val) {
  4190. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4191. foreach ($val as $k => $v) {
  4192. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4193. if ($val[$k]['r'] > 0) {
  4194. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4195. } else {
  4196. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4197. }
  4198. }
  4199. $str .= "</tr>";
  4200. }
  4201. $str .= "</table>";
  4202. $str .= "</body></html>";
  4203. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4204. header("Content-type: application/octet-stream");
  4205. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4206. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4207. header("Pragma: no-cache");
  4208. header("Expires: 0");
  4209. exit($str);
  4210. }
  4211. }
  4212. //数量调整模板导出
  4213. public function _presetout()
  4214. {
  4215. if (isset($_GET['excel'])) {
  4216. $where = "sku != 'Preset' and purchase != 0";
  4217. //数据排序
  4218. $order_str = "id desc";
  4219. if (empty($page)) {
  4220. $start = 0;
  4221. $perpage = 1;
  4222. } else {
  4223. $start = ($page - 1) * $perpage;
  4224. }
  4225. //取得信息列表
  4226. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4227. $rows = array();
  4228. $list = array();
  4229. foreach ($info_list as $value) {
  4230. $warehouse = $this->warehouse->read($value['warehouse']);
  4231. $number = $value['number'];
  4232. $ftime = time() - 15 * 24 * 3600;
  4233. $purchase = $this->purchase->read($value['purchase']);
  4234. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4235. }
  4236. $title = "库存模板";
  4237. $titlename = "<table border=1>
  4238. <tr align='center'>
  4239. <td>仓库</td>
  4240. <td>供应商编码</td>
  4241. <td>SKU</td>
  4242. <td>增减数量(正数或负数)</td>
  4243. <td>增减备注</td>
  4244. <td>扣减方式:0减少库存1删除库存</td>
  4245. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4246. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4247. </tr>
  4248. </table>";
  4249. $filename = $title . ".xls";
  4250. $tail = "";
  4251. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4252. }
  4253. }
  4254. //数量调整模板导入
  4255. public function _presetedit()
  4256. {
  4257. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4258. $config['upload_path'] = '.' . $dir;
  4259. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4260. $config['allowed_types'] = 'xls|xlsx|csv';
  4261. $config['max_size'] = 10240;
  4262. $this->load->library('upload', $config);
  4263. $this->upload->initialize($config);
  4264. if ($this->upload->do_upload('userfile')) {
  4265. $full_path = $dir . $this->upload->data('file_name');
  4266. $fileName = '.' . $full_path;
  4267. if (!file_exists($fileName)) {
  4268. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4269. exit;
  4270. } else {
  4271. require_once "./data/excel/PHPExcel/IOFactory.php";
  4272. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4273. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4274. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4275. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4276. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4277. ++$column; //如果列数大于26行
  4278. $list = array();
  4279. for ($i = 2; $i <= $row; $i++) // 行数循环
  4280. {
  4281. $data = array();
  4282. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4283. {
  4284. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4285. }
  4286. $list[] = $data;
  4287. }
  4288. }
  4289. $i = 0;
  4290. $j = 0;
  4291. $ed = array();
  4292. foreach ($list as $key => $value) {
  4293. $time = time();
  4294. if ($value['0'] == "") {
  4295. continue;
  4296. }
  4297. $warehouse = $this->warehouse->get_title($value['0']);
  4298. $purchase = $this->purchase->get_bm($value['1']);
  4299. $sku = $value['2'];
  4300. $num = $value['3']; //调整数量
  4301. $text = $value['4']; //扣减说明
  4302. $type = $value['5']; //调整方式0扣减1删除
  4303. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4304. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4305. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4306. if (!$purchase) //如果没有这个SKU
  4307. {
  4308. $ed[] = array($purchase . '-不存在此供应商编码');
  4309. $j++;
  4310. continue;
  4311. }
  4312. if (!$d) //如果没有这个SKU
  4313. {
  4314. $ed[] = array($sku . '-库存中不存在此SKU');
  4315. $j++;
  4316. continue;
  4317. }
  4318. if (!isset($warehouse['id'])) {
  4319. $ed[] = array($sku . '-仓库名错误!');
  4320. $j++;
  4321. continue;
  4322. }
  4323. if ($type != '0' && $type != '1') {
  4324. $ed[] = array($sku . '-扣减方式填写错误!');
  4325. $j++;
  4326. continue;
  4327. }
  4328. if ($num < 0) //扣减库存
  4329. {
  4330. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4331. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4332. $j++;
  4333. continue;
  4334. }
  4335. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4336. if (count($data) < abs($num)) {
  4337. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4338. $j++;
  4339. continue;
  4340. }
  4341. if ($type == 0) //如果扣减方式为 扣减库存
  4342. {
  4343. for ($i = 0; $i < abs($num); $i++) {
  4344. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4345. }
  4346. } else if ($type == 1) {
  4347. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4348. if (count($zt) > 0) {
  4349. $ed[] = array($sku . '-有在途库存无法删除!');
  4350. $j++;
  4351. continue;
  4352. }
  4353. for ($i = 0; $i < abs($num); $i++) {
  4354. $this->whlabel->remove($data[$i]['id']);
  4355. }
  4356. }
  4357. } else if ($num > 0) //增加库存
  4358. {
  4359. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4360. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4361. $j++;
  4362. continue;
  4363. }
  4364. $post['sku'] = $d['sku'];
  4365. $post['shop'] = $d['shop'];
  4366. $post['warehouse'] = $warehouse['id'];
  4367. $post['purchase'] = $purchase['id'];
  4368. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4369. $post['state'] = 0;
  4370. $post['title'] = $d['title'];
  4371. $post['number'] = $d['number'];
  4372. $post['features'] = $d['features'];
  4373. $post['enter'] = $time;
  4374. $post['time'] = $time; //操作时间
  4375. $post['rktype'] = $rktype;
  4376. for ($i = 0; $i < $num; $i++) {
  4377. $post['label'] = time() . rand(100, 999) . $i;
  4378. $this->whlabel->insert($post);
  4379. }
  4380. }
  4381. sleep(1); //防止入库时间一样,需要延迟1秒
  4382. }
  4383. if ($j > 0) {
  4384. $tt = date('Ymd', time());
  4385. $title = '库存导入错误信息-' . $tt;
  4386. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4387. $tail = "\n";
  4388. $filename = $title . ".xls";
  4389. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4390. $dir = '/data/excel/' . $time . '/';
  4391. $file_name = 'error_' . $time . rand(1000, 9999);
  4392. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4393. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4394. fwrite($myfile, $ecl);
  4395. fclose($myfile);
  4396. $error = $dir . $file_name . '.xls';
  4397. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4398. exit;
  4399. } else {
  4400. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4401. exit;
  4402. }
  4403. }
  4404. }
  4405. //笛卡儿积
  4406. function cp($ps, $sets, $list)
  4407. {
  4408. $result = array();
  4409. $j = 0;
  4410. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4411. if ($i == 0) {
  4412. $result = $sets[$i];
  4413. }
  4414. $tmp = array();
  4415. foreach ($result as $res) {
  4416. foreach ($sets[$i + 1] as $set) {
  4417. $tmp[] = $res . ',' . $set;
  4418. }
  4419. }
  4420. $result = $tmp;
  4421. }
  4422. $this->db->trans_begin();
  4423. foreach ($result as $v) {
  4424. $post = array();
  4425. $title = "";
  4426. $num = "";
  4427. $data = explode(',', $v);
  4428. for ($i = 0; $i < count($list); $i++) {
  4429. $post[$list[$i]] = $data[$i];
  4430. $typeclass = $this->typeclass->read($data[$i]);
  4431. $title = $title . $typeclass['title'] . " ";
  4432. if ($data[$i] != 0) {
  4433. $num .= $data[$i]; //所有数据ID拼接
  4434. }
  4435. }
  4436. foreach ($ps as $kp => $vp) {
  4437. $post[$kp] = $vp;
  4438. }
  4439. $post['number'] = $num;
  4440. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4441. if ($info_list) {
  4442. $j++;
  4443. } else {
  4444. $skunum = $this->whlabel->find_count();
  4445. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4446. $post['title'] = rtrim($title, ' ');
  4447. $this->whlabel->insert($post);
  4448. }
  4449. }
  4450. if ($this->db->trans_status() === FALSE) {
  4451. $this->db->trans_commit();
  4452. return NULL;
  4453. } else {
  4454. $this->db->trans_commit();
  4455. return $j;
  4456. }
  4457. }
  4458. public function _kj($arg_array)
  4459. {
  4460. if (isset($_POST['sku'])) {
  4461. $time = time();
  4462. $sku = $this->input->post('sku', true);
  4463. $warehouse = $this->input->post('warehouse', true);
  4464. $num = $this->input->post('num', true);
  4465. $text = $this->input->post('text', true);
  4466. $purchase = $this->input->post('purchase', true);
  4467. $cktype = $this->input->post('cktype', true);
  4468. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4469. if ($cktype != 1 && $text == '') {
  4470. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4471. exit;
  4472. }
  4473. if ($num > count($order)) {
  4474. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4475. exit;
  4476. } else {
  4477. for ($i = 0; $i < $num; $i++) {
  4478. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4479. }
  4480. }
  4481. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4482. exit;
  4483. }
  4484. $uid = $this->whlabel->read($arg_array[0]);
  4485. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4486. $this->data['data'] = $uid;
  4487. $this->_Template('whlabel_kj', $this->data);
  4488. }
  4489. public function _summary($arg_array)
  4490. {
  4491. $prc = array();
  4492. $purchase = $this->purchase->find_all();
  4493. foreach ($purchase as $k => $v) {
  4494. $prc[$v['id']] = $v['title'];
  4495. }
  4496. if (isset($_GET['excel'])) {
  4497. $ktime = $this->input->get('ktime', true);
  4498. $jtime = $this->input->get('jtime', true);
  4499. $ktime = strtotime($ktime);
  4500. $jtime = strtotime($jtime);
  4501. $where = "1=1";
  4502. if ($ktime && $jtime) {
  4503. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4504. }
  4505. //数据排序
  4506. $order_str = "time desc";
  4507. if (empty($page)) {
  4508. $start = 0;
  4509. $perpage = 1;
  4510. } else {
  4511. $start = ($page - 1) * $perpage;
  4512. }
  4513. //取得信息列表
  4514. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4515. foreach ($info_list as $key => $value) {
  4516. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4517. $warehouse = $this->warehouse->read($value['warehouse']);
  4518. $info_list[$key]['warehouse'] = $warehouse['title'];
  4519. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4520. $details = array();
  4521. $cpid = array();
  4522. foreach ($x as $k => $v) {
  4523. if ($v['details'] != '') {
  4524. $details[$v['details']] = $v['details'];
  4525. }
  4526. if ($v['cpid'] != 0) {
  4527. $cpid[$v['cpid']] = $v['cpid'];
  4528. }
  4529. }
  4530. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4531. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4532. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4533. $info_list[$key]['s'] = $s;
  4534. $info_list[$key]['x'] = count($x);
  4535. }
  4536. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4537. $titlename = "<table border=1>
  4538. <tr align='center'>
  4539. <td>仓库</td>
  4540. <td>供应商</td>
  4541. <td>出库位置</td>
  4542. <td>出库编码</td>
  4543. <td>SKU</td>
  4544. <td>产品名</td>
  4545. <td>总剩余库存</td>
  4546. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4547. </tr>
  4548. </table>";
  4549. $filename = $title . ".xls";
  4550. $tail = "";
  4551. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4552. }
  4553. }
  4554. //usps发货清单
  4555. public function _manifest()
  4556. {
  4557. if (isset($_POST['manifest'])) {
  4558. $wltext = $this->input->post('wltext', true);
  4559. $time = time() - 16 * 3600;
  4560. $ptime = strtotime(date('Y-m-d', $time));
  4561. $waybill = array();
  4562. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4563. foreach ($fullorder as $v) {
  4564. $waybill[$v['waybill']] = $v['waybill'];
  4565. }
  4566. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4567. foreach ($fullordersmt as $v) {
  4568. $waybill[$v['waybill']] = $v['waybill'];
  4569. }
  4570. $wltext = explode(';', $wltext);
  4571. foreach ($wltext as $v) {
  4572. if (isset($waybill[$v])) {
  4573. unset($waybill[$v]);
  4574. }
  4575. }
  4576. $data = $this->usps->get_manifest($waybill);
  4577. if (isset($data['Description'])) {
  4578. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4579. exit;
  4580. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4581. $bctime = date('Ymd', time());
  4582. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4583. echo json_encode(array('msg' => $pdf, 'success' => true));
  4584. exit;
  4585. } else {
  4586. echo json_encode(array('msg' => $data, 'success' => false));
  4587. exit;
  4588. }
  4589. }
  4590. }
  4591. public function _pdf($pdf, $title, $bctime)
  4592. {
  4593. $pdf_path = './data/pdf/' . $bctime . '/';
  4594. $file_base64 = $pdf;
  4595. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4596. $file_base64 = base64_decode($file_base64);
  4597. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4598. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4599. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4600. }
  4601. /**
  4602. *
  4603. *
  4604. *
  4605. 进销存占单异常索引
  4606. *
  4607. *
  4608. *
  4609. **/
  4610. public function _abnormal()
  4611. {
  4612. $post = $this->input->post(NULL, TRUE);
  4613. if (isset($post['page'])) {
  4614. $page = $this->input->post('page', true);
  4615. $perpage = $this->input->post('perpage', true);
  4616. $sku = $this->input->post('sku', true);
  4617. $where = "1=1";
  4618. //数据排序
  4619. $order_str = "id desc";
  4620. if (empty($page)) {
  4621. $start = 0;
  4622. $perpage = 1;
  4623. } else {
  4624. $start = ($page - 1) * $perpage;
  4625. }
  4626. //取得信息列表
  4627. $info_list = $this->whlabel->find_all($where, '*');
  4628. $rows = array();
  4629. $list = array();
  4630. foreach ($info_list as $key => $value) {
  4631. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4632. }
  4633. foreach ($rows as $value) {
  4634. $warehouse = $this->warehouse->read($value['warehouse']);
  4635. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4636. $number = $value['number'];
  4637. $ftime = time() - 15 * 24 * 3600;
  4638. if ($value['shop'] != '') {
  4639. $shop = $value['shop'];
  4640. $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');
  4641. $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');
  4642. $order = array_merge($orderdlz, $ordersmt);
  4643. $od = 0;
  4644. $a = '';
  4645. $orid = '';
  4646. foreach ($order as $v) {
  4647. $or = explode('|', ltrim($v['whlabel'], '|'));
  4648. for ($i = 0; $i < count($or); $i++) {
  4649. $orod = explode('-', $or[$i]);
  4650. if ($orod[0] == $number) {
  4651. $od += $orod[1];
  4652. }
  4653. }
  4654. $orid .= $v['number'] . '-';
  4655. }
  4656. } else {
  4657. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4658. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4659. $order = array_merge($orderdlz, $ordersmt);
  4660. $od = 0;
  4661. $a = '';
  4662. $orid = '';
  4663. $qt = array();
  4664. foreach ($order as $v) {
  4665. $or = explode('|', ltrim($v['whlabel'], '|'));
  4666. for ($i = 0; $i < count($or); $i++) {
  4667. $orod = explode('-', $or[$i]);
  4668. if ($orod[0] == $number) {
  4669. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4670. if ($czzs > 0) {
  4671. if (isset($qt[$v['shop']])) {
  4672. if ($qt[$v['shop']] < $orod[1]) {
  4673. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4674. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4675. } else {
  4676. $qt[$v['shop']] -= $orod[1];
  4677. }
  4678. } else {
  4679. $qt[$v['shop']] = $czzs;
  4680. }
  4681. } else {
  4682. $od += $orod[1];
  4683. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4684. }
  4685. }
  4686. }
  4687. }
  4688. }
  4689. $z = $od . '(' . $orid . ')'; //查看订单号
  4690. //$z = $od;
  4691. if ($od > $c) {
  4692. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4693. }
  4694. }
  4695. $listdata = array_slice($list, $start, $perpage);
  4696. $total = count($list);
  4697. $pagenum = ceil($total / $perpage);
  4698. $over = $total - ($start + $perpage);
  4699. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4700. echo json_encode($rows);
  4701. exit;
  4702. }
  4703. $this->_Template('whlabel_abnormal', $this->data);
  4704. }
  4705. /**
  4706. *
  4707. *
  4708. *
  4709. 进销存占单异常索引
  4710. *
  4711. *
  4712. *
  4713. **/
  4714. public function _error()
  4715. {
  4716. $post = $this->input->post(NULL, TRUE);
  4717. if (isset($post['page'])) {
  4718. $page = $this->input->post('page', true);
  4719. $perpage = $this->input->post('perpage', true);
  4720. $sku = $this->input->post('sku', true);
  4721. $warehouse = $this->input->post('warehouse', true);
  4722. $ktime = $this->input->post('ktime', true);
  4723. $jtime = $this->input->post('jtime', true);
  4724. $ktime = strtotime($ktime);
  4725. $jtime = strtotime($jtime);
  4726. $where = "sku != 'Preset'";
  4727. $gj = '';
  4728. if ($sku) {
  4729. $where .= " and sku like '%$sku%'";
  4730. } else {
  4731. if ($ktime && $jtime) {
  4732. $gj = " and time > '$ktime' and time < '$jtime'";
  4733. }
  4734. }
  4735. if ($warehouse) {
  4736. $where .= " and warehouse = '$warehouse'";
  4737. }
  4738. //数据排序
  4739. $order_str = "id desc";
  4740. if (empty($page)) {
  4741. $start = 0;
  4742. $perpage = 1;
  4743. } else {
  4744. $start = ($page - 1) * $perpage;
  4745. }
  4746. //取得信息列表
  4747. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4748. $rows = array();
  4749. $list = array();
  4750. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4751. // foreach ($info_list as $value)
  4752. // {
  4753. // $warehouse = $this->warehouse->read($value['warehouse']);
  4754. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4755. // $number = $value['number'];$ftime = time()-15*24*3600;
  4756. // if($c < 1)
  4757. // {
  4758. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4759. // }
  4760. // }
  4761. $warehouse_list = $this->warehouse->find_all();
  4762. $warehouse_list = array_column($warehouse_list, null, 'id');
  4763. foreach ($info_list as $value) {
  4764. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4765. 'title' => "",
  4766. ];
  4767. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4768. $number = $value['number'];
  4769. $ftime = time() - 15 * 24 * 3600;
  4770. if ($c < 1) {
  4771. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4772. }
  4773. }
  4774. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4775. // $query = $this->db->query($sql);
  4776. // $info_list = $query->result_array();
  4777. // $sql_two = "select title,id from crowd_warehouse";
  4778. // $query_two = $this->db->query($sql_two);
  4779. // $warehouse_list = $query_two->result_array();
  4780. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4781. // foreach ($info_list as $value)
  4782. // {
  4783. // if(isset($warehouse_arr[$value['warehouse']])){
  4784. // $warehouse = $warehouse_arr[$value['warehouse']];
  4785. // }else{
  4786. // $warehouse = [
  4787. // 'id'=>0,
  4788. // 'title'=>"异常",
  4789. // ];
  4790. // }
  4791. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4792. // $number = $value['number'];$ftime = time()-15*24*3600;
  4793. // if($c < 1)
  4794. // {
  4795. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4796. // }
  4797. // }
  4798. $listdata = array_slice($list, $start, $perpage);
  4799. $total = count($list);
  4800. $pagenum = ceil($total / $perpage);
  4801. $over = $total - ($start + $perpage);
  4802. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4803. echo json_encode($rows);
  4804. exit;
  4805. }
  4806. if (isset($post['s'])) {
  4807. $id_arr = $this->input->post('s');
  4808. $id_arr = explode(',', trim($id_arr, ','));
  4809. if (!$id_arr) {
  4810. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4811. exit;
  4812. }
  4813. //循环删除记录
  4814. foreach ($id_arr as $v) {
  4815. $dd = $this->whlabel->read($v);
  4816. if (!isset($dd['id'])) {
  4817. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4818. exit;
  4819. }
  4820. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4821. if (isset($zt[0])) {
  4822. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4823. exit;
  4824. }
  4825. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4826. foreach ($deldd as $vv) {
  4827. $this->whlabel->remove($vv['id']);
  4828. }
  4829. }
  4830. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4831. exit;
  4832. }
  4833. $this->_Template('whlabel_error', $this->data);
  4834. }
  4835. public function _errorexcel()
  4836. {
  4837. $post = $this->input->post(NULL, TRUE);
  4838. if (isset($_GET['page'])) {
  4839. $page = $this->input->get('page', true);
  4840. $perpage = $this->input->get('perpage', true);
  4841. $sku = $this->input->get('sku', true);
  4842. $warehouse = $this->input->get('warehouse', true);
  4843. $ktime = $this->input->get('ktime', true);
  4844. $jtime = $this->input->get('jtime', true);
  4845. $ktime = strtotime($ktime);
  4846. $jtime = strtotime($jtime);
  4847. $where = "sku != 'Preset'";
  4848. $gj = '';
  4849. if ($sku) {
  4850. $where .= " and sku like '%$sku%'";
  4851. } else {
  4852. if ($ktime && $jtime) {
  4853. $gj = " and time > '$ktime' and time < '$jtime'";
  4854. }
  4855. }
  4856. if ($warehouse) {
  4857. $where .= " and warehouse = '$warehouse'";
  4858. }
  4859. //数据排序
  4860. $order_str = "id desc";
  4861. if (empty($page)) {
  4862. $start = 0;
  4863. $perpage = 1;
  4864. } else {
  4865. $start = ($page - 1) * $perpage;
  4866. }
  4867. //取得信息列表
  4868. $rows = array();
  4869. $list = array();
  4870. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4871. foreach ($info_list as $value) {
  4872. $warehouse = $this->warehouse->read($value['warehouse']);
  4873. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4874. $number = $value['number'];
  4875. $ftime = time() - 15 * 24 * 3600;
  4876. if ($c < 1) {
  4877. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4878. }
  4879. }
  4880. $title = "0库存汇总";
  4881. $titlename = "<table border=1>
  4882. <tr align='center'>
  4883. <td>仓库</td>
  4884. <td>SKU</td>
  4885. <td>产品</td>
  4886. <td>当前库存</td>
  4887. </tr>
  4888. </table>";
  4889. $filename = $title . ".xls";
  4890. $tail = "";
  4891. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4892. }
  4893. }
  4894. /**
  4895. *
  4896. *
  4897. * 占单
  4898. *
  4899. *
  4900. **/
  4901. public function _kcyz()
  4902. {
  4903. $post = $this->input->post(NULL, TRUE);
  4904. if (isset($post['warehouse'])) {
  4905. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  4906. exit; //不再使用
  4907. $warehouse = $this->input->post('warehouse', true);
  4908. $whlabel = $this->input->post('whlabel', true);
  4909. $id = $this->input->post('id', true);
  4910. $shop = $this->input->post('shop', true);
  4911. $number = $this->input->post('number', true);
  4912. if (!$whlabel || $whlabel == '|') {
  4913. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  4914. exit;
  4915. }
  4916. $pp = explode('|', trim($whlabel, '|'));
  4917. $x = 0;
  4918. $save = array();
  4919. foreach ($pp as $va) {
  4920. $num = explode('-', $va);
  4921. if ($number) {
  4922. $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 = '')"); //通用
  4923. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  4924. } else {
  4925. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  4926. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  4927. }
  4928. $x++;
  4929. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  4930. $save[] = $x - 1;
  4931. continue; //提前先加X不然出错,所以要减1
  4932. }
  4933. }
  4934. if (isset($save[0])) {
  4935. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  4936. exit;
  4937. } else {
  4938. echo json_encode(array('success' => true));
  4939. exit;
  4940. }
  4941. }
  4942. }
  4943. public function _db()
  4944. {
  4945. $post = $this->input->post(NULL, TRUE);
  4946. if (isset($post['page'])) {
  4947. $page = $this->input->post('page', true);
  4948. $perpage = $this->input->post('perpage', true);
  4949. $sku = $this->input->post('sku', true);
  4950. $number = $this->input->post('number', true);
  4951. $warehouse = $this->input->post('warehouse', true);
  4952. $purchase = $this->input->post('purchase', true);
  4953. $orderinfo = $this->input->post('orderinfo', true);
  4954. $waybill = $this->input->post('waybill', true);
  4955. $category = $this->input->post('category', true);
  4956. $size = $this->input->post('size', true);
  4957. $grade = $this->input->post('grade', true);
  4958. $color = $this->input->post('color', true);
  4959. $lowe = $this->input->post('lowe', true);
  4960. $state = $this->input->post('state', true);
  4961. $label = $this->input->post('label', true);
  4962. $timetk = $this->input->post('timetkk', true);
  4963. $timetj = $this->input->post('timetjj', true);
  4964. $timetk = strtotime($timetk);
  4965. $timetj = strtotime($timetj);
  4966. $where = "dbtime > 0";
  4967. if ($timetk && $timetj) {
  4968. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  4969. }
  4970. if ($sku) {
  4971. $where .= " and sku = '$sku'";
  4972. }
  4973. if ($warehouse) {
  4974. $where .= " and warehouse = '$warehouse'";
  4975. if ($warehouse == 12) {
  4976. $w = 'specialstock';
  4977. } else {
  4978. $w = 'whlabel';
  4979. }
  4980. }
  4981. if ($purchase) {
  4982. $where .= " and purchase = '$purchase'";
  4983. }
  4984. if ($category) {
  4985. $where .= " and features like '%-$category-%'";
  4986. }
  4987. if ($size) {
  4988. $where .= " and features like '%-$size-%'";
  4989. }
  4990. if ($grade) {
  4991. $where .= " and features like '%-$grade-%'";
  4992. }
  4993. if ($color) {
  4994. $where .= " and features like '%-$color-%'";
  4995. }
  4996. if ($lowe) {
  4997. $where .= " and features like '%-$lowe-%'";
  4998. }
  4999. if ($state != '') {
  5000. $where .= " and state = '$state'";
  5001. }
  5002. //数据排序
  5003. $order_str = "dbtime desc";
  5004. if (empty($page)) {
  5005. $start = 0;
  5006. $perpage = 1;
  5007. } else {
  5008. $start = ($page - 1) * $perpage;
  5009. }
  5010. //取得信息列表
  5011. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5012. foreach ($info_list as $key => $value) {
  5013. $warehouse = $this->$w->read($value['warehouse']);
  5014. $info_list[$key]['warehouse'] = $warehouse['title'];
  5015. $purchase = $this->purchase->read($value['purchase']);
  5016. $info_list[$key]['purchase'] = $purchase['title'];
  5017. if ($value['enter'] != 0) {
  5018. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5019. } else {
  5020. $info_list[$key]['enter'] = "";
  5021. }
  5022. if ($value['dbtime'] != 0) {
  5023. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5024. } else {
  5025. $info_list[$key]['dbtime'] = "";
  5026. }
  5027. if ($value['state'] == 0) {
  5028. $info_list[$key]['state'] = "在库";
  5029. } else if ($value['state'] == 1) {
  5030. $info_list[$key]['state'] = "出库";
  5031. } else if ($value['state'] == 2) {
  5032. $info_list[$key]['state'] = "退库";
  5033. } else if ($value['state'] == 3) {
  5034. $info_list[$key]['state'] = "调拨中";
  5035. } else if ($value['state'] == 4) {
  5036. $info_list[$key]['state'] = "再加工";
  5037. } else if ($value['state'] == 5) {
  5038. $info_list[$key]['state'] = "维修中";
  5039. } else if ($value['state'] == 6) {
  5040. $info_list[$key]['state'] = "盘亏";
  5041. } else if ($value['state'] == 7) {
  5042. $info_list[$key]['state'] = "更换标签";
  5043. } else if ($value['state'] == 8) {
  5044. $info_list[$key]['state'] = "其它";
  5045. } else if ($value['state'] == 9) {
  5046. $info_list[$key]['state'] = "预设";
  5047. }
  5048. }
  5049. $total = $this->whlabel->find_count($where);
  5050. $pagenum = ceil($total / $perpage);
  5051. $over = $total - ($start + $perpage);
  5052. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5053. echo json_encode($rows);
  5054. exit;
  5055. }
  5056. if (isset($post['outsku'])) {
  5057. $time = time();
  5058. $cz = $this->input->post('cz', true);
  5059. $label = $this->input->post('outsku', true);
  5060. $sl = $this->input->post('sl', true);
  5061. $num = $this->input->post('num', true);
  5062. //$warehouse = $this->input->post('warehouse',true);
  5063. if (!$sl) {
  5064. $sl = 1;
  5065. }
  5066. if (!$warehouse) {
  5067. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5068. exit;
  5069. }
  5070. $dblabel = $this->whlabellabel->get_label($label);
  5071. if ($dblabel) {
  5072. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5073. if (count($data) < 1) {
  5074. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5075. exit;
  5076. }
  5077. if (count($data) < $num) {
  5078. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5079. exit;
  5080. }
  5081. for ($i = 0; $i < $sl; $i++) {
  5082. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5083. }
  5084. echo json_encode(array('success' => true));
  5085. exit;
  5086. } else {
  5087. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5088. exit;
  5089. }
  5090. }
  5091. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5092. $this->_Template('whlabel_db', $this->data);
  5093. }
  5094. public function _dbrk()
  5095. {
  5096. $post = $this->input->post(NULL, TRUE);
  5097. if (isset($post['page'])) {
  5098. $page = $this->input->post('page', true);
  5099. $perpage = $this->input->post('perpage', true);
  5100. $sku = $this->input->post('sku', true);
  5101. $number = $this->input->post('number', true);
  5102. $warehouse = $this->input->post('warehouse', true);
  5103. $purchase = $this->input->post('purchase', true);
  5104. $orderinfo = $this->input->post('orderinfo', true);
  5105. $waybill = $this->input->post('waybill', true);
  5106. $category = $this->input->post('category', true);
  5107. $size = $this->input->post('size', true);
  5108. $grade = $this->input->post('grade', true);
  5109. $color = $this->input->post('color', true);
  5110. $lowe = $this->input->post('lowe', true);
  5111. $state = $this->input->post('state', true);
  5112. $label = $this->input->post('label', true);
  5113. $ctime = $this->input->post('ctime', true);
  5114. $timetk = $this->input->post('timetkk', true);
  5115. $timetj = $this->input->post('timetjj', true);
  5116. $timetk = strtotime($timetk);
  5117. $timetj = strtotime($timetj);
  5118. $where = "dbtime > 0";
  5119. if ($timetk && $timetj) {
  5120. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5121. }
  5122. if ($sku) {
  5123. $where .= " and sku = '$sku'";
  5124. }
  5125. if ($warehouse) {
  5126. $where .= " and warehouse = '$warehouse'";
  5127. }
  5128. if ($purchase) {
  5129. $where .= " and purchase = '$purchase'";
  5130. }
  5131. if ($category) {
  5132. $where .= " and features like '%-$category-%'";
  5133. }
  5134. if ($size) {
  5135. $where .= " and features like '%-$size-%'";
  5136. }
  5137. if ($grade) {
  5138. $where .= " and features like '%-$grade-%'";
  5139. }
  5140. if ($color) {
  5141. $where .= " and features like '%-$color-%'";
  5142. }
  5143. if ($lowe) {
  5144. $where .= " and features like '%-$lowe-%'";
  5145. }
  5146. if ($state != '') {
  5147. $where .= " and state = '$state'";
  5148. }
  5149. //数据排序
  5150. $order_str = "dbtime desc";
  5151. if (empty($page)) {
  5152. $start = 0;
  5153. $perpage = 1;
  5154. } else {
  5155. $start = ($page - 1) * $perpage;
  5156. }
  5157. //取得信息列表
  5158. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5159. foreach ($info_list as $key => $value) {
  5160. $warehouse = $this->warehouse->read($value['warehouse']);
  5161. $info_list[$key]['warehouse'] = $warehouse['title'];
  5162. $purchase = $this->purchase->read($value['purchase']);
  5163. $info_list[$key]['purchase'] = $purchase['title'];
  5164. if ($value['enter'] != 0) {
  5165. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5166. } else {
  5167. $info_list[$key]['enter'] = "";
  5168. }
  5169. if ($value['dbtime'] != 0) {
  5170. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5171. } else {
  5172. $info_list[$key]['dbtime'] = "";
  5173. }
  5174. if ($value['state'] == 0) {
  5175. $info_list[$key]['state'] = "在库";
  5176. } else if ($value['state'] == 1) {
  5177. $info_list[$key]['state'] = "出库";
  5178. } else if ($value['state'] == 2) {
  5179. $info_list[$key]['state'] = "退库";
  5180. } else if ($value['state'] == 3) {
  5181. $info_list[$key]['state'] = "调拨中";
  5182. } else if ($value['state'] == 4) {
  5183. $info_list[$key]['state'] = "再加工";
  5184. } else if ($value['state'] == 5) {
  5185. $info_list[$key]['state'] = "维修中";
  5186. } else if ($value['state'] == 6) {
  5187. $info_list[$key]['state'] = "盘亏";
  5188. } else if ($value['state'] == 7) {
  5189. $info_list[$key]['state'] = "更换标签";
  5190. } else if ($value['state'] == 8) {
  5191. $info_list[$key]['state'] = "其它";
  5192. } else if ($value['state'] == 9) {
  5193. $info_list[$key]['state'] = "预设";
  5194. }
  5195. }
  5196. $total = $this->whlabel->find_count($where);
  5197. $pagenum = ceil($total / $perpage);
  5198. $over = $total - ($start + $perpage);
  5199. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5200. echo json_encode($rows);
  5201. exit;
  5202. }
  5203. if (isset($post['rsku'])) {
  5204. $cz = $this->input->post('cz', true);
  5205. $label = $this->input->post('rsku', true);
  5206. $sl = $this->input->post('sl', true);
  5207. $warehouse = $this->input->post('warehouse', true);
  5208. if (!$sl) {
  5209. $sl = 1;
  5210. }
  5211. if (!$warehouse) {
  5212. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5213. exit;
  5214. }
  5215. $dblabel = $this->whlabellabel->get_label($label);
  5216. if ($dblabel) {
  5217. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5218. if (count($data) < 1) {
  5219. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5220. exit;
  5221. }
  5222. if ($sl > count($data)) {
  5223. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5224. exit;
  5225. }
  5226. $time = time();
  5227. for ($i = 0; $i < $sl; $i++) {
  5228. $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']);
  5229. }
  5230. echo json_encode(array('success' => true));
  5231. exit;
  5232. } else {
  5233. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5234. exit;
  5235. }
  5236. }
  5237. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5238. $this->_Template('whlabel_dbrk', $this->data);
  5239. }
  5240. public function _whlabelczdc()
  5241. {
  5242. if (isset($_GET['excel'])) {
  5243. //数据排序
  5244. $order_str = "id desc";
  5245. if (empty($page)) {
  5246. $start = 0;
  5247. $perpage = 1;
  5248. } else {
  5249. $start = ($page - 1) * $perpage;
  5250. }
  5251. $state = $this->input->get('state', true);
  5252. $sku = $this->input->get('sku', true);
  5253. $ctime = $this->input->get('ctime', true);
  5254. $category = $this->input->get('category', true);
  5255. $size = $this->input->get('size', true);
  5256. $grade = $this->input->get('grade', true);
  5257. $color = $this->input->get('color', true);
  5258. $lowe = $this->input->get('lowe', true);
  5259. $timetk = $this->input->get('timetkk', true);
  5260. $timetj = $this->input->get('timetjj', true);
  5261. $timetk = strtotime($timetk);
  5262. $timetj = strtotime($timetj);
  5263. $where = "dbtime > 0";
  5264. if ($timetk && $timetj) {
  5265. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5266. }
  5267. if ($category) {
  5268. $where .= " and features like '%-$category-%'";
  5269. }
  5270. if ($size) {
  5271. $where .= " and features like '%-$size-%'";
  5272. }
  5273. if ($grade) {
  5274. $where .= " and features like '%-$grade-%'";
  5275. }
  5276. if ($color) {
  5277. $where .= " and features like '%-$color-%'";
  5278. }
  5279. if ($lowe) {
  5280. $where .= " and features like '%-$lowe-%'";
  5281. }
  5282. //取得信息列表
  5283. $info_list = $this->whlabel->find_all($where, '*');
  5284. $rows = array();
  5285. $list = array();
  5286. foreach ($info_list as $key => $value) {
  5287. $rows[$value['sku']] = $value; //所有数据sku
  5288. }
  5289. foreach ($rows as $value) {
  5290. $warehouse = $this->warehouse->read($value['warehouse']);
  5291. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5292. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5293. if ($value['orderinfo'] == 0) {
  5294. $info_list[$key]['orderinfo'] = "";
  5295. }
  5296. if ($value['waybill'] == 0) {
  5297. $info_list[$key]['waybill'] = "";
  5298. }
  5299. if ($value['state'] == 0) {
  5300. $value['state'] = "在库";
  5301. } else if ($value['state'] == 3) {
  5302. $value['state'] = "调拨中";
  5303. }
  5304. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5305. }
  5306. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5307. $titlename = "<table border=1>
  5308. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5309. <tr align='center'>
  5310. <td>SKU</td>
  5311. <td>产品</td>
  5312. <td>调拨数量</td>
  5313. <td>入库数量</td>
  5314. </tr>
  5315. </table>";
  5316. $filename = $title . ".xls";
  5317. $tail = "";
  5318. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5319. }
  5320. }
  5321. public function _print($arg_array)
  5322. {
  5323. if (isset($_SESSION['api'])) {
  5324. $user = $this->user->get_api($_SESSION['api']);
  5325. $usp = $user;
  5326. $fgshop = "";
  5327. $sid = "";
  5328. $wid = "";
  5329. $wtype = "";
  5330. $usersp = explode('|', trim($user['shop'], '|'));
  5331. $userwh = explode('|', trim($user['warehouse'], '|'));
  5332. foreach ($usersp as $value) {
  5333. $fgshop .= " shop = " . $value . " or";
  5334. $sid .= " id = " . $value . " or";
  5335. }
  5336. foreach ($userwh as $value) {
  5337. $wid .= " id = " . $value . " or";
  5338. $wtype .= " type = " . $value . " or";
  5339. }
  5340. }
  5341. $post = $this->input->post(NULL, TRUE);
  5342. if (isset($post['tmsku'])) {
  5343. $tmsku = $this->input->post('tmsku', true);
  5344. if (is_numeric($tmsku)) {
  5345. $yyh = $this->whlabellabel->get_label($tmsku);
  5346. } else {
  5347. $yyh = $this->whlabellabel->get_sku($tmsku);
  5348. }
  5349. if ($yyh) {
  5350. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5351. exit;
  5352. } else {
  5353. echo json_encode(array('success' => false));
  5354. exit;
  5355. }
  5356. }
  5357. $classid = $this->classid->sku();
  5358. $pm = $classid;
  5359. $scsku = $classid;
  5360. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5361. if (isset($post['warehouse'])) {
  5362. if ($post['warehouse']) {
  5363. $list = array();
  5364. $num = "";
  5365. $title = "";
  5366. $features = "";
  5367. $order = 0;
  5368. $post['shop'] = '';
  5369. $brand = $this->input->post('brand', true);
  5370. if ($brand != '0,') {
  5371. $b = $this->brand->read(rtrim($brand, ','));
  5372. if ($b) {
  5373. $post['shop'] = str_replace('|', ',', $b['shop']);
  5374. }
  5375. }
  5376. $post['details'] = $this->input->post('details', true); //打印数量
  5377. $xbqnum = $this->input->post('xbqnum', true);
  5378. $post['purchase'] = $this->input->post('purchase', true);
  5379. $post['warehouse'] = $this->input->post('warehouse', true);
  5380. $post['purchase'] = $this->input->post('purchase', true);
  5381. $post['retreatwarehouse'] = $post['warehouse'];
  5382. $post['cpbz'] = $this->input->post('cpbz', true);
  5383. $post['state'] = 9;
  5384. $category = $this->input->post('category', true);
  5385. $list['category'] = $category;
  5386. $list['hairtype'] = $this->input->post('hairtype', true);
  5387. $list['grade'] = $this->input->post('grade', true);
  5388. $size = $this->input->post('size', true);
  5389. $list['size'] = rtrim($size, ',');
  5390. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5391. $list['extension'] = $this->input->post('extension', true);
  5392. if ($category == 1297) {
  5393. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5394. }
  5395. if ($category == 1702) {
  5396. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5397. $list['syother'] = $this->input->post('syother', true);
  5398. }
  5399. if ($category == 133) {
  5400. $list['fittype'] = $this->input->post('fittype', true);
  5401. $list['acother'] = $this->input->post('acother', true);
  5402. }
  5403. $list['color'] = $this->input->post('color', true);
  5404. $list['lowe'] = $this->input->post('lowe', true);
  5405. if ($category == 127) {
  5406. $list['type'] = $this->input->post('type', true);
  5407. $list['headroad'] = $this->input->post('headroad', true);
  5408. $list['density'] = $this->input->post('density', true);
  5409. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5410. $list['lacesize'] = $this->input->post('lacesize', true);
  5411. }
  5412. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5413. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5414. }
  5415. if ($category == 128) {
  5416. $list['lacetype'] = $this->input->post('lacetype', true);
  5417. $list['haircap'] = $this->input->post('haircap', true);
  5418. $list['density'] = $this->input->post('density', true);
  5419. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5420. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5421. $list['wigother'] = $this->input->post('wigother', true);
  5422. $list['wigother1'] = $this->input->post('wigother1', true);
  5423. $list['wigother2'] = $this->input->post('wigother2', true);
  5424. }
  5425. if ($category == 129) {
  5426. $list['wide'] = $this->input->post('wide', true);
  5427. }
  5428. if ($category == 131) {
  5429. $list['gifttype'] = $this->input->post('gifttype', true);
  5430. $list['giftother'] = $this->input->post('giftother', true);
  5431. }
  5432. if ($category == 134) {
  5433. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5434. }
  5435. if ($category == 1297) {
  5436. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5437. $list['sywigother'] = $this->input->post('sywigother', true);
  5438. }
  5439. if ($category == 130 || $category == 133 || $category == 1702) {
  5440. $list['items'] = $this->input->post('items', true);
  5441. $list['weight'] = $this->input->post('weight', true);
  5442. }
  5443. if ($category == 1702) {
  5444. $list['syhairther'] = $this->input->post('syhairther', true);
  5445. }
  5446. foreach ($list as $k => $v) {
  5447. if ($v != 0) {
  5448. $num .= $v;
  5449. $features .= $v . '-';
  5450. $post[$k] = $v;
  5451. $typeclass = $this->typeclass->read($v);
  5452. if (isset($pm[$typeclass['classid']])) {
  5453. if (stripos($typeclass['zh'], '|') !== false) {
  5454. $exzh = explode('|', $typeclass['zh']);
  5455. $pm[$typeclass['classid']] = $exzh[0];
  5456. } else {
  5457. $pm[$typeclass['classid']] = $typeclass['zh'];
  5458. }
  5459. }
  5460. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5461. if ($k != 'size') {
  5462. $title .= $typeclass['title'] . " ";
  5463. }
  5464. }
  5465. }
  5466. $typeclass = $this->typeclass->read($list['size']);
  5467. $title .= $typeclass['title'];
  5468. $time = time();
  5469. $post['title'] = rtrim($title, ' ');
  5470. $post['number'] = $num;
  5471. $post['features'] = '-' . $features;
  5472. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5473. $featurespp = explode('-', trim($featurespp, '-'));
  5474. if (isset($featurespp[5])) {
  5475. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5476. } else {
  5477. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5478. }
  5479. $post['enter'] = $time;
  5480. $post['time'] = $time; //操作时间
  5481. $scsku = implode("-", $scsku);
  5482. $zh = implode(" ", $pm);
  5483. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5484. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5485. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5486. $post['sku'] = $bqsku;
  5487. $label = time() . rand(0, 9);
  5488. $post['label'] = $label;
  5489. $cpid = $this->whlabellabel->find_count();
  5490. $post['cpid'] = $cpid + 1;
  5491. $cpid = $post['cpid'];
  5492. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5493. //if($whlabelbarcode)
  5494. //{
  5495. //$post['label'] = $whlabelbarcode['label'];
  5496. //if(!$this->whlabellabel->insert($post))
  5497. //{
  5498. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5499. //}
  5500. //}
  5501. //else
  5502. //{
  5503. $this->db->trans_begin();
  5504. $this->whlabellabel->insert($post);
  5505. //$this->whlabelbarcode->insert($post);
  5506. if ($this->db->trans_status() === TRUE) {
  5507. $this->db->trans_commit();
  5508. } else {
  5509. $this->db->trans_rollback();
  5510. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5511. exit;
  5512. }
  5513. //}
  5514. $warehouse_name = "";
  5515. $warehouse = $post['warehouse'];
  5516. if($warehouse == 12){
  5517. $warehouse_name = "特殊库存库";
  5518. }
  5519. // if($warehouse == 13){
  5520. // $warehouse_name = "许昌仓";
  5521. // }
  5522. // if($warehouse == 5){
  5523. // $warehouse_name = "美国店";
  5524. // }
  5525. // if($warehouse == 16){
  5526. // $warehouse_name = "定制头套仓";
  5527. // }
  5528. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5529. if(!empty($warehouse_name)){
  5530. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5531. }
  5532. $purchase = $this->purchase->read($post['purchase']);
  5533. 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));
  5534. exit; //特殊仓目前不需要仓库选项
  5535. }
  5536. }
  5537. if (isset($_SESSION['api'])) {
  5538. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5539. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5540. $this->data['wlshop'] = $wlshop;
  5541. $this->data['warehouse'] = $warehouse;
  5542. }
  5543. $whlabelwz = $this->whlabelwz->find_all();
  5544. $this->data['whlabelwz'] = $whlabelwz;
  5545. $this->_Template('whlabel_print', $this->data);
  5546. }
  5547. public function _usaprint($arg_array)
  5548. {
  5549. if (isset($_SESSION['api'])) {
  5550. $user = $this->user->get_api($_SESSION['api']);
  5551. $usp = $user;
  5552. $fgshop = "";
  5553. $sid = "";
  5554. $wid = "";
  5555. $wtype = "";
  5556. $usersp = explode('|', trim($user['shop'], '|'));
  5557. $userwh = explode('|', trim($user['warehouse'], '|'));
  5558. foreach ($usersp as $value) {
  5559. $fgshop .= " shop = " . $value . " or";
  5560. $sid .= " id = " . $value . " or";
  5561. }
  5562. foreach ($userwh as $value) {
  5563. $wid .= " id = " . $value . " or";
  5564. $wtype .= " type = " . $value . " or";
  5565. }
  5566. }
  5567. $post = $this->input->post(NULL, TRUE);
  5568. if (isset($post['tmsku'])) {
  5569. $tmsku = $this->input->post('tmsku', true);
  5570. if (is_numeric($tmsku)) {
  5571. $yyh = $this->whlabellabel->get_label($tmsku);
  5572. } else {
  5573. $yyh = $this->whlabellabel->get_sku($tmsku);
  5574. }
  5575. if ($yyh) {
  5576. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5577. exit;
  5578. } else {
  5579. echo json_encode(array('success' => false));
  5580. exit;
  5581. }
  5582. }
  5583. $classid = $this->classid->sku();
  5584. $pm = $classid;
  5585. $scsku = $classid;
  5586. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5587. if (isset($post['warehouse'])) {
  5588. if ($post['warehouse']) {
  5589. $list = array();
  5590. $num = "";
  5591. $title = "";
  5592. $features = "";
  5593. $order = 0;
  5594. $post['shop'] = '';
  5595. $brand = $this->input->post('brand', true);
  5596. if ($brand != '0,') {
  5597. $b = $this->brand->read(rtrim($brand, ','));
  5598. if ($b) {
  5599. $post['shop'] = str_replace('|', ',', $b['shop']);
  5600. }
  5601. }
  5602. $post['details'] = $this->input->post('details', true); //打印数量
  5603. $xbqnum = $this->input->post('xbqnum', true);
  5604. $post['purchase'] = $this->input->post('purchase', true);
  5605. $post['warehouse'] = $this->input->post('warehouse', true);
  5606. $post['purchase'] = $this->input->post('purchase', true);
  5607. $post['retreatwarehouse'] = $post['warehouse'];
  5608. $post['cpbz'] = $this->input->post('cpbz', true);
  5609. $post['state'] = 9;
  5610. $category = $this->input->post('category', true);
  5611. $list['category'] = $category;
  5612. $list['hairtype'] = $this->input->post('hairtype', true);
  5613. $list['grade'] = $this->input->post('grade', true);
  5614. $size = $this->input->post('size', true);
  5615. $list['size'] = rtrim($size, ',');
  5616. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5617. $list['extension'] = $this->input->post('extension', true);
  5618. if ($category == 1297) {
  5619. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5620. }
  5621. if ($category == 1702) {
  5622. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5623. $list['syother'] = $this->input->post('syother', true);
  5624. }
  5625. if ($category == 133) {
  5626. $list['fittype'] = $this->input->post('fittype', true);
  5627. $list['acother'] = $this->input->post('acother', true);
  5628. }
  5629. $list['color'] = $this->input->post('color', true);
  5630. $list['lowe'] = $this->input->post('lowe', true);
  5631. if ($category == 127) {
  5632. $list['type'] = $this->input->post('type', true);
  5633. $list['headroad'] = $this->input->post('headroad', true);
  5634. $list['density'] = $this->input->post('density', true);
  5635. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5636. $list['lacesize'] = $this->input->post('lacesize', true);
  5637. }
  5638. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5639. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5640. }
  5641. if ($category == 128) {
  5642. $list['lacetype'] = $this->input->post('lacetype', true);
  5643. $list['haircap'] = $this->input->post('haircap', true);
  5644. $list['density'] = $this->input->post('density', true);
  5645. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5646. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5647. $list['wigother'] = $this->input->post('wigother', true);
  5648. $list['wigother1'] = $this->input->post('wigother1', true);
  5649. $list['wigother2'] = $this->input->post('wigother2', true);
  5650. }
  5651. if ($category == 129) {
  5652. $list['wide'] = $this->input->post('wide', true);
  5653. }
  5654. if ($category == 131) {
  5655. $list['gifttype'] = $this->input->post('gifttype', true);
  5656. $list['giftother'] = $this->input->post('giftother', true);
  5657. }
  5658. if ($category == 134) {
  5659. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5660. }
  5661. if ($category == 1297) {
  5662. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5663. $list['sywigother'] = $this->input->post('sywigother', true);
  5664. }
  5665. if ($category == 130 || $category == 133 || $category == 1702) {
  5666. $list['items'] = $this->input->post('items', true);
  5667. $list['weight'] = $this->input->post('weight', true);
  5668. }
  5669. if ($category == 1702) {
  5670. $list['syhairther'] = $this->input->post('syhairther', true);
  5671. }
  5672. foreach ($list as $k => $v) {
  5673. if ($v != 0) {
  5674. $num .= $v;
  5675. $features .= $v . '-';
  5676. $post[$k] = $v;
  5677. $typeclass = $this->typeclass->read($v);
  5678. if (isset($pm[$typeclass['classid']])) {
  5679. if (stripos($typeclass['zh'], '|') !== false) {
  5680. $exzh = explode('|', $typeclass['zh']);
  5681. $pm[$typeclass['classid']] = $exzh[0];
  5682. } else {
  5683. $pm[$typeclass['classid']] = $typeclass['zh'];
  5684. }
  5685. }
  5686. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5687. if ($k != 'size') {
  5688. $title .= $typeclass['title'] . " ";
  5689. }
  5690. }
  5691. }
  5692. $typeclass = $this->typeclass->read($list['size']);
  5693. $title .= $typeclass['title'];
  5694. $time = time();
  5695. $post['title'] = rtrim($title, ' ');
  5696. $post['number'] = $num;
  5697. $post['features'] = '-' . $features;
  5698. $fp = $this->whlabel->get_features($post['features']);
  5699. if (!$fp) {
  5700. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5701. exit;
  5702. }
  5703. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5704. $featurespp = explode('-', trim($featurespp, '-'));
  5705. if (isset($featurespp[5])) {
  5706. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5707. } else {
  5708. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5709. }
  5710. $post['enter'] = $time;
  5711. $post['time'] = $time; //操作时间
  5712. $scsku = implode("-", $scsku);
  5713. $zh = implode(" ", $pm);
  5714. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5715. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5716. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5717. $post['sku'] = $fp['sku'];
  5718. $post['label'] = $fp['sku'];
  5719. $cpid = $this->whlabellabel->find_count();
  5720. $post['cpid'] = $cpid + 1;
  5721. $cpid = $post['cpid'];
  5722. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5723. //if($whlabelbarcode)
  5724. //{
  5725. //$post['label'] = $whlabelbarcode['label'];
  5726. //if(!$this->whlabellabel->insert($post))
  5727. //{
  5728. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5729. //}
  5730. //}
  5731. //else
  5732. //{
  5733. $this->db->trans_begin();
  5734. $this->whlabellabel->insert($post);
  5735. //$this->whlabelbarcode->insert($post);
  5736. if ($this->db->trans_status() === TRUE) {
  5737. $this->db->trans_commit();
  5738. } else {
  5739. $this->db->trans_rollback();
  5740. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5741. exit;
  5742. }
  5743. //}
  5744. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5745. $purchase = $this->purchase->read($post['purchase']);
  5746. 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));
  5747. exit; //特殊仓目前不需要仓库选项
  5748. }
  5749. }
  5750. if (isset($_SESSION['api'])) {
  5751. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5752. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5753. $this->data['wlshop'] = $wlshop;
  5754. $this->data['warehouse'] = $warehouse;
  5755. }
  5756. $whlabelwz = $this->whlabelwz->find_all();
  5757. $this->data['whlabelwz'] = $whlabelwz;
  5758. $this->_Template('whlabel_usaprint', $this->data);
  5759. }
  5760. public function _printrk($arg_array)
  5761. {
  5762. $prc = array();
  5763. $purchase = $this->purchase->find_all();
  5764. foreach ($purchase as $k => $v) {
  5765. $prc[$v['id']] = $v['title'];
  5766. }
  5767. $post = $this->input->post(NULL, TRUE);
  5768. if (isset($post['page'])) {
  5769. $page = $this->input->post('page', true);
  5770. $perpage = $this->input->post('perpage', true);
  5771. $sku = $this->input->post('sku', true);
  5772. $bs = $this->input->post('bs', true);
  5773. $number = $this->input->post('number', true);
  5774. $warehouse = $this->input->post('warehouse', true);
  5775. $purchase = $this->input->post('purchase', true);
  5776. $orderinfo = $this->input->post('orderinfo', true);
  5777. $waybill = $this->input->post('waybill', true);
  5778. $category = $this->input->post('category', true);
  5779. $size = $this->input->post('size', true);
  5780. $grade = $this->input->post('grade', true);
  5781. $color = $this->input->post('color', true);
  5782. $lowe = $this->input->post('lowe', true);
  5783. $state = $this->input->post('state', true);
  5784. $label = $this->input->post('label', true);
  5785. $timetk = $this->input->post('ktime', true);
  5786. $timetj = $this->input->post('jtime', true);
  5787. $timetk = strtotime($timetk);
  5788. $timetj = strtotime($timetj);
  5789. $where = "1=1 ";
  5790. if ($timetk && $timetj) {
  5791. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5792. }
  5793. if ($sku) {
  5794. $where .= " and sku = '$sku'";
  5795. }
  5796. if ($bs != '') {
  5797. $where .= " and bs = '$bs'";
  5798. }
  5799. if ($number) {
  5800. $where .= " and number = '$number'";
  5801. }
  5802. if ($warehouse) {
  5803. $where .= " and warehouse = '$warehouse'";
  5804. }
  5805. if ($purchase) {
  5806. $where .= " and purchase = '$purchase'";
  5807. }
  5808. if ($orderinfo) {
  5809. $where .= " and orderinfo = '$orderinfo'";
  5810. }
  5811. if ($waybill) {
  5812. $where .= " and waybill = '$waybill'";
  5813. }
  5814. if ($category) {
  5815. $where .= " and features like '%-$category-%'";
  5816. }
  5817. if ($size) {
  5818. $where .= " and features like '%-$size-%'";
  5819. }
  5820. if ($grade) {
  5821. $where .= " and features like '%-$grade-%'";
  5822. }
  5823. if ($color) {
  5824. $where .= " and features like '%-$color-%'";
  5825. }
  5826. if ($lowe) {
  5827. $where .= " and features like '%-$lowe-%'";
  5828. }
  5829. if ($label) {
  5830. $where .= " and label = '$label'";
  5831. }
  5832. if ($state || $state == 0) {
  5833. $where .= " and state = '$state'";
  5834. }
  5835. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5836. //数据排序
  5837. $order_str = "enter desc";
  5838. if (empty($page)) {
  5839. $start = 0;
  5840. $perpage = 1;
  5841. } else {
  5842. $start = ($page - 1) * $perpage;
  5843. }
  5844. //取得信息列表
  5845. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5846. foreach ($info_list as $key => $value) {
  5847. $warehouse = $this->warehouse->read($value['warehouse']);
  5848. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5849. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5850. if ($value['state'] == 0) {
  5851. $info_list[$key]['state'] = "在库";
  5852. } else if ($value['state'] == 1) {
  5853. $info_list[$key]['state'] = "出库";
  5854. } else if ($value['state'] == 2) {
  5855. $info_list[$key]['state'] = "退库";
  5856. } else if ($value['state'] == 3) {
  5857. $info_list[$key]['state'] = "调拨中";
  5858. } else if ($value['state'] == 4) {
  5859. $info_list[$key]['state'] = "再加工";
  5860. } else if ($value['state'] == 5) {
  5861. $info_list[$key]['state'] = "维修中";
  5862. } else if ($value['state'] == 6) {
  5863. $info_list[$key]['state'] = "盘亏";
  5864. } else if ($value['state'] == 7) {
  5865. $info_list[$key]['state'] = "更换标签";
  5866. } else if ($value['state'] == 8) {
  5867. $info_list[$key]['state'] = "其它";
  5868. } else if ($value['state'] == 9) {
  5869. $info_list[$key]['state'] = "预设";
  5870. } else if ($value['state'] == 10) {
  5871. $info_list[$key]['state'] = "美店零售";
  5872. }
  5873. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5874. }
  5875. $total = $this->$ck->find_count($where);
  5876. $pagenum = ceil($total / $perpage);
  5877. $over = $total - ($start + $perpage);
  5878. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5879. echo json_encode($rows);
  5880. exit;
  5881. }
  5882. if (isset($post['tmsku'])) {
  5883. $time = time();
  5884. $tmsku = $this->input->post('tmsku', true);
  5885. //$post['shop'] = $this->input->post('shop',true);
  5886. $num = $this->input->post('num', true);
  5887. $rktype = $this->input->post('rktype', true);
  5888. if ($num > 200) {
  5889. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5890. exit;
  5891. }
  5892. if (!$rktype) {
  5893. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5894. }
  5895. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5896. /**
  5897. $wz = array();
  5898. foreach ($rk as $key=>$value)
  5899. {
  5900. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5901. }
  5902. if(count($wz) > 1)
  5903. {
  5904. $wz = array_values($wz);
  5905. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  5906. }
  5907. **/
  5908. if (isset($rk[0]['purchase'])) {
  5909. $rk = $rk[0];
  5910. $j = 0;
  5911. $post['purchase'] = $rk['purchase'];
  5912. $post['warehouse'] = $rk['warehouse'];
  5913. $post['retreatwarehouse'] = $rk['warehouse'];
  5914. $post['sku'] = $rk['sku'];
  5915. $post['number'] = $rk['number'];
  5916. $post['features'] = $rk['features'];
  5917. $post['title'] = $rk['title'];
  5918. $post['enter'] = $time;
  5919. $post['time'] = $time;
  5920. $post['bs'] = 1;
  5921. $post['shop'] = $rk['shop'];
  5922. $post['details'] = $rk['details'];
  5923. $post['cpid'] = $rk['cpid'];
  5924. $post['cpbz'] = $rk['cpbz'];
  5925. //$post['rktype'] = $rktype;
  5926. $warehouse = $this->warehouse->read($rk['warehouse']);
  5927. if ($warehouse['bdck'] == '') {
  5928. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  5929. exit;
  5930. } else {
  5931. $bdck = $warehouse['bdck'];
  5932. }
  5933. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  5934. if (isset($pdwz['details'])) {
  5935. if ($pdwz['details'] != $post['details']) {
  5936. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  5937. exit;
  5938. }
  5939. }
  5940. $post['featurespp'] = $rk['featurespp'];
  5941. if ($post['warehouse'] == '5') {
  5942. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5943. if ($yza) {
  5944. if ($post['features'] != $yza[0]['features']) {
  5945. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  5946. exit;
  5947. }
  5948. }
  5949. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5950. if ($yzb) {
  5951. if ($post['sku'] != $yzb[0]['sku']) {
  5952. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  5953. exit;
  5954. }
  5955. }
  5956. }
  5957. for ($i = 0; $i < $num; $i++) {
  5958. $post['label'] = time() . rand(100, 999) . $i;
  5959. if ($this->$bdck->insert($post)) {
  5960. $j++;
  5961. }
  5962. }
  5963. /**
  5964. if($post['warehouse'] != 12)
  5965. {
  5966. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5967. }
  5968. **/
  5969. if ($j == $num) {
  5970. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  5971. exit;
  5972. } else {
  5973. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  5974. exit;
  5975. }
  5976. } else {
  5977. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  5978. exit;
  5979. }
  5980. }
  5981. $this->_Template('whlabel_printrk', $this->data);
  5982. }
  5983. public function _printxzrk($arg_array)
  5984. {
  5985. $post = $this->input->post(NULL, TRUE);
  5986. if (isset($post['wzid'])) {
  5987. $time = time();
  5988. $id = $this->input->post('wzid', true);
  5989. //$post['shop'] = $this->input->post('shop',true);
  5990. $num = 1;
  5991. $rk = $this->whlabellabel->read($id);
  5992. if (isset($rk['purchase'])) {
  5993. $x = 0;
  5994. $post['purchase'] = $rk['purchase'];
  5995. $post['warehouse'] = $rk['warehouse'];
  5996. $post['retreatwarehouse'] = $rk['warehouse'];
  5997. $post['sku'] = $rk['sku'];
  5998. $post['number'] = $rk['number'];
  5999. $post['features'] = $rk['features'];
  6000. $post['title'] = $rk['title'];
  6001. $post['enter'] = $time;
  6002. $post['time'] = $time;
  6003. $post['bs'] = 1;
  6004. $post['shop'] = $rk['shop'];
  6005. $post['details'] = $rk['details'];
  6006. $post['cpid'] = $rk['cpid'];
  6007. $post['cpbz'] = $rk['cpbz'];
  6008. $warehouse = $this->warehouse->read($rk['warehouse']);
  6009. if ($warehouse['bdck'] == '') {
  6010. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6011. exit;
  6012. } else {
  6013. $bdck = $warehouse['bdck'];
  6014. }
  6015. $post['featurespp'] = $rk['featurespp'];
  6016. $this->db->trans_begin();
  6017. for ($i = 0; $i < $num; $i++) {
  6018. $post['label'] = time() . rand(100, 999) . $i;
  6019. $this->$bdck->insert($post);
  6020. }
  6021. /**
  6022. if($post['warehouse'] != 12)
  6023. {
  6024. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6025. }
  6026. **/
  6027. if ($this->db->trans_status() === TRUE) {
  6028. $this->db->trans_commit();
  6029. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6030. exit;
  6031. } else {
  6032. $this->db->trans_rollback();
  6033. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6034. exit;
  6035. }
  6036. } else {
  6037. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6038. exit;
  6039. }
  6040. }
  6041. }
  6042. public function _printck($arg_array)
  6043. {
  6044. $prc = array();
  6045. $purchase = $this->purchase->find_all();
  6046. foreach ($purchase as $k => $v) {
  6047. $prc[$v['id']] = $v['title'];
  6048. }
  6049. $post = $this->input->post(NULL, TRUE);
  6050. if (isset($post['page'])) {
  6051. $page = $this->input->post('page', true);
  6052. $perpage = $this->input->post('perpage', true);
  6053. $sku = $this->input->post('sku', true);
  6054. $bs = $this->input->post('bs', true);
  6055. $number = $this->input->post('number', true);
  6056. $warehouse = $this->input->post('warehouse', true);
  6057. $purchase = $this->input->post('purchase', true);
  6058. $orderinfo = $this->input->post('orderinfo', true);
  6059. $waybill = $this->input->post('waybill', true);
  6060. $category = $this->input->post('category', true);
  6061. $size = $this->input->post('size', true);
  6062. $grade = $this->input->post('grade', true);
  6063. $color = $this->input->post('color', true);
  6064. $lowe = $this->input->post('lowe', true);
  6065. $state = $this->input->post('state', true);
  6066. $label = $this->input->post('label', true);
  6067. $timetk = $this->input->post('ktime', true);
  6068. $timetj = $this->input->post('jtime', true);
  6069. $timetk = strtotime($timetk);
  6070. $timetj = strtotime($timetj);
  6071. $where = "state=1 ";
  6072. if ($timetk && $timetj) {
  6073. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6074. }
  6075. if ($sku) {
  6076. $where .= " and sku = '$sku'";
  6077. }
  6078. if ($bs != '') {
  6079. $where .= " and bs = '$bs'";
  6080. }
  6081. if ($number) {
  6082. $where .= " and number = '$number'";
  6083. }
  6084. if ($warehouse) {
  6085. $where .= " and warehouse = '$warehouse'";
  6086. }
  6087. if ($purchase) {
  6088. $where .= " and purchase = '$purchase'";
  6089. }
  6090. if ($orderinfo) {
  6091. $where .= " and orderinfo = '$orderinfo'";
  6092. }
  6093. if ($waybill) {
  6094. $where .= " and waybill = '$waybill'";
  6095. }
  6096. if ($category) {
  6097. $where .= " and features like '%-$category-%'";
  6098. }
  6099. if ($size) {
  6100. $where .= " and features like '%-$size-%'";
  6101. }
  6102. if ($grade) {
  6103. $where .= " and features like '%-$grade-%'";
  6104. }
  6105. if ($color) {
  6106. $where .= " and features like '%-$color-%'";
  6107. }
  6108. if ($lowe) {
  6109. $where .= " and features like '%-$lowe-%'";
  6110. }
  6111. if ($label) {
  6112. $where .= " and label = '$label'";
  6113. }
  6114. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6115. //数据排序
  6116. $order_str = "outk desc";
  6117. if (empty($page)) {
  6118. $start = 0;
  6119. $perpage = 1;
  6120. } else {
  6121. $start = ($page - 1) * $perpage;
  6122. }
  6123. //取得信息列表
  6124. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6125. foreach ($info_list as $key => $value) {
  6126. $warehouse = $this->warehouse->read($value['warehouse']);
  6127. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6128. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6129. if ($value['state'] == 0) {
  6130. $info_list[$key]['state'] = "在库";
  6131. } else if ($value['state'] == 1) {
  6132. $info_list[$key]['state'] = "出库";
  6133. } else if ($value['state'] == 2) {
  6134. $info_list[$key]['state'] = "退库";
  6135. } else if ($value['state'] == 3) {
  6136. $info_list[$key]['state'] = "调拨中";
  6137. } else if ($value['state'] == 4) {
  6138. $info_list[$key]['state'] = "再加工";
  6139. } else if ($value['state'] == 5) {
  6140. $info_list[$key]['state'] = "维修中";
  6141. } else if ($value['state'] == 6) {
  6142. $info_list[$key]['state'] = "盘亏";
  6143. } else if ($value['state'] == 7) {
  6144. $info_list[$key]['state'] = "更换标签";
  6145. } else if ($value['state'] == 8) {
  6146. $info_list[$key]['state'] = "其它";
  6147. } else if ($value['state'] == 9) {
  6148. $info_list[$key]['state'] = "预设";
  6149. } else if ($value['state'] == 10) {
  6150. $info_list[$key]['state'] = "美店零售";
  6151. }
  6152. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6153. }
  6154. $total = $this->$ck->find_count($where);
  6155. $pagenum = ceil($total / $perpage);
  6156. $over = $total - ($start + $perpage);
  6157. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6158. echo json_encode($rows);
  6159. exit;
  6160. }
  6161. if (isset($post['tmsku'])) {
  6162. $time = time();
  6163. $tmsku = $this->input->post('tmsku', true);
  6164. //$post['shop'] = $this->input->post('shop',true);
  6165. $num = $this->input->post('num', true);
  6166. $cktype = $this->input->post('cktype', true);
  6167. $label = $this->whlabellabel->get_label($tmsku);
  6168. if (!$cktype) {
  6169. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6170. }
  6171. if (!isset($label['warehouse'])) {
  6172. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6173. exit;
  6174. }
  6175. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6176. if (stripos($label['features'], '-126-') !== false) {
  6177. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6178. } else {
  6179. $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 = ''");
  6180. }
  6181. $j = 0;
  6182. if (count($ck) >= $num) {
  6183. for ($i = 0; $i < $num; $i++) {
  6184. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6185. {
  6186. $j++;
  6187. }
  6188. }
  6189. if ($j == $num) {
  6190. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6191. exit;
  6192. } else {
  6193. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6194. exit;
  6195. }
  6196. } else {
  6197. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6198. exit;
  6199. }
  6200. }
  6201. if(isset($_SESSION['api']))
  6202. {
  6203. $user = $this->user->get_api($_SESSION['api']);
  6204. if(in_array($user['power'],[1,27])){
  6205. $vip = 1;
  6206. }
  6207. }
  6208. else
  6209. {
  6210. $vip = 0;
  6211. header('Location: /');exit;
  6212. }
  6213. $this->data['vip'] = $vip;
  6214. $this->_Template('whlabel_printck', $this->data);
  6215. }
  6216. public function _printexcel()
  6217. {
  6218. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6219. $config['upload_path'] = '.' . $dir;
  6220. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6221. $config['allowed_types'] = 'xls|xlsx|csv';
  6222. $config['max_size'] = 10240;
  6223. $this->load->library('upload', $config);
  6224. $this->upload->initialize($config);
  6225. if ($this->upload->do_upload('userfile')) {
  6226. $full_path = $dir . $this->upload->data('file_name');
  6227. $fileName = '.' . $full_path;
  6228. if (!file_exists($fileName)) {
  6229. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6230. exit;
  6231. } else {
  6232. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6233. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6234. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6235. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6236. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6237. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6238. ++$column; //如果列数大于26行
  6239. $list = array();
  6240. for ($i = 2; $i <= $row; $i++) // 行数循环
  6241. {
  6242. $data = array();
  6243. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6244. {
  6245. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6246. }
  6247. $list[] = $data;
  6248. }
  6249. }
  6250. $ed = array();
  6251. $i = 0;
  6252. $j = 0;
  6253. $dcdata = array();
  6254. $yc = '';
  6255. $cmf_arr = array_column($list, '1');
  6256. array_multisort($cmf_arr, SORT_ASC, $list);
  6257. foreach ($list as $key => $value) {
  6258. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6259. if ($typeclass) {
  6260. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6261. } else {
  6262. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6263. $i++;
  6264. continue;
  6265. }
  6266. }
  6267. if ($i > 0) {
  6268. $yc = $i . '条异常';
  6269. }
  6270. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6271. exit;
  6272. }
  6273. }
  6274. public function _uck()
  6275. {
  6276. if (isset($_GET['excel'])) {
  6277. $tc = array();
  6278. $typeclass = $this->typeclass->find_all();
  6279. foreach ($typeclass as $v) {
  6280. $tc[$v['id']] = $v['zh'];
  6281. }
  6282. $data = array();
  6283. $t = array();
  6284. $rq = '';
  6285. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6286. $ts = $ts / (24 * 3600);
  6287. for ($i = 0; $i < $ts; $i++) {
  6288. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6289. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6290. }
  6291. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6292. foreach ($info_list as $k => $v) {
  6293. $features = explode('-', trim($v['features'], '-'));
  6294. if (!isset($features[3]) || !isset($features[4])) {
  6295. continue;
  6296. }
  6297. $data[$k][0] = $tc[$features[0]]; //类型
  6298. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6299. $data[$k][2] = $tc[$features[4]]; //曲度
  6300. $data[$k][3] = '';
  6301. if (isset($data[$k][1])) {
  6302. $data[$k][3] .= $data[$k][1];
  6303. }
  6304. if (isset($data[$k][2])) {
  6305. $data[$k][3] .= $data[$k][2];
  6306. }
  6307. if (isset($features[5])) {
  6308. $data[$k][3] .= $tc[$features[5]];
  6309. }
  6310. if (isset($features[2])) {
  6311. $data[$k][3] .= $tc[$features[2]];
  6312. }
  6313. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6314. $data[$k][4] = $v['sku'];
  6315. $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())) . '))'); //月初库存
  6316. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6317. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6318. $ztrq = '';
  6319. $ztsl = '';
  6320. if (count($zt) > 0) {
  6321. foreach ($zt as $vv) {
  6322. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6323. $ztsl .= $vv['num'] . '<br>';
  6324. }
  6325. }
  6326. $data[$k][] = trim($ztsl, '<br>');
  6327. $data[$k][] = trim($ztrq, '<br>');
  6328. $byck = 0;
  6329. foreach ($t as $vv) {
  6330. $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));
  6331. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6332. $byck += $sl;
  6333. }
  6334. $data[$k][] = ($byck > 0) ? $byck : '';
  6335. }
  6336. $title = "详情 " . date("Y-m-d", time());
  6337. $titlename = "<table border=1>
  6338. <tr align='center'>
  6339. <td>类别</td>
  6340. <td>颜色</td>
  6341. <td>曲度</td>
  6342. <td>名称</td>
  6343. <td>SKU</td>
  6344. <td>月初库存</td>
  6345. <td>剩余库存</td>
  6346. <td>在途数量</td>
  6347. <td>预达日期</td>" .
  6348. $rq
  6349. . "<td>本月出库</td></tr>
  6350. </table>";
  6351. $filename = $title . ".xls";
  6352. $tail = "";
  6353. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6354. }
  6355. }
  6356. public function _whlabelexcelzh()
  6357. {
  6358. if (isset($_GET['excel'])) {
  6359. $where = "sku != 'Preset'";
  6360. //数据排序
  6361. $order_str = "id desc";
  6362. if (empty($page)) {
  6363. $start = 0;
  6364. $perpage = 1;
  6365. } else {
  6366. $start = ($page - 1) * $perpage;
  6367. }
  6368. $category = $this->input->get('category', true);
  6369. $warehouse = $this->input->get('warehouse', true);
  6370. $excelid = $this->input->get('sid', true);
  6371. if ($category) {
  6372. $where .= " and features like '%-$category-%'";
  6373. }
  6374. if ($warehouse) {
  6375. $where .= " and warehouse = '$warehouse'";
  6376. }
  6377. $xzid = '';
  6378. if ($excelid) {
  6379. $excelid = explode(',', trim($excelid, ','));
  6380. foreach ($excelid as $key => $value) {
  6381. $xzid .= " id = " . $value . " or";
  6382. }
  6383. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6384. }
  6385. //取得信息列表
  6386. /**
  6387. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6388. $rows = array();$list = array();
  6389. foreach ($info_list as $key=>$value)
  6390. {
  6391. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6392. }
  6393. **/
  6394. $list = array();
  6395. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6396. foreach ($rows as $key => $value) {
  6397. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6398. $zh = '';
  6399. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6400. foreach ($zt as $v) {
  6401. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6402. }
  6403. $zt = array_sum(array_column($zt, 'num'));
  6404. $number = $value['number'];
  6405. $ftime = time() - 15 * 24 * 3600;
  6406. $warehouse = $this->warehouse->read($value['warehouse']);
  6407. $rows[$key]['warehouse'] = $warehouse['title'];
  6408. $rows[$key]['number'] = $c;
  6409. $rows[$key]['features'] = $zh;
  6410. $rows[$key]['hb'] = $c + $zt;
  6411. }
  6412. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6413. $titlename = "<table border=1>
  6414. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6415. <tr align='center'>
  6416. <td>仓库</td>
  6417. <td>SKU</td>
  6418. <td>产品</td>
  6419. <td>库存数量</td>
  6420. <td>在途数量及预达日期</td>
  6421. <td>在途+库存数量</td>
  6422. </tr>
  6423. </table>";
  6424. $filename = $title . ".xls";
  6425. $tail = "";
  6426. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6427. }
  6428. if (isset($_GET['excel'])) {
  6429. $warehouse = $this->input->get('warehouse', true);
  6430. $sku = $this->input->get('sku', true);
  6431. $cz = $this->input->get('cz', true);
  6432. $text = $this->input->post('text', true);
  6433. $xztime = $this->input->get('xztime', true);
  6434. $timetk = $this->input->get('timetk', true);
  6435. $timetj = $this->input->get('timetj', true);
  6436. $timetk = strtotime($timetk);
  6437. $timetj = strtotime($timetj);
  6438. $where = "time = '0' ";
  6439. if ($warehouse) {
  6440. $where .= " and warehouse = '$warehouse'";
  6441. }
  6442. if ($sku) {
  6443. $where .= " and sku = '$sku'";
  6444. }
  6445. if ($text) {
  6446. $where .= " and text like '%$text%'";
  6447. }
  6448. if ($cz != '') {
  6449. $where .= " and cz = '$cz'";
  6450. }
  6451. if ($timetk && $timetj) {
  6452. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6453. }
  6454. //数据排序
  6455. $order_str = $xztime . " desc";
  6456. //取得信息列表
  6457. $zh = array();
  6458. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6459. foreach ($info_list as $v) {
  6460. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6461. $warehouse = $this->warehouse->read($v['warehouse']);
  6462. $v['warehouse'] = $warehouse['title'];
  6463. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6464. $v['stime'] = date('Y-m-d', $v['stime']);
  6465. if (isset($zh[$v['features']])) {
  6466. $zh[$v['features']]['num'] += $v['num'];
  6467. } else {
  6468. $zh[$v['features']] = $v;
  6469. }
  6470. $zh[$v['features']]['features'] = $c;
  6471. }
  6472. $title = "在途数据" . date('Y-m-d', time());
  6473. $titlename = "<table border=1>
  6474. <tr align='center'>
  6475. <td>仓库</td>
  6476. <td>SKU</td>
  6477. <td>名称</td>
  6478. <td>在途数量</td>
  6479. <td>库存数量</td>
  6480. <td>添加在途日期</td>
  6481. <td>预达日期</td>
  6482. <td>备注</td>
  6483. </tr>
  6484. </table>";
  6485. $filename = $title . ".xls";
  6486. $tail = "";
  6487. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6488. }
  6489. }
  6490. public function _fc()
  6491. {
  6492. $vip = 0;
  6493. if (isset($_SESSION['api'])) {
  6494. $user = $this->user->get_api($_SESSION['api']);
  6495. if ($user['vip'] == 1) {
  6496. $vip = 1;
  6497. }
  6498. } else {
  6499. header('Location: /');
  6500. exit;
  6501. }
  6502. $post = $this->input->post(NULL, TRUE);
  6503. if (isset($post['page'])) {
  6504. $page = $this->input->post('page', true);
  6505. $perpage = $this->input->post('perpage', true);
  6506. $category = $this->input->post('category', true);
  6507. $size = $this->input->post('size', true);
  6508. $grade = $this->input->post('grade', true);
  6509. $color = $this->input->post('color', true);
  6510. $lowe = $this->input->post('lowe', true);
  6511. $sku = $this->input->post('sku');
  6512. $title = $this->input->post('title');
  6513. $warehouse = $this->input->post('warehouse', true);
  6514. $usa = $this->input->post('usa', true);
  6515. $purchase = $this->input->post('purchase', true);
  6516. $lacetype = $this->input->post('lacetype', true);
  6517. $haircap = $this->input->post('haircap', true);
  6518. $density = $this->input->post('density', true);
  6519. $details = $this->input->post('details', true);
  6520. $state = $this->input->post('state', true);
  6521. $ktime = $this->input->post('ktime', true);
  6522. $jtime = $this->input->post('jtime', true);
  6523. $ktime = strtotime($ktime);
  6524. $jtime = strtotime($jtime);
  6525. $where = "state = '11'";
  6526. $gj = "";
  6527. $ck = "";
  6528. if ($lacetype) {
  6529. $where .= " and features like '%-$lacetype-%'";
  6530. }
  6531. if ($category) {
  6532. $where .= " and features like '%-$category-%'";
  6533. }
  6534. if ($size) {
  6535. $where .= " and features like '%-$size-%'";
  6536. }
  6537. if ($grade) {
  6538. $where .= " and features like '%-$grade-%'";
  6539. }
  6540. if ($color) {
  6541. $where .= " and features like '%-$color-%'";
  6542. }
  6543. if ($lowe) {
  6544. $where .= " and features like '%-$lowe-%'";
  6545. }
  6546. if ($haircap) {
  6547. $where .= " and features like '%-$haircap-%'";
  6548. }
  6549. if ($density) {
  6550. $where .= " and features like '%-$density-%'";
  6551. }
  6552. if ($usa) {
  6553. if (!$warehouse) {
  6554. $where .= " and (warehouse = '5' or warehouse = '8')";
  6555. }
  6556. }
  6557. if ($warehouse) {
  6558. $where .= " and warehouse = '$warehouse'";
  6559. }
  6560. if ($details) {
  6561. $where .= " and details = '$details'";
  6562. }
  6563. if ($purchase) {
  6564. $where .= " and purchase = '$purchase'";
  6565. }
  6566. if ($state) {
  6567. $where .= " and state = '$state'";
  6568. }
  6569. if ($ktime && $jtime) {
  6570. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6571. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6572. }
  6573. //数据排序
  6574. $order_str = "id desc";
  6575. if (empty($page)) {
  6576. $start = 0;
  6577. $perpage = 1;
  6578. } else {
  6579. $start = ($page - 1) * $perpage;
  6580. }
  6581. if ($sku) {
  6582. $sku = trim($sku, ' ');
  6583. $sku = trim($sku, ' ');
  6584. $where .= " and sku like '%$sku%'";
  6585. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6586. } else if ($title) {
  6587. $title = trim($title, ' ');
  6588. $title = trim($title, ' ');
  6589. $where .= " and title like '%$title%'";
  6590. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6591. } else {
  6592. //$where .= " and time > '$ktime' and time < '$jtime'";
  6593. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6594. }
  6595. //取得信息列表
  6596. $rows = array();
  6597. $list = array();
  6598. foreach ($info_list as $key => $value) {
  6599. $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'] . '"');
  6600. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6601. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6602. $warehouse = $this->warehouse->read($value['warehouse']);
  6603. $info_list[$key]['warehouse'] = $warehouse['title'];
  6604. $info_list[$key]['number'] = $g;
  6605. $info_list[$key]['features'] = $x;
  6606. $info_list[$key]['x'] = $s;
  6607. }
  6608. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6609. $pagenum = ceil($total / $perpage);
  6610. $over = $total - ($start + $perpage);
  6611. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6612. echo json_encode($rows);
  6613. exit;
  6614. }
  6615. $this->data['vip'] = $vip;
  6616. $this->_Template('whlabel_fc', $this->data);
  6617. }
  6618. public function _fcmb()
  6619. {
  6620. $where = "sku != 'Preset'";
  6621. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6622. foreach ($rows as $k => $v) {
  6623. $warehouse = $this->warehouse->read($v['warehouse']);
  6624. $rows[$k]['warehouse'] = $warehouse['title'];
  6625. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6626. $rows[$k]['t'] = '';
  6627. $rows[$k]['n'] = '';
  6628. }
  6629. $title = "封货产品数据导入模板";
  6630. $titlename = "<table border=1>
  6631. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6632. <tr align='center'>
  6633. <td>仓库</td>
  6634. <td>SKU</td>
  6635. <td>产品</td>
  6636. <td>封存产品总数量</td>
  6637. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6638. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6639. </tr>
  6640. </table>";
  6641. $filename = $title . ".xls";
  6642. $tail = "";
  6643. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6644. }
  6645. public function _fcexcel()
  6646. {
  6647. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6648. $config['upload_path'] = '.' . $dir;
  6649. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6650. $config['allowed_types'] = 'xls|xlsx|csv';
  6651. $config['max_size'] = 10240;
  6652. $this->load->library('upload', $config);
  6653. $this->upload->initialize($config);
  6654. if ($this->upload->do_upload('userfile')) {
  6655. $full_path = $dir . $this->upload->data('file_name');
  6656. $fileName = '.' . $full_path;
  6657. if (!file_exists($fileName)) {
  6658. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6659. exit;
  6660. } else {
  6661. libxml_use_internal_errors(true);
  6662. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6663. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6664. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6665. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6666. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6667. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6668. ++$column; //如果列数大于26行
  6669. $list = array();
  6670. for ($i = 2; $i <= $row; $i++) // 行数循环
  6671. {
  6672. $data = array();
  6673. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6674. {
  6675. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6676. }
  6677. $list[] = $data;
  6678. }
  6679. }
  6680. $i = 0;
  6681. $j = 0;
  6682. $ed = array();
  6683. foreach ($list as $key => $value) {
  6684. $time = time();
  6685. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6686. continue;
  6687. }
  6688. $warehouse = $this->warehouse->get_title($value['0']);
  6689. $sku = $value['1'];
  6690. $type = $value['4']; //调整方式0扣减1删除
  6691. $num = $value['5']; //调整数量
  6692. //$text = $value['4'];//扣减说明
  6693. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6694. if (!$d) //如果没有这个SKU
  6695. {
  6696. $ed[] = array($sku . '-库存中不存在此SKU');
  6697. $j++;
  6698. continue;
  6699. }
  6700. if (!isset($warehouse['id'])) {
  6701. $ed[] = array($sku . '-仓库名错误!');
  6702. $j++;
  6703. continue;
  6704. }
  6705. if ($type == 1 || $type == 2) //扣减库存
  6706. {
  6707. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6708. if (count($data) < abs($num)) {
  6709. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6710. $j++;
  6711. continue;
  6712. }
  6713. if ($type == 1) //转入库存
  6714. {
  6715. for ($i = 0; $i < abs($num); $i++) {
  6716. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6717. }
  6718. } else if ($type == 2) //删除
  6719. {
  6720. for ($i = 0; $i < abs($num); $i++) {
  6721. $this->whlabel->remove($data[$i]['id']);
  6722. }
  6723. }
  6724. } else if ($type == 0) //增加库存
  6725. {
  6726. $post['sku'] = $d['sku'];
  6727. $post['shop'] = '';
  6728. $post['warehouse'] = $warehouse['id'];
  6729. $post['purchase'] = $d['purchase'];
  6730. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6731. $post['state'] = 11;
  6732. $post['title'] = $d['title'];
  6733. $post['number'] = $d['number'];
  6734. $post['features'] = $d['features'];
  6735. $post['enter'] = $time;
  6736. $post['time'] = $time; //操作时间
  6737. for ($i = 0; $i < $num; $i++) {
  6738. $post['label'] = time() . rand(100, 999) . $i;
  6739. $this->whlabel->insert($post);
  6740. }
  6741. }
  6742. sleep(1); //防止入库时间一样,需要延迟1秒
  6743. }
  6744. if ($j > 0) {
  6745. $tt = date('Ymd', time());
  6746. $title = '库存导入错误信息-' . $tt;
  6747. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6748. $tail = "\n";
  6749. $filename = $title . ".xls";
  6750. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6751. $dir = '/data/excel/' . $time . '/';
  6752. $file_name = 'error_' . $time . rand(1000, 9999);
  6753. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6754. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6755. fwrite($myfile, $ecl);
  6756. fclose($myfile);
  6757. $error = $dir . $file_name . '.xls';
  6758. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6759. exit;
  6760. } else {
  6761. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6762. exit;
  6763. }
  6764. }
  6765. }
  6766. public function _fcjxc($arg_array)
  6767. {
  6768. if (isset($_GET['excel'])) {
  6769. $category = $this->input->get('category', true);
  6770. $size = $this->input->get('size', true);
  6771. $grade = $this->input->get('grade', true);
  6772. $color = $this->input->get('color', true);
  6773. $lowe = $this->input->get('lowe', true);
  6774. $sku = $this->input->get('sku');
  6775. $title = $this->input->get('title');
  6776. $warehouse = $arg_array[0];
  6777. $usa = $this->input->get('usa', true);
  6778. $purchase = $this->input->get('purchase', true);
  6779. $lacetype = $this->input->get('lacetype', true);
  6780. $haircap = $this->input->get('haircap', true);
  6781. $density = $this->input->get('density', true);
  6782. $title = $this->input->get('title', true);
  6783. $state = $this->input->get('state', true);
  6784. $ktime = $this->input->get('ktime', true);
  6785. $jtime = $this->input->get('jtime', true);
  6786. $where = "state=11";
  6787. $gj = "";
  6788. $ck = "";
  6789. if ($lacetype) {
  6790. $where .= " and features like '%-$lacetype-%'";
  6791. }
  6792. if ($category) {
  6793. $where .= " and features like '%-$category-%'";
  6794. }
  6795. if ($size) {
  6796. $where .= " and features like '%-$size-%'";
  6797. }
  6798. if ($grade) {
  6799. $where .= " and features like '%-$grade-%'";
  6800. }
  6801. if ($color) {
  6802. $where .= " and features like '%-$color-%'";
  6803. }
  6804. if ($lowe) {
  6805. $where .= " and features like '%-$lowe-%'";
  6806. }
  6807. if ($haircap) {
  6808. $where .= " and features like '%-$haircap-%'";
  6809. }
  6810. if ($density) {
  6811. $where .= " and features like '%-$density-%'";
  6812. }
  6813. if ($usa) {
  6814. if (!$warehouse) {
  6815. $where .= " and (warehouse = '5' or warehouse = '8')";
  6816. }
  6817. }
  6818. if ($warehouse) {
  6819. $where .= " and warehouse = '$warehouse'";
  6820. }
  6821. if ($purchase) {
  6822. $where .= " and purchase = '$purchase'";
  6823. }
  6824. if ($state) {
  6825. $where .= " and state = '$state'";
  6826. }
  6827. $order_str = "id desc";
  6828. if ($sku) {
  6829. $sku = trim($sku, ' ');
  6830. $sku = trim($sku, ' ');
  6831. $where .= " and sku like '%$sku%'";
  6832. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6833. } else if ($title) {
  6834. $title = trim($title, ' ');
  6835. $title = trim($title, ' ');
  6836. $where .= " and title like '%$title%'";
  6837. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6838. } else {
  6839. //$where .= " and time > '$ktime' and time < '$jtime'";
  6840. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6841. }
  6842. //取得信息列表
  6843. $rows = array();
  6844. $list = array();
  6845. foreach ($info_list as $key => $value) {
  6846. $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'] . '"');
  6847. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6848. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6849. $rows[$key] = $value;
  6850. $warehouse = $this->warehouse->read($value['warehouse']);
  6851. $rows[$key]['warehouse'] = $warehouse['title'];
  6852. $rows[$key]['features'] = $g;
  6853. $rows[$key]['a'] = $x;
  6854. $rows[$key]['b'] = $s;
  6855. }
  6856. $title = "总统计表";
  6857. $titlename = "<table border=1>
  6858. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6859. <tr align='center'>
  6860. <td>仓库</td>
  6861. <td>SKU</td>
  6862. <td>产品名称</td>
  6863. <td>录入总量</td>
  6864. <td>取出总量</td>
  6865. <td>剩余总量</td>
  6866. </tr>
  6867. </table>";
  6868. $filename = $title . ".xls";
  6869. $tail = "";
  6870. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6871. }
  6872. $vip = 0;
  6873. if (isset($_SESSION['api'])) {
  6874. $user = $this->user->get_api($_SESSION['api']);
  6875. if ($user['vip'] == 1) {
  6876. $vip = 1;
  6877. }
  6878. } else {
  6879. header('Location: /');
  6880. exit;
  6881. }
  6882. $post = $this->input->post(NULL, TRUE);
  6883. if (isset($post['page'])) {
  6884. $page = $this->input->post('page', true);
  6885. $perpage = $this->input->post('perpage', true);
  6886. $category = $this->input->post('category', true);
  6887. $size = $this->input->post('size', true);
  6888. $grade = $this->input->post('grade', true);
  6889. $color = $this->input->post('color', true);
  6890. $lowe = $this->input->post('lowe', true);
  6891. $sku = $this->input->post('sku');
  6892. $title = $this->input->post('title');
  6893. $warehouse = $arg_array[0];
  6894. $usa = $this->input->post('usa', true);
  6895. $purchase = $this->input->post('purchase', true);
  6896. $lacetype = $this->input->post('lacetype', true);
  6897. $haircap = $this->input->post('haircap', true);
  6898. $density = $this->input->post('density', true);
  6899. $title = $this->input->post('title', true);
  6900. $state = $this->input->post('state', true);
  6901. $ktime = $this->input->post('ktime', true);
  6902. $jtime = $this->input->post('jtime', true);
  6903. $ktime = strtotime($ktime);
  6904. $jtime = strtotime($jtime);
  6905. $where = "state=11";
  6906. $gj = "";
  6907. $ck = "";
  6908. if ($lacetype) {
  6909. $where .= " and features like '%-$lacetype-%'";
  6910. }
  6911. if ($category) {
  6912. $where .= " and features like '%-$category-%'";
  6913. }
  6914. if ($size) {
  6915. $where .= " and features like '%-$size-%'";
  6916. }
  6917. if ($grade) {
  6918. $where .= " and features like '%-$grade-%'";
  6919. }
  6920. if ($color) {
  6921. $where .= " and features like '%-$color-%'";
  6922. }
  6923. if ($lowe) {
  6924. $where .= " and features like '%-$lowe-%'";
  6925. }
  6926. if ($haircap) {
  6927. $where .= " and features like '%-$haircap-%'";
  6928. }
  6929. if ($density) {
  6930. $where .= " and features like '%-$density-%'";
  6931. }
  6932. if ($usa) {
  6933. if (!$warehouse) {
  6934. $where .= " and (warehouse = '5' or warehouse = '8')";
  6935. }
  6936. }
  6937. if ($warehouse) {
  6938. $where .= " and warehouse = '$warehouse'";
  6939. }
  6940. if ($purchase) {
  6941. $where .= " and purchase = '$purchase'";
  6942. }
  6943. if ($state) {
  6944. $where .= " and state = '$state'";
  6945. }
  6946. if ($ktime && $jtime) {
  6947. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6948. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6949. }
  6950. //数据排序
  6951. $order_str = "id desc";
  6952. $xs = 0;
  6953. $rows = array();
  6954. $list = array();
  6955. if (empty($page)) {
  6956. $start = 0;
  6957. $perpage = 1;
  6958. } else {
  6959. $start = ($page - 1) * $perpage;
  6960. }
  6961. if ($sku || $title) {
  6962. if ($title) {
  6963. $title = trim($title, ' ');
  6964. $title = trim($title, ' ');
  6965. $where .= " and title like '%$title%'";
  6966. } else {
  6967. $sku = trim($sku, ' ');
  6968. $sku = trim($sku, ' ');
  6969. $where .= " and sku like '%$sku%'";
  6970. }
  6971. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6972. foreach ($info_list as $key => $value) {
  6973. $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'] . '"');
  6974. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6975. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6976. $rows[$key] = $value;
  6977. $warehouse = $this->warehouse->read($value['warehouse']);
  6978. $rows[$key]['warehouse'] = $warehouse['title'];
  6979. $rows[$key]['features'] = $g;
  6980. $rows[$key]['a'] = $x;
  6981. $rows[$key]['b'] = $s;
  6982. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6983. $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天销量
  6984. $yj = $c / ($xl / 30);
  6985. if ($yj < 7) {
  6986. $rows[$key]['y'] = round($yj) . '天销量';
  6987. } else {
  6988. $rows[$key]['y'] = '正常';
  6989. }
  6990. }
  6991. } else {
  6992. //$where .= " and time > '$ktime' and time < '$jtime'";
  6993. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6994. foreach ($info_list as $key => $value) {
  6995. $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'] . '"');
  6996. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6997. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6998. $zs[$key] = $value;
  6999. $warehouse = $this->warehouse->read($value['warehouse']);
  7000. $zs[$key]['warehouse'] = $warehouse['title'];
  7001. $zs[$key]['features'] = $g;
  7002. $zs[$key]['a'] = $x;
  7003. $zs[$key]['b'] = $s;
  7004. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7005. $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天销量
  7006. $yj = $c / ($xl / 30);
  7007. if ($yj < 7) {
  7008. $zs[$key]['y'] = round($yj) . '天销量';
  7009. $rows[$key] = $zs[$key];
  7010. }
  7011. }
  7012. }
  7013. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7014. $pagenum = ceil($total / $perpage);
  7015. $over = $total - ($start + $perpage);
  7016. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7017. echo json_encode($rows);
  7018. exit;
  7019. }
  7020. $this->data['arg_array'] = $arg_array[0];
  7021. $this->_Template('whlabel_fcjxc', $this->data);
  7022. }
  7023. public function _0kcdel()
  7024. {
  7025. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7026. $config['upload_path'] = '.' . $dir;
  7027. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7028. $config['allowed_types'] = 'xls|xlsx|csv';
  7029. $config['max_size'] = 10240;
  7030. $this->load->library('upload', $config);
  7031. $this->upload->initialize($config);
  7032. if ($this->upload->do_upload('userfile')) {
  7033. $full_path = $dir . $this->upload->data('file_name');
  7034. $fileName = '.' . $full_path;
  7035. if (!file_exists($fileName)) {
  7036. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7037. exit;
  7038. } else {
  7039. require_once "./data/excel/PHPExcel/IOFactory.php";
  7040. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7041. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7042. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7043. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7044. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7045. ++$column; //如果列数大于26行
  7046. $list = array();
  7047. for ($i = 2; $i <= $row; $i++) // 行数循环
  7048. {
  7049. $data = array();
  7050. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7051. {
  7052. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7053. }
  7054. $list[] = $data;
  7055. }
  7056. }
  7057. $i = 0;
  7058. $j = 0;
  7059. $ed = array();
  7060. foreach ($list as $key => $value) {
  7061. $time = time();
  7062. if ($value['0'] == "" || $value['1'] == "") {
  7063. continue;
  7064. }
  7065. $warehouse = $this->warehouse->get_title($value['0']);
  7066. $sku = $value['1'];
  7067. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7068. if (!$d) //如果没有这个SKU
  7069. {
  7070. $ed[] = array($sku . '-库存中不存在此SKU');
  7071. $j++;
  7072. continue;
  7073. }
  7074. if (!isset($warehouse['id'])) {
  7075. $ed[] = array($sku . '-仓库名错误!');
  7076. $j++;
  7077. continue;
  7078. }
  7079. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7080. if ($z < 1) {
  7081. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7082. foreach ($z as $v) {
  7083. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7084. if (count($zt) > 0) {
  7085. $ed[] = array($sku . '-有在途库存无法删除!');
  7086. $j++;
  7087. continue;
  7088. }
  7089. $this->whlabel->remove($v['id']);
  7090. }
  7091. } else {
  7092. $ed[] = array($sku . '-非0库存!');
  7093. $j++;
  7094. continue;
  7095. }
  7096. }
  7097. if ($j > 0) {
  7098. $tt = date('Ymd', time());
  7099. $title = '删除0库存错误信息-' . $tt;
  7100. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7101. $tail = "\n";
  7102. $filename = $title . ".xls";
  7103. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7104. $dir = '/data/excel/' . $time . '/';
  7105. $file_name = 'error_' . $time . rand(1000, 9999);
  7106. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7107. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7108. fwrite($myfile, $ecl);
  7109. fclose($myfile);
  7110. $error = $dir . $file_name . '.xls';
  7111. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7112. exit;
  7113. } else {
  7114. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7115. exit;
  7116. }
  7117. }
  7118. }
  7119. public function _gbhtype()
  7120. {
  7121. $post = $this->input->post(NULL, TRUE);
  7122. if (isset($post['s'])) {
  7123. $n = $this->input->post('n');
  7124. $d = $this->input->post('s');
  7125. if (!$d) {
  7126. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7127. exit;
  7128. }
  7129. $d = explode(',', trim($d, ','));
  7130. $t = $this->whlabel_type->read($n);
  7131. //循环删除记录
  7132. foreach ($d as $v) {
  7133. $u = $this->whlabel->read($v);
  7134. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7135. foreach ($data as $val) {
  7136. $this->whlabel->save(array('type' => $n), $val['id']);
  7137. }
  7138. }
  7139. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7140. }
  7141. }
  7142. //出库、退库导出
  7143. public function _dccrtype()
  7144. {
  7145. $classid = $this->classid->sku();
  7146. $pm = $classid;
  7147. $typeclass = array();
  7148. $tc = $this->typeclass->find_all();
  7149. foreach ($tc as $v) {
  7150. $typeclass[$v['id']] = $v;
  7151. }
  7152. $prc = array();
  7153. $purchase = $this->purchase->find_all();
  7154. foreach ($purchase as $k => $v) {
  7155. $prc[$v['id']] = $v['title'];
  7156. }
  7157. if (isset($_GET['sid'])) {
  7158. $wh = array();
  7159. $w = $this->warehouse->find_all('1=1', 'id,title');
  7160. foreach ($w as $v) {
  7161. $wh[$v['id']] = $v['title'];
  7162. }
  7163. $type = $this->input->get('excel', true);
  7164. $category = $this->input->get('category', true);
  7165. $size = $this->input->get('size', true);
  7166. $grade = $this->input->get('grade', true);
  7167. $color = $this->input->get('color', true);
  7168. $lowe = $this->input->get('lowe', true);
  7169. $sku = $this->input->get('sku', true);
  7170. $warehouse = $this->input->get('warehouse', true);
  7171. $lacetype = $this->input->get('lacetype', true);
  7172. $lacecolor = $this->input->get('lacecolor', true);
  7173. $density = $this->input->get('density', true);
  7174. $haircap = $this->input->get('haircap', true);
  7175. $purchase = $this->input->get('purchase', true);
  7176. $title = $this->input->get('title', true);
  7177. $state = $this->input->get('state', true);
  7178. $sid = $this->input->get('sid', true);
  7179. $ktime = $this->input->get('ktime', true);
  7180. $jtime = $this->input->get('jtime', true);
  7181. $ktime = strtotime($ktime);
  7182. $jtime = strtotime($jtime);
  7183. $where = "1=1";
  7184. $gj = "";
  7185. $ck = "";
  7186. if ($category) {
  7187. $where .= " and features like '%-$category-%'";
  7188. }
  7189. if ($size) {
  7190. $where .= " and features like '%-$size-%'";
  7191. }
  7192. if ($grade) {
  7193. $where .= " and features like '%-$grade-%'";
  7194. }
  7195. if ($color) {
  7196. $where .= " and features like '%-$color-%'";
  7197. }
  7198. if ($lowe) {
  7199. $where .= " and features like '%-$lowe-%'";
  7200. }
  7201. if ($warehouse) {
  7202. $where .= " and warehouse = '$warehouse'";
  7203. }
  7204. if ($purchase) {
  7205. $where .= " and purchase = '$purchase'";
  7206. }
  7207. if ($state) {
  7208. $where .= " and state = '$state'";
  7209. }
  7210. if ($lacetype) {
  7211. $where .= " and features like '%-$lacetype-%'";
  7212. }
  7213. if ($lacecolor) {
  7214. $where .= " and features like '%-$lacecolor-%'";
  7215. }
  7216. if ($density) {
  7217. $where .= " and features like '%-$density-%'";
  7218. }
  7219. if ($haircap) {
  7220. $where .= " and features like '%-$haircap-%'";
  7221. }
  7222. if ($title) {
  7223. $title = trim($title, ' ');
  7224. $title = trim($title, ' ');
  7225. $where .= " and title like '%$title%'";
  7226. }
  7227. if ($sku) {
  7228. $sku = trim($sku, ' ');
  7229. $sku = trim($sku, ' ');
  7230. $where .= " and sku like '%$sku%'";
  7231. }
  7232. if ($ktime && $jtime) {
  7233. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7234. }
  7235. $sidwhere = '';
  7236. if ($sid) {
  7237. $sd = "";
  7238. $s = explode(',', trim($sid, ','));
  7239. foreach ($s as $value) {
  7240. $sd .= " id = " . $value . " or";
  7241. }
  7242. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7243. }
  7244. //数据排序
  7245. $order_str = "time desc";
  7246. if (empty($page)) {
  7247. $start = 0;
  7248. $perpage = 1;
  7249. } else {
  7250. $start = ($page - 1) * $perpage;
  7251. }
  7252. $wh = array();
  7253. $w = $this->warehouse->find_all('1=1', 'id,title');
  7254. foreach ($w as $v) {
  7255. $wh[$v['id']] = $v['title'];
  7256. }
  7257. $wt = array();
  7258. $whlabel_type = $this->whlabel_type->find_all();
  7259. foreach ($whlabel_type as $v) {
  7260. $wt[$v['id']] = $v['title'];
  7261. }
  7262. $classid = $this->classid->sku();
  7263. $list = array();
  7264. $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');
  7265. foreach ($rows_r as $key => $value) {
  7266. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7267. $pm = $classid;
  7268. $jm = $classid;
  7269. $rows_r[$key]['enter'] = '入库';
  7270. $rows_r[$key]['time'] = $value['enter'];
  7271. if ($value['rktype'] == 1) {
  7272. $rows_r[$key]['rktype'] = '采购入库';
  7273. } else if ($value['rktype'] == 2) {
  7274. $rows_r[$key]['rktype'] = '盘盈调整';
  7275. } else if ($value['rktype'] == 3) {
  7276. $rows_r[$key]['rktype'] = '其他调整入库';
  7277. } else if ($value['rktype'] == 4) {
  7278. $rows_r[$key]['rktype'] = '其他调整入库';
  7279. } else if ($value['rktype'] == 5) {
  7280. $rows_r[$key]['rktype'] = '退库入库';
  7281. } else if ($value['rktype'] == 6) {
  7282. $rows_r[$key]['rktype'] = '退货可用入库';
  7283. } else if ($value['rktype'] == 7) {
  7284. $rows_r[$key]['rktype'] = '形态转换入库';
  7285. } else {
  7286. $rows_r[$key]['rktype'] = '';
  7287. }
  7288. $features = explode('-', trim($value['features'], '-'));
  7289. foreach ($features as $v) {
  7290. if (isset($typeclass[$v])) {
  7291. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7292. $pm[$typeclass[$v]['classid']] = $zh[0];
  7293. }
  7294. if (isset($typeclass[$v])) {
  7295. if (isset($jm[$typeclass[$v]['classid']])) {
  7296. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7297. }
  7298. }
  7299. }
  7300. $zh = implode(" ", $pm);
  7301. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7302. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7303. $rows_r[$key]['zh'] = $zh;
  7304. $jm = array_filter($jm);
  7305. $rows_r[$key]['features'] = implode("-", $jm);
  7306. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7307. }
  7308. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout,state');
  7309. foreach ($rows_c as $key => $value) {
  7310. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7311. $pm = $classid;
  7312. $jm = $classid;
  7313. $rows_c[$key]['time'] = $value['outk'];
  7314. $rows_c[$key]['outk'] = '出库';
  7315. if ($value['cktype'] == 1) {
  7316. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7317. } else if ($value['cktype'] == 2) {
  7318. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7319. } else if ($value['cktype'] == 3) {
  7320. $rows_c[$key]['cktype'] = '盘亏调整';
  7321. } else if ($value['cktype'] == 4) {
  7322. $rows_c[$key]['cktype'] = '其他调整出库';
  7323. } else if ($value['cktype'] == 5) {
  7324. $rows_c[$key]['cktype'] = '形态转换出库';
  7325. } else {
  7326. $rows_c[$key]['cktype'] = '';
  7327. }
  7328. unset($rows_c[$key]['state']);
  7329. $features = explode('-', trim($value['features'], '-'));
  7330. foreach ($features as $v) {
  7331. if (isset($typeclass[$v])) {
  7332. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7333. $pm[$typeclass[$v]['classid']] = $zh[0];
  7334. }
  7335. if (isset($typeclass[$v])) {
  7336. if (isset($jm[$typeclass[$v]['classid']])) {
  7337. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7338. }
  7339. }
  7340. }
  7341. $zh = implode(" ", $pm);
  7342. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7343. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7344. $rows_c[$key]['zh'] = $zh;
  7345. $jm = array_filter($jm);
  7346. $rows_c[$key]['features'] = implode("-", $jm);
  7347. $rows_c[$key]['number'] = 1;
  7348. }
  7349. $merged = $rows_r;
  7350. foreach ($rows_c as $key => $value) {
  7351. if (isset($merged[$key])) {
  7352. $merged[] = $value;
  7353. } else {
  7354. $merged[$key] = $value;
  7355. }
  7356. }
  7357. usort($merged, function ($a, $b) {
  7358. return $a['time'] - $b['time'];
  7359. });
  7360. foreach ($merged as $key => $value) {
  7361. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7362. }
  7363. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7364. $titlename = "<table border=1>
  7365. <tr align='center'>
  7366. <td>仓库</td>
  7367. <td>SKU</td>
  7368. <td>商品名称</td>
  7369. <td>仓库品名</td>
  7370. <td>料号</td>
  7371. <td>时间</td>
  7372. <td>操作</td>
  7373. <td>类型</td>
  7374. <td>数量</td>
  7375. <td>备注</td>
  7376. </tr>
  7377. </table>";
  7378. $filename = $title . ".xlsx";
  7379. $tail = "";
  7380. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7381. }
  7382. }
  7383. }