Whlabel.php 259 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. }
  45. //定义方法的调用规则 获取URI第二段值
  46. public function _remap($arg, $arg_array)
  47. {
  48. if ($arg == 'existence') //在库标签
  49. {
  50. $this->_existence();
  51. } else if ($arg == 'cpbqdc') //在库标签
  52. {
  53. $this->_cpbqdc();
  54. } else if ($arg == 'type') //进销存浏览
  55. {
  56. $this->_type();
  57. } else if ($arg == 'typedy') //进销存浏览店员页面
  58. {
  59. $this->_typedy($arg_array);
  60. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  61. {
  62. $this->_typedy_ck($arg_array);
  63. } else if ($arg == 'typeck') {
  64. $this->_typeck($arg_array);
  65. } else if ($arg == 'whlabeckdc') {
  66. $this->_whlabeckdc($arg_array);
  67. } else if ($arg == 'usatype') //美仓进销存浏览
  68. {
  69. $this->_usatype();
  70. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  71. {
  72. $this->_usatypeapp();
  73. } else if ($arg == 'enteradd') //入库操作
  74. {
  75. $this->_enteradd();
  76. } else if ($arg == 'enteredit') //修改
  77. {
  78. $this->_enteredit($arg_array);
  79. } else if ($arg == 'enter') //入库浏览
  80. {
  81. $this->_enter();
  82. } else if ($arg == 'out') //出库浏览
  83. {
  84. $this->_out();
  85. } else if ($arg == 'label') //出库标签浏览
  86. {
  87. $this->_label();
  88. } else if ($arg == 'outorder') //独立站出库订单
  89. {
  90. $this->_outorder();
  91. } else if ($arg == 'soutorder') //速卖通出库订单
  92. {
  93. $this->_soutorder();
  94. } else if ($arg == 'toutorder') //TT出库订单
  95. {
  96. $this->_toutorder();
  97. }else if ($arg == 'aoutorder') //amz出库订单
  98. {
  99. $this->_aoutorder();
  100. } else if ($arg == 'retreat') //退库订单
  101. {
  102. $this->_retreat();
  103. } else if ($arg == 'retreatlk') //退库订单
  104. {
  105. $this->_retreatlk();
  106. } else if ($arg == 'change') //更换标签
  107. {
  108. $this->_change();
  109. } else if ($arg == 'del') //删除
  110. {
  111. $this->_del();
  112. } else if ($arg == 'exceljxc') //进销存信息导出
  113. {
  114. $this->_exceljxc();
  115. } else if ($arg == 'excelr') //入库信息导出
  116. {
  117. $this->_excelr();
  118. } else if ($arg == 'excelct') //出库、退库信息导出
  119. {
  120. $this->_excelct();
  121. } else if ($arg == 'dccrtype') //根据出入库类型导出
  122. {
  123. $this->_dccrtype();
  124. } else if ($arg == 'excelcr') //出库、退库信息导出
  125. {
  126. $this->_excelcr();
  127. } else if ($arg == 'kcyz') //库存验证
  128. {
  129. $this->_kcyz();
  130. } else if ($arg == 'kj') //库存扣减
  131. {
  132. $this->_kj($arg_array);
  133. } else if ($arg == 'presetout') //预设库存导入
  134. {
  135. $this->_presetout($arg_array);
  136. } else if ($arg == 'presetedit') //预设库存导入
  137. {
  138. $this->_presetedit($arg_array);
  139. } else if ($arg == 'summary') //汇总导出
  140. {
  141. $this->_summary($arg_array);
  142. } else if ($arg == 'manifest') //usps发货清单
  143. {
  144. $this->_manifest();
  145. } else if ($arg == 'abnormal') //占单异常
  146. {
  147. $this->_abnormal();
  148. } else if ($arg == 'error') //0库存SKU
  149. {
  150. $this->_error();
  151. } else if ($arg == 'errorexcel') //0库存SKU导出
  152. {
  153. $this->_errorexcel();
  154. } else if ($arg == 'db') {
  155. $this->_db();
  156. } else if ($arg == 'dbrk') {
  157. $this->_dbrk();
  158. } else if ($arg == 'whlabelczdc') {
  159. $this->_whlabelczdc();
  160. } else if ($arg == 'print') {
  161. $this->_print($arg_array);
  162. } else if ($arg == 'usaprint') {
  163. $this->_usaprint($arg_array);
  164. } else if ($arg == 'printck') {
  165. $this->_printck($arg_array);
  166. } else if ($arg == 'printrk') {
  167. $this->_printrk($arg_array);
  168. } else if ($arg == 'printxzrk') {
  169. $this->_printxzrk($arg_array);
  170. } else if ($arg == 'printexcel') {
  171. $this->_printexcel($arg_array);
  172. } else if ($arg == 'uck') {
  173. $this->_uck();
  174. } else if ($arg == 'whlabelexcelzh') {
  175. $this->_whlabelexcelzh();
  176. } else if ($arg == 'fc') {
  177. $this->_fc();
  178. } else if ($arg == 'fcmb') {
  179. $this->_fcmb();
  180. } else if ($arg == 'fcexcel') {
  181. $this->_fcexcel();
  182. } else if ($arg == 'fcjxc') {
  183. $this->_fcjxc($arg_array);
  184. } else if ($arg == '0kcdel') {
  185. $this->_0kcdel(); //导表删除0库存
  186. } else if ($arg == 'gbhtype') {
  187. $this->_gbhtype(); //更改备货状态
  188. } else {
  189. $this->_index();
  190. }
  191. }
  192. //管理
  193. public function _index()
  194. {
  195. $post = $this->input->post(NULL, TRUE);
  196. if (isset($post['page'])) {
  197. $page = $this->input->post('page', true);
  198. $perpage = $this->input->post('perpage', true);
  199. $sku = $this->input->post('sku', true);
  200. $number = $this->input->post('number', true);
  201. $warehouse = $this->input->post('warehouse', true);
  202. $purchase = $this->input->post('purchase', true);
  203. $orderinfo = $this->input->post('orderinfo', true);
  204. $waybill = $this->input->post('waybill', true);
  205. $category = $this->input->post('category', true);
  206. $size = $this->input->post('size', true);
  207. $grade = $this->input->post('grade', true);
  208. $color = $this->input->post('color', true);
  209. $lowe = $this->input->post('lowe', true);
  210. $state = $this->input->post('state', true);
  211. $label = $this->input->post('label', true);
  212. $timetk = $this->input->post('timetkk', true);
  213. $timetj = $this->input->post('timetjj', true);
  214. $timetk = strtotime($timetk);
  215. $timetj = strtotime($timetj);
  216. $where = "1=1 ";
  217. if ($timetk && $timetj) {
  218. $where .= " and time > '$timetk' and time < '$timetj'";
  219. }
  220. if ($sku) {
  221. $where .= " and sku = '$sku'";
  222. }
  223. if ($number) {
  224. $where .= " and number = '$number'";
  225. }
  226. if ($warehouse) {
  227. $where .= " and warehouse = '$warehouse'";
  228. }
  229. if ($purchase) {
  230. $where .= " and purchase = '$purchase'";
  231. }
  232. if ($orderinfo) {
  233. $where .= " and orderinfo = '$orderinfo'";
  234. }
  235. if ($waybill) {
  236. $where .= " and waybill = '$waybill'";
  237. }
  238. if ($category) {
  239. $where .= " and features like '%-$category-%'";
  240. }
  241. if ($size) {
  242. $where .= " and features like '%-$size-%'";
  243. }
  244. if ($grade) {
  245. $where .= " and features like '%-$grade-%'";
  246. }
  247. if ($color) {
  248. $where .= " and features like '%-$color-%'";
  249. }
  250. if ($lowe) {
  251. $where .= " and features like '%-$lowe-%'";
  252. }
  253. if ($label) {
  254. $where .= " and label = '$label'";
  255. }
  256. if ($state != '') {
  257. $where .= " and state = '$state'";
  258. }
  259. //数据排序
  260. $order_str = "time desc";
  261. if (empty($page)) {
  262. $start = 0;
  263. $perpage = 1;
  264. } else {
  265. $start = ($page - 1) * $perpage;
  266. }
  267. //取得信息列表
  268. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,label,printing,enter,warehouse,outk,orderinfo,waybill,text,time', $order_str, $start, $perpage);
  269. foreach ($info_list as $key => $value) {
  270. $warehouse = $this->warehouse->read($value['warehouse']);
  271. $info_list[$key]['warehouse'] = $warehouse['title'];
  272. $purchase = $this->purchase->read($value['purchase']);
  273. $info_list[$key]['purchase'] = $purchase['title'];
  274. if ($value['enter'] != 0) {
  275. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  276. } else {
  277. $info_list[$key]['enter'] = "";
  278. }
  279. if ($value['outk'] != 0) {
  280. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  281. } else {
  282. $info_list[$key]['outk'] = "";
  283. }
  284. if ($value['printing'] != 0) {
  285. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  286. } else {
  287. $info_list[$key]['printing'] = "";
  288. }
  289. if ($value['orderinfo'] == 0) {
  290. $info_list[$key]['orderinfo'] = "";
  291. }
  292. if ($value['waybill'] == 0) {
  293. $info_list[$key]['waybill'] = "";
  294. }
  295. if ($value['state'] == 0) {
  296. $info_list[$key]['state'] = "在库";
  297. } else if ($value['state'] == 1) {
  298. $info_list[$key]['state'] = "出库";
  299. } else if ($value['state'] == 2) {
  300. $info_list[$key]['state'] = "退库";
  301. } else if ($value['state'] == 3) {
  302. $info_list[$key]['state'] = "调拨中";
  303. } else if ($value['state'] == 4) {
  304. $info_list[$key]['state'] = "再加工";
  305. } else if ($value['state'] == 5) {
  306. $info_list[$key]['state'] = "维修中";
  307. } else if ($value['state'] == 6) {
  308. $info_list[$key]['state'] = "盘亏";
  309. } else if ($value['state'] == 7) {
  310. $info_list[$key]['state'] = "更换标签";
  311. } else if ($value['state'] == 8) {
  312. $info_list[$key]['state'] = "其它";
  313. } else if ($value['state'] == 9) {
  314. $info_list[$key]['state'] = "预设";
  315. } else if ($value['state'] == 10) {
  316. $info_list[$key]['state'] = "美店零售";
  317. }
  318. if ($value['text'] == "") {
  319. $info_list[$key]['text'] = "";
  320. }
  321. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  322. }
  323. $total = $this->whlabel->find_count($where);
  324. $pagenum = ceil($total / $perpage);
  325. $over = $total - ($start + $perpage);
  326. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  327. echo json_encode($rows);
  328. exit;
  329. }
  330. if (isset($post['outsku'])) {
  331. $cz = $this->input->post('cz', true);
  332. if ($cz == '1') {
  333. $sku = $this->input->post('outsku', true);
  334. if ($sku) {
  335. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  336. if (count($data) < 1) {
  337. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  338. exit;
  339. }
  340. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 1), $data[0]['id']);
  341. echo json_encode(array('success' => true));
  342. exit;
  343. }
  344. } else {
  345. $sku = $this->input->post('outsku', true);
  346. if ($sku) {
  347. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  348. if (count($data) < 1) {
  349. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  350. exit;
  351. }
  352. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  353. echo json_encode(array('success' => true));
  354. exit;
  355. }
  356. }
  357. }
  358. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  359. $this->_Template('whlabel', $this->data);
  360. }
  361. //在库标签
  362. public function _existence()
  363. {
  364. $post = $this->input->post(NULL, TRUE);
  365. if (isset($post['s'])) {
  366. $id_arr = $this->input->post('s');
  367. $id_arr = explode(',', $id_arr);
  368. if (!$id_arr) {
  369. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  370. exit;
  371. }
  372. //循环删除记录
  373. foreach ($id_arr as $v) {
  374. $sid = $this->whlabel->read($v);
  375. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  376. if ($count > 0) {
  377. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  378. exit;
  379. }
  380. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  381. if (count($zt) > 0) {
  382. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  383. exit;
  384. }
  385. $this->whlabel->remove($v);
  386. }
  387. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  388. exit;
  389. }
  390. if (isset($post['page'])) {
  391. $page = $this->input->post('page', true);
  392. $perpage = $this->input->post('perpage', true);
  393. $warehouse = $this->input->post('warehouse', true);
  394. $label = $this->input->post('label', true);
  395. $where = "1=1 and state = 0";
  396. if ($warehouse) {
  397. $where .= " and warehouse = '$warehouse'";
  398. }
  399. if ($label) {
  400. $where .= " and label = '$label'";
  401. }
  402. //数据排序
  403. $order_str = "time asc";
  404. if (empty($page)) {
  405. $start = 0;
  406. $perpage = 1;
  407. } else {
  408. $start = ($page - 1) * $perpage;
  409. }
  410. //取得信息列表
  411. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  412. foreach ($info_list as $key => $value) {
  413. if ($value['enter'] != 0) {
  414. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  415. } else {
  416. $info_list[$key]['enter'] = "";
  417. }
  418. if ($value['printing'] != 0) {
  419. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  420. } else {
  421. $info_list[$key]['printing'] = "";
  422. }
  423. }
  424. $total = $this->whlabel->find_count($where);
  425. $pagenum = ceil($total / $perpage);
  426. $over = $total - ($start + $perpage);
  427. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  428. echo json_encode($rows);
  429. exit;
  430. }
  431. $this->_Template('whlabel_existence', $this->data);
  432. }
  433. //进销存浏览
  434. public function _typedy($arg_array)
  435. {
  436. $prc = array();
  437. $purchase = $this->purchase->find_all();
  438. foreach ($purchase as $k => $v) {
  439. $prc[$v['id']] = $v['title'];
  440. }
  441. $post = $this->input->post(NULL, TRUE);
  442. if (isset($post['page'])) {
  443. $page = $this->input->post('page', true);
  444. $perpage = $this->input->post('perpage', true);
  445. $category = $this->input->post('category', true);
  446. $size = $this->input->post('size', true);
  447. $grade = $this->input->post('grade', true);
  448. $color = $this->input->post('color', true);
  449. $lowe = $this->input->post('lowe', true);
  450. $sku = $this->input->post('sku');
  451. $title = $this->input->post('title');
  452. $warehouse = $this->input->post('warehouse', true);
  453. $usa = $this->input->post('usa', true);
  454. $purchase = $this->input->post('purchase', true);
  455. $lacetype = $this->input->post('lacetype', true);
  456. $haircap = $this->input->post('haircap', true);
  457. $density = $this->input->post('density', true);
  458. $details = $this->input->post('details', true);
  459. $state = $this->input->post('state', true);
  460. $lacecolor = $this->input->post('lacecolor', true);
  461. $hairnumber = $this->input->post('hairnumber', true);
  462. $cklx = $this->input->post('cklx', true);
  463. $ktime = $this->input->post('ktime', true);
  464. $jtime = $this->input->post('jtime', true);
  465. $sm = $this->input->post('sm', true);
  466. $cpbz = $this->input->post('cpbz', true);
  467. $type = $this->input->post('type', true);
  468. $ktime = strtotime($ktime);
  469. $jtime = strtotime($jtime);
  470. $where = "1=1";
  471. $gj = "";
  472. $ck = "";
  473. if ($usa) {
  474. if (!$warehouse) {
  475. $where .= " and (warehouse = '5' or warehouse = '8')";
  476. }
  477. }
  478. if ($warehouse) {
  479. $where .= " and warehouse = '$warehouse'";
  480. }
  481. if ($details) {
  482. $where .= " and details = '$details'";
  483. }
  484. if ($purchase) {
  485. $where .= " and purchase = '$purchase'";
  486. }
  487. if ($state) {
  488. $where .= " and state = '$state'";
  489. }
  490. if ($lacetype) {
  491. $where .= " and features like '%-$lacetype-%'";
  492. }
  493. if ($category) {
  494. $where .= " and features like '%-$category-%'";
  495. }
  496. if ($size) {
  497. $where .= " and features like '%-$size-%'";
  498. }
  499. if ($grade) {
  500. $where .= " and features like '%-$grade-%'";
  501. }
  502. if ($color) {
  503. $where .= " and features like '%-$color-%'";
  504. }
  505. if ($lowe) {
  506. $where .= " and features like '%-$lowe-%'";
  507. }
  508. if ($haircap) {
  509. $where .= " and features like '%-$haircap-%'";
  510. }
  511. if ($density) {
  512. $where .= " and features like '%-$density-%'";
  513. }
  514. if ($lacecolor) {
  515. $where .= " and features like '%-$lacecolor-%'";
  516. }
  517. if($sm){
  518. $where .= " and sm like '%".$sm."%'";
  519. }
  520. if($cpbz){
  521. $where .= " and cpbz like '%".$cpbz."%'";
  522. }
  523. if($type){
  524. $where .= " and type = ".$type."";
  525. }
  526. if (!empty($hairnumber)) {
  527. $where .= " and features like '%-128-%' ";
  528. if ($hairnumber < 0) {
  529. $class_list = $this->typeclass->find_all('classid = 43');
  530. foreach ($class_list as $v) {
  531. $where .= " and features not like '%-" . $v['id'] . "-%'";
  532. }
  533. } else {
  534. $where .= " and features like '%-$hairnumber-%'";
  535. }
  536. }
  537. $where_add = '';
  538. if ($cklx) {
  539. $shop = $this->shop->read($cklx);
  540. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  541. }
  542. if ($ktime && $jtime) {
  543. $gj = " and enter > '$ktime' and enter < '$jtime'";
  544. $ck = " and outk > '$ktime' and outk < '$jtime'";
  545. }
  546. //数据排序
  547. $order_str = "id desc";
  548. if (empty($page)) {
  549. $start = 0;
  550. $perpage = 1;
  551. } else {
  552. $start = ($page - 1) * $perpage;
  553. }
  554. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  555. if ($sku) {
  556. $sku = trim($sku, ' ');
  557. $sku = trim($sku, ' ');
  558. $where .= " and sku like '%$sku%'";
  559. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  560. } else if ($title) {
  561. $title = trim($title, ' ');
  562. $title = trim($title, ' ');
  563. $where .= " and title like '%$title%'";
  564. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  565. } else {
  566. //$where .= " and time > '$ktime' and time < '$jtime'";
  567. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  568. }
  569. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  570. foreach ($info_list as $k => $v) {
  571. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  572. unset($info_list[$k]['pm']);
  573. unset($info_list[$k]['jm']);
  574. unset($info_list[$k]['bm']);
  575. }
  576. //取得信息列表
  577. $rows = array();
  578. $list = array();
  579. foreach ($info_list as $key => $value) {
  580. $warehouse = $this->warehouse->read($value['warehouse']);
  581. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  582. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  583. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  584. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  585. $info_list[$key]['label'] = $value['sm'];
  586. $number = $value['number'];
  587. $ftime = time() - 15 * 24 * 3600;
  588. $info_list[$key]['warehouse'] = $warehouse['title'];
  589. $info_list[$key]['features'] = count($c);
  590. $z = count($z); //查看订单号
  591. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  592. $ztdata = '';
  593. if (count($zt) > 0) {
  594. foreach ($zt as $vv) {
  595. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  596. }
  597. }
  598. $info_list[$key]['number'] = $ztdata;
  599. $info_list[$key]['sm'] = $z;
  600. $details = array();
  601. $cpid = array();
  602. foreach ($c as $k => $v) {
  603. $details[$v['details']] = $v['details'];
  604. if ($v['cpid'] != 0) {
  605. $cpid[$v['cpid']] = $v['cpid'];
  606. }
  607. }
  608. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  609. if ($value['shop'] != '') {
  610. $shop = explode(',', trim($value['shop'], ','));
  611. $shop = $this->shop->read($shop[0]);
  612. $info_list[$key]['shop'] = $shop['shopname'];
  613. }
  614. }
  615. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  616. $pagenum = ceil($total / $perpage);
  617. $over = $total - ($start + $perpage);
  618. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  619. echo json_encode($rows);
  620. exit;
  621. }
  622. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  623. $this->_Template('whlabel_typedy', $this->data);
  624. }
  625. //进销存浏览
  626. public function _typedy_ck($arg_array)
  627. {
  628. $prc = array();
  629. $purchase = $this->purchase->find_all();
  630. foreach ($purchase as $k => $v) {
  631. $prc[$v['id']] = $v['title'];
  632. }
  633. $post = $this->input->post(NULL, TRUE);
  634. if (isset($post['page'])) {
  635. $page = $this->input->post('page', true);
  636. $perpage = $this->input->post('perpage', true);
  637. $category = $this->input->post('category', true);
  638. $size = $this->input->post('size', true);
  639. $grade = $this->input->post('grade', true);
  640. $color = $this->input->post('color', true);
  641. $lowe = $this->input->post('lowe', true);
  642. $sku = $this->input->post('sku');
  643. $title = $this->input->post('title');
  644. $warehouse = $this->input->post('warehouse', true);
  645. $usa = $this->input->post('usa', true);
  646. $purchase = $this->input->post('purchase', true);
  647. $lacetype = $this->input->post('lacetype', true);
  648. $haircap = $this->input->post('haircap', true);
  649. $density = $this->input->post('density', true);
  650. $details = $this->input->post('details', true);
  651. $state = $this->input->post('state', true);
  652. $lacecolor = $this->input->post('lacecolor', true);
  653. $cklx = $this->input->post('cklx', true);
  654. $ktime = $this->input->post('ktime', true);
  655. $jtime = $this->input->post('jtime', true);
  656. $ktime = strtotime($ktime);
  657. $jtime = strtotime($jtime);
  658. $where = "1=1";
  659. $gj = "";
  660. $ck = "";
  661. if ($lacetype) {
  662. $where .= " and features like '%-$lacetype-%'";
  663. }
  664. if ($category) {
  665. $where .= " and features like '%-$category-%'";
  666. }
  667. if ($size) {
  668. $where .= " and features like '%-$size-%'";
  669. }
  670. if ($grade) {
  671. $where .= " and features like '%-$grade-%'";
  672. }
  673. if ($color) {
  674. $where .= " and features like '%-$color-%'";
  675. }
  676. if ($lowe) {
  677. $where .= " and features like '%-$lowe-%'";
  678. }
  679. if ($haircap) {
  680. $where .= " and features like '%-$haircap-%'";
  681. }
  682. if ($density) {
  683. $where .= " and features like '%-$density-%'";
  684. }
  685. if ($lacecolor) {
  686. $where .= " and features like '%-$lacecolor-%'";
  687. }
  688. if ($usa) {
  689. if (!$warehouse) {
  690. $where .= " and (warehouse = '5' or warehouse = '8')";
  691. }
  692. }
  693. if ($warehouse) {
  694. $where .= " and warehouse = '$warehouse'";
  695. }
  696. if ($details) {
  697. $where .= " and details = '$details'";
  698. }
  699. if ($purchase) {
  700. $where .= " and purchase = '$purchase'";
  701. }
  702. if ($state) {
  703. $where .= " and state = '$state'";
  704. }
  705. $where_add = '';
  706. if ($cklx) {
  707. $shop = $this->shop->read($cklx);
  708. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  709. }
  710. if ($ktime && $jtime) {
  711. $gj = " and enter > '$ktime' and enter < '$jtime'";
  712. $ck = " and outk > '$ktime' and outk < '$jtime'";
  713. }
  714. //数据排序
  715. $order_str = "id desc";
  716. if (empty($page)) {
  717. $start = 0;
  718. $perpage = 1;
  719. } else {
  720. $start = ($page - 1) * $perpage;
  721. }
  722. if ($sku) {
  723. $sku = trim($sku, ' ');
  724. $sku = trim($sku, ' ');
  725. $where .= " and sku like '%$sku%'";
  726. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  727. } else if ($title) {
  728. $title = trim($title, ' ');
  729. $title = trim($title, ' ');
  730. $where .= " and title like '%$title%'";
  731. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  732. } else {
  733. //$where .= " and time > '$ktime' and time < '$jtime'";
  734. $info_list = $this->whlabel->find_pc($where . $where_add . ' and zd != ""', 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,zd,COUNT(CASE WHEN zd != "" and state = 0 THEN 1 ELSE NULL END) AS zd', 'zd desc', $start, $perpage);
  735. }
  736. //取得信息列表
  737. $rows = array();
  738. $list = array();
  739. foreach ($info_list as $key => $value) {
  740. $warehouse = $this->warehouse->read($value['warehouse']);
  741. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  742. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  743. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  744. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  745. $ftime = time() - 15 * 24 * 3600;
  746. $info_list[$key]['warehouse'] = $warehouse['title'];
  747. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  748. //$z = count($z);//查看订单号
  749. //$info_list[$key]['zd'] = $z;
  750. $details = array();
  751. $cpid = array();
  752. foreach ($c as $k => $v) {
  753. $details[$v['details']] = $v['details'];
  754. if ($v['cpid'] != 0) {
  755. $cpid[$v['cpid']] = $v['cpid'];
  756. }
  757. }
  758. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  759. if ($value['shop'] != '') {
  760. $shop = explode(',', trim($value['shop'], ','));
  761. $shop = $this->shop->read($shop[0]);
  762. $info_list[$key]['shop'] = $shop['shopname'];
  763. }
  764. }
  765. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  766. $pagenum = ceil($total / $perpage);
  767. $over = $total - ($start + $perpage);
  768. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  769. echo json_encode($rows);
  770. exit;
  771. }
  772. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  773. $this->_Template('whlabel_typedy_ck', $this->data);
  774. }
  775. public function _typeck($arg_array)
  776. {
  777. $prc = array();
  778. $purchase = $this->purchase->find_all();
  779. foreach ($purchase as $k => $v) {
  780. $prc[$v['id']] = $v['title'];
  781. }
  782. $post = $this->input->post(NULL, TRUE);
  783. if (isset($post['page'])) {
  784. $page = $this->input->post('page', true);
  785. $perpage = $this->input->post('perpage', true);
  786. $category = $this->input->post('category', true);
  787. $size = $this->input->post('size', true);
  788. $grade = $this->input->post('grade', true);
  789. $color = $this->input->post('color', true);
  790. $lacecolor = $this->input->post('lacecolor', true);
  791. $lowe = $this->input->post('lowe', true);
  792. $sku = $this->input->post('sku');
  793. $title = $this->input->post('title');
  794. $warehouse = 13;
  795. $usa = $this->input->post('usa', true);
  796. $purchase = $this->input->post('purchase', true);
  797. $lacetype = $this->input->post('lacetype', true);
  798. $haircap = $this->input->post('haircap', true);
  799. $density = $this->input->post('density', true);
  800. $details = $this->input->post('details', true);
  801. $state = $this->input->post('state', true);
  802. $ktime = $this->input->post('ktime', true);
  803. $jtime = $this->input->post('jtime', true);
  804. $ktime = strtotime($ktime);
  805. $jtime = strtotime($jtime);
  806. $where = "1=1";
  807. $gj = "";
  808. $ck = "";
  809. if ($lacetype) {
  810. $where .= " and features like '%-$lacetype-%'";
  811. }
  812. if ($category) {
  813. $where .= " and features like '%-$category-%'";
  814. }
  815. if ($size) {
  816. $where .= " and features like '%-$size-%'";
  817. }
  818. if ($grade) {
  819. $where .= " and features like '%-$grade-%'";
  820. }
  821. if ($color) {
  822. $where .= " and features like '%-$color-%'";
  823. }
  824. if ($lacecolor) {
  825. $where .= " and features like '%-$lacecolor-%'";
  826. }
  827. if ($lowe) {
  828. $where .= " and features like '%-$lowe-%'";
  829. }
  830. if ($haircap) {
  831. $where .= " and features like '%-$haircap-%'";
  832. }
  833. if ($density) {
  834. $where .= " and features like '%-$density-%'";
  835. }
  836. if ($warehouse) {
  837. $where .= " and warehouse = '$warehouse'";
  838. }
  839. if ($details) {
  840. $where .= " and details = '$details'";
  841. }
  842. if ($purchase) {
  843. $where .= " and purchase = '$purchase'";
  844. }
  845. if ($state) {
  846. $where .= " and state = '$state'";
  847. }
  848. if ($ktime && $jtime) {
  849. $gj = " and enter > '$ktime' and enter < '$jtime'";
  850. $ck = " and outk > '$ktime' and outk < '$jtime'";
  851. }
  852. //数据排序
  853. $order_str = "id desc";
  854. if (empty($page)) {
  855. $start = 0;
  856. $perpage = 1;
  857. } else {
  858. $start = ($page - 1) * $perpage;
  859. }
  860. if ($sku) {
  861. $sku = trim($sku, ' ');
  862. $sku = trim($sku, ' ');
  863. $where .= " and sku like '%$sku%'";
  864. } else if ($title) {
  865. $title = trim($title, ' ');
  866. $title = trim($title, ' ');
  867. $where .= " and title like '%$title%'";
  868. }
  869. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  870. //取得信息列表
  871. $t = array();
  872. $typeclass = $this->typeclass->find_all();
  873. foreach ($typeclass as $v) {
  874. $t[$v['id']] = $v;
  875. }
  876. $rows = array();
  877. $list = array();
  878. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  879. foreach ($info_list as $key => $value) {
  880. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  881. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  882. $warehouse = $this->warehouse->read($value['warehouse']);
  883. $c = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  884. $z = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  885. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  886. $number = $value['number'];
  887. $ftime = time() - 15 * 24 * 3600;
  888. $z = count($z); //查看订单号
  889. $info_list[$key]['warehouse'] = $warehouse['title'];
  890. $info_list[$key]['features'] = count($c);
  891. $info_list[$key]['number'] = $z;
  892. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  893. $details = array();
  894. $cpid = array();
  895. foreach ($c as $k => $v) {
  896. $details[$v['details']] = $v['details'];
  897. if ($v['cpid'] != 0) {
  898. $cpid[$v['cpid']] = $v['cpid'];
  899. }
  900. }
  901. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  902. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  903. unset($info_list[$key]['pm']);
  904. unset($info_list[$key]['jm']);
  905. unset($info_list[$key]['bm']);
  906. }
  907. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  908. $pagenum = ceil($total / $perpage);
  909. $over = $total - ($start + $perpage);
  910. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  911. echo json_encode($rows);
  912. exit;
  913. }
  914. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  915. $this->_Template('whlabel_typeck', $this->data);
  916. }
  917. //进销存导出
  918. public function _whlabeckdc()
  919. {
  920. $prc = array();
  921. $purchase = $this->purchase->find_all();
  922. foreach ($purchase as $k => $v) {
  923. $prc[$v['id']] = $v['title'];
  924. }
  925. if (isset($_GET['excel'])) {
  926. $where = "sku != 'Preset'";
  927. //数据排序
  928. $order_str = "id desc";
  929. if (empty($page)) {
  930. $start = 0;
  931. $perpage = 1;
  932. } else {
  933. $start = ($page - 1) * $perpage;
  934. }
  935. $category = $this->input->get('category', true);
  936. $color = $this->input->get('color', true);
  937. $lowe = $this->input->get('lowe', true);
  938. $lacetype = $this->input->get('lacetype', true);
  939. $size = $this->input->get('size', true);
  940. $density = $this->input->get('density', true);
  941. $haircap = $this->input->get('haircap', true);
  942. $sku = $this->input->get('sku', true);
  943. $details = $this->input->get('details', true);
  944. $warehouse = 13;
  945. $excelid = $this->input->get('sid', true);
  946. if ($category) {
  947. $where .= " and features like '%-$category-%'";
  948. }
  949. if ($color) {
  950. $where .= " and features like '%-$color-%'";
  951. }
  952. if ($lowe) {
  953. $where .= " and features like '%-$lowe-%'";
  954. }
  955. if ($lacetype) {
  956. $where .= " and features like '%-$lacetype-%'";
  957. }
  958. if ($size) {
  959. $where .= " and features like '%-$size-%'";
  960. }
  961. if ($density) {
  962. $where .= " and features like '%-$density-%'";
  963. }
  964. if ($haircap) {
  965. $where .= " and features like '%-$haircap-%'";
  966. }
  967. if ($warehouse) {
  968. $where .= " and warehouse = '$warehouse'";
  969. }
  970. if ($sku) {
  971. $where .= " and sku like '%$sku%'";
  972. }
  973. if ($details) {
  974. $where .= " and details = '$details'";
  975. }
  976. $xzid = '';
  977. if ($excelid) {
  978. $excelid = explode(',', trim($excelid, ','));
  979. foreach ($excelid as $key => $value) {
  980. $xzid .= " id = " . $value . " or";
  981. }
  982. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  983. }
  984. //取得信息列表
  985. /**
  986. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  987. $rows = array();$list = array();
  988. foreach ($info_list as $key=>$value)
  989. {
  990. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  991. }
  992. **/
  993. $wh = array();
  994. $w = $this->warehouse->find_all('1=1', 'id,title');
  995. foreach ($w as $v) {
  996. $wh[$v['id']] = $v['title'];
  997. }
  998. $tc = array();
  999. $tcdata = array();
  1000. $list = array();
  1001. $classid = $this->classid->sku();
  1002. $tcall = $this->typeclass->find_all();
  1003. $typeclass = array();
  1004. foreach ($tcall as $v)
  1005. {
  1006. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1007. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1008. }
  1009. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1010. foreach ($rows as $key => $value) {
  1011. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1012. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1013. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1014. $rows[$key]['cpbz'] = $u9_info['bm'];
  1015. $rows[$key]['cs'] = $u9_info['jm'];
  1016. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1017. $details = array();
  1018. $cpid = array();
  1019. $cpbz = array();
  1020. $c = 0;
  1021. $g = 0;
  1022. $x = 0;
  1023. $t = 0;
  1024. $s = 0;
  1025. $q = 0;
  1026. foreach ($sd as $k => $v) {
  1027. if ($v['state'] == 0) {
  1028. $c++;
  1029. }
  1030. if ($v['state'] != 9) {
  1031. $g++;
  1032. }
  1033. if ($v['state'] == 1) {
  1034. $x++;
  1035. }
  1036. if ($v['state'] == 2) {
  1037. $t++;
  1038. }
  1039. if ($v['state'] == 8) {
  1040. $s++;
  1041. }
  1042. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1043. $q++;
  1044. }
  1045. $details[$v['details']] = $v['details'];
  1046. if ($v['cpid'] != 0) {
  1047. $cpid[$v['cpid']] = $v['cpid'];
  1048. }
  1049. if ($v['cpbz'] != '') {
  1050. $cpbz[$v['cpbz']] = $v['cpbz'];
  1051. }
  1052. }
  1053. $rows[$key]['details'] = implode("、", $details);
  1054. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1055. $number = $value['number'];
  1056. $ftime = time() - 15 * 24 * 3600;
  1057. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1058. $rows[$key]['number'] = $g;
  1059. $rows[$key]['features'] = $c;
  1060. $rows[$key]['x'] = $x;
  1061. $rows[$key]['t'] = $t;
  1062. $rows[$key]['s'] = $s;
  1063. $rows[$key]['q'] = $q;
  1064. $rows[$key]['wzsl'] = count($details);
  1065. }
  1066. $title = "进销存统计表" . date('Y-m-d', time());
  1067. $titlename = "<table border=1>
  1068. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1069. <tr align='center'>
  1070. <td>仓库</td>
  1071. <td>供应商</td>
  1072. <td>位置</td>
  1073. <td>库存编码</td>
  1074. <td>SKU</td>
  1075. <td>用友编码</td>
  1076. <td>用友料号</td>
  1077. <td>产品英文名</td>
  1078. <td>产品中文名</td>
  1079. <td>入库总量</td>
  1080. <td>库存数量</td>
  1081. <td>销售数量</td>
  1082. <td>退货数量</td>
  1083. <td>删除数量</td>
  1084. <td>其它操作</td>
  1085. <td>位置数量</td>
  1086. </tr>
  1087. </table>";
  1088. $filename = $title . ".xls";
  1089. $tail = "";
  1090. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1091. }
  1092. }
  1093. public function _type()
  1094. {
  1095. $vip = 0;
  1096. if (isset($_SESSION['api'])) {
  1097. $user = $this->user->get_api($_SESSION['api']);
  1098. $fgshop = "";
  1099. $sid = "";
  1100. $usersp = explode('|', trim($user['shop'], '|'));
  1101. foreach ($usersp as $value) {
  1102. $fgshop .= " shop = " . $value . " or";
  1103. $sid .= " id = " . $value . " or";
  1104. }
  1105. if ($user['vip'] == 1) {
  1106. $vip = 1;
  1107. }
  1108. } else {
  1109. header('Location: /');
  1110. exit;
  1111. }
  1112. $prc = array();
  1113. $purchase = $this->purchase->find_all();
  1114. foreach ($purchase as $k => $v) {
  1115. $prc[$v['id']] = $v['title'];
  1116. }
  1117. $company = array();
  1118. $ct = $this->company->find_all();
  1119. foreach ($ct as $k => $v) {
  1120. $company[$v['id']] = $v['title'];
  1121. }
  1122. $sp = array();
  1123. $s = $this->shop->find_all('1=1', 'id,shopname');
  1124. foreach ($s as $v) {
  1125. $sp[$v['id']] = $v['shopname'];
  1126. }
  1127. $wh = array();
  1128. $w = $this->warehouse->find_all('1=1', 'id,title');
  1129. foreach ($w as $v) {
  1130. $wh[$v['id']] = $v['title'];
  1131. }
  1132. $post = $this->input->post(NULL, TRUE);
  1133. if (isset($post['page'])) {
  1134. $page = $this->input->post('page', true);
  1135. $perpage = $this->input->post('perpage', true);
  1136. $category = $this->input->post('category', true);
  1137. $size = $this->input->post('size', true);
  1138. $grade = $this->input->post('grade', true);
  1139. $color = $this->input->post('color', true);
  1140. $lowe = $this->input->post('lowe', true);
  1141. $sku = $this->input->post('sku');
  1142. $title = $this->input->post('title');
  1143. $warehouse = $this->input->post('warehouse', true);
  1144. $usa = $this->input->post('usa', true);
  1145. $purchase = $this->input->post('purchase', true);
  1146. $lacetype = $this->input->post('lacetype', true);
  1147. $haircap = $this->input->post('haircap', true);
  1148. $density = $this->input->post('density', true);
  1149. $details = $this->input->post('details', true);
  1150. $state = $this->input->post('state', true);
  1151. $shop = $this->input->post('shop', true);
  1152. $lacecolor = $this->input->post('lacecolor', true);
  1153. $hairnumber = $this->input->post('hairnumber', true);
  1154. $type = $this->input->post('type', true);
  1155. $ktime = $this->input->post('ktime', true);
  1156. $jtime = $this->input->post('jtime', true);
  1157. $ktime = strtotime($ktime);
  1158. $jtime = strtotime($jtime);
  1159. $cpbz = $this->input->post('cpbz', true);
  1160. $sm = $this->input->post('sm', true);
  1161. $where = "1=1";
  1162. $gj = "";
  1163. $ck = "";
  1164. if ($usa) {
  1165. if (!$warehouse) {
  1166. $where .= " and (warehouse = '5' or warehouse = '8')";
  1167. }
  1168. }
  1169. if ($warehouse) {
  1170. $where .= " and warehouse = '$warehouse'";
  1171. }
  1172. if ($details) {
  1173. $where .= " and details = '$details'";
  1174. }
  1175. if ($purchase) {
  1176. $where .= " and purchase = '$purchase'";
  1177. }
  1178. if ($state) {
  1179. $where .= " and state = '$state'";
  1180. }
  1181. if ($shop) {
  1182. $where .= " and shop like '%$shop%'";
  1183. }
  1184. if ($type) {
  1185. $where .= " and type = '$type'";
  1186. }
  1187. if ($ktime && $jtime) {
  1188. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1189. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1190. }
  1191. if ($cpbz) {
  1192. $where .= " and cpbz like '%$cpbz%' ";
  1193. }
  1194. if ($sm) {
  1195. $where .= " and sm like '%$sm%' ";
  1196. }
  1197. if ($lacecolor) {
  1198. $where .= " and features like '%-$lacecolor-%'";
  1199. }
  1200. if ($lacetype) {
  1201. $where .= " and features like '%-$lacetype-%'";
  1202. }
  1203. if ($category) {
  1204. $where .= " and features like '%-$category-%'";
  1205. }
  1206. if ($size) {
  1207. $where .= " and features like '%-$size-%'";
  1208. }
  1209. if ($grade) {
  1210. $where .= " and features like '%-$grade-%'";
  1211. }
  1212. if ($color) {
  1213. $where .= " and features like '%-$color-%'";
  1214. }
  1215. if ($lowe) {
  1216. $where .= " and features like '%-$lowe-%'";
  1217. }
  1218. if ($haircap) {
  1219. $where .= " and features like '%-$haircap-%'";
  1220. }
  1221. if ($density) {
  1222. $where .= " and features like '%-$density-%'";
  1223. }
  1224. if (!empty($hairnumber)) {
  1225. $where .= " and features like '%-128-%' ";
  1226. if ($hairnumber < 0) {
  1227. $class_list = $this->typeclass->find_all('classid = 43');
  1228. foreach ($class_list as $v) {
  1229. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1230. }
  1231. } else {
  1232. $where .= " and features like '%-$hairnumber-%'";
  1233. }
  1234. }
  1235. //数据排序
  1236. $order_str = "id desc";
  1237. if (empty($page)) {
  1238. $start = 0;
  1239. $perpage = 1;
  1240. } else {
  1241. $start = ($page - 1) * $perpage;
  1242. }
  1243. $fjnr = '';
  1244. if ($sku) {
  1245. $sku = trim($sku, ' ');
  1246. $sku = trim($sku, ' ');
  1247. $fjnr .= " and sku like '%$sku%'";
  1248. }
  1249. if ($title) {
  1250. $title = trim($title, ' ');
  1251. $title = trim($title, ' ');
  1252. $fjnr .= " and title like '%$title%'";
  1253. }
  1254. $wt = array();
  1255. $whlabel_type = $this->whlabel_type->find_all();
  1256. foreach ($whlabel_type as $v) {
  1257. $wt[$v['id']] = $v['title'];
  1258. }
  1259. //$where .= " and time > '$ktime' and time < '$jtime'";
  1260. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,type,features,number,sm', $order_str, $start, $perpage); //改这需要修改_gbhtype
  1261. //取得信息列表
  1262. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1263. $rows = array();
  1264. $list = array();
  1265. foreach ($info_list as $key => $value) {
  1266. if (isset($wt[$value['type']])) {
  1267. $info_list[$key]['type'] = $wt[$value['type']];
  1268. } else {
  1269. $info_list[$key]['type'] = '未设置';
  1270. }
  1271. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1272. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1273. $ztdata = '';
  1274. if (count($zt) > 0) {
  1275. foreach ($zt as $vv) {
  1276. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1277. }
  1278. }
  1279. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1280. $cdata = array_filter($qbdata, function ($item) {
  1281. return $item['state'] < 1;
  1282. });
  1283. $c = array_sum(array_column($cdata, 'jnum'));
  1284. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1285. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1286. });
  1287. $g = array_sum(array_column($gdata, 'jnum'));
  1288. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1289. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1290. });
  1291. $x = array_sum(array_column($xdata, 'jnum'));
  1292. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1293. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1294. });
  1295. $t = array_sum(array_column($tdata, 'jnum'));
  1296. $zdata = array_filter($qbdata, function ($item) {
  1297. return $item['zd'] != "" && $item['state'] < 1;
  1298. });
  1299. $z = array_sum(array_column($zdata, 'jnum'));
  1300. $zdata = array_filter($qbdata, function ($item) {
  1301. return $item['zd'] != "" && $item['state'] < 1;
  1302. });
  1303. $z = array_sum(array_column($zdata, 'jnum'));
  1304. //$c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
  1305. //$g = $this->whlabel->find_count($where.$gj.' and sku = "'.$value['sku'].'" and state < 100 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1306. //$x = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and state = 1 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1307. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1308. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1309. $details = array();
  1310. $cpid = array();
  1311. $od = array();
  1312. $odid = '';
  1313. $companytitle = '';
  1314. $shop_list = [];
  1315. foreach ($qbdata as $v) {
  1316. if ($v['zd'] != "" && $v['state'] < 1) {
  1317. if (!isset($od[$v['zd']])) {
  1318. $od[$v['zd']] = 1; //所有数据sku
  1319. } else {
  1320. $od[$v['zd']] = $od[$v['zd']] + 1;
  1321. }
  1322. }
  1323. if ($v['state'] < 1) {
  1324. $details[$v['details']] = $v['details'];
  1325. if ($v['cpid'] != 0) {
  1326. $cpid[$v['cpid']] = $v['cpid'];
  1327. }
  1328. }
  1329. if($v['state'] == 0){
  1330. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1331. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1332. }
  1333. if ($v['shop'] != '') {
  1334. $shop = explode(',', trim($v['shop'], ','));
  1335. foreach ($shop as $vv) {
  1336. if (!in_array($vv, $shop_list)) {
  1337. $shop_list[] = $vv;
  1338. }
  1339. }
  1340. }
  1341. }
  1342. }
  1343. foreach ($od as $k => $vv) {
  1344. $odid .= $k . '数量' . $vv;
  1345. }
  1346. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1347. $info_list[$key]['label'] = $value['sm'];
  1348. $number = $value['number'];
  1349. $ftime = time() - 15 * 24 * 3600;
  1350. $z = $z . '(' . $odid . ')'; //查看订单号
  1351. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1352. $info_list[$key]['features'] = $c;
  1353. $info_list[$key]['number'] = $ztdata;
  1354. $info_list[$key]['sm'] = $g;
  1355. $info_list[$key]['x'] = $x;
  1356. $info_list[$key]['t'] = $t;
  1357. $info_list[$key]['z'] = $z;
  1358. /**
  1359. foreach ($cdata as $k=>$v)
  1360. {
  1361. $details[$v['details']] = $v['details'];
  1362. if($v['cpid'] != 0)
  1363. {
  1364. $cpid[$v['cpid']] = $v['cpid'];
  1365. }
  1366. }
  1367. **/
  1368. $info_list[$key]['shop'] = '';
  1369. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1370. // if ($value['shop'] != '') {
  1371. // $shop = explode(',', trim($value['shop'], ','));
  1372. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1373. // }
  1374. $shop_list = array_unique($shop_list);
  1375. $shop_str = '';
  1376. foreach ($shop_list as $v) {
  1377. if(isset($sp[$v])){
  1378. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1379. }
  1380. }
  1381. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1382. /**
  1383. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1384. if(isset($companytitle[0]))
  1385. {
  1386. foreach ($companytitle as $k=>$v)
  1387. {
  1388. if($v['companytitle'] != '')
  1389. {
  1390. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1391. }
  1392. }
  1393. }
  1394. **/
  1395. }
  1396. $final_all_list = [];
  1397. foreach ($info_list as $k => $v) {
  1398. $final_all_list[] = [
  1399. 'id' => $v['id'],
  1400. "warehouse" => $v["warehouse"],
  1401. "purchase" => $v["purchase"],
  1402. "sku" => $v["sku"],
  1403. "title" => $v["title"] . "<br/>" . $v["pm"],
  1404. "details" => $v["details"],
  1405. "shop" => $v["shop"],
  1406. "cpbz" => $v["cpbz"],
  1407. 'label' => $v['label'],
  1408. "type" => $v["type"],
  1409. "features" => $v["features"],
  1410. "number" => $v["number"],
  1411. "sm" => $v["sm"],
  1412. "x" => $v["x"],
  1413. "t" => $v["t"],
  1414. "z" => $v["z"]
  1415. ];
  1416. }
  1417. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1418. $pagenum = ceil($total / $perpage);
  1419. $over = $total - ($start + $perpage);
  1420. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1421. echo json_encode($rows);
  1422. exit;
  1423. }
  1424. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1425. $this->data['shop'] = $wlshop;
  1426. $this->data['vip'] = $vip;
  1427. $this->_Template('whlabel_type', $this->data);
  1428. }
  1429. //美仓进销存浏览
  1430. public function _usatype()
  1431. {
  1432. if (isset($_SESSION['api'])) {
  1433. $user = $this->user->get_api($_SESSION['api']);
  1434. $usp = $user;
  1435. $fgshop = "";
  1436. $sid = "";
  1437. $wid = "";
  1438. $wtype = "";
  1439. $userwh = explode('|', trim($user['warehouse'], '|'));
  1440. foreach ($userwh as $value) {
  1441. $wid .= " id = " . $value . " or";
  1442. $wtype .= " type = " . $value . " or";
  1443. }
  1444. }
  1445. $prc = array();
  1446. $purchase = $this->purchase->find_all();
  1447. foreach ($purchase as $k => $v) {
  1448. $prc[$v['id']] = $v['title'];
  1449. }
  1450. $post = $this->input->post(NULL, TRUE);
  1451. if (isset($post['page'])) {
  1452. $page = $this->input->post('page', true);
  1453. $perpage = $this->input->post('perpage', true);
  1454. $category = $this->input->post('category', true);
  1455. $size = $this->input->post('size', true);
  1456. $grade = $this->input->post('grade', true);
  1457. $color = $this->input->post('color', true);
  1458. $lowe = $this->input->post('lowe', true);
  1459. $sku = $this->input->post('sku');
  1460. $title = $this->input->post('title');
  1461. $warehouse = $this->input->post('warehouse', true);
  1462. $usa = $this->input->post('usa', true);
  1463. $purchase = $this->input->post('purchase', true);
  1464. $lacetype = $this->input->post('lacetype', true);
  1465. $haircap = $this->input->post('haircap', true);
  1466. $density = $this->input->post('density', true);
  1467. $details = $this->input->post('details', true);
  1468. $state = $this->input->post('state', true);
  1469. $lacecolor = $this->input->post('lacecolor', true);
  1470. $cklx = $this->input->post('cklx', true);
  1471. $ktime = $this->input->post('ktime', true);
  1472. $jtime = $this->input->post('jtime', true);
  1473. $ktime = strtotime($ktime);
  1474. $jtime = strtotime($jtime);
  1475. $where = "1=1";
  1476. $gj = "";
  1477. $ck = "";
  1478. if ($lacetype) {
  1479. $where .= " and features like '%-$lacetype-%'";
  1480. }
  1481. if ($category) {
  1482. $where .= " and features like '%-$category-%'";
  1483. }
  1484. if ($size) {
  1485. $where .= " and features like '%-$size-%'";
  1486. }
  1487. if ($grade) {
  1488. $where .= " and features like '%-$grade-%'";
  1489. }
  1490. if ($color) {
  1491. $where .= " and features like '%-$color-%'";
  1492. }
  1493. if ($lowe) {
  1494. $where .= " and features like '%-$lowe-%'";
  1495. }
  1496. if ($haircap) {
  1497. $where .= " and features like '%-$haircap-%'";
  1498. }
  1499. if ($density) {
  1500. $where .= " and features like '%-$density-%'";
  1501. }
  1502. if ($lacecolor) {
  1503. $where .= " and features like '%-$lacecolor-%'";
  1504. }
  1505. if ($usa) {
  1506. if (!$warehouse) {
  1507. $where .= " and (warehouse = '5' or warehouse = '8')";
  1508. }
  1509. }
  1510. if ($warehouse) {
  1511. $where .= " and warehouse = '$warehouse'";
  1512. }
  1513. if ($details) {
  1514. $where .= " and details = '$details'";
  1515. }
  1516. if ($purchase) {
  1517. $where .= " and purchase = '$purchase'";
  1518. }
  1519. if ($state) {
  1520. $where .= " and state = '$state'";
  1521. }
  1522. $where_add = '';
  1523. if ($cklx) {
  1524. $shop = $this->shop->read($cklx);
  1525. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1526. }
  1527. if ($ktime && $jtime) {
  1528. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1529. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1530. }
  1531. //数据排序
  1532. $order_str = "id desc";
  1533. if (empty($page)) {
  1534. $start = 0;
  1535. $perpage = 1;
  1536. } else {
  1537. $start = ($page - 1) * $perpage;
  1538. }
  1539. if ($sku) {
  1540. $sku = trim($sku, ' ');
  1541. $sku = trim($sku, ' ');
  1542. $where .= " and sku like '%$sku%'";
  1543. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1544. } else if ($title) {
  1545. $title = trim($title, ' ');
  1546. $title = trim($title, ' ');
  1547. $where .= " and title like '%$title%'";
  1548. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1549. } else {
  1550. //$where .= " and time > '$ktime' and time < '$jtime'";
  1551. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1552. }
  1553. //取得信息列表
  1554. $rows = array();
  1555. $list = array();
  1556. foreach ($info_list as $key => $value) {
  1557. $warehouse = $this->warehouse->read($value['warehouse']);
  1558. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1559. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1560. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1561. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1562. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1563. $od = array();
  1564. $odid = '';
  1565. foreach ($z as $v) {
  1566. if (!isset($od[$v['zd']])) {
  1567. $od[$v['zd']] = 1; //所有数据sku
  1568. } else {
  1569. $od[$v['zd']] = $od[$v['zd']] + 1;
  1570. }
  1571. }
  1572. foreach ($od as $k => $vv) {
  1573. $odid .= $k . '数量' . $vv . ' ';
  1574. }
  1575. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1576. $info_list[$key]['features'] = $c;
  1577. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1578. $ztdata = '';
  1579. if (count($zt) > 0) {
  1580. foreach ($zt as $vv) {
  1581. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1582. }
  1583. }
  1584. $info_list[$key]['warehouse'] = $ztdata;
  1585. $info_list[$key]['g'] = $g;
  1586. $info_list[$key]['x'] = $x;
  1587. $info_list[$key]['t'] = $t;
  1588. $info_list[$key]['z'] = $z;
  1589. }
  1590. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1591. $pagenum = ceil($total / $perpage);
  1592. $over = $total - ($start + $perpage);
  1593. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1594. echo json_encode($rows);
  1595. exit;
  1596. }
  1597. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1598. $this->data['warehouse'] = $warehouse;
  1599. $this->_Template('whlabel_typeusa', $this->data);
  1600. }
  1601. //美仓进销存浏览
  1602. public function _usatypeapp()
  1603. {
  1604. $post = $this->input->post(NULL, TRUE);
  1605. if (isset($post['page'])) {
  1606. $page = $this->input->post('page', true);
  1607. $perpage = $this->input->post('perpage', true);
  1608. $sku = $this->input->post('sku', true);
  1609. $warehouse = 5;
  1610. $title = $this->input->post('title', true);
  1611. $state = $this->input->post('state', true);
  1612. $ktime = $this->input->post('ktime', true);
  1613. $jtime = $this->input->post('jtime', true);
  1614. $ktime = strtotime($ktime);
  1615. $jtime = strtotime($jtime);
  1616. $where = "1=1";
  1617. $gj = "";
  1618. $ck = "";
  1619. if ($title) {
  1620. $st = explode(' ', trim($title, ' '));
  1621. foreach ($st as $v) {
  1622. $where .= " and title like '%$v%'";
  1623. }
  1624. }
  1625. if ($warehouse) {
  1626. $where .= " and warehouse = '$warehouse'";
  1627. }
  1628. if ($state) {
  1629. $where .= " and state = '$state'";
  1630. }
  1631. if ($sku) {
  1632. $where .= " and sku like '%$sku%'";
  1633. }
  1634. if ($ktime && $jtime) {
  1635. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1636. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1637. }
  1638. //数据排序
  1639. $order_str = "id desc";
  1640. if (empty($page)) {
  1641. $start = 0;
  1642. $perpage = 1;
  1643. } else {
  1644. $start = ($page - 1) * $perpage;
  1645. }
  1646. //取得信息列表
  1647. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1648. $rows = array();
  1649. $list = array();
  1650. foreach ($info_list as $key => $value) {
  1651. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1652. }
  1653. $rowsdq = array_slice($rows, $start, $perpage);
  1654. foreach ($rowsdq as $value) {
  1655. $warehouse = $this->warehouse->read($value['warehouse']);
  1656. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1657. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1658. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1659. $od = array();
  1660. $odid = '';
  1661. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1662. }
  1663. $total = count($rows);
  1664. $pagenum = ceil($total / $perpage);
  1665. $over = $total - ($start + $perpage);
  1666. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1667. echo json_encode($rows);
  1668. exit;
  1669. }
  1670. $this->_Template('phone/p_usatypeapp', $this->data);
  1671. }
  1672. //入库操作
  1673. public function _enteradd()
  1674. {
  1675. $dt = 0;
  1676. if (isset($_SESSION['api'])) {
  1677. $user = $this->user->get_api($_SESSION['api']);
  1678. $usp = $user;
  1679. $fgshop = "";
  1680. $sid = "";
  1681. $user = explode('|', trim($user['shop'], '|'));
  1682. foreach ($user as $value) {
  1683. $fgshop .= " shop = " . $value . " or";
  1684. $sid .= " id = " . $value . " or";
  1685. }
  1686. }
  1687. $tc = $this->typeclass->find_all();
  1688. $typeclass = array();
  1689. foreach ($tc as $v) {
  1690. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1691. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1692. }
  1693. $post = $this->input->post(NULL, TRUE);
  1694. if (isset($post['sku'])) {
  1695. $list = array();
  1696. $num = "";
  1697. $title = "";
  1698. $features = "";
  1699. $order = $this->input->post('order', true);
  1700. $shop = $this->input->post('shop', true);
  1701. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1702. $sku = $this->input->post('sku', true);
  1703. $post['sm'] = $this->input->post('sm', true);
  1704. $post['warehouse'] = $this->input->post('warehouse', true);
  1705. $post['purchase'] = $this->input->post('purchase', true);
  1706. $post['retreatwarehouse'] = $post['warehouse'];
  1707. $post['state'] = $this->input->post('state', true);
  1708. $post['rktype'] = $this->input->post('rktype', true);
  1709. $post['text'] = $this->input->post('text', true);
  1710. $category = $this->input->post('category', true);
  1711. $list['category'] = $category;
  1712. $list['hairtype'] = $this->input->post('hairtype', true);
  1713. $list['grade'] = $this->input->post('grade', true);
  1714. $size = $this->input->post('size', true);
  1715. $xzsku = $this->input->post('xzsku', true);
  1716. $list['size'] = rtrim($size, ',');
  1717. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1718. $list['extension'] = $this->input->post('extension', true);
  1719. if ($category == 1297) {
  1720. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1721. }
  1722. if ($category == 1702) {
  1723. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1724. $list['syother'] = $this->input->post('syother', true);
  1725. }
  1726. if ($category == 133) {
  1727. $list['fittype'] = $this->input->post('fittype', true);
  1728. $list['acother'] = $this->input->post('acother', true);
  1729. }
  1730. $list['color'] = $this->input->post('color', true);
  1731. $list['lowe'] = $this->input->post('lowe', true);
  1732. if (!$post['purchase']) {
  1733. $post['purchase'] = 1;
  1734. }
  1735. if ($category == 127) {
  1736. $list['type'] = $this->input->post('type', true);
  1737. $list['headroad'] = $this->input->post('headroad', true);
  1738. $list['density'] = $this->input->post('density', true);
  1739. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1740. $list['lacesize'] = $this->input->post('lacesize', true);
  1741. }
  1742. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1743. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1744. }
  1745. if ($category == 128) {
  1746. $list['lacetype'] = $this->input->post('lacetype', true);
  1747. $list['haircap'] = $this->input->post('haircap', true);
  1748. $list['density'] = $this->input->post('density', true);
  1749. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1750. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1751. $list['wigother'] = $this->input->post('wigother', true);
  1752. $list['wigother1'] = $this->input->post('wigother1', true);
  1753. $list['wigother2'] = $this->input->post('wigother2', true);
  1754. }
  1755. if ($category == 129) {
  1756. $list['wide'] = $this->input->post('wide', true);
  1757. }
  1758. if ($category == 131) {
  1759. $list['gifttype'] = $this->input->post('gifttype', true);
  1760. $list['giftother'] = $this->input->post('giftother', true);
  1761. }
  1762. if ($category == 134) {
  1763. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1764. }
  1765. if ($category == 1297) {
  1766. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1767. $list['sywigother'] = $this->input->post('sywigother', true);
  1768. }
  1769. if ($category == 130 || $category == 133 || $category == 1702) {
  1770. $list['items'] = $this->input->post('items', true);
  1771. $list['weight'] = $this->input->post('weight', true);
  1772. }
  1773. if ($category == 1702) {
  1774. $list['syhairther'] = $this->input->post('syhairther', true);
  1775. }
  1776. $classid = $this->classid->sku();
  1777. $scsku = $classid;
  1778. $pm = $classid;
  1779. foreach ($list as $k => $v) {
  1780. if ($v != 0) {
  1781. $num .= $v;
  1782. $features .= $v . '-';
  1783. $post[$k] = $v;
  1784. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1785. if ($k != 'size') {
  1786. $title .= $typeclass[$v]['title'] . " ";
  1787. }
  1788. if (isset($pm[$typeclass[$v]['classid']])) {
  1789. if ($typeclass[$v]['title'] == '9A') {
  1790. $pm[$typeclass[$v]['classid']] = '9A';
  1791. } else if ($typeclass[$v]['title'] == '10A') {
  1792. $pm[$typeclass[$v]['classid']] = '10A';
  1793. } else {
  1794. $clzh = $typeclass[$v]['zh'];
  1795. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1796. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1797. $clzh = $clzh[0];
  1798. }
  1799. $pm[$typeclass[$v]['classid']] = $clzh;
  1800. }
  1801. }
  1802. }
  1803. }
  1804. $zh = implode(" ", $pm);
  1805. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1806. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1807. if ($list['size']) {
  1808. $typeclass = $this->typeclass->read($list['size']);
  1809. $title .= $typeclass['title'];
  1810. }
  1811. $time = time();
  1812. if ($xzsku) {
  1813. $scsku = implode("-", $scsku);
  1814. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1815. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1816. $post['sku'] = trim($scsku, ' ');
  1817. } else {
  1818. $post['sku'] = $sku;
  1819. }
  1820. //$post['sku'] = trim($sku,' ');
  1821. $post['title'] = rtrim($title, ' ');
  1822. $post['number'] = $num;
  1823. $post['features'] = '-' . $features;
  1824. $post['enter'] = $time;
  1825. $post['time'] = $time; //操作时间
  1826. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1827. if ($yza) {
  1828. if ($post['features'] != $yza[0]['features']) {
  1829. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1830. exit;
  1831. }
  1832. }
  1833. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1834. if ($yzb) {
  1835. if ($post['sku'] != $yzb[0]['sku']) {
  1836. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1837. exit;
  1838. }
  1839. }
  1840. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1841. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1842. exit;
  1843. }
  1844. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1845. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1846. exit;
  1847. }
  1848. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1849. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1850. exit;
  1851. }
  1852. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1853. if (isset($yz[0]['type'])) {
  1854. $post['type'] = $yz[0]['type'];
  1855. }
  1856. if ($post['state'] == 9) //如果选择预设库存
  1857. {
  1858. $this->whlabel->insert($post);
  1859. } else {
  1860. /**
  1861. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1862. if($ljg == 1)
  1863. {
  1864. for($i=0;$i<$order;$i++)
  1865. {
  1866. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1867. $this->whlabel->insert($post);
  1868. }
  1869. }
  1870. **/
  1871. //if($post['warehouse'] == '5')
  1872. //{
  1873. //}
  1874. $yydata = $post;
  1875. $yydata['zh'] = $zh;
  1876. /**
  1877. $wl = $this->apiyy->get_cjlp($yydata);
  1878. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1879. {
  1880. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1881. }
  1882. if($wl['Data'][0]['m_isSucess'] != 1)
  1883. {
  1884. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1885. }
  1886. **/
  1887. for ($i = 0; $i < $order; $i++) {
  1888. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1889. $this->whlabel->insert($post);
  1890. }
  1891. }
  1892. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1893. exit;
  1894. }
  1895. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1896. $this->data['wlshop'] = $wlshop;
  1897. $this->_Template('whlabel_enteradd', $this->data);
  1898. }
  1899. //修改产品
  1900. public function _enteredit($arg_array)
  1901. {
  1902. $dt = 0;
  1903. if (isset($_SESSION['api'])) {
  1904. $user = $this->user->get_api($_SESSION['api']);
  1905. $usp = $user;
  1906. $fgshop = "";
  1907. $sid = "";
  1908. $user = explode('|', trim($user['shop'], '|'));
  1909. foreach ($user as $value) {
  1910. $fgshop .= " shop = " . $value . " or";
  1911. $sid .= " id = " . $value . " or";
  1912. }
  1913. }
  1914. $post = $this->input->post(NULL, TRUE);
  1915. if (isset($post['sku'])) {
  1916. $list = array();
  1917. $num = "";
  1918. $title = "";
  1919. $features = "";
  1920. $id = $this->input->post('id', true);
  1921. $order = $this->input->post('order', true);
  1922. $shop = $this->input->post('shop', true);
  1923. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1924. $post['sku'] = $this->input->post('sku', true);
  1925. $post['sm'] = $this->input->post('sm', true);
  1926. $post['warehouse'] = $this->input->post('warehouse', true);
  1927. $post['purchase'] = $this->input->post('purchase', true);
  1928. $post['retreatwarehouse'] = $post['warehouse'];
  1929. $category = $this->input->post('category', true);
  1930. $list['category'] = $category;
  1931. $list['hairtype'] = $this->input->post('hairtype', true);
  1932. $list['grade'] = $this->input->post('grade', true);
  1933. $size = $this->input->post('size', true);
  1934. $list['size'] = rtrim($size, ',');
  1935. $post['rktype'] = $this->input->post('rktype', true);
  1936. $post['text'] = $this->input->post('text', true);
  1937. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1938. $list['extension'] = $this->input->post('extension', true);
  1939. if ($category == 1297) {
  1940. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1941. }
  1942. if ($category == 1702) {
  1943. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1944. $list['syother'] = $this->input->post('syother', true);
  1945. }
  1946. if ($category == 133) {
  1947. $list['fittype'] = $this->input->post('fittype', true);
  1948. $list['acother'] = $this->input->post('acother', true);
  1949. }
  1950. $list['color'] = $this->input->post('color', true);
  1951. $list['lowe'] = $this->input->post('lowe', true);
  1952. if (!$post['purchase']) {
  1953. $post['purchase'] = 1;
  1954. }
  1955. if ($category == 127) {
  1956. $list['type'] = $this->input->post('type', true);
  1957. $list['headroad'] = $this->input->post('headroad', true);
  1958. $list['density'] = $this->input->post('density', true);
  1959. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1960. $list['lacesize'] = $this->input->post('lacesize', true);
  1961. }
  1962. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1963. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1964. }
  1965. if ($category == 128) {
  1966. $list['lacetype'] = $this->input->post('lacetype', true);
  1967. $list['haircap'] = $this->input->post('haircap', true);
  1968. $list['density'] = $this->input->post('density', true);
  1969. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1970. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1971. $list['wigother'] = $this->input->post('wigother', true);
  1972. $list['wigother1'] = $this->input->post('wigother1', true);
  1973. $list['wigother2'] = $this->input->post('wigother2', true);
  1974. }
  1975. if ($category == 129) {
  1976. $list['wide'] = $this->input->post('wide', true);
  1977. }
  1978. if ($category == 131) {
  1979. $list['gifttype'] = $this->input->post('gifttype', true);
  1980. $list['giftother'] = $this->input->post('giftother', true);
  1981. }
  1982. if ($category == 134) {
  1983. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1984. }
  1985. if ($category == 1297) {
  1986. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1987. $list['sywigother'] = $this->input->post('sywigother', true);
  1988. }
  1989. if ($category == 130 || $category == 133 || $category == 1702) {
  1990. $list['items'] = $this->input->post('items', true);
  1991. $list['weight'] = $this->input->post('weight', true);
  1992. }
  1993. if ($category == 1702) {
  1994. $list['syhairther'] = $this->input->post('syhairther', true);
  1995. }
  1996. foreach ($list as $k => $v) {
  1997. if ($v != 0) {
  1998. $num .= $v;
  1999. $features .= $v . '-';
  2000. $typeclass = $this->typeclass->read($v);
  2001. if ($k != 'size') {
  2002. $title .= $typeclass['title'] . " ";
  2003. }
  2004. }
  2005. }
  2006. $typeclass = $this->typeclass->read($list['size']);
  2007. $title .= $typeclass['title'];
  2008. $time = time();
  2009. $post['title'] = rtrim($title, ' ');
  2010. $post['number'] = $num;
  2011. $post['features'] = '-' . $features;
  2012. $post['time'] = $time; //操作时间
  2013. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2014. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2015. exit;
  2016. }
  2017. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2018. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2019. exit;
  2020. }
  2021. $uid = $this->whlabel->read($id);
  2022. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2023. if ($datanum > 0) {
  2024. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2025. exit;
  2026. }
  2027. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2028. {
  2029. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2030. if ($yza) {
  2031. if ($post['features'] != $yza[0]['features']) {
  2032. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2033. exit;
  2034. }
  2035. }
  2036. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2037. if ($yzb) {
  2038. if ($post['sku'] != $yzb[0]['sku']) {
  2039. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2040. exit;
  2041. }
  2042. }
  2043. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2044. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2045. exit;
  2046. }
  2047. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2048. foreach ($data as $v) {
  2049. $post['id'] = $v['id'];
  2050. $this->whlabel->save($post, $v['id']);
  2051. }
  2052. } else {
  2053. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2054. if ($data > 0) {
  2055. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2056. exit;
  2057. } else {
  2058. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2059. foreach ($data as $v) {
  2060. $post['id'] = $v['id'];
  2061. $this->whlabel->save($post, $v['id']);
  2062. }
  2063. }
  2064. }
  2065. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2066. exit;
  2067. }
  2068. $uid = $this->whlabel->read($arg_array[0]);
  2069. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2070. $this->data['enter'] = $uid;
  2071. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2072. $this->data['wlshop'] = $wlshop;
  2073. $this->_Template('whlabel_enteredit', $this->data);
  2074. }
  2075. //入库浏览
  2076. public function _enter()
  2077. {
  2078. $post = $this->input->post(NULL, TRUE);
  2079. if (isset($post['s'])) {
  2080. $id_arr = $this->input->post('s');
  2081. $id_arr = explode(',', $id_arr);
  2082. if (!$id_arr) {
  2083. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2084. exit;
  2085. }
  2086. //循环删除记录
  2087. foreach ($id_arr as $v) {
  2088. $sid = $this->whlabel->read($v);
  2089. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2090. if ($count > 0) {
  2091. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2092. exit;
  2093. }
  2094. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2095. foreach ($info_list as $va) {
  2096. $this->whlabel->remove($va['id']);
  2097. }
  2098. }
  2099. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2100. exit;
  2101. }
  2102. $sp = array();
  2103. $s = $this->shop->find_all('1=1', 'id,shopname');
  2104. foreach ($s as $v) {
  2105. $sp[$v['id']] = $v['shopname'];
  2106. }
  2107. $wh = array();
  2108. $w = $this->warehouse->find_all('1=1', 'id,title');
  2109. foreach ($w as $v) {
  2110. $wh[$v['id']] = $v['title'];
  2111. }
  2112. if (isset($post['page'])) {
  2113. $page = $this->input->post('page', true);
  2114. $perpage = $this->input->post('perpage', true);
  2115. $category = $this->input->post('category', true);
  2116. $size = $this->input->post('size', true);
  2117. $grade = $this->input->post('grade', true);
  2118. $color = $this->input->post('color', true);
  2119. $lowe = $this->input->post('lowe', true);
  2120. $sku = $this->input->post('sku', true);
  2121. $warehouse = $this->input->post('warehouse', true);
  2122. $purchase = $this->input->post('purchase', true);
  2123. $ktime = $this->input->post('ktime', true);
  2124. $jtime = $this->input->post('jtime', true);
  2125. $ktime = strtotime($ktime);
  2126. $jtime = strtotime($jtime);
  2127. $where = "1=1";
  2128. $gj = "";
  2129. $ck = "";
  2130. if ($category) {
  2131. $where .= " and features like '%-$category-%'";
  2132. }
  2133. if ($size) {
  2134. $where .= " and features like '%-$size-%'";
  2135. }
  2136. if ($grade) {
  2137. $where .= " and features like '%-$grade-%'";
  2138. }
  2139. if ($color) {
  2140. $where .= " and features like '%-$color-%'";
  2141. }
  2142. if ($lowe) {
  2143. $where .= " and features like '%-$lowe-%'";
  2144. }
  2145. if ($warehouse) {
  2146. $where .= " and warehouse = '$warehouse'";
  2147. }
  2148. if ($purchase) {
  2149. $where .= " and purchase = '$purchase'";
  2150. }
  2151. if ($sku) {
  2152. $where .= " and sku like '%$sku%'";
  2153. }
  2154. if ($ktime && $jtime) {
  2155. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2156. }
  2157. //数据排序
  2158. $order_str = "enter desc";
  2159. if (empty($page)) {
  2160. $start = 0;
  2161. $perpage = 1;
  2162. } else {
  2163. $start = ($page - 1) * $perpage;
  2164. }
  2165. //取得信息列表
  2166. $info_list = $this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2167. foreach ($info_list as $k => $v) {
  2168. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2169. if ($v['shop'] == '') {
  2170. $s = '通用';
  2171. } else {
  2172. $info_list[$k]['shop'] = '';
  2173. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2174. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2175. }
  2176. }
  2177. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2178. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2179. $info_list[$k]['g'] = $g;
  2180. }
  2181. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2182. $total = count($this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,sku,title,features,number'));
  2183. $pagenum = ceil($total / $perpage);
  2184. $over = $total - ($start + $perpage);
  2185. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2186. echo json_encode($rows);
  2187. exit;
  2188. }
  2189. $this->_Template('whlabel_enter', $this->data);
  2190. }
  2191. //出库浏览
  2192. public function _out()
  2193. {
  2194. $post = $this->input->post(NULL, TRUE);
  2195. if (isset($post['page'])) {
  2196. $page = $this->input->post('page', true);
  2197. $perpage = $this->input->post('perpage', true);
  2198. $category = $this->input->post('category', true);
  2199. $size = $this->input->post('size', true);
  2200. $grade = $this->input->post('grade', true);
  2201. $color = $this->input->post('color', true);
  2202. $lowe = $this->input->post('lowe', true);
  2203. $sku = $this->input->post('sku', true);
  2204. $warehouse = $this->input->post('warehouse', true);
  2205. $purchase = $this->input->post('purchase', true);
  2206. $state = $this->input->post('state', true);
  2207. $ktime = $this->input->post('ktime', true);
  2208. $jtime = $this->input->post('jtime', true);
  2209. $ktime = strtotime($ktime);
  2210. $jtime = strtotime($jtime);
  2211. $where = "state=3";
  2212. $gj = "";
  2213. $ck = "";
  2214. if ($category) {
  2215. $where .= " and features like '%-$category-%'";
  2216. }
  2217. if ($size) {
  2218. $where .= " and features like '%-$size-%'";
  2219. }
  2220. if ($grade) {
  2221. $where .= " and features like '%-$grade-%'";
  2222. }
  2223. if ($color) {
  2224. $where .= " and features like '%-$color-%'";
  2225. }
  2226. if ($lowe) {
  2227. $where .= " and features like '%-$lowe-%'";
  2228. }
  2229. if ($state) {
  2230. $where .= " and state = '$state'";
  2231. }
  2232. if ($warehouse) {
  2233. $where .= " and warehouse = '$warehouse'";
  2234. }
  2235. if ($purchase) {
  2236. $where .= " and purchase = '$purchase'";
  2237. }
  2238. if ($sku) {
  2239. $where .= " and sku = '$sku'";
  2240. }
  2241. if ($ktime && $jtime) {
  2242. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2243. }
  2244. //数据排序
  2245. $order_str = "id desc";
  2246. if (empty($page)) {
  2247. $start = 0;
  2248. $perpage = 1;
  2249. } else {
  2250. $start = ($page - 1) * $perpage;
  2251. }
  2252. //取得信息列表
  2253. $info_list = $this->whlabel->find_all($where, 'sku');
  2254. $rows = array();
  2255. $list = array();
  2256. foreach ($info_list as $key => $value) {
  2257. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2258. }
  2259. $rows = array_unique($rows); //删除重复记录
  2260. foreach ($rows as $key => $value) {
  2261. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2262. $ck = $this->warehouse->read($data['warehouse']);
  2263. $warehouse = $ck['title'];
  2264. $gy = $this->purchase->read($data['purchase']);
  2265. $purchase = $gy['purchase'];
  2266. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2267. $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);
  2268. }
  2269. $total = count($list);
  2270. $pagenum = ceil($total / $perpage);
  2271. $over = $total - ($start + $perpage);
  2272. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2273. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2274. echo json_encode($rows);
  2275. exit;
  2276. }
  2277. $this->_Template('whlabel_out', $this->data);
  2278. }
  2279. //出库标签浏览
  2280. public function _label()
  2281. {
  2282. $post = $this->input->post(NULL, TRUE);
  2283. if (isset($post['page'])) {
  2284. $page = $this->input->post('page', true);
  2285. $perpage = $this->input->post('perpage', true);
  2286. $sku = $this->input->post('sku', true);
  2287. $warehouse = $this->input->post('warehouse', true);
  2288. $purchase = $this->input->post('purchase', true);
  2289. $orderinfo = $this->input->post('orderinfo', true);
  2290. $waybill = $this->input->post('waybill', true);
  2291. $category = $this->input->post('category', true);
  2292. $size = $this->input->post('size', true);
  2293. $grade = $this->input->post('grade', true);
  2294. $color = $this->input->post('color', true);
  2295. $lowe = $this->input->post('lowe', true);
  2296. $where = "state=1";
  2297. if ($sku) {
  2298. $where .= " and sku = '$sku'";
  2299. }
  2300. if ($warehouse) {
  2301. $where .= " and warehouse = '$warehouse'";
  2302. }
  2303. if ($purchase) {
  2304. $where .= " and purchase = '$purchase'";
  2305. }
  2306. if ($orderinfo) {
  2307. $where .= " and orderinfo = '$orderinfo'";
  2308. }
  2309. if ($waybill) {
  2310. $where .= " and waybill = '$waybill'";
  2311. }
  2312. if ($category) {
  2313. $where .= " and features like '%-$category-%'";
  2314. }
  2315. if ($size) {
  2316. $where .= " and features like '%-$size-%'";
  2317. }
  2318. if ($grade) {
  2319. $where .= " and features like '%-$grade-%'";
  2320. }
  2321. if ($color) {
  2322. $where .= " and features like '%-$color-%'";
  2323. }
  2324. if ($lowe) {
  2325. $where .= " and features like '%-$lowe-%'";
  2326. }
  2327. //数据排序
  2328. $order_str = "outk desc";
  2329. if (empty($page)) {
  2330. $start = 0;
  2331. $perpage = 1;
  2332. } else {
  2333. $start = ($page - 1) * $perpage;
  2334. }
  2335. //取得信息列表
  2336. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2337. foreach ($info_list as $key => $value) {
  2338. $warehouse = $this->warehouse->read($value['warehouse']);
  2339. $info_list[$key]['warehouse'] = $warehouse['title'];
  2340. $purchase = $this->purchase->read($value['purchase']);
  2341. $info_list[$key]['purchase'] = $purchase['title'];
  2342. if ($value['outk'] != 0) {
  2343. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2344. } else {
  2345. $info_list[$key]['outk'] = "";
  2346. }
  2347. if ($value['orderinfo'] == 0) {
  2348. $info_list[$key]['orderinfo'] = "";
  2349. }
  2350. if ($value['waybill'] == 0) {
  2351. $info_list[$key]['waybill'] = "";
  2352. }
  2353. }
  2354. $total = $this->whlabel->find_count($where);
  2355. $pagenum = ceil($total / $perpage);
  2356. $over = $total - ($start + $perpage);
  2357. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2358. echo json_encode($rows);
  2359. exit;
  2360. }
  2361. $this->_Template('whlabel_label', $this->data);
  2362. }
  2363. //独立站出库订单
  2364. public function _outorder()
  2365. {
  2366. if (isset($_SESSION['api'])) {
  2367. $user = $this->user->get_api($_SESSION['api']);
  2368. $usp = $user;
  2369. $fgshop = "";
  2370. $sid = "";
  2371. $user = explode('|', trim($user['shop'], '|'));
  2372. foreach ($user as $value) {
  2373. $fgshop .= " shop = " . $value . " or";
  2374. $sid .= " id = " . $value . " or";
  2375. }
  2376. } else {
  2377. echo "请重新登录";
  2378. }
  2379. $post = $this->input->post(NULL, TRUE);
  2380. if (isset($post['page'])) {
  2381. $page = $this->input->post('page', true);
  2382. $perpage = $this->input->post('perpage', true);
  2383. $warehouse = $this->input->post('warehouse', true);
  2384. $xztime = $this->input->post('xztime', true);
  2385. $timetk = $this->input->post('timetkk', true);
  2386. $timetj = $this->input->post('timetjj', true);
  2387. $shop = $this->input->post('shop', true);
  2388. $source = $this->input->post('source', true);
  2389. $orderinfo = $this->input->post('orderinfo', true);
  2390. $number = $this->input->post('number', true);
  2391. $sfxh = $this->input->post('sfxh', true);
  2392. $express = $this->input->post('express', true);
  2393. $waybill = $this->input->post('waybill', true);
  2394. $library = $this->input->post('library', true);
  2395. $country = $this->input->post('country', true);
  2396. $so = $this->input->post('so', true);
  2397. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2398. $print = $this->input->post('print', true);
  2399. $state = $this->input->post('state', true);
  2400. $orderurl = $this->input->post('orderurl', true);
  2401. $timetk = strtotime($timetk);
  2402. $timetj = strtotime($timetj);
  2403. /**
  2404. $sj = $this->input->post('sj',true);
  2405. if($sj)
  2406. {
  2407. $sj = $this->input->post('sj',true);
  2408. }
  2409. else
  2410. {
  2411. $sj = "fullorder";
  2412. }
  2413. **/
  2414. $sj = "fullorder";
  2415. $where = "1=1";
  2416. if ($warehouse) {
  2417. $where .= " and type = '$warehouse'";
  2418. }
  2419. if ($timetk && $timetj) {
  2420. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2421. }
  2422. if ($orderinfo) {
  2423. $where .= " and orderinfo = '$orderinfo'";
  2424. }
  2425. if ($number) {
  2426. $where .= " and number = '$number'";
  2427. }
  2428. if ($express) {
  2429. $where .= " and express = '$express'";
  2430. }
  2431. if ($waybill) {
  2432. $where .= " and waybill = '$waybill'";
  2433. }
  2434. if ($library) {
  2435. $where .= " and library = '$library'";
  2436. }
  2437. if ($print) {
  2438. $where .= " and print = '$print'";
  2439. }
  2440. if ($libraryconfirm) {
  2441. $where .= " and libraryconfirm = '$libraryconfirm'";
  2442. }
  2443. if ($state) {
  2444. $where .= " and state = '$state'";
  2445. }
  2446. if ($shop) {
  2447. $where .= " and shop = '$shop'";
  2448. }
  2449. if ($country) {
  2450. $where .= " and country = '$country'";
  2451. }
  2452. if ($sfxh != '') {
  2453. $where .= " and sfxh = '$sfxh'";
  2454. }
  2455. if ($so) {
  2456. $where .= " and shipremarks like '%$so%'";
  2457. }
  2458. if ($source) {
  2459. if ($source == '2d') {
  2460. $where .= " and source >= '2'";
  2461. } else {
  2462. $where .= " and source = '$source'";
  2463. }
  2464. }
  2465. if (isset($_SESSION['api'])) {
  2466. foreach ($user as $value) {
  2467. $fgshop .= " shop = " . $value . " or";
  2468. }
  2469. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2470. }
  2471. if ($orderurl) {
  2472. $url = $this->orderurl->read($orderurl);
  2473. $where .= " and link like '%" . $url['url'] . "%'";
  2474. }
  2475. //数据排序
  2476. $order_str = "librarytime desc";
  2477. if (empty($page)) {
  2478. $start = 0;
  2479. $perpage = 1;
  2480. } else {
  2481. $start = ($page - 1) * $perpage;
  2482. }
  2483. //取得信息列表
  2484. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2485. //格式化数据
  2486. foreach ($info_list as $key => $value) {
  2487. $shop = $this->shop->read($value['shop']);
  2488. $info_list[$key]['shop'] = $shop['shopname'];
  2489. $express = $this->express->read($value['express']);
  2490. $info_list[$key]['express'] = $express['servicename'];
  2491. $warehouse = $this->warehouse->read($value['type']);
  2492. $info_list[$key]['type'] = $warehouse['title'];
  2493. if ($value['librarytime'] == '0') {
  2494. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2495. } else {
  2496. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2497. }
  2498. }
  2499. $total = $this->$sj->find_count($where);
  2500. $pagenum = ceil($total / $perpage);
  2501. $over = $total - ($start + $perpage);
  2502. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2503. echo json_encode($rows);
  2504. exit;
  2505. }
  2506. $this->data['express'] = $this->express->find_all();
  2507. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2508. $this->data['wlshop'] = $wlshop;
  2509. $user = $this->user->get_api($_SESSION['api']);
  2510. $powerid = $this->power->read($user['power']);
  2511. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2512. $pid = '';
  2513. foreach ($powertext as $v) {
  2514. $pid .= " id = " . $v . " or";
  2515. }
  2516. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2517. $this->data['fullorderexcel'] = $fullorderexcel;
  2518. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2519. $this->data['orderurl'] = $orderurl;
  2520. $this->_Template('whlabel_outorder', $this->data);
  2521. }
  2522. //tt出库
  2523. public function _toutorder()
  2524. {
  2525. if (isset($_SESSION['api'])) {
  2526. $user = $this->user->get_api($_SESSION['api']);
  2527. $usp = $user;
  2528. $fgshop = "";
  2529. $sid = "";
  2530. $user = explode('|', trim($user['shop'], '|'));
  2531. foreach ($user as $value) {
  2532. $fgshop .= " shop = " . $value . " or";
  2533. $sid .= " id = " . $value . " or";
  2534. }
  2535. } else {
  2536. echo "请重新登录";
  2537. }
  2538. $post = $this->input->post(NULL, TRUE);
  2539. if (isset($post['page'])) {
  2540. $page = $this->input->post('page', true);
  2541. $perpage = $this->input->post('perpage', true);
  2542. $warehouse = $this->input->post('warehouse', true);
  2543. $xztime = $this->input->post('xztime', true);
  2544. $timetk = $this->input->post('timetkk', true);
  2545. $timetj = $this->input->post('timetjj', true);
  2546. $shop = $this->input->post('shop', true);
  2547. $source = $this->input->post('source', true);
  2548. $orderinfo = $this->input->post('orderinfo', true);
  2549. $number = $this->input->post('number', true);
  2550. $sfxh = $this->input->post('sfxh', true);
  2551. $express = $this->input->post('express', true);
  2552. $waybill = $this->input->post('waybill', true);
  2553. $library = $this->input->post('library', true);
  2554. $country = $this->input->post('country', true);
  2555. $so = $this->input->post('so', true);
  2556. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2557. $print = $this->input->post('print', true);
  2558. $state = $this->input->post('state', true);
  2559. $orderurl = $this->input->post('orderurl', true);
  2560. $timetk = strtotime($timetk);
  2561. $timetj = strtotime($timetj);
  2562. /**
  2563. $sj = $this->input->post('sj',true);
  2564. if($sj)
  2565. {
  2566. $sj = $this->input->post('sj',true);
  2567. }
  2568. else
  2569. {
  2570. $sj = "fullorder";
  2571. }
  2572. **/
  2573. $sj = "fullordertt";
  2574. $where = "1=1";
  2575. if ($warehouse) {
  2576. $where .= " and type = '$warehouse'";
  2577. }
  2578. if ($timetk && $timetj) {
  2579. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2580. }
  2581. if ($orderinfo) {
  2582. $where .= " and orderinfo = '$orderinfo'";
  2583. }
  2584. if ($number) {
  2585. $where .= " and number = '$number'";
  2586. }
  2587. if ($express) {
  2588. $where .= " and express = '$express'";
  2589. }
  2590. if ($waybill) {
  2591. $where .= " and waybill = '$waybill'";
  2592. }
  2593. if ($library) {
  2594. $where .= " and library = '$library'";
  2595. }
  2596. if ($print) {
  2597. $where .= " and print = '$print'";
  2598. }
  2599. if ($libraryconfirm) {
  2600. $where .= " and libraryconfirm = '$libraryconfirm'";
  2601. }
  2602. if ($state) {
  2603. $where .= " and state = '$state'";
  2604. }
  2605. if ($shop) {
  2606. $where .= " and shop = '$shop'";
  2607. }
  2608. if ($country) {
  2609. $where .= " and country = '$country'";
  2610. }
  2611. if ($sfxh != '') {
  2612. $where .= " and sfxh = '$sfxh'";
  2613. }
  2614. if ($so) {
  2615. $where .= " and shipremarks like '%$so%'";
  2616. }
  2617. if ($source) {
  2618. if ($source == '2d') {
  2619. $where .= " and source >= '2'";
  2620. } else {
  2621. $where .= " and source = '$source'";
  2622. }
  2623. }
  2624. if (isset($_SESSION['api'])) {
  2625. foreach ($user as $value) {
  2626. $fgshop .= " shop = " . $value . " or";
  2627. }
  2628. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2629. }
  2630. if ($orderurl) {
  2631. $url = $this->orderurl->read($orderurl);
  2632. $where .= " and link like '%" . $url['url'] . "%'";
  2633. }
  2634. //数据排序
  2635. $order_str = "librarytime desc";
  2636. if (empty($page)) {
  2637. $start = 0;
  2638. $perpage = 1;
  2639. } else {
  2640. $start = ($page - 1) * $perpage;
  2641. }
  2642. //取得信息列表
  2643. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2644. //格式化数据
  2645. foreach ($info_list as $key => $value) {
  2646. $shop = $this->shop->read($value['shop']);
  2647. $info_list[$key]['shop'] = $shop['shopname'];
  2648. $express = $this->express->read($value['express']);
  2649. $info_list[$key]['express'] = $express['servicename'];
  2650. $warehouse = $this->warehouse->read($value['type']);
  2651. $info_list[$key]['type'] = $warehouse['title'];
  2652. if ($value['librarytime'] == '0') {
  2653. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2654. } else {
  2655. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2656. }
  2657. }
  2658. $total = $this->$sj->find_count($where);
  2659. $pagenum = ceil($total / $perpage);
  2660. $over = $total - ($start + $perpage);
  2661. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2662. echo json_encode($rows);
  2663. exit;
  2664. }
  2665. $this->data['express'] = $this->express->find_all();
  2666. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2667. $this->data['wlshop'] = $wlshop;
  2668. $user = $this->user->get_api($_SESSION['api']);
  2669. $powerid = $this->power->read($user['power']);
  2670. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2671. $pid = '';
  2672. foreach ($powertext as $v) {
  2673. $pid .= " id = " . $v . " or";
  2674. }
  2675. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2676. $this->data['fullorderexcel'] = $fullorderexcel;
  2677. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2678. $this->data['orderurl'] = $orderurl;
  2679. $this->_Template('whlabel_toutorder', $this->data);
  2680. }
  2681. //tt出库
  2682. public function _aoutorder()
  2683. {
  2684. if (isset($_SESSION['api'])) {
  2685. $user = $this->user->get_api($_SESSION['api']);
  2686. $usp = $user;
  2687. $fgshop = "";
  2688. $sid = "";
  2689. $user = explode('|', trim($user['shop'], '|'));
  2690. foreach ($user as $value) {
  2691. $fgshop .= " shop = " . $value . " or";
  2692. $sid .= " id = " . $value . " or";
  2693. }
  2694. } else {
  2695. echo "请重新登录";
  2696. }
  2697. $post = $this->input->post(NULL, TRUE);
  2698. if (isset($post['page'])) {
  2699. $page = $this->input->post('page', true);
  2700. $perpage = $this->input->post('perpage', true);
  2701. $warehouse = $this->input->post('warehouse', true);
  2702. $xztime = $this->input->post('xztime', true);
  2703. $timetk = $this->input->post('timetkk', true);
  2704. $timetj = $this->input->post('timetjj', true);
  2705. $shop = $this->input->post('shop', true);
  2706. $source = $this->input->post('source', true);
  2707. $orderinfo = $this->input->post('orderinfo', true);
  2708. $number = $this->input->post('number', true);
  2709. $sfxh = $this->input->post('sfxh', true);
  2710. $express = $this->input->post('express', true);
  2711. $waybill = $this->input->post('waybill', true);
  2712. $library = $this->input->post('library', true);
  2713. $country = $this->input->post('country', true);
  2714. $so = $this->input->post('so', true);
  2715. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2716. $print = $this->input->post('print', true);
  2717. $state = $this->input->post('state', true);
  2718. $orderurl = $this->input->post('orderurl', true);
  2719. $timetk = strtotime($timetk);
  2720. $timetj = strtotime($timetj);
  2721. /**
  2722. $sj = $this->input->post('sj',true);
  2723. if($sj)
  2724. {
  2725. $sj = $this->input->post('sj',true);
  2726. }
  2727. else
  2728. {
  2729. $sj = "fullorder";
  2730. }
  2731. **/
  2732. $sj = "fullorderamz";
  2733. $where = "1=1";
  2734. if ($warehouse) {
  2735. $where .= " and type = '$warehouse'";
  2736. }
  2737. if ($timetk && $timetj) {
  2738. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2739. }
  2740. if ($orderinfo) {
  2741. $where .= " and orderinfo = '$orderinfo'";
  2742. }
  2743. if ($number) {
  2744. $where .= " and number = '$number'";
  2745. }
  2746. if ($express) {
  2747. $where .= " and express = '$express'";
  2748. }
  2749. if ($waybill) {
  2750. $where .= " and waybill = '$waybill'";
  2751. }
  2752. if ($library) {
  2753. $where .= " and library = '$library'";
  2754. }
  2755. if ($print) {
  2756. $where .= " and print = '$print'";
  2757. }
  2758. if ($libraryconfirm) {
  2759. $where .= " and libraryconfirm = '$libraryconfirm'";
  2760. }
  2761. if ($state) {
  2762. $where .= " and state = '$state'";
  2763. }
  2764. if ($shop) {
  2765. $where .= " and shop = '$shop'";
  2766. }
  2767. if ($country) {
  2768. $where .= " and country = '$country'";
  2769. }
  2770. if ($sfxh != '') {
  2771. $where .= " and sfxh = '$sfxh'";
  2772. }
  2773. if ($so) {
  2774. $where .= " and shipremarks like '%$so%'";
  2775. }
  2776. if ($source) {
  2777. if ($source == '2d') {
  2778. $where .= " and source >= '2'";
  2779. } else {
  2780. $where .= " and source = '$source'";
  2781. }
  2782. }
  2783. if (isset($_SESSION['api'])) {
  2784. foreach ($user as $value) {
  2785. $fgshop .= " shop = " . $value . " or";
  2786. }
  2787. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2788. }
  2789. if ($orderurl) {
  2790. $url = $this->orderurl->read($orderurl);
  2791. $where .= " and link like '%" . $url['url'] . "%'";
  2792. }
  2793. //数据排序
  2794. $order_str = "librarytime desc";
  2795. if (empty($page)) {
  2796. $start = 0;
  2797. $perpage = 1;
  2798. } else {
  2799. $start = ($page - 1) * $perpage;
  2800. }
  2801. //取得信息列表
  2802. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2803. //格式化数据
  2804. foreach ($info_list as $key => $value) {
  2805. $shop = $this->shop->read($value['shop']);
  2806. $info_list[$key]['shop'] = $shop['shopname'];
  2807. $express = $this->express->read($value['express']);
  2808. $info_list[$key]['express'] = $express['servicename'];
  2809. $warehouse = $this->warehouse->read($value['type']);
  2810. $info_list[$key]['type'] = $warehouse['title'];
  2811. if ($value['librarytime'] == '0') {
  2812. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2813. } else {
  2814. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2815. }
  2816. }
  2817. $total = $this->$sj->find_count($where);
  2818. $pagenum = ceil($total / $perpage);
  2819. $over = $total - ($start + $perpage);
  2820. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2821. echo json_encode($rows);
  2822. exit;
  2823. }
  2824. $this->data['express'] = $this->express->find_all();
  2825. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2826. $this->data['wlshop'] = $wlshop;
  2827. $user = $this->user->get_api($_SESSION['api']);
  2828. $powerid = $this->power->read($user['power']);
  2829. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2830. $pid = '';
  2831. foreach ($powertext as $v) {
  2832. $pid .= " id = " . $v . " or";
  2833. }
  2834. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2835. $this->data['fullorderexcel'] = $fullorderexcel;
  2836. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2837. $this->data['orderurl'] = $orderurl;
  2838. $this->_Template('whlabel_aoutorder', $this->data);
  2839. }
  2840. //速卖通出库订单
  2841. public function _soutorder()
  2842. {
  2843. if (isset($_SESSION['api'])) {
  2844. $user = $this->user->get_api($_SESSION['api']);
  2845. $usp = $user;
  2846. $fgshop = "";
  2847. $sid = "";
  2848. $user = explode('|', trim($user['shop'], '|'));
  2849. foreach ($user as $value) {
  2850. $sid .= " id = " . $value . " or";
  2851. }
  2852. }
  2853. $post = $this->input->post(NULL, TRUE);
  2854. if (isset($post['page'])) {
  2855. $page = $this->input->post('page', true);
  2856. $perpage = $this->input->post('perpage', true);
  2857. $warehouse = $this->input->post('warehouse', true);
  2858. $xztime = $this->input->post('xztime', true);
  2859. $timetk = $this->input->post('timetkk', true);
  2860. $timetj = $this->input->post('timetjj', true);
  2861. $shop = $this->input->post('shop', true);
  2862. $source = $this->input->post('source', true);
  2863. $orderinfo = $this->input->post('orderinfo', true);
  2864. $number = $this->input->post('number', true);
  2865. $express = $this->input->post('express', true);
  2866. $waybill = $this->input->post('waybill', true);
  2867. $library = $this->input->post('library', true);
  2868. $country = $this->input->post('country', true);
  2869. $sfxh = $this->input->post('sfxh', true);
  2870. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2871. $print = $this->input->post('print', true);
  2872. $state = $this->input->post('state', true);
  2873. $so = $this->input->post('so', true);
  2874. $timetk = strtotime($timetk);
  2875. $timetj = strtotime($timetj);
  2876. /**
  2877. $sj = $this->input->post('sj',true);
  2878. if($sj)
  2879. {
  2880. $sj = $this->input->post('sj',true);
  2881. }
  2882. else
  2883. {
  2884. $sj = "fullorder";
  2885. }
  2886. **/
  2887. $sj = "fullordersmt";
  2888. $where = "1=1";
  2889. if ($warehouse) {
  2890. $where .= " and type = '$warehouse'";
  2891. }
  2892. if ($timetk && $timetj) {
  2893. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2894. }
  2895. if ($orderinfo) {
  2896. $where .= " and orderinfo = '$orderinfo'";
  2897. }
  2898. if ($number) {
  2899. $where .= " and number = '$number'";
  2900. }
  2901. if ($express) {
  2902. $where .= " and express = '$express'";
  2903. }
  2904. if ($waybill) {
  2905. $where .= " and waybill = '$waybill'";
  2906. }
  2907. if ($library) {
  2908. $where .= " and library = '$library'";
  2909. }
  2910. if ($print) {
  2911. $where .= " and print = '$print'";
  2912. }
  2913. if ($libraryconfirm) {
  2914. $where .= " and libraryconfirm = '$libraryconfirm'";
  2915. }
  2916. if ($state) {
  2917. $where .= " and state = '$state'";
  2918. }
  2919. if ($shop) {
  2920. $where .= " and shop = '$shop'";
  2921. }
  2922. if ($sfxh != '') {
  2923. $where .= " and sfxh = '$sfxh'";
  2924. }
  2925. if ($so) {
  2926. $where .= " and shipremarks like '%$so%'";
  2927. }
  2928. if ($source) {
  2929. $where .= " and source = '$source'";
  2930. }
  2931. if ($country) {
  2932. $where .= " and country = '$country'";
  2933. } else {
  2934. if (isset($_SESSION['api'])) {
  2935. foreach ($user as $value) {
  2936. $fgshop .= " shop = " . $value . " or";
  2937. }
  2938. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2939. }
  2940. }
  2941. //数据排序
  2942. $order_str = "librarytime desc";
  2943. if (empty($page)) {
  2944. $start = 0;
  2945. $perpage = 1;
  2946. } else {
  2947. $start = ($page - 1) * $perpage;
  2948. }
  2949. //取得信息列表
  2950. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2951. //格式化数据
  2952. foreach ($info_list as $key => $value) {
  2953. $shop = $this->shop->read($value['shop']);
  2954. $info_list[$key]['shop'] = $shop['shopname'];
  2955. $express = $this->express->read($value['express']);
  2956. $info_list[$key]['express'] = $express['servicename'];
  2957. $warehouse = $this->warehouse->read($value['type']);
  2958. $info_list[$key]['type'] = $warehouse['title'];
  2959. if ($value['librarytime'] == '0') {
  2960. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2961. } else {
  2962. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2963. }
  2964. }
  2965. $total = $this->$sj->find_count($where);
  2966. $pagenum = ceil($total / $perpage);
  2967. $over = $total - ($start + $perpage);
  2968. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2969. echo json_encode($rows);
  2970. exit;
  2971. }
  2972. $this->data['express'] = $this->express->find_all();
  2973. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2974. $this->data['wlshop'] = $wlshop;
  2975. $user = $this->user->get_api($_SESSION['api']);
  2976. $powerid = $this->power->read($user['power']);
  2977. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2978. $pid = '';
  2979. foreach ($powertext as $v) {
  2980. $pid .= " id = " . $v . " or";
  2981. }
  2982. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2983. $this->data['fullorderexcel'] = $fullorderexcel;
  2984. $this->_Template('whlabel_soutorder', $this->data);
  2985. }
  2986. //订单退库
  2987. public function _retreat()
  2988. {
  2989. $post = $this->input->post(NULL, TRUE);
  2990. if (isset($post['page'])) {
  2991. $page = $this->input->post('page', true);
  2992. $perpage = $this->input->post('perpage', true);
  2993. $warehouse = $this->input->post('warehouse', true);
  2994. $timetk = $this->input->post('timetk', true);
  2995. $timetj = $this->input->post('timetj', true);
  2996. $shop = $this->input->post('shop', true);
  2997. $source = $this->input->post('source', true);
  2998. $state = $this->input->post('state', true);
  2999. $review = $this->input->post('review', true);
  3000. $state = $this->input->post('state', true);
  3001. $express = $this->input->post('express', true);
  3002. $orderinfo = $this->input->post('orderinfo', true);
  3003. $user = $this->input->post('user', true);
  3004. $name = $this->input->post('name', true);
  3005. $waybill = $this->input->post('waybill', true);
  3006. $timetk = strtotime($timetk);
  3007. $timetj = strtotime($timetj);
  3008. $where = "(state=206 or state=210) and mergeid = 0";
  3009. if ($warehouse) {
  3010. $where .= " and state = '$warehouse'";
  3011. }
  3012. if ($timetk && $timetj) {
  3013. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3014. }
  3015. if ($shop) {
  3016. $where .= " and shop = '$shop'";
  3017. }
  3018. if ($source) {
  3019. $where .= " and source = '$source'";
  3020. }
  3021. if ($state) {
  3022. $where .= " and state = '$state'";
  3023. }
  3024. if ($review) {
  3025. $where .= " and review = '$review'";
  3026. }
  3027. if ($state) {
  3028. $where .= " and state = '$state'";
  3029. }
  3030. if ($express) {
  3031. $where .= " and express = '$express'";
  3032. }
  3033. if ($orderinfo) {
  3034. $where .= " and orderinfo = '$orderinfo'";
  3035. }
  3036. if ($user) {
  3037. $where .= " and user = '$user'";
  3038. }
  3039. if ($name) {
  3040. $where .= " and name = '$name'";
  3041. }
  3042. if ($waybill) {
  3043. $where .= " and waybill = '$waybill'";
  3044. }
  3045. //数据排序
  3046. $order_str = "id desc";
  3047. if (empty($page)) {
  3048. $start = 0;
  3049. $perpage = 1;
  3050. } else {
  3051. $start = ($page - 1) * $perpage;
  3052. }
  3053. //取得信息列表
  3054. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3055. //格式化数据
  3056. foreach ($info_list as $key => $value) {
  3057. $shop = $this->shop->read($value['shop']);
  3058. $info_list[$key]['shop'] = $shop['shopname'];
  3059. $warehouse = $this->warehouse->read($value['warehouse']);
  3060. $info_list[$key]['warehouse'] = $warehouse['title'];
  3061. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3062. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3063. if ($value['waybill'] == 0) {
  3064. $info_list[$key]['waybill'] = "";
  3065. }
  3066. $express = $this->express->read($value['express']);
  3067. $info_list[$key]['express'] = $express['title'];
  3068. $typeclass = $this->typeclass->read($value['state']);
  3069. $info_list[$key]['state'] = $typeclass['title'];
  3070. }
  3071. $total = $this->fullorder->find_count($where);
  3072. $pagenum = ceil($total / $perpage);
  3073. $over = $total - ($start + $perpage);
  3074. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3075. echo json_encode($rows);
  3076. exit;
  3077. }
  3078. $this->data['express'] = $this->express->find_all();
  3079. $this->_Template('whlabel_retreat', $this->data);
  3080. }
  3081. //退库标签浏览
  3082. public function _retreatlk()
  3083. {
  3084. $post = $this->input->post(NULL, TRUE);
  3085. if (isset($post['page'])) {
  3086. $page = $this->input->post('page', true);
  3087. $perpage = $this->input->post('perpage', true);
  3088. $timetk = $this->input->post('timetk', true);
  3089. $timetj = $this->input->post('timetj', true);
  3090. $sku = $this->input->post('sku', true);
  3091. $warehouse = $this->input->post('warehouse', true);
  3092. $purchase = $this->input->post('purchase', true);
  3093. $orderinfo = $this->input->post('orderinfo', true);
  3094. $waybill = $this->input->post('waybill', true);
  3095. $category = $this->input->post('category', true);
  3096. $size = $this->input->post('size', true);
  3097. $grade = $this->input->post('grade', true);
  3098. $color = $this->input->post('color', true);
  3099. $lowe = $this->input->post('lowe', true);
  3100. $state = $this->input->post('state', true);
  3101. $timetk = strtotime($timetk);
  3102. $timetj = strtotime($timetj);
  3103. $where = "state=2";
  3104. if ($timetk && $timetj) {
  3105. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3106. }
  3107. if ($sku) {
  3108. $where .= " and sku = '$sku'";
  3109. }
  3110. if ($warehouse) {
  3111. $where .= " and warehouse = '$warehouse'";
  3112. }
  3113. if ($purchase) {
  3114. $where .= " and purchase = '$purchase'";
  3115. }
  3116. if ($orderinfo) {
  3117. $where .= " and orderinfo = '$orderinfo'";
  3118. }
  3119. if ($waybill) {
  3120. $where .= " and waybill = '$waybill'";
  3121. }
  3122. if ($category) {
  3123. $where .= " and features like '%-$category-%'";
  3124. }
  3125. if ($size) {
  3126. $where .= " and features like '%-$size-%'";
  3127. }
  3128. if ($grade) {
  3129. $where .= " and features like '%-$grade-%'";
  3130. }
  3131. if ($color) {
  3132. $where .= " and features like '%-$color-%'";
  3133. }
  3134. if ($lowe) {
  3135. $where .= " and features like '%-$lowe-%'";
  3136. }
  3137. //数据排序
  3138. $order_str = "time desc";
  3139. if (empty($page)) {
  3140. $start = 0;
  3141. $perpage = 1;
  3142. } else {
  3143. $start = ($page - 1) * $perpage;
  3144. }
  3145. //取得信息列表
  3146. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3147. foreach ($info_list as $key => $value) {
  3148. $warehouse = $this->warehouse->read($value['warehouse']);
  3149. $info_list[$key]['warehouse'] = $warehouse['title'];
  3150. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3151. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3152. $purchase = $this->purchase->read($value['purchase']);
  3153. $info_list[$key]['purchase'] = $purchase['title'];
  3154. if ($value['outk'] != 0) {
  3155. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3156. } else {
  3157. $info_list[$key]['outk'] = "";
  3158. }
  3159. if ($value['retreat'] != 0) {
  3160. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3161. } else {
  3162. $info_list[$key]['retreat'] = "";
  3163. }
  3164. if ($value['orderinfo'] == 0) {
  3165. $info_list[$key]['orderinfo'] = "";
  3166. }
  3167. if ($value['waybill'] == 0) {
  3168. $info_list[$key]['waybill'] = "";
  3169. }
  3170. }
  3171. $total = $this->whlabel->find_count($where);
  3172. $pagenum = ceil($total / $perpage);
  3173. $over = $total - ($start + $perpage);
  3174. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3175. echo json_encode($rows);
  3176. exit;
  3177. }
  3178. $this->_Template('whlabel_retreatlk', $this->data);
  3179. }
  3180. //更换标签及浏览
  3181. public function _change()
  3182. {
  3183. $post = $this->input->post(NULL, TRUE);
  3184. if (isset($post['page'])) {
  3185. $page = $this->input->post('page', true);
  3186. $perpage = $this->input->post('perpage', true);
  3187. $timetk = $this->input->post('timetk', true);
  3188. $timetj = $this->input->post('timetj', true);
  3189. $label = $this->input->post('label', true);
  3190. $oldlabel = $this->input->post('oldlabel', true);
  3191. $timetk = strtotime($timetk);
  3192. $timetj = strtotime($timetj);
  3193. $where = "state=10 ";
  3194. if ($timetk && $timetj) {
  3195. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3196. }
  3197. if ($label) {
  3198. $where .= " and label = '$label'";
  3199. }
  3200. if ($oldlabel) {
  3201. $where .= " and oldlabel = '$oldlabel'";
  3202. }
  3203. //数据排序
  3204. $order_str = "time asc";
  3205. if (empty($page)) {
  3206. $start = 0;
  3207. $perpage = 1;
  3208. } else {
  3209. $start = ($page - 1) * $perpage;
  3210. }
  3211. //取得信息列表
  3212. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3213. foreach ($info_list as $key => $value) {
  3214. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3215. }
  3216. $total = $this->whlabel->find_count($where);
  3217. $pagenum = ceil($total / $perpage);
  3218. $over = $total - ($start + $perpage);
  3219. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3220. echo json_encode($rows);
  3221. exit;
  3222. }
  3223. $this->_Template('whlabel_change', $this->data);
  3224. }
  3225. //产品标签
  3226. public function _cpbqdc()
  3227. {
  3228. if (isset($_GET['excel'])) {
  3229. $where = "1=1";
  3230. //数据排序
  3231. $order_str = "id desc";
  3232. if (empty($page)) {
  3233. $start = 0;
  3234. $perpage = 1;
  3235. } else {
  3236. $start = ($page - 1) * $perpage;
  3237. }
  3238. $warehouse = $this->input->get('warehouse', true);
  3239. $state = $this->input->get('state', true);
  3240. $timetk = $this->input->get('timetkk', true);
  3241. $timetj = $this->input->get('timetjj', true);
  3242. $timetk = strtotime($timetk);
  3243. $timetj = strtotime($timetj);
  3244. if ($warehouse) {
  3245. $where .= " and warehouse = '$warehouse'";
  3246. }
  3247. if ($state || $state == 0) {
  3248. $where .= " and state = '$state'";
  3249. }
  3250. if ($timetk && $timetj) {
  3251. $where .= " and time > '$timetk' and time < '$timetj'";
  3252. }
  3253. //取得信息列表
  3254. $info_list = $this->whlabel->find_all($where, '*');
  3255. $rows = array();
  3256. $list = array();
  3257. foreach ($info_list as $key => $value) {
  3258. $rows[$value['time']] = $value; //所有数据sku
  3259. }
  3260. foreach ($rows as $value) {
  3261. $warehouse = $this->warehouse->read($value['warehouse']);
  3262. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3263. $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);
  3264. }
  3265. $title = "产品标签统计表";
  3266. $titlename = "<table border=1>
  3267. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3268. <tr align='center'>
  3269. <td>仓库</td>
  3270. <td>SKU</td>
  3271. <td>产品</td>
  3272. <td>入库时间</td>
  3273. <td>操作时间</td>
  3274. <td>备注</td>
  3275. <td>数量</td>
  3276. </tr>
  3277. </table>";
  3278. $filename = $title . ".xls";
  3279. $tail = "";
  3280. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3281. }
  3282. }
  3283. //进销存导出
  3284. public function _exceljxc()
  3285. {
  3286. $classid = $this->classid->sku();
  3287. $pm = $classid;
  3288. $typeclass = array();
  3289. $tc = $this->typeclass->find_all();
  3290. foreach ($tc as $v) {
  3291. $typeclass[$v['id']] = $v;
  3292. }
  3293. $prc = array();
  3294. $purchase = $this->purchase->find_all();
  3295. foreach ($purchase as $k => $v) {
  3296. $prc[$v['id']] = $v['title'];
  3297. }
  3298. if (isset($_GET['excel'])) {
  3299. $where = "sku != 'Preset'";
  3300. //数据排序
  3301. $order_str = "id desc";
  3302. if (empty($page)) {
  3303. $start = 0;
  3304. $perpage = 1;
  3305. } else {
  3306. $start = ($page - 1) * $perpage;
  3307. }
  3308. $category = $this->input->get('category', true);
  3309. $warehouse = $this->input->get('warehouse', true);
  3310. $excelid = $this->input->get('sid', true);
  3311. if ($category) {
  3312. $where .= " and features like '%-$category-%'";
  3313. }
  3314. if ($warehouse) {
  3315. $where .= " and warehouse = '$warehouse'";
  3316. }
  3317. $xzid = '';
  3318. if ($excelid) {
  3319. $excelid = explode(',', trim($excelid, ','));
  3320. foreach ($excelid as $key => $value) {
  3321. $xzid .= " id = " . $value . " or";
  3322. }
  3323. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3324. }
  3325. //取得信息列表
  3326. /**
  3327. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3328. $rows = array();$list = array();
  3329. foreach ($info_list as $key=>$value)
  3330. {
  3331. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3332. }
  3333. **/
  3334. $wt = array();
  3335. $whlabel_type = $this->whlabel_type->find_all();
  3336. foreach ($whlabel_type as $v) {
  3337. $wt[$v['id']] = $v['title'];
  3338. }
  3339. $wh = array();
  3340. $w = $this->warehouse->find_all('1=1', 'id,title');
  3341. foreach ($w as $v) {
  3342. $wh[$v['id']] = $v['title'];
  3343. }
  3344. $list = array();
  3345. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3346. foreach ($rows as $key => $value) {
  3347. if (isset($wt[$value['type']])) {
  3348. $rows[$key]['type'] = $wt[$value['type']];
  3349. } else {
  3350. $rows[$key]['type'] = '未设置';
  3351. }
  3352. $bm = '03';
  3353. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3354. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3355. $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');
  3356. $details = array();
  3357. $cpid = array();
  3358. $cpbz = array();
  3359. $c = 0;
  3360. $g = 0;
  3361. $x = 0;
  3362. $t = 0;
  3363. $s = 0;
  3364. $q = 0;
  3365. foreach ($sd as $k => $v) {
  3366. if ($v['state'] == 0) {
  3367. $c++;
  3368. if ($v['cpid'] != 0) {
  3369. $cpid[$v['cpid']] = $v['cpid'];
  3370. }
  3371. if ($v['cpbz'] != '') {
  3372. $cpbz[$v['cpbz']] = $v['cpbz'];
  3373. }
  3374. }
  3375. if ($v['state'] != 9) {
  3376. $g++;
  3377. }
  3378. if ($v['state'] == 1) {
  3379. $x++;
  3380. }
  3381. if ($v['state'] == 2) {
  3382. $t++;
  3383. }
  3384. if ($v['state'] == 8) {
  3385. $s++;
  3386. }
  3387. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3388. $q++;
  3389. }
  3390. $details[$v['details']] = $v['details'];
  3391. }
  3392. $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'] . '"');
  3393. $rows[$key]['details'] = implode("、", $details);
  3394. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3395. $number = $value['number'];
  3396. $ftime = time() - 15 * 24 * 3600;
  3397. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3398. $rows[$key]['number'] = $g;
  3399. $rows[$key]['c'] = $c;
  3400. $rows[$key]['x'] = $x;
  3401. $rows[$key]['t'] = $t;
  3402. $rows[$key]['s'] = $s;
  3403. $rows[$key]['q'] = $q;
  3404. $rows[$key]['z'] = $z;
  3405. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3406. $features = explode('-', trim($features, '-'));
  3407. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3408. // $pm = $classid;
  3409. // $jm = $classid;
  3410. // foreach($features as $k=>$v)
  3411. // {
  3412. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3413. // {
  3414. // if($typeclass[$v]['bm'] != '')
  3415. // {
  3416. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3417. // }
  3418. // }
  3419. // if($v != 0)
  3420. // {
  3421. // if(!isset($typeclass[$v]))
  3422. // {
  3423. // continue;
  3424. // }
  3425. // if(isset($pm[$typeclass[$v]['classid']]))
  3426. // {
  3427. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3428. // {
  3429. // $tz = explode('|',$typeclass[$v]['zh']);
  3430. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3431. // }
  3432. // else
  3433. // {
  3434. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3435. // }
  3436. // }
  3437. // if(isset($jm[$typeclass[$v]['classid']]))
  3438. // {
  3439. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3440. // }
  3441. // }
  3442. // }
  3443. // $jm = array_filter($jm);
  3444. // $rows[$key]['bs'] = implode("-",$jm);
  3445. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3446. // $zh = implode(" ",$pm);
  3447. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3448. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3449. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3450. // $rows[$key]['features'] = $zh;
  3451. }
  3452. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3453. $final_list = [];
  3454. foreach ($list as $k => $v) {
  3455. if (empty($v['sku'])) {
  3456. continue;
  3457. }
  3458. $final_list[] = [
  3459. "warehouse" => $v["warehouse"],
  3460. "purchase" => $v["purchase"],
  3461. "details" => $v["details"],
  3462. "cpid" => $v["cpid"],
  3463. "dbcontent" => $v["dbcontent"],
  3464. "sku" => $v["sku"],
  3465. "cs" => $v["bm"],
  3466. "bs" => $v["jm"],
  3467. "title" => $v["title"],
  3468. "features" => $v["pm"],
  3469. "cpbz" => $v["cpbz"],
  3470. "sm" => $v["sm"],
  3471. "type" => $v["type"],
  3472. "number" => $v["number"],
  3473. "c" => $v["c"],
  3474. "x" => $v["x"],
  3475. "t" => $v["t"],
  3476. "s" => $v["s"],
  3477. "q" => $v["q"],
  3478. "z" => $v["z"],
  3479. "weight" => $v['weight'],
  3480. ];
  3481. }
  3482. $title = "总进销存统计表";
  3483. $titlename = "<table border=1>
  3484. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3485. <tr align='center'>
  3486. <td>仓库</td>
  3487. <td>供应商</td>
  3488. <td>位置</td>
  3489. <td>库存编码</td>
  3490. <td>类目</td>
  3491. <td>SKU</td>
  3492. <td>用友编码</td>
  3493. <td>用友料号</td>
  3494. <td>商品名称</td>
  3495. <td>商品中文</td>
  3496. <td>产品备注</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>重量(g)</td>
  3507. </tr>
  3508. </table>";
  3509. $filename = $title . ".xls";
  3510. $tail = "";
  3511. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3512. }
  3513. }
  3514. //入库导出
  3515. public function _excelr()
  3516. {
  3517. if (isset($_GET['excel'])) {
  3518. $category = $this->input->get('category', true);
  3519. $size = $this->input->get('size', true);
  3520. $grade = $this->input->get('grade', true);
  3521. $color = $this->input->get('color', true);
  3522. $lowe = $this->input->get('lowe', true);
  3523. $sku = $this->input->get('sku', true);
  3524. $warehouse = $this->input->get('warehouse', true);
  3525. $purchase = $this->input->get('purchase', true);
  3526. $ktime = $this->input->get('ktime', true);
  3527. $jtime = $this->input->get('jtime', true);
  3528. $ktime = strtotime($ktime);
  3529. $jtime = strtotime($jtime);
  3530. $where = "1=1";
  3531. $gj = "";
  3532. $ck = "";
  3533. if ($category) {
  3534. $where .= " and features like '%-$category-%'";
  3535. }
  3536. if ($size) {
  3537. $where .= " and features like '%-$size-%'";
  3538. }
  3539. if ($grade) {
  3540. $where .= " and features like '%-$grade-%'";
  3541. }
  3542. if ($color) {
  3543. $where .= " and features like '%-$color-%'";
  3544. }
  3545. if ($lowe) {
  3546. $where .= " and features like '%-$lowe-%'";
  3547. }
  3548. if ($warehouse) {
  3549. $where .= " and warehouse = '$warehouse'";
  3550. }
  3551. if ($purchase) {
  3552. $where .= " and purchase = '$purchase'";
  3553. }
  3554. if ($sku) {
  3555. $where .= " and sku = '$sku'";
  3556. }
  3557. if ($ktime && $jtime) {
  3558. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3559. }
  3560. //数据排序
  3561. $order_str = "id desc";
  3562. if (empty($page)) {
  3563. $start = 0;
  3564. $perpage = 1;
  3565. } else {
  3566. $start = ($page - 1) * $perpage;
  3567. }
  3568. $list = array();
  3569. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3570. foreach ($rows as $value) {
  3571. $ck = $this->warehouse->read($value['warehouse']);
  3572. $warehouse = $ck['title'];
  3573. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3574. $retreatwarehouse = $tkck['title'];
  3575. $gy = $this->purchase->read($value['purchase']);
  3576. $purchase = $gy['title'];
  3577. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3578. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3579. }
  3580. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3581. $titlename = "<table border=1>
  3582. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3583. <tr align='center'>
  3584. <td>仓库</td>
  3585. <td>SKU</td>
  3586. <td>产品</td>
  3587. <td>时间</td>
  3588. <td>数量</td>
  3589. </tr>
  3590. </table>";
  3591. $filename = $title . ".xls";
  3592. $tail = "";
  3593. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3594. }
  3595. }
  3596. //出库、退库导出
  3597. public function _excelct()
  3598. {
  3599. $classid = $this->classid->sku();
  3600. $pm = $classid;
  3601. $typeclass = array();
  3602. $tc = $this->typeclass->find_all();
  3603. foreach ($tc as $v) {
  3604. $typeclass[$v['id']] = $v;
  3605. }
  3606. $prc = array();
  3607. $purchase = $this->purchase->find_all();
  3608. foreach ($purchase as $k => $v) {
  3609. $prc[$v['id']] = $v['title'];
  3610. }
  3611. if (isset($_GET['excel'])) {
  3612. $wh = array();
  3613. $w = $this->warehouse->find_all('1=1', 'id,title');
  3614. foreach ($w as $v) {
  3615. $wh[$v['id']] = $v['title'];
  3616. }
  3617. $type = $this->input->get('excel', true);
  3618. $category = $this->input->get('category', true);
  3619. $size = $this->input->get('size', true);
  3620. $grade = $this->input->get('grade', true);
  3621. $color = $this->input->get('color', true);
  3622. $lowe = $this->input->get('lowe', true);
  3623. $sku = $this->input->get('sku', true);
  3624. $warehouse = $this->input->get('warehouse', true);
  3625. $lacetype = $this->input->get('lacetype', true);
  3626. $lacecolor = $this->input->get('lacecolor', true);
  3627. $density = $this->input->get('density', true);
  3628. $haircap = $this->input->get('haircap', true);
  3629. $purchase = $this->input->get('purchase', true);
  3630. $title = $this->input->get('title', true);
  3631. $state = $this->input->get('state', true);
  3632. $sid = $this->input->get('sid', true);
  3633. $ktime = $this->input->get('ktime', true);
  3634. $jtime = $this->input->get('jtime', true);
  3635. $ktime = strtotime($ktime);
  3636. $jtime = strtotime($jtime);
  3637. $where = "1=1";
  3638. $gj = "";
  3639. $ck = "";
  3640. if ($category) {
  3641. $where .= " and features like '%-$category-%'";
  3642. }
  3643. if ($size) {
  3644. $where .= " and features like '%-$size-%'";
  3645. }
  3646. if ($grade) {
  3647. $where .= " and features like '%-$grade-%'";
  3648. }
  3649. if ($color) {
  3650. $where .= " and features like '%-$color-%'";
  3651. }
  3652. if ($lowe) {
  3653. $where .= " and features like '%-$lowe-%'";
  3654. }
  3655. if ($warehouse) {
  3656. $where .= " and warehouse = '$warehouse'";
  3657. }
  3658. if ($purchase) {
  3659. $where .= " and purchase = '$purchase'";
  3660. }
  3661. if ($state) {
  3662. $where .= " and state = '$state'";
  3663. }
  3664. if ($lacetype) {
  3665. $where .= " and features like '%-$lacetype-%'";
  3666. }
  3667. if ($lacecolor) {
  3668. $where .= " and features like '%-$lacecolor-%'";
  3669. }
  3670. if ($density) {
  3671. $where .= " and features like '%-$density-%'";
  3672. }
  3673. if ($haircap) {
  3674. $where .= " and features like '%-$haircap-%'";
  3675. }
  3676. if ($title) {
  3677. $title = trim($title, ' ');
  3678. $title = trim($title, ' ');
  3679. $where .= " and title like '%$title%'";
  3680. }
  3681. if ($sku) {
  3682. $sku = trim($sku, ' ');
  3683. $sku = trim($sku, ' ');
  3684. $where .= " and sku like '%$sku%'";
  3685. }
  3686. if ($ktime && $jtime) {
  3687. if ($type == 1) {
  3688. $tl = '出库';
  3689. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3690. } else if ($type == 2) {
  3691. $tl = '退库';
  3692. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3693. } else if ($type == 3) {
  3694. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3695. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3696. } else if ($type == 4) {
  3697. $tl = '出库+零售';
  3698. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3699. } else if ($type == 5) {
  3700. $tl = '零售';
  3701. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3702. }
  3703. }
  3704. $sidwhere = '';
  3705. if ($sid) {
  3706. $sd = "";
  3707. $s = explode(',', trim($sid, ','));
  3708. foreach ($s as $value) {
  3709. $sd .= " id = " . $value . " or";
  3710. }
  3711. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3712. }
  3713. //数据排序
  3714. $order_str = "time desc";
  3715. if (empty($page)) {
  3716. $start = 0;
  3717. $perpage = 1;
  3718. } else {
  3719. $start = ($page - 1) * $perpage;
  3720. }
  3721. //取得信息列表
  3722. if ($type != 3 && $type != 5) {
  3723. if ($type == 1 || $type == 4) {
  3724. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3725. foreach ($info_list as $key => $value) {
  3726. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3727. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3728. $warehouse = $this->warehouse->read($value['warehouse']);
  3729. $info_list[$key]['warehouse'] = $warehouse['title'];
  3730. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3731. $features = explode('-', trim($features, '-'));
  3732. $pm = $classid;
  3733. foreach ($features as $k => $v) {
  3734. if ($v != 0) {
  3735. if (!isset($typeclass[$v])) {
  3736. continue;
  3737. }
  3738. if (isset($pm[$typeclass[$v]['classid']])) {
  3739. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3740. $tz = explode('|', $typeclass[$v]['zh']);
  3741. $pm[$typeclass[$v]['classid']] = $tz[0];
  3742. } else {
  3743. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3744. }
  3745. }
  3746. }
  3747. }
  3748. $zh = implode(" ", $pm);
  3749. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3750. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3751. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3752. $info_list[$key]['features'] = $zh;
  3753. }
  3754. $final_list = [];
  3755. foreach($info_list as $k=>$v){
  3756. $number = "";
  3757. if(!empty($v['orderinfo'])){
  3758. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3759. if(!empty($tmp_info['number'])){
  3760. $number = $tmp_info['number'];
  3761. }
  3762. }
  3763. $final_list[] = [
  3764. 'warehouse'=>$v['warehouse'],
  3765. 'purchase'=>$v['purchase'],
  3766. 'sku'=>$v['sku'],
  3767. 'title'=>$v['title'],
  3768. 'features'=>$v['features'],
  3769. 'label'=>$v['label'],
  3770. 'orderinfo'=>$v['orderinfo'],
  3771. 'number'=>$number,
  3772. 'waybill'=>$v['waybill'],
  3773. 'outk'=>$v['outk'],
  3774. ];
  3775. }
  3776. } else {
  3777. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3778. foreach ($info_list as $key => $value) {
  3779. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3780. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3781. $warehouse = $this->warehouse->read($value['warehouse']);
  3782. $info_list[$key]['warehouse'] = $warehouse['title'];
  3783. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3784. $features = explode('-', trim($features, '-'));
  3785. $pm = $classid;
  3786. foreach ($features as $k => $v) {
  3787. if ($v != 0) {
  3788. if (!isset($typeclass[$v])) {
  3789. continue;
  3790. }
  3791. if (isset($pm[$typeclass[$v]['classid']])) {
  3792. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3793. $tz = explode('|', $typeclass[$v]['zh']);
  3794. $pm[$typeclass[$v]['classid']] = $tz[0];
  3795. } else {
  3796. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3797. }
  3798. }
  3799. }
  3800. }
  3801. $zh = implode(" ", $pm);
  3802. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3803. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3804. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3805. $info_list[$key]['features'] = $zh;
  3806. }
  3807. $final_list = [];
  3808. foreach($info_list as $k=>$v){
  3809. $number = "";
  3810. if(!empty($v['orderinfo'])){
  3811. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3812. if(!empty($tmp_info['number'])){
  3813. $number = $tmp_info['number'];
  3814. }
  3815. }
  3816. $final_list[] = [
  3817. 'warehouse'=>$v['warehouse'],
  3818. 'purchase'=>$v['purchase'],
  3819. 'sku'=>$v['sku'],
  3820. 'title'=>$v['title'],
  3821. 'features'=>$v['features'],
  3822. 'label'=>$v['label'],
  3823. 'orderinfo'=>$v['orderinfo'],
  3824. 'number'=>$number,
  3825. 'waybill'=>$v['waybill'],
  3826. 'retreat'=>$v['retreat'],
  3827. ];
  3828. }
  3829. }
  3830. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3831. $titlename = "<table border=1>
  3832. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3833. <tr align='center'>
  3834. <td>仓库</td>
  3835. <td>供应商</td>
  3836. <td>SKU</td>
  3837. <td>商品名称</td>
  3838. <td>商品中文</td>
  3839. <td>标签</td>
  3840. <td>订单号</td>
  3841. <td>订单编码</td>
  3842. <td>运单号</td>
  3843. <td>" . $tl . "时间(中国时间)</td>
  3844. </tr>
  3845. </table>";
  3846. $filename = $title . ".xls";
  3847. $tail = "";
  3848. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3849. } else if ($type == 5) {
  3850. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3851. foreach ($info_list as $key => $value) {
  3852. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3853. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3854. $warehouse = $this->warehouse->read($value['warehouse']);
  3855. $info_list[$key]['warehouse'] = $warehouse['title'];
  3856. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3857. $features = explode('-', trim($features, '-'));
  3858. $pm = $classid;
  3859. foreach ($features as $k => $v) {
  3860. if ($v != 0) {
  3861. if (!isset($typeclass[$v])) {
  3862. continue;
  3863. }
  3864. if (isset($pm[$typeclass[$v]['classid']])) {
  3865. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3866. $tz = explode('|', $typeclass[$v]['zh']);
  3867. $pm[$typeclass[$v]['classid']] = $tz[0];
  3868. } else {
  3869. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3870. }
  3871. }
  3872. }
  3873. }
  3874. $zh = implode(" ", $pm);
  3875. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3876. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3877. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3878. $info_list[$key]['features'] = $zh;
  3879. }
  3880. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3881. $titlename = "<table border=1>
  3882. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3883. <tr align='center'>
  3884. <td>仓库</td>
  3885. <td>供应商</td>
  3886. <td>SKU</td>
  3887. <td>商品名称</td>
  3888. <td>商品中文</td>
  3889. <td>标签</td>
  3890. <td>" . $tl . "时间(中国时间)</td>
  3891. </tr>
  3892. </table>";
  3893. $filename = $title . ".xls";
  3894. $tail = "";
  3895. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3896. } else {
  3897. /**
  3898. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  3899. $rows = array();$list = array();
  3900. foreach ($info_list as $key=>$value)
  3901. {
  3902. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  3903. }
  3904. **/
  3905. $wh = array();
  3906. $w = $this->warehouse->find_all('1=1', 'id,title');
  3907. foreach ($w as $v) {
  3908. $wh[$v['id']] = $v['title'];
  3909. }
  3910. $wt = array();
  3911. $whlabel_type = $this->whlabel_type->find_all();
  3912. foreach ($whlabel_type as $v) {
  3913. $wt[$v['id']] = $v['title'];
  3914. }
  3915. $classid = $this->classid->sku();
  3916. $list = array();
  3917. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  3918. foreach ($rows as $key => $value) {
  3919. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3920. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3921. $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');
  3922. $details = array();
  3923. $cpid = array();
  3924. $cpbz = array();
  3925. $c = 0;
  3926. $g = 0;
  3927. $x = 0;
  3928. $t = 0;
  3929. $s = 0;
  3930. $q = 0;
  3931. foreach ($sd as $k => $v) {
  3932. if ($v['state'] == 0) {
  3933. $c++;
  3934. }
  3935. if ($v['state'] != 9) {
  3936. $g++;
  3937. }
  3938. if ($v['outk'] > 1) {
  3939. $x++;
  3940. }
  3941. if ($v['retreat'] > 0) {
  3942. $t++;
  3943. }
  3944. if ($v['state'] == 8) {
  3945. $s++;
  3946. }
  3947. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3948. $q++;
  3949. }
  3950. $details[$v['details']] = $v['details'];
  3951. if ($v['cpid'] != 0) {
  3952. $cpid[$v['cpid']] = $v['cpid'];
  3953. }
  3954. if ($v['cpbz'] != '') {
  3955. $cpbz[$v['cpbz']] = $v['cpbz'];
  3956. }
  3957. }
  3958. if (isset($wt[$value['type']])) {
  3959. $rows[$key]['type'] = $wt[$value['type']];
  3960. } else {
  3961. $rows[$key]['type'] = '未设置';
  3962. }
  3963. $rows[$key]['details'] = implode("、", $details);
  3964. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3965. $ftime = time() - 15 * 24 * 3600;
  3966. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3967. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  3968. $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);
  3969. $rows[$key]['c'] = $c;
  3970. $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);
  3971. $rows[$key]['t'] = $t;
  3972. $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'] . '"');
  3973. $rows[$key]['z'] = $z;
  3974. // $jm = $classid;
  3975. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3976. $features = explode('-', trim($features, '-'));
  3977. // $pm = $classid;
  3978. // foreach ($features as $k => $v) {
  3979. // if ($v != 0) {
  3980. // if (!isset($typeclass[$v])) {
  3981. // continue;
  3982. // }
  3983. // if (isset($pm[$typeclass[$v]['classid']])) {
  3984. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3985. // $tz = explode('|', $typeclass[$v]['zh']);
  3986. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3987. // } else {
  3988. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3989. // }
  3990. // if (isset($jm[$typeclass[$v]['classid']])) {
  3991. // if ($typeclass[$v]['jm']) {
  3992. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3993. // }
  3994. // }
  3995. // }
  3996. // }
  3997. // }
  3998. // $zh = implode(" ", $pm);
  3999. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4000. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4001. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4002. // $rows[$key]['features'] = $zh;
  4003. // $jm = array_filter($jm); //去除空值
  4004. // $jm = implode("-", $jm);
  4005. // $rows[$key]['jm'] = $jm;
  4006. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4007. }
  4008. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4009. // echo "<pre>";
  4010. // print_r($tmp_list);
  4011. // die;
  4012. $final_list =[];
  4013. foreach($tmp_list as $k=>$v){
  4014. $final_list[] = [
  4015. "warehouse"=>$v['warehouse'],
  4016. "purchase"=>$v['purchase'],
  4017. "details"=>$v['details'],
  4018. "cpid"=>$v['cpid'],
  4019. "sku"=>$v['sku'],
  4020. "title"=>$v['title'],
  4021. "features"=>$v['pm'],
  4022. "cpbz"=>$v['cpbz'],
  4023. "sm"=>$v['sm'],
  4024. "type"=>$v['type'],
  4025. "g"=>$v["g"],
  4026. "c"=>$v["c"],
  4027. "x"=>$v["x"],
  4028. "t"=>$v["t"],
  4029. "z"=>$v["z"],
  4030. "jm"=>$v["jm"],
  4031. "weight"=>$v["weight"],
  4032. "asd"=>$v["asd"],
  4033. ];
  4034. }
  4035. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4036. $titlename = "<table border=1>
  4037. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4038. <tr align='center'>
  4039. <td>仓库</td>
  4040. <td>供应商</td>
  4041. <td>位置</td>
  4042. <td>库存编码</td>
  4043. <td>SKU</td>
  4044. <td>商品名称</td>
  4045. <td>商品中文</td>
  4046. <td>产品备注</td>
  4047. <td>说明</td>
  4048. <td>类型</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. </tr>
  4058. </table>";
  4059. $filename = $title . ".xls";
  4060. $tail = "";
  4061. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4062. }
  4063. }
  4064. }
  4065. //出库+入库数据整合
  4066. public function _excelcr()
  4067. {
  4068. if (isset($_GET['excel'])) {
  4069. $type = $this->input->get('excel', true);
  4070. $category = $this->input->get('category', true);
  4071. $size = $this->input->get('size', true);
  4072. $grade = $this->input->get('grade', true);
  4073. $color = $this->input->get('color', true);
  4074. $lowe = $this->input->get('lowe', true);
  4075. $sku = $this->input->get('sku', true);
  4076. $warehouse = $this->input->get('warehouse', true);
  4077. $purchase = $this->input->get('purchase', true);
  4078. $state = $this->input->get('state', true);
  4079. $sid = $this->input->get('sid', true);
  4080. $ktime = $this->input->get('ktime', true);
  4081. $jtime = $this->input->get('jtime', true);
  4082. $ktime = strtotime($ktime);
  4083. $jtime = strtotime($jtime);
  4084. $where = "1=1";
  4085. $gj = "";
  4086. $ck = "";
  4087. if ($category) {
  4088. $where .= " and features like '%-$category-%'";
  4089. }
  4090. if ($size) {
  4091. $where .= " and features like '%-$size-%'";
  4092. }
  4093. if ($grade) {
  4094. $where .= " and features like '%-$grade-%'";
  4095. }
  4096. if ($color) {
  4097. $where .= " and features like '%-$color-%'";
  4098. }
  4099. if ($lowe) {
  4100. $where .= " and features like '%-$lowe-%'";
  4101. }
  4102. if ($warehouse) {
  4103. $where .= " and warehouse = '$warehouse'";
  4104. }
  4105. if ($purchase) {
  4106. $where .= " and purchase = '$purchase'";
  4107. }
  4108. if ($state) {
  4109. $where .= " and state = '$state'";
  4110. }
  4111. if ($sku) {
  4112. $where .= " and sku like '%$sku%'";
  4113. }
  4114. if ($ktime && $jtime) {
  4115. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4116. }
  4117. $sidwhere = '';
  4118. if ($sid) {
  4119. $sd = "";
  4120. $s = explode(',', trim($sid, ','));
  4121. foreach ($s as $value) {
  4122. $sd .= " id = " . $value . " or";
  4123. }
  4124. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4125. }
  4126. //取得信息列表
  4127. $timeread = $ktime;
  4128. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4129. $timelist = array();
  4130. for ($i = 0; $i < $timenum; $i++) {
  4131. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4132. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4133. }
  4134. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4135. //echo "<pre>";
  4136. //print_r($info_list);
  4137. //exit();
  4138. $rows = array();
  4139. $list = array();
  4140. foreach ($info_list as $key => $value) {
  4141. $thistime = $timelist;
  4142. if (isset($rows[strtolower($value['sku'])])) {
  4143. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4144. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4145. }
  4146. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4147. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4148. }
  4149. } else {
  4150. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4151. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4152. }
  4153. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4154. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4155. }
  4156. $rows[strtolower($value['sku'])] = $thistime;
  4157. }
  4158. }
  4159. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4160. <head>
  4161. <!--[if gte mso 9]><xml>
  4162. <x:ExcelWorkbook>
  4163. <x:ExcelWorksheets>
  4164. <x:ExcelWorksheet>
  4165. <x:Name>EXCEL</x:Name>
  4166. <x:WorksheetOptions>
  4167. <x:Print>
  4168. <x:ValidPrinterInfo />
  4169. </x:Print>
  4170. </x:WorksheetOptions>
  4171. </x:ExcelWorksheet>
  4172. </x:ExcelWorksheets>
  4173. </x:ExcelWorkbook>
  4174. </xml>
  4175. <![endif]-->
  4176. </head><body>";
  4177. $str .= "<table border=1><tr><td>SKU</td>";
  4178. foreach ($timelist as $k => $v) {
  4179. $str .= "<td>" . $k . "出库</td>";
  4180. $str .= "<td>" . $k . "入库</td>";
  4181. }
  4182. $str .= "</tr></table>";
  4183. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4184. foreach ($rows as $key => $val) {
  4185. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4186. foreach ($val as $k => $v) {
  4187. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4188. if ($val[$k]['r'] > 0) {
  4189. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4190. } else {
  4191. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4192. }
  4193. }
  4194. $str .= "</tr>";
  4195. }
  4196. $str .= "</table>";
  4197. $str .= "</body></html>";
  4198. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4199. header("Content-type: application/octet-stream");
  4200. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4201. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4202. header("Pragma: no-cache");
  4203. header("Expires: 0");
  4204. exit($str);
  4205. }
  4206. }
  4207. //数量调整模板导出
  4208. public function _presetout()
  4209. {
  4210. if (isset($_GET['excel'])) {
  4211. $where = "sku != 'Preset' and purchase != 0";
  4212. //数据排序
  4213. $order_str = "id desc";
  4214. if (empty($page)) {
  4215. $start = 0;
  4216. $perpage = 1;
  4217. } else {
  4218. $start = ($page - 1) * $perpage;
  4219. }
  4220. //取得信息列表
  4221. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4222. $rows = array();
  4223. $list = array();
  4224. foreach ($info_list as $value) {
  4225. $warehouse = $this->warehouse->read($value['warehouse']);
  4226. $number = $value['number'];
  4227. $ftime = time() - 15 * 24 * 3600;
  4228. $purchase = $this->purchase->read($value['purchase']);
  4229. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4230. }
  4231. $title = "库存模板";
  4232. $titlename = "<table border=1>
  4233. <tr align='center'>
  4234. <td>仓库</td>
  4235. <td>供应商编码</td>
  4236. <td>SKU</td>
  4237. <td>增减数量(正数或负数)</td>
  4238. <td>增减备注</td>
  4239. <td>扣减方式:0减少库存1删除库存</td>
  4240. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4241. <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4242. </tr>
  4243. </table>";
  4244. $filename = $title . ".xls";
  4245. $tail = "";
  4246. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4247. }
  4248. }
  4249. //数量调整模板导入
  4250. public function _presetedit()
  4251. {
  4252. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4253. $config['upload_path'] = '.' . $dir;
  4254. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4255. $config['allowed_types'] = 'xls|xlsx|csv';
  4256. $config['max_size'] = 10240;
  4257. $this->load->library('upload', $config);
  4258. $this->upload->initialize($config);
  4259. if ($this->upload->do_upload('userfile')) {
  4260. $full_path = $dir . $this->upload->data('file_name');
  4261. $fileName = '.' . $full_path;
  4262. if (!file_exists($fileName)) {
  4263. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4264. exit;
  4265. } else {
  4266. require_once "./data/excel/PHPExcel/IOFactory.php";
  4267. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4268. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4269. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4270. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4271. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4272. ++$column; //如果列数大于26行
  4273. $list = array();
  4274. for ($i = 2; $i <= $row; $i++) // 行数循环
  4275. {
  4276. $data = array();
  4277. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4278. {
  4279. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4280. }
  4281. $list[] = $data;
  4282. }
  4283. }
  4284. $i = 0;
  4285. $j = 0;
  4286. $ed = array();
  4287. foreach ($list as $key => $value) {
  4288. $time = time();
  4289. if ($value['0'] == "") {
  4290. continue;
  4291. }
  4292. $warehouse = $this->warehouse->get_title($value['0']);
  4293. $purchase = $this->purchase->get_bm($value['1']);
  4294. $sku = $value['2'];
  4295. $num = $value['3']; //调整数量
  4296. $text = $value['4']; //扣减说明
  4297. $type = $value['5']; //调整方式0扣减1删除
  4298. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4299. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4300. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4301. if (!$purchase) //如果没有这个SKU
  4302. {
  4303. $ed[] = array($purchase . '-不存在此供应商编码');
  4304. $j++;
  4305. continue;
  4306. }
  4307. if (!$d) //如果没有这个SKU
  4308. {
  4309. $ed[] = array($sku . '-库存中不存在此SKU');
  4310. $j++;
  4311. continue;
  4312. }
  4313. if (!isset($warehouse['id'])) {
  4314. $ed[] = array($sku . '-仓库名错误!');
  4315. $j++;
  4316. continue;
  4317. }
  4318. if ($type != '0' && $type != '1') {
  4319. $ed[] = array($sku . '-扣减方式填写错误!');
  4320. $j++;
  4321. continue;
  4322. }
  4323. if ($num < 0) //扣减库存
  4324. {
  4325. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4326. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4327. $j++;
  4328. continue;
  4329. }
  4330. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4331. if (count($data) < abs($num)) {
  4332. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4333. $j++;
  4334. continue;
  4335. }
  4336. if ($type == 0) //如果扣减方式为 扣减库存
  4337. {
  4338. for ($i = 0; $i < abs($num); $i++) {
  4339. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4340. }
  4341. } else if ($type == 1) {
  4342. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4343. if (count($zt) > 0) {
  4344. $ed[] = array($sku . '-有在途库存无法删除!');
  4345. $j++;
  4346. continue;
  4347. }
  4348. for ($i = 0; $i < abs($num); $i++) {
  4349. $this->whlabel->remove($data[$i]['id']);
  4350. }
  4351. }
  4352. } else if ($num > 0) //增加库存
  4353. {
  4354. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4355. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4356. $j++;
  4357. continue;
  4358. }
  4359. $post['sku'] = $d['sku'];
  4360. $post['shop'] = $d['shop'];
  4361. $post['warehouse'] = $warehouse['id'];
  4362. $post['purchase'] = $purchase['id'];
  4363. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4364. $post['state'] = 0;
  4365. $post['title'] = $d['title'];
  4366. $post['number'] = $d['number'];
  4367. $post['features'] = $d['features'];
  4368. $post['enter'] = $time;
  4369. $post['time'] = $time; //操作时间
  4370. $post['rktype'] = $rktype;
  4371. for ($i = 0; $i < $num; $i++) {
  4372. $post['label'] = time() . rand(100, 999) . $i;
  4373. $this->whlabel->insert($post);
  4374. }
  4375. }
  4376. sleep(1); //防止入库时间一样,需要延迟1秒
  4377. }
  4378. if ($j > 0) {
  4379. $tt = date('Ymd', time());
  4380. $title = '库存导入错误信息-' . $tt;
  4381. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4382. $tail = "\n";
  4383. $filename = $title . ".xls";
  4384. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4385. $dir = '/data/excel/' . $time . '/';
  4386. $file_name = 'error_' . $time . rand(1000, 9999);
  4387. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4388. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4389. fwrite($myfile, $ecl);
  4390. fclose($myfile);
  4391. $error = $dir . $file_name . '.xls';
  4392. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4393. exit;
  4394. } else {
  4395. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4396. exit;
  4397. }
  4398. }
  4399. }
  4400. //笛卡儿积
  4401. function cp($ps, $sets, $list)
  4402. {
  4403. $result = array();
  4404. $j = 0;
  4405. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4406. if ($i == 0) {
  4407. $result = $sets[$i];
  4408. }
  4409. $tmp = array();
  4410. foreach ($result as $res) {
  4411. foreach ($sets[$i + 1] as $set) {
  4412. $tmp[] = $res . ',' . $set;
  4413. }
  4414. }
  4415. $result = $tmp;
  4416. }
  4417. $this->db->trans_begin();
  4418. foreach ($result as $v) {
  4419. $post = array();
  4420. $title = "";
  4421. $num = "";
  4422. $data = explode(',', $v);
  4423. for ($i = 0; $i < count($list); $i++) {
  4424. $post[$list[$i]] = $data[$i];
  4425. $typeclass = $this->typeclass->read($data[$i]);
  4426. $title = $title . $typeclass['title'] . " ";
  4427. if ($data[$i] != 0) {
  4428. $num .= $data[$i]; //所有数据ID拼接
  4429. }
  4430. }
  4431. foreach ($ps as $kp => $vp) {
  4432. $post[$kp] = $vp;
  4433. }
  4434. $post['number'] = $num;
  4435. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4436. if ($info_list) {
  4437. $j++;
  4438. } else {
  4439. $skunum = $this->whlabel->find_count();
  4440. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4441. $post['title'] = rtrim($title, ' ');
  4442. $this->whlabel->insert($post);
  4443. }
  4444. }
  4445. if ($this->db->trans_status() === FALSE) {
  4446. $this->db->trans_commit();
  4447. return NULL;
  4448. } else {
  4449. $this->db->trans_commit();
  4450. return $j;
  4451. }
  4452. }
  4453. public function _kj($arg_array)
  4454. {
  4455. if (isset($_POST['sku'])) {
  4456. $time = time();
  4457. $sku = $this->input->post('sku', true);
  4458. $warehouse = $this->input->post('warehouse', true);
  4459. $num = $this->input->post('num', true);
  4460. $text = $this->input->post('text', true);
  4461. $purchase = $this->input->post('purchase', true);
  4462. $cktype = $this->input->post('cktype', true);
  4463. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4464. if ($cktype != 1 && $text == '') {
  4465. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4466. exit;
  4467. }
  4468. if ($num > count($order)) {
  4469. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4470. exit;
  4471. } else {
  4472. for ($i = 0; $i < $num; $i++) {
  4473. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4474. }
  4475. }
  4476. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4477. exit;
  4478. }
  4479. $uid = $this->whlabel->read($arg_array[0]);
  4480. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4481. $this->data['data'] = $uid;
  4482. $this->_Template('whlabel_kj', $this->data);
  4483. }
  4484. public function _summary($arg_array)
  4485. {
  4486. $prc = array();
  4487. $purchase = $this->purchase->find_all();
  4488. foreach ($purchase as $k => $v) {
  4489. $prc[$v['id']] = $v['title'];
  4490. }
  4491. if (isset($_GET['excel'])) {
  4492. $ktime = $this->input->get('ktime', true);
  4493. $jtime = $this->input->get('jtime', true);
  4494. $ktime = strtotime($ktime);
  4495. $jtime = strtotime($jtime);
  4496. $where = "1=1";
  4497. if ($ktime && $jtime) {
  4498. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4499. }
  4500. //数据排序
  4501. $order_str = "time desc";
  4502. if (empty($page)) {
  4503. $start = 0;
  4504. $perpage = 1;
  4505. } else {
  4506. $start = ($page - 1) * $perpage;
  4507. }
  4508. //取得信息列表
  4509. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4510. foreach ($info_list as $key => $value) {
  4511. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4512. $warehouse = $this->warehouse->read($value['warehouse']);
  4513. $info_list[$key]['warehouse'] = $warehouse['title'];
  4514. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4515. $details = array();
  4516. $cpid = array();
  4517. foreach ($x as $k => $v) {
  4518. if ($v['details'] != '') {
  4519. $details[$v['details']] = $v['details'];
  4520. }
  4521. if ($v['cpid'] != 0) {
  4522. $cpid[$v['cpid']] = $v['cpid'];
  4523. }
  4524. }
  4525. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4526. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4527. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4528. $info_list[$key]['s'] = $s;
  4529. $info_list[$key]['x'] = count($x);
  4530. }
  4531. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4532. $titlename = "<table border=1>
  4533. <tr align='center'>
  4534. <td>仓库</td>
  4535. <td>供应商</td>
  4536. <td>出库位置</td>
  4537. <td>出库编码</td>
  4538. <td>SKU</td>
  4539. <td>产品名</td>
  4540. <td>总剩余库存</td>
  4541. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4542. </tr>
  4543. </table>";
  4544. $filename = $title . ".xls";
  4545. $tail = "";
  4546. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4547. }
  4548. }
  4549. //usps发货清单
  4550. public function _manifest()
  4551. {
  4552. if (isset($_POST['manifest'])) {
  4553. $wltext = $this->input->post('wltext', true);
  4554. $time = time() - 16 * 3600;
  4555. $ptime = strtotime(date('Y-m-d', $time));
  4556. $waybill = array();
  4557. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4558. foreach ($fullorder as $v) {
  4559. $waybill[$v['waybill']] = $v['waybill'];
  4560. }
  4561. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4562. foreach ($fullordersmt as $v) {
  4563. $waybill[$v['waybill']] = $v['waybill'];
  4564. }
  4565. $wltext = explode(';', $wltext);
  4566. foreach ($wltext as $v) {
  4567. if (isset($waybill[$v])) {
  4568. unset($waybill[$v]);
  4569. }
  4570. }
  4571. $data = $this->usps->get_manifest($waybill);
  4572. if (isset($data['Description'])) {
  4573. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4574. exit;
  4575. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4576. $bctime = date('Ymd', time());
  4577. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4578. echo json_encode(array('msg' => $pdf, 'success' => true));
  4579. exit;
  4580. } else {
  4581. echo json_encode(array('msg' => $data, 'success' => false));
  4582. exit;
  4583. }
  4584. }
  4585. }
  4586. public function _pdf($pdf, $title, $bctime)
  4587. {
  4588. $pdf_path = './data/pdf/' . $bctime . '/';
  4589. $file_base64 = $pdf;
  4590. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4591. $file_base64 = base64_decode($file_base64);
  4592. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4593. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4594. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4595. }
  4596. /**
  4597. *
  4598. *
  4599. *
  4600. 进销存占单异常索引
  4601. *
  4602. *
  4603. *
  4604. **/
  4605. public function _abnormal()
  4606. {
  4607. $post = $this->input->post(NULL, TRUE);
  4608. if (isset($post['page'])) {
  4609. $page = $this->input->post('page', true);
  4610. $perpage = $this->input->post('perpage', true);
  4611. $sku = $this->input->post('sku', true);
  4612. $where = "1=1";
  4613. //数据排序
  4614. $order_str = "id desc";
  4615. if (empty($page)) {
  4616. $start = 0;
  4617. $perpage = 1;
  4618. } else {
  4619. $start = ($page - 1) * $perpage;
  4620. }
  4621. //取得信息列表
  4622. $info_list = $this->whlabel->find_all($where, '*');
  4623. $rows = array();
  4624. $list = array();
  4625. foreach ($info_list as $key => $value) {
  4626. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4627. }
  4628. foreach ($rows as $value) {
  4629. $warehouse = $this->warehouse->read($value['warehouse']);
  4630. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4631. $number = $value['number'];
  4632. $ftime = time() - 15 * 24 * 3600;
  4633. if ($value['shop'] != '') {
  4634. $shop = $value['shop'];
  4635. $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');
  4636. $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');
  4637. $order = array_merge($orderdlz, $ordersmt);
  4638. $od = 0;
  4639. $a = '';
  4640. $orid = '';
  4641. foreach ($order as $v) {
  4642. $or = explode('|', ltrim($v['whlabel'], '|'));
  4643. for ($i = 0; $i < count($or); $i++) {
  4644. $orod = explode('-', $or[$i]);
  4645. if ($orod[0] == $number) {
  4646. $od += $orod[1];
  4647. }
  4648. }
  4649. $orid .= $v['number'] . '-';
  4650. }
  4651. } else {
  4652. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4653. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4654. $order = array_merge($orderdlz, $ordersmt);
  4655. $od = 0;
  4656. $a = '';
  4657. $orid = '';
  4658. $qt = array();
  4659. foreach ($order as $v) {
  4660. $or = explode('|', ltrim($v['whlabel'], '|'));
  4661. for ($i = 0; $i < count($or); $i++) {
  4662. $orod = explode('-', $or[$i]);
  4663. if ($orod[0] == $number) {
  4664. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4665. if ($czzs > 0) {
  4666. if (isset($qt[$v['shop']])) {
  4667. if ($qt[$v['shop']] < $orod[1]) {
  4668. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4669. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4670. } else {
  4671. $qt[$v['shop']] -= $orod[1];
  4672. }
  4673. } else {
  4674. $qt[$v['shop']] = $czzs;
  4675. }
  4676. } else {
  4677. $od += $orod[1];
  4678. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4679. }
  4680. }
  4681. }
  4682. }
  4683. }
  4684. $z = $od . '(' . $orid . ')'; //查看订单号
  4685. //$z = $od;
  4686. if ($od > $c) {
  4687. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4688. }
  4689. }
  4690. $listdata = array_slice($list, $start, $perpage);
  4691. $total = count($list);
  4692. $pagenum = ceil($total / $perpage);
  4693. $over = $total - ($start + $perpage);
  4694. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4695. echo json_encode($rows);
  4696. exit;
  4697. }
  4698. $this->_Template('whlabel_abnormal', $this->data);
  4699. }
  4700. /**
  4701. *
  4702. *
  4703. *
  4704. 进销存占单异常索引
  4705. *
  4706. *
  4707. *
  4708. **/
  4709. public function _error()
  4710. {
  4711. $post = $this->input->post(NULL, TRUE);
  4712. if (isset($post['page'])) {
  4713. $page = $this->input->post('page', true);
  4714. $perpage = $this->input->post('perpage', true);
  4715. $sku = $this->input->post('sku', true);
  4716. $warehouse = $this->input->post('warehouse', true);
  4717. $ktime = $this->input->post('ktime', true);
  4718. $jtime = $this->input->post('jtime', true);
  4719. $ktime = strtotime($ktime);
  4720. $jtime = strtotime($jtime);
  4721. $where = "sku != 'Preset'";
  4722. $gj = '';
  4723. if ($sku) {
  4724. $where .= " and sku like '%$sku%'";
  4725. } else {
  4726. if ($ktime && $jtime) {
  4727. $gj = " and time > '$ktime' and time < '$jtime'";
  4728. }
  4729. }
  4730. if ($warehouse) {
  4731. $where .= " and warehouse = '$warehouse'";
  4732. }
  4733. //数据排序
  4734. $order_str = "id desc";
  4735. if (empty($page)) {
  4736. $start = 0;
  4737. $perpage = 1;
  4738. } else {
  4739. $start = ($page - 1) * $perpage;
  4740. }
  4741. //取得信息列表
  4742. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4743. $rows = array();
  4744. $list = array();
  4745. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4746. // foreach ($info_list as $value)
  4747. // {
  4748. // $warehouse = $this->warehouse->read($value['warehouse']);
  4749. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4750. // $number = $value['number'];$ftime = time()-15*24*3600;
  4751. // if($c < 1)
  4752. // {
  4753. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4754. // }
  4755. // }
  4756. $warehouse_list = $this->warehouse->find_all();
  4757. $warehouse_list = array_column($warehouse_list, null, 'id');
  4758. foreach ($info_list as $value) {
  4759. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4760. 'title' => "",
  4761. ];
  4762. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4763. $number = $value['number'];
  4764. $ftime = time() - 15 * 24 * 3600;
  4765. if ($c < 1) {
  4766. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4767. }
  4768. }
  4769. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4770. // $query = $this->db->query($sql);
  4771. // $info_list = $query->result_array();
  4772. // $sql_two = "select title,id from crowd_warehouse";
  4773. // $query_two = $this->db->query($sql_two);
  4774. // $warehouse_list = $query_two->result_array();
  4775. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4776. // foreach ($info_list as $value)
  4777. // {
  4778. // if(isset($warehouse_arr[$value['warehouse']])){
  4779. // $warehouse = $warehouse_arr[$value['warehouse']];
  4780. // }else{
  4781. // $warehouse = [
  4782. // 'id'=>0,
  4783. // 'title'=>"异常",
  4784. // ];
  4785. // }
  4786. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4787. // $number = $value['number'];$ftime = time()-15*24*3600;
  4788. // if($c < 1)
  4789. // {
  4790. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4791. // }
  4792. // }
  4793. $listdata = array_slice($list, $start, $perpage);
  4794. $total = count($list);
  4795. $pagenum = ceil($total / $perpage);
  4796. $over = $total - ($start + $perpage);
  4797. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4798. echo json_encode($rows);
  4799. exit;
  4800. }
  4801. if (isset($post['s'])) {
  4802. $id_arr = $this->input->post('s');
  4803. $id_arr = explode(',', trim($id_arr, ','));
  4804. if (!$id_arr) {
  4805. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4806. exit;
  4807. }
  4808. //循环删除记录
  4809. foreach ($id_arr as $v) {
  4810. $dd = $this->whlabel->read($v);
  4811. if (!isset($dd['id'])) {
  4812. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4813. exit;
  4814. }
  4815. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4816. if (isset($zt[0])) {
  4817. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4818. exit;
  4819. }
  4820. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4821. foreach ($deldd as $vv) {
  4822. $this->whlabel->remove($vv['id']);
  4823. }
  4824. }
  4825. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4826. exit;
  4827. }
  4828. $this->_Template('whlabel_error', $this->data);
  4829. }
  4830. public function _errorexcel()
  4831. {
  4832. $post = $this->input->post(NULL, TRUE);
  4833. if (isset($_GET['page'])) {
  4834. $page = $this->input->get('page', true);
  4835. $perpage = $this->input->get('perpage', true);
  4836. $sku = $this->input->get('sku', true);
  4837. $warehouse = $this->input->get('warehouse', true);
  4838. $ktime = $this->input->get('ktime', true);
  4839. $jtime = $this->input->get('jtime', true);
  4840. $ktime = strtotime($ktime);
  4841. $jtime = strtotime($jtime);
  4842. $where = "sku != 'Preset'";
  4843. $gj = '';
  4844. if ($sku) {
  4845. $where .= " and sku like '%$sku%'";
  4846. } else {
  4847. if ($ktime && $jtime) {
  4848. $gj = " and time > '$ktime' and time < '$jtime'";
  4849. }
  4850. }
  4851. if ($warehouse) {
  4852. $where .= " and warehouse = '$warehouse'";
  4853. }
  4854. //数据排序
  4855. $order_str = "id desc";
  4856. if (empty($page)) {
  4857. $start = 0;
  4858. $perpage = 1;
  4859. } else {
  4860. $start = ($page - 1) * $perpage;
  4861. }
  4862. //取得信息列表
  4863. $rows = array();
  4864. $list = array();
  4865. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4866. foreach ($info_list as $value) {
  4867. $warehouse = $this->warehouse->read($value['warehouse']);
  4868. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4869. $number = $value['number'];
  4870. $ftime = time() - 15 * 24 * 3600;
  4871. if ($c < 1) {
  4872. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4873. }
  4874. }
  4875. $title = "0库存汇总";
  4876. $titlename = "<table border=1>
  4877. <tr align='center'>
  4878. <td>仓库</td>
  4879. <td>SKU</td>
  4880. <td>产品</td>
  4881. <td>当前库存</td>
  4882. </tr>
  4883. </table>";
  4884. $filename = $title . ".xls";
  4885. $tail = "";
  4886. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4887. }
  4888. }
  4889. /**
  4890. *
  4891. *
  4892. * 占单
  4893. *
  4894. *
  4895. **/
  4896. public function _kcyz()
  4897. {
  4898. $post = $this->input->post(NULL, TRUE);
  4899. if (isset($post['warehouse'])) {
  4900. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  4901. exit; //不再使用
  4902. $warehouse = $this->input->post('warehouse', true);
  4903. $whlabel = $this->input->post('whlabel', true);
  4904. $id = $this->input->post('id', true);
  4905. $shop = $this->input->post('shop', true);
  4906. $number = $this->input->post('number', true);
  4907. if (!$whlabel || $whlabel == '|') {
  4908. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  4909. exit;
  4910. }
  4911. $pp = explode('|', trim($whlabel, '|'));
  4912. $x = 0;
  4913. $save = array();
  4914. foreach ($pp as $va) {
  4915. $num = explode('-', $va);
  4916. if ($number) {
  4917. $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 = '')"); //通用
  4918. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  4919. } else {
  4920. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  4921. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  4922. }
  4923. $x++;
  4924. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  4925. $save[] = $x - 1;
  4926. continue; //提前先加X不然出错,所以要减1
  4927. }
  4928. }
  4929. if (isset($save[0])) {
  4930. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  4931. exit;
  4932. } else {
  4933. echo json_encode(array('success' => true));
  4934. exit;
  4935. }
  4936. }
  4937. }
  4938. public function _db()
  4939. {
  4940. $post = $this->input->post(NULL, TRUE);
  4941. if (isset($post['page'])) {
  4942. $page = $this->input->post('page', true);
  4943. $perpage = $this->input->post('perpage', true);
  4944. $sku = $this->input->post('sku', true);
  4945. $number = $this->input->post('number', true);
  4946. $warehouse = $this->input->post('warehouse', true);
  4947. $purchase = $this->input->post('purchase', true);
  4948. $orderinfo = $this->input->post('orderinfo', true);
  4949. $waybill = $this->input->post('waybill', true);
  4950. $category = $this->input->post('category', true);
  4951. $size = $this->input->post('size', true);
  4952. $grade = $this->input->post('grade', true);
  4953. $color = $this->input->post('color', true);
  4954. $lowe = $this->input->post('lowe', true);
  4955. $state = $this->input->post('state', true);
  4956. $label = $this->input->post('label', true);
  4957. $timetk = $this->input->post('timetkk', true);
  4958. $timetj = $this->input->post('timetjj', true);
  4959. $timetk = strtotime($timetk);
  4960. $timetj = strtotime($timetj);
  4961. $where = "dbtime > 0";
  4962. if ($timetk && $timetj) {
  4963. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  4964. }
  4965. if ($sku) {
  4966. $where .= " and sku = '$sku'";
  4967. }
  4968. if ($warehouse) {
  4969. $where .= " and warehouse = '$warehouse'";
  4970. if ($warehouse == 12) {
  4971. $w = 'specialstock';
  4972. } else {
  4973. $w = 'whlabel';
  4974. }
  4975. }
  4976. if ($purchase) {
  4977. $where .= " and purchase = '$purchase'";
  4978. }
  4979. if ($category) {
  4980. $where .= " and features like '%-$category-%'";
  4981. }
  4982. if ($size) {
  4983. $where .= " and features like '%-$size-%'";
  4984. }
  4985. if ($grade) {
  4986. $where .= " and features like '%-$grade-%'";
  4987. }
  4988. if ($color) {
  4989. $where .= " and features like '%-$color-%'";
  4990. }
  4991. if ($lowe) {
  4992. $where .= " and features like '%-$lowe-%'";
  4993. }
  4994. if ($state != '') {
  4995. $where .= " and state = '$state'";
  4996. }
  4997. //数据排序
  4998. $order_str = "dbtime desc";
  4999. if (empty($page)) {
  5000. $start = 0;
  5001. $perpage = 1;
  5002. } else {
  5003. $start = ($page - 1) * $perpage;
  5004. }
  5005. //取得信息列表
  5006. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5007. foreach ($info_list as $key => $value) {
  5008. $warehouse = $this->$w->read($value['warehouse']);
  5009. $info_list[$key]['warehouse'] = $warehouse['title'];
  5010. $purchase = $this->purchase->read($value['purchase']);
  5011. $info_list[$key]['purchase'] = $purchase['title'];
  5012. if ($value['enter'] != 0) {
  5013. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5014. } else {
  5015. $info_list[$key]['enter'] = "";
  5016. }
  5017. if ($value['dbtime'] != 0) {
  5018. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5019. } else {
  5020. $info_list[$key]['dbtime'] = "";
  5021. }
  5022. if ($value['state'] == 0) {
  5023. $info_list[$key]['state'] = "在库";
  5024. } else if ($value['state'] == 1) {
  5025. $info_list[$key]['state'] = "出库";
  5026. } else if ($value['state'] == 2) {
  5027. $info_list[$key]['state'] = "退库";
  5028. } else if ($value['state'] == 3) {
  5029. $info_list[$key]['state'] = "调拨中";
  5030. } else if ($value['state'] == 4) {
  5031. $info_list[$key]['state'] = "再加工";
  5032. } else if ($value['state'] == 5) {
  5033. $info_list[$key]['state'] = "维修中";
  5034. } else if ($value['state'] == 6) {
  5035. $info_list[$key]['state'] = "盘亏";
  5036. } else if ($value['state'] == 7) {
  5037. $info_list[$key]['state'] = "更换标签";
  5038. } else if ($value['state'] == 8) {
  5039. $info_list[$key]['state'] = "其它";
  5040. } else if ($value['state'] == 9) {
  5041. $info_list[$key]['state'] = "预设";
  5042. }
  5043. }
  5044. $total = $this->whlabel->find_count($where);
  5045. $pagenum = ceil($total / $perpage);
  5046. $over = $total - ($start + $perpage);
  5047. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5048. echo json_encode($rows);
  5049. exit;
  5050. }
  5051. if (isset($post['outsku'])) {
  5052. $time = time();
  5053. $cz = $this->input->post('cz', true);
  5054. $label = $this->input->post('outsku', true);
  5055. $sl = $this->input->post('sl', true);
  5056. $num = $this->input->post('num', true);
  5057. //$warehouse = $this->input->post('warehouse',true);
  5058. if (!$sl) {
  5059. $sl = 1;
  5060. }
  5061. if (!$warehouse) {
  5062. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5063. exit;
  5064. }
  5065. $dblabel = $this->whlabellabel->get_label($label);
  5066. if ($dblabel) {
  5067. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5068. if (count($data) < 1) {
  5069. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5070. exit;
  5071. }
  5072. if (count($data) < $num) {
  5073. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5074. exit;
  5075. }
  5076. for ($i = 0; $i < $sl; $i++) {
  5077. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5078. }
  5079. echo json_encode(array('success' => true));
  5080. exit;
  5081. } else {
  5082. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5083. exit;
  5084. }
  5085. }
  5086. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5087. $this->_Template('whlabel_db', $this->data);
  5088. }
  5089. public function _dbrk()
  5090. {
  5091. $post = $this->input->post(NULL, TRUE);
  5092. if (isset($post['page'])) {
  5093. $page = $this->input->post('page', true);
  5094. $perpage = $this->input->post('perpage', true);
  5095. $sku = $this->input->post('sku', true);
  5096. $number = $this->input->post('number', true);
  5097. $warehouse = $this->input->post('warehouse', true);
  5098. $purchase = $this->input->post('purchase', true);
  5099. $orderinfo = $this->input->post('orderinfo', true);
  5100. $waybill = $this->input->post('waybill', true);
  5101. $category = $this->input->post('category', true);
  5102. $size = $this->input->post('size', true);
  5103. $grade = $this->input->post('grade', true);
  5104. $color = $this->input->post('color', true);
  5105. $lowe = $this->input->post('lowe', true);
  5106. $state = $this->input->post('state', true);
  5107. $label = $this->input->post('label', true);
  5108. $ctime = $this->input->post('ctime', true);
  5109. $timetk = $this->input->post('timetkk', true);
  5110. $timetj = $this->input->post('timetjj', true);
  5111. $timetk = strtotime($timetk);
  5112. $timetj = strtotime($timetj);
  5113. $where = "dbtime > 0";
  5114. if ($timetk && $timetj) {
  5115. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5116. }
  5117. if ($sku) {
  5118. $where .= " and sku = '$sku'";
  5119. }
  5120. if ($warehouse) {
  5121. $where .= " and warehouse = '$warehouse'";
  5122. }
  5123. if ($purchase) {
  5124. $where .= " and purchase = '$purchase'";
  5125. }
  5126. if ($category) {
  5127. $where .= " and features like '%-$category-%'";
  5128. }
  5129. if ($size) {
  5130. $where .= " and features like '%-$size-%'";
  5131. }
  5132. if ($grade) {
  5133. $where .= " and features like '%-$grade-%'";
  5134. }
  5135. if ($color) {
  5136. $where .= " and features like '%-$color-%'";
  5137. }
  5138. if ($lowe) {
  5139. $where .= " and features like '%-$lowe-%'";
  5140. }
  5141. if ($state != '') {
  5142. $where .= " and state = '$state'";
  5143. }
  5144. //数据排序
  5145. $order_str = "dbtime desc";
  5146. if (empty($page)) {
  5147. $start = 0;
  5148. $perpage = 1;
  5149. } else {
  5150. $start = ($page - 1) * $perpage;
  5151. }
  5152. //取得信息列表
  5153. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5154. foreach ($info_list as $key => $value) {
  5155. $warehouse = $this->warehouse->read($value['warehouse']);
  5156. $info_list[$key]['warehouse'] = $warehouse['title'];
  5157. $purchase = $this->purchase->read($value['purchase']);
  5158. $info_list[$key]['purchase'] = $purchase['title'];
  5159. if ($value['enter'] != 0) {
  5160. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5161. } else {
  5162. $info_list[$key]['enter'] = "";
  5163. }
  5164. if ($value['dbtime'] != 0) {
  5165. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5166. } else {
  5167. $info_list[$key]['dbtime'] = "";
  5168. }
  5169. if ($value['state'] == 0) {
  5170. $info_list[$key]['state'] = "在库";
  5171. } else if ($value['state'] == 1) {
  5172. $info_list[$key]['state'] = "出库";
  5173. } else if ($value['state'] == 2) {
  5174. $info_list[$key]['state'] = "退库";
  5175. } else if ($value['state'] == 3) {
  5176. $info_list[$key]['state'] = "调拨中";
  5177. } else if ($value['state'] == 4) {
  5178. $info_list[$key]['state'] = "再加工";
  5179. } else if ($value['state'] == 5) {
  5180. $info_list[$key]['state'] = "维修中";
  5181. } else if ($value['state'] == 6) {
  5182. $info_list[$key]['state'] = "盘亏";
  5183. } else if ($value['state'] == 7) {
  5184. $info_list[$key]['state'] = "更换标签";
  5185. } else if ($value['state'] == 8) {
  5186. $info_list[$key]['state'] = "其它";
  5187. } else if ($value['state'] == 9) {
  5188. $info_list[$key]['state'] = "预设";
  5189. }
  5190. }
  5191. $total = $this->whlabel->find_count($where);
  5192. $pagenum = ceil($total / $perpage);
  5193. $over = $total - ($start + $perpage);
  5194. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5195. echo json_encode($rows);
  5196. exit;
  5197. }
  5198. if (isset($post['rsku'])) {
  5199. $cz = $this->input->post('cz', true);
  5200. $label = $this->input->post('rsku', true);
  5201. $sl = $this->input->post('sl', true);
  5202. $warehouse = $this->input->post('warehouse', true);
  5203. if (!$sl) {
  5204. $sl = 1;
  5205. }
  5206. if (!$warehouse) {
  5207. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5208. exit;
  5209. }
  5210. $dblabel = $this->whlabellabel->get_label($label);
  5211. if ($dblabel) {
  5212. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5213. if (count($data) < 1) {
  5214. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5215. exit;
  5216. }
  5217. if ($sl > count($data)) {
  5218. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5219. exit;
  5220. }
  5221. $time = time();
  5222. for ($i = 0; $i < $sl; $i++) {
  5223. $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']);
  5224. }
  5225. echo json_encode(array('success' => true));
  5226. exit;
  5227. } else {
  5228. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5229. exit;
  5230. }
  5231. }
  5232. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5233. $this->_Template('whlabel_dbrk', $this->data);
  5234. }
  5235. public function _whlabelczdc()
  5236. {
  5237. if (isset($_GET['excel'])) {
  5238. //数据排序
  5239. $order_str = "id desc";
  5240. if (empty($page)) {
  5241. $start = 0;
  5242. $perpage = 1;
  5243. } else {
  5244. $start = ($page - 1) * $perpage;
  5245. }
  5246. $state = $this->input->get('state', true);
  5247. $sku = $this->input->get('sku', true);
  5248. $ctime = $this->input->get('ctime', true);
  5249. $category = $this->input->get('category', true);
  5250. $size = $this->input->get('size', true);
  5251. $grade = $this->input->get('grade', true);
  5252. $color = $this->input->get('color', true);
  5253. $lowe = $this->input->get('lowe', true);
  5254. $timetk = $this->input->get('timetkk', true);
  5255. $timetj = $this->input->get('timetjj', true);
  5256. $timetk = strtotime($timetk);
  5257. $timetj = strtotime($timetj);
  5258. $where = "dbtime > 0";
  5259. if ($timetk && $timetj) {
  5260. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5261. }
  5262. if ($category) {
  5263. $where .= " and features like '%-$category-%'";
  5264. }
  5265. if ($size) {
  5266. $where .= " and features like '%-$size-%'";
  5267. }
  5268. if ($grade) {
  5269. $where .= " and features like '%-$grade-%'";
  5270. }
  5271. if ($color) {
  5272. $where .= " and features like '%-$color-%'";
  5273. }
  5274. if ($lowe) {
  5275. $where .= " and features like '%-$lowe-%'";
  5276. }
  5277. //取得信息列表
  5278. $info_list = $this->whlabel->find_all($where, '*');
  5279. $rows = array();
  5280. $list = array();
  5281. foreach ($info_list as $key => $value) {
  5282. $rows[$value['sku']] = $value; //所有数据sku
  5283. }
  5284. foreach ($rows as $value) {
  5285. $warehouse = $this->warehouse->read($value['warehouse']);
  5286. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5287. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5288. if ($value['orderinfo'] == 0) {
  5289. $info_list[$key]['orderinfo'] = "";
  5290. }
  5291. if ($value['waybill'] == 0) {
  5292. $info_list[$key]['waybill'] = "";
  5293. }
  5294. if ($value['state'] == 0) {
  5295. $value['state'] = "在库";
  5296. } else if ($value['state'] == 3) {
  5297. $value['state'] = "调拨中";
  5298. }
  5299. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5300. }
  5301. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5302. $titlename = "<table border=1>
  5303. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5304. <tr align='center'>
  5305. <td>SKU</td>
  5306. <td>产品</td>
  5307. <td>调拨数量</td>
  5308. <td>入库数量</td>
  5309. </tr>
  5310. </table>";
  5311. $filename = $title . ".xls";
  5312. $tail = "";
  5313. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5314. }
  5315. }
  5316. public function _print($arg_array)
  5317. {
  5318. if (isset($_SESSION['api'])) {
  5319. $user = $this->user->get_api($_SESSION['api']);
  5320. $usp = $user;
  5321. $fgshop = "";
  5322. $sid = "";
  5323. $wid = "";
  5324. $wtype = "";
  5325. $usersp = explode('|', trim($user['shop'], '|'));
  5326. $userwh = explode('|', trim($user['warehouse'], '|'));
  5327. foreach ($usersp as $value) {
  5328. $fgshop .= " shop = " . $value . " or";
  5329. $sid .= " id = " . $value . " or";
  5330. }
  5331. foreach ($userwh as $value) {
  5332. $wid .= " id = " . $value . " or";
  5333. $wtype .= " type = " . $value . " or";
  5334. }
  5335. }
  5336. $post = $this->input->post(NULL, TRUE);
  5337. if (isset($post['tmsku'])) {
  5338. $tmsku = $this->input->post('tmsku', true);
  5339. if (is_numeric($tmsku)) {
  5340. $yyh = $this->whlabellabel->get_label($tmsku);
  5341. } else {
  5342. $yyh = $this->whlabellabel->get_sku($tmsku);
  5343. }
  5344. if ($yyh) {
  5345. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5346. exit;
  5347. } else {
  5348. echo json_encode(array('success' => false));
  5349. exit;
  5350. }
  5351. }
  5352. $classid = $this->classid->sku();
  5353. $pm = $classid;
  5354. $scsku = $classid;
  5355. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5356. if (isset($post['warehouse'])) {
  5357. if ($post['warehouse']) {
  5358. $list = array();
  5359. $num = "";
  5360. $title = "";
  5361. $features = "";
  5362. $order = 0;
  5363. $post['shop'] = '';
  5364. $brand = $this->input->post('brand', true);
  5365. if ($brand != '0,') {
  5366. $b = $this->brand->read(rtrim($brand, ','));
  5367. if ($b) {
  5368. $post['shop'] = str_replace('|', ',', $b['shop']);
  5369. }
  5370. }
  5371. $post['details'] = $this->input->post('details', true); //打印数量
  5372. $xbqnum = $this->input->post('xbqnum', true);
  5373. $post['purchase'] = $this->input->post('purchase', true);
  5374. $post['warehouse'] = $this->input->post('warehouse', true);
  5375. $post['purchase'] = $this->input->post('purchase', true);
  5376. $post['retreatwarehouse'] = $post['warehouse'];
  5377. $post['cpbz'] = $this->input->post('cpbz', true);
  5378. $post['state'] = 9;
  5379. $category = $this->input->post('category', true);
  5380. $list['category'] = $category;
  5381. $list['hairtype'] = $this->input->post('hairtype', true);
  5382. $list['grade'] = $this->input->post('grade', true);
  5383. $size = $this->input->post('size', true);
  5384. $list['size'] = rtrim($size, ',');
  5385. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5386. $list['extension'] = $this->input->post('extension', true);
  5387. if ($category == 1297) {
  5388. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5389. }
  5390. if ($category == 1702) {
  5391. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5392. $list['syother'] = $this->input->post('syother', true);
  5393. }
  5394. if ($category == 133) {
  5395. $list['fittype'] = $this->input->post('fittype', true);
  5396. $list['acother'] = $this->input->post('acother', true);
  5397. }
  5398. $list['color'] = $this->input->post('color', true);
  5399. $list['lowe'] = $this->input->post('lowe', true);
  5400. if ($category == 127) {
  5401. $list['type'] = $this->input->post('type', true);
  5402. $list['headroad'] = $this->input->post('headroad', true);
  5403. $list['density'] = $this->input->post('density', true);
  5404. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5405. $list['lacesize'] = $this->input->post('lacesize', true);
  5406. }
  5407. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5408. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5409. }
  5410. if ($category == 128) {
  5411. $list['lacetype'] = $this->input->post('lacetype', true);
  5412. $list['haircap'] = $this->input->post('haircap', true);
  5413. $list['density'] = $this->input->post('density', true);
  5414. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5415. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5416. $list['wigother'] = $this->input->post('wigother', true);
  5417. $list['wigother1'] = $this->input->post('wigother1', true);
  5418. $list['wigother2'] = $this->input->post('wigother2', true);
  5419. }
  5420. if ($category == 129) {
  5421. $list['wide'] = $this->input->post('wide', true);
  5422. }
  5423. if ($category == 131) {
  5424. $list['gifttype'] = $this->input->post('gifttype', true);
  5425. $list['giftother'] = $this->input->post('giftother', true);
  5426. }
  5427. if ($category == 134) {
  5428. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5429. }
  5430. if ($category == 1297) {
  5431. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5432. $list['sywigother'] = $this->input->post('sywigother', true);
  5433. }
  5434. if ($category == 130 || $category == 133 || $category == 1702) {
  5435. $list['items'] = $this->input->post('items', true);
  5436. $list['weight'] = $this->input->post('weight', true);
  5437. }
  5438. if ($category == 1702) {
  5439. $list['syhairther'] = $this->input->post('syhairther', true);
  5440. }
  5441. foreach ($list as $k => $v) {
  5442. if ($v != 0) {
  5443. $num .= $v;
  5444. $features .= $v . '-';
  5445. $post[$k] = $v;
  5446. $typeclass = $this->typeclass->read($v);
  5447. if (isset($pm[$typeclass['classid']])) {
  5448. if (stripos($typeclass['zh'], '|') !== false) {
  5449. $exzh = explode('|', $typeclass['zh']);
  5450. $pm[$typeclass['classid']] = $exzh[0];
  5451. } else {
  5452. $pm[$typeclass['classid']] = $typeclass['zh'];
  5453. }
  5454. }
  5455. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5456. if ($k != 'size') {
  5457. $title .= $typeclass['title'] . " ";
  5458. }
  5459. }
  5460. }
  5461. $typeclass = $this->typeclass->read($list['size']);
  5462. $title .= $typeclass['title'];
  5463. $time = time();
  5464. $post['title'] = rtrim($title, ' ');
  5465. $post['number'] = $num;
  5466. $post['features'] = '-' . $features;
  5467. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5468. $featurespp = explode('-', trim($featurespp, '-'));
  5469. if (isset($featurespp[5])) {
  5470. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5471. } else {
  5472. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5473. }
  5474. $post['enter'] = $time;
  5475. $post['time'] = $time; //操作时间
  5476. $scsku = implode("-", $scsku);
  5477. $zh = implode(" ", $pm);
  5478. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5479. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5480. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5481. $post['sku'] = $bqsku;
  5482. $label = time() . rand(0, 9);
  5483. $post['label'] = $label;
  5484. $cpid = $this->whlabellabel->find_count();
  5485. $post['cpid'] = $cpid + 1;
  5486. $cpid = $post['cpid'];
  5487. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5488. //if($whlabelbarcode)
  5489. //{
  5490. //$post['label'] = $whlabelbarcode['label'];
  5491. //if(!$this->whlabellabel->insert($post))
  5492. //{
  5493. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5494. //}
  5495. //}
  5496. //else
  5497. //{
  5498. $this->db->trans_begin();
  5499. $this->whlabellabel->insert($post);
  5500. //$this->whlabelbarcode->insert($post);
  5501. if ($this->db->trans_status() === TRUE) {
  5502. $this->db->trans_commit();
  5503. } else {
  5504. $this->db->trans_rollback();
  5505. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5506. exit;
  5507. }
  5508. //}
  5509. $warehouse_name = "";
  5510. $warehouse = $post['warehouse'];
  5511. if($warehouse == 12){
  5512. $warehouse_name = "特殊库存库";
  5513. }
  5514. // if($warehouse == 13){
  5515. // $warehouse_name = "许昌仓";
  5516. // }
  5517. // if($warehouse == 5){
  5518. // $warehouse_name = "美国店";
  5519. // }
  5520. // if($warehouse == 16){
  5521. // $warehouse_name = "定制头套仓";
  5522. // }
  5523. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5524. if(!empty($warehouse_name)){
  5525. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5526. }
  5527. $purchase = $this->purchase->read($post['purchase']);
  5528. 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));
  5529. exit; //特殊仓目前不需要仓库选项
  5530. }
  5531. }
  5532. if (isset($_SESSION['api'])) {
  5533. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5534. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5535. $this->data['wlshop'] = $wlshop;
  5536. $this->data['warehouse'] = $warehouse;
  5537. }
  5538. $whlabelwz = $this->whlabelwz->find_all();
  5539. $this->data['whlabelwz'] = $whlabelwz;
  5540. $this->_Template('whlabel_print', $this->data);
  5541. }
  5542. public function _usaprint($arg_array)
  5543. {
  5544. if (isset($_SESSION['api'])) {
  5545. $user = $this->user->get_api($_SESSION['api']);
  5546. $usp = $user;
  5547. $fgshop = "";
  5548. $sid = "";
  5549. $wid = "";
  5550. $wtype = "";
  5551. $usersp = explode('|', trim($user['shop'], '|'));
  5552. $userwh = explode('|', trim($user['warehouse'], '|'));
  5553. foreach ($usersp as $value) {
  5554. $fgshop .= " shop = " . $value . " or";
  5555. $sid .= " id = " . $value . " or";
  5556. }
  5557. foreach ($userwh as $value) {
  5558. $wid .= " id = " . $value . " or";
  5559. $wtype .= " type = " . $value . " or";
  5560. }
  5561. }
  5562. $post = $this->input->post(NULL, TRUE);
  5563. if (isset($post['tmsku'])) {
  5564. $tmsku = $this->input->post('tmsku', true);
  5565. if (is_numeric($tmsku)) {
  5566. $yyh = $this->whlabellabel->get_label($tmsku);
  5567. } else {
  5568. $yyh = $this->whlabellabel->get_sku($tmsku);
  5569. }
  5570. if ($yyh) {
  5571. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5572. exit;
  5573. } else {
  5574. echo json_encode(array('success' => false));
  5575. exit;
  5576. }
  5577. }
  5578. $classid = $this->classid->sku();
  5579. $pm = $classid;
  5580. $scsku = $classid;
  5581. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5582. if (isset($post['warehouse'])) {
  5583. if ($post['warehouse']) {
  5584. $list = array();
  5585. $num = "";
  5586. $title = "";
  5587. $features = "";
  5588. $order = 0;
  5589. $post['shop'] = '';
  5590. $brand = $this->input->post('brand', true);
  5591. if ($brand != '0,') {
  5592. $b = $this->brand->read(rtrim($brand, ','));
  5593. if ($b) {
  5594. $post['shop'] = str_replace('|', ',', $b['shop']);
  5595. }
  5596. }
  5597. $post['details'] = $this->input->post('details', true); //打印数量
  5598. $xbqnum = $this->input->post('xbqnum', true);
  5599. $post['purchase'] = $this->input->post('purchase', true);
  5600. $post['warehouse'] = $this->input->post('warehouse', true);
  5601. $post['purchase'] = $this->input->post('purchase', true);
  5602. $post['retreatwarehouse'] = $post['warehouse'];
  5603. $post['cpbz'] = $this->input->post('cpbz', true);
  5604. $post['state'] = 9;
  5605. $category = $this->input->post('category', true);
  5606. $list['category'] = $category;
  5607. $list['hairtype'] = $this->input->post('hairtype', true);
  5608. $list['grade'] = $this->input->post('grade', true);
  5609. $size = $this->input->post('size', true);
  5610. $list['size'] = rtrim($size, ',');
  5611. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5612. $list['extension'] = $this->input->post('extension', true);
  5613. if ($category == 1297) {
  5614. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5615. }
  5616. if ($category == 1702) {
  5617. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5618. $list['syother'] = $this->input->post('syother', true);
  5619. }
  5620. if ($category == 133) {
  5621. $list['fittype'] = $this->input->post('fittype', true);
  5622. $list['acother'] = $this->input->post('acother', true);
  5623. }
  5624. $list['color'] = $this->input->post('color', true);
  5625. $list['lowe'] = $this->input->post('lowe', true);
  5626. if ($category == 127) {
  5627. $list['type'] = $this->input->post('type', true);
  5628. $list['headroad'] = $this->input->post('headroad', true);
  5629. $list['density'] = $this->input->post('density', true);
  5630. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5631. $list['lacesize'] = $this->input->post('lacesize', true);
  5632. }
  5633. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5634. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5635. }
  5636. if ($category == 128) {
  5637. $list['lacetype'] = $this->input->post('lacetype', true);
  5638. $list['haircap'] = $this->input->post('haircap', true);
  5639. $list['density'] = $this->input->post('density', true);
  5640. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5641. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5642. $list['wigother'] = $this->input->post('wigother', true);
  5643. $list['wigother1'] = $this->input->post('wigother1', true);
  5644. $list['wigother2'] = $this->input->post('wigother2', true);
  5645. }
  5646. if ($category == 129) {
  5647. $list['wide'] = $this->input->post('wide', true);
  5648. }
  5649. if ($category == 131) {
  5650. $list['gifttype'] = $this->input->post('gifttype', true);
  5651. $list['giftother'] = $this->input->post('giftother', true);
  5652. }
  5653. if ($category == 134) {
  5654. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5655. }
  5656. if ($category == 1297) {
  5657. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5658. $list['sywigother'] = $this->input->post('sywigother', true);
  5659. }
  5660. if ($category == 130 || $category == 133 || $category == 1702) {
  5661. $list['items'] = $this->input->post('items', true);
  5662. $list['weight'] = $this->input->post('weight', true);
  5663. }
  5664. if ($category == 1702) {
  5665. $list['syhairther'] = $this->input->post('syhairther', true);
  5666. }
  5667. foreach ($list as $k => $v) {
  5668. if ($v != 0) {
  5669. $num .= $v;
  5670. $features .= $v . '-';
  5671. $post[$k] = $v;
  5672. $typeclass = $this->typeclass->read($v);
  5673. if (isset($pm[$typeclass['classid']])) {
  5674. if (stripos($typeclass['zh'], '|') !== false) {
  5675. $exzh = explode('|', $typeclass['zh']);
  5676. $pm[$typeclass['classid']] = $exzh[0];
  5677. } else {
  5678. $pm[$typeclass['classid']] = $typeclass['zh'];
  5679. }
  5680. }
  5681. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5682. if ($k != 'size') {
  5683. $title .= $typeclass['title'] . " ";
  5684. }
  5685. }
  5686. }
  5687. $typeclass = $this->typeclass->read($list['size']);
  5688. $title .= $typeclass['title'];
  5689. $time = time();
  5690. $post['title'] = rtrim($title, ' ');
  5691. $post['number'] = $num;
  5692. $post['features'] = '-' . $features;
  5693. $fp = $this->whlabel->get_features($post['features']);
  5694. if (!$fp) {
  5695. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5696. exit;
  5697. }
  5698. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5699. $featurespp = explode('-', trim($featurespp, '-'));
  5700. if (isset($featurespp[5])) {
  5701. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5702. } else {
  5703. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5704. }
  5705. $post['enter'] = $time;
  5706. $post['time'] = $time; //操作时间
  5707. $scsku = implode("-", $scsku);
  5708. $zh = implode(" ", $pm);
  5709. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5710. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5711. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5712. $post['sku'] = $fp['sku'];
  5713. $post['label'] = $fp['sku'];
  5714. $cpid = $this->whlabellabel->find_count();
  5715. $post['cpid'] = $cpid + 1;
  5716. $cpid = $post['cpid'];
  5717. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5718. //if($whlabelbarcode)
  5719. //{
  5720. //$post['label'] = $whlabelbarcode['label'];
  5721. //if(!$this->whlabellabel->insert($post))
  5722. //{
  5723. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5724. //}
  5725. //}
  5726. //else
  5727. //{
  5728. $this->db->trans_begin();
  5729. $this->whlabellabel->insert($post);
  5730. //$this->whlabelbarcode->insert($post);
  5731. if ($this->db->trans_status() === TRUE) {
  5732. $this->db->trans_commit();
  5733. } else {
  5734. $this->db->trans_rollback();
  5735. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5736. exit;
  5737. }
  5738. //}
  5739. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5740. $purchase = $this->purchase->read($post['purchase']);
  5741. 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));
  5742. exit; //特殊仓目前不需要仓库选项
  5743. }
  5744. }
  5745. if (isset($_SESSION['api'])) {
  5746. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5747. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5748. $this->data['wlshop'] = $wlshop;
  5749. $this->data['warehouse'] = $warehouse;
  5750. }
  5751. $whlabelwz = $this->whlabelwz->find_all();
  5752. $this->data['whlabelwz'] = $whlabelwz;
  5753. $this->_Template('whlabel_usaprint', $this->data);
  5754. }
  5755. public function _printrk($arg_array)
  5756. {
  5757. $prc = array();
  5758. $purchase = $this->purchase->find_all();
  5759. foreach ($purchase as $k => $v) {
  5760. $prc[$v['id']] = $v['title'];
  5761. }
  5762. $post = $this->input->post(NULL, TRUE);
  5763. if (isset($post['page'])) {
  5764. $page = $this->input->post('page', true);
  5765. $perpage = $this->input->post('perpage', true);
  5766. $sku = $this->input->post('sku', true);
  5767. $bs = $this->input->post('bs', true);
  5768. $number = $this->input->post('number', true);
  5769. $warehouse = $this->input->post('warehouse', true);
  5770. $purchase = $this->input->post('purchase', true);
  5771. $orderinfo = $this->input->post('orderinfo', true);
  5772. $waybill = $this->input->post('waybill', true);
  5773. $category = $this->input->post('category', true);
  5774. $size = $this->input->post('size', true);
  5775. $grade = $this->input->post('grade', true);
  5776. $color = $this->input->post('color', true);
  5777. $lowe = $this->input->post('lowe', true);
  5778. $state = $this->input->post('state', true);
  5779. $label = $this->input->post('label', true);
  5780. $timetk = $this->input->post('ktime', true);
  5781. $timetj = $this->input->post('jtime', true);
  5782. $timetk = strtotime($timetk);
  5783. $timetj = strtotime($timetj);
  5784. $where = "1=1 ";
  5785. if ($timetk && $timetj) {
  5786. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5787. }
  5788. if ($sku) {
  5789. $where .= " and sku = '$sku'";
  5790. }
  5791. if ($bs != '') {
  5792. $where .= " and bs = '$bs'";
  5793. }
  5794. if ($number) {
  5795. $where .= " and number = '$number'";
  5796. }
  5797. if ($warehouse) {
  5798. $where .= " and warehouse = '$warehouse'";
  5799. }
  5800. if ($purchase) {
  5801. $where .= " and purchase = '$purchase'";
  5802. }
  5803. if ($orderinfo) {
  5804. $where .= " and orderinfo = '$orderinfo'";
  5805. }
  5806. if ($waybill) {
  5807. $where .= " and waybill = '$waybill'";
  5808. }
  5809. if ($category) {
  5810. $where .= " and features like '%-$category-%'";
  5811. }
  5812. if ($size) {
  5813. $where .= " and features like '%-$size-%'";
  5814. }
  5815. if ($grade) {
  5816. $where .= " and features like '%-$grade-%'";
  5817. }
  5818. if ($color) {
  5819. $where .= " and features like '%-$color-%'";
  5820. }
  5821. if ($lowe) {
  5822. $where .= " and features like '%-$lowe-%'";
  5823. }
  5824. if ($label) {
  5825. $where .= " and label = '$label'";
  5826. }
  5827. if ($state || $state == 0) {
  5828. $where .= " and state = '$state'";
  5829. }
  5830. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5831. //数据排序
  5832. $order_str = "enter desc";
  5833. if (empty($page)) {
  5834. $start = 0;
  5835. $perpage = 1;
  5836. } else {
  5837. $start = ($page - 1) * $perpage;
  5838. }
  5839. //取得信息列表
  5840. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5841. foreach ($info_list as $key => $value) {
  5842. $warehouse = $this->warehouse->read($value['warehouse']);
  5843. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5844. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5845. if ($value['state'] == 0) {
  5846. $info_list[$key]['state'] = "在库";
  5847. } else if ($value['state'] == 1) {
  5848. $info_list[$key]['state'] = "出库";
  5849. } else if ($value['state'] == 2) {
  5850. $info_list[$key]['state'] = "退库";
  5851. } else if ($value['state'] == 3) {
  5852. $info_list[$key]['state'] = "调拨中";
  5853. } else if ($value['state'] == 4) {
  5854. $info_list[$key]['state'] = "再加工";
  5855. } else if ($value['state'] == 5) {
  5856. $info_list[$key]['state'] = "维修中";
  5857. } else if ($value['state'] == 6) {
  5858. $info_list[$key]['state'] = "盘亏";
  5859. } else if ($value['state'] == 7) {
  5860. $info_list[$key]['state'] = "更换标签";
  5861. } else if ($value['state'] == 8) {
  5862. $info_list[$key]['state'] = "其它";
  5863. } else if ($value['state'] == 9) {
  5864. $info_list[$key]['state'] = "预设";
  5865. } else if ($value['state'] == 10) {
  5866. $info_list[$key]['state'] = "美店零售";
  5867. }
  5868. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5869. }
  5870. $total = $this->$ck->find_count($where);
  5871. $pagenum = ceil($total / $perpage);
  5872. $over = $total - ($start + $perpage);
  5873. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5874. echo json_encode($rows);
  5875. exit;
  5876. }
  5877. if (isset($post['tmsku'])) {
  5878. $time = time();
  5879. $tmsku = $this->input->post('tmsku', true);
  5880. //$post['shop'] = $this->input->post('shop',true);
  5881. $num = $this->input->post('num', true);
  5882. $rktype = $this->input->post('rktype', true);
  5883. if ($num > 200) {
  5884. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5885. exit;
  5886. }
  5887. if (!$rktype) {
  5888. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5889. }
  5890. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5891. /**
  5892. $wz = array();
  5893. foreach ($rk as $key=>$value)
  5894. {
  5895. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5896. }
  5897. if(count($wz) > 1)
  5898. {
  5899. $wz = array_values($wz);
  5900. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  5901. }
  5902. **/
  5903. if (isset($rk[0]['purchase'])) {
  5904. $rk = $rk[0];
  5905. $j = 0;
  5906. $post['purchase'] = $rk['purchase'];
  5907. $post['warehouse'] = $rk['warehouse'];
  5908. $post['retreatwarehouse'] = $rk['warehouse'];
  5909. $post['sku'] = $rk['sku'];
  5910. $post['number'] = $rk['number'];
  5911. $post['features'] = $rk['features'];
  5912. $post['title'] = $rk['title'];
  5913. $post['enter'] = $time;
  5914. $post['time'] = $time;
  5915. $post['bs'] = 1;
  5916. $post['shop'] = $rk['shop'];
  5917. $post['details'] = $rk['details'];
  5918. $post['cpid'] = $rk['cpid'];
  5919. $post['cpbz'] = $rk['cpbz'];
  5920. //$post['rktype'] = $rktype;
  5921. $warehouse = $this->warehouse->read($rk['warehouse']);
  5922. if ($warehouse['bdck'] == '') {
  5923. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  5924. exit;
  5925. } else {
  5926. $bdck = $warehouse['bdck'];
  5927. }
  5928. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  5929. if (isset($pdwz['details'])) {
  5930. if ($pdwz['details'] != $post['details']) {
  5931. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  5932. exit;
  5933. }
  5934. }
  5935. $post['featurespp'] = $rk['featurespp'];
  5936. if ($post['warehouse'] == '5') {
  5937. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5938. if ($yza) {
  5939. if ($post['features'] != $yza[0]['features']) {
  5940. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  5941. exit;
  5942. }
  5943. }
  5944. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5945. if ($yzb) {
  5946. if ($post['sku'] != $yzb[0]['sku']) {
  5947. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  5948. exit;
  5949. }
  5950. }
  5951. }
  5952. for ($i = 0; $i < $num; $i++) {
  5953. $post['label'] = time() . rand(100, 999) . $i;
  5954. if ($this->$bdck->insert($post)) {
  5955. $j++;
  5956. }
  5957. }
  5958. /**
  5959. if($post['warehouse'] != 12)
  5960. {
  5961. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5962. }
  5963. **/
  5964. if ($j == $num) {
  5965. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  5966. exit;
  5967. } else {
  5968. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  5969. exit;
  5970. }
  5971. } else {
  5972. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  5973. exit;
  5974. }
  5975. }
  5976. $this->_Template('whlabel_printrk', $this->data);
  5977. }
  5978. public function _printxzrk($arg_array)
  5979. {
  5980. $post = $this->input->post(NULL, TRUE);
  5981. if (isset($post['wzid'])) {
  5982. $time = time();
  5983. $id = $this->input->post('wzid', true);
  5984. //$post['shop'] = $this->input->post('shop',true);
  5985. $num = 1;
  5986. $rk = $this->whlabellabel->read($id);
  5987. if (isset($rk['purchase'])) {
  5988. $x = 0;
  5989. $post['purchase'] = $rk['purchase'];
  5990. $post['warehouse'] = $rk['warehouse'];
  5991. $post['retreatwarehouse'] = $rk['warehouse'];
  5992. $post['sku'] = $rk['sku'];
  5993. $post['number'] = $rk['number'];
  5994. $post['features'] = $rk['features'];
  5995. $post['title'] = $rk['title'];
  5996. $post['enter'] = $time;
  5997. $post['time'] = $time;
  5998. $post['bs'] = 1;
  5999. $post['shop'] = $rk['shop'];
  6000. $post['details'] = $rk['details'];
  6001. $post['cpid'] = $rk['cpid'];
  6002. $post['cpbz'] = $rk['cpbz'];
  6003. $warehouse = $this->warehouse->read($rk['warehouse']);
  6004. if ($warehouse['bdck'] == '') {
  6005. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6006. exit;
  6007. } else {
  6008. $bdck = $warehouse['bdck'];
  6009. }
  6010. $post['featurespp'] = $rk['featurespp'];
  6011. $this->db->trans_begin();
  6012. for ($i = 0; $i < $num; $i++) {
  6013. $post['label'] = time() . rand(100, 999) . $i;
  6014. $this->$bdck->insert($post);
  6015. }
  6016. /**
  6017. if($post['warehouse'] != 12)
  6018. {
  6019. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6020. }
  6021. **/
  6022. if ($this->db->trans_status() === TRUE) {
  6023. $this->db->trans_commit();
  6024. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6025. exit;
  6026. } else {
  6027. $this->db->trans_rollback();
  6028. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6029. exit;
  6030. }
  6031. } else {
  6032. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6033. exit;
  6034. }
  6035. }
  6036. }
  6037. public function _printck($arg_array)
  6038. {
  6039. $prc = array();
  6040. $purchase = $this->purchase->find_all();
  6041. foreach ($purchase as $k => $v) {
  6042. $prc[$v['id']] = $v['title'];
  6043. }
  6044. $post = $this->input->post(NULL, TRUE);
  6045. if (isset($post['page'])) {
  6046. $page = $this->input->post('page', true);
  6047. $perpage = $this->input->post('perpage', true);
  6048. $sku = $this->input->post('sku', true);
  6049. $bs = $this->input->post('bs', true);
  6050. $number = $this->input->post('number', true);
  6051. $warehouse = $this->input->post('warehouse', true);
  6052. $purchase = $this->input->post('purchase', true);
  6053. $orderinfo = $this->input->post('orderinfo', true);
  6054. $waybill = $this->input->post('waybill', true);
  6055. $category = $this->input->post('category', true);
  6056. $size = $this->input->post('size', true);
  6057. $grade = $this->input->post('grade', true);
  6058. $color = $this->input->post('color', true);
  6059. $lowe = $this->input->post('lowe', true);
  6060. $state = $this->input->post('state', true);
  6061. $label = $this->input->post('label', true);
  6062. $timetk = $this->input->post('ktime', true);
  6063. $timetj = $this->input->post('jtime', true);
  6064. $timetk = strtotime($timetk);
  6065. $timetj = strtotime($timetj);
  6066. $where = "state=1 ";
  6067. if ($timetk && $timetj) {
  6068. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6069. }
  6070. if ($sku) {
  6071. $where .= " and sku = '$sku'";
  6072. }
  6073. if ($bs != '') {
  6074. $where .= " and bs = '$bs'";
  6075. }
  6076. if ($number) {
  6077. $where .= " and number = '$number'";
  6078. }
  6079. if ($warehouse) {
  6080. $where .= " and warehouse = '$warehouse'";
  6081. }
  6082. if ($purchase) {
  6083. $where .= " and purchase = '$purchase'";
  6084. }
  6085. if ($orderinfo) {
  6086. $where .= " and orderinfo = '$orderinfo'";
  6087. }
  6088. if ($waybill) {
  6089. $where .= " and waybill = '$waybill'";
  6090. }
  6091. if ($category) {
  6092. $where .= " and features like '%-$category-%'";
  6093. }
  6094. if ($size) {
  6095. $where .= " and features like '%-$size-%'";
  6096. }
  6097. if ($grade) {
  6098. $where .= " and features like '%-$grade-%'";
  6099. }
  6100. if ($color) {
  6101. $where .= " and features like '%-$color-%'";
  6102. }
  6103. if ($lowe) {
  6104. $where .= " and features like '%-$lowe-%'";
  6105. }
  6106. if ($label) {
  6107. $where .= " and label = '$label'";
  6108. }
  6109. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6110. //数据排序
  6111. $order_str = "outk desc";
  6112. if (empty($page)) {
  6113. $start = 0;
  6114. $perpage = 1;
  6115. } else {
  6116. $start = ($page - 1) * $perpage;
  6117. }
  6118. //取得信息列表
  6119. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6120. foreach ($info_list as $key => $value) {
  6121. $warehouse = $this->warehouse->read($value['warehouse']);
  6122. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6123. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6124. if ($value['state'] == 0) {
  6125. $info_list[$key]['state'] = "在库";
  6126. } else if ($value['state'] == 1) {
  6127. $info_list[$key]['state'] = "出库";
  6128. } else if ($value['state'] == 2) {
  6129. $info_list[$key]['state'] = "退库";
  6130. } else if ($value['state'] == 3) {
  6131. $info_list[$key]['state'] = "调拨中";
  6132. } else if ($value['state'] == 4) {
  6133. $info_list[$key]['state'] = "再加工";
  6134. } else if ($value['state'] == 5) {
  6135. $info_list[$key]['state'] = "维修中";
  6136. } else if ($value['state'] == 6) {
  6137. $info_list[$key]['state'] = "盘亏";
  6138. } else if ($value['state'] == 7) {
  6139. $info_list[$key]['state'] = "更换标签";
  6140. } else if ($value['state'] == 8) {
  6141. $info_list[$key]['state'] = "其它";
  6142. } else if ($value['state'] == 9) {
  6143. $info_list[$key]['state'] = "预设";
  6144. } else if ($value['state'] == 10) {
  6145. $info_list[$key]['state'] = "美店零售";
  6146. }
  6147. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6148. }
  6149. $total = $this->$ck->find_count($where);
  6150. $pagenum = ceil($total / $perpage);
  6151. $over = $total - ($start + $perpage);
  6152. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6153. echo json_encode($rows);
  6154. exit;
  6155. }
  6156. if (isset($post['tmsku'])) {
  6157. $time = time();
  6158. $tmsku = $this->input->post('tmsku', true);
  6159. //$post['shop'] = $this->input->post('shop',true);
  6160. $num = $this->input->post('num', true);
  6161. $cktype = $this->input->post('cktype', true);
  6162. $label = $this->whlabellabel->get_label($tmsku);
  6163. if (!$cktype) {
  6164. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6165. }
  6166. if (!isset($label['warehouse'])) {
  6167. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6168. exit;
  6169. }
  6170. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6171. if (stripos($label['features'], '-126-') !== false) {
  6172. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6173. } else {
  6174. $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 = ''");
  6175. }
  6176. $j = 0;
  6177. if (count($ck) >= $num) {
  6178. for ($i = 0; $i < $num; $i++) {
  6179. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6180. {
  6181. $j++;
  6182. }
  6183. }
  6184. if ($j == $num) {
  6185. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6186. exit;
  6187. } else {
  6188. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6189. exit;
  6190. }
  6191. } else {
  6192. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6193. exit;
  6194. }
  6195. }
  6196. if(isset($_SESSION['api']))
  6197. {
  6198. $user = $this->user->get_api($_SESSION['api']);
  6199. if(in_array($user['power'],[1,27])){
  6200. $vip = 1;
  6201. }
  6202. }
  6203. else
  6204. {
  6205. $vip = 0;
  6206. header('Location: /');exit;
  6207. }
  6208. $this->data['vip'] = $vip;
  6209. $this->_Template('whlabel_printck', $this->data);
  6210. }
  6211. public function _printexcel()
  6212. {
  6213. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6214. $config['upload_path'] = '.' . $dir;
  6215. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6216. $config['allowed_types'] = 'xls|xlsx|csv';
  6217. $config['max_size'] = 10240;
  6218. $this->load->library('upload', $config);
  6219. $this->upload->initialize($config);
  6220. if ($this->upload->do_upload('userfile')) {
  6221. $full_path = $dir . $this->upload->data('file_name');
  6222. $fileName = '.' . $full_path;
  6223. if (!file_exists($fileName)) {
  6224. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6225. exit;
  6226. } else {
  6227. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6228. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6229. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6230. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6231. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6232. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6233. ++$column; //如果列数大于26行
  6234. $list = array();
  6235. for ($i = 2; $i <= $row; $i++) // 行数循环
  6236. {
  6237. $data = array();
  6238. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6239. {
  6240. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6241. }
  6242. $list[] = $data;
  6243. }
  6244. }
  6245. $ed = array();
  6246. $i = 0;
  6247. $j = 0;
  6248. $dcdata = array();
  6249. $yc = '';
  6250. $cmf_arr = array_column($list, '1');
  6251. array_multisort($cmf_arr, SORT_ASC, $list);
  6252. foreach ($list as $key => $value) {
  6253. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6254. if ($typeclass) {
  6255. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6256. } else {
  6257. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6258. $i++;
  6259. continue;
  6260. }
  6261. }
  6262. if ($i > 0) {
  6263. $yc = $i . '条异常';
  6264. }
  6265. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6266. exit;
  6267. }
  6268. }
  6269. public function _uck()
  6270. {
  6271. if (isset($_GET['excel'])) {
  6272. $tc = array();
  6273. $typeclass = $this->typeclass->find_all();
  6274. foreach ($typeclass as $v) {
  6275. $tc[$v['id']] = $v['zh'];
  6276. }
  6277. $data = array();
  6278. $t = array();
  6279. $rq = '';
  6280. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6281. $ts = $ts / (24 * 3600);
  6282. for ($i = 0; $i < $ts; $i++) {
  6283. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6284. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6285. }
  6286. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6287. foreach ($info_list as $k => $v) {
  6288. $features = explode('-', trim($v['features'], '-'));
  6289. if (!isset($features[3]) || !isset($features[4])) {
  6290. continue;
  6291. }
  6292. $data[$k][0] = $tc[$features[0]]; //类型
  6293. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6294. $data[$k][2] = $tc[$features[4]]; //曲度
  6295. $data[$k][3] = '';
  6296. if (isset($data[$k][1])) {
  6297. $data[$k][3] .= $data[$k][1];
  6298. }
  6299. if (isset($data[$k][2])) {
  6300. $data[$k][3] .= $data[$k][2];
  6301. }
  6302. if (isset($features[5])) {
  6303. $data[$k][3] .= $tc[$features[5]];
  6304. }
  6305. if (isset($features[2])) {
  6306. $data[$k][3] .= $tc[$features[2]];
  6307. }
  6308. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6309. $data[$k][4] = $v['sku'];
  6310. $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())) . '))'); //月初库存
  6311. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6312. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6313. $ztrq = '';
  6314. $ztsl = '';
  6315. if (count($zt) > 0) {
  6316. foreach ($zt as $vv) {
  6317. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6318. $ztsl .= $vv['num'] . '<br>';
  6319. }
  6320. }
  6321. $data[$k][] = trim($ztsl, '<br>');
  6322. $data[$k][] = trim($ztrq, '<br>');
  6323. $byck = 0;
  6324. foreach ($t as $vv) {
  6325. $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));
  6326. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6327. $byck += $sl;
  6328. }
  6329. $data[$k][] = ($byck > 0) ? $byck : '';
  6330. }
  6331. $title = "详情 " . date("Y-m-d", time());
  6332. $titlename = "<table border=1>
  6333. <tr align='center'>
  6334. <td>类别</td>
  6335. <td>颜色</td>
  6336. <td>曲度</td>
  6337. <td>名称</td>
  6338. <td>SKU</td>
  6339. <td>月初库存</td>
  6340. <td>剩余库存</td>
  6341. <td>在途数量</td>
  6342. <td>预达日期</td>" .
  6343. $rq
  6344. . "<td>本月出库</td></tr>
  6345. </table>";
  6346. $filename = $title . ".xls";
  6347. $tail = "";
  6348. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6349. }
  6350. }
  6351. public function _whlabelexcelzh()
  6352. {
  6353. if (isset($_GET['excel'])) {
  6354. $where = "sku != 'Preset'";
  6355. //数据排序
  6356. $order_str = "id desc";
  6357. if (empty($page)) {
  6358. $start = 0;
  6359. $perpage = 1;
  6360. } else {
  6361. $start = ($page - 1) * $perpage;
  6362. }
  6363. $category = $this->input->get('category', true);
  6364. $warehouse = $this->input->get('warehouse', true);
  6365. $excelid = $this->input->get('sid', true);
  6366. if ($category) {
  6367. $where .= " and features like '%-$category-%'";
  6368. }
  6369. if ($warehouse) {
  6370. $where .= " and warehouse = '$warehouse'";
  6371. }
  6372. $xzid = '';
  6373. if ($excelid) {
  6374. $excelid = explode(',', trim($excelid, ','));
  6375. foreach ($excelid as $key => $value) {
  6376. $xzid .= " id = " . $value . " or";
  6377. }
  6378. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6379. }
  6380. //取得信息列表
  6381. /**
  6382. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6383. $rows = array();$list = array();
  6384. foreach ($info_list as $key=>$value)
  6385. {
  6386. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6387. }
  6388. **/
  6389. $list = array();
  6390. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6391. foreach ($rows as $key => $value) {
  6392. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6393. $zh = '';
  6394. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6395. foreach ($zt as $v) {
  6396. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6397. }
  6398. $zt = array_sum(array_column($zt, 'num'));
  6399. $number = $value['number'];
  6400. $ftime = time() - 15 * 24 * 3600;
  6401. $warehouse = $this->warehouse->read($value['warehouse']);
  6402. $rows[$key]['warehouse'] = $warehouse['title'];
  6403. $rows[$key]['number'] = $c;
  6404. $rows[$key]['features'] = $zh;
  6405. $rows[$key]['hb'] = $c + $zt;
  6406. }
  6407. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6408. $titlename = "<table border=1>
  6409. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6410. <tr align='center'>
  6411. <td>仓库</td>
  6412. <td>SKU</td>
  6413. <td>产品</td>
  6414. <td>库存数量</td>
  6415. <td>在途数量及预达日期</td>
  6416. <td>在途+库存数量</td>
  6417. </tr>
  6418. </table>";
  6419. $filename = $title . ".xls";
  6420. $tail = "";
  6421. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6422. }
  6423. if (isset($_GET['excel'])) {
  6424. $warehouse = $this->input->get('warehouse', true);
  6425. $sku = $this->input->get('sku', true);
  6426. $cz = $this->input->get('cz', true);
  6427. $text = $this->input->post('text', true);
  6428. $xztime = $this->input->get('xztime', true);
  6429. $timetk = $this->input->get('timetk', true);
  6430. $timetj = $this->input->get('timetj', true);
  6431. $timetk = strtotime($timetk);
  6432. $timetj = strtotime($timetj);
  6433. $where = "time = '0' ";
  6434. if ($warehouse) {
  6435. $where .= " and warehouse = '$warehouse'";
  6436. }
  6437. if ($sku) {
  6438. $where .= " and sku = '$sku'";
  6439. }
  6440. if ($text) {
  6441. $where .= " and text like '%$text%'";
  6442. }
  6443. if ($cz != '') {
  6444. $where .= " and cz = '$cz'";
  6445. }
  6446. if ($timetk && $timetj) {
  6447. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6448. }
  6449. //数据排序
  6450. $order_str = $xztime . " desc";
  6451. //取得信息列表
  6452. $zh = array();
  6453. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6454. foreach ($info_list as $v) {
  6455. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6456. $warehouse = $this->warehouse->read($v['warehouse']);
  6457. $v['warehouse'] = $warehouse['title'];
  6458. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6459. $v['stime'] = date('Y-m-d', $v['stime']);
  6460. if (isset($zh[$v['features']])) {
  6461. $zh[$v['features']]['num'] += $v['num'];
  6462. } else {
  6463. $zh[$v['features']] = $v;
  6464. }
  6465. $zh[$v['features']]['features'] = $c;
  6466. }
  6467. $title = "在途数据" . date('Y-m-d', time());
  6468. $titlename = "<table border=1>
  6469. <tr align='center'>
  6470. <td>仓库</td>
  6471. <td>SKU</td>
  6472. <td>名称</td>
  6473. <td>在途数量</td>
  6474. <td>库存数量</td>
  6475. <td>添加在途日期</td>
  6476. <td>预达日期</td>
  6477. <td>备注</td>
  6478. </tr>
  6479. </table>";
  6480. $filename = $title . ".xls";
  6481. $tail = "";
  6482. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6483. }
  6484. }
  6485. public function _fc()
  6486. {
  6487. $vip = 0;
  6488. if (isset($_SESSION['api'])) {
  6489. $user = $this->user->get_api($_SESSION['api']);
  6490. if ($user['vip'] == 1) {
  6491. $vip = 1;
  6492. }
  6493. } else {
  6494. header('Location: /');
  6495. exit;
  6496. }
  6497. $post = $this->input->post(NULL, TRUE);
  6498. if (isset($post['page'])) {
  6499. $page = $this->input->post('page', true);
  6500. $perpage = $this->input->post('perpage', true);
  6501. $category = $this->input->post('category', true);
  6502. $size = $this->input->post('size', true);
  6503. $grade = $this->input->post('grade', true);
  6504. $color = $this->input->post('color', true);
  6505. $lowe = $this->input->post('lowe', true);
  6506. $sku = $this->input->post('sku');
  6507. $title = $this->input->post('title');
  6508. $warehouse = $this->input->post('warehouse', true);
  6509. $usa = $this->input->post('usa', true);
  6510. $purchase = $this->input->post('purchase', true);
  6511. $lacetype = $this->input->post('lacetype', true);
  6512. $haircap = $this->input->post('haircap', true);
  6513. $density = $this->input->post('density', true);
  6514. $details = $this->input->post('details', true);
  6515. $state = $this->input->post('state', true);
  6516. $ktime = $this->input->post('ktime', true);
  6517. $jtime = $this->input->post('jtime', true);
  6518. $ktime = strtotime($ktime);
  6519. $jtime = strtotime($jtime);
  6520. $where = "state = '11'";
  6521. $gj = "";
  6522. $ck = "";
  6523. if ($lacetype) {
  6524. $where .= " and features like '%-$lacetype-%'";
  6525. }
  6526. if ($category) {
  6527. $where .= " and features like '%-$category-%'";
  6528. }
  6529. if ($size) {
  6530. $where .= " and features like '%-$size-%'";
  6531. }
  6532. if ($grade) {
  6533. $where .= " and features like '%-$grade-%'";
  6534. }
  6535. if ($color) {
  6536. $where .= " and features like '%-$color-%'";
  6537. }
  6538. if ($lowe) {
  6539. $where .= " and features like '%-$lowe-%'";
  6540. }
  6541. if ($haircap) {
  6542. $where .= " and features like '%-$haircap-%'";
  6543. }
  6544. if ($density) {
  6545. $where .= " and features like '%-$density-%'";
  6546. }
  6547. if ($usa) {
  6548. if (!$warehouse) {
  6549. $where .= " and (warehouse = '5' or warehouse = '8')";
  6550. }
  6551. }
  6552. if ($warehouse) {
  6553. $where .= " and warehouse = '$warehouse'";
  6554. }
  6555. if ($details) {
  6556. $where .= " and details = '$details'";
  6557. }
  6558. if ($purchase) {
  6559. $where .= " and purchase = '$purchase'";
  6560. }
  6561. if ($state) {
  6562. $where .= " and state = '$state'";
  6563. }
  6564. if ($ktime && $jtime) {
  6565. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6566. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6567. }
  6568. //数据排序
  6569. $order_str = "id desc";
  6570. if (empty($page)) {
  6571. $start = 0;
  6572. $perpage = 1;
  6573. } else {
  6574. $start = ($page - 1) * $perpage;
  6575. }
  6576. if ($sku) {
  6577. $sku = trim($sku, ' ');
  6578. $sku = trim($sku, ' ');
  6579. $where .= " and sku like '%$sku%'";
  6580. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6581. } else if ($title) {
  6582. $title = trim($title, ' ');
  6583. $title = trim($title, ' ');
  6584. $where .= " and title like '%$title%'";
  6585. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6586. } else {
  6587. //$where .= " and time > '$ktime' and time < '$jtime'";
  6588. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6589. }
  6590. //取得信息列表
  6591. $rows = array();
  6592. $list = array();
  6593. foreach ($info_list as $key => $value) {
  6594. $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'] . '"');
  6595. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6596. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6597. $warehouse = $this->warehouse->read($value['warehouse']);
  6598. $info_list[$key]['warehouse'] = $warehouse['title'];
  6599. $info_list[$key]['number'] = $g;
  6600. $info_list[$key]['features'] = $x;
  6601. $info_list[$key]['x'] = $s;
  6602. }
  6603. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6604. $pagenum = ceil($total / $perpage);
  6605. $over = $total - ($start + $perpage);
  6606. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6607. echo json_encode($rows);
  6608. exit;
  6609. }
  6610. $this->data['vip'] = $vip;
  6611. $this->_Template('whlabel_fc', $this->data);
  6612. }
  6613. public function _fcmb()
  6614. {
  6615. $where = "sku != 'Preset'";
  6616. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6617. foreach ($rows as $k => $v) {
  6618. $warehouse = $this->warehouse->read($v['warehouse']);
  6619. $rows[$k]['warehouse'] = $warehouse['title'];
  6620. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6621. $rows[$k]['t'] = '';
  6622. $rows[$k]['n'] = '';
  6623. }
  6624. $title = "封货产品数据导入模板";
  6625. $titlename = "<table border=1>
  6626. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6627. <tr align='center'>
  6628. <td>仓库</td>
  6629. <td>SKU</td>
  6630. <td>产品</td>
  6631. <td>封存产品总数量</td>
  6632. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6633. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6634. </tr>
  6635. </table>";
  6636. $filename = $title . ".xls";
  6637. $tail = "";
  6638. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6639. }
  6640. public function _fcexcel()
  6641. {
  6642. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6643. $config['upload_path'] = '.' . $dir;
  6644. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6645. $config['allowed_types'] = 'xls|xlsx|csv';
  6646. $config['max_size'] = 10240;
  6647. $this->load->library('upload', $config);
  6648. $this->upload->initialize($config);
  6649. if ($this->upload->do_upload('userfile')) {
  6650. $full_path = $dir . $this->upload->data('file_name');
  6651. $fileName = '.' . $full_path;
  6652. if (!file_exists($fileName)) {
  6653. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6654. exit;
  6655. } else {
  6656. libxml_use_internal_errors(true);
  6657. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6658. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6659. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6660. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6661. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6662. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6663. ++$column; //如果列数大于26行
  6664. $list = array();
  6665. for ($i = 2; $i <= $row; $i++) // 行数循环
  6666. {
  6667. $data = array();
  6668. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6669. {
  6670. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6671. }
  6672. $list[] = $data;
  6673. }
  6674. }
  6675. $i = 0;
  6676. $j = 0;
  6677. $ed = array();
  6678. foreach ($list as $key => $value) {
  6679. $time = time();
  6680. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6681. continue;
  6682. }
  6683. $warehouse = $this->warehouse->get_title($value['0']);
  6684. $sku = $value['1'];
  6685. $type = $value['4']; //调整方式0扣减1删除
  6686. $num = $value['5']; //调整数量
  6687. //$text = $value['4'];//扣减说明
  6688. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6689. if (!$d) //如果没有这个SKU
  6690. {
  6691. $ed[] = array($sku . '-库存中不存在此SKU');
  6692. $j++;
  6693. continue;
  6694. }
  6695. if (!isset($warehouse['id'])) {
  6696. $ed[] = array($sku . '-仓库名错误!');
  6697. $j++;
  6698. continue;
  6699. }
  6700. if ($type == 1 || $type == 2) //扣减库存
  6701. {
  6702. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6703. if (count($data) < abs($num)) {
  6704. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6705. $j++;
  6706. continue;
  6707. }
  6708. if ($type == 1) //转入库存
  6709. {
  6710. for ($i = 0; $i < abs($num); $i++) {
  6711. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6712. }
  6713. } else if ($type == 2) //删除
  6714. {
  6715. for ($i = 0; $i < abs($num); $i++) {
  6716. $this->whlabel->remove($data[$i]['id']);
  6717. }
  6718. }
  6719. } else if ($type == 0) //增加库存
  6720. {
  6721. $post['sku'] = $d['sku'];
  6722. $post['shop'] = '';
  6723. $post['warehouse'] = $warehouse['id'];
  6724. $post['purchase'] = $d['purchase'];
  6725. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6726. $post['state'] = 11;
  6727. $post['title'] = $d['title'];
  6728. $post['number'] = $d['number'];
  6729. $post['features'] = $d['features'];
  6730. $post['enter'] = $time;
  6731. $post['time'] = $time; //操作时间
  6732. for ($i = 0; $i < $num; $i++) {
  6733. $post['label'] = time() . rand(100, 999) . $i;
  6734. $this->whlabel->insert($post);
  6735. }
  6736. }
  6737. sleep(1); //防止入库时间一样,需要延迟1秒
  6738. }
  6739. if ($j > 0) {
  6740. $tt = date('Ymd', time());
  6741. $title = '库存导入错误信息-' . $tt;
  6742. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6743. $tail = "\n";
  6744. $filename = $title . ".xls";
  6745. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6746. $dir = '/data/excel/' . $time . '/';
  6747. $file_name = 'error_' . $time . rand(1000, 9999);
  6748. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6749. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6750. fwrite($myfile, $ecl);
  6751. fclose($myfile);
  6752. $error = $dir . $file_name . '.xls';
  6753. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6754. exit;
  6755. } else {
  6756. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6757. exit;
  6758. }
  6759. }
  6760. }
  6761. public function _fcjxc($arg_array)
  6762. {
  6763. if (isset($_GET['excel'])) {
  6764. $category = $this->input->get('category', true);
  6765. $size = $this->input->get('size', true);
  6766. $grade = $this->input->get('grade', true);
  6767. $color = $this->input->get('color', true);
  6768. $lowe = $this->input->get('lowe', true);
  6769. $sku = $this->input->get('sku');
  6770. $title = $this->input->get('title');
  6771. $warehouse = $arg_array[0];
  6772. $usa = $this->input->get('usa', true);
  6773. $purchase = $this->input->get('purchase', true);
  6774. $lacetype = $this->input->get('lacetype', true);
  6775. $haircap = $this->input->get('haircap', true);
  6776. $density = $this->input->get('density', true);
  6777. $title = $this->input->get('title', true);
  6778. $state = $this->input->get('state', true);
  6779. $ktime = $this->input->get('ktime', true);
  6780. $jtime = $this->input->get('jtime', true);
  6781. $where = "state=11";
  6782. $gj = "";
  6783. $ck = "";
  6784. if ($lacetype) {
  6785. $where .= " and features like '%-$lacetype-%'";
  6786. }
  6787. if ($category) {
  6788. $where .= " and features like '%-$category-%'";
  6789. }
  6790. if ($size) {
  6791. $where .= " and features like '%-$size-%'";
  6792. }
  6793. if ($grade) {
  6794. $where .= " and features like '%-$grade-%'";
  6795. }
  6796. if ($color) {
  6797. $where .= " and features like '%-$color-%'";
  6798. }
  6799. if ($lowe) {
  6800. $where .= " and features like '%-$lowe-%'";
  6801. }
  6802. if ($haircap) {
  6803. $where .= " and features like '%-$haircap-%'";
  6804. }
  6805. if ($density) {
  6806. $where .= " and features like '%-$density-%'";
  6807. }
  6808. if ($usa) {
  6809. if (!$warehouse) {
  6810. $where .= " and (warehouse = '5' or warehouse = '8')";
  6811. }
  6812. }
  6813. if ($warehouse) {
  6814. $where .= " and warehouse = '$warehouse'";
  6815. }
  6816. if ($purchase) {
  6817. $where .= " and purchase = '$purchase'";
  6818. }
  6819. if ($state) {
  6820. $where .= " and state = '$state'";
  6821. }
  6822. $order_str = "id desc";
  6823. if ($sku) {
  6824. $sku = trim($sku, ' ');
  6825. $sku = trim($sku, ' ');
  6826. $where .= " and sku like '%$sku%'";
  6827. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6828. } else if ($title) {
  6829. $title = trim($title, ' ');
  6830. $title = trim($title, ' ');
  6831. $where .= " and title like '%$title%'";
  6832. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6833. } else {
  6834. //$where .= " and time > '$ktime' and time < '$jtime'";
  6835. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6836. }
  6837. //取得信息列表
  6838. $rows = array();
  6839. $list = array();
  6840. foreach ($info_list as $key => $value) {
  6841. $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'] . '"');
  6842. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6843. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6844. $rows[$key] = $value;
  6845. $warehouse = $this->warehouse->read($value['warehouse']);
  6846. $rows[$key]['warehouse'] = $warehouse['title'];
  6847. $rows[$key]['features'] = $g;
  6848. $rows[$key]['a'] = $x;
  6849. $rows[$key]['b'] = $s;
  6850. }
  6851. $title = "总统计表";
  6852. $titlename = "<table border=1>
  6853. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6854. <tr align='center'>
  6855. <td>仓库</td>
  6856. <td>SKU</td>
  6857. <td>产品名称</td>
  6858. <td>录入总量</td>
  6859. <td>取出总量</td>
  6860. <td>剩余总量</td>
  6861. </tr>
  6862. </table>";
  6863. $filename = $title . ".xls";
  6864. $tail = "";
  6865. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6866. }
  6867. $vip = 0;
  6868. if (isset($_SESSION['api'])) {
  6869. $user = $this->user->get_api($_SESSION['api']);
  6870. if ($user['vip'] == 1) {
  6871. $vip = 1;
  6872. }
  6873. } else {
  6874. header('Location: /');
  6875. exit;
  6876. }
  6877. $post = $this->input->post(NULL, TRUE);
  6878. if (isset($post['page'])) {
  6879. $page = $this->input->post('page', true);
  6880. $perpage = $this->input->post('perpage', true);
  6881. $category = $this->input->post('category', true);
  6882. $size = $this->input->post('size', true);
  6883. $grade = $this->input->post('grade', true);
  6884. $color = $this->input->post('color', true);
  6885. $lowe = $this->input->post('lowe', true);
  6886. $sku = $this->input->post('sku');
  6887. $title = $this->input->post('title');
  6888. $warehouse = $arg_array[0];
  6889. $usa = $this->input->post('usa', true);
  6890. $purchase = $this->input->post('purchase', true);
  6891. $lacetype = $this->input->post('lacetype', true);
  6892. $haircap = $this->input->post('haircap', true);
  6893. $density = $this->input->post('density', true);
  6894. $title = $this->input->post('title', true);
  6895. $state = $this->input->post('state', true);
  6896. $ktime = $this->input->post('ktime', true);
  6897. $jtime = $this->input->post('jtime', true);
  6898. $ktime = strtotime($ktime);
  6899. $jtime = strtotime($jtime);
  6900. $where = "state=11";
  6901. $gj = "";
  6902. $ck = "";
  6903. if ($lacetype) {
  6904. $where .= " and features like '%-$lacetype-%'";
  6905. }
  6906. if ($category) {
  6907. $where .= " and features like '%-$category-%'";
  6908. }
  6909. if ($size) {
  6910. $where .= " and features like '%-$size-%'";
  6911. }
  6912. if ($grade) {
  6913. $where .= " and features like '%-$grade-%'";
  6914. }
  6915. if ($color) {
  6916. $where .= " and features like '%-$color-%'";
  6917. }
  6918. if ($lowe) {
  6919. $where .= " and features like '%-$lowe-%'";
  6920. }
  6921. if ($haircap) {
  6922. $where .= " and features like '%-$haircap-%'";
  6923. }
  6924. if ($density) {
  6925. $where .= " and features like '%-$density-%'";
  6926. }
  6927. if ($usa) {
  6928. if (!$warehouse) {
  6929. $where .= " and (warehouse = '5' or warehouse = '8')";
  6930. }
  6931. }
  6932. if ($warehouse) {
  6933. $where .= " and warehouse = '$warehouse'";
  6934. }
  6935. if ($purchase) {
  6936. $where .= " and purchase = '$purchase'";
  6937. }
  6938. if ($state) {
  6939. $where .= " and state = '$state'";
  6940. }
  6941. if ($ktime && $jtime) {
  6942. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6943. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6944. }
  6945. //数据排序
  6946. $order_str = "id desc";
  6947. $xs = 0;
  6948. $rows = array();
  6949. $list = array();
  6950. if (empty($page)) {
  6951. $start = 0;
  6952. $perpage = 1;
  6953. } else {
  6954. $start = ($page - 1) * $perpage;
  6955. }
  6956. if ($sku || $title) {
  6957. if ($title) {
  6958. $title = trim($title, ' ');
  6959. $title = trim($title, ' ');
  6960. $where .= " and title like '%$title%'";
  6961. } else {
  6962. $sku = trim($sku, ' ');
  6963. $sku = trim($sku, ' ');
  6964. $where .= " and sku like '%$sku%'";
  6965. }
  6966. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6967. foreach ($info_list as $key => $value) {
  6968. $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'] . '"');
  6969. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6970. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6971. $rows[$key] = $value;
  6972. $warehouse = $this->warehouse->read($value['warehouse']);
  6973. $rows[$key]['warehouse'] = $warehouse['title'];
  6974. $rows[$key]['features'] = $g;
  6975. $rows[$key]['a'] = $x;
  6976. $rows[$key]['b'] = $s;
  6977. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6978. $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天销量
  6979. $yj = $c / ($xl / 30);
  6980. if ($yj < 7) {
  6981. $rows[$key]['y'] = round($yj) . '天销量';
  6982. } else {
  6983. $rows[$key]['y'] = '正常';
  6984. }
  6985. }
  6986. } else {
  6987. //$where .= " and time > '$ktime' and time < '$jtime'";
  6988. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6989. foreach ($info_list as $key => $value) {
  6990. $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'] . '"');
  6991. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6992. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6993. $zs[$key] = $value;
  6994. $warehouse = $this->warehouse->read($value['warehouse']);
  6995. $zs[$key]['warehouse'] = $warehouse['title'];
  6996. $zs[$key]['features'] = $g;
  6997. $zs[$key]['a'] = $x;
  6998. $zs[$key]['b'] = $s;
  6999. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7000. $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天销量
  7001. $yj = $c / ($xl / 30);
  7002. if ($yj < 7) {
  7003. $zs[$key]['y'] = round($yj) . '天销量';
  7004. $rows[$key] = $zs[$key];
  7005. }
  7006. }
  7007. }
  7008. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7009. $pagenum = ceil($total / $perpage);
  7010. $over = $total - ($start + $perpage);
  7011. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7012. echo json_encode($rows);
  7013. exit;
  7014. }
  7015. $this->data['arg_array'] = $arg_array[0];
  7016. $this->_Template('whlabel_fcjxc', $this->data);
  7017. }
  7018. public function _0kcdel()
  7019. {
  7020. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7021. $config['upload_path'] = '.' . $dir;
  7022. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7023. $config['allowed_types'] = 'xls|xlsx|csv';
  7024. $config['max_size'] = 10240;
  7025. $this->load->library('upload', $config);
  7026. $this->upload->initialize($config);
  7027. if ($this->upload->do_upload('userfile')) {
  7028. $full_path = $dir . $this->upload->data('file_name');
  7029. $fileName = '.' . $full_path;
  7030. if (!file_exists($fileName)) {
  7031. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7032. exit;
  7033. } else {
  7034. require_once "./data/excel/PHPExcel/IOFactory.php";
  7035. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7036. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7037. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7038. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7039. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7040. ++$column; //如果列数大于26行
  7041. $list = array();
  7042. for ($i = 2; $i <= $row; $i++) // 行数循环
  7043. {
  7044. $data = array();
  7045. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7046. {
  7047. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7048. }
  7049. $list[] = $data;
  7050. }
  7051. }
  7052. $i = 0;
  7053. $j = 0;
  7054. $ed = array();
  7055. foreach ($list as $key => $value) {
  7056. $time = time();
  7057. if ($value['0'] == "" || $value['1'] == "") {
  7058. continue;
  7059. }
  7060. $warehouse = $this->warehouse->get_title($value['0']);
  7061. $sku = $value['1'];
  7062. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7063. if (!$d) //如果没有这个SKU
  7064. {
  7065. $ed[] = array($sku . '-库存中不存在此SKU');
  7066. $j++;
  7067. continue;
  7068. }
  7069. if (!isset($warehouse['id'])) {
  7070. $ed[] = array($sku . '-仓库名错误!');
  7071. $j++;
  7072. continue;
  7073. }
  7074. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7075. if ($z < 1) {
  7076. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7077. foreach ($z as $v) {
  7078. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7079. if (count($zt) > 0) {
  7080. $ed[] = array($sku . '-有在途库存无法删除!');
  7081. $j++;
  7082. continue;
  7083. }
  7084. $this->whlabel->remove($v['id']);
  7085. }
  7086. } else {
  7087. $ed[] = array($sku . '-非0库存!');
  7088. $j++;
  7089. continue;
  7090. }
  7091. }
  7092. if ($j > 0) {
  7093. $tt = date('Ymd', time());
  7094. $title = '删除0库存错误信息-' . $tt;
  7095. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7096. $tail = "\n";
  7097. $filename = $title . ".xls";
  7098. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7099. $dir = '/data/excel/' . $time . '/';
  7100. $file_name = 'error_' . $time . rand(1000, 9999);
  7101. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7102. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7103. fwrite($myfile, $ecl);
  7104. fclose($myfile);
  7105. $error = $dir . $file_name . '.xls';
  7106. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7107. exit;
  7108. } else {
  7109. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7110. exit;
  7111. }
  7112. }
  7113. }
  7114. public function _gbhtype()
  7115. {
  7116. $post = $this->input->post(NULL, TRUE);
  7117. if (isset($post['s'])) {
  7118. $n = $this->input->post('n');
  7119. $d = $this->input->post('s');
  7120. if (!$d) {
  7121. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7122. exit;
  7123. }
  7124. $d = explode(',', trim($d, ','));
  7125. $t = $this->whlabel_type->read($n);
  7126. //循环删除记录
  7127. foreach ($d as $v) {
  7128. $u = $this->whlabel->read($v);
  7129. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7130. foreach ($data as $val) {
  7131. $this->whlabel->save(array('type' => $n), $val['id']);
  7132. }
  7133. }
  7134. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7135. }
  7136. }
  7137. //出库、退库导出
  7138. public function _dccrtype()
  7139. {
  7140. $classid = $this->classid->sku();
  7141. $pm = $classid;
  7142. $typeclass = array();
  7143. $tc = $this->typeclass->find_all();
  7144. foreach ($tc as $v) {
  7145. $typeclass[$v['id']] = $v;
  7146. }
  7147. $prc = array();
  7148. $purchase = $this->purchase->find_all();
  7149. foreach ($purchase as $k => $v) {
  7150. $prc[$v['id']] = $v['title'];
  7151. }
  7152. if (isset($_GET['sid'])) {
  7153. $wh = array();
  7154. $w = $this->warehouse->find_all('1=1', 'id,title');
  7155. foreach ($w as $v) {
  7156. $wh[$v['id']] = $v['title'];
  7157. }
  7158. $type = $this->input->get('excel', true);
  7159. $category = $this->input->get('category', true);
  7160. $size = $this->input->get('size', true);
  7161. $grade = $this->input->get('grade', true);
  7162. $color = $this->input->get('color', true);
  7163. $lowe = $this->input->get('lowe', true);
  7164. $sku = $this->input->get('sku', true);
  7165. $warehouse = $this->input->get('warehouse', true);
  7166. $lacetype = $this->input->get('lacetype', true);
  7167. $lacecolor = $this->input->get('lacecolor', true);
  7168. $density = $this->input->get('density', true);
  7169. $haircap = $this->input->get('haircap', true);
  7170. $purchase = $this->input->get('purchase', true);
  7171. $title = $this->input->get('title', true);
  7172. $state = $this->input->get('state', true);
  7173. $sid = $this->input->get('sid', true);
  7174. $ktime = $this->input->get('ktime', true);
  7175. $jtime = $this->input->get('jtime', true);
  7176. $ktime = strtotime($ktime);
  7177. $jtime = strtotime($jtime);
  7178. $where = "1=1";
  7179. $gj = "";
  7180. $ck = "";
  7181. if ($category) {
  7182. $where .= " and features like '%-$category-%'";
  7183. }
  7184. if ($size) {
  7185. $where .= " and features like '%-$size-%'";
  7186. }
  7187. if ($grade) {
  7188. $where .= " and features like '%-$grade-%'";
  7189. }
  7190. if ($color) {
  7191. $where .= " and features like '%-$color-%'";
  7192. }
  7193. if ($lowe) {
  7194. $where .= " and features like '%-$lowe-%'";
  7195. }
  7196. if ($warehouse) {
  7197. $where .= " and warehouse = '$warehouse'";
  7198. }
  7199. if ($purchase) {
  7200. $where .= " and purchase = '$purchase'";
  7201. }
  7202. if ($state) {
  7203. $where .= " and state = '$state'";
  7204. }
  7205. if ($lacetype) {
  7206. $where .= " and features like '%-$lacetype-%'";
  7207. }
  7208. if ($lacecolor) {
  7209. $where .= " and features like '%-$lacecolor-%'";
  7210. }
  7211. if ($density) {
  7212. $where .= " and features like '%-$density-%'";
  7213. }
  7214. if ($haircap) {
  7215. $where .= " and features like '%-$haircap-%'";
  7216. }
  7217. if ($title) {
  7218. $title = trim($title, ' ');
  7219. $title = trim($title, ' ');
  7220. $where .= " and title like '%$title%'";
  7221. }
  7222. if ($sku) {
  7223. $sku = trim($sku, ' ');
  7224. $sku = trim($sku, ' ');
  7225. $where .= " and sku like '%$sku%'";
  7226. }
  7227. if ($ktime && $jtime) {
  7228. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7229. }
  7230. $sidwhere = '';
  7231. if ($sid) {
  7232. $sd = "";
  7233. $s = explode(',', trim($sid, ','));
  7234. foreach ($s as $value) {
  7235. $sd .= " id = " . $value . " or";
  7236. }
  7237. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7238. }
  7239. //数据排序
  7240. $order_str = "time desc";
  7241. if (empty($page)) {
  7242. $start = 0;
  7243. $perpage = 1;
  7244. } else {
  7245. $start = ($page - 1) * $perpage;
  7246. }
  7247. $wh = array();
  7248. $w = $this->warehouse->find_all('1=1', 'id,title');
  7249. foreach ($w as $v) {
  7250. $wh[$v['id']] = $v['title'];
  7251. }
  7252. $wt = array();
  7253. $whlabel_type = $this->whlabel_type->find_all();
  7254. foreach ($whlabel_type as $v) {
  7255. $wt[$v['id']] = $v['title'];
  7256. }
  7257. $classid = $this->classid->sku();
  7258. $list = array();
  7259. $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');
  7260. foreach ($rows_r as $key => $value) {
  7261. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7262. $pm = $classid;
  7263. $jm = $classid;
  7264. $rows_r[$key]['enter'] = '入库';
  7265. $rows_r[$key]['time'] = $value['enter'];
  7266. if ($value['rktype'] == 1) {
  7267. $rows_r[$key]['rktype'] = '采购入库';
  7268. } else if ($value['rktype'] == 2) {
  7269. $rows_r[$key]['rktype'] = '盘盈调整';
  7270. } else if ($value['rktype'] == 3) {
  7271. $rows_r[$key]['rktype'] = '其他调整入库';
  7272. } else if ($value['rktype'] == 4) {
  7273. $rows_r[$key]['rktype'] = '其他调整入库';
  7274. } else if ($value['rktype'] == 5) {
  7275. $rows_r[$key]['rktype'] = '退库入库';
  7276. } else if ($value['rktype'] == 6) {
  7277. $rows_r[$key]['rktype'] = '退货可用入库';
  7278. } else if ($value['rktype'] == 7) {
  7279. $rows_r[$key]['rktype'] = '形态转换入库';
  7280. } else {
  7281. $rows_r[$key]['rktype'] = '';
  7282. }
  7283. $features = explode('-', trim($value['features'], '-'));
  7284. foreach ($features as $v) {
  7285. if (isset($typeclass[$v])) {
  7286. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7287. $pm[$typeclass[$v]['classid']] = $zh[0];
  7288. }
  7289. if (isset($typeclass[$v])) {
  7290. if (isset($jm[$typeclass[$v]['classid']])) {
  7291. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7292. }
  7293. }
  7294. }
  7295. $zh = implode(" ", $pm);
  7296. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7297. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7298. $rows_r[$key]['zh'] = $zh;
  7299. $jm = array_filter($jm);
  7300. $rows_r[$key]['features'] = implode("-", $jm);
  7301. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7302. }
  7303. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  7304. foreach ($rows_c as $key => $value) {
  7305. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7306. $pm = $classid;
  7307. $jm = $classid;
  7308. $rows_c[$key]['time'] = $value['outk'];
  7309. $rows_c[$key]['outk'] = '出库';
  7310. if ($value['cktype'] == 1) {
  7311. $rows_c[$key]['cktype'] = '销售出库';
  7312. } else if ($value['cktype'] == 2) {
  7313. $rows_c[$key]['cktype'] = '销售美国出库';
  7314. } else if ($value['cktype'] == 3) {
  7315. $rows_c[$key]['cktype'] = '盘亏调整';
  7316. } else if ($value['cktype'] == 4) {
  7317. $rows_c[$key]['cktype'] = '其他调整出库';
  7318. } else if ($value['cktype'] == 5) {
  7319. $rows_c[$key]['cktype'] = '形态转换出库';
  7320. } else {
  7321. $rows_c[$key]['cktype'] = '';
  7322. }
  7323. $features = explode('-', trim($value['features'], '-'));
  7324. foreach ($features as $v) {
  7325. if (isset($typeclass[$v])) {
  7326. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7327. $pm[$typeclass[$v]['classid']] = $zh[0];
  7328. }
  7329. if (isset($typeclass[$v])) {
  7330. if (isset($jm[$typeclass[$v]['classid']])) {
  7331. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7332. }
  7333. }
  7334. }
  7335. $zh = implode(" ", $pm);
  7336. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7337. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7338. $rows_c[$key]['zh'] = $zh;
  7339. $jm = array_filter($jm);
  7340. $rows_c[$key]['features'] = implode("-", $jm);
  7341. $rows_c[$key]['number'] = 1;
  7342. }
  7343. $merged = $rows_r;
  7344. foreach ($rows_c as $key => $value) {
  7345. if (isset($merged[$key])) {
  7346. $merged[] = $value;
  7347. } else {
  7348. $merged[$key] = $value;
  7349. }
  7350. }
  7351. usort($merged, function ($a, $b) {
  7352. return $a['time'] - $b['time'];
  7353. });
  7354. foreach ($merged as $key => $value) {
  7355. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7356. }
  7357. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7358. $titlename = "<table border=1>
  7359. <tr align='center'>
  7360. <td>仓库</td>
  7361. <td>SKU</td>
  7362. <td>商品名称</td>
  7363. <td>仓库品名</td>
  7364. <td>料号</td>
  7365. <td>时间</td>
  7366. <td>操作</td>
  7367. <td>类型</td>
  7368. <td>数量</td>
  7369. <td>备注</td>
  7370. </tr>
  7371. </table>";
  7372. $filename = $title . ".xlsx";
  7373. $tail = "";
  7374. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7375. }
  7376. }
  7377. }