Whlabel.php 259 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. $this->load->_model("Model_logic_ding","logic_ding");
  45. }
  46. //定义方法的调用规则 获取URI第二段值
  47. public function _remap($arg, $arg_array)
  48. {
  49. if ($arg == 'existence') //在库标签
  50. {
  51. $this->_existence();
  52. } else if ($arg == 'cpbqdc') //在库标签
  53. {
  54. $this->_cpbqdc();
  55. } else if ($arg == 'type') //进销存浏览
  56. {
  57. $this->_type();
  58. } else if ($arg == 'typedy') //进销存浏览店员页面
  59. {
  60. $this->_typedy($arg_array);
  61. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  62. {
  63. $this->_typedy_ck($arg_array);
  64. } else if ($arg == 'typeck') {
  65. $this->_typeck($arg_array);
  66. } else if ($arg == 'whlabeckdc') {
  67. $this->_whlabeckdc($arg_array);
  68. } else if ($arg == 'usatype') //美仓进销存浏览
  69. {
  70. $this->_usatype();
  71. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  72. {
  73. $this->_usatypeapp();
  74. } else if ($arg == 'enteradd') //入库操作
  75. {
  76. $this->_enteradd();
  77. } else if ($arg == 'enteredit') //修改
  78. {
  79. $this->_enteredit($arg_array);
  80. } else if ($arg == 'enter') //入库浏览
  81. {
  82. $this->_enter();
  83. } else if ($arg == 'out') //出库浏览
  84. {
  85. $this->_out();
  86. } else if ($arg == 'label') //出库标签浏览
  87. {
  88. $this->_label();
  89. } else if ($arg == 'outorder') //独立站出库订单
  90. {
  91. $this->_outorder();
  92. } else if ($arg == 'soutorder') //速卖通出库订单
  93. {
  94. $this->_soutorder();
  95. } else if ($arg == 'toutorder') //TT出库订单
  96. {
  97. $this->_toutorder();
  98. }else if ($arg == 'aoutorder') //amz出库订单
  99. {
  100. $this->_aoutorder();
  101. } else if ($arg == 'retreat') //退库订单
  102. {
  103. $this->_retreat();
  104. } else if ($arg == 'retreatlk') //退库订单
  105. {
  106. $this->_retreatlk();
  107. } else if ($arg == 'change') //更换标签
  108. {
  109. $this->_change();
  110. } else if ($arg == 'del') //删除
  111. {
  112. $this->_del();
  113. } else if ($arg == 'exceljxc') //进销存信息导出
  114. {
  115. $this->_exceljxc();
  116. } else if ($arg == 'excelr') //入库信息导出
  117. {
  118. $this->_excelr();
  119. } else if ($arg == 'excelct') //出库、退库信息导出
  120. {
  121. $this->_excelct();
  122. } else if ($arg == 'dccrtype') //根据出入库类型导出
  123. {
  124. $this->_dccrtype();
  125. } else if ($arg == 'excelcr') //出库、退库信息导出
  126. {
  127. $this->_excelcr();
  128. } else if ($arg == 'kcyz') //库存验证
  129. {
  130. $this->_kcyz();
  131. } else if ($arg == 'kj') //库存扣减
  132. {
  133. $this->_kj($arg_array);
  134. } else if ($arg == 'presetout') //预设库存导入
  135. {
  136. $this->_presetout($arg_array);
  137. } else if ($arg == 'presetedit') //预设库存导入
  138. {
  139. $this->_presetedit($arg_array);
  140. } else if ($arg == 'summary') //汇总导出
  141. {
  142. $this->_summary($arg_array);
  143. } else if ($arg == 'manifest') //usps发货清单
  144. {
  145. $this->_manifest();
  146. } else if ($arg == 'abnormal') //占单异常
  147. {
  148. $this->_abnormal();
  149. } else if ($arg == 'error') //0库存SKU
  150. {
  151. $this->_error();
  152. } else if ($arg == 'errorexcel') //0库存SKU导出
  153. {
  154. $this->_errorexcel();
  155. } else if ($arg == 'db') {
  156. $this->_db();
  157. } else if ($arg == 'dbrk') {
  158. $this->_dbrk();
  159. } else if ($arg == 'whlabelczdc') {
  160. $this->_whlabelczdc();
  161. } else if ($arg == 'print') {
  162. $this->_print($arg_array);
  163. } else if ($arg == 'usaprint') {
  164. $this->_usaprint($arg_array);
  165. } else if ($arg == 'printck') {
  166. $this->_printck($arg_array);
  167. } else if ($arg == 'printrk') {
  168. $this->_printrk($arg_array);
  169. } else if ($arg == 'printxzrk') {
  170. $this->_printxzrk($arg_array);
  171. } else if ($arg == 'printexcel') {
  172. $this->_printexcel($arg_array);
  173. } else if ($arg == 'uck') {
  174. $this->_uck();
  175. } else if ($arg == 'whlabelexcelzh') {
  176. $this->_whlabelexcelzh();
  177. } else if ($arg == 'fc') {
  178. $this->_fc();
  179. } else if ($arg == 'fcmb') {
  180. $this->_fcmb();
  181. } else if ($arg == 'fcexcel') {
  182. $this->_fcexcel();
  183. } else if ($arg == 'fcjxc') {
  184. $this->_fcjxc($arg_array);
  185. } else if ($arg == '0kcdel') {
  186. $this->_0kcdel(); //导表删除0库存
  187. } else if ($arg == 'gbhtype') {
  188. $this->_gbhtype(); //更改备货状态
  189. } else {
  190. $this->_index();
  191. }
  192. }
  193. //管理
  194. public function _index()
  195. {
  196. $post = $this->input->post(NULL, TRUE);
  197. if (isset($post['page'])) {
  198. $page = $this->input->post('page', true);
  199. $perpage = $this->input->post('perpage', true);
  200. $sku = $this->input->post('sku', true);
  201. $number = $this->input->post('number', true);
  202. $warehouse = $this->input->post('warehouse', true);
  203. $purchase = $this->input->post('purchase', true);
  204. $orderinfo = $this->input->post('orderinfo', true);
  205. $waybill = $this->input->post('waybill', true);
  206. $category = $this->input->post('category', true);
  207. $size = $this->input->post('size', true);
  208. $grade = $this->input->post('grade', true);
  209. $color = $this->input->post('color', true);
  210. $lowe = $this->input->post('lowe', true);
  211. $state = $this->input->post('state', true);
  212. $label = $this->input->post('label', true);
  213. $timetk = $this->input->post('timetkk', true);
  214. $timetj = $this->input->post('timetjj', true);
  215. $timetk = strtotime($timetk);
  216. $timetj = strtotime($timetj);
  217. $where = "1=1 ";
  218. if ($timetk && $timetj) {
  219. $where .= " and time > '$timetk' and time < '$timetj'";
  220. }
  221. if ($sku) {
  222. $where .= " and sku = '$sku'";
  223. }
  224. if ($number) {
  225. $where .= " and number = '$number'";
  226. }
  227. if ($warehouse) {
  228. $where .= " and warehouse = '$warehouse'";
  229. }
  230. if ($purchase) {
  231. $where .= " and purchase = '$purchase'";
  232. }
  233. if ($orderinfo) {
  234. $where .= " and orderinfo = '$orderinfo'";
  235. }
  236. if ($waybill) {
  237. $where .= " and waybill = '$waybill'";
  238. }
  239. if ($category) {
  240. $where .= " and features like '%-$category-%'";
  241. }
  242. if ($size) {
  243. $where .= " and features like '%-$size-%'";
  244. }
  245. if ($grade) {
  246. $where .= " and features like '%-$grade-%'";
  247. }
  248. if ($color) {
  249. $where .= " and features like '%-$color-%'";
  250. }
  251. if ($lowe) {
  252. $where .= " and features like '%-$lowe-%'";
  253. }
  254. if ($label) {
  255. $where .= " and label = '$label'";
  256. }
  257. if ($state != '') {
  258. $where .= " and state = '$state'";
  259. }
  260. //数据排序
  261. $order_str = "time desc";
  262. if (empty($page)) {
  263. $start = 0;
  264. $perpage = 1;
  265. } else {
  266. $start = ($page - 1) * $perpage;
  267. }
  268. //取得信息列表
  269. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,label,printing,enter,warehouse,outk,orderinfo,waybill,text,time', $order_str, $start, $perpage);
  270. foreach ($info_list as $key => $value) {
  271. $warehouse = $this->warehouse->read($value['warehouse']);
  272. $info_list[$key]['warehouse'] = $warehouse['title'];
  273. $purchase = $this->purchase->read($value['purchase']);
  274. $info_list[$key]['purchase'] = $purchase['title'];
  275. if ($value['enter'] != 0) {
  276. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  277. } else {
  278. $info_list[$key]['enter'] = "";
  279. }
  280. if ($value['outk'] != 0) {
  281. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  282. } else {
  283. $info_list[$key]['outk'] = "";
  284. }
  285. if ($value['printing'] != 0) {
  286. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  287. } else {
  288. $info_list[$key]['printing'] = "";
  289. }
  290. if ($value['orderinfo'] == 0) {
  291. $info_list[$key]['orderinfo'] = "";
  292. }
  293. if ($value['waybill'] == 0) {
  294. $info_list[$key]['waybill'] = "";
  295. }
  296. if ($value['state'] == 0) {
  297. $info_list[$key]['state'] = "在库";
  298. } else if ($value['state'] == 1) {
  299. $info_list[$key]['state'] = "出库";
  300. } else if ($value['state'] == 2) {
  301. $info_list[$key]['state'] = "退库";
  302. } else if ($value['state'] == 3) {
  303. $info_list[$key]['state'] = "调拨中";
  304. } else if ($value['state'] == 4) {
  305. $info_list[$key]['state'] = "再加工";
  306. } else if ($value['state'] == 5) {
  307. $info_list[$key]['state'] = "维修中";
  308. } else if ($value['state'] == 6) {
  309. $info_list[$key]['state'] = "盘亏";
  310. } else if ($value['state'] == 7) {
  311. $info_list[$key]['state'] = "更换标签";
  312. } else if ($value['state'] == 8) {
  313. $info_list[$key]['state'] = "其它";
  314. } else if ($value['state'] == 9) {
  315. $info_list[$key]['state'] = "预设";
  316. } else if ($value['state'] == 10) {
  317. $info_list[$key]['state'] = "美店零售";
  318. }
  319. if ($value['text'] == "") {
  320. $info_list[$key]['text'] = "";
  321. }
  322. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  323. }
  324. $total = $this->whlabel->find_count($where);
  325. $pagenum = ceil($total / $perpage);
  326. $over = $total - ($start + $perpage);
  327. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  328. echo json_encode($rows);
  329. exit;
  330. }
  331. if (isset($post['outsku'])) {
  332. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  333. $cz = $this->input->post('cz', true);
  334. if ($cz == '1') {
  335. $sku = $this->input->post('outsku', true);
  336. if ($sku) {
  337. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  338. if (count($data) < 1) {
  339. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  340. exit;
  341. }
  342. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  343. echo json_encode(array('success' => true));
  344. exit;
  345. }
  346. } else {
  347. echo json_encode(array('msg' => '此方法禁用!', 'success' => false));
  348. exit;
  349. $sku = $this->input->post('outsku', true);
  350. if ($sku) {
  351. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  352. if (count($data) < 1) {
  353. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  354. exit;
  355. }
  356. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  357. echo json_encode(array('success' => true));
  358. exit;
  359. }
  360. }
  361. }
  362. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  363. $this->_Template('whlabel', $this->data);
  364. }
  365. //在库标签
  366. public function _existence()
  367. {
  368. $post = $this->input->post(NULL, TRUE);
  369. if (isset($post['s'])) {
  370. $id_arr = $this->input->post('s');
  371. $id_arr = explode(',', $id_arr);
  372. if (!$id_arr) {
  373. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  374. exit;
  375. }
  376. //循环删除记录
  377. foreach ($id_arr as $v) {
  378. $sid = $this->whlabel->read($v);
  379. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  380. if ($count > 0) {
  381. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  382. exit;
  383. }
  384. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  385. if (count($zt) > 0) {
  386. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  387. exit;
  388. }
  389. $this->whlabel->remove($v);
  390. }
  391. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  392. exit;
  393. }
  394. if (isset($post['page'])) {
  395. $page = $this->input->post('page', true);
  396. $perpage = $this->input->post('perpage', true);
  397. $warehouse = $this->input->post('warehouse', true);
  398. $label = $this->input->post('label', true);
  399. $where = "1=1 and state = 0";
  400. if ($warehouse) {
  401. $where .= " and warehouse = '$warehouse'";
  402. }
  403. if ($label) {
  404. $where .= " and label = '$label'";
  405. }
  406. //数据排序
  407. $order_str = "time asc";
  408. if (empty($page)) {
  409. $start = 0;
  410. $perpage = 1;
  411. } else {
  412. $start = ($page - 1) * $perpage;
  413. }
  414. //取得信息列表
  415. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  416. foreach ($info_list as $key => $value) {
  417. if ($value['enter'] != 0) {
  418. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  419. } else {
  420. $info_list[$key]['enter'] = "";
  421. }
  422. if ($value['printing'] != 0) {
  423. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  424. } else {
  425. $info_list[$key]['printing'] = "";
  426. }
  427. }
  428. $total = $this->whlabel->find_count($where);
  429. $pagenum = ceil($total / $perpage);
  430. $over = $total - ($start + $perpage);
  431. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  432. echo json_encode($rows);
  433. exit;
  434. }
  435. $this->_Template('whlabel_existence', $this->data);
  436. }
  437. //进销存浏览
  438. public function _typedy($arg_array)
  439. {
  440. $prc = array();
  441. $purchase = $this->purchase->find_all();
  442. foreach ($purchase as $k => $v) {
  443. $prc[$v['id']] = $v['title'];
  444. }
  445. $post = $this->input->post(NULL, TRUE);
  446. if (isset($post['page'])) {
  447. $page = $this->input->post('page', true);
  448. $perpage = $this->input->post('perpage', true);
  449. $category = $this->input->post('category', true);
  450. $size = $this->input->post('size', true);
  451. $grade = $this->input->post('grade', true);
  452. $color = $this->input->post('color', true);
  453. $lowe = $this->input->post('lowe', true);
  454. $sku = $this->input->post('sku');
  455. $title = $this->input->post('title');
  456. $warehouse = $this->input->post('warehouse', true);
  457. $usa = $this->input->post('usa', true);
  458. $purchase = $this->input->post('purchase', true);
  459. $lacetype = $this->input->post('lacetype', true);
  460. $haircap = $this->input->post('haircap', true);
  461. $density = $this->input->post('density', true);
  462. $details = $this->input->post('details', true);
  463. $state = $this->input->post('state', true);
  464. $lacecolor = $this->input->post('lacecolor', true);
  465. $hairnumber = $this->input->post('hairnumber', true);
  466. $cklx = $this->input->post('cklx', true);
  467. $ktime = $this->input->post('ktime', true);
  468. $jtime = $this->input->post('jtime', true);
  469. $sm = $this->input->post('sm', true);
  470. $cpbz = $this->input->post('cpbz', true);
  471. $type = $this->input->post('type', true);
  472. $ktime = strtotime($ktime);
  473. $jtime = strtotime($jtime);
  474. $where = "1=1";
  475. $gj = "";
  476. $ck = "";
  477. if ($usa) {
  478. if (!$warehouse) {
  479. $where .= " and (warehouse = '5' or warehouse = '8')";
  480. }
  481. }
  482. if ($warehouse) {
  483. $where .= " and warehouse = '$warehouse'";
  484. }
  485. if ($details) {
  486. $where .= " and details = '$details'";
  487. }
  488. if ($purchase) {
  489. $where .= " and purchase = '$purchase'";
  490. }
  491. if (isset($state)) {
  492. if($state >-1){
  493. $where .= " and state = '$state'";
  494. }
  495. }
  496. if ($lacetype) {
  497. $where .= " and features like '%-$lacetype-%'";
  498. }
  499. if ($category) {
  500. $where .= " and features like '%-$category-%'";
  501. }
  502. if ($size) {
  503. $where .= " and features like '%-$size-%'";
  504. }
  505. if ($grade) {
  506. $where .= " and features like '%-$grade-%'";
  507. }
  508. if ($color) {
  509. $where .= " and features like '%-$color-%'";
  510. }
  511. if ($lowe) {
  512. $where .= " and features like '%-$lowe-%'";
  513. }
  514. if ($haircap) {
  515. $where .= " and features like '%-$haircap-%'";
  516. }
  517. if ($density) {
  518. $where .= " and features like '%-$density-%'";
  519. }
  520. if ($lacecolor) {
  521. $where .= " and features like '%-$lacecolor-%'";
  522. }
  523. if($sm){
  524. $where .= " and sm like '%".$sm."%'";
  525. }
  526. if($cpbz){
  527. $where .= " and cpbz like '%".$cpbz."%'";
  528. }
  529. if($type){
  530. $where .= " and type = ".$type."";
  531. }
  532. if (!empty($hairnumber)) {
  533. $where .= " and features like '%-128-%' ";
  534. if ($hairnumber < 0) {
  535. $class_list = $this->typeclass->find_all('classid = 43');
  536. foreach ($class_list as $v) {
  537. $where .= " and features not like '%-" . $v['id'] . "-%'";
  538. }
  539. } else {
  540. $where .= " and features like '%-$hairnumber-%'";
  541. }
  542. }
  543. $where_add = '';
  544. if ($cklx) {
  545. $shop = $this->shop->read($cklx);
  546. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  547. }
  548. if ($ktime && $jtime) {
  549. $gj = " and enter > '$ktime' and enter < '$jtime'";
  550. $ck = " and outk > '$ktime' and outk < '$jtime'";
  551. }
  552. //数据排序
  553. $order_str = "id desc";
  554. if (empty($page)) {
  555. $start = 0;
  556. $perpage = 1;
  557. } else {
  558. $start = ($page - 1) * $perpage;
  559. }
  560. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  561. if ($sku) {
  562. $sku = trim($sku, ' ');
  563. $sku = trim($sku, ' ');
  564. $where .= " and sku like '%$sku%'";
  565. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  566. } else if ($title) {
  567. $title = trim($title, ' ');
  568. $title = trim($title, ' ');
  569. $where .= " and title like '%$title%'";
  570. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  571. } else {
  572. //$where .= " and time > '$ktime' and time < '$jtime'";
  573. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  574. }
  575. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  576. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  577. foreach ($info_list as $k => $v) {
  578. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  579. unset($info_list[$k]['pm']);
  580. unset($info_list[$k]['jm']);
  581. unset($info_list[$k]['bm']);
  582. }
  583. //取得信息列表
  584. $rows = array();
  585. $list = array();
  586. foreach ($info_list as $key => $value) {
  587. $warehouse = $this->warehouse->read($value['warehouse']);
  588. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  589. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  590. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  591. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  592. $info_list[$key]['label'] = $value['sm'];
  593. $number = $value['number'];
  594. $ftime = time() - 15 * 24 * 3600;
  595. $info_list[$key]['warehouse'] = $warehouse['title'];
  596. $info_list[$key]['features'] = count($c);
  597. $z = count($z); //查看订单号
  598. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  599. $ztdata = '';
  600. if (count($zt) > 0) {
  601. foreach ($zt as $vv) {
  602. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  603. }
  604. }
  605. $info_list[$key]['number'] = $ztdata;
  606. $info_list[$key]['sm'] = $z;
  607. $details = array();
  608. $cpid = array();
  609. foreach ($c as $k => $v) {
  610. $details[$v['details']] = $v['details'];
  611. if ($v['cpid'] != 0) {
  612. $cpid[$v['cpid']] = $v['cpid'];
  613. }
  614. }
  615. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  616. if ($value['shop'] != '') {
  617. $shop = explode(',', trim($value['shop'], ','));
  618. $shop = $this->shop->read($shop[0]);
  619. $info_list[$key]['shop'] = $shop['shopname'];
  620. }
  621. }
  622. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  623. $pagenum = ceil($total / $perpage);
  624. $over = $total - ($start + $perpage);
  625. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  626. echo json_encode($rows);
  627. exit;
  628. }
  629. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  630. $this->_Template('whlabel_typedy', $this->data);
  631. }
  632. //进销存浏览
  633. public function _typedy_ck($arg_array)
  634. {
  635. $prc = array();
  636. $purchase = $this->purchase->find_all();
  637. foreach ($purchase as $k => $v) {
  638. $prc[$v['id']] = $v['title'];
  639. }
  640. $post = $this->input->post(NULL, TRUE);
  641. if (isset($post['page'])) {
  642. $page = $this->input->post('page', true);
  643. $perpage = $this->input->post('perpage', true);
  644. $category = $this->input->post('category', true);
  645. $size = $this->input->post('size', true);
  646. $grade = $this->input->post('grade', true);
  647. $color = $this->input->post('color', true);
  648. $lowe = $this->input->post('lowe', true);
  649. $sku = $this->input->post('sku');
  650. $title = $this->input->post('title');
  651. $warehouse = $this->input->post('warehouse', true);
  652. $usa = $this->input->post('usa', true);
  653. $purchase = $this->input->post('purchase', true);
  654. $lacetype = $this->input->post('lacetype', true);
  655. $haircap = $this->input->post('haircap', true);
  656. $density = $this->input->post('density', true);
  657. $details = $this->input->post('details', true);
  658. $state = $this->input->post('state', true);
  659. $lacecolor = $this->input->post('lacecolor', true);
  660. $cklx = $this->input->post('cklx', true);
  661. $ktime = $this->input->post('ktime', true);
  662. $jtime = $this->input->post('jtime', true);
  663. $ktime = strtotime($ktime);
  664. $jtime = strtotime($jtime);
  665. $where = "1=1";
  666. $gj = "";
  667. $ck = "";
  668. if ($lacetype) {
  669. $where .= " and features like '%-$lacetype-%'";
  670. }
  671. if ($category) {
  672. $where .= " and features like '%-$category-%'";
  673. }
  674. if ($size) {
  675. $where .= " and features like '%-$size-%'";
  676. }
  677. if ($grade) {
  678. $where .= " and features like '%-$grade-%'";
  679. }
  680. if ($color) {
  681. $where .= " and features like '%-$color-%'";
  682. }
  683. if ($lowe) {
  684. $where .= " and features like '%-$lowe-%'";
  685. }
  686. if ($haircap) {
  687. $where .= " and features like '%-$haircap-%'";
  688. }
  689. if ($density) {
  690. $where .= " and features like '%-$density-%'";
  691. }
  692. if ($lacecolor) {
  693. $where .= " and features like '%-$lacecolor-%'";
  694. }
  695. if ($usa) {
  696. if (!$warehouse) {
  697. $where .= " and (warehouse = '5' or warehouse = '8')";
  698. }
  699. }
  700. if ($warehouse) {
  701. $where .= " and warehouse = '$warehouse'";
  702. }
  703. if ($details) {
  704. $where .= " and details = '$details'";
  705. }
  706. if ($purchase) {
  707. $where .= " and purchase = '$purchase'";
  708. }
  709. if ($state) {
  710. $where .= " and state = '$state'";
  711. }
  712. $where_add = '';
  713. if ($cklx) {
  714. $shop = $this->shop->read($cklx);
  715. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  716. }
  717. if ($ktime && $jtime) {
  718. $gj = " and enter > '$ktime' and enter < '$jtime'";
  719. $ck = " and outk > '$ktime' and outk < '$jtime'";
  720. }
  721. //数据排序
  722. $order_str = "id desc";
  723. if (empty($page)) {
  724. $start = 0;
  725. $perpage = 1;
  726. } else {
  727. $start = ($page - 1) * $perpage;
  728. }
  729. if ($sku) {
  730. $sku = trim($sku, ' ');
  731. $sku = trim($sku, ' ');
  732. $where .= " and sku like '%$sku%'";
  733. $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);
  734. } else if ($title) {
  735. $title = trim($title, ' ');
  736. $title = trim($title, ' ');
  737. $where .= " and title like '%$title%'";
  738. $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);
  739. } else {
  740. //$where .= " and time > '$ktime' and time < '$jtime'";
  741. $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);
  742. }
  743. //取得信息列表
  744. $rows = array();
  745. $list = array();
  746. foreach ($info_list as $key => $value) {
  747. $warehouse = $this->warehouse->read($value['warehouse']);
  748. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  749. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  750. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  751. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  752. $ftime = time() - 15 * 24 * 3600;
  753. $info_list[$key]['warehouse'] = $warehouse['title'];
  754. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  755. //$z = count($z);//查看订单号
  756. //$info_list[$key]['zd'] = $z;
  757. $details = array();
  758. $cpid = array();
  759. foreach ($c as $k => $v) {
  760. $details[$v['details']] = $v['details'];
  761. if ($v['cpid'] != 0) {
  762. $cpid[$v['cpid']] = $v['cpid'];
  763. }
  764. }
  765. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  766. if ($value['shop'] != '') {
  767. $shop = explode(',', trim($value['shop'], ','));
  768. $shop = $this->shop->read($shop[0]);
  769. $info_list[$key]['shop'] = $shop['shopname'];
  770. }
  771. }
  772. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  773. $pagenum = ceil($total / $perpage);
  774. $over = $total - ($start + $perpage);
  775. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  776. echo json_encode($rows);
  777. exit;
  778. }
  779. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  780. $this->_Template('whlabel_typedy_ck', $this->data);
  781. }
  782. public function _typeck($arg_array)
  783. {
  784. $prc = array();
  785. $purchase = $this->purchase->find_all();
  786. foreach ($purchase as $k => $v) {
  787. $prc[$v['id']] = $v['title'];
  788. }
  789. $post = $this->input->post(NULL, TRUE);
  790. if (isset($post['page'])) {
  791. $page = $this->input->post('page', true);
  792. $perpage = $this->input->post('perpage', true);
  793. $category = $this->input->post('category', true);
  794. $size = $this->input->post('size', true);
  795. $grade = $this->input->post('grade', true);
  796. $color = $this->input->post('color', true);
  797. $lacecolor = $this->input->post('lacecolor', true);
  798. $lowe = $this->input->post('lowe', true);
  799. $sku = $this->input->post('sku');
  800. $title = $this->input->post('title');
  801. $warehouse = 13;
  802. $usa = $this->input->post('usa', true);
  803. $purchase = $this->input->post('purchase', true);
  804. $lacetype = $this->input->post('lacetype', true);
  805. $haircap = $this->input->post('haircap', true);
  806. $density = $this->input->post('density', true);
  807. $details = $this->input->post('details', true);
  808. $state = $this->input->post('state', true);
  809. $ktime = $this->input->post('ktime', true);
  810. $jtime = $this->input->post('jtime', true);
  811. $ktime = strtotime($ktime);
  812. $jtime = strtotime($jtime);
  813. $where = "1=1";
  814. $gj = "";
  815. $ck = "";
  816. if ($lacetype) {
  817. $where .= " and features like '%-$lacetype-%'";
  818. }
  819. if ($category) {
  820. $where .= " and features like '%-$category-%'";
  821. }
  822. if ($size) {
  823. $where .= " and features like '%-$size-%'";
  824. }
  825. if ($grade) {
  826. $where .= " and features like '%-$grade-%'";
  827. }
  828. if ($color) {
  829. $where .= " and features like '%-$color-%'";
  830. }
  831. if ($lacecolor) {
  832. $where .= " and features like '%-$lacecolor-%'";
  833. }
  834. if ($lowe) {
  835. $where .= " and features like '%-$lowe-%'";
  836. }
  837. if ($haircap) {
  838. $where .= " and features like '%-$haircap-%'";
  839. }
  840. if ($density) {
  841. $where .= " and features like '%-$density-%'";
  842. }
  843. if ($warehouse) {
  844. $where .= " and warehouse = '$warehouse'";
  845. }
  846. if ($details) {
  847. $where .= " and details = '$details'";
  848. }
  849. if ($purchase) {
  850. $where .= " and purchase = '$purchase'";
  851. }
  852. if ($state) {
  853. $where .= " and state = '$state'";
  854. }
  855. if ($ktime && $jtime) {
  856. $gj = " and enter > '$ktime' and enter < '$jtime'";
  857. $ck = " and outk > '$ktime' and outk < '$jtime'";
  858. }
  859. //数据排序
  860. $order_str = "id desc";
  861. if (empty($page)) {
  862. $start = 0;
  863. $perpage = 1;
  864. } else {
  865. $start = ($page - 1) * $perpage;
  866. }
  867. if ($sku) {
  868. $sku = trim($sku, ' ');
  869. $sku = trim($sku, ' ');
  870. $where .= " and sku like '%$sku%'";
  871. } else if ($title) {
  872. $title = trim($title, ' ');
  873. $title = trim($title, ' ');
  874. $where .= " and title like '%$title%'";
  875. }
  876. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  877. //取得信息列表
  878. $t = array();
  879. $typeclass = $this->typeclass->find_all();
  880. foreach ($typeclass as $v) {
  881. $t[$v['id']] = $v;
  882. }
  883. $rows = array();
  884. $list = array();
  885. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  886. foreach ($info_list as $key => $value) {
  887. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  888. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  889. $warehouse = $this->warehouse->read($value['warehouse']);
  890. $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');
  891. $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'] . '"');
  892. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  893. $number = $value['number'];
  894. $ftime = time() - 15 * 24 * 3600;
  895. $z = count($z); //查看订单号
  896. $info_list[$key]['warehouse'] = $warehouse['title'];
  897. $info_list[$key]['features'] = count($c);
  898. $info_list[$key]['number'] = $z;
  899. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  900. $details = array();
  901. $cpid = array();
  902. foreach ($c as $k => $v) {
  903. $details[$v['details']] = $v['details'];
  904. if ($v['cpid'] != 0) {
  905. $cpid[$v['cpid']] = $v['cpid'];
  906. }
  907. }
  908. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  909. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  910. unset($info_list[$key]['pm']);
  911. unset($info_list[$key]['jm']);
  912. unset($info_list[$key]['bm']);
  913. }
  914. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  915. $pagenum = ceil($total / $perpage);
  916. $over = $total - ($start + $perpage);
  917. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  918. echo json_encode($rows);
  919. exit;
  920. }
  921. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  922. $this->_Template('whlabel_typeck', $this->data);
  923. }
  924. //进销存导出
  925. public function _whlabeckdc()
  926. {
  927. $prc = array();
  928. $purchase = $this->purchase->find_all();
  929. foreach ($purchase as $k => $v) {
  930. $prc[$v['id']] = $v['title'];
  931. }
  932. if (isset($_GET['excel'])) {
  933. $where = "sku != 'Preset'";
  934. //数据排序
  935. $order_str = "id desc";
  936. if (empty($page)) {
  937. $start = 0;
  938. $perpage = 1;
  939. } else {
  940. $start = ($page - 1) * $perpage;
  941. }
  942. $category = $this->input->get('category', true);
  943. $color = $this->input->get('color', true);
  944. $lowe = $this->input->get('lowe', true);
  945. $lacetype = $this->input->get('lacetype', true);
  946. $size = $this->input->get('size', true);
  947. $density = $this->input->get('density', true);
  948. $haircap = $this->input->get('haircap', true);
  949. $sku = $this->input->get('sku', true);
  950. $details = $this->input->get('details', true);
  951. $warehouse = 13;
  952. $excelid = $this->input->get('sid', true);
  953. if ($category) {
  954. $where .= " and features like '%-$category-%'";
  955. }
  956. if ($color) {
  957. $where .= " and features like '%-$color-%'";
  958. }
  959. if ($lowe) {
  960. $where .= " and features like '%-$lowe-%'";
  961. }
  962. if ($lacetype) {
  963. $where .= " and features like '%-$lacetype-%'";
  964. }
  965. if ($size) {
  966. $where .= " and features like '%-$size-%'";
  967. }
  968. if ($density) {
  969. $where .= " and features like '%-$density-%'";
  970. }
  971. if ($haircap) {
  972. $where .= " and features like '%-$haircap-%'";
  973. }
  974. if ($warehouse) {
  975. $where .= " and warehouse = '$warehouse'";
  976. }
  977. if ($sku) {
  978. $where .= " and sku like '%$sku%'";
  979. }
  980. if ($details) {
  981. $where .= " and details = '$details'";
  982. }
  983. $xzid = '';
  984. if ($excelid) {
  985. $excelid = explode(',', trim($excelid, ','));
  986. foreach ($excelid as $key => $value) {
  987. $xzid .= " id = " . $value . " or";
  988. }
  989. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  990. }
  991. //取得信息列表
  992. /**
  993. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  994. $rows = array();$list = array();
  995. foreach ($info_list as $key=>$value)
  996. {
  997. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  998. }
  999. **/
  1000. $wh = array();
  1001. $w = $this->warehouse->find_all('1=1', 'id,title');
  1002. foreach ($w as $v) {
  1003. $wh[$v['id']] = $v['title'];
  1004. }
  1005. $tc = array();
  1006. $tcdata = array();
  1007. $list = array();
  1008. $classid = $this->classid->sku();
  1009. $tcall = $this->typeclass->find_all();
  1010. $typeclass = array();
  1011. foreach ($tcall as $v)
  1012. {
  1013. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1014. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1015. }
  1016. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1017. foreach ($rows as $key => $value) {
  1018. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1019. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1020. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1021. $rows[$key]['cpbz'] = $u9_info['bm'];
  1022. $rows[$key]['cs'] = $u9_info['jm'];
  1023. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1024. $details = array();
  1025. $cpid = array();
  1026. $cpbz = array();
  1027. $c = 0;
  1028. $g = 0;
  1029. $x = 0;
  1030. $t = 0;
  1031. $s = 0;
  1032. $q = 0;
  1033. foreach ($sd as $k => $v) {
  1034. if ($v['state'] == 0) {
  1035. $c++;
  1036. }
  1037. if ($v['state'] != 9) {
  1038. $g++;
  1039. }
  1040. if ($v['state'] == 1) {
  1041. $x++;
  1042. }
  1043. if ($v['state'] == 2) {
  1044. $t++;
  1045. }
  1046. if ($v['state'] == 8) {
  1047. $s++;
  1048. }
  1049. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1050. $q++;
  1051. }
  1052. $details[$v['details']] = $v['details'];
  1053. if ($v['cpid'] != 0) {
  1054. $cpid[$v['cpid']] = $v['cpid'];
  1055. }
  1056. if ($v['cpbz'] != '') {
  1057. $cpbz[$v['cpbz']] = $v['cpbz'];
  1058. }
  1059. }
  1060. $rows[$key]['details'] = implode("、", $details);
  1061. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1062. $number = $value['number'];
  1063. $ftime = time() - 15 * 24 * 3600;
  1064. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1065. $rows[$key]['number'] = $g;
  1066. $rows[$key]['features'] = $c;
  1067. $rows[$key]['x'] = $x;
  1068. $rows[$key]['t'] = $t;
  1069. $rows[$key]['s'] = $s;
  1070. $rows[$key]['q'] = $q;
  1071. $rows[$key]['wzsl'] = count($details);
  1072. }
  1073. $title = "进销存统计表" . date('Y-m-d', time());
  1074. $titlename = "<table border=1>
  1075. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1076. <tr align='center'>
  1077. <td>仓库</td>
  1078. <td>供应商</td>
  1079. <td>位置</td>
  1080. <td>库存编码</td>
  1081. <td>SKU</td>
  1082. <td>用友编码</td>
  1083. <td>用友料号</td>
  1084. <td>产品英文名</td>
  1085. <td>产品中文名</td>
  1086. <td>入库总量</td>
  1087. <td>库存数量</td>
  1088. <td>销售数量</td>
  1089. <td>退货数量</td>
  1090. <td>删除数量</td>
  1091. <td>其它操作</td>
  1092. <td>位置数量</td>
  1093. </tr>
  1094. </table>";
  1095. $filename = $title . ".xls";
  1096. $tail = "";
  1097. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1098. }
  1099. }
  1100. public function _type()
  1101. {
  1102. $vip = 0;
  1103. if (isset($_SESSION['api'])) {
  1104. $user = $this->user->get_api($_SESSION['api']);
  1105. $fgshop = "";
  1106. $sid = "";
  1107. $usersp = explode('|', trim($user['shop'], '|'));
  1108. foreach ($usersp as $value) {
  1109. $fgshop .= " shop = " . $value . " or";
  1110. $sid .= " id = " . $value . " or";
  1111. }
  1112. if ($user['vip'] == 1) {
  1113. $vip = 1;
  1114. }
  1115. } else {
  1116. header('Location: /');
  1117. exit;
  1118. }
  1119. $prc = array();
  1120. $purchase = $this->purchase->find_all();
  1121. foreach ($purchase as $k => $v) {
  1122. $prc[$v['id']] = $v['title'];
  1123. }
  1124. $company = array();
  1125. $ct = $this->company->find_all();
  1126. foreach ($ct as $k => $v) {
  1127. $company[$v['id']] = $v['title'];
  1128. }
  1129. $sp = array();
  1130. $s = $this->shop->find_all('1=1', 'id,shopname');
  1131. foreach ($s as $v) {
  1132. $sp[$v['id']] = $v['shopname'];
  1133. }
  1134. $wh = array();
  1135. $w = $this->warehouse->find_all('1=1', 'id,title');
  1136. foreach ($w as $v) {
  1137. $wh[$v['id']] = $v['title'];
  1138. }
  1139. $post = $this->input->post(NULL, TRUE);
  1140. if (isset($post['page'])) {
  1141. $page = $this->input->post('page', true);
  1142. $perpage = $this->input->post('perpage', true);
  1143. $category = $this->input->post('category', true);
  1144. $size = $this->input->post('size', true);
  1145. $grade = $this->input->post('grade', true);
  1146. $color = $this->input->post('color', true);
  1147. $lowe = $this->input->post('lowe', true);
  1148. $sku = $this->input->post('sku');
  1149. $title = $this->input->post('title');
  1150. $warehouse = $this->input->post('warehouse', true);
  1151. $usa = $this->input->post('usa', true);
  1152. $purchase = $this->input->post('purchase', true);
  1153. $lacetype = $this->input->post('lacetype', true);
  1154. $haircap = $this->input->post('haircap', true);
  1155. $density = $this->input->post('density', true);
  1156. $details = $this->input->post('details', true);
  1157. $state = $this->input->post('state', true);
  1158. $shop = $this->input->post('shop', true);
  1159. $lacecolor = $this->input->post('lacecolor', true);
  1160. $hairnumber = $this->input->post('hairnumber', true);
  1161. $type = $this->input->post('type', true);
  1162. $ktime = $this->input->post('ktime', true);
  1163. $jtime = $this->input->post('jtime', true);
  1164. $ktime = strtotime($ktime);
  1165. $jtime = strtotime($jtime);
  1166. $cpbz = $this->input->post('cpbz', true);
  1167. $sm = $this->input->post('sm', true);
  1168. $where = "1=1";
  1169. $gj = "";
  1170. $ck = "";
  1171. if ($usa) {
  1172. if (!$warehouse) {
  1173. $where .= " and (warehouse = '5' or warehouse = '8')";
  1174. }
  1175. }
  1176. if ($warehouse) {
  1177. $where .= " and warehouse = '$warehouse'";
  1178. }
  1179. if ($details) {
  1180. $where .= " and details = '$details'";
  1181. }
  1182. if ($purchase) {
  1183. $where .= " and purchase = '$purchase'";
  1184. }
  1185. if ($state) {
  1186. $where .= " and state = '$state'";
  1187. }
  1188. if ($shop) {
  1189. $where .= " and shop like '%$shop%'";
  1190. }
  1191. if ($type) {
  1192. $where .= " and type = '$type'";
  1193. }
  1194. if ($ktime && $jtime) {
  1195. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1196. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1197. }
  1198. if ($cpbz) {
  1199. $where .= " and cpbz like '%$cpbz%' ";
  1200. }
  1201. if ($sm) {
  1202. $where .= " and sm like '%$sm%' ";
  1203. }
  1204. if ($lacecolor) {
  1205. $where .= " and features like '%-$lacecolor-%'";
  1206. }
  1207. if ($lacetype) {
  1208. $where .= " and features like '%-$lacetype-%'";
  1209. }
  1210. if ($category) {
  1211. $where .= " and features like '%-$category-%'";
  1212. }
  1213. if ($size) {
  1214. $where .= " and features like '%-$size-%'";
  1215. }
  1216. if ($grade) {
  1217. $where .= " and features like '%-$grade-%'";
  1218. }
  1219. if ($color) {
  1220. $where .= " and features like '%-$color-%'";
  1221. }
  1222. if ($lowe) {
  1223. $where .= " and features like '%-$lowe-%'";
  1224. }
  1225. if ($haircap) {
  1226. $where .= " and features like '%-$haircap-%'";
  1227. }
  1228. if ($density) {
  1229. $where .= " and features like '%-$density-%'";
  1230. }
  1231. if (!empty($hairnumber)) {
  1232. $where .= " and features like '%-128-%' ";
  1233. if ($hairnumber < 0) {
  1234. $class_list = $this->typeclass->find_all('classid = 43');
  1235. foreach ($class_list as $v) {
  1236. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1237. }
  1238. } else {
  1239. $where .= " and features like '%-$hairnumber-%'";
  1240. }
  1241. }
  1242. //数据排序
  1243. $order_str = "id desc";
  1244. if (empty($page)) {
  1245. $start = 0;
  1246. $perpage = 1;
  1247. } else {
  1248. $start = ($page - 1) * $perpage;
  1249. }
  1250. $fjnr = '';
  1251. if ($sku) {
  1252. $sku = trim($sku, ' ');
  1253. $sku = trim($sku, ' ');
  1254. $fjnr .= " and sku like '%$sku%'";
  1255. }
  1256. if ($title) {
  1257. $title = trim($title, ' ');
  1258. $title = trim($title, ' ');
  1259. $fjnr .= " and title like '%$title%'";
  1260. }
  1261. $wt = array();
  1262. $whlabel_type = $this->whlabel_type->find_all();
  1263. foreach ($whlabel_type as $v) {
  1264. $wt[$v['id']] = $v['title'];
  1265. }
  1266. //$where .= " and time > '$ktime' and time < '$jtime'";
  1267. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,type,features,number,sm', $order_str, $start, $perpage); //改这需要修改_gbhtype
  1268. //取得信息列表
  1269. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1270. $rows = array();
  1271. $list = array();
  1272. foreach ($info_list as $key => $value) {
  1273. if (isset($wt[$value['type']])) {
  1274. $info_list[$key]['type'] = $wt[$value['type']];
  1275. } else {
  1276. $info_list[$key]['type'] = '未设置';
  1277. }
  1278. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1279. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1280. $ztdata = '';
  1281. if (count($zt) > 0) {
  1282. foreach ($zt as $vv) {
  1283. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1284. }
  1285. }
  1286. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1287. $cdata = array_filter($qbdata, function ($item) {
  1288. return $item['state'] < 1;
  1289. });
  1290. $c = array_sum(array_column($cdata, 'jnum'));
  1291. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1292. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1293. });
  1294. $g = array_sum(array_column($gdata, 'jnum'));
  1295. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1296. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1297. });
  1298. $x = array_sum(array_column($xdata, 'jnum'));
  1299. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1300. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1301. });
  1302. $t = array_sum(array_column($tdata, 'jnum'));
  1303. $zdata = array_filter($qbdata, function ($item) {
  1304. return $item['zd'] != "" && $item['state'] < 1;
  1305. });
  1306. $z = array_sum(array_column($zdata, 'jnum'));
  1307. $zdata = array_filter($qbdata, function ($item) {
  1308. return $item['zd'] != "" && $item['state'] < 1;
  1309. });
  1310. $z = array_sum(array_column($zdata, 'jnum'));
  1311. //$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');
  1312. //$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'].'"');
  1313. //$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'].'"');
  1314. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1315. //$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'].'"');
  1316. $details = array();
  1317. $cpid = array();
  1318. $od = array();
  1319. $odid = '';
  1320. $companytitle = '';
  1321. $shop_list = [];
  1322. foreach ($qbdata as $v) {
  1323. if ($v['zd'] != "" && $v['state'] < 1) {
  1324. if (!isset($od[$v['zd']])) {
  1325. $od[$v['zd']] = 1; //所有数据sku
  1326. } else {
  1327. $od[$v['zd']] = $od[$v['zd']] + 1;
  1328. }
  1329. }
  1330. if ($v['state'] < 1) {
  1331. $details[$v['details']] = $v['details'];
  1332. if ($v['cpid'] != 0) {
  1333. $cpid[$v['cpid']] = $v['cpid'];
  1334. }
  1335. }
  1336. if($v['state'] == 0){
  1337. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1338. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1339. }
  1340. if ($v['shop'] != '') {
  1341. $shop = explode(',', trim($v['shop'], ','));
  1342. foreach ($shop as $vv) {
  1343. if (!in_array($vv, $shop_list)) {
  1344. $shop_list[] = $vv;
  1345. }
  1346. }
  1347. }
  1348. }
  1349. }
  1350. foreach ($od as $k => $vv) {
  1351. $odid .= $k . '数量' . $vv;
  1352. }
  1353. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1354. $info_list[$key]['label'] = $value['sm'];
  1355. $number = $value['number'];
  1356. $ftime = time() - 15 * 24 * 3600;
  1357. $z = $z . '(' . $odid . ')'; //查看订单号
  1358. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1359. $info_list[$key]['features'] = $c;
  1360. $info_list[$key]['number'] = $ztdata;
  1361. $info_list[$key]['sm'] = $g;
  1362. $info_list[$key]['x'] = $x;
  1363. $info_list[$key]['t'] = $t;
  1364. $info_list[$key]['z'] = $z;
  1365. /**
  1366. foreach ($cdata as $k=>$v)
  1367. {
  1368. $details[$v['details']] = $v['details'];
  1369. if($v['cpid'] != 0)
  1370. {
  1371. $cpid[$v['cpid']] = $v['cpid'];
  1372. }
  1373. }
  1374. **/
  1375. $info_list[$key]['shop'] = '';
  1376. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1377. // if ($value['shop'] != '') {
  1378. // $shop = explode(',', trim($value['shop'], ','));
  1379. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1380. // }
  1381. $shop_list = array_unique($shop_list);
  1382. $shop_str = '';
  1383. foreach ($shop_list as $v) {
  1384. if(isset($sp[$v])){
  1385. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1386. }
  1387. }
  1388. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1389. /**
  1390. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1391. if(isset($companytitle[0]))
  1392. {
  1393. foreach ($companytitle as $k=>$v)
  1394. {
  1395. if($v['companytitle'] != '')
  1396. {
  1397. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1398. }
  1399. }
  1400. }
  1401. **/
  1402. }
  1403. $final_all_list = [];
  1404. foreach ($info_list as $k => $v) {
  1405. $final_all_list[] = [
  1406. 'id' => $v['id'],
  1407. "warehouse" => $v["warehouse"],
  1408. "purchase" => $v["purchase"],
  1409. "sku" => $v["sku"],
  1410. "title" => $v["title"] . "<br/>" . $v["pm"],
  1411. "details" => $v["details"],
  1412. "shop" => $v["shop"],
  1413. "cpbz" => $v["cpbz"],
  1414. 'label' => $v['label'],
  1415. "type" => $v["type"],
  1416. "features" => $v["features"],
  1417. "number" => $v["number"],
  1418. "sm" => $v["sm"],
  1419. "x" => $v["x"],
  1420. "t" => $v["t"],
  1421. "z" => $v["z"]
  1422. ];
  1423. }
  1424. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1425. $pagenum = ceil($total / $perpage);
  1426. $over = $total - ($start + $perpage);
  1427. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1428. echo json_encode($rows);
  1429. exit;
  1430. }
  1431. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1432. $this->data['shop'] = $wlshop;
  1433. $this->data['vip'] = $vip;
  1434. $this->_Template('whlabel_type', $this->data);
  1435. }
  1436. //美仓进销存浏览
  1437. public function _usatype()
  1438. {
  1439. if (isset($_SESSION['api'])) {
  1440. $user = $this->user->get_api($_SESSION['api']);
  1441. $usp = $user;
  1442. $fgshop = "";
  1443. $sid = "";
  1444. $wid = "";
  1445. $wtype = "";
  1446. $userwh = explode('|', trim($user['warehouse'], '|'));
  1447. foreach ($userwh as $value) {
  1448. $wid .= " id = " . $value . " or";
  1449. $wtype .= " type = " . $value . " or";
  1450. }
  1451. }
  1452. $prc = array();
  1453. $purchase = $this->purchase->find_all();
  1454. foreach ($purchase as $k => $v) {
  1455. $prc[$v['id']] = $v['title'];
  1456. }
  1457. $post = $this->input->post(NULL, TRUE);
  1458. if (isset($post['page'])) {
  1459. $page = $this->input->post('page', true);
  1460. $perpage = $this->input->post('perpage', true);
  1461. $category = $this->input->post('category', true);
  1462. $size = $this->input->post('size', true);
  1463. $grade = $this->input->post('grade', true);
  1464. $color = $this->input->post('color', true);
  1465. $lowe = $this->input->post('lowe', true);
  1466. $sku = $this->input->post('sku');
  1467. $title = $this->input->post('title');
  1468. $warehouse = $this->input->post('warehouse', true);
  1469. $usa = $this->input->post('usa', true);
  1470. $purchase = $this->input->post('purchase', true);
  1471. $lacetype = $this->input->post('lacetype', true);
  1472. $haircap = $this->input->post('haircap', true);
  1473. $density = $this->input->post('density', true);
  1474. $details = $this->input->post('details', true);
  1475. $state = $this->input->post('state', true);
  1476. $lacecolor = $this->input->post('lacecolor', true);
  1477. $cklx = $this->input->post('cklx', true);
  1478. $ktime = $this->input->post('ktime', true);
  1479. $jtime = $this->input->post('jtime', true);
  1480. $ktime = strtotime($ktime);
  1481. $jtime = strtotime($jtime);
  1482. $where = "1=1";
  1483. $gj = "";
  1484. $ck = "";
  1485. if ($lacetype) {
  1486. $where .= " and features like '%-$lacetype-%'";
  1487. }
  1488. if ($category) {
  1489. $where .= " and features like '%-$category-%'";
  1490. }
  1491. if ($size) {
  1492. $where .= " and features like '%-$size-%'";
  1493. }
  1494. if ($grade) {
  1495. $where .= " and features like '%-$grade-%'";
  1496. }
  1497. if ($color) {
  1498. $where .= " and features like '%-$color-%'";
  1499. }
  1500. if ($lowe) {
  1501. $where .= " and features like '%-$lowe-%'";
  1502. }
  1503. if ($haircap) {
  1504. $where .= " and features like '%-$haircap-%'";
  1505. }
  1506. if ($density) {
  1507. $where .= " and features like '%-$density-%'";
  1508. }
  1509. if ($lacecolor) {
  1510. $where .= " and features like '%-$lacecolor-%'";
  1511. }
  1512. if ($usa) {
  1513. if (!$warehouse) {
  1514. $where .= " and (warehouse = '5' or warehouse = '8')";
  1515. }
  1516. }
  1517. if ($warehouse) {
  1518. $where .= " and warehouse = '$warehouse'";
  1519. }
  1520. if ($details) {
  1521. $where .= " and details = '$details'";
  1522. }
  1523. if ($purchase) {
  1524. $where .= " and purchase = '$purchase'";
  1525. }
  1526. if ($state) {
  1527. $where .= " and state = '$state'";
  1528. }
  1529. $where_add = '';
  1530. if ($cklx) {
  1531. $shop = $this->shop->read($cklx);
  1532. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1533. }
  1534. if ($ktime && $jtime) {
  1535. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1536. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1537. }
  1538. //数据排序
  1539. $order_str = "id desc";
  1540. if (empty($page)) {
  1541. $start = 0;
  1542. $perpage = 1;
  1543. } else {
  1544. $start = ($page - 1) * $perpage;
  1545. }
  1546. if ($sku) {
  1547. $sku = trim($sku, ' ');
  1548. $sku = trim($sku, ' ');
  1549. $where .= " and sku like '%$sku%'";
  1550. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1551. } else if ($title) {
  1552. $title = trim($title, ' ');
  1553. $title = trim($title, ' ');
  1554. $where .= " and title like '%$title%'";
  1555. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1556. } else {
  1557. //$where .= " and time > '$ktime' and time < '$jtime'";
  1558. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1559. }
  1560. //取得信息列表
  1561. $rows = array();
  1562. $list = array();
  1563. foreach ($info_list as $key => $value) {
  1564. $warehouse = $this->warehouse->read($value['warehouse']);
  1565. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1566. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1567. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1568. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1569. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1570. $od = array();
  1571. $odid = '';
  1572. foreach ($z as $v) {
  1573. if (!isset($od[$v['zd']])) {
  1574. $od[$v['zd']] = 1; //所有数据sku
  1575. } else {
  1576. $od[$v['zd']] = $od[$v['zd']] + 1;
  1577. }
  1578. }
  1579. foreach ($od as $k => $vv) {
  1580. $odid .= $k . '数量' . $vv . ' ';
  1581. }
  1582. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1583. $info_list[$key]['features'] = $c;
  1584. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1585. $ztdata = '';
  1586. if (count($zt) > 0) {
  1587. foreach ($zt as $vv) {
  1588. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1589. }
  1590. }
  1591. $info_list[$key]['warehouse'] = $ztdata;
  1592. $info_list[$key]['g'] = $g;
  1593. $info_list[$key]['x'] = $x;
  1594. $info_list[$key]['t'] = $t;
  1595. $info_list[$key]['z'] = $z;
  1596. }
  1597. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1598. $pagenum = ceil($total / $perpage);
  1599. $over = $total - ($start + $perpage);
  1600. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1601. echo json_encode($rows);
  1602. exit;
  1603. }
  1604. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1605. $this->data['warehouse'] = $warehouse;
  1606. $this->_Template('whlabel_typeusa', $this->data);
  1607. }
  1608. //美仓进销存浏览
  1609. public function _usatypeapp()
  1610. {
  1611. $post = $this->input->post(NULL, TRUE);
  1612. if (isset($post['page'])) {
  1613. $page = $this->input->post('page', true);
  1614. $perpage = $this->input->post('perpage', true);
  1615. $sku = $this->input->post('sku', true);
  1616. $warehouse = 5;
  1617. $title = $this->input->post('title', true);
  1618. $state = $this->input->post('state', true);
  1619. $ktime = $this->input->post('ktime', true);
  1620. $jtime = $this->input->post('jtime', true);
  1621. $ktime = strtotime($ktime);
  1622. $jtime = strtotime($jtime);
  1623. $where = "1=1";
  1624. $gj = "";
  1625. $ck = "";
  1626. if ($title) {
  1627. $st = explode(' ', trim($title, ' '));
  1628. foreach ($st as $v) {
  1629. $where .= " and title like '%$v%'";
  1630. }
  1631. }
  1632. if ($warehouse) {
  1633. $where .= " and warehouse = '$warehouse'";
  1634. }
  1635. if ($state) {
  1636. $where .= " and state = '$state'";
  1637. }
  1638. if ($sku) {
  1639. $where .= " and sku like '%$sku%'";
  1640. }
  1641. if ($ktime && $jtime) {
  1642. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1643. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1644. }
  1645. //数据排序
  1646. $order_str = "id desc";
  1647. if (empty($page)) {
  1648. $start = 0;
  1649. $perpage = 1;
  1650. } else {
  1651. $start = ($page - 1) * $perpage;
  1652. }
  1653. //取得信息列表
  1654. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1655. $rows = array();
  1656. $list = array();
  1657. foreach ($info_list as $key => $value) {
  1658. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1659. }
  1660. $rowsdq = array_slice($rows, $start, $perpage);
  1661. foreach ($rowsdq as $value) {
  1662. $warehouse = $this->warehouse->read($value['warehouse']);
  1663. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1664. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1665. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1666. $od = array();
  1667. $odid = '';
  1668. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1669. }
  1670. $total = count($rows);
  1671. $pagenum = ceil($total / $perpage);
  1672. $over = $total - ($start + $perpage);
  1673. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1674. echo json_encode($rows);
  1675. exit;
  1676. }
  1677. $this->_Template('phone/p_usatypeapp', $this->data);
  1678. }
  1679. //入库操作
  1680. public function _enteradd()
  1681. {
  1682. $dt = 0;
  1683. if (isset($_SESSION['api'])) {
  1684. $user = $this->user->get_api($_SESSION['api']);
  1685. $usp = $user;
  1686. $fgshop = "";
  1687. $sid = "";
  1688. $user = explode('|', trim($user['shop'], '|'));
  1689. foreach ($user as $value) {
  1690. $fgshop .= " shop = " . $value . " or";
  1691. $sid .= " id = " . $value . " or";
  1692. }
  1693. }
  1694. $tc = $this->typeclass->find_all();
  1695. $typeclass = array();
  1696. foreach ($tc as $v) {
  1697. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1698. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1699. }
  1700. $post = $this->input->post(NULL, TRUE);
  1701. if (isset($post['sku'])) {
  1702. $list = array();
  1703. $num = "";
  1704. $title = "";
  1705. $features = "";
  1706. $order = $this->input->post('order', true);
  1707. $shop = $this->input->post('shop', true);
  1708. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1709. $sku = $this->input->post('sku', true);
  1710. $post['sm'] = $this->input->post('sm', true);
  1711. $post['warehouse'] = $this->input->post('warehouse', true);
  1712. $post['purchase'] = $this->input->post('purchase', true);
  1713. $post['retreatwarehouse'] = $post['warehouse'];
  1714. $post['state'] = $this->input->post('state', true);
  1715. $post['rktype'] = $this->input->post('rktype', true);
  1716. $post['text'] = $this->input->post('text', true);
  1717. $category = $this->input->post('category', true);
  1718. $list['category'] = $category;
  1719. $list['hairtype'] = $this->input->post('hairtype', true);
  1720. $list['grade'] = $this->input->post('grade', true);
  1721. $size = $this->input->post('size', true);
  1722. $xzsku = $this->input->post('xzsku', true);
  1723. $list['size'] = rtrim($size, ',');
  1724. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1725. $list['extension'] = $this->input->post('extension', true);
  1726. if ($category == 1297) {
  1727. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1728. }
  1729. if ($category == 1702) {
  1730. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1731. $list['syother'] = $this->input->post('syother', true);
  1732. }
  1733. if ($category == 133) {
  1734. $list['fittype'] = $this->input->post('fittype', true);
  1735. $list['acother'] = $this->input->post('acother', true);
  1736. }
  1737. $list['color'] = $this->input->post('color', true);
  1738. $list['lowe'] = $this->input->post('lowe', true);
  1739. if (!$post['purchase']) {
  1740. $post['purchase'] = 1;
  1741. }
  1742. if ($category == 127) {
  1743. $list['type'] = $this->input->post('type', true);
  1744. $list['headroad'] = $this->input->post('headroad', true);
  1745. $list['density'] = $this->input->post('density', true);
  1746. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1747. $list['lacesize'] = $this->input->post('lacesize', true);
  1748. }
  1749. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1750. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1751. }
  1752. if ($category == 128) {
  1753. $list['lacetype'] = $this->input->post('lacetype', true);
  1754. $list['haircap'] = $this->input->post('haircap', true);
  1755. $list['density'] = $this->input->post('density', true);
  1756. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1757. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1758. $list['wigother'] = $this->input->post('wigother', true);
  1759. $list['wigother1'] = $this->input->post('wigother1', true);
  1760. $list['wigother2'] = $this->input->post('wigother2', true);
  1761. }
  1762. if ($category == 129) {
  1763. $list['wide'] = $this->input->post('wide', true);
  1764. }
  1765. if ($category == 131) {
  1766. $list['gifttype'] = $this->input->post('gifttype', true);
  1767. $list['giftother'] = $this->input->post('giftother', true);
  1768. }
  1769. if ($category == 134) {
  1770. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1771. }
  1772. if ($category == 1297) {
  1773. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1774. $list['sywigother'] = $this->input->post('sywigother', true);
  1775. }
  1776. if ($category == 130 || $category == 133 || $category == 1702) {
  1777. $list['items'] = $this->input->post('items', true);
  1778. $list['weight'] = $this->input->post('weight', true);
  1779. }
  1780. if ($category == 1702) {
  1781. $list['syhairther'] = $this->input->post('syhairther', true);
  1782. }
  1783. $classid = $this->classid->sku();
  1784. $scsku = $classid;
  1785. $pm = $classid;
  1786. foreach ($list as $k => $v) {
  1787. if ($v != 0) {
  1788. $num .= $v;
  1789. $features .= $v . '-';
  1790. $post[$k] = $v;
  1791. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1792. if ($k != 'size') {
  1793. $title .= $typeclass[$v]['title'] . " ";
  1794. }
  1795. if (isset($pm[$typeclass[$v]['classid']])) {
  1796. if ($typeclass[$v]['title'] == '9A') {
  1797. $pm[$typeclass[$v]['classid']] = '9A';
  1798. } else if ($typeclass[$v]['title'] == '10A') {
  1799. $pm[$typeclass[$v]['classid']] = '10A';
  1800. } else {
  1801. $clzh = $typeclass[$v]['zh'];
  1802. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1803. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1804. $clzh = $clzh[0];
  1805. }
  1806. $pm[$typeclass[$v]['classid']] = $clzh;
  1807. }
  1808. }
  1809. }
  1810. }
  1811. $zh = implode(" ", $pm);
  1812. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1813. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1814. if ($list['size']) {
  1815. $typeclass = $this->typeclass->read($list['size']);
  1816. $title .= $typeclass['title'];
  1817. }
  1818. $time = time();
  1819. if ($xzsku) {
  1820. $scsku = implode("-", $scsku);
  1821. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1822. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1823. $post['sku'] = trim($scsku, ' ');
  1824. } else {
  1825. $post['sku'] = $sku;
  1826. }
  1827. //$post['sku'] = trim($sku,' ');
  1828. $post['title'] = rtrim($title, ' ');
  1829. $post['number'] = $num;
  1830. $post['features'] = '-' . $features;
  1831. $post['enter'] = $time;
  1832. $post['time'] = $time; //操作时间
  1833. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1834. if ($yza) {
  1835. if ($post['features'] != $yza[0]['features']) {
  1836. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1837. exit;
  1838. }
  1839. }
  1840. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1841. if ($yzb) {
  1842. if ($post['sku'] != $yzb[0]['sku']) {
  1843. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1844. exit;
  1845. }
  1846. }
  1847. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1848. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1849. exit;
  1850. }
  1851. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1852. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1853. exit;
  1854. }
  1855. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1856. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1857. exit;
  1858. }
  1859. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1860. if (isset($yz[0]['type'])) {
  1861. $post['type'] = $yz[0]['type'];
  1862. }
  1863. if ($post['state'] == 9) //如果选择预设库存
  1864. {
  1865. $this->whlabel->insert($post);
  1866. } else {
  1867. /**
  1868. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1869. if($ljg == 1)
  1870. {
  1871. for($i=0;$i<$order;$i++)
  1872. {
  1873. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1874. $this->whlabel->insert($post);
  1875. }
  1876. }
  1877. **/
  1878. //if($post['warehouse'] == '5')
  1879. //{
  1880. //}
  1881. $yydata = $post;
  1882. $yydata['zh'] = $zh;
  1883. /**
  1884. $wl = $this->apiyy->get_cjlp($yydata);
  1885. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1886. {
  1887. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1888. }
  1889. if($wl['Data'][0]['m_isSucess'] != 1)
  1890. {
  1891. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1892. }
  1893. **/
  1894. for ($i = 0; $i < $order; $i++) {
  1895. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1896. $this->whlabel->insert($post);
  1897. }
  1898. }
  1899. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1900. exit;
  1901. }
  1902. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1903. $this->data['wlshop'] = $wlshop;
  1904. $this->_Template('whlabel_enteradd', $this->data);
  1905. }
  1906. //修改产品
  1907. public function _enteredit($arg_array)
  1908. {
  1909. $dt = 0;
  1910. if (isset($_SESSION['api'])) {
  1911. $user = $this->user->get_api($_SESSION['api']);
  1912. $usp = $user;
  1913. $fgshop = "";
  1914. $sid = "";
  1915. $user = explode('|', trim($user['shop'], '|'));
  1916. foreach ($user as $value) {
  1917. $fgshop .= " shop = " . $value . " or";
  1918. $sid .= " id = " . $value . " or";
  1919. }
  1920. }
  1921. $post = $this->input->post(NULL, TRUE);
  1922. if (isset($post['sku'])) {
  1923. $list = array();
  1924. $num = "";
  1925. $title = "";
  1926. $features = "";
  1927. $id = $this->input->post('id', true);
  1928. $order = $this->input->post('order', true);
  1929. $shop = $this->input->post('shop', true);
  1930. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1931. $post['sku'] = $this->input->post('sku', true);
  1932. $post['sm'] = $this->input->post('sm', true);
  1933. $post['warehouse'] = $this->input->post('warehouse', true);
  1934. $post['purchase'] = $this->input->post('purchase', true);
  1935. $post['retreatwarehouse'] = $post['warehouse'];
  1936. $category = $this->input->post('category', true);
  1937. $list['category'] = $category;
  1938. $list['hairtype'] = $this->input->post('hairtype', true);
  1939. $list['grade'] = $this->input->post('grade', true);
  1940. $size = $this->input->post('size', true);
  1941. $list['size'] = rtrim($size, ',');
  1942. $post['rktype'] = $this->input->post('rktype', true);
  1943. $post['text'] = $this->input->post('text', true);
  1944. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1945. $list['extension'] = $this->input->post('extension', true);
  1946. if ($category == 1297) {
  1947. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1948. }
  1949. if ($category == 1702) {
  1950. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1951. $list['syother'] = $this->input->post('syother', true);
  1952. }
  1953. if ($category == 133) {
  1954. $list['fittype'] = $this->input->post('fittype', true);
  1955. $list['acother'] = $this->input->post('acother', true);
  1956. }
  1957. $list['color'] = $this->input->post('color', true);
  1958. $list['lowe'] = $this->input->post('lowe', true);
  1959. if (!$post['purchase']) {
  1960. $post['purchase'] = 1;
  1961. }
  1962. if ($category == 127) {
  1963. $list['type'] = $this->input->post('type', true);
  1964. $list['headroad'] = $this->input->post('headroad', true);
  1965. $list['density'] = $this->input->post('density', true);
  1966. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1967. $list['lacesize'] = $this->input->post('lacesize', true);
  1968. }
  1969. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1970. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1971. }
  1972. if ($category == 128) {
  1973. $list['lacetype'] = $this->input->post('lacetype', true);
  1974. $list['haircap'] = $this->input->post('haircap', true);
  1975. $list['density'] = $this->input->post('density', true);
  1976. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1977. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1978. $list['wigother'] = $this->input->post('wigother', true);
  1979. $list['wigother1'] = $this->input->post('wigother1', true);
  1980. $list['wigother2'] = $this->input->post('wigother2', true);
  1981. }
  1982. if ($category == 129) {
  1983. $list['wide'] = $this->input->post('wide', true);
  1984. }
  1985. if ($category == 131) {
  1986. $list['gifttype'] = $this->input->post('gifttype', true);
  1987. $list['giftother'] = $this->input->post('giftother', true);
  1988. }
  1989. if ($category == 134) {
  1990. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1991. }
  1992. if ($category == 1297) {
  1993. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1994. $list['sywigother'] = $this->input->post('sywigother', true);
  1995. }
  1996. if ($category == 130 || $category == 133 || $category == 1702) {
  1997. $list['items'] = $this->input->post('items', true);
  1998. $list['weight'] = $this->input->post('weight', true);
  1999. }
  2000. if ($category == 1702) {
  2001. $list['syhairther'] = $this->input->post('syhairther', true);
  2002. }
  2003. foreach ($list as $k => $v) {
  2004. if ($v != 0) {
  2005. $num .= $v;
  2006. $features .= $v . '-';
  2007. $typeclass = $this->typeclass->read($v);
  2008. if ($k != 'size') {
  2009. $title .= $typeclass['title'] . " ";
  2010. }
  2011. }
  2012. }
  2013. $typeclass = $this->typeclass->read($list['size']);
  2014. $title .= $typeclass['title'];
  2015. $time = time();
  2016. $post['title'] = rtrim($title, ' ');
  2017. $post['number'] = $num;
  2018. $post['features'] = '-' . $features;
  2019. $post['time'] = $time; //操作时间
  2020. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2021. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2022. exit;
  2023. }
  2024. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2025. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2026. exit;
  2027. }
  2028. $uid = $this->whlabel->read($id);
  2029. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2030. if ($datanum > 0) {
  2031. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2032. exit;
  2033. }
  2034. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2035. {
  2036. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2037. if ($yza) {
  2038. if ($post['features'] != $yza[0]['features']) {
  2039. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2040. exit;
  2041. }
  2042. }
  2043. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2044. if ($yzb) {
  2045. if ($post['sku'] != $yzb[0]['sku']) {
  2046. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2047. exit;
  2048. }
  2049. }
  2050. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2051. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2052. exit;
  2053. }
  2054. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2055. foreach ($data as $v) {
  2056. $post['id'] = $v['id'];
  2057. $this->whlabel->save($post, $v['id']);
  2058. }
  2059. } else {
  2060. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2061. if ($data > 0) {
  2062. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2063. exit;
  2064. } else {
  2065. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2066. foreach ($data as $v) {
  2067. $post['id'] = $v['id'];
  2068. $this->whlabel->save($post, $v['id']);
  2069. }
  2070. }
  2071. }
  2072. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2073. exit;
  2074. }
  2075. $uid = $this->whlabel->read($arg_array[0]);
  2076. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2077. $this->data['enter'] = $uid;
  2078. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2079. $this->data['wlshop'] = $wlshop;
  2080. $this->_Template('whlabel_enteredit', $this->data);
  2081. }
  2082. //入库浏览
  2083. public function _enter()
  2084. {
  2085. $post = $this->input->post(NULL, TRUE);
  2086. if (isset($post['s'])) {
  2087. $id_arr = $this->input->post('s');
  2088. $id_arr = explode(',', $id_arr);
  2089. if (!$id_arr) {
  2090. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2091. exit;
  2092. }
  2093. //循环删除记录
  2094. foreach ($id_arr as $v) {
  2095. $sid = $this->whlabel->read($v);
  2096. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2097. if ($count > 0) {
  2098. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2099. exit;
  2100. }
  2101. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2102. foreach ($info_list as $va) {
  2103. $this->whlabel->remove($va['id']);
  2104. }
  2105. }
  2106. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2107. exit;
  2108. }
  2109. $sp = array();
  2110. $s = $this->shop->find_all('1=1', 'id,shopname');
  2111. foreach ($s as $v) {
  2112. $sp[$v['id']] = $v['shopname'];
  2113. }
  2114. $wh = array();
  2115. $w = $this->warehouse->find_all('1=1', 'id,title');
  2116. foreach ($w as $v) {
  2117. $wh[$v['id']] = $v['title'];
  2118. }
  2119. if (isset($post['page'])) {
  2120. $page = $this->input->post('page', true);
  2121. $perpage = $this->input->post('perpage', true);
  2122. $category = $this->input->post('category', true);
  2123. $size = $this->input->post('size', true);
  2124. $grade = $this->input->post('grade', true);
  2125. $color = $this->input->post('color', true);
  2126. $lowe = $this->input->post('lowe', true);
  2127. $sku = $this->input->post('sku', true);
  2128. $warehouse = $this->input->post('warehouse', true);
  2129. $purchase = $this->input->post('purchase', true);
  2130. $ktime = $this->input->post('ktime', true);
  2131. $jtime = $this->input->post('jtime', true);
  2132. $ktime = strtotime($ktime);
  2133. $jtime = strtotime($jtime);
  2134. $where = "1=1";
  2135. $gj = "";
  2136. $ck = "";
  2137. if ($category) {
  2138. $where .= " and features like '%-$category-%'";
  2139. }
  2140. if ($size) {
  2141. $where .= " and features like '%-$size-%'";
  2142. }
  2143. if ($grade) {
  2144. $where .= " and features like '%-$grade-%'";
  2145. }
  2146. if ($color) {
  2147. $where .= " and features like '%-$color-%'";
  2148. }
  2149. if ($lowe) {
  2150. $where .= " and features like '%-$lowe-%'";
  2151. }
  2152. if ($warehouse) {
  2153. $where .= " and warehouse = '$warehouse'";
  2154. }
  2155. if ($purchase) {
  2156. $where .= " and purchase = '$purchase'";
  2157. }
  2158. if ($sku) {
  2159. $where .= " and sku like '%$sku%'";
  2160. }
  2161. if ($ktime && $jtime) {
  2162. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2163. }
  2164. //数据排序
  2165. $order_str = "enter desc";
  2166. if (empty($page)) {
  2167. $start = 0;
  2168. $perpage = 1;
  2169. } else {
  2170. $start = ($page - 1) * $perpage;
  2171. }
  2172. //取得信息列表
  2173. $info_list = $this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2174. foreach ($info_list as $k => $v) {
  2175. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2176. if ($v['shop'] == '') {
  2177. $s = '通用';
  2178. } else {
  2179. $info_list[$k]['shop'] = '';
  2180. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2181. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2182. }
  2183. }
  2184. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2185. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2186. $info_list[$k]['g'] = $g;
  2187. }
  2188. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2189. $total = count($this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,sku,title,features,number'));
  2190. $pagenum = ceil($total / $perpage);
  2191. $over = $total - ($start + $perpage);
  2192. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2193. echo json_encode($rows);
  2194. exit;
  2195. }
  2196. $this->_Template('whlabel_enter', $this->data);
  2197. }
  2198. //出库浏览
  2199. public function _out()
  2200. {
  2201. $post = $this->input->post(NULL, TRUE);
  2202. if (isset($post['page'])) {
  2203. $page = $this->input->post('page', true);
  2204. $perpage = $this->input->post('perpage', true);
  2205. $category = $this->input->post('category', true);
  2206. $size = $this->input->post('size', true);
  2207. $grade = $this->input->post('grade', true);
  2208. $color = $this->input->post('color', true);
  2209. $lowe = $this->input->post('lowe', true);
  2210. $sku = $this->input->post('sku', true);
  2211. $warehouse = $this->input->post('warehouse', true);
  2212. $purchase = $this->input->post('purchase', true);
  2213. $state = $this->input->post('state', true);
  2214. $ktime = $this->input->post('ktime', true);
  2215. $jtime = $this->input->post('jtime', true);
  2216. $ktime = strtotime($ktime);
  2217. $jtime = strtotime($jtime);
  2218. $where = "state=3";
  2219. $gj = "";
  2220. $ck = "";
  2221. if ($category) {
  2222. $where .= " and features like '%-$category-%'";
  2223. }
  2224. if ($size) {
  2225. $where .= " and features like '%-$size-%'";
  2226. }
  2227. if ($grade) {
  2228. $where .= " and features like '%-$grade-%'";
  2229. }
  2230. if ($color) {
  2231. $where .= " and features like '%-$color-%'";
  2232. }
  2233. if ($lowe) {
  2234. $where .= " and features like '%-$lowe-%'";
  2235. }
  2236. if ($state) {
  2237. $where .= " and state = '$state'";
  2238. }
  2239. if ($warehouse) {
  2240. $where .= " and warehouse = '$warehouse'";
  2241. }
  2242. if ($purchase) {
  2243. $where .= " and purchase = '$purchase'";
  2244. }
  2245. if ($sku) {
  2246. $where .= " and sku = '$sku'";
  2247. }
  2248. if ($ktime && $jtime) {
  2249. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2250. }
  2251. //数据排序
  2252. $order_str = "id desc";
  2253. if (empty($page)) {
  2254. $start = 0;
  2255. $perpage = 1;
  2256. } else {
  2257. $start = ($page - 1) * $perpage;
  2258. }
  2259. //取得信息列表
  2260. $info_list = $this->whlabel->find_all($where, 'sku');
  2261. $rows = array();
  2262. $list = array();
  2263. foreach ($info_list as $key => $value) {
  2264. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2265. }
  2266. $rows = array_unique($rows); //删除重复记录
  2267. foreach ($rows as $key => $value) {
  2268. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2269. $ck = $this->warehouse->read($data['warehouse']);
  2270. $warehouse = $ck['title'];
  2271. $gy = $this->purchase->read($data['purchase']);
  2272. $purchase = $gy['purchase'];
  2273. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2274. $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);
  2275. }
  2276. $total = count($list);
  2277. $pagenum = ceil($total / $perpage);
  2278. $over = $total - ($start + $perpage);
  2279. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2280. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2281. echo json_encode($rows);
  2282. exit;
  2283. }
  2284. $this->_Template('whlabel_out', $this->data);
  2285. }
  2286. //出库标签浏览
  2287. public function _label()
  2288. {
  2289. $post = $this->input->post(NULL, TRUE);
  2290. if (isset($post['page'])) {
  2291. $page = $this->input->post('page', true);
  2292. $perpage = $this->input->post('perpage', true);
  2293. $sku = $this->input->post('sku', true);
  2294. $warehouse = $this->input->post('warehouse', true);
  2295. $purchase = $this->input->post('purchase', true);
  2296. $orderinfo = $this->input->post('orderinfo', true);
  2297. $waybill = $this->input->post('waybill', true);
  2298. $category = $this->input->post('category', true);
  2299. $size = $this->input->post('size', true);
  2300. $grade = $this->input->post('grade', true);
  2301. $color = $this->input->post('color', true);
  2302. $lowe = $this->input->post('lowe', true);
  2303. $where = "state=1";
  2304. if ($sku) {
  2305. $where .= " and sku = '$sku'";
  2306. }
  2307. if ($warehouse) {
  2308. $where .= " and warehouse = '$warehouse'";
  2309. }
  2310. if ($purchase) {
  2311. $where .= " and purchase = '$purchase'";
  2312. }
  2313. if ($orderinfo) {
  2314. $where .= " and orderinfo = '$orderinfo'";
  2315. }
  2316. if ($waybill) {
  2317. $where .= " and waybill = '$waybill'";
  2318. }
  2319. if ($category) {
  2320. $where .= " and features like '%-$category-%'";
  2321. }
  2322. if ($size) {
  2323. $where .= " and features like '%-$size-%'";
  2324. }
  2325. if ($grade) {
  2326. $where .= " and features like '%-$grade-%'";
  2327. }
  2328. if ($color) {
  2329. $where .= " and features like '%-$color-%'";
  2330. }
  2331. if ($lowe) {
  2332. $where .= " and features like '%-$lowe-%'";
  2333. }
  2334. //数据排序
  2335. $order_str = "outk desc";
  2336. if (empty($page)) {
  2337. $start = 0;
  2338. $perpage = 1;
  2339. } else {
  2340. $start = ($page - 1) * $perpage;
  2341. }
  2342. //取得信息列表
  2343. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2344. foreach ($info_list as $key => $value) {
  2345. $warehouse = $this->warehouse->read($value['warehouse']);
  2346. $info_list[$key]['warehouse'] = $warehouse['title'];
  2347. $purchase = $this->purchase->read($value['purchase']);
  2348. $info_list[$key]['purchase'] = $purchase['title'];
  2349. if ($value['outk'] != 0) {
  2350. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2351. } else {
  2352. $info_list[$key]['outk'] = "";
  2353. }
  2354. if ($value['orderinfo'] == 0) {
  2355. $info_list[$key]['orderinfo'] = "";
  2356. }
  2357. if ($value['waybill'] == 0) {
  2358. $info_list[$key]['waybill'] = "";
  2359. }
  2360. }
  2361. $total = $this->whlabel->find_count($where);
  2362. $pagenum = ceil($total / $perpage);
  2363. $over = $total - ($start + $perpage);
  2364. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2365. echo json_encode($rows);
  2366. exit;
  2367. }
  2368. $this->_Template('whlabel_label', $this->data);
  2369. }
  2370. //独立站出库订单
  2371. public function _outorder()
  2372. {
  2373. if (isset($_SESSION['api'])) {
  2374. $user = $this->user->get_api($_SESSION['api']);
  2375. $usp = $user;
  2376. $fgshop = "";
  2377. $sid = "";
  2378. $user = explode('|', trim($user['shop'], '|'));
  2379. foreach ($user as $value) {
  2380. $fgshop .= " shop = " . $value . " or";
  2381. $sid .= " id = " . $value . " or";
  2382. }
  2383. } else {
  2384. echo "请重新登录";
  2385. }
  2386. $post = $this->input->post(NULL, TRUE);
  2387. if (isset($post['page'])) {
  2388. $page = $this->input->post('page', true);
  2389. $perpage = $this->input->post('perpage', true);
  2390. $warehouse = $this->input->post('warehouse', true);
  2391. $xztime = $this->input->post('xztime', true);
  2392. $timetk = $this->input->post('timetkk', true);
  2393. $timetj = $this->input->post('timetjj', true);
  2394. $shop = $this->input->post('shop', true);
  2395. $source = $this->input->post('source', true);
  2396. $orderinfo = $this->input->post('orderinfo', true);
  2397. $number = $this->input->post('number', true);
  2398. $sfxh = $this->input->post('sfxh', true);
  2399. $express = $this->input->post('express', true);
  2400. $waybill = $this->input->post('waybill', true);
  2401. $library = $this->input->post('library', true);
  2402. $country = $this->input->post('country', true);
  2403. $so = $this->input->post('so', true);
  2404. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2405. $print = $this->input->post('print', true);
  2406. $state = $this->input->post('state', true);
  2407. $orderurl = $this->input->post('orderurl', true);
  2408. $timetk = strtotime($timetk);
  2409. $timetj = strtotime($timetj);
  2410. /**
  2411. $sj = $this->input->post('sj',true);
  2412. if($sj)
  2413. {
  2414. $sj = $this->input->post('sj',true);
  2415. }
  2416. else
  2417. {
  2418. $sj = "fullorder";
  2419. }
  2420. **/
  2421. $sj = "fullorder";
  2422. $where = "1=1";
  2423. if ($warehouse) {
  2424. $where .= " and type = '$warehouse'";
  2425. }
  2426. if ($timetk && $timetj) {
  2427. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2428. }
  2429. if ($orderinfo) {
  2430. $where .= " and orderinfo = '$orderinfo'";
  2431. }
  2432. if ($number) {
  2433. $where .= " and number = '$number'";
  2434. }
  2435. if ($express) {
  2436. $where .= " and express = '$express'";
  2437. }
  2438. if ($waybill) {
  2439. $where .= " and waybill = '$waybill'";
  2440. }
  2441. if ($library) {
  2442. $where .= " and library = '$library'";
  2443. }
  2444. if ($print) {
  2445. $where .= " and print = '$print'";
  2446. }
  2447. if ($libraryconfirm) {
  2448. $where .= " and libraryconfirm = '$libraryconfirm'";
  2449. }
  2450. if ($state) {
  2451. $where .= " and state = '$state'";
  2452. }
  2453. if ($shop) {
  2454. $where .= " and shop = '$shop'";
  2455. }
  2456. if ($country) {
  2457. $where .= " and country = '$country'";
  2458. }
  2459. if ($sfxh != '') {
  2460. $where .= " and sfxh = '$sfxh'";
  2461. }
  2462. if ($so) {
  2463. $where .= " and shipremarks like '%$so%'";
  2464. }
  2465. if ($source) {
  2466. if ($source == '2d') {
  2467. $where .= " and source >= '2'";
  2468. } else {
  2469. $where .= " and source = '$source'";
  2470. }
  2471. }
  2472. if (isset($_SESSION['api'])) {
  2473. foreach ($user as $value) {
  2474. $fgshop .= " shop = " . $value . " or";
  2475. }
  2476. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2477. }
  2478. if ($orderurl) {
  2479. $url = $this->orderurl->read($orderurl);
  2480. $where .= " and link like '%" . $url['url'] . "%'";
  2481. }
  2482. //数据排序
  2483. $order_str = "librarytime desc";
  2484. if (empty($page)) {
  2485. $start = 0;
  2486. $perpage = 1;
  2487. } else {
  2488. $start = ($page - 1) * $perpage;
  2489. }
  2490. //取得信息列表
  2491. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2492. //格式化数据
  2493. foreach ($info_list as $key => $value) {
  2494. $shop = $this->shop->read($value['shop']);
  2495. $info_list[$key]['shop'] = $shop['shopname'];
  2496. $express = $this->express->read($value['express']);
  2497. $info_list[$key]['express'] = $express['servicename'];
  2498. $warehouse = $this->warehouse->read($value['type']);
  2499. $info_list[$key]['type'] = $warehouse['title'];
  2500. if ($value['librarytime'] == '0') {
  2501. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2502. } else {
  2503. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2504. }
  2505. }
  2506. $total = $this->$sj->find_count($where);
  2507. $pagenum = ceil($total / $perpage);
  2508. $over = $total - ($start + $perpage);
  2509. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2510. echo json_encode($rows);
  2511. exit;
  2512. }
  2513. $this->data['express'] = $this->express->find_all();
  2514. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2515. $this->data['wlshop'] = $wlshop;
  2516. $user = $this->user->get_api($_SESSION['api']);
  2517. $powerid = $this->power->read($user['power']);
  2518. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2519. $pid = '';
  2520. foreach ($powertext as $v) {
  2521. $pid .= " id = " . $v . " or";
  2522. }
  2523. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2524. $this->data['fullorderexcel'] = $fullorderexcel;
  2525. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2526. $this->data['orderurl'] = $orderurl;
  2527. $this->_Template('whlabel_outorder', $this->data);
  2528. }
  2529. //tt出库
  2530. public function _toutorder()
  2531. {
  2532. $fgshop = "";
  2533. $sid = "";
  2534. if (isset($_SESSION['api'])) {
  2535. $user = $this->user->get_api($_SESSION['api']);
  2536. $usp = $user;
  2537. $user = explode('|', trim($user['shop'], '|'));
  2538. foreach ($user as $value) {
  2539. $fgshop .= " shop = " . $value . " or";
  2540. $sid .= " id = " . $value . " or";
  2541. }
  2542. } else {
  2543. echo "请重新登录";
  2544. }
  2545. $post = $this->input->post(NULL, TRUE);
  2546. if (isset($post['page'])) {
  2547. $page = $this->input->post('page', true);
  2548. $perpage = $this->input->post('perpage', true);
  2549. $warehouse = $this->input->post('warehouse', true);
  2550. $xztime = $this->input->post('xztime', true);
  2551. $timetk = $this->input->post('timetkk', true);
  2552. $timetj = $this->input->post('timetjj', true);
  2553. $shop = $this->input->post('shop', true);
  2554. $source = $this->input->post('source', true);
  2555. $orderinfo = $this->input->post('orderinfo', true);
  2556. $number = $this->input->post('number', true);
  2557. $sfxh = $this->input->post('sfxh', true);
  2558. $express = $this->input->post('express', true);
  2559. $waybill = $this->input->post('waybill', true);
  2560. $library = $this->input->post('library', true);
  2561. $country = $this->input->post('country', true);
  2562. $so = $this->input->post('so', true);
  2563. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2564. $print = $this->input->post('print', true);
  2565. $state = $this->input->post('state', true);
  2566. $orderurl = $this->input->post('orderurl', true);
  2567. $timetk = strtotime($timetk);
  2568. $timetj = strtotime($timetj);
  2569. /**
  2570. $sj = $this->input->post('sj',true);
  2571. if($sj)
  2572. {
  2573. $sj = $this->input->post('sj',true);
  2574. }
  2575. else
  2576. {
  2577. $sj = "fullorder";
  2578. }
  2579. **/
  2580. $sj = "fullordertt";
  2581. $where = "1=1";
  2582. if ($warehouse) {
  2583. $where .= " and type = '$warehouse'";
  2584. }
  2585. if ($timetk && $timetj) {
  2586. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2587. }
  2588. if ($orderinfo) {
  2589. $where .= " and orderinfo = '$orderinfo'";
  2590. }
  2591. if ($number) {
  2592. $where .= " and number = '$number'";
  2593. }
  2594. if ($express) {
  2595. $where .= " and express = '$express'";
  2596. }
  2597. if ($waybill) {
  2598. $where .= " and waybill = '$waybill'";
  2599. }
  2600. if ($library) {
  2601. $where .= " and library = '$library'";
  2602. }
  2603. if ($print) {
  2604. $where .= " and print = '$print'";
  2605. }
  2606. if ($libraryconfirm) {
  2607. $where .= " and libraryconfirm = '$libraryconfirm'";
  2608. }
  2609. if ($state) {
  2610. $where .= " and state = '$state'";
  2611. }
  2612. if ($shop) {
  2613. $where .= " and shop = '$shop'";
  2614. }
  2615. if ($country) {
  2616. $where .= " and country = '$country'";
  2617. }
  2618. if ($sfxh != '') {
  2619. $where .= " and sfxh = '$sfxh'";
  2620. }
  2621. if ($so) {
  2622. $where .= " and shipremarks like '%$so%'";
  2623. }
  2624. if ($source) {
  2625. if ($source == '2d') {
  2626. $where .= " and source >= '2'";
  2627. } else {
  2628. $where .= " and source = '$source'";
  2629. }
  2630. }
  2631. if (isset($_SESSION['api'])) {
  2632. foreach ($user as $value) {
  2633. $fgshop .= " shop = " . $value . " or";
  2634. }
  2635. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2636. }
  2637. if ($orderurl) {
  2638. $url = $this->orderurl->read($orderurl);
  2639. $where .= " and link like '%" . $url['url'] . "%'";
  2640. }
  2641. //数据排序
  2642. $order_str = "librarytime desc";
  2643. if (empty($page)) {
  2644. $start = 0;
  2645. $perpage = 1;
  2646. } else {
  2647. $start = ($page - 1) * $perpage;
  2648. }
  2649. //取得信息列表
  2650. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2651. //格式化数据
  2652. foreach ($info_list as $key => $value) {
  2653. $shop = $this->shop->read($value['shop']);
  2654. $info_list[$key]['shop'] = $shop['shopname'];
  2655. $express = $this->express->read($value['express']);
  2656. $info_list[$key]['express'] = $express['servicename'];
  2657. $warehouse = $this->warehouse->read($value['type']);
  2658. $info_list[$key]['type'] = $warehouse['title'];
  2659. if ($value['librarytime'] == '0') {
  2660. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2661. } else {
  2662. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2663. }
  2664. }
  2665. $total = $this->$sj->find_count($where);
  2666. $pagenum = ceil($total / $perpage);
  2667. $over = $total - ($start + $perpage);
  2668. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2669. echo json_encode($rows);
  2670. exit;
  2671. }
  2672. $this->data['express'] = $this->express->find_all();
  2673. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2674. $this->data['wlshop'] = $wlshop;
  2675. $user = $this->user->get_api($_SESSION['api']);
  2676. $powerid = $this->power->read($user['power']);
  2677. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2678. $pid = '';
  2679. foreach ($powertext as $v) {
  2680. $pid .= " id = " . $v . " or";
  2681. }
  2682. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2683. $this->data['fullorderexcel'] = $fullorderexcel;
  2684. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2685. $this->data['orderurl'] = $orderurl;
  2686. $this->_Template('whlabel_toutorder', $this->data);
  2687. }
  2688. //tt出库
  2689. public function _aoutorder()
  2690. {
  2691. if (isset($_SESSION['api'])) {
  2692. $user = $this->user->get_api($_SESSION['api']);
  2693. $usp = $user;
  2694. $fgshop = "";
  2695. $sid = "";
  2696. $user = explode('|', trim($user['shop'], '|'));
  2697. foreach ($user as $value) {
  2698. $fgshop .= " shop = " . $value . " or";
  2699. $sid .= " id = " . $value . " or";
  2700. }
  2701. } else {
  2702. echo "请重新登录";
  2703. }
  2704. $post = $this->input->post(NULL, TRUE);
  2705. if (isset($post['page'])) {
  2706. $page = $this->input->post('page', true);
  2707. $perpage = $this->input->post('perpage', true);
  2708. $warehouse = $this->input->post('warehouse', true);
  2709. $xztime = $this->input->post('xztime', true);
  2710. $timetk = $this->input->post('timetkk', true);
  2711. $timetj = $this->input->post('timetjj', true);
  2712. $shop = $this->input->post('shop', true);
  2713. $source = $this->input->post('source', true);
  2714. $orderinfo = $this->input->post('orderinfo', true);
  2715. $number = $this->input->post('number', true);
  2716. $sfxh = $this->input->post('sfxh', true);
  2717. $express = $this->input->post('express', true);
  2718. $waybill = $this->input->post('waybill', true);
  2719. $library = $this->input->post('library', true);
  2720. $country = $this->input->post('country', true);
  2721. $so = $this->input->post('so', true);
  2722. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2723. $print = $this->input->post('print', true);
  2724. $state = $this->input->post('state', true);
  2725. $orderurl = $this->input->post('orderurl', true);
  2726. $timetk = strtotime($timetk);
  2727. $timetj = strtotime($timetj);
  2728. /**
  2729. $sj = $this->input->post('sj',true);
  2730. if($sj)
  2731. {
  2732. $sj = $this->input->post('sj',true);
  2733. }
  2734. else
  2735. {
  2736. $sj = "fullorder";
  2737. }
  2738. **/
  2739. $sj = "fullorderamz";
  2740. $where = "1=1";
  2741. if ($warehouse) {
  2742. $where .= " and type = '$warehouse'";
  2743. }
  2744. if ($timetk && $timetj) {
  2745. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2746. }
  2747. if ($orderinfo) {
  2748. $where .= " and orderinfo = '$orderinfo'";
  2749. }
  2750. if ($number) {
  2751. $where .= " and number = '$number'";
  2752. }
  2753. if ($express) {
  2754. $where .= " and express = '$express'";
  2755. }
  2756. if ($waybill) {
  2757. $where .= " and waybill = '$waybill'";
  2758. }
  2759. if ($library) {
  2760. $where .= " and library = '$library'";
  2761. }
  2762. if ($print) {
  2763. $where .= " and print = '$print'";
  2764. }
  2765. if ($libraryconfirm) {
  2766. $where .= " and libraryconfirm = '$libraryconfirm'";
  2767. }
  2768. if ($state) {
  2769. $where .= " and state = '$state'";
  2770. }
  2771. if ($shop) {
  2772. $where .= " and shop = '$shop'";
  2773. }
  2774. if ($country) {
  2775. $where .= " and country = '$country'";
  2776. }
  2777. if ($sfxh != '') {
  2778. $where .= " and sfxh = '$sfxh'";
  2779. }
  2780. if ($so) {
  2781. $where .= " and shipremarks like '%$so%'";
  2782. }
  2783. if ($source) {
  2784. if ($source == '2d') {
  2785. $where .= " and source >= '2'";
  2786. } else {
  2787. $where .= " and source = '$source'";
  2788. }
  2789. }
  2790. if (isset($_SESSION['api'])) {
  2791. foreach ($user as $value) {
  2792. $fgshop .= " shop = " . $value . " or";
  2793. }
  2794. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2795. }
  2796. if ($orderurl) {
  2797. $url = $this->orderurl->read($orderurl);
  2798. $where .= " and link like '%" . $url['url'] . "%'";
  2799. }
  2800. //数据排序
  2801. $order_str = "librarytime desc";
  2802. if (empty($page)) {
  2803. $start = 0;
  2804. $perpage = 1;
  2805. } else {
  2806. $start = ($page - 1) * $perpage;
  2807. }
  2808. //取得信息列表
  2809. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2810. //格式化数据
  2811. foreach ($info_list as $key => $value) {
  2812. $shop = $this->shop->read($value['shop']);
  2813. $info_list[$key]['shop'] = $shop['shopname'];
  2814. $express = $this->express->read($value['express']);
  2815. $info_list[$key]['express'] = $express['servicename'];
  2816. $warehouse = $this->warehouse->read($value['type']);
  2817. $info_list[$key]['type'] = $warehouse['title'];
  2818. if ($value['librarytime'] == '0') {
  2819. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2820. } else {
  2821. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2822. }
  2823. }
  2824. $total = $this->$sj->find_count($where);
  2825. $pagenum = ceil($total / $perpage);
  2826. $over = $total - ($start + $perpage);
  2827. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2828. echo json_encode($rows);
  2829. exit;
  2830. }
  2831. $this->data['express'] = $this->express->find_all();
  2832. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2833. $this->data['wlshop'] = $wlshop;
  2834. $user = $this->user->get_api($_SESSION['api']);
  2835. $powerid = $this->power->read($user['power']);
  2836. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2837. $pid = '';
  2838. foreach ($powertext as $v) {
  2839. $pid .= " id = " . $v . " or";
  2840. }
  2841. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2842. $this->data['fullorderexcel'] = $fullorderexcel;
  2843. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2844. $this->data['orderurl'] = $orderurl;
  2845. $this->_Template('whlabel_aoutorder', $this->data);
  2846. }
  2847. //速卖通出库订单
  2848. public function _soutorder()
  2849. {
  2850. if (isset($_SESSION['api'])) {
  2851. $user = $this->user->get_api($_SESSION['api']);
  2852. $usp = $user;
  2853. $fgshop = "";
  2854. $sid = "";
  2855. $user = explode('|', trim($user['shop'], '|'));
  2856. foreach ($user as $value) {
  2857. $sid .= " id = " . $value . " or";
  2858. }
  2859. }
  2860. $post = $this->input->post(NULL, TRUE);
  2861. if (isset($post['page'])) {
  2862. $page = $this->input->post('page', true);
  2863. $perpage = $this->input->post('perpage', true);
  2864. $warehouse = $this->input->post('warehouse', true);
  2865. $xztime = $this->input->post('xztime', true);
  2866. $timetk = $this->input->post('timetkk', true);
  2867. $timetj = $this->input->post('timetjj', true);
  2868. $shop = $this->input->post('shop', true);
  2869. $source = $this->input->post('source', true);
  2870. $orderinfo = $this->input->post('orderinfo', true);
  2871. $number = $this->input->post('number', true);
  2872. $express = $this->input->post('express', true);
  2873. $waybill = $this->input->post('waybill', true);
  2874. $library = $this->input->post('library', true);
  2875. $country = $this->input->post('country', true);
  2876. $sfxh = $this->input->post('sfxh', true);
  2877. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2878. $print = $this->input->post('print', true);
  2879. $state = $this->input->post('state', true);
  2880. $so = $this->input->post('so', true);
  2881. $timetk = strtotime($timetk);
  2882. $timetj = strtotime($timetj);
  2883. /**
  2884. $sj = $this->input->post('sj',true);
  2885. if($sj)
  2886. {
  2887. $sj = $this->input->post('sj',true);
  2888. }
  2889. else
  2890. {
  2891. $sj = "fullorder";
  2892. }
  2893. **/
  2894. $sj = "fullordersmt";
  2895. $where = "1=1";
  2896. if ($warehouse) {
  2897. $where .= " and type = '$warehouse'";
  2898. }
  2899. if ($timetk && $timetj) {
  2900. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2901. }
  2902. if ($orderinfo) {
  2903. $where .= " and orderinfo = '$orderinfo'";
  2904. }
  2905. if ($number) {
  2906. $where .= " and number = '$number'";
  2907. }
  2908. if ($express) {
  2909. $where .= " and express = '$express'";
  2910. }
  2911. if ($waybill) {
  2912. $where .= " and waybill = '$waybill'";
  2913. }
  2914. if ($library) {
  2915. $where .= " and library = '$library'";
  2916. }
  2917. if ($print) {
  2918. $where .= " and print = '$print'";
  2919. }
  2920. if ($libraryconfirm) {
  2921. $where .= " and libraryconfirm = '$libraryconfirm'";
  2922. }
  2923. if ($state) {
  2924. $where .= " and state = '$state'";
  2925. }
  2926. if ($shop) {
  2927. $where .= " and shop = '$shop'";
  2928. }
  2929. if ($sfxh != '') {
  2930. $where .= " and sfxh = '$sfxh'";
  2931. }
  2932. if ($so) {
  2933. $where .= " and shipremarks like '%$so%'";
  2934. }
  2935. if ($source) {
  2936. $where .= " and source = '$source'";
  2937. }
  2938. if ($country) {
  2939. $where .= " and country = '$country'";
  2940. } else {
  2941. if (isset($_SESSION['api'])) {
  2942. foreach ($user as $value) {
  2943. $fgshop .= " shop = " . $value . " or";
  2944. }
  2945. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2946. }
  2947. }
  2948. //数据排序
  2949. $order_str = "librarytime desc";
  2950. if (empty($page)) {
  2951. $start = 0;
  2952. $perpage = 1;
  2953. } else {
  2954. $start = ($page - 1) * $perpage;
  2955. }
  2956. //取得信息列表
  2957. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2958. //格式化数据
  2959. foreach ($info_list as $key => $value) {
  2960. $shop = $this->shop->read($value['shop']);
  2961. $info_list[$key]['shop'] = $shop['shopname'];
  2962. $express = $this->express->read($value['express']);
  2963. $info_list[$key]['express'] = $express['servicename'];
  2964. $warehouse = $this->warehouse->read($value['type']);
  2965. $info_list[$key]['type'] = $warehouse['title'];
  2966. if ($value['librarytime'] == '0') {
  2967. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2968. } else {
  2969. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2970. }
  2971. }
  2972. $total = $this->$sj->find_count($where);
  2973. $pagenum = ceil($total / $perpage);
  2974. $over = $total - ($start + $perpage);
  2975. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2976. echo json_encode($rows);
  2977. exit;
  2978. }
  2979. $this->data['express'] = $this->express->find_all();
  2980. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2981. $this->data['wlshop'] = $wlshop;
  2982. $user = $this->user->get_api($_SESSION['api']);
  2983. $powerid = $this->power->read($user['power']);
  2984. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2985. $pid = '';
  2986. foreach ($powertext as $v) {
  2987. $pid .= " id = " . $v . " or";
  2988. }
  2989. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2990. $this->data['fullorderexcel'] = $fullorderexcel;
  2991. $this->_Template('whlabel_soutorder', $this->data);
  2992. }
  2993. //订单退库
  2994. public function _retreat()
  2995. {
  2996. $post = $this->input->post(NULL, TRUE);
  2997. if (isset($post['page'])) {
  2998. $page = $this->input->post('page', true);
  2999. $perpage = $this->input->post('perpage', true);
  3000. $warehouse = $this->input->post('warehouse', true);
  3001. $timetk = $this->input->post('timetk', true);
  3002. $timetj = $this->input->post('timetj', true);
  3003. $shop = $this->input->post('shop', true);
  3004. $source = $this->input->post('source', true);
  3005. $state = $this->input->post('state', true);
  3006. $review = $this->input->post('review', true);
  3007. $state = $this->input->post('state', true);
  3008. $express = $this->input->post('express', true);
  3009. $orderinfo = $this->input->post('orderinfo', true);
  3010. $user = $this->input->post('user', true);
  3011. $name = $this->input->post('name', true);
  3012. $waybill = $this->input->post('waybill', true);
  3013. $timetk = strtotime($timetk);
  3014. $timetj = strtotime($timetj);
  3015. $where = "(state=206 or state=210) and mergeid = 0";
  3016. if ($warehouse) {
  3017. $where .= " and state = '$warehouse'";
  3018. }
  3019. if ($timetk && $timetj) {
  3020. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3021. }
  3022. if ($shop) {
  3023. $where .= " and shop = '$shop'";
  3024. }
  3025. if ($source) {
  3026. $where .= " and source = '$source'";
  3027. }
  3028. if ($state) {
  3029. $where .= " and state = '$state'";
  3030. }
  3031. if ($review) {
  3032. $where .= " and review = '$review'";
  3033. }
  3034. if ($state) {
  3035. $where .= " and state = '$state'";
  3036. }
  3037. if ($express) {
  3038. $where .= " and express = '$express'";
  3039. }
  3040. if ($orderinfo) {
  3041. $where .= " and orderinfo = '$orderinfo'";
  3042. }
  3043. if ($user) {
  3044. $where .= " and user = '$user'";
  3045. }
  3046. if ($name) {
  3047. $where .= " and name = '$name'";
  3048. }
  3049. if ($waybill) {
  3050. $where .= " and waybill = '$waybill'";
  3051. }
  3052. //数据排序
  3053. $order_str = "id desc";
  3054. if (empty($page)) {
  3055. $start = 0;
  3056. $perpage = 1;
  3057. } else {
  3058. $start = ($page - 1) * $perpage;
  3059. }
  3060. //取得信息列表
  3061. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3062. //格式化数据
  3063. foreach ($info_list as $key => $value) {
  3064. $shop = $this->shop->read($value['shop']);
  3065. $info_list[$key]['shop'] = $shop['shopname'];
  3066. $warehouse = $this->warehouse->read($value['warehouse']);
  3067. $info_list[$key]['warehouse'] = $warehouse['title'];
  3068. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3069. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3070. if ($value['waybill'] == 0) {
  3071. $info_list[$key]['waybill'] = "";
  3072. }
  3073. $express = $this->express->read($value['express']);
  3074. $info_list[$key]['express'] = $express['title'];
  3075. $typeclass = $this->typeclass->read($value['state']);
  3076. $info_list[$key]['state'] = $typeclass['title'];
  3077. }
  3078. $total = $this->fullorder->find_count($where);
  3079. $pagenum = ceil($total / $perpage);
  3080. $over = $total - ($start + $perpage);
  3081. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3082. echo json_encode($rows);
  3083. exit;
  3084. }
  3085. $this->data['express'] = $this->express->find_all();
  3086. $this->_Template('whlabel_retreat', $this->data);
  3087. }
  3088. //退库标签浏览
  3089. public function _retreatlk()
  3090. {
  3091. $post = $this->input->post(NULL, TRUE);
  3092. if (isset($post['page'])) {
  3093. $page = $this->input->post('page', true);
  3094. $perpage = $this->input->post('perpage', true);
  3095. $timetk = $this->input->post('timetk', true);
  3096. $timetj = $this->input->post('timetj', true);
  3097. $sku = $this->input->post('sku', true);
  3098. $warehouse = $this->input->post('warehouse', true);
  3099. $purchase = $this->input->post('purchase', true);
  3100. $orderinfo = $this->input->post('orderinfo', true);
  3101. $waybill = $this->input->post('waybill', true);
  3102. $category = $this->input->post('category', true);
  3103. $size = $this->input->post('size', true);
  3104. $grade = $this->input->post('grade', true);
  3105. $color = $this->input->post('color', true);
  3106. $lowe = $this->input->post('lowe', true);
  3107. $state = $this->input->post('state', true);
  3108. $timetk = strtotime($timetk);
  3109. $timetj = strtotime($timetj);
  3110. $where = "state=2";
  3111. if ($timetk && $timetj) {
  3112. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3113. }
  3114. if ($sku) {
  3115. $where .= " and sku = '$sku'";
  3116. }
  3117. if ($warehouse) {
  3118. $where .= " and warehouse = '$warehouse'";
  3119. }
  3120. if ($purchase) {
  3121. $where .= " and purchase = '$purchase'";
  3122. }
  3123. if ($orderinfo) {
  3124. $where .= " and orderinfo = '$orderinfo'";
  3125. }
  3126. if ($waybill) {
  3127. $where .= " and waybill = '$waybill'";
  3128. }
  3129. if ($category) {
  3130. $where .= " and features like '%-$category-%'";
  3131. }
  3132. if ($size) {
  3133. $where .= " and features like '%-$size-%'";
  3134. }
  3135. if ($grade) {
  3136. $where .= " and features like '%-$grade-%'";
  3137. }
  3138. if ($color) {
  3139. $where .= " and features like '%-$color-%'";
  3140. }
  3141. if ($lowe) {
  3142. $where .= " and features like '%-$lowe-%'";
  3143. }
  3144. //数据排序
  3145. $order_str = "time desc";
  3146. if (empty($page)) {
  3147. $start = 0;
  3148. $perpage = 1;
  3149. } else {
  3150. $start = ($page - 1) * $perpage;
  3151. }
  3152. //取得信息列表
  3153. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3154. foreach ($info_list as $key => $value) {
  3155. $warehouse = $this->warehouse->read($value['warehouse']);
  3156. $info_list[$key]['warehouse'] = $warehouse['title'];
  3157. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3158. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3159. $purchase = $this->purchase->read($value['purchase']);
  3160. $info_list[$key]['purchase'] = $purchase['title'];
  3161. if ($value['outk'] != 0) {
  3162. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3163. } else {
  3164. $info_list[$key]['outk'] = "";
  3165. }
  3166. if ($value['retreat'] != 0) {
  3167. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3168. } else {
  3169. $info_list[$key]['retreat'] = "";
  3170. }
  3171. if ($value['orderinfo'] == 0) {
  3172. $info_list[$key]['orderinfo'] = "";
  3173. }
  3174. if ($value['waybill'] == 0) {
  3175. $info_list[$key]['waybill'] = "";
  3176. }
  3177. }
  3178. $total = $this->whlabel->find_count($where);
  3179. $pagenum = ceil($total / $perpage);
  3180. $over = $total - ($start + $perpage);
  3181. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3182. echo json_encode($rows);
  3183. exit;
  3184. }
  3185. $this->_Template('whlabel_retreatlk', $this->data);
  3186. }
  3187. //更换标签及浏览
  3188. public function _change()
  3189. {
  3190. $post = $this->input->post(NULL, TRUE);
  3191. if (isset($post['page'])) {
  3192. $page = $this->input->post('page', true);
  3193. $perpage = $this->input->post('perpage', true);
  3194. $timetk = $this->input->post('timetk', true);
  3195. $timetj = $this->input->post('timetj', true);
  3196. $label = $this->input->post('label', true);
  3197. $oldlabel = $this->input->post('oldlabel', true);
  3198. $timetk = strtotime($timetk);
  3199. $timetj = strtotime($timetj);
  3200. $where = "state=10 ";
  3201. if ($timetk && $timetj) {
  3202. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3203. }
  3204. if ($label) {
  3205. $where .= " and label = '$label'";
  3206. }
  3207. if ($oldlabel) {
  3208. $where .= " and oldlabel = '$oldlabel'";
  3209. }
  3210. //数据排序
  3211. $order_str = "time asc";
  3212. if (empty($page)) {
  3213. $start = 0;
  3214. $perpage = 1;
  3215. } else {
  3216. $start = ($page - 1) * $perpage;
  3217. }
  3218. //取得信息列表
  3219. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3220. foreach ($info_list as $key => $value) {
  3221. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3222. }
  3223. $total = $this->whlabel->find_count($where);
  3224. $pagenum = ceil($total / $perpage);
  3225. $over = $total - ($start + $perpage);
  3226. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3227. echo json_encode($rows);
  3228. exit;
  3229. }
  3230. $this->_Template('whlabel_change', $this->data);
  3231. }
  3232. //产品标签
  3233. public function _cpbqdc()
  3234. {
  3235. if (isset($_GET['excel'])) {
  3236. $where = "1=1";
  3237. //数据排序
  3238. $order_str = "id desc";
  3239. if (empty($page)) {
  3240. $start = 0;
  3241. $perpage = 1;
  3242. } else {
  3243. $start = ($page - 1) * $perpage;
  3244. }
  3245. $warehouse = $this->input->get('warehouse', true);
  3246. $state = $this->input->get('state', true);
  3247. $timetk = $this->input->get('timetkk', true);
  3248. $timetj = $this->input->get('timetjj', true);
  3249. $timetk = strtotime($timetk);
  3250. $timetj = strtotime($timetj);
  3251. if ($warehouse) {
  3252. $where .= " and warehouse = '$warehouse'";
  3253. }
  3254. if ($state || $state == 0) {
  3255. $where .= " and state = '$state'";
  3256. }
  3257. if ($timetk && $timetj) {
  3258. $where .= " and time > '$timetk' and time < '$timetj'";
  3259. }
  3260. //取得信息列表
  3261. $info_list = $this->whlabel->find_all($where, '*');
  3262. $rows = array();
  3263. $list = array();
  3264. foreach ($info_list as $key => $value) {
  3265. $rows[$value['time']] = $value; //所有数据sku
  3266. }
  3267. foreach ($rows as $value) {
  3268. $warehouse = $this->warehouse->read($value['warehouse']);
  3269. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3270. $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);
  3271. }
  3272. $title = "产品标签统计表";
  3273. $titlename = "<table border=1>
  3274. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3275. <tr align='center'>
  3276. <td>仓库</td>
  3277. <td>SKU</td>
  3278. <td>产品</td>
  3279. <td>入库时间</td>
  3280. <td>操作时间</td>
  3281. <td>备注</td>
  3282. <td>数量</td>
  3283. </tr>
  3284. </table>";
  3285. $filename = $title . ".xls";
  3286. $tail = "";
  3287. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3288. }
  3289. }
  3290. //进销存导出
  3291. public function _exceljxc()
  3292. {
  3293. $classid = $this->classid->sku();
  3294. $pm = $classid;
  3295. $typeclass = array();
  3296. $tc = $this->typeclass->find_all();
  3297. foreach ($tc as $v) {
  3298. $typeclass[$v['id']] = $v;
  3299. }
  3300. $prc = array();
  3301. $purchase = $this->purchase->find_all();
  3302. foreach ($purchase as $k => $v) {
  3303. $prc[$v['id']] = $v['title'];
  3304. }
  3305. if (isset($_GET['excel'])) {
  3306. $where = "sku != 'Preset'";
  3307. //数据排序
  3308. $order_str = "id desc";
  3309. if (empty($page)) {
  3310. $start = 0;
  3311. $perpage = 1;
  3312. } else {
  3313. $start = ($page - 1) * $perpage;
  3314. }
  3315. $category = $this->input->get('category', true);
  3316. $warehouse = $this->input->get('warehouse', true);
  3317. $excelid = $this->input->get('sid', true);
  3318. if ($category) {
  3319. $where .= " and features like '%-$category-%'";
  3320. }
  3321. if ($warehouse) {
  3322. $where .= " and warehouse = '$warehouse'";
  3323. }
  3324. $xzid = '';
  3325. if ($excelid) {
  3326. $excelid = explode(',', trim($excelid, ','));
  3327. foreach ($excelid as $key => $value) {
  3328. $xzid .= " id = " . $value . " or";
  3329. }
  3330. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3331. }
  3332. //取得信息列表
  3333. /**
  3334. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3335. $rows = array();$list = array();
  3336. foreach ($info_list as $key=>$value)
  3337. {
  3338. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3339. }
  3340. **/
  3341. $wt = array();
  3342. $whlabel_type = $this->whlabel_type->find_all();
  3343. foreach ($whlabel_type as $v) {
  3344. $wt[$v['id']] = $v['title'];
  3345. }
  3346. $wh = array();
  3347. $w = $this->warehouse->find_all('1=1', 'id,title');
  3348. foreach ($w as $v) {
  3349. $wh[$v['id']] = $v['title'];
  3350. }
  3351. $list = array();
  3352. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3353. foreach ($rows as $key => $value) {
  3354. if (isset($wt[$value['type']])) {
  3355. $rows[$key]['type'] = $wt[$value['type']];
  3356. } else {
  3357. $rows[$key]['type'] = '未设置';
  3358. }
  3359. $bm = '03';
  3360. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3361. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3362. $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');
  3363. $details = array();
  3364. $cpid = array();
  3365. $cpbz = array();
  3366. $c = 0;
  3367. $g = 0;
  3368. $x = 0;
  3369. $t = 0;
  3370. $s = 0;
  3371. $q = 0;
  3372. foreach ($sd as $k => $v) {
  3373. if ($v['state'] == 0) {
  3374. $c++;
  3375. if ($v['cpid'] != 0) {
  3376. $cpid[$v['cpid']] = $v['cpid'];
  3377. }
  3378. if ($v['cpbz'] != '') {
  3379. $cpbz[$v['cpbz']] = $v['cpbz'];
  3380. }
  3381. }
  3382. if ($v['state'] != 9) {
  3383. $g++;
  3384. }
  3385. if ($v['state'] == 1) {
  3386. $x++;
  3387. }
  3388. if ($v['state'] == 2) {
  3389. $t++;
  3390. }
  3391. if ($v['state'] == 8) {
  3392. $s++;
  3393. }
  3394. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3395. $q++;
  3396. }
  3397. $details[$v['details']] = $v['details'];
  3398. }
  3399. $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'] . '"');
  3400. $rows[$key]['details'] = implode("、", $details);
  3401. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3402. $number = $value['number'];
  3403. $ftime = time() - 15 * 24 * 3600;
  3404. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3405. $rows[$key]['number'] = $g;
  3406. $rows[$key]['c'] = $c;
  3407. $rows[$key]['x'] = $x;
  3408. $rows[$key]['t'] = $t;
  3409. $rows[$key]['s'] = $s;
  3410. $rows[$key]['q'] = $q;
  3411. $rows[$key]['z'] = $z;
  3412. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3413. $features = explode('-', trim($features, '-'));
  3414. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3415. // $pm = $classid;
  3416. // $jm = $classid;
  3417. // foreach($features as $k=>$v)
  3418. // {
  3419. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3420. // {
  3421. // if($typeclass[$v]['bm'] != '')
  3422. // {
  3423. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3424. // }
  3425. // }
  3426. // if($v != 0)
  3427. // {
  3428. // if(!isset($typeclass[$v]))
  3429. // {
  3430. // continue;
  3431. // }
  3432. // if(isset($pm[$typeclass[$v]['classid']]))
  3433. // {
  3434. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3435. // {
  3436. // $tz = explode('|',$typeclass[$v]['zh']);
  3437. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3438. // }
  3439. // else
  3440. // {
  3441. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3442. // }
  3443. // }
  3444. // if(isset($jm[$typeclass[$v]['classid']]))
  3445. // {
  3446. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3447. // }
  3448. // }
  3449. // }
  3450. // $jm = array_filter($jm);
  3451. // $rows[$key]['bs'] = implode("-",$jm);
  3452. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3453. // $zh = implode(" ",$pm);
  3454. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3455. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3456. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3457. // $rows[$key]['features'] = $zh;
  3458. }
  3459. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3460. $final_list = [];
  3461. foreach ($list as $k => $v) {
  3462. if (empty($v['sku'])) {
  3463. continue;
  3464. }
  3465. $final_list[] = [
  3466. "warehouse" => $v["warehouse"],
  3467. "purchase" => $v["purchase"],
  3468. "details" => $v["details"],
  3469. "cpid" => $v["cpid"],
  3470. "dbcontent" => $v["dbcontent"],
  3471. "sku" => $v["sku"],
  3472. "cs" => $v["bm"],
  3473. "bs" => $v["jm"],
  3474. "title" => $v["title"],
  3475. "features" => $v["pm"],
  3476. "cpbz" => $v["cpbz"],
  3477. "sm" => $v["sm"],
  3478. "type" => $v["type"],
  3479. "number" => $v["number"],
  3480. "c" => $v["c"],
  3481. "x" => $v["x"],
  3482. "t" => $v["t"],
  3483. "s" => $v["s"],
  3484. "q" => $v["q"],
  3485. "z" => $v["z"],
  3486. "weight" => $v['weight'],
  3487. ];
  3488. }
  3489. $title = "总进销存统计表";
  3490. $titlename = "<table border=1>
  3491. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3492. <tr align='center'>
  3493. <td>仓库</td>
  3494. <td>供应商</td>
  3495. <td>位置</td>
  3496. <td>库存编码</td>
  3497. <td>类目</td>
  3498. <td>SKU</td>
  3499. <td>用友编码</td>
  3500. <td>用友料号</td>
  3501. <td>商品名称</td>
  3502. <td>商品中文</td>
  3503. <td>产品备注</td>
  3504. <td>说明</td>
  3505. <td>类型</td>
  3506. <td>入库总量</td>
  3507. <td>库存数量</td>
  3508. <td>销售数量</td>
  3509. <td>退货数量</td>
  3510. <td>删除数量</td>
  3511. <td>其它操作</td>
  3512. <td>占单数量</td>
  3513. <td>重量(g)</td>
  3514. </tr>
  3515. </table>";
  3516. $filename = $title . ".xls";
  3517. $tail = "";
  3518. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3519. }
  3520. }
  3521. //入库导出
  3522. public function _excelr()
  3523. {
  3524. if (isset($_GET['excel'])) {
  3525. $category = $this->input->get('category', true);
  3526. $size = $this->input->get('size', true);
  3527. $grade = $this->input->get('grade', true);
  3528. $color = $this->input->get('color', true);
  3529. $lowe = $this->input->get('lowe', true);
  3530. $sku = $this->input->get('sku', true);
  3531. $warehouse = $this->input->get('warehouse', true);
  3532. $purchase = $this->input->get('purchase', true);
  3533. $ktime = $this->input->get('ktime', true);
  3534. $jtime = $this->input->get('jtime', true);
  3535. $ktime = strtotime($ktime);
  3536. $jtime = strtotime($jtime);
  3537. $where = "1=1";
  3538. $gj = "";
  3539. $ck = "";
  3540. if ($category) {
  3541. $where .= " and features like '%-$category-%'";
  3542. }
  3543. if ($size) {
  3544. $where .= " and features like '%-$size-%'";
  3545. }
  3546. if ($grade) {
  3547. $where .= " and features like '%-$grade-%'";
  3548. }
  3549. if ($color) {
  3550. $where .= " and features like '%-$color-%'";
  3551. }
  3552. if ($lowe) {
  3553. $where .= " and features like '%-$lowe-%'";
  3554. }
  3555. if ($warehouse) {
  3556. $where .= " and warehouse = '$warehouse'";
  3557. }
  3558. if ($purchase) {
  3559. $where .= " and purchase = '$purchase'";
  3560. }
  3561. if ($sku) {
  3562. $where .= " and sku = '$sku'";
  3563. }
  3564. if ($ktime && $jtime) {
  3565. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3566. }
  3567. //数据排序
  3568. $order_str = "id desc";
  3569. if (empty($page)) {
  3570. $start = 0;
  3571. $perpage = 1;
  3572. } else {
  3573. $start = ($page - 1) * $perpage;
  3574. }
  3575. $list = array();
  3576. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3577. foreach ($rows as $value) {
  3578. $ck = $this->warehouse->read($value['warehouse']);
  3579. $warehouse = $ck['title'];
  3580. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3581. $retreatwarehouse = $tkck['title'];
  3582. $gy = $this->purchase->read($value['purchase']);
  3583. $purchase = $gy['title'];
  3584. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3585. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3586. }
  3587. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3588. $titlename = "<table border=1>
  3589. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3590. <tr align='center'>
  3591. <td>仓库</td>
  3592. <td>SKU</td>
  3593. <td>产品</td>
  3594. <td>时间</td>
  3595. <td>数量</td>
  3596. </tr>
  3597. </table>";
  3598. $filename = $title . ".xls";
  3599. $tail = "";
  3600. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3601. }
  3602. }
  3603. //出库、退库导出
  3604. public function _excelct()
  3605. {
  3606. $classid = $this->classid->sku();
  3607. $pm = $classid;
  3608. $typeclass = array();
  3609. $tc = $this->typeclass->find_all();
  3610. foreach ($tc as $v) {
  3611. $typeclass[$v['id']] = $v;
  3612. }
  3613. $prc = array();
  3614. $purchase = $this->purchase->find_all();
  3615. foreach ($purchase as $k => $v) {
  3616. $prc[$v['id']] = $v['title'];
  3617. }
  3618. if (isset($_GET['excel'])) {
  3619. $wh = array();
  3620. $w = $this->warehouse->find_all('1=1', 'id,title');
  3621. foreach ($w as $v) {
  3622. $wh[$v['id']] = $v['title'];
  3623. }
  3624. $type = $this->input->get('excel', true);
  3625. $category = $this->input->get('category', true);
  3626. $size = $this->input->get('size', true);
  3627. $grade = $this->input->get('grade', true);
  3628. $color = $this->input->get('color', true);
  3629. $lowe = $this->input->get('lowe', true);
  3630. $sku = $this->input->get('sku', true);
  3631. $warehouse = $this->input->get('warehouse', true);
  3632. $lacetype = $this->input->get('lacetype', true);
  3633. $lacecolor = $this->input->get('lacecolor', true);
  3634. $density = $this->input->get('density', true);
  3635. $haircap = $this->input->get('haircap', true);
  3636. $purchase = $this->input->get('purchase', true);
  3637. $title = $this->input->get('title', true);
  3638. $state = $this->input->get('state', true);
  3639. $sid = $this->input->get('sid', true);
  3640. $ktime = $this->input->get('ktime', true);
  3641. $jtime = $this->input->get('jtime', true);
  3642. $ktime = strtotime($ktime);
  3643. $jtime = strtotime($jtime);
  3644. $where = "1=1";
  3645. $gj = "";
  3646. $ck = "";
  3647. if ($category) {
  3648. $where .= " and features like '%-$category-%'";
  3649. }
  3650. if ($size) {
  3651. $where .= " and features like '%-$size-%'";
  3652. }
  3653. if ($grade) {
  3654. $where .= " and features like '%-$grade-%'";
  3655. }
  3656. if ($color) {
  3657. $where .= " and features like '%-$color-%'";
  3658. }
  3659. if ($lowe) {
  3660. $where .= " and features like '%-$lowe-%'";
  3661. }
  3662. if ($warehouse) {
  3663. $where .= " and warehouse = '$warehouse'";
  3664. }
  3665. if ($purchase) {
  3666. $where .= " and purchase = '$purchase'";
  3667. }
  3668. if ($state) {
  3669. $where .= " and state = '$state'";
  3670. }
  3671. if ($lacetype) {
  3672. $where .= " and features like '%-$lacetype-%'";
  3673. }
  3674. if ($lacecolor) {
  3675. $where .= " and features like '%-$lacecolor-%'";
  3676. }
  3677. if ($density) {
  3678. $where .= " and features like '%-$density-%'";
  3679. }
  3680. if ($haircap) {
  3681. $where .= " and features like '%-$haircap-%'";
  3682. }
  3683. if ($title) {
  3684. $title = trim($title, ' ');
  3685. $title = trim($title, ' ');
  3686. $where .= " and title like '%$title%'";
  3687. }
  3688. if ($sku) {
  3689. $sku = trim($sku, ' ');
  3690. $sku = trim($sku, ' ');
  3691. $where .= " and sku like '%$sku%'";
  3692. }
  3693. if ($ktime && $jtime) {
  3694. if ($type == 1) {
  3695. $tl = '出库';
  3696. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3697. } else if ($type == 2) {
  3698. $tl = '退库';
  3699. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3700. } else if ($type == 3) {
  3701. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3702. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3703. } else if ($type == 4) {
  3704. $tl = '出库+零售';
  3705. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3706. } else if ($type == 5) {
  3707. $tl = '零售';
  3708. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3709. }
  3710. }
  3711. $sidwhere = '';
  3712. if ($sid) {
  3713. $sd = "";
  3714. $s = explode(',', trim($sid, ','));
  3715. foreach ($s as $value) {
  3716. $sd .= " id = " . $value . " or";
  3717. }
  3718. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3719. }
  3720. //数据排序
  3721. $order_str = "time desc";
  3722. if (empty($page)) {
  3723. $start = 0;
  3724. $perpage = 1;
  3725. } else {
  3726. $start = ($page - 1) * $perpage;
  3727. }
  3728. //取得信息列表
  3729. if ($type != 3 && $type != 5) {
  3730. if ($type == 1 || $type == 4) {
  3731. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3732. foreach ($info_list as $key => $value) {
  3733. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3734. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3735. $warehouse = $this->warehouse->read($value['warehouse']);
  3736. $info_list[$key]['warehouse'] = $warehouse['title'];
  3737. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3738. $features = explode('-', trim($features, '-'));
  3739. $pm = $classid;
  3740. foreach ($features as $k => $v) {
  3741. if ($v != 0) {
  3742. if (!isset($typeclass[$v])) {
  3743. continue;
  3744. }
  3745. if (isset($pm[$typeclass[$v]['classid']])) {
  3746. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3747. $tz = explode('|', $typeclass[$v]['zh']);
  3748. $pm[$typeclass[$v]['classid']] = $tz[0];
  3749. } else {
  3750. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3751. }
  3752. }
  3753. }
  3754. }
  3755. $zh = implode(" ", $pm);
  3756. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3757. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3758. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3759. $info_list[$key]['features'] = $zh;
  3760. }
  3761. $final_list = [];
  3762. foreach($info_list as $k=>$v){
  3763. $number = "";
  3764. if(!empty($v['orderinfo'])){
  3765. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3766. if(!empty($tmp_info['number'])){
  3767. $number = $tmp_info['number'];
  3768. }
  3769. }
  3770. $final_list[] = [
  3771. 'warehouse'=>$v['warehouse'],
  3772. 'purchase'=>$v['purchase'],
  3773. 'sku'=>$v['sku'],
  3774. 'title'=>$v['title'],
  3775. 'features'=>$v['features'],
  3776. 'label'=>$v['label'],
  3777. 'orderinfo'=>$v['orderinfo'],
  3778. 'number'=>$number,
  3779. 'waybill'=>$v['waybill'],
  3780. 'outk'=>$v['outk'],
  3781. ];
  3782. }
  3783. } else {
  3784. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3785. foreach ($info_list as $key => $value) {
  3786. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3787. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3788. $warehouse = $this->warehouse->read($value['warehouse']);
  3789. $info_list[$key]['warehouse'] = $warehouse['title'];
  3790. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3791. $features = explode('-', trim($features, '-'));
  3792. $pm = $classid;
  3793. foreach ($features as $k => $v) {
  3794. if ($v != 0) {
  3795. if (!isset($typeclass[$v])) {
  3796. continue;
  3797. }
  3798. if (isset($pm[$typeclass[$v]['classid']])) {
  3799. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3800. $tz = explode('|', $typeclass[$v]['zh']);
  3801. $pm[$typeclass[$v]['classid']] = $tz[0];
  3802. } else {
  3803. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3804. }
  3805. }
  3806. }
  3807. }
  3808. $zh = implode(" ", $pm);
  3809. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3810. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3811. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3812. $info_list[$key]['features'] = $zh;
  3813. }
  3814. $final_list = [];
  3815. foreach($info_list as $k=>$v){
  3816. $number = "";
  3817. if(!empty($v['orderinfo'])){
  3818. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3819. if(!empty($tmp_info['number'])){
  3820. $number = $tmp_info['number'];
  3821. }
  3822. }
  3823. $final_list[] = [
  3824. 'warehouse'=>$v['warehouse'],
  3825. 'purchase'=>$v['purchase'],
  3826. 'sku'=>$v['sku'],
  3827. 'title'=>$v['title'],
  3828. 'features'=>$v['features'],
  3829. 'label'=>$v['label'],
  3830. 'orderinfo'=>$v['orderinfo'],
  3831. 'number'=>$number,
  3832. 'waybill'=>$v['waybill'],
  3833. 'retreat'=>$v['retreat'],
  3834. ];
  3835. }
  3836. }
  3837. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3838. $titlename = "<table border=1>
  3839. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3840. <tr align='center'>
  3841. <td>仓库</td>
  3842. <td>供应商</td>
  3843. <td>SKU</td>
  3844. <td>商品名称</td>
  3845. <td>商品中文</td>
  3846. <td>标签</td>
  3847. <td>订单号</td>
  3848. <td>订单编码</td>
  3849. <td>运单号</td>
  3850. <td>" . $tl . "时间(中国时间)</td>
  3851. </tr>
  3852. </table>";
  3853. $filename = $title . ".xls";
  3854. $tail = "";
  3855. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3856. } else if ($type == 5) {
  3857. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3858. foreach ($info_list as $key => $value) {
  3859. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3860. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3861. $warehouse = $this->warehouse->read($value['warehouse']);
  3862. $info_list[$key]['warehouse'] = $warehouse['title'];
  3863. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3864. $features = explode('-', trim($features, '-'));
  3865. $pm = $classid;
  3866. foreach ($features as $k => $v) {
  3867. if ($v != 0) {
  3868. if (!isset($typeclass[$v])) {
  3869. continue;
  3870. }
  3871. if (isset($pm[$typeclass[$v]['classid']])) {
  3872. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3873. $tz = explode('|', $typeclass[$v]['zh']);
  3874. $pm[$typeclass[$v]['classid']] = $tz[0];
  3875. } else {
  3876. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3877. }
  3878. }
  3879. }
  3880. }
  3881. $zh = implode(" ", $pm);
  3882. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3883. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3884. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3885. $info_list[$key]['features'] = $zh;
  3886. }
  3887. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3888. $titlename = "<table border=1>
  3889. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3890. <tr align='center'>
  3891. <td>仓库</td>
  3892. <td>供应商</td>
  3893. <td>SKU</td>
  3894. <td>商品名称</td>
  3895. <td>商品中文</td>
  3896. <td>标签</td>
  3897. <td>" . $tl . "时间(中国时间)</td>
  3898. </tr>
  3899. </table>";
  3900. $filename = $title . ".xls";
  3901. $tail = "";
  3902. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3903. } else {
  3904. /**
  3905. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  3906. $rows = array();$list = array();
  3907. foreach ($info_list as $key=>$value)
  3908. {
  3909. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  3910. }
  3911. **/
  3912. $wh = array();
  3913. $w = $this->warehouse->find_all('1=1', 'id,title');
  3914. foreach ($w as $v) {
  3915. $wh[$v['id']] = $v['title'];
  3916. }
  3917. $wt = array();
  3918. $whlabel_type = $this->whlabel_type->find_all();
  3919. foreach ($whlabel_type as $v) {
  3920. $wt[$v['id']] = $v['title'];
  3921. }
  3922. $classid = $this->classid->sku();
  3923. $list = array();
  3924. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  3925. foreach ($rows as $key => $value) {
  3926. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3927. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3928. $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');
  3929. $details = array();
  3930. $cpid = array();
  3931. $cpbz = array();
  3932. $c = 0;
  3933. $g = 0;
  3934. $x = 0;
  3935. $t = 0;
  3936. $s = 0;
  3937. $q = 0;
  3938. foreach ($sd as $k => $v) {
  3939. if ($v['state'] == 0) {
  3940. $c++;
  3941. }
  3942. if ($v['state'] != 9) {
  3943. $g++;
  3944. }
  3945. if ($v['outk'] > 1) {
  3946. $x++;
  3947. }
  3948. if ($v['retreat'] > 0) {
  3949. $t++;
  3950. }
  3951. if ($v['state'] == 8) {
  3952. $s++;
  3953. }
  3954. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3955. $q++;
  3956. }
  3957. $details[$v['details']] = $v['details'];
  3958. if ($v['cpid'] != 0) {
  3959. $cpid[$v['cpid']] = $v['cpid'];
  3960. }
  3961. if ($v['cpbz'] != '') {
  3962. $cpbz[$v['cpbz']] = $v['cpbz'];
  3963. }
  3964. }
  3965. if (isset($wt[$value['type']])) {
  3966. $rows[$key]['type'] = $wt[$value['type']];
  3967. } else {
  3968. $rows[$key]['type'] = '未设置';
  3969. }
  3970. $rows[$key]['details'] = implode("、", $details);
  3971. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3972. $ftime = time() - 15 * 24 * 3600;
  3973. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3974. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  3975. $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);
  3976. $rows[$key]['c'] = $c;
  3977. $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);
  3978. $rows[$key]['t'] = $t;
  3979. $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'] . '"');
  3980. $rows[$key]['z'] = $z;
  3981. // $jm = $classid;
  3982. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3983. $features = explode('-', trim($features, '-'));
  3984. // $pm = $classid;
  3985. // foreach ($features as $k => $v) {
  3986. // if ($v != 0) {
  3987. // if (!isset($typeclass[$v])) {
  3988. // continue;
  3989. // }
  3990. // if (isset($pm[$typeclass[$v]['classid']])) {
  3991. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3992. // $tz = explode('|', $typeclass[$v]['zh']);
  3993. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3994. // } else {
  3995. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3996. // }
  3997. // if (isset($jm[$typeclass[$v]['classid']])) {
  3998. // if ($typeclass[$v]['jm']) {
  3999. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4000. // }
  4001. // }
  4002. // }
  4003. // }
  4004. // }
  4005. // $zh = implode(" ", $pm);
  4006. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4007. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4008. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4009. // $rows[$key]['features'] = $zh;
  4010. // $jm = array_filter($jm); //去除空值
  4011. // $jm = implode("-", $jm);
  4012. // $rows[$key]['jm'] = $jm;
  4013. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4014. }
  4015. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4016. // echo "<pre>";
  4017. // print_r($tmp_list);
  4018. // die;
  4019. $final_list =[];
  4020. foreach($tmp_list as $k=>$v){
  4021. $final_list[] = [
  4022. "warehouse"=>$v['warehouse'],
  4023. "purchase"=>$v['purchase'],
  4024. "details"=>$v['details'],
  4025. "cpid"=>$v['cpid'],
  4026. "sku"=>$v['sku'],
  4027. "title"=>$v['title'],
  4028. "features"=>$v['pm'],
  4029. "cpbz"=>$v['cpbz'],
  4030. "sm"=>$v['sm'],
  4031. "type"=>$v['type'],
  4032. "g"=>$v["g"],
  4033. "c"=>$v["c"],
  4034. "x"=>$v["x"],
  4035. "t"=>$v["t"],
  4036. "z"=>$v["z"],
  4037. "jm"=>$v["jm"],
  4038. "weight"=>$v["weight"],
  4039. "asd"=>$v["asd"],
  4040. ];
  4041. }
  4042. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4043. $titlename = "<table border=1>
  4044. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4045. <tr align='center'>
  4046. <td>仓库</td>
  4047. <td>供应商</td>
  4048. <td>位置</td>
  4049. <td>库存编码</td>
  4050. <td>SKU</td>
  4051. <td>商品名称</td>
  4052. <td>商品中文</td>
  4053. <td>产品备注</td>
  4054. <td>说明</td>
  4055. <td>类型</td>
  4056. <td>入库总量</td>
  4057. <td>库存数量</td>
  4058. <td>销售数量</td>
  4059. <td>退货数量</td>
  4060. <td>占单数量</td>
  4061. <td>料号</td>
  4062. <td>重量</td>
  4063. <td>类目</td>
  4064. </tr>
  4065. </table>";
  4066. $filename = $title . ".xls";
  4067. $tail = "";
  4068. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4069. }
  4070. }
  4071. }
  4072. //出库+入库数据整合
  4073. public function _excelcr()
  4074. {
  4075. if (isset($_GET['excel'])) {
  4076. $type = $this->input->get('excel', true);
  4077. $category = $this->input->get('category', true);
  4078. $size = $this->input->get('size', true);
  4079. $grade = $this->input->get('grade', true);
  4080. $color = $this->input->get('color', true);
  4081. $lowe = $this->input->get('lowe', true);
  4082. $sku = $this->input->get('sku', true);
  4083. $warehouse = $this->input->get('warehouse', true);
  4084. $purchase = $this->input->get('purchase', true);
  4085. $state = $this->input->get('state', true);
  4086. $sid = $this->input->get('sid', true);
  4087. $ktime = $this->input->get('ktime', true);
  4088. $jtime = $this->input->get('jtime', true);
  4089. $ktime = strtotime($ktime);
  4090. $jtime = strtotime($jtime);
  4091. $where = "1=1";
  4092. $gj = "";
  4093. $ck = "";
  4094. if ($category) {
  4095. $where .= " and features like '%-$category-%'";
  4096. }
  4097. if ($size) {
  4098. $where .= " and features like '%-$size-%'";
  4099. }
  4100. if ($grade) {
  4101. $where .= " and features like '%-$grade-%'";
  4102. }
  4103. if ($color) {
  4104. $where .= " and features like '%-$color-%'";
  4105. }
  4106. if ($lowe) {
  4107. $where .= " and features like '%-$lowe-%'";
  4108. }
  4109. if ($warehouse) {
  4110. $where .= " and warehouse = '$warehouse'";
  4111. }
  4112. if ($purchase) {
  4113. $where .= " and purchase = '$purchase'";
  4114. }
  4115. if ($state) {
  4116. $where .= " and state = '$state'";
  4117. }
  4118. if ($sku) {
  4119. $where .= " and sku like '%$sku%'";
  4120. }
  4121. if ($ktime && $jtime) {
  4122. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4123. }
  4124. $sidwhere = '';
  4125. if ($sid) {
  4126. $sd = "";
  4127. $s = explode(',', trim($sid, ','));
  4128. foreach ($s as $value) {
  4129. $sd .= " id = " . $value . " or";
  4130. }
  4131. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4132. }
  4133. //取得信息列表
  4134. $timeread = $ktime;
  4135. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4136. $timelist = array();
  4137. for ($i = 0; $i < $timenum; $i++) {
  4138. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4139. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4140. }
  4141. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4142. //echo "<pre>";
  4143. //print_r($info_list);
  4144. //exit();
  4145. $rows = array();
  4146. $list = array();
  4147. foreach ($info_list as $key => $value) {
  4148. $thistime = $timelist;
  4149. if (isset($rows[strtolower($value['sku'])])) {
  4150. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4151. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4152. }
  4153. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4154. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4155. }
  4156. } else {
  4157. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4158. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4159. }
  4160. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4161. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4162. }
  4163. $rows[strtolower($value['sku'])] = $thistime;
  4164. }
  4165. }
  4166. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4167. <head>
  4168. <!--[if gte mso 9]><xml>
  4169. <x:ExcelWorkbook>
  4170. <x:ExcelWorksheets>
  4171. <x:ExcelWorksheet>
  4172. <x:Name>EXCEL</x:Name>
  4173. <x:WorksheetOptions>
  4174. <x:Print>
  4175. <x:ValidPrinterInfo />
  4176. </x:Print>
  4177. </x:WorksheetOptions>
  4178. </x:ExcelWorksheet>
  4179. </x:ExcelWorksheets>
  4180. </x:ExcelWorkbook>
  4181. </xml>
  4182. <![endif]-->
  4183. </head><body>";
  4184. $str .= "<table border=1><tr><td>SKU</td>";
  4185. foreach ($timelist as $k => $v) {
  4186. $str .= "<td>" . $k . "出库</td>";
  4187. $str .= "<td>" . $k . "入库</td>";
  4188. }
  4189. $str .= "</tr></table>";
  4190. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4191. foreach ($rows as $key => $val) {
  4192. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4193. foreach ($val as $k => $v) {
  4194. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4195. if ($val[$k]['r'] > 0) {
  4196. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4197. } else {
  4198. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4199. }
  4200. }
  4201. $str .= "</tr>";
  4202. }
  4203. $str .= "</table>";
  4204. $str .= "</body></html>";
  4205. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4206. header("Content-type: application/octet-stream");
  4207. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4208. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4209. header("Pragma: no-cache");
  4210. header("Expires: 0");
  4211. exit($str);
  4212. }
  4213. }
  4214. //数量调整模板导出
  4215. public function _presetout()
  4216. {
  4217. if (isset($_GET['excel'])) {
  4218. $where = "sku != 'Preset' and purchase != 0";
  4219. //数据排序
  4220. $order_str = "id desc";
  4221. if (empty($page)) {
  4222. $start = 0;
  4223. $perpage = 1;
  4224. } else {
  4225. $start = ($page - 1) * $perpage;
  4226. }
  4227. //取得信息列表
  4228. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4229. $rows = array();
  4230. $list = array();
  4231. foreach ($info_list as $value) {
  4232. $warehouse = $this->warehouse->read($value['warehouse']);
  4233. $number = $value['number'];
  4234. $ftime = time() - 15 * 24 * 3600;
  4235. $purchase = $this->purchase->read($value['purchase']);
  4236. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4237. }
  4238. $title = "库存模板";
  4239. $titlename = "<table border=1>
  4240. <tr align='center'>
  4241. <td>仓库</td>
  4242. <td>供应商编码</td>
  4243. <td>SKU</td>
  4244. <td>增减数量(正数或负数)</td>
  4245. <td>增减备注</td>
  4246. <td>扣减方式:0减少库存1删除库存</td>
  4247. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4248. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4249. </tr>
  4250. </table>";
  4251. $filename = $title . ".xls";
  4252. $tail = "";
  4253. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4254. }
  4255. }
  4256. //数量调整模板导入
  4257. public function _presetedit()
  4258. {
  4259. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4260. $config['upload_path'] = '.' . $dir;
  4261. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4262. $config['allowed_types'] = 'xls|xlsx|csv';
  4263. $config['max_size'] = 10240;
  4264. $this->load->library('upload', $config);
  4265. $this->upload->initialize($config);
  4266. if ($this->upload->do_upload('userfile')) {
  4267. $full_path = $dir . $this->upload->data('file_name');
  4268. $fileName = '.' . $full_path;
  4269. if (!file_exists($fileName)) {
  4270. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4271. exit;
  4272. } else {
  4273. require_once "./data/excel/PHPExcel/IOFactory.php";
  4274. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4275. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4276. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4277. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4278. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4279. ++$column; //如果列数大于26行
  4280. $list = array();
  4281. for ($i = 2; $i <= $row; $i++) // 行数循环
  4282. {
  4283. $data = array();
  4284. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4285. {
  4286. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4287. }
  4288. $list[] = $data;
  4289. }
  4290. }
  4291. $i = 0;
  4292. $j = 0;
  4293. $ed = array();
  4294. foreach ($list as $key => $value) {
  4295. $time = time();
  4296. if ($value['0'] == "") {
  4297. continue;
  4298. }
  4299. $warehouse = $this->warehouse->get_title($value['0']);
  4300. $purchase = $this->purchase->get_bm($value['1']);
  4301. $sku = $value['2'];
  4302. $num = $value['3']; //调整数量
  4303. $text = $value['4']; //扣减说明
  4304. $type = $value['5']; //调整方式0扣减1删除
  4305. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4306. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4307. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4308. if (!$purchase) //如果没有这个SKU
  4309. {
  4310. $ed[] = array($purchase . '-不存在此供应商编码');
  4311. $j++;
  4312. continue;
  4313. }
  4314. if (!$d) //如果没有这个SKU
  4315. {
  4316. $ed[] = array($sku . '-库存中不存在此SKU');
  4317. $j++;
  4318. continue;
  4319. }
  4320. if (!isset($warehouse['id'])) {
  4321. $ed[] = array($sku . '-仓库名错误!');
  4322. $j++;
  4323. continue;
  4324. }
  4325. if ($type != '0' && $type != '1') {
  4326. $ed[] = array($sku . '-扣减方式填写错误!');
  4327. $j++;
  4328. continue;
  4329. }
  4330. if ($num < 0) //扣减库存
  4331. {
  4332. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4333. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4334. $j++;
  4335. continue;
  4336. }
  4337. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4338. if (count($data) < abs($num)) {
  4339. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4340. $j++;
  4341. continue;
  4342. }
  4343. if ($type == 0) //如果扣减方式为 扣减库存
  4344. {
  4345. for ($i = 0; $i < abs($num); $i++) {
  4346. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4347. }
  4348. } else if ($type == 1) {
  4349. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4350. if (count($zt) > 0) {
  4351. $ed[] = array($sku . '-有在途库存无法删除!');
  4352. $j++;
  4353. continue;
  4354. }
  4355. for ($i = 0; $i < abs($num); $i++) {
  4356. $this->whlabel->remove($data[$i]['id']);
  4357. }
  4358. }
  4359. } else if ($num > 0) //增加库存
  4360. {
  4361. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4362. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4363. $j++;
  4364. continue;
  4365. }
  4366. $post['sku'] = $d['sku'];
  4367. $post['shop'] = $d['shop'];
  4368. $post['warehouse'] = $warehouse['id'];
  4369. $post['purchase'] = $purchase['id'];
  4370. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4371. $post['state'] = 0;
  4372. $post['title'] = $d['title'];
  4373. $post['number'] = $d['number'];
  4374. $post['features'] = $d['features'];
  4375. $post['enter'] = $time;
  4376. $post['time'] = $time; //操作时间
  4377. $post['rktype'] = $rktype;
  4378. for ($i = 0; $i < $num; $i++) {
  4379. $post['label'] = time() . rand(100, 999) . $i;
  4380. $this->whlabel->insert($post);
  4381. }
  4382. }
  4383. sleep(1); //防止入库时间一样,需要延迟1秒
  4384. }
  4385. if ($j > 0) {
  4386. $tt = date('Ymd', time());
  4387. $title = '库存导入错误信息-' . $tt;
  4388. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4389. $tail = "\n";
  4390. $filename = $title . ".xls";
  4391. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4392. $dir = '/data/excel/' . $time . '/';
  4393. $file_name = 'error_' . $time . rand(1000, 9999);
  4394. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4395. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4396. fwrite($myfile, $ecl);
  4397. fclose($myfile);
  4398. $error = $dir . $file_name . '.xls';
  4399. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4400. exit;
  4401. } else {
  4402. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4403. exit;
  4404. }
  4405. }
  4406. }
  4407. //笛卡儿积
  4408. function cp($ps, $sets, $list)
  4409. {
  4410. $result = array();
  4411. $j = 0;
  4412. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4413. if ($i == 0) {
  4414. $result = $sets[$i];
  4415. }
  4416. $tmp = array();
  4417. foreach ($result as $res) {
  4418. foreach ($sets[$i + 1] as $set) {
  4419. $tmp[] = $res . ',' . $set;
  4420. }
  4421. }
  4422. $result = $tmp;
  4423. }
  4424. $this->db->trans_begin();
  4425. foreach ($result as $v) {
  4426. $post = array();
  4427. $title = "";
  4428. $num = "";
  4429. $data = explode(',', $v);
  4430. for ($i = 0; $i < count($list); $i++) {
  4431. $post[$list[$i]] = $data[$i];
  4432. $typeclass = $this->typeclass->read($data[$i]);
  4433. $title = $title . $typeclass['title'] . " ";
  4434. if ($data[$i] != 0) {
  4435. $num .= $data[$i]; //所有数据ID拼接
  4436. }
  4437. }
  4438. foreach ($ps as $kp => $vp) {
  4439. $post[$kp] = $vp;
  4440. }
  4441. $post['number'] = $num;
  4442. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4443. if ($info_list) {
  4444. $j++;
  4445. } else {
  4446. $skunum = $this->whlabel->find_count();
  4447. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4448. $post['title'] = rtrim($title, ' ');
  4449. $this->whlabel->insert($post);
  4450. }
  4451. }
  4452. if ($this->db->trans_status() === FALSE) {
  4453. $this->db->trans_commit();
  4454. return NULL;
  4455. } else {
  4456. $this->db->trans_commit();
  4457. return $j;
  4458. }
  4459. }
  4460. public function _kj($arg_array)
  4461. {
  4462. if (isset($_POST['sku'])) {
  4463. $time = time();
  4464. $sku = $this->input->post('sku', true);
  4465. $warehouse = $this->input->post('warehouse', true);
  4466. $num = $this->input->post('num', true);
  4467. $text = $this->input->post('text', true);
  4468. $purchase = $this->input->post('purchase', true);
  4469. $cktype = $this->input->post('cktype', true);
  4470. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4471. if ($cktype != 1 && $text == '') {
  4472. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4473. exit;
  4474. }
  4475. if ($num > count($order)) {
  4476. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4477. exit;
  4478. } else {
  4479. for ($i = 0; $i < $num; $i++) {
  4480. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4481. }
  4482. }
  4483. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4484. exit;
  4485. }
  4486. $uid = $this->whlabel->read($arg_array[0]);
  4487. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4488. $this->data['data'] = $uid;
  4489. $this->_Template('whlabel_kj', $this->data);
  4490. }
  4491. public function _summary($arg_array)
  4492. {
  4493. $prc = array();
  4494. $purchase = $this->purchase->find_all();
  4495. foreach ($purchase as $k => $v) {
  4496. $prc[$v['id']] = $v['title'];
  4497. }
  4498. if (isset($_GET['excel'])) {
  4499. $ktime = $this->input->get('ktime', true);
  4500. $jtime = $this->input->get('jtime', true);
  4501. $ktime = strtotime($ktime);
  4502. $jtime = strtotime($jtime);
  4503. $where = "1=1";
  4504. if ($ktime && $jtime) {
  4505. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4506. }
  4507. //数据排序
  4508. $order_str = "time desc";
  4509. if (empty($page)) {
  4510. $start = 0;
  4511. $perpage = 1;
  4512. } else {
  4513. $start = ($page - 1) * $perpage;
  4514. }
  4515. //取得信息列表
  4516. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4517. foreach ($info_list as $key => $value) {
  4518. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4519. $warehouse = $this->warehouse->read($value['warehouse']);
  4520. $info_list[$key]['warehouse'] = $warehouse['title'];
  4521. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4522. $details = array();
  4523. $cpid = array();
  4524. foreach ($x as $k => $v) {
  4525. if ($v['details'] != '') {
  4526. $details[$v['details']] = $v['details'];
  4527. }
  4528. if ($v['cpid'] != 0) {
  4529. $cpid[$v['cpid']] = $v['cpid'];
  4530. }
  4531. }
  4532. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4533. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4534. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4535. $info_list[$key]['s'] = $s;
  4536. $info_list[$key]['x'] = count($x);
  4537. }
  4538. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4539. $titlename = "<table border=1>
  4540. <tr align='center'>
  4541. <td>仓库</td>
  4542. <td>供应商</td>
  4543. <td>出库位置</td>
  4544. <td>出库编码</td>
  4545. <td>SKU</td>
  4546. <td>产品名</td>
  4547. <td>总剩余库存</td>
  4548. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4549. </tr>
  4550. </table>";
  4551. $filename = $title . ".xls";
  4552. $tail = "";
  4553. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4554. }
  4555. }
  4556. //usps发货清单
  4557. public function _manifest()
  4558. {
  4559. if (isset($_POST['manifest'])) {
  4560. $wltext = $this->input->post('wltext', true);
  4561. $time = time() - 16 * 3600;
  4562. $ptime = strtotime(date('Y-m-d', $time));
  4563. $waybill = array();
  4564. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4565. foreach ($fullorder as $v) {
  4566. $waybill[$v['waybill']] = $v['waybill'];
  4567. }
  4568. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4569. foreach ($fullordersmt as $v) {
  4570. $waybill[$v['waybill']] = $v['waybill'];
  4571. }
  4572. $wltext = explode(';', $wltext);
  4573. foreach ($wltext as $v) {
  4574. if (isset($waybill[$v])) {
  4575. unset($waybill[$v]);
  4576. }
  4577. }
  4578. $data = $this->usps->get_manifest($waybill);
  4579. if (isset($data['Description'])) {
  4580. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4581. exit;
  4582. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4583. $bctime = date('Ymd', time());
  4584. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4585. echo json_encode(array('msg' => $pdf, 'success' => true));
  4586. exit;
  4587. } else {
  4588. echo json_encode(array('msg' => $data, 'success' => false));
  4589. exit;
  4590. }
  4591. }
  4592. }
  4593. public function _pdf($pdf, $title, $bctime)
  4594. {
  4595. $pdf_path = './data/pdf/' . $bctime . '/';
  4596. $file_base64 = $pdf;
  4597. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4598. $file_base64 = base64_decode($file_base64);
  4599. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4600. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4601. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4602. }
  4603. /**
  4604. *
  4605. *
  4606. *
  4607. 进销存占单异常索引
  4608. *
  4609. *
  4610. *
  4611. **/
  4612. public function _abnormal()
  4613. {
  4614. $post = $this->input->post(NULL, TRUE);
  4615. if (isset($post['page'])) {
  4616. $page = $this->input->post('page', true);
  4617. $perpage = $this->input->post('perpage', true);
  4618. $sku = $this->input->post('sku', true);
  4619. $where = "1=1";
  4620. //数据排序
  4621. $order_str = "id desc";
  4622. if (empty($page)) {
  4623. $start = 0;
  4624. $perpage = 1;
  4625. } else {
  4626. $start = ($page - 1) * $perpage;
  4627. }
  4628. //取得信息列表
  4629. $info_list = $this->whlabel->find_all($where, '*');
  4630. $rows = array();
  4631. $list = array();
  4632. foreach ($info_list as $key => $value) {
  4633. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4634. }
  4635. foreach ($rows as $value) {
  4636. $warehouse = $this->warehouse->read($value['warehouse']);
  4637. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4638. $number = $value['number'];
  4639. $ftime = time() - 15 * 24 * 3600;
  4640. if ($value['shop'] != '') {
  4641. $shop = $value['shop'];
  4642. $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');
  4643. $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');
  4644. $order = array_merge($orderdlz, $ordersmt);
  4645. $od = 0;
  4646. $a = '';
  4647. $orid = '';
  4648. foreach ($order as $v) {
  4649. $or = explode('|', ltrim($v['whlabel'], '|'));
  4650. for ($i = 0; $i < count($or); $i++) {
  4651. $orod = explode('-', $or[$i]);
  4652. if ($orod[0] == $number) {
  4653. $od += $orod[1];
  4654. }
  4655. }
  4656. $orid .= $v['number'] . '-';
  4657. }
  4658. } else {
  4659. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4660. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4661. $order = array_merge($orderdlz, $ordersmt);
  4662. $od = 0;
  4663. $a = '';
  4664. $orid = '';
  4665. $qt = array();
  4666. foreach ($order as $v) {
  4667. $or = explode('|', ltrim($v['whlabel'], '|'));
  4668. for ($i = 0; $i < count($or); $i++) {
  4669. $orod = explode('-', $or[$i]);
  4670. if ($orod[0] == $number) {
  4671. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4672. if ($czzs > 0) {
  4673. if (isset($qt[$v['shop']])) {
  4674. if ($qt[$v['shop']] < $orod[1]) {
  4675. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4676. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4677. } else {
  4678. $qt[$v['shop']] -= $orod[1];
  4679. }
  4680. } else {
  4681. $qt[$v['shop']] = $czzs;
  4682. }
  4683. } else {
  4684. $od += $orod[1];
  4685. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4686. }
  4687. }
  4688. }
  4689. }
  4690. }
  4691. $z = $od . '(' . $orid . ')'; //查看订单号
  4692. //$z = $od;
  4693. if ($od > $c) {
  4694. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4695. }
  4696. }
  4697. $listdata = array_slice($list, $start, $perpage);
  4698. $total = count($list);
  4699. $pagenum = ceil($total / $perpage);
  4700. $over = $total - ($start + $perpage);
  4701. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4702. echo json_encode($rows);
  4703. exit;
  4704. }
  4705. $this->_Template('whlabel_abnormal', $this->data);
  4706. }
  4707. /**
  4708. *
  4709. *
  4710. *
  4711. 进销存占单异常索引
  4712. *
  4713. *
  4714. *
  4715. **/
  4716. public function _error()
  4717. {
  4718. $post = $this->input->post(NULL, TRUE);
  4719. if (isset($post['page'])) {
  4720. $page = $this->input->post('page', true);
  4721. $perpage = $this->input->post('perpage', true);
  4722. $sku = $this->input->post('sku', true);
  4723. $warehouse = $this->input->post('warehouse', true);
  4724. $ktime = $this->input->post('ktime', true);
  4725. $jtime = $this->input->post('jtime', true);
  4726. $ktime = strtotime($ktime);
  4727. $jtime = strtotime($jtime);
  4728. $where = "sku != 'Preset'";
  4729. $gj = '';
  4730. if ($sku) {
  4731. $where .= " and sku like '%$sku%'";
  4732. } else {
  4733. if ($ktime && $jtime) {
  4734. $gj = " and time > '$ktime' and time < '$jtime'";
  4735. }
  4736. }
  4737. if ($warehouse) {
  4738. $where .= " and warehouse = '$warehouse'";
  4739. }
  4740. //数据排序
  4741. $order_str = "id desc";
  4742. if (empty($page)) {
  4743. $start = 0;
  4744. $perpage = 1;
  4745. } else {
  4746. $start = ($page - 1) * $perpage;
  4747. }
  4748. //取得信息列表
  4749. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4750. $rows = array();
  4751. $list = array();
  4752. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4753. // foreach ($info_list as $value)
  4754. // {
  4755. // $warehouse = $this->warehouse->read($value['warehouse']);
  4756. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4757. // $number = $value['number'];$ftime = time()-15*24*3600;
  4758. // if($c < 1)
  4759. // {
  4760. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4761. // }
  4762. // }
  4763. $warehouse_list = $this->warehouse->find_all();
  4764. $warehouse_list = array_column($warehouse_list, null, 'id');
  4765. foreach ($info_list as $value) {
  4766. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4767. 'title' => "",
  4768. ];
  4769. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4770. $number = $value['number'];
  4771. $ftime = time() - 15 * 24 * 3600;
  4772. if ($c < 1) {
  4773. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4774. }
  4775. }
  4776. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4777. // $query = $this->db->query($sql);
  4778. // $info_list = $query->result_array();
  4779. // $sql_two = "select title,id from crowd_warehouse";
  4780. // $query_two = $this->db->query($sql_two);
  4781. // $warehouse_list = $query_two->result_array();
  4782. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4783. // foreach ($info_list as $value)
  4784. // {
  4785. // if(isset($warehouse_arr[$value['warehouse']])){
  4786. // $warehouse = $warehouse_arr[$value['warehouse']];
  4787. // }else{
  4788. // $warehouse = [
  4789. // 'id'=>0,
  4790. // 'title'=>"异常",
  4791. // ];
  4792. // }
  4793. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4794. // $number = $value['number'];$ftime = time()-15*24*3600;
  4795. // if($c < 1)
  4796. // {
  4797. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4798. // }
  4799. // }
  4800. $listdata = array_slice($list, $start, $perpage);
  4801. $total = count($list);
  4802. $pagenum = ceil($total / $perpage);
  4803. $over = $total - ($start + $perpage);
  4804. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4805. echo json_encode($rows);
  4806. exit;
  4807. }
  4808. if (isset($post['s'])) {
  4809. $id_arr = $this->input->post('s');
  4810. $id_arr = explode(',', trim($id_arr, ','));
  4811. if (!$id_arr) {
  4812. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4813. exit;
  4814. }
  4815. //循环删除记录
  4816. foreach ($id_arr as $v) {
  4817. $dd = $this->whlabel->read($v);
  4818. if (!isset($dd['id'])) {
  4819. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4820. exit;
  4821. }
  4822. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4823. if (isset($zt[0])) {
  4824. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4825. exit;
  4826. }
  4827. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4828. foreach ($deldd as $vv) {
  4829. $this->whlabel->remove($vv['id']);
  4830. }
  4831. }
  4832. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4833. exit;
  4834. }
  4835. $this->_Template('whlabel_error', $this->data);
  4836. }
  4837. public function _errorexcel()
  4838. {
  4839. $post = $this->input->post(NULL, TRUE);
  4840. if (isset($_GET['page'])) {
  4841. $page = $this->input->get('page', true);
  4842. $perpage = $this->input->get('perpage', true);
  4843. $sku = $this->input->get('sku', true);
  4844. $warehouse = $this->input->get('warehouse', true);
  4845. $ktime = $this->input->get('ktime', true);
  4846. $jtime = $this->input->get('jtime', true);
  4847. $ktime = strtotime($ktime);
  4848. $jtime = strtotime($jtime);
  4849. $where = "sku != 'Preset'";
  4850. $gj = '';
  4851. if ($sku) {
  4852. $where .= " and sku like '%$sku%'";
  4853. } else {
  4854. if ($ktime && $jtime) {
  4855. $gj = " and time > '$ktime' and time < '$jtime'";
  4856. }
  4857. }
  4858. if ($warehouse) {
  4859. $where .= " and warehouse = '$warehouse'";
  4860. }
  4861. //数据排序
  4862. $order_str = "id desc";
  4863. if (empty($page)) {
  4864. $start = 0;
  4865. $perpage = 1;
  4866. } else {
  4867. $start = ($page - 1) * $perpage;
  4868. }
  4869. //取得信息列表
  4870. $rows = array();
  4871. $list = array();
  4872. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4873. foreach ($info_list as $value) {
  4874. $warehouse = $this->warehouse->read($value['warehouse']);
  4875. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4876. $number = $value['number'];
  4877. $ftime = time() - 15 * 24 * 3600;
  4878. if ($c < 1) {
  4879. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4880. }
  4881. }
  4882. $title = "0库存汇总";
  4883. $titlename = "<table border=1>
  4884. <tr align='center'>
  4885. <td>仓库</td>
  4886. <td>SKU</td>
  4887. <td>产品</td>
  4888. <td>当前库存</td>
  4889. </tr>
  4890. </table>";
  4891. $filename = $title . ".xls";
  4892. $tail = "";
  4893. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4894. }
  4895. }
  4896. /**
  4897. *
  4898. *
  4899. * 占单
  4900. *
  4901. *
  4902. **/
  4903. public function _kcyz()
  4904. {
  4905. $post = $this->input->post(NULL, TRUE);
  4906. if (isset($post['warehouse'])) {
  4907. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  4908. exit; //不再使用
  4909. $warehouse = $this->input->post('warehouse', true);
  4910. $whlabel = $this->input->post('whlabel', true);
  4911. $id = $this->input->post('id', true);
  4912. $shop = $this->input->post('shop', true);
  4913. $number = $this->input->post('number', true);
  4914. if (!$whlabel || $whlabel == '|') {
  4915. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  4916. exit;
  4917. }
  4918. $pp = explode('|', trim($whlabel, '|'));
  4919. $x = 0;
  4920. $save = array();
  4921. foreach ($pp as $va) {
  4922. $num = explode('-', $va);
  4923. if ($number) {
  4924. $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 = '')"); //通用
  4925. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  4926. } else {
  4927. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  4928. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  4929. }
  4930. $x++;
  4931. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  4932. $save[] = $x - 1;
  4933. continue; //提前先加X不然出错,所以要减1
  4934. }
  4935. }
  4936. if (isset($save[0])) {
  4937. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  4938. exit;
  4939. } else {
  4940. echo json_encode(array('success' => true));
  4941. exit;
  4942. }
  4943. }
  4944. }
  4945. public function _db()
  4946. {
  4947. $post = $this->input->post(NULL, TRUE);
  4948. if (isset($post['page'])) {
  4949. $page = $this->input->post('page', true);
  4950. $perpage = $this->input->post('perpage', true);
  4951. $sku = $this->input->post('sku', true);
  4952. $number = $this->input->post('number', true);
  4953. $warehouse = $this->input->post('warehouse', true);
  4954. $purchase = $this->input->post('purchase', true);
  4955. $orderinfo = $this->input->post('orderinfo', true);
  4956. $waybill = $this->input->post('waybill', true);
  4957. $category = $this->input->post('category', true);
  4958. $size = $this->input->post('size', true);
  4959. $grade = $this->input->post('grade', true);
  4960. $color = $this->input->post('color', true);
  4961. $lowe = $this->input->post('lowe', true);
  4962. $state = $this->input->post('state', true);
  4963. $label = $this->input->post('label', true);
  4964. $timetk = $this->input->post('timetkk', true);
  4965. $timetj = $this->input->post('timetjj', true);
  4966. $timetk = strtotime($timetk);
  4967. $timetj = strtotime($timetj);
  4968. $where = "dbtime > 0";
  4969. if ($timetk && $timetj) {
  4970. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  4971. }
  4972. if ($sku) {
  4973. $where .= " and sku = '$sku'";
  4974. }
  4975. if ($warehouse) {
  4976. $where .= " and warehouse = '$warehouse'";
  4977. if ($warehouse == 12) {
  4978. $w = 'specialstock';
  4979. } else {
  4980. $w = 'whlabel';
  4981. }
  4982. }
  4983. if ($purchase) {
  4984. $where .= " and purchase = '$purchase'";
  4985. }
  4986. if ($category) {
  4987. $where .= " and features like '%-$category-%'";
  4988. }
  4989. if ($size) {
  4990. $where .= " and features like '%-$size-%'";
  4991. }
  4992. if ($grade) {
  4993. $where .= " and features like '%-$grade-%'";
  4994. }
  4995. if ($color) {
  4996. $where .= " and features like '%-$color-%'";
  4997. }
  4998. if ($lowe) {
  4999. $where .= " and features like '%-$lowe-%'";
  5000. }
  5001. if ($state != '') {
  5002. $where .= " and state = '$state'";
  5003. }
  5004. //数据排序
  5005. $order_str = "dbtime desc";
  5006. if (empty($page)) {
  5007. $start = 0;
  5008. $perpage = 1;
  5009. } else {
  5010. $start = ($page - 1) * $perpage;
  5011. }
  5012. //取得信息列表
  5013. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5014. foreach ($info_list as $key => $value) {
  5015. $warehouse = $this->$w->read($value['warehouse']);
  5016. $info_list[$key]['warehouse'] = $warehouse['title'];
  5017. $purchase = $this->purchase->read($value['purchase']);
  5018. $info_list[$key]['purchase'] = $purchase['title'];
  5019. if ($value['enter'] != 0) {
  5020. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5021. } else {
  5022. $info_list[$key]['enter'] = "";
  5023. }
  5024. if ($value['dbtime'] != 0) {
  5025. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5026. } else {
  5027. $info_list[$key]['dbtime'] = "";
  5028. }
  5029. if ($value['state'] == 0) {
  5030. $info_list[$key]['state'] = "在库";
  5031. } else if ($value['state'] == 1) {
  5032. $info_list[$key]['state'] = "出库";
  5033. } else if ($value['state'] == 2) {
  5034. $info_list[$key]['state'] = "退库";
  5035. } else if ($value['state'] == 3) {
  5036. $info_list[$key]['state'] = "调拨中";
  5037. } else if ($value['state'] == 4) {
  5038. $info_list[$key]['state'] = "再加工";
  5039. } else if ($value['state'] == 5) {
  5040. $info_list[$key]['state'] = "维修中";
  5041. } else if ($value['state'] == 6) {
  5042. $info_list[$key]['state'] = "盘亏";
  5043. } else if ($value['state'] == 7) {
  5044. $info_list[$key]['state'] = "更换标签";
  5045. } else if ($value['state'] == 8) {
  5046. $info_list[$key]['state'] = "其它";
  5047. } else if ($value['state'] == 9) {
  5048. $info_list[$key]['state'] = "预设";
  5049. }
  5050. }
  5051. $total = $this->whlabel->find_count($where);
  5052. $pagenum = ceil($total / $perpage);
  5053. $over = $total - ($start + $perpage);
  5054. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5055. echo json_encode($rows);
  5056. exit;
  5057. }
  5058. if (isset($post['outsku'])) {
  5059. $time = time();
  5060. $cz = $this->input->post('cz', true);
  5061. $label = $this->input->post('outsku', true);
  5062. $sl = $this->input->post('sl', true);
  5063. $num = $this->input->post('num', true);
  5064. //$warehouse = $this->input->post('warehouse',true);
  5065. if (!$sl) {
  5066. $sl = 1;
  5067. }
  5068. if (!$warehouse) {
  5069. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5070. exit;
  5071. }
  5072. $dblabel = $this->whlabellabel->get_label($label);
  5073. if ($dblabel) {
  5074. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5075. if (count($data) < 1) {
  5076. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5077. exit;
  5078. }
  5079. if (count($data) < $num) {
  5080. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5081. exit;
  5082. }
  5083. for ($i = 0; $i < $sl; $i++) {
  5084. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5085. }
  5086. echo json_encode(array('success' => true));
  5087. exit;
  5088. } else {
  5089. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5090. exit;
  5091. }
  5092. }
  5093. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5094. $this->_Template('whlabel_db', $this->data);
  5095. }
  5096. public function _dbrk()
  5097. {
  5098. $post = $this->input->post(NULL, TRUE);
  5099. if (isset($post['page'])) {
  5100. $page = $this->input->post('page', true);
  5101. $perpage = $this->input->post('perpage', true);
  5102. $sku = $this->input->post('sku', true);
  5103. $number = $this->input->post('number', true);
  5104. $warehouse = $this->input->post('warehouse', true);
  5105. $purchase = $this->input->post('purchase', true);
  5106. $orderinfo = $this->input->post('orderinfo', true);
  5107. $waybill = $this->input->post('waybill', true);
  5108. $category = $this->input->post('category', true);
  5109. $size = $this->input->post('size', true);
  5110. $grade = $this->input->post('grade', true);
  5111. $color = $this->input->post('color', true);
  5112. $lowe = $this->input->post('lowe', true);
  5113. $state = $this->input->post('state', true);
  5114. $label = $this->input->post('label', true);
  5115. $ctime = $this->input->post('ctime', true);
  5116. $timetk = $this->input->post('timetkk', true);
  5117. $timetj = $this->input->post('timetjj', true);
  5118. $timetk = strtotime($timetk);
  5119. $timetj = strtotime($timetj);
  5120. $where = "dbtime > 0";
  5121. if ($timetk && $timetj) {
  5122. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5123. }
  5124. if ($sku) {
  5125. $where .= " and sku = '$sku'";
  5126. }
  5127. if ($warehouse) {
  5128. $where .= " and warehouse = '$warehouse'";
  5129. }
  5130. if ($purchase) {
  5131. $where .= " and purchase = '$purchase'";
  5132. }
  5133. if ($category) {
  5134. $where .= " and features like '%-$category-%'";
  5135. }
  5136. if ($size) {
  5137. $where .= " and features like '%-$size-%'";
  5138. }
  5139. if ($grade) {
  5140. $where .= " and features like '%-$grade-%'";
  5141. }
  5142. if ($color) {
  5143. $where .= " and features like '%-$color-%'";
  5144. }
  5145. if ($lowe) {
  5146. $where .= " and features like '%-$lowe-%'";
  5147. }
  5148. if ($state != '') {
  5149. $where .= " and state = '$state'";
  5150. }
  5151. //数据排序
  5152. $order_str = "dbtime desc";
  5153. if (empty($page)) {
  5154. $start = 0;
  5155. $perpage = 1;
  5156. } else {
  5157. $start = ($page - 1) * $perpage;
  5158. }
  5159. //取得信息列表
  5160. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5161. foreach ($info_list as $key => $value) {
  5162. $warehouse = $this->warehouse->read($value['warehouse']);
  5163. $info_list[$key]['warehouse'] = $warehouse['title'];
  5164. $purchase = $this->purchase->read($value['purchase']);
  5165. $info_list[$key]['purchase'] = $purchase['title'];
  5166. if ($value['enter'] != 0) {
  5167. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5168. } else {
  5169. $info_list[$key]['enter'] = "";
  5170. }
  5171. if ($value['dbtime'] != 0) {
  5172. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5173. } else {
  5174. $info_list[$key]['dbtime'] = "";
  5175. }
  5176. if ($value['state'] == 0) {
  5177. $info_list[$key]['state'] = "在库";
  5178. } else if ($value['state'] == 1) {
  5179. $info_list[$key]['state'] = "出库";
  5180. } else if ($value['state'] == 2) {
  5181. $info_list[$key]['state'] = "退库";
  5182. } else if ($value['state'] == 3) {
  5183. $info_list[$key]['state'] = "调拨中";
  5184. } else if ($value['state'] == 4) {
  5185. $info_list[$key]['state'] = "再加工";
  5186. } else if ($value['state'] == 5) {
  5187. $info_list[$key]['state'] = "维修中";
  5188. } else if ($value['state'] == 6) {
  5189. $info_list[$key]['state'] = "盘亏";
  5190. } else if ($value['state'] == 7) {
  5191. $info_list[$key]['state'] = "更换标签";
  5192. } else if ($value['state'] == 8) {
  5193. $info_list[$key]['state'] = "其它";
  5194. } else if ($value['state'] == 9) {
  5195. $info_list[$key]['state'] = "预设";
  5196. }
  5197. }
  5198. $total = $this->whlabel->find_count($where);
  5199. $pagenum = ceil($total / $perpage);
  5200. $over = $total - ($start + $perpage);
  5201. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5202. echo json_encode($rows);
  5203. exit;
  5204. }
  5205. if (isset($post['rsku'])) {
  5206. $cz = $this->input->post('cz', true);
  5207. $label = $this->input->post('rsku', true);
  5208. $sl = $this->input->post('sl', true);
  5209. $warehouse = $this->input->post('warehouse', true);
  5210. if (!$sl) {
  5211. $sl = 1;
  5212. }
  5213. if (!$warehouse) {
  5214. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5215. exit;
  5216. }
  5217. $dblabel = $this->whlabellabel->get_label($label);
  5218. if ($dblabel) {
  5219. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5220. if (count($data) < 1) {
  5221. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5222. exit;
  5223. }
  5224. if ($sl > count($data)) {
  5225. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5226. exit;
  5227. }
  5228. $time = time();
  5229. for ($i = 0; $i < $sl; $i++) {
  5230. $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']);
  5231. }
  5232. echo json_encode(array('success' => true));
  5233. exit;
  5234. } else {
  5235. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5236. exit;
  5237. }
  5238. }
  5239. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5240. $this->_Template('whlabel_dbrk', $this->data);
  5241. }
  5242. public function _whlabelczdc()
  5243. {
  5244. if (isset($_GET['excel'])) {
  5245. //数据排序
  5246. $order_str = "id desc";
  5247. if (empty($page)) {
  5248. $start = 0;
  5249. $perpage = 1;
  5250. } else {
  5251. $start = ($page - 1) * $perpage;
  5252. }
  5253. $state = $this->input->get('state', true);
  5254. $sku = $this->input->get('sku', true);
  5255. $ctime = $this->input->get('ctime', true);
  5256. $category = $this->input->get('category', true);
  5257. $size = $this->input->get('size', true);
  5258. $grade = $this->input->get('grade', true);
  5259. $color = $this->input->get('color', true);
  5260. $lowe = $this->input->get('lowe', true);
  5261. $timetk = $this->input->get('timetkk', true);
  5262. $timetj = $this->input->get('timetjj', true);
  5263. $timetk = strtotime($timetk);
  5264. $timetj = strtotime($timetj);
  5265. $where = "dbtime > 0";
  5266. if ($timetk && $timetj) {
  5267. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5268. }
  5269. if ($category) {
  5270. $where .= " and features like '%-$category-%'";
  5271. }
  5272. if ($size) {
  5273. $where .= " and features like '%-$size-%'";
  5274. }
  5275. if ($grade) {
  5276. $where .= " and features like '%-$grade-%'";
  5277. }
  5278. if ($color) {
  5279. $where .= " and features like '%-$color-%'";
  5280. }
  5281. if ($lowe) {
  5282. $where .= " and features like '%-$lowe-%'";
  5283. }
  5284. //取得信息列表
  5285. $info_list = $this->whlabel->find_all($where, '*');
  5286. $rows = array();
  5287. $list = array();
  5288. foreach ($info_list as $key => $value) {
  5289. $rows[$value['sku']] = $value; //所有数据sku
  5290. }
  5291. foreach ($rows as $value) {
  5292. $warehouse = $this->warehouse->read($value['warehouse']);
  5293. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5294. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5295. if ($value['orderinfo'] == 0) {
  5296. $info_list[$key]['orderinfo'] = "";
  5297. }
  5298. if ($value['waybill'] == 0) {
  5299. $info_list[$key]['waybill'] = "";
  5300. }
  5301. if ($value['state'] == 0) {
  5302. $value['state'] = "在库";
  5303. } else if ($value['state'] == 3) {
  5304. $value['state'] = "调拨中";
  5305. }
  5306. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5307. }
  5308. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5309. $titlename = "<table border=1>
  5310. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5311. <tr align='center'>
  5312. <td>SKU</td>
  5313. <td>产品</td>
  5314. <td>调拨数量</td>
  5315. <td>入库数量</td>
  5316. </tr>
  5317. </table>";
  5318. $filename = $title . ".xls";
  5319. $tail = "";
  5320. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5321. }
  5322. }
  5323. public function _print($arg_array)
  5324. {
  5325. if (isset($_SESSION['api'])) {
  5326. $user = $this->user->get_api($_SESSION['api']);
  5327. $usp = $user;
  5328. $fgshop = "";
  5329. $sid = "";
  5330. $wid = "";
  5331. $wtype = "";
  5332. $usersp = explode('|', trim($user['shop'], '|'));
  5333. $userwh = explode('|', trim($user['warehouse'], '|'));
  5334. foreach ($usersp as $value) {
  5335. $fgshop .= " shop = " . $value . " or";
  5336. $sid .= " id = " . $value . " or";
  5337. }
  5338. foreach ($userwh as $value) {
  5339. $wid .= " id = " . $value . " or";
  5340. $wtype .= " type = " . $value . " or";
  5341. }
  5342. }
  5343. $post = $this->input->post(NULL, TRUE);
  5344. if (isset($post['tmsku'])) {
  5345. $tmsku = $this->input->post('tmsku', true);
  5346. if (is_numeric($tmsku)) {
  5347. $yyh = $this->whlabellabel->get_label($tmsku);
  5348. } else {
  5349. $yyh = $this->whlabellabel->get_sku($tmsku);
  5350. }
  5351. if ($yyh) {
  5352. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5353. exit;
  5354. } else {
  5355. echo json_encode(array('success' => false));
  5356. exit;
  5357. }
  5358. }
  5359. $classid = $this->classid->sku();
  5360. $pm = $classid;
  5361. $scsku = $classid;
  5362. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5363. if (isset($post['warehouse'])) {
  5364. if ($post['warehouse']) {
  5365. $list = array();
  5366. $num = "";
  5367. $title = "";
  5368. $features = "";
  5369. $order = 0;
  5370. $post['shop'] = '';
  5371. $brand = $this->input->post('brand', true);
  5372. if ($brand != '0,') {
  5373. $b = $this->brand->read(rtrim($brand, ','));
  5374. if ($b) {
  5375. $post['shop'] = str_replace('|', ',', $b['shop']);
  5376. }
  5377. }
  5378. $post['details'] = $this->input->post('details', true); //打印数量
  5379. $xbqnum = $this->input->post('xbqnum', true);
  5380. $post['purchase'] = $this->input->post('purchase', true);
  5381. $post['warehouse'] = $this->input->post('warehouse', true);
  5382. $post['purchase'] = $this->input->post('purchase', true);
  5383. $post['retreatwarehouse'] = $post['warehouse'];
  5384. $post['cpbz'] = $this->input->post('cpbz', true);
  5385. $post['state'] = 9;
  5386. $category = $this->input->post('category', true);
  5387. $list['category'] = $category;
  5388. $list['hairtype'] = $this->input->post('hairtype', true);
  5389. $list['grade'] = $this->input->post('grade', true);
  5390. $size = $this->input->post('size', true);
  5391. $list['size'] = rtrim($size, ',');
  5392. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5393. $list['extension'] = $this->input->post('extension', true);
  5394. if ($category == 1297) {
  5395. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5396. }
  5397. if ($category == 1702) {
  5398. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5399. $list['syother'] = $this->input->post('syother', true);
  5400. }
  5401. if ($category == 133) {
  5402. $list['fittype'] = $this->input->post('fittype', true);
  5403. $list['acother'] = $this->input->post('acother', true);
  5404. }
  5405. $list['color'] = $this->input->post('color', true);
  5406. $list['lowe'] = $this->input->post('lowe', true);
  5407. if ($category == 127) {
  5408. $list['type'] = $this->input->post('type', true);
  5409. $list['headroad'] = $this->input->post('headroad', true);
  5410. $list['density'] = $this->input->post('density', true);
  5411. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5412. $list['lacesize'] = $this->input->post('lacesize', true);
  5413. }
  5414. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5415. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5416. }
  5417. if ($category == 128) {
  5418. $list['lacetype'] = $this->input->post('lacetype', true);
  5419. $list['haircap'] = $this->input->post('haircap', true);
  5420. $list['density'] = $this->input->post('density', true);
  5421. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5422. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5423. $list['wigother'] = $this->input->post('wigother', true);
  5424. $list['wigother1'] = $this->input->post('wigother1', true);
  5425. $list['wigother2'] = $this->input->post('wigother2', true);
  5426. }
  5427. if ($category == 129) {
  5428. $list['wide'] = $this->input->post('wide', true);
  5429. }
  5430. if ($category == 131) {
  5431. $list['gifttype'] = $this->input->post('gifttype', true);
  5432. $list['giftother'] = $this->input->post('giftother', true);
  5433. }
  5434. if ($category == 134) {
  5435. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5436. }
  5437. if ($category == 1297) {
  5438. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5439. $list['sywigother'] = $this->input->post('sywigother', true);
  5440. }
  5441. if ($category == 130 || $category == 133 || $category == 1702) {
  5442. $list['items'] = $this->input->post('items', true);
  5443. $list['weight'] = $this->input->post('weight', true);
  5444. }
  5445. if ($category == 1702) {
  5446. $list['syhairther'] = $this->input->post('syhairther', true);
  5447. }
  5448. foreach ($list as $k => $v) {
  5449. if ($v != 0) {
  5450. $num .= $v;
  5451. $features .= $v . '-';
  5452. $post[$k] = $v;
  5453. $typeclass = $this->typeclass->read($v);
  5454. if (isset($pm[$typeclass['classid']])) {
  5455. if (stripos($typeclass['zh'], '|') !== false) {
  5456. $exzh = explode('|', $typeclass['zh']);
  5457. $pm[$typeclass['classid']] = $exzh[0];
  5458. } else {
  5459. $pm[$typeclass['classid']] = $typeclass['zh'];
  5460. }
  5461. }
  5462. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5463. if ($k != 'size') {
  5464. $title .= $typeclass['title'] . " ";
  5465. }
  5466. }
  5467. }
  5468. $typeclass = $this->typeclass->read($list['size']);
  5469. $title .= $typeclass['title'];
  5470. $time = time();
  5471. $post['title'] = rtrim($title, ' ');
  5472. $post['number'] = $num;
  5473. $post['features'] = '-' . $features;
  5474. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5475. $featurespp = explode('-', trim($featurespp, '-'));
  5476. if (isset($featurespp[5])) {
  5477. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5478. } else {
  5479. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5480. }
  5481. $post['enter'] = $time;
  5482. $post['time'] = $time; //操作时间
  5483. $scsku = implode("-", $scsku);
  5484. $zh = implode(" ", $pm);
  5485. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5486. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5487. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5488. $post['sku'] = $bqsku;
  5489. $label = time() . rand(0, 9);
  5490. $post['label'] = $label;
  5491. $cpid = $this->whlabellabel->find_count();
  5492. $post['cpid'] = $cpid + 1;
  5493. $cpid = $post['cpid'];
  5494. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5495. //if($whlabelbarcode)
  5496. //{
  5497. //$post['label'] = $whlabelbarcode['label'];
  5498. //if(!$this->whlabellabel->insert($post))
  5499. //{
  5500. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5501. //}
  5502. //}
  5503. //else
  5504. //{
  5505. $this->db->trans_begin();
  5506. $this->whlabellabel->insert($post);
  5507. //$this->whlabelbarcode->insert($post);
  5508. if ($this->db->trans_status() === TRUE) {
  5509. $this->db->trans_commit();
  5510. } else {
  5511. $this->db->trans_rollback();
  5512. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5513. exit;
  5514. }
  5515. //}
  5516. $warehouse_name = "";
  5517. $warehouse = $post['warehouse'];
  5518. if($warehouse == 12){
  5519. $warehouse_name = "特殊库存库";
  5520. }
  5521. // if($warehouse == 13){
  5522. // $warehouse_name = "许昌仓";
  5523. // }
  5524. // if($warehouse == 5){
  5525. // $warehouse_name = "美国店";
  5526. // }
  5527. // if($warehouse == 16){
  5528. // $warehouse_name = "定制头套仓";
  5529. // }
  5530. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5531. if(!empty($warehouse_name)){
  5532. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5533. }
  5534. $purchase = $this->purchase->read($post['purchase']);
  5535. 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));
  5536. exit; //特殊仓目前不需要仓库选项
  5537. }
  5538. }
  5539. if (isset($_SESSION['api'])) {
  5540. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5541. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5542. $this->data['wlshop'] = $wlshop;
  5543. $this->data['warehouse'] = $warehouse;
  5544. }
  5545. $whlabelwz = $this->whlabelwz->find_all();
  5546. $this->data['whlabelwz'] = $whlabelwz;
  5547. $this->_Template('whlabel_print', $this->data);
  5548. }
  5549. public function _usaprint($arg_array)
  5550. {
  5551. if (isset($_SESSION['api'])) {
  5552. $user = $this->user->get_api($_SESSION['api']);
  5553. $usp = $user;
  5554. $fgshop = "";
  5555. $sid = "";
  5556. $wid = "";
  5557. $wtype = "";
  5558. $usersp = explode('|', trim($user['shop'], '|'));
  5559. $userwh = explode('|', trim($user['warehouse'], '|'));
  5560. foreach ($usersp as $value) {
  5561. $fgshop .= " shop = " . $value . " or";
  5562. $sid .= " id = " . $value . " or";
  5563. }
  5564. foreach ($userwh as $value) {
  5565. $wid .= " id = " . $value . " or";
  5566. $wtype .= " type = " . $value . " or";
  5567. }
  5568. }
  5569. $post = $this->input->post(NULL, TRUE);
  5570. if (isset($post['tmsku'])) {
  5571. $tmsku = $this->input->post('tmsku', true);
  5572. if (is_numeric($tmsku)) {
  5573. $yyh = $this->whlabellabel->get_label($tmsku);
  5574. } else {
  5575. $yyh = $this->whlabellabel->get_sku($tmsku);
  5576. }
  5577. if ($yyh) {
  5578. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5579. exit;
  5580. } else {
  5581. echo json_encode(array('success' => false));
  5582. exit;
  5583. }
  5584. }
  5585. $classid = $this->classid->sku();
  5586. $pm = $classid;
  5587. $scsku = $classid;
  5588. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5589. if (isset($post['warehouse'])) {
  5590. if ($post['warehouse']) {
  5591. $list = array();
  5592. $num = "";
  5593. $title = "";
  5594. $features = "";
  5595. $order = 0;
  5596. $post['shop'] = '';
  5597. $brand = $this->input->post('brand', true);
  5598. if ($brand != '0,') {
  5599. $b = $this->brand->read(rtrim($brand, ','));
  5600. if ($b) {
  5601. $post['shop'] = str_replace('|', ',', $b['shop']);
  5602. }
  5603. }
  5604. $post['details'] = $this->input->post('details', true); //打印数量
  5605. $xbqnum = $this->input->post('xbqnum', true);
  5606. $post['purchase'] = $this->input->post('purchase', true);
  5607. $post['warehouse'] = $this->input->post('warehouse', true);
  5608. $post['purchase'] = $this->input->post('purchase', true);
  5609. $post['retreatwarehouse'] = $post['warehouse'];
  5610. $post['cpbz'] = $this->input->post('cpbz', true);
  5611. $post['state'] = 9;
  5612. $category = $this->input->post('category', true);
  5613. $list['category'] = $category;
  5614. $list['hairtype'] = $this->input->post('hairtype', true);
  5615. $list['grade'] = $this->input->post('grade', true);
  5616. $size = $this->input->post('size', true);
  5617. $list['size'] = rtrim($size, ',');
  5618. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5619. $list['extension'] = $this->input->post('extension', true);
  5620. if ($category == 1297) {
  5621. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5622. }
  5623. if ($category == 1702) {
  5624. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5625. $list['syother'] = $this->input->post('syother', true);
  5626. }
  5627. if ($category == 133) {
  5628. $list['fittype'] = $this->input->post('fittype', true);
  5629. $list['acother'] = $this->input->post('acother', true);
  5630. }
  5631. $list['color'] = $this->input->post('color', true);
  5632. $list['lowe'] = $this->input->post('lowe', true);
  5633. if ($category == 127) {
  5634. $list['type'] = $this->input->post('type', true);
  5635. $list['headroad'] = $this->input->post('headroad', true);
  5636. $list['density'] = $this->input->post('density', true);
  5637. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5638. $list['lacesize'] = $this->input->post('lacesize', true);
  5639. }
  5640. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5641. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5642. }
  5643. if ($category == 128) {
  5644. $list['lacetype'] = $this->input->post('lacetype', true);
  5645. $list['haircap'] = $this->input->post('haircap', true);
  5646. $list['density'] = $this->input->post('density', true);
  5647. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5648. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5649. $list['wigother'] = $this->input->post('wigother', true);
  5650. $list['wigother1'] = $this->input->post('wigother1', true);
  5651. $list['wigother2'] = $this->input->post('wigother2', true);
  5652. }
  5653. if ($category == 129) {
  5654. $list['wide'] = $this->input->post('wide', true);
  5655. }
  5656. if ($category == 131) {
  5657. $list['gifttype'] = $this->input->post('gifttype', true);
  5658. $list['giftother'] = $this->input->post('giftother', true);
  5659. }
  5660. if ($category == 134) {
  5661. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5662. }
  5663. if ($category == 1297) {
  5664. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5665. $list['sywigother'] = $this->input->post('sywigother', true);
  5666. }
  5667. if ($category == 130 || $category == 133 || $category == 1702) {
  5668. $list['items'] = $this->input->post('items', true);
  5669. $list['weight'] = $this->input->post('weight', true);
  5670. }
  5671. if ($category == 1702) {
  5672. $list['syhairther'] = $this->input->post('syhairther', true);
  5673. }
  5674. foreach ($list as $k => $v) {
  5675. if ($v != 0) {
  5676. $num .= $v;
  5677. $features .= $v . '-';
  5678. $post[$k] = $v;
  5679. $typeclass = $this->typeclass->read($v);
  5680. if (isset($pm[$typeclass['classid']])) {
  5681. if (stripos($typeclass['zh'], '|') !== false) {
  5682. $exzh = explode('|', $typeclass['zh']);
  5683. $pm[$typeclass['classid']] = $exzh[0];
  5684. } else {
  5685. $pm[$typeclass['classid']] = $typeclass['zh'];
  5686. }
  5687. }
  5688. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5689. if ($k != 'size') {
  5690. $title .= $typeclass['title'] . " ";
  5691. }
  5692. }
  5693. }
  5694. $typeclass = $this->typeclass->read($list['size']);
  5695. $title .= $typeclass['title'];
  5696. $time = time();
  5697. $post['title'] = rtrim($title, ' ');
  5698. $post['number'] = $num;
  5699. $post['features'] = '-' . $features;
  5700. $fp = $this->whlabel->get_features($post['features']);
  5701. if (!$fp) {
  5702. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5703. exit;
  5704. }
  5705. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5706. $featurespp = explode('-', trim($featurespp, '-'));
  5707. if (isset($featurespp[5])) {
  5708. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5709. } else {
  5710. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5711. }
  5712. $post['enter'] = $time;
  5713. $post['time'] = $time; //操作时间
  5714. $scsku = implode("-", $scsku);
  5715. $zh = implode(" ", $pm);
  5716. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5717. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5718. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5719. $post['sku'] = $fp['sku'];
  5720. $post['label'] = $fp['sku'];
  5721. $cpid = $this->whlabellabel->find_count();
  5722. $post['cpid'] = $cpid + 1;
  5723. $cpid = $post['cpid'];
  5724. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5725. //if($whlabelbarcode)
  5726. //{
  5727. //$post['label'] = $whlabelbarcode['label'];
  5728. //if(!$this->whlabellabel->insert($post))
  5729. //{
  5730. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5731. //}
  5732. //}
  5733. //else
  5734. //{
  5735. $this->db->trans_begin();
  5736. $this->whlabellabel->insert($post);
  5737. //$this->whlabelbarcode->insert($post);
  5738. if ($this->db->trans_status() === TRUE) {
  5739. $this->db->trans_commit();
  5740. } else {
  5741. $this->db->trans_rollback();
  5742. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5743. exit;
  5744. }
  5745. //}
  5746. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5747. $purchase = $this->purchase->read($post['purchase']);
  5748. 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));
  5749. exit; //特殊仓目前不需要仓库选项
  5750. }
  5751. }
  5752. if (isset($_SESSION['api'])) {
  5753. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5754. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5755. $this->data['wlshop'] = $wlshop;
  5756. $this->data['warehouse'] = $warehouse;
  5757. }
  5758. $whlabelwz = $this->whlabelwz->find_all();
  5759. $this->data['whlabelwz'] = $whlabelwz;
  5760. $this->_Template('whlabel_usaprint', $this->data);
  5761. }
  5762. public function _printrk($arg_array)
  5763. {
  5764. $prc = array();
  5765. $purchase = $this->purchase->find_all();
  5766. foreach ($purchase as $k => $v) {
  5767. $prc[$v['id']] = $v['title'];
  5768. }
  5769. $post = $this->input->post(NULL, TRUE);
  5770. if (isset($post['page'])) {
  5771. $page = $this->input->post('page', true);
  5772. $perpage = $this->input->post('perpage', true);
  5773. $sku = $this->input->post('sku', true);
  5774. $bs = $this->input->post('bs', true);
  5775. $number = $this->input->post('number', true);
  5776. $warehouse = $this->input->post('warehouse', true);
  5777. $purchase = $this->input->post('purchase', true);
  5778. $orderinfo = $this->input->post('orderinfo', true);
  5779. $waybill = $this->input->post('waybill', true);
  5780. $category = $this->input->post('category', true);
  5781. $size = $this->input->post('size', true);
  5782. $grade = $this->input->post('grade', true);
  5783. $color = $this->input->post('color', true);
  5784. $lowe = $this->input->post('lowe', true);
  5785. $state = $this->input->post('state', true);
  5786. $label = $this->input->post('label', true);
  5787. $timetk = $this->input->post('ktime', true);
  5788. $timetj = $this->input->post('jtime', true);
  5789. $timetk = strtotime($timetk);
  5790. $timetj = strtotime($timetj);
  5791. $where = "1=1 ";
  5792. if ($timetk && $timetj) {
  5793. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5794. }
  5795. if ($sku) {
  5796. $where .= " and sku = '$sku'";
  5797. }
  5798. if ($bs != '') {
  5799. $where .= " and bs = '$bs'";
  5800. }
  5801. if ($number) {
  5802. $where .= " and number = '$number'";
  5803. }
  5804. if ($warehouse) {
  5805. $where .= " and warehouse = '$warehouse'";
  5806. }
  5807. if ($purchase) {
  5808. $where .= " and purchase = '$purchase'";
  5809. }
  5810. if ($orderinfo) {
  5811. $where .= " and orderinfo = '$orderinfo'";
  5812. }
  5813. if ($waybill) {
  5814. $where .= " and waybill = '$waybill'";
  5815. }
  5816. if ($category) {
  5817. $where .= " and features like '%-$category-%'";
  5818. }
  5819. if ($size) {
  5820. $where .= " and features like '%-$size-%'";
  5821. }
  5822. if ($grade) {
  5823. $where .= " and features like '%-$grade-%'";
  5824. }
  5825. if ($color) {
  5826. $where .= " and features like '%-$color-%'";
  5827. }
  5828. if ($lowe) {
  5829. $where .= " and features like '%-$lowe-%'";
  5830. }
  5831. if ($label) {
  5832. $where .= " and label = '$label'";
  5833. }
  5834. if ($state || $state == 0) {
  5835. $where .= " and state = '$state'";
  5836. }
  5837. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5838. //数据排序
  5839. $order_str = "enter desc";
  5840. if (empty($page)) {
  5841. $start = 0;
  5842. $perpage = 1;
  5843. } else {
  5844. $start = ($page - 1) * $perpage;
  5845. }
  5846. //取得信息列表
  5847. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5848. foreach ($info_list as $key => $value) {
  5849. $warehouse = $this->warehouse->read($value['warehouse']);
  5850. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5851. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5852. if ($value['state'] == 0) {
  5853. $info_list[$key]['state'] = "在库";
  5854. } else if ($value['state'] == 1) {
  5855. $info_list[$key]['state'] = "出库";
  5856. } else if ($value['state'] == 2) {
  5857. $info_list[$key]['state'] = "退库";
  5858. } else if ($value['state'] == 3) {
  5859. $info_list[$key]['state'] = "调拨中";
  5860. } else if ($value['state'] == 4) {
  5861. $info_list[$key]['state'] = "再加工";
  5862. } else if ($value['state'] == 5) {
  5863. $info_list[$key]['state'] = "维修中";
  5864. } else if ($value['state'] == 6) {
  5865. $info_list[$key]['state'] = "盘亏";
  5866. } else if ($value['state'] == 7) {
  5867. $info_list[$key]['state'] = "更换标签";
  5868. } else if ($value['state'] == 8) {
  5869. $info_list[$key]['state'] = "其它";
  5870. } else if ($value['state'] == 9) {
  5871. $info_list[$key]['state'] = "预设";
  5872. } else if ($value['state'] == 10) {
  5873. $info_list[$key]['state'] = "美店零售";
  5874. }
  5875. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5876. }
  5877. $total = $this->$ck->find_count($where);
  5878. $pagenum = ceil($total / $perpage);
  5879. $over = $total - ($start + $perpage);
  5880. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5881. echo json_encode($rows);
  5882. exit;
  5883. }
  5884. if (isset($post['tmsku'])) {
  5885. $time = time();
  5886. $tmsku = $this->input->post('tmsku', true);
  5887. //$post['shop'] = $this->input->post('shop',true);
  5888. $num = $this->input->post('num', true);
  5889. $rktype = $this->input->post('rktype', true);
  5890. if ($num > 200) {
  5891. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5892. exit;
  5893. }
  5894. if (!$rktype) {
  5895. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5896. }
  5897. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5898. /**
  5899. $wz = array();
  5900. foreach ($rk as $key=>$value)
  5901. {
  5902. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5903. }
  5904. if(count($wz) > 1)
  5905. {
  5906. $wz = array_values($wz);
  5907. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  5908. }
  5909. **/
  5910. if (isset($rk[0]['purchase'])) {
  5911. $rk = $rk[0];
  5912. $j = 0;
  5913. $post['purchase'] = $rk['purchase'];
  5914. $post['warehouse'] = $rk['warehouse'];
  5915. $post['retreatwarehouse'] = $rk['warehouse'];
  5916. $post['sku'] = $rk['sku'];
  5917. $post['number'] = $rk['number'];
  5918. $post['features'] = $rk['features'];
  5919. $post['title'] = $rk['title'];
  5920. $post['enter'] = $time;
  5921. $post['time'] = $time;
  5922. $post['bs'] = 1;
  5923. $post['shop'] = $rk['shop'];
  5924. $post['details'] = $rk['details'];
  5925. $post['cpid'] = $rk['cpid'];
  5926. $post['cpbz'] = $rk['cpbz'];
  5927. //$post['rktype'] = $rktype;
  5928. $warehouse = $this->warehouse->read($rk['warehouse']);
  5929. if ($warehouse['bdck'] == '') {
  5930. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  5931. exit;
  5932. } else {
  5933. $bdck = $warehouse['bdck'];
  5934. }
  5935. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  5936. if (isset($pdwz['details'])) {
  5937. if ($pdwz['details'] != $post['details']) {
  5938. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  5939. exit;
  5940. }
  5941. }
  5942. $post['featurespp'] = $rk['featurespp'];
  5943. if ($post['warehouse'] == '5') {
  5944. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5945. if ($yza) {
  5946. if ($post['features'] != $yza[0]['features']) {
  5947. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  5948. exit;
  5949. }
  5950. }
  5951. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5952. if ($yzb) {
  5953. if ($post['sku'] != $yzb[0]['sku']) {
  5954. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  5955. exit;
  5956. }
  5957. }
  5958. }
  5959. for ($i = 0; $i < $num; $i++) {
  5960. $post['label'] = time() . rand(100, 999) . $i;
  5961. if ($this->$bdck->insert($post)) {
  5962. $j++;
  5963. }
  5964. }
  5965. /**
  5966. if($post['warehouse'] != 12)
  5967. {
  5968. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5969. }
  5970. **/
  5971. if ($j == $num) {
  5972. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  5973. exit;
  5974. } else {
  5975. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  5976. exit;
  5977. }
  5978. } else {
  5979. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  5980. exit;
  5981. }
  5982. }
  5983. $this->_Template('whlabel_printrk', $this->data);
  5984. }
  5985. public function _printxzrk($arg_array)
  5986. {
  5987. $post = $this->input->post(NULL, TRUE);
  5988. if (isset($post['wzid'])) {
  5989. $time = time();
  5990. $id = $this->input->post('wzid', true);
  5991. //$post['shop'] = $this->input->post('shop',true);
  5992. $num = 1;
  5993. $rk = $this->whlabellabel->read($id);
  5994. if (isset($rk['purchase'])) {
  5995. $x = 0;
  5996. $post['purchase'] = $rk['purchase'];
  5997. $post['warehouse'] = $rk['warehouse'];
  5998. $post['retreatwarehouse'] = $rk['warehouse'];
  5999. $post['sku'] = $rk['sku'];
  6000. $post['number'] = $rk['number'];
  6001. $post['features'] = $rk['features'];
  6002. $post['title'] = $rk['title'];
  6003. $post['enter'] = $time;
  6004. $post['time'] = $time;
  6005. $post['bs'] = 1;
  6006. $post['shop'] = $rk['shop'];
  6007. $post['details'] = $rk['details'];
  6008. $post['cpid'] = $rk['cpid'];
  6009. $post['cpbz'] = $rk['cpbz'];
  6010. $warehouse = $this->warehouse->read($rk['warehouse']);
  6011. if ($warehouse['bdck'] == '') {
  6012. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6013. exit;
  6014. } else {
  6015. $bdck = $warehouse['bdck'];
  6016. }
  6017. $post['featurespp'] = $rk['featurespp'];
  6018. $this->db->trans_begin();
  6019. for ($i = 0; $i < $num; $i++) {
  6020. $post['label'] = time() . rand(100, 999) . $i;
  6021. $this->$bdck->insert($post);
  6022. }
  6023. /**
  6024. if($post['warehouse'] != 12)
  6025. {
  6026. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6027. }
  6028. **/
  6029. if ($this->db->trans_status() === TRUE) {
  6030. $this->db->trans_commit();
  6031. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6032. exit;
  6033. } else {
  6034. $this->db->trans_rollback();
  6035. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6036. exit;
  6037. }
  6038. } else {
  6039. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6040. exit;
  6041. }
  6042. }
  6043. }
  6044. public function _printck($arg_array)
  6045. {
  6046. $prc = array();
  6047. $purchase = $this->purchase->find_all();
  6048. foreach ($purchase as $k => $v) {
  6049. $prc[$v['id']] = $v['title'];
  6050. }
  6051. $post = $this->input->post(NULL, TRUE);
  6052. if (isset($post['page'])) {
  6053. $page = $this->input->post('page', true);
  6054. $perpage = $this->input->post('perpage', true);
  6055. $sku = $this->input->post('sku', true);
  6056. $bs = $this->input->post('bs', true);
  6057. $number = $this->input->post('number', true);
  6058. $warehouse = $this->input->post('warehouse', true);
  6059. $purchase = $this->input->post('purchase', true);
  6060. $orderinfo = $this->input->post('orderinfo', true);
  6061. $waybill = $this->input->post('waybill', true);
  6062. $category = $this->input->post('category', true);
  6063. $size = $this->input->post('size', true);
  6064. $grade = $this->input->post('grade', true);
  6065. $color = $this->input->post('color', true);
  6066. $lowe = $this->input->post('lowe', true);
  6067. $state = $this->input->post('state', true);
  6068. $label = $this->input->post('label', true);
  6069. $timetk = $this->input->post('ktime', true);
  6070. $timetj = $this->input->post('jtime', true);
  6071. $timetk = strtotime($timetk);
  6072. $timetj = strtotime($timetj);
  6073. $where = "state=1 ";
  6074. if ($timetk && $timetj) {
  6075. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6076. }
  6077. if ($sku) {
  6078. $where .= " and sku = '$sku'";
  6079. }
  6080. if ($bs != '') {
  6081. $where .= " and bs = '$bs'";
  6082. }
  6083. if ($number) {
  6084. $where .= " and number = '$number'";
  6085. }
  6086. if ($warehouse) {
  6087. $where .= " and warehouse = '$warehouse'";
  6088. }
  6089. if ($purchase) {
  6090. $where .= " and purchase = '$purchase'";
  6091. }
  6092. if ($orderinfo) {
  6093. $where .= " and orderinfo = '$orderinfo'";
  6094. }
  6095. if ($waybill) {
  6096. $where .= " and waybill = '$waybill'";
  6097. }
  6098. if ($category) {
  6099. $where .= " and features like '%-$category-%'";
  6100. }
  6101. if ($size) {
  6102. $where .= " and features like '%-$size-%'";
  6103. }
  6104. if ($grade) {
  6105. $where .= " and features like '%-$grade-%'";
  6106. }
  6107. if ($color) {
  6108. $where .= " and features like '%-$color-%'";
  6109. }
  6110. if ($lowe) {
  6111. $where .= " and features like '%-$lowe-%'";
  6112. }
  6113. if ($label) {
  6114. $where .= " and label = '$label'";
  6115. }
  6116. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6117. //数据排序
  6118. $order_str = "outk desc";
  6119. if (empty($page)) {
  6120. $start = 0;
  6121. $perpage = 1;
  6122. } else {
  6123. $start = ($page - 1) * $perpage;
  6124. }
  6125. //取得信息列表
  6126. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6127. foreach ($info_list as $key => $value) {
  6128. $warehouse = $this->warehouse->read($value['warehouse']);
  6129. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6130. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6131. if ($value['state'] == 0) {
  6132. $info_list[$key]['state'] = "在库";
  6133. } else if ($value['state'] == 1) {
  6134. $info_list[$key]['state'] = "出库";
  6135. } else if ($value['state'] == 2) {
  6136. $info_list[$key]['state'] = "退库";
  6137. } else if ($value['state'] == 3) {
  6138. $info_list[$key]['state'] = "调拨中";
  6139. } else if ($value['state'] == 4) {
  6140. $info_list[$key]['state'] = "再加工";
  6141. } else if ($value['state'] == 5) {
  6142. $info_list[$key]['state'] = "维修中";
  6143. } else if ($value['state'] == 6) {
  6144. $info_list[$key]['state'] = "盘亏";
  6145. } else if ($value['state'] == 7) {
  6146. $info_list[$key]['state'] = "更换标签";
  6147. } else if ($value['state'] == 8) {
  6148. $info_list[$key]['state'] = "其它";
  6149. } else if ($value['state'] == 9) {
  6150. $info_list[$key]['state'] = "预设";
  6151. } else if ($value['state'] == 10) {
  6152. $info_list[$key]['state'] = "美店零售";
  6153. }
  6154. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6155. }
  6156. $total = $this->$ck->find_count($where);
  6157. $pagenum = ceil($total / $perpage);
  6158. $over = $total - ($start + $perpage);
  6159. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6160. echo json_encode($rows);
  6161. exit;
  6162. }
  6163. if (isset($post['tmsku'])) {
  6164. $time = time();
  6165. $tmsku = $this->input->post('tmsku', true);
  6166. //$post['shop'] = $this->input->post('shop',true);
  6167. $num = $this->input->post('num', true);
  6168. $cktype = $this->input->post('cktype', true);
  6169. $label = $this->whlabellabel->get_label($tmsku);
  6170. if (!$cktype) {
  6171. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6172. }
  6173. if (!isset($label['warehouse'])) {
  6174. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6175. exit;
  6176. }
  6177. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6178. if (stripos($label['features'], '-126-') !== false) {
  6179. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6180. } else {
  6181. $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 = ''");
  6182. }
  6183. $j = 0;
  6184. if (count($ck) >= $num) {
  6185. for ($i = 0; $i < $num; $i++) {
  6186. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6187. {
  6188. $j++;
  6189. }
  6190. }
  6191. if ($j == $num) {
  6192. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6193. exit;
  6194. } else {
  6195. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6196. exit;
  6197. }
  6198. } else {
  6199. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6200. exit;
  6201. }
  6202. }
  6203. if(isset($_SESSION['api']))
  6204. {
  6205. $user = $this->user->get_api($_SESSION['api']);
  6206. if(in_array($user['power'],[1,27])){
  6207. $vip = 1;
  6208. }
  6209. }
  6210. else
  6211. {
  6212. $vip = 0;
  6213. header('Location: /');exit;
  6214. }
  6215. $this->data['vip'] = $vip;
  6216. $this->_Template('whlabel_printck', $this->data);
  6217. }
  6218. public function _printexcel()
  6219. {
  6220. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6221. $config['upload_path'] = '.' . $dir;
  6222. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6223. $config['allowed_types'] = 'xls|xlsx|csv';
  6224. $config['max_size'] = 10240;
  6225. $this->load->library('upload', $config);
  6226. $this->upload->initialize($config);
  6227. if ($this->upload->do_upload('userfile')) {
  6228. $full_path = $dir . $this->upload->data('file_name');
  6229. $fileName = '.' . $full_path;
  6230. if (!file_exists($fileName)) {
  6231. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6232. exit;
  6233. } else {
  6234. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6235. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6236. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6237. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6238. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6239. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6240. ++$column; //如果列数大于26行
  6241. $list = array();
  6242. for ($i = 2; $i <= $row; $i++) // 行数循环
  6243. {
  6244. $data = array();
  6245. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6246. {
  6247. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6248. }
  6249. $list[] = $data;
  6250. }
  6251. }
  6252. $ed = array();
  6253. $i = 0;
  6254. $j = 0;
  6255. $dcdata = array();
  6256. $yc = '';
  6257. $cmf_arr = array_column($list, '1');
  6258. array_multisort($cmf_arr, SORT_ASC, $list);
  6259. foreach ($list as $key => $value) {
  6260. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6261. if ($typeclass) {
  6262. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6263. } else {
  6264. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6265. $i++;
  6266. continue;
  6267. }
  6268. }
  6269. if ($i > 0) {
  6270. $yc = $i . '条异常';
  6271. }
  6272. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6273. exit;
  6274. }
  6275. }
  6276. public function _uck()
  6277. {
  6278. if (isset($_GET['excel'])) {
  6279. $tc = array();
  6280. $typeclass = $this->typeclass->find_all();
  6281. foreach ($typeclass as $v) {
  6282. $tc[$v['id']] = $v['zh'];
  6283. }
  6284. $data = array();
  6285. $t = array();
  6286. $rq = '';
  6287. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6288. $ts = $ts / (24 * 3600);
  6289. for ($i = 0; $i < $ts; $i++) {
  6290. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6291. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6292. }
  6293. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6294. foreach ($info_list as $k => $v) {
  6295. $features = explode('-', trim($v['features'], '-'));
  6296. if (!isset($features[3]) || !isset($features[4])) {
  6297. continue;
  6298. }
  6299. $data[$k][0] = $tc[$features[0]]; //类型
  6300. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6301. $data[$k][2] = $tc[$features[4]]; //曲度
  6302. $data[$k][3] = '';
  6303. if (isset($data[$k][1])) {
  6304. $data[$k][3] .= $data[$k][1];
  6305. }
  6306. if (isset($data[$k][2])) {
  6307. $data[$k][3] .= $data[$k][2];
  6308. }
  6309. if (isset($features[5])) {
  6310. $data[$k][3] .= $tc[$features[5]];
  6311. }
  6312. if (isset($features[2])) {
  6313. $data[$k][3] .= $tc[$features[2]];
  6314. }
  6315. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6316. $data[$k][4] = $v['sku'];
  6317. $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())) . '))'); //月初库存
  6318. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6319. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6320. $ztrq = '';
  6321. $ztsl = '';
  6322. if (count($zt) > 0) {
  6323. foreach ($zt as $vv) {
  6324. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6325. $ztsl .= $vv['num'] . '<br>';
  6326. }
  6327. }
  6328. $data[$k][] = trim($ztsl, '<br>');
  6329. $data[$k][] = trim($ztrq, '<br>');
  6330. $byck = 0;
  6331. foreach ($t as $vv) {
  6332. $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));
  6333. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6334. $byck += $sl;
  6335. }
  6336. $data[$k][] = ($byck > 0) ? $byck : '';
  6337. }
  6338. $title = "详情 " . date("Y-m-d", time());
  6339. $titlename = "<table border=1>
  6340. <tr align='center'>
  6341. <td>类别</td>
  6342. <td>颜色</td>
  6343. <td>曲度</td>
  6344. <td>名称</td>
  6345. <td>SKU</td>
  6346. <td>月初库存</td>
  6347. <td>剩余库存</td>
  6348. <td>在途数量</td>
  6349. <td>预达日期</td>" .
  6350. $rq
  6351. . "<td>本月出库</td></tr>
  6352. </table>";
  6353. $filename = $title . ".xls";
  6354. $tail = "";
  6355. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6356. }
  6357. }
  6358. public function _whlabelexcelzh()
  6359. {
  6360. if (isset($_GET['excel'])) {
  6361. $where = "sku != 'Preset'";
  6362. //数据排序
  6363. $order_str = "id desc";
  6364. if (empty($page)) {
  6365. $start = 0;
  6366. $perpage = 1;
  6367. } else {
  6368. $start = ($page - 1) * $perpage;
  6369. }
  6370. $category = $this->input->get('category', true);
  6371. $warehouse = $this->input->get('warehouse', true);
  6372. $excelid = $this->input->get('sid', true);
  6373. if ($category) {
  6374. $where .= " and features like '%-$category-%'";
  6375. }
  6376. if ($warehouse) {
  6377. $where .= " and warehouse = '$warehouse'";
  6378. }
  6379. $xzid = '';
  6380. if ($excelid) {
  6381. $excelid = explode(',', trim($excelid, ','));
  6382. foreach ($excelid as $key => $value) {
  6383. $xzid .= " id = " . $value . " or";
  6384. }
  6385. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6386. }
  6387. //取得信息列表
  6388. /**
  6389. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6390. $rows = array();$list = array();
  6391. foreach ($info_list as $key=>$value)
  6392. {
  6393. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6394. }
  6395. **/
  6396. $list = array();
  6397. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6398. foreach ($rows as $key => $value) {
  6399. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6400. $zh = '';
  6401. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6402. foreach ($zt as $v) {
  6403. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6404. }
  6405. $zt = array_sum(array_column($zt, 'num'));
  6406. $number = $value['number'];
  6407. $ftime = time() - 15 * 24 * 3600;
  6408. $warehouse = $this->warehouse->read($value['warehouse']);
  6409. $rows[$key]['warehouse'] = $warehouse['title'];
  6410. $rows[$key]['number'] = $c;
  6411. $rows[$key]['features'] = $zh;
  6412. $rows[$key]['hb'] = $c + $zt;
  6413. }
  6414. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6415. $titlename = "<table border=1>
  6416. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6417. <tr align='center'>
  6418. <td>仓库</td>
  6419. <td>SKU</td>
  6420. <td>产品</td>
  6421. <td>库存数量</td>
  6422. <td>在途数量及预达日期</td>
  6423. <td>在途+库存数量</td>
  6424. </tr>
  6425. </table>";
  6426. $filename = $title . ".xls";
  6427. $tail = "";
  6428. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6429. }
  6430. if (isset($_GET['excel'])) {
  6431. $warehouse = $this->input->get('warehouse', true);
  6432. $sku = $this->input->get('sku', true);
  6433. $cz = $this->input->get('cz', true);
  6434. $text = $this->input->post('text', true);
  6435. $xztime = $this->input->get('xztime', true);
  6436. $timetk = $this->input->get('timetk', true);
  6437. $timetj = $this->input->get('timetj', true);
  6438. $timetk = strtotime($timetk);
  6439. $timetj = strtotime($timetj);
  6440. $where = "time = '0' ";
  6441. if ($warehouse) {
  6442. $where .= " and warehouse = '$warehouse'";
  6443. }
  6444. if ($sku) {
  6445. $where .= " and sku = '$sku'";
  6446. }
  6447. if ($text) {
  6448. $where .= " and text like '%$text%'";
  6449. }
  6450. if ($cz != '') {
  6451. $where .= " and cz = '$cz'";
  6452. }
  6453. if ($timetk && $timetj) {
  6454. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6455. }
  6456. //数据排序
  6457. $order_str = $xztime . " desc";
  6458. //取得信息列表
  6459. $zh = array();
  6460. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6461. foreach ($info_list as $v) {
  6462. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6463. $warehouse = $this->warehouse->read($v['warehouse']);
  6464. $v['warehouse'] = $warehouse['title'];
  6465. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6466. $v['stime'] = date('Y-m-d', $v['stime']);
  6467. if (isset($zh[$v['features']])) {
  6468. $zh[$v['features']]['num'] += $v['num'];
  6469. } else {
  6470. $zh[$v['features']] = $v;
  6471. }
  6472. $zh[$v['features']]['features'] = $c;
  6473. }
  6474. $title = "在途数据" . date('Y-m-d', time());
  6475. $titlename = "<table border=1>
  6476. <tr align='center'>
  6477. <td>仓库</td>
  6478. <td>SKU</td>
  6479. <td>名称</td>
  6480. <td>在途数量</td>
  6481. <td>库存数量</td>
  6482. <td>添加在途日期</td>
  6483. <td>预达日期</td>
  6484. <td>备注</td>
  6485. </tr>
  6486. </table>";
  6487. $filename = $title . ".xls";
  6488. $tail = "";
  6489. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6490. }
  6491. }
  6492. public function _fc()
  6493. {
  6494. $vip = 0;
  6495. if (isset($_SESSION['api'])) {
  6496. $user = $this->user->get_api($_SESSION['api']);
  6497. if ($user['vip'] == 1) {
  6498. $vip = 1;
  6499. }
  6500. } else {
  6501. header('Location: /');
  6502. exit;
  6503. }
  6504. $post = $this->input->post(NULL, TRUE);
  6505. if (isset($post['page'])) {
  6506. $page = $this->input->post('page', true);
  6507. $perpage = $this->input->post('perpage', true);
  6508. $category = $this->input->post('category', true);
  6509. $size = $this->input->post('size', true);
  6510. $grade = $this->input->post('grade', true);
  6511. $color = $this->input->post('color', true);
  6512. $lowe = $this->input->post('lowe', true);
  6513. $sku = $this->input->post('sku');
  6514. $title = $this->input->post('title');
  6515. $warehouse = $this->input->post('warehouse', true);
  6516. $usa = $this->input->post('usa', true);
  6517. $purchase = $this->input->post('purchase', true);
  6518. $lacetype = $this->input->post('lacetype', true);
  6519. $haircap = $this->input->post('haircap', true);
  6520. $density = $this->input->post('density', true);
  6521. $details = $this->input->post('details', true);
  6522. $state = $this->input->post('state', true);
  6523. $ktime = $this->input->post('ktime', true);
  6524. $jtime = $this->input->post('jtime', true);
  6525. $ktime = strtotime($ktime);
  6526. $jtime = strtotime($jtime);
  6527. $where = "state = '11'";
  6528. $gj = "";
  6529. $ck = "";
  6530. if ($lacetype) {
  6531. $where .= " and features like '%-$lacetype-%'";
  6532. }
  6533. if ($category) {
  6534. $where .= " and features like '%-$category-%'";
  6535. }
  6536. if ($size) {
  6537. $where .= " and features like '%-$size-%'";
  6538. }
  6539. if ($grade) {
  6540. $where .= " and features like '%-$grade-%'";
  6541. }
  6542. if ($color) {
  6543. $where .= " and features like '%-$color-%'";
  6544. }
  6545. if ($lowe) {
  6546. $where .= " and features like '%-$lowe-%'";
  6547. }
  6548. if ($haircap) {
  6549. $where .= " and features like '%-$haircap-%'";
  6550. }
  6551. if ($density) {
  6552. $where .= " and features like '%-$density-%'";
  6553. }
  6554. if ($usa) {
  6555. if (!$warehouse) {
  6556. $where .= " and (warehouse = '5' or warehouse = '8')";
  6557. }
  6558. }
  6559. if ($warehouse) {
  6560. $where .= " and warehouse = '$warehouse'";
  6561. }
  6562. if ($details) {
  6563. $where .= " and details = '$details'";
  6564. }
  6565. if ($purchase) {
  6566. $where .= " and purchase = '$purchase'";
  6567. }
  6568. if ($state) {
  6569. $where .= " and state = '$state'";
  6570. }
  6571. if ($ktime && $jtime) {
  6572. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6573. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6574. }
  6575. //数据排序
  6576. $order_str = "id desc";
  6577. if (empty($page)) {
  6578. $start = 0;
  6579. $perpage = 1;
  6580. } else {
  6581. $start = ($page - 1) * $perpage;
  6582. }
  6583. if ($sku) {
  6584. $sku = trim($sku, ' ');
  6585. $sku = trim($sku, ' ');
  6586. $where .= " and sku like '%$sku%'";
  6587. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6588. } else if ($title) {
  6589. $title = trim($title, ' ');
  6590. $title = trim($title, ' ');
  6591. $where .= " and title like '%$title%'";
  6592. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6593. } else {
  6594. //$where .= " and time > '$ktime' and time < '$jtime'";
  6595. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6596. }
  6597. //取得信息列表
  6598. $rows = array();
  6599. $list = array();
  6600. foreach ($info_list as $key => $value) {
  6601. $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'] . '"');
  6602. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6603. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6604. $warehouse = $this->warehouse->read($value['warehouse']);
  6605. $info_list[$key]['warehouse'] = $warehouse['title'];
  6606. $info_list[$key]['number'] = $g;
  6607. $info_list[$key]['features'] = $x;
  6608. $info_list[$key]['x'] = $s;
  6609. }
  6610. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6611. $pagenum = ceil($total / $perpage);
  6612. $over = $total - ($start + $perpage);
  6613. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6614. echo json_encode($rows);
  6615. exit;
  6616. }
  6617. $this->data['vip'] = $vip;
  6618. $this->_Template('whlabel_fc', $this->data);
  6619. }
  6620. public function _fcmb()
  6621. {
  6622. $where = "sku != 'Preset'";
  6623. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6624. foreach ($rows as $k => $v) {
  6625. $warehouse = $this->warehouse->read($v['warehouse']);
  6626. $rows[$k]['warehouse'] = $warehouse['title'];
  6627. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6628. $rows[$k]['t'] = '';
  6629. $rows[$k]['n'] = '';
  6630. }
  6631. $title = "封货产品数据导入模板";
  6632. $titlename = "<table border=1>
  6633. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6634. <tr align='center'>
  6635. <td>仓库</td>
  6636. <td>SKU</td>
  6637. <td>产品</td>
  6638. <td>封存产品总数量</td>
  6639. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6640. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6641. </tr>
  6642. </table>";
  6643. $filename = $title . ".xls";
  6644. $tail = "";
  6645. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6646. }
  6647. public function _fcexcel()
  6648. {
  6649. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6650. $config['upload_path'] = '.' . $dir;
  6651. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6652. $config['allowed_types'] = 'xls|xlsx|csv';
  6653. $config['max_size'] = 10240;
  6654. $this->load->library('upload', $config);
  6655. $this->upload->initialize($config);
  6656. if ($this->upload->do_upload('userfile')) {
  6657. $full_path = $dir . $this->upload->data('file_name');
  6658. $fileName = '.' . $full_path;
  6659. if (!file_exists($fileName)) {
  6660. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6661. exit;
  6662. } else {
  6663. libxml_use_internal_errors(true);
  6664. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6665. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6666. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6667. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6668. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6669. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6670. ++$column; //如果列数大于26行
  6671. $list = array();
  6672. for ($i = 2; $i <= $row; $i++) // 行数循环
  6673. {
  6674. $data = array();
  6675. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6676. {
  6677. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6678. }
  6679. $list[] = $data;
  6680. }
  6681. }
  6682. $i = 0;
  6683. $j = 0;
  6684. $ed = array();
  6685. foreach ($list as $key => $value) {
  6686. $time = time();
  6687. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6688. continue;
  6689. }
  6690. $warehouse = $this->warehouse->get_title($value['0']);
  6691. $sku = $value['1'];
  6692. $type = $value['4']; //调整方式0扣减1删除
  6693. $num = $value['5']; //调整数量
  6694. //$text = $value['4'];//扣减说明
  6695. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6696. if (!$d) //如果没有这个SKU
  6697. {
  6698. $ed[] = array($sku . '-库存中不存在此SKU');
  6699. $j++;
  6700. continue;
  6701. }
  6702. if (!isset($warehouse['id'])) {
  6703. $ed[] = array($sku . '-仓库名错误!');
  6704. $j++;
  6705. continue;
  6706. }
  6707. if ($type == 1 || $type == 2) //扣减库存
  6708. {
  6709. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6710. if (count($data) < abs($num)) {
  6711. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6712. $j++;
  6713. continue;
  6714. }
  6715. if ($type == 1) //转入库存
  6716. {
  6717. for ($i = 0; $i < abs($num); $i++) {
  6718. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6719. }
  6720. } else if ($type == 2) //删除
  6721. {
  6722. for ($i = 0; $i < abs($num); $i++) {
  6723. $this->whlabel->remove($data[$i]['id']);
  6724. }
  6725. }
  6726. } else if ($type == 0) //增加库存
  6727. {
  6728. $post['sku'] = $d['sku'];
  6729. $post['shop'] = '';
  6730. $post['warehouse'] = $warehouse['id'];
  6731. $post['purchase'] = $d['purchase'];
  6732. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6733. $post['state'] = 11;
  6734. $post['title'] = $d['title'];
  6735. $post['number'] = $d['number'];
  6736. $post['features'] = $d['features'];
  6737. $post['enter'] = $time;
  6738. $post['time'] = $time; //操作时间
  6739. for ($i = 0; $i < $num; $i++) {
  6740. $post['label'] = time() . rand(100, 999) . $i;
  6741. $this->whlabel->insert($post);
  6742. }
  6743. }
  6744. sleep(1); //防止入库时间一样,需要延迟1秒
  6745. }
  6746. if ($j > 0) {
  6747. $tt = date('Ymd', time());
  6748. $title = '库存导入错误信息-' . $tt;
  6749. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6750. $tail = "\n";
  6751. $filename = $title . ".xls";
  6752. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6753. $dir = '/data/excel/' . $time . '/';
  6754. $file_name = 'error_' . $time . rand(1000, 9999);
  6755. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6756. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6757. fwrite($myfile, $ecl);
  6758. fclose($myfile);
  6759. $error = $dir . $file_name . '.xls';
  6760. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6761. exit;
  6762. } else {
  6763. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6764. exit;
  6765. }
  6766. }
  6767. }
  6768. public function _fcjxc($arg_array)
  6769. {
  6770. if (isset($_GET['excel'])) {
  6771. $category = $this->input->get('category', true);
  6772. $size = $this->input->get('size', true);
  6773. $grade = $this->input->get('grade', true);
  6774. $color = $this->input->get('color', true);
  6775. $lowe = $this->input->get('lowe', true);
  6776. $sku = $this->input->get('sku');
  6777. $title = $this->input->get('title');
  6778. $warehouse = $arg_array[0];
  6779. $usa = $this->input->get('usa', true);
  6780. $purchase = $this->input->get('purchase', true);
  6781. $lacetype = $this->input->get('lacetype', true);
  6782. $haircap = $this->input->get('haircap', true);
  6783. $density = $this->input->get('density', true);
  6784. $title = $this->input->get('title', true);
  6785. $state = $this->input->get('state', true);
  6786. $ktime = $this->input->get('ktime', true);
  6787. $jtime = $this->input->get('jtime', true);
  6788. $where = "state=11";
  6789. $gj = "";
  6790. $ck = "";
  6791. if ($lacetype) {
  6792. $where .= " and features like '%-$lacetype-%'";
  6793. }
  6794. if ($category) {
  6795. $where .= " and features like '%-$category-%'";
  6796. }
  6797. if ($size) {
  6798. $where .= " and features like '%-$size-%'";
  6799. }
  6800. if ($grade) {
  6801. $where .= " and features like '%-$grade-%'";
  6802. }
  6803. if ($color) {
  6804. $where .= " and features like '%-$color-%'";
  6805. }
  6806. if ($lowe) {
  6807. $where .= " and features like '%-$lowe-%'";
  6808. }
  6809. if ($haircap) {
  6810. $where .= " and features like '%-$haircap-%'";
  6811. }
  6812. if ($density) {
  6813. $where .= " and features like '%-$density-%'";
  6814. }
  6815. if ($usa) {
  6816. if (!$warehouse) {
  6817. $where .= " and (warehouse = '5' or warehouse = '8')";
  6818. }
  6819. }
  6820. if ($warehouse) {
  6821. $where .= " and warehouse = '$warehouse'";
  6822. }
  6823. if ($purchase) {
  6824. $where .= " and purchase = '$purchase'";
  6825. }
  6826. if ($state) {
  6827. $where .= " and state = '$state'";
  6828. }
  6829. $order_str = "id desc";
  6830. if ($sku) {
  6831. $sku = trim($sku, ' ');
  6832. $sku = trim($sku, ' ');
  6833. $where .= " and sku like '%$sku%'";
  6834. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6835. } else if ($title) {
  6836. $title = trim($title, ' ');
  6837. $title = trim($title, ' ');
  6838. $where .= " and title like '%$title%'";
  6839. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6840. } else {
  6841. //$where .= " and time > '$ktime' and time < '$jtime'";
  6842. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6843. }
  6844. //取得信息列表
  6845. $rows = array();
  6846. $list = array();
  6847. foreach ($info_list as $key => $value) {
  6848. $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'] . '"');
  6849. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6850. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6851. $rows[$key] = $value;
  6852. $warehouse = $this->warehouse->read($value['warehouse']);
  6853. $rows[$key]['warehouse'] = $warehouse['title'];
  6854. $rows[$key]['features'] = $g;
  6855. $rows[$key]['a'] = $x;
  6856. $rows[$key]['b'] = $s;
  6857. }
  6858. $title = "总统计表";
  6859. $titlename = "<table border=1>
  6860. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6861. <tr align='center'>
  6862. <td>仓库</td>
  6863. <td>SKU</td>
  6864. <td>产品名称</td>
  6865. <td>录入总量</td>
  6866. <td>取出总量</td>
  6867. <td>剩余总量</td>
  6868. </tr>
  6869. </table>";
  6870. $filename = $title . ".xls";
  6871. $tail = "";
  6872. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6873. }
  6874. $vip = 0;
  6875. if (isset($_SESSION['api'])) {
  6876. $user = $this->user->get_api($_SESSION['api']);
  6877. if ($user['vip'] == 1) {
  6878. $vip = 1;
  6879. }
  6880. } else {
  6881. header('Location: /');
  6882. exit;
  6883. }
  6884. $post = $this->input->post(NULL, TRUE);
  6885. if (isset($post['page'])) {
  6886. $page = $this->input->post('page', true);
  6887. $perpage = $this->input->post('perpage', true);
  6888. $category = $this->input->post('category', true);
  6889. $size = $this->input->post('size', true);
  6890. $grade = $this->input->post('grade', true);
  6891. $color = $this->input->post('color', true);
  6892. $lowe = $this->input->post('lowe', true);
  6893. $sku = $this->input->post('sku');
  6894. $title = $this->input->post('title');
  6895. $warehouse = $arg_array[0];
  6896. $usa = $this->input->post('usa', true);
  6897. $purchase = $this->input->post('purchase', true);
  6898. $lacetype = $this->input->post('lacetype', true);
  6899. $haircap = $this->input->post('haircap', true);
  6900. $density = $this->input->post('density', true);
  6901. $title = $this->input->post('title', true);
  6902. $state = $this->input->post('state', true);
  6903. $ktime = $this->input->post('ktime', true);
  6904. $jtime = $this->input->post('jtime', true);
  6905. $ktime = strtotime($ktime);
  6906. $jtime = strtotime($jtime);
  6907. $where = "state=11";
  6908. $gj = "";
  6909. $ck = "";
  6910. if ($lacetype) {
  6911. $where .= " and features like '%-$lacetype-%'";
  6912. }
  6913. if ($category) {
  6914. $where .= " and features like '%-$category-%'";
  6915. }
  6916. if ($size) {
  6917. $where .= " and features like '%-$size-%'";
  6918. }
  6919. if ($grade) {
  6920. $where .= " and features like '%-$grade-%'";
  6921. }
  6922. if ($color) {
  6923. $where .= " and features like '%-$color-%'";
  6924. }
  6925. if ($lowe) {
  6926. $where .= " and features like '%-$lowe-%'";
  6927. }
  6928. if ($haircap) {
  6929. $where .= " and features like '%-$haircap-%'";
  6930. }
  6931. if ($density) {
  6932. $where .= " and features like '%-$density-%'";
  6933. }
  6934. if ($usa) {
  6935. if (!$warehouse) {
  6936. $where .= " and (warehouse = '5' or warehouse = '8')";
  6937. }
  6938. }
  6939. if ($warehouse) {
  6940. $where .= " and warehouse = '$warehouse'";
  6941. }
  6942. if ($purchase) {
  6943. $where .= " and purchase = '$purchase'";
  6944. }
  6945. if ($state) {
  6946. $where .= " and state = '$state'";
  6947. }
  6948. if ($ktime && $jtime) {
  6949. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6950. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6951. }
  6952. //数据排序
  6953. $order_str = "id desc";
  6954. $xs = 0;
  6955. $rows = array();
  6956. $list = array();
  6957. if (empty($page)) {
  6958. $start = 0;
  6959. $perpage = 1;
  6960. } else {
  6961. $start = ($page - 1) * $perpage;
  6962. }
  6963. if ($sku || $title) {
  6964. if ($title) {
  6965. $title = trim($title, ' ');
  6966. $title = trim($title, ' ');
  6967. $where .= " and title like '%$title%'";
  6968. } else {
  6969. $sku = trim($sku, ' ');
  6970. $sku = trim($sku, ' ');
  6971. $where .= " and sku like '%$sku%'";
  6972. }
  6973. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6974. foreach ($info_list as $key => $value) {
  6975. $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'] . '"');
  6976. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6977. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6978. $rows[$key] = $value;
  6979. $warehouse = $this->warehouse->read($value['warehouse']);
  6980. $rows[$key]['warehouse'] = $warehouse['title'];
  6981. $rows[$key]['features'] = $g;
  6982. $rows[$key]['a'] = $x;
  6983. $rows[$key]['b'] = $s;
  6984. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6985. $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天销量
  6986. $yj = $c / ($xl / 30);
  6987. if ($yj < 7) {
  6988. $rows[$key]['y'] = round($yj) . '天销量';
  6989. } else {
  6990. $rows[$key]['y'] = '正常';
  6991. }
  6992. }
  6993. } else {
  6994. //$where .= " and time > '$ktime' and time < '$jtime'";
  6995. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6996. foreach ($info_list as $key => $value) {
  6997. $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'] . '"');
  6998. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6999. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7000. $zs[$key] = $value;
  7001. $warehouse = $this->warehouse->read($value['warehouse']);
  7002. $zs[$key]['warehouse'] = $warehouse['title'];
  7003. $zs[$key]['features'] = $g;
  7004. $zs[$key]['a'] = $x;
  7005. $zs[$key]['b'] = $s;
  7006. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7007. $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天销量
  7008. $yj = $c / ($xl / 30);
  7009. if ($yj < 7) {
  7010. $zs[$key]['y'] = round($yj) . '天销量';
  7011. $rows[$key] = $zs[$key];
  7012. }
  7013. }
  7014. }
  7015. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7016. $pagenum = ceil($total / $perpage);
  7017. $over = $total - ($start + $perpage);
  7018. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7019. echo json_encode($rows);
  7020. exit;
  7021. }
  7022. $this->data['arg_array'] = $arg_array[0];
  7023. $this->_Template('whlabel_fcjxc', $this->data);
  7024. }
  7025. public function _0kcdel()
  7026. {
  7027. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7028. $config['upload_path'] = '.' . $dir;
  7029. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7030. $config['allowed_types'] = 'xls|xlsx|csv';
  7031. $config['max_size'] = 10240;
  7032. $this->load->library('upload', $config);
  7033. $this->upload->initialize($config);
  7034. if ($this->upload->do_upload('userfile')) {
  7035. $full_path = $dir . $this->upload->data('file_name');
  7036. $fileName = '.' . $full_path;
  7037. if (!file_exists($fileName)) {
  7038. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7039. exit;
  7040. } else {
  7041. require_once "./data/excel/PHPExcel/IOFactory.php";
  7042. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7043. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7044. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7045. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7046. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7047. ++$column; //如果列数大于26行
  7048. $list = array();
  7049. for ($i = 2; $i <= $row; $i++) // 行数循环
  7050. {
  7051. $data = array();
  7052. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7053. {
  7054. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7055. }
  7056. $list[] = $data;
  7057. }
  7058. }
  7059. $i = 0;
  7060. $j = 0;
  7061. $ed = array();
  7062. foreach ($list as $key => $value) {
  7063. $time = time();
  7064. if ($value['0'] == "" || $value['1'] == "") {
  7065. continue;
  7066. }
  7067. $warehouse = $this->warehouse->get_title($value['0']);
  7068. $sku = $value['1'];
  7069. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7070. if (!$d) //如果没有这个SKU
  7071. {
  7072. $ed[] = array($sku . '-库存中不存在此SKU');
  7073. $j++;
  7074. continue;
  7075. }
  7076. if (!isset($warehouse['id'])) {
  7077. $ed[] = array($sku . '-仓库名错误!');
  7078. $j++;
  7079. continue;
  7080. }
  7081. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7082. if ($z < 1) {
  7083. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7084. foreach ($z as $v) {
  7085. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7086. if (count($zt) > 0) {
  7087. $ed[] = array($sku . '-有在途库存无法删除!');
  7088. $j++;
  7089. continue;
  7090. }
  7091. $this->whlabel->remove($v['id']);
  7092. }
  7093. } else {
  7094. $ed[] = array($sku . '-非0库存!');
  7095. $j++;
  7096. continue;
  7097. }
  7098. }
  7099. if ($j > 0) {
  7100. $tt = date('Ymd', time());
  7101. $title = '删除0库存错误信息-' . $tt;
  7102. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7103. $tail = "\n";
  7104. $filename = $title . ".xls";
  7105. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7106. $dir = '/data/excel/' . $time . '/';
  7107. $file_name = 'error_' . $time . rand(1000, 9999);
  7108. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7109. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7110. fwrite($myfile, $ecl);
  7111. fclose($myfile);
  7112. $error = $dir . $file_name . '.xls';
  7113. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7114. exit;
  7115. } else {
  7116. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7117. exit;
  7118. }
  7119. }
  7120. }
  7121. public function _gbhtype()
  7122. {
  7123. $post = $this->input->post(NULL, TRUE);
  7124. if (isset($post['s'])) {
  7125. $n = $this->input->post('n');
  7126. $d = $this->input->post('s');
  7127. if (!$d) {
  7128. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7129. exit;
  7130. }
  7131. $d = explode(',', trim($d, ','));
  7132. $t = $this->whlabel_type->read($n);
  7133. //循环删除记录
  7134. foreach ($d as $v) {
  7135. $u = $this->whlabel->read($v);
  7136. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7137. foreach ($data as $val) {
  7138. $this->whlabel->save(array('type' => $n), $val['id']);
  7139. }
  7140. }
  7141. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7142. }
  7143. }
  7144. //出库、退库导出
  7145. public function _dccrtype()
  7146. {
  7147. $classid = $this->classid->sku();
  7148. $pm = $classid;
  7149. $typeclass = array();
  7150. $tc = $this->typeclass->find_all();
  7151. foreach ($tc as $v) {
  7152. $typeclass[$v['id']] = $v;
  7153. }
  7154. $prc = array();
  7155. $purchase = $this->purchase->find_all();
  7156. foreach ($purchase as $k => $v) {
  7157. $prc[$v['id']] = $v['title'];
  7158. }
  7159. if (isset($_GET['sid'])) {
  7160. $wh = array();
  7161. $w = $this->warehouse->find_all('1=1', 'id,title');
  7162. foreach ($w as $v) {
  7163. $wh[$v['id']] = $v['title'];
  7164. }
  7165. $type = $this->input->get('excel', true);
  7166. $category = $this->input->get('category', true);
  7167. $size = $this->input->get('size', true);
  7168. $grade = $this->input->get('grade', true);
  7169. $color = $this->input->get('color', true);
  7170. $lowe = $this->input->get('lowe', true);
  7171. $sku = $this->input->get('sku', true);
  7172. $warehouse = $this->input->get('warehouse', true);
  7173. $lacetype = $this->input->get('lacetype', true);
  7174. $lacecolor = $this->input->get('lacecolor', true);
  7175. $density = $this->input->get('density', true);
  7176. $haircap = $this->input->get('haircap', true);
  7177. $purchase = $this->input->get('purchase', true);
  7178. $title = $this->input->get('title', true);
  7179. $state = $this->input->get('state', true);
  7180. $sid = $this->input->get('sid', true);
  7181. $ktime = $this->input->get('ktime', true);
  7182. $jtime = $this->input->get('jtime', true);
  7183. $ktime = strtotime($ktime);
  7184. $jtime = strtotime($jtime);
  7185. $where = "1=1";
  7186. $gj = "";
  7187. $ck = "";
  7188. if ($category) {
  7189. $where .= " and features like '%-$category-%'";
  7190. }
  7191. if ($size) {
  7192. $where .= " and features like '%-$size-%'";
  7193. }
  7194. if ($grade) {
  7195. $where .= " and features like '%-$grade-%'";
  7196. }
  7197. if ($color) {
  7198. $where .= " and features like '%-$color-%'";
  7199. }
  7200. if ($lowe) {
  7201. $where .= " and features like '%-$lowe-%'";
  7202. }
  7203. if ($warehouse) {
  7204. $where .= " and warehouse = '$warehouse'";
  7205. }
  7206. if ($purchase) {
  7207. $where .= " and purchase = '$purchase'";
  7208. }
  7209. if ($state) {
  7210. $where .= " and state = '$state'";
  7211. }
  7212. if ($lacetype) {
  7213. $where .= " and features like '%-$lacetype-%'";
  7214. }
  7215. if ($lacecolor) {
  7216. $where .= " and features like '%-$lacecolor-%'";
  7217. }
  7218. if ($density) {
  7219. $where .= " and features like '%-$density-%'";
  7220. }
  7221. if ($haircap) {
  7222. $where .= " and features like '%-$haircap-%'";
  7223. }
  7224. if ($title) {
  7225. $title = trim($title, ' ');
  7226. $title = trim($title, ' ');
  7227. $where .= " and title like '%$title%'";
  7228. }
  7229. if ($sku) {
  7230. $sku = trim($sku, ' ');
  7231. $sku = trim($sku, ' ');
  7232. $where .= " and sku like '%$sku%'";
  7233. }
  7234. if ($ktime && $jtime) {
  7235. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7236. }
  7237. $sidwhere = '';
  7238. if ($sid) {
  7239. $sd = "";
  7240. $s = explode(',', trim($sid, ','));
  7241. foreach ($s as $value) {
  7242. $sd .= " id = " . $value . " or";
  7243. }
  7244. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7245. }
  7246. //数据排序
  7247. $order_str = "time desc";
  7248. if (empty($page)) {
  7249. $start = 0;
  7250. $perpage = 1;
  7251. } else {
  7252. $start = ($page - 1) * $perpage;
  7253. }
  7254. $wh = array();
  7255. $w = $this->warehouse->find_all('1=1', 'id,title');
  7256. foreach ($w as $v) {
  7257. $wh[$v['id']] = $v['title'];
  7258. }
  7259. $wt = array();
  7260. $whlabel_type = $this->whlabel_type->find_all();
  7261. foreach ($whlabel_type as $v) {
  7262. $wt[$v['id']] = $v['title'];
  7263. }
  7264. $classid = $this->classid->sku();
  7265. $list = array();
  7266. $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');
  7267. foreach ($rows_r as $key => $value) {
  7268. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7269. $pm = $classid;
  7270. $jm = $classid;
  7271. $rows_r[$key]['enter'] = '入库';
  7272. $rows_r[$key]['time'] = $value['enter'];
  7273. if ($value['rktype'] == 1) {
  7274. $rows_r[$key]['rktype'] = '采购入库';
  7275. } else if ($value['rktype'] == 2) {
  7276. $rows_r[$key]['rktype'] = '盘盈调整';
  7277. } else if ($value['rktype'] == 3) {
  7278. $rows_r[$key]['rktype'] = '其他调整入库';
  7279. } else if ($value['rktype'] == 4) {
  7280. $rows_r[$key]['rktype'] = '其他调整入库';
  7281. } else if ($value['rktype'] == 5) {
  7282. $rows_r[$key]['rktype'] = '退库入库';
  7283. } else if ($value['rktype'] == 6) {
  7284. $rows_r[$key]['rktype'] = '退货可用入库';
  7285. } else if ($value['rktype'] == 7) {
  7286. $rows_r[$key]['rktype'] = '形态转换入库';
  7287. } else {
  7288. $rows_r[$key]['rktype'] = '';
  7289. }
  7290. $features = explode('-', trim($value['features'], '-'));
  7291. foreach ($features as $v) {
  7292. if (isset($typeclass[$v])) {
  7293. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7294. $pm[$typeclass[$v]['classid']] = $zh[0];
  7295. }
  7296. if (isset($typeclass[$v])) {
  7297. if (isset($jm[$typeclass[$v]['classid']])) {
  7298. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7299. }
  7300. }
  7301. }
  7302. $zh = implode(" ", $pm);
  7303. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7304. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7305. $rows_r[$key]['zh'] = $zh;
  7306. $jm = array_filter($jm);
  7307. $rows_r[$key]['features'] = implode("-", $jm);
  7308. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7309. }
  7310. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout,state');
  7311. foreach ($rows_c as $key => $value) {
  7312. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7313. $pm = $classid;
  7314. $jm = $classid;
  7315. $rows_c[$key]['time'] = $value['outk'];
  7316. $rows_c[$key]['outk'] = '出库';
  7317. if ($value['cktype'] == 1) {
  7318. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7319. } else if ($value['cktype'] == 2) {
  7320. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7321. } else if ($value['cktype'] == 3) {
  7322. $rows_c[$key]['cktype'] = '盘亏调整';
  7323. } else if ($value['cktype'] == 4) {
  7324. $rows_c[$key]['cktype'] = '其他调整出库';
  7325. } else if ($value['cktype'] == 5) {
  7326. $rows_c[$key]['cktype'] = '形态转换出库';
  7327. } else {
  7328. $rows_c[$key]['cktype'] = '';
  7329. }
  7330. unset($rows_c[$key]['state']);
  7331. $features = explode('-', trim($value['features'], '-'));
  7332. foreach ($features as $v) {
  7333. if (isset($typeclass[$v])) {
  7334. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7335. $pm[$typeclass[$v]['classid']] = $zh[0];
  7336. }
  7337. if (isset($typeclass[$v])) {
  7338. if (isset($jm[$typeclass[$v]['classid']])) {
  7339. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7340. }
  7341. }
  7342. }
  7343. $zh = implode(" ", $pm);
  7344. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7345. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7346. $rows_c[$key]['zh'] = $zh;
  7347. $jm = array_filter($jm);
  7348. $rows_c[$key]['features'] = implode("-", $jm);
  7349. $rows_c[$key]['number'] = 1;
  7350. }
  7351. $merged = $rows_r;
  7352. foreach ($rows_c as $key => $value) {
  7353. if (isset($merged[$key])) {
  7354. $merged[] = $value;
  7355. } else {
  7356. $merged[$key] = $value;
  7357. }
  7358. }
  7359. usort($merged, function ($a, $b) {
  7360. return $a['time'] - $b['time'];
  7361. });
  7362. foreach ($merged as $key => $value) {
  7363. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7364. }
  7365. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7366. $titlename = "<table border=1>
  7367. <tr align='center'>
  7368. <td>仓库</td>
  7369. <td>SKU</td>
  7370. <td>商品名称</td>
  7371. <td>仓库品名</td>
  7372. <td>料号</td>
  7373. <td>时间</td>
  7374. <td>操作</td>
  7375. <td>类型</td>
  7376. <td>数量</td>
  7377. <td>备注</td>
  7378. </tr>
  7379. </table>";
  7380. $filename = $title . ".xlsx";
  7381. $tail = "";
  7382. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7383. }
  7384. }
  7385. }