Whlabel.php 257 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. }
  45. //定义方法的调用规则 获取URI第二段值
  46. public function _remap($arg, $arg_array)
  47. {
  48. if ($arg == 'existence') //在库标签
  49. {
  50. $this->_existence();
  51. } else if ($arg == 'cpbqdc') //在库标签
  52. {
  53. $this->_cpbqdc();
  54. } else if ($arg == 'type') //进销存浏览
  55. {
  56. $this->_type();
  57. } else if ($arg == 'typedy') //进销存浏览店员页面
  58. {
  59. $this->_typedy($arg_array);
  60. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  61. {
  62. $this->_typedy_ck($arg_array);
  63. } else if ($arg == 'typeck') {
  64. $this->_typeck($arg_array);
  65. } else if ($arg == 'whlabeckdc') {
  66. $this->_whlabeckdc($arg_array);
  67. } else if ($arg == 'usatype') //美仓进销存浏览
  68. {
  69. $this->_usatype();
  70. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  71. {
  72. $this->_usatypeapp();
  73. } else if ($arg == 'enteradd') //入库操作
  74. {
  75. $this->_enteradd();
  76. } else if ($arg == 'enteredit') //修改
  77. {
  78. $this->_enteredit($arg_array);
  79. } else if ($arg == 'enter') //入库浏览
  80. {
  81. $this->_enter();
  82. } else if ($arg == 'out') //出库浏览
  83. {
  84. $this->_out();
  85. } else if ($arg == 'label') //出库标签浏览
  86. {
  87. $this->_label();
  88. } else if ($arg == 'outorder') //独立站出库订单
  89. {
  90. $this->_outorder();
  91. } else if ($arg == 'soutorder') //速卖通出库订单
  92. {
  93. $this->_soutorder();
  94. } else if ($arg == 'toutorder') //TT出库订单
  95. {
  96. $this->_toutorder();
  97. }else if ($arg == 'aoutorder') //amz出库订单
  98. {
  99. $this->_aoutorder();
  100. } else if ($arg == 'retreat') //退库订单
  101. {
  102. $this->_retreat();
  103. } else if ($arg == 'retreatlk') //退库订单
  104. {
  105. $this->_retreatlk();
  106. } else if ($arg == 'change') //更换标签
  107. {
  108. $this->_change();
  109. } else if ($arg == 'del') //删除
  110. {
  111. $this->_del();
  112. } else if ($arg == 'exceljxc') //进销存信息导出
  113. {
  114. $this->_exceljxc();
  115. } else if ($arg == 'excelr') //入库信息导出
  116. {
  117. $this->_excelr();
  118. } else if ($arg == 'excelct') //出库、退库信息导出
  119. {
  120. $this->_excelct();
  121. } else if ($arg == 'dccrtype') //根据出入库类型导出
  122. {
  123. $this->_dccrtype();
  124. } else if ($arg == 'excelcr') //出库、退库信息导出
  125. {
  126. $this->_excelcr();
  127. } else if ($arg == 'kcyz') //库存验证
  128. {
  129. $this->_kcyz();
  130. } else if ($arg == 'kj') //库存扣减
  131. {
  132. $this->_kj($arg_array);
  133. } else if ($arg == 'presetout') //预设库存导入
  134. {
  135. $this->_presetout($arg_array);
  136. } else if ($arg == 'presetedit') //预设库存导入
  137. {
  138. $this->_presetedit($arg_array);
  139. } else if ($arg == 'summary') //汇总导出
  140. {
  141. $this->_summary($arg_array);
  142. } else if ($arg == 'manifest') //usps发货清单
  143. {
  144. $this->_manifest();
  145. } else if ($arg == 'abnormal') //占单异常
  146. {
  147. $this->_abnormal();
  148. } else if ($arg == 'error') //0库存SKU
  149. {
  150. $this->_error();
  151. } else if ($arg == 'errorexcel') //0库存SKU导出
  152. {
  153. $this->_errorexcel();
  154. } else if ($arg == 'db') {
  155. $this->_db();
  156. } else if ($arg == 'dbrk') {
  157. $this->_dbrk();
  158. } else if ($arg == 'whlabelczdc') {
  159. $this->_whlabelczdc();
  160. } else if ($arg == 'print') {
  161. $this->_print($arg_array);
  162. } else if ($arg == 'usaprint') {
  163. $this->_usaprint($arg_array);
  164. } else if ($arg == 'printck') {
  165. $this->_printck($arg_array);
  166. } else if ($arg == 'printrk') {
  167. $this->_printrk($arg_array);
  168. } else if ($arg == 'printxzrk') {
  169. $this->_printxzrk($arg_array);
  170. } else if ($arg == 'printexcel') {
  171. $this->_printexcel($arg_array);
  172. } else if ($arg == 'uck') {
  173. $this->_uck();
  174. } else if ($arg == 'whlabelexcelzh') {
  175. $this->_whlabelexcelzh();
  176. } else if ($arg == 'fc') {
  177. $this->_fc();
  178. } else if ($arg == 'fcmb') {
  179. $this->_fcmb();
  180. } else if ($arg == 'fcexcel') {
  181. $this->_fcexcel();
  182. } else if ($arg == 'fcjxc') {
  183. $this->_fcjxc($arg_array);
  184. } else if ($arg == '0kcdel') {
  185. $this->_0kcdel(); //导表删除0库存
  186. } else if ($arg == 'gbhtype') {
  187. $this->_gbhtype(); //更改备货状态
  188. } else {
  189. $this->_index();
  190. }
  191. }
  192. //管理
  193. public function _index()
  194. {
  195. $post = $this->input->post(NULL, TRUE);
  196. if (isset($post['page'])) {
  197. $page = $this->input->post('page', true);
  198. $perpage = $this->input->post('perpage', true);
  199. $sku = $this->input->post('sku', true);
  200. $number = $this->input->post('number', true);
  201. $warehouse = $this->input->post('warehouse', true);
  202. $purchase = $this->input->post('purchase', true);
  203. $orderinfo = $this->input->post('orderinfo', true);
  204. $waybill = $this->input->post('waybill', true);
  205. $category = $this->input->post('category', true);
  206. $size = $this->input->post('size', true);
  207. $grade = $this->input->post('grade', true);
  208. $color = $this->input->post('color', true);
  209. $lowe = $this->input->post('lowe', true);
  210. $state = $this->input->post('state', true);
  211. $label = $this->input->post('label', true);
  212. $timetk = $this->input->post('timetkk', true);
  213. $timetj = $this->input->post('timetjj', true);
  214. $timetk = strtotime($timetk);
  215. $timetj = strtotime($timetj);
  216. $where = "1=1 ";
  217. if ($timetk && $timetj) {
  218. $where .= " and time > '$timetk' and time < '$timetj'";
  219. }
  220. if ($sku) {
  221. $where .= " and sku = '$sku'";
  222. }
  223. if ($number) {
  224. $where .= " and number = '$number'";
  225. }
  226. if ($warehouse) {
  227. $where .= " and warehouse = '$warehouse'";
  228. }
  229. if ($purchase) {
  230. $where .= " and purchase = '$purchase'";
  231. }
  232. if ($orderinfo) {
  233. $where .= " and orderinfo = '$orderinfo'";
  234. }
  235. if ($waybill) {
  236. $where .= " and waybill = '$waybill'";
  237. }
  238. if ($category) {
  239. $where .= " and features like '%-$category-%'";
  240. }
  241. if ($size) {
  242. $where .= " and features like '%-$size-%'";
  243. }
  244. if ($grade) {
  245. $where .= " and features like '%-$grade-%'";
  246. }
  247. if ($color) {
  248. $where .= " and features like '%-$color-%'";
  249. }
  250. if ($lowe) {
  251. $where .= " and features like '%-$lowe-%'";
  252. }
  253. if ($label) {
  254. $where .= " and label = '$label'";
  255. }
  256. if ($state != '') {
  257. $where .= " and state = '$state'";
  258. }
  259. //数据排序
  260. $order_str = "time desc";
  261. if (empty($page)) {
  262. $start = 0;
  263. $perpage = 1;
  264. } else {
  265. $start = ($page - 1) * $perpage;
  266. }
  267. //取得信息列表
  268. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,label,printing,enter,warehouse,outk,orderinfo,waybill,text,time', $order_str, $start, $perpage);
  269. foreach ($info_list as $key => $value) {
  270. $warehouse = $this->warehouse->read($value['warehouse']);
  271. $info_list[$key]['warehouse'] = $warehouse['title'];
  272. $purchase = $this->purchase->read($value['purchase']);
  273. $info_list[$key]['purchase'] = $purchase['title'];
  274. if ($value['enter'] != 0) {
  275. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  276. } else {
  277. $info_list[$key]['enter'] = "";
  278. }
  279. if ($value['outk'] != 0) {
  280. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  281. } else {
  282. $info_list[$key]['outk'] = "";
  283. }
  284. if ($value['printing'] != 0) {
  285. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  286. } else {
  287. $info_list[$key]['printing'] = "";
  288. }
  289. if ($value['orderinfo'] == 0) {
  290. $info_list[$key]['orderinfo'] = "";
  291. }
  292. if ($value['waybill'] == 0) {
  293. $info_list[$key]['waybill'] = "";
  294. }
  295. if ($value['state'] == 0) {
  296. $info_list[$key]['state'] = "在库";
  297. } else if ($value['state'] == 1) {
  298. $info_list[$key]['state'] = "出库";
  299. } else if ($value['state'] == 2) {
  300. $info_list[$key]['state'] = "退库";
  301. } else if ($value['state'] == 3) {
  302. $info_list[$key]['state'] = "调拨中";
  303. } else if ($value['state'] == 4) {
  304. $info_list[$key]['state'] = "再加工";
  305. } else if ($value['state'] == 5) {
  306. $info_list[$key]['state'] = "维修中";
  307. } else if ($value['state'] == 6) {
  308. $info_list[$key]['state'] = "盘亏";
  309. } else if ($value['state'] == 7) {
  310. $info_list[$key]['state'] = "更换标签";
  311. } else if ($value['state'] == 8) {
  312. $info_list[$key]['state'] = "其它";
  313. } else if ($value['state'] == 9) {
  314. $info_list[$key]['state'] = "预设";
  315. } else if ($value['state'] == 10) {
  316. $info_list[$key]['state'] = "美店零售";
  317. }
  318. if ($value['text'] == "") {
  319. $info_list[$key]['text'] = "";
  320. }
  321. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  322. }
  323. $total = $this->whlabel->find_count($where);
  324. $pagenum = ceil($total / $perpage);
  325. $over = $total - ($start + $perpage);
  326. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  327. echo json_encode($rows);
  328. exit;
  329. }
  330. if (isset($post['outsku'])) {
  331. $cz = $this->input->post('cz', true);
  332. if ($cz == '1') {
  333. $sku = $this->input->post('outsku', true);
  334. if ($sku) {
  335. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  336. if (count($data) < 1) {
  337. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  338. exit;
  339. }
  340. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 1), $data[0]['id']);
  341. echo json_encode(array('success' => true));
  342. exit;
  343. }
  344. } else {
  345. $sku = $this->input->post('outsku', true);
  346. if ($sku) {
  347. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  348. if (count($data) < 1) {
  349. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  350. exit;
  351. }
  352. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  353. echo json_encode(array('success' => true));
  354. exit;
  355. }
  356. }
  357. }
  358. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  359. $this->_Template('whlabel', $this->data);
  360. }
  361. //在库标签
  362. public function _existence()
  363. {
  364. $post = $this->input->post(NULL, TRUE);
  365. if (isset($post['s'])) {
  366. $id_arr = $this->input->post('s');
  367. $id_arr = explode(',', $id_arr);
  368. if (!$id_arr) {
  369. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  370. exit;
  371. }
  372. //循环删除记录
  373. foreach ($id_arr as $v) {
  374. $sid = $this->whlabel->read($v);
  375. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  376. if ($count > 0) {
  377. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  378. exit;
  379. }
  380. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  381. if (count($zt) > 0) {
  382. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  383. exit;
  384. }
  385. $this->whlabel->remove($v);
  386. }
  387. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  388. exit;
  389. }
  390. if (isset($post['page'])) {
  391. $page = $this->input->post('page', true);
  392. $perpage = $this->input->post('perpage', true);
  393. $warehouse = $this->input->post('warehouse', true);
  394. $label = $this->input->post('label', true);
  395. $where = "1=1 and state = 0";
  396. if ($warehouse) {
  397. $where .= " and warehouse = '$warehouse'";
  398. }
  399. if ($label) {
  400. $where .= " and label = '$label'";
  401. }
  402. //数据排序
  403. $order_str = "time asc";
  404. if (empty($page)) {
  405. $start = 0;
  406. $perpage = 1;
  407. } else {
  408. $start = ($page - 1) * $perpage;
  409. }
  410. //取得信息列表
  411. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  412. foreach ($info_list as $key => $value) {
  413. if ($value['enter'] != 0) {
  414. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  415. } else {
  416. $info_list[$key]['enter'] = "";
  417. }
  418. if ($value['printing'] != 0) {
  419. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  420. } else {
  421. $info_list[$key]['printing'] = "";
  422. }
  423. }
  424. $total = $this->whlabel->find_count($where);
  425. $pagenum = ceil($total / $perpage);
  426. $over = $total - ($start + $perpage);
  427. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  428. echo json_encode($rows);
  429. exit;
  430. }
  431. $this->_Template('whlabel_existence', $this->data);
  432. }
  433. //进销存浏览
  434. public function _typedy($arg_array)
  435. {
  436. $prc = array();
  437. $purchase = $this->purchase->find_all();
  438. foreach ($purchase as $k => $v) {
  439. $prc[$v['id']] = $v['title'];
  440. }
  441. $post = $this->input->post(NULL, TRUE);
  442. if (isset($post['page'])) {
  443. $page = $this->input->post('page', true);
  444. $perpage = $this->input->post('perpage', true);
  445. $category = $this->input->post('category', true);
  446. $size = $this->input->post('size', true);
  447. $grade = $this->input->post('grade', true);
  448. $color = $this->input->post('color', true);
  449. $lowe = $this->input->post('lowe', true);
  450. $sku = $this->input->post('sku');
  451. $title = $this->input->post('title');
  452. $warehouse = $this->input->post('warehouse', true);
  453. $usa = $this->input->post('usa', true);
  454. $purchase = $this->input->post('purchase', true);
  455. $lacetype = $this->input->post('lacetype', true);
  456. $haircap = $this->input->post('haircap', true);
  457. $density = $this->input->post('density', true);
  458. $details = $this->input->post('details', true);
  459. $state = $this->input->post('state', true);
  460. $lacecolor = $this->input->post('lacecolor', true);
  461. $hairnumber = $this->input->post('hairnumber', true);
  462. $cklx = $this->input->post('cklx', true);
  463. $ktime = $this->input->post('ktime', true);
  464. $jtime = $this->input->post('jtime', true);
  465. $ktime = strtotime($ktime);
  466. $jtime = strtotime($jtime);
  467. $where = "1=1";
  468. $gj = "";
  469. $ck = "";
  470. if ($usa) {
  471. if (!$warehouse) {
  472. $where .= " and (warehouse = '5' or warehouse = '8')";
  473. }
  474. }
  475. if ($warehouse) {
  476. $where .= " and warehouse = '$warehouse'";
  477. }
  478. if ($details) {
  479. $where .= " and details = '$details'";
  480. }
  481. if ($purchase) {
  482. $where .= " and purchase = '$purchase'";
  483. }
  484. if ($state) {
  485. $where .= " and state = '$state'";
  486. }
  487. if ($lacetype) {
  488. $where .= " and features like '%-$lacetype-%'";
  489. }
  490. if ($category) {
  491. $where .= " and features like '%-$category-%'";
  492. }
  493. if ($size) {
  494. $where .= " and features like '%-$size-%'";
  495. }
  496. if ($grade) {
  497. $where .= " and features like '%-$grade-%'";
  498. }
  499. if ($color) {
  500. $where .= " and features like '%-$color-%'";
  501. }
  502. if ($lowe) {
  503. $where .= " and features like '%-$lowe-%'";
  504. }
  505. if ($haircap) {
  506. $where .= " and features like '%-$haircap-%'";
  507. }
  508. if ($density) {
  509. $where .= " and features like '%-$density-%'";
  510. }
  511. if ($lacecolor) {
  512. $where .= " and features like '%-$lacecolor-%'";
  513. }
  514. if (!empty($hairnumber)) {
  515. $where .= " and features like '%-128-%' ";
  516. if ($hairnumber < 0) {
  517. $class_list = $this->typeclass->find_all('classid = 43');
  518. foreach ($class_list as $v) {
  519. $where .= " and features not like '%-" . $v['id'] . "-%'";
  520. }
  521. } else {
  522. $where .= " and features like '%-$hairnumber-%'";
  523. }
  524. }
  525. $where_add = '';
  526. if ($cklx) {
  527. $shop = $this->shop->read($cklx);
  528. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  529. }
  530. if ($ktime && $jtime) {
  531. $gj = " and enter > '$ktime' and enter < '$jtime'";
  532. $ck = " and outk > '$ktime' and outk < '$jtime'";
  533. }
  534. //数据排序
  535. $order_str = "id desc";
  536. if (empty($page)) {
  537. $start = 0;
  538. $perpage = 1;
  539. } else {
  540. $start = ($page - 1) * $perpage;
  541. }
  542. if ($sku) {
  543. $sku = trim($sku, ' ');
  544. $sku = trim($sku, ' ');
  545. $where .= " and sku like '%$sku%'";
  546. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm', $order_str, $start, $perpage);
  547. } else if ($title) {
  548. $title = trim($title, ' ');
  549. $title = trim($title, ' ');
  550. $where .= " and title like '%$title%'";
  551. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm', $order_str, $start, $perpage);
  552. } else {
  553. //$where .= " and time > '$ktime' and time < '$jtime'";
  554. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm', $order_str, $start, $perpage);
  555. }
  556. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  557. foreach ($info_list as $k => $v) {
  558. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  559. unset($info_list[$k]['pm']);
  560. unset($info_list[$k]['jm']);
  561. unset($info_list[$k]['bm']);
  562. }
  563. //取得信息列表
  564. $rows = array();
  565. $list = array();
  566. foreach ($info_list as $key => $value) {
  567. $warehouse = $this->warehouse->read($value['warehouse']);
  568. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  569. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  570. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  571. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  572. $number = $value['number'];
  573. $ftime = time() - 15 * 24 * 3600;
  574. $info_list[$key]['warehouse'] = $warehouse['title'];
  575. $info_list[$key]['features'] = count($c);
  576. $z = count($z); //查看订单号
  577. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  578. $ztdata = '';
  579. if (count($zt) > 0) {
  580. foreach ($zt as $vv) {
  581. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  582. }
  583. }
  584. $info_list[$key]['number'] = $ztdata;
  585. $info_list[$key]['sm'] = $z;
  586. $details = array();
  587. $cpid = array();
  588. foreach ($c as $k => $v) {
  589. $details[$v['details']] = $v['details'];
  590. if ($v['cpid'] != 0) {
  591. $cpid[$v['cpid']] = $v['cpid'];
  592. }
  593. }
  594. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  595. if ($value['shop'] != '') {
  596. $shop = explode(',', trim($value['shop'], ','));
  597. $shop = $this->shop->read($shop[0]);
  598. $info_list[$key]['shop'] = $shop['shopname'];
  599. }
  600. }
  601. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  602. $pagenum = ceil($total / $perpage);
  603. $over = $total - ($start + $perpage);
  604. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  605. echo json_encode($rows);
  606. exit;
  607. }
  608. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  609. $this->_Template('whlabel_typedy', $this->data);
  610. }
  611. //进销存浏览
  612. public function _typedy_ck($arg_array)
  613. {
  614. $prc = array();
  615. $purchase = $this->purchase->find_all();
  616. foreach ($purchase as $k => $v) {
  617. $prc[$v['id']] = $v['title'];
  618. }
  619. $post = $this->input->post(NULL, TRUE);
  620. if (isset($post['page'])) {
  621. $page = $this->input->post('page', true);
  622. $perpage = $this->input->post('perpage', true);
  623. $category = $this->input->post('category', true);
  624. $size = $this->input->post('size', true);
  625. $grade = $this->input->post('grade', true);
  626. $color = $this->input->post('color', true);
  627. $lowe = $this->input->post('lowe', true);
  628. $sku = $this->input->post('sku');
  629. $title = $this->input->post('title');
  630. $warehouse = $this->input->post('warehouse', true);
  631. $usa = $this->input->post('usa', true);
  632. $purchase = $this->input->post('purchase', true);
  633. $lacetype = $this->input->post('lacetype', true);
  634. $haircap = $this->input->post('haircap', true);
  635. $density = $this->input->post('density', true);
  636. $details = $this->input->post('details', true);
  637. $state = $this->input->post('state', true);
  638. $lacecolor = $this->input->post('lacecolor', true);
  639. $cklx = $this->input->post('cklx', true);
  640. $ktime = $this->input->post('ktime', true);
  641. $jtime = $this->input->post('jtime', true);
  642. $ktime = strtotime($ktime);
  643. $jtime = strtotime($jtime);
  644. $where = "1=1";
  645. $gj = "";
  646. $ck = "";
  647. if ($lacetype) {
  648. $where .= " and features like '%-$lacetype-%'";
  649. }
  650. if ($category) {
  651. $where .= " and features like '%-$category-%'";
  652. }
  653. if ($size) {
  654. $where .= " and features like '%-$size-%'";
  655. }
  656. if ($grade) {
  657. $where .= " and features like '%-$grade-%'";
  658. }
  659. if ($color) {
  660. $where .= " and features like '%-$color-%'";
  661. }
  662. if ($lowe) {
  663. $where .= " and features like '%-$lowe-%'";
  664. }
  665. if ($haircap) {
  666. $where .= " and features like '%-$haircap-%'";
  667. }
  668. if ($density) {
  669. $where .= " and features like '%-$density-%'";
  670. }
  671. if ($lacecolor) {
  672. $where .= " and features like '%-$lacecolor-%'";
  673. }
  674. if ($usa) {
  675. if (!$warehouse) {
  676. $where .= " and (warehouse = '5' or warehouse = '8')";
  677. }
  678. }
  679. if ($warehouse) {
  680. $where .= " and warehouse = '$warehouse'";
  681. }
  682. if ($details) {
  683. $where .= " and details = '$details'";
  684. }
  685. if ($purchase) {
  686. $where .= " and purchase = '$purchase'";
  687. }
  688. if ($state) {
  689. $where .= " and state = '$state'";
  690. }
  691. $where_add = '';
  692. if ($cklx) {
  693. $shop = $this->shop->read($cklx);
  694. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  695. }
  696. if ($ktime && $jtime) {
  697. $gj = " and enter > '$ktime' and enter < '$jtime'";
  698. $ck = " and outk > '$ktime' and outk < '$jtime'";
  699. }
  700. //数据排序
  701. $order_str = "id desc";
  702. if (empty($page)) {
  703. $start = 0;
  704. $perpage = 1;
  705. } else {
  706. $start = ($page - 1) * $perpage;
  707. }
  708. if ($sku) {
  709. $sku = trim($sku, ' ');
  710. $sku = trim($sku, ' ');
  711. $where .= " and sku like '%$sku%'";
  712. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  713. } else if ($title) {
  714. $title = trim($title, ' ');
  715. $title = trim($title, ' ');
  716. $where .= " and title like '%$title%'";
  717. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  718. } else {
  719. //$where .= " and time > '$ktime' and time < '$jtime'";
  720. $info_list = $this->whlabel->find_pc($where . $where_add . ' and zd != ""', 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,zd,COUNT(CASE WHEN zd != "" and state = 0 THEN 1 ELSE NULL END) AS zd', 'zd desc', $start, $perpage);
  721. }
  722. //取得信息列表
  723. $rows = array();
  724. $list = array();
  725. foreach ($info_list as $key => $value) {
  726. $warehouse = $this->warehouse->read($value['warehouse']);
  727. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  728. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  729. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  730. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  731. $ftime = time() - 15 * 24 * 3600;
  732. $info_list[$key]['warehouse'] = $warehouse['title'];
  733. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  734. //$z = count($z);//查看订单号
  735. //$info_list[$key]['zd'] = $z;
  736. $details = array();
  737. $cpid = array();
  738. foreach ($c as $k => $v) {
  739. $details[$v['details']] = $v['details'];
  740. if ($v['cpid'] != 0) {
  741. $cpid[$v['cpid']] = $v['cpid'];
  742. }
  743. }
  744. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  745. if ($value['shop'] != '') {
  746. $shop = explode(',', trim($value['shop'], ','));
  747. $shop = $this->shop->read($shop[0]);
  748. $info_list[$key]['shop'] = $shop['shopname'];
  749. }
  750. }
  751. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  752. $pagenum = ceil($total / $perpage);
  753. $over = $total - ($start + $perpage);
  754. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  755. echo json_encode($rows);
  756. exit;
  757. }
  758. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  759. $this->_Template('whlabel_typedy_ck', $this->data);
  760. }
  761. public function _typeck($arg_array)
  762. {
  763. $prc = array();
  764. $purchase = $this->purchase->find_all();
  765. foreach ($purchase as $k => $v) {
  766. $prc[$v['id']] = $v['title'];
  767. }
  768. $post = $this->input->post(NULL, TRUE);
  769. if (isset($post['page'])) {
  770. $page = $this->input->post('page', true);
  771. $perpage = $this->input->post('perpage', true);
  772. $category = $this->input->post('category', true);
  773. $size = $this->input->post('size', true);
  774. $grade = $this->input->post('grade', true);
  775. $color = $this->input->post('color', true);
  776. $lacecolor = $this->input->post('lacecolor', true);
  777. $lowe = $this->input->post('lowe', true);
  778. $sku = $this->input->post('sku');
  779. $title = $this->input->post('title');
  780. $warehouse = 13;
  781. $usa = $this->input->post('usa', true);
  782. $purchase = $this->input->post('purchase', true);
  783. $lacetype = $this->input->post('lacetype', true);
  784. $haircap = $this->input->post('haircap', true);
  785. $density = $this->input->post('density', true);
  786. $details = $this->input->post('details', true);
  787. $state = $this->input->post('state', true);
  788. $ktime = $this->input->post('ktime', true);
  789. $jtime = $this->input->post('jtime', true);
  790. $ktime = strtotime($ktime);
  791. $jtime = strtotime($jtime);
  792. $where = "1=1";
  793. $gj = "";
  794. $ck = "";
  795. if ($lacetype) {
  796. $where .= " and features like '%-$lacetype-%'";
  797. }
  798. if ($category) {
  799. $where .= " and features like '%-$category-%'";
  800. }
  801. if ($size) {
  802. $where .= " and features like '%-$size-%'";
  803. }
  804. if ($grade) {
  805. $where .= " and features like '%-$grade-%'";
  806. }
  807. if ($color) {
  808. $where .= " and features like '%-$color-%'";
  809. }
  810. if ($lacecolor) {
  811. $where .= " and features like '%-$lacecolor-%'";
  812. }
  813. if ($lowe) {
  814. $where .= " and features like '%-$lowe-%'";
  815. }
  816. if ($haircap) {
  817. $where .= " and features like '%-$haircap-%'";
  818. }
  819. if ($density) {
  820. $where .= " and features like '%-$density-%'";
  821. }
  822. if ($warehouse) {
  823. $where .= " and warehouse = '$warehouse'";
  824. }
  825. if ($details) {
  826. $where .= " and details = '$details'";
  827. }
  828. if ($purchase) {
  829. $where .= " and purchase = '$purchase'";
  830. }
  831. if ($state) {
  832. $where .= " and state = '$state'";
  833. }
  834. if ($ktime && $jtime) {
  835. $gj = " and enter > '$ktime' and enter < '$jtime'";
  836. $ck = " and outk > '$ktime' and outk < '$jtime'";
  837. }
  838. //数据排序
  839. $order_str = "id desc";
  840. if (empty($page)) {
  841. $start = 0;
  842. $perpage = 1;
  843. } else {
  844. $start = ($page - 1) * $perpage;
  845. }
  846. if ($sku) {
  847. $sku = trim($sku, ' ');
  848. $sku = trim($sku, ' ');
  849. $where .= " and sku like '%$sku%'";
  850. } else if ($title) {
  851. $title = trim($title, ' ');
  852. $title = trim($title, ' ');
  853. $where .= " and title like '%$title%'";
  854. }
  855. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  856. //取得信息列表
  857. $t = array();
  858. $typeclass = $this->typeclass->find_all();
  859. foreach ($typeclass as $v) {
  860. $t[$v['id']] = $v;
  861. }
  862. $rows = array();
  863. $list = array();
  864. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  865. foreach ($info_list as $key => $value) {
  866. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  867. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  868. $warehouse = $this->warehouse->read($value['warehouse']);
  869. $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');
  870. $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'] . '"');
  871. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  872. $number = $value['number'];
  873. $ftime = time() - 15 * 24 * 3600;
  874. $z = count($z); //查看订单号
  875. $info_list[$key]['warehouse'] = $warehouse['title'];
  876. $info_list[$key]['features'] = count($c);
  877. $info_list[$key]['number'] = $z;
  878. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  879. $details = array();
  880. $cpid = array();
  881. foreach ($c as $k => $v) {
  882. $details[$v['details']] = $v['details'];
  883. if ($v['cpid'] != 0) {
  884. $cpid[$v['cpid']] = $v['cpid'];
  885. }
  886. }
  887. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  888. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  889. unset($info_list[$key]['pm']);
  890. unset($info_list[$key]['jm']);
  891. unset($info_list[$key]['bm']);
  892. }
  893. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  894. $pagenum = ceil($total / $perpage);
  895. $over = $total - ($start + $perpage);
  896. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  897. echo json_encode($rows);
  898. exit;
  899. }
  900. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  901. $this->_Template('whlabel_typeck', $this->data);
  902. }
  903. //进销存导出
  904. public function _whlabeckdc()
  905. {
  906. $prc = array();
  907. $purchase = $this->purchase->find_all();
  908. foreach ($purchase as $k => $v) {
  909. $prc[$v['id']] = $v['title'];
  910. }
  911. if (isset($_GET['excel'])) {
  912. $where = "sku != 'Preset'";
  913. //数据排序
  914. $order_str = "id desc";
  915. if (empty($page)) {
  916. $start = 0;
  917. $perpage = 1;
  918. } else {
  919. $start = ($page - 1) * $perpage;
  920. }
  921. $category = $this->input->get('category', true);
  922. $color = $this->input->get('color', true);
  923. $lowe = $this->input->get('lowe', true);
  924. $lacetype = $this->input->get('lacetype', true);
  925. $size = $this->input->get('size', true);
  926. $density = $this->input->get('density', true);
  927. $haircap = $this->input->get('haircap', true);
  928. $sku = $this->input->get('sku', true);
  929. $details = $this->input->get('details', true);
  930. $warehouse = 13;
  931. $excelid = $this->input->get('sid', true);
  932. if ($category) {
  933. $where .= " and features like '%-$category-%'";
  934. }
  935. if ($color) {
  936. $where .= " and features like '%-$color-%'";
  937. }
  938. if ($lowe) {
  939. $where .= " and features like '%-$lowe-%'";
  940. }
  941. if ($lacetype) {
  942. $where .= " and features like '%-$lacetype-%'";
  943. }
  944. if ($size) {
  945. $where .= " and features like '%-$size-%'";
  946. }
  947. if ($density) {
  948. $where .= " and features like '%-$density-%'";
  949. }
  950. if ($haircap) {
  951. $where .= " and features like '%-$haircap-%'";
  952. }
  953. if ($warehouse) {
  954. $where .= " and warehouse = '$warehouse'";
  955. }
  956. if ($sku) {
  957. $where .= " and sku like '%$sku%'";
  958. }
  959. if ($details) {
  960. $where .= " and details = '$details'";
  961. }
  962. $xzid = '';
  963. if ($excelid) {
  964. $excelid = explode(',', trim($excelid, ','));
  965. foreach ($excelid as $key => $value) {
  966. $xzid .= " id = " . $value . " or";
  967. }
  968. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  969. }
  970. //取得信息列表
  971. /**
  972. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  973. $rows = array();$list = array();
  974. foreach ($info_list as $key=>$value)
  975. {
  976. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  977. }
  978. **/
  979. $wh = array();
  980. $w = $this->warehouse->find_all('1=1', 'id,title');
  981. foreach ($w as $v) {
  982. $wh[$v['id']] = $v['title'];
  983. }
  984. $tc = array();
  985. $tcdata = array();
  986. $list = array();
  987. $classid = $this->classid->sku();
  988. $tcall = $this->typeclass->find_all();
  989. $typeclass = array();
  990. foreach ($tcall as $v)
  991. {
  992. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  993. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  994. }
  995. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  996. foreach ($rows as $key => $value) {
  997. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  998. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  999. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1000. $rows[$key]['cpbz'] = $u9_info['bm'];
  1001. $rows[$key]['cs'] = $u9_info['jm'];
  1002. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1003. $details = array();
  1004. $cpid = array();
  1005. $cpbz = array();
  1006. $c = 0;
  1007. $g = 0;
  1008. $x = 0;
  1009. $t = 0;
  1010. $s = 0;
  1011. $q = 0;
  1012. foreach ($sd as $k => $v) {
  1013. if ($v['state'] == 0) {
  1014. $c++;
  1015. }
  1016. if ($v['state'] != 9) {
  1017. $g++;
  1018. }
  1019. if ($v['state'] == 1) {
  1020. $x++;
  1021. }
  1022. if ($v['state'] == 2) {
  1023. $t++;
  1024. }
  1025. if ($v['state'] == 8) {
  1026. $s++;
  1027. }
  1028. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1029. $q++;
  1030. }
  1031. $details[$v['details']] = $v['details'];
  1032. if ($v['cpid'] != 0) {
  1033. $cpid[$v['cpid']] = $v['cpid'];
  1034. }
  1035. if ($v['cpbz'] != '') {
  1036. $cpbz[$v['cpbz']] = $v['cpbz'];
  1037. }
  1038. }
  1039. $rows[$key]['details'] = implode("、", $details);
  1040. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1041. $number = $value['number'];
  1042. $ftime = time() - 15 * 24 * 3600;
  1043. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1044. $rows[$key]['number'] = $g;
  1045. $rows[$key]['features'] = $c;
  1046. $rows[$key]['x'] = $x;
  1047. $rows[$key]['t'] = $t;
  1048. $rows[$key]['s'] = $s;
  1049. $rows[$key]['q'] = $q;
  1050. $rows[$key]['wzsl'] = count($details);
  1051. }
  1052. $title = "进销存统计表" . date('Y-m-d', time());
  1053. $titlename = "<table border=1>
  1054. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1055. <tr align='center'>
  1056. <td>仓库</td>
  1057. <td>供应商</td>
  1058. <td>位置</td>
  1059. <td>库存编码</td>
  1060. <td>SKU</td>
  1061. <td>用友编码</td>
  1062. <td>用友料号</td>
  1063. <td>产品英文名</td>
  1064. <td>产品中文名</td>
  1065. <td>入库总量</td>
  1066. <td>库存数量</td>
  1067. <td>销售数量</td>
  1068. <td>退货数量</td>
  1069. <td>删除数量</td>
  1070. <td>其它操作</td>
  1071. <td>位置数量</td>
  1072. </tr>
  1073. </table>";
  1074. $filename = $title . ".xls";
  1075. $tail = "";
  1076. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1077. }
  1078. }
  1079. public function _type()
  1080. {
  1081. $vip = 0;
  1082. if (isset($_SESSION['api'])) {
  1083. $user = $this->user->get_api($_SESSION['api']);
  1084. $fgshop = "";
  1085. $sid = "";
  1086. $usersp = explode('|', trim($user['shop'], '|'));
  1087. foreach ($usersp as $value) {
  1088. $fgshop .= " shop = " . $value . " or";
  1089. $sid .= " id = " . $value . " or";
  1090. }
  1091. if ($user['vip'] == 1) {
  1092. $vip = 1;
  1093. }
  1094. } else {
  1095. header('Location: /');
  1096. exit;
  1097. }
  1098. $prc = array();
  1099. $purchase = $this->purchase->find_all();
  1100. foreach ($purchase as $k => $v) {
  1101. $prc[$v['id']] = $v['title'];
  1102. }
  1103. $company = array();
  1104. $ct = $this->company->find_all();
  1105. foreach ($ct as $k => $v) {
  1106. $company[$v['id']] = $v['title'];
  1107. }
  1108. $sp = array();
  1109. $s = $this->shop->find_all('1=1', 'id,shopname');
  1110. foreach ($s as $v) {
  1111. $sp[$v['id']] = $v['shopname'];
  1112. }
  1113. $wh = array();
  1114. $w = $this->warehouse->find_all('1=1', 'id,title');
  1115. foreach ($w as $v) {
  1116. $wh[$v['id']] = $v['title'];
  1117. }
  1118. $post = $this->input->post(NULL, TRUE);
  1119. if (isset($post['page'])) {
  1120. $page = $this->input->post('page', true);
  1121. $perpage = $this->input->post('perpage', true);
  1122. $category = $this->input->post('category', true);
  1123. $size = $this->input->post('size', true);
  1124. $grade = $this->input->post('grade', true);
  1125. $color = $this->input->post('color', true);
  1126. $lowe = $this->input->post('lowe', true);
  1127. $sku = $this->input->post('sku');
  1128. $title = $this->input->post('title');
  1129. $warehouse = $this->input->post('warehouse', true);
  1130. $usa = $this->input->post('usa', true);
  1131. $purchase = $this->input->post('purchase', true);
  1132. $lacetype = $this->input->post('lacetype', true);
  1133. $haircap = $this->input->post('haircap', true);
  1134. $density = $this->input->post('density', true);
  1135. $details = $this->input->post('details', true);
  1136. $state = $this->input->post('state', true);
  1137. $shop = $this->input->post('shop', true);
  1138. $lacecolor = $this->input->post('lacecolor', true);
  1139. $hairnumber = $this->input->post('hairnumber', true);
  1140. $type = $this->input->post('type', true);
  1141. $ktime = $this->input->post('ktime', true);
  1142. $jtime = $this->input->post('jtime', true);
  1143. $ktime = strtotime($ktime);
  1144. $jtime = strtotime($jtime);
  1145. $cpbz = $this->input->post('cpbz', true);
  1146. $where = "1=1";
  1147. $gj = "";
  1148. $ck = "";
  1149. if ($usa) {
  1150. if (!$warehouse) {
  1151. $where .= " and (warehouse = '5' or warehouse = '8')";
  1152. }
  1153. }
  1154. if ($warehouse) {
  1155. $where .= " and warehouse = '$warehouse'";
  1156. }
  1157. if ($details) {
  1158. $where .= " and details = '$details'";
  1159. }
  1160. if ($purchase) {
  1161. $where .= " and purchase = '$purchase'";
  1162. }
  1163. if ($state) {
  1164. $where .= " and state = '$state'";
  1165. }
  1166. if ($shop) {
  1167. $where .= " and shop like '%$shop%'";
  1168. }
  1169. if ($type) {
  1170. $where .= " and type = '$type'";
  1171. }
  1172. if ($ktime && $jtime) {
  1173. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1174. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1175. }
  1176. if ($cpbz) {
  1177. $where .= " and cpbz like '%$cpbz%' ";
  1178. }
  1179. if ($lacecolor) {
  1180. $where .= " and features like '%-$lacecolor-%'";
  1181. }
  1182. if ($lacetype) {
  1183. $where .= " and features like '%-$lacetype-%'";
  1184. }
  1185. if ($category) {
  1186. $where .= " and features like '%-$category-%'";
  1187. }
  1188. if ($size) {
  1189. $where .= " and features like '%-$size-%'";
  1190. }
  1191. if ($grade) {
  1192. $where .= " and features like '%-$grade-%'";
  1193. }
  1194. if ($color) {
  1195. $where .= " and features like '%-$color-%'";
  1196. }
  1197. if ($lowe) {
  1198. $where .= " and features like '%-$lowe-%'";
  1199. }
  1200. if ($haircap) {
  1201. $where .= " and features like '%-$haircap-%'";
  1202. }
  1203. if ($density) {
  1204. $where .= " and features like '%-$density-%'";
  1205. }
  1206. if (!empty($hairnumber)) {
  1207. $where .= " and features like '%-128-%' ";
  1208. if ($hairnumber < 0) {
  1209. $class_list = $this->typeclass->find_all('classid = 43');
  1210. foreach ($class_list as $v) {
  1211. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1212. }
  1213. } else {
  1214. $where .= " and features like '%-$hairnumber-%'";
  1215. }
  1216. }
  1217. //数据排序
  1218. $order_str = "id desc";
  1219. if (empty($page)) {
  1220. $start = 0;
  1221. $perpage = 1;
  1222. } else {
  1223. $start = ($page - 1) * $perpage;
  1224. }
  1225. $fjnr = '';
  1226. if ($sku) {
  1227. $sku = trim($sku, ' ');
  1228. $sku = trim($sku, ' ');
  1229. $fjnr .= " and sku like '%$sku%'";
  1230. }
  1231. if ($title) {
  1232. $title = trim($title, ' ');
  1233. $title = trim($title, ' ');
  1234. $fjnr .= " and title like '%$title%'";
  1235. }
  1236. $wt = array();
  1237. $whlabel_type = $this->whlabel_type->find_all();
  1238. foreach ($whlabel_type as $v) {
  1239. $wt[$v['id']] = $v['title'];
  1240. }
  1241. //$where .= " and time > '$ktime' and time < '$jtime'";
  1242. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,type,features,number,sm', $order_str, $start, $perpage); //改这需要修改_gbhtype
  1243. //取得信息列表
  1244. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1245. $rows = array();
  1246. $list = array();
  1247. foreach ($info_list as $key => $value) {
  1248. if (isset($wt[$value['type']])) {
  1249. $info_list[$key]['type'] = $wt[$value['type']];
  1250. } else {
  1251. $info_list[$key]['type'] = '未设置';
  1252. }
  1253. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1254. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1255. $ztdata = '';
  1256. if (count($zt) > 0) {
  1257. foreach ($zt as $vv) {
  1258. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1259. }
  1260. }
  1261. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1262. $cdata = array_filter($qbdata, function ($item) {
  1263. return $item['state'] < 1;
  1264. });
  1265. $c = array_sum(array_column($cdata, 'jnum'));
  1266. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1267. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1268. });
  1269. $g = array_sum(array_column($gdata, 'jnum'));
  1270. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1271. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1272. });
  1273. $x = array_sum(array_column($xdata, 'jnum'));
  1274. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1275. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1276. });
  1277. $t = array_sum(array_column($tdata, 'jnum'));
  1278. $zdata = array_filter($qbdata, function ($item) {
  1279. return $item['zd'] != "" && $item['state'] < 1;
  1280. });
  1281. $z = array_sum(array_column($zdata, 'jnum'));
  1282. $zdata = array_filter($qbdata, function ($item) {
  1283. return $item['zd'] != "" && $item['state'] < 1;
  1284. });
  1285. $z = array_sum(array_column($zdata, 'jnum'));
  1286. //$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');
  1287. //$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'].'"');
  1288. //$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'].'"');
  1289. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1290. //$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'].'"');
  1291. $details = array();
  1292. $cpid = array();
  1293. $od = array();
  1294. $odid = '';
  1295. $companytitle = '';
  1296. foreach ($qbdata as $v) {
  1297. if ($v['zd'] != "" && $v['state'] < 1) {
  1298. if (!isset($od[$v['zd']])) {
  1299. $od[$v['zd']] = 1; //所有数据sku
  1300. } else {
  1301. $od[$v['zd']] = $od[$v['zd']] + 1;
  1302. }
  1303. }
  1304. if ($v['state'] < 1) {
  1305. $details[$v['details']] = $v['details'];
  1306. if ($v['cpid'] != 0) {
  1307. $cpid[$v['cpid']] = $v['cpid'];
  1308. }
  1309. }
  1310. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1311. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1312. }
  1313. }
  1314. foreach ($od as $k => $vv) {
  1315. $odid .= $k . '数量' . $vv;
  1316. }
  1317. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  1318. $number = $value['number'];
  1319. $ftime = time() - 15 * 24 * 3600;
  1320. $z = $z . '(' . $odid . ')'; //查看订单号
  1321. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1322. $info_list[$key]['features'] = $c;
  1323. $info_list[$key]['number'] = $ztdata;
  1324. $info_list[$key]['sm'] = $g;
  1325. $info_list[$key]['x'] = $x;
  1326. $info_list[$key]['t'] = $t;
  1327. $info_list[$key]['z'] = $z;
  1328. /**
  1329. foreach ($cdata as $k=>$v)
  1330. {
  1331. $details[$v['details']] = $v['details'];
  1332. if($v['cpid'] != 0)
  1333. {
  1334. $cpid[$v['cpid']] = $v['cpid'];
  1335. }
  1336. }
  1337. **/
  1338. $info_list[$key]['shop'] = '';
  1339. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1340. if ($value['shop'] != '') {
  1341. $shop = explode(',', trim($value['shop'], ','));
  1342. $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1343. }
  1344. $info_list[$key]['shop'] .= $companytitle;
  1345. /**
  1346. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1347. if(isset($companytitle[0]))
  1348. {
  1349. foreach ($companytitle as $k=>$v)
  1350. {
  1351. if($v['companytitle'] != '')
  1352. {
  1353. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1354. }
  1355. }
  1356. }
  1357. **/
  1358. }
  1359. $final_all_list = [];
  1360. foreach ($info_list as $k => $v) {
  1361. $final_all_list[] = [
  1362. 'id' => $v['id'],
  1363. "warehouse" => $v["warehouse"],
  1364. "purchase" => $v["purchase"],
  1365. "sku" => $v["sku"],
  1366. "title" => $v["title"] . "<br/>" . $v["pm"],
  1367. "details" => $v["details"],
  1368. "shop" => $v["shop"],
  1369. "cpbz" => $v["cpbz"],
  1370. "type" => $v["type"],
  1371. "features" => $v["features"],
  1372. "number" => $v["number"],
  1373. "sm" => $v["sm"],
  1374. "x" => $v["x"],
  1375. "t" => $v["t"],
  1376. "z" => $v["z"]
  1377. ];
  1378. }
  1379. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1380. $pagenum = ceil($total / $perpage);
  1381. $over = $total - ($start + $perpage);
  1382. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1383. echo json_encode($rows);
  1384. exit;
  1385. }
  1386. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1387. $this->data['shop'] = $wlshop;
  1388. $this->data['vip'] = $vip;
  1389. $this->_Template('whlabel_type', $this->data);
  1390. }
  1391. //美仓进销存浏览
  1392. public function _usatype()
  1393. {
  1394. if (isset($_SESSION['api'])) {
  1395. $user = $this->user->get_api($_SESSION['api']);
  1396. $usp = $user;
  1397. $fgshop = "";
  1398. $sid = "";
  1399. $wid = "";
  1400. $wtype = "";
  1401. $userwh = explode('|', trim($user['warehouse'], '|'));
  1402. foreach ($userwh as $value) {
  1403. $wid .= " id = " . $value . " or";
  1404. $wtype .= " type = " . $value . " or";
  1405. }
  1406. }
  1407. $prc = array();
  1408. $purchase = $this->purchase->find_all();
  1409. foreach ($purchase as $k => $v) {
  1410. $prc[$v['id']] = $v['title'];
  1411. }
  1412. $post = $this->input->post(NULL, TRUE);
  1413. if (isset($post['page'])) {
  1414. $page = $this->input->post('page', true);
  1415. $perpage = $this->input->post('perpage', true);
  1416. $category = $this->input->post('category', true);
  1417. $size = $this->input->post('size', true);
  1418. $grade = $this->input->post('grade', true);
  1419. $color = $this->input->post('color', true);
  1420. $lowe = $this->input->post('lowe', true);
  1421. $sku = $this->input->post('sku');
  1422. $title = $this->input->post('title');
  1423. $warehouse = $this->input->post('warehouse', true);
  1424. $usa = $this->input->post('usa', true);
  1425. $purchase = $this->input->post('purchase', true);
  1426. $lacetype = $this->input->post('lacetype', true);
  1427. $haircap = $this->input->post('haircap', true);
  1428. $density = $this->input->post('density', true);
  1429. $details = $this->input->post('details', true);
  1430. $state = $this->input->post('state', true);
  1431. $lacecolor = $this->input->post('lacecolor', true);
  1432. $cklx = $this->input->post('cklx', true);
  1433. $ktime = $this->input->post('ktime', true);
  1434. $jtime = $this->input->post('jtime', true);
  1435. $ktime = strtotime($ktime);
  1436. $jtime = strtotime($jtime);
  1437. $where = "1=1";
  1438. $gj = "";
  1439. $ck = "";
  1440. if ($lacetype) {
  1441. $where .= " and features like '%-$lacetype-%'";
  1442. }
  1443. if ($category) {
  1444. $where .= " and features like '%-$category-%'";
  1445. }
  1446. if ($size) {
  1447. $where .= " and features like '%-$size-%'";
  1448. }
  1449. if ($grade) {
  1450. $where .= " and features like '%-$grade-%'";
  1451. }
  1452. if ($color) {
  1453. $where .= " and features like '%-$color-%'";
  1454. }
  1455. if ($lowe) {
  1456. $where .= " and features like '%-$lowe-%'";
  1457. }
  1458. if ($haircap) {
  1459. $where .= " and features like '%-$haircap-%'";
  1460. }
  1461. if ($density) {
  1462. $where .= " and features like '%-$density-%'";
  1463. }
  1464. if ($lacecolor) {
  1465. $where .= " and features like '%-$lacecolor-%'";
  1466. }
  1467. if ($usa) {
  1468. if (!$warehouse) {
  1469. $where .= " and (warehouse = '5' or warehouse = '8')";
  1470. }
  1471. }
  1472. if ($warehouse) {
  1473. $where .= " and warehouse = '$warehouse'";
  1474. }
  1475. if ($details) {
  1476. $where .= " and details = '$details'";
  1477. }
  1478. if ($purchase) {
  1479. $where .= " and purchase = '$purchase'";
  1480. }
  1481. if ($state) {
  1482. $where .= " and state = '$state'";
  1483. }
  1484. $where_add = '';
  1485. if ($cklx) {
  1486. $shop = $this->shop->read($cklx);
  1487. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1488. }
  1489. if ($ktime && $jtime) {
  1490. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1491. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1492. }
  1493. //数据排序
  1494. $order_str = "id desc";
  1495. if (empty($page)) {
  1496. $start = 0;
  1497. $perpage = 1;
  1498. } else {
  1499. $start = ($page - 1) * $perpage;
  1500. }
  1501. if ($sku) {
  1502. $sku = trim($sku, ' ');
  1503. $sku = trim($sku, ' ');
  1504. $where .= " and sku like '%$sku%'";
  1505. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1506. } else if ($title) {
  1507. $title = trim($title, ' ');
  1508. $title = trim($title, ' ');
  1509. $where .= " and title like '%$title%'";
  1510. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1511. } else {
  1512. //$where .= " and time > '$ktime' and time < '$jtime'";
  1513. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1514. }
  1515. //取得信息列表
  1516. $rows = array();
  1517. $list = array();
  1518. foreach ($info_list as $key => $value) {
  1519. $warehouse = $this->warehouse->read($value['warehouse']);
  1520. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1521. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1522. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1523. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1524. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1525. $od = array();
  1526. $odid = '';
  1527. foreach ($z as $v) {
  1528. if (!isset($od[$v['zd']])) {
  1529. $od[$v['zd']] = 1; //所有数据sku
  1530. } else {
  1531. $od[$v['zd']] = $od[$v['zd']] + 1;
  1532. }
  1533. }
  1534. foreach ($od as $k => $vv) {
  1535. $odid .= $k . '数量' . $vv . ' ';
  1536. }
  1537. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1538. $info_list[$key]['features'] = $c;
  1539. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1540. $ztdata = '';
  1541. if (count($zt) > 0) {
  1542. foreach ($zt as $vv) {
  1543. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1544. }
  1545. }
  1546. $info_list[$key]['warehouse'] = $ztdata;
  1547. $info_list[$key]['g'] = $g;
  1548. $info_list[$key]['x'] = $x;
  1549. $info_list[$key]['t'] = $t;
  1550. $info_list[$key]['z'] = $z;
  1551. }
  1552. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1553. $pagenum = ceil($total / $perpage);
  1554. $over = $total - ($start + $perpage);
  1555. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1556. echo json_encode($rows);
  1557. exit;
  1558. }
  1559. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1560. $this->data['warehouse'] = $warehouse;
  1561. $this->_Template('whlabel_typeusa', $this->data);
  1562. }
  1563. //美仓进销存浏览
  1564. public function _usatypeapp()
  1565. {
  1566. $post = $this->input->post(NULL, TRUE);
  1567. if (isset($post['page'])) {
  1568. $page = $this->input->post('page', true);
  1569. $perpage = $this->input->post('perpage', true);
  1570. $sku = $this->input->post('sku', true);
  1571. $warehouse = 5;
  1572. $title = $this->input->post('title', true);
  1573. $state = $this->input->post('state', true);
  1574. $ktime = $this->input->post('ktime', true);
  1575. $jtime = $this->input->post('jtime', true);
  1576. $ktime = strtotime($ktime);
  1577. $jtime = strtotime($jtime);
  1578. $where = "1=1";
  1579. $gj = "";
  1580. $ck = "";
  1581. if ($title) {
  1582. $st = explode(' ', trim($title, ' '));
  1583. foreach ($st as $v) {
  1584. $where .= " and title like '%$v%'";
  1585. }
  1586. }
  1587. if ($warehouse) {
  1588. $where .= " and warehouse = '$warehouse'";
  1589. }
  1590. if ($state) {
  1591. $where .= " and state = '$state'";
  1592. }
  1593. if ($sku) {
  1594. $where .= " and sku like '%$sku%'";
  1595. }
  1596. if ($ktime && $jtime) {
  1597. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1598. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1599. }
  1600. //数据排序
  1601. $order_str = "id desc";
  1602. if (empty($page)) {
  1603. $start = 0;
  1604. $perpage = 1;
  1605. } else {
  1606. $start = ($page - 1) * $perpage;
  1607. }
  1608. //取得信息列表
  1609. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1610. $rows = array();
  1611. $list = array();
  1612. foreach ($info_list as $key => $value) {
  1613. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1614. }
  1615. $rowsdq = array_slice($rows, $start, $perpage);
  1616. foreach ($rowsdq as $value) {
  1617. $warehouse = $this->warehouse->read($value['warehouse']);
  1618. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1619. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1620. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1621. $od = array();
  1622. $odid = '';
  1623. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1624. }
  1625. $total = count($rows);
  1626. $pagenum = ceil($total / $perpage);
  1627. $over = $total - ($start + $perpage);
  1628. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1629. echo json_encode($rows);
  1630. exit;
  1631. }
  1632. $this->_Template('phone/p_usatypeapp', $this->data);
  1633. }
  1634. //入库操作
  1635. public function _enteradd()
  1636. {
  1637. $dt = 0;
  1638. if (isset($_SESSION['api'])) {
  1639. $user = $this->user->get_api($_SESSION['api']);
  1640. $usp = $user;
  1641. $fgshop = "";
  1642. $sid = "";
  1643. $user = explode('|', trim($user['shop'], '|'));
  1644. foreach ($user as $value) {
  1645. $fgshop .= " shop = " . $value . " or";
  1646. $sid .= " id = " . $value . " or";
  1647. }
  1648. }
  1649. $tc = $this->typeclass->find_all();
  1650. $typeclass = array();
  1651. foreach ($tc as $v) {
  1652. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1653. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1654. }
  1655. $post = $this->input->post(NULL, TRUE);
  1656. if (isset($post['sku'])) {
  1657. $list = array();
  1658. $num = "";
  1659. $title = "";
  1660. $features = "";
  1661. $order = $this->input->post('order', true);
  1662. $shop = $this->input->post('shop', true);
  1663. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1664. $sku = $this->input->post('sku', true);
  1665. $post['sm'] = $this->input->post('sm', true);
  1666. $post['warehouse'] = $this->input->post('warehouse', true);
  1667. $post['purchase'] = $this->input->post('purchase', true);
  1668. $post['retreatwarehouse'] = $post['warehouse'];
  1669. $post['state'] = $this->input->post('state', true);
  1670. $post['rktype'] = $this->input->post('rktype', true);
  1671. $post['text'] = $this->input->post('text', true);
  1672. $category = $this->input->post('category', true);
  1673. $list['category'] = $category;
  1674. $list['hairtype'] = $this->input->post('hairtype', true);
  1675. $list['grade'] = $this->input->post('grade', true);
  1676. $size = $this->input->post('size', true);
  1677. $xzsku = $this->input->post('xzsku', true);
  1678. $list['size'] = rtrim($size, ',');
  1679. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1680. $list['extension'] = $this->input->post('extension', true);
  1681. if ($category == 1297) {
  1682. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1683. }
  1684. if ($category == 1702) {
  1685. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1686. $list['syother'] = $this->input->post('syother', true);
  1687. }
  1688. if ($category == 133) {
  1689. $list['fittype'] = $this->input->post('fittype', true);
  1690. $list['acother'] = $this->input->post('acother', true);
  1691. }
  1692. $list['color'] = $this->input->post('color', true);
  1693. $list['lowe'] = $this->input->post('lowe', true);
  1694. if (!$post['purchase']) {
  1695. $post['purchase'] = 1;
  1696. }
  1697. if ($category == 127) {
  1698. $list['type'] = $this->input->post('type', true);
  1699. $list['headroad'] = $this->input->post('headroad', true);
  1700. $list['density'] = $this->input->post('density', true);
  1701. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1702. $list['lacesize'] = $this->input->post('lacesize', true);
  1703. }
  1704. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1705. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1706. }
  1707. if ($category == 128) {
  1708. $list['lacetype'] = $this->input->post('lacetype', true);
  1709. $list['haircap'] = $this->input->post('haircap', true);
  1710. $list['density'] = $this->input->post('density', true);
  1711. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1712. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1713. $list['wigother'] = $this->input->post('wigother', true);
  1714. $list['wigother1'] = $this->input->post('wigother1', true);
  1715. $list['wigother2'] = $this->input->post('wigother2', true);
  1716. }
  1717. if ($category == 129) {
  1718. $list['wide'] = $this->input->post('wide', true);
  1719. }
  1720. if ($category == 131) {
  1721. $list['gifttype'] = $this->input->post('gifttype', true);
  1722. $list['giftother'] = $this->input->post('giftother', true);
  1723. }
  1724. if ($category == 134) {
  1725. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1726. }
  1727. if ($category == 1297) {
  1728. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1729. $list['sywigother'] = $this->input->post('sywigother', true);
  1730. }
  1731. if ($category == 130 || $category == 133 || $category == 1702) {
  1732. $list['items'] = $this->input->post('items', true);
  1733. $list['weight'] = $this->input->post('weight', true);
  1734. }
  1735. if ($category == 1702) {
  1736. $list['syhairther'] = $this->input->post('syhairther', true);
  1737. }
  1738. $classid = $this->classid->sku();
  1739. $scsku = $classid;
  1740. $pm = $classid;
  1741. foreach ($list as $k => $v) {
  1742. if ($v != 0) {
  1743. $num .= $v;
  1744. $features .= $v . '-';
  1745. $post[$k] = $v;
  1746. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1747. if ($k != 'size') {
  1748. $title .= $typeclass[$v]['title'] . " ";
  1749. }
  1750. if (isset($pm[$typeclass[$v]['classid']])) {
  1751. if ($typeclass[$v]['title'] == '9A') {
  1752. $pm[$typeclass[$v]['classid']] = '9A';
  1753. } else if ($typeclass[$v]['title'] == '10A') {
  1754. $pm[$typeclass[$v]['classid']] = '10A';
  1755. } else {
  1756. $clzh = $typeclass[$v]['zh'];
  1757. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1758. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1759. $clzh = $clzh[0];
  1760. }
  1761. $pm[$typeclass[$v]['classid']] = $clzh;
  1762. }
  1763. }
  1764. }
  1765. }
  1766. $zh = implode(" ", $pm);
  1767. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1768. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1769. if ($list['size']) {
  1770. $typeclass = $this->typeclass->read($list['size']);
  1771. $title .= $typeclass['title'];
  1772. }
  1773. $time = time();
  1774. if ($xzsku) {
  1775. $scsku = implode("-", $scsku);
  1776. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1777. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1778. $post['sku'] = trim($scsku, ' ');
  1779. } else {
  1780. $post['sku'] = $sku;
  1781. }
  1782. //$post['sku'] = trim($sku,' ');
  1783. $post['title'] = rtrim($title, ' ');
  1784. $post['number'] = $num;
  1785. $post['features'] = '-' . $features;
  1786. $post['enter'] = $time;
  1787. $post['time'] = $time; //操作时间
  1788. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1789. if ($yza) {
  1790. if ($post['features'] != $yza[0]['features']) {
  1791. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1792. exit;
  1793. }
  1794. }
  1795. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1796. if ($yzb) {
  1797. if ($post['sku'] != $yzb[0]['sku']) {
  1798. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1799. exit;
  1800. }
  1801. }
  1802. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1803. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1804. exit;
  1805. }
  1806. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1807. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1808. exit;
  1809. }
  1810. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1811. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1812. exit;
  1813. }
  1814. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1815. if (isset($yz[0]['type'])) {
  1816. $post['type'] = $yz[0]['type'];
  1817. }
  1818. if ($post['state'] == 9) //如果选择预设库存
  1819. {
  1820. $this->whlabel->insert($post);
  1821. } else {
  1822. /**
  1823. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1824. if($ljg == 1)
  1825. {
  1826. for($i=0;$i<$order;$i++)
  1827. {
  1828. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1829. $this->whlabel->insert($post);
  1830. }
  1831. }
  1832. **/
  1833. //if($post['warehouse'] == '5')
  1834. //{
  1835. //}
  1836. $yydata = $post;
  1837. $yydata['zh'] = $zh;
  1838. /**
  1839. $wl = $this->apiyy->get_cjlp($yydata);
  1840. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1841. {
  1842. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1843. }
  1844. if($wl['Data'][0]['m_isSucess'] != 1)
  1845. {
  1846. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1847. }
  1848. **/
  1849. for ($i = 0; $i < $order; $i++) {
  1850. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1851. $this->whlabel->insert($post);
  1852. }
  1853. }
  1854. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1855. exit;
  1856. }
  1857. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1858. $this->data['wlshop'] = $wlshop;
  1859. $this->_Template('whlabel_enteradd', $this->data);
  1860. }
  1861. //修改产品
  1862. public function _enteredit($arg_array)
  1863. {
  1864. $dt = 0;
  1865. if (isset($_SESSION['api'])) {
  1866. $user = $this->user->get_api($_SESSION['api']);
  1867. $usp = $user;
  1868. $fgshop = "";
  1869. $sid = "";
  1870. $user = explode('|', trim($user['shop'], '|'));
  1871. foreach ($user as $value) {
  1872. $fgshop .= " shop = " . $value . " or";
  1873. $sid .= " id = " . $value . " or";
  1874. }
  1875. }
  1876. $post = $this->input->post(NULL, TRUE);
  1877. if (isset($post['sku'])) {
  1878. $list = array();
  1879. $num = "";
  1880. $title = "";
  1881. $features = "";
  1882. $id = $this->input->post('id', true);
  1883. $order = $this->input->post('order', true);
  1884. $shop = $this->input->post('shop', true);
  1885. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1886. $post['sku'] = $this->input->post('sku', true);
  1887. $post['sm'] = $this->input->post('sm', true);
  1888. $post['warehouse'] = $this->input->post('warehouse', true);
  1889. $post['purchase'] = $this->input->post('purchase', true);
  1890. $post['retreatwarehouse'] = $post['warehouse'];
  1891. $category = $this->input->post('category', true);
  1892. $list['category'] = $category;
  1893. $list['hairtype'] = $this->input->post('hairtype', true);
  1894. $list['grade'] = $this->input->post('grade', true);
  1895. $size = $this->input->post('size', true);
  1896. $list['size'] = rtrim($size, ',');
  1897. $post['rktype'] = $this->input->post('rktype', true);
  1898. $post['text'] = $this->input->post('text', true);
  1899. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1900. $list['extension'] = $this->input->post('extension', true);
  1901. if ($category == 1297) {
  1902. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1903. }
  1904. if ($category == 1702) {
  1905. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1906. $list['syother'] = $this->input->post('syother', true);
  1907. }
  1908. if ($category == 133) {
  1909. $list['fittype'] = $this->input->post('fittype', true);
  1910. $list['acother'] = $this->input->post('acother', true);
  1911. }
  1912. $list['color'] = $this->input->post('color', true);
  1913. $list['lowe'] = $this->input->post('lowe', true);
  1914. if (!$post['purchase']) {
  1915. $post['purchase'] = 1;
  1916. }
  1917. if ($category == 127) {
  1918. $list['type'] = $this->input->post('type', true);
  1919. $list['headroad'] = $this->input->post('headroad', true);
  1920. $list['density'] = $this->input->post('density', true);
  1921. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1922. $list['lacesize'] = $this->input->post('lacesize', true);
  1923. }
  1924. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1925. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1926. }
  1927. if ($category == 128) {
  1928. $list['lacetype'] = $this->input->post('lacetype', true);
  1929. $list['haircap'] = $this->input->post('haircap', true);
  1930. $list['density'] = $this->input->post('density', true);
  1931. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1932. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1933. $list['wigother'] = $this->input->post('wigother', true);
  1934. $list['wigother1'] = $this->input->post('wigother2', true);
  1935. $list['wigother2'] = $this->input->post('wigother2', true);
  1936. }
  1937. if ($category == 129) {
  1938. $list['wide'] = $this->input->post('wide', true);
  1939. }
  1940. if ($category == 131) {
  1941. $list['gifttype'] = $this->input->post('gifttype', true);
  1942. $list['giftother'] = $this->input->post('giftother', true);
  1943. }
  1944. if ($category == 134) {
  1945. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1946. }
  1947. if ($category == 1297) {
  1948. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1949. $list['sywigother'] = $this->input->post('sywigother', true);
  1950. }
  1951. if ($category == 130 || $category == 133 || $category == 1702) {
  1952. $list['items'] = $this->input->post('items', true);
  1953. $list['weight'] = $this->input->post('weight', true);
  1954. }
  1955. if ($category == 1702) {
  1956. $list['syhairther'] = $this->input->post('syhairther', true);
  1957. }
  1958. foreach ($list as $k => $v) {
  1959. if ($v != 0) {
  1960. $num .= $v;
  1961. $features .= $v . '-';
  1962. $typeclass = $this->typeclass->read($v);
  1963. if ($k != 'size') {
  1964. $title .= $typeclass['title'] . " ";
  1965. }
  1966. }
  1967. }
  1968. $typeclass = $this->typeclass->read($list['size']);
  1969. $title .= $typeclass['title'];
  1970. $time = time();
  1971. $post['title'] = rtrim($title, ' ');
  1972. $post['number'] = $num;
  1973. $post['features'] = '-' . $features;
  1974. $post['time'] = $time; //操作时间
  1975. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1976. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1977. exit;
  1978. }
  1979. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1980. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1981. exit;
  1982. }
  1983. $uid = $this->whlabel->read($id);
  1984. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  1985. if ($datanum > 0) {
  1986. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  1987. exit;
  1988. }
  1989. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  1990. {
  1991. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  1992. if ($yza) {
  1993. if ($post['features'] != $yza[0]['features']) {
  1994. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  1995. exit;
  1996. }
  1997. }
  1998. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  1999. if ($yzb) {
  2000. if ($post['sku'] != $yzb[0]['sku']) {
  2001. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2002. exit;
  2003. }
  2004. }
  2005. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2006. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2007. exit;
  2008. }
  2009. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2010. foreach ($data as $v) {
  2011. $post['id'] = $v['id'];
  2012. $this->whlabel->save($post, $v['id']);
  2013. }
  2014. } else {
  2015. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2016. if ($data > 0) {
  2017. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2018. exit;
  2019. } else {
  2020. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2021. foreach ($data as $v) {
  2022. $post['id'] = $v['id'];
  2023. $this->whlabel->save($post, $v['id']);
  2024. }
  2025. }
  2026. }
  2027. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2028. exit;
  2029. }
  2030. $uid = $this->whlabel->read($arg_array[0]);
  2031. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2032. $this->data['enter'] = $uid;
  2033. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2034. $this->data['wlshop'] = $wlshop;
  2035. $this->_Template('whlabel_enteredit', $this->data);
  2036. }
  2037. //入库浏览
  2038. public function _enter()
  2039. {
  2040. $post = $this->input->post(NULL, TRUE);
  2041. if (isset($post['s'])) {
  2042. $id_arr = $this->input->post('s');
  2043. $id_arr = explode(',', $id_arr);
  2044. if (!$id_arr) {
  2045. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2046. exit;
  2047. }
  2048. //循环删除记录
  2049. foreach ($id_arr as $v) {
  2050. $sid = $this->whlabel->read($v);
  2051. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2052. if ($count > 0) {
  2053. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2054. exit;
  2055. }
  2056. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2057. foreach ($info_list as $va) {
  2058. $this->whlabel->remove($va['id']);
  2059. }
  2060. }
  2061. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2062. exit;
  2063. }
  2064. $sp = array();
  2065. $s = $this->shop->find_all('1=1', 'id,shopname');
  2066. foreach ($s as $v) {
  2067. $sp[$v['id']] = $v['shopname'];
  2068. }
  2069. $wh = array();
  2070. $w = $this->warehouse->find_all('1=1', 'id,title');
  2071. foreach ($w as $v) {
  2072. $wh[$v['id']] = $v['title'];
  2073. }
  2074. if (isset($post['page'])) {
  2075. $page = $this->input->post('page', true);
  2076. $perpage = $this->input->post('perpage', true);
  2077. $category = $this->input->post('category', true);
  2078. $size = $this->input->post('size', true);
  2079. $grade = $this->input->post('grade', true);
  2080. $color = $this->input->post('color', true);
  2081. $lowe = $this->input->post('lowe', true);
  2082. $sku = $this->input->post('sku', true);
  2083. $warehouse = $this->input->post('warehouse', true);
  2084. $purchase = $this->input->post('purchase', true);
  2085. $ktime = $this->input->post('ktime', true);
  2086. $jtime = $this->input->post('jtime', true);
  2087. $ktime = strtotime($ktime);
  2088. $jtime = strtotime($jtime);
  2089. $where = "1=1";
  2090. $gj = "";
  2091. $ck = "";
  2092. if ($category) {
  2093. $where .= " and features like '%-$category-%'";
  2094. }
  2095. if ($size) {
  2096. $where .= " and features like '%-$size-%'";
  2097. }
  2098. if ($grade) {
  2099. $where .= " and features like '%-$grade-%'";
  2100. }
  2101. if ($color) {
  2102. $where .= " and features like '%-$color-%'";
  2103. }
  2104. if ($lowe) {
  2105. $where .= " and features like '%-$lowe-%'";
  2106. }
  2107. if ($warehouse) {
  2108. $where .= " and warehouse = '$warehouse'";
  2109. }
  2110. if ($purchase) {
  2111. $where .= " and purchase = '$purchase'";
  2112. }
  2113. if ($sku) {
  2114. $where .= " and sku like '%$sku%'";
  2115. }
  2116. if ($ktime && $jtime) {
  2117. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2118. }
  2119. //数据排序
  2120. $order_str = "enter desc";
  2121. if (empty($page)) {
  2122. $start = 0;
  2123. $perpage = 1;
  2124. } else {
  2125. $start = ($page - 1) * $perpage;
  2126. }
  2127. //取得信息列表
  2128. $info_list = $this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2129. foreach ($info_list as $k => $v) {
  2130. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2131. if ($v['shop'] == '') {
  2132. $s = '通用';
  2133. } else {
  2134. $info_list[$k]['shop'] = '';
  2135. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2136. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2137. }
  2138. }
  2139. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2140. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2141. $info_list[$k]['g'] = $g;
  2142. }
  2143. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2144. $pagenum = ceil($total / $perpage);
  2145. $over = $total - ($start + $perpage);
  2146. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2147. echo json_encode($rows);
  2148. exit;
  2149. }
  2150. $this->_Template('whlabel_enter', $this->data);
  2151. }
  2152. //出库浏览
  2153. public function _out()
  2154. {
  2155. $post = $this->input->post(NULL, TRUE);
  2156. if (isset($post['page'])) {
  2157. $page = $this->input->post('page', true);
  2158. $perpage = $this->input->post('perpage', true);
  2159. $category = $this->input->post('category', true);
  2160. $size = $this->input->post('size', true);
  2161. $grade = $this->input->post('grade', true);
  2162. $color = $this->input->post('color', true);
  2163. $lowe = $this->input->post('lowe', true);
  2164. $sku = $this->input->post('sku', true);
  2165. $warehouse = $this->input->post('warehouse', true);
  2166. $purchase = $this->input->post('purchase', true);
  2167. $state = $this->input->post('state', true);
  2168. $ktime = $this->input->post('ktime', true);
  2169. $jtime = $this->input->post('jtime', true);
  2170. $ktime = strtotime($ktime);
  2171. $jtime = strtotime($jtime);
  2172. $where = "state=3";
  2173. $gj = "";
  2174. $ck = "";
  2175. if ($category) {
  2176. $where .= " and features like '%-$category-%'";
  2177. }
  2178. if ($size) {
  2179. $where .= " and features like '%-$size-%'";
  2180. }
  2181. if ($grade) {
  2182. $where .= " and features like '%-$grade-%'";
  2183. }
  2184. if ($color) {
  2185. $where .= " and features like '%-$color-%'";
  2186. }
  2187. if ($lowe) {
  2188. $where .= " and features like '%-$lowe-%'";
  2189. }
  2190. if ($state) {
  2191. $where .= " and state = '$state'";
  2192. }
  2193. if ($warehouse) {
  2194. $where .= " and warehouse = '$warehouse'";
  2195. }
  2196. if ($purchase) {
  2197. $where .= " and purchase = '$purchase'";
  2198. }
  2199. if ($sku) {
  2200. $where .= " and sku = '$sku'";
  2201. }
  2202. if ($ktime && $jtime) {
  2203. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2204. }
  2205. //数据排序
  2206. $order_str = "id desc";
  2207. if (empty($page)) {
  2208. $start = 0;
  2209. $perpage = 1;
  2210. } else {
  2211. $start = ($page - 1) * $perpage;
  2212. }
  2213. //取得信息列表
  2214. $info_list = $this->whlabel->find_all($where, 'sku');
  2215. $rows = array();
  2216. $list = array();
  2217. foreach ($info_list as $key => $value) {
  2218. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2219. }
  2220. $rows = array_unique($rows); //删除重复记录
  2221. foreach ($rows as $key => $value) {
  2222. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2223. $ck = $this->warehouse->read($data['warehouse']);
  2224. $warehouse = $ck['title'];
  2225. $gy = $this->purchase->read($data['purchase']);
  2226. $purchase = $gy['purchase'];
  2227. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2228. $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);
  2229. }
  2230. $total = count($list);
  2231. $pagenum = ceil($total / $perpage);
  2232. $over = $total - ($start + $perpage);
  2233. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2234. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2235. echo json_encode($rows);
  2236. exit;
  2237. }
  2238. $this->_Template('whlabel_out', $this->data);
  2239. }
  2240. //出库标签浏览
  2241. public function _label()
  2242. {
  2243. $post = $this->input->post(NULL, TRUE);
  2244. if (isset($post['page'])) {
  2245. $page = $this->input->post('page', true);
  2246. $perpage = $this->input->post('perpage', true);
  2247. $sku = $this->input->post('sku', true);
  2248. $warehouse = $this->input->post('warehouse', true);
  2249. $purchase = $this->input->post('purchase', true);
  2250. $orderinfo = $this->input->post('orderinfo', true);
  2251. $waybill = $this->input->post('waybill', true);
  2252. $category = $this->input->post('category', true);
  2253. $size = $this->input->post('size', true);
  2254. $grade = $this->input->post('grade', true);
  2255. $color = $this->input->post('color', true);
  2256. $lowe = $this->input->post('lowe', true);
  2257. $where = "state=1";
  2258. if ($sku) {
  2259. $where .= " and sku = '$sku'";
  2260. }
  2261. if ($warehouse) {
  2262. $where .= " and warehouse = '$warehouse'";
  2263. }
  2264. if ($purchase) {
  2265. $where .= " and purchase = '$purchase'";
  2266. }
  2267. if ($orderinfo) {
  2268. $where .= " and orderinfo = '$orderinfo'";
  2269. }
  2270. if ($waybill) {
  2271. $where .= " and waybill = '$waybill'";
  2272. }
  2273. if ($category) {
  2274. $where .= " and features like '%-$category-%'";
  2275. }
  2276. if ($size) {
  2277. $where .= " and features like '%-$size-%'";
  2278. }
  2279. if ($grade) {
  2280. $where .= " and features like '%-$grade-%'";
  2281. }
  2282. if ($color) {
  2283. $where .= " and features like '%-$color-%'";
  2284. }
  2285. if ($lowe) {
  2286. $where .= " and features like '%-$lowe-%'";
  2287. }
  2288. //数据排序
  2289. $order_str = "outk desc";
  2290. if (empty($page)) {
  2291. $start = 0;
  2292. $perpage = 1;
  2293. } else {
  2294. $start = ($page - 1) * $perpage;
  2295. }
  2296. //取得信息列表
  2297. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2298. foreach ($info_list as $key => $value) {
  2299. $warehouse = $this->warehouse->read($value['warehouse']);
  2300. $info_list[$key]['warehouse'] = $warehouse['title'];
  2301. $purchase = $this->purchase->read($value['purchase']);
  2302. $info_list[$key]['purchase'] = $purchase['title'];
  2303. if ($value['outk'] != 0) {
  2304. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2305. } else {
  2306. $info_list[$key]['outk'] = "";
  2307. }
  2308. if ($value['orderinfo'] == 0) {
  2309. $info_list[$key]['orderinfo'] = "";
  2310. }
  2311. if ($value['waybill'] == 0) {
  2312. $info_list[$key]['waybill'] = "";
  2313. }
  2314. }
  2315. $total = $this->whlabel->find_count($where);
  2316. $pagenum = ceil($total / $perpage);
  2317. $over = $total - ($start + $perpage);
  2318. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2319. echo json_encode($rows);
  2320. exit;
  2321. }
  2322. $this->_Template('whlabel_label', $this->data);
  2323. }
  2324. //独立站出库订单
  2325. public function _outorder()
  2326. {
  2327. if (isset($_SESSION['api'])) {
  2328. $user = $this->user->get_api($_SESSION['api']);
  2329. $usp = $user;
  2330. $fgshop = "";
  2331. $sid = "";
  2332. $user = explode('|', trim($user['shop'], '|'));
  2333. foreach ($user as $value) {
  2334. $fgshop .= " shop = " . $value . " or";
  2335. $sid .= " id = " . $value . " or";
  2336. }
  2337. } else {
  2338. echo "请重新登录";
  2339. }
  2340. $post = $this->input->post(NULL, TRUE);
  2341. if (isset($post['page'])) {
  2342. $page = $this->input->post('page', true);
  2343. $perpage = $this->input->post('perpage', true);
  2344. $warehouse = $this->input->post('warehouse', true);
  2345. $xztime = $this->input->post('xztime', true);
  2346. $timetk = $this->input->post('timetkk', true);
  2347. $timetj = $this->input->post('timetjj', true);
  2348. $shop = $this->input->post('shop', true);
  2349. $source = $this->input->post('source', true);
  2350. $orderinfo = $this->input->post('orderinfo', true);
  2351. $number = $this->input->post('number', true);
  2352. $sfxh = $this->input->post('sfxh', true);
  2353. $express = $this->input->post('express', true);
  2354. $waybill = $this->input->post('waybill', true);
  2355. $library = $this->input->post('library', true);
  2356. $country = $this->input->post('country', true);
  2357. $so = $this->input->post('so', true);
  2358. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2359. $print = $this->input->post('print', true);
  2360. $state = $this->input->post('state', true);
  2361. $orderurl = $this->input->post('orderurl', true);
  2362. $timetk = strtotime($timetk);
  2363. $timetj = strtotime($timetj);
  2364. /**
  2365. $sj = $this->input->post('sj',true);
  2366. if($sj)
  2367. {
  2368. $sj = $this->input->post('sj',true);
  2369. }
  2370. else
  2371. {
  2372. $sj = "fullorder";
  2373. }
  2374. **/
  2375. $sj = "fullorder";
  2376. $where = "1=1";
  2377. if ($warehouse) {
  2378. $where .= " and type = '$warehouse'";
  2379. }
  2380. if ($timetk && $timetj) {
  2381. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2382. }
  2383. if ($orderinfo) {
  2384. $where .= " and orderinfo = '$orderinfo'";
  2385. }
  2386. if ($number) {
  2387. $where .= " and number = '$number'";
  2388. }
  2389. if ($express) {
  2390. $where .= " and express = '$express'";
  2391. }
  2392. if ($waybill) {
  2393. $where .= " and waybill = '$waybill'";
  2394. }
  2395. if ($library) {
  2396. $where .= " and library = '$library'";
  2397. }
  2398. if ($print) {
  2399. $where .= " and print = '$print'";
  2400. }
  2401. if ($libraryconfirm) {
  2402. $where .= " and libraryconfirm = '$libraryconfirm'";
  2403. }
  2404. if ($state) {
  2405. $where .= " and state = '$state'";
  2406. }
  2407. if ($shop) {
  2408. $where .= " and shop = '$shop'";
  2409. }
  2410. if ($country) {
  2411. $where .= " and country = '$country'";
  2412. }
  2413. if ($sfxh != '') {
  2414. $where .= " and sfxh = '$sfxh'";
  2415. }
  2416. if ($so) {
  2417. $where .= " and shipremarks like '%$so%'";
  2418. }
  2419. if ($source) {
  2420. if ($source == '2d') {
  2421. $where .= " and source >= '2'";
  2422. } else {
  2423. $where .= " and source = '$source'";
  2424. }
  2425. }
  2426. if (isset($_SESSION['api'])) {
  2427. foreach ($user as $value) {
  2428. $fgshop .= " shop = " . $value . " or";
  2429. }
  2430. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2431. }
  2432. if ($orderurl) {
  2433. $url = $this->orderurl->read($orderurl);
  2434. $where .= " and link like '%" . $url['url'] . "%'";
  2435. }
  2436. //数据排序
  2437. $order_str = "librarytime desc";
  2438. if (empty($page)) {
  2439. $start = 0;
  2440. $perpage = 1;
  2441. } else {
  2442. $start = ($page - 1) * $perpage;
  2443. }
  2444. //取得信息列表
  2445. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2446. //格式化数据
  2447. foreach ($info_list as $key => $value) {
  2448. $shop = $this->shop->read($value['shop']);
  2449. $info_list[$key]['shop'] = $shop['shopname'];
  2450. $express = $this->express->read($value['express']);
  2451. $info_list[$key]['express'] = $express['servicename'];
  2452. $warehouse = $this->warehouse->read($value['type']);
  2453. $info_list[$key]['type'] = $warehouse['title'];
  2454. if ($value['librarytime'] == '0') {
  2455. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2456. } else {
  2457. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2458. }
  2459. }
  2460. $total = $this->$sj->find_count($where);
  2461. $pagenum = ceil($total / $perpage);
  2462. $over = $total - ($start + $perpage);
  2463. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2464. echo json_encode($rows);
  2465. exit;
  2466. }
  2467. $this->data['express'] = $this->express->find_all();
  2468. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2469. $this->data['wlshop'] = $wlshop;
  2470. $user = $this->user->get_api($_SESSION['api']);
  2471. $powerid = $this->power->read($user['power']);
  2472. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2473. $pid = '';
  2474. foreach ($powertext as $v) {
  2475. $pid .= " id = " . $v . " or";
  2476. }
  2477. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2478. $this->data['fullorderexcel'] = $fullorderexcel;
  2479. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2480. $this->data['orderurl'] = $orderurl;
  2481. $this->_Template('whlabel_outorder', $this->data);
  2482. }
  2483. //tt出库
  2484. public function _toutorder()
  2485. {
  2486. if (isset($_SESSION['api'])) {
  2487. $user = $this->user->get_api($_SESSION['api']);
  2488. $usp = $user;
  2489. $fgshop = "";
  2490. $sid = "";
  2491. $user = explode('|', trim($user['shop'], '|'));
  2492. foreach ($user as $value) {
  2493. $fgshop .= " shop = " . $value . " or";
  2494. $sid .= " id = " . $value . " or";
  2495. }
  2496. } else {
  2497. echo "请重新登录";
  2498. }
  2499. $post = $this->input->post(NULL, TRUE);
  2500. if (isset($post['page'])) {
  2501. $page = $this->input->post('page', true);
  2502. $perpage = $this->input->post('perpage', true);
  2503. $warehouse = $this->input->post('warehouse', true);
  2504. $xztime = $this->input->post('xztime', true);
  2505. $timetk = $this->input->post('timetkk', true);
  2506. $timetj = $this->input->post('timetjj', true);
  2507. $shop = $this->input->post('shop', true);
  2508. $source = $this->input->post('source', true);
  2509. $orderinfo = $this->input->post('orderinfo', true);
  2510. $number = $this->input->post('number', true);
  2511. $sfxh = $this->input->post('sfxh', true);
  2512. $express = $this->input->post('express', true);
  2513. $waybill = $this->input->post('waybill', true);
  2514. $library = $this->input->post('library', true);
  2515. $country = $this->input->post('country', true);
  2516. $so = $this->input->post('so', true);
  2517. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2518. $print = $this->input->post('print', true);
  2519. $state = $this->input->post('state', true);
  2520. $orderurl = $this->input->post('orderurl', true);
  2521. $timetk = strtotime($timetk);
  2522. $timetj = strtotime($timetj);
  2523. /**
  2524. $sj = $this->input->post('sj',true);
  2525. if($sj)
  2526. {
  2527. $sj = $this->input->post('sj',true);
  2528. }
  2529. else
  2530. {
  2531. $sj = "fullorder";
  2532. }
  2533. **/
  2534. $sj = "fullordertt";
  2535. $where = "1=1";
  2536. if ($warehouse) {
  2537. $where .= " and type = '$warehouse'";
  2538. }
  2539. if ($timetk && $timetj) {
  2540. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2541. }
  2542. if ($orderinfo) {
  2543. $where .= " and orderinfo = '$orderinfo'";
  2544. }
  2545. if ($number) {
  2546. $where .= " and number = '$number'";
  2547. }
  2548. if ($express) {
  2549. $where .= " and express = '$express'";
  2550. }
  2551. if ($waybill) {
  2552. $where .= " and waybill = '$waybill'";
  2553. }
  2554. if ($library) {
  2555. $where .= " and library = '$library'";
  2556. }
  2557. if ($print) {
  2558. $where .= " and print = '$print'";
  2559. }
  2560. if ($libraryconfirm) {
  2561. $where .= " and libraryconfirm = '$libraryconfirm'";
  2562. }
  2563. if ($state) {
  2564. $where .= " and state = '$state'";
  2565. }
  2566. if ($shop) {
  2567. $where .= " and shop = '$shop'";
  2568. }
  2569. if ($country) {
  2570. $where .= " and country = '$country'";
  2571. }
  2572. if ($sfxh != '') {
  2573. $where .= " and sfxh = '$sfxh'";
  2574. }
  2575. if ($so) {
  2576. $where .= " and shipremarks like '%$so%'";
  2577. }
  2578. if ($source) {
  2579. if ($source == '2d') {
  2580. $where .= " and source >= '2'";
  2581. } else {
  2582. $where .= " and source = '$source'";
  2583. }
  2584. }
  2585. if (isset($_SESSION['api'])) {
  2586. foreach ($user as $value) {
  2587. $fgshop .= " shop = " . $value . " or";
  2588. }
  2589. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2590. }
  2591. if ($orderurl) {
  2592. $url = $this->orderurl->read($orderurl);
  2593. $where .= " and link like '%" . $url['url'] . "%'";
  2594. }
  2595. //数据排序
  2596. $order_str = "librarytime desc";
  2597. if (empty($page)) {
  2598. $start = 0;
  2599. $perpage = 1;
  2600. } else {
  2601. $start = ($page - 1) * $perpage;
  2602. }
  2603. //取得信息列表
  2604. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2605. //格式化数据
  2606. foreach ($info_list as $key => $value) {
  2607. $shop = $this->shop->read($value['shop']);
  2608. $info_list[$key]['shop'] = $shop['shopname'];
  2609. $express = $this->express->read($value['express']);
  2610. $info_list[$key]['express'] = $express['servicename'];
  2611. $warehouse = $this->warehouse->read($value['type']);
  2612. $info_list[$key]['type'] = $warehouse['title'];
  2613. if ($value['librarytime'] == '0') {
  2614. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2615. } else {
  2616. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2617. }
  2618. }
  2619. $total = $this->$sj->find_count($where);
  2620. $pagenum = ceil($total / $perpage);
  2621. $over = $total - ($start + $perpage);
  2622. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2623. echo json_encode($rows);
  2624. exit;
  2625. }
  2626. $this->data['express'] = $this->express->find_all();
  2627. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2628. $this->data['wlshop'] = $wlshop;
  2629. $user = $this->user->get_api($_SESSION['api']);
  2630. $powerid = $this->power->read($user['power']);
  2631. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2632. $pid = '';
  2633. foreach ($powertext as $v) {
  2634. $pid .= " id = " . $v . " or";
  2635. }
  2636. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2637. $this->data['fullorderexcel'] = $fullorderexcel;
  2638. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2639. $this->data['orderurl'] = $orderurl;
  2640. $this->_Template('whlabel_toutorder', $this->data);
  2641. }
  2642. //tt出库
  2643. public function _aoutorder()
  2644. {
  2645. if (isset($_SESSION['api'])) {
  2646. $user = $this->user->get_api($_SESSION['api']);
  2647. $usp = $user;
  2648. $fgshop = "";
  2649. $sid = "";
  2650. $user = explode('|', trim($user['shop'], '|'));
  2651. foreach ($user as $value) {
  2652. $fgshop .= " shop = " . $value . " or";
  2653. $sid .= " id = " . $value . " or";
  2654. }
  2655. } else {
  2656. echo "请重新登录";
  2657. }
  2658. $post = $this->input->post(NULL, TRUE);
  2659. if (isset($post['page'])) {
  2660. $page = $this->input->post('page', true);
  2661. $perpage = $this->input->post('perpage', true);
  2662. $warehouse = $this->input->post('warehouse', true);
  2663. $xztime = $this->input->post('xztime', true);
  2664. $timetk = $this->input->post('timetkk', true);
  2665. $timetj = $this->input->post('timetjj', true);
  2666. $shop = $this->input->post('shop', true);
  2667. $source = $this->input->post('source', true);
  2668. $orderinfo = $this->input->post('orderinfo', true);
  2669. $number = $this->input->post('number', true);
  2670. $sfxh = $this->input->post('sfxh', true);
  2671. $express = $this->input->post('express', true);
  2672. $waybill = $this->input->post('waybill', true);
  2673. $library = $this->input->post('library', true);
  2674. $country = $this->input->post('country', true);
  2675. $so = $this->input->post('so', true);
  2676. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2677. $print = $this->input->post('print', true);
  2678. $state = $this->input->post('state', true);
  2679. $orderurl = $this->input->post('orderurl', true);
  2680. $timetk = strtotime($timetk);
  2681. $timetj = strtotime($timetj);
  2682. /**
  2683. $sj = $this->input->post('sj',true);
  2684. if($sj)
  2685. {
  2686. $sj = $this->input->post('sj',true);
  2687. }
  2688. else
  2689. {
  2690. $sj = "fullorder";
  2691. }
  2692. **/
  2693. $sj = "fullorderamz";
  2694. $where = "1=1";
  2695. if ($warehouse) {
  2696. $where .= " and type = '$warehouse'";
  2697. }
  2698. if ($timetk && $timetj) {
  2699. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2700. }
  2701. if ($orderinfo) {
  2702. $where .= " and orderinfo = '$orderinfo'";
  2703. }
  2704. if ($number) {
  2705. $where .= " and number = '$number'";
  2706. }
  2707. if ($express) {
  2708. $where .= " and express = '$express'";
  2709. }
  2710. if ($waybill) {
  2711. $where .= " and waybill = '$waybill'";
  2712. }
  2713. if ($library) {
  2714. $where .= " and library = '$library'";
  2715. }
  2716. if ($print) {
  2717. $where .= " and print = '$print'";
  2718. }
  2719. if ($libraryconfirm) {
  2720. $where .= " and libraryconfirm = '$libraryconfirm'";
  2721. }
  2722. if ($state) {
  2723. $where .= " and state = '$state'";
  2724. }
  2725. if ($shop) {
  2726. $where .= " and shop = '$shop'";
  2727. }
  2728. if ($country) {
  2729. $where .= " and country = '$country'";
  2730. }
  2731. if ($sfxh != '') {
  2732. $where .= " and sfxh = '$sfxh'";
  2733. }
  2734. if ($so) {
  2735. $where .= " and shipremarks like '%$so%'";
  2736. }
  2737. if ($source) {
  2738. if ($source == '2d') {
  2739. $where .= " and source >= '2'";
  2740. } else {
  2741. $where .= " and source = '$source'";
  2742. }
  2743. }
  2744. if (isset($_SESSION['api'])) {
  2745. foreach ($user as $value) {
  2746. $fgshop .= " shop = " . $value . " or";
  2747. }
  2748. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2749. }
  2750. if ($orderurl) {
  2751. $url = $this->orderurl->read($orderurl);
  2752. $where .= " and link like '%" . $url['url'] . "%'";
  2753. }
  2754. //数据排序
  2755. $order_str = "librarytime desc";
  2756. if (empty($page)) {
  2757. $start = 0;
  2758. $perpage = 1;
  2759. } else {
  2760. $start = ($page - 1) * $perpage;
  2761. }
  2762. //取得信息列表
  2763. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2764. //格式化数据
  2765. foreach ($info_list as $key => $value) {
  2766. $shop = $this->shop->read($value['shop']);
  2767. $info_list[$key]['shop'] = $shop['shopname'];
  2768. $express = $this->express->read($value['express']);
  2769. $info_list[$key]['express'] = $express['servicename'];
  2770. $warehouse = $this->warehouse->read($value['type']);
  2771. $info_list[$key]['type'] = $warehouse['title'];
  2772. if ($value['librarytime'] == '0') {
  2773. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2774. } else {
  2775. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2776. }
  2777. }
  2778. $total = $this->$sj->find_count($where);
  2779. $pagenum = ceil($total / $perpage);
  2780. $over = $total - ($start + $perpage);
  2781. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2782. echo json_encode($rows);
  2783. exit;
  2784. }
  2785. $this->data['express'] = $this->express->find_all();
  2786. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2787. $this->data['wlshop'] = $wlshop;
  2788. $user = $this->user->get_api($_SESSION['api']);
  2789. $powerid = $this->power->read($user['power']);
  2790. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2791. $pid = '';
  2792. foreach ($powertext as $v) {
  2793. $pid .= " id = " . $v . " or";
  2794. }
  2795. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2796. $this->data['fullorderexcel'] = $fullorderexcel;
  2797. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2798. $this->data['orderurl'] = $orderurl;
  2799. $this->_Template('whlabel_aoutorder', $this->data);
  2800. }
  2801. //速卖通出库订单
  2802. public function _soutorder()
  2803. {
  2804. if (isset($_SESSION['api'])) {
  2805. $user = $this->user->get_api($_SESSION['api']);
  2806. $usp = $user;
  2807. $fgshop = "";
  2808. $sid = "";
  2809. $user = explode('|', trim($user['shop'], '|'));
  2810. foreach ($user as $value) {
  2811. $sid .= " id = " . $value . " or";
  2812. }
  2813. }
  2814. $post = $this->input->post(NULL, TRUE);
  2815. if (isset($post['page'])) {
  2816. $page = $this->input->post('page', true);
  2817. $perpage = $this->input->post('perpage', true);
  2818. $warehouse = $this->input->post('warehouse', true);
  2819. $xztime = $this->input->post('xztime', true);
  2820. $timetk = $this->input->post('timetkk', true);
  2821. $timetj = $this->input->post('timetjj', true);
  2822. $shop = $this->input->post('shop', true);
  2823. $source = $this->input->post('source', true);
  2824. $orderinfo = $this->input->post('orderinfo', true);
  2825. $number = $this->input->post('number', true);
  2826. $express = $this->input->post('express', true);
  2827. $waybill = $this->input->post('waybill', true);
  2828. $library = $this->input->post('library', true);
  2829. $country = $this->input->post('country', true);
  2830. $sfxh = $this->input->post('sfxh', true);
  2831. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2832. $print = $this->input->post('print', true);
  2833. $state = $this->input->post('state', true);
  2834. $so = $this->input->post('so', true);
  2835. $timetk = strtotime($timetk);
  2836. $timetj = strtotime($timetj);
  2837. /**
  2838. $sj = $this->input->post('sj',true);
  2839. if($sj)
  2840. {
  2841. $sj = $this->input->post('sj',true);
  2842. }
  2843. else
  2844. {
  2845. $sj = "fullorder";
  2846. }
  2847. **/
  2848. $sj = "fullordersmt";
  2849. $where = "1=1";
  2850. if ($warehouse) {
  2851. $where .= " and type = '$warehouse'";
  2852. }
  2853. if ($timetk && $timetj) {
  2854. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2855. }
  2856. if ($orderinfo) {
  2857. $where .= " and orderinfo = '$orderinfo'";
  2858. }
  2859. if ($number) {
  2860. $where .= " and number = '$number'";
  2861. }
  2862. if ($express) {
  2863. $where .= " and express = '$express'";
  2864. }
  2865. if ($waybill) {
  2866. $where .= " and waybill = '$waybill'";
  2867. }
  2868. if ($library) {
  2869. $where .= " and library = '$library'";
  2870. }
  2871. if ($print) {
  2872. $where .= " and print = '$print'";
  2873. }
  2874. if ($libraryconfirm) {
  2875. $where .= " and libraryconfirm = '$libraryconfirm'";
  2876. }
  2877. if ($state) {
  2878. $where .= " and state = '$state'";
  2879. }
  2880. if ($shop) {
  2881. $where .= " and shop = '$shop'";
  2882. }
  2883. if ($sfxh != '') {
  2884. $where .= " and sfxh = '$sfxh'";
  2885. }
  2886. if ($so) {
  2887. $where .= " and shipremarks like '%$so%'";
  2888. }
  2889. if ($source) {
  2890. $where .= " and source = '$source'";
  2891. }
  2892. if ($country) {
  2893. $where .= " and country = '$country'";
  2894. } else {
  2895. if (isset($_SESSION['api'])) {
  2896. foreach ($user as $value) {
  2897. $fgshop .= " shop = " . $value . " or";
  2898. }
  2899. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2900. }
  2901. }
  2902. //数据排序
  2903. $order_str = "librarytime desc";
  2904. if (empty($page)) {
  2905. $start = 0;
  2906. $perpage = 1;
  2907. } else {
  2908. $start = ($page - 1) * $perpage;
  2909. }
  2910. //取得信息列表
  2911. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2912. //格式化数据
  2913. foreach ($info_list as $key => $value) {
  2914. $shop = $this->shop->read($value['shop']);
  2915. $info_list[$key]['shop'] = $shop['shopname'];
  2916. $express = $this->express->read($value['express']);
  2917. $info_list[$key]['express'] = $express['servicename'];
  2918. $warehouse = $this->warehouse->read($value['type']);
  2919. $info_list[$key]['type'] = $warehouse['title'];
  2920. if ($value['librarytime'] == '0') {
  2921. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2922. } else {
  2923. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2924. }
  2925. }
  2926. $total = $this->$sj->find_count($where);
  2927. $pagenum = ceil($total / $perpage);
  2928. $over = $total - ($start + $perpage);
  2929. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2930. echo json_encode($rows);
  2931. exit;
  2932. }
  2933. $this->data['express'] = $this->express->find_all();
  2934. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2935. $this->data['wlshop'] = $wlshop;
  2936. $user = $this->user->get_api($_SESSION['api']);
  2937. $powerid = $this->power->read($user['power']);
  2938. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2939. $pid = '';
  2940. foreach ($powertext as $v) {
  2941. $pid .= " id = " . $v . " or";
  2942. }
  2943. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2944. $this->data['fullorderexcel'] = $fullorderexcel;
  2945. $this->_Template('whlabel_soutorder', $this->data);
  2946. }
  2947. //订单退库
  2948. public function _retreat()
  2949. {
  2950. $post = $this->input->post(NULL, TRUE);
  2951. if (isset($post['page'])) {
  2952. $page = $this->input->post('page', true);
  2953. $perpage = $this->input->post('perpage', true);
  2954. $warehouse = $this->input->post('warehouse', true);
  2955. $timetk = $this->input->post('timetk', true);
  2956. $timetj = $this->input->post('timetj', true);
  2957. $shop = $this->input->post('shop', true);
  2958. $source = $this->input->post('source', true);
  2959. $state = $this->input->post('state', true);
  2960. $review = $this->input->post('review', true);
  2961. $state = $this->input->post('state', true);
  2962. $express = $this->input->post('express', true);
  2963. $orderinfo = $this->input->post('orderinfo', true);
  2964. $user = $this->input->post('user', true);
  2965. $name = $this->input->post('name', true);
  2966. $waybill = $this->input->post('waybill', true);
  2967. $timetk = strtotime($timetk);
  2968. $timetj = strtotime($timetj);
  2969. $where = "(state=206 or state=210) and mergeid = 0";
  2970. if ($warehouse) {
  2971. $where .= " and state = '$warehouse'";
  2972. }
  2973. if ($timetk && $timetj) {
  2974. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  2975. }
  2976. if ($shop) {
  2977. $where .= " and shop = '$shop'";
  2978. }
  2979. if ($source) {
  2980. $where .= " and source = '$source'";
  2981. }
  2982. if ($state) {
  2983. $where .= " and state = '$state'";
  2984. }
  2985. if ($review) {
  2986. $where .= " and review = '$review'";
  2987. }
  2988. if ($state) {
  2989. $where .= " and state = '$state'";
  2990. }
  2991. if ($express) {
  2992. $where .= " and express = '$express'";
  2993. }
  2994. if ($orderinfo) {
  2995. $where .= " and orderinfo = '$orderinfo'";
  2996. }
  2997. if ($user) {
  2998. $where .= " and user = '$user'";
  2999. }
  3000. if ($name) {
  3001. $where .= " and name = '$name'";
  3002. }
  3003. if ($waybill) {
  3004. $where .= " and waybill = '$waybill'";
  3005. }
  3006. //数据排序
  3007. $order_str = "id desc";
  3008. if (empty($page)) {
  3009. $start = 0;
  3010. $perpage = 1;
  3011. } else {
  3012. $start = ($page - 1) * $perpage;
  3013. }
  3014. //取得信息列表
  3015. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3016. //格式化数据
  3017. foreach ($info_list as $key => $value) {
  3018. $shop = $this->shop->read($value['shop']);
  3019. $info_list[$key]['shop'] = $shop['shopname'];
  3020. $warehouse = $this->warehouse->read($value['warehouse']);
  3021. $info_list[$key]['warehouse'] = $warehouse['title'];
  3022. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3023. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3024. if ($value['waybill'] == 0) {
  3025. $info_list[$key]['waybill'] = "";
  3026. }
  3027. $express = $this->express->read($value['express']);
  3028. $info_list[$key]['express'] = $express['title'];
  3029. $typeclass = $this->typeclass->read($value['state']);
  3030. $info_list[$key]['state'] = $typeclass['title'];
  3031. }
  3032. $total = $this->fullorder->find_count($where);
  3033. $pagenum = ceil($total / $perpage);
  3034. $over = $total - ($start + $perpage);
  3035. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3036. echo json_encode($rows);
  3037. exit;
  3038. }
  3039. $this->data['express'] = $this->express->find_all();
  3040. $this->_Template('whlabel_retreat', $this->data);
  3041. }
  3042. //退库标签浏览
  3043. public function _retreatlk()
  3044. {
  3045. $post = $this->input->post(NULL, TRUE);
  3046. if (isset($post['page'])) {
  3047. $page = $this->input->post('page', true);
  3048. $perpage = $this->input->post('perpage', true);
  3049. $timetk = $this->input->post('timetk', true);
  3050. $timetj = $this->input->post('timetj', true);
  3051. $sku = $this->input->post('sku', true);
  3052. $warehouse = $this->input->post('warehouse', true);
  3053. $purchase = $this->input->post('purchase', true);
  3054. $orderinfo = $this->input->post('orderinfo', true);
  3055. $waybill = $this->input->post('waybill', true);
  3056. $category = $this->input->post('category', true);
  3057. $size = $this->input->post('size', true);
  3058. $grade = $this->input->post('grade', true);
  3059. $color = $this->input->post('color', true);
  3060. $lowe = $this->input->post('lowe', true);
  3061. $state = $this->input->post('state', true);
  3062. $timetk = strtotime($timetk);
  3063. $timetj = strtotime($timetj);
  3064. $where = "state=2";
  3065. if ($timetk && $timetj) {
  3066. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3067. }
  3068. if ($sku) {
  3069. $where .= " and sku = '$sku'";
  3070. }
  3071. if ($warehouse) {
  3072. $where .= " and warehouse = '$warehouse'";
  3073. }
  3074. if ($purchase) {
  3075. $where .= " and purchase = '$purchase'";
  3076. }
  3077. if ($orderinfo) {
  3078. $where .= " and orderinfo = '$orderinfo'";
  3079. }
  3080. if ($waybill) {
  3081. $where .= " and waybill = '$waybill'";
  3082. }
  3083. if ($category) {
  3084. $where .= " and features like '%-$category-%'";
  3085. }
  3086. if ($size) {
  3087. $where .= " and features like '%-$size-%'";
  3088. }
  3089. if ($grade) {
  3090. $where .= " and features like '%-$grade-%'";
  3091. }
  3092. if ($color) {
  3093. $where .= " and features like '%-$color-%'";
  3094. }
  3095. if ($lowe) {
  3096. $where .= " and features like '%-$lowe-%'";
  3097. }
  3098. //数据排序
  3099. $order_str = "time desc";
  3100. if (empty($page)) {
  3101. $start = 0;
  3102. $perpage = 1;
  3103. } else {
  3104. $start = ($page - 1) * $perpage;
  3105. }
  3106. //取得信息列表
  3107. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3108. foreach ($info_list as $key => $value) {
  3109. $warehouse = $this->warehouse->read($value['warehouse']);
  3110. $info_list[$key]['warehouse'] = $warehouse['title'];
  3111. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3112. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3113. $purchase = $this->purchase->read($value['purchase']);
  3114. $info_list[$key]['purchase'] = $purchase['title'];
  3115. if ($value['outk'] != 0) {
  3116. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3117. } else {
  3118. $info_list[$key]['outk'] = "";
  3119. }
  3120. if ($value['retreat'] != 0) {
  3121. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3122. } else {
  3123. $info_list[$key]['retreat'] = "";
  3124. }
  3125. if ($value['orderinfo'] == 0) {
  3126. $info_list[$key]['orderinfo'] = "";
  3127. }
  3128. if ($value['waybill'] == 0) {
  3129. $info_list[$key]['waybill'] = "";
  3130. }
  3131. }
  3132. $total = $this->whlabel->find_count($where);
  3133. $pagenum = ceil($total / $perpage);
  3134. $over = $total - ($start + $perpage);
  3135. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3136. echo json_encode($rows);
  3137. exit;
  3138. }
  3139. $this->_Template('whlabel_retreatlk', $this->data);
  3140. }
  3141. //更换标签及浏览
  3142. public function _change()
  3143. {
  3144. $post = $this->input->post(NULL, TRUE);
  3145. if (isset($post['page'])) {
  3146. $page = $this->input->post('page', true);
  3147. $perpage = $this->input->post('perpage', true);
  3148. $timetk = $this->input->post('timetk', true);
  3149. $timetj = $this->input->post('timetj', true);
  3150. $label = $this->input->post('label', true);
  3151. $oldlabel = $this->input->post('oldlabel', true);
  3152. $timetk = strtotime($timetk);
  3153. $timetj = strtotime($timetj);
  3154. $where = "state=10 ";
  3155. if ($timetk && $timetj) {
  3156. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3157. }
  3158. if ($label) {
  3159. $where .= " and label = '$label'";
  3160. }
  3161. if ($oldlabel) {
  3162. $where .= " and oldlabel = '$oldlabel'";
  3163. }
  3164. //数据排序
  3165. $order_str = "time asc";
  3166. if (empty($page)) {
  3167. $start = 0;
  3168. $perpage = 1;
  3169. } else {
  3170. $start = ($page - 1) * $perpage;
  3171. }
  3172. //取得信息列表
  3173. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3174. foreach ($info_list as $key => $value) {
  3175. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3176. }
  3177. $total = $this->whlabel->find_count($where);
  3178. $pagenum = ceil($total / $perpage);
  3179. $over = $total - ($start + $perpage);
  3180. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3181. echo json_encode($rows);
  3182. exit;
  3183. }
  3184. $this->_Template('whlabel_change', $this->data);
  3185. }
  3186. //产品标签
  3187. public function _cpbqdc()
  3188. {
  3189. if (isset($_GET['excel'])) {
  3190. $where = "1=1";
  3191. //数据排序
  3192. $order_str = "id desc";
  3193. if (empty($page)) {
  3194. $start = 0;
  3195. $perpage = 1;
  3196. } else {
  3197. $start = ($page - 1) * $perpage;
  3198. }
  3199. $warehouse = $this->input->get('warehouse', true);
  3200. $state = $this->input->get('state', true);
  3201. $timetk = $this->input->get('timetkk', true);
  3202. $timetj = $this->input->get('timetjj', true);
  3203. $timetk = strtotime($timetk);
  3204. $timetj = strtotime($timetj);
  3205. if ($warehouse) {
  3206. $where .= " and warehouse = '$warehouse'";
  3207. }
  3208. if ($state || $state == 0) {
  3209. $where .= " and state = '$state'";
  3210. }
  3211. if ($timetk && $timetj) {
  3212. $where .= " and time > '$timetk' and time < '$timetj'";
  3213. }
  3214. //取得信息列表
  3215. $info_list = $this->whlabel->find_all($where, '*');
  3216. $rows = array();
  3217. $list = array();
  3218. foreach ($info_list as $key => $value) {
  3219. $rows[$value['time']] = $value; //所有数据sku
  3220. }
  3221. foreach ($rows as $value) {
  3222. $warehouse = $this->warehouse->read($value['warehouse']);
  3223. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3224. $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);
  3225. }
  3226. $title = "产品标签统计表";
  3227. $titlename = "<table border=1>
  3228. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3229. <tr align='center'>
  3230. <td>仓库</td>
  3231. <td>SKU</td>
  3232. <td>产品</td>
  3233. <td>入库时间</td>
  3234. <td>操作时间</td>
  3235. <td>备注</td>
  3236. <td>数量</td>
  3237. </tr>
  3238. </table>";
  3239. $filename = $title . ".xls";
  3240. $tail = "";
  3241. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3242. }
  3243. }
  3244. //进销存导出
  3245. public function _exceljxc()
  3246. {
  3247. $classid = $this->classid->sku();
  3248. $pm = $classid;
  3249. $typeclass = array();
  3250. $tc = $this->typeclass->find_all();
  3251. foreach ($tc as $v) {
  3252. $typeclass[$v['id']] = $v;
  3253. }
  3254. $prc = array();
  3255. $purchase = $this->purchase->find_all();
  3256. foreach ($purchase as $k => $v) {
  3257. $prc[$v['id']] = $v['title'];
  3258. }
  3259. if (isset($_GET['excel'])) {
  3260. $where = "sku != 'Preset'";
  3261. //数据排序
  3262. $order_str = "id desc";
  3263. if (empty($page)) {
  3264. $start = 0;
  3265. $perpage = 1;
  3266. } else {
  3267. $start = ($page - 1) * $perpage;
  3268. }
  3269. $category = $this->input->get('category', true);
  3270. $warehouse = $this->input->get('warehouse', true);
  3271. $excelid = $this->input->get('sid', true);
  3272. if ($category) {
  3273. $where .= " and features like '%-$category-%'";
  3274. }
  3275. if ($warehouse) {
  3276. $where .= " and warehouse = '$warehouse'";
  3277. }
  3278. $xzid = '';
  3279. if ($excelid) {
  3280. $excelid = explode(',', trim($excelid, ','));
  3281. foreach ($excelid as $key => $value) {
  3282. $xzid .= " id = " . $value . " or";
  3283. }
  3284. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3285. }
  3286. //取得信息列表
  3287. /**
  3288. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3289. $rows = array();$list = array();
  3290. foreach ($info_list as $key=>$value)
  3291. {
  3292. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3293. }
  3294. **/
  3295. $wt = array();
  3296. $whlabel_type = $this->whlabel_type->find_all();
  3297. foreach ($whlabel_type as $v) {
  3298. $wt[$v['id']] = $v['title'];
  3299. }
  3300. $wh = array();
  3301. $w = $this->warehouse->find_all('1=1', 'id,title');
  3302. foreach ($w as $v) {
  3303. $wh[$v['id']] = $v['title'];
  3304. }
  3305. $list = array();
  3306. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3307. foreach ($rows as $key => $value) {
  3308. if (isset($wt[$value['type']])) {
  3309. $rows[$key]['type'] = $wt[$value['type']];
  3310. } else {
  3311. $rows[$key]['type'] = '未设置';
  3312. }
  3313. $bm = '03';
  3314. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3315. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3316. $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');
  3317. $details = array();
  3318. $cpid = array();
  3319. $cpbz = array();
  3320. $c = 0;
  3321. $g = 0;
  3322. $x = 0;
  3323. $t = 0;
  3324. $s = 0;
  3325. $q = 0;
  3326. foreach ($sd as $k => $v) {
  3327. if ($v['state'] == 0) {
  3328. $c++;
  3329. if ($v['cpid'] != 0) {
  3330. $cpid[$v['cpid']] = $v['cpid'];
  3331. }
  3332. if ($v['cpbz'] != '') {
  3333. $cpbz[$v['cpbz']] = $v['cpbz'];
  3334. }
  3335. }
  3336. if ($v['state'] != 9) {
  3337. $g++;
  3338. }
  3339. if ($v['state'] == 1) {
  3340. $x++;
  3341. }
  3342. if ($v['state'] == 2) {
  3343. $t++;
  3344. }
  3345. if ($v['state'] == 8) {
  3346. $s++;
  3347. }
  3348. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3349. $q++;
  3350. }
  3351. $details[$v['details']] = $v['details'];
  3352. }
  3353. $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'] . '"');
  3354. $rows[$key]['details'] = implode("、", $details);
  3355. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3356. $number = $value['number'];
  3357. $ftime = time() - 15 * 24 * 3600;
  3358. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3359. $rows[$key]['number'] = $g;
  3360. $rows[$key]['c'] = $c;
  3361. $rows[$key]['x'] = $x;
  3362. $rows[$key]['t'] = $t;
  3363. $rows[$key]['s'] = $s;
  3364. $rows[$key]['q'] = $q;
  3365. $rows[$key]['z'] = $z;
  3366. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3367. $features = explode('-', trim($features, '-'));
  3368. $rows[$key]['dbcontent'] = $typeclass[$features[0]]['title'];
  3369. // $pm = $classid;
  3370. // $jm = $classid;
  3371. // foreach($features as $k=>$v)
  3372. // {
  3373. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3374. // {
  3375. // if($typeclass[$v]['bm'] != '')
  3376. // {
  3377. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3378. // }
  3379. // }
  3380. // if($v != 0)
  3381. // {
  3382. // if(!isset($typeclass[$v]))
  3383. // {
  3384. // continue;
  3385. // }
  3386. // if(isset($pm[$typeclass[$v]['classid']]))
  3387. // {
  3388. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3389. // {
  3390. // $tz = explode('|',$typeclass[$v]['zh']);
  3391. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3392. // }
  3393. // else
  3394. // {
  3395. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3396. // }
  3397. // }
  3398. // if(isset($jm[$typeclass[$v]['classid']]))
  3399. // {
  3400. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3401. // }
  3402. // }
  3403. // }
  3404. // $jm = array_filter($jm);
  3405. // $rows[$key]['bs'] = implode("-",$jm);
  3406. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3407. // $zh = implode(" ",$pm);
  3408. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3409. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3410. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3411. // $rows[$key]['features'] = $zh;
  3412. }
  3413. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3414. $final_list = [];
  3415. foreach ($list as $k => $v) {
  3416. if (empty($v['sku'])) {
  3417. continue;
  3418. }
  3419. $final_list[] = [
  3420. "warehouse" => $v["warehouse"],
  3421. "purchase" => $v["purchase"],
  3422. "details" => $v["details"],
  3423. "cpid" => $v["cpid"],
  3424. "dbcontent" => $v["dbcontent"],
  3425. "sku" => $v["sku"],
  3426. "cs" => $v["bm"],
  3427. "bs" => $v["jm"],
  3428. "title" => $v["title"],
  3429. "features" => $v["pm"],
  3430. "cpbz" => $v["cpbz"],
  3431. "sm" => $v["sm"],
  3432. "type" => $v["type"],
  3433. "number" => $v["number"],
  3434. "c" => $v["c"],
  3435. "x" => $v["x"],
  3436. "t" => $v["t"],
  3437. "s" => $v["s"],
  3438. "q" => $v["q"],
  3439. "z" => $v["z"],
  3440. "weight" => $v['weight'],
  3441. ];
  3442. }
  3443. $title = "总进销存统计表";
  3444. $titlename = "<table border=1>
  3445. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3446. <tr align='center'>
  3447. <td>仓库</td>
  3448. <td>供应商</td>
  3449. <td>位置</td>
  3450. <td>库存编码</td>
  3451. <td>类目</td>
  3452. <td>SKU</td>
  3453. <td>用友编码</td>
  3454. <td>用友料号</td>
  3455. <td>商品名称</td>
  3456. <td>商品中文</td>
  3457. <td>产品备注</td>
  3458. <td>说明</td>
  3459. <td>类型</td>
  3460. <td>入库总量</td>
  3461. <td>库存数量</td>
  3462. <td>销售数量</td>
  3463. <td>退货数量</td>
  3464. <td>删除数量</td>
  3465. <td>其它操作</td>
  3466. <td>占单数量</td>
  3467. <td>重量(g)</td>
  3468. </tr>
  3469. </table>";
  3470. $filename = $title . ".xls";
  3471. $tail = "";
  3472. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3473. }
  3474. }
  3475. //入库导出
  3476. public function _excelr()
  3477. {
  3478. if (isset($_GET['excel'])) {
  3479. $category = $this->input->get('category', true);
  3480. $size = $this->input->get('size', true);
  3481. $grade = $this->input->get('grade', true);
  3482. $color = $this->input->get('color', true);
  3483. $lowe = $this->input->get('lowe', true);
  3484. $sku = $this->input->get('sku', true);
  3485. $warehouse = $this->input->get('warehouse', true);
  3486. $purchase = $this->input->get('purchase', true);
  3487. $ktime = $this->input->get('ktime', true);
  3488. $jtime = $this->input->get('jtime', true);
  3489. $ktime = strtotime($ktime);
  3490. $jtime = strtotime($jtime);
  3491. $where = "1=1";
  3492. $gj = "";
  3493. $ck = "";
  3494. if ($category) {
  3495. $where .= " and features like '%-$category-%'";
  3496. }
  3497. if ($size) {
  3498. $where .= " and features like '%-$size-%'";
  3499. }
  3500. if ($grade) {
  3501. $where .= " and features like '%-$grade-%'";
  3502. }
  3503. if ($color) {
  3504. $where .= " and features like '%-$color-%'";
  3505. }
  3506. if ($lowe) {
  3507. $where .= " and features like '%-$lowe-%'";
  3508. }
  3509. if ($warehouse) {
  3510. $where .= " and warehouse = '$warehouse'";
  3511. }
  3512. if ($purchase) {
  3513. $where .= " and purchase = '$purchase'";
  3514. }
  3515. if ($sku) {
  3516. $where .= " and sku = '$sku'";
  3517. }
  3518. if ($ktime && $jtime) {
  3519. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3520. }
  3521. //数据排序
  3522. $order_str = "id desc";
  3523. if (empty($page)) {
  3524. $start = 0;
  3525. $perpage = 1;
  3526. } else {
  3527. $start = ($page - 1) * $perpage;
  3528. }
  3529. $list = array();
  3530. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3531. foreach ($rows as $value) {
  3532. $ck = $this->warehouse->read($value['warehouse']);
  3533. $warehouse = $ck['title'];
  3534. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3535. $retreatwarehouse = $tkck['title'];
  3536. $gy = $this->purchase->read($value['purchase']);
  3537. $purchase = $gy['title'];
  3538. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3539. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3540. }
  3541. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3542. $titlename = "<table border=1>
  3543. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3544. <tr align='center'>
  3545. <td>仓库</td>
  3546. <td>SKU</td>
  3547. <td>产品</td>
  3548. <td>时间</td>
  3549. <td>数量</td>
  3550. </tr>
  3551. </table>";
  3552. $filename = $title . ".xls";
  3553. $tail = "";
  3554. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3555. }
  3556. }
  3557. //出库、退库导出
  3558. public function _excelct()
  3559. {
  3560. $classid = $this->classid->sku();
  3561. $pm = $classid;
  3562. $typeclass = array();
  3563. $tc = $this->typeclass->find_all();
  3564. foreach ($tc as $v) {
  3565. $typeclass[$v['id']] = $v;
  3566. }
  3567. $prc = array();
  3568. $purchase = $this->purchase->find_all();
  3569. foreach ($purchase as $k => $v) {
  3570. $prc[$v['id']] = $v['title'];
  3571. }
  3572. if (isset($_GET['excel'])) {
  3573. $wh = array();
  3574. $w = $this->warehouse->find_all('1=1', 'id,title');
  3575. foreach ($w as $v) {
  3576. $wh[$v['id']] = $v['title'];
  3577. }
  3578. $type = $this->input->get('excel', true);
  3579. $category = $this->input->get('category', true);
  3580. $size = $this->input->get('size', true);
  3581. $grade = $this->input->get('grade', true);
  3582. $color = $this->input->get('color', true);
  3583. $lowe = $this->input->get('lowe', true);
  3584. $sku = $this->input->get('sku', true);
  3585. $warehouse = $this->input->get('warehouse', true);
  3586. $lacetype = $this->input->get('lacetype', true);
  3587. $lacecolor = $this->input->get('lacecolor', true);
  3588. $density = $this->input->get('density', true);
  3589. $haircap = $this->input->get('haircap', true);
  3590. $purchase = $this->input->get('purchase', true);
  3591. $title = $this->input->get('title', true);
  3592. $state = $this->input->get('state', true);
  3593. $sid = $this->input->get('sid', true);
  3594. $ktime = $this->input->get('ktime', true);
  3595. $jtime = $this->input->get('jtime', true);
  3596. $ktime = strtotime($ktime);
  3597. $jtime = strtotime($jtime);
  3598. $where = "1=1";
  3599. $gj = "";
  3600. $ck = "";
  3601. if ($category) {
  3602. $where .= " and features like '%-$category-%'";
  3603. }
  3604. if ($size) {
  3605. $where .= " and features like '%-$size-%'";
  3606. }
  3607. if ($grade) {
  3608. $where .= " and features like '%-$grade-%'";
  3609. }
  3610. if ($color) {
  3611. $where .= " and features like '%-$color-%'";
  3612. }
  3613. if ($lowe) {
  3614. $where .= " and features like '%-$lowe-%'";
  3615. }
  3616. if ($warehouse) {
  3617. $where .= " and warehouse = '$warehouse'";
  3618. }
  3619. if ($purchase) {
  3620. $where .= " and purchase = '$purchase'";
  3621. }
  3622. if ($state) {
  3623. $where .= " and state = '$state'";
  3624. }
  3625. if ($lacetype) {
  3626. $where .= " and features like '%-$lacetype-%'";
  3627. }
  3628. if ($lacecolor) {
  3629. $where .= " and features like '%-$lacecolor-%'";
  3630. }
  3631. if ($density) {
  3632. $where .= " and features like '%-$density-%'";
  3633. }
  3634. if ($haircap) {
  3635. $where .= " and features like '%-$haircap-%'";
  3636. }
  3637. if ($title) {
  3638. $title = trim($title, ' ');
  3639. $title = trim($title, ' ');
  3640. $where .= " and title like '%$title%'";
  3641. }
  3642. if ($sku) {
  3643. $sku = trim($sku, ' ');
  3644. $sku = trim($sku, ' ');
  3645. $where .= " and sku like '%$sku%'";
  3646. }
  3647. if ($ktime && $jtime) {
  3648. if ($type == 1) {
  3649. $tl = '出库';
  3650. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3651. } else if ($type == 2) {
  3652. $tl = '退库';
  3653. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3654. } else if ($type == 3) {
  3655. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3656. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3657. } else if ($type == 4) {
  3658. $tl = '出库+零售';
  3659. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3660. } else if ($type == 5) {
  3661. $tl = '零售';
  3662. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3663. }
  3664. }
  3665. $sidwhere = '';
  3666. if ($sid) {
  3667. $sd = "";
  3668. $s = explode(',', trim($sid, ','));
  3669. foreach ($s as $value) {
  3670. $sd .= " id = " . $value . " or";
  3671. }
  3672. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3673. }
  3674. //数据排序
  3675. $order_str = "time desc";
  3676. if (empty($page)) {
  3677. $start = 0;
  3678. $perpage = 1;
  3679. } else {
  3680. $start = ($page - 1) * $perpage;
  3681. }
  3682. //取得信息列表
  3683. if ($type != 3 && $type != 5) {
  3684. if ($type == 1 || $type == 4) {
  3685. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3686. foreach ($info_list as $key => $value) {
  3687. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3688. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3689. $warehouse = $this->warehouse->read($value['warehouse']);
  3690. $info_list[$key]['warehouse'] = $warehouse['title'];
  3691. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3692. $features = explode('-', trim($features, '-'));
  3693. $pm = $classid;
  3694. foreach ($features as $k => $v) {
  3695. if ($v != 0) {
  3696. if (!isset($typeclass[$v])) {
  3697. continue;
  3698. }
  3699. if (isset($pm[$typeclass[$v]['classid']])) {
  3700. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3701. $tz = explode('|', $typeclass[$v]['zh']);
  3702. $pm[$typeclass[$v]['classid']] = $tz[0];
  3703. } else {
  3704. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3705. }
  3706. }
  3707. }
  3708. }
  3709. $zh = implode(" ", $pm);
  3710. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3711. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3712. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3713. $info_list[$key]['features'] = $zh;
  3714. }
  3715. $final_list = [];
  3716. foreach($info_list as $k=>$v){
  3717. $number = "";
  3718. if(!empty($v['orderinfo'])){
  3719. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3720. if(!empty($tmp_info['number'])){
  3721. $number = $tmp_info['number'];
  3722. }
  3723. }
  3724. $final_list[] = [
  3725. 'warehouse'=>$v['warehouse'],
  3726. 'purchase'=>$v['purchase'],
  3727. 'sku'=>$v['sku'],
  3728. 'title'=>$v['title'],
  3729. 'features'=>$v['features'],
  3730. 'label'=>$v['label'],
  3731. 'orderinfo'=>$v['orderinfo'],
  3732. 'number'=>$number,
  3733. 'waybill'=>$v['waybill'],
  3734. 'outk'=>$v['outk'],
  3735. ];
  3736. }
  3737. } else {
  3738. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3739. foreach ($info_list as $key => $value) {
  3740. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3741. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3742. $warehouse = $this->warehouse->read($value['warehouse']);
  3743. $info_list[$key]['warehouse'] = $warehouse['title'];
  3744. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3745. $features = explode('-', trim($features, '-'));
  3746. $pm = $classid;
  3747. foreach ($features as $k => $v) {
  3748. if ($v != 0) {
  3749. if (!isset($typeclass[$v])) {
  3750. continue;
  3751. }
  3752. if (isset($pm[$typeclass[$v]['classid']])) {
  3753. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3754. $tz = explode('|', $typeclass[$v]['zh']);
  3755. $pm[$typeclass[$v]['classid']] = $tz[0];
  3756. } else {
  3757. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3758. }
  3759. }
  3760. }
  3761. }
  3762. $zh = implode(" ", $pm);
  3763. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3764. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3765. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3766. $info_list[$key]['features'] = $zh;
  3767. }
  3768. $final_list = [];
  3769. foreach($info_list as $k=>$v){
  3770. $number = "";
  3771. if(!empty($v['orderinfo'])){
  3772. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3773. if(!empty($tmp_info['number'])){
  3774. $number = $tmp_info['number'];
  3775. }
  3776. }
  3777. $final_list[] = [
  3778. 'warehouse'=>$v['warehouse'],
  3779. 'purchase'=>$v['purchase'],
  3780. 'sku'=>$v['sku'],
  3781. 'title'=>$v['title'],
  3782. 'features'=>$v['features'],
  3783. 'label'=>$v['label'],
  3784. 'orderinfo'=>$v['orderinfo'],
  3785. 'number'=>$number,
  3786. 'waybill'=>$v['waybill'],
  3787. 'retreat'=>$v['retreat'],
  3788. ];
  3789. }
  3790. }
  3791. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3792. $titlename = "<table border=1>
  3793. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3794. <tr align='center'>
  3795. <td>仓库</td>
  3796. <td>供应商</td>
  3797. <td>SKU</td>
  3798. <td>商品名称</td>
  3799. <td>商品中文</td>
  3800. <td>标签</td>
  3801. <td>订单号</td>
  3802. <td>订单编码</td>
  3803. <td>运单号</td>
  3804. <td>" . $tl . "时间(中国时间)</td>
  3805. </tr>
  3806. </table>";
  3807. $filename = $title . ".xls";
  3808. $tail = "";
  3809. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3810. } else if ($type == 5) {
  3811. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3812. foreach ($info_list as $key => $value) {
  3813. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3814. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3815. $warehouse = $this->warehouse->read($value['warehouse']);
  3816. $info_list[$key]['warehouse'] = $warehouse['title'];
  3817. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3818. $features = explode('-', trim($features, '-'));
  3819. $pm = $classid;
  3820. foreach ($features as $k => $v) {
  3821. if ($v != 0) {
  3822. if (!isset($typeclass[$v])) {
  3823. continue;
  3824. }
  3825. if (isset($pm[$typeclass[$v]['classid']])) {
  3826. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3827. $tz = explode('|', $typeclass[$v]['zh']);
  3828. $pm[$typeclass[$v]['classid']] = $tz[0];
  3829. } else {
  3830. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3831. }
  3832. }
  3833. }
  3834. }
  3835. $zh = implode(" ", $pm);
  3836. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3837. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3838. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3839. $info_list[$key]['features'] = $zh;
  3840. }
  3841. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3842. $titlename = "<table border=1>
  3843. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3844. <tr align='center'>
  3845. <td>仓库</td>
  3846. <td>供应商</td>
  3847. <td>SKU</td>
  3848. <td>商品名称</td>
  3849. <td>商品中文</td>
  3850. <td>标签</td>
  3851. <td>" . $tl . "时间(中国时间)</td>
  3852. </tr>
  3853. </table>";
  3854. $filename = $title . ".xls";
  3855. $tail = "";
  3856. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3857. } else {
  3858. /**
  3859. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  3860. $rows = array();$list = array();
  3861. foreach ($info_list as $key=>$value)
  3862. {
  3863. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  3864. }
  3865. **/
  3866. $wh = array();
  3867. $w = $this->warehouse->find_all('1=1', 'id,title');
  3868. foreach ($w as $v) {
  3869. $wh[$v['id']] = $v['title'];
  3870. }
  3871. $wt = array();
  3872. $whlabel_type = $this->whlabel_type->find_all();
  3873. foreach ($whlabel_type as $v) {
  3874. $wt[$v['id']] = $v['title'];
  3875. }
  3876. $classid = $this->classid->sku();
  3877. $list = array();
  3878. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  3879. foreach ($rows as $key => $value) {
  3880. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3881. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3882. $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');
  3883. $details = array();
  3884. $cpid = array();
  3885. $cpbz = array();
  3886. $c = 0;
  3887. $g = 0;
  3888. $x = 0;
  3889. $t = 0;
  3890. $s = 0;
  3891. $q = 0;
  3892. foreach ($sd as $k => $v) {
  3893. if ($v['state'] == 0) {
  3894. $c++;
  3895. }
  3896. if ($v['state'] != 9) {
  3897. $g++;
  3898. }
  3899. if ($v['outk'] > 1) {
  3900. $x++;
  3901. }
  3902. if ($v['retreat'] > 0) {
  3903. $t++;
  3904. }
  3905. if ($v['state'] == 8) {
  3906. $s++;
  3907. }
  3908. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3909. $q++;
  3910. }
  3911. $details[$v['details']] = $v['details'];
  3912. if ($v['cpid'] != 0) {
  3913. $cpid[$v['cpid']] = $v['cpid'];
  3914. }
  3915. if ($v['cpbz'] != '') {
  3916. $cpbz[$v['cpbz']] = $v['cpbz'];
  3917. }
  3918. }
  3919. if (isset($wt[$value['type']])) {
  3920. $rows[$key]['type'] = $wt[$value['type']];
  3921. } else {
  3922. $rows[$key]['type'] = '未设置';
  3923. }
  3924. $rows[$key]['details'] = implode("、", $details);
  3925. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3926. $ftime = time() - 15 * 24 * 3600;
  3927. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3928. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  3929. $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);
  3930. $rows[$key]['c'] = $c;
  3931. $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);
  3932. $rows[$key]['t'] = $t;
  3933. $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'] . '"');
  3934. $rows[$key]['z'] = $z;
  3935. // $jm = $classid;
  3936. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3937. $features = explode('-', trim($features, '-'));
  3938. // $pm = $classid;
  3939. // foreach ($features as $k => $v) {
  3940. // if ($v != 0) {
  3941. // if (!isset($typeclass[$v])) {
  3942. // continue;
  3943. // }
  3944. // if (isset($pm[$typeclass[$v]['classid']])) {
  3945. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3946. // $tz = explode('|', $typeclass[$v]['zh']);
  3947. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3948. // } else {
  3949. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3950. // }
  3951. // if (isset($jm[$typeclass[$v]['classid']])) {
  3952. // if ($typeclass[$v]['jm']) {
  3953. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3954. // }
  3955. // }
  3956. // }
  3957. // }
  3958. // }
  3959. // $zh = implode(" ", $pm);
  3960. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3961. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3962. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3963. // $rows[$key]['features'] = $zh;
  3964. // $jm = array_filter($jm); //去除空值
  3965. // $jm = implode("-", $jm);
  3966. // $rows[$key]['jm'] = $jm;
  3967. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  3968. }
  3969. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  3970. // echo "<pre>";
  3971. // print_r($tmp_list);
  3972. // die;
  3973. $final_list =[];
  3974. foreach($tmp_list as $k=>$v){
  3975. $final_list[] = [
  3976. "warehouse"=>$v['warehouse'],
  3977. "purchase"=>$v['purchase'],
  3978. "details"=>$v['details'],
  3979. "cpid"=>$v['cpid'],
  3980. "sku"=>$v['sku'],
  3981. "title"=>$v['title'],
  3982. "features"=>$v['pm'],
  3983. "cpbz"=>$v['cpbz'],
  3984. "sm"=>$v['sm'],
  3985. "type"=>$v['type'],
  3986. "g"=>$v["g"],
  3987. "c"=>$v["c"],
  3988. "x"=>$v["x"],
  3989. "t"=>$v["t"],
  3990. "z"=>$v["z"],
  3991. "jm"=>$v["jm"],
  3992. "weight"=>$v["weight"],
  3993. "asd"=>$v["asd"],
  3994. ];
  3995. }
  3996. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  3997. $titlename = "<table border=1>
  3998. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  3999. <tr align='center'>
  4000. <td>仓库</td>
  4001. <td>供应商</td>
  4002. <td>位置</td>
  4003. <td>库存编码</td>
  4004. <td>SKU</td>
  4005. <td>商品名称</td>
  4006. <td>商品中文</td>
  4007. <td>产品备注</td>
  4008. <td>说明</td>
  4009. <td>类型</td>
  4010. <td>入库总量</td>
  4011. <td>库存数量</td>
  4012. <td>销售数量</td>
  4013. <td>退货数量</td>
  4014. <td>占单数量</td>
  4015. <td>料号</td>
  4016. <td>重量</td>
  4017. <td>类目</td>
  4018. </tr>
  4019. </table>";
  4020. $filename = $title . ".xls";
  4021. $tail = "";
  4022. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4023. }
  4024. }
  4025. }
  4026. //出库+入库数据整合
  4027. public function _excelcr()
  4028. {
  4029. if (isset($_GET['excel'])) {
  4030. $type = $this->input->get('excel', true);
  4031. $category = $this->input->get('category', true);
  4032. $size = $this->input->get('size', true);
  4033. $grade = $this->input->get('grade', true);
  4034. $color = $this->input->get('color', true);
  4035. $lowe = $this->input->get('lowe', true);
  4036. $sku = $this->input->get('sku', true);
  4037. $warehouse = $this->input->get('warehouse', true);
  4038. $purchase = $this->input->get('purchase', true);
  4039. $state = $this->input->get('state', true);
  4040. $sid = $this->input->get('sid', true);
  4041. $ktime = $this->input->get('ktime', true);
  4042. $jtime = $this->input->get('jtime', true);
  4043. $ktime = strtotime($ktime);
  4044. $jtime = strtotime($jtime);
  4045. $where = "1=1";
  4046. $gj = "";
  4047. $ck = "";
  4048. if ($category) {
  4049. $where .= " and features like '%-$category-%'";
  4050. }
  4051. if ($size) {
  4052. $where .= " and features like '%-$size-%'";
  4053. }
  4054. if ($grade) {
  4055. $where .= " and features like '%-$grade-%'";
  4056. }
  4057. if ($color) {
  4058. $where .= " and features like '%-$color-%'";
  4059. }
  4060. if ($lowe) {
  4061. $where .= " and features like '%-$lowe-%'";
  4062. }
  4063. if ($warehouse) {
  4064. $where .= " and warehouse = '$warehouse'";
  4065. }
  4066. if ($purchase) {
  4067. $where .= " and purchase = '$purchase'";
  4068. }
  4069. if ($state) {
  4070. $where .= " and state = '$state'";
  4071. }
  4072. if ($sku) {
  4073. $where .= " and sku like '%$sku%'";
  4074. }
  4075. if ($ktime && $jtime) {
  4076. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4077. }
  4078. $sidwhere = '';
  4079. if ($sid) {
  4080. $sd = "";
  4081. $s = explode(',', trim($sid, ','));
  4082. foreach ($s as $value) {
  4083. $sd .= " id = " . $value . " or";
  4084. }
  4085. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4086. }
  4087. //取得信息列表
  4088. $timeread = $ktime;
  4089. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4090. $timelist = array();
  4091. for ($i = 0; $i < $timenum; $i++) {
  4092. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4093. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4094. }
  4095. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4096. //echo "<pre>";
  4097. //print_r($info_list);
  4098. //exit();
  4099. $rows = array();
  4100. $list = array();
  4101. foreach ($info_list as $key => $value) {
  4102. $thistime = $timelist;
  4103. if (isset($rows[strtolower($value['sku'])])) {
  4104. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4105. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4106. }
  4107. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4108. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4109. }
  4110. } else {
  4111. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4112. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4113. }
  4114. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4115. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4116. }
  4117. $rows[strtolower($value['sku'])] = $thistime;
  4118. }
  4119. }
  4120. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4121. <head>
  4122. <!--[if gte mso 9]><xml>
  4123. <x:ExcelWorkbook>
  4124. <x:ExcelWorksheets>
  4125. <x:ExcelWorksheet>
  4126. <x:Name>EXCEL</x:Name>
  4127. <x:WorksheetOptions>
  4128. <x:Print>
  4129. <x:ValidPrinterInfo />
  4130. </x:Print>
  4131. </x:WorksheetOptions>
  4132. </x:ExcelWorksheet>
  4133. </x:ExcelWorksheets>
  4134. </x:ExcelWorkbook>
  4135. </xml>
  4136. <![endif]-->
  4137. </head><body>";
  4138. $str .= "<table border=1><tr><td>SKU</td>";
  4139. foreach ($timelist as $k => $v) {
  4140. $str .= "<td>" . $k . "出库</td>";
  4141. $str .= "<td>" . $k . "入库</td>";
  4142. }
  4143. $str .= "</tr></table>";
  4144. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4145. foreach ($rows as $key => $val) {
  4146. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4147. foreach ($val as $k => $v) {
  4148. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4149. if ($val[$k]['r'] > 0) {
  4150. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4151. } else {
  4152. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4153. }
  4154. }
  4155. $str .= "</tr>";
  4156. }
  4157. $str .= "</table>";
  4158. $str .= "</body></html>";
  4159. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4160. header("Content-type: application/octet-stream");
  4161. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4162. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4163. header("Pragma: no-cache");
  4164. header("Expires: 0");
  4165. exit($str);
  4166. }
  4167. }
  4168. //数量调整模板导出
  4169. public function _presetout()
  4170. {
  4171. if (isset($_GET['excel'])) {
  4172. $where = "sku != 'Preset' and purchase != 0";
  4173. //数据排序
  4174. $order_str = "id desc";
  4175. if (empty($page)) {
  4176. $start = 0;
  4177. $perpage = 1;
  4178. } else {
  4179. $start = ($page - 1) * $perpage;
  4180. }
  4181. //取得信息列表
  4182. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4183. $rows = array();
  4184. $list = array();
  4185. foreach ($info_list as $value) {
  4186. $warehouse = $this->warehouse->read($value['warehouse']);
  4187. $number = $value['number'];
  4188. $ftime = time() - 15 * 24 * 3600;
  4189. $purchase = $this->purchase->read($value['purchase']);
  4190. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4191. }
  4192. $title = "库存模板";
  4193. $titlename = "<table border=1>
  4194. <tr align='center'>
  4195. <td>仓库</td>
  4196. <td>供应商编码</td>
  4197. <td>SKU</td>
  4198. <td>增减数量(正数或负数)</td>
  4199. <td>增减备注</td>
  4200. <td>扣减方式:0减少库存1删除库存</td>
  4201. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4202. <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4203. </tr>
  4204. </table>";
  4205. $filename = $title . ".xls";
  4206. $tail = "";
  4207. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4208. }
  4209. }
  4210. //数量调整模板导入
  4211. public function _presetedit()
  4212. {
  4213. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4214. $config['upload_path'] = '.' . $dir;
  4215. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4216. $config['allowed_types'] = 'xls|xlsx|csv';
  4217. $config['max_size'] = 10240;
  4218. $this->load->library('upload', $config);
  4219. $this->upload->initialize($config);
  4220. if ($this->upload->do_upload('userfile')) {
  4221. $full_path = $dir . $this->upload->data('file_name');
  4222. $fileName = '.' . $full_path;
  4223. if (!file_exists($fileName)) {
  4224. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4225. exit;
  4226. } else {
  4227. require_once "./data/excel/PHPExcel/IOFactory.php";
  4228. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4229. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4230. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4231. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4232. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4233. ++$column; //如果列数大于26行
  4234. $list = array();
  4235. for ($i = 2; $i <= $row; $i++) // 行数循环
  4236. {
  4237. $data = array();
  4238. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4239. {
  4240. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4241. }
  4242. $list[] = $data;
  4243. }
  4244. }
  4245. $i = 0;
  4246. $j = 0;
  4247. $ed = array();
  4248. foreach ($list as $key => $value) {
  4249. $time = time();
  4250. if ($value['0'] == "") {
  4251. continue;
  4252. }
  4253. $warehouse = $this->warehouse->get_title($value['0']);
  4254. $purchase = $this->purchase->get_bm($value['1']);
  4255. $sku = $value['2'];
  4256. $num = $value['3']; //调整数量
  4257. $text = $value['4']; //扣减说明
  4258. $type = $value['5']; //调整方式0扣减1删除
  4259. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4260. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4261. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4262. if (!$purchase) //如果没有这个SKU
  4263. {
  4264. $ed[] = array($purchase . '-不存在此供应商编码');
  4265. $j++;
  4266. continue;
  4267. }
  4268. if (!$d) //如果没有这个SKU
  4269. {
  4270. $ed[] = array($sku . '-库存中不存在此SKU');
  4271. $j++;
  4272. continue;
  4273. }
  4274. if (!isset($warehouse['id'])) {
  4275. $ed[] = array($sku . '-仓库名错误!');
  4276. $j++;
  4277. continue;
  4278. }
  4279. if ($type != '0' && $type != '1') {
  4280. $ed[] = array($sku . '-扣减方式填写错误!');
  4281. $j++;
  4282. continue;
  4283. }
  4284. if ($num < 0) //扣减库存
  4285. {
  4286. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4287. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4288. $j++;
  4289. continue;
  4290. }
  4291. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4292. if (count($data) < abs($num)) {
  4293. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4294. $j++;
  4295. continue;
  4296. }
  4297. if ($type == 0) //如果扣减方式为 扣减库存
  4298. {
  4299. for ($i = 0; $i < abs($num); $i++) {
  4300. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4301. }
  4302. } else if ($type == 1) {
  4303. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4304. if (count($zt) > 0) {
  4305. $ed[] = array($sku . '-有在途库存无法删除!');
  4306. $j++;
  4307. continue;
  4308. }
  4309. for ($i = 0; $i < abs($num); $i++) {
  4310. $this->whlabel->remove($data[$i]['id']);
  4311. }
  4312. }
  4313. } else if ($num > 0) //增加库存
  4314. {
  4315. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4316. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4317. $j++;
  4318. continue;
  4319. }
  4320. $post['sku'] = $d['sku'];
  4321. $post['shop'] = $d['shop'];
  4322. $post['warehouse'] = $warehouse['id'];
  4323. $post['purchase'] = $purchase['id'];
  4324. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4325. $post['state'] = 0;
  4326. $post['title'] = $d['title'];
  4327. $post['number'] = $d['number'];
  4328. $post['features'] = $d['features'];
  4329. $post['enter'] = $time;
  4330. $post['time'] = $time; //操作时间
  4331. $post['rktype'] = $rktype;
  4332. for ($i = 0; $i < $num; $i++) {
  4333. $post['label'] = time() . rand(100, 999) . $i;
  4334. $this->whlabel->insert($post);
  4335. }
  4336. }
  4337. sleep(1); //防止入库时间一样,需要延迟1秒
  4338. }
  4339. if ($j > 0) {
  4340. $tt = date('Ymd', time());
  4341. $title = '库存导入错误信息-' . $tt;
  4342. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4343. $tail = "\n";
  4344. $filename = $title . ".xls";
  4345. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4346. $dir = '/data/excel/' . $time . '/';
  4347. $file_name = 'error_' . $time . rand(1000, 9999);
  4348. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4349. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4350. fwrite($myfile, $ecl);
  4351. fclose($myfile);
  4352. $error = $dir . $file_name . '.xls';
  4353. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4354. exit;
  4355. } else {
  4356. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4357. exit;
  4358. }
  4359. }
  4360. }
  4361. //笛卡儿积
  4362. function cp($ps, $sets, $list)
  4363. {
  4364. $result = array();
  4365. $j = 0;
  4366. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4367. if ($i == 0) {
  4368. $result = $sets[$i];
  4369. }
  4370. $tmp = array();
  4371. foreach ($result as $res) {
  4372. foreach ($sets[$i + 1] as $set) {
  4373. $tmp[] = $res . ',' . $set;
  4374. }
  4375. }
  4376. $result = $tmp;
  4377. }
  4378. $this->db->trans_begin();
  4379. foreach ($result as $v) {
  4380. $post = array();
  4381. $title = "";
  4382. $num = "";
  4383. $data = explode(',', $v);
  4384. for ($i = 0; $i < count($list); $i++) {
  4385. $post[$list[$i]] = $data[$i];
  4386. $typeclass = $this->typeclass->read($data[$i]);
  4387. $title = $title . $typeclass['title'] . " ";
  4388. if ($data[$i] != 0) {
  4389. $num .= $data[$i]; //所有数据ID拼接
  4390. }
  4391. }
  4392. foreach ($ps as $kp => $vp) {
  4393. $post[$kp] = $vp;
  4394. }
  4395. $post['number'] = $num;
  4396. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4397. if ($info_list) {
  4398. $j++;
  4399. } else {
  4400. $skunum = $this->whlabel->find_count();
  4401. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4402. $post['title'] = rtrim($title, ' ');
  4403. $this->whlabel->insert($post);
  4404. }
  4405. }
  4406. if ($this->db->trans_status() === FALSE) {
  4407. $this->db->trans_commit();
  4408. return NULL;
  4409. } else {
  4410. $this->db->trans_commit();
  4411. return $j;
  4412. }
  4413. }
  4414. public function _kj($arg_array)
  4415. {
  4416. if (isset($_POST['sku'])) {
  4417. $time = time();
  4418. $sku = $this->input->post('sku', true);
  4419. $warehouse = $this->input->post('warehouse', true);
  4420. $num = $this->input->post('num', true);
  4421. $text = $this->input->post('text', true);
  4422. $purchase = $this->input->post('purchase', true);
  4423. $cktype = $this->input->post('cktype', true);
  4424. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4425. if ($cktype != 1 && $text == '') {
  4426. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4427. exit;
  4428. }
  4429. if ($num > count($order)) {
  4430. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4431. exit;
  4432. } else {
  4433. for ($i = 0; $i < $num; $i++) {
  4434. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4435. }
  4436. }
  4437. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4438. exit;
  4439. }
  4440. $uid = $this->whlabel->read($arg_array[0]);
  4441. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4442. $this->data['data'] = $uid;
  4443. $this->_Template('whlabel_kj', $this->data);
  4444. }
  4445. public function _summary($arg_array)
  4446. {
  4447. $prc = array();
  4448. $purchase = $this->purchase->find_all();
  4449. foreach ($purchase as $k => $v) {
  4450. $prc[$v['id']] = $v['title'];
  4451. }
  4452. if (isset($_GET['excel'])) {
  4453. $ktime = $this->input->get('ktime', true);
  4454. $jtime = $this->input->get('jtime', true);
  4455. $ktime = strtotime($ktime);
  4456. $jtime = strtotime($jtime);
  4457. $where = "1=1";
  4458. if ($ktime && $jtime) {
  4459. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4460. }
  4461. //数据排序
  4462. $order_str = "time desc";
  4463. if (empty($page)) {
  4464. $start = 0;
  4465. $perpage = 1;
  4466. } else {
  4467. $start = ($page - 1) * $perpage;
  4468. }
  4469. //取得信息列表
  4470. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4471. foreach ($info_list as $key => $value) {
  4472. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4473. $warehouse = $this->warehouse->read($value['warehouse']);
  4474. $info_list[$key]['warehouse'] = $warehouse['title'];
  4475. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4476. $details = array();
  4477. $cpid = array();
  4478. foreach ($x as $k => $v) {
  4479. if ($v['details'] != '') {
  4480. $details[$v['details']] = $v['details'];
  4481. }
  4482. if ($v['cpid'] != 0) {
  4483. $cpid[$v['cpid']] = $v['cpid'];
  4484. }
  4485. }
  4486. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4487. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4488. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4489. $info_list[$key]['s'] = $s;
  4490. $info_list[$key]['x'] = count($x);
  4491. }
  4492. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4493. $titlename = "<table border=1>
  4494. <tr align='center'>
  4495. <td>仓库</td>
  4496. <td>供应商</td>
  4497. <td>出库位置</td>
  4498. <td>出库编码</td>
  4499. <td>SKU</td>
  4500. <td>产品名</td>
  4501. <td>总剩余库存</td>
  4502. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4503. </tr>
  4504. </table>";
  4505. $filename = $title . ".xls";
  4506. $tail = "";
  4507. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4508. }
  4509. }
  4510. //usps发货清单
  4511. public function _manifest()
  4512. {
  4513. if (isset($_POST['manifest'])) {
  4514. $wltext = $this->input->post('wltext', true);
  4515. $time = time() - 16 * 3600;
  4516. $ptime = strtotime(date('Y-m-d', $time));
  4517. $waybill = array();
  4518. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4519. foreach ($fullorder as $v) {
  4520. $waybill[$v['waybill']] = $v['waybill'];
  4521. }
  4522. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4523. foreach ($fullordersmt as $v) {
  4524. $waybill[$v['waybill']] = $v['waybill'];
  4525. }
  4526. $wltext = explode(';', $wltext);
  4527. foreach ($wltext as $v) {
  4528. if (isset($waybill[$v])) {
  4529. unset($waybill[$v]);
  4530. }
  4531. }
  4532. $data = $this->usps->get_manifest($waybill);
  4533. if (isset($data['Description'])) {
  4534. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4535. exit;
  4536. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4537. $bctime = date('Ymd', time());
  4538. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4539. echo json_encode(array('msg' => $pdf, 'success' => true));
  4540. exit;
  4541. } else {
  4542. echo json_encode(array('msg' => $data, 'success' => false));
  4543. exit;
  4544. }
  4545. }
  4546. }
  4547. public function _pdf($pdf, $title, $bctime)
  4548. {
  4549. $pdf_path = './data/pdf/' . $bctime . '/';
  4550. $file_base64 = $pdf;
  4551. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4552. $file_base64 = base64_decode($file_base64);
  4553. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4554. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4555. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4556. }
  4557. /**
  4558. *
  4559. *
  4560. *
  4561. 进销存占单异常索引
  4562. *
  4563. *
  4564. *
  4565. **/
  4566. public function _abnormal()
  4567. {
  4568. $post = $this->input->post(NULL, TRUE);
  4569. if (isset($post['page'])) {
  4570. $page = $this->input->post('page', true);
  4571. $perpage = $this->input->post('perpage', true);
  4572. $sku = $this->input->post('sku', true);
  4573. $where = "1=1";
  4574. //数据排序
  4575. $order_str = "id desc";
  4576. if (empty($page)) {
  4577. $start = 0;
  4578. $perpage = 1;
  4579. } else {
  4580. $start = ($page - 1) * $perpage;
  4581. }
  4582. //取得信息列表
  4583. $info_list = $this->whlabel->find_all($where, '*');
  4584. $rows = array();
  4585. $list = array();
  4586. foreach ($info_list as $key => $value) {
  4587. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4588. }
  4589. foreach ($rows as $value) {
  4590. $warehouse = $this->warehouse->read($value['warehouse']);
  4591. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4592. $number = $value['number'];
  4593. $ftime = time() - 15 * 24 * 3600;
  4594. if ($value['shop'] != '') {
  4595. $shop = $value['shop'];
  4596. $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');
  4597. $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');
  4598. $order = array_merge($orderdlz, $ordersmt);
  4599. $od = 0;
  4600. $a = '';
  4601. $orid = '';
  4602. foreach ($order as $v) {
  4603. $or = explode('|', ltrim($v['whlabel'], '|'));
  4604. for ($i = 0; $i < count($or); $i++) {
  4605. $orod = explode('-', $or[$i]);
  4606. if ($orod[0] == $number) {
  4607. $od += $orod[1];
  4608. }
  4609. }
  4610. $orid .= $v['number'] . '-';
  4611. }
  4612. } else {
  4613. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4614. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4615. $order = array_merge($orderdlz, $ordersmt);
  4616. $od = 0;
  4617. $a = '';
  4618. $orid = '';
  4619. $qt = array();
  4620. foreach ($order as $v) {
  4621. $or = explode('|', ltrim($v['whlabel'], '|'));
  4622. for ($i = 0; $i < count($or); $i++) {
  4623. $orod = explode('-', $or[$i]);
  4624. if ($orod[0] == $number) {
  4625. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4626. if ($czzs > 0) {
  4627. if (isset($qt[$v['shop']])) {
  4628. if ($qt[$v['shop']] < $orod[1]) {
  4629. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4630. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4631. } else {
  4632. $qt[$v['shop']] -= $orod[1];
  4633. }
  4634. } else {
  4635. $qt[$v['shop']] = $czzs;
  4636. }
  4637. } else {
  4638. $od += $orod[1];
  4639. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4640. }
  4641. }
  4642. }
  4643. }
  4644. }
  4645. $z = $od . '(' . $orid . ')'; //查看订单号
  4646. //$z = $od;
  4647. if ($od > $c) {
  4648. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4649. }
  4650. }
  4651. $listdata = array_slice($list, $start, $perpage);
  4652. $total = count($list);
  4653. $pagenum = ceil($total / $perpage);
  4654. $over = $total - ($start + $perpage);
  4655. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4656. echo json_encode($rows);
  4657. exit;
  4658. }
  4659. $this->_Template('whlabel_abnormal', $this->data);
  4660. }
  4661. /**
  4662. *
  4663. *
  4664. *
  4665. 进销存占单异常索引
  4666. *
  4667. *
  4668. *
  4669. **/
  4670. public function _error()
  4671. {
  4672. $post = $this->input->post(NULL, TRUE);
  4673. if (isset($post['page'])) {
  4674. $page = $this->input->post('page', true);
  4675. $perpage = $this->input->post('perpage', true);
  4676. $sku = $this->input->post('sku', true);
  4677. $warehouse = $this->input->post('warehouse', true);
  4678. $ktime = $this->input->post('ktime', true);
  4679. $jtime = $this->input->post('jtime', true);
  4680. $ktime = strtotime($ktime);
  4681. $jtime = strtotime($jtime);
  4682. $where = "sku != 'Preset'";
  4683. $gj = '';
  4684. if ($sku) {
  4685. $where .= " and sku like '%$sku%'";
  4686. } else {
  4687. if ($ktime && $jtime) {
  4688. $gj = " and time > '$ktime' and time < '$jtime'";
  4689. }
  4690. }
  4691. if ($warehouse) {
  4692. $where .= " and warehouse = '$warehouse'";
  4693. }
  4694. //数据排序
  4695. $order_str = "id desc";
  4696. if (empty($page)) {
  4697. $start = 0;
  4698. $perpage = 1;
  4699. } else {
  4700. $start = ($page - 1) * $perpage;
  4701. }
  4702. //取得信息列表
  4703. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4704. $rows = array();
  4705. $list = array();
  4706. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4707. // foreach ($info_list as $value)
  4708. // {
  4709. // $warehouse = $this->warehouse->read($value['warehouse']);
  4710. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4711. // $number = $value['number'];$ftime = time()-15*24*3600;
  4712. // if($c < 1)
  4713. // {
  4714. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4715. // }
  4716. // }
  4717. $warehouse_list = $this->warehouse->find_all();
  4718. $warehouse_list = array_column($warehouse_list, null, 'id');
  4719. foreach ($info_list as $value) {
  4720. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4721. 'title' => "",
  4722. ];
  4723. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4724. $number = $value['number'];
  4725. $ftime = time() - 15 * 24 * 3600;
  4726. if ($c < 1) {
  4727. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4728. }
  4729. }
  4730. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4731. // $query = $this->db->query($sql);
  4732. // $info_list = $query->result_array();
  4733. // $sql_two = "select title,id from crowd_warehouse";
  4734. // $query_two = $this->db->query($sql_two);
  4735. // $warehouse_list = $query_two->result_array();
  4736. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4737. // foreach ($info_list as $value)
  4738. // {
  4739. // if(isset($warehouse_arr[$value['warehouse']])){
  4740. // $warehouse = $warehouse_arr[$value['warehouse']];
  4741. // }else{
  4742. // $warehouse = [
  4743. // 'id'=>0,
  4744. // 'title'=>"异常",
  4745. // ];
  4746. // }
  4747. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4748. // $number = $value['number'];$ftime = time()-15*24*3600;
  4749. // if($c < 1)
  4750. // {
  4751. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4752. // }
  4753. // }
  4754. $listdata = array_slice($list, $start, $perpage);
  4755. $total = count($list);
  4756. $pagenum = ceil($total / $perpage);
  4757. $over = $total - ($start + $perpage);
  4758. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4759. echo json_encode($rows);
  4760. exit;
  4761. }
  4762. if (isset($post['s'])) {
  4763. $id_arr = $this->input->post('s');
  4764. $id_arr = explode(',', trim($id_arr, ','));
  4765. if (!$id_arr) {
  4766. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4767. exit;
  4768. }
  4769. //循环删除记录
  4770. foreach ($id_arr as $v) {
  4771. $dd = $this->whlabel->read($v);
  4772. if (!isset($dd['id'])) {
  4773. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4774. exit;
  4775. }
  4776. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4777. if (isset($zt[0])) {
  4778. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4779. exit;
  4780. }
  4781. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4782. foreach ($deldd as $vv) {
  4783. $this->whlabel->remove($vv['id']);
  4784. }
  4785. }
  4786. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4787. exit;
  4788. }
  4789. $this->_Template('whlabel_error', $this->data);
  4790. }
  4791. public function _errorexcel()
  4792. {
  4793. $post = $this->input->post(NULL, TRUE);
  4794. if (isset($_GET['page'])) {
  4795. $page = $this->input->get('page', true);
  4796. $perpage = $this->input->get('perpage', true);
  4797. $sku = $this->input->get('sku', true);
  4798. $warehouse = $this->input->get('warehouse', true);
  4799. $ktime = $this->input->get('ktime', true);
  4800. $jtime = $this->input->get('jtime', true);
  4801. $ktime = strtotime($ktime);
  4802. $jtime = strtotime($jtime);
  4803. $where = "sku != 'Preset'";
  4804. $gj = '';
  4805. if ($sku) {
  4806. $where .= " and sku like '%$sku%'";
  4807. } else {
  4808. if ($ktime && $jtime) {
  4809. $gj = " and time > '$ktime' and time < '$jtime'";
  4810. }
  4811. }
  4812. if ($warehouse) {
  4813. $where .= " and warehouse = '$warehouse'";
  4814. }
  4815. //数据排序
  4816. $order_str = "id desc";
  4817. if (empty($page)) {
  4818. $start = 0;
  4819. $perpage = 1;
  4820. } else {
  4821. $start = ($page - 1) * $perpage;
  4822. }
  4823. //取得信息列表
  4824. $rows = array();
  4825. $list = array();
  4826. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4827. foreach ($info_list as $value) {
  4828. $warehouse = $this->warehouse->read($value['warehouse']);
  4829. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4830. $number = $value['number'];
  4831. $ftime = time() - 15 * 24 * 3600;
  4832. if ($c < 1) {
  4833. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4834. }
  4835. }
  4836. $title = "0库存汇总";
  4837. $titlename = "<table border=1>
  4838. <tr align='center'>
  4839. <td>仓库</td>
  4840. <td>SKU</td>
  4841. <td>产品</td>
  4842. <td>当前库存</td>
  4843. </tr>
  4844. </table>";
  4845. $filename = $title . ".xls";
  4846. $tail = "";
  4847. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4848. }
  4849. }
  4850. /**
  4851. *
  4852. *
  4853. * 占单
  4854. *
  4855. *
  4856. **/
  4857. public function _kcyz()
  4858. {
  4859. $post = $this->input->post(NULL, TRUE);
  4860. if (isset($post['warehouse'])) {
  4861. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  4862. exit; //不再使用
  4863. $warehouse = $this->input->post('warehouse', true);
  4864. $whlabel = $this->input->post('whlabel', true);
  4865. $id = $this->input->post('id', true);
  4866. $shop = $this->input->post('shop', true);
  4867. $number = $this->input->post('number', true);
  4868. if (!$whlabel || $whlabel == '|') {
  4869. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  4870. exit;
  4871. }
  4872. $pp = explode('|', trim($whlabel, '|'));
  4873. $x = 0;
  4874. $save = array();
  4875. foreach ($pp as $va) {
  4876. $num = explode('-', $va);
  4877. if ($number) {
  4878. $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 = '')"); //通用
  4879. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  4880. } else {
  4881. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  4882. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  4883. }
  4884. $x++;
  4885. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  4886. $save[] = $x - 1;
  4887. continue; //提前先加X不然出错,所以要减1
  4888. }
  4889. }
  4890. if (isset($save[0])) {
  4891. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  4892. exit;
  4893. } else {
  4894. echo json_encode(array('success' => true));
  4895. exit;
  4896. }
  4897. }
  4898. }
  4899. public function _db()
  4900. {
  4901. $post = $this->input->post(NULL, TRUE);
  4902. if (isset($post['page'])) {
  4903. $page = $this->input->post('page', true);
  4904. $perpage = $this->input->post('perpage', true);
  4905. $sku = $this->input->post('sku', true);
  4906. $number = $this->input->post('number', true);
  4907. $warehouse = $this->input->post('warehouse', true);
  4908. $purchase = $this->input->post('purchase', true);
  4909. $orderinfo = $this->input->post('orderinfo', true);
  4910. $waybill = $this->input->post('waybill', true);
  4911. $category = $this->input->post('category', true);
  4912. $size = $this->input->post('size', true);
  4913. $grade = $this->input->post('grade', true);
  4914. $color = $this->input->post('color', true);
  4915. $lowe = $this->input->post('lowe', true);
  4916. $state = $this->input->post('state', true);
  4917. $label = $this->input->post('label', true);
  4918. $timetk = $this->input->post('timetkk', true);
  4919. $timetj = $this->input->post('timetjj', true);
  4920. $timetk = strtotime($timetk);
  4921. $timetj = strtotime($timetj);
  4922. $where = "dbtime > 0";
  4923. if ($timetk && $timetj) {
  4924. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  4925. }
  4926. if ($sku) {
  4927. $where .= " and sku = '$sku'";
  4928. }
  4929. if ($warehouse) {
  4930. $where .= " and warehouse = '$warehouse'";
  4931. if ($warehouse == 12) {
  4932. $w = 'specialstock';
  4933. } else {
  4934. $w = 'whlabel';
  4935. }
  4936. }
  4937. if ($purchase) {
  4938. $where .= " and purchase = '$purchase'";
  4939. }
  4940. if ($category) {
  4941. $where .= " and features like '%-$category-%'";
  4942. }
  4943. if ($size) {
  4944. $where .= " and features like '%-$size-%'";
  4945. }
  4946. if ($grade) {
  4947. $where .= " and features like '%-$grade-%'";
  4948. }
  4949. if ($color) {
  4950. $where .= " and features like '%-$color-%'";
  4951. }
  4952. if ($lowe) {
  4953. $where .= " and features like '%-$lowe-%'";
  4954. }
  4955. if ($state != '') {
  4956. $where .= " and state = '$state'";
  4957. }
  4958. //数据排序
  4959. $order_str = "dbtime desc";
  4960. if (empty($page)) {
  4961. $start = 0;
  4962. $perpage = 1;
  4963. } else {
  4964. $start = ($page - 1) * $perpage;
  4965. }
  4966. //取得信息列表
  4967. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  4968. foreach ($info_list as $key => $value) {
  4969. $warehouse = $this->$w->read($value['warehouse']);
  4970. $info_list[$key]['warehouse'] = $warehouse['title'];
  4971. $purchase = $this->purchase->read($value['purchase']);
  4972. $info_list[$key]['purchase'] = $purchase['title'];
  4973. if ($value['enter'] != 0) {
  4974. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  4975. } else {
  4976. $info_list[$key]['enter'] = "";
  4977. }
  4978. if ($value['dbtime'] != 0) {
  4979. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  4980. } else {
  4981. $info_list[$key]['dbtime'] = "";
  4982. }
  4983. if ($value['state'] == 0) {
  4984. $info_list[$key]['state'] = "在库";
  4985. } else if ($value['state'] == 1) {
  4986. $info_list[$key]['state'] = "出库";
  4987. } else if ($value['state'] == 2) {
  4988. $info_list[$key]['state'] = "退库";
  4989. } else if ($value['state'] == 3) {
  4990. $info_list[$key]['state'] = "调拨中";
  4991. } else if ($value['state'] == 4) {
  4992. $info_list[$key]['state'] = "再加工";
  4993. } else if ($value['state'] == 5) {
  4994. $info_list[$key]['state'] = "维修中";
  4995. } else if ($value['state'] == 6) {
  4996. $info_list[$key]['state'] = "盘亏";
  4997. } else if ($value['state'] == 7) {
  4998. $info_list[$key]['state'] = "更换标签";
  4999. } else if ($value['state'] == 8) {
  5000. $info_list[$key]['state'] = "其它";
  5001. } else if ($value['state'] == 9) {
  5002. $info_list[$key]['state'] = "预设";
  5003. }
  5004. }
  5005. $total = $this->whlabel->find_count($where);
  5006. $pagenum = ceil($total / $perpage);
  5007. $over = $total - ($start + $perpage);
  5008. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5009. echo json_encode($rows);
  5010. exit;
  5011. }
  5012. if (isset($post['outsku'])) {
  5013. $time = time();
  5014. $cz = $this->input->post('cz', true);
  5015. $label = $this->input->post('outsku', true);
  5016. $sl = $this->input->post('sl', true);
  5017. $num = $this->input->post('num', true);
  5018. //$warehouse = $this->input->post('warehouse',true);
  5019. if (!$sl) {
  5020. $sl = 1;
  5021. }
  5022. if (!$warehouse) {
  5023. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5024. exit;
  5025. }
  5026. $dblabel = $this->whlabellabel->get_label($label);
  5027. if ($dblabel) {
  5028. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5029. if (count($data) < 1) {
  5030. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5031. exit;
  5032. }
  5033. if (count($data) < $num) {
  5034. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5035. exit;
  5036. }
  5037. for ($i = 0; $i < $sl; $i++) {
  5038. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5039. }
  5040. echo json_encode(array('success' => true));
  5041. exit;
  5042. } else {
  5043. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5044. exit;
  5045. }
  5046. }
  5047. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5048. $this->_Template('whlabel_db', $this->data);
  5049. }
  5050. public function _dbrk()
  5051. {
  5052. $post = $this->input->post(NULL, TRUE);
  5053. if (isset($post['page'])) {
  5054. $page = $this->input->post('page', true);
  5055. $perpage = $this->input->post('perpage', true);
  5056. $sku = $this->input->post('sku', true);
  5057. $number = $this->input->post('number', true);
  5058. $warehouse = $this->input->post('warehouse', true);
  5059. $purchase = $this->input->post('purchase', true);
  5060. $orderinfo = $this->input->post('orderinfo', true);
  5061. $waybill = $this->input->post('waybill', true);
  5062. $category = $this->input->post('category', true);
  5063. $size = $this->input->post('size', true);
  5064. $grade = $this->input->post('grade', true);
  5065. $color = $this->input->post('color', true);
  5066. $lowe = $this->input->post('lowe', true);
  5067. $state = $this->input->post('state', true);
  5068. $label = $this->input->post('label', true);
  5069. $ctime = $this->input->post('ctime', true);
  5070. $timetk = $this->input->post('timetkk', true);
  5071. $timetj = $this->input->post('timetjj', true);
  5072. $timetk = strtotime($timetk);
  5073. $timetj = strtotime($timetj);
  5074. $where = "dbtime > 0";
  5075. if ($timetk && $timetj) {
  5076. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5077. }
  5078. if ($sku) {
  5079. $where .= " and sku = '$sku'";
  5080. }
  5081. if ($warehouse) {
  5082. $where .= " and warehouse = '$warehouse'";
  5083. }
  5084. if ($purchase) {
  5085. $where .= " and purchase = '$purchase'";
  5086. }
  5087. if ($category) {
  5088. $where .= " and features like '%-$category-%'";
  5089. }
  5090. if ($size) {
  5091. $where .= " and features like '%-$size-%'";
  5092. }
  5093. if ($grade) {
  5094. $where .= " and features like '%-$grade-%'";
  5095. }
  5096. if ($color) {
  5097. $where .= " and features like '%-$color-%'";
  5098. }
  5099. if ($lowe) {
  5100. $where .= " and features like '%-$lowe-%'";
  5101. }
  5102. if ($state != '') {
  5103. $where .= " and state = '$state'";
  5104. }
  5105. //数据排序
  5106. $order_str = "dbtime desc";
  5107. if (empty($page)) {
  5108. $start = 0;
  5109. $perpage = 1;
  5110. } else {
  5111. $start = ($page - 1) * $perpage;
  5112. }
  5113. //取得信息列表
  5114. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5115. foreach ($info_list as $key => $value) {
  5116. $warehouse = $this->warehouse->read($value['warehouse']);
  5117. $info_list[$key]['warehouse'] = $warehouse['title'];
  5118. $purchase = $this->purchase->read($value['purchase']);
  5119. $info_list[$key]['purchase'] = $purchase['title'];
  5120. if ($value['enter'] != 0) {
  5121. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5122. } else {
  5123. $info_list[$key]['enter'] = "";
  5124. }
  5125. if ($value['dbtime'] != 0) {
  5126. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5127. } else {
  5128. $info_list[$key]['dbtime'] = "";
  5129. }
  5130. if ($value['state'] == 0) {
  5131. $info_list[$key]['state'] = "在库";
  5132. } else if ($value['state'] == 1) {
  5133. $info_list[$key]['state'] = "出库";
  5134. } else if ($value['state'] == 2) {
  5135. $info_list[$key]['state'] = "退库";
  5136. } else if ($value['state'] == 3) {
  5137. $info_list[$key]['state'] = "调拨中";
  5138. } else if ($value['state'] == 4) {
  5139. $info_list[$key]['state'] = "再加工";
  5140. } else if ($value['state'] == 5) {
  5141. $info_list[$key]['state'] = "维修中";
  5142. } else if ($value['state'] == 6) {
  5143. $info_list[$key]['state'] = "盘亏";
  5144. } else if ($value['state'] == 7) {
  5145. $info_list[$key]['state'] = "更换标签";
  5146. } else if ($value['state'] == 8) {
  5147. $info_list[$key]['state'] = "其它";
  5148. } else if ($value['state'] == 9) {
  5149. $info_list[$key]['state'] = "预设";
  5150. }
  5151. }
  5152. $total = $this->whlabel->find_count($where);
  5153. $pagenum = ceil($total / $perpage);
  5154. $over = $total - ($start + $perpage);
  5155. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5156. echo json_encode($rows);
  5157. exit;
  5158. }
  5159. if (isset($post['rsku'])) {
  5160. $cz = $this->input->post('cz', true);
  5161. $label = $this->input->post('rsku', true);
  5162. $sl = $this->input->post('sl', true);
  5163. $warehouse = $this->input->post('warehouse', true);
  5164. if (!$sl) {
  5165. $sl = 1;
  5166. }
  5167. if (!$warehouse) {
  5168. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5169. exit;
  5170. }
  5171. $dblabel = $this->whlabellabel->get_label($label);
  5172. if ($dblabel) {
  5173. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5174. if (count($data) < 1) {
  5175. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5176. exit;
  5177. }
  5178. if ($sl > count($data)) {
  5179. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5180. exit;
  5181. }
  5182. $time = time();
  5183. for ($i = 0; $i < $sl; $i++) {
  5184. $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']);
  5185. }
  5186. echo json_encode(array('success' => true));
  5187. exit;
  5188. } else {
  5189. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5190. exit;
  5191. }
  5192. }
  5193. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5194. $this->_Template('whlabel_dbrk', $this->data);
  5195. }
  5196. public function _whlabelczdc()
  5197. {
  5198. if (isset($_GET['excel'])) {
  5199. //数据排序
  5200. $order_str = "id desc";
  5201. if (empty($page)) {
  5202. $start = 0;
  5203. $perpage = 1;
  5204. } else {
  5205. $start = ($page - 1) * $perpage;
  5206. }
  5207. $state = $this->input->get('state', true);
  5208. $sku = $this->input->get('sku', true);
  5209. $ctime = $this->input->get('ctime', true);
  5210. $category = $this->input->get('category', true);
  5211. $size = $this->input->get('size', true);
  5212. $grade = $this->input->get('grade', true);
  5213. $color = $this->input->get('color', true);
  5214. $lowe = $this->input->get('lowe', true);
  5215. $timetk = $this->input->get('timetkk', true);
  5216. $timetj = $this->input->get('timetjj', true);
  5217. $timetk = strtotime($timetk);
  5218. $timetj = strtotime($timetj);
  5219. $where = "dbtime > 0";
  5220. if ($timetk && $timetj) {
  5221. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5222. }
  5223. if ($category) {
  5224. $where .= " and features like '%-$category-%'";
  5225. }
  5226. if ($size) {
  5227. $where .= " and features like '%-$size-%'";
  5228. }
  5229. if ($grade) {
  5230. $where .= " and features like '%-$grade-%'";
  5231. }
  5232. if ($color) {
  5233. $where .= " and features like '%-$color-%'";
  5234. }
  5235. if ($lowe) {
  5236. $where .= " and features like '%-$lowe-%'";
  5237. }
  5238. //取得信息列表
  5239. $info_list = $this->whlabel->find_all($where, '*');
  5240. $rows = array();
  5241. $list = array();
  5242. foreach ($info_list as $key => $value) {
  5243. $rows[$value['sku']] = $value; //所有数据sku
  5244. }
  5245. foreach ($rows as $value) {
  5246. $warehouse = $this->warehouse->read($value['warehouse']);
  5247. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5248. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5249. if ($value['orderinfo'] == 0) {
  5250. $info_list[$key]['orderinfo'] = "";
  5251. }
  5252. if ($value['waybill'] == 0) {
  5253. $info_list[$key]['waybill'] = "";
  5254. }
  5255. if ($value['state'] == 0) {
  5256. $value['state'] = "在库";
  5257. } else if ($value['state'] == 3) {
  5258. $value['state'] = "调拨中";
  5259. }
  5260. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5261. }
  5262. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5263. $titlename = "<table border=1>
  5264. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5265. <tr align='center'>
  5266. <td>SKU</td>
  5267. <td>产品</td>
  5268. <td>调拨数量</td>
  5269. <td>入库数量</td>
  5270. </tr>
  5271. </table>";
  5272. $filename = $title . ".xls";
  5273. $tail = "";
  5274. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5275. }
  5276. }
  5277. public function _print($arg_array)
  5278. {
  5279. if (isset($_SESSION['api'])) {
  5280. $user = $this->user->get_api($_SESSION['api']);
  5281. $usp = $user;
  5282. $fgshop = "";
  5283. $sid = "";
  5284. $wid = "";
  5285. $wtype = "";
  5286. $usersp = explode('|', trim($user['shop'], '|'));
  5287. $userwh = explode('|', trim($user['warehouse'], '|'));
  5288. foreach ($usersp as $value) {
  5289. $fgshop .= " shop = " . $value . " or";
  5290. $sid .= " id = " . $value . " or";
  5291. }
  5292. foreach ($userwh as $value) {
  5293. $wid .= " id = " . $value . " or";
  5294. $wtype .= " type = " . $value . " or";
  5295. }
  5296. }
  5297. $post = $this->input->post(NULL, TRUE);
  5298. if (isset($post['tmsku'])) {
  5299. $tmsku = $this->input->post('tmsku', true);
  5300. if (is_numeric($tmsku)) {
  5301. $yyh = $this->whlabellabel->get_label($tmsku);
  5302. } else {
  5303. $yyh = $this->whlabellabel->get_sku($tmsku);
  5304. }
  5305. if ($yyh) {
  5306. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5307. exit;
  5308. } else {
  5309. echo json_encode(array('success' => false));
  5310. exit;
  5311. }
  5312. }
  5313. $classid = $this->classid->sku();
  5314. $pm = $classid;
  5315. $scsku = $classid;
  5316. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5317. if (isset($post['warehouse'])) {
  5318. if ($post['warehouse']) {
  5319. $list = array();
  5320. $num = "";
  5321. $title = "";
  5322. $features = "";
  5323. $order = 0;
  5324. $post['shop'] = '';
  5325. $brand = $this->input->post('brand', true);
  5326. if ($brand != '0,') {
  5327. $b = $this->brand->read(rtrim($brand, ','));
  5328. if ($b) {
  5329. $post['shop'] = str_replace('|', ',', $b['shop']);
  5330. }
  5331. }
  5332. $post['details'] = $this->input->post('details', true); //打印数量
  5333. $xbqnum = $this->input->post('xbqnum', true);
  5334. $post['purchase'] = $this->input->post('purchase', true);
  5335. $post['warehouse'] = $this->input->post('warehouse', true);
  5336. $post['purchase'] = $this->input->post('purchase', true);
  5337. $post['retreatwarehouse'] = $post['warehouse'];
  5338. $post['cpbz'] = $this->input->post('cpbz', true);
  5339. $post['state'] = 9;
  5340. $category = $this->input->post('category', true);
  5341. $list['category'] = $category;
  5342. $list['hairtype'] = $this->input->post('hairtype', true);
  5343. $list['grade'] = $this->input->post('grade', true);
  5344. $size = $this->input->post('size', true);
  5345. $list['size'] = rtrim($size, ',');
  5346. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5347. $list['extension'] = $this->input->post('extension', true);
  5348. if ($category == 1297) {
  5349. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5350. }
  5351. if ($category == 1702) {
  5352. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5353. $list['syother'] = $this->input->post('syother', true);
  5354. }
  5355. if ($category == 133) {
  5356. $list['fittype'] = $this->input->post('fittype', true);
  5357. $list['acother'] = $this->input->post('acother', true);
  5358. }
  5359. $list['color'] = $this->input->post('color', true);
  5360. $list['lowe'] = $this->input->post('lowe', true);
  5361. if ($category == 127) {
  5362. $list['type'] = $this->input->post('type', true);
  5363. $list['headroad'] = $this->input->post('headroad', true);
  5364. $list['density'] = $this->input->post('density', true);
  5365. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5366. $list['lacesize'] = $this->input->post('lacesize', true);
  5367. }
  5368. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5369. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5370. }
  5371. if ($category == 128) {
  5372. $list['lacetype'] = $this->input->post('lacetype', true);
  5373. $list['haircap'] = $this->input->post('haircap', true);
  5374. $list['density'] = $this->input->post('density', true);
  5375. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5376. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5377. $list['wigother'] = $this->input->post('wigother', true);
  5378. $list['wigother1'] = $this->input->post('wigother1', true);
  5379. $list['wigother2'] = $this->input->post('wigother2', true);
  5380. }
  5381. if ($category == 129) {
  5382. $list['wide'] = $this->input->post('wide', true);
  5383. }
  5384. if ($category == 131) {
  5385. $list['gifttype'] = $this->input->post('gifttype', true);
  5386. $list['giftother'] = $this->input->post('giftother', true);
  5387. }
  5388. if ($category == 134) {
  5389. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5390. }
  5391. if ($category == 1297) {
  5392. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5393. $list['sywigother'] = $this->input->post('sywigother', true);
  5394. }
  5395. if ($category == 130 || $category == 133 || $category == 1702) {
  5396. $list['items'] = $this->input->post('items', true);
  5397. $list['weight'] = $this->input->post('weight', true);
  5398. }
  5399. if ($category == 1702) {
  5400. $list['syhairther'] = $this->input->post('syhairther', true);
  5401. }
  5402. foreach ($list as $k => $v) {
  5403. if ($v != 0) {
  5404. $num .= $v;
  5405. $features .= $v . '-';
  5406. $post[$k] = $v;
  5407. $typeclass = $this->typeclass->read($v);
  5408. if (isset($pm[$typeclass['classid']])) {
  5409. if (stripos($typeclass['zh'], '|') !== false) {
  5410. $exzh = explode('|', $typeclass['zh']);
  5411. $pm[$typeclass['classid']] = $exzh[0];
  5412. } else {
  5413. $pm[$typeclass['classid']] = $typeclass['zh'];
  5414. }
  5415. }
  5416. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5417. if ($k != 'size') {
  5418. $title .= $typeclass['title'] . " ";
  5419. }
  5420. }
  5421. }
  5422. $typeclass = $this->typeclass->read($list['size']);
  5423. $title .= $typeclass['title'];
  5424. $time = time();
  5425. $post['title'] = rtrim($title, ' ');
  5426. $post['number'] = $num;
  5427. $post['features'] = '-' . $features;
  5428. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5429. $featurespp = explode('-', trim($featurespp, '-'));
  5430. if (isset($featurespp[5])) {
  5431. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5432. } else {
  5433. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5434. }
  5435. $post['enter'] = $time;
  5436. $post['time'] = $time; //操作时间
  5437. $scsku = implode("-", $scsku);
  5438. $zh = implode(" ", $pm);
  5439. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5440. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5441. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5442. $post['sku'] = $bqsku;
  5443. $label = time() . rand(0, 9);
  5444. $post['label'] = $label;
  5445. $cpid = $this->whlabellabel->find_count();
  5446. $post['cpid'] = $cpid + 1;
  5447. $cpid = $post['cpid'];
  5448. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5449. //if($whlabelbarcode)
  5450. //{
  5451. //$post['label'] = $whlabelbarcode['label'];
  5452. //if(!$this->whlabellabel->insert($post))
  5453. //{
  5454. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5455. //}
  5456. //}
  5457. //else
  5458. //{
  5459. $this->db->trans_begin();
  5460. $this->whlabellabel->insert($post);
  5461. //$this->whlabelbarcode->insert($post);
  5462. if ($this->db->trans_status() === TRUE) {
  5463. $this->db->trans_commit();
  5464. } else {
  5465. $this->db->trans_rollback();
  5466. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5467. exit;
  5468. }
  5469. //}
  5470. $warehouse_name = "";
  5471. $warehouse = $post['warehouse'];
  5472. if($warehouse == 12){
  5473. $warehouse_name = "特殊库存库";
  5474. }
  5475. // if($warehouse == 13){
  5476. // $warehouse_name = "许昌仓";
  5477. // }
  5478. // if($warehouse == 5){
  5479. // $warehouse_name = "美国店";
  5480. // }
  5481. // if($warehouse == 16){
  5482. // $warehouse_name = "定制头套仓";
  5483. // }
  5484. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5485. if(!empty($warehouse_name)){
  5486. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5487. }
  5488. $purchase = $this->purchase->read($post['purchase']);
  5489. 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));
  5490. exit; //特殊仓目前不需要仓库选项
  5491. }
  5492. }
  5493. if (isset($_SESSION['api'])) {
  5494. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5495. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5496. $this->data['wlshop'] = $wlshop;
  5497. $this->data['warehouse'] = $warehouse;
  5498. }
  5499. $whlabelwz = $this->whlabelwz->find_all();
  5500. $this->data['whlabelwz'] = $whlabelwz;
  5501. $this->_Template('whlabel_print', $this->data);
  5502. }
  5503. public function _usaprint($arg_array)
  5504. {
  5505. if (isset($_SESSION['api'])) {
  5506. $user = $this->user->get_api($_SESSION['api']);
  5507. $usp = $user;
  5508. $fgshop = "";
  5509. $sid = "";
  5510. $wid = "";
  5511. $wtype = "";
  5512. $usersp = explode('|', trim($user['shop'], '|'));
  5513. $userwh = explode('|', trim($user['warehouse'], '|'));
  5514. foreach ($usersp as $value) {
  5515. $fgshop .= " shop = " . $value . " or";
  5516. $sid .= " id = " . $value . " or";
  5517. }
  5518. foreach ($userwh as $value) {
  5519. $wid .= " id = " . $value . " or";
  5520. $wtype .= " type = " . $value . " or";
  5521. }
  5522. }
  5523. $post = $this->input->post(NULL, TRUE);
  5524. if (isset($post['tmsku'])) {
  5525. $tmsku = $this->input->post('tmsku', true);
  5526. if (is_numeric($tmsku)) {
  5527. $yyh = $this->whlabellabel->get_label($tmsku);
  5528. } else {
  5529. $yyh = $this->whlabellabel->get_sku($tmsku);
  5530. }
  5531. if ($yyh) {
  5532. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5533. exit;
  5534. } else {
  5535. echo json_encode(array('success' => false));
  5536. exit;
  5537. }
  5538. }
  5539. $classid = $this->classid->sku();
  5540. $pm = $classid;
  5541. $scsku = $classid;
  5542. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5543. if (isset($post['warehouse'])) {
  5544. if ($post['warehouse']) {
  5545. $list = array();
  5546. $num = "";
  5547. $title = "";
  5548. $features = "";
  5549. $order = 0;
  5550. $post['shop'] = '';
  5551. $brand = $this->input->post('brand', true);
  5552. if ($brand != '0,') {
  5553. $b = $this->brand->read(rtrim($brand, ','));
  5554. if ($b) {
  5555. $post['shop'] = str_replace('|', ',', $b['shop']);
  5556. }
  5557. }
  5558. $post['details'] = $this->input->post('details', true); //打印数量
  5559. $xbqnum = $this->input->post('xbqnum', true);
  5560. $post['purchase'] = $this->input->post('purchase', true);
  5561. $post['warehouse'] = $this->input->post('warehouse', true);
  5562. $post['purchase'] = $this->input->post('purchase', true);
  5563. $post['retreatwarehouse'] = $post['warehouse'];
  5564. $post['cpbz'] = $this->input->post('cpbz', true);
  5565. $post['state'] = 9;
  5566. $category = $this->input->post('category', true);
  5567. $list['category'] = $category;
  5568. $list['hairtype'] = $this->input->post('hairtype', true);
  5569. $list['grade'] = $this->input->post('grade', true);
  5570. $size = $this->input->post('size', true);
  5571. $list['size'] = rtrim($size, ',');
  5572. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5573. $list['extension'] = $this->input->post('extension', true);
  5574. if ($category == 1297) {
  5575. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5576. }
  5577. if ($category == 1702) {
  5578. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5579. $list['syother'] = $this->input->post('syother', true);
  5580. }
  5581. if ($category == 133) {
  5582. $list['fittype'] = $this->input->post('fittype', true);
  5583. $list['acother'] = $this->input->post('acother', true);
  5584. }
  5585. $list['color'] = $this->input->post('color', true);
  5586. $list['lowe'] = $this->input->post('lowe', true);
  5587. if ($category == 127) {
  5588. $list['type'] = $this->input->post('type', true);
  5589. $list['headroad'] = $this->input->post('headroad', true);
  5590. $list['density'] = $this->input->post('density', true);
  5591. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5592. $list['lacesize'] = $this->input->post('lacesize', true);
  5593. }
  5594. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5595. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5596. }
  5597. if ($category == 128) {
  5598. $list['lacetype'] = $this->input->post('lacetype', true);
  5599. $list['haircap'] = $this->input->post('haircap', true);
  5600. $list['density'] = $this->input->post('density', true);
  5601. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5602. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5603. $list['wigother'] = $this->input->post('wigother', true);
  5604. $list['wigother1'] = $this->input->post('wigother1', true);
  5605. $list['wigother2'] = $this->input->post('wigother2', true);
  5606. }
  5607. if ($category == 129) {
  5608. $list['wide'] = $this->input->post('wide', true);
  5609. }
  5610. if ($category == 131) {
  5611. $list['gifttype'] = $this->input->post('gifttype', true);
  5612. $list['giftother'] = $this->input->post('giftother', true);
  5613. }
  5614. if ($category == 134) {
  5615. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5616. }
  5617. if ($category == 1297) {
  5618. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5619. $list['sywigother'] = $this->input->post('sywigother', true);
  5620. }
  5621. if ($category == 130 || $category == 133 || $category == 1702) {
  5622. $list['items'] = $this->input->post('items', true);
  5623. $list['weight'] = $this->input->post('weight', true);
  5624. }
  5625. if ($category == 1702) {
  5626. $list['syhairther'] = $this->input->post('syhairther', true);
  5627. }
  5628. foreach ($list as $k => $v) {
  5629. if ($v != 0) {
  5630. $num .= $v;
  5631. $features .= $v . '-';
  5632. $post[$k] = $v;
  5633. $typeclass = $this->typeclass->read($v);
  5634. if (isset($pm[$typeclass['classid']])) {
  5635. if (stripos($typeclass['zh'], '|') !== false) {
  5636. $exzh = explode('|', $typeclass['zh']);
  5637. $pm[$typeclass['classid']] = $exzh[0];
  5638. } else {
  5639. $pm[$typeclass['classid']] = $typeclass['zh'];
  5640. }
  5641. }
  5642. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5643. if ($k != 'size') {
  5644. $title .= $typeclass['title'] . " ";
  5645. }
  5646. }
  5647. }
  5648. $typeclass = $this->typeclass->read($list['size']);
  5649. $title .= $typeclass['title'];
  5650. $time = time();
  5651. $post['title'] = rtrim($title, ' ');
  5652. $post['number'] = $num;
  5653. $post['features'] = '-' . $features;
  5654. $fp = $this->whlabel->get_features($post['features']);
  5655. if (!$fp) {
  5656. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5657. exit;
  5658. }
  5659. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5660. $featurespp = explode('-', trim($featurespp, '-'));
  5661. if (isset($featurespp[5])) {
  5662. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5663. } else {
  5664. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5665. }
  5666. $post['enter'] = $time;
  5667. $post['time'] = $time; //操作时间
  5668. $scsku = implode("-", $scsku);
  5669. $zh = implode(" ", $pm);
  5670. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5671. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5672. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5673. $post['sku'] = $fp['sku'];
  5674. $post['label'] = $fp['sku'];
  5675. $cpid = $this->whlabellabel->find_count();
  5676. $post['cpid'] = $cpid + 1;
  5677. $cpid = $post['cpid'];
  5678. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5679. //if($whlabelbarcode)
  5680. //{
  5681. //$post['label'] = $whlabelbarcode['label'];
  5682. //if(!$this->whlabellabel->insert($post))
  5683. //{
  5684. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5685. //}
  5686. //}
  5687. //else
  5688. //{
  5689. $this->db->trans_begin();
  5690. $this->whlabellabel->insert($post);
  5691. //$this->whlabelbarcode->insert($post);
  5692. if ($this->db->trans_status() === TRUE) {
  5693. $this->db->trans_commit();
  5694. } else {
  5695. $this->db->trans_rollback();
  5696. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5697. exit;
  5698. }
  5699. //}
  5700. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5701. $purchase = $this->purchase->read($post['purchase']);
  5702. 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));
  5703. exit; //特殊仓目前不需要仓库选项
  5704. }
  5705. }
  5706. if (isset($_SESSION['api'])) {
  5707. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5708. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5709. $this->data['wlshop'] = $wlshop;
  5710. $this->data['warehouse'] = $warehouse;
  5711. }
  5712. $whlabelwz = $this->whlabelwz->find_all();
  5713. $this->data['whlabelwz'] = $whlabelwz;
  5714. $this->_Template('whlabel_usaprint', $this->data);
  5715. }
  5716. public function _printrk($arg_array)
  5717. {
  5718. $prc = array();
  5719. $purchase = $this->purchase->find_all();
  5720. foreach ($purchase as $k => $v) {
  5721. $prc[$v['id']] = $v['title'];
  5722. }
  5723. $post = $this->input->post(NULL, TRUE);
  5724. if (isset($post['page'])) {
  5725. $page = $this->input->post('page', true);
  5726. $perpage = $this->input->post('perpage', true);
  5727. $sku = $this->input->post('sku', true);
  5728. $bs = $this->input->post('bs', true);
  5729. $number = $this->input->post('number', true);
  5730. $warehouse = $this->input->post('warehouse', true);
  5731. $purchase = $this->input->post('purchase', true);
  5732. $orderinfo = $this->input->post('orderinfo', true);
  5733. $waybill = $this->input->post('waybill', true);
  5734. $category = $this->input->post('category', true);
  5735. $size = $this->input->post('size', true);
  5736. $grade = $this->input->post('grade', true);
  5737. $color = $this->input->post('color', true);
  5738. $lowe = $this->input->post('lowe', true);
  5739. $state = $this->input->post('state', true);
  5740. $label = $this->input->post('label', true);
  5741. $timetk = $this->input->post('ktime', true);
  5742. $timetj = $this->input->post('jtime', true);
  5743. $timetk = strtotime($timetk);
  5744. $timetj = strtotime($timetj);
  5745. $where = "1=1 ";
  5746. if ($timetk && $timetj) {
  5747. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5748. }
  5749. if ($sku) {
  5750. $where .= " and sku = '$sku'";
  5751. }
  5752. if ($bs != '') {
  5753. $where .= " and bs = '$bs'";
  5754. }
  5755. if ($number) {
  5756. $where .= " and number = '$number'";
  5757. }
  5758. if ($warehouse) {
  5759. $where .= " and warehouse = '$warehouse'";
  5760. }
  5761. if ($purchase) {
  5762. $where .= " and purchase = '$purchase'";
  5763. }
  5764. if ($orderinfo) {
  5765. $where .= " and orderinfo = '$orderinfo'";
  5766. }
  5767. if ($waybill) {
  5768. $where .= " and waybill = '$waybill'";
  5769. }
  5770. if ($category) {
  5771. $where .= " and features like '%-$category-%'";
  5772. }
  5773. if ($size) {
  5774. $where .= " and features like '%-$size-%'";
  5775. }
  5776. if ($grade) {
  5777. $where .= " and features like '%-$grade-%'";
  5778. }
  5779. if ($color) {
  5780. $where .= " and features like '%-$color-%'";
  5781. }
  5782. if ($lowe) {
  5783. $where .= " and features like '%-$lowe-%'";
  5784. }
  5785. if ($label) {
  5786. $where .= " and label = '$label'";
  5787. }
  5788. if ($state || $state == 0) {
  5789. $where .= " and state = '$state'";
  5790. }
  5791. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5792. //数据排序
  5793. $order_str = "enter desc";
  5794. if (empty($page)) {
  5795. $start = 0;
  5796. $perpage = 1;
  5797. } else {
  5798. $start = ($page - 1) * $perpage;
  5799. }
  5800. //取得信息列表
  5801. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5802. foreach ($info_list as $key => $value) {
  5803. $warehouse = $this->warehouse->read($value['warehouse']);
  5804. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5805. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5806. if ($value['state'] == 0) {
  5807. $info_list[$key]['state'] = "在库";
  5808. } else if ($value['state'] == 1) {
  5809. $info_list[$key]['state'] = "出库";
  5810. } else if ($value['state'] == 2) {
  5811. $info_list[$key]['state'] = "退库";
  5812. } else if ($value['state'] == 3) {
  5813. $info_list[$key]['state'] = "调拨中";
  5814. } else if ($value['state'] == 4) {
  5815. $info_list[$key]['state'] = "再加工";
  5816. } else if ($value['state'] == 5) {
  5817. $info_list[$key]['state'] = "维修中";
  5818. } else if ($value['state'] == 6) {
  5819. $info_list[$key]['state'] = "盘亏";
  5820. } else if ($value['state'] == 7) {
  5821. $info_list[$key]['state'] = "更换标签";
  5822. } else if ($value['state'] == 8) {
  5823. $info_list[$key]['state'] = "其它";
  5824. } else if ($value['state'] == 9) {
  5825. $info_list[$key]['state'] = "预设";
  5826. } else if ($value['state'] == 10) {
  5827. $info_list[$key]['state'] = "美店零售";
  5828. }
  5829. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5830. }
  5831. $total = $this->$ck->find_count($where);
  5832. $pagenum = ceil($total / $perpage);
  5833. $over = $total - ($start + $perpage);
  5834. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5835. echo json_encode($rows);
  5836. exit;
  5837. }
  5838. if (isset($post['tmsku'])) {
  5839. $time = time();
  5840. $tmsku = $this->input->post('tmsku', true);
  5841. //$post['shop'] = $this->input->post('shop',true);
  5842. $num = $this->input->post('num', true);
  5843. $rktype = $this->input->post('rktype', true);
  5844. if ($num > 200) {
  5845. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5846. exit;
  5847. }
  5848. if (!$rktype) {
  5849. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5850. }
  5851. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5852. /**
  5853. $wz = array();
  5854. foreach ($rk as $key=>$value)
  5855. {
  5856. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5857. }
  5858. if(count($wz) > 1)
  5859. {
  5860. $wz = array_values($wz);
  5861. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  5862. }
  5863. **/
  5864. if (isset($rk[0]['purchase'])) {
  5865. $rk = $rk[0];
  5866. $j = 0;
  5867. $post['purchase'] = $rk['purchase'];
  5868. $post['warehouse'] = $rk['warehouse'];
  5869. $post['retreatwarehouse'] = $rk['warehouse'];
  5870. $post['sku'] = $rk['sku'];
  5871. $post['number'] = $rk['number'];
  5872. $post['features'] = $rk['features'];
  5873. $post['title'] = $rk['title'];
  5874. $post['enter'] = $time;
  5875. $post['time'] = $time;
  5876. $post['bs'] = 1;
  5877. $post['shop'] = $rk['shop'];
  5878. $post['details'] = $rk['details'];
  5879. $post['cpid'] = $rk['cpid'];
  5880. $post['cpbz'] = $rk['cpbz'];
  5881. //$post['rktype'] = $rktype;
  5882. $warehouse = $this->warehouse->read($rk['warehouse']);
  5883. if ($warehouse['bdck'] == '') {
  5884. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  5885. exit;
  5886. } else {
  5887. $bdck = $warehouse['bdck'];
  5888. }
  5889. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  5890. if (isset($pdwz['details'])) {
  5891. if ($pdwz['details'] != $post['details']) {
  5892. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  5893. exit;
  5894. }
  5895. }
  5896. $post['featurespp'] = $rk['featurespp'];
  5897. if ($post['warehouse'] == '5') {
  5898. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5899. if ($yza) {
  5900. if ($post['features'] != $yza[0]['features']) {
  5901. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  5902. exit;
  5903. }
  5904. }
  5905. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5906. if ($yzb) {
  5907. if ($post['sku'] != $yzb[0]['sku']) {
  5908. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  5909. exit;
  5910. }
  5911. }
  5912. }
  5913. for ($i = 0; $i < $num; $i++) {
  5914. $post['label'] = time() . rand(100, 999) . $i;
  5915. if ($this->$bdck->insert($post)) {
  5916. $j++;
  5917. }
  5918. }
  5919. /**
  5920. if($post['warehouse'] != 12)
  5921. {
  5922. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5923. }
  5924. **/
  5925. if ($j == $num) {
  5926. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  5927. exit;
  5928. } else {
  5929. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  5930. exit;
  5931. }
  5932. } else {
  5933. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  5934. exit;
  5935. }
  5936. }
  5937. $this->_Template('whlabel_printrk', $this->data);
  5938. }
  5939. public function _printxzrk($arg_array)
  5940. {
  5941. $post = $this->input->post(NULL, TRUE);
  5942. if (isset($post['wzid'])) {
  5943. $time = time();
  5944. $id = $this->input->post('wzid', true);
  5945. //$post['shop'] = $this->input->post('shop',true);
  5946. $num = 1;
  5947. $rk = $this->whlabellabel->read($id);
  5948. if (isset($rk['purchase'])) {
  5949. $x = 0;
  5950. $post['purchase'] = $rk['purchase'];
  5951. $post['warehouse'] = $rk['warehouse'];
  5952. $post['retreatwarehouse'] = $rk['warehouse'];
  5953. $post['sku'] = $rk['sku'];
  5954. $post['number'] = $rk['number'];
  5955. $post['features'] = $rk['features'];
  5956. $post['title'] = $rk['title'];
  5957. $post['enter'] = $time;
  5958. $post['time'] = $time;
  5959. $post['bs'] = 1;
  5960. $post['shop'] = $rk['shop'];
  5961. $post['details'] = $rk['details'];
  5962. $post['cpid'] = $rk['cpid'];
  5963. $post['cpbz'] = $rk['cpbz'];
  5964. $warehouse = $this->warehouse->read($rk['warehouse']);
  5965. if ($warehouse['bdck'] == '') {
  5966. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  5967. exit;
  5968. } else {
  5969. $bdck = $warehouse['bdck'];
  5970. }
  5971. $post['featurespp'] = $rk['featurespp'];
  5972. $this->db->trans_begin();
  5973. for ($i = 0; $i < $num; $i++) {
  5974. $post['label'] = time() . rand(100, 999) . $i;
  5975. $this->$bdck->insert($post);
  5976. }
  5977. /**
  5978. if($post['warehouse'] != 12)
  5979. {
  5980. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5981. }
  5982. **/
  5983. if ($this->db->trans_status() === TRUE) {
  5984. $this->db->trans_commit();
  5985. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  5986. exit;
  5987. } else {
  5988. $this->db->trans_rollback();
  5989. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  5990. exit;
  5991. }
  5992. } else {
  5993. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  5994. exit;
  5995. }
  5996. }
  5997. }
  5998. public function _printck($arg_array)
  5999. {
  6000. $prc = array();
  6001. $purchase = $this->purchase->find_all();
  6002. foreach ($purchase as $k => $v) {
  6003. $prc[$v['id']] = $v['title'];
  6004. }
  6005. $post = $this->input->post(NULL, TRUE);
  6006. if (isset($post['page'])) {
  6007. $page = $this->input->post('page', true);
  6008. $perpage = $this->input->post('perpage', true);
  6009. $sku = $this->input->post('sku', true);
  6010. $bs = $this->input->post('bs', true);
  6011. $number = $this->input->post('number', true);
  6012. $warehouse = $this->input->post('warehouse', true);
  6013. $purchase = $this->input->post('purchase', true);
  6014. $orderinfo = $this->input->post('orderinfo', true);
  6015. $waybill = $this->input->post('waybill', true);
  6016. $category = $this->input->post('category', true);
  6017. $size = $this->input->post('size', true);
  6018. $grade = $this->input->post('grade', true);
  6019. $color = $this->input->post('color', true);
  6020. $lowe = $this->input->post('lowe', true);
  6021. $state = $this->input->post('state', true);
  6022. $label = $this->input->post('label', true);
  6023. $timetk = $this->input->post('ktime', true);
  6024. $timetj = $this->input->post('jtime', true);
  6025. $timetk = strtotime($timetk);
  6026. $timetj = strtotime($timetj);
  6027. $where = "state=1 ";
  6028. if ($timetk && $timetj) {
  6029. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6030. }
  6031. if ($sku) {
  6032. $where .= " and sku = '$sku'";
  6033. }
  6034. if ($bs != '') {
  6035. $where .= " and bs = '$bs'";
  6036. }
  6037. if ($number) {
  6038. $where .= " and number = '$number'";
  6039. }
  6040. if ($warehouse) {
  6041. $where .= " and warehouse = '$warehouse'";
  6042. }
  6043. if ($purchase) {
  6044. $where .= " and purchase = '$purchase'";
  6045. }
  6046. if ($orderinfo) {
  6047. $where .= " and orderinfo = '$orderinfo'";
  6048. }
  6049. if ($waybill) {
  6050. $where .= " and waybill = '$waybill'";
  6051. }
  6052. if ($category) {
  6053. $where .= " and features like '%-$category-%'";
  6054. }
  6055. if ($size) {
  6056. $where .= " and features like '%-$size-%'";
  6057. }
  6058. if ($grade) {
  6059. $where .= " and features like '%-$grade-%'";
  6060. }
  6061. if ($color) {
  6062. $where .= " and features like '%-$color-%'";
  6063. }
  6064. if ($lowe) {
  6065. $where .= " and features like '%-$lowe-%'";
  6066. }
  6067. if ($label) {
  6068. $where .= " and label = '$label'";
  6069. }
  6070. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6071. //数据排序
  6072. $order_str = "outk desc";
  6073. if (empty($page)) {
  6074. $start = 0;
  6075. $perpage = 1;
  6076. } else {
  6077. $start = ($page - 1) * $perpage;
  6078. }
  6079. //取得信息列表
  6080. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6081. foreach ($info_list as $key => $value) {
  6082. $warehouse = $this->warehouse->read($value['warehouse']);
  6083. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6084. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6085. if ($value['state'] == 0) {
  6086. $info_list[$key]['state'] = "在库";
  6087. } else if ($value['state'] == 1) {
  6088. $info_list[$key]['state'] = "出库";
  6089. } else if ($value['state'] == 2) {
  6090. $info_list[$key]['state'] = "退库";
  6091. } else if ($value['state'] == 3) {
  6092. $info_list[$key]['state'] = "调拨中";
  6093. } else if ($value['state'] == 4) {
  6094. $info_list[$key]['state'] = "再加工";
  6095. } else if ($value['state'] == 5) {
  6096. $info_list[$key]['state'] = "维修中";
  6097. } else if ($value['state'] == 6) {
  6098. $info_list[$key]['state'] = "盘亏";
  6099. } else if ($value['state'] == 7) {
  6100. $info_list[$key]['state'] = "更换标签";
  6101. } else if ($value['state'] == 8) {
  6102. $info_list[$key]['state'] = "其它";
  6103. } else if ($value['state'] == 9) {
  6104. $info_list[$key]['state'] = "预设";
  6105. } else if ($value['state'] == 10) {
  6106. $info_list[$key]['state'] = "美店零售";
  6107. }
  6108. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6109. }
  6110. $total = $this->$ck->find_count($where);
  6111. $pagenum = ceil($total / $perpage);
  6112. $over = $total - ($start + $perpage);
  6113. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6114. echo json_encode($rows);
  6115. exit;
  6116. }
  6117. if (isset($post['tmsku'])) {
  6118. $time = time();
  6119. $tmsku = $this->input->post('tmsku', true);
  6120. //$post['shop'] = $this->input->post('shop',true);
  6121. $num = $this->input->post('num', true);
  6122. $cktype = $this->input->post('cktype', true);
  6123. $label = $this->whlabellabel->get_label($tmsku);
  6124. if (!$cktype) {
  6125. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6126. }
  6127. if (!isset($label['warehouse'])) {
  6128. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6129. exit;
  6130. }
  6131. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6132. if (stripos($label['features'], '-126-') !== false) {
  6133. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6134. } else {
  6135. $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 = ''");
  6136. }
  6137. $j = 0;
  6138. if (count($ck) >= $num) {
  6139. for ($i = 0; $i < $num; $i++) {
  6140. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6141. {
  6142. $j++;
  6143. }
  6144. }
  6145. if ($j == $num) {
  6146. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6147. exit;
  6148. } else {
  6149. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6150. exit;
  6151. }
  6152. } else {
  6153. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6154. exit;
  6155. }
  6156. }
  6157. if(isset($_SESSION['api']))
  6158. {
  6159. $user = $this->user->get_api($_SESSION['api']);
  6160. if(in_array($user['power'],[1,27])){
  6161. $vip = 1;
  6162. }
  6163. }
  6164. else
  6165. {
  6166. $vip = 0;
  6167. header('Location: /');exit;
  6168. }
  6169. $this->data['vip'] = $vip;
  6170. $this->_Template('whlabel_printck', $this->data);
  6171. }
  6172. public function _printexcel()
  6173. {
  6174. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6175. $config['upload_path'] = '.' . $dir;
  6176. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6177. $config['allowed_types'] = 'xls|xlsx|csv';
  6178. $config['max_size'] = 10240;
  6179. $this->load->library('upload', $config);
  6180. $this->upload->initialize($config);
  6181. if ($this->upload->do_upload('userfile')) {
  6182. $full_path = $dir . $this->upload->data('file_name');
  6183. $fileName = '.' . $full_path;
  6184. if (!file_exists($fileName)) {
  6185. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6186. exit;
  6187. } else {
  6188. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6189. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6190. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6191. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6192. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6193. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6194. ++$column; //如果列数大于26行
  6195. $list = array();
  6196. for ($i = 2; $i <= $row; $i++) // 行数循环
  6197. {
  6198. $data = array();
  6199. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6200. {
  6201. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6202. }
  6203. $list[] = $data;
  6204. }
  6205. }
  6206. $ed = array();
  6207. $i = 0;
  6208. $j = 0;
  6209. $dcdata = array();
  6210. $yc = '';
  6211. $cmf_arr = array_column($list, '1');
  6212. array_multisort($cmf_arr, SORT_ASC, $list);
  6213. foreach ($list as $key => $value) {
  6214. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6215. if ($typeclass) {
  6216. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6217. } else {
  6218. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6219. $i++;
  6220. continue;
  6221. }
  6222. }
  6223. if ($i > 0) {
  6224. $yc = $i . '条异常';
  6225. }
  6226. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6227. exit;
  6228. }
  6229. }
  6230. public function _uck()
  6231. {
  6232. if (isset($_GET['excel'])) {
  6233. $tc = array();
  6234. $typeclass = $this->typeclass->find_all();
  6235. foreach ($typeclass as $v) {
  6236. $tc[$v['id']] = $v['zh'];
  6237. }
  6238. $data = array();
  6239. $t = array();
  6240. $rq = '';
  6241. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6242. $ts = $ts / (24 * 3600);
  6243. for ($i = 0; $i < $ts; $i++) {
  6244. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6245. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6246. }
  6247. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6248. foreach ($info_list as $k => $v) {
  6249. $features = explode('-', trim($v['features'], '-'));
  6250. if (!isset($features[3]) || !isset($features[4])) {
  6251. continue;
  6252. }
  6253. $data[$k][0] = $tc[$features[0]]; //类型
  6254. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6255. $data[$k][2] = $tc[$features[4]]; //曲度
  6256. $data[$k][3] = '';
  6257. if (isset($data[$k][1])) {
  6258. $data[$k][3] .= $data[$k][1];
  6259. }
  6260. if (isset($data[$k][2])) {
  6261. $data[$k][3] .= $data[$k][2];
  6262. }
  6263. if (isset($features[5])) {
  6264. $data[$k][3] .= $tc[$features[5]];
  6265. }
  6266. if (isset($features[2])) {
  6267. $data[$k][3] .= $tc[$features[2]];
  6268. }
  6269. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6270. $data[$k][4] = $v['sku'];
  6271. $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())) . '))'); //月初库存
  6272. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6273. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6274. $ztrq = '';
  6275. $ztsl = '';
  6276. if (count($zt) > 0) {
  6277. foreach ($zt as $vv) {
  6278. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6279. $ztsl .= $vv['num'] . '<br>';
  6280. }
  6281. }
  6282. $data[$k][] = trim($ztsl, '<br>');
  6283. $data[$k][] = trim($ztrq, '<br>');
  6284. $byck = 0;
  6285. foreach ($t as $vv) {
  6286. $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));
  6287. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6288. $byck += $sl;
  6289. }
  6290. $data[$k][] = ($byck > 0) ? $byck : '';
  6291. }
  6292. $title = "详情 " . date("Y-m-d", time());
  6293. $titlename = "<table border=1>
  6294. <tr align='center'>
  6295. <td>类别</td>
  6296. <td>颜色</td>
  6297. <td>曲度</td>
  6298. <td>名称</td>
  6299. <td>SKU</td>
  6300. <td>月初库存</td>
  6301. <td>剩余库存</td>
  6302. <td>在途数量</td>
  6303. <td>预达日期</td>" .
  6304. $rq
  6305. . "<td>本月出库</td></tr>
  6306. </table>";
  6307. $filename = $title . ".xls";
  6308. $tail = "";
  6309. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6310. }
  6311. }
  6312. public function _whlabelexcelzh()
  6313. {
  6314. if (isset($_GET['excel'])) {
  6315. $where = "sku != 'Preset'";
  6316. //数据排序
  6317. $order_str = "id desc";
  6318. if (empty($page)) {
  6319. $start = 0;
  6320. $perpage = 1;
  6321. } else {
  6322. $start = ($page - 1) * $perpage;
  6323. }
  6324. $category = $this->input->get('category', true);
  6325. $warehouse = $this->input->get('warehouse', true);
  6326. $excelid = $this->input->get('sid', true);
  6327. if ($category) {
  6328. $where .= " and features like '%-$category-%'";
  6329. }
  6330. if ($warehouse) {
  6331. $where .= " and warehouse = '$warehouse'";
  6332. }
  6333. $xzid = '';
  6334. if ($excelid) {
  6335. $excelid = explode(',', trim($excelid, ','));
  6336. foreach ($excelid as $key => $value) {
  6337. $xzid .= " id = " . $value . " or";
  6338. }
  6339. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6340. }
  6341. //取得信息列表
  6342. /**
  6343. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6344. $rows = array();$list = array();
  6345. foreach ($info_list as $key=>$value)
  6346. {
  6347. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6348. }
  6349. **/
  6350. $list = array();
  6351. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6352. foreach ($rows as $key => $value) {
  6353. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6354. $zh = '';
  6355. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6356. foreach ($zt as $v) {
  6357. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6358. }
  6359. $zt = array_sum(array_column($zt, 'num'));
  6360. $number = $value['number'];
  6361. $ftime = time() - 15 * 24 * 3600;
  6362. $warehouse = $this->warehouse->read($value['warehouse']);
  6363. $rows[$key]['warehouse'] = $warehouse['title'];
  6364. $rows[$key]['number'] = $c;
  6365. $rows[$key]['features'] = $zh;
  6366. $rows[$key]['hb'] = $c + $zt;
  6367. }
  6368. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6369. $titlename = "<table border=1>
  6370. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6371. <tr align='center'>
  6372. <td>仓库</td>
  6373. <td>SKU</td>
  6374. <td>产品</td>
  6375. <td>库存数量</td>
  6376. <td>在途数量及预达日期</td>
  6377. <td>在途+库存数量</td>
  6378. </tr>
  6379. </table>";
  6380. $filename = $title . ".xls";
  6381. $tail = "";
  6382. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6383. }
  6384. if (isset($_GET['excel'])) {
  6385. $warehouse = $this->input->get('warehouse', true);
  6386. $sku = $this->input->get('sku', true);
  6387. $cz = $this->input->get('cz', true);
  6388. $text = $this->input->post('text', true);
  6389. $xztime = $this->input->get('xztime', true);
  6390. $timetk = $this->input->get('timetk', true);
  6391. $timetj = $this->input->get('timetj', true);
  6392. $timetk = strtotime($timetk);
  6393. $timetj = strtotime($timetj);
  6394. $where = "time = '0' ";
  6395. if ($warehouse) {
  6396. $where .= " and warehouse = '$warehouse'";
  6397. }
  6398. if ($sku) {
  6399. $where .= " and sku = '$sku'";
  6400. }
  6401. if ($text) {
  6402. $where .= " and text like '%$text%'";
  6403. }
  6404. if ($cz != '') {
  6405. $where .= " and cz = '$cz'";
  6406. }
  6407. if ($timetk && $timetj) {
  6408. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6409. }
  6410. //数据排序
  6411. $order_str = $xztime . " desc";
  6412. //取得信息列表
  6413. $zh = array();
  6414. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6415. foreach ($info_list as $v) {
  6416. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6417. $warehouse = $this->warehouse->read($v['warehouse']);
  6418. $v['warehouse'] = $warehouse['title'];
  6419. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6420. $v['stime'] = date('Y-m-d', $v['stime']);
  6421. if (isset($zh[$v['features']])) {
  6422. $zh[$v['features']]['num'] += $v['num'];
  6423. } else {
  6424. $zh[$v['features']] = $v;
  6425. }
  6426. $zh[$v['features']]['features'] = $c;
  6427. }
  6428. $title = "在途数据" . date('Y-m-d', time());
  6429. $titlename = "<table border=1>
  6430. <tr align='center'>
  6431. <td>仓库</td>
  6432. <td>SKU</td>
  6433. <td>名称</td>
  6434. <td>在途数量</td>
  6435. <td>库存数量</td>
  6436. <td>添加在途日期</td>
  6437. <td>预达日期</td>
  6438. <td>备注</td>
  6439. </tr>
  6440. </table>";
  6441. $filename = $title . ".xls";
  6442. $tail = "";
  6443. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6444. }
  6445. }
  6446. public function _fc()
  6447. {
  6448. $vip = 0;
  6449. if (isset($_SESSION['api'])) {
  6450. $user = $this->user->get_api($_SESSION['api']);
  6451. if ($user['vip'] == 1) {
  6452. $vip = 1;
  6453. }
  6454. } else {
  6455. header('Location: /');
  6456. exit;
  6457. }
  6458. $post = $this->input->post(NULL, TRUE);
  6459. if (isset($post['page'])) {
  6460. $page = $this->input->post('page', true);
  6461. $perpage = $this->input->post('perpage', true);
  6462. $category = $this->input->post('category', true);
  6463. $size = $this->input->post('size', true);
  6464. $grade = $this->input->post('grade', true);
  6465. $color = $this->input->post('color', true);
  6466. $lowe = $this->input->post('lowe', true);
  6467. $sku = $this->input->post('sku');
  6468. $title = $this->input->post('title');
  6469. $warehouse = $this->input->post('warehouse', true);
  6470. $usa = $this->input->post('usa', true);
  6471. $purchase = $this->input->post('purchase', true);
  6472. $lacetype = $this->input->post('lacetype', true);
  6473. $haircap = $this->input->post('haircap', true);
  6474. $density = $this->input->post('density', true);
  6475. $details = $this->input->post('details', true);
  6476. $state = $this->input->post('state', true);
  6477. $ktime = $this->input->post('ktime', true);
  6478. $jtime = $this->input->post('jtime', true);
  6479. $ktime = strtotime($ktime);
  6480. $jtime = strtotime($jtime);
  6481. $where = "state = '11'";
  6482. $gj = "";
  6483. $ck = "";
  6484. if ($lacetype) {
  6485. $where .= " and features like '%-$lacetype-%'";
  6486. }
  6487. if ($category) {
  6488. $where .= " and features like '%-$category-%'";
  6489. }
  6490. if ($size) {
  6491. $where .= " and features like '%-$size-%'";
  6492. }
  6493. if ($grade) {
  6494. $where .= " and features like '%-$grade-%'";
  6495. }
  6496. if ($color) {
  6497. $where .= " and features like '%-$color-%'";
  6498. }
  6499. if ($lowe) {
  6500. $where .= " and features like '%-$lowe-%'";
  6501. }
  6502. if ($haircap) {
  6503. $where .= " and features like '%-$haircap-%'";
  6504. }
  6505. if ($density) {
  6506. $where .= " and features like '%-$density-%'";
  6507. }
  6508. if ($usa) {
  6509. if (!$warehouse) {
  6510. $where .= " and (warehouse = '5' or warehouse = '8')";
  6511. }
  6512. }
  6513. if ($warehouse) {
  6514. $where .= " and warehouse = '$warehouse'";
  6515. }
  6516. if ($details) {
  6517. $where .= " and details = '$details'";
  6518. }
  6519. if ($purchase) {
  6520. $where .= " and purchase = '$purchase'";
  6521. }
  6522. if ($state) {
  6523. $where .= " and state = '$state'";
  6524. }
  6525. if ($ktime && $jtime) {
  6526. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6527. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6528. }
  6529. //数据排序
  6530. $order_str = "id desc";
  6531. if (empty($page)) {
  6532. $start = 0;
  6533. $perpage = 1;
  6534. } else {
  6535. $start = ($page - 1) * $perpage;
  6536. }
  6537. if ($sku) {
  6538. $sku = trim($sku, ' ');
  6539. $sku = trim($sku, ' ');
  6540. $where .= " and sku like '%$sku%'";
  6541. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6542. } else if ($title) {
  6543. $title = trim($title, ' ');
  6544. $title = trim($title, ' ');
  6545. $where .= " and title like '%$title%'";
  6546. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6547. } else {
  6548. //$where .= " and time > '$ktime' and time < '$jtime'";
  6549. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6550. }
  6551. //取得信息列表
  6552. $rows = array();
  6553. $list = array();
  6554. foreach ($info_list as $key => $value) {
  6555. $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'] . '"');
  6556. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6557. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6558. $warehouse = $this->warehouse->read($value['warehouse']);
  6559. $info_list[$key]['warehouse'] = $warehouse['title'];
  6560. $info_list[$key]['number'] = $g;
  6561. $info_list[$key]['features'] = $x;
  6562. $info_list[$key]['x'] = $s;
  6563. }
  6564. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6565. $pagenum = ceil($total / $perpage);
  6566. $over = $total - ($start + $perpage);
  6567. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6568. echo json_encode($rows);
  6569. exit;
  6570. }
  6571. $this->data['vip'] = $vip;
  6572. $this->_Template('whlabel_fc', $this->data);
  6573. }
  6574. public function _fcmb()
  6575. {
  6576. $where = "sku != 'Preset'";
  6577. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6578. foreach ($rows as $k => $v) {
  6579. $warehouse = $this->warehouse->read($v['warehouse']);
  6580. $rows[$k]['warehouse'] = $warehouse['title'];
  6581. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6582. $rows[$k]['t'] = '';
  6583. $rows[$k]['n'] = '';
  6584. }
  6585. $title = "封货产品数据导入模板";
  6586. $titlename = "<table border=1>
  6587. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6588. <tr align='center'>
  6589. <td>仓库</td>
  6590. <td>SKU</td>
  6591. <td>产品</td>
  6592. <td>封存产品总数量</td>
  6593. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6594. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6595. </tr>
  6596. </table>";
  6597. $filename = $title . ".xls";
  6598. $tail = "";
  6599. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6600. }
  6601. public function _fcexcel()
  6602. {
  6603. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6604. $config['upload_path'] = '.' . $dir;
  6605. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6606. $config['allowed_types'] = 'xls|xlsx|csv';
  6607. $config['max_size'] = 10240;
  6608. $this->load->library('upload', $config);
  6609. $this->upload->initialize($config);
  6610. if ($this->upload->do_upload('userfile')) {
  6611. $full_path = $dir . $this->upload->data('file_name');
  6612. $fileName = '.' . $full_path;
  6613. if (!file_exists($fileName)) {
  6614. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6615. exit;
  6616. } else {
  6617. libxml_use_internal_errors(true);
  6618. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6619. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6620. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6621. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6622. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6623. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6624. ++$column; //如果列数大于26行
  6625. $list = array();
  6626. for ($i = 2; $i <= $row; $i++) // 行数循环
  6627. {
  6628. $data = array();
  6629. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6630. {
  6631. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6632. }
  6633. $list[] = $data;
  6634. }
  6635. }
  6636. $i = 0;
  6637. $j = 0;
  6638. $ed = array();
  6639. foreach ($list as $key => $value) {
  6640. $time = time();
  6641. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6642. continue;
  6643. }
  6644. $warehouse = $this->warehouse->get_title($value['0']);
  6645. $sku = $value['1'];
  6646. $type = $value['4']; //调整方式0扣减1删除
  6647. $num = $value['5']; //调整数量
  6648. //$text = $value['4'];//扣减说明
  6649. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6650. if (!$d) //如果没有这个SKU
  6651. {
  6652. $ed[] = array($sku . '-库存中不存在此SKU');
  6653. $j++;
  6654. continue;
  6655. }
  6656. if (!isset($warehouse['id'])) {
  6657. $ed[] = array($sku . '-仓库名错误!');
  6658. $j++;
  6659. continue;
  6660. }
  6661. if ($type == 1 || $type == 2) //扣减库存
  6662. {
  6663. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6664. if (count($data) < abs($num)) {
  6665. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6666. $j++;
  6667. continue;
  6668. }
  6669. if ($type == 1) //转入库存
  6670. {
  6671. for ($i = 0; $i < abs($num); $i++) {
  6672. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6673. }
  6674. } else if ($type == 2) //删除
  6675. {
  6676. for ($i = 0; $i < abs($num); $i++) {
  6677. $this->whlabel->remove($data[$i]['id']);
  6678. }
  6679. }
  6680. } else if ($type == 0) //增加库存
  6681. {
  6682. $post['sku'] = $d['sku'];
  6683. $post['shop'] = '';
  6684. $post['warehouse'] = $warehouse['id'];
  6685. $post['purchase'] = $d['purchase'];
  6686. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6687. $post['state'] = 11;
  6688. $post['title'] = $d['title'];
  6689. $post['number'] = $d['number'];
  6690. $post['features'] = $d['features'];
  6691. $post['enter'] = $time;
  6692. $post['time'] = $time; //操作时间
  6693. for ($i = 0; $i < $num; $i++) {
  6694. $post['label'] = time() . rand(100, 999) . $i;
  6695. $this->whlabel->insert($post);
  6696. }
  6697. }
  6698. sleep(1); //防止入库时间一样,需要延迟1秒
  6699. }
  6700. if ($j > 0) {
  6701. $tt = date('Ymd', time());
  6702. $title = '库存导入错误信息-' . $tt;
  6703. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6704. $tail = "\n";
  6705. $filename = $title . ".xls";
  6706. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6707. $dir = '/data/excel/' . $time . '/';
  6708. $file_name = 'error_' . $time . rand(1000, 9999);
  6709. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6710. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6711. fwrite($myfile, $ecl);
  6712. fclose($myfile);
  6713. $error = $dir . $file_name . '.xls';
  6714. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6715. exit;
  6716. } else {
  6717. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6718. exit;
  6719. }
  6720. }
  6721. }
  6722. public function _fcjxc($arg_array)
  6723. {
  6724. if (isset($_GET['excel'])) {
  6725. $category = $this->input->get('category', true);
  6726. $size = $this->input->get('size', true);
  6727. $grade = $this->input->get('grade', true);
  6728. $color = $this->input->get('color', true);
  6729. $lowe = $this->input->get('lowe', true);
  6730. $sku = $this->input->get('sku');
  6731. $title = $this->input->get('title');
  6732. $warehouse = $arg_array[0];
  6733. $usa = $this->input->get('usa', true);
  6734. $purchase = $this->input->get('purchase', true);
  6735. $lacetype = $this->input->get('lacetype', true);
  6736. $haircap = $this->input->get('haircap', true);
  6737. $density = $this->input->get('density', true);
  6738. $title = $this->input->get('title', true);
  6739. $state = $this->input->get('state', true);
  6740. $ktime = $this->input->get('ktime', true);
  6741. $jtime = $this->input->get('jtime', true);
  6742. $where = "state=11";
  6743. $gj = "";
  6744. $ck = "";
  6745. if ($lacetype) {
  6746. $where .= " and features like '%-$lacetype-%'";
  6747. }
  6748. if ($category) {
  6749. $where .= " and features like '%-$category-%'";
  6750. }
  6751. if ($size) {
  6752. $where .= " and features like '%-$size-%'";
  6753. }
  6754. if ($grade) {
  6755. $where .= " and features like '%-$grade-%'";
  6756. }
  6757. if ($color) {
  6758. $where .= " and features like '%-$color-%'";
  6759. }
  6760. if ($lowe) {
  6761. $where .= " and features like '%-$lowe-%'";
  6762. }
  6763. if ($haircap) {
  6764. $where .= " and features like '%-$haircap-%'";
  6765. }
  6766. if ($density) {
  6767. $where .= " and features like '%-$density-%'";
  6768. }
  6769. if ($usa) {
  6770. if (!$warehouse) {
  6771. $where .= " and (warehouse = '5' or warehouse = '8')";
  6772. }
  6773. }
  6774. if ($warehouse) {
  6775. $where .= " and warehouse = '$warehouse'";
  6776. }
  6777. if ($purchase) {
  6778. $where .= " and purchase = '$purchase'";
  6779. }
  6780. if ($state) {
  6781. $where .= " and state = '$state'";
  6782. }
  6783. $order_str = "id desc";
  6784. if ($sku) {
  6785. $sku = trim($sku, ' ');
  6786. $sku = trim($sku, ' ');
  6787. $where .= " and sku like '%$sku%'";
  6788. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6789. } else if ($title) {
  6790. $title = trim($title, ' ');
  6791. $title = trim($title, ' ');
  6792. $where .= " and title like '%$title%'";
  6793. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6794. } else {
  6795. //$where .= " and time > '$ktime' and time < '$jtime'";
  6796. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6797. }
  6798. //取得信息列表
  6799. $rows = array();
  6800. $list = array();
  6801. foreach ($info_list as $key => $value) {
  6802. $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'] . '"');
  6803. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6804. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6805. $rows[$key] = $value;
  6806. $warehouse = $this->warehouse->read($value['warehouse']);
  6807. $rows[$key]['warehouse'] = $warehouse['title'];
  6808. $rows[$key]['features'] = $g;
  6809. $rows[$key]['a'] = $x;
  6810. $rows[$key]['b'] = $s;
  6811. }
  6812. $title = "总统计表";
  6813. $titlename = "<table border=1>
  6814. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6815. <tr align='center'>
  6816. <td>仓库</td>
  6817. <td>SKU</td>
  6818. <td>产品名称</td>
  6819. <td>录入总量</td>
  6820. <td>取出总量</td>
  6821. <td>剩余总量</td>
  6822. </tr>
  6823. </table>";
  6824. $filename = $title . ".xls";
  6825. $tail = "";
  6826. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6827. }
  6828. $vip = 0;
  6829. if (isset($_SESSION['api'])) {
  6830. $user = $this->user->get_api($_SESSION['api']);
  6831. if ($user['vip'] == 1) {
  6832. $vip = 1;
  6833. }
  6834. } else {
  6835. header('Location: /');
  6836. exit;
  6837. }
  6838. $post = $this->input->post(NULL, TRUE);
  6839. if (isset($post['page'])) {
  6840. $page = $this->input->post('page', true);
  6841. $perpage = $this->input->post('perpage', true);
  6842. $category = $this->input->post('category', true);
  6843. $size = $this->input->post('size', true);
  6844. $grade = $this->input->post('grade', true);
  6845. $color = $this->input->post('color', true);
  6846. $lowe = $this->input->post('lowe', true);
  6847. $sku = $this->input->post('sku');
  6848. $title = $this->input->post('title');
  6849. $warehouse = $arg_array[0];
  6850. $usa = $this->input->post('usa', true);
  6851. $purchase = $this->input->post('purchase', true);
  6852. $lacetype = $this->input->post('lacetype', true);
  6853. $haircap = $this->input->post('haircap', true);
  6854. $density = $this->input->post('density', true);
  6855. $title = $this->input->post('title', true);
  6856. $state = $this->input->post('state', true);
  6857. $ktime = $this->input->post('ktime', true);
  6858. $jtime = $this->input->post('jtime', true);
  6859. $ktime = strtotime($ktime);
  6860. $jtime = strtotime($jtime);
  6861. $where = "state=11";
  6862. $gj = "";
  6863. $ck = "";
  6864. if ($lacetype) {
  6865. $where .= " and features like '%-$lacetype-%'";
  6866. }
  6867. if ($category) {
  6868. $where .= " and features like '%-$category-%'";
  6869. }
  6870. if ($size) {
  6871. $where .= " and features like '%-$size-%'";
  6872. }
  6873. if ($grade) {
  6874. $where .= " and features like '%-$grade-%'";
  6875. }
  6876. if ($color) {
  6877. $where .= " and features like '%-$color-%'";
  6878. }
  6879. if ($lowe) {
  6880. $where .= " and features like '%-$lowe-%'";
  6881. }
  6882. if ($haircap) {
  6883. $where .= " and features like '%-$haircap-%'";
  6884. }
  6885. if ($density) {
  6886. $where .= " and features like '%-$density-%'";
  6887. }
  6888. if ($usa) {
  6889. if (!$warehouse) {
  6890. $where .= " and (warehouse = '5' or warehouse = '8')";
  6891. }
  6892. }
  6893. if ($warehouse) {
  6894. $where .= " and warehouse = '$warehouse'";
  6895. }
  6896. if ($purchase) {
  6897. $where .= " and purchase = '$purchase'";
  6898. }
  6899. if ($state) {
  6900. $where .= " and state = '$state'";
  6901. }
  6902. if ($ktime && $jtime) {
  6903. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6904. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6905. }
  6906. //数据排序
  6907. $order_str = "id desc";
  6908. $xs = 0;
  6909. $rows = array();
  6910. $list = array();
  6911. if (empty($page)) {
  6912. $start = 0;
  6913. $perpage = 1;
  6914. } else {
  6915. $start = ($page - 1) * $perpage;
  6916. }
  6917. if ($sku || $title) {
  6918. if ($title) {
  6919. $title = trim($title, ' ');
  6920. $title = trim($title, ' ');
  6921. $where .= " and title like '%$title%'";
  6922. } else {
  6923. $sku = trim($sku, ' ');
  6924. $sku = trim($sku, ' ');
  6925. $where .= " and sku like '%$sku%'";
  6926. }
  6927. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6928. foreach ($info_list as $key => $value) {
  6929. $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'] . '"');
  6930. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6931. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6932. $rows[$key] = $value;
  6933. $warehouse = $this->warehouse->read($value['warehouse']);
  6934. $rows[$key]['warehouse'] = $warehouse['title'];
  6935. $rows[$key]['features'] = $g;
  6936. $rows[$key]['a'] = $x;
  6937. $rows[$key]['b'] = $s;
  6938. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6939. $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天销量
  6940. $yj = $c / ($xl / 30);
  6941. if ($yj < 7) {
  6942. $rows[$key]['y'] = round($yj) . '天销量';
  6943. } else {
  6944. $rows[$key]['y'] = '正常';
  6945. }
  6946. }
  6947. } else {
  6948. //$where .= " and time > '$ktime' and time < '$jtime'";
  6949. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6950. foreach ($info_list as $key => $value) {
  6951. $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'] . '"');
  6952. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6953. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6954. $zs[$key] = $value;
  6955. $warehouse = $this->warehouse->read($value['warehouse']);
  6956. $zs[$key]['warehouse'] = $warehouse['title'];
  6957. $zs[$key]['features'] = $g;
  6958. $zs[$key]['a'] = $x;
  6959. $zs[$key]['b'] = $s;
  6960. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6961. $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天销量
  6962. $yj = $c / ($xl / 30);
  6963. if ($yj < 7) {
  6964. $zs[$key]['y'] = round($yj) . '天销量';
  6965. $rows[$key] = $zs[$key];
  6966. }
  6967. }
  6968. }
  6969. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  6970. $pagenum = ceil($total / $perpage);
  6971. $over = $total - ($start + $perpage);
  6972. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  6973. echo json_encode($rows);
  6974. exit;
  6975. }
  6976. $this->data['arg_array'] = $arg_array[0];
  6977. $this->_Template('whlabel_fcjxc', $this->data);
  6978. }
  6979. public function _0kcdel()
  6980. {
  6981. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6982. $config['upload_path'] = '.' . $dir;
  6983. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6984. $config['allowed_types'] = 'xls|xlsx|csv';
  6985. $config['max_size'] = 10240;
  6986. $this->load->library('upload', $config);
  6987. $this->upload->initialize($config);
  6988. if ($this->upload->do_upload('userfile')) {
  6989. $full_path = $dir . $this->upload->data('file_name');
  6990. $fileName = '.' . $full_path;
  6991. if (!file_exists($fileName)) {
  6992. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6993. exit;
  6994. } else {
  6995. require_once "./data/excel/PHPExcel/IOFactory.php";
  6996. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6997. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6998. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6999. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7000. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7001. ++$column; //如果列数大于26行
  7002. $list = array();
  7003. for ($i = 2; $i <= $row; $i++) // 行数循环
  7004. {
  7005. $data = array();
  7006. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7007. {
  7008. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7009. }
  7010. $list[] = $data;
  7011. }
  7012. }
  7013. $i = 0;
  7014. $j = 0;
  7015. $ed = array();
  7016. foreach ($list as $key => $value) {
  7017. $time = time();
  7018. if ($value['0'] == "" || $value['1'] == "") {
  7019. continue;
  7020. }
  7021. $warehouse = $this->warehouse->get_title($value['0']);
  7022. $sku = $value['1'];
  7023. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7024. if (!$d) //如果没有这个SKU
  7025. {
  7026. $ed[] = array($sku . '-库存中不存在此SKU');
  7027. $j++;
  7028. continue;
  7029. }
  7030. if (!isset($warehouse['id'])) {
  7031. $ed[] = array($sku . '-仓库名错误!');
  7032. $j++;
  7033. continue;
  7034. }
  7035. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7036. if ($z < 1) {
  7037. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7038. foreach ($z as $v) {
  7039. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7040. if (count($zt) > 0) {
  7041. $ed[] = array($sku . '-有在途库存无法删除!');
  7042. $j++;
  7043. continue;
  7044. }
  7045. $this->whlabel->remove($v['id']);
  7046. }
  7047. } else {
  7048. $ed[] = array($sku . '-非0库存!');
  7049. $j++;
  7050. continue;
  7051. }
  7052. }
  7053. if ($j > 0) {
  7054. $tt = date('Ymd', time());
  7055. $title = '删除0库存错误信息-' . $tt;
  7056. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7057. $tail = "\n";
  7058. $filename = $title . ".xls";
  7059. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7060. $dir = '/data/excel/' . $time . '/';
  7061. $file_name = 'error_' . $time . rand(1000, 9999);
  7062. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7063. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7064. fwrite($myfile, $ecl);
  7065. fclose($myfile);
  7066. $error = $dir . $file_name . '.xls';
  7067. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7068. exit;
  7069. } else {
  7070. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7071. exit;
  7072. }
  7073. }
  7074. }
  7075. public function _gbhtype()
  7076. {
  7077. $post = $this->input->post(NULL, TRUE);
  7078. if (isset($post['s'])) {
  7079. $n = $this->input->post('n');
  7080. $d = $this->input->post('s');
  7081. if (!$d) {
  7082. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7083. exit;
  7084. }
  7085. $d = explode(',', trim($d, ','));
  7086. $t = $this->whlabel_type->read($n);
  7087. //循环删除记录
  7088. foreach ($d as $v) {
  7089. $u = $this->whlabel->read($v);
  7090. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7091. foreach ($data as $val) {
  7092. $this->whlabel->save(array('type' => $n), $val['id']);
  7093. }
  7094. }
  7095. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7096. }
  7097. }
  7098. //出库、退库导出
  7099. public function _dccrtype()
  7100. {
  7101. $classid = $this->classid->sku();
  7102. $pm = $classid;
  7103. $typeclass = array();
  7104. $tc = $this->typeclass->find_all();
  7105. foreach ($tc as $v) {
  7106. $typeclass[$v['id']] = $v;
  7107. }
  7108. $prc = array();
  7109. $purchase = $this->purchase->find_all();
  7110. foreach ($purchase as $k => $v) {
  7111. $prc[$v['id']] = $v['title'];
  7112. }
  7113. if (isset($_GET['sid'])) {
  7114. $wh = array();
  7115. $w = $this->warehouse->find_all('1=1', 'id,title');
  7116. foreach ($w as $v) {
  7117. $wh[$v['id']] = $v['title'];
  7118. }
  7119. $type = $this->input->get('excel', true);
  7120. $category = $this->input->get('category', true);
  7121. $size = $this->input->get('size', true);
  7122. $grade = $this->input->get('grade', true);
  7123. $color = $this->input->get('color', true);
  7124. $lowe = $this->input->get('lowe', true);
  7125. $sku = $this->input->get('sku', true);
  7126. $warehouse = $this->input->get('warehouse', true);
  7127. $lacetype = $this->input->get('lacetype', true);
  7128. $lacecolor = $this->input->get('lacecolor', true);
  7129. $density = $this->input->get('density', true);
  7130. $haircap = $this->input->get('haircap', true);
  7131. $purchase = $this->input->get('purchase', true);
  7132. $title = $this->input->get('title', true);
  7133. $state = $this->input->get('state', true);
  7134. $sid = $this->input->get('sid', true);
  7135. $ktime = $this->input->get('ktime', true);
  7136. $jtime = $this->input->get('jtime', true);
  7137. $ktime = strtotime($ktime);
  7138. $jtime = strtotime($jtime);
  7139. $where = "1=1";
  7140. $gj = "";
  7141. $ck = "";
  7142. if ($category) {
  7143. $where .= " and features like '%-$category-%'";
  7144. }
  7145. if ($size) {
  7146. $where .= " and features like '%-$size-%'";
  7147. }
  7148. if ($grade) {
  7149. $where .= " and features like '%-$grade-%'";
  7150. }
  7151. if ($color) {
  7152. $where .= " and features like '%-$color-%'";
  7153. }
  7154. if ($lowe) {
  7155. $where .= " and features like '%-$lowe-%'";
  7156. }
  7157. if ($warehouse) {
  7158. $where .= " and warehouse = '$warehouse'";
  7159. }
  7160. if ($purchase) {
  7161. $where .= " and purchase = '$purchase'";
  7162. }
  7163. if ($state) {
  7164. $where .= " and state = '$state'";
  7165. }
  7166. if ($lacetype) {
  7167. $where .= " and features like '%-$lacetype-%'";
  7168. }
  7169. if ($lacecolor) {
  7170. $where .= " and features like '%-$lacecolor-%'";
  7171. }
  7172. if ($density) {
  7173. $where .= " and features like '%-$density-%'";
  7174. }
  7175. if ($haircap) {
  7176. $where .= " and features like '%-$haircap-%'";
  7177. }
  7178. if ($title) {
  7179. $title = trim($title, ' ');
  7180. $title = trim($title, ' ');
  7181. $where .= " and title like '%$title%'";
  7182. }
  7183. if ($sku) {
  7184. $sku = trim($sku, ' ');
  7185. $sku = trim($sku, ' ');
  7186. $where .= " and sku like '%$sku%'";
  7187. }
  7188. if ($ktime && $jtime) {
  7189. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7190. }
  7191. $sidwhere = '';
  7192. if ($sid) {
  7193. $sd = "";
  7194. $s = explode(',', trim($sid, ','));
  7195. foreach ($s as $value) {
  7196. $sd .= " id = " . $value . " or";
  7197. }
  7198. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7199. }
  7200. //数据排序
  7201. $order_str = "time desc";
  7202. if (empty($page)) {
  7203. $start = 0;
  7204. $perpage = 1;
  7205. } else {
  7206. $start = ($page - 1) * $perpage;
  7207. }
  7208. $wh = array();
  7209. $w = $this->warehouse->find_all('1=1', 'id,title');
  7210. foreach ($w as $v) {
  7211. $wh[$v['id']] = $v['title'];
  7212. }
  7213. $wt = array();
  7214. $whlabel_type = $this->whlabel_type->find_all();
  7215. foreach ($whlabel_type as $v) {
  7216. $wt[$v['id']] = $v['title'];
  7217. }
  7218. $classid = $this->classid->sku();
  7219. $list = array();
  7220. $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');
  7221. foreach ($rows_r as $key => $value) {
  7222. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7223. $pm = $classid;
  7224. $jm = $classid;
  7225. $rows_r[$key]['enter'] = '入库';
  7226. $rows_r[$key]['time'] = $value['enter'];
  7227. if ($value['rktype'] == 1) {
  7228. $rows_r[$key]['rktype'] = '采购入库';
  7229. } else if ($value['rktype'] == 2) {
  7230. $rows_r[$key]['rktype'] = '盘盈调整';
  7231. } else if ($value['rktype'] == 3) {
  7232. $rows_r[$key]['rktype'] = '其他调整入库';
  7233. } else if ($value['rktype'] == 4) {
  7234. $rows_r[$key]['rktype'] = '其他调整入库';
  7235. } else if ($value['rktype'] == 5) {
  7236. $rows_r[$key]['rktype'] = '退库入库';
  7237. } else if ($value['rktype'] == 6) {
  7238. $rows_r[$key]['rktype'] = '退货可用入库';
  7239. } else if ($value['rktype'] == 7) {
  7240. $rows_r[$key]['rktype'] = '形态转换入库';
  7241. } else {
  7242. $rows_r[$key]['rktype'] = '';
  7243. }
  7244. $features = explode('-', trim($value['features'], '-'));
  7245. foreach ($features as $v) {
  7246. if (isset($typeclass[$v])) {
  7247. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7248. $pm[$typeclass[$v]['classid']] = $zh[0];
  7249. }
  7250. if (isset($typeclass[$v])) {
  7251. if (isset($jm[$typeclass[$v]['classid']])) {
  7252. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7253. }
  7254. }
  7255. }
  7256. $zh = implode(" ", $pm);
  7257. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7258. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7259. $rows_r[$key]['zh'] = $zh;
  7260. $jm = array_filter($jm);
  7261. $rows_r[$key]['features'] = implode("-", $jm);
  7262. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7263. }
  7264. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  7265. foreach ($rows_c as $key => $value) {
  7266. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7267. $pm = $classid;
  7268. $jm = $classid;
  7269. $rows_c[$key]['time'] = $value['outk'];
  7270. $rows_c[$key]['outk'] = '出库';
  7271. if ($value['cktype'] == 1) {
  7272. $rows_c[$key]['cktype'] = '销售出库';
  7273. } else if ($value['cktype'] == 2) {
  7274. $rows_c[$key]['cktype'] = '销售美国出库';
  7275. } else if ($value['cktype'] == 3) {
  7276. $rows_c[$key]['cktype'] = '盘亏调整';
  7277. } else if ($value['cktype'] == 4) {
  7278. $rows_c[$key]['cktype'] = '其他调整出库';
  7279. } else if ($value['cktype'] == 5) {
  7280. $rows_c[$key]['cktype'] = '形态转换出库';
  7281. } else {
  7282. $rows_c[$key]['cktype'] = '';
  7283. }
  7284. $features = explode('-', trim($value['features'], '-'));
  7285. foreach ($features as $v) {
  7286. if (isset($typeclass[$v])) {
  7287. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7288. $pm[$typeclass[$v]['classid']] = $zh[0];
  7289. }
  7290. if (isset($typeclass[$v])) {
  7291. if (isset($jm[$typeclass[$v]['classid']])) {
  7292. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7293. }
  7294. }
  7295. }
  7296. $zh = implode(" ", $pm);
  7297. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7298. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7299. $rows_c[$key]['zh'] = $zh;
  7300. $jm = array_filter($jm);
  7301. $rows_c[$key]['features'] = implode("-", $jm);
  7302. $rows_c[$key]['number'] = 1;
  7303. }
  7304. $merged = $rows_r;
  7305. foreach ($rows_c as $key => $value) {
  7306. if (isset($merged[$key])) {
  7307. $merged[] = $value;
  7308. } else {
  7309. $merged[$key] = $value;
  7310. }
  7311. }
  7312. usort($merged, function ($a, $b) {
  7313. return $a['time'] - $b['time'];
  7314. });
  7315. foreach ($merged as $key => $value) {
  7316. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7317. }
  7318. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7319. $titlename = "<table border=1>
  7320. <tr align='center'>
  7321. <td>仓库</td>
  7322. <td>SKU</td>
  7323. <td>商品名称</td>
  7324. <td>仓库品名</td>
  7325. <td>料号</td>
  7326. <td>时间</td>
  7327. <td>操作</td>
  7328. <td>类型</td>
  7329. <td>数量</td>
  7330. <td>备注</td>
  7331. </tr>
  7332. </table>";
  7333. $filename = $title . ".xlsx";
  7334. $tail = "";
  7335. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7336. }
  7337. }
  7338. }